glsl: Disable several optimizations on shared variables
authorJordan Justen <jordan.l.justen@intel.com>
Sat, 10 Oct 2015 18:30:33 +0000 (11:30 -0700)
committerJordan Justen <jordan.l.justen@intel.com>
Thu, 10 Dec 2015 07:50:38 +0000 (23:50 -0800)
Shared variables can be accessed by other threads within the same
local workgroup. This prevents us from performing certain
optimizations with shared variables.

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
src/glsl/opt_constant_propagation.cpp
src/glsl/opt_constant_variable.cpp
src/glsl/opt_copy_propagation.cpp

index 184aaa1c2975ce864f1ecfda4b86625bdeec7709..fb24a4fad046e7324fe96df58d0979ff59930a60 100644 (file)
@@ -500,7 +500,8 @@ ir_constant_propagation_visitor::add_constant(ir_assignment *ir)
     * the variable value isn't modified between this assignment and the next
     * instruction where its value is read.
     */
-   if (deref->var->data.mode == ir_var_shader_storage)
+   if (deref->var->data.mode == ir_var_shader_storage ||
+       deref->var->data.mode == ir_var_shader_shared)
       return;
 
    entry = new(this->mem_ctx) acp_entry(deref->var, ir->write_mask, constant);
index cdfbc34024379d4f1f390f87cc0687f9c04137d9..56f6a819e1ede80ad71ff12c0f42fd2634bd3eeb 100644 (file)
@@ -120,7 +120,8 @@ ir_constant_variable_visitor::visit_enter(ir_assignment *ir)
     * and we can't be sure that this variable won't be written by another
     * thread.
     */
-   if (var->data.mode == ir_var_shader_storage)
+   if (var->data.mode == ir_var_shader_storage ||
+       var->data.mode == ir_var_shader_shared)
       return visit_continue;
 
    constval = ir->rhs->constant_expression_value();
index f20699563fd0e60854bcad89f77f5e04c086b0ea..5d4cb4fe6131ebef054e4bbec47906ee8bc73c5c 100644 (file)
@@ -330,7 +330,8 @@ ir_copy_propagation_visitor::add_copy(ir_assignment *ir)
          */
         ir->condition = new(ralloc_parent(ir)) ir_constant(false);
         this->progress = true;
-      } else if (lhs_var->data.mode != ir_var_shader_storage) {
+      } else if (lhs_var->data.mode != ir_var_shader_storage &&
+                 lhs_var->data.mode != ir_var_shader_shared) {
         entry = new(this->acp) acp_entry(lhs_var, rhs_var);
         this->acp->push_tail(entry);
       }