Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do stencil passes write to color buffer?

Tags:

vulkan

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.

like image 553
hiddenbit Avatar asked Oct 31 '22 04:10

hiddenbit


1 Answers

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.

like image 146
Nicol Bolas Avatar answered Nov 17 '22 00:11

Nicol Bolas