From 7cfea184a5feb28228033752025304620d3d534b Mon Sep 17 00:00:00 2001 From: Masahiro Masuda Date: Sun, 21 Mar 2021 08:37:11 +0900 Subject: [PATCH] do not delete ubo when not using it --- src/runtime/vulkan/vulkan.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/runtime/vulkan/vulkan.cc b/src/runtime/vulkan/vulkan.cc index c3b232987a62..a45ed167ac13 100644 --- a/src/runtime/vulkan/vulkan.cc +++ b/src/runtime/vulkan/vulkan.cc @@ -828,10 +828,12 @@ class VulkanModuleNode final : public runtime::ModuleNode { vkDestroyDescriptorSetLayout(vctx.device, pe->descriptor_set_layout, nullptr); vkDestroyShaderModule(vctx.device, pe->shader, nullptr); // UBO - vkDestroyBuffer(vctx.device, pe->ubo.vk_buf->buffer, nullptr); - vkFreeMemory(vctx.device, pe->ubo.vk_buf->memory, nullptr); - delete pe->ubo.vk_buf; - delete[] pe->ubo.host_buf; + if (pe->ubo.host_buf) { + vkDestroyBuffer(vctx.device, pe->ubo.vk_buf->buffer, nullptr); + vkFreeMemory(vctx.device, pe->ubo.vk_buf->memory, nullptr); + delete pe->ubo.vk_buf; + delete[] pe->ubo.host_buf; + } } } }