From 533f85cf8e1ba3de6e9434031ca4940644dffed9 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Sun, 19 Dec 2021 14:15:22 +0100 Subject: [PATCH] gpu/internal/vulkan: don't destroy nil vkDescriptorPool Most drivers seem to tolerate vkDestroyDescriptorPool with a nil pool, but NVIDIA's (rightly) doesn't. Fix that. References: https://todo.sr.ht/~eliasnaur/gio/323 References: https://todo.sr.ht/~eliasnaur/gio/314 Signed-off-by: Elias Naur --- gpu/internal/vulkan/vulkan.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gpu/internal/vulkan/vulkan.go b/gpu/internal/vulkan/vulkan.go index f69c2322..7d3791e8 100644 --- a/gpu/internal/vulkan/vulkan.go +++ b/gpu/internal/vulkan/vulkan.go @@ -678,10 +678,11 @@ func (p *descPool) release(d vk.Device) { func (p *descPool) bindDescriptorSet(b *Backend, cmdBuf vk.CommandBuffer, bindPoint vk.PipelineBindPoint, texBinds [texUnits]*Texture, bufBinds [storageUnits]*Buffer) { realloced := false destroyPool := func() { - pool := p.pool - b.deferFunc(func(d vk.Device) { - vk.DestroyDescriptorPool(d, pool) - }) + if pool := p.pool; pool != 0 { + b.deferFunc(func(d vk.Device) { + vk.DestroyDescriptorPool(d, pool) + }) + } p.pool = 0 p.cap = 0 }