Search code examples
openglglslvulkanspir-v

Does every variable have to be set for every vertex emitted in a geometry shader?


In my geometry shader that I was using in OpenGL setting a variable once at the beginning and then emitting vertices without resetting it works, but in vulkan if I don't write to that variable between every EmitVertex() my code will not work properly.

I can't find anything about this in the glsl specification, is there a rule for this and the first case just happens to work? Did anything change moving to spirv?


Solution

  • From the khronos opengl docs:

    GS code writes all of the output values for a vertex, then calls EmitVertex(). This tells the system to write those output values to where ever it is that output vertices get written. After calling this function, all output variables contain undefined values. So you will need to write to them all again before emitting the next vertex (if there is a next vertex).