glsl: Make read_from_write_only_variable_visitor ignore .length().
authorKenneth Graunke <kenneth@whitecape.org>
Mon, 11 Jan 2016 22:51:38 +0000 (14:51 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Tue, 12 Jan 2016 20:20:02 +0000 (12:20 -0800)
.length() on an unsized SSBO variable doesn't actually read any data
from the SSBO, and is allowed on variables marked 'writeonly'.

Fixes compute shader compilation in Shadow of Mordor.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
src/glsl/ast_to_hir.cpp

index f3966d7e3f4cd4ae1a9f9112ed69bda740a975e4..13696a36b0cffe058be3503bfc17190e4c55b9fc 100644 (file)
@@ -106,6 +106,15 @@ public:
       return found;
    }
 
+   virtual ir_visitor_status visit_enter(ir_expression *ir)
+   {
+      /* .length() doesn't actually read anything */
+      if (ir->operation == ir_unop_ssbo_unsized_array_length)
+         return visit_continue_with_parent;
+
+      return visit_continue;
+   }
+
 private:
    ir_variable *found;
 };