aboutsummaryrefslogtreecommitdiff
path: root/layers/basic.cpp
diff options
context:
space:
mode:
authorJon Ashburn <jon@lunarg.com>2015-05-19 16:34:53 -0600
committerCourtney Goeltzenleuchter <courtney@LunarG.com>2015-06-17 19:47:02 -0600
commit35103349325efcf48b3b28862776027b7edc6903 (patch)
tree85fca0115418c0d6ce2ff425ca587784766fbfa9 /layers/basic.cpp
parenta8424a2f91bec8712bbfb0d102b5fa40a8f58fb1 (diff)
downloadusermoji-35103349325efcf48b3b28862776027b7edc6903.tar.xz
layers: Add DestroyDevice and DestroyInstance hooking to deinitialize tables
Table maps need to get cleaned up at DestroyInstance and DestroyDevice
Diffstat (limited to 'layers/basic.cpp')
-rw-r--r--layers/basic.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/layers/basic.cpp b/layers/basic.cpp
index 0d24876d..f5edf7c0 100644
--- a/layers/basic.cpp
+++ b/layers/basic.cpp
@@ -166,6 +166,26 @@ VK_LAYER_EXPORT VkResult VKAPI vkCreateDevice(VkPhysicalDevice gpu, const VkDevi
return result;
}
+/* hook DestroyDevice to remove tableMap entry */
+VK_LAYER_EXPORT VkResult VKAPI vkDestroyDevice(VkDevice device)
+{
+ VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) device;
+ VkLayerDispatchTable *pTable = tableMap[pDisp];
+ VkResult res = pTable->DestroyDevice(device);
+ tableMap.erase(pDisp);
+ return res;
+}
+
+/* hook DestroyInstance to remove tableInstanceMap entry */
+VK_LAYER_EXPORT VkResult VKAPI vkDestroyInstance(VkInstance instance)
+{
+ VkLayerInstanceDispatchTable *pDisp = *(VkLayerInstanceDispatchTable **) instance;
+ VkLayerInstanceDispatchTable *pTable = tableInstanceMap[pDisp];
+ VkResult res = pTable->DestroyInstance(instance);
+ tableInstanceMap.erase(pDisp);
+ return res;
+}
+
VK_LAYER_EXPORT VkResult VKAPI vkGetFormatInfo(VkDevice device, VkFormat format, VkFormatInfoType infoType, size_t* pDataSize, void* pData)
{
VkLayerDispatchTable **ppDisp = (VkLayerDispatchTable **) device;
@@ -221,6 +241,8 @@ VK_LAYER_EXPORT void * VKAPI vkGetDeviceProcAddr(VkDevice device, const char* pN
return (void *) vkGetDeviceProcAddr;
if (!strcmp("vkGetFormatInfo", pName))
return (void *) vkGetFormatInfo;
+ if (!strcmp("vkDestroyDevice", pName))
+ return (void *) vkDestroyDevice;
if (!strcmp("vkLayerExtension1", pName))
return (void *) vkLayerExtension1;
else {
@@ -240,6 +262,8 @@ VK_LAYER_EXPORT void * VKAPI vkGetInstanceProcAddr(VkInstance instance, const ch
if (!strcmp("vkGetInstanceProcAddr", pName))
return (void *) vkGetInstanceProcAddr;
+ if (!strcmp("vkDestroyInstance", pName))
+ return (void *) vkDestroyInstance;
if (!strcmp("vkEnumeratePhysicalDevices", pName))
return (void*) vkEnumeratePhysicalDevices;
if (!strcmp("vkGetGlobalExtensionInfo", pName))