[Mesa-dev] [PATCH 12/27] i965: Assign hw-binding table index for each UBO constant buffer.
Pohjolainen, Topi
topi.pohjolainen at intel.com
Thu May 7 08:21:59 PDT 2015
On Tue, Apr 28, 2015 at 11:08:09PM +0300, Abdiel Janulgue wrote:
> To be able to refer to a constant buffer, the resource streamer needs
> to index it with a hardware binding table entry. This blankets the ubo
> buffers with hardware binding table indices.
>
> Gather constants hardware fetches in 16-entry binding table blocks.
> So we need to use a block that is unused.
>
> Signed-off-by: Abdiel Janulgue <abdiel.janulgue at linux.intel.com>
> ---
> src/mesa/drivers/dri/i965/brw_context.h | 11 +++++++++++
> src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 6 ++++++
> 2 files changed, 17 insertions(+)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
> index e25c64d..276c359 100644
> --- a/src/mesa/drivers/dri/i965/brw_context.h
> +++ b/src/mesa/drivers/dri/i965/brw_context.h
> @@ -678,6 +678,17 @@ struct brw_vs_prog_data {
>
> #define SURF_INDEX_GEN6_SOL_BINDING(t) (t)
>
> +/** Start of hardware binding table index for uniform gather constant entries.
> + * This must be aligned to the start of a hardware binding table block (a block
> + * is a group 16 binding table entries).
> + */
> +#define BRW_UNIFORM_GATHER_INDEX_START 32
> +
> +/** Appended to the end of the binding table index for uniform constant buffers to indicate
Wrap this line.
> + * start of the UBO gather constant binding table.
> + */
> +#define BRW_UBO_GATHER_INDEX_APPEND 2
> +
> /* Note: brw_gs_prog_data_compare() must be updated when adding fields to
> * this struct!
> */
> diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
> index 161d140..ce61554 100644
> --- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
> +++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
> @@ -884,6 +884,7 @@ brw_upload_ubo_surfaces(struct brw_context *brw,
>
> uint32_t *surf_offsets =
> &stage_state->surf_offset[prog_data->binding_table.ubo_start];
> + bool use_gather = (brw->gather_pool.bo != NULL);
I would move this closer to the only use. This won't get re-used in the
rest of the series.
>
> for (int i = 0; i < shader->NumUniformBlocks; i++) {
> struct gl_uniform_buffer_binding *binding;
> @@ -904,6 +905,11 @@ brw_upload_ubo_surfaces(struct brw_context *brw,
> bo->size - binding->Offset,
> &surf_offsets[i],
> dword_pitch);
> + if (use_gather) {
Or simply:
if (brw->gather_pool.bo) {
> + int bt_idx = BRW_UNIFORM_GATHER_INDEX_START + BRW_UBO_GATHER_INDEX_APPEND + i;
Wrap this line.
> + gen7_update_binding_table(brw, stage_state->stage,
> + bt_idx, surf_offsets[i]);
> + }
> }
>
> if (shader->NumUniformBlocks)
> --
> 1.9.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list