Signed-off-by: Topi Pohjolainen <topi.pohjolai...@intel.com> --- src/mesa/drivers/dri/i965/brw_cfg.cpp | 8 ++++---- src/mesa/drivers/dri/i965/brw_cfg.h | 4 ++-- src/mesa/drivers/dri/i965/brw_dead_control_flow.cpp | 6 +++--- src/mesa/drivers/dri/i965/brw_dead_control_flow.h | 2 +- src/mesa/drivers/dri/i965/brw_fs.h | 2 +- src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 3 ++- .../drivers/dri/i965/brw_schedule_instructions.cpp | 4 ++-- src/mesa/drivers/dri/i965/brw_shader.cpp | 15 +++++++++------ src/mesa/drivers/dri/i965/brw_shader.h | 20 ++++++++++++++------ src/mesa/drivers/dri/i965/brw_vec4.h | 2 +- src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 3 ++- 11 files changed, 41 insertions(+), 28 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_cfg.cpp b/src/mesa/drivers/dri/i965/brw_cfg.cpp index 32ba4a4..67ca930 100644 --- a/src/mesa/drivers/dri/i965/brw_cfg.cpp +++ b/src/mesa/drivers/dri/i965/brw_cfg.cpp @@ -65,14 +65,14 @@ bblock_t::add_successor(void *mem_ctx, bblock_t *successor) } void -bblock_t::dump(backend_visitor *v) +bblock_t::dump(backend_emitter *e) { int ip = this->start_ip; for (backend_instruction *inst = (backend_instruction *)this->start; inst != this->end->next; inst = (backend_instruction *) inst->next) { printf("%5d: ", ip); - v->dump_instruction(inst); + e->dump_instruction(inst); ip++; } } @@ -293,7 +293,7 @@ cfg_t::make_block_array() } void -cfg_t::dump(backend_visitor *v) +cfg_t::dump(backend_emitter *e) { for (int b = 0; b < this->num_blocks; b++) { bblock_t *block = this->blocks[b]; @@ -303,7 +303,7 @@ cfg_t::dump(backend_visitor *v) printf(" <-B%d", link->block->block_num); } printf("\n"); - block->dump(v); + block->dump(e); printf("END B%d", b); foreach_list(node, &block->children) { bblock_link *link = (bblock_link *)node; diff --git a/src/mesa/drivers/dri/i965/brw_cfg.h b/src/mesa/drivers/dri/i965/brw_cfg.h index 7bd3e24..1316518 100644 --- a/src/mesa/drivers/dri/i965/brw_cfg.h +++ b/src/mesa/drivers/dri/i965/brw_cfg.h @@ -46,7 +46,7 @@ public: bblock_t(); void add_successor(void *mem_ctx, bblock_t *successor); - void dump(backend_visitor *v); + void dump(backend_emitter *e); backend_instruction *start; backend_instruction *end; @@ -80,7 +80,7 @@ public: void set_next_block(bblock_t **cur, bblock_t *block, int ip); void make_block_array(); - void dump(backend_visitor *v); + void dump(backend_emitter *e); void *mem_ctx; diff --git a/src/mesa/drivers/dri/i965/brw_dead_control_flow.cpp b/src/mesa/drivers/dri/i965/brw_dead_control_flow.cpp index 63a3e5b..35b0de0 100644 --- a/src/mesa/drivers/dri/i965/brw_dead_control_flow.cpp +++ b/src/mesa/drivers/dri/i965/brw_dead_control_flow.cpp @@ -35,11 +35,11 @@ * - if/else/endif */ bool -dead_control_flow_eliminate(backend_visitor *v) +dead_control_flow_eliminate(backend_emitter *e) { bool progress = false; - cfg_t cfg(&v->instructions); + cfg_t cfg(&e->instructions); for (int b = 0; b < cfg.num_blocks; b++) { bblock_t *block = cfg.blocks[b]; @@ -77,7 +77,7 @@ dead_control_flow_eliminate(backend_visitor *v) } if (progress) - v->invalidate_live_intervals(); + e->invalidate_live_intervals(); return progress; } diff --git a/src/mesa/drivers/dri/i965/brw_dead_control_flow.h b/src/mesa/drivers/dri/i965/brw_dead_control_flow.h index 57a4dab..58f8612 100644 --- a/src/mesa/drivers/dri/i965/brw_dead_control_flow.h +++ b/src/mesa/drivers/dri/i965/brw_dead_control_flow.h @@ -23,4 +23,4 @@ #include "brw_shader.h" -bool dead_control_flow_eliminate(backend_visitor *v); +bool dead_control_flow_eliminate(backend_emitter *e); diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h index eb9e1bf..d273560 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.h +++ b/src/mesa/drivers/dri/i965/brw_fs.h @@ -242,7 +242,7 @@ public: * * Translates either GLSL IR or Mesa IR (for ARB_fragment_program) into FS IR. */ -class fs_visitor : public backend_visitor +class fs_visitor : public backend_visitor, public backend_emitter { public: diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp index ba370a0..09fa6c1 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp @@ -2947,8 +2947,9 @@ fs_visitor::fs_visitor(struct brw_context *brw, struct gl_shader_program *shader_prog, struct gl_fragment_program *fp, unsigned dispatch_width) - : backend_visitor(brw, shader_prog, &fp->Base, &c->prog_data.base, + : backend_visitor(shader_prog, &fp->Base, &c->prog_data.base, MESA_SHADER_FRAGMENT), + backend_emitter(brw), dispatch_width(dispatch_width) { this->c = c; diff --git a/src/mesa/drivers/dri/i965/brw_schedule_instructions.cpp b/src/mesa/drivers/dri/i965/brw_schedule_instructions.cpp index a61bbab..f0bd391 100644 --- a/src/mesa/drivers/dri/i965/brw_schedule_instructions.cpp +++ b/src/mesa/drivers/dri/i965/brw_schedule_instructions.cpp @@ -393,7 +393,7 @@ schedule_node::set_latency_gen7(bool is_haswell) class instruction_scheduler { public: - instruction_scheduler(backend_visitor *v, int grf_count, + instruction_scheduler(backend_emitter *v, int grf_count, instruction_scheduler_mode mode) { this->bv = v; @@ -449,7 +449,7 @@ public: int grf_count; int time; exec_list instructions; - backend_visitor *bv; + backend_emitter *bv; instruction_scheduler_mode mode; diff --git a/src/mesa/drivers/dri/i965/brw_shader.cpp b/src/mesa/drivers/dri/i965/brw_shader.cpp index 077d961..17763c8 100644 --- a/src/mesa/drivers/dri/i965/brw_shader.cpp +++ b/src/mesa/drivers/dri/i965/brw_shader.cpp @@ -537,14 +537,11 @@ brw_instruction_name(enum opcode op) } } -backend_visitor::backend_visitor(struct brw_context *brw, - struct gl_shader_program *shader_prog, +backend_visitor::backend_visitor(struct gl_shader_program *shader_prog, struct gl_program *prog, struct brw_stage_prog_data *stage_prog_data, gl_shader_stage stage) - : brw(brw), - ctx(&brw->ctx), - shader(shader_prog ? + : shader(shader_prog ? (struct brw_shader *)shader_prog->_LinkedShaders[stage] : NULL), shader_prog(shader_prog), prog(prog), @@ -552,6 +549,12 @@ backend_visitor::backend_visitor(struct brw_context *brw, { } +backend_emitter::backend_emitter(struct brw_context *brw) + : brw(brw), + ctx(&brw->ctx) +{ +} + bool backend_instruction::is_tex() { @@ -676,7 +679,7 @@ backend_instruction::has_side_effects() const } void -backend_visitor::dump_instructions() +backend_emitter::dump_instructions() { int ip = 0; foreach_list(node, &this->instructions) { diff --git a/src/mesa/drivers/dri/i965/brw_shader.h b/src/mesa/drivers/dri/i965/brw_shader.h index e718197..b45687a 100644 --- a/src/mesa/drivers/dri/i965/brw_shader.h +++ b/src/mesa/drivers/dri/i965/brw_shader.h @@ -70,20 +70,30 @@ enum instruction_scheduler_mode { class backend_visitor : public ir_visitor { protected: - backend_visitor(struct brw_context *brw, - struct gl_shader_program *shader_prog, + backend_visitor(struct gl_shader_program *shader_prog, struct gl_program *prog, struct brw_stage_prog_data *stage_prog_data, gl_shader_stage stage); public: - struct brw_context * const brw; - struct gl_context * const ctx; + void assign_common_binding_table_offsets(uint32_t next_binding_table_offset); + struct brw_shader * const shader; struct gl_shader_program * const shader_prog; struct gl_program * const prog; struct brw_stage_prog_data * const stage_prog_data; +}; + +class backend_emitter { +protected: + + explicit backend_emitter(struct brw_context *brw); + +public: + + struct brw_context * const brw; + struct gl_context * const ctx; /** ralloc context for temporary data used during compile */ void *mem_ctx; @@ -97,8 +107,6 @@ public: virtual void dump_instruction(backend_instruction *inst) = 0; virtual void dump_instructions(); - void assign_common_binding_table_offsets(uint32_t next_binding_table_offset); - virtual void invalidate_live_intervals() = 0; }; diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h b/src/mesa/drivers/dri/i965/brw_vec4.h index 52e9b51..0aff357 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4.h +++ b/src/mesa/drivers/dri/i965/brw_vec4.h @@ -278,7 +278,7 @@ public: * Translates either GLSL IR or Mesa IR (for ARB_vertex_program and * fixed-function) into VS IR. */ -class vec4_visitor : public backend_visitor +class vec4_visitor : public backend_visitor, public backend_emitter { public: vec4_visitor(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 d841fec..145cb8c 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) - : backend_visitor(brw, shader_prog, prog, &prog_data->base, stage), + : backend_visitor(shader_prog, prog, &prog_data->base, stage), + backend_emitter(brw), c(c), key(key), prog_data(prog_data), -- 1.8.3.1 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev