diff options
| author | Chris Forbes <chrisforbes@google.com> | 2016-10-12 13:27:13 +1300 |
|---|---|---|
| committer | Chris Forbes <chrisforbes@google.com> | 2016-11-22 11:45:12 +1300 |
| commit | 3b11cb7ae4ecfdaf5b57e70d1977577419f0685c (patch) | |
| tree | 026ce0154848806f9c391bd5208bae5abe2ad800 | |
| parent | 0ce6d00e0853606345712c0b277c9bfc74454bd9 (diff) | |
| download | usermoji-3b11cb7ae4ecfdaf5b57e70d1977577419f0685c.tar.xz | |
layers: Move too many images case to CV
Signed-off-by: Chris Forbes <chrisforbes@google.com>
| -rw-r--r-- | layers/core_validation.cpp | 14 | ||||
| -rw-r--r-- | layers/core_validation_error_enums.h | 1 | ||||
| -rw-r--r-- | layers/swapchain.cpp | 24 | ||||
| -rw-r--r-- | layers/swapchain.h | 1 |
4 files changed, 14 insertions, 26 deletions
diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index 8e779cac..93670f94 100644 --- a/layers/core_validation.cpp +++ b/layers/core_validation.cpp @@ -12003,6 +12003,19 @@ VKAPI_ATTR VkResult VKAPI_CALL AcquireNextImageKHR(VkDevice device, VkSwapchainK if (pFence) { skip_call |= ValidateFenceForSubmit(dev_data, pFence); } + + auto swapchain_data = getSwapchainNode(dev_data, swapchain); + auto physical_device_state = getPhysicalDeviceState(dev_data->instance_data, dev_data->physical_device); + if (physical_device_state->vkGetPhysicalDeviceSurfaceCapabilitiesKHRState != UNCALLED) { + int acquired_images = std::count_if(swapchain_data->images.begin(), swapchain_data->images.end(), + [=](VkImage image) { return getImageState(dev_data, image)->acquired; }); + if (acquired_images > swapchain_data->images.size() - physical_device_state->surfaceCapabilities.minImageCount) { + skip_call |= log_msg( + dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT, + reinterpret_cast<uint64_t const &>(swapchain), __LINE__, DRAWSTATE_SWAPCHAIN_TOO_MANY_IMAGES, "DS", + "vkAcquireNextImageKHR: Application has already acquired the maximum number of images (%d)", acquired_images); + } + } lock.unlock(); if (skip_call) @@ -12024,7 +12037,6 @@ VKAPI_ATTR VkResult VKAPI_CALL AcquireNextImageKHR(VkDevice device, VkSwapchainK } // Mark the image as acquired. - auto swapchain_data = getSwapchainNode(dev_data, swapchain); auto image = swapchain_data->images[*pImageIndex]; auto image_state = getImageState(dev_data, image); image_state->acquired = true; diff --git a/layers/core_validation_error_enums.h b/layers/core_validation_error_enums.h index 35634fd7..76ec8be7 100644 --- a/layers/core_validation_error_enums.h +++ b/layers/core_validation_error_enums.h @@ -258,6 +258,7 @@ enum DRAW_STATE_ERROR { DRAWSTATE_SWAPCHAIN_BAD_COMPOSITE_ALPHA, // Composite alpha mode not supported DRAWSTATE_SWAPCHAIN_BAD_LAYER_COUNT, // Layer count not supported DRAWSTATE_SWAPCHAIN_BAD_USAGE_FLAGS, // Image usage flags not supported + DRAWSTATE_SWAPCHAIN_TOO_MANY_IMAGES, // Application already owns the maximum number of images }; // Shader Checker ERROR codes diff --git a/layers/swapchain.cpp b/layers/swapchain.cpp index 32c41ee0..2f0f64e5 100644 --- a/layers/swapchain.cpp +++ b/layers/swapchain.cpp @@ -1526,30 +1526,6 @@ VKAPI_ATTR VkResult VKAPI_CALL AcquireNextImageKHR(VkDevice device, VkSwapchainK auto it = my_data->swapchainMap.find(swapchain); pSwapchain = (it == my_data->swapchainMap.end()) ? NULL : &it->second; } - SwpPhysicalDevice *pPhysicalDevice = pDevice->pPhysicalDevice; - if (pSwapchain && pPhysicalDevice && pPhysicalDevice->gotSurfaceCapabilities) { - // Look to see if the application has already acquired the maximum - // number of images, and this will push it past the spec-defined - // limits: - uint32_t minImageCount = pPhysicalDevice->surfaceCapabilities.minImageCount; - uint32_t imagesAcquiredByApp = 0; - for (uint32_t i = 0; i < pSwapchain->imageCount; i++) { - if (pSwapchain->images[i].acquiredByApp) { - imagesAcquiredByApp++; - } - } - if (imagesAcquiredByApp > (pSwapchain->imageCount - minImageCount)) { - 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__, SWAPCHAIN_APP_ACQUIRES_TOO_MANY_IMAGES, swapchain_layer_name, - "vkAcquireNextImageKHR() called when it cannot succeed. The application has acquired %d image(s) that have not " - "yet " - "been presented. The maximum number of images that the application can simultaneously acquire from this swapchain " - "(including this call to vkCreateSwapchainKHR()) is %d. That value is derived by subtracting " - "VkSurfaceCapabilitiesKHR::minImageCount (%d) from the number of images in the swapchain (%d) and adding 1.", - imagesAcquiredByApp, (pSwapchain->imageCount - minImageCount + 1), minImageCount, pSwapchain->imageCount); - } - } lock.unlock(); if (!skip_call) { diff --git a/layers/swapchain.h b/layers/swapchain.h index 2fe42e43..a5ac41cf 100644 --- a/layers/swapchain.h +++ b/layers/swapchain.h @@ -53,7 +53,6 @@ enum SWAPCHAIN_ERROR { SWAPCHAIN_CREATE_SWAP_BAD_SHARING_MODE, // Called vkCreateSwapchainKHR() with a non-supported imageSharingMode SWAPCHAIN_CREATE_SWAP_BAD_SHARING_VALUES, // Called vkCreateSwapchainKHR() with bad values when imageSharingMode is // VK_SHARING_MODE_CONCURRENT - SWAPCHAIN_APP_ACQUIRES_TOO_MANY_IMAGES, // vkAcquireNextImageKHR() asked for more images than are available SWAPCHAIN_BAD_BOOL, // VkBool32 that doesn't have value of VK_TRUE or VK_FALSE (e.g. is a non-zero form of true) SWAPCHAIN_PRIOR_COUNT, // Query must be called first to get value of pCount, then called second time SWAPCHAIN_INVALID_COUNT, // Second time a query called, the pCount value didn't match first time |
