mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-12 22:28:32 +09:00
[Fix] (MG_Backend/DirectVulkan): add move ctor for BackendProgramObject
This commit is contained in:
@@ -29,12 +29,45 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
|||||||
Vector<VkPipelineShaderStageCreateInfo> stages;
|
Vector<VkPipelineShaderStageCreateInfo> stages;
|
||||||
Vector<VkShaderModule> modules;
|
Vector<VkShaderModule> modules;
|
||||||
|
|
||||||
|
BackendProgramObject() = default;
|
||||||
|
BackendProgramObject(const BackendProgramObject&) = delete;
|
||||||
|
BackendProgramObject& operator=(const BackendProgramObject&) = delete;
|
||||||
|
BackendProgramObject(BackendProgramObject&& other) noexcept {
|
||||||
|
hash = other.hash;
|
||||||
|
device = other.device;
|
||||||
|
stages = std::move(other.stages);
|
||||||
|
modules = std::move(other.modules);
|
||||||
|
other.hash = 0;
|
||||||
|
other.device = VK_NULL_HANDLE;
|
||||||
|
}
|
||||||
|
BackendProgramObject& operator=(BackendProgramObject&& other) noexcept {
|
||||||
|
if (this == &other) {
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
DestroyModules();
|
||||||
|
stages.clear();
|
||||||
|
hash = other.hash;
|
||||||
|
device = other.device;
|
||||||
|
stages = std::move(other.stages);
|
||||||
|
modules = std::move(other.modules);
|
||||||
|
other.hash = 0;
|
||||||
|
other.device = VK_NULL_HANDLE;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
~BackendProgramObject() {
|
~BackendProgramObject() {
|
||||||
|
DestroyModules();
|
||||||
|
stages.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void DestroyModules() {
|
||||||
for (auto module: modules) {
|
for (auto module: modules) {
|
||||||
|
if (module != VK_NULL_HANDLE && device != VK_NULL_HANDLE) {
|
||||||
vkDestroyShaderModule(device, module, nullptr);
|
vkDestroyShaderModule(device, module, nullptr);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
modules.clear();
|
modules.clear();
|
||||||
stages.clear();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user