nir: Add a late texcoord replacement pass
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Sun, 18 Dec 2022 04:02:32 +0000 (23:02 -0500)
committerMarge Bot <emma+marge@anholt.net>
Fri, 3 Feb 2023 15:03:06 +0000 (15:03 +0000)
commit071ac599604bf578a7a9c190cd4901c1c5c6a44a
tree4c80d252f0ac935d48c857f47768b53b3cf53e69
parent4397c166c01b641c57348d9e0d881a4a1f351455
nir: Add a late texcoord replacement pass

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 good for 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.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Emma Anholt <emma@anholt.net>
Acked-by: Asahi Lina <lina@asahilina.net>
Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21065>
src/compiler/nir/meson.build
src/compiler/nir/nir.h
src/compiler/nir/nir_lower_texcoord_replace_late.c [new file with mode: 0644]