# HG changeset patch # User Sam # Date 1701536738 -25200 # Node ID eaf084ba80e51b0c5f40393fc4313afbb88d42dc # Parent 8e926856a9cef9e881f4e4ea824833e6810a27e0 fix: cleanup when multiple textures use same vulkan image diff -r 8e926856a9ce -r eaf084ba80e5 semicongine.nimble --- a/semicongine.nimble Sat Dec 02 22:26:45 2023 +0700 +++ b/semicongine.nimble Sun Dec 03 00:05:38 2023 +0700 @@ -9,7 +9,7 @@ # Dependencies -requires "nim >= 1.6.10" +requires "nim >= 2.0" requires "winim" requires "x11" requires "zippy" diff -r 8e926856a9ce -r eaf084ba80e5 semicongine/renderer.nim --- a/semicongine/renderer.nim Sat Dec 02 22:26:45 2023 +0700 +++ b/semicongine/renderer.nim Sun Dec 03 00:05:38 2023 +0700 @@ -478,12 +478,16 @@ for buffer in pipelineUniforms.mitems: assert buffer.vk.valid buffer.destroy() + var destroyedTextures: seq[VkImage] for pipelineTextures in scenedata.textures.mvalues: for textures in pipelineTextures.mvalues: for texture in textures.mitems: - texture.destroy() + if not destroyedTextures.contains(texture.image.vk): + destroyedTextures.add texture.image.vk + texture.destroy() for descriptorPool in scenedata.descriptorPools.mvalues: descriptorPool.destroy() + renderer.scenedata.del(scene) proc destroy*(renderer: var Renderer) = for scenedata in renderer.scenedata.mvalues: @@ -497,12 +501,17 @@ for buffer in pipelineUniforms.mitems: assert buffer.vk.valid buffer.destroy() + var destroyedTextures: seq[VkImage] for pipelineTextures in scenedata.textures.mvalues: for textures in pipelineTextures.mvalues: for texture in textures.mitems: - texture.destroy() + if not destroyedTextures.contains(texture.image.vk): + destroyedTextures.add texture.image.vk + texture.destroy() for descriptorPool in scenedata.descriptorPools.mvalues: descriptorPool.destroy() + for scene in renderer.scenedata.keys.toSeq: + renderer.scenedata.del(scene) renderer.emptyTexture.destroy() renderer.renderPass.destroy() renderer.swapchain.destroy() diff -r 8e926856a9ce -r eaf084ba80e5 tests/test_materials.nim --- a/tests/test_materials.nim Sat Dec 02 22:26:45 2023 +0700 +++ b/tests/test_materials.nim Sun Dec 03 00:05:38 2023 +0700 @@ -16,7 +16,7 @@ swiss = loadImage("flag.png") doubleTextureMaterial = MaterialType( name:"Double texture", - meshAttributes: { + vertexAttributes: { "position": Vec3F32, "uv": Vec2F32, }.toTable, diff -r 8e926856a9ce -r eaf084ba80e5 tests/test_vulkan_wrapper.nim --- a/tests/test_vulkan_wrapper.nim Sat Dec 02 22:26:45 2023 +0700 +++ b/tests/test_vulkan_wrapper.nim Sun Dec 03 00:05:38 2023 +0700 @@ -25,7 +25,7 @@ ) Mat2Type = MaterialType( name: "single texture material 2", - meshAttributes: { + vertexAttributes: { "position": Vec3F32, "uv": Vec2F32, }.toTable,