Skip to content

nir: Add a late texcoord replacement pass

Alyssa Rosenzweig requested to merge alyssa/mesa:nir/late-texcoord into main

Add a second NIR pass for lowering point/texture coordinate replacement (i.e. point sprites). Why a second one? The current pass works on derefs/variables, which is drivers that don't lower I/O at all (like Zink, where the pass originates). However, it is problematic for hardware drivers: the inputs to this pass depend on the shader key, so we want to run the pass as late as possible to minimize the cost of building/compiling the associated shader variants. In particular, we need to be able to lower point sprites after lowering I/O if we would like to lower I/O when preprocessing NIR.

The logic for early lowering and late lowering is considerably different (the late lowering is a lot simpler), so I've split this out into a second pass rather than trying to weld them together into one.

This pass will be used on Asahi, which currently uses the early pass. It may be useful for other drivers as well. (Actually, it's been shipping on Asahi for a little while now, just hasn't been sent upstream yet.)

Tested with Neverball.

Cc @kusma who wrote the original pass that this is based on. Cc @asahilina as Asahi reviewer. See also !20836 (merged), which is also needed for lowering I/O when preprocessing shaders on Asahi. (That one should also make blend shaders a lot cheaper on panvk in the extended_dynamic_state3 future.)

Merge request reports