From 1c3671d2ba3734d483d28c6c79d91fdcb72f005d Mon Sep 17 00:00:00 2001 From: Mark Collins Date: Fri, 18 Nov 2022 07:48:14 +0000 Subject: [PATCH] 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 Part-of: --- src/freedreno/ci/traces-freedreno.yml | 6 +++--- src/freedreno/ir3/ir3_nir_lower_tex_prefetch.c | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/freedreno/ci/traces-freedreno.yml b/src/freedreno/ci/traces-freedreno.yml index 62d2884daf6..a3aeed33136 100644 --- a/src/freedreno/ci/traces-freedreno.yml +++ b/src/freedreno/ci/traces-freedreno.yml @@ -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: diff --git a/src/freedreno/ir3/ir3_nir_lower_tex_prefetch.c b/src/freedreno/ir3/ir3_nir_lower_tex_prefetch.c index 45e65365864..d1a9ed1ff44 100644 --- a/src/freedreno/ir3/ir3_nir_lower_tex_prefetch.c +++ b/src/freedreno/ir3/ir3_nir_lower_tex_prefetch.c @@ -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;