From 032d0fc6f9e67210884921f7973a4686ae426f3c Mon Sep 17 00:00:00 2001 From: Courtney Goeltzenleuchter Date: Sun, 14 Jun 2015 12:03:26 -0600 Subject: mem_tracker: add per-instance persistent data --- layers/layers_table.cpp | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) (limited to 'layers/layers_table.cpp') diff --git a/layers/layers_table.cpp b/layers/layers_table.cpp index 03499a94..da28be98 100644 --- a/layers/layers_table.cpp +++ b/layers/layers_table.cpp @@ -25,8 +25,9 @@ #include #include "vk_dispatch_table_helper.h" #include "vkLayer.h" -std::unordered_map tableMap; -std::unordered_map tableInstanceMap; +#include "layers_table.h" +device_table_map tableMap; +instance_table_map tableInstanceMap; /* Various dispatchable objects will use the same underlying dispatch table if they @@ -36,17 +37,17 @@ std::unordered_map tableInstanceMap; * 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 */ -VkLayerInstanceDispatchTable * initInstanceTable(const VkBaseLayerObject *instancew) +VkLayerInstanceDispatchTable * initInstanceTable(instance_table_map &map, const VkBaseLayerObject *instancew) { VkLayerInstanceDispatchTable *pTable; assert(instancew); VkLayerInstanceDispatchTable **ppDisp = (VkLayerInstanceDispatchTable **) instancew->baseObject; - std::unordered_map::const_iterator it = tableInstanceMap.find((void *) *ppDisp); + std::unordered_map::const_iterator it = map.find((void *) *ppDisp); if (it == tableInstanceMap.end()) { pTable = new VkLayerInstanceDispatchTable; - tableInstanceMap[(void *) *ppDisp] = pTable; + map[(void *) *ppDisp] = pTable; } else { return it->second; @@ -57,23 +58,35 @@ VkLayerInstanceDispatchTable * initInstanceTable(const VkBaseLayerObject *instan return pTable; } -VkLayerDispatchTable * initDeviceTable(const VkBaseLayerObject *devw) +VkLayerInstanceDispatchTable * initInstanceTable(const VkBaseLayerObject *instancew) +{ + return initInstanceTable(tableInstanceMap, instancew); +} + +VkLayerDispatchTable * initDeviceTable(device_table_map &map, const VkBaseLayerObject *devw) { - VkLayerDispatchTable *pTable; + VkLayerDispatchTable *layer_device_table = NULL; assert(devw); VkLayerDispatchTable **ppDisp = (VkLayerDispatchTable **) (devw->baseObject); + VkLayerDispatchTable *base_device_table = *ppDisp; - std::unordered_map::const_iterator it = tableMap.find((void *) *ppDisp); + std::unordered_map::const_iterator it = map.find((void *) base_device_table); if (it == tableMap.end()) { - pTable = new VkLayerDispatchTable; - tableMap[(void *) *ppDisp] = pTable; + layer_device_table = new VkLayerDispatchTable; + map[(void *) base_device_table] = layer_device_table; + fprintf(stderr, "initDeviceTable(%p): %p => %p\n", devw, base_device_table, layer_device_table); } else { return it->second; } - layer_initialize_dispatch_table(pTable, devw); + layer_initialize_dispatch_table(layer_device_table, devw); - return pTable; + return layer_device_table; +} + +VkLayerDispatchTable * initDeviceTable(const VkBaseLayerObject *devw) +{ + return initDeviceTable(tableMap, devw); } -- cgit v1.2.3