I’m trying to understand how overlapping triangles are handled in Vulkan when using vkCmdDrawIndexed to draw multiple triangles covering the same pixel area.
If two triangles overlap, does the later triangle always overwrite the previous one when no depth buffer is enabled?
While a lot of Vulkan processes are executed in an arbitrary order unless you do something specific, rasterization of triangles is an exception. Since blending, depth tests, and a number of other things functionally requires ensuring a consistent ordering of primitives at the fragment level, Vulkan provides guarantees on the ordering of primitives and rasterization.
For the simple case of draw indexed calls (when you’re not causing one primitive to become multiple primitives, as in the case of geometry or tessellation shaders), the order of the index buffer (and its creation of primitives) defines the order of primitives and rasterization between them. That is, if the 3 indices that create a triangle are later in the index buffer than the 3 indices that make up another triangle, the later ones in the buffer are rendered on top of the earlier ones from that buffer.
Thank you for the information. Do you know of any documentation that explains the draw process in full detail? I’d like to see the entire rendering pipeline: from the device queue all the way down to a single command in the command buffer — how each stage transitions, when memory is accessed, and how synchronization is enforced between stages and resources.
I tried reading the blog “Understanding Vulkan Synchronization,” but I’m missing many of the foundational details, and I find it hard to follow.