glsl: Don't do constant variable on buffer variables
authorIago Toral Quiroga <itoral@igalia.com>
Fri, 24 Apr 2015 09:15:48 +0000 (11:15 +0200)
committerSamuel Iglesias Gonsalvez <siglesias@igalia.com>
Tue, 14 Jul 2015 05:04:04 +0000 (07:04 +0200)
Since the backing storage for these is shared we cannot ensure that
the value won't change by writes from other threads. Normally SSBO
accesses are not guaranteed to be syncronized with other threads,
except when memoryBarrier is used. So, we might be able to optimize
some SSBO accesses, but for now we always take the safe path and emit
the SSBO access.

Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
src/glsl/opt_constant_variable.cpp

index 7222eb92a7d358bd255b6e11d7854cc47e549497..7aaaeedf98d23e912857e70707e7bef9f900c358 100644 (file)
@@ -115,6 +115,13 @@ ir_constant_variable_visitor::visit_enter(ir_assignment *ir)
    if (!var)
       return visit_continue;
 
+   /* Ignore buffer variables, since the underlying storage is shared
+    * and we can't be sure that this variable won't be written by another
+    * thread.
+    */
+   if (var->data.mode == ir_var_shader_storage)
+      return visit_continue;
+
    constval = ir->rhs->constant_expression_value();
    if (!constval)
       return visit_continue;