intel/tools/aubinator_error_decode: read HW Context before other batches
authorD Scott Phillips <d.scott.phillips@intel.com>
Thu, 19 Mar 2020 18:10:11 +0000 (11:10 -0700)
committerMarge Bot <eric+marge@anholt.net>
Mon, 23 Mar 2020 18:13:37 +0000 (18:13 +0000)
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 <rafael.antognolli@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4246>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4246>

src/intel/tools/aubinator_error_decode.c

index aa1b1d53d7e77c83d996015a7b1a4084afb6edec..6ee9c0447412da3203d9bd77ed3b183cb354f91d 100644 (file)
@@ -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;