From 49f9a0bb57219d0fa57dd10dfd69e64f6356c9df Mon Sep 17 00:00:00 2001 From: D Scott Phillips Date: Thu, 19 Mar 2020 11:10:11 -0700 Subject: [PATCH] intel/tools/aubinator_error_decode: read HW Context before other batches The hardware context buffer has state that was set before the batch started. By decoding it first, references to things like Dynamic State Base Address are decodable in the command batches. Reviewed-by: Rafael Antognolli Reviewed-by: Jason Ekstrand Tested-by: Marge Bot Part-of: --- src/intel/tools/aubinator_error_decode.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/intel/tools/aubinator_error_decode.c b/src/intel/tools/aubinator_error_decode.c index aa1b1d53d7e..6ee9c044741 100644 --- a/src/intel/tools/aubinator_error_decode.c +++ b/src/intel/tools/aubinator_error_decode.c @@ -380,6 +380,17 @@ static int ascii85_decode(const char *in, uint32_t **out, bool inflate) return zlib_inflate(out, len); } +static int qsort_hw_context_first(const void *a, const void *b) +{ + const struct section *sa = a, *sb = b; + if (strcmp(sa->buffer_name, "HW Context") == 0) + return -1; + if (strcmp(sb->buffer_name, "HW Context") == 0) + return 1; + else + return 0; +} + static struct gen_batch_decode_bo get_gen_batch_bo(void *user_data, bool ppgtt, uint64_t address) { @@ -584,6 +595,13 @@ read_data_file(FILE *file) free(line); free(ring_name); + /* + * Order sections so that the hardware context section is visited by the + * decoder before other command buffers. This will allow the decoder to see + * persistent state that was set before the current batch. + */ + qsort(sections, num_sections, sizeof(sections[0]), qsort_hw_context_first); + enum gen_batch_decode_flags batch_flags = 0; if (option_color == COLOR_ALWAYS) batch_flags |= GEN_BATCH_DECODE_IN_COLOR; -- 2.30.2