ir3: Disallow noperspective texture preloads

The `coord_offset` pass is responsible for upgrading any eligible
texture loads into prefetches, but a texture prefetch's capabilities
are limited and cannot handle any interpolation modes aside from
`smooth`.

An exception is carved out for `flat` interpolation modes, but this
doesn't exclude upgrading `noperspective` texture loads and results
in perspective-corrected samples being provided that can severely
break applications depending on this behaviour.

Fixes incorrect lighting projection on Super Mario Odyssey on
Skyline Emulator.

Fixes incorrect dirt texture mapping on Portal 2 trace on Turnip and
Zink on Turnip.

Fixes incorrect lighter shadowing on Half Life 2 trace on Turnip.

Signed-off-by: Mark Collins <mark@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19842>
This commit is contained in:
Mark Collins 2022-11-18 07:48:14 +00:00 committed by Marge Bot
parent 5b8917bb91
commit 1c3671d2ba
2 changed files with 10 additions and 3 deletions

View file

@ -27,7 +27,7 @@ traces:
freedreno-a530:
checksum: f7e6f426d7b9c82742f00baed830797f
freedreno-a630:
checksum: 14f7656971b98fdaaf00bf576ada7ccf
checksum: 6aef509acd1257cc56612141e24dc11c
zink-a630:
checksum: 45bdbb33bf87ed114bd548248be13408
@ -38,9 +38,9 @@ traces:
freedreno-a530:
checksum: 102a09ce76092436173fd09a6a2bd941
freedreno-a630:
checksum: a3a9e158ccf7fa5ba978e045505a060e
checksum: e0e18dcc50ab2e23cead650d64469178
zink-a630:
checksum: cd427d434d54990bde533302c01e945f
checksum: b589b5d9ddd3026cbde08f0abe840ea7
valve/counterstrike-source-v2.trace:
freedreno-a306:

View file

@ -91,6 +91,13 @@ coord_offset(nir_ssa_def *ssa)
if (interp->intrinsic != nir_intrinsic_load_barycentric_pixel)
return -1;
/* interpolation modes such as noperspective aren't covered by the other
* test, we need to explicitly check for them here.
*/
unsigned interp_mode = nir_intrinsic_interp_mode(interp);
if (interp_mode != INTERP_MODE_NONE && interp_mode != INTERP_MODE_SMOOTH)
return -1;
/* we also need a const input offset: */
if (!nir_src_is_const(input->src[1]))
return -1;