nir_lower_tex_shadow: For old-style shadows, use vec4(result, 0, 0, 1)

If the app requests a swizzle on the shadow sampler which doesn't just
return the red channel or literal 0s/1s, we'll crash attempting to build
the result vector. Use something that's probably valid.

Cc: mesa-stable
Reviewed-by: Christian Gmeiner <cgmeiner@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28001>
(cherry picked from commit cda6877cb6)
This commit is contained in:
Jesse Natalie 2024-03-05 16:23:42 -08:00 committed by Eric Engestrom
parent 6fdb734b86
commit d12ea6f472
2 changed files with 2 additions and 2 deletions

View file

@ -104,7 +104,7 @@
"description": "nir_lower_tex_shadow: For old-style shadows, use vec4(result, 0, 0, 1)",
"nominated": true,
"nomination_type": 0,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null,
"notes": null

View file

@ -115,7 +115,7 @@ nir_lower_tex_shadow_impl(nir_builder *b, nir_instr *instr, void *options)
nir_def *one = nir_imm_float(b, 1.0);
nir_def *zero = nir_imm_float(b, 0.0);
nir_def *lookup[6] = { result, NULL, NULL, NULL, zero, one };
nir_def *lookup[6] = { result, zero, zero, one, zero, one };
nir_def *r[4] = { result, result, result, result };
if (sampler_binding < state->n_states) {