ir3: opt_deref in opt loop to remove unnecessary tex casts

Otherwise we may be left with such casts:

 vec1 32 ssa_72 = deref_var &shadow_map (uniform sampler2D)
 vec1 32 ssa_73 = deref_cast (texture2D *)ssa_72 (uniform texture2D)
 vec1 32 ssa_74 = deref_cast (sampler *)ssa_72 (uniform sampler)
 vec1 32 ssa_76 = (float32)tex ssa_73 (texture_deref), ssa_74 (sampler_deref), ssa_75 (coord), ssa_64 (comparator)

And crash in ycbcr lowering since we aren't able to follow deref chain.

Fixes crash in GFXBench Aztec Ruins Vulkan tests.
See issue: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5945

Cc: mesa-stable

Signed-off-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14819>
(cherry picked from commit f917c73528)
This commit is contained in:
Danylo Piliaiev 2022-02-01 14:32:02 +02:00 committed by Eric Engestrom
parent 77f9a3ada4
commit 2027acff50
2 changed files with 2 additions and 1 deletions

View file

@ -2254,7 +2254,7 @@
"description": "ir3: opt_deref in opt loop to remove unnecessary tex casts",
"nominated": true,
"nomination_type": 0,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null
},

View file

@ -210,6 +210,7 @@ ir3_optimize_loop(struct ir3_compiler *compiler, nir_shader *s)
progress |= OPT(s, nir_lower_phis_to_scalar, false);
progress |= OPT(s, nir_copy_prop);
progress |= OPT(s, nir_opt_deref);
progress |= OPT(s, nir_opt_dce);
progress |= OPT(s, nir_opt_cse);
static int gcm = -1;