diff --git a/src/render/batch.cpp b/src/render/batch.cpp index 8325d68..3faa3f0 100644 --- a/src/render/batch.cpp +++ b/src/render/batch.cpp @@ -186,87 +186,6 @@ batch_renderer::~batch_renderer() { destroy_resources(); } -batch_renderer::batch_renderer(batch_renderer&& other) noexcept - : device_(std::move(other.device_)) - , allocator_(other.allocator_) - , config_(other.config_) - , pipeline_layout_(std::move(other.pipeline_layout_)) - , pipeline_(std::move(other.pipeline_)) - , vertex_buffer_(other.vertex_buffer_) - , vertex_allocation_(other.vertex_allocation_) - , index_buffer_(other.index_buffer_) - , index_allocation_(other.index_allocation_) - , staging_buffer_(other.staging_buffer_) - , staging_allocation_(other.staging_allocation_) - , staging_mapped_data_(other.staging_mapped_data_) - , vertices_(std::move(other.vertices_)) - , current_cmd_buffer_(other.current_cmd_buffer_) - , current_descriptor_set_(other.current_descriptor_set_) - , push_constants_(other.push_constants_) - , statistics_(other.statistics_) - , max_quads_(other.max_quads_) - , max_texture_slots_(other.max_texture_slots_) - , current_quad_count_(other.current_quad_count_) - , initialized_(other.initialized_) - , batching_(other.batching_) -{ - other.allocator_ = nullptr; - other.vertex_buffer_ = nullptr; - other.vertex_allocation_ = nullptr; - other.index_buffer_ = nullptr; - other.index_allocation_ = nullptr; - other.staging_buffer_ = nullptr; - other.staging_allocation_ = nullptr; - other.staging_mapped_data_ = nullptr; - other.current_cmd_buffer_ = nullptr; - other.current_descriptor_set_ = nullptr; - other.initialized_ = false; - other.batching_ = false; -} - -batch_renderer& batch_renderer::operator=(batch_renderer&& other) noexcept { - if (this != &other) { - destroy_resources(); - - device_ = std::move(other.device_); - allocator_ = other.allocator_; - config_ = other.config_; - pipeline_layout_ = std::move(other.pipeline_layout_); - pipeline_ = std::move(other.pipeline_); - vertex_buffer_ = other.vertex_buffer_; - vertex_allocation_ = other.vertex_allocation_; - index_buffer_ = other.index_buffer_; - index_allocation_ = other.index_allocation_; - staging_buffer_ = other.staging_buffer_; - staging_allocation_ = other.staging_allocation_; - staging_mapped_data_ = other.staging_mapped_data_; - vertices_ = std::move(other.vertices_); - current_cmd_buffer_ = other.current_cmd_buffer_; - current_descriptor_set_ = other.current_descriptor_set_; - push_constants_ = other.push_constants_; - statistics_ = other.statistics_; - max_quads_ = other.max_quads_; - max_texture_slots_ = other.max_texture_slots_; - current_quad_count_ = other.current_quad_count_; - initialized_ = other.initialized_; - batching_ = other.batching_; - - other.allocator_ = nullptr; - other.vertex_buffer_ = nullptr; - other.vertex_allocation_ = nullptr; - other.index_buffer_ = nullptr; - other.index_allocation_ = nullptr; - other.staging_buffer_ = nullptr; - other.staging_allocation_ = nullptr; - other.staging_mapped_data_ = nullptr; - other.current_cmd_buffer_ = nullptr; - other.current_descriptor_set_ = nullptr; - other.initialized_ = false; - other.batching_ = false; - } - return *this; -} - bool batch_renderer::initialize(vk::Format color_format, vk::Format depth_format) { if (initialized_) { MIRAI_LOG_WARN("Batch renderer already initialized"); diff --git a/src/render/batch.hpp b/src/render/batch.hpp index a1ee204..d250c65 100644 --- a/src/render/batch.hpp +++ b/src/render/batch.hpp @@ -237,14 +237,6 @@ public: */ ~batch_renderer() override; - /// 禁用拷贝 - batch_renderer(const batch_renderer&) = delete; - batch_renderer& operator=(const batch_renderer&) = delete; - - /// 允许移动 - batch_renderer(batch_renderer&& other) noexcept; - batch_renderer& operator=(batch_renderer&& other) noexcept; - /** * @brief 初始化渲染器 * @param color_format 颜色格式 diff --git a/src/render/command_buffer.cpp b/src/render/command_buffer.cpp index 5b6d519..b5156fa 100644 --- a/src/render/command_buffer.cpp +++ b/src/render/command_buffer.cpp @@ -185,39 +185,6 @@ command_buffer::~command_buffer() { } } -command_buffer::command_buffer(command_buffer&& other) noexcept - : device_(std::move(other.device_)) - , pool_(other.pool_) - , buffer_(other.buffer_) - , level_(other.level_) - , recording_(other.recording_) - , owns_buffer_(other.owns_buffer_) -{ - other.buffer_ = nullptr; - other.pool_ = nullptr; - other.recording_ = false; -} - -command_buffer& command_buffer::operator=(command_buffer&& other) noexcept { - if (this != &other) { - if (owns_buffer_ && buffer_ && pool_ != nullptr) { - device_->get_device().freeCommandBuffers(pool_->get_vulkan_pool(), buffer_); - } - - device_ = std::move(other.device_); - pool_ = other.pool_; - buffer_ = other.buffer_; - level_ = other.level_; - recording_ = other.recording_; - owns_buffer_ = other.owns_buffer_; - - other.buffer_ = nullptr; - other.pool_ = nullptr; - other.recording_ = false; - } - return *this; -} - void command_buffer::on_created() { MIRAI_LOG_DEBUG("Command buffer created"); } diff --git a/src/render/command_buffer.hpp b/src/render/command_buffer.hpp index 69a651b..2f9a60c 100644 --- a/src/render/command_buffer.hpp +++ b/src/render/command_buffer.hpp @@ -259,15 +259,7 @@ public: * @brief 析构函数 */ ~command_buffer() override; - - // 禁止拷贝 - command_buffer(const command_buffer&) = delete; - command_buffer& operator=(const command_buffer&) = delete; - - // 允许移动 - command_buffer(command_buffer&& other) noexcept; - command_buffer& operator=(command_buffer&& other) noexcept; - + // ============================================================================================ // 录制控制 // ============================================================================================ diff --git a/src/render/frame_sync.cpp b/src/render/frame_sync.cpp index 39cac09..25f622c 100644 --- a/src/render/frame_sync.cpp +++ b/src/render/frame_sync.cpp @@ -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_sync::begin_frame() { if (!is_valid() || !swapchain_) { return {frame_begin_result::error, 0}; diff --git a/src/render/frame_sync.hpp b/src/render/frame_sync.hpp index 09116ed..7d0f522 100644 --- a/src/render/frame_sync.hpp +++ b/src/render/frame_sync.hpp @@ -114,15 +114,7 @@ public: * @brief 析构函数 */ ~frame_sync() override; - - /// 禁用拷贝 - frame_sync(const frame_sync&) = delete; - frame_sync& operator=(const frame_sync&) = delete; - - /// 允许移动 - frame_sync(frame_sync&& other) noexcept; - frame_sync& operator=(frame_sync&& other) noexcept; - + /** * @brief 开始帧 * diff --git a/src/render/pipeline.cpp b/src/render/pipeline.cpp index 7138e8f..c5a6078 100644 --- a/src/render/pipeline.cpp +++ b/src/render/pipeline.cpp @@ -36,26 +36,6 @@ pipeline_layout::~pipeline_layout() { } } -pipeline_layout::pipeline_layout(pipeline_layout&& other) noexcept - : device_(std::move(other.device_)) - , layout_(other.layout_) -{ - other.layout_ = nullptr; -} - -pipeline_layout& pipeline_layout::operator=(pipeline_layout&& other) noexcept { - if (this != &other) { - if (layout_ && device_ && device_->is_valid()) { - device_->get_device().destroyPipelineLayout(layout_); - } - - device_ = std::move(other.device_); - layout_ = other.layout_; - other.layout_ = nullptr; - } - return *this; -} - void pipeline_layout::on_created() { MIRAI_LOG_DEBUG("Pipeline layout created"); } @@ -562,31 +542,6 @@ graphics_pipeline::~graphics_pipeline() { } } -graphics_pipeline::graphics_pipeline(graphics_pipeline&& other) noexcept - : device_(std::move(other.device_)) - , pipeline_(other.pipeline_) - , layout_(other.layout_) -{ - other.pipeline_ = nullptr; - other.layout_ = nullptr; -} - -graphics_pipeline& graphics_pipeline::operator=(graphics_pipeline&& other) noexcept { - if (this != &other) { - if (pipeline_ && device_ && device_->is_valid()) { - device_->get_device().destroyPipeline(pipeline_); - } - - device_ = std::move(other.device_); - pipeline_ = other.pipeline_; - layout_ = other.layout_; - - other.pipeline_ = nullptr; - other.layout_ = nullptr; - } - return *this; -} - void graphics_pipeline::on_created() { MIRAI_LOG_DEBUG("Graphics pipeline created"); } @@ -629,31 +584,6 @@ compute_pipeline::~compute_pipeline() { } } -compute_pipeline::compute_pipeline(compute_pipeline&& other) noexcept - : device_(std::move(other.device_)) - , pipeline_(other.pipeline_) - , layout_(other.layout_) -{ - other.pipeline_ = nullptr; - other.layout_ = nullptr; -} - -compute_pipeline& compute_pipeline::operator=(compute_pipeline&& other) noexcept { - if (this != &other) { - if (pipeline_ && device_ && device_->is_valid()) { - device_->get_device().destroyPipeline(pipeline_); - } - - device_ = std::move(other.device_); - pipeline_ = other.pipeline_; - layout_ = other.layout_; - - other.pipeline_ = nullptr; - other.layout_ = nullptr; - } - return *this; -} - void compute_pipeline::on_created() { MIRAI_LOG_DEBUG("Compute pipeline created"); } diff --git a/src/render/pipeline.hpp b/src/render/pipeline.hpp index 9743206..1cd2cee 100644 --- a/src/render/pipeline.hpp +++ b/src/render/pipeline.hpp @@ -96,15 +96,7 @@ public: * @brief 析构函数 */ ~pipeline_layout() override; - - // 禁止拷贝 - pipeline_layout(const pipeline_layout&) = delete; - pipeline_layout& operator=(const pipeline_layout&) = delete; - - // 允许移动 - pipeline_layout(pipeline_layout&& other) noexcept; - pipeline_layout& operator=(pipeline_layout&& other) noexcept; - + /** * @brief 获取管线布局句柄 * @return vk::PipelineLayout 句柄 @@ -699,15 +691,7 @@ public: * @brief 析构函数 */ ~graphics_pipeline() override; - - // 禁止拷贝 - graphics_pipeline(const graphics_pipeline&) = delete; - graphics_pipeline& operator=(const graphics_pipeline&) = delete; - - // 允许移动 - graphics_pipeline(graphics_pipeline&& other) noexcept; - graphics_pipeline& operator=(graphics_pipeline&& other) noexcept; - + /** * @brief 获取管线句柄 * @return vk::Pipeline 句柄 @@ -787,15 +771,7 @@ public: * @brief 析构函数 */ ~compute_pipeline() override; - - // 禁止拷贝 - compute_pipeline(const compute_pipeline&) = delete; - compute_pipeline& operator=(const compute_pipeline&) = delete; - - // 允许移动 - compute_pipeline(compute_pipeline&& other) noexcept; - compute_pipeline& operator=(compute_pipeline&& other) noexcept; - + /** * @brief 获取管线句柄 * @return vk::Pipeline 句柄 diff --git a/src/render/renderer.cpp b/src/render/renderer.cpp index 329c39d..c2ceed9 100644 --- a/src/render/renderer.cpp +++ b/src/render/renderer.cpp @@ -22,83 +22,6 @@ renderer::~renderer() { shutdown(); } -renderer::renderer(renderer&& other) noexcept - : config_(std::move(other.config_)) - , state_(other.state_) - , window_(other.window_) - , instance_(std::move(other.instance_)) - , device_(std::move(other.device_)) - , surface_(other.surface_) - , swapchain_(std::move(other.swapchain_)) - , allocator_(other.allocator_) - , frame_sync_(std::move(other.frame_sync_)) - , command_pool_(std::move(other.command_pool_)) - , command_buffers_(std::move(other.command_buffers_)) - , batch_renderer_(std::move(other.batch_renderer_)) - , depth_image_(other.depth_image_) - , depth_allocation_(other.depth_allocation_) - , depth_image_view_(other.depth_image_view_) - , depth_format_(other.depth_format_) - , current_frame_index_(other.current_frame_index_) - , current_image_index_(other.current_image_index_) - , frame_count_(other.frame_count_) - , frame_time_tracker_(std::move(other.frame_time_tracker_)) - , swapchain_needs_recreation_(other.swapchain_needs_recreation_) - , window_minimized_(other.window_minimized_) - , on_frame_begin_(std::move(other.on_frame_begin_)) - , on_frame_end_(std::move(other.on_frame_end_)) - , on_swapchain_recreated_(std::move(other.on_swapchain_recreated_)) -{ - other.state_ = render_state::uninitialized; - other.window_ = nullptr; - other.surface_ = nullptr; - other.allocator_ = VK_NULL_HANDLE; - other.depth_image_ = nullptr; - other.depth_allocation_ = nullptr; - other.depth_image_view_ = nullptr; -} - -renderer& renderer::operator=(renderer&& other) noexcept { - if (this != &other) { - shutdown(); - - config_ = std::move(other.config_); - state_ = other.state_; - window_ = other.window_; - instance_ = std::move(other.instance_); - device_ = std::move(other.device_); - surface_ = other.surface_; - swapchain_ = std::move(other.swapchain_); - allocator_ = other.allocator_; - frame_sync_ = std::move(other.frame_sync_); - command_pool_ = std::move(other.command_pool_); - command_buffers_ = std::move(other.command_buffers_); - batch_renderer_ = std::move(other.batch_renderer_); - depth_image_ = other.depth_image_; - depth_allocation_ = other.depth_allocation_; - depth_image_view_ = other.depth_image_view_; - depth_format_ = other.depth_format_; - current_frame_index_ = other.current_frame_index_; - current_image_index_ = other.current_image_index_; - frame_count_ = other.frame_count_; - frame_time_tracker_ = std::move(other.frame_time_tracker_); - swapchain_needs_recreation_ = other.swapchain_needs_recreation_; - window_minimized_ = other.window_minimized_; - on_frame_begin_ = std::move(other.on_frame_begin_); - on_frame_end_ = std::move(other.on_frame_end_); - on_swapchain_recreated_ = std::move(other.on_swapchain_recreated_); - - other.state_ = render_state::uninitialized; - other.window_ = nullptr; - other.surface_ = nullptr; - other.allocator_ = VK_NULL_HANDLE; - other.depth_image_ = nullptr; - other.depth_allocation_ = nullptr; - other.depth_image_view_ = nullptr; - } - return *this; -} - bool renderer::initialize(SDL_Window* window) { if (state_ != render_state::uninitialized) { MIRAI_LOG_WARN("Renderer already initialized"); diff --git a/src/render/renderer.hpp b/src/render/renderer.hpp index b380085..e451168 100644 --- a/src/render/renderer.hpp +++ b/src/render/renderer.hpp @@ -99,15 +99,7 @@ public: * @brief 析构函数 */ ~renderer() override; - - /// 禁用拷贝 - renderer(const renderer&) = delete; - renderer& operator=(const renderer&) = delete; - - /// 允许移动 - renderer(renderer&& other) noexcept; - renderer& operator=(renderer&& other) noexcept; - + /** * @brief 初始化渲染器 * @param window SDL 窗口 diff --git a/src/render/swapchain.cpp b/src/render/swapchain.cpp index c174647..236306e 100644 --- a/src/render/swapchain.cpp +++ b/src/render/swapchain.cpp @@ -34,43 +34,6 @@ swapchain::~swapchain() { cleanup(); } -swapchain::swapchain(swapchain&& other) noexcept - : device_(std::move(other.device_)) - , surface_(other.surface_) - , swapchain_(other.swapchain_) - , images_(std::move(other.images_)) - , image_views_(std::move(other.image_views_)) - , format_(other.format_) - , extent_(other.extent_) - , present_mode_(other.present_mode_) - , config_(other.config_) - , needs_recreate_(other.needs_recreate_) -{ - other.surface_ = nullptr; - other.swapchain_ = nullptr; -} - -swapchain& swapchain::operator=(swapchain&& other) noexcept { - if (this != &other) { - cleanup(); - - device_ = std::move(other.device_); - surface_ = other.surface_; - swapchain_ = other.swapchain_; - images_ = std::move(other.images_); - image_views_ = std::move(other.image_views_); - format_ = other.format_; - extent_ = other.extent_; - present_mode_ = other.present_mode_; - config_ = other.config_; - needs_recreate_ = other.needs_recreate_; - - other.surface_ = nullptr; - other.swapchain_ = nullptr; - } - return *this; -} - // ================================================================================================ // 对象生命周期回调 // ================================================================================================ diff --git a/src/render/swapchain.hpp b/src/render/swapchain.hpp index b171bc2..392b3d6 100644 --- a/src/render/swapchain.hpp +++ b/src/render/swapchain.hpp @@ -150,15 +150,7 @@ public: * @brief 析构函数 */ ~swapchain() override; - - // 禁止拷贝 - swapchain(const swapchain&) = delete; - swapchain& operator=(const swapchain&) = delete; - - // 允许移动 - swapchain(swapchain&& other) noexcept; - swapchain& operator=(swapchain&& other) noexcept; - + // ============================================================================================ // 图像获取和呈现 // ============================================================================================ diff --git a/src/render/vulkan_device.hpp b/src/render/vulkan_device.hpp index 5c0be13..b3cb532 100644 --- a/src/render/vulkan_device.hpp +++ b/src/render/vulkan_device.hpp @@ -121,13 +121,7 @@ public: * @brief 析构函数 */ ~vulkan_device() override; - - // 禁止拷贝和移动 - vulkan_device(const vulkan_device&) = delete; - vulkan_device& operator=(const vulkan_device&) = delete; - vulkan_device(vulkan_device&&) = delete; - vulkan_device& operator=(vulkan_device&&) = delete; - + // ============================================================================================ // 设备访问 // ============================================================================================ diff --git a/src/render/vulkan_instance.hpp b/src/render/vulkan_instance.hpp index 27740c2..b597a09 100644 --- a/src/render/vulkan_instance.hpp +++ b/src/render/vulkan_instance.hpp @@ -142,15 +142,7 @@ public: * @brief 析构函数 */ ~vulkan_instance() override; - - // 禁止拷贝 - vulkan_instance(const vulkan_instance&) = delete; - vulkan_instance& operator=(const vulkan_instance&) = delete; - - // 禁止移动(Vulkan 实例通常是全局单例) - vulkan_instance(vulkan_instance&&) = delete; - vulkan_instance& operator=(vulkan_instance&&) = delete; - + // ============================================================================================ // 实例访问 // ============================================================================================ diff --git a/src/resource/allocator.hpp b/src/resource/allocator.hpp index d05e7ec..9e2fc96 100644 --- a/src/resource/allocator.hpp +++ b/src/resource/allocator.hpp @@ -218,13 +218,7 @@ public: * @brief 析构函数 */ ~gpu_allocator() override; - - // 禁止拷贝和移动 - gpu_allocator(const gpu_allocator&) = delete; - gpu_allocator& operator=(const gpu_allocator&) = delete; - gpu_allocator(gpu_allocator&&) = delete; - gpu_allocator& operator=(gpu_allocator&&) = delete; - + // ============================================================================================ // Buffer 分配 // ============================================================================================ diff --git a/src/resource/buffer.cpp b/src/resource/buffer.cpp index 90b43fa..67f4336 100644 --- a/src/resource/buffer.cpp +++ b/src/resource/buffer.cpp @@ -95,50 +95,6 @@ buffer::~buffer() { } } -buffer::buffer(buffer&& other) noexcept - : allocator_(std::move(other.allocator_)) - , allocation_(other.allocation_) - , size_(other.size_) - , usage_(other.usage_) - , mem_usage_(other.mem_usage_) - , mapped_ptr_(other.mapped_ptr_) - , persistent_mapped_(other.persistent_mapped_) - , debug_name_(std::move(other.debug_name_)) { - - // 清空源对象 - other.allocation_ = {}; - other.size_ = 0; - other.mapped_ptr_ = nullptr; -} - -buffer& buffer::operator=(buffer&& other) noexcept { - if (this != &other) { - // 释放当前资源 - if (is_valid() && allocator_) { - if (mapped_ptr_ != nullptr && !persistent_mapped_) { - unmap(); - } - allocator_->free(allocation_); - } - - // 移动资源 - allocator_ = std::move(other.allocator_); - allocation_ = other.allocation_; - size_ = other.size_; - usage_ = other.usage_; - mem_usage_ = other.mem_usage_; - mapped_ptr_ = other.mapped_ptr_; - persistent_mapped_ = other.persistent_mapped_; - debug_name_ = std::move(other.debug_name_); - - // 清空源对象 - other.allocation_ = {}; - other.size_ = 0; - other.mapped_ptr_ = nullptr; - } - return *this; -} - // ================================================================================================ // 内存映射 // ================================================================================================ @@ -408,35 +364,6 @@ staging_buffer::~staging_buffer() { } } -staging_buffer::staging_buffer(staging_buffer&& other) noexcept - : allocator_(std::move(other.allocator_)) - , allocation_(other.allocation_) - , size_(other.size_) - , mapped_ptr_(other.mapped_ptr_) { - - other.allocation_ = {}; - other.size_ = 0; - other.mapped_ptr_ = nullptr; -} - -staging_buffer& staging_buffer::operator=(staging_buffer&& other) noexcept { - if (this != &other) { - if (is_valid() && allocator_) { - allocator_->free(allocation_); - } - - allocator_ = std::move(other.allocator_); - allocation_ = other.allocation_; - size_ = other.size_; - mapped_ptr_ = other.mapped_ptr_; - - other.allocation_ = {}; - other.size_ = 0; - other.mapped_ptr_ = nullptr; - } - return *this; -} - void_result staging_buffer::write(const void* data, u64 size, u64 offset) { if (!is_valid()) { return make_void_error(error_code::invalid_state, "Staging buffer is not valid"); diff --git a/src/resource/buffer.hpp b/src/resource/buffer.hpp index 755d5f6..2f8bd28 100644 --- a/src/resource/buffer.hpp +++ b/src/resource/buffer.hpp @@ -107,15 +107,7 @@ public: * @brief 析构函数 */ ~buffer() override; - - // 禁止拷贝 - buffer(const buffer&) = delete; - buffer& operator=(const buffer&) = delete; - - // 允许移动 - buffer(buffer&& other) noexcept; - buffer& operator=(buffer&& other) noexcept; - + // ============================================================================================ // 属性访问 // ============================================================================================ @@ -425,15 +417,7 @@ public: * @brief 析构函数 */ ~staging_buffer() override; - - // 禁止拷贝 - staging_buffer(const staging_buffer&) = delete; - staging_buffer& operator=(const staging_buffer&) = delete; - - // 允许移动 - staging_buffer(staging_buffer&& other) noexcept; - staging_buffer& operator=(staging_buffer&& other) noexcept; - + /** * @brief 获取大小 * @return Buffer 大小 diff --git a/src/resource/descriptor_pool.cpp b/src/resource/descriptor_pool.cpp index 9a54c19..41627a9 100644 --- a/src/resource/descriptor_pool.cpp +++ b/src/resource/descriptor_pool.cpp @@ -42,42 +42,6 @@ descriptor_pool::~descriptor_pool() { pools_.clear(); } -descriptor_pool::descriptor_pool(descriptor_pool&& other) noexcept - : device_(other.device_) - , pools_(std::move(other.pools_)) - , config_(std::move(other.config_)) - , current_frame_(other.current_frame_) - , allocated_sets_(other.allocated_sets_) { - - other.device_ = vk::Device{}; - other.current_frame_ = 0; - other.allocated_sets_ = 0; -} - -descriptor_pool& descriptor_pool::operator=(descriptor_pool&& other) noexcept { - if (this != &other) { - // 释放当前资源 - for (auto pool : pools_) { - if (pool) { - device_.destroyDescriptorPool(pool); - } - } - - // 移动资源 - device_ = other.device_; - pools_ = std::move(other.pools_); - config_ = std::move(other.config_); - current_frame_ = other.current_frame_; - allocated_sets_ = other.allocated_sets_; - - // 清空源对象 - other.device_ = vk::Device{}; - other.current_frame_ = 0; - other.allocated_sets_ = 0; - } - return *this; -} - // ================================================================================================ // 池创建 // ================================================================================================ diff --git a/src/resource/descriptor_pool.hpp b/src/resource/descriptor_pool.hpp index a7e32d3..2b8b0ab 100644 --- a/src/resource/descriptor_pool.hpp +++ b/src/resource/descriptor_pool.hpp @@ -189,15 +189,7 @@ public: * @brief 析构函数 */ ~descriptor_pool() override; - - // 禁止拷贝 - descriptor_pool(const descriptor_pool&) = delete; - descriptor_pool& operator=(const descriptor_pool&) = delete; - - // 允许移动 - descriptor_pool(descriptor_pool&& other) noexcept; - descriptor_pool& operator=(descriptor_pool&& other) noexcept; - + // ============================================================================================ // 描述符集操作 // ============================================================================================ @@ -357,13 +349,7 @@ public: * @brief 析构函数 */ ~descriptor_set() override; - - // 禁止拷贝和移动(描述符集的生命周期由池管理) - descriptor_set(const descriptor_set&) = delete; - descriptor_set& operator=(const descriptor_set&) = delete; - descriptor_set(descriptor_set&&) = delete; - descriptor_set& operator=(descriptor_set&&) = delete; - + // ============================================================================================ // 资源绑定 // ============================================================================================ diff --git a/src/resource/resource_loader.hpp b/src/resource/resource_loader.hpp index a0d017d..15b39da 100644 --- a/src/resource/resource_loader.hpp +++ b/src/resource/resource_loader.hpp @@ -306,13 +306,7 @@ public: * @brief 析构函数 */ ~resource_loader() override; - - // 禁止拷贝和移动 - resource_loader(const resource_loader&) = delete; - resource_loader& operator=(const resource_loader&) = delete; - resource_loader(resource_loader&&) = delete; - resource_loader& operator=(resource_loader&&) = delete; - + // ============================================================================================ // 异步加载 // ============================================================================================ diff --git a/src/resource/resource_manager.hpp b/src/resource/resource_manager.hpp index f2ec083..d7b2b9d 100644 --- a/src/resource/resource_manager.hpp +++ b/src/resource/resource_manager.hpp @@ -243,15 +243,7 @@ public: * @brief 析构函数 */ ~resource_manager() override; - - // 禁用拷贝 - resource_manager(const resource_manager&) = delete; - resource_manager& operator=(const resource_manager&) = delete; - - // 允许移动 - resource_manager(resource_manager&&) noexcept = default; - resource_manager& operator=(resource_manager&&) noexcept = default; - + // ============================================================================================ // 组件访问 // ============================================================================================ diff --git a/src/resource/sampler.cpp b/src/resource/sampler.cpp index fe07cc8..e6bf1c8 100644 --- a/src/resource/sampler.cpp +++ b/src/resource/sampler.cpp @@ -37,32 +37,6 @@ sampler::~sampler() { } } -sampler::sampler(sampler&& other) noexcept - : device_(other.device_) - , sampler_(other.sampler_) - , info_(std::move(other.info_)) { - - other.sampler_ = vk::Sampler{}; -} - -sampler& sampler::operator=(sampler&& other) noexcept { - if (this != &other) { - // 释放当前资源 - if (sampler_ && device_) { - device_.destroySampler(sampler_); - } - - // 移动资源 - device_ = other.device_; - sampler_ = other.sampler_; - info_ = std::move(other.info_); - - // 清空源对象 - other.sampler_ = vk::Sampler{}; - } - return *this; -} - // ================================================================================================ // 采样器创建 // ================================================================================================ diff --git a/src/resource/sampler.hpp b/src/resource/sampler.hpp index 93b5662..0c2916a 100644 --- a/src/resource/sampler.hpp +++ b/src/resource/sampler.hpp @@ -257,15 +257,7 @@ public: * @brief 析构函数 */ ~sampler() override; - - // 禁止拷贝 - sampler(const sampler&) = delete; - sampler& operator=(const sampler&) = delete; - - // 允许移动 - sampler(sampler&& other) noexcept; - sampler& operator=(sampler&& other) noexcept; - + // ============================================================================================ // 属性访问 // ============================================================================================ diff --git a/src/resource/texture.cpp b/src/resource/texture.cpp index 7416767..9af9ba9 100644 --- a/src/resource/texture.cpp +++ b/src/resource/texture.cpp @@ -65,42 +65,6 @@ texture::~texture() { } } -texture::texture(texture&& other) noexcept - : allocator_(std::move(other.allocator_)) - , allocation_(other.allocation_) - , image_(other.image_) - , info_(std::move(other.info_)) - , owns_image_(other.owns_image_) - , current_layout_(other.current_layout_) { - - other.allocation_ = {}; - other.image_ = vk::Image{}; - other.owns_image_ = false; -} - -texture& texture::operator=(texture&& other) noexcept { - if (this != &other) { - // 释放当前资源 - if (owns_image_ && allocation_.is_valid() && allocator_) { - allocator_->free(allocation_); - } - - // 移动资源 - allocator_ = std::move(other.allocator_); - allocation_ = other.allocation_; - image_ = other.image_; - info_ = std::move(other.info_); - owns_image_ = other.owns_image_; - current_layout_ = other.current_layout_; - - // 清空源对象 - other.allocation_ = {}; - other.image_ = vk::Image{}; - other.owns_image_ = false; - } - return *this; -} - // ================================================================================================ // 图像创建 // ================================================================================================ diff --git a/src/resource/texture.hpp b/src/resource/texture.hpp index 9f08e80..844e72c 100644 --- a/src/resource/texture.hpp +++ b/src/resource/texture.hpp @@ -236,15 +236,7 @@ public: * @brief 析构函数 */ ~texture() override; - - // 禁止拷贝 - texture(const texture&) = delete; - texture& operator=(const texture&) = delete; - - // 允许移动 - texture(texture&& other) noexcept; - texture& operator=(texture&& other) noexcept; - + // ============================================================================================ // 属性访问 // ============================================================================================ diff --git a/src/resource/texture_view.cpp b/src/resource/texture_view.cpp index fb4dc90..135b44f 100644 --- a/src/resource/texture_view.cpp +++ b/src/resource/texture_view.cpp @@ -66,32 +66,6 @@ texture_view::~texture_view() { } } -texture_view::texture_view(texture_view&& other) noexcept - : texture_(std::move(other.texture_)) - , view_(other.view_) - , info_(std::move(other.info_)) { - - other.view_ = vk::ImageView{}; -} - -texture_view& texture_view::operator=(texture_view&& other) noexcept { - if (this != &other) { - // 释放当前资源 - if (view_ && texture_ && texture_->get_allocator()) { - texture_->get_allocator()->get_device().destroyImageView(view_); - } - - // 移动资源 - texture_ = std::move(other.texture_); - view_ = other.view_; - info_ = std::move(other.info_); - - // 清空源对象 - other.view_ = vk::ImageView{}; - } - return *this; -} - // ================================================================================================ // 视图创建 // ================================================================================================ diff --git a/src/resource/texture_view.hpp b/src/resource/texture_view.hpp index 9a14c1b..7655a8a 100644 --- a/src/resource/texture_view.hpp +++ b/src/resource/texture_view.hpp @@ -103,15 +103,7 @@ public: * @brief 析构函数 */ ~texture_view() override; - - // 禁止拷贝 - texture_view(const texture_view&) = delete; - texture_view& operator=(const texture_view&) = delete; - - // 允许移动 - texture_view(texture_view&& other) noexcept; - texture_view& operator=(texture_view&& other) noexcept; - + // ============================================================================================ // 属性访问 // ============================================================================================ diff --git a/src/text/glyph_atlas.cpp b/src/text/glyph_atlas.cpp index 177b6af..7318e75 100644 --- a/src/text/glyph_atlas.cpp +++ b/src/text/glyph_atlas.cpp @@ -682,10 +682,7 @@ bool glyph_atlas::create_gpu_texture(atlas_page& page) { info.mem_usage = memory_usage::gpu_only; info.debug_name = "GlyphAtlasPage"; - allocator_config alloc_cfg{}; - alloc_cfg.device = device->get_device(); - auto gpu_alloc= std::make_shared(alloc_cfg); - page.gpu_texture = make_obj(gpu_alloc, info); + page.gpu_texture = make_obj(allocator, info); if (!page.gpu_texture || !page.gpu_texture->is_valid()) { MIRAI_LOG_ERROR("Failed to create atlas texture"); diff --git a/src/ui/widget.hpp b/src/ui/widget.hpp index 785a8a1..2edaa09 100644 --- a/src/ui/widget.hpp +++ b/src/ui/widget.hpp @@ -89,14 +89,6 @@ public: */ ~widget() override; - // 禁止拷贝 - widget(const widget&) = delete; - widget& operator=(const widget&) = delete; - - // 允许移动 - widget(widget&&) noexcept = default; - widget& operator=(widget&&) noexcept = default; - // ============================================================================================ // 生命周期 // ============================================================================================