[Mesa-dev] [PATCH 1/2] intel: decoder: limit to the number decoded lines from VBO

Lionel Landwerlin lionel.g.landwerlin at intel.com
Wed May 2 17:42:04 UTC 2018


By default we set no limit, but the debug batch decoder in i965 sets
it to 100.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
---
 src/intel/common/gen_batch_decoder.c          | 22 ++++++++++++-------
 src/intel/common/gen_decoder.h                |  2 ++
 src/mesa/drivers/dri/i965/intel_batchbuffer.c |  1 +
 3 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/src/intel/common/gen_batch_decoder.c b/src/intel/common/gen_batch_decoder.c
index c059b194974..3852f32de36 100644
--- a/src/intel/common/gen_batch_decoder.c
+++ b/src/intel/common/gen_batch_decoder.c
@@ -43,6 +43,7 @@ gen_batch_decode_ctx_init(struct gen_batch_decode_ctx *ctx,
    ctx->user_data = user_data;
    ctx->fp = fp;
    ctx->flags = flags;
+   ctx->max_vbo_decoded_lines = -1; /* No limit! */
 
    if (xml_path == NULL)
       ctx->spec = gen_spec_load(devinfo);
@@ -165,24 +166,29 @@ static void
 ctx_print_buffer(struct gen_batch_decode_ctx *ctx,
                  struct gen_batch_decode_bo bo,
                  uint32_t read_length,
-                 uint32_t pitch)
+                 uint32_t pitch,
+                 int max_lines)
 {
    const uint32_t *dw_end = bo.map + MIN2(bo.size, read_length);
 
-   unsigned line_count = 0;
+   int column_count = 0, line_count = -1;
    for (const uint32_t *dw = bo.map; dw < dw_end; dw++) {
-      if (line_count * 4 == pitch || line_count == 8) {
+      if (column_count * 4 == pitch || column_count == 8) {
          fprintf(ctx->fp, "\n");
-         line_count = 0;
+         column_count = 0;
+         line_count++;
+
+         if (max_lines >= 0 && line_count >= max_lines)
+            break;
       }
-      fprintf(ctx->fp, line_count == 0 ? "  " : " ");
+      fprintf(ctx->fp, column_count == 0 ? "  " : " ");
 
       if ((ctx->flags & GEN_BATCH_DECODE_FLOATS) && probably_float(*dw))
          fprintf(ctx->fp, "  %8.2f", *(float *) dw);
       else
          fprintf(ctx->fp, "  0x%08x", *dw);
 
-      line_count++;
+      column_count++;
    }
    fprintf(ctx->fp, "\n");
 }
@@ -387,7 +393,7 @@ handle_3dstate_vertex_buffers(struct gen_batch_decode_ctx *ctx,
          if (vb.map == 0 || vb_size == 0)
             continue;
 
-         ctx_print_buffer(ctx, vb, vb_size, pitch);
+         ctx_print_buffer(ctx, vb, vb_size, pitch, ctx->max_vbo_decoded_lines);
 
          vb.map = NULL;
          vb_size = 0;
@@ -576,7 +582,7 @@ decode_3dstate_constant(struct gen_batch_decode_ctx *ctx, const uint32_t *p)
          unsigned size = read_length[i] * 32;
          fprintf(ctx->fp, "constant buffer %d, size %u\n", i, size);
 
-         ctx_print_buffer(ctx, buffer[i], size, 0);
+         ctx_print_buffer(ctx, buffer[i], size, 0, -1);
       }
    }
 }
diff --git a/src/intel/common/gen_decoder.h b/src/intel/common/gen_decoder.h
index 37f6c3ee989..f2207ddf889 100644
--- a/src/intel/common/gen_decoder.h
+++ b/src/intel/common/gen_decoder.h
@@ -220,6 +220,8 @@ struct gen_batch_decode_ctx {
    struct gen_batch_decode_bo surface_base;
    struct gen_batch_decode_bo dynamic_base;
    struct gen_batch_decode_bo instruction_base;
+
+   int max_vbo_decoded_lines;
 };
 
 void gen_batch_decode_ctx_init(struct gen_batch_decode_ctx *ctx,
diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.c b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
index b3e4bdc981e..bac6e6dae85 100644
--- a/src/mesa/drivers/dri/i965/intel_batchbuffer.c
+++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
@@ -166,6 +166,7 @@ intel_batchbuffer_init(struct brw_context *brw)
       gen_batch_decode_ctx_init(&batch->decoder, devinfo, stderr,
                                 decode_flags, NULL, decode_get_bo,
                                 decode_get_state_size, brw);
+      batch->decoder.max_vbo_decoded_lines = 100;
    }
 
    batch->use_batch_first =
-- 
2.17.0



More information about the mesa-dev mailing list