[Mesa-dev] [RFC 09/27] i965: Merge initialisation of backend_visitor

Topi Pohjolainen topi.pohjolainen at intel.com
Sat Feb 22 01:05:35 PST 2014


Signed-off-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
---
 src/mesa/drivers/dri/i965/brw_fs_visitor.cpp   |  9 ++-------
 src/mesa/drivers/dri/i965/brw_shader.cpp       | 12 ++++++++++++
 src/mesa/drivers/dri/i965/brw_shader.h         |  7 +++++++
 src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp |  9 ++-------
 4 files changed, 23 insertions(+), 14 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index aea3360..f89183b 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -2947,16 +2947,11 @@ fs_visitor::fs_visitor(struct brw_context *brw,
                        struct gl_shader_program *shader_prog,
                        struct gl_fragment_program *fp,
                        unsigned dispatch_width)
-   : dispatch_width(dispatch_width)
+   : backend_visitor(brw, shader_prog, &fp->Base, &c->prog_data.base),
+     dispatch_width(dispatch_width)
 {
    this->c = c;
-   this->brw = brw;
    this->fp = fp;
-   this->prog = &fp->Base;
-   this->shader_prog = shader_prog;
-   this->prog = &fp->Base;
-   this->stage_prog_data = &c->prog_data.base;
-   this->ctx = &brw->ctx;
    this->mem_ctx = ralloc_context(NULL);
    if (shader_prog)
       shader = (struct brw_shader *)
diff --git a/src/mesa/drivers/dri/i965/brw_shader.cpp b/src/mesa/drivers/dri/i965/brw_shader.cpp
index d3a7560..2f20835 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.cpp
+++ b/src/mesa/drivers/dri/i965/brw_shader.cpp
@@ -537,6 +537,18 @@ brw_instruction_name(enum opcode op)
    }
 }
 
+backend_visitor::backend_visitor(struct brw_context *brw,
+                                 struct gl_shader_program *shader_prog,
+                                 struct gl_program *prog,
+                                 struct brw_stage_prog_data *stage_prog_data)
+   : brw(brw),
+     ctx(&brw->ctx),
+     shader_prog(shader_prog),
+     prog(prog),
+     stage_prog_data(stage_prog_data)
+{
+}
+
 bool
 backend_instruction::is_tex()
 {
diff --git a/src/mesa/drivers/dri/i965/brw_shader.h b/src/mesa/drivers/dri/i965/brw_shader.h
index c76f33b..ac03a2f 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.h
+++ b/src/mesa/drivers/dri/i965/brw_shader.h
@@ -68,6 +68,13 @@ enum instruction_scheduler_mode {
 };
 
 class backend_visitor : public ir_visitor {
+protected:
+
+   backend_visitor(struct brw_context *brw,
+                   struct gl_shader_program *shader_prog,
+                   struct gl_program *prog,
+                   struct brw_stage_prog_data *stage_prog_data);
+
 public:
 
    struct brw_context *brw;
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
index c11c514..7ffa338 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
@@ -3315,7 +3315,8 @@ vec4_visitor::vec4_visitor(struct brw_context *brw,
                            shader_time_shader_type st_base,
                            shader_time_shader_type st_written,
                            shader_time_shader_type st_reset)
-   : c(c),
+   : backend_visitor(brw, shader_prog, prog, &prog_data->base),
+     c(c),
      key(key),
      prog_data(prog_data),
      sanity_param_count(0),
@@ -3328,9 +3329,6 @@ vec4_visitor::vec4_visitor(struct brw_context *brw,
      st_written(st_written),
      st_reset(st_reset)
 {
-   this->brw = brw;
-   this->ctx = &brw->ctx;
-   this->shader_prog = shader_prog;
    this->shader = shader;
 
    this->mem_ctx = mem_ctx;
@@ -3340,9 +3338,6 @@ vec4_visitor::vec4_visitor(struct brw_context *brw,
    this->current_annotation = NULL;
    memset(this->output_reg_annotation, 0, sizeof(this->output_reg_annotation));
 
-   this->prog = prog;
-   this->stage_prog_data = &prog_data->base;
-
    this->variable_ht = hash_table_ctor(0,
 				       hash_table_pointer_hash,
 				       hash_table_pointer_compare);
-- 
1.8.3.1



More information about the mesa-dev mailing list