From f710a35e301ec0239fc077ee8475f1ec81a6e707 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Fri, 23 Oct 2020 14:00:49 -0500 Subject: [PATCH] mesa/spirv: Lower variable initializers for global variables MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We lower variable initializers for local variables higher up in the function but we never called nir_lower_variable_initializers for anything else. Cc: mesa-stable@lists.freedesktop.org Reviewed-by: Alejandro PiƱeiro Part-of: (cherry picked from commit 6b85a887ff511c40ea6ea0f1aea311151ab9d01d) --- .pick_status.json | 2 +- src/mesa/main/glspirv.c | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.pick_status.json b/.pick_status.json index dd5a34198e7..07a1ec42ccc 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -4873,7 +4873,7 @@ "description": "mesa/spirv: Lower variable initializers for global variables", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "master_sha": null, "because_sha": null }, diff --git a/src/mesa/main/glspirv.c b/src/mesa/main/glspirv.c index dc0a0d29dd3..92c521ba649 100644 --- a/src/mesa/main/glspirv.c +++ b/src/mesa/main/glspirv.c @@ -295,6 +295,13 @@ _mesa_spirv_to_nir(struct gl_context *ctx, } assert(exec_list_length(&nir->functions) == 1); + /* Now that we've deleted all but the main function, we can go ahead and + * lower the rest of the constant initializers. We do this here so that + * nir_remove_dead_variables and split_per_member_structs below see the + * corresponding stores. + */ + NIR_PASS_V(nir, nir_lower_variable_initializers, ~0); + /* Split member structs. We do this before lower_io_to_temporaries so that * it doesn't lower system values to temporaries by accident. */