From b3114bd21ddecd99ee90a70ebd7c286acec66085 Mon Sep 17 00:00:00 2001 From: baldurk Date: Thu, 5 May 2016 12:45:22 +0200 Subject: [PATCH] Modify vkCreateInstance requested extensions to add DEBUG_REPORT * This only happens if we have DebugDeviceMode enabled, but it lets us listen to anything the validation layers report. --- .../vulkan/wrappers/vk_device_funcs.cpp | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/renderdoc/driver/vulkan/wrappers/vk_device_funcs.cpp b/renderdoc/driver/vulkan/wrappers/vk_device_funcs.cpp index a7dc6b93a..14bd64b40 100644 --- a/renderdoc/driver/vulkan/wrappers/vk_device_funcs.cpp +++ b/renderdoc/driver/vulkan/wrappers/vk_device_funcs.cpp @@ -187,8 +187,21 @@ VkResult WrappedVulkan::vkCreateInstance( layerCreateInfo->u.pLayerInfo = layerCreateInfo->u.pLayerInfo->pNext; PFN_vkCreateInstance createFunc = (PFN_vkCreateInstance)gpa(VK_NULL_HANDLE, "vkCreateInstance"); + + VkInstanceCreateInfo modifiedCreateInfo; + modifiedCreateInfo = *pCreateInfo; + + const char **addedExts = new const char *[modifiedCreateInfo.enabledExtensionCount+1]; + + for(uint32_t i=0; i < modifiedCreateInfo.enabledExtensionCount; i++) + addedExts[i] = modifiedCreateInfo.ppEnabledExtensionNames[i]; + + if(RenderDoc::Inst().GetCaptureOptions().DebugDeviceMode) + addedExts[modifiedCreateInfo.enabledExtensionCount++] = VK_EXT_DEBUG_REPORT_EXTENSION_NAME; + + modifiedCreateInfo.ppEnabledExtensionNames = addedExts; - VkResult ret = createFunc(pCreateInfo, pAllocator, pInstance); + VkResult ret = createFunc(&modifiedCreateInfo, pAllocator, pInstance); m_Instance = *pInstance; @@ -207,13 +220,15 @@ VkResult WrappedVulkan::vkCreateInstance( record->instDevInfo = new InstanceDeviceInfo(); #undef CheckExt -#define CheckExt(name) if(!strcmp(pCreateInfo->ppEnabledExtensionNames[i], STRINGIZE(name))) { record->instDevInfo->name = true; } +#define CheckExt(name) if(!strcmp(modifiedCreateInfo.ppEnabledExtensionNames[i], STRINGIZE(name))) { record->instDevInfo->name = true; } - for(uint32_t i=0; i < pCreateInfo->enabledExtensionCount; i++) + for(uint32_t i=0; i < modifiedCreateInfo.enabledExtensionCount; i++) { CheckInstanceExts(); } + delete[] addedExts; + InitInstanceExtensionTables(m_Instance); RenderDoc::Inst().AddDeviceFrameCapturer(LayerDisp(m_Instance), this); @@ -311,6 +326,9 @@ void WrappedVulkan::Shutdown() void WrappedVulkan::vkDestroyInstance(VkInstance instance, const VkAllocationCallbacks* pAllocator) { RDCASSERT(m_Instance == instance); + + if(ObjDisp(m_Instance)->DestroyDebugReportCallbackEXT && m_DbgMsgCallback != VK_NULL_HANDLE) + ObjDisp(m_Instance)->DestroyDebugReportCallbackEXT(Unwrap(m_Instance), m_DbgMsgCallback, NULL); // the device should already have been destroyed, assuming that the // application is well behaved. If not, we just leak.