[Mesa-dev] [PATCH v2 29/82] glsl: Do constant folding on ir_ssbo_store

Iago Toral Quiroga itoral at igalia.com
Wed Jun 3 00:01:19 PDT 2015


We have ir_rvalues for various fields within ir_ssbo_store, so we want
constant folding to know about them. Specifically, the offset of the
store operation can be computed as the addition of a constant offset
and a constant base offset, so we want that constant addition replaced
with its constant result.
---
 src/glsl/opt_constant_folding.cpp | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/src/glsl/opt_constant_folding.cpp b/src/glsl/opt_constant_folding.cpp
index 4aae3f0..4cc9f68 100644
--- a/src/glsl/opt_constant_folding.cpp
+++ b/src/glsl/opt_constant_folding.cpp
@@ -53,6 +53,7 @@ public:
    virtual ir_visitor_status visit_enter(ir_discard *ir);
    virtual ir_visitor_status visit_enter(ir_assignment *ir);
    virtual ir_visitor_status visit_enter(ir_call *ir);
+   virtual ir_visitor_status visit_enter(ir_ssbo_store *ir);
 
    virtual void handle_rvalue(ir_rvalue **rvalue);
 
@@ -179,6 +180,21 @@ ir_constant_folding_visitor::visit_enter(ir_call *ir)
    return visit_continue_with_parent;
 }
 
+ir_visitor_status
+ir_constant_folding_visitor::visit_enter(ir_ssbo_store *ir)
+{
+   ir->block->accept(this);
+   handle_rvalue(&ir->block);
+
+   ir->offset->accept(this);
+   handle_rvalue(&ir->offset);
+
+   ir->val->accept(this);
+   handle_rvalue(&ir->val);
+
+   return visit_continue_with_parent;
+}
+
 bool
 do_constant_folding(exec_list *instructions)
 {
-- 
1.9.1



More information about the mesa-dev mailing list