Skip to content

Commit

Permalink
VulkanPipeline: Clean up created pipelines correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
skalarproduktraum committed Oct 13, 2023
1 parent 77028d6 commit 7664489
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/main/kotlin/graphics/scenery/backends/vulkan/VulkanPipeline.kt
Original file line number Diff line number Diff line change
Expand Up @@ -286,15 +286,21 @@ class VulkanPipeline(val device: VulkanDevice, val renderpass: VulkanRenderpass,
override fun close() {
val removedLayouts = ArrayList<Long>()

pipeline.forEach { _, pipeline ->
vkDestroyPipeline(device.vulkanDevice, pipeline.pipeline, null)
pipeline.forEach { (_, pipeline) ->
if(pipeline.pipeline != 0L) {
vkDestroyPipeline(device.vulkanDevice, pipeline.pipeline, null)
pipeline.pipeline = 0L
}

if(!removedLayouts.contains(pipeline.layout)) {
vkDestroyPipelineLayout(device.vulkanDevice, pipeline.layout, null)
if(!removedLayouts.contains(pipeline.layout) && pipeline.layout != 0L) {
removedLayouts.add(pipeline.layout)
vkDestroyPipelineLayout(device.vulkanDevice, pipeline.layout, null)
pipeline.layout = 0L
}
}

pipeline.clear()

inputAssemblyState.free()
rasterizationState.free()
depthStencilState.free()
Expand Down

0 comments on commit 7664489

Please sign in to comment.