Mesa (master): spirv: Don't remove dead variables in `create_library` mode

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sat Jan 30 01:19:52 UTC 2021


Module: Mesa
Branch: master
Commit: a0d73ca65c0b159a25e9bf6bbe0f5a418f1f58cc
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a0d73ca65c0b159a25e9bf6bbe0f5a418f1f58cc

Author: Caio Marcelo de Oliveira Filho <caio.oliveira at intel.com>
Date:   Thu Jan 21 02:35:43 2021 -0800

spirv: Don't remove dead variables in `create_library` mode

The issues fixed by the removal happen when a module has multiple
entry points and conflicting global variables.  Neither conditions are
expected in a library.

Reviewed-by: Jesse Natalie <jenatali at microsoft.com>
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8786>

---

 src/compiler/spirv/spirv_to_nir.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c
index 006a43a4ee2..8c1366cd006 100644
--- a/src/compiler/spirv/spirv_to_nir.c
+++ b/src/compiler/spirv/spirv_to_nir.c
@@ -5976,14 +5976,16 @@ spirv_to_nir(const uint32_t *words, size_t word_count,
     * initializers on outputs so nir_remove_dead_variables sees that they're
     * written to.
     */
-   nir_lower_variable_initializers(b->shader, nir_var_shader_out |
-                                              nir_var_system_value);
-   const nir_remove_dead_variables_options dead_opts = {
-      .can_remove_var = can_remove,
-      .can_remove_var_data = b->vars_used_indirectly,
-   };
-   nir_remove_dead_variables(b->shader, ~nir_var_function_temp,
-                             b->vars_used_indirectly ? &dead_opts : NULL);
+   if (!options->create_library) {
+      nir_lower_variable_initializers(b->shader, nir_var_shader_out |
+                                                 nir_var_system_value);
+      const nir_remove_dead_variables_options dead_opts = {
+         .can_remove_var = can_remove,
+         .can_remove_var_data = b->vars_used_indirectly,
+      };
+      nir_remove_dead_variables(b->shader, ~nir_var_function_temp,
+                                b->vars_used_indirectly ? &dead_opts : NULL);
+   }
 
    /* We sometimes generate bogus derefs that, while never used, give the
     * validator a bit of heartburn.  Run dead code to get rid of them.



More information about the mesa-commit mailing list