aboutsummaryrefslogtreecommitdiff
path: root/layers/image.cpp
diff options
context:
space:
mode:
authorChia-I Wu <olv@google.com>2016-04-28 14:38:57 +0800
committerTobin Ehlis <tobine@google.com>2016-05-05 06:42:18 -0600
commitc9295376891e6e84cc4ea6754ce85d42b8a2f0da (patch)
tree2768564f2154aa4769195531e5bcb433f07a6314 /layers/image.cpp
parent238e332d5ebd89130dec404148e2356e557e3f28 (diff)
downloadusermoji-c9295376891e6e84cc4ea6754ce85d42b8a2f0da.tar.xz
image: 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/image.cpp')
-rw-r--r--layers/image.cpp76
1 files changed, 40 insertions, 36 deletions
diff --git a/layers/image.cpp b/layers/image.cpp
index 10bc65e1..9a914801 100644
--- a/layers/image.cpp
+++ b/layers/image.cpp
@@ -1257,43 +1257,15 @@ VKAPI_ATTR VkResult VKAPI_CALL EnumerateDeviceExtensionProperties(VkPhysicalDevi
return pTable->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(funcName, "vkGetDeviceProcAddr"))
- return (PFN_vkVoidFunction)GetDeviceProcAddr;
- if (!strcmp(funcName, "vkDestroyDevice"))
- return (PFN_vkVoidFunction)DestroyDevice;
- if (!strcmp(funcName, "vkCreateImage"))
- return (PFN_vkVoidFunction)CreateImage;
- if (!strcmp(funcName, "vkDestroyImage"))
- return (PFN_vkVoidFunction)DestroyImage;
- if (!strcmp(funcName, "vkCreateImageView"))
- return (PFN_vkVoidFunction)CreateImageView;
- if (!strcmp(funcName, "vkCreateRenderPass"))
- return (PFN_vkVoidFunction)CreateRenderPass;
- if (!strcmp(funcName, "vkCmdClearColorImage"))
- return (PFN_vkVoidFunction)CmdClearColorImage;
- if (!strcmp(funcName, "vkCmdClearDepthStencilImage"))
- return (PFN_vkVoidFunction)CmdClearDepthStencilImage;
- if (!strcmp(funcName, "vkCmdClearAttachments"))
- return (PFN_vkVoidFunction)CmdClearAttachments;
- if (!strcmp(funcName, "vkCmdCopyImage"))
- return (PFN_vkVoidFunction)CmdCopyImage;
- if (!strcmp(funcName, "vkCmdCopyImageToBuffer"))
- return (PFN_vkVoidFunction)CmdCopyImageToBuffer;
- if (!strcmp(funcName, "vkCmdCopyBufferToImage"))
- return (PFN_vkVoidFunction)CmdCopyBufferToImage;
- if (!strcmp(funcName, "vkCmdBlitImage"))
- return (PFN_vkVoidFunction)CmdBlitImage;
- if (!strcmp(funcName, "vkCmdPipelineBarrier"))
- return (PFN_vkVoidFunction)CmdPipelineBarrier;
- if (!strcmp(funcName, "vkCmdResolveImage"))
- return (PFN_vkVoidFunction)CmdResolveImage;
- if (!strcmp(funcName, "vkGetImageSubresourceLayout"))
- return (PFN_vkVoidFunction)GetImageSubresourceLayout;
-
- if (device == NULL) {
- return NULL;
- }
+ PFN_vkVoidFunction proc = intercept_core_device_command(funcName);
+ if (proc)
+ return proc;
+
+ assert(device);
layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map);
@@ -1341,6 +1313,38 @@ 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) },
+ { "vkCreateImage", reinterpret_cast<PFN_vkVoidFunction>(CreateImage) },
+ { "vkDestroyImage", reinterpret_cast<PFN_vkVoidFunction>(DestroyImage) },
+ { "vkCreateImageView", reinterpret_cast<PFN_vkVoidFunction>(CreateImageView) },
+ { "vkCreateRenderPass", reinterpret_cast<PFN_vkVoidFunction>(CreateRenderPass) },
+ { "vkCmdClearColorImage", reinterpret_cast<PFN_vkVoidFunction>(CmdClearColorImage) },
+ { "vkCmdClearDepthStencilImage", reinterpret_cast<PFN_vkVoidFunction>(CmdClearDepthStencilImage) },
+ { "vkCmdClearAttachments", reinterpret_cast<PFN_vkVoidFunction>(CmdClearAttachments) },
+ { "vkCmdCopyImage", reinterpret_cast<PFN_vkVoidFunction>(CmdCopyImage) },
+ { "vkCmdCopyImageToBuffer", reinterpret_cast<PFN_vkVoidFunction>(CmdCopyImageToBuffer) },
+ { "vkCmdCopyBufferToImage", reinterpret_cast<PFN_vkVoidFunction>(CmdCopyBufferToImage) },
+ { "vkCmdBlitImage", reinterpret_cast<PFN_vkVoidFunction>(CmdBlitImage) },
+ { "vkCmdPipelineBarrier", reinterpret_cast<PFN_vkVoidFunction>(CmdPipelineBarrier) },
+ { "vkCmdResolveImage", reinterpret_cast<PFN_vkVoidFunction>(CmdResolveImage) },
+ { "vkGetImageSubresourceLayout", reinterpret_cast<PFN_vkVoidFunction>(GetImageSubresourceLayout) },
+ };
+
+ 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 image
// vk_layer_logging.h expects these to be defined