[Mesa-dev] [PATCH 2/6] i965/fs: Track the maximum surface index used in brw_wm_prog_data.
Paul Berry
stereotype441 at gmail.com
Fri Aug 16 06:11:25 PDT 2013
On 14 August 2013 21:07, Kenneth Graunke <kenneth at whitecape.org> wrote:
> This allows us to determine 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).
>
> Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
> ---
> 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 ff0a65c..380fe08 100644
> --- a/src/mesa/drivers/dri/i965/brw_context.h
> +++ b/src/mesa/drivers/dri/i965/brw_context.h
> @@ -305,6 +305,8 @@ struct brw_wm_prog_data {
> GLuint reg_blocks_16;
> GLuint total_scratch;
>
> + unsigned max_surface_index;
> +
>
I'm bothered by the off-by-one inconsistency of using max_surface_index
here, but using binding_table_size over in brw_vec4_prog_data (see patch
5). Could we change this to binding_table_size, and update
fs_generator::mark_surface_used() to do:
prog_data->binding_table_size = MAX2(prog_data->binding_table_size,
surf_index + 1);
Then it would be consistent with vec4_generator::mark_surface_used().
With that changed, this patch is:
Reviewed-by: Paul Berry <stereotype441 at gmail.com>
> 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 7feb2b6..9d240b5 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 b90cf0f..41dacff 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs_emit.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_fs_emit.cpp
> @@ -59,6 +59,15 @@ fs_generator::~fs_generator()
> }
>
> void
> +fs_generator::mark_surface_used(unsigned surf_index)
> +{
> + assert(surf_index < BRW_MAX_WM_SURFACES);
> +
> + if (surf_index > c->prog_data.max_surface_index)
> + c->prog_data.max_surface_index = surf_index;
> +}
> +
> +void
> fs_generator::patch_discard_jumps_to_fb_writes()
> {
> if (brw->gen < 6 || this->discard_halt_patches.is_empty())
> @@ -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
> --
> 1.8.3.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20130816/f0ee75f1/attachment-0001.html>
More information about the mesa-dev
mailing list