Mercurial > games > semicongine
changeset 845:19b5051d6eb7
fix: cleanup when multiple textures use same vulkan image
author | Sam <sam@basx.dev> |
---|---|
date | Sun, 03 Dec 2023 00:05:38 +0700 |
parents | 094342d38c69 |
children | d4f4cc238379 |
files | semicongine.nimble semicongine/renderer.nim tests/test_materials.nim tests/test_vulkan_wrapper.nim |
diffstat | 4 files changed, 14 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- 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"
--- 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()
--- 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,
--- 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,