Skip to content

freedreno/turnip: Implement PrimID passthrough

Connor Abbott requested to merge cwabbott0/mesa:review/tu-primid-fs into master

Ever since geometry shaders were added, GL and Vulkan have specified that gl_PrimitiveID is accessible in the fragment shader as a normal varying. When a geometry shader is present, gl_PrimitiveID acts like a normal flat varying which is passed to the FS, but without the geometry shader, it has to be passed through automatically from the last geometry stage, either VS or TES, where it is a sysval. This wasn't implemented correctly in turnip or freedreno.

It turns out that, at least on a6xx, there is a mechanism to automatically pass gl_PrimitiveID down to the VPC without doing anything in the VS/TES shader. Using it requires refactoring the varying linking code to better handle FS inputs which don't correspond to a VS output, so that we don't accidentally fill the PrimID slot with garbage, and then it's just a matter of setting a few registers.

This is untested on freedreno, but on turnip it fixes dEQP-VK.pipeline.framebuffer_attachment.no_attachments once fragmentShaderStoresAndAtomics is enabled as well as dEQP-VK.pipeline.multisample.sample_locations_ext.verify_location.* on a650. I also haven't tested this when tessellation is enabled.

Merge request reports