[Mesa-dev] [PATCH 23/23] i965: Add polymorphic backend_visitor method to extract the result of a visit.

Francisco Jerez currojerez at riseup.net
Mon Dec 2 11:36:17 PST 2013


This will be used by the generic implementation of the image and
atomic counter built-ins to extract the register location of its
arguments without having to be aware of the actual visitor type.
---
 src/mesa/drivers/dri/i965/brw_fs.h             | 3 +++
 src/mesa/drivers/dri/i965/brw_fs_visitor.cpp   | 7 +++++++
 src/mesa/drivers/dri/i965/brw_shader.h         | 3 +++
 src/mesa/drivers/dri/i965/brw_vec4.h           | 3 +++
 src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 7 +++++++
 5 files changed, 23 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h
index 4f9767c..4ada075 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -237,6 +237,9 @@ public:
    void visit(ir_emit_vertex *);
    void visit(ir_end_primitive *);
 
+   /** Visit an instruction \p ir and extract the result. */
+   virtual fs_reg &visit_result(ir_instruction *ir);
+
    uint32_t gather_channel(ir_texture *ir, int sampler);
    void swizzle_result(ir_texture *ir, fs_reg orig_val, int sampler);
 
diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index f45f089..b5957c6 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -2874,6 +2874,13 @@ fs_visitor::resolve_bool_comparison(ir_rvalue *rvalue, fs_reg *reg)
    *reg = temp;
 }
 
+fs_reg &
+fs_visitor::visit_result(ir_instruction *ir)
+{
+   ir->accept(this);
+   return result;
+}
+
 fs_visitor::fs_visitor(struct brw_context *brw,
                        struct brw_wm_compile *c,
                        struct gl_shader_program *shader_prog,
diff --git a/src/mesa/drivers/dri/i965/brw_shader.h b/src/mesa/drivers/dri/i965/brw_shader.h
index c31f76d..48382af 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.h
+++ b/src/mesa/drivers/dri/i965/brw_shader.h
@@ -141,6 +141,9 @@ public:
     */
    exec_list instructions;
 
+   /** Visit an instruction \p ir and extract the result. */
+   virtual backend_reg &visit_result(ir_instruction *ir) = 0;
+
    virtual void dump_instruction(backend_instruction *inst) = 0;
    void dump_instructions();
 
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h b/src/mesa/drivers/dri/i965/brw_vec4.h
index 50e4794..355d497 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.h
+++ b/src/mesa/drivers/dri/i965/brw_vec4.h
@@ -354,6 +354,9 @@ public:
    virtual void visit(ir_end_primitive *);
    /*@}*/
 
+   /** Visit an instruction \p ir and extract the result. */
+   virtual src_reg &visit_result(ir_instruction *ir);
+
    src_reg result;
 
    /* Regs for vertex results.  Generated at ir_variable visiting time
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
index 5b0ceea..97bd26d 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
@@ -3230,6 +3230,13 @@ vec4_visitor::resolve_ud_negate(src_reg *reg)
    *reg = temp;
 }
 
+src_reg &
+vec4_visitor::visit_result(ir_instruction *ir)
+{
+   ir->accept(this);
+   return result;
+}
+
 vec4_visitor::vec4_visitor(struct brw_context *brw,
                            struct brw_vec4_compile *c,
                            struct gl_program *prog,
-- 
1.8.3.4



More information about the mesa-dev mailing list