Defer resetting MTLTexture in MVKSwapchainImage until request to acquire.

Move call to MVKSwapchainImage::resetMetalDrawable() from immediately after
presentation until request to acquire, to preserve image content for copying
after presentation in cases such as an app screen capture operation.

Testing indicates this deferral has little or no adverse effect on the performance
of retrieving the drawable when next needed.
This commit is contained in:
Bill Hollings 2020-04-02 12:54:57 -04:00
parent fde9d515ca
commit 2037b6c007
2 changed files with 1 additions and 1 deletions

View File

@ -958,7 +958,6 @@ void MVKSwapchainImage::presentCAMetalDrawable(id<MTLCommandBuffer> mtlCmdBuff)
[mtlCmdBuff presentDrawable: getCAMetalDrawable()];
if (scName) { mvkPopDebugGroup(mtlCmdBuff); }
resetMetalDrawable();
signalPresentationSemaphore(mtlCmdBuff);
retain(); // Ensure this image is not destroyed while awaiting MTLCommandBuffer completion

View File

@ -97,6 +97,7 @@ VkResult MVKSwapchain::acquireNextImageKHR(uint64_t timeout,
// Return the index of the image with the shortest wait and signal the semaphore and fence when it's available
*pImageIndex = minWaitImage->_swapchainIndex;
minWaitImage->resetMetalDrawable();
minWaitImage->signalWhenAvailable((MVKSemaphore*)semaphore, (MVKFence*)fence);
return getHasSurfaceSizeChanged() ? VK_ERROR_OUT_OF_DATE_KHR : VK_SUCCESS;