Skip to content
  • Faith Ekstrand's avatar
    intel/nir: Rewrite the guts of lower_alpha_to_coverage · f2c5bc10
    Faith Ekstrand authored and Eric Engestrom's avatar Eric Engestrom committed
    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. It now properly handles the case where the gl_SampleMask write comes
        before the gl_FragColor or gl_FragData[0] write.
    
     2. It should early-exit faster because it now looks at bits in
        shader_info::outputs_written instead of looking for variables.
    
     3. 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.
    
     4. It asserts that the index parameter to store_output is a constant
        instead of silently failing if it isn't.
    
     5. 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.
    
     6. In the case where 3 or fewer components of the output are written,
        we explicitly choose to leave the sample mask alone.
    
    Fixes: 7ecfbd4f
    
     "nir: Add alpha_to_coverage lowering pass"
    Closes: #3166
    Reviewed-by: default avatarCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
    Part-of: <mesa!6233>
    (cherry picked from commit b6fdb140)
    f2c5bc10