summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr Kraus <petr_kraus@email.cz>2017-05-02 01:27:57 +0200
committerChris Forbes <chrisf@ijw.co.nz>2017-05-02 14:15:27 -0700
commit0bbc015828bdb99e85e6731ce92428557902701f (patch)
treec02fc56749c201b49ac6c92370503925f9ab29f9
parenta469089d367e8221926f7048bd4dcb2dc2721c0a (diff)
layers: Migrate surface support check to core
- fix memory leak of `pQueueFamilyIndexSupport` - remove vestige of queue family support check
-rw-r--r--layers/core_validation.cpp25
-rw-r--r--layers/swapchain.cpp57
-rw-r--r--layers/swapchain.h14
3 files changed, 24 insertions, 72 deletions
diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp
index 73062774..604bdae1 100644
--- a/layers/core_validation.cpp
+++ b/layers/core_validation.cpp
@@ -10114,6 +10114,29 @@ static bool PreCallValidateCreateSwapchainKHR(layer_data *dev_data, const char *
auto most_recent_swapchain = surface_state->swapchain ? surface_state->swapchain : surface_state->old_swapchain;
// TODO: revisit this. some of these rules are being relaxed.
+
+ // All physical devices and queue families are required to be able
+ // to present to any native window on Android; require the
+ // application to have established support on any other platform.
+ if (!dev_data->instance_data->androidSurfaceExtensionEnabled) {
+ auto support_predicate = [dev_data](decltype(surface_state->gpu_queue_support)::const_reference qs) -> bool {
+ // TODO: should restrict search only to queue families of VkDeviceQueueCreateInfos, not whole phys. device
+ return (qs.first.gpu == dev_data->physical_device) && qs.second;
+ };
+ const auto& support = surface_state->gpu_queue_support;
+ bool is_supported = std::any_of(support.begin(), support.end(), support_predicate);
+
+ if (!is_supported) {
+ if (log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT,
+ reinterpret_cast<uint64_t>(dev_data->device), __LINE__, VALIDATION_ERROR_01922, "DS",
+ "%s: pCreateInfo->surface is not known at this time to be supported for presentation by this device. "
+ "The vkGetPhysicalDeviceSurfaceSupportKHR() must be called beforehand, and it must return VK_TRUE support "
+ "with this surface for at least one queue family of this device. %s",
+ func_name, validation_error_map[VALIDATION_ERROR_01922]))
+ return true;
+ }
+ }
+
if (most_recent_swapchain != old_swapchain_state || (surface_state->old_swapchain && surface_state->swapchain)) {
if (log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT,
reinterpret_cast<uint64_t>(dev_data->device), __LINE__, DRAWSTATE_SWAPCHAIN_ALREADY_EXISTS, "DS",
@@ -11052,7 +11075,7 @@ VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevi
instance_data->dispatch_table.GetPhysicalDeviceSurfaceSupportKHR(physicalDevice, queueFamilyIndex, surface, pSupported);
if (result == VK_SUCCESS) {
- surface_state->gpu_queue_support[{physicalDevice, queueFamilyIndex}] = (*pSupported != 0);
+ surface_state->gpu_queue_support[{physicalDevice, queueFamilyIndex}] = (*pSupported == VK_TRUE);
}
return result;
diff --git a/layers/swapchain.cpp b/layers/swapchain.cpp
index ab1f9601..5a5c5efe 100644
--- a/layers/swapchain.cpp
+++ b/layers/swapchain.cpp
@@ -320,8 +320,6 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateAndroidSurfaceKHR(VkInstance instance, cons
// Record the VkSurfaceKHR returned by the ICD:
my_data->surfaceMap[*pSurface].surface = *pSurface;
my_data->surfaceMap[*pSurface].pInstance = pInstance;
- my_data->surfaceMap[*pSurface].numQueueFamilyIndexSupport = 0;
- my_data->surfaceMap[*pSurface].pQueueFamilyIndexSupport = NULL;
// Point to the associated SwpInstance:
pInstance->surfaces[*pSurface] = &my_data->surfaceMap[*pSurface];
}
@@ -362,8 +360,6 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateMirSurfaceKHR(VkInstance instance, const Vk
// Record the VkSurfaceKHR returned by the ICD:
my_data->surfaceMap[*pSurface].surface = *pSurface;
my_data->surfaceMap[*pSurface].pInstance = pInstance;
- my_data->surfaceMap[*pSurface].numQueueFamilyIndexSupport = 0;
- my_data->surfaceMap[*pSurface].pQueueFamilyIndexSupport = NULL;
// Point to the associated SwpInstance:
pInstance->surfaces[*pSurface] = &my_data->surfaceMap[*pSurface];
}
@@ -431,8 +427,6 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateWaylandSurfaceKHR(VkInstance instance, cons
// Record the VkSurfaceKHR returned by the ICD:
my_data->surfaceMap[*pSurface].surface = *pSurface;
my_data->surfaceMap[*pSurface].pInstance = pInstance;
- my_data->surfaceMap[*pSurface].numQueueFamilyIndexSupport = 0;
- my_data->surfaceMap[*pSurface].pQueueFamilyIndexSupport = NULL;
// Point to the associated SwpInstance:
pInstance->surfaces[*pSurface] = &my_data->surfaceMap[*pSurface];
}
@@ -501,8 +495,6 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateWin32SurfaceKHR(VkInstance instance, const
// Record the VkSurfaceKHR returned by the ICD:
my_data->surfaceMap[*pSurface].surface = *pSurface;
my_data->surfaceMap[*pSurface].pInstance = pInstance;
- my_data->surfaceMap[*pSurface].numQueueFamilyIndexSupport = 0;
- my_data->surfaceMap[*pSurface].pQueueFamilyIndexSupport = NULL;
// Point to the associated SwpInstance:
pInstance->surfaces[*pSurface] = &my_data->surfaceMap[*pSurface];
}
@@ -569,8 +561,6 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateXcbSurfaceKHR(VkInstance instance, const Vk
// Record the VkSurfaceKHR returned by the ICD:
my_data->surfaceMap[*pSurface].surface = *pSurface;
my_data->surfaceMap[*pSurface].pInstance = pInstance;
- my_data->surfaceMap[*pSurface].numQueueFamilyIndexSupport = 0;
- my_data->surfaceMap[*pSurface].pQueueFamilyIndexSupport = NULL;
// Point to the associated SwpInstance:
pInstance->surfaces[*pSurface] = &my_data->surfaceMap[*pSurface];
}
@@ -639,8 +629,6 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateXlibSurfaceKHR(VkInstance instance, const V
// Record the VkSurfaceKHR returned by the ICD:
my_data->surfaceMap[*pSurface].surface = *pSurface;
my_data->surfaceMap[*pSurface].pInstance = pInstance;
- my_data->surfaceMap[*pSurface].numQueueFamilyIndexSupport = 0;
- my_data->surfaceMap[*pSurface].pQueueFamilyIndexSupport = NULL;
// Point to the associated SwpInstance:
pInstance->surfaces[*pSurface] = &my_data->surfaceMap[*pSurface];
}
@@ -811,8 +799,6 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateDisplayPlaneSurfaceKHR(VkInstance instance,
// Record the VkSurfaceKHR returned by the ICD:
my_data->surfaceMap[*pSurface].surface = *pSurface;
my_data->surfaceMap[*pSurface].pInstance = pInstance;
- my_data->surfaceMap[*pSurface].numQueueFamilyIndexSupport = 0;
- my_data->surfaceMap[*pSurface].pQueueFamilyIndexSupport = NULL;
// Point to the associated SwpInstance:
pInstance->surfaces[*pSurface] = &my_data->surfaceMap[*pSurface];
}
@@ -1005,34 +991,6 @@ VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevi
// Call down the call chain:
result = my_data->instance_dispatch_table->GetPhysicalDeviceSurfaceSupportKHR(physicalDevice, queueFamilyIndex, surface,
pSupported);
- lock.lock();
-
- // Obtain this pointer again after locking:
- {
- auto it = my_data->physicalDeviceMap.find(physicalDevice);
- pPhysicalDevice = (it == my_data->physicalDeviceMap.end()) ? NULL : &it->second;
- }
- if ((result == VK_SUCCESS) && pSupported && pPhysicalDevice) {
- // Record the result of this query:
- SwpInstance *pInstance = pPhysicalDevice->pInstance;
- SwpSurface *pSurface = (pInstance) ? pInstance->surfaces[surface] : NULL;
- if (pSurface) {
- pPhysicalDevice->supportedSurfaces[surface] = pSurface;
- if (!pSurface->numQueueFamilyIndexSupport) {
- if (pPhysicalDevice->gotQueueFamilyPropertyCount) {
- pSurface->pQueueFamilyIndexSupport =
- (VkBool32 *)malloc(pPhysicalDevice->numOfQueueFamilies * sizeof(VkBool32));
- if (pSurface->pQueueFamilyIndexSupport != NULL) {
- pSurface->numQueueFamilyIndexSupport = pPhysicalDevice->numOfQueueFamilies;
- }
- }
- }
- if (pSurface->numQueueFamilyIndexSupport) {
- pSurface->pQueueFamilyIndexSupport[queueFamilyIndex] = *pSupported;
- }
- }
- }
- lock.unlock();
return result;
}
@@ -1065,21 +1023,6 @@ static bool validateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateI
}
}
- if (pCreateInfo) {
- // Validate pCreateInfo->surface to make sure that
- // vkGetPhysicalDeviceSurfaceSupportKHR() reported this as a supported
- // surface:
- SwpSurface *pSurface = ((pPhysicalDevice) ? pPhysicalDevice->supportedSurfaces[pCreateInfo->surface] : NULL);
- if (!pSurface) {
- skip_call |= log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT,
- reinterpret_cast<uint64_t>(device), __LINE__, VALIDATION_ERROR_01922, swapchain_layer_name,
- "The surface in pCreateInfo->surface, that was given to vkCreateSwapchainKHR(), must be a surface "
- "that is supported by the device as determined by vkGetPhysicalDeviceSurfaceSupportKHR(). "
- "However, vkGetPhysicalDeviceSurfaceSupportKHR() was never called with this surface. %s",
- validation_error_map[VALIDATION_ERROR_01922]);
- }
- }
-
// Validate pCreateInfo->imageSharingMode and related values:
if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
if (pCreateInfo->queueFamilyIndexCount <= 1) {
diff --git a/layers/swapchain.h b/layers/swapchain.h
index d2913aab..748a712a 100644
--- a/layers/swapchain.h
+++ b/layers/swapchain.h
@@ -114,16 +114,6 @@ struct SwpSurface {
// When vkCreateSwapchainKHR is called, the VkSwapchainKHR's are
// remembered:
std::unordered_map<VkSwapchainKHR, SwpSwapchain *> swapchains;
-
- // Value of pQueueFamilyPropertyCount that was returned by the
- // vkGetPhysicalDeviceQueueFamilyProperties() function:
- uint32_t numQueueFamilyIndexSupport;
- // Array of VkBool32's that is intialized by the
- // vkGetPhysicalDeviceSurfaceSupportKHR() function. First call for a given
- // surface allocates and initializes this array to false for all
- // queueFamilyIndex's (and sets numQueueFamilyIndexSupport to non-zero).
- // All calls set the entry for a given queueFamilyIndex:
- VkBool32 *pQueueFamilyIndexSupport;
};
// Create one of these for each VkPhysicalDevice within a VkInstance:
@@ -142,10 +132,6 @@ struct SwpPhysicalDevice {
bool gotQueueFamilyPropertyCount;
uint32_t numOfQueueFamilies;
- // Record all surfaces that vkGetPhysicalDeviceSurfaceSupportKHR() was
- // called for:
- std::unordered_map<VkSurfaceKHR, SwpSurface *> supportedSurfaces;
-
// Count returned by vkGetPhysicalDeviceDisplayPlanePropertiesKHR():
uint32_t displayPlanePropertyCount;
bool gotDisplayPlanePropertyCount;