From a2de09baf4bd61cc1faab9964b2a0dd9e2906517 Mon Sep 17 00:00:00 2001 From: Mark Lobodzinski Date: Wed, 8 Feb 2017 15:27:18 -0700 Subject: [PATCH] layers: Enable autogen'd procmap for PV Routines and tables were previously hard-coded. They are now generated from vk.xml. Change-Id: I26c98bb42c9ccc287e9dd4c12447d66ea1c68d91 --- layers/parameter_validation.cpp | 396 ++-------------------------------------- 1 file changed, 19 insertions(+), 377 deletions(-) diff --git a/layers/parameter_validation.cpp b/layers/parameter_validation.cpp index 846526f..bbd9260 100644 --- a/layers/parameter_validation.cpp +++ b/layers/parameter_validation.cpp @@ -6111,402 +6111,44 @@ VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceGeneratedCommandsPropertiesNVX(VkPhy } } -static PFN_vkVoidFunction intercept_core_instance_command(const char *name); - -static PFN_vkVoidFunction intercept_core_device_command(const char *name); - -static PFN_vkVoidFunction InterceptWsiEnabledCommand(const char *name, VkDevice device); - -static PFN_vkVoidFunction InterceptWsiEnabledCommand(const char *name, VkInstance instance); - -static PFN_vkVoidFunction intercept_extension_instance_command(const char *name, VkInstance instance); - -static PFN_vkVoidFunction intercept_extension_device_command(const char *name, VkDevice device); +static inline PFN_vkVoidFunction layer_intercept_proc(const char *name) { + for (unsigned int i = 0; i < sizeof(procmap) / sizeof(procmap[0]); i++) { + if (!strcmp(name, procmap[i].name)) return procmap[i].pFunc; + } + return NULL; +} VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetDeviceProcAddr(VkDevice device, const char *funcName) { assert(device); - layer_data *data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); - - if (validate_string(data->report_data, "vkGetDeviceProcAddr", "funcName", funcName)) { - return NULL; - } - - PFN_vkVoidFunction proc = intercept_core_device_command(funcName); - if (proc) return proc; + PFN_vkVoidFunction addr = layer_intercept_proc(funcName); + if (addr) return addr; - proc = InterceptWsiEnabledCommand(funcName, device); - if (proc) return proc; + layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); - proc = intercept_extension_device_command(funcName, device); - if (proc) return proc; - - if (!data->dispatch_table.GetDeviceProcAddr) return nullptr; - return data->dispatch_table.GetDeviceProcAddr(device, funcName); + if (!dev_data->dispatch_table.GetDeviceProcAddr) return nullptr; + return dev_data->dispatch_table.GetDeviceProcAddr(device, funcName); } VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetInstanceProcAddr(VkInstance instance, const char *funcName) { - PFN_vkVoidFunction proc = intercept_core_instance_command(funcName); - if (!proc) proc = intercept_core_device_command(funcName); - - if (!proc) proc = InterceptWsiEnabledCommand(funcName, VkDevice(VK_NULL_HANDLE)); - if (proc) return proc; + PFN_vkVoidFunction addr = layer_intercept_proc(funcName); + if (addr) return addr; assert(instance); - auto data = GetLayerDataPtr(get_dispatch_key(instance), instance_layer_data_map); - - proc = debug_report_get_instance_proc_addr(data->report_data, funcName); - if (!proc) proc = InterceptWsiEnabledCommand(funcName, instance); - - if (!proc) proc = intercept_extension_instance_command(funcName, instance); + auto instance_data = GetLayerDataPtr(get_dispatch_key(instance), instance_layer_data_map); - if (proc) return proc; - - if (!data->dispatch_table.GetInstanceProcAddr) return nullptr; - return data->dispatch_table.GetInstanceProcAddr(instance, funcName); + if (!instance_data->dispatch_table.GetInstanceProcAddr) return nullptr; + return instance_data->dispatch_table.GetInstanceProcAddr(instance, funcName); } VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetPhysicalDeviceProcAddr(VkInstance instance, const char *funcName) { assert(instance); - auto data = GetLayerDataPtr(get_dispatch_key(instance), instance_layer_data_map); - - if (!data->dispatch_table.GetPhysicalDeviceProcAddr) return nullptr; - return data->dispatch_table.GetPhysicalDeviceProcAddr(instance, funcName); -} - -static PFN_vkVoidFunction intercept_core_instance_command(const char *name) { - static const struct { - const char *name; - PFN_vkVoidFunction proc; - } core_instance_commands[] = { - {"vkGetInstanceProcAddr", reinterpret_cast(GetInstanceProcAddr)}, - {"vkCreateInstance", reinterpret_cast(CreateInstance)}, - {"vkDestroyInstance", reinterpret_cast(DestroyInstance)}, - {"vkCreateDevice", reinterpret_cast(CreateDevice)}, - {"vkEnumeratePhysicalDevices", reinterpret_cast(EnumeratePhysicalDevices)}, - {"vk_layerGetPhysicalDeviceProcAddr", reinterpret_cast(GetPhysicalDeviceProcAddr)}, - {"vkGetPhysicalDeviceProperties", reinterpret_cast(GetPhysicalDeviceProperties)}, - {"vkGetPhysicalDeviceFeatures", reinterpret_cast(GetPhysicalDeviceFeatures)}, - {"vkGetPhysicalDeviceFormatProperties", reinterpret_cast(GetPhysicalDeviceFormatProperties)}, - {"vkGetPhysicalDeviceImageFormatProperties", reinterpret_cast(GetPhysicalDeviceImageFormatProperties)}, - {"vkGetPhysicalDeviceSparseImageFormatProperties", - reinterpret_cast(GetPhysicalDeviceSparseImageFormatProperties)}, - {"vkGetPhysicalDeviceQueueFamilyProperties", reinterpret_cast(GetPhysicalDeviceQueueFamilyProperties)}, - {"vkGetPhysicalDeviceMemoryProperties", reinterpret_cast(GetPhysicalDeviceMemoryProperties)}, - {"vkEnumerateInstanceLayerProperties", reinterpret_cast(EnumerateInstanceLayerProperties)}, - {"vkEnumerateDeviceLayerProperties", reinterpret_cast(EnumerateDeviceLayerProperties)}, - {"vkEnumerateInstanceExtensionProperties", reinterpret_cast(EnumerateInstanceExtensionProperties)}, - {"vkEnumerateDeviceExtensionProperties", reinterpret_cast(EnumerateDeviceExtensionProperties)}, - {"vkGetPhysicalDeviceExternalImageFormatPropertiesNV", - reinterpret_cast(GetPhysicalDeviceExternalImageFormatPropertiesNV)}, - // NVX_device_generated_commands - {"vkGetPhysicalDeviceGeneratedCommandsPropertiesNVX", - reinterpret_cast(GetPhysicalDeviceGeneratedCommandsPropertiesNVX)}, - }; - - for (size_t i = 0; i < ARRAY_SIZE(core_instance_commands); i++) { - if (!strcmp(core_instance_commands[i].name, name)) return core_instance_commands[i].proc; - } - - return nullptr; -} - -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(GetDeviceProcAddr)}, - {"vkDestroyDevice", reinterpret_cast(DestroyDevice)}, - {"vkGetDeviceQueue", reinterpret_cast(GetDeviceQueue)}, - {"vkQueueSubmit", reinterpret_cast(QueueSubmit)}, - {"vkQueueWaitIdle", reinterpret_cast(QueueWaitIdle)}, - {"vkDeviceWaitIdle", reinterpret_cast(DeviceWaitIdle)}, - {"vkAllocateMemory", reinterpret_cast(AllocateMemory)}, - {"vkFreeMemory", reinterpret_cast(FreeMemory)}, - {"vkMapMemory", reinterpret_cast(MapMemory)}, - {"vkUnmapMemory", reinterpret_cast(UnmapMemory)}, - {"vkFlushMappedMemoryRanges", reinterpret_cast(FlushMappedMemoryRanges)}, - {"vkInvalidateMappedMemoryRanges", reinterpret_cast(InvalidateMappedMemoryRanges)}, - {"vkGetDeviceMemoryCommitment", reinterpret_cast(GetDeviceMemoryCommitment)}, - {"vkBindBufferMemory", reinterpret_cast(BindBufferMemory)}, - {"vkBindImageMemory", reinterpret_cast(BindImageMemory)}, - {"vkCreateFence", reinterpret_cast(CreateFence)}, - {"vkDestroyFence", reinterpret_cast(DestroyFence)}, - {"vkResetFences", reinterpret_cast(ResetFences)}, - {"vkGetFenceStatus", reinterpret_cast(GetFenceStatus)}, - {"vkWaitForFences", reinterpret_cast(WaitForFences)}, - {"vkCreateSemaphore", reinterpret_cast(CreateSemaphore)}, - {"vkDestroySemaphore", reinterpret_cast(DestroySemaphore)}, - {"vkCreateEvent", reinterpret_cast(CreateEvent)}, - {"vkDestroyEvent", reinterpret_cast(DestroyEvent)}, - {"vkGetEventStatus", reinterpret_cast(GetEventStatus)}, - {"vkSetEvent", reinterpret_cast(SetEvent)}, - {"vkResetEvent", reinterpret_cast(ResetEvent)}, - {"vkCreateQueryPool", reinterpret_cast(CreateQueryPool)}, - {"vkDestroyQueryPool", reinterpret_cast(DestroyQueryPool)}, - {"vkGetQueryPoolResults", reinterpret_cast(GetQueryPoolResults)}, - {"vkCreateBuffer", reinterpret_cast(CreateBuffer)}, - {"vkDestroyBuffer", reinterpret_cast(DestroyBuffer)}, - {"vkCreateBufferView", reinterpret_cast(CreateBufferView)}, - {"vkDestroyBufferView", reinterpret_cast(DestroyBufferView)}, - {"vkCreateImage", reinterpret_cast(CreateImage)}, - {"vkDestroyImage", reinterpret_cast(DestroyImage)}, - {"vkGetImageSubresourceLayout", reinterpret_cast(GetImageSubresourceLayout)}, - {"vkCreateImageView", reinterpret_cast(CreateImageView)}, - {"vkDestroyImageView", reinterpret_cast(DestroyImageView)}, - {"vkCreateShaderModule", reinterpret_cast(CreateShaderModule)}, - {"vkDestroyShaderModule", reinterpret_cast(DestroyShaderModule)}, - {"vkCreatePipelineCache", reinterpret_cast(CreatePipelineCache)}, - {"vkDestroyPipelineCache", reinterpret_cast(DestroyPipelineCache)}, - {"vkGetPipelineCacheData", reinterpret_cast(GetPipelineCacheData)}, - {"vkMergePipelineCaches", reinterpret_cast(MergePipelineCaches)}, - {"vkCreateGraphicsPipelines", reinterpret_cast(CreateGraphicsPipelines)}, - {"vkCreateComputePipelines", reinterpret_cast(CreateComputePipelines)}, - {"vkDestroyPipeline", reinterpret_cast(DestroyPipeline)}, - {"vkCreatePipelineLayout", reinterpret_cast(CreatePipelineLayout)}, - {"vkDestroyPipelineLayout", reinterpret_cast(DestroyPipelineLayout)}, - {"vkCreateSampler", reinterpret_cast(CreateSampler)}, - {"vkDestroySampler", reinterpret_cast(DestroySampler)}, - {"vkCreateDescriptorSetLayout", reinterpret_cast(CreateDescriptorSetLayout)}, - {"vkDestroyDescriptorSetLayout", reinterpret_cast(DestroyDescriptorSetLayout)}, - {"vkCreateDescriptorPool", reinterpret_cast(CreateDescriptorPool)}, - {"vkDestroyDescriptorPool", reinterpret_cast(DestroyDescriptorPool)}, - {"vkResetDescriptorPool", reinterpret_cast(ResetDescriptorPool)}, - {"vkAllocateDescriptorSets", reinterpret_cast(AllocateDescriptorSets)}, - {"vkFreeDescriptorSets", reinterpret_cast(FreeDescriptorSets)}, - {"vkUpdateDescriptorSets", reinterpret_cast(UpdateDescriptorSets)}, - {"vkCmdSetViewport", reinterpret_cast(CmdSetViewport)}, - {"vkCmdSetScissor", reinterpret_cast(CmdSetScissor)}, - {"vkCmdSetLineWidth", reinterpret_cast(CmdSetLineWidth)}, - {"vkCmdSetDepthBias", reinterpret_cast(CmdSetDepthBias)}, - {"vkCmdSetBlendConstants", reinterpret_cast(CmdSetBlendConstants)}, - {"vkCmdSetDepthBounds", reinterpret_cast(CmdSetDepthBounds)}, - {"vkCmdSetStencilCompareMask", reinterpret_cast(CmdSetStencilCompareMask)}, - {"vkCmdSetStencilWriteMask", reinterpret_cast(CmdSetStencilWriteMask)}, - {"vkCmdSetStencilReference", reinterpret_cast(CmdSetStencilReference)}, - {"vkAllocateCommandBuffers", reinterpret_cast(AllocateCommandBuffers)}, - {"vkFreeCommandBuffers", reinterpret_cast(FreeCommandBuffers)}, - {"vkBeginCommandBuffer", reinterpret_cast(BeginCommandBuffer)}, - {"vkEndCommandBuffer", reinterpret_cast(EndCommandBuffer)}, - {"vkResetCommandBuffer", reinterpret_cast(ResetCommandBuffer)}, - {"vkCmdBindPipeline", reinterpret_cast(CmdBindPipeline)}, - {"vkCmdBindDescriptorSets", reinterpret_cast(CmdBindDescriptorSets)}, - {"vkCmdBindVertexBuffers", reinterpret_cast(CmdBindVertexBuffers)}, - {"vkCmdBindIndexBuffer", reinterpret_cast(CmdBindIndexBuffer)}, - {"vkCmdDraw", reinterpret_cast(CmdDraw)}, - {"vkCmdDrawIndexed", reinterpret_cast(CmdDrawIndexed)}, - {"vkCmdDrawIndirect", reinterpret_cast(CmdDrawIndirect)}, - {"vkCmdDrawIndexedIndirect", reinterpret_cast(CmdDrawIndexedIndirect)}, - {"vkCmdDispatch", reinterpret_cast(CmdDispatch)}, - {"vkCmdDispatchIndirect", reinterpret_cast(CmdDispatchIndirect)}, - {"vkCmdCopyBuffer", reinterpret_cast(CmdCopyBuffer)}, - {"vkCmdCopyImage", reinterpret_cast(CmdCopyImage)}, - {"vkCmdBlitImage", reinterpret_cast(CmdBlitImage)}, - {"vkCmdCopyBufferToImage", reinterpret_cast(CmdCopyBufferToImage)}, - {"vkCmdCopyImageToBuffer", reinterpret_cast(CmdCopyImageToBuffer)}, - {"vkCmdUpdateBuffer", reinterpret_cast(CmdUpdateBuffer)}, - {"vkCmdFillBuffer", reinterpret_cast(CmdFillBuffer)}, - {"vkCmdClearColorImage", reinterpret_cast(CmdClearColorImage)}, - {"vkCmdClearDepthStencilImage", reinterpret_cast(CmdClearDepthStencilImage)}, - {"vkCmdClearAttachments", reinterpret_cast(CmdClearAttachments)}, - {"vkCmdResolveImage", reinterpret_cast(CmdResolveImage)}, - {"vkCmdSetEvent", reinterpret_cast(CmdSetEvent)}, - {"vkCmdResetEvent", reinterpret_cast(CmdResetEvent)}, - {"vkCmdWaitEvents", reinterpret_cast(CmdWaitEvents)}, - {"vkCmdPipelineBarrier", reinterpret_cast(CmdPipelineBarrier)}, - {"vkCmdBeginQuery", reinterpret_cast(CmdBeginQuery)}, - {"vkCmdEndQuery", reinterpret_cast(CmdEndQuery)}, - {"vkCmdResetQueryPool", reinterpret_cast(CmdResetQueryPool)}, - {"vkCmdWriteTimestamp", reinterpret_cast(CmdWriteTimestamp)}, - {"vkCmdCopyQueryPoolResults", reinterpret_cast(CmdCopyQueryPoolResults)}, - {"vkCmdPushConstants", reinterpret_cast(CmdPushConstants)}, - {"vkCreateFramebuffer", reinterpret_cast(CreateFramebuffer)}, - {"vkDestroyFramebuffer", reinterpret_cast(DestroyFramebuffer)}, - {"vkCreateRenderPass", reinterpret_cast(CreateRenderPass)}, - {"vkDestroyRenderPass", reinterpret_cast(DestroyRenderPass)}, - {"vkGetRenderAreaGranularity", reinterpret_cast(GetRenderAreaGranularity)}, - {"vkCreateCommandPool", reinterpret_cast(CreateCommandPool)}, - {"vkDestroyCommandPool", reinterpret_cast(DestroyCommandPool)}, - {"vkResetCommandPool", reinterpret_cast(ResetCommandPool)}, - {"vkCmdBeginRenderPass", reinterpret_cast(CmdBeginRenderPass)}, - {"vkCmdNextSubpass", reinterpret_cast(CmdNextSubpass)}, - {"vkCmdExecuteCommands", reinterpret_cast(CmdExecuteCommands)}, - {"vkCmdEndRenderPass", reinterpret_cast(CmdEndRenderPass)}, - {"vkDebugMarkerSetObjectTagEXT", reinterpret_cast(DebugMarkerSetObjectTagEXT)}, - {"vkDebugMarkerSetObjectNameEXT", reinterpret_cast(DebugMarkerSetObjectNameEXT)}, - {"vkCmdDebugMarkerBeginEXT", reinterpret_cast(CmdDebugMarkerBeginEXT)}, - {"vkCmdDebugMarkerInsertEXT", reinterpret_cast(CmdDebugMarkerInsertEXT)}, -#ifdef VK_USE_PLATFORM_WIN32_KHR - {"vkGetMemoryWin32HandleNV", reinterpret_cast(GetMemoryWin32HandleNV)}, -#endif // VK_USE_PLATFORM_WIN32_KHR - // NVX_device_generated_commands - {"vkCmdProcessCommandsNVX", reinterpret_cast(CmdProcessCommandsNVX)}, - {"vkCmdReserveSpaceForCommandsNVX", reinterpret_cast(CmdReserveSpaceForCommandsNVX)}, - {"vkCreateIndirectCommandsLayoutNVX", reinterpret_cast(CreateIndirectCommandsLayoutNVX)}, - {"vkDestroyIndirectCommandsLayoutNVX", reinterpret_cast(DestroyIndirectCommandsLayoutNVX)}, - {"vkCreateObjectTableNVX", reinterpret_cast(CreateObjectTableNVX)}, - {"vkDestroyObjectTableNVX", reinterpret_cast(DestroyObjectTableNVX)}, - {"vkRegisterObjectsNVX", reinterpret_cast(RegisterObjectsNVX)}, - {"vkUnregisterObjectsNVX", reinterpret_cast(UnregisterObjectsNVX)}, - }; - - 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; -} - -static PFN_vkVoidFunction InterceptWsiEnabledCommand(const char *name, VkDevice device) { - static const struct { - const char *name; - PFN_vkVoidFunction proc; - } wsi_device_commands[] = { - {"vkCreateSwapchainKHR", reinterpret_cast(CreateSwapchainKHR)}, - {"vkGetSwapchainImagesKHR", reinterpret_cast(GetSwapchainImagesKHR)}, - {"vkAcquireNextImageKHR", reinterpret_cast(AcquireNextImageKHR)}, - {"vkQueuePresentKHR", reinterpret_cast(QueuePresentKHR)}, - {"vkDestroySwapchainKHR", reinterpret_cast(DestroySwapchainKHR)}, - {"vkCreateSharedSwapchainsKHR", reinterpret_cast(CreateSharedSwapchainsKHR)}, - }; - - if (device) { - for (size_t i = 0; i < ARRAY_SIZE(wsi_device_commands); i++) { - if (!strcmp(wsi_device_commands[i].name, name)) return wsi_device_commands[i].proc; - } - - if (!strcmp("vkCreateSharedSwapchainsKHR", name)) { - return reinterpret_cast(CreateSharedSwapchainsKHR); - } - } - - return nullptr; -} - -static PFN_vkVoidFunction InterceptWsiEnabledCommand(const char *name, VkInstance instance) { - static const struct { - const char *name; - PFN_vkVoidFunction proc; - } wsi_instance_commands[] = { - {"vkGetPhysicalDeviceSurfaceSupportKHR", reinterpret_cast(GetPhysicalDeviceSurfaceSupportKHR)}, - {"vkGetPhysicalDeviceSurfaceCapabilitiesKHR", - reinterpret_cast(GetPhysicalDeviceSurfaceCapabilitiesKHR)}, - {"vkGetPhysicalDeviceSurfaceFormatsKHR", reinterpret_cast(GetPhysicalDeviceSurfaceFormatsKHR)}, - {"vkGetPhysicalDeviceSurfacePresentModesKHR", - reinterpret_cast(GetPhysicalDeviceSurfacePresentModesKHR)}, - {"vkDestroySurfaceKHR", reinterpret_cast(DestroySurfaceKHR)}, - {"vkGetPhysicalDeviceDisplayPropertiesKHR", reinterpret_cast(GetPhysicalDeviceDisplayPropertiesKHR)}, - {"vkGetPhysicalDeviceDisplayPlanePropertiesKHR", - reinterpret_cast(GetPhysicalDeviceDisplayPlanePropertiesKHR)}, - {"vkGetDisplayPlaneSupportedDisplaysKHR", reinterpret_cast(GetDisplayPlaneSupportedDisplaysKHR)}, - {"vkGetDisplayModePropertiesKHR", reinterpret_cast(GetDisplayModePropertiesKHR)}, - {"vkCreateDisplayModeKHR", reinterpret_cast(CreateDisplayModeKHR)}, - {"vkGetDisplayPlaneCapabilitiesKHR", reinterpret_cast(GetDisplayPlaneCapabilitiesKHR)}, - {"vkCreateDisplayPlaneSurfaceKHR", reinterpret_cast(CreateDisplayPlaneSurfaceKHR)}, -#ifdef VK_USE_PLATFORM_WIN32_KHR - {"vkCreateWin32SurfaceKHR", reinterpret_cast(CreateWin32SurfaceKHR)}, - {"vkGetPhysicalDeviceWin32PresentationSupportKHR", - reinterpret_cast(GetPhysicalDeviceWin32PresentationSupportKHR)}, -#endif -#ifdef VK_USE_PLATFORM_XCB_KHR - {"vkCreateXcbSurfaceKHR", reinterpret_cast(CreateXcbSurfaceKHR)}, - {"vkGetPhysicalDeviceXcbPresentationSupportKHR", - reinterpret_cast(GetPhysicalDeviceXcbPresentationSupportKHR)}, -#endif -#ifdef VK_USE_PLATFORM_XLIB_KHR - {"vkCreateXlibSurfaceKHR", reinterpret_cast(CreateXlibSurfaceKHR)}, - {"vkGetPhysicalDeviceXlibPresentationSupportKHR", - reinterpret_cast(GetPhysicalDeviceXlibPresentationSupportKHR)}, -#endif -#ifdef VK_USE_PLATFORM_MIR_KHR - {"vkCreateMirSurfaceKHR", reinterpret_cast(CreateMirSurfaceKHR)}, - {"vkGetPhysicalDeviceMirPresentationSupportKHR", - reinterpret_cast(GetPhysicalDeviceMirPresentationSupportKHR)}, -#endif -#ifdef VK_USE_PLATFORM_WAYLAND_KHR - {"vkCreateWaylandSurfaceKHR", reinterpret_cast(CreateWaylandSurfaceKHR)}, - {"vkGetPhysicalDeviceWaylandPresentationSupportKHR", - reinterpret_cast(GetPhysicalDeviceWaylandPresentationSupportKHR)}, -#endif -#ifdef VK_USE_PLATFORM_ANDROID_KHR - {"vkCreateAndroidSurfaceKHR", reinterpret_cast(CreateAndroidSurfaceKHR)}, -#endif - }; - - for (size_t i = 0; i < ARRAY_SIZE(wsi_instance_commands); i++) { - if (!strcmp(wsi_instance_commands[i].name, name)) return wsi_instance_commands[i].proc; - } - - return nullptr; -} - -static PFN_vkVoidFunction intercept_extension_instance_command(const char *name, VkInstance instance) { - static const struct { - const char *name; - PFN_vkVoidFunction proc; - } extension_instance_commands[] = { - {"vkGetPhysicalDeviceFeatures2KHR", reinterpret_cast(GetPhysicalDeviceFeatures2KHR)}, - {"vkGetPhysicalDeviceProperties2KHR", reinterpret_cast(GetPhysicalDeviceProperties2KHR)}, - {"vkGetPhysicalDeviceFormatProperties2KHR", reinterpret_cast(GetPhysicalDeviceFormatProperties2KHR)}, - {"vkGetPhysicalDeviceImageFormatProperties2KHR", - reinterpret_cast(GetPhysicalDeviceImageFormatProperties2KHR)}, - {"vkGetPhysicalDeviceQueueFamilyProperties2KHR", - reinterpret_cast(GetPhysicalDeviceQueueFamilyProperties2KHR)}, - {"vkGetPhysicalDeviceMemoryProperties2KHR", reinterpret_cast(GetPhysicalDeviceMemoryProperties2KHR)}, - {"vkGetPhysicalDeviceSparseImageFormatProperties2KHR", - reinterpret_cast(GetPhysicalDeviceSparseImageFormatProperties2KHR)}, - // NV_external_memory_capabilities - {"vkGetPhysicalDeviceExternalImageFormatPropertiesNV", - reinterpret_cast(GetPhysicalDeviceExternalImageFormatPropertiesNV)}, - // NVX_device_generated_commands - {"vkGetPhysicalDeviceGeneratedCommandsPropertiesNVX", - reinterpret_cast(GetPhysicalDeviceGeneratedCommandsPropertiesNVX)}, - }; - - for (size_t i = 0; i < ARRAY_SIZE(extension_instance_commands); i++) { - if (!strcmp(extension_instance_commands[i].name, name)) return extension_instance_commands[i].proc; - } - - return nullptr; -} - -static PFN_vkVoidFunction intercept_extension_device_command(const char *name, VkDevice device) { - struct ExtProc { - const char *name; - PFN_vkVoidFunction proc; - } extension_device_commands[] = { - // KHR_maintenance1 - {"vkTrimCommandPoolKHR", reinterpret_cast(TrimCommandPoolKHR)}, -#ifdef VK_USE_PLATFORM_WIN32_KHR - // NV_external_memory_win32 - {"vkGetMemoryWin32HandleNV", reinterpret_cast(GetMemoryWin32HandleNV)}, -#endif // VK_USE_PLATFORM_WIN32_KHR - // EXT_debug_marker - {"vkDebugMarkerSetObjectTagEXT", reinterpret_cast(DebugMarkerSetObjectTagEXT)}, - {"vkDebugMarkerSetObjectNameEXT", reinterpret_cast(DebugMarkerSetObjectNameEXT)}, - {"vkCmdDebugMarkerBeginEXT", reinterpret_cast(CmdDebugMarkerBeginEXT)}, - {"vkCmdDebugMarkerInsertEXT", reinterpret_cast(CmdDebugMarkerInsertEXT)}, - // NVX_device_generated_commands - {"vkCmdProcessCommandsNVX", reinterpret_cast(CmdProcessCommandsNVX)}, - {"vkCmdReserveSpaceForCommandsNVX", reinterpret_cast(CmdReserveSpaceForCommandsNVX)}, - {"vkCreateIndirectCommandsLayoutNVX", reinterpret_cast(CreateIndirectCommandsLayoutNVX)}, - {"vkDestroyIndirectCommandsLayoutNVX", reinterpret_cast(DestroyIndirectCommandsLayoutNVX)}, - {"vkCreateObjectTableNVX", reinterpret_cast(CreateObjectTableNVX)}, - {"vkDestroyObjectTableNVX", reinterpret_cast(DestroyObjectTableNVX)}, - {"vkRegisterObjectsNVX", reinterpret_cast(RegisterObjectsNVX)}, - {"vkUnregisterObjectsNVX", reinterpret_cast(UnregisterObjectsNVX)}, - }; - - if (device) { - for (size_t i = 0; i < ARRAY_SIZE(extension_device_commands); i++) { - if (!strcmp(extension_device_commands[i].name, name)) return extension_device_commands[i].proc; - } - } + auto pdev_data = GetLayerDataPtr(get_dispatch_key(instance), instance_layer_data_map); - return nullptr; + if (!pdev_data->dispatch_table.GetPhysicalDeviceProcAddr) return nullptr; + return pdev_data->dispatch_table.GetPhysicalDeviceProcAddr(instance, funcName); } } // namespace parameter_validation -- 2.7.4