[Mesa-dev] [PATCH 6/6] i965: Add some batchbuffer debugging code.

Kenneth Graunke kenneth at whitecape.org
Wed Nov 29 00:13:21 UTC 2017


Uncommenting these blocks stress tests the batch/state growth code by
trying to "grow" a buffer to the same size at least once per batch.

When anything goes wrong with this code, dumping the validation list
is a useful way to figure out what's happening.
---
 src/mesa/drivers/dri/i965/intel_batchbuffer.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.c b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
index 12d165d7236..b5b9468ed65 100644
--- a/src/mesa/drivers/dri/i965/intel_batchbuffer.c
+++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
@@ -64,6 +64,21 @@
 static void
 intel_batchbuffer_reset(struct brw_context *brw);
 
+UNUSED static void
+dump_validation_list(struct intel_batchbuffer *batch)
+{
+   fprintf(stderr, "Validation list (length %d):\n", batch->exec_count);
+
+   for (int i = 0; i < batch->exec_count; i++) {
+      assert(batch->validation_list[i].handle ==
+             batch->exec_bos[i]->gem_handle);
+      fprintf(stderr, "[%d] = %d %s %p\n", i,
+              batch->validation_list[i].handle,
+              batch->exec_bos[i]->name,
+              batch->exec_bos[i]);
+   }
+}
+
 static bool
 uint_key_compare(const void *a, const void *b)
 {
@@ -996,6 +1011,18 @@ _intel_batchbuffer_flush_fence(struct brw_context *brw,
    brw_finish_batch(brw);
    intel_upload_finish(brw);
 
+   /* Test batch/state growing by swapping a BO for one of the same size */
+   if (0) {
+      const unsigned used = 4 * USED_BATCH(brw->batch);
+      grow_buffer(brw, &brw->batch.batch, used, brw->batch.batch.bo->size);
+      brw->batch.map_next = (void *) brw->batch.batch.map + used;
+   }
+   if (0) {
+      /* Ditto for state buffers */
+      grow_buffer(brw, &brw->batch.state, brw->batch.state_used,
+                  brw->batch.state.bo->size);
+   }
+
    finish_growing_bos(&brw->batch.batch);
    finish_growing_bos(&brw->batch.state);
 
-- 
2.15.0



More information about the mesa-dev mailing list