From a32817f3c248125fb537c3a915566445e5600d45 Mon Sep 17 00:00:00 2001 From: Francisco Jerez Date: Tue, 26 Nov 2013 19:56:07 -0800 Subject: [PATCH] i965: Unify fs_generator:: and vec4_generator::mark_surface_used as a free function. This way it can be used anywhere. I need it from the visitor. Reviewed-by: Paul Berry --- src/mesa/drivers/dri/i965/brw_fs.h | 2 -- .../drivers/dri/i965/brw_fs_generator.cpp | 28 +++++++------------ src/mesa/drivers/dri/i965/brw_program.c | 10 +++++++ src/mesa/drivers/dri/i965/brw_program.h | 4 +++ src/mesa/drivers/dri/i965/brw_shader.cpp | 2 +- src/mesa/drivers/dri/i965/brw_vec4.h | 2 -- .../drivers/dri/i965/brw_vec4_generator.cpp | 22 +++++---------- 7 files changed, 32 insertions(+), 38 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h index c6f4ffb4a19..914ace67ce9 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.h +++ b/src/mesa/drivers/dri/i965/brw_fs.h @@ -641,8 +641,6 @@ private: struct brw_reg dst, struct brw_reg surf_index); - void mark_surface_used(unsigned surf_index); - void patch_discard_jumps_to_fb_writes(); struct brw_context *brw; diff --git a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp index ee13ced9e57..82db1407e81 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp @@ -56,15 +56,6 @@ fs_generator::~fs_generator() { } -void -fs_generator::mark_surface_used(unsigned surf_index) -{ - assert(surf_index < BRW_MAX_SURFACES); - - c->prog_data.base.binding_table.size_bytes = - MAX2(c->prog_data.base.binding_table.size_bytes, (surf_index + 1) * 4); -} - void fs_generator::patch_discard_jumps_to_fb_writes() { @@ -189,7 +180,7 @@ fs_generator::generate_fb_write(fs_inst *inst) eot, inst->header_present); - mark_surface_used(surf_index); + brw_mark_surface_used(&c->prog_data.base, surf_index); } void @@ -619,7 +610,7 @@ fs_generator::generate_tex(fs_inst *inst, struct brw_reg dst, struct brw_reg src simd_mode, return_format); - mark_surface_used(surface_index); + brw_mark_surface_used(&c->prog_data.base, surface_index); } @@ -831,7 +822,7 @@ fs_generator::generate_uniform_pull_constant_load(fs_inst *inst, brw_oword_block_read(p, dst, brw_message_reg(inst->base_mrf), read_offset, surf_index); - mark_surface_used(surf_index); + brw_mark_surface_used(&c->prog_data.base, surf_index); } void @@ -873,7 +864,7 @@ fs_generator::generate_uniform_pull_constant_load_gen7(fs_inst *inst, BRW_SAMPLER_SIMD_MODE_SIMD4X2, 0); - mark_surface_used(surf_index); + brw_mark_surface_used(&c->prog_data.base, surf_index); } void @@ -940,7 +931,7 @@ fs_generator::generate_varying_pull_constant_load(fs_inst *inst, simd_mode, return_format); - mark_surface_used(surf_index); + brw_mark_surface_used(&c->prog_data.base, surf_index); } void @@ -984,7 +975,7 @@ fs_generator::generate_varying_pull_constant_load_gen7(fs_inst *inst, simd_mode, 0); - mark_surface_used(surf_index); + brw_mark_surface_used(&c->prog_data.base, surf_index); } /** @@ -1290,7 +1281,8 @@ fs_generator::generate_shader_time_add(fs_inst *inst, c->prog_data.base.binding_table.shader_time_start); brw_pop_insn_state(p); - mark_surface_used(c->prog_data.base.binding_table.shader_time_start); + brw_mark_surface_used(&c->prog_data.base, + c->prog_data.base.binding_table.shader_time_start); } void @@ -1307,7 +1299,7 @@ fs_generator::generate_untyped_atomic(fs_inst *inst, struct brw_reg dst, atomic_op.dw1.ud, surf_index.dw1.ud, inst->mlen, dispatch_width / 8); - mark_surface_used(surf_index.dw1.ud); + brw_mark_surface_used(&c->prog_data.base, surf_index.dw1.ud); } void @@ -1321,7 +1313,7 @@ fs_generator::generate_untyped_surface_read(fs_inst *inst, struct brw_reg dst, surf_index.dw1.ud, inst->mlen, dispatch_width / 8); - mark_surface_used(surf_index.dw1.ud); + brw_mark_surface_used(&c->prog_data.base, surf_index.dw1.ud); } void diff --git a/src/mesa/drivers/dri/i965/brw_program.c b/src/mesa/drivers/dri/i965/brw_program.c index f69c3129c01..58a7e811e3a 100644 --- a/src/mesa/drivers/dri/i965/brw_program.c +++ b/src/mesa/drivers/dri/i965/brw_program.c @@ -545,6 +545,16 @@ brw_destroy_shader_time(struct brw_context *brw) brw->shader_time.bo = NULL; } +void +brw_mark_surface_used(struct brw_stage_prog_data *prog_data, + unsigned surf_index) +{ + assert(surf_index < BRW_MAX_SURFACES); + + prog_data->binding_table.size_bytes = + MAX2(prog_data->binding_table.size_bytes, (surf_index + 1) * 4); +} + bool brw_stage_prog_data_compare(const struct brw_stage_prog_data *a, const struct brw_stage_prog_data *b) diff --git a/src/mesa/drivers/dri/i965/brw_program.h b/src/mesa/drivers/dri/i965/brw_program.h index 36134de95da..59f628be6ec 100644 --- a/src/mesa/drivers/dri/i965/brw_program.h +++ b/src/mesa/drivers/dri/i965/brw_program.h @@ -76,6 +76,10 @@ bool brw_debug_recompile_sampler_key(struct brw_context *brw, const struct brw_sampler_prog_key_data *key); void brw_add_texrect_params(struct gl_program *prog); +void +brw_mark_surface_used(struct brw_stage_prog_data *prog_data, + unsigned surf_index); + bool brw_stage_prog_data_compare(const struct brw_stage_prog_data *a, const struct brw_stage_prog_data *b); diff --git a/src/mesa/drivers/dri/i965/brw_shader.cpp b/src/mesa/drivers/dri/i965/brw_shader.cpp index d58c13d733c..d3a75607846 100644 --- a/src/mesa/drivers/dri/i965/brw_shader.cpp +++ b/src/mesa/drivers/dri/i965/brw_shader.cpp @@ -722,5 +722,5 @@ backend_visitor::assign_common_binding_table_offsets(uint32_t next_binding_table assert(next_binding_table_offset <= BRW_MAX_SURFACES); - /* prog_data->base.binding_table.size will be set by mark_surface_used. */ + /* prog_data->base.binding_table.size will be set by brw_mark_surface_used. */ } diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h b/src/mesa/drivers/dri/i965/brw_vec4.h index 9bbb6d823b8..ecb16497fdb 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4.h +++ b/src/mesa/drivers/dri/i965/brw_vec4.h @@ -644,8 +644,6 @@ private: struct brw_reg dst, struct brw_reg surf_index); - void mark_surface_used(unsigned surf_index); - struct brw_context *brw; struct brw_compile *p; diff --git a/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp b/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp index e5ed2c29300..058b639309b 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp @@ -150,15 +150,6 @@ vec4_generator::~vec4_generator() { } -void -vec4_generator::mark_surface_used(unsigned surf_index) -{ - assert(surf_index < BRW_MAX_SURFACES); - - prog_data->base.binding_table.size_bytes = - MAX2(prog_data->base.binding_table.size_bytes, (surf_index + 1) * 4); -} - void vec4_generator::generate_math1_gen4(vec4_instruction *inst, struct brw_reg dst, @@ -438,7 +429,7 @@ vec4_generator::generate_tex(vec4_instruction *inst, BRW_SAMPLER_SIMD_MODE_SIMD4X2, return_format); - mark_surface_used(surface_index); + brw_mark_surface_used(&prog_data->base, surface_index); } void @@ -850,7 +841,7 @@ vec4_generator::generate_pull_constant_load(vec4_instruction *inst, true, /* header_present */ 1 /* rlen */); - mark_surface_used(surf_index); + brw_mark_surface_used(&prog_data->base, surf_index); } void @@ -875,7 +866,7 @@ vec4_generator::generate_pull_constant_load_gen7(vec4_instruction *inst, BRW_SAMPLER_SIMD_MODE_SIMD4X2, 0); - mark_surface_used(surf_index.dw1.ud); + brw_mark_surface_used(&prog_data->base, surf_index.dw1.ud); } void @@ -893,7 +884,7 @@ vec4_generator::generate_untyped_atomic(vec4_instruction *inst, atomic_op.dw1.ud, surf_index.dw1.ud, inst->mlen, 1); - mark_surface_used(surf_index.dw1.ud); + brw_mark_surface_used(&prog_data->base, surf_index.dw1.ud); } void @@ -908,7 +899,7 @@ vec4_generator::generate_untyped_surface_read(vec4_instruction *inst, surf_index.dw1.ud, inst->mlen, 1); - mark_surface_used(surf_index.dw1.ud); + brw_mark_surface_used(&prog_data->base, surf_index.dw1.ud); } /** @@ -1221,7 +1212,8 @@ vec4_generator::generate_vec4_instruction(vec4_instruction *instruction, case SHADER_OPCODE_SHADER_TIME_ADD: brw_shader_time_add(p, src[0], prog_data->base.binding_table.shader_time_start); - mark_surface_used(prog_data->base.binding_table.shader_time_start); + brw_mark_surface_used(&prog_data->base, + prog_data->base.binding_table.shader_time_start); break; case SHADER_OPCODE_UNTYPED_ATOMIC: -- 2.30.2