object不允许复制和移动
This commit is contained in:
@@ -60,56 +60,6 @@ frame_sync::~frame_sync() {
|
||||
}
|
||||
}
|
||||
|
||||
frame_sync::frame_sync(frame_sync&& other) noexcept
|
||||
: device_(std::move(other.device_))
|
||||
, swapchain_(std::move(other.swapchain_))
|
||||
, command_pool_(other.command_pool_)
|
||||
, frame_resources_(std::move(other.frame_resources_))
|
||||
, images_in_flight_(std::move(other.images_in_flight_))
|
||||
, frames_in_flight_(other.frames_in_flight_)
|
||||
, current_frame_(other.current_frame_)
|
||||
, current_image_index_(other.current_image_index_)
|
||||
, fence_timeout_(other.fence_timeout_)
|
||||
, on_frame_begin_(std::move(other.on_frame_begin_))
|
||||
, on_frame_end_(std::move(other.on_frame_end_))
|
||||
{
|
||||
other.command_pool_ = nullptr;
|
||||
other.frames_in_flight_ = 0;
|
||||
other.current_frame_ = 0;
|
||||
other.current_image_index_ = 0;
|
||||
}
|
||||
|
||||
frame_sync& frame_sync::operator=(frame_sync&& other) noexcept {
|
||||
if (this != &other) {
|
||||
// 清理现有资源
|
||||
if (device_ && device_->is_valid()) {
|
||||
device_->wait_idle();
|
||||
destroy_command_buffers();
|
||||
destroy_sync_objects();
|
||||
}
|
||||
|
||||
// 移动资源
|
||||
device_ = std::move(other.device_);
|
||||
swapchain_ = std::move(other.swapchain_);
|
||||
command_pool_ = other.command_pool_;
|
||||
frame_resources_ = std::move(other.frame_resources_);
|
||||
images_in_flight_ = std::move(other.images_in_flight_);
|
||||
frames_in_flight_ = other.frames_in_flight_;
|
||||
current_frame_ = other.current_frame_;
|
||||
current_image_index_ = other.current_image_index_;
|
||||
fence_timeout_ = other.fence_timeout_;
|
||||
on_frame_begin_ = std::move(other.on_frame_begin_);
|
||||
on_frame_end_ = std::move(other.on_frame_end_);
|
||||
|
||||
// 清空源对象
|
||||
other.command_pool_ = nullptr;
|
||||
other.frames_in_flight_ = 0;
|
||||
other.current_frame_ = 0;
|
||||
other.current_image_index_ = 0;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
std::pair<frame_begin_result, u32> frame_sync::begin_frame() {
|
||||
if (!is_valid() || !swapchain_) {
|
||||
return {frame_begin_result::error, 0};
|
||||
|
||||
Reference in New Issue
Block a user