nir: Add lowering for fround_even on r300.
authorEmma Anholt <emma@anholt.net>
Mon, 11 Apr 2022 23:28:05 +0000 (16:28 -0700)
committerEmma Anholt <emma@anholt.net>
Sat, 16 Apr 2022 20:07:09 +0000 (13:07 -0700)
commit6947016b468417f60203db68c34e0961e4ac7845
tree79716f6e6befbe6414578c192d3d187838d6cb90
parentc60fea8c228ae3f32e20d6b65c473d9f04871d20
nir: Add lowering for fround_even on r300.

When we put NIR in the compiler stack for r300, indirect addressing broke
for gallium nine.  DX's array indirects round the float value, so the DX
shader gets mapped to a TGSI "ARR ADDR[0] src.x" instruction.  Translating
that to NIR maps to r0[f2i32(fround(src.x))].  While we might hope that in
translation back using nir-to-tgsi after optimization we would recognize
the construct and emit ARR again, that's going to be error prone (think
"what if src.x is in a NIR register?") so we need a fallback plan.  r300
will be able to handle this lowering, so get it in place first to fix the
regression.

Fixes: #6297
Fixes: 7d2ea9b0edef ("r300: Request NIR shaders from mesa/st and use NIR-to-TGSI.")
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15870>
src/compiler/nir/nir.h
src/compiler/nir/nir_opt_algebraic.py
src/gallium/drivers/r300/r300_screen.c