[Mesa-dev] [PATCH 2/3] intel: Give the batch decoder a callback to ask about state size.
Lionel Landwerlin
lionel.g.landwerlin at intel.com
Wed May 2 10:52:22 UTC 2018
On 02/05/18 06:50, Kenneth Graunke wrote:
> Given an arbitrary batch, we don't always know what the size of certain
> things are, such as how many entries are in a binding table. But it's
> easy for the driver to track that information, so with a simple callback
> we can calculate this correctly for INTEL_DEBUG=bat.
> ---
> src/intel/common/gen_batch_decoder.c | 23 +++++++++++++++++++----
> src/intel/common/gen_decoder.h | 4 ++++
> src/intel/tools/aubinator.c | 2 +-
> src/intel/tools/aubinator_error_decode.c | 2 +-
> 4 files changed, 25 insertions(+), 6 deletions(-)
>
> diff --git a/src/intel/common/gen_batch_decoder.c b/src/intel/common/gen_batch_decoder.c
> index c6b908758b2..37eac1ab2a1 100644
> --- a/src/intel/common/gen_batch_decoder.c
> +++ b/src/intel/common/gen_batch_decoder.c
> @@ -33,11 +33,13 @@ gen_batch_decode_ctx_init(struct gen_batch_decode_ctx *ctx,
> const char *xml_path,
> struct gen_batch_decode_bo (*get_bo)(void *,
> uint64_t),
> + unsigned (*get_state_size)(void *, uint32_t),
> void *user_data)
> {
> memset(ctx, 0, sizeof(*ctx));
>
> ctx->get_bo = get_bo;
> + ctx->get_state_size = get_state_size;
> ctx->user_data = user_data;
> ctx->fp = fp;
> ctx->flags = flags;
> @@ -103,6 +105,21 @@ ctx_get_bo(struct gen_batch_decode_ctx *ctx, uint64_t addr)
> return bo;
> }
>
> +static int
> +update_count(struct gen_batch_decode_ctx *ctx,
> + uint32_t offset_from_dsba,
> + unsigned element_dwords,
> + unsigned guess)
> +{
> + unsigned size = ctx->get_state_size(ctx->user_data, offset_from_dsba);
You probably want to get the fact that ctx->get_state_size might be NULL?
> +
> + if (size > 0)
> + return size / (sizeof(uint32_t) * element_dwords);
> +
> + /* In the absence of any information, just guess arbitrarily. */
> + return guess;
> +}
> +
> static void
> ctx_disassemble_program(struct gen_batch_decode_ctx *ctx,
> uint32_t ksp, const char *type)
> @@ -196,9 +213,8 @@ dump_binding_table(struct gen_batch_decode_ctx *ctx, uint32_t offset, int count)
> return;
> }
>
> - /* If we don't know the actual count, guess. */
> if (count < 0)
> - count = 8;
> + count = update_count(ctx, offset, 1, 8);
>
> if (ctx->surface_base.map == NULL) {
> fprintf(ctx->fp, " binding table unavailable\n");
> @@ -233,9 +249,8 @@ dump_samplers(struct gen_batch_decode_ctx *ctx, uint32_t offset, int count)
> {
> struct gen_group *strct = gen_spec_find_struct(ctx->spec, "SAMPLER_STATE");
>
> - /* If we don't know the actual count, guess. */
> if (count < 0)
> - count = 4;
> + count = update_count(ctx, offset, strct->dw_length, 4);
>
> if (ctx->dynamic_base.map == NULL) {
> fprintf(ctx->fp, " samplers unavailable\n");
> diff --git a/src/intel/common/gen_decoder.h b/src/intel/common/gen_decoder.h
> index f28ac7d27af..fc567456624 100644
> --- a/src/intel/common/gen_decoder.h
> +++ b/src/intel/common/gen_decoder.h
> @@ -207,6 +207,8 @@ struct gen_disasm *disasm;
> struct gen_batch_decode_ctx {
> struct gen_batch_decode_bo (*get_bo)(void *user_data,
> uint64_t base_address);
> + unsigned (*get_state_size)(void *user_data,
> + uint32_t offset_from_dynamic_state_base_addr);
> void *user_data;
>
> FILE *fp;
> @@ -226,6 +228,8 @@ void gen_batch_decode_ctx_init(struct gen_batch_decode_ctx *ctx,
> const char *xml_path,
> struct gen_batch_decode_bo (*get_bo)(void *,
> uint64_t),
> +
> + unsigned (*get_state_size)(void *, uint32_t),
> void *user_data);
> void gen_batch_decode_ctx_finish(struct gen_batch_decode_ctx *ctx);
>
> diff --git a/src/intel/tools/aubinator.c b/src/intel/tools/aubinator.c
> index 2a72efa8a2c..ab053c66b36 100644
> --- a/src/intel/tools/aubinator.c
> +++ b/src/intel/tools/aubinator.c
> @@ -178,7 +178,7 @@ aubinator_init(uint16_t aub_pci_id, const char *app_name)
> batch_flags |= GEN_BATCH_DECODE_FLOATS;
>
> gen_batch_decode_ctx_init(&batch_ctx, &devinfo, outfile, batch_flags,
> - xml_path, get_gen_batch_bo, NULL);
> + xml_path, get_gen_batch_bo, NULL, NULL);
>
> char *color = GREEN_HEADER, *reset_color = NORMAL;
> if (option_color == COLOR_NEVER)
> diff --git a/src/intel/tools/aubinator_error_decode.c b/src/intel/tools/aubinator_error_decode.c
> index 0234c59371d..2735bd72714 100644
> --- a/src/intel/tools/aubinator_error_decode.c
> +++ b/src/intel/tools/aubinator_error_decode.c
> @@ -595,7 +595,7 @@ read_data_file(FILE *file)
>
> struct gen_batch_decode_ctx batch_ctx;
> gen_batch_decode_ctx_init(&batch_ctx, &devinfo, stdout, batch_flags,
> - xml_path, get_gen_batch_bo, NULL);
> + xml_path, get_gen_batch_bo, NULL, NULL);
>
>
> for (int s = 0; s < sect_num; s++) {
More information about the mesa-dev
mailing list