Skip to content

intel/nir: Rewrite the guts of lower_alpha_to_coverage

I have no idea how this pass ever worked. I guess it worked ok on the one or two piglit tests but the whole thing seemed very fragile. It makes a number of undocumented and unasserted assumptions and they aren't always valid. This rewrite makes a number of changes:

  1. Pass a pointer to the builder instead of passing it by-value.

  2. It now properly handles the case where the gl_SampleMask write comes before the gl_FragColor or gl_FragData[0] write.

  3. It should early-exit faster because it now looks at bits in shader_info::outputs_written instead of looking for variables.

  4. Instead of the fragile variable lookup where we try to look the variable up by both location and driver_location and match, we just use the driver_location calculations used by brw_fs_nir.

  5. It asserts that the index parameter to store_output is a constant instead of silently failing if it isn't.

  6. We now actually assert the implicit assumption that the two writes are in the same block. We go even further and assert that they are in the last block in the shader.

  7. In the case where 3 or fewer components of the output are written, we explicitly choose to leave the sample mask alone.

I assigned this one to @kwg specifically because I think he's the one who came up with the bonkers FS output indexing scheme we use and the new version of the pass makes use of it.

Merge request reports