vulkan

gl_VertexIndex with VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP


I'm drawing a rectangle using VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP, and I want to know how gl_VertexIndex works with it.

For example, if I draw my rectangle with bottom-right; top-left; bottom-right; top-right, will the gl_VertexIndex be 0;1;2;1;2;3 or 0;1;2;3;4;5;6?


Solution

  • Non-indexed rendering for these purposes is effectively treated as indexed rendering with an index list of "0, 1, 2, 3, 4, 5, ...". When rendering triangle strips, a quad takes 4 vertices. So the indices your VS gets will be "0, 1, 2, 3". If the VS needs to be executed multiple times for the shared vertices (which it almost certainly won't) then those indices will be repeated, along with their input data fed to the VS.