Confused about depth stencil attachment resolve

Hi,

I’m reading in Render Pass :: Vulkan Documentation Project that

Fixed-function multisample resolve operations for attachments execute in the VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT pipeline stage. … Reads from the multisample attachment can be synchronized with VK_ACCESS_COLOR_ATTACHMENT_READ_BIT. Access to the single sample attachment can be synchronized with VK_ACCESS_COLOR_ATTACHMENT_READ_BIT and VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT. These pipeline stage and access types are used whether the attachments are color or depth/stencil attachments.

Does this mean that my depth resolve attachment ( pDepthStencilResolveAttachment ) has to be created as a color attachment instead of a depth/stencil attachment? Otherwise I’m confused as to how am I going to use the aforementioned flags with a depth/stencil usage/layout.

The stage where something happens is different from the nature of the things they’re happening to. What it’s saying is that the stages and access types for multisample resolves are called “color attachment” even if the things they’re operating on aren’t actually “color attachments”.

Sorry, it’s still not clear to me. According to this paragraph, if I want to read from the depth/stencil resolve attachment afterwards, I should use VK_ACCESS_COLOR_ATTACHMENT_READ_BIT . But then the “best practices” validation layer complains that this is not the expected access mask for a depth/stencil image.

Can you post the error it gives you?

Sure.

vkCmdPipelineBarrier2KHR(): pDependencyInfo->pImageMemoryBarriers[0] image is VkImage 0x3270000000327[Depth/Stencil Resolve Texture] and accessMask is VK_ACCESS_2_COLOR_ATTACHMENT_WRITE_BIT, but for layout VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL expected accessMask are VK_ACCESS_2_DEPTH_STENCIL_ATTACHMENT_READ_BIT|
K_ACCESS_2_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT.

I have a basic state tracker struct implemented on the host, to keep the last access stage and access masks, so at the end of my renderpass I set those to VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT and VK_ACCESS_2_COLOR_ATTACHMENT_WRITE_BIT as per the spec suggestions that I’ve linked. Then when I’m trying to transition this attachment’s image in order to read/transfer from it, I get the above validation error from the “best practices” checks.

One way I found to silence it was setting the access stage to VK_PIPELINE_STAGE_2_ALL_GRAPHICS_BIT_KHR and access mask to VK_ACCESS_2_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT_KHR. But this is not the same as with what the spec is saying.

I don’t see a valid usage rule in the specification that specifies the layout as a requirement of using COLOR_ATTACHMENT_WRITE_BIT. And the layer doesn’t cite a valid usage rule. So it’s unclear to me why it is complaining or which validation layer is doing the complaining.

It’s from the “Best Practices” part of the standard validation layer. I found a relevant issue in

, could this be incorrect/incomplete?

The specification makes it clear that not only can you do it, it does have specific meaning and a specific instance where you have to. So if this “best practices” layer is flagging it as incorrect on some level, then the layer needs to be changed.

You should file a bug report about the layer, citing the specification where it makes it clear that you have to do this in order to access depth/stencil resolve images.

Alright then, will do. Thanks @Alfonse_Reinheart for your help.

1 Like