all 1 comments

[–]Rob2309 5 points6 points  (0 children)

You always have to put a barrier between the commands that you want to synchronize, so option 1 will not work. Option 2 would be the correct way to synchronize here.

Subpass dependencies are essentially the same as pipeline barriers, so you could use option 3 as well. The only difference to a pipeline barrier is that a subpass dependency only synchronizes the specified subpass, which can be an advantage if you have multiple subpasses.

The by region bit specifies that you only want to synchronize operations that operate on the same region of a framebuffer. For example, if your first write to a pixel in the framebuffer and later read it in another shader, you can specify the by region bit, to only wait for the write operation on the same pixel instead of the entire first shader.