diff --git a/implementations/Crafter.Graphics-ComputeShader.cpp b/implementations/Crafter.Graphics-ComputeShader.cpp index 3af554b..f1daa93 100644 --- a/implementations/Crafter.Graphics-ComputeShader.cpp +++ b/implementations/Crafter.Graphics-ComputeShader.cpp @@ -74,8 +74,12 @@ void ComputeShader::Load(const std::filesystem::path& spvPath, DescriptorHeapVul }, .layout = layout, }; - Device::CheckVkResult(vkCreateComputePipelines( - Device::device, Device::pipelineCache, 1, &info, nullptr, &pipeline)); + const VkResult created = vkCreateComputePipelines( + Device::device, Device::pipelineCache, 1, &info, nullptr, &pipeline); + // The module is only an input to pipeline creation; VulkanShader does + // not destroy it, so it is released here either way. + vkDestroyShaderModule(Device::device, shader.shader, nullptr); + Device::CheckVkResult(created); return; } @@ -106,8 +110,10 @@ void ComputeShader::Load(const std::filesystem::path& spvPath, DescriptorHeapVul }, .layout = VK_NULL_HANDLE, }; - Device::CheckVkResult(vkCreateComputePipelines( - Device::device, Device::pipelineCache, 1, &info, nullptr, &pipeline)); + const VkResult created = vkCreateComputePipelines( + Device::device, Device::pipelineCache, 1, &info, nullptr, &pipeline); + vkDestroyShaderModule(Device::device, shader.shader, nullptr); + Device::CheckVkResult(created); } void ComputeShader::Dispatch(VkCommandBuffer cmd,