ARM-software / vulkan-sdk

Github repository for the Vulkan SDK
Other
228 stars 49 forks source link

"This is bad because the presentation engine can still be reading from the image. ", why? #19

Closed flowerdancedatou closed 5 years ago

flowerdancedatou commented 5 years ago

The image layout transition as part of a subpass will happen without any waiting. Why "This is bad because the presentation engine can still be reading from the image. "?

AttilioProvenzano-ARM commented 5 years ago

Hi, could you send more information on the point where this happens?

I'd assume it is related to acquiring an image from the swapchain and using it in a render pass. The problem is that the acquisition is only complete when the semaphore is signaled and the implicit transition as part of a subpass doesn't wait for that semaphore. You can ensure that the transition is correctly synchronized by adding an explicit subpass dependency.

For more details on the problem and the correct dependency to add, see here: https://github.com/ARM-software/vulkan-sdk/issues/14#issuecomment-489096767

flowerdancedatou commented 5 years ago

In "https://arm-software.github.io/vulkan-sdk/hello_triangle.html".

Adding Subpass Dependency The image layout transition as part of a subpass will happen without any waiting. This is bad because the presentation engine can still be reading from the image. To properly enforce this we need to add an external dependency to our first subpass where the layout transition happens.

AttilioProvenzano-ARM commented 5 years ago

Hi, that confirms it was about acquiring a swapchain image. :)

You can follow the explanation in the tutorial to ensure that your explicit subpass dependency is correct.

Another approach, in case you find it simpler, is to disable the implicit dependency (i.e. set initialLayout = layout = finalLayout) and do the layout transitions via pipeline barriers. This way you can ensure that the transition happens at the correct stage, when the image has already been acquired.

flowerdancedatou commented 5 years ago

thank you very much.^_^