Cleanup shader handling

This commit is contained in:
2023-08-05 21:01:11 +02:00
parent 836e9dce42
commit da1782c4a9
9 changed files with 28 additions and 24 deletions

View File

@@ -11,6 +11,16 @@
namespace openVulkanoCpp::Vulkan
{
VulkanShader::~VulkanShader()
{
if (!shader) return;
device.destroyPipeline(pipeline);
for(auto& shaderModule : shaderModules)
{
device.destroyShaderModule(shaderModule);
}
}
void VulkanShader::Init(Context* context, Scene::Shader* shader, IShaderOwner* owner)
{
this->device = context->device->device;
@@ -108,11 +118,5 @@ namespace openVulkanoCpp::Vulkan
void VulkanShader::Close()
{
owner->RemoveShader(this);
shader = nullptr;
device.destroyPipeline(pipeline);
for(auto& shaderModule : shaderModules)
{
device.destroyShaderModule(shaderModule);
}
}
}