diff options
| author | Chia-I Wu <olvaffe@gmail.com> | 2016-05-05 16:13:19 +0800 |
|---|---|---|
| committer | Chia-I Wu <olv@google.com> | 2016-05-13 10:35:37 +0800 |
| commit | 247abbbb9487e72c10f6b61bc100316b5c6e0e0f (patch) | |
| tree | f98dbe4c557b40ac0f831a7c4369a42a07883615 | |
| parent | a17745fcc1ce5febef0ea744fabf3f823a272053 (diff) | |
| download | usermoji-247abbbb9487e72c10f6b61bc100316b5c6e0e0f.tar.xz | |
swapchain: add intercept_khr_swapchain_command
It returns the function pointers for all intercepted VK_KHR_swapchain
commands. Call intercept_khr_swapchain_command from GetDeviceProcAddr.
| -rw-r--r-- | layers/swapchain.cpp | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/layers/swapchain.cpp b/layers/swapchain.cpp index 6cad92e8..0f49cac3 100644 --- a/layers/swapchain.cpp +++ b/layers/swapchain.cpp @@ -2136,6 +2136,9 @@ VKAPI_ATTR VkResult VKAPI_CALL EnumerateDeviceExtensionProperties(VkPhysicalDevi static PFN_vkVoidFunction intercept_core_device_command(const char *name); +static PFN_vkVoidFunction +intercept_khr_swapchain_command(const char *name, VkDevice dev); + VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetDeviceProcAddr(VkDevice device, const char *funcName) { PFN_vkVoidFunction proc = intercept_core_device_command(funcName); if (proc) @@ -2147,16 +2150,10 @@ VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetDeviceProcAddr(VkDevice device, cons my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); VkLayerDispatchTable *pDisp = my_data->device_dispatch_table; - if (!strcmp("vkCreateSwapchainKHR", funcName)) - return reinterpret_cast<PFN_vkVoidFunction>(CreateSwapchainKHR); - if (!strcmp("vkDestroySwapchainKHR", funcName)) - return reinterpret_cast<PFN_vkVoidFunction>(DestroySwapchainKHR); - if (!strcmp("vkGetSwapchainImagesKHR", funcName)) - return reinterpret_cast<PFN_vkVoidFunction>(GetSwapchainImagesKHR); - if (!strcmp("vkAcquireNextImageKHR", funcName)) - return reinterpret_cast<PFN_vkVoidFunction>(AcquireNextImageKHR); - if (!strcmp("vkQueuePresentKHR", funcName)) - return reinterpret_cast<PFN_vkVoidFunction>(QueuePresentKHR); + + proc = intercept_khr_swapchain_command(funcName, device); + if (proc) + return proc; if (pDisp->GetDeviceProcAddr == NULL) return NULL; @@ -2268,6 +2265,29 @@ intercept_core_device_command(const char *name) { return nullptr; } +static PFN_vkVoidFunction +intercept_khr_swapchain_command(const char *name, VkDevice dev) { + static const struct { + const char *name; + PFN_vkVoidFunction proc; + } khr_swapchain_commands[] = { + { "vkCreateSwapchainKHR", reinterpret_cast<PFN_vkVoidFunction>(CreateSwapchainKHR) }, + { "vkDestroySwapchainKHR", reinterpret_cast<PFN_vkVoidFunction>(DestroySwapchainKHR) }, + { "vkGetSwapchainImagesKHR", reinterpret_cast<PFN_vkVoidFunction>(GetSwapchainImagesKHR) }, + { "vkAcquireNextImageKHR", reinterpret_cast<PFN_vkVoidFunction>(AcquireNextImageKHR) }, + { "vkQueuePresentKHR", reinterpret_cast<PFN_vkVoidFunction>(QueuePresentKHR) }, + }; + + // do not check if VK_KHR_swapchain is enabled (why?) + + for (size_t i = 0; i < ARRAY_SIZE(khr_swapchain_commands); i++) { + if (!strcmp(khr_swapchain_commands[i].name, name)) + return khr_swapchain_commands[i].proc; + } + + return nullptr; +} + } // namespace swapchain // vk_layer_logging.h expects these to be defined |
