glsl: Don't dead-code eliminiate uniforms declared in uniform blocks.
authorEric Anholt <eric@anholt.net>
Tue, 1 May 2012 21:26:09 +0000 (14:26 -0700)
committerEric Anholt <eric@anholt.net>
Fri, 20 Jul 2012 17:43:52 +0000 (10:43 -0700)
This is a requirement for std140 uniform blocks, and optional for
packed/shared blocks.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/glsl/opt_dead_code.cpp

index 0578f1737b050becd8405eddbcc58f8bc16ffe05..de8475f956eb3fd0a3ad8a515862086c78790753 100644 (file)
@@ -95,9 +95,15 @@ do_dead_code(exec_list *instructions, bool uniform_locations_assigned)
         /* uniform initializers are precious, and could get used by another
          * stage.  Also, once uniform locations have been assigned, the
          * declaration cannot be deleted.
+         *
+         * Also, GL_ARB_uniform_buffer_object says that std140
+         * uniforms will not be eliminated.  Since we always do
+         * std140, just don't eliminate uniforms in UBOs.
          */
         if (entry->var->mode == ir_var_uniform &&
-            (uniform_locations_assigned || entry->var->constant_value))
+            (uniform_locations_assigned ||
+             entry->var->constant_value ||
+             entry->var->uniform_block != -1))
            continue;
 
         entry->var->remove();