From 5d3d85d129403ebd376e61d52ec0a8de7e51b114 Mon Sep 17 00:00:00 2001 From: Courtney Goeltzenleuchter Date: Mon, 1 Jun 2015 14:29:58 -0600 Subject: draw_state: Add CreateInstance support Layers need to intercept CreateInstance in order to see what's been enabled on the Instance chain. As this layer supports DEBUG_REPORT extension it needs to know if that has been enabled or not. --- layers/draw_state.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/layers/draw_state.cpp b/layers/draw_state.cpp index bbf0b5e4..34971f43 100644 --- a/layers/draw_state.cpp +++ b/layers/draw_state.cpp @@ -1525,6 +1525,21 @@ static void initDrawState(void) } } +VK_LAYER_EXPORT VkResult VKAPI vkCreateInstance(const VkInstanceCreateInfo* pCreateInfo, VkInstance* pInstance) +{ + VkLayerInstanceDispatchTable *pDisp = *(VkLayerInstanceDispatchTable **) (*pInstance); + VkLayerInstanceDispatchTable *pTable = tableInstanceMap[pDisp]; + + loader_platform_thread_once(&g_initOnce, initDrawState); + + VkResult result = pTable->CreateInstance(pCreateInfo, pInstance); + + if (result == VK_SUCCESS) { + enable_debug_report(pCreateInfo->extensionCount, pCreateInfo->pEnabledExtensions); + } + return result; +} + /* hook DestroyInstance to remove tableInstanceMap entry */ VK_LAYER_EXPORT VkResult VKAPI vkDestroyInstance(VkInstance instance) { @@ -3056,6 +3071,8 @@ VK_LAYER_EXPORT void * VKAPI vkGetInstanceProcAddr(VkInstance instance, const ch initInstanceTable((const VkBaseLayerObject *) instance); return (void *) vkGetInstanceProcAddr; } + if (!strcmp(funcName, "vkCreateInstance")) + return (void *) vkCreateInstance; if (!strcmp(funcName, "vkDestroyInstance")) return (void *) vkDestroyInstance; if (!strcmp(funcName, "vkCreateDevice")) -- cgit v1.2.3