diff options
| author | Courtney Goeltzenleuchter <courtney@LunarG.com> | 2015-06-14 12:03:26 -0600 |
|---|---|---|
| committer | Courtney Goeltzenleuchter <courtney@LunarG.com> | 2015-06-18 10:22:55 -0600 |
| commit | 032d0fc6f9e67210884921f7973a4686ae426f3c (patch) | |
| tree | f6ce57c3a188ae2dd68d590711e66529c0d8a2a4 /layers/layers_table.cpp | |
| parent | d8b43b42c12d931bed5c97fd6866369b190a3c5a (diff) | |
| download | usermoji-032d0fc6f9e67210884921f7973a4686ae426f3c.tar.xz | |
mem_tracker: add per-instance persistent data
Diffstat (limited to 'layers/layers_table.cpp')
| -rw-r--r-- | layers/layers_table.cpp | 37 |
1 files changed, 25 insertions, 12 deletions
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 <unordered_map> #include "vk_dispatch_table_helper.h" #include "vkLayer.h" -std::unordered_map<void *, VkLayerDispatchTable *> tableMap; -std::unordered_map<void *, VkLayerInstanceDispatchTable *> 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<void *, VkLayerInstanceDispatchTable *> 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<void *, VkLayerInstanceDispatchTable *>::const_iterator it = tableInstanceMap.find((void *) *ppDisp); + std::unordered_map<void *, VkLayerInstanceDispatchTable *>::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<void *, VkLayerDispatchTable *>::const_iterator it = tableMap.find((void *) *ppDisp); + std::unordered_map<void *, VkLayerDispatchTable *>::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); } |
