From 6a441764d9b4f423860811e1be23d6afdc4a5bc2 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Thu, 22 Sep 2016 16:40:27 +1200 Subject: [PATCH] layers: Move ACQUIRE_NO_SYNC check from Swapchain to Core Validation Signed-off-by: Chris Forbes --- layers/core_validation.cpp | 8 ++++++++ layers/core_validation_error_enums.h | 1 + layers/swapchain.cpp | 7 ------- layers/swapchain.h | 1 - layers/vk_validation_layer_details.md | 2 +- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index 114a34e..129ab92 100644 --- a/layers/core_validation.cpp +++ b/layers/core_validation.cpp @@ -11314,6 +11314,14 @@ VKAPI_ATTR VkResult VKAPI_CALL AcquireNextImageKHR(VkDevice device, VkSwapchainK bool skip_call = false; std::unique_lock lock(global_lock); + + if (fence == VK_NULL_HANDLE && semaphore == VK_NULL_HANDLE) { + skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, + reinterpret_cast(device), __LINE__, DRAWSTATE_NO_SYNC_FOR_ACQUIRE, "DS", + "vkAcquireNextImageKHR: Semaphore and fence cannot both be VK_NULL_HANDLE. There would be no way " + "to determine the completion of this operation."); + } + auto pSemaphore = getSemaphoreNode(dev_data, semaphore); if (pSemaphore && pSemaphore->signaled) { skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_SEMAPHORE_EXT, diff --git a/layers/core_validation_error_enums.h b/layers/core_validation_error_enums.h index 0bb18d8..12e56d5 100644 --- a/layers/core_validation_error_enums.h +++ b/layers/core_validation_error_enums.h @@ -235,6 +235,7 @@ enum DRAW_STATE_ERROR { // granularity DRAWSTATE_PUSH_CONSTANTS_ERROR, // Push constants exceed maxPushConstantSize DRAWSTATE_INVALID_SUBPASS_INDEX, // Stepping beyond last subpass, or not reaching it + DRAWSTATE_NO_SYNC_FOR_ACQUIRE, // AcquireNextImageKHR with no sync object }; // Shader Checker ERROR codes diff --git a/layers/swapchain.cpp b/layers/swapchain.cpp index 5aca7f6..4ca28a6 100644 --- a/layers/swapchain.cpp +++ b/layers/swapchain.cpp @@ -2089,13 +2089,6 @@ VKAPI_ATTR VkResult VKAPI_CALL AcquireNextImageKHR(VkDevice device, VkSwapchainK "vkAcquireNextImageKHR() called even though the %s extension was not enabled for this VkDevice.", VK_KHR_SWAPCHAIN_EXTENSION_NAME); } - if ((semaphore == VK_NULL_HANDLE) && (fence == VK_NULL_HANDLE)) { - skip_call |= - log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, - reinterpret_cast(device), __LINE__, SWAPCHAIN_NO_SYNC_FOR_ACQUIRE, swapchain_layer_name, - "vkAcquireNextImageKHR() called with both the semaphore and fence parameters set to VK_NULL_HANDLE (at " - "least one should be used)."); - } SwpSwapchain *pSwapchain = NULL; { auto it = my_data->swapchainMap.find(swapchain); diff --git a/layers/swapchain.h b/layers/swapchain.h index 9b84f20..f28b92e 100644 --- a/layers/swapchain.h +++ b/layers/swapchain.h @@ -73,7 +73,6 @@ enum SWAPCHAIN_ERROR { // vkGetPhysicalDeviceQueueFamilyProperties() SWAPCHAIN_SURFACE_NOT_SUPPORTED_WITH_QUEUE, // A surface is not supported by a given queueFamilyIndex, as seen by // vkGetPhysicalDeviceSurfaceSupportKHR() - SWAPCHAIN_NO_SYNC_FOR_ACQUIRE, // vkAcquireNextImageKHR should be called with a valid semaphore and/or fence SWAPCHAIN_GET_SUPPORTED_DISPLAYS_WITHOUT_QUERY, // vkGetDisplayPlaneSupportedDisplaysKHR should be called after querying // device display plane properties SWAPCHAIN_PLANE_INDEX_TOO_LARGE, // a planeIndex value is larger than what vkGetDisplayPlaneSupportedDisplaysKHR returns diff --git a/layers/vk_validation_layer_details.md b/layers/vk_validation_layer_details.md index 3c97fda..5673863 100644 --- a/layers/vk_validation_layer_details.md +++ b/layers/vk_validation_layer_details.md @@ -120,6 +120,7 @@ The Draw State portion of the core validation layer tracks state leading into Dr | NA | Enum used for errors in the layer itself. This does not indicate an app issue, but instead a bug in the layer. | INTERNAL_ERROR | | TODO | None | | NA | Enum used when VK_LAYER_LUNARG_core_validation attempts to allocate memory for its own internal use and is unable to. | OUT_OF_MEMORY | | TODO | None | | Bad subpass indexing | Must not step beyond last subpass in a renderpass instance, and must reach the last subpass before CmdEndRenderPass. | INVALID_SUBPASS_INDEX | vkCmdNextSubpass | RenderPassExcessiveNextSubpass | NA | +| Proper synchronization of acquired images | vkAcquireNextImageKHR should be called with a valid semaphore and/or fence | NO_SYNC_FOR_ACQUIRE | vkAcquireNextImageKHR | TODO | None | ### VK_LAYER_LUNARG_core_validation Draw State Pending Work @@ -360,7 +361,6 @@ This layer is a work in progress. VK_LAYER_LUNARG_swapchain layer is intended to | Valid use of queueFamilyIndex | Validates that a queueFamilyIndex not used before vkGetPhysicalDeviceQueueFamilyProperties() was called | DID_NOT_QUERY_QUEUE_FAMILIES | vkGetPhysicalDeviceSurfaceSupportKHR | TODO | None | | Valid queueFamilyIndex value | Validates that a queueFamilyIndex value is less-than pQueueFamilyPropertyCount returned by vkGetPhysicalDeviceQueueFamilyProperties | QUEUE_FAMILY_INDEX_TOO_LARGE | vkGetPhysicalDeviceSurfaceSupportKHR | TODO | None | | Supported combination of queue and surface | Validates that the surface associated with a swapchain was seen to support the queueFamilyIndex of a given queue | SURFACE_NOT_SUPPORTED_WITH_QUEUE | vkQueuePresentKHR | TODO | None | -| Proper synchronization of acquired images | vkAcquireNextImageKHR should be called with a valid semaphore and/or fence | NO_SYNC_FOR_ACQUIRE | vkAcquireNextImageKHR | TODO | None | | Potential use before query | Validates that Display Plane Properties are queried before getting supported Display Planes | GET_SUPPORTED_DISPLAYS_WITHOUT_QUERY | vkGetPhysicalDeviceSurfaceSupportKHR | TODO | actually: vkGetDisplayPlaneSupportedDisplaysKHR | | Index too large | Validates index is in range of phys device display plane props | PLANE_INDEX_TOO_LARGE | vkGetPhysicalDeviceSurfaceSupportKHR | TODO | actually: vkGetDisplayPlaneSupportedDisplaysKHR | | Index too large | Validates index is in range of phys device display plane props | PLANE_INDEX_TOO_LARGE | vkGetPhysicalDeviceSurfaceSupportKHR | TODO | actually: vkGetDisplayPlaneCapabilitiesKHR | -- 2.7.4