Skip to content

Commit

Permalink
Defer resetting MTLTexture in MVKSwapchainImage until request to acqu…
Browse files Browse the repository at this point in the history
…ire.

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.
  • Loading branch information
billhollings committed Apr 2, 2020
1 parent fde9d51 commit 2037b6c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 1 deletion.
1 change: 0 additions & 1 deletion MoltenVK/MoltenVK/GPUObjects/MVKImage.mm
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,6 @@
[mtlCmdBuff presentDrawable: getCAMetalDrawable()];
if (scName) { mvkPopDebugGroup(mtlCmdBuff); }

resetMetalDrawable();
signalPresentationSemaphore(mtlCmdBuff);

retain(); // Ensure this image is not destroyed while awaiting MTLCommandBuffer completion
Expand Down
1 change: 1 addition & 0 deletions MoltenVK/MoltenVK/GPUObjects/MVKSwapchain.mm
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@

// 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;
Expand Down

0 comments on commit 2037b6c

Please sign in to comment.