From 4f4713af5a2dddf885b4a006a39c1c39bee6fff0 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Wed, 2 Nov 2016 17:43:34 +1300 Subject: [PATCH] layers: Move enable checks for KHR_surface to PV Signed-off-by: Chris Forbes --- layers/parameter_validation.cpp | 45 +++++++++++++++++++++++++++++++++++------ layers/swapchain.cpp | 36 --------------------------------- 2 files changed, 39 insertions(+), 42 deletions(-) diff --git a/layers/parameter_validation.cpp b/layers/parameter_validation.cpp index fe6f925..5169e94 100644 --- a/layers/parameter_validation.cpp +++ b/layers/parameter_validation.cpp @@ -4820,6 +4820,15 @@ VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevi layer_data *my_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map); assert(my_data != NULL); + if (!instance_extension_map[get_dispatch_table(pc_instance_table_map, physicalDevice)].surface_enabled) { + skip_call |= log_msg( + my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, + reinterpret_cast(physicalDevice), __LINE__, EXTENSION_NOT_ENABLED, + LayerName, + "vkGetPhysicalDeviceSurfaceSupportKHR() called even though the %s extension was not enabled for this VkInstance.", + VK_KHR_SURFACE_EXTENSION_NAME); + } + skip_call |= parameter_validation_vkGetPhysicalDeviceSurfaceSupportKHR(my_data->report_data, queueFamilyIndex, surface, pSupported); @@ -4840,6 +4849,15 @@ VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceSurfaceCapabilitiesKHR(VkPhysica layer_data *my_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map); assert(my_data != NULL); + if (!instance_extension_map[get_dispatch_table(pc_instance_table_map, physicalDevice)].surface_enabled) { + skip_call |= log_msg( + my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, + reinterpret_cast(physicalDevice), __LINE__, EXTENSION_NOT_ENABLED, + LayerName, + "vkGetPhysicalDeviceSurfaceCapabilitiesKHR() called even though the %s extension was not enabled for this VkInstance.", + VK_KHR_DISPLAY_EXTENSION_NAME); + } + skip_call |= parameter_validation_vkGetPhysicalDeviceSurfaceCapabilitiesKHR(my_data->report_data, surface, pSurfaceCapabilities); @@ -4861,6 +4879,15 @@ VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevi layer_data *my_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map); assert(my_data != NULL); + if (!instance_extension_map[get_dispatch_table(pc_instance_table_map, physicalDevice)].surface_enabled) { + skip_call |= log_msg( + my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, + reinterpret_cast(physicalDevice), __LINE__, EXTENSION_NOT_ENABLED, + LayerName, + "vkGetPhysicalDeviceSurfaceFormatsKHR() called even though the %s extension was not enabled for this VkInstance.", + VK_KHR_DISPLAY_EXTENSION_NAME); + } + skip_call |= parameter_validation_vkGetPhysicalDeviceSurfaceFormatsKHR(my_data->report_data, surface, pSurfaceFormatCount, pSurfaceFormats); @@ -4882,6 +4909,15 @@ VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceSurfacePresentModesKHR(VkPhysica layer_data *my_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map); assert(my_data != NULL); + if (!instance_extension_map[get_dispatch_table(pc_instance_table_map, physicalDevice)].surface_enabled) { + skip_call |= log_msg( + my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, + reinterpret_cast(physicalDevice), __LINE__, EXTENSION_NOT_ENABLED, + LayerName, + "vkGetPhysicalDeviceSurfacePresentModesKHR() called even though the %s extension was not enabled for this VkInstance.", + VK_KHR_DISPLAY_EXTENSION_NAME); + } + skip_call |= parameter_validation_vkGetPhysicalDeviceSurfacePresentModesKHR(my_data->report_data, surface, pPresentModeCount, pPresentModes); @@ -5607,12 +5643,9 @@ static PFN_vkVoidFunction InterceptWsiEnabledCommand(const char *name, VkInstanc reinterpret_cast(GetPhysicalDeviceSurfacePresentModesKHR)}, }; - VkLayerInstanceDispatchTable *pTable = get_dispatch_table(pc_instance_table_map, instance); - if (instance_extension_map[pTable].surface_enabled) { - 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; - } + 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; } #ifdef VK_USE_PLATFORM_WIN32_KHR diff --git a/layers/swapchain.cpp b/layers/swapchain.cpp index 04c4714..502f750 100644 --- a/layers/swapchain.cpp +++ b/layers/swapchain.cpp @@ -1132,15 +1132,6 @@ VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevi pPhysicalDevice = (it == my_data->physicalDeviceMap.end()) ? NULL : &it->second; } - // Validate that the surface extension was enabled: - if (pPhysicalDevice && pPhysicalDevice->pInstance && !pPhysicalDevice->pInstance->surfaceExtensionEnabled) { - skip_call |= log_msg( - my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, - reinterpret_cast(pPhysicalDevice->pInstance->instance), __LINE__, SWAPCHAIN_EXT_NOT_ENABLED_BUT_USED, - swapchain_layer_name, - "vkGetPhysicalDeviceSurfaceSupportKHR() called even though the %s extension was not enabled for this VkInstance.", - VK_KHR_SURFACE_EXTENSION_NAME); - } if (!pPhysicalDevice->gotQueueFamilyPropertyCount) { skip_call |= log_msg( my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, @@ -1204,15 +1195,6 @@ VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceSurfaceCapabilitiesKHR(VkPhysica pPhysicalDevice = (it == my_data->physicalDeviceMap.end()) ? NULL : &it->second; } - // Validate that the surface extension was enabled: - if (pPhysicalDevice && pPhysicalDevice->pInstance && !pPhysicalDevice->pInstance->surfaceExtensionEnabled) { - skip_call |= log_msg( - my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, - reinterpret_cast(pPhysicalDevice->pInstance->instance), __LINE__, SWAPCHAIN_EXT_NOT_ENABLED_BUT_USED, - swapchain_layer_name, - "vkGetPhysicalDeviceSurfaceCapabilitiesKHR() called even though the %s extension was not enabled for this VkInstance.", - VK_KHR_DISPLAY_EXTENSION_NAME); - } lock.unlock(); if (!skip_call) { @@ -1251,15 +1233,6 @@ VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevi pPhysicalDevice = (it == my_data->physicalDeviceMap.end()) ? NULL : &it->second; } - // Validate that the surface extension was enabled: - if (pPhysicalDevice && pPhysicalDevice->pInstance && !pPhysicalDevice->pInstance->surfaceExtensionEnabled) { - skip_call |= log_msg( - my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, - reinterpret_cast(pPhysicalDevice->pInstance->instance), __LINE__, SWAPCHAIN_EXT_NOT_ENABLED_BUT_USED, - swapchain_layer_name, - "vkGetPhysicalDeviceSurfaceFormatsKHR() called even though the %s extension was not enabled for this VkInstance.", - VK_KHR_DISPLAY_EXTENSION_NAME); - } if (pPhysicalDevice && pSurfaceFormats) { // Compare the preliminary value of *pSurfaceFormatCount with the value this time: if (pPhysicalDevice->surfaceFormatCount == 0) { @@ -1334,15 +1307,6 @@ VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceSurfacePresentModesKHR(VkPhysica pPhysicalDevice = (it == my_data->physicalDeviceMap.end()) ? NULL : &it->second; } - // Validate that the surface extension was enabled: - if (pPhysicalDevice && pPhysicalDevice->pInstance && !pPhysicalDevice->pInstance->surfaceExtensionEnabled) { - skip_call |= log_msg( - my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, - reinterpret_cast(pPhysicalDevice->pInstance->instance), __LINE__, SWAPCHAIN_EXT_NOT_ENABLED_BUT_USED, - swapchain_layer_name, - "vkGetPhysicalDeviceSurfacePresentModesKHR() called even though the %s extension was not enabled for this VkInstance.", - VK_KHR_DISPLAY_EXTENSION_NAME); - } if (pPhysicalDevice && pPresentModes) { // Compare the preliminary value of *pPresentModeCount with the value this time: if (pPhysicalDevice->presentModeCount == 0) { -- 2.7.4