Don't misbehave when freeing or destroying VK_NULL_HANDLE

This commit is contained in:
baldurk
2020-08-14 19:48:21 +01:00
parent 2b990bdf46
commit 7f1748e8fc
4 changed files with 19 additions and 1 deletions
@@ -547,7 +547,10 @@ VkResult WrappedVulkan::vkFreeDescriptorSets(VkDevice device, VkDescriptorPool d
unwrapped[i] = Unwrap(pDescriptorSets[i]);
for(uint32_t i = 0; i < count; i++)
GetResourceManager()->ReleaseWrappedResource(pDescriptorSets[i]);
{
if(pDescriptorSets[i] != VK_NULL_HANDLE)
GetResourceManager()->ReleaseWrappedResource(pDescriptorSets[i]);
}
VkResult ret =
ObjDisp(device)->FreeDescriptorSets(Unwrap(device), Unwrap(descriptorPool), count, unwrapped);
@@ -926,6 +926,9 @@ void WrappedVulkan::Shutdown()
void WrappedVulkan::vkDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator)
{
if(instance == VK_NULL_HANDLE)
return;
RDCASSERT(m_Instance == instance);
if(ObjDisp(m_Instance)->DestroyDebugReportCallbackEXT && m_DbgReportCallback != VK_NULL_HANDLE)
@@ -3676,6 +3679,9 @@ VkResult WrappedVulkan::vkCreateDevice(VkPhysicalDevice physicalDevice,
void WrappedVulkan::vkDestroyDevice(VkDevice device, const VkAllocationCallbacks *pAllocator)
{
if(device == VK_NULL_HANDLE)
return;
// flush out any pending commands/semaphores
SubmitCmds();
SubmitSemaphores();
@@ -1756,6 +1756,9 @@ void WrappedVulkan::vkDestroyDebugReportCallbackEXT(VkInstance instance,
VkDebugReportCallbackEXT callback,
const VkAllocationCallbacks *pAllocator)
{
if(callback == VK_NULL_HANDLE)
return;
UserDebugReportCallbackData *user =
(UserDebugReportCallbackData *)(uintptr_t)NON_DISP_TO_UINT64(callback);
@@ -2089,6 +2092,9 @@ void WrappedVulkan::vkDestroyDebugUtilsMessengerEXT(VkInstance instance,
VkDebugUtilsMessengerEXT messenger,
const VkAllocationCallbacks *pAllocator)
{
if(messenger == VK_NULL_HANDLE)
return;
UserDebugUtilsCallbackData *user =
(UserDebugUtilsCallbackData *)(uintptr_t)NON_DISP_TO_UINT64(messenger);
@@ -987,6 +987,9 @@ VkResult WrappedVulkan::vkQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR
void WrappedVulkan::vkDestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface,
const VkAllocationCallbacks *pAllocator)
{
if(surface == VK_NULL_HANDLE)
return;
WrappedVkSurfaceKHR *wrapper = GetWrapped(surface);
// record pointer has window handle packed in