From: Mark Young Date: Tue, 7 Mar 2017 20:09:00 +0000 (-0700) Subject: layers: Fix parameter validation X-Git-Tag: upstream/1.1.92~1479 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=efe9a7d930d38eb10b019c351e0a706ba92667b4;p=platform%2Fupstream%2FVulkan-Tools.git layers: Fix parameter validation An earlier change clobbered part of a parameter validation change. Change-Id: Ica28e79c17f094637e3a12c44dd25c5283c586ef --- diff --git a/layers/parameter_validation.cpp b/layers/parameter_validation.cpp index 402aebf..d7f961d 100644 --- a/layers/parameter_validation.cpp +++ b/layers/parameter_validation.cpp @@ -6871,436 +6871,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); - auto 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; - - proc = InterceptWsiEnabledCommand(funcName, device); - if (proc) return proc; + PFN_vkVoidFunction addr = layer_intercept_proc(funcName); + if (addr) return addr; - proc = intercept_extension_device_command(funcName, device); - if (proc) return proc; + layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); - 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); - - if (proc) return proc; + auto instance_data = GetLayerDataPtr(get_dispatch_key(instance), instance_layer_data_map); - 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)}, - }; - - 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)}, - }; - - 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)}, - // KHX_device_group (physical device procs) - {"vkGetPhysicalDevicePresentRectanglesKHX", reinterpret_cast(GetPhysicalDevicePresentRectanglesKHX)}, - // KHX_device_group_creation - {"vkEnumeratePhysicalDeviceGroupsKHX", reinterpret_cast(EnumeratePhysicalDeviceGroupsKHX)}, - // KHX_external_memory_capabilities - {"vkGetPhysicalDeviceExternalBufferPropertiesKHX", - reinterpret_cast(GetPhysicalDeviceExternalBufferPropertiesKHX)}, - {"vkGetPhysicalDeviceProperties2KHX", reinterpret_cast(GetPhysicalDeviceProperties2KHX)}, - {"vkGetPhysicalDeviceImageFormatProperties2KHX", - reinterpret_cast(GetPhysicalDeviceImageFormatProperties2KHX)}, - // KHX_external_semaphore_capabilities - {"vkGetPhysicalDeviceExternalSemaphorePropertiesKHX", - reinterpret_cast(GetPhysicalDeviceExternalSemaphorePropertiesKHX)}, - // 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)}, - // KHR_push_descriptor - {"vkCmdPushDescriptorSetKHR", reinterpret_cast(CmdPushDescriptorSetKHR)}, - // KHR_descriptor_update_template - {"vkCreateDescriptorUpdateTemplateKHR", reinterpret_cast(CreateDescriptorUpdateTemplateKHR)}, - {"vkDestroyDescriptorUpdateTemplateKHR", reinterpret_cast(DestroyDescriptorUpdateTemplateKHR)}, - {"vkUpdateDescriptorSetWithTemplateKHR", reinterpret_cast(UpdateDescriptorSetWithTemplateKHR)}, - {"vkCmdPushDescriptorSetWithTemplateKHR", reinterpret_cast(CmdPushDescriptorSetWithTemplateKHR)}, - // KHX_device_group - {"vkGetDeviceGroupPeerMemoryFeaturesKHX", reinterpret_cast(GetDeviceGroupPeerMemoryFeaturesKHX)}, - {"vkBindBufferMemory2KHX", reinterpret_cast(BindBufferMemory2KHX)}, - {"vkBindImageMemory2KHX", reinterpret_cast(BindImageMemory2KHX)}, - // Nothing to validate: {"vkCmdSetDeviceMaskKHX", reinterpret_cast(vkCmdSetDeviceMaskKHX) }, - {"vkGetDeviceGroupPresentCapabilitiesKHX", reinterpret_cast(GetDeviceGroupPresentCapabilitiesKHX)}, - {"vkGetDeviceGroupSurfacePresentModesKHX", reinterpret_cast(GetDeviceGroupSurfacePresentModesKHX)}, - {"vkAcquireNextImage2KHX", reinterpret_cast(AcquireNextImage2KHX)}, - {"vkCmdDispatchBaseKHX", reinterpret_cast(CmdDispatchBaseKHX)}, - // KHX_external_memory_fd - {"vkGetMemoryFdKHX", reinterpret_cast(GetMemoryFdKHX)}, - {"vkGetMemoryFdPropertiesKHX", reinterpret_cast(GetMemoryFdPropertiesKHX)}, - // KHX_external_semaphore_fd - {"vkImportSemaphoreFdKHX", reinterpret_cast(ImportSemaphoreFdKHX)}, - {"vkGetSemaphoreFdKHX", reinterpret_cast(GetSemaphoreFdKHX)}, -#ifdef VK_USE_PLATFORM_WIN32_KHR - // KHX_external_memory_win32 - {"vkGetMemoryWin32HandleKHX", reinterpret_cast(GetMemoryWin32HandleKHX)}, - {"vkGetMemoryWin32HandlePropertiesKHX", reinterpret_cast(GetMemoryWin32HandlePropertiesKHX)}, - // KHX_external_semaphore_win32 - {"vkImportSemaphoreWin32HandleKHX", reinterpret_cast(ImportSemaphoreWin32HandleKHX)}, - {"vkGetSemaphoreWin32HandleKHX", reinterpret_cast(GetSemaphoreWin32HandleKHX)}, -#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)}, - // VK_EXT_discard_rectangles - {"vkCmdSetDiscardRectangleEXT", reinterpret_cast(CmdSetDiscardRectangleEXT)}, - // EXT_display_control - {"vkDisplayPowerControlEXT", reinterpret_cast(DisplayPowerControlEXT)}, - {"vkRegisterDeviceEventEXT", reinterpret_cast(RegisterDeviceEventEXT)}, - {"vkRegisterDisplayEventEXT", reinterpret_cast(RegisterDisplayEventEXT)}, - {"vkGetSwapchainCounterEXT", reinterpret_cast(GetSwapchainCounterEXT)}, - // AMD_draw_indirect_count extension - {"vkCmdDrawIndirectCountAMD", reinterpret_cast(CmdDrawIndirectCountAMD)}, - {"vkCmdDrawIndexedIndirectCountAMD", reinterpret_cast(CmdDrawIndexedIndirectCountAMD)}, - // VK_NV_clip_space_w_scaling extension - {"vkCmdSetViewportWScalingNV", reinterpret_cast(CmdSetViewportWScalingNV)}, -#ifdef VK_USE_PLATFORM_WIN32_KHR - // NV_external_memory_win32 - {"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)}, - }; - - 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