Reputation: 898
I am trying to use light volumes for my deferred renderer. But i come across a problem with stencil operations.
Right now i am using a depth/stencil attachment with format VK_FORMAT_D32_SFLOAT_S8_UINT
. In the lighting subpass i need to read the depth to reconstruct position, and read and write the stencil to mask the light volume.
To the lighting subpass I want to add the depth/stencil as an input attachment, and as a depth attachment, but these require different layout which are obviously not possible at the same time.
Right now i am referring to the same attachment both as an input attachment and a depth attachment in the same subpass.
As input attachment the layout is VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
and as depth attachment the layout is VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL
(giving no validation errors?), and my stencil operations are not executed.
Now i could create two different attachments for depth and stencil, but that would possibly use more memory, which is not great either. So my question is, how do you setup a subpass where you can read and write the same depth/stencil attachment? (within a single pipeline as well)
Upvotes: 2
Views: 1286
Reputation: 474506
but these require different layout
Nonsense; that's what the GENERAL
layout is for. The specification even explicitly brings that up:
An attachment used as both an input attachment and depth/stencil attachment must be in either the VK_IMAGE_LAYOUT_GENERAL or VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL layout
Obviously the latter is not helpful for you ;)
Upvotes: 3