Skip to content

asahi: Fix flat shaded clipping

Asahi Lina requested to merge asahilina/mesa:agx/clip_flat_fix into main

This turned out to be harder to fix than expected...

We have to tell the hardware the counts of varyings that are {smooth, flat, linear} × {fp32, fp16}. This implies that each combination has to be grouped consecutively. Presumably, the tiling hardware uses this when clipping polygons to decide how to interpolate the new vertices, independently of the shading mode used for coefficient registers, and this is what was tripping us up with clipped flat shaded polygons.

This means that the interpolation type affects the varyings layout. In Metal, the interpolation type is specified in the vertex shader, so that is all lovely and can be applied at compile time. Unfortunately, in GL, this info is only in the fragment shader. This means we need to introduce the interpolation type mask to the vertex shader key, and make the vertex shader depend on the fragment shader (ew...).

Hopefully the cases of a single VS being used with multiple interpolation combinations are rare enough that this won't materially increase the number of variants compiled.

Once we get the mask of flat shaded varyings propagated all the way to the VS, it's simple enough to modify the existing agx_remap_varyings_vs function to put everything in the right order, and gather the counts so we can pass them to the hardware.

Edited by Asahi Lina

Merge request reports