glsl/spirv: remove dead uniforms in spirv nir linker
authorTimothy Arceri <tarceri@itsqueeze.com>
Mon, 4 May 2020 04:33:56 +0000 (14:33 +1000)
committerMarge Bot <eric+marge@anholt.net>
Wed, 3 Jun 2020 02:22:23 +0000 (02:22 +0000)
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4797>

src/compiler/glsl/gl_nir_linker.c

index 7c38f28cd3c6fcfa536171d25d62ebe3fbd0b456..c0cd587d0a11bb67b60a5ec1d36ad70f157fdcda 100644 (file)
@@ -601,6 +601,14 @@ bool
 gl_nir_link_spirv(struct gl_context *ctx, struct gl_shader_program *prog,
                   const struct gl_nir_linker_options *options)
 {
+   for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
+      struct gl_linked_shader *shader = prog->_LinkedShaders[i];
+      if (shader) {
+         nir_remove_dead_variables(shader->Program->nir, nir_var_uniform,
+                                   &can_remove_uniform);
+      }
+   }
+
    if (!gl_nir_link_uniform_blocks(ctx, prog))
       return false;