diff options
| author | Chia-I Wu <olv@google.com> | 2016-04-28 14:38:57 +0800 |
|---|---|---|
| committer | Chia-I Wu <olv@google.com> | 2016-05-13 10:35:37 +0800 |
| commit | a17745fcc1ce5febef0ea744fabf3f823a272053 (patch) | |
| tree | 359fe93653b3f8258612a70494aaadcdd73f0bb7 /layers/swapchain.cpp | |
| parent | 1695c66fd68e3607d07e44c891328d7bb4292842 (diff) | |
| download | usermoji-a17745fcc1ce5febef0ea744fabf3f823a272053.tar.xz | |
swapchain: add intercept_core_device_command
It returns the function pointers for all intercepted core device commands.
Call intercept_core_device_command from GetDeviceProcAddr. Assert that
device is valid in GetDeviceProcAddr.
Diffstat (limited to 'layers/swapchain.cpp')
| -rw-r--r-- | layers/swapchain.cpp | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/layers/swapchain.cpp b/layers/swapchain.cpp index bcdf151b..6cad92e8 100644 --- a/layers/swapchain.cpp +++ b/layers/swapchain.cpp @@ -2133,15 +2133,15 @@ VKAPI_ATTR VkResult VKAPI_CALL EnumerateDeviceExtensionProperties(VkPhysicalDevi return my_data->instance_dispatch_table->EnumerateDeviceExtensionProperties(physicalDevice, NULL, pCount, pProperties); } +static PFN_vkVoidFunction +intercept_core_device_command(const char *name); + VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetDeviceProcAddr(VkDevice device, const char *funcName) { - if (!strcmp("vkGetDeviceProcAddr", funcName)) - return (PFN_vkVoidFunction)GetDeviceProcAddr; - if (!strcmp(funcName, "vkDestroyDevice")) - return (PFN_vkVoidFunction)DestroyDevice; + PFN_vkVoidFunction proc = intercept_core_device_command(funcName); + if (proc) + return proc; - if (device == VK_NULL_HANDLE) { - return NULL; - } + assert(device); layer_data *my_data; @@ -2157,8 +2157,6 @@ VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetDeviceProcAddr(VkDevice device, cons return reinterpret_cast<PFN_vkVoidFunction>(AcquireNextImageKHR); if (!strcmp("vkQueuePresentKHR", funcName)) return reinterpret_cast<PFN_vkVoidFunction>(QueuePresentKHR); - if (!strcmp("vkGetDeviceQueue", funcName)) - return reinterpret_cast<PFN_vkVoidFunction>(GetDeviceQueue); if (pDisp->GetDeviceProcAddr == NULL) return NULL; @@ -2251,6 +2249,25 @@ VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetInstanceProcAddr(VkInstance instance return pTable->GetInstanceProcAddr(instance, funcName); } +static PFN_vkVoidFunction +intercept_core_device_command(const char *name) { + static const struct { + const char *name; + PFN_vkVoidFunction proc; + } core_device_commands[] = { + { "vkGetDeviceProcAddr", reinterpret_cast<PFN_vkVoidFunction>(GetDeviceProcAddr) }, + { "vkDestroyDevice", reinterpret_cast<PFN_vkVoidFunction>(DestroyDevice) }, + { "vkGetDeviceQueue", reinterpret_cast<PFN_vkVoidFunction>(GetDeviceQueue) }, + }; + + for (size_t i = 0; i < ARRAY_SIZE(core_device_commands); i++) { + if (!strcmp(core_device_commands[i].name, name)) + return core_device_commands[i].proc; + } + + return nullptr; +} + } // namespace swapchain // vk_layer_logging.h expects these to be defined |
