diff options
| author | Jon Ashburn <jon@lunarg.com> | 2015-06-01 09:37:38 -0600 |
|---|---|---|
| committer | Courtney Goeltzenleuchter <courtney@LunarG.com> | 2015-06-18 10:18:20 -0600 |
| commit | cf99decc751668b995be63f15b0c29a677a6f494 (patch) | |
| tree | a06cf12cc275c6a122aee1f0b5952e8db5884894 /layers | |
| parent | 87e0fa040fad2093a7ae96943bca64b47cbadb62 (diff) | |
| download | usermoji-cf99decc751668b995be63f15b0c29a677a6f494.tar.xz | |
layers: Fix DrawState and ParamChecker to only use debug_marker if enabled
Diffstat (limited to 'layers')
| -rw-r--r-- | layers/draw_state.cpp | 88 | ||||
| -rw-r--r-- | layers/layers_debug_marker_table.cpp | 60 | ||||
| -rw-r--r-- | layers/layers_debug_marker_table.h | 39 | ||||
| -rw-r--r-- | layers/param_checker.cpp | 89 |
4 files changed, 204 insertions, 72 deletions
diff --git a/layers/draw_state.cpp b/layers/draw_state.cpp index 33712714..65401950 100644 --- a/layers/draw_state.cpp +++ b/layers/draw_state.cpp @@ -45,6 +45,7 @@ // being used: #include "loader_platform.h" #include "layers_msg.h" +#include "layers_debug_marker_table.h" unordered_map<VkSampler, SAMPLER_NODE*> sampleMap; unordered_map<VkImageView, IMAGE_NODE*> imageMap; @@ -59,9 +60,13 @@ unordered_map<VkCmdBuffer, GLOBAL_CB_NODE*> cmdBufferMap; unordered_map<VkRenderPass, VkRenderPassCreateInfo*> renderPassMap; unordered_map<VkFramebuffer, VkFramebufferCreateInfo*> frameBufferMap; +struct devExts { + bool debug_marker_enabled; +}; + static std::unordered_map<void *, VkLayerDispatchTable *> tableMap; -static std::unordered_map<void *, VkLayerDebugMarkerDispatchTable *> tableDebugMarkerMap; static std::unordered_map<void *, VkLayerInstanceDispatchTable *> tableInstanceMap; +static std::unordered_map<void *, struct devExts> deviceExtMap; static LOADER_PLATFORM_THREAD_ONCE_DECLARATION(g_initOnce); @@ -1445,7 +1450,6 @@ static void synchAndPrintDSConfig(const VkCmdBuffer cb) static VkLayerDispatchTable * initDeviceTable(const VkBaseLayerObject *devw) { VkLayerDispatchTable *pTable; - VkLayerDebugMarkerDispatchTable *pDebugMarkerTable; assert(devw); VkLayerDispatchTable **ppDisp = (VkLayerDispatchTable **) (devw->baseObject); @@ -1455,8 +1459,7 @@ static VkLayerDispatchTable * initDeviceTable(const VkBaseLayerObject *devw) { pTable = new VkLayerDispatchTable; tableMap[(void *) *ppDisp] = pTable; - pDebugMarkerTable = new VkLayerDebugMarkerDispatchTable; - tableDebugMarkerMap[(void *) *ppDisp] = pDebugMarkerTable; + } else { return it->second; @@ -1464,13 +1467,6 @@ static VkLayerDispatchTable * initDeviceTable(const VkBaseLayerObject *devw) layer_initialize_dispatch_table(pTable, devw); - VkDevice device = (VkDevice) devw->baseObject; - pDebugMarkerTable->CmdDbgMarkerBegin = (PFN_vkCmdDbgMarkerBegin) devw->pGPA(device, "vkCmdDbgMarkerBegin"); - pDebugMarkerTable->CmdDbgMarkerEnd = (PFN_vkCmdDbgMarkerEnd) devw->pGPA(device, "vkCmdDbgMarkerEnd"); - pDebugMarkerTable->DbgSetObjectTag = (PFN_vkDbgSetObjectTag) devw->pGPA(device, "vkDbgSetObjectTag"); - pDebugMarkerTable->DbgSetObjectName = (PFN_vkDbgSetObjectName) devw->pGPA(device, "vkDbgSetObjectName"); - pDebugMarkerTable->ext_enabled = false; - return pTable; } @@ -1558,13 +1554,14 @@ VK_LAYER_EXPORT VkResult VKAPI vkDestroyInstance(VkInstance instance) static void createDeviceRegisterExtensions(const VkDeviceCreateInfo* pCreateInfo, VkDevice device) { uint32_t i, ext_idx; - VkLayerDebugMarkerDispatchTable *pDisp = *(VkLayerDebugMarkerDispatchTable **) device; - VkLayerDebugMarkerDispatchTable *pTable = tableDebugMarkerMap[pDisp]; + VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) device; + deviceExtMap[pDisp].debug_marker_enabled = false; for (i = 0; i < pCreateInfo->extensionCount; i++) { if (strcmp(pCreateInfo->pEnabledExtensions[i].name, DEBUG_MARKER_EXTENSION_NAME) == 0) { - /* Found a matching extension name, mark it enabled */ - pTable->ext_enabled = true; + /* Found a matching extension name, mark it enabled and init dispatch table*/ + initDebugMarkerTable(device); + deviceExtMap[pDisp].debug_marker_enabled = true; } } @@ -1597,6 +1594,8 @@ VK_LAYER_EXPORT VkResult VKAPI vkDestroyDevice(VkDevice device) VkLayerDispatchTable *pTable = tableMap[pDisp]; VkResult result = pTable->DestroyDevice(device); tableMap.erase(pDisp); + tableDebugMarkerMap.erase(pDisp); + deviceExtMap.erase(pDisp); return result; } @@ -2841,12 +2840,12 @@ VK_LAYER_EXPORT VkResult VKAPI vkDbgDestroyMsgCallback( VK_LAYER_EXPORT void VKAPI vkCmdDbgMarkerBegin(VkCmdBuffer cmdBuffer, const char* pMarker) { GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); - VkLayerDebugMarkerDispatchTable *pDisp = *(VkLayerDebugMarkerDispatchTable **) cmdBuffer; - VkLayerDebugMarkerDispatchTable *pTable = tableDebugMarkerMap[pDisp]; - if (!pTable->ext_enabled) { + VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) cmdBuffer; + if (!deviceExtMap[pDisp].debug_marker_enabled) { char str[1024]; sprintf(str, "Attempt to use CmdDbgMarkerBegin but extension disabled!"); layerCbMsg(VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, cmdBuffer, 0, DRAWSTATE_INVALID_EXTENSION, "DS", str); + return; } else if (pCB) { updateCBTracking(cmdBuffer); @@ -2857,18 +2856,18 @@ VK_LAYER_EXPORT void VKAPI vkCmdDbgMarkerBegin(VkCmdBuffer cmdBuffer, const char sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); layerCbMsg(VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); } - pTable->CmdDbgMarkerBegin(cmdBuffer, pMarker); + debug_marker_dispatch_table(cmdBuffer)->CmdDbgMarkerBegin(cmdBuffer, pMarker); } VK_LAYER_EXPORT void VKAPI vkCmdDbgMarkerEnd(VkCmdBuffer cmdBuffer) { GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); - VkLayerDebugMarkerDispatchTable *pDisp = *(VkLayerDebugMarkerDispatchTable **) cmdBuffer; - VkLayerDebugMarkerDispatchTable *pTable = tableDebugMarkerMap[pDisp]; - if (!pTable->ext_enabled) { + VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) cmdBuffer; + if (!deviceExtMap[pDisp].debug_marker_enabled) { char str[1024]; sprintf(str, "Attempt to use CmdDbgMarkerEnd but extension disabled!"); layerCbMsg(VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, cmdBuffer, 0, DRAWSTATE_INVALID_EXTENSION, "DS", str); + return; } else if (pCB) { updateCBTracking(cmdBuffer); @@ -2879,7 +2878,29 @@ VK_LAYER_EXPORT void VKAPI vkCmdDbgMarkerEnd(VkCmdBuffer cmdBuffer) sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); layerCbMsg(VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); } - pTable->CmdDbgMarkerEnd(cmdBuffer); + debug_marker_dispatch_table(cmdBuffer)->CmdDbgMarkerEnd(cmdBuffer); +} + +VK_LAYER_EXPORT VkResult VKAPI vkDbgSetObjectTag(VkDevice device, VkObjectType objType, VkObject object, size_t tagSize, const void* pTag) +{ + VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) device; + if (!deviceExtMap[pDisp].debug_marker_enabled) { + char const str[] = "Attempt to use DbgSetObjectTag but extension disabled!"; + layerCbMsg(VK_DBG_REPORT_ERROR_BIT, objType, object, 0, DRAWSTATE_INVALID_EXTENSION, "DS", str); + return VK_ERROR_UNAVAILABLE; + } + debug_marker_dispatch_table(device)->DbgSetObjectTag(device, objType, object, tagSize, pTag); +} + +VK_LAYER_EXPORT VkResult VKAPI vkDbgSetObjectName(VkDevice device, VkObjectType objType, VkObject object, size_t nameSize, const char* pName) +{ + VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) device; + if (!deviceExtMap[pDisp].debug_marker_enabled) { + char const str[] = "Attempt to use DbgSetObjectName but extension disabled!"; + layerCbMsg(VK_DBG_REPORT_ERROR_BIT, objType, object, 0, DRAWSTATE_INVALID_EXTENSION, "DS", str); + return VK_ERROR_UNAVAILABLE; + } + debug_marker_dispatch_table(device)->DbgSetObjectName(device, objType, object, nameSize, pName); } // TODO : Want to pass in a cmdBuffer here based on which state to display @@ -3048,20 +3069,27 @@ VK_LAYER_EXPORT void* VKAPI vkGetDeviceProcAddr(VkDevice dev, const char* funcNa return (void*) vkCmdBeginRenderPass; if (!strcmp(funcName, "vkCmdEndRenderPass")) return (void*) vkCmdEndRenderPass; - if (!strcmp(funcName, "vkCmdDbgMarkerBegin")) - return (void*) vkCmdDbgMarkerBegin; - if (!strcmp(funcName, "vkCmdDbgMarkerEnd")) - return (void*) vkCmdDbgMarkerEnd; if (!strcmp("drawStateDumpDotFile", funcName)) return (void*) drawStateDumpDotFile; if (!strcmp("drawStateDumpCommandBufferDotFile", funcName)) return (void*) drawStateDumpCommandBufferDotFile; if (!strcmp("drawStateDumpPngFile", funcName)) return (void*) drawStateDumpPngFile; - else + + VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) dev; + if (!deviceExtMap[pDisp].debug_marker_enabled) + { + if (!strcmp(funcName, "CmdDbgMarkerBegin")) + return (void*) vkCmdDbgMarkerBegin; + if (!strcmp(funcName, "CmdDbgMarkerEnd")) + return (void*) vkCmdDbgMarkerEnd; + if (!strcmp(funcName, "DbgSetObjectTag")) + return (void*) vkDbgSetObjectTag; + if (!strcmp(funcName, "DbgSetObjectName")) + return (void*) vkDbgSetObjectName; + } { - VkLayerDispatchTable **ppDisp = (VkLayerDispatchTable **) dev; - VkLayerDispatchTable* pTable = tableMap[*ppDisp]; + VkLayerDispatchTable* pTable = tableMap[pDisp]; if (pTable->GetDeviceProcAddr == NULL) return NULL; return pTable->GetDeviceProcAddr(dev, funcName); diff --git a/layers/layers_debug_marker_table.cpp b/layers/layers_debug_marker_table.cpp new file mode 100644 index 00000000..47c93b10 --- /dev/null +++ b/layers/layers_debug_marker_table.cpp @@ -0,0 +1,60 @@ +/* + * Vulkan + * + * Copyright (C) 2014 LunarG, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#include <assert.h> +#include <unordered_map> +#include "vk_debug_marker_layer.h" +std::unordered_map<void *, VkLayerDebugMarkerDispatchTable *> tableDebugMarkerMap; + +/* Various dispatchable objects will use the same underlying dispatch table if they + * are created from that "parent" object. Thus use pointer to dispatch table + * as the key to these table maps. + * Instance -> PhysicalDevice + * Device -> CmdBuffer or Queue + * If use the object themselves as key to map then implies Create entrypoints have to be intercepted + * and a new key inserted into map */ +VkLayerDebugMarkerDispatchTable * initDebugMarkerTable(VkDevice device) +{ + VkLayerDebugMarkerDispatchTable *pTable; + VkLayerDebugMarkerDispatchTable *pDebugMarkerTable; + + assert(device); + VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) device; + + std::unordered_map<void *, VkLayerDebugMarkerDispatchTable *>::const_iterator it = tableDebugMarkerMap.find((void *) pDisp); + if (it == tableDebugMarkerMap.end()) + { + pDebugMarkerTable = new VkLayerDebugMarkerDispatchTable; + tableDebugMarkerMap[(void *) pDisp] = pDebugMarkerTable; + } else + { + return it->second; + } + + pDebugMarkerTable->CmdDbgMarkerBegin = (PFN_vkCmdDbgMarkerBegin) pDisp->GetDeviceProcAddr(device, "vkCmdDbgMarkerBegin"); + pDebugMarkerTable->CmdDbgMarkerEnd = (PFN_vkCmdDbgMarkerEnd) pDisp->GetDeviceProcAddr(device, "vkCmdDbgMarkerEnd"); + pDebugMarkerTable->DbgSetObjectTag = (PFN_vkDbgSetObjectTag) pDisp->GetDeviceProcAddr(device, "vkDbgSetObjectTag"); + pDebugMarkerTable->DbgSetObjectName = (PFN_vkDbgSetObjectName) pDisp->GetDeviceProcAddr(device, "vkDbgSetObjectName"); + + return pTable; +}
\ No newline at end of file diff --git a/layers/layers_debug_marker_table.h b/layers/layers_debug_marker_table.h new file mode 100644 index 00000000..8fc6e2e8 --- /dev/null +++ b/layers/layers_debug_marker_table.h @@ -0,0 +1,39 @@ +/* + * Vulkan + * + * Copyright (C) 2014 LunarG, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#pragma once + +#include <unordered_map> + +extern std::unordered_map<void *, VkLayerDebugMarkerDispatchTable *> tableDebugMarkerMap; +VkLayerDebugMarkerDispatchTable * initDebugMarkerTable(VkDevice dev); + +// Map lookup must be thread safe +static inline VkLayerDebugMarkerDispatchTable *debug_marker_dispatch_table(VkObject object) +{ + VkLayerDebugMarkerDispatchTable *pDisp = *(VkLayerDebugMarkerDispatchTable **) object; + std::unordered_map<void *, VkLayerDebugMarkerDispatchTable *>::const_iterator it = tableDebugMarkerMap.find((void *) pDisp); + assert(it != tableDebugMarkerMap.end() && "Not able to find debug marker dispatch entry"); + return it->second; +} + diff --git a/layers/param_checker.cpp b/layers/param_checker.cpp index 15056f5a..771054e1 100644 --- a/layers/param_checker.cpp +++ b/layers/param_checker.cpp @@ -41,12 +41,15 @@ #include "loader_platform.h" #include "layers_msg.h" +#include "layers_debug_marker_table.h" static LOADER_PLATFORM_THREAD_ONCE_DECLARATION(initOnce); - +struct devExts { + bool debug_marker_enabled; +}; static std::unordered_map<void *, VkLayerDispatchTable *> tableMap; -static std::unordered_map<void *, VkLayerDebugMarkerDispatchTable *> tableDebugMarkerMap; static std::unordered_map<void *, VkLayerInstanceDispatchTable *> tableInstanceMap; +static std::unordered_map<void *, struct devExts> deviceExtMap; static inline VkLayerDispatchTable *device_dispatch_table(VkObject object) { VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) object; @@ -66,7 +69,6 @@ static inline VkLayerInstanceDispatchTable *instance_dispatch_table(VkObject obj static VkLayerDispatchTable * initDeviceTable(const VkBaseLayerObject *devw) { VkLayerDispatchTable *pTable; - VkLayerDebugMarkerDispatchTable *pDebugMarkerTable; assert(devw); VkLayerDispatchTable **ppDisp = (VkLayerDispatchTable **) (devw->baseObject); @@ -76,8 +78,6 @@ static VkLayerDispatchTable * initDeviceTable(const VkBaseLayerObject *devw) { pTable = new VkLayerDispatchTable; tableMap[(void *) *ppDisp] = pTable; - pDebugMarkerTable = new VkLayerDebugMarkerDispatchTable; - tableDebugMarkerMap[(void *) *ppDisp] = pDebugMarkerTable; } else { return it->second; @@ -85,13 +85,6 @@ static VkLayerDispatchTable * initDeviceTable(const VkBaseLayerObject *devw) layer_initialize_dispatch_table(pTable, devw); - VkDevice device = (VkDevice) devw->baseObject; - pDebugMarkerTable->CmdDbgMarkerBegin = (PFN_vkCmdDbgMarkerBegin) devw->pGPA(device, "vkCmdDbgMarkerBegin"); - pDebugMarkerTable->CmdDbgMarkerEnd = (PFN_vkCmdDbgMarkerEnd) devw->pGPA(device, "vkCmdDbgMarkerEnd"); - pDebugMarkerTable->DbgSetObjectTag = (PFN_vkDbgSetObjectTag) devw->pGPA(device, "vkDbgSetObjectTag"); - pDebugMarkerTable->DbgSetObjectName = (PFN_vkDbgSetObjectName) devw->pGPA(device, "vkDbgSetObjectName"); - pDebugMarkerTable->ext_enabled = false; - return pTable; } @@ -285,13 +278,14 @@ void PreCreateDevice(VkPhysicalDevice gpu, const VkDeviceCreateInfo* pCreateInfo static void createDeviceRegisterExtensions(const VkDeviceCreateInfo* pCreateInfo, VkDevice device) { uint32_t i, ext_idx; - VkLayerDebugMarkerDispatchTable *pDisp = *(VkLayerDebugMarkerDispatchTable **) device; - VkLayerDebugMarkerDispatchTable *pTable = tableDebugMarkerMap[pDisp]; - + VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) device; + deviceExtMap[pDisp].debug_marker_enabled = false; for (i = 0; i < pCreateInfo->extensionCount; i++) { if (strcmp(pCreateInfo->pEnabledExtensions[i].name, DEBUG_MARKER_EXTENSION_NAME) == 0) { - /* Found a matching extension name, mark it enabled */ - pTable->ext_enabled = true; + /* Found a matching extension name, mark it enabled and init dispatch table*/ + initDebugMarkerTable(device); + deviceExtMap[pDisp].debug_marker_enabled = true; + } } @@ -307,15 +301,15 @@ void PostCreateDevice(VkResult result, const VkDeviceCreateInfo *pCreateInfo, Vk return; } - enable_debug_report(pCreateInfo->extensionCount, pCreateInfo->pEnabledExtensions); - createDeviceRegisterExtensions(pCreateInfo, *pDevice); - if(pDevice == nullptr) { char const str[] = "vkCreateDevice parameter, VkDevice* pDevice, is nullptr (postcondition)."; layerCbMsg(VK_DBG_REPORT_INFO_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str); return; } + VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) *pDevice; + enable_debug_report(pCreateInfo->extensionCount, pCreateInfo->pEnabledExtensions); + createDeviceRegisterExtensions(pCreateInfo, *pDevice); } VK_LAYER_EXPORT VkResult VKAPI vkCreateDevice(VkPhysicalDevice gpu, const VkDeviceCreateInfo* pCreateInfo, VkDevice* pDevice) @@ -332,6 +326,8 @@ VK_LAYER_EXPORT VkResult VKAPI vkDestroyDevice(VkDevice device) VkLayerDispatchTable *pTable = tableMap[pDisp]; VkResult result = pTable->DestroyDevice(device); tableMap.erase(pDisp); + tableDebugMarkerMap.erase(pDisp); + deviceExtMap.erase(pDisp); return result; } @@ -393,6 +389,7 @@ VK_LAYER_EXPORT VkResult VKAPI vkGetPhysicalDeviceExtensionInfo( size_t* pDataSize, void* pData) { + //TODO add debug_marker /* This entrypoint is NOT going to init it's own dispatch table since loader calls here early */ uint32_t *count; @@ -1946,47 +1943,46 @@ VK_LAYER_EXPORT VkResult VKAPI vkDbgDestroyMsgCallback( VK_LAYER_EXPORT void VKAPI vkCmdDbgMarkerBegin(VkCmdBuffer cmdBuffer, const char* pMarker) { - VkLayerDebugMarkerDispatchTable *pDisp = *(VkLayerDebugMarkerDispatchTable **) cmdBuffer; - VkLayerDebugMarkerDispatchTable *pTable = tableDebugMarkerMap[pDisp]; - if (!pTable->ext_enabled) { + VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) cmdBuffer; + if (!deviceExtMap[pDisp].debug_marker_enabled) { char const str[] = "Attempt to use CmdDbgMarkerBegin but extension disabled!"; layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str); + return; } - pTable->CmdDbgMarkerBegin(cmdBuffer, pMarker); + debug_marker_dispatch_table(cmdBuffer)->CmdDbgMarkerBegin(cmdBuffer, pMarker); } VK_LAYER_EXPORT void VKAPI vkCmdDbgMarkerEnd(VkCmdBuffer cmdBuffer) { - VkLayerDebugMarkerDispatchTable *pDisp = *(VkLayerDebugMarkerDispatchTable **) cmdBuffer; - VkLayerDebugMarkerDispatchTable *pTable = tableDebugMarkerMap[pDisp]; - if (!pTable->ext_enabled) { + VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) cmdBuffer; + if (!deviceExtMap[pDisp].debug_marker_enabled) { char const str[] = "Attempt to use CmdDbgMarkerEnd but extension disabled!"; layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str); + return; } - pTable->CmdDbgMarkerEnd(cmdBuffer); + debug_marker_dispatch_table(cmdBuffer)->CmdDbgMarkerEnd(cmdBuffer); } VkResult VKAPI vkDbgSetObjectTag(VkDevice device, VkObjectType objType, VkObject object, size_t tagSize, const void* pTag) { - VkLayerDebugMarkerDispatchTable *pDisp = *(VkLayerDebugMarkerDispatchTable **) device; - VkLayerDebugMarkerDispatchTable *pTable = tableDebugMarkerMap[pDisp]; - if (!pTable->ext_enabled) { + VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) device; + if (!deviceExtMap[pDisp].debug_marker_enabled) { char const str[] = "Attempt to use DbgSetObjectTag but extension disabled!"; layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str); + return VK_ERROR_UNAVAILABLE; } - pTable->DbgSetObjectTag(device, objType, object, tagSize, pTag); + debug_marker_dispatch_table(device)->DbgSetObjectTag(device, objType, object, tagSize, pTag); } VkResult VKAPI vkDbgSetObjectName(VkDevice device, VkObjectType objType, VkObject object, size_t nameSize, const char* pName) { - VkLayerDebugMarkerDispatchTable *pDisp = *(VkLayerDebugMarkerDispatchTable **) device; - VkLayerDebugMarkerDispatchTable *pTable = tableDebugMarkerMap[pDisp]; - - if (!pTable->ext_enabled) { + VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) device; + if (!deviceExtMap[pDisp].debug_marker_enabled) { char const str[] = "Attempt to use DbgSetObjectName but extension disabled!"; layerCbMsg(VK_DBG_REPORT_ERROR_BIT, (VkObjectType) 0, NULL, 0, 1, "PARAMCHECK", str); + return VK_ERROR_UNAVAILABLE; } - pTable->DbgSetObjectName(device, objType, object, nameSize, pName); + debug_marker_dispatch_table(device)->DbgSetObjectName(device, objType, object, nameSize, pName); } VK_LAYER_EXPORT VkResult VKAPI vkGetDisplayInfoWSI(VkDisplayWSI display, VkDisplayInfoTypeWSI infoType, size_t* pDataSize, void* pData) @@ -2223,10 +2219,6 @@ static inline void* layer_intercept_proc(const char *name) return (void*) vkCmdBeginRenderPass; if (!strcmp(name, "CmdEndRenderPass")) return (void*) vkCmdEndRenderPass; - if (!strcmp(name, "CmdDbgMarkerBegin")) - return (void*) vkCmdDbgMarkerBegin; - if (!strcmp(name, "CmdDbgMarkerEnd")) - return (void*) vkCmdDbgMarkerEnd; if (!strcmp(name, "GetDisplayInfoWSI")) return (void*) vkGetDisplayInfoWSI; if (!strcmp(name, "CreateSwapChainWSI")) @@ -2284,7 +2276,20 @@ VK_LAYER_EXPORT void* VKAPI vkGetDeviceProcAddr(VkDevice device, const char* fun if (addr) { return addr; } - else { + + VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) device; + if (!deviceExtMap[pDisp].debug_marker_enabled) + { + if (!strcmp(funcName, "CmdDbgMarkerBegin")) + return (void*) vkCmdDbgMarkerBegin; + if (!strcmp(funcName, "CmdDbgMarkerEnd")) + return (void*) vkCmdDbgMarkerEnd; + if (!strcmp(funcName, "DbgSetObjectTag")) + return (void*) vkDbgSetObjectTag; + if (!strcmp(funcName, "DbgSetObjectName")) + return (void*) vkDbgSetObjectName; + } + { VkLayerDispatchTable **ppDisp = (VkLayerDispatchTable **) device; VkLayerDispatchTable* pTable = tableMap[*ppDisp]; if (pTable->GetDeviceProcAddr == NULL) |
