From abd5cabfa6e0f56ed231c2f18b6de2e3cc302e90 Mon Sep 17 00:00:00 2001 From: Ian Elliott Date: Wed, 20 Jan 2016 08:52:08 -0700 Subject: Swapchain: Start keeping better track of surface-queueFamilyIndices. --- layers/swapchain.cpp | 43 ++++++++++++++--------------------- layers/swapchain.h | 10 ++++++-- layers/vk_validation_layer_details.md | 1 + 3 files changed, 26 insertions(+), 28 deletions(-) diff --git a/layers/swapchain.cpp b/layers/swapchain.cpp index 841105f2..ea9d8be4 100644 --- a/layers/swapchain.cpp +++ b/layers/swapchain.cpp @@ -488,11 +488,6 @@ VK_LAYER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceMirPresentatio // Call down the call chain: result = my_data->instance_dispatch_table->GetPhysicalDeviceMirPresentationSupportKHR( physicalDevice, queueFamilyIndex, connection); - - if (pPhysicalDevice) { - // Record the result of this query: - pPhysicalDevice->queueFamilyIndexSupport[queueFamilyIndex] = result; - } } return result; } @@ -572,11 +567,6 @@ VK_LAYER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceWaylandPresent // Call down the call chain: result = my_data->instance_dispatch_table->GetPhysicalDeviceWaylandPresentationSupportKHR( physicalDevice, queueFamilyIndex, display); - - if (pPhysicalDevice) { - // Record the result of this query: - pPhysicalDevice->queueFamilyIndexSupport[queueFamilyIndex] = result; - } } return result; } @@ -655,11 +645,6 @@ VK_LAYER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceWin32Presentat // Call down the call chain: result = my_data->instance_dispatch_table->GetPhysicalDeviceWin32PresentationSupportKHR( physicalDevice, queueFamilyIndex); - - if (pPhysicalDevice) { - // Record the result of this query: - pPhysicalDevice->queueFamilyIndexSupport[queueFamilyIndex] = result; - } } return result; } @@ -740,11 +725,6 @@ VK_LAYER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceXcbPresentatio // Call down the call chain: result = my_data->instance_dispatch_table->GetPhysicalDeviceXcbPresentationSupportKHR( physicalDevice, queueFamilyIndex, connection, visual_id); - - if (pPhysicalDevice) { - // Record the result of this query: - pPhysicalDevice->queueFamilyIndexSupport[queueFamilyIndex] = result; - } } return result; } @@ -825,11 +805,6 @@ VK_LAYER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceXlibPresentati // Call down the call chain: result = my_data->instance_dispatch_table->GetPhysicalDeviceXlibPresentationSupportKHR( physicalDevice, queueFamilyIndex, dpy, visualID); - - if (pPhysicalDevice) { - // Record the result of this query: - pPhysicalDevice->queueFamilyIndexSupport[queueFamilyIndex] = result; - } } return result; } @@ -999,7 +974,9 @@ VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceSupport if ((result == VK_SUCCESS) && pSupported && pPhysicalDevice) { // Record the result of this query: pPhysicalDevice->queueFamilyIndexSupport[queueFamilyIndex] = - *pSupported; + surface; + pPhysicalDevice->surfaceSupport[surface] = + queueFamilyIndex; // TODO: We need to compare this with the actual queue used for // presentation, to ensure it was advertised to the application as // supported for presentation. @@ -1249,6 +1226,20 @@ static VkBool32 validateCreateSwapchainKHR( "vkGetPhysicalDeviceSurfaceCapabilitiesKHR().", fn); } else if (pCreateInfo) { + // Validate pCreateInfo->surface to make sure that + // vkGetPhysicalDeviceSurfaceSupportKHR() reported this as a supported + // surface: + uint32_t queueFamilyIndex = pPhysicalDevice->surfaceSupport[pCreateInfo->surface]; + if (!queueFamilyIndex) { + skipCall |= LOG_ERROR(VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, device, "VkDevice", + SWAPCHAIN_CREATE_UNSUPPORTED_SURFACE, + "%s() called with pCreateInfo->surface that " + "was not returned by " + "vkGetPhysicalDeviceSurfaceSupportKHR() " + "for the device.", + fn); + } + // Validate pCreateInfo->minImageCount against // VkSurfaceCapabilitiesKHR::{min|max}ImageCount: VkSurfaceCapabilitiesKHR *pCapabilities = &pPhysicalDevice->surfaceCapabilities; diff --git a/layers/swapchain.h b/layers/swapchain.h index 7076697b..3508cbe2 100644 --- a/layers/swapchain.h +++ b/layers/swapchain.h @@ -64,6 +64,7 @@ typedef enum _SWAPCHAIN_ERROR SWAPCHAIN_NULL_POINTER, // Pointer set to NULL, instead of being a valid pointer SWAPCHAIN_EXT_NOT_ENABLED_BUT_USED, // Did not enable WSI extension, but called WSI function SWAPCHAIN_DEL_DEVICE_BEFORE_SWAPCHAINS, // Called vkDestroyDevice() before vkDestroySwapchainKHR() + SWAPCHAIN_CREATE_UNSUPPORTED_SURFACE, // Called vkCreateSwapchainKHR() with a pCreateInfo->surface that wasn't seen as supported by vkGetPhysicalDeviceSurfaceSupportKHR for the device SWAPCHAIN_CREATE_SWAP_WITHOUT_QUERY, // Called vkCreateSwapchainKHR() without calling a query (e.g. vkGetPhysicalDeviceSurfaceCapabilitiesKHR()) SWAPCHAIN_CREATE_SWAP_BAD_MIN_IMG_COUNT, // Called vkCreateSwapchainKHR() with out-of-bounds minImageCount SWAPCHAIN_CREATE_SWAP_OUT_OF_BOUNDS_EXTENTS,// Called vkCreateSwapchainKHR() with out-of-bounds imageExtent @@ -214,8 +215,13 @@ struct _SwpPhysicalDevice { // VkInstance that this VkPhysicalDevice is associated with: SwpInstance *pInstance; - // Which queueFamilyIndices support presenting with WSI swapchains: - unordered_map queueFamilyIndexSupport; + // Record all supported queueFamilyIndex-surface pairs that support + // presenting with WSI swapchains: + unordered_map queueFamilyIndexSupport; + + // Record all supported surface-queueFamilyIndex pairs that support + // presenting with WSI swapchains: + unordered_map surfaceSupport; // TODO: Record/use this info per-surface, not per-device, once a // non-dispatchable surface object is added to WSI: diff --git a/layers/vk_validation_layer_details.md b/layers/vk_validation_layer_details.md index ce002ad3..c09ff33c 100644 --- a/layers/vk_validation_layer_details.md +++ b/layers/vk_validation_layer_details.md @@ -348,6 +348,7 @@ This layer is a work in progress. VK_LAYER_LUNARG_swapchain layer is intended to | Valid pointer | If a NULL pointer is used, this error will be flagged | NULL_POINTER | vkGetPhysicalDeviceSurfaceSupportKHR vkGetPhysicalDeviceSurfaceCapabilitiesKHR vkGetPhysicalDeviceSurfaceFormatsKHR vkGetPhysicalDeviceSurfacePresentModesKHR vkCreateSwapchainKHR vkGetSwapchainImagesKHR vkAcquireNextImageKHR vkQueuePresentKHR | NA | None | | Extension enabled before use | Validates that a WSI extension is enabled before its functions are used | EXT_NOT_ENABLED_BUT_USED | vkGetPhysicalDeviceSurfaceSupportKHR vkGetPhysicalDeviceSurfaceCapabilitiesKHR vkGetPhysicalDeviceSurfaceFormatsKHR vkGetPhysicalDeviceSurfacePresentModesKHR vkCreateSwapchainKHR vkDestroySwapchainKHR vkGetSwapchainImagesKHR vkAcquireNextImageKHR vkQueuePresentKHR | NA | None | | Swapchains destroyed before devices | Validates that vkDestroySwapchainKHR() is called for all swapchains associated with a device before vkDestroyDevice() is called | DEL_DEVICE_BEFORE_SWAPCHAINS | vkDestroyDevice | NA | None | +| Supported surface used with a swapchain | Validates that vkGetPhysicalDeviceSurfaceSupportKHR() was seen to support the surface used with a swapchain | CREATE_SWAP_UNSUPPORTED_SURFACE | vkCreateSwapchainKHR | NA | None | | Queries occur before swapchain creation | Validates that vkGetPhysicalDeviceSurfaceCapabilitiesKHR(), vkGetPhysicalDeviceSurfaceFormatsKHR() and vkGetPhysicalDeviceSurfacePresentModesKHR() are called before vkCreateSwapchainKHR() | CREATE_SWAP_WITHOUT_QUERY | vkCreateSwapchainKHR | NA | None | | vkCreateSwapchainKHR(pCreateInfo->minImageCount) | Validates vkCreateSwapchainKHR(pCreateInfo->minImageCount) | CREATE_SWAP_BAD_MIN_IMG_COUNT | vkCreateSwapchainKHR | NA | None | | vkCreateSwapchainKHR(pCreateInfo->imageExtent) | Validates vkCreateSwapchainKHR(pCreateInfo->imageExtent) when window has no fixed size | CREATE_SWAP_OUT_OF_BOUNDS_EXTENTS | vkCreateSwapchainKHR | NA | None | -- cgit v1.2.3