diff --git a/renderdoc/common/wrapped_pool.h b/renderdoc/common/wrapped_pool.h index ed0fbf6e2..c9c850b5b 100644 --- a/renderdoc/common/wrapped_pool.h +++ b/renderdoc/common/wrapped_pool.h @@ -111,6 +111,9 @@ public: void Deallocate(void *p) { + if(p == NULL) + return; + SCOPED_LOCK(m_Lock); // try immediate pool diff --git a/renderdoc/driver/vulkan/vk_debug.cpp b/renderdoc/driver/vulkan/vk_debug.cpp index aee26b686..735861cd9 100644 --- a/renderdoc/driver/vulkan/vk_debug.cpp +++ b/renderdoc/driver/vulkan/vk_debug.cpp @@ -1414,7 +1414,8 @@ void VulkanReplay::DestroyResources() { ClearPostVSCache(); - m_pDriver->vkDestroyDescriptorSetLayout(m_pDriver->GetDev(), m_MeshFetchDescSetLayout, NULL); + if(m_MeshFetchDescSetLayout) + m_pDriver->vkDestroyDescriptorSetLayout(m_pDriver->GetDev(), m_MeshFetchDescSetLayout, NULL); m_General.Destroy(m_pDriver); m_TexRender.Destroy(m_pDriver); @@ -1458,6 +1459,9 @@ void VulkanReplay::GeneralMisc::Init(WrappedVulkan *driver, VkDescriptorPool des void VulkanReplay::GeneralMisc::Destroy(WrappedVulkan *driver) { + if(DescriptorPool == VK_NULL_HANDLE) + return; + driver->vkDestroyDescriptorPool(driver->GetDev(), DescriptorPool, NULL); driver->vkDestroySampler(driver->GetDev(), PointSampler, NULL); } @@ -1720,6 +1724,9 @@ void VulkanReplay::TextureRendering::Init(WrappedVulkan *driver, VkDescriptorPoo void VulkanReplay::TextureRendering::Destroy(WrappedVulkan *driver) { + if(DescSetLayout == VK_NULL_HANDLE) + return; + driver->vkDestroyDescriptorSetLayout(driver->GetDev(), DescSetLayout, NULL); driver->vkDestroyPipelineLayout(driver->GetDev(), PipeLayout, NULL); driver->vkDestroyPipeline(driver->GetDev(), Pipeline, NULL); @@ -1866,6 +1873,9 @@ void VulkanReplay::OverlayRendering::Init(WrappedVulkan *driver, VkDescriptorPoo void VulkanReplay::OverlayRendering::Destroy(WrappedVulkan *driver) { + if(ImageMem == VK_NULL_HANDLE) + return; + driver->vkFreeMemory(driver->GetDev(), ImageMem, NULL); driver->vkDestroyImage(driver->GetDev(), Image, NULL); driver->vkDestroyImageView(driver->GetDev(), ImageView, NULL); @@ -1952,6 +1962,9 @@ void VulkanReplay::CheckerboardRendering::Init(WrappedVulkan *driver, VkDescript void VulkanReplay::CheckerboardRendering::Destroy(WrappedVulkan *driver) { + if(DescSetLayout == VK_NULL_HANDLE) + return; + driver->vkDestroyDescriptorSetLayout(driver->GetDev(), DescSetLayout, NULL); driver->vkDestroyPipelineLayout(driver->GetDev(), PipeLayout, NULL); driver->vkDestroyPipeline(driver->GetDev(), Pipeline, NULL); @@ -2020,6 +2033,9 @@ void VulkanReplay::MeshRendering::Init(WrappedVulkan *driver, VkDescriptorPool d void VulkanReplay::MeshRendering::Destroy(WrappedVulkan *driver) { + if(DescSetLayout == VK_NULL_HANDLE) + return; + UBO.Destroy(); BBoxVB.Destroy(); AxisFrustumVB.Destroy(); @@ -2079,6 +2095,9 @@ void VulkanReplay::VertexPicking::Init(WrappedVulkan *driver, VkDescriptorPool d void VulkanReplay::VertexPicking::Destroy(WrappedVulkan *driver) { + if(DescSetLayout == VK_NULL_HANDLE) + return; + UBO.Destroy(); IB.Destroy(); IBUpload.Destroy(); @@ -2192,6 +2211,9 @@ void VulkanReplay::PixelPicking::Init(WrappedVulkan *driver, VkDescriptorPool de void VulkanReplay::PixelPicking::Destroy(WrappedVulkan *driver) { + if(Image == VK_NULL_HANDLE) + return; + driver->vkDestroyImage(driver->GetDev(), Image, NULL); driver->vkFreeMemory(driver->GetDev(), ImageMem, NULL); driver->vkDestroyImageView(driver->GetDev(), ImageView, NULL); @@ -2325,6 +2347,9 @@ void VulkanReplay::HistogramMinMax::Init(WrappedVulkan *driver, VkDescriptorPool void VulkanReplay::HistogramMinMax::Destroy(WrappedVulkan *driver) { + if(m_HistogramDescSetLayout == VK_NULL_HANDLE) + return; + driver->vkDestroyDescriptorSetLayout(driver->GetDev(), m_HistogramDescSetLayout, NULL); driver->vkDestroyPipelineLayout(driver->GetDev(), m_HistogramPipeLayout, NULL); diff --git a/renderdoc/driver/vulkan/vk_memory.cpp b/renderdoc/driver/vulkan/vk_memory.cpp index 8ab8b87f2..b8eae8b64 100644 --- a/renderdoc/driver/vulkan/vk_memory.cpp +++ b/renderdoc/driver/vulkan/vk_memory.cpp @@ -355,10 +355,13 @@ MemoryAllocation WrappedVulkan::AllocateMemoryForResource(VkBuffer buf, MemorySc void WrappedVulkan::FreeAllMemory(MemoryScope scope) { - VkDevice d = GetDev(); - std::vector &allocList = m_MemoryBlocks[(size_t)scope]; + if(allocList.empty()) + return; + + VkDevice d = GetDev(); + for(MemoryAllocation alloc : allocList) { ObjDisp(d)->FreeMemory(Unwrap(d), Unwrap(alloc.mem), NULL); diff --git a/renderdoc/driver/vulkan/wrappers/vk_device_funcs.cpp b/renderdoc/driver/vulkan/wrappers/vk_device_funcs.cpp index 1b271bb88..c283c5dac 100644 --- a/renderdoc/driver/vulkan/wrappers/vk_device_funcs.cpp +++ b/renderdoc/driver/vulkan/wrappers/vk_device_funcs.cpp @@ -191,7 +191,7 @@ ReplayStatus WrappedVulkan::Initialise(VkInitParams ¶ms, uint64_t sectionVer { if(supportedLayers.find(params.Layers[i]) == supportedLayers.end()) { - RDCERR("Log requires layer '%s' which is not supported", params.Layers[i].c_str()); + RDCERR("Capture requires layer '%s' which is not supported", params.Layers[i].c_str()); return ReplayStatus::APIHardwareUnsupported; } } @@ -200,7 +200,7 @@ ReplayStatus WrappedVulkan::Initialise(VkInitParams ¶ms, uint64_t sectionVer { if(supportedExtensions.find(params.Extensions[i]) == supportedExtensions.end()) { - RDCERR("Log requires extension '%s' which is not supported", params.Extensions[i].c_str()); + RDCERR("Capture requires extension '%s' which is not supported", params.Extensions[i].c_str()); return ReplayStatus::APIHardwareUnsupported; } } @@ -496,8 +496,11 @@ void WrappedVulkan::Shutdown() GetResourceManager()->ReleaseWrappedResource(m_InternalCmds.freecmds[i]); // destroy the pool - ObjDisp(m_Device)->DestroyCommandPool(Unwrap(m_Device), Unwrap(m_InternalCmds.cmdpool), NULL); - GetResourceManager()->ReleaseWrappedResource(m_InternalCmds.cmdpool); + if(m_Device && m_InternalCmds.cmdpool) + { + ObjDisp(m_Device)->DestroyCommandPool(Unwrap(m_Device), Unwrap(m_InternalCmds.cmdpool), NULL); + GetResourceManager()->ReleaseWrappedResource(m_InternalCmds.cmdpool); + } for(size_t i = 0; i < m_InternalCmds.freesems.size(); i++) { @@ -521,7 +524,8 @@ void WrappedVulkan::Shutdown() SAFE_DELETE(m_DebugManager); SAFE_DELETE(m_ShaderCache); - if(ObjDisp(m_Instance)->DestroyDebugReportCallbackEXT && m_DbgMsgCallback != VK_NULL_HANDLE) + if(m_Instance && ObjDisp(m_Instance)->DestroyDebugReportCallbackEXT && + m_DbgMsgCallback != VK_NULL_HANDLE) ObjDisp(m_Instance)->DestroyDebugReportCallbackEXT(Unwrap(m_Instance), m_DbgMsgCallback, NULL); // need to store the unwrapped device and instance to destroy the @@ -529,8 +533,8 @@ void WrappedVulkan::Shutdown() VkInstance inst = Unwrap(m_Instance); VkDevice dev = Unwrap(m_Device); - const VkLayerDispatchTable *vt = ObjDisp(m_Device); - const VkLayerInstanceDispatchTable *vit = ObjDisp(m_Instance); + const VkLayerDispatchTable *vt = m_Device != VK_NULL_HANDLE ? ObjDisp(m_Device) : NULL; + const VkLayerInstanceDispatchTable *vit = m_Instance != VK_NULL_HANDLE ? ObjDisp(m_Instance) : NULL; // this destroys the wrapped objects for the devices and instances m_ResourceManager->Shutdown(); @@ -551,8 +555,10 @@ void WrappedVulkan::Shutdown() m_QueueFamilies.clear(); // finally destroy device then instance - vt->DestroyDevice(dev, NULL); - vit->DestroyInstance(inst, NULL); + if(vt) + vt->DestroyDevice(dev, NULL); + if(vit) + vit->DestroyInstance(inst, NULL); } void WrappedVulkan::vkDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) @@ -628,7 +634,7 @@ bool WrappedVulkan::Serialise_vkEnumeratePhysicalDevices(SerialiserType &ser, Vk { VkDriverInfo capturedVersion(physProps); - RDCLOG("Captured log describes physical device %u:", PhysicalDeviceIndex); + RDCLOG("Capture describes physical device %u:", PhysicalDeviceIndex); RDCLOG(" - %s (ver %u.%u patch 0x%x) - %04x:%04x", physProps.deviceName, capturedVersion.Major(), capturedVersion.Minor(), capturedVersion.Patch(), physProps.vendorID, physProps.deviceID); @@ -1027,7 +1033,16 @@ bool WrappedVulkan::Serialise_vkCreateDevice(SerialiserType &ser, VkPhysicalDevi extArray = new const char *[createInfo.enabledExtensionCount]; for(uint32_t i = 0; i < createInfo.enabledExtensionCount; i++) + { + if(supportedExtensions.find(Extensions[i]) == supportedExtensions.end()) + { + m_FailedReplayStatus = ReplayStatus::APIHardwareUnsupported; + RDCERR("Capture requires extension '%s' which is not supported", Extensions[i].c_str()); + return false; + } + extArray[i] = Extensions[i].c_str(); + } createInfo.ppEnabledExtensionNames = extArray; } diff --git a/renderdoc/driver/vulkan/wrappers/vk_misc_funcs.cpp b/renderdoc/driver/vulkan/wrappers/vk_misc_funcs.cpp index 90a624082..9add5e6af 100644 --- a/renderdoc/driver/vulkan/wrappers/vk_misc_funcs.cpp +++ b/renderdoc/driver/vulkan/wrappers/vk_misc_funcs.cpp @@ -190,8 +190,8 @@ bool WrappedVulkan::ReleaseResource(WrappedVkRes *res) return true; // MULTIDEVICE need to get the actual device that created this object - VkDevice dev = GetDev(); - const VkLayerDispatchTable *vt = ObjDisp(dev); + VkDevice dev = m_Device; + const VkLayerDispatchTable *vt = m_Device != VK_NULL_HANDLE ? ObjDisp(dev) : NULL; WrappedVkNonDispRes *nondisp = (WrappedVkNonDispRes *)res; WrappedVkDispRes *disp = (WrappedVkDispRes *)res;