Fix some shader issues

This commit is contained in:
Georg Hagen
2024-07-03 15:43:15 +02:00
parent 9e95285173
commit 002206e9d6
4 changed files with 17 additions and 13 deletions

View File

@@ -17,14 +17,7 @@ namespace OpenVulkano::Vulkan
VulkanShader::~VulkanShader()
{
if (!shader) return;
device.destroyPipeline(pipeline);
for(auto& shaderModule : shaderModules)
{
device.destroyShaderModule(shaderModule);
}
device.destroyPipelineLayout(pipelineLayout);
for(auto& descriptorSetLayout : descriptorSetLayouts)
device.destroyDescriptorSetLayout(descriptorSetLayout);
Close();
}
void VulkanShader::Init(Context* context, Scene::Shader* shader, IShaderOwner* owner)
@@ -124,7 +117,17 @@ namespace OpenVulkano::Vulkan
void VulkanShader::Close()
{
owner->RemoveShader(this);
shader->renderShader = nullptr;
device.destroyPipeline(pipeline);
for(auto& shaderModule : shaderModules)
{
device.destroyShaderModule(shaderModule);
}
device.destroyPipelineLayout(pipelineLayout);
for(auto& descriptorSetLayout : descriptorSetLayouts)
device.destroyDescriptorSetLayout(descriptorSetLayout);
shader = nullptr;
if (owner) owner->RemoveShader(this);
}
void VulkanShader::CreatePipelineLayout()
@@ -150,4 +153,4 @@ namespace OpenVulkano::Vulkan
vk::PipelineLayoutCreateInfo plci = { {}, static_cast<uint32_t>(descriptorSetLayouts.size()), descriptorSetLayouts.data(), 0, nullptr };
pipelineLayout = this->device.createPipelineLayout(plci);
}
}
}