aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Ashburn <jon@lunarg.com>2015-06-01 10:02:09 -0600
committerCourtney Goeltzenleuchter <courtney@LunarG.com>2015-06-18 10:18:20 -0600
commit9e4ff10ead3cda563265f5e5298eb6e32a4b2819 (patch)
tree45c8ba1e5581f0903139d0198d8d56eed36e657f
parentcf99decc751668b995be63f15b0c29a677a6f494 (diff)
downloadusermoji-9e4ff10ead3cda563265f5e5298eb6e32a4b2819.tar.xz
layers: Make dispatch table thread safe
-rw-r--r--layers/CMakeLists.txt18
-rw-r--r--layers/basic.cpp91
-rw-r--r--layers/draw_state.cpp300
-rw-r--r--layers/layers_table.cpp79
-rw-r--r--layers/layers_table.h48
-rw-r--r--layers/mem_tracker.cpp75
-rw-r--r--layers/multi.cpp76
-rw-r--r--layers/param_checker.cpp78
-rw-r--r--layers/shader_checker.cpp76
-rwxr-xr-xvk-layer-generate.py161
10 files changed, 302 insertions, 700 deletions
diff --git a/layers/CMakeLists.txt b/layers/CMakeLists.txt
index 883d880c..d87692f5 100644
--- a/layers/CMakeLists.txt
+++ b/layers/CMakeLists.txt
@@ -95,14 +95,14 @@ if (WIN32)
target_link_libraries(layer_utils)
endif()
-add_vk_layer(Basic basic.cpp)
+add_vk_layer(Basic basic.cpp layers_table.cpp)
add_vk_layer(Multi multi.cpp)
-add_vk_layer(DrawState draw_state.cpp)
-add_vk_layer(MemTracker mem_tracker.cpp)
-add_vk_layer(ShaderChecker shader_checker.cpp)
+add_vk_layer(DrawState draw_state.cpp layers_debug_marker_table.cpp layers_table.cpp)
+add_vk_layer(MemTracker mem_tracker.cpp layers_table.cpp)
+add_vk_layer(ShaderChecker shader_checker.cpp layers_table.cpp)
# generated
-add_vk_layer(Generic generic_layer.cpp)
-add_vk_layer(APIDump api_dump.cpp)
-add_vk_layer(ObjectTracker object_track.cpp)
-add_vk_layer(ParamChecker param_checker.cpp)
-add_vk_layer(Threading threading.cpp)
+add_vk_layer(Generic generic_layer.cpp layers_table.cpp)
+add_vk_layer(APIDump api_dump.cpp layers_table.cpp)
+add_vk_layer(ObjectTracker object_track.cpp layers_table.cpp)
+add_vk_layer(ParamChecker param_checker.cpp layers_debug_marker_table.cpp layers_table.cpp)
+add_vk_layer(Threading threading.cpp layers_table.cpp)
diff --git a/layers/basic.cpp b/layers/basic.cpp
index 1ba3188e..81cdaa8b 100644
--- a/layers/basic.cpp
+++ b/layers/basic.cpp
@@ -24,65 +24,14 @@
#include <string.h>
#include <stdlib.h>
#include <assert.h>
-#include <unordered_map>
#include "loader_platform.h"
#include "vk_dispatch_table_helper.h"
#include "vkLayer.h"
+#include "layers_table.h"
// The following is #included again to catch certain OS-specific functions
// being used:
#include "loader_platform.h"
-static std::unordered_map<void *, VkLayerDispatchTable *> tableMap;
-static std::unordered_map<void *, VkLayerInstanceDispatchTable *> tableInstanceMap;
-
-/* 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 */
-static VkLayerInstanceDispatchTable * initLayerInstanceTable(const VkBaseLayerObject *instancew)
-{
- VkLayerInstanceDispatchTable *pTable;
- assert(instancew);
- VkLayerInstanceDispatchTable **ppDisp = (VkLayerInstanceDispatchTable **) instancew->baseObject;
-
- std::unordered_map<void *, VkLayerInstanceDispatchTable *>::const_iterator it = tableInstanceMap.find((void *) *ppDisp);
- if (it == tableInstanceMap.end())
- {
- pTable = new VkLayerInstanceDispatchTable;
- tableInstanceMap[(void *) *ppDisp] = pTable;
- } else
- {
- return it->second;
- }
-
- layer_init_instance_dispatch_table(pTable, instancew);
-
- return pTable;
-}
-
-static VkLayerDispatchTable * initLayerTable(const VkBaseLayerObject *devw)
-{
- VkLayerDispatchTable *pTable;
- assert(devw);
- VkLayerDispatchTable **ppDisp = (VkLayerDispatchTable **) (devw->baseObject);
-
- std::unordered_map<void *, VkLayerDispatchTable *>::const_iterator it = tableMap.find((void *) *ppDisp);
- if (it == tableMap.end())
- {
- pTable = new VkLayerDispatchTable;
- tableMap[(void *) *ppDisp] = pTable;
- } else
- {
- return it->second;
- }
-
- layer_initialize_dispatch_table(pTable, devw);
-
- return pTable;
-}
VK_LAYER_EXPORT VkResult VKAPI vkLayerExtension1(VkDevice device)
{
@@ -152,21 +101,16 @@ VK_LAYER_EXPORT VkResult VKAPI vkEnumeratePhysicalDevices(
uint32_t* pPhysicalDeviceCount,
VkPhysicalDevice* pPhysicalDevices)
{
- VkLayerInstanceDispatchTable **ppDisp = (VkLayerInstanceDispatchTable **) instance;
- VkLayerInstanceDispatchTable *pInstTable = tableInstanceMap[*ppDisp];
printf("At start of wrapped vkEnumeratePhysicalDevices() call w/ inst: %p\n", (void*)instance);
- VkResult result = pInstTable->EnumeratePhysicalDevices(instance, pPhysicalDeviceCount, pPhysicalDevices);
+ VkResult result = instance_dispatch_table(instance)->EnumeratePhysicalDevices(instance, pPhysicalDeviceCount, pPhysicalDevices);
printf("Completed wrapped vkEnumeratePhysicalDevices() call w/ count %u\n", *pPhysicalDeviceCount);
return result;
}
VK_LAYER_EXPORT VkResult VKAPI vkCreateDevice(VkPhysicalDevice gpu, const VkDeviceCreateInfo* pCreateInfo, VkDevice* pDevice)
{
- VkLayerInstanceDispatchTable **ppDisp = (VkLayerInstanceDispatchTable **) gpu;
- VkLayerInstanceDispatchTable* pInstTable = tableInstanceMap[*ppDisp];
-
printf("At start of wrapped vkCreateDevice() call w/ gpu: %p\n", (void*)gpu);
- VkResult result = pInstTable->CreateDevice(gpu, pCreateInfo, pDevice);
+ VkResult result = instance_dispatch_table(gpu)->CreateDevice(gpu, pCreateInfo, pDevice);
printf("Completed wrapped vkCreateDevice() call w/ pDevice, Device %p: %p\n", (void*)pDevice, (void *) *pDevice);
return result;
}
@@ -175,8 +119,7 @@ VK_LAYER_EXPORT VkResult VKAPI vkCreateDevice(VkPhysicalDevice gpu, const VkDevi
VK_LAYER_EXPORT VkResult VKAPI vkDestroyDevice(VkDevice device)
{
VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) device;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- VkResult res = pTable->DestroyDevice(device);
+ VkResult res = device_dispatch_table(device)->DestroyDevice(device);
tableMap.erase(pDisp);
return res;
}
@@ -184,20 +127,16 @@ VK_LAYER_EXPORT VkResult VKAPI vkDestroyDevice(VkDevice device)
/* 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);
+ VkLayerInstanceDispatchTable *pDisp = *(VkLayerInstanceDispatchTable **) instance;
+ VkResult res = instance_dispatch_table(instance)->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;
- VkLayerDispatchTable* pTable = tableMap[*ppDisp];
-
printf("At start of wrapped vkGetFormatInfo() call w/ device: %p\n", (void*)device);
- VkResult result = pTable->GetFormatInfo(device, format, infoType, pDataSize, pData);
+ VkResult result = device_dispatch_table(device)->GetFormatInfo(device, format, infoType, pDataSize, pData);
printf("Completed wrapped vkGetFormatInfo() call w/ device: %p\n", (void*)device);
return result;
}
@@ -209,7 +148,7 @@ VK_LAYER_EXPORT void * VKAPI vkGetDeviceProcAddr(VkDevice device, const char* pN
/* loader uses this to force layer initialization; device object is wrapped */
if (!strcmp("vkGetDeviceProcAddr", pName)) {
- initLayerTable((const VkBaseLayerObject *) device);
+ initDeviceTable((const VkBaseLayerObject *) device);
return (void *) vkGetDeviceProcAddr;
}
@@ -221,11 +160,9 @@ VK_LAYER_EXPORT void * VKAPI vkGetDeviceProcAddr(VkDevice device, const char* pN
return (void *) vkLayerExtension1;
else
{
- VkLayerDispatchTable **ppDisp = (VkLayerDispatchTable **) device;
- VkLayerDispatchTable* pTable = tableMap[*ppDisp];
- if (pTable->GetDeviceProcAddr == NULL)
+ if (device_dispatch_table(device)->GetDeviceProcAddr == NULL)
return NULL;
- return pTable->GetDeviceProcAddr(device, pName);
+ return device_dispatch_table(device)->GetDeviceProcAddr(device, pName);
}
}
@@ -236,7 +173,7 @@ VK_LAYER_EXPORT void * VKAPI vkGetInstanceProcAddr(VkInstance instance, const ch
/* loader uses this to force layer initialization; instance object is wrapped */
if (!strcmp("vkGetInstanceProcAddr", pName)) {
- initLayerInstanceTable((const VkBaseLayerObject *) instance);
+ initInstanceTable((const VkBaseLayerObject *) instance);
return (void *) vkGetInstanceProcAddr;
}
@@ -250,11 +187,9 @@ VK_LAYER_EXPORT void * VKAPI vkGetInstanceProcAddr(VkInstance instance, const ch
return (void *) vkCreateDevice;
else
{
- VkLayerInstanceDispatchTable **ppDisp = (VkLayerInstanceDispatchTable **) instance;
- VkLayerInstanceDispatchTable* pTable = tableInstanceMap[*ppDisp];
- if (pTable->GetInstanceProcAddr == NULL)
+ if (instance_dispatch_table(instance)->GetInstanceProcAddr == NULL)
return NULL;
- return pTable->GetInstanceProcAddr(instance, pName);
+ return instance_dispatch_table(instance)->GetInstanceProcAddr(instance, pName);
}
}
diff --git a/layers/draw_state.cpp b/layers/draw_state.cpp
index 65401950..41789730 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_table.h"
#include "layers_debug_marker_table.h"
unordered_map<VkSampler, SAMPLER_NODE*> sampleMap;
@@ -64,8 +65,6 @@ struct devExts {
bool debug_marker_enabled;
};
-static std::unordered_map<void *, VkLayerDispatchTable *> tableMap;
-static std::unordered_map<void *, VkLayerInstanceDispatchTable *> tableInstanceMap;
static std::unordered_map<void *, struct devExts> deviceExtMap;
static LOADER_PLATFORM_THREAD_ONCE_DECLARATION(g_initOnce);
@@ -1447,50 +1446,6 @@ static void synchAndPrintDSConfig(const VkCmdBuffer cb)
}
}
-static VkLayerDispatchTable * initDeviceTable(const VkBaseLayerObject *devw)
-{
- VkLayerDispatchTable *pTable;
-
- assert(devw);
- VkLayerDispatchTable **ppDisp = (VkLayerDispatchTable **) (devw->baseObject);
-
- std::unordered_map<void *, VkLayerDispatchTable *>::const_iterator it = tableMap.find((void *) *ppDisp);
- if (it == tableMap.end())
- {
- pTable = new VkLayerDispatchTable;
- tableMap[(void *) *ppDisp] = pTable;
-
- } else
- {
- return it->second;
- }
-
- layer_initialize_dispatch_table(pTable, devw);
-
- return pTable;
-}
-
-static VkLayerInstanceDispatchTable * initInstanceTable(const VkBaseLayerObject *instw)
-{
- VkLayerInstanceDispatchTable *pTable;
- assert(instw);
- VkLayerInstanceDispatchTable **ppDisp = (VkLayerInstanceDispatchTable **) instw->baseObject;
-
- std::unordered_map<void *, VkLayerInstanceDispatchTable *>::const_iterator it = tableInstanceMap.find((void *) *ppDisp);
- if (it == tableInstanceMap.end())
- {
- pTable = new VkLayerInstanceDispatchTable;
- tableInstanceMap[(void *) *ppDisp] = pTable;
- } else
- {
- return it->second;
- }
-
- layer_init_instance_dispatch_table(pTable, instw);
-
- return pTable;
-}
-
static void initDrawState(void)
{
const char *strOpt;
@@ -1545,8 +1500,7 @@ VK_LAYER_EXPORT VkResult VKAPI vkCreateInstance(const VkInstanceCreateInfo* pCre
VK_LAYER_EXPORT VkResult VKAPI vkDestroyInstance(VkInstance instance)
{
VkLayerInstanceDispatchTable *pDisp = *(VkLayerInstanceDispatchTable **) instance;
- VkLayerInstanceDispatchTable *pTable = tableInstanceMap[pDisp];
- VkResult res = pTable->DestroyInstance(instance);
+ VkResult res = instance_dispatch_table(instance)->DestroyInstance(instance);
tableInstanceMap.erase(pDisp);
return res;
}
@@ -1569,9 +1523,7 @@ static void createDeviceRegisterExtensions(const VkDeviceCreateInfo* pCreateInfo
VK_LAYER_EXPORT VkResult VKAPI vkCreateDevice(VkPhysicalDevice gpu, const VkDeviceCreateInfo* pCreateInfo, VkDevice* pDevice)
{
- VkLayerInstanceDispatchTable **ppDisp = (VkLayerInstanceDispatchTable **) gpu;
- VkLayerInstanceDispatchTable* pInstTable = tableInstanceMap[*ppDisp];
- VkResult result = pInstTable->CreateDevice(gpu, pCreateInfo, pDevice);
+ VkResult result = instance_dispatch_table(gpu)->CreateDevice(gpu, pCreateInfo, pDevice);
createDeviceRegisterExtensions(pCreateInfo, *pDevice);
return result;
}
@@ -1591,8 +1543,7 @@ VK_LAYER_EXPORT VkResult VKAPI vkDestroyDevice(VkDevice device)
loader_platform_thread_unlock_mutex(&globalLock);
VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) device;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- VkResult result = pTable->DestroyDevice(device);
+ VkResult result = device_dispatch_table(device)->DestroyDevice(device);
tableMap.erase(pDisp);
tableDebugMarkerMap.erase(pDisp);
deviceExtMap.erase(pDisp);
@@ -1673,26 +1624,20 @@ VK_LAYER_EXPORT VkResult VKAPI vkQueueSubmit(VkQueue queue, uint32_t cmdBufferCo
loader_platform_thread_unlock_mutex(&globalLock);
}
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) queue;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- VkResult result = pTable->QueueSubmit(queue, cmdBufferCount, pCmdBuffers, fence);
+ VkResult result = device_dispatch_table(queue)->QueueSubmit(queue, cmdBufferCount, pCmdBuffers, fence);
return result;
}
VK_LAYER_EXPORT VkResult VKAPI vkDestroyObject(VkDevice device, VkObjectType objType, VkObject object)
{
// TODO : When wrapped objects (such as dynamic state) are destroyed, need to clean up memory
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) device;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- VkResult result = pTable->DestroyObject(device, objType, object);
+ VkResult result = device_dispatch_table(device)->DestroyObject(device, objType, object);
return result;
}
VK_LAYER_EXPORT VkResult VKAPI vkCreateBufferView(VkDevice device, const VkBufferViewCreateInfo* pCreateInfo, VkBufferView* pView)
{
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) device;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- VkResult result = pTable->CreateBufferView(device, pCreateInfo, pView);
+ VkResult result = device_dispatch_table(device)->CreateBufferView(device, pCreateInfo, pView);
if (VK_SUCCESS == result) {
loader_platform_thread_lock_mutex(&globalLock);
BUFFER_NODE* pNewNode = new BUFFER_NODE;
@@ -1706,9 +1651,7 @@ VK_LAYER_EXPORT VkResult VKAPI vkCreateBufferView(VkDevice device, const VkBuffe
VK_LAYER_EXPORT VkResult VKAPI vkCreateImageView(VkDevice device, const VkImageViewCreateInfo* pCreateInfo, VkImageView* pView)
{
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) device;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- VkResult result = pTable->CreateImageView(device, pCreateInfo, pView);
+ VkResult result = device_dispatch_table(device)->CreateImageView(device, pCreateInfo, pView);
if (VK_SUCCESS == result) {
loader_platform_thread_lock_mutex(&globalLock);
IMAGE_NODE *pNewNode = new IMAGE_NODE;
@@ -1733,9 +1676,7 @@ static void track_pipeline(const VkGraphicsPipelineCreateInfo* pCreateInfo, VkPi
VK_LAYER_EXPORT VkResult VKAPI vkCreateGraphicsPipeline(VkDevice device, const VkGraphicsPipelineCreateInfo* pCreateInfo, VkPipeline* pPipeline)
{
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) device;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- VkResult result = pTable->CreateGraphicsPipeline(device, pCreateInfo, pPipeline);
+ VkResult result = device_dispatch_table(device)->CreateGraphicsPipeline(device, pCreateInfo, pPipeline);
// Create LL HEAD for this Pipeline
char str[1024];
sprintf(str, "Created Gfx Pipeline %p", (void*)*pPipeline);
@@ -1752,9 +1693,7 @@ VK_LAYER_EXPORT VkResult VKAPI vkCreateGraphicsPipelineDerivative(
VkPipeline basePipeline,
VkPipeline* pPipeline)
{
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) device;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- VkResult result = pTable->CreateGraphicsPipelineDerivative(device, pCreateInfo, basePipeline, pPipeline);
+ VkResult result = device_dispatch_table(device)->CreateGraphicsPipelineDerivative(device, pCreateInfo, basePipeline, pPipeline);
// Create LL HEAD for this Pipeline
char str[1024];
sprintf(str, "Created Gfx Pipeline %p (derived from pipeline %p)", (void*)*pPipeline, basePipeline);
@@ -1769,9 +1708,7 @@ VK_LAYER_EXPORT VkResult VKAPI vkCreateGraphicsPipelineDerivative(
VK_LAYER_EXPORT VkResult VKAPI vkCreateSampler(VkDevice device, const VkSamplerCreateInfo* pCreateInfo, VkSampler* pSampler)
{
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) device;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- VkResult result = pTable->CreateSampler(device, pCreateInfo, pSampler);
+ VkResult result = device_dispatch_table(device)->CreateSampler(device, pCreateInfo, pSampler);
if (VK_SUCCESS == result) {
loader_platform_thread_lock_mutex(&globalLock);
SAMPLER_NODE* pNewNode = new SAMPLER_NODE;
@@ -1785,9 +1722,7 @@ VK_LAYER_EXPORT VkResult VKAPI vkCreateSampler(VkDevice device, const VkSamplerC
VK_LAYER_EXPORT VkResult VKAPI vkCreateDescriptorSetLayout(VkDevice device, const VkDescriptorSetLayoutCreateInfo* pCreateInfo, VkDescriptorSetLayout* pSetLayout)
{
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) device;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- VkResult result = pTable->CreateDescriptorSetLayout(device, pCreateInfo, pSetLayout);
+ VkResult result = device_dispatch_table(device)->CreateDescriptorSetLayout(device, pCreateInfo, pSetLayout);
if (VK_SUCCESS == result) {
LAYOUT_NODE* pNewNode = new LAYOUT_NODE;
if (NULL == pNewNode) {
@@ -1833,9 +1768,7 @@ VK_LAYER_EXPORT VkResult VKAPI vkCreateDescriptorSetLayout(VkDevice device, cons
VkResult VKAPI vkCreatePipelineLayout(VkDevice device, const VkPipelineLayoutCreateInfo* pCreateInfo, VkPipelineLayout* pPipelineLayout)
{
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) device;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- VkResult result = pTable->CreatePipelineLayout(device, pCreateInfo, pPipelineLayout);
+ VkResult result = device_dispatch_table(device)->CreatePipelineLayout(device, pCreateInfo, pPipelineLayout);
if (VK_SUCCESS == result) {
// TODO : Need to capture the pipeline layout
}
@@ -1844,9 +1777,7 @@ VkResult VKAPI vkCreatePipelineLayout(VkDevice device, const VkPipelineLayoutCre
VK_LAYER_EXPORT VkResult VKAPI vkCreateDescriptorPool(VkDevice device, VkDescriptorPoolUsage poolUsage, uint32_t maxSets, const VkDescriptorPoolCreateInfo* pCreateInfo, VkDescriptorPool* pDescriptorPool)
{
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) device;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- VkResult result = pTable->CreateDescriptorPool(device, poolUsage, maxSets, pCreateInfo, pDescriptorPool);
+ VkResult result = device_dispatch_table(device)->CreateDescriptorPool(device, poolUsage, maxSets, pCreateInfo, pDescriptorPool);
if (VK_SUCCESS == result) {
// Insert this pool into Global Pool LL at head
char str[1024];
@@ -1883,9 +1814,7 @@ VK_LAYER_EXPORT VkResult VKAPI vkCreateDescriptorPool(VkDevice device, VkDescrip
VK_LAYER_EXPORT VkResult VKAPI vkResetDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool)
{
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) device;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- VkResult result = pTable->ResetDescriptorPool(device, descriptorPool);
+ VkResult result = device_dispatch_table(device)->ResetDescriptorPool(device, descriptorPool);
if (VK_SUCCESS == result) {
clearDescriptorPool(descriptorPool);
}
@@ -1894,9 +1823,7 @@ VK_LAYER_EXPORT VkResult VKAPI vkResetDescriptorPool(VkDevice device, VkDescript
VK_LAYER_EXPORT VkResult VKAPI vkAllocDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorSetUsage setUsage, uint32_t count, const VkDescriptorSetLayout* pSetLayouts, VkDescriptorSet* pDescriptorSets, uint32_t* pCount)
{
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) device;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- VkResult result = pTable->AllocDescriptorSets(device, descriptorPool, setUsage, count, pSetLayouts, pDescriptorSets, pCount);
+ VkResult result = device_dispatch_table(device)->AllocDescriptorSets(device, descriptorPool, setUsage, count, pSetLayouts, pDescriptorSets, pCount);
if ((VK_SUCCESS == result) || (*pCount > 0)) {
POOL_NODE *pPoolNode = getPoolNode(descriptorPool);
if (!pPoolNode) {
@@ -1950,63 +1877,49 @@ VK_LAYER_EXPORT void VKAPI vkClearDescriptorSets(VkDevice device, VkDescriptorPo
for (uint32_t i = 0; i < count; i++) {
clearDescriptorSet(pDescriptorSets[i]);
}
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) device;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- pTable->ClearDescriptorSets(device, descriptorPool, count, pDescriptorSets);
+ device_dispatch_table(device)->ClearDescriptorSets(device, descriptorPool, count, pDescriptorSets);
}
VK_LAYER_EXPORT VkResult VKAPI vkUpdateDescriptorSets(VkDevice device, uint32_t writeCount, const VkWriteDescriptorSet* pDescriptorWrites, uint32_t copyCount, const VkCopyDescriptorSet* pDescriptorCopies)
{
if (dsUpdate(VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, writeCount, pDescriptorWrites) &&
dsUpdate(VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET, copyCount, pDescriptorCopies)) {
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) device;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- return pTable->UpdateDescriptorSets(device, writeCount, pDescriptorWrites, copyCount, pDescriptorCopies);
+ return device_dispatch_table(device)->UpdateDescriptorSets(device, writeCount, pDescriptorWrites, copyCount, pDescriptorCopies);
}
return VK_ERROR_UNKNOWN;
}
VK_LAYER_EXPORT VkResult VKAPI vkCreateDynamicViewportState(VkDevice device, const VkDynamicVpStateCreateInfo* pCreateInfo, VkDynamicVpState* pState)
{
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) device;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- VkResult result = pTable->CreateDynamicViewportState(device, pCreateInfo, pState);
+ VkResult result = device_dispatch_table(device)->CreateDynamicViewportState(device, pCreateInfo, pState);
insertDynamicState(*pState, (GENERIC_HEADER*)pCreateInfo, VK_STATE_BIND_POINT_VIEWPORT);
return result;
}
VK_LAYER_EXPORT VkResult VKAPI vkCreateDynamicRasterState(VkDevice device, const VkDynamicRsStateCreateInfo* pCreateInfo, VkDynamicRsState* pState)
{
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) device;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- VkResult result = pTable->CreateDynamicRasterState(device, pCreateInfo, pState);
+ VkResult result = device_dispatch_table(device)->CreateDynamicRasterState(device, pCreateInfo, pState);
insertDynamicState(*pState, (GENERIC_HEADER*)pCreateInfo, VK_STATE_BIND_POINT_RASTER);
return result;
}
VK_LAYER_EXPORT VkResult VKAPI vkCreateDynamicColorBlendState(VkDevice device, const VkDynamicCbStateCreateInfo* pCreateInfo, VkDynamicCbState* pState)
{
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) device;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- VkResult result = pTable->CreateDynamicColorBlendState(device, pCreateInfo, pState);
+ VkResult result = device_dispatch_table(device)->CreateDynamicColorBlendState(device, pCreateInfo, pState);
insertDynamicState(*pState, (GENERIC_HEADER*)pCreateInfo, VK_STATE_BIND_POINT_COLOR_BLEND);
return result;
}
VK_LAYER_EXPORT VkResult VKAPI vkCreateDynamicDepthStencilState(VkDevice device, const VkDynamicDsStateCreateInfo* pCreateInfo, VkDynamicDsState* pState)
{
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) device;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- VkResult result = pTable->CreateDynamicDepthStencilState(device, pCreateInfo, pState);
+ VkResult result = device_dispatch_table(device)->CreateDynamicDepthStencilState(device, pCreateInfo, pState);
insertDynamicState(*pState, (GENERIC_HEADER*)pCreateInfo, VK_STATE_BIND_POINT_DEPTH_STENCIL);
return result;
}
VK_LAYER_EXPORT VkResult VKAPI vkCreateCommandBuffer(VkDevice device, const VkCmdBufferCreateInfo* pCreateInfo, VkCmdBuffer* pCmdBuffer)
{
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) device;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- VkResult result = pTable->CreateCommandBuffer(device, pCreateInfo, pCmdBuffer);
+ VkResult result = device_dispatch_table(device)->CreateCommandBuffer(device, pCreateInfo, pCmdBuffer);
if (VK_SUCCESS == result) {
loader_platform_thread_lock_mutex(&globalLock);
GLOBAL_CB_NODE* pCB = new GLOBAL_CB_NODE;
@@ -2024,9 +1937,7 @@ VK_LAYER_EXPORT VkResult VKAPI vkCreateCommandBuffer(VkDevice device, const VkCm
VK_LAYER_EXPORT VkResult VKAPI vkBeginCommandBuffer(VkCmdBuffer cmdBuffer, const VkCmdBufferBeginInfo* pBeginInfo)
{
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) cmdBuffer;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- VkResult result = pTable->BeginCommandBuffer(cmdBuffer, pBeginInfo);
+ VkResult result = device_dispatch_table(cmdBuffer)->BeginCommandBuffer(cmdBuffer, pBeginInfo);
if (VK_SUCCESS == result) {
GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
if (pCB) {
@@ -2052,9 +1963,7 @@ VK_LAYER_EXPORT VkResult VKAPI vkBeginCommandBuffer(VkCmdBuffer cmdBuffer, const
VK_LAYER_EXPORT VkResult VKAPI vkEndCommandBuffer(VkCmdBuffer cmdBuffer)
{
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) cmdBuffer;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- VkResult result = pTable->EndCommandBuffer(cmdBuffer);
+ VkResult result = device_dispatch_table(cmdBuffer)->EndCommandBuffer(cmdBuffer);
if (VK_SUCCESS == result) {
GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
if (pCB) {
@@ -2076,9 +1985,7 @@ VK_LAYER_EXPORT VkResult VKAPI vkEndCommandBuffer(VkCmdBuffer cmdBuffer)
VK_LAYER_EXPORT VkResult VKAPI vkResetCommandBuffer(VkCmdBuffer cmdBuffer)
{
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) cmdBuffer;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- VkResult result = pTable->ResetCommandBuffer(cmdBuffer);
+ VkResult result = device_dispatch_table(cmdBuffer)->ResetCommandBuffer(cmdBuffer);
if (VK_SUCCESS == result) {
resetCB(cmdBuffer);
updateCBTracking(cmdBuffer);
@@ -2099,9 +2006,7 @@ VK_LAYER_EXPORT void VKAPI vkCmdBindPipeline(VkCmdBuffer cmdBuffer, VkPipelineBi
g_lastBoundPipeline = pPN;
loader_platform_thread_unlock_mutex(&globalLock);
validatePipelineState(pCB, pipelineBindPoint, pipeline);
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) cmdBuffer;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- pTable->CmdBindPipeline(cmdBuffer, pipelineBindPoint, pipeline);
+ device_dispatch_table(cmdBuffer)->CmdBindPipeline(cmdBuffer, pipelineBindPoint, pipeline);
}
else {
char str[1024];
@@ -2119,9 +2024,7 @@ VK_LAYER_EXPORT void VKAPI vkCmdBindPipeline(VkCmdBuffer cmdBuffer, VkPipelineBi
VK_LAYER_EXPORT void VKAPI vkCmdBindDynamicStateObject(VkCmdBuffer cmdBuffer, VkStateBindPoint stateBindPoint, VkDynamicStateObject state)
{
setLastBoundDynamicState(cmdBuffer, state, stateBindPoint);
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) cmdBuffer;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- pTable->CmdBindDynamicStateObject(cmdBuffer, stateBindPoint, state);
+ device_dispatch_table(cmdBuffer)->CmdBindDynamicStateObject(cmdBuffer, stateBindPoint, state);
}
VK_LAYER_EXPORT void VKAPI vkCmdBindDescriptorSets(VkCmdBuffer cmdBuffer, VkPipelineBindPoint pipelineBindPoint, uint32_t firstSet, uint32_t setCount, const VkDescriptorSet* pDescriptorSets, uint32_t dynamicOffsetCount, const uint32_t* pDynamicOffsets)
@@ -2148,9 +2051,7 @@ VK_LAYER_EXPORT void VKAPI vkCmdBindDescriptorSets(VkCmdBuffer cmdBuffer, VkPipe
layerCbMsg(VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_DESCRIPTOR_SET, pDescriptorSets[i], 0, DRAWSTATE_INVALID_SET, "DS", str);
}
}
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) cmdBuffer;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- pTable->CmdBindDescriptorSets(cmdBuffer, pipelineBindPoint, firstSet, setCount, pDescriptorSets, dynamicOffsetCount, pDynamicOffsets);
+ device_dispatch_table(cmdBuffer)->CmdBindDescriptorSets(cmdBuffer, pipelineBindPoint, firstSet, setCount, pDescriptorSets, dynamicOffsetCount, pDynamicOffsets);
}
}
else {
@@ -2173,9 +2074,7 @@ VK_LAYER_EXPORT void VKAPI vkCmdBindIndexBuffer(VkCmdBuffer cmdBuffer, VkBuffer
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);
}
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) cmdBuffer;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- pTable->CmdBindIndexBuffer(cmdBuffer, buffer, offset, indexType);
+ device_dispatch_table(cmdBuffer)->CmdBindIndexBuffer(cmdBuffer, buffer, offset, indexType);
}
VK_LAYER_EXPORT void VKAPI vkCmdBindVertexBuffers(
@@ -2192,9 +2091,7 @@ VK_LAYER_EXPORT void VKAPI vkCmdBindVertexBuffers(
addCmd(pCB, CMD_BINDVERTEXBUFFER);
pCB->lastVtxBinding = startBinding + bindingCount -1;
if (validateBoundPipeline(cmdBuffer)) {
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) cmdBuffer;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- pTable->CmdBindVertexBuffers(cmdBuffer, startBinding, bindingCount, pBuffers, pOffsets);
+ device_dispatch_table(cmdBuffer)->CmdBindVertexBuffers(cmdBuffer, startBinding, bindingCount, pBuffers, pOffsets);
}
} else {
char str[1024];
@@ -2225,9 +2122,7 @@ VK_LAYER_EXPORT void VKAPI vkCmdDraw(VkCmdBuffer cmdBuffer, uint32_t firstVertex
layerCbMsg(VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str);
}
if (valid) {
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) cmdBuffer;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- pTable->CmdDraw(cmdBuffer, firstVertex, vertexCount, firstInstance, instanceCount);
+ device_dispatch_table(cmdBuffer)->CmdDraw(cmdBuffer, firstVertex, vertexCount, firstInstance, instanceCount);
}
}
@@ -2253,9 +2148,7 @@ VK_LAYER_EXPORT void VKAPI vkCmdDrawIndexed(VkCmdBuffer cmdBuffer, uint32_t firs
layerCbMsg(VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str);
}
if (valid) {
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) cmdBuffer;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- pTable->CmdDrawIndexed(cmdBuffer, firstIndex, indexCount, vertexOffset, firstInstance, instanceCount);
+ device_dispatch_table(cmdBuffer)->CmdDrawIndexed(cmdBuffer, firstIndex, indexCount, vertexOffset, firstInstance, instanceCount);
}
}
@@ -2281,9 +2174,7 @@ VK_LAYER_EXPORT void VKAPI vkCmdDrawIndirect(VkCmdBuffer cmdBuffer, VkBuffer buf
layerCbMsg(VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str);
}
if (valid) {
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) cmdBuffer;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- pTable->CmdDrawIndirect(cmdBuffer, buffer, offset, count, stride);
+ device_dispatch_table(cmdBuffer)->CmdDrawIndirect(cmdBuffer, buffer, offset, count, stride);
}
}
@@ -2309,9 +2200,7 @@ VK_LAYER_EXPORT void VKAPI vkCmdDrawIndexedIndirect(VkCmdBuffer cmdBuffer, VkBuf
layerCbMsg(VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str);
}
if (valid) {
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) cmdBuffer;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- pTable->CmdDrawIndexedIndirect(cmdBuffer, buffer, offset, count, stride);
+ device_dispatch_table(cmdBuffer)->CmdDrawIndexedIndirect(cmdBuffer, buffer, offset, count, stride);
}
}
@@ -2327,9 +2216,7 @@ VK_LAYER_EXPORT void VKAPI vkCmdDispatch(VkCmdBuffer cmdBuffer, uint32_t x, uint
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);
}
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) cmdBuffer;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- pTable->CmdDispatch(cmdBuffer, x, y, z);
+ device_dispatch_table(cmdBuffer)->CmdDispatch(cmdBuffer, x, y, z);
}
VK_LAYER_EXPORT void VKAPI vkCmdDispatchIndirect(VkCmdBuffer cmdBuffer, VkBuffer buffer, VkDeviceSize offset)
@@ -2344,9 +2231,7 @@ VK_LAYER_EXPORT void VKAPI vkCmdDispatchIndirect(VkCmdBuffer cmdBuffer, VkBuffer
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);
}
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) cmdBuffer;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- pTable->CmdDispatchIndirect(cmdBuffer, buffer, offset);
+ device_dispatch_table(cmdBuffer)->CmdDispatchIndirect(cmdBuffer, buffer, offset);
}
VK_LAYER_EXPORT void VKAPI vkCmdCopyBuffer(VkCmdBuffer cmdBuffer, VkBuffer srcBuffer, VkBuffer destBuffer, uint32_t regionCount, const VkBufferCopy* pRegions)
@@ -2361,9 +2246,7 @@ VK_LAYER_EXPORT void VKAPI vkCmdCopyBuffer(VkCmdBuffer cmdBuffer, VkBuffer srcBu
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);
}
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) cmdBuffer;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- pTable->CmdCopyBuffer(cmdBuffer, srcBuffer, destBuffer, regionCount, pRegions);
+ device_dispatch_table(cmdBuffer)->CmdCopyBuffer(cmdBuffer, srcBuffer, destBuffer, regionCount, pRegions);
}
VK_LAYER_EXPORT void VKAPI vkCmdCopyImage(VkCmdBuffer cmdBuffer,
@@ -2383,9 +2266,7 @@ VK_LAYER_EXPORT void VKAPI vkCmdCopyImage(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);
}
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) cmdBuffer;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- pTable->CmdCopyImage(cmdBuffer, srcImage, srcImageLayout, destImage, destImageLayout, regionCount, pRegions);
+ device_dispatch_table(cmdBuffer)->CmdCopyImage(cmdBuffer, srcImage, srcImageLayout, destImage, destImageLayout, regionCount, pRegions);
}
VK_LAYER_EXPORT void VKAPI vkCmdBlitImage(VkCmdBuffer cmdBuffer,
@@ -2404,9 +2285,7 @@ VK_LAYER_EXPORT void VKAPI vkCmdBlitImage(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);
}
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) cmdBuffer;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- pTable->CmdBlitImage(cmdBuffer, srcImage, srcImageLayout, destImage, destImageLayout, regionCount, pRegions, filter);
+ device_dispatch_table(cmdBuffer)->CmdBlitImage(cmdBuffer, srcImage, srcImageLayout, destImage, destImageLayout, regionCount, pRegions, filter);
}
VK_LAYER_EXPORT void VKAPI vkCmdCopyBufferToImage(VkCmdBuffer cmdBuffer,
@@ -2424,9 +2303,7 @@ VK_LAYER_EXPORT void VKAPI vkCmdCopyBufferToImage(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);
}
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) cmdBuffer;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- pTable->CmdCopyBufferToImage(cmdBuffer, srcBuffer, destImage, destImageLayout, regionCount, pRegions);
+ device_dispatch_table(cmdBuffer)->CmdCopyBufferToImage(cmdBuffer, srcBuffer, destImage, destImageLayout, regionCount, pRegions);
}
VK_LAYER_EXPORT void VKAPI vkCmdCopyImageToBuffer(VkCmdBuffer cmdBuffer,
@@ -2444,9 +2321,7 @@ VK_LAYER_EXPORT void VKAPI vkCmdCopyImageToBuffer(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);
}
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) cmdBuffer;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- pTable->CmdCopyImageToBuffer(cmdBuffer, srcImage, srcImageLayout, destBuffer, regionCount, pRegions);
+ device_dispatch_table(cmdBuffer)->CmdCopyImageToBuffer(cmdBuffer, srcImage, srcImageLayout, destBuffer, regionCount, pRegions);
}
VK_LAYER_EXPORT void VKAPI vkCmdUpdateBuffer(VkCmdBuffer cmdBuffer, VkBuffer destBuffer, VkDeviceSize destOffset, VkDeviceSize dataSize, const uint32_t* pData)
@@ -2461,9 +2336,7 @@ VK_LAYER_EXPORT void VKAPI vkCmdUpdateBuffer(VkCmdBuffer cmdBuffer, VkBuffer des
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);
}
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) cmdBuffer;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- pTable->CmdUpdateBuffer(cmdBuffer, destBuffer, destOffset, dataSize, pData);
+ device_dispatch_table(cmdBuffer)->CmdUpdateBuffer(cmdBuffer, destBuffer, destOffset, dataSize, pData);
}
VK_LAYER_EXPORT void VKAPI vkCmdFillBuffer(VkCmdBuffer cmdBuffer, VkBuffer destBuffer, VkDeviceSize destOffset, VkDeviceSize fillSize, uint32_t data)
@@ -2478,9 +2351,7 @@ VK_LAYER_EXPORT void VKAPI vkCmdFillBuffer(VkCmdBuffer cmdBuffer, VkBuffer destB
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);
}
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) cmdBuffer;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- pTable->CmdFillBuffer(cmdBuffer, destBuffer, destOffset, fillSize, data);
+ device_dispatch_table(cmdBuffer)->CmdFillBuffer(cmdBuffer, destBuffer, destOffset, fillSize, data);
}
VK_LAYER_EXPORT void VKAPI vkCmdClearColorImage(
@@ -2499,9 +2370,7 @@ VK_LAYER_EXPORT void VKAPI vkCmdClearColorImage(
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);
}
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) cmdBuffer;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- pTable->CmdClearColorImage(cmdBuffer, image, imageLayout, pColor, rangeCount, pRanges);
+ device_dispatch_table(cmdBuffer)->CmdClearColorImage(cmdBuffer, image, imageLayout, pColor, rangeCount, pRanges);
}
VK_LAYER_EXPORT void VKAPI vkCmdClearDepthStencil(VkCmdBuffer cmdBuffer,
@@ -2519,9 +2388,7 @@ VK_LAYER_EXPORT void VKAPI vkCmdClearDepthStencil(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);
}
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) cmdBuffer;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- pTable->CmdClearDepthStencil(cmdBuffer, image, imageLayout, depth, stencil, rangeCount, pRanges);
+ device_dispatch_table(cmdBuffer)->CmdClearDepthStencil(cmdBuffer, image, imageLayout, depth, stencil, rangeCount, pRanges);
}
VK_LAYER_EXPORT void VKAPI vkCmdResolveImage(VkCmdBuffer cmdBuffer,
@@ -2539,9 +2406,7 @@ VK_LAYER_EXPORT void VKAPI vkCmdResolveImage(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);
}
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) cmdBuffer;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- pTable->CmdResolveImage(cmdBuffer, srcImage, srcImageLayout, destImage, destImageLayout, regionCount, pRegions);
+ device_dispatch_table(cmdBuffer)->CmdResolveImage(cmdBuffer, srcImage, srcImageLayout, destImage, destImageLayout, regionCount, pRegions);
}
VK_LAYER_EXPORT void VKAPI vkCmdSetEvent(VkCmdBuffer cmdBuffer, VkEvent event, VkPipeEvent pipeEvent)
@@ -2556,9 +2421,7 @@ VK_LAYER_EXPORT void VKAPI vkCmdSetEvent(VkCmdBuffer cmdBuffer, VkEvent event, V
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);
}
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) cmdBuffer;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- pTable->CmdSetEvent(cmdBuffer, event, pipeEvent);
+ device_dispatch_table(cmdBuffer)->CmdSetEvent(cmdBuffer, event, pipeEvent);
}
VK_LAYER_EXPORT void VKAPI vkCmdResetEvent(VkCmdBuffer cmdBuffer, VkEvent event, VkPipeEvent pipeEvent)
@@ -2573,9 +2436,7 @@ VK_LAYER_EXPORT void VKAPI vkCmdResetEvent(VkCmdBuffer cmdBuffer, VkEvent event,
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);
}
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) cmdBuffer;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- pTable->CmdResetEvent(cmdBuffer, event, pipeEvent);
+ device_dispatch_table(cmdBuffer)->CmdResetEvent(cmdBuffer, event, pipeEvent);
}
VK_LAYER_EXPORT void VKAPI vkCmdWaitEvents(VkCmdBuffer cmdBuffer, VkWaitEvent waitEvent, uint32_t eventCount, const VkEvent* pEvents, uint32_t memBarrierCount, const void** ppMemBarriers)
@@ -2590,9 +2451,7 @@ VK_LAYER_EXPORT void VKAPI vkCmdWaitEvents(VkCmdBuffer cmdBuffer, VkWaitEvent wa
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);
}
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) cmdBuffer;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- pTable->CmdWaitEvents(cmdBuffer, waitEvent, eventCount, pEvents, memBarrierCount, ppMemBarriers);
+ device_dispatch_table(cmdBuffer)->CmdWaitEvents(cmdBuffer, waitEvent, eventCount, pEvents, memBarrierCount, ppMemBarriers);
}
VK_LAYER_EXPORT void VKAPI vkCmdPipelineBarrier(VkCmdBuffer cmdBuffer, VkWaitEvent waitEvent, uint32_t pipeEventCount, const VkPipeEvent* pPipeEvents, uint32_t memBarrierCount, const void** ppMemBarriers)
@@ -2607,9 +2466,7 @@ VK_LAYER_EXPORT void VKAPI vkCmdPipelineBarrier(VkCmdBuffer cmdBuffer, VkWaitEve
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);
}
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) cmdBuffer;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- pTable->CmdPipelineBarrier(cmdBuffer, waitEvent, pipeEventCount, pPipeEvents, memBarrierCount, ppMemBarriers);
+ device_dispatch_table(cmdBuffer)->CmdPipelineBarrier(cmdBuffer, waitEvent, pipeEventCount, pPipeEvents, memBarrierCount, ppMemBarriers);
}
VK_LAYER_EXPORT void VKAPI vkCmdBeginQuery(VkCmdBuffer cmdBuffer, VkQueryPool queryPool, uint32_t slot, VkFlags flags)
@@ -2624,9 +2481,7 @@ VK_LAYER_EXPORT void VKAPI vkCmdBeginQuery(VkCmdBuffer cmdBuffer, VkQueryPool qu
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);
}
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) cmdBuffer;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- pTable->CmdBeginQuery(cmdBuffer, queryPool, slot, flags);
+ device_dispatch_table(cmdBuffer)->CmdBeginQuery(cmdBuffer, queryPool, slot, flags);
}
VK_LAYER_EXPORT void VKAPI vkCmdEndQuery(VkCmdBuffer cmdBuffer, VkQueryPool queryPool, uint32_t slot)
@@ -2641,9 +2496,7 @@ VK_LAYER_EXPORT void VKAPI vkCmdEndQuery(VkCmdBuffer cmdBuffer, VkQueryPool quer
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);
}
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) cmdBuffer;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- pTable->CmdEndQuery(cmdBuffer, queryPool, slot);
+ device_dispatch_table(cmdBuffer)->CmdEndQuery(cmdBuffer, queryPool, slot);
}
VK_LAYER_EXPORT void VKAPI vkCmdResetQueryPool(VkCmdBuffer cmdBuffer, VkQueryPool queryPool, uint32_t startQuery, uint32_t queryCount)
@@ -2658,9 +2511,7 @@ VK_LAYER_EXPORT void VKAPI vkCmdResetQueryPool(VkCmdBuffer cmdBuffer, VkQueryPoo
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);
}
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) cmdBuffer;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- pTable->CmdResetQueryPool(cmdBuffer, queryPool, startQuery, queryCount);
+ device_dispatch_table(cmdBuffer)->CmdResetQueryPool(cmdBuffer, queryPool, startQuery, queryCount);
}
VK_LAYER_EXPORT void VKAPI vkCmdWriteTimestamp(VkCmdBuffer cmdBuffer, VkTimestampType timestampType, VkBuffer destBuffer, VkDeviceSize destOffset)
@@ -2675,9 +2526,7 @@ VK_LAYER_EXPORT void VKAPI vkCmdWriteTimestamp(VkCmdBuffer cmdBuffer, VkTimestam
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);
}
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) cmdBuffer;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- pTable->CmdWriteTimestamp(cmdBuffer, timestampType, destBuffer, destOffset);
+ device_dispatch_table(cmdBuffer)->CmdWriteTimestamp(cmdBuffer, timestampType, destBuffer, destOffset);
}
VK_LAYER_EXPORT void VKAPI vkCmdInitAtomicCounters(VkCmdBuffer cmdBuffer, VkPipelineBindPoint pipelineBindPoint, uint32_t startCounter, uint32_t counterCount, const uint32_t* pData)
@@ -2692,9 +2541,7 @@ VK_LAYER_EXPORT void VKAPI vkCmdInitAtomicCounters(VkCmdBuffer cmdBuffer, VkPipe
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);
}
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) cmdBuffer;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- pTable->CmdInitAtomicCounters(cmdBuffer, pipelineBindPoint, startCounter, counterCount, pData);
+ device_dispatch_table(cmdBuffer)->CmdInitAtomicCounters(cmdBuffer, pipelineBindPoint, startCounter, counterCount, pData);
}
VK_LAYER_EXPORT void VKAPI vkCmdLoadAtomicCounters(VkCmdBuffer cmdBuffer, VkPipelineBindPoint pipelineBindPoint, uint32_t startCounter, uint32_t counterCount, VkBuffer srcBuffer, VkDeviceSize srcOffset)
@@ -2709,9 +2556,7 @@ VK_LAYER_EXPORT void VKAPI vkCmdLoadAtomicCounters(VkCmdBuffer cmdBuffer, VkPipe
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);
}
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) cmdBuffer;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- pTable->CmdLoadAtomicCounters(cmdBuffer, pipelineBindPoint, startCounter, counterCount, srcBuffer, srcOffset);
+ device_dispatch_table(cmdBuffer)->CmdLoadAtomicCounters(cmdBuffer, pipelineBindPoint, startCounter, counterCount, srcBuffer, srcOffset);
}
VK_LAYER_EXPORT void VKAPI vkCmdSaveAtomicCounters(VkCmdBuffer cmdBuffer, VkPipelineBindPoint pipelineBindPoint, uint32_t startCounter, uint32_t counterCount, VkBuffer destBuffer, VkDeviceSize destOffset)
@@ -2726,16 +2571,12 @@ VK_LAYER_EXPORT void VKAPI vkCmdSaveAtomicCounters(VkCmdBuffer cmdBuffer, VkPipe
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);
}
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) cmdBuffer;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- pTable->CmdSaveAtomicCounters(cmdBuffer, pipelineBindPoint, startCounter, counterCount, destBuffer, destOffset);
+ device_dispatch_table(cmdBuffer)->CmdSaveAtomicCounters(cmdBuffer, pipelineBindPoint, startCounter, counterCount, destBuffer, destOffset);
}
VK_LAYER_EXPORT VkResult VKAPI vkCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo* pCreateInfo, VkFramebuffer* pFramebuffer)
{
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) device;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- VkResult result = pTable->CreateFramebuffer(device, pCreateInfo, pFramebuffer);
+ VkResult result = device_dispatch_table(device)->CreateFramebuffer(device, pCreateInfo, pFramebuffer);
if (VK_SUCCESS == result) {
// Shadow create info and store in map
VkFramebufferCreateInfo* localFBCI = new VkFramebufferCreateInfo(*pCreateInfo);
@@ -2754,9 +2595,7 @@ VK_LAYER_EXPORT VkResult VKAPI vkCreateFramebuffer(VkDevice device, const VkFram
VK_LAYER_EXPORT VkResult VKAPI vkCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo* pCreateInfo, VkRenderPass* pRenderPass)
{
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) device;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- VkResult result = pTable->CreateRenderPass(device, pCreateInfo, pRenderPass);
+ VkResult result = device_dispatch_table(device)->CreateRenderPass(device, pCreateInfo, pRenderPass);
if (VK_SUCCESS == result) {
// Shadow create info and store in map
VkRenderPassCreateInfo* localRPCI = new VkRenderPassCreateInfo(*pCreateInfo);
@@ -2793,9 +2632,7 @@ VK_LAYER_EXPORT void VKAPI vkCmdBeginRenderPass(VkCmdBuffer cmdBuffer, const VkR
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);
}
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) cmdBuffer;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- pTable->CmdBeginRenderPass(cmdBuffer, pRenderPassBegin);
+ device_dispatch_table(cmdBuffer)->CmdBeginRenderPass(cmdBuffer, pRenderPassBegin);
}
VK_LAYER_EXPORT void VKAPI vkCmdEndRenderPass(VkCmdBuffer cmdBuffer, VkRenderPass renderPass)
@@ -2811,9 +2648,7 @@ VK_LAYER_EXPORT void VKAPI vkCmdEndRenderPass(VkCmdBuffer cmdBuffer, VkRenderPas
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);
}
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) cmdBuffer;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- pTable->CmdEndRenderPass(cmdBuffer, renderPass);
+ device_dispatch_table(cmdBuffer)->CmdEndRenderPass(cmdBuffer, renderPass);
}
VK_LAYER_EXPORT VkResult VKAPI vkDbgCreateMsgCallback(
@@ -2823,8 +2658,7 @@ VK_LAYER_EXPORT VkResult VKAPI vkDbgCreateMsgCallback(
void* pUserData,
VkDbgMsgCallback* pMsgCallback)
{
- VkLayerInstanceDispatchTable *pDisp = *(VkLayerInstanceDispatchTable **) instance;
- VkLayerInstanceDispatchTable *pTable = tableInstanceMap[pDisp];
+ VkLayerInstanceDispatchTable *pTable = instance_dispatch_table(instance);
return layer_create_msg_callback(instance, pTable, msgFlags, pfnMsgCallback, pUserData, pMsgCallback);
}
@@ -2832,8 +2666,7 @@ VK_LAYER_EXPORT VkResult VKAPI vkDbgDestroyMsgCallback(
VkInstance instance,
VkDbgMsgCallback msgCallback)
{
- VkLayerInstanceDispatchTable *pDisp = *(VkLayerInstanceDispatchTable **) instance;
- VkLayerInstanceDispatchTable *pTable = tableInstanceMap[pDisp];
+ VkLayerInstanceDispatchTable *pTable = instance_dispatch_table(instance);
return layer_destroy_msg_callback(instance, pTable, msgCallback);
}
@@ -3089,7 +2922,7 @@ VK_LAYER_EXPORT void* VKAPI vkGetDeviceProcAddr(VkDevice dev, const char* funcNa
return (void*) vkDbgSetObjectName;
}
{
- VkLayerDispatchTable* pTable = tableMap[pDisp];
+ VkLayerDispatchTable* pTable = device_dispatch_table(dev);
if (pTable->GetDeviceProcAddr == NULL)
return NULL;
return pTable->GetDeviceProcAddr(dev, funcName);
@@ -3121,8 +2954,7 @@ VK_LAYER_EXPORT void * VKAPI vkGetInstanceProcAddr(VkInstance instance, const ch
return fptr;
{
- VkLayerInstanceDispatchTable **ppDisp = (VkLayerInstanceDispatchTable **) instance;
- VkLayerInstanceDispatchTable* pTable = tableInstanceMap[*ppDisp];
+ VkLayerInstanceDispatchTable* pTable = instance_dispatch_table(instance);
if (pTable->GetInstanceProcAddr == NULL)
return NULL;
return pTable->GetInstanceProcAddr(instance, funcName);
diff --git a/layers/layers_table.cpp b/layers/layers_table.cpp
new file mode 100644
index 00000000..03499a94
--- /dev/null
+++ b/layers/layers_table.cpp
@@ -0,0 +1,79 @@
+/*
+ * 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_dispatch_table_helper.h"
+#include "vkLayer.h"
+std::unordered_map<void *, VkLayerDispatchTable *> tableMap;
+std::unordered_map<void *, VkLayerInstanceDispatchTable *> tableInstanceMap;
+
+
+/* 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 */
+VkLayerInstanceDispatchTable * initInstanceTable(const VkBaseLayerObject *instancew)
+{
+ VkLayerInstanceDispatchTable *pTable;
+ assert(instancew);
+ VkLayerInstanceDispatchTable **ppDisp = (VkLayerInstanceDispatchTable **) instancew->baseObject;
+
+ std::unordered_map<void *, VkLayerInstanceDispatchTable *>::const_iterator it = tableInstanceMap.find((void *) *ppDisp);
+ if (it == tableInstanceMap.end())
+ {
+ pTable = new VkLayerInstanceDispatchTable;
+ tableInstanceMap[(void *) *ppDisp] = pTable;
+ } else
+ {
+ return it->second;
+ }
+
+ layer_init_instance_dispatch_table(pTable, instancew);
+
+ return pTable;
+}
+
+VkLayerDispatchTable * initDeviceTable(const VkBaseLayerObject *devw)
+{
+ VkLayerDispatchTable *pTable;
+ assert(devw);
+ VkLayerDispatchTable **ppDisp = (VkLayerDispatchTable **) (devw->baseObject);
+
+ std::unordered_map<void *, VkLayerDispatchTable *>::const_iterator it = tableMap.find((void *) *ppDisp);
+ if (it == tableMap.end())
+ {
+ pTable = new VkLayerDispatchTable;
+ tableMap[(void *) *ppDisp] = pTable;
+ } else
+ {
+ return it->second;
+ }
+
+ layer_initialize_dispatch_table(pTable, devw);
+
+ return pTable;
+}
diff --git a/layers/layers_table.h b/layers/layers_table.h
new file mode 100644
index 00000000..98f4583e
--- /dev/null
+++ b/layers/layers_table.h
@@ -0,0 +1,48 @@
+/*
+ * 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 *, VkLayerDispatchTable *> tableMap;
+extern std::unordered_map<void *, VkLayerInstanceDispatchTable *> tableInstanceMap;
+VkLayerDispatchTable * initDeviceTable(const VkBaseLayerObject *devw);
+VkLayerInstanceDispatchTable * initInstanceTable(const VkBaseLayerObject *instancew);
+
+// Map lookup must be thread safe
+static inline VkLayerDispatchTable *device_dispatch_table(VkObject object)
+{
+ VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) object;
+ std::unordered_map<void *, VkLayerDispatchTable *>::const_iterator it = tableMap.find((void *) pDisp);
+ assert(it != tableMap.end() && "Not able to find device dispatch entry");
+ return it->second;
+}
+
+static inline VkLayerInstanceDispatchTable *instance_dispatch_table(VkObject object)
+{
+ VkLayerInstanceDispatchTable *pDisp = *(VkLayerInstanceDispatchTable **) object;
+ std::unordered_map<void *, VkLayerInstanceDispatchTable *>::const_iterator it = tableInstanceMap.find((void *) pDisp);
+ assert(it != tableInstanceMap.end() && "Not able to find instance dispatch entry");
+ return it->second;
+}
diff --git a/layers/mem_tracker.cpp b/layers/mem_tracker.cpp
index 9e51e889..25e5cd88 100644
--- a/layers/mem_tracker.cpp
+++ b/layers/mem_tracker.cpp
@@ -29,7 +29,6 @@
#include <assert.h>
#include <list>
#include <map>
-#include <unordered_map>
#include <vector>
using namespace std;
@@ -42,23 +41,10 @@ using namespace std;
// being used:
#include "loader_platform.h"
#include "layers_msg.h"
-
-static std::unordered_map<void *, VkLayerDispatchTable *> tableMap;
-static std::unordered_map<void *, VkLayerInstanceDispatchTable *> tableInstanceMap;
+#include "layers_table.h"
static LOADER_PLATFORM_THREAD_ONCE_DECLARATION(g_initOnce);
-static inline VkLayerDispatchTable *device_dispatch_table(VkObject object) {
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) object;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- return pTable;
-}
-
-static inline VkLayerInstanceDispatchTable *instance_dispatch_table(VkObject object) {
- VkLayerInstanceDispatchTable **ppDisp = (VkLayerInstanceDispatchTable **) object;
- VkLayerInstanceDispatchTable *pInstanceTable = tableInstanceMap[*ppDisp];
- return pInstanceTable;
-}
// TODO : This can be much smarter, using separate locks for separate global data
static int globalLockInitialized = 0;
@@ -779,50 +765,6 @@ static void printCBList(
}
}
-static VkLayerDispatchTable * initDeviceTable(const VkBaseLayerObject *devw)
- {
- VkLayerDispatchTable *pTable;
-
- assert(devw);
- VkLayerDispatchTable **ppDisp = (VkLayerDispatchTable **) (devw->baseObject);
-
- std::unordered_map<void *, VkLayerDispatchTable *>::const_iterator it = tableMap.find((void *) *ppDisp);
- if (it == tableMap.end())
- {
- pTable = new VkLayerDispatchTable;
- tableMap[(void *) *ppDisp] = pTable;
- } else
- {
- return it->second;
- }
-
- layer_initialize_dispatch_table(pTable, devw);
-
- return pTable;
-}
-
-
-static VkLayerInstanceDispatchTable * initInstanceTable(const VkBaseLayerObject *instw)
-{
- VkLayerInstanceDispatchTable *pTable;
- assert(instw);
- VkLayerInstanceDispatchTable **ppDisp = (VkLayerInstanceDispatchTable **) instw->baseObject;
-
- std::unordered_map<void *, VkLayerInstanceDispatchTable *>::const_iterator it = tableInstanceMap.find((void *) *ppDisp);
- if (it == tableInstanceMap.end())
- {
- pTable = new VkLayerInstanceDispatchTable;
- tableInstanceMap[(void *) *ppDisp] = pTable;
- } else
- {
- return it->second;
- }
-
- layer_init_instance_dispatch_table(pTable, instw);
-
- return pTable;
-}
-
static void initMemTracker(
void)
{
@@ -930,8 +872,7 @@ VK_LAYER_EXPORT VkResult VKAPI vkDestroyDevice(
loader_platform_thread_unlock_mutex(&globalLock);
VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) device;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- VkResult result = pTable->DestroyDevice(device);
+ VkResult result = device_dispatch_table(device)->DestroyDevice(device);
tableMap.erase(pDisp);
return result;
}
@@ -2369,11 +2310,9 @@ VK_LAYER_EXPORT void* VKAPI vkGetDeviceProcAddr(
return fptr;
{
- VkLayerDispatchTable **ppDisp = (VkLayerDispatchTable **) dev;
- VkLayerDispatchTable* pTable = tableMap[*ppDisp];
- if (pTable->GetDeviceProcAddr == NULL)
+ if (device_dispatch_table(dev)->GetDeviceProcAddr == NULL)
return NULL;
- return pTable->GetDeviceProcAddr(dev, funcName);
+ return device_dispatch_table(dev)->GetDeviceProcAddr(dev, funcName);
}
}
@@ -2406,10 +2345,8 @@ VK_LAYER_EXPORT void* VKAPI vkGetInstanceProcAddr(
return fptr;
{
- VkLayerInstanceDispatchTable **ppDisp = (VkLayerInstanceDispatchTable **) instance;
- VkLayerInstanceDispatchTable* pTable = tableInstanceMap[*ppDisp];
- if (pTable->GetInstanceProcAddr == NULL)
+ if (instance_dispatch_table(instance)->GetInstanceProcAddr == NULL)
return NULL;
- return pTable->GetInstanceProcAddr(instance, funcName);
+ return instance_dispatch_table(instance)->GetInstanceProcAddr(instance, funcName);
}
}
diff --git a/layers/multi.cpp b/layers/multi.cpp
index b0e8f212..fc0bb38e 100644
--- a/layers/multi.cpp
+++ b/layers/multi.cpp
@@ -48,6 +48,23 @@ static std::unordered_map<void *, VkLayerDispatchTable *> tableMap1;
static std::unordered_map<void *, VkLayerInstanceDispatchTable *> tableInstanceMap1;
static bool layer1_first_activated = false;
+// Map lookup must be thread safe
+static inline VkLayerDispatchTable *device_dispatch_table1(VkObject object)
+{
+ VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) object;
+ std::unordered_map<void *, VkLayerDispatchTable *>::const_iterator it = tableMap1.find((void *) pDisp);
+ assert(it != tableMap1.end() && "Not able to find device dispatch entry");
+ return it->second;
+}
+
+static inline VkLayerInstanceDispatchTable *instance_dispatch_table1(VkObject object)
+{
+ VkLayerInstanceDispatchTable *pDisp = *(VkLayerInstanceDispatchTable **) object;
+ std::unordered_map<void *, VkLayerInstanceDispatchTable *>::const_iterator it = tableInstanceMap1.find((void *) pDisp);
+ assert(it != tableInstanceMap1.end() && "Not able to find instance dispatch entry");
+ return it->second;
+}
+
static VkLayerDispatchTable *getLayer1Table(const VkBaseLayerObject *devw)
{
VkLayerDispatchTable *pTable;
@@ -92,8 +109,7 @@ extern "C" {
VK_LAYER_EXPORT VkResult VKAPI multi1DestroyDevice(VkDevice device)
{
VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) device;
- VkLayerDispatchTable *pTable = tableMap1[pDisp];
- VkResult res = pTable->DestroyDevice(device);
+ VkResult res = device_dispatch_table1(device)->DestroyDevice(device);
tableMap1.erase(pDisp);
return res;
}
@@ -102,8 +118,7 @@ VK_LAYER_EXPORT VkResult VKAPI multi1DestroyDevice(VkDevice device)
VK_LAYER_EXPORT VkResult VKAPI multi1DestroyInstance(VkInstance instance)
{
VkLayerInstanceDispatchTable *pDisp = *(VkLayerInstanceDispatchTable **) instance;
- VkLayerInstanceDispatchTable *pTable = tableInstanceMap1[pDisp];
- VkResult res = pTable->DestroyInstance(instance);
+ VkResult res = instance_dispatch_table1(instance)->DestroyInstance(instance);
tableInstanceMap1.erase(pDisp);
return res;
}
@@ -111,10 +126,9 @@ VK_LAYER_EXPORT VkResult VKAPI multi1DestroyInstance(VkInstance instance)
VK_LAYER_EXPORT VkResult VKAPI multi1CreateSampler(VkDevice device, const VkSamplerCreateInfo* pCreateInfo, VkSampler* pSampler)
{
VkLayerDispatchTable **ppDisp = (VkLayerDispatchTable **) device;
- VkLayerDispatchTable *pTable = tableMap1[*ppDisp];
printf("At start of multi1 layer vkCreateSampler()\n");
- VkResult result = pTable->CreateSampler(device, pCreateInfo, pSampler);
+ VkResult result = device_dispatch_table1(device)->CreateSampler(device, pCreateInfo, pSampler);
printf("Completed multi1 layer vkCreateSampler()\n");
return result;
}
@@ -123,10 +137,9 @@ VK_LAYER_EXPORT VkResult VKAPI multi1CreateGraphicsPipeline(VkDevice device, con
VkPipeline* pPipeline)
{
VkLayerDispatchTable **ppDisp = (VkLayerDispatchTable **) device;
- VkLayerDispatchTable *pTable = tableMap1[*ppDisp];
printf("At start of multi1 layer vkCreateGraphicsPipeline()\n");
- VkResult result = pTable->CreateGraphicsPipeline(device, pCreateInfo, pPipeline);
+ VkResult result = device_dispatch_table1(device)->CreateGraphicsPipeline(device, pCreateInfo, pPipeline);
printf("Completed multi1 layer vkCreateGraphicsPipeline()\n");
return result;
}
@@ -134,10 +147,9 @@ VK_LAYER_EXPORT VkResult VKAPI multi1CreateGraphicsPipeline(VkDevice device, con
VK_LAYER_EXPORT VkResult VKAPI multi1StorePipeline(VkDevice device, VkPipeline pipeline, size_t* pDataSize, void* pData)
{
VkLayerDispatchTable **ppDisp = (VkLayerDispatchTable **) device;
- VkLayerDispatchTable *pTable = tableMap1[*ppDisp];
printf("At start of multi1 layer vkStorePipeline()\n");
- VkResult result = pTable->StorePipeline(device, pipeline, pDataSize, pData);
+ VkResult result = device_dispatch_table1(device)->StorePipeline(device, pipeline, pDataSize, pData);
printf("Completed multi1 layer vkStorePipeline()\n");
return result;
}
@@ -165,7 +177,7 @@ VK_LAYER_EXPORT void * VKAPI multi1GetDeviceProcAddr(VkDevice device, const char
return (void *) multi1StorePipeline;
else {
VkLayerDispatchTable **ppDisp = (VkLayerDispatchTable **) device;
- VkLayerDispatchTable* pTable = tableMap1[*ppDisp];
+ VkLayerDispatchTable* pTable = device_dispatch_table1(device);
if (pTable->GetDeviceProcAddr == NULL)
return NULL;
return pTable->GetDeviceProcAddr(device, pName);
@@ -191,7 +203,7 @@ VK_LAYER_EXPORT void * VKAPI multi1GetInstanceProcAddr(VkInstance inst, const ch
return (void*) vkGetGlobalExtensionInfo;
else {
VkLayerInstanceDispatchTable **ppDisp = (VkLayerInstanceDispatchTable **) inst;
- VkLayerInstanceDispatchTable* pTable = tableInstanceMap1[*ppDisp];
+ VkLayerInstanceDispatchTable* pTable = instance_dispatch_table1(inst);
if (pTable->GetInstanceProcAddr == NULL)
return NULL;
return pTable->GetInstanceProcAddr(inst, pName);
@@ -203,6 +215,23 @@ static std::unordered_map<void *, VkLayerDispatchTable *> tableMap2;
static std::unordered_map<void *, VkLayerInstanceDispatchTable *> tableInstanceMap2;
static bool layer2_first_activated = false;
+// Map lookup must be thread safe
+static inline VkLayerDispatchTable *device_dispatch_table2(VkObject object)
+{
+ VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) object;
+ std::unordered_map<void *, VkLayerDispatchTable *>::const_iterator it = tableMap2.find((void *) pDisp);
+ assert(it != tableMap2.end() && "Not able to find device dispatch entry");
+ return it->second;
+}
+
+static inline VkLayerInstanceDispatchTable *instance_dispatch_table2(VkObject object)
+{
+ VkLayerInstanceDispatchTable *pDisp = *(VkLayerInstanceDispatchTable **) object;
+ std::unordered_map<void *, VkLayerInstanceDispatchTable *>::const_iterator it = tableInstanceMap2.find((void *) pDisp);
+ assert(it != tableInstanceMap2.end() && "Not able to find instance dispatch entry");
+ return it->second;
+}
+
static VkLayerInstanceDispatchTable *getLayer2InstanceTable(const VkBaseLayerObject *instw)
{
VkLayerInstanceDispatchTable *pTable;
@@ -247,10 +276,9 @@ VK_LAYER_EXPORT VkResult VKAPI multi2EnumeratePhysicalDevices(
VkPhysicalDevice* pPhysicalDevices)
{
VkLayerInstanceDispatchTable **ppDisp = (VkLayerInstanceDispatchTable **) instance;
- VkLayerInstanceDispatchTable *pInstTable = tableInstanceMap2[*ppDisp];
printf("At start of wrapped multi2 vkEnumeratePhysicalDevices()\n");
- VkResult result = pInstTable->EnumeratePhysicalDevices(instance, pPhysicalDeviceCount, pPhysicalDevices);
+ VkResult result = instance_dispatch_table2(instance)->EnumeratePhysicalDevices(instance, pPhysicalDeviceCount, pPhysicalDevices);
printf("Completed multi2 layer vkEnumeratePhysicalDevices()\n");
return result;
}
@@ -259,8 +287,7 @@ VK_LAYER_EXPORT VkResult VKAPI multi2EnumeratePhysicalDevices(
VK_LAYER_EXPORT VkResult VKAPI multi2DestroyDevice(VkDevice device)
{
VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) device;
- VkLayerDispatchTable *pTable = tableMap2[pDisp];
- VkResult res = pTable->DestroyDevice(device);
+ VkResult res = device_dispatch_table2(device)->DestroyDevice(device);
tableMap2.erase(pDisp);
return res;
}
@@ -269,8 +296,7 @@ VK_LAYER_EXPORT VkResult VKAPI multi2DestroyDevice(VkDevice device)
VK_LAYER_EXPORT VkResult VKAPI multi2DestroyInstance(VkInstance instance)
{
VkLayerInstanceDispatchTable *pDisp = *(VkLayerInstanceDispatchTable **) instance;
- VkLayerInstanceDispatchTable *pTable = tableInstanceMap2[pDisp];
- VkResult res = pTable->DestroyInstance(instance);
+ VkResult res = instance_dispatch_table2(instance)->DestroyInstance(instance);
tableInstanceMap2.erase(pDisp);
return res;
}
@@ -279,10 +305,8 @@ VK_LAYER_EXPORT VkResult VKAPI multi2CreateDevice(VkPhysicalDevice gpu, const Vk
VkDevice* pDevice)
{
VkLayerInstanceDispatchTable **ppDisp = (VkLayerInstanceDispatchTable **) gpu;
- VkLayerInstanceDispatchTable *pInstTable = tableInstanceMap2[*ppDisp];
-
printf("At start of multi2 vkCreateDevice()\n");
- VkResult result = pInstTable->CreateDevice(gpu, pCreateInfo, pDevice);
+ VkResult result = instance_dispatch_table2(gpu)->CreateDevice(gpu, pCreateInfo, pDevice);
printf("Completed multi2 layer vkCreateDevice()\n");
return result;
}
@@ -291,10 +315,9 @@ VK_LAYER_EXPORT VkResult VKAPI multi2CreateCommandBuffer(VkDevice device, const
VkCmdBuffer* pCmdBuffer)
{
VkLayerDispatchTable **ppDisp = (VkLayerDispatchTable **) device;
- VkLayerDispatchTable *pTable = tableMap2[*ppDisp];
printf("At start of multi2 layer vkCreateCommandBuffer()\n");
- VkResult result = pTable->CreateCommandBuffer(device, pCreateInfo, pCmdBuffer);
+ VkResult result = device_dispatch_table2(device)->CreateCommandBuffer(device, pCreateInfo, pCmdBuffer);
printf("Completed multi2 layer vkCreateCommandBuffer()\n");
return result;
}
@@ -302,10 +325,9 @@ VK_LAYER_EXPORT VkResult VKAPI multi2CreateCommandBuffer(VkDevice device, const
VK_LAYER_EXPORT VkResult VKAPI multi2BeginCommandBuffer(VkCmdBuffer cmdBuffer, const VkCmdBufferBeginInfo* pBeginInfo)
{
VkLayerDispatchTable **ppDisp = (VkLayerDispatchTable **) cmdBuffer;
- VkLayerDispatchTable *pTable = tableMap2[*ppDisp];
printf("At start of multi2 layer vkBeginCommandBuffer()\n");
- VkResult result = pTable->BeginCommandBuffer(cmdBuffer, pBeginInfo);
+ VkResult result = device_dispatch_table2(cmdBuffer)->BeginCommandBuffer(cmdBuffer, pBeginInfo);
printf("Completed multi2 layer vkBeginCommandBuffer()\n");
return result;
@@ -330,7 +352,7 @@ VK_LAYER_EXPORT void * VKAPI multi2GetDeviceProcAddr(VkDevice device, const char
return (void *) multi2BeginCommandBuffer;
else {
VkLayerDispatchTable **ppDisp = (VkLayerDispatchTable **) device;
- VkLayerDispatchTable* pTable = tableMap2[*ppDisp];
+ VkLayerDispatchTable* pTable = device_dispatch_table2(device);
if (pTable->GetDeviceProcAddr == NULL)
return NULL;
return pTable->GetDeviceProcAddr(device, pName);
@@ -358,7 +380,7 @@ VK_LAYER_EXPORT void * VKAPI multi2GetInstanceProcAddr(VkInstance inst, const ch
return (void*) vkGetGlobalExtensionInfo;
else {
VkLayerInstanceDispatchTable **ppDisp = (VkLayerInstanceDispatchTable **) inst;
- VkLayerInstanceDispatchTable* pTable = tableInstanceMap2[*ppDisp];
+ VkLayerInstanceDispatchTable* pTable = instance_dispatch_table2(inst);
if (pTable->GetInstanceProcAddr == NULL)
return NULL;
return pTable->GetInstanceProcAddr(inst, pName);
diff --git a/layers/param_checker.cpp b/layers/param_checker.cpp
index 771054e1..c1a6fef5 100644
--- a/layers/param_checker.cpp
+++ b/layers/param_checker.cpp
@@ -42,73 +42,17 @@
#include "layers_msg.h"
#include "layers_debug_marker_table.h"
+#include "layers_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 *, VkLayerInstanceDispatchTable *> tableInstanceMap;
static std::unordered_map<void *, struct devExts> deviceExtMap;
-static inline VkLayerDispatchTable *device_dispatch_table(VkObject object) {
- VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) object;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- return pTable;
-}
-
-static inline VkLayerInstanceDispatchTable *instance_dispatch_table(VkObject object) {
- VkLayerInstanceDispatchTable **ppDisp = (VkLayerInstanceDispatchTable **) object;
- VkLayerInstanceDispatchTable *pInstanceTable = tableInstanceMap[*ppDisp];
- return pInstanceTable;
-}
-
#include "vk_dispatch_table_helper.h"
-static VkLayerDispatchTable * initDeviceTable(const VkBaseLayerObject *devw)
-{
- VkLayerDispatchTable *pTable;
-
- assert(devw);
- VkLayerDispatchTable **ppDisp = (VkLayerDispatchTable **) (devw->baseObject);
-
- std::unordered_map<void *, VkLayerDispatchTable *>::const_iterator it = tableMap.find((void *) *ppDisp);
- if (it == tableMap.end())
- {
- pTable = new VkLayerDispatchTable;
- tableMap[(void *) *ppDisp] = pTable;
- } else
- {
- return it->second;
- }
-
- layer_initialize_dispatch_table(pTable, devw);
-
- return pTable;
-}
-
-static VkLayerInstanceDispatchTable * initInstanceTable(const VkBaseLayerObject *instw)
-{
- VkLayerInstanceDispatchTable *pTable;
- assert(instw);
- VkLayerInstanceDispatchTable **ppDisp = (VkLayerInstanceDispatchTable **) instw->baseObject;
-
- std::unordered_map<void *, VkLayerInstanceDispatchTable *>::const_iterator it = tableInstanceMap.find((void *) *ppDisp);
- if (it == tableInstanceMap.end())
- {
- pTable = new VkLayerInstanceDispatchTable;
- tableInstanceMap[(void *) *ppDisp] = pTable;
- } else
- {
- return it->second;
- }
-
- layer_init_instance_dispatch_table(pTable, instw);
-
- return pTable;
-}
-
static void initParamChecker(void)
{
@@ -323,8 +267,7 @@ VK_LAYER_EXPORT VkResult VKAPI vkCreateDevice(VkPhysicalDevice gpu, const VkDevi
VK_LAYER_EXPORT VkResult VKAPI vkDestroyDevice(VkDevice device)
{
VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) device;
- VkLayerDispatchTable *pTable = tableMap[pDisp];
- VkResult result = pTable->DestroyDevice(device);
+ VkResult result = device_dispatch_table(device)->DestroyDevice(device);
tableMap.erase(pDisp);
tableDebugMarkerMap.erase(pDisp);
deviceExtMap.erase(pDisp);
@@ -1927,8 +1870,7 @@ VK_LAYER_EXPORT VkResult VKAPI vkDbgCreateMsgCallback(
void* pUserData,
VkDbgMsgCallback* pMsgCallback)
{
- VkLayerInstanceDispatchTable *pDisp = *(VkLayerInstanceDispatchTable **) instance;
- VkLayerInstanceDispatchTable *pTable = tableInstanceMap[pDisp];
+ VkLayerInstanceDispatchTable *pTable = instance_dispatch_table(instance);
return layer_create_msg_callback(instance, pTable, msgFlags, pfnMsgCallback, pUserData, pMsgCallback);
}
@@ -2290,8 +2232,7 @@ VK_LAYER_EXPORT void* VKAPI vkGetDeviceProcAddr(VkDevice device, const char* fun
return (void*) vkDbgSetObjectName;
}
{
- VkLayerDispatchTable **ppDisp = (VkLayerDispatchTable **) device;
- VkLayerDispatchTable* pTable = tableMap[*ppDisp];
+ VkLayerDispatchTable* pTable = device_dispatch_table(device);
if (pTable->GetDeviceProcAddr == NULL)
return NULL;
return pTable->GetDeviceProcAddr(device, funcName);
@@ -2323,11 +2264,8 @@ VK_LAYER_EXPORT void* VKAPI vkGetInstanceProcAddr(VkInstance instance, const cha
if (fptr)
return fptr;
- {
- VkLayerInstanceDispatchTable **ppDisp = (VkLayerInstanceDispatchTable **) instance;
- VkLayerInstanceDispatchTable* pTable = tableInstanceMap[*ppDisp];
- if (pTable->GetInstanceProcAddr == NULL)
- return NULL;
- return pTable->GetInstanceProcAddr(instance, funcName);
- }
+ VkLayerInstanceDispatchTable* pTable = instance_dispatch_table(instance);
+ if (pTable->GetInstanceProcAddr == NULL)
+ return NULL;
+ return pTable->GetInstanceProcAddr(instance, funcName);
}
diff --git a/layers/shader_checker.cpp b/layers/shader_checker.cpp
index d31d7f65..57aab4f0 100644
--- a/layers/shader_checker.cpp
+++ b/layers/shader_checker.cpp
@@ -33,6 +33,7 @@
#include "vkLayer.h"
#include "layers_config.h"
#include "layers_msg.h"
+#include "layers_table.h"
#include "vk_enum_string_helper.h"
#include "shader_checker.h"
// The following is #included again to catch certain OS-specific functions
@@ -42,9 +43,6 @@
#include "spirv/spirv.h"
-static std::unordered_map<void *, VkLayerDispatchTable *> tableMap;
-static VkBaseLayerObject *pCurObj;
-static std::unordered_map<void *, VkLayerInstanceDispatchTable *> tableInstanceMap;
static LOADER_PLATFORM_THREAD_ONCE_DECLARATION(g_initOnce);
// TODO : This can be much smarter, using separate locks for separate global data
static int globalLockInitialized = 0;
@@ -144,47 +142,6 @@ initLayer()
}
}
-
-static VkLayerDispatchTable * initLayerTable(const VkBaseLayerObject *devw)
-{
- VkLayerDispatchTable *pTable;
-
- assert(devw);
- std::unordered_map<void *, VkLayerDispatchTable *>::const_iterator it = tableMap.find((void *) devw->baseObject);
- if (it == tableMap.end())
- {
- pTable = new VkLayerDispatchTable;
- tableMap[(void *) devw->baseObject] = pTable;
- } else
- {
- return it->second;
- }
-
- layer_initialize_dispatch_table(pTable, devw);
-
- return pTable;
-}
-
-static VkLayerInstanceDispatchTable * initLayerInstanceTable(const VkBaseLayerObject *instw)
-{
- VkLayerInstanceDispatchTable *pTable;
-
- assert(instw);
- std::unordered_map<void *, VkLayerInstanceDispatchTable *>::const_iterator it = tableInstanceMap.find((void *) instw->baseObject);
- if (it == tableInstanceMap.end())
- {
- pTable = new VkLayerInstanceDispatchTable;
- tableInstanceMap[(void *) instw->baseObject] = pTable;
- } else
- {
- return it->second;
- }
-
- layer_init_instance_dispatch_table(pTable, instw);
-
- return pTable;
-}
-
#define SHADER_CHECKER_LAYER_EXT_ARRAY_SIZE 2
static const VkExtensionProperties shaderCheckerExts[SHADER_CHECKER_LAYER_EXT_ARRAY_SIZE] = {
{
@@ -474,8 +431,7 @@ VK_LAYER_EXPORT VkResult VKAPI vkCreateShader(VkDevice device, const VkShaderCre
VkShader *pShader)
{
loader_platform_thread_lock_mutex(&globalLock);
- VkLayerDispatchTable* pTable = tableMap[(VkBaseLayerObject *)device];
- VkResult res = pTable->CreateShader(device, pCreateInfo, pShader);
+ VkResult res = device_dispatch_table(device)->CreateShader(device, pCreateInfo, pShader);
shader_map[(VkBaseLayerObject *) *pShader] = new shader_source(pCreateInfo);
loader_platform_thread_unlock_mutex(&globalLock);
@@ -900,8 +856,7 @@ vkCreateGraphicsPipeline(VkDevice device,
/* The driver is allowed to crash if passed junk. Only actually create the
* pipeline if we didn't run into any showstoppers above.
*/
- VkLayerDispatchTable *pTable = tableMap[(VkBaseLayerObject *)device];
- return pTable->CreateGraphicsPipeline(device, pCreateInfo, pPipeline);
+ return device_dispatch_table(device)->CreateGraphicsPipeline(device, pCreateInfo, pPipeline);
}
else {
return VK_ERROR_UNKNOWN;
@@ -921,8 +876,7 @@ vkCreateGraphicsPipelineDerivative(VkDevice device,
/* The driver is allowed to crash if passed junk. Only actually create the
* pipeline if we didn't run into any showstoppers above.
*/
- VkLayerDispatchTable *pTable = tableMap[(VkBaseLayerObject *)device];
- return pTable->CreateGraphicsPipelineDerivative(device, pCreateInfo, basePipeline, pPipeline);
+ return device_dispatch_table(device)->CreateGraphicsPipelineDerivative(device, pCreateInfo, basePipeline, pPipeline);
}
else {
return VK_ERROR_UNKNOWN;
@@ -933,9 +887,9 @@ vkCreateGraphicsPipelineDerivative(VkDevice device,
/* hook DextroyDevice to remove tableMap entry */
VK_LAYER_EXPORT VkResult VKAPI vkDestroyDevice(VkDevice device)
{
- VkLayerDispatchTable *pTable = tableMap[(VkBaseLayerObject *)device];
- VkResult res = pTable->DestroyDevice(device);
- tableMap.erase(device);
+ VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) device;
+ VkResult res = device_dispatch_table(device)->DestroyDevice(device);
+ tableMap.erase(pDisp);
return res;
}
@@ -949,7 +903,7 @@ VkResult VKAPI vkCreateInstance(
* For layers, the pInstance has already been filled out
* by the loader so that dispatch table is available.
*/
- VkLayerInstanceDispatchTable *pTable = initLayerInstanceTable((const VkBaseLayerObject *) (*pInstance));
+ VkLayerInstanceDispatchTable *pTable = initInstanceTable((const VkBaseLayerObject *) (*pInstance));
VkResult result = pTable->CreateInstance(pCreateInfo, pInstance);
@@ -967,9 +921,9 @@ VkResult VKAPI vkCreateInstance(
/* hook DestroyInstance to remove tableInstanceMap entry */
VK_LAYER_EXPORT VkResult VKAPI vkDestroyInstance(VkInstance instance)
{
- VkLayerInstanceDispatchTable *pTable = tableInstanceMap[(VkBaseLayerObject *)instance];
- VkResult res = pTable->DestroyInstance(instance);
- tableInstanceMap.erase(instance);
+ VkLayerInstanceDispatchTable *pDisp = *(VkLayerInstanceDispatchTable **) instance;
+ VkResult res = instance_dispatch_table(instance)->DestroyInstance(instance);
+ tableInstanceMap.erase(pDisp);
return res;
}
@@ -1001,7 +955,7 @@ VK_LAYER_EXPORT void * VKAPI vkGetDeviceProcAddr(VkDevice device, const char* pN
/* loader uses this to force layer initialization; device object is wrapped */
if (!strcmp("vkGetDeviceProcAddr", pName)) {
- initLayerTable((const VkBaseLayerObject *) device);
+ initDeviceTable((const VkBaseLayerObject *) device);
return (void *) vkGetDeviceProcAddr;
}
@@ -1014,7 +968,7 @@ VK_LAYER_EXPORT void * VKAPI vkGetDeviceProcAddr(VkDevice device, const char* pN
ADD_HOOK(vkCreateGraphicsPipeline);
ADD_HOOK(vkCreateGraphicsPipelineDerivative);
#undef ADD_HOOK
- VkLayerDispatchTable* pTable = tableMap[(VkBaseLayerObject *)device];
+ VkLayerDispatchTable* pTable = device_dispatch_table(device);
if (pTable->GetDeviceProcAddr == NULL)
return NULL;
return pTable->GetDeviceProcAddr(device, pName);
@@ -1030,7 +984,7 @@ VK_LAYER_EXPORT void * VKAPI vkGetInstanceProcAddr(VkInstance inst, const char*
loader_platform_thread_once(&g_initOnce, initLayer);
if (!strcmp("vkGetInstanceProcAddr", pName)) {
- initLayerInstanceTable((const VkBaseLayerObject *) inst);
+ initInstanceTable((const VkBaseLayerObject *) inst);
return (void *) vkGetInstanceProcAddr;
}
#define ADD_HOOK(fn) \
@@ -1046,7 +1000,7 @@ VK_LAYER_EXPORT void * VKAPI vkGetInstanceProcAddr(VkInstance inst, const char*
if (fptr)
return fptr;
- VkLayerInstanceDispatchTable* pTable = tableInstanceMap[(VkBaseLayerObject *) inst];
+ VkLayerInstanceDispatchTable* pTable = instance_dispatch_table(inst);
if (pTable->GetInstanceProcAddr == NULL)
return NULL;
return pTable->GetInstanceProcAddr(inst, pName);
diff --git a/vk-layer-generate.py b/vk-layer-generate.py
index 99948c9a..bc40f7a3 100755
--- a/vk-layer-generate.py
+++ b/vk-layer-generate.py
@@ -428,8 +428,7 @@ class Subcommand(object):
func_body.append(' else if (!strcmp("%s", funcName))\n'
' return %s%s%s;' % (ext_name, cpp_prefix, ext_name, cpp_postfix))
func_body.append(" else {\n"
- " VkLayerDispatchTable **ppDisp = (VkLayerDispatchTable **) device;\n"
- " VkLayerDispatchTable* pTable = tableMap[*ppDisp];\n"
+ " VkLayerDispatchTable* pTable = device_dispatch_table(device);\n"
" if (pTable->GetDeviceProcAddr == NULL)\n"
" return NULL;\n"
" return pTable->GetDeviceProcAddr(device, funcName);\n"
@@ -458,13 +457,10 @@ class Subcommand(object):
" fptr = %s(funcName);\n"
" if (fptr) return fptr;\n"
" }\n" % ext_name)
- func_body.append(" {\n"
- " VkLayerInstanceDispatchTable **ppDisp = (VkLayerInstanceDispatchTable **) instance;\n"
- " VkLayerInstanceDispatchTable* pTable = tableInstanceMap[*ppDisp];\n"
- " if (pTable->GetInstanceProcAddr == NULL)\n"
- " return NULL;\n"
- " return pTable->GetInstanceProcAddr(instance, funcName);\n"
- " }\n"
+ func_body.append(" VkLayerInstanceDispatchTable* pTable = instance_dispatch_table(instance);\n"
+ " if (pTable->GetInstanceProcAddr == NULL)\n"
+ " return NULL;\n"
+ " return pTable->GetInstanceProcAddr(instance, funcName);\n"
"}\n")
return "\n".join(func_body)
@@ -501,49 +497,6 @@ class Subcommand(object):
func_body.append(" }")
func_body.append("}\n")
func_body.append('')
- func_body.append('static VkLayerDispatchTable * initDeviceTable(const VkBaseLayerObject *devw)')
- func_body.append(' {')
- func_body.append(' VkLayerDispatchTable *pTable;')
- func_body.append('')
- func_body.append(' assert(devw);')
- func_body.append(' VkLayerDispatchTable **ppDisp = (VkLayerDispatchTable **) (devw->baseObject);')
- func_body.append('')
- func_body.append(' std::unordered_map<void *, VkLayerDispatchTable *>::const_iterator it = tableMap.find((void *) *ppDisp);')
- func_body.append(' if (it == tableMap.end())')
- func_body.append(' {')
- func_body.append(' pTable = new VkLayerDispatchTable;')
- func_body.append(' tableMap[(void *) *ppDisp] = pTable;')
- func_body.append(' } else')
- func_body.append(' {')
- func_body.append(' return it->second;')
- func_body.append(' }')
- func_body.append('')
- func_body.append(' layer_initialize_dispatch_table(pTable, devw);')
- func_body.append('')
- func_body.append(' return pTable;')
- func_body.append('}')
- func_body.append('')
- func_body.append('static VkLayerInstanceDispatchTable * initInstanceTable(const VkBaseLayerObject *instw)')
- func_body.append(' {')
- func_body.append(' VkLayerInstanceDispatchTable *pTable;')
- func_body.append(' assert(instw);')
- func_body.append(' VkLayerInstanceDispatchTable **ppDisp = (VkLayerInstanceDispatchTable **) instw->baseObject;')
- func_body.append('')
- func_body.append(' std::unordered_map<void *, VkLayerInstanceDispatchTable *>::const_iterator it = tableInstanceMap.find((void *) *ppDisp);')
- func_body.append(' if (it == tableInstanceMap.end())')
- func_body.append(' {')
- func_body.append(' pTable = new VkLayerInstanceDispatchTable;')
- func_body.append(' tableInstanceMap[(void *) *ppDisp] = pTable;')
- func_body.append(' } else')
- func_body.append(' {')
- func_body.append(' return it->second;')
- func_body.append(' }')
- func_body.append('')
- func_body.append(' layer_init_instance_dispatch_table(pTable, instw);')
- func_body.append('')
- func_body.append(' return pTable;')
- func_body.append('}')
- func_body.append('')
return "\n".join(func_body)
class LayerFuncsSubcommand(Subcommand):
@@ -574,23 +527,10 @@ class GenericLayerSubcommand(Subcommand):
gen_header.append('#include "loader_platform.h"')
gen_header.append('#include "layers_config.h"')
gen_header.append('#include "layers_msg.h"')
- gen_header.append('')
- gen_header.append('static std::unordered_map<void *, VkLayerDispatchTable *> tableMap;')
- gen_header.append('static std::unordered_map<void *, VkLayerInstanceDispatchTable *> tableInstanceMap;')
+ gen_header.append('#include "layers_table.h"')
gen_header.append('')
gen_header.append('static LOADER_PLATFORM_THREAD_ONCE_DECLARATION(initOnce);')
gen_header.append('')
- gen_header.append(' static inline VkLayerDispatchTable *device_dispatch_table(VkObject object) {')
- gen_header.append(' VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) object;')
- gen_header.append(' VkLayerDispatchTable *pTable = tableMap[pDisp];')
- gen_header.append(' return pTable;')
- gen_header.append('}')
- gen_header.append('')
- gen_header.append('static inline VkLayerInstanceDispatchTable *instance_dispatch_table(VkObject object) {')
- gen_header.append(' VkLayerInstanceDispatchTable **ppDisp = (VkLayerInstanceDispatchTable **) object;')
- gen_header.append(' VkLayerInstanceDispatchTable *pInstanceTable = tableInstanceMap[*ppDisp];')
- gen_header.append(' return pInstanceTable;')
- gen_header.append('}')
return "\n".join(gen_header)
def generate_intercept(self, proto, qual):
if proto.name in [ 'GetGlobalExtensionInfo', 'GetPhysicalDeviceExtensionInfo' ]:
@@ -700,18 +640,15 @@ class APIDumpSubcommand(Subcommand):
header_txt.append('#include "loader_platform.h"')
header_txt.append('#include "vkLayer.h"')
header_txt.append('#include "vk_struct_string_helper_cpp.h"')
+ header_txt.append('#include "layers_table.h"')
header_txt.append('#include <unordered_map>')
header_txt.append('')
header_txt.append('// The following is #included again to catch certain OS-specific functions being used:')
header_txt.append('#include "loader_platform.h"')
header_txt.append('')
- header_txt.append('static VkLayerDispatchTable nextTable;')
- header_txt.append('static VkLayerInstanceDispatchTable nextInstanceTable;')
header_txt.append('static VkBaseLayerObject *pCurObj;')
header_txt.append('static bool g_APIDumpDetailed = true;')
header_txt.append('')
- header_txt.append('static std::unordered_map<void *, VkLayerDispatchTable *> tableMap;')
- header_txt.append('static std::unordered_map<void *, VkLayerInstanceDispatchTable *> tableInstanceMap;')
header_txt.append('static LOADER_PLATFORM_THREAD_ONCE_DECLARATION(initOnce);')
header_txt.append('')
header_txt.append('static int printLockInitialized = 0;')
@@ -735,17 +672,6 @@ class APIDumpSubcommand(Subcommand):
header_txt.append(' return retVal;')
header_txt.append('}')
header_txt.append('')
- header_txt.append('static inline VkLayerDispatchTable *device_dispatch_table(VkObject object) {')
- header_txt.append(' VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) object;')
- header_txt.append(' VkLayerDispatchTable *pTable = tableMap[pDisp];')
- header_txt.append(' return pTable;')
- header_txt.append('}')
- header_txt.append('')
- header_txt.append('static inline VkLayerInstanceDispatchTable *instance_dispatch_table(VkObject object) {')
- header_txt.append(' VkLayerInstanceDispatchTable **ppDisp = (VkLayerInstanceDispatchTable **) object;')
- header_txt.append(' VkLayerInstanceDispatchTable *pInstanceTable = tableInstanceMap[*ppDisp];')
- header_txt.append(' return pInstanceTable;')
- header_txt.append('}')
return "\n".join(header_txt)
def generate_init(self):
@@ -821,49 +747,6 @@ class APIDumpSubcommand(Subcommand):
func_body.append(' }')
func_body.append('}')
func_body.append('')
- func_body.append('static VkLayerDispatchTable * initDeviceTable(const VkBaseLayerObject *devw)')
- func_body.append(' {')
- func_body.append(' VkLayerDispatchTable *pTable;')
- func_body.append('')
- func_body.append(' assert(devw);')
- func_body.append(' VkLayerDispatchTable **ppDisp = (VkLayerDispatchTable **) (devw->baseObject);')
- func_body.append('')
- func_body.append(' std::unordered_map<void *, VkLayerDispatchTable *>::const_iterator it = tableMap.find((void *) *ppDisp);')
- func_body.append(' if (it == tableMap.end())')
- func_body.append(' {')
- func_body.append(' pTable = new VkLayerDispatchTable;')
- func_body.append(' tableMap[(void *) *ppDisp] = pTable;')
- func_body.append(' } else')
- func_body.append(' {')
- func_body.append(' return it->second;')
- func_body.append(' }')
- func_body.append('')
- func_body.append(' layer_initialize_dispatch_table(pTable, devw);')
- func_body.append('')
- func_body.append(' return pTable;')
- func_body.append('}')
- func_body.append('')
- func_body.append('static VkLayerInstanceDispatchTable * initInstanceTable(const VkBaseLayerObject *instw)')
- func_body.append(' {')
- func_body.append(' VkLayerInstanceDispatchTable *pTable;')
- func_body.append(' assert(instw);')
- func_body.append(' VkLayerInstanceDispatchTable **ppDisp = (VkLayerInstanceDispatchTable **) instw->baseObject;')
- func_body.append('')
- func_body.append(' std::unordered_map<void *, VkLayerInstanceDispatchTable *>::const_iterator it = tableInstanceMap.find((void *) *ppDisp);')
- func_body.append(' if (it == tableInstanceMap.end())')
- func_body.append(' {')
- func_body.append(' pTable = new VkLayerInstanceDispatchTable;')
- func_body.append(' tableInstanceMap[(void *) *ppDisp] = pTable;')
- func_body.append(' } else')
- func_body.append(' {')
- func_body.append(' return it->second;')
- func_body.append(' }')
- func_body.append('')
- func_body.append(' layer_init_instance_dispatch_table(pTable, instw);')
- func_body.append('')
- func_body.append(' return pTable;')
- func_body.append('}')
- func_body.append('')
return "\n".join(func_body)
def generate_intercept(self, proto, qual):
@@ -1044,23 +927,10 @@ class ObjectTrackerSubcommand(Subcommand):
header_txt.append('#include "layers_config.h"')
header_txt.append('#include "layers_msg.h"')
header_txt.append('#include "vk_debug_report_lunarg.h"')
+ header_txt.append('#include "layers_table.h"')
header_txt.append('')
- header_txt.append('static std::unordered_map<void *, VkLayerDispatchTable *> tableMap;')
- header_txt.append('static std::unordered_map<void *, VkLayerInstanceDispatchTable *> tableInstanceMap;')
header_txt.append('static LOADER_PLATFORM_THREAD_ONCE_DECLARATION(initOnce);')
header_txt.append('')
- header_txt.append('static inline VkLayerDispatchTable *device_dispatch_table(VkObject object) {')
- header_txt.append(' VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) object;')
- header_txt.append(' VkLayerDispatchTable *pTable = tableMap[pDisp];')
- header_txt.append(' return pTable;')
- header_txt.append('}')
- header_txt.append('')
- header_txt.append('static inline VkLayerInstanceDispatchTable *instance_dispatch_table(VkObject object) {')
- header_txt.append(' VkLayerInstanceDispatchTable **ppDisp = (VkLayerInstanceDispatchTable **) object;')
- header_txt.append(' VkLayerInstanceDispatchTable *pInstanceTable = tableInstanceMap[*ppDisp];')
- header_txt.append(' return pInstanceTable;')
- header_txt.append('}')
- header_txt.append('')
header_txt.append('static long long unsigned int object_track_index = 0;')
header_txt.append('static int objLockInitialized = 0;')
header_txt.append('static loader_platform_thread_mutex objLock;')
@@ -1503,24 +1373,11 @@ class ThreadingSubcommand(Subcommand):
header_txt.append('//The following is #included again to catch certain OS-specific functions being used:')
header_txt.append('#include "loader_platform.h"\n')
header_txt.append('#include "layers_msg.h"\n')
+ header_txt.append('#include "layers_table.h"\n')
header_txt.append('')
- header_txt.append('static std::unordered_map<void *, VkLayerDispatchTable *> tableMap;')
- header_txt.append('static std::unordered_map<void *, VkLayerInstanceDispatchTable *> tableInstanceMap;')
header_txt.append('')
header_txt.append('static LOADER_PLATFORM_THREAD_ONCE_DECLARATION(initOnce);')
header_txt.append('')
- header_txt.append('static inline VkLayerDispatchTable *device_dispatch_table(VkObject object) {')
- header_txt.append(' VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) object;')
- header_txt.append(' VkLayerDispatchTable *pTable = tableMap[pDisp];')
- header_txt.append(' return pTable;')
- header_txt.append('}')
- header_txt.append('')
- header_txt.append('static inline VkLayerInstanceDispatchTable *instance_dispatch_table(VkObject object) {')
- header_txt.append(' VkLayerInstanceDispatchTable **ppDisp = (VkLayerInstanceDispatchTable **) object;')
- header_txt.append(' VkLayerInstanceDispatchTable *pInstanceTable = tableInstanceMap[*ppDisp];')
- header_txt.append(' return pInstanceTable;')
- header_txt.append('}')
- header_txt.append('')
header_txt.append('using namespace std;')
header_txt.append('static unordered_map<int, void*> proxy_objectsInUse;\n')
header_txt.append('static unordered_map<VkObject, loader_platform_thread_id> objectsInUse;\n')