From d12ea6f4725e063f701f952084efc86809cbfb6b Mon Sep 17 00:00:00 2001 From: Jesse Natalie Date: Tue, 5 Mar 2024 16:23:42 -0800 Subject: [PATCH] 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 Part-of: (cherry picked from commit cda6877cb6bb473970e32f3b13f6e5483ada6bcb) --- .pick_status.json | 2 +- src/compiler/nir/nir_lower_tex_shadow.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 8fcf42e71a9..4aa5a0b0097 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -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 diff --git a/src/compiler/nir/nir_lower_tex_shadow.c b/src/compiler/nir/nir_lower_tex_shadow.c index 882a5cc2003..ec077a60d97 100644 --- a/src/compiler/nir/nir_lower_tex_shadow.c +++ b/src/compiler/nir/nir_lower_tex_shadow.c @@ -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) {