if ((semaphore == VK_NULL_HANDLE) && (fence == VK_NULL_HANDLE)) {
skipCall |= LOG_ERROR(VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, device, "VkDevice", SWAPCHAIN_NO_SYNC_FOR_ACQUIRE,
"%s() called with both the semaphore and fence parameters set to "
- "VK_NULL_HANDLE (at least one should be used).", __FUNCTION__);
+ "VK_NULL_HANDLE (at least one should be used)\n.", __FUNCTION__);
}
SwpSwapchain *pSwapchain = &my_data->swapchainMap[swapchain];
- if (pSwapchain) {
- // Look to see if the application is trying to own too many images at
- // the same time (i.e. not leave any to display):
- uint32_t imagesOwnedByApp = 0;
+ 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].ownedByApp) {
- imagesOwnedByApp++;
+ imagesAcquiredByApp++;
}
}
- if (imagesOwnedByApp >= (pSwapchain->imageCount - 1)) {
- skipCall |= LOG_PERF_WARNING(VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT, swapchain, "VkSwapchainKHR",
- SWAPCHAIN_APP_OWNS_TOO_MANY_IMAGES, "%s() called when the application "
- "already owns all presentable images "
- "in this swapchain except for the "
- "image currently being displayed. "
- "This call to %s() cannot succeed "
- "unless another thread calls the "
- "vkQueuePresentKHR() function in "
- "order to release ownership of one of "
- "the presentable images of this "
- "swapchain.",
- __FUNCTION__, __FUNCTION__);
+ if (imagesAcquiredByApp > (pSwapchain->imageCount - minImageCount)) {
+ skipCall |= LOG_ERROR(
+ VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT,
+ swapchain, "VkSwapchainKHR",
+ SWAPCHAIN_APP_ACQUIRES_TOO_MANY_IMAGES,
+ "%s() 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 %s()) is %d. That value is derived by subtracting "
+ "VkSurfaceCapabilitiesKHR::minImageCount (%d) from the number "
+ "of images in the swapchain (%d) and adding 1.\n",
+ __FUNCTION__, imagesAcquiredByApp, __FUNCTION__,
+ (pSwapchain->imageCount - minImageCount + 1),
+ minImageCount, pSwapchain->imageCount);
}
}
if (!pImageIndex) {
SWAPCHAIN_CREATE_SWAP_DIFF_SURFACE, // Called vkCreateSwapchainKHR() with pCreateInfo->oldSwapchain that has a different surface
// than pCreateInfo->surface
SWAPCHAIN_DESTROY_SWAP_DIFF_DEVICE, // Called vkDestroySwapchainKHR() with a different VkDevice than vkCreateSwapchainKHR()
- SWAPCHAIN_APP_OWNS_TOO_MANY_IMAGES, // vkAcquireNextImageKHR() asked for more images than are available
+ SWAPCHAIN_APP_ACQUIRES_TOO_MANY_IMAGES, // vkAcquireNextImageKHR() asked for more images than are available
SWAPCHAIN_INDEX_TOO_LARGE, // Index is too large for swapchain
SWAPCHAIN_INDEX_NOT_IN_USE, // vkQueuePresentKHR() given index that is not owned by app
SWAPCHAIN_BAD_BOOL, // VkBool32 that doesn't have value of VK_TRUE or VK_FALSE (e.g. is a non-zero form of true)
| vkCreateSwapchainKHR(pCreateInfo->imageSharingMode) | Validates vkCreateSwapchainKHR(pCreateInfo->imageSharingMode) | CREATE_SWAP_BAD_SHARING_VALUES | vkCreateSwapchainKHR | NA | None |
| vkCreateSwapchainKHR(pCreateInfo->oldSwapchain and pCreateInfo->surface) | pCreateInfo->surface must match pCreateInfo->oldSwapchain's surface | CREATE_SWAP_DIFF_SURFACE | vkCreateSwapchainKHR | NA | None |
| Use same device for swapchain | Validates that vkDestroySwapchainKHR() called with the same VkDevice as vkCreateSwapchainKHR() | DESTROY_SWAP_DIFF_DEVICE | vkCreateSwapchainKHR vkDestroySwapchainKHR | NA | None |
-| Don't use too many images | Validates that app never tries to own too many swapchain images at a time | APP_OWNS_TOO_MANY_IMAGES | vkAcquireNextImageKHR | NA | None |
+| Don't acquire too many images | Validates that app never tries to acquire too many swapchain images at a time | APP_ACQUIRES_TOO_MANY_IMAGES | vkAcquireNextImageKHR | NA | None |
| Index too large | Validates that an image index is within the number of images in a swapchain | INDEX_TOO_LARGE | vkQueuePresentKHR | NA | None |
| Can't present a non-owned image | Validates that application only presents images that it owns | INDEX_NOT_IN_USE | vkQueuePresentKHR | NA | None |
| A VkBool32 must have values of VK_TRUE or VK_FALSE | Validates that a VkBool32 must have values of VK_TRUE or VK_FALSE | BAD_BOOL | vkCreateSwapchainKHR | NA | None |