Image layout transition

Specification: “Applications must ensure that layout transitions happen-after all operations accessing the image with the old layout, and happen-before any operations that will access the image with the new layout. Layout transitions are potentially read/write operations, so not defining appropriate memory dependencies to guarantee this will result in a data race”. How to ensure it? vkQueueWaitIdle?

With synchronization. Basically, any of the tools spelled out in Chapter 7. Just like for any other data race.

1 Like

Sorry, forgot to clarify: layout transition using imageBarrier.

Please stop posting the same thing multiple times and deleting the previous versions.

Also, there are only 2 ways to do a layout transition: with an image barrier or the implicit ones for attachments in render passes. So you’re not exactly narrowing anything down.

1 Like

I’ve given it some thought and can assume that layout transition happens after srcStage and srcAccess, but before dstStage and dstAccess in the image barrier. Is this assumption correct?

Something like that. What the specification says:

When a layout transition is specified in a memory dependency, it happens-after the availability operations in the memory dependency, and happens-before the visibility operations.


Or to put it another way, when you make operations on an image available to subsequent operations, those “subsequent operations” include the layout transition that is part of the dependency. And when you make prior operations on an image visible to later operations, the layout transition in the dependency is included in those “prior operations”.

1 Like

In short, it happens at some arbitrary time inbetween of whatever two things the given sync primitive is supposed to be syncing.

For most part one does not have to worry about it if the sync is otherwisely correct, but annoying anomaly of the API design is that sometimes one has to sync purely for the sake of the layout transition. That is for example the common case of getting image from a swapchain with a semaphore and then transitioning the layout as a first thing.

1 Like

Off-topic question:
Is it possible to mark multiple answers on this site as a solution? They are all good, but I don’t know which one to make as a solution.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.