I've been examining drawsubpasses sample in LunarG's samples (file: API-Samples/drawsubpasses/drawsubpasses.cpp).
In this example, the active sub pass when the very first vkCmdDraw() is called, does not have a color attachment but only a depth/stencil attachment. The fragment shader used does have an output variable.
Reading the spec didn't help me understand whether this usage is "safe", or how a driver would handle it.
Vulkan 1.0.16 seems to have corrected this. It explicitly says that no writes are performed to attachment indices greater than a subpasses attachmentCount
, or which are explicitly declared VK_ATTACHMENT_UNUSED
. The output variable will be undefined, but nothing will be written to it, based on the current subpass's description.
That is a very good question. I spent several minutes reading the spec in the expected places, and yet there is no language explaining what happens when a fragment shader writes to an output location that has no attachment in a subpass. It ought to be specified in section 14.3, but there is nothing there about this.
You may want to file a Vulkan spec bug report.
I assume the correct behavior would be the same as OpenGL: to effectively ignore such outputs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With