From 54675a3541dbe52c08272101b19d963418327d1b Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Thu, 2 Jul 2020 09:09:52 -0400 Subject: Only call m_api functions if m_api has been validly set on dtor of VulkanDeviceQueue. (#1426) --- tools/gfx/vulkan/vk-device-queue.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'tools') diff --git a/tools/gfx/vulkan/vk-device-queue.cpp b/tools/gfx/vulkan/vk-device-queue.cpp index 10a3d0e3b..3b9e6cbcd 100644 --- a/tools/gfx/vulkan/vk-device-queue.cpp +++ b/tools/gfx/vulkan/vk-device-queue.cpp @@ -1,4 +1,4 @@ -// vk-device-queue.cpp +// vk-device-queue.cpp #include "vk-device-queue.h" #include @@ -10,17 +10,20 @@ using namespace Slang; VulkanDeviceQueue::~VulkanDeviceQueue() { - for (int i = 0; i < int(EventType::CountOf); ++i) + if (m_api) { - m_api->vkDestroySemaphore(m_api->m_device, m_semaphores[i], nullptr); - } + for (int i = 0; i < int(EventType::CountOf); ++i) + { + m_api->vkDestroySemaphore(m_api->m_device, m_semaphores[i], nullptr); + } - for (int i = 0; i < m_numCommandBuffers; i++) - { - m_api->vkFreeCommandBuffers(m_api->m_device, m_commandPool, 1, &m_commandBuffers[i]); - m_api->vkDestroyFence(m_api->m_device, m_fences[i].fence, nullptr); + for (int i = 0; i < m_numCommandBuffers; i++) + { + m_api->vkFreeCommandBuffers(m_api->m_device, m_commandPool, 1, &m_commandBuffers[i]); + m_api->vkDestroyFence(m_api->m_device, m_fences[i].fence, nullptr); + } + m_api->vkDestroyCommandPool(m_api->m_device, m_commandPool, nullptr); } - m_api->vkDestroyCommandPool(m_api->m_device, m_commandPool, nullptr); } SlangResult VulkanDeviceQueue::init(const VulkanApi& api, VkQueue queue, int queueIndex) -- cgit v1.2.3