From 6d89bc803d83d27d8946afdd2f749334a41a9d1f Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 14 Aug 2013 19:49:33 -0700 Subject: [PATCH] i965/fs: Track the binding table size in brw_wm_prog_data. By tracking the maximum surface index used by the shader, we know just how small we can make the binding table. Since it depends entirely on the shader program, we can just compute it once at compile time, rather than at binding table emit time (which happens during drawing). v2: Store binding_table_size, rather than max_surface_index, for consistency with the VS (which needs to be able to represent 0 surfaces). Signed-off-by: Kenneth Graunke --- src/mesa/drivers/dri/i965/brw_context.h | 2 ++ src/mesa/drivers/dri/i965/brw_fs.h | 2 ++ src/mesa/drivers/dri/i965/brw_fs_emit.cpp | 23 +++++++++++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index 909e0555ea1..9178485cb5f 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -306,6 +306,8 @@ struct brw_wm_prog_data { GLuint reg_blocks_16; GLuint total_scratch; + unsigned binding_table_size; + GLuint nr_params; /**< number of float params/constants */ GLuint nr_pull_params; bool dual_src_blend; diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h index 7feb2b680be..9d240b588ef 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.h +++ b/src/mesa/drivers/dri/i965/brw_fs.h @@ -569,6 +569,8 @@ private: struct brw_reg offset, struct brw_reg value); + 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_emit.cpp b/src/mesa/drivers/dri/i965/brw_fs_emit.cpp index b90cf0fb908..bfb3d331b0a 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_emit.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_emit.cpp @@ -58,6 +58,15 @@ fs_generator::~fs_generator() { } +void +fs_generator::mark_surface_used(unsigned surf_index) +{ + assert(surf_index < BRW_MAX_WM_SURFACES); + + c->prog_data.binding_table_size = + MAX2(c->prog_data.binding_table_size, surf_index + 1); +} + void fs_generator::patch_discard_jumps_to_fb_writes() { @@ -175,6 +184,8 @@ fs_generator::generate_fb_write(fs_inst *inst) 0, eot, inst->header_present); + + mark_surface_used(SURF_INDEX_DRAW(inst->target)); } /* Computes the integer pixel x,y values from the origin. @@ -519,6 +530,8 @@ fs_generator::generate_tex(fs_inst *inst, struct brw_reg dst, struct brw_reg src inst->header_present, simd_mode, return_format); + + mark_surface_used(SURF_INDEX_TEXTURE(inst->sampler)); } @@ -648,6 +661,8 @@ 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); } void @@ -688,6 +703,8 @@ fs_generator::generate_uniform_pull_constant_load_gen7(fs_inst *inst, false, /* no header */ BRW_SAMPLER_SIMD_MODE_SIMD4X2, 0); + + mark_surface_used(surf_index); } void @@ -753,6 +770,8 @@ fs_generator::generate_varying_pull_constant_load(fs_inst *inst, inst->header_present, simd_mode, return_format); + + mark_surface_used(surf_index); } void @@ -795,6 +814,8 @@ fs_generator::generate_varying_pull_constant_load_gen7(fs_inst *inst, false, /* no header */ simd_mode, 0); + + mark_surface_used(surf_index); } /** @@ -1040,6 +1061,8 @@ fs_generator::generate_shader_time_add(fs_inst *inst, brw_MOV(p, payload_value, value); brw_shader_time_add(p, payload, SURF_INDEX_WM_SHADER_TIME); brw_pop_insn_state(p); + + mark_surface_used(SURF_INDEX_WM_SHADER_TIME); } void -- 2.30.2