egl: replace _EGLDriver param with _EGLDisplay->Driver in _eglReleaseDisplayResources()
[mesa.git] / src / intel / common / gen_batch_decoder.c
index 2a5261b2f929e73f4859ab73fa306ee230383a2d..3d80b4e6bae90d00b22532d5688fd8192049bf0d 100644 (file)
@@ -176,11 +176,13 @@ ctx_print_buffer(struct gen_batch_decode_ctx *ctx,
    const uint32_t *dw_end =
          bo.map + ROUND_DOWN_TO(MIN2(bo.size, read_length), 4);
 
-   int column_count = 0, line_count = -1;
+   int column_count = 0, pitch_col_count = 0, line_count = -1;
    for (const uint32_t *dw = bo.map; dw < dw_end; dw++) {
-      if (column_count * 4 == pitch || column_count == 8) {
+      if (pitch_col_count * 4 == pitch || column_count == 8) {
          fprintf(ctx->fp, "\n");
          column_count = 0;
+         if (pitch_col_count * 4 == pitch)
+            pitch_col_count = 0;
          line_count++;
 
          if (max_lines >= 0 && line_count >= max_lines)
@@ -194,6 +196,7 @@ ctx_print_buffer(struct gen_batch_decode_ctx *ctx,
          fprintf(ctx->fp, "  0x%08x", *dw);
 
       column_count++;
+      pitch_col_count++;
    }
    fprintf(ctx->fp, "\n");
 }
@@ -375,7 +378,7 @@ handle_media_interface_descriptor_load(struct gen_batch_decode_ctx *ctx,
       }
 
       ctx_disassemble_program(ctx, ksp, "compute shader");
-      printf("\n");
+      fprintf(ctx->fp, "\n");
 
       dump_samplers(ctx, sampler_offset, sampler_count);
       dump_binding_table(ctx, binding_table_offset, binding_entry_count);
@@ -537,7 +540,7 @@ decode_single_ksp(struct gen_batch_decode_ctx *ctx, const uint32_t *p)
 
    if (is_enabled) {
       ctx_disassemble_program(ctx, ksp, type);
-      printf("\n");
+      fprintf(ctx->fp, "\n");
    }
 }
 
@@ -837,6 +840,172 @@ decode_load_register_imm(struct gen_batch_decode_ctx *ctx, const uint32_t *p)
    }
 }
 
+static void
+decode_vs_state(struct gen_batch_decode_ctx *ctx, uint32_t offset)
+{
+   struct gen_group *strct =
+      gen_spec_find_struct(ctx->spec, "VS_STATE");
+   if (strct == NULL) {
+      fprintf(ctx->fp, "did not find VS_STATE info\n");
+      return;
+   }
+
+   struct gen_batch_decode_bo bind_bo =
+      ctx_get_bo(ctx, true, offset);
+
+   if (bind_bo.map == NULL) {
+      fprintf(ctx->fp, " vs state unavailable\n");
+      return;
+   }
+
+   ctx_print_group(ctx, strct, offset, bind_bo.map);
+}
+
+
+static void
+decode_clip_state(struct gen_batch_decode_ctx *ctx, uint32_t offset)
+{
+   struct gen_group *strct =
+      gen_spec_find_struct(ctx->spec, "CLIP_STATE");
+   if (strct == NULL) {
+      fprintf(ctx->fp, "did not find CLIP_STATE info\n");
+      return;
+   }
+
+   struct gen_batch_decode_bo bind_bo =
+      ctx_get_bo(ctx, true, offset);
+
+   if (bind_bo.map == NULL) {
+      fprintf(ctx->fp, " clip state unavailable\n");
+      return;
+   }
+
+   ctx_print_group(ctx, strct, offset, bind_bo.map);
+
+   struct gen_group *vp_strct =
+      gen_spec_find_struct(ctx->spec, "CLIP_VIEWPORT");
+   if (vp_strct == NULL) {
+      fprintf(ctx->fp, "did not find CLIP_VIEWPORT info\n");
+      return;
+   }
+   uint32_t clip_vp_offset = ((uint32_t *)bind_bo.map)[6] & ~0x3;
+   struct gen_batch_decode_bo vp_bo =
+      ctx_get_bo(ctx, true, clip_vp_offset);
+   if (vp_bo.map == NULL) {
+      fprintf(ctx->fp, " clip vp state unavailable\n");
+      return;
+   }
+   ctx_print_group(ctx, vp_strct, clip_vp_offset, vp_bo.map);
+}
+
+static void
+decode_sf_state(struct gen_batch_decode_ctx *ctx, uint32_t offset)
+{
+   struct gen_group *strct =
+      gen_spec_find_struct(ctx->spec, "SF_STATE");
+   if (strct == NULL) {
+      fprintf(ctx->fp, "did not find SF_STATE info\n");
+      return;
+   }
+
+   struct gen_batch_decode_bo bind_bo =
+      ctx_get_bo(ctx, true, offset);
+
+   if (bind_bo.map == NULL) {
+      fprintf(ctx->fp, " sf state unavailable\n");
+      return;
+   }
+
+   ctx_print_group(ctx, strct, offset, bind_bo.map);
+
+   struct gen_group *vp_strct =
+      gen_spec_find_struct(ctx->spec, "SF_VIEWPORT");
+   if (vp_strct == NULL) {
+      fprintf(ctx->fp, "did not find SF_VIEWPORT info\n");
+      return;
+   }
+
+   uint32_t sf_vp_offset = ((uint32_t *)bind_bo.map)[5] & ~0x3;
+   struct gen_batch_decode_bo vp_bo =
+      ctx_get_bo(ctx, true, sf_vp_offset);
+   if (vp_bo.map == NULL) {
+      fprintf(ctx->fp, " sf vp state unavailable\n");
+      return;
+   }
+   ctx_print_group(ctx, vp_strct, sf_vp_offset, vp_bo.map);
+}
+
+static void
+decode_wm_state(struct gen_batch_decode_ctx *ctx, uint32_t offset)
+{
+   struct gen_group *strct =
+      gen_spec_find_struct(ctx->spec, "WM_STATE");
+   if (strct == NULL) {
+      fprintf(ctx->fp, "did not find WM_STATE info\n");
+      return;
+   }
+
+   struct gen_batch_decode_bo bind_bo =
+      ctx_get_bo(ctx, true, offset);
+
+   if (bind_bo.map == NULL) {
+      fprintf(ctx->fp, " wm state unavailable\n");
+      return;
+   }
+
+   ctx_print_group(ctx, strct, offset, bind_bo.map);
+}
+
+static void
+decode_cc_state(struct gen_batch_decode_ctx *ctx, uint32_t offset)
+{
+   struct gen_group *strct =
+      gen_spec_find_struct(ctx->spec, "COLOR_CALC_STATE");
+   if (strct == NULL) {
+      fprintf(ctx->fp, "did not find COLOR_CALC_STATE info\n");
+      return;
+   }
+
+   struct gen_batch_decode_bo bind_bo =
+      ctx_get_bo(ctx, true, offset);
+
+   if (bind_bo.map == NULL) {
+      fprintf(ctx->fp, " cc state unavailable\n");
+      return;
+   }
+
+   ctx_print_group(ctx, strct, offset, bind_bo.map);
+
+   struct gen_group *vp_strct =
+      gen_spec_find_struct(ctx->spec, "CC_VIEWPORT");
+   if (vp_strct == NULL) {
+      fprintf(ctx->fp, "did not find CC_VIEWPORT info\n");
+      return;
+   }
+   uint32_t cc_vp_offset = ((uint32_t *)bind_bo.map)[4] & ~0x3;
+   struct gen_batch_decode_bo vp_bo =
+      ctx_get_bo(ctx, true, cc_vp_offset);
+   if (vp_bo.map == NULL) {
+      fprintf(ctx->fp, " cc vp state unavailable\n");
+      return;
+   }
+   ctx_print_group(ctx, vp_strct, cc_vp_offset, vp_bo.map);
+}
+static void
+decode_pipelined_pointers(struct gen_batch_decode_ctx *ctx, const uint32_t *p)
+{
+   fprintf(ctx->fp, "VS State Table:\n");
+   decode_vs_state(ctx, p[1]);
+   fprintf(ctx->fp, "Clip State Table:\n");
+   decode_clip_state(ctx, p[3] & ~1);
+   fprintf(ctx->fp, "SF State Table:\n");
+   decode_sf_state(ctx, p[4]);
+   fprintf(ctx->fp, "WM State Table:\n");
+   decode_wm_state(ctx, p[5]);
+   fprintf(ctx->fp, "CC State Table:\n");
+   decode_cc_state(ctx, p[6]);
+}
+
 struct custom_decoder {
    const char *cmd_name;
    void (*decode)(struct gen_batch_decode_ctx *ctx, const uint32_t *p);
@@ -878,7 +1047,8 @@ struct custom_decoder {
    { "3DSTATE_CC_STATE_POINTERS", decode_3dstate_cc_state_pointers },
    { "3DSTATE_SCISSOR_STATE_POINTERS", decode_3dstate_scissor_state_pointers },
    { "3DSTATE_SLICE_TABLE_STATE_POINTERS", decode_3dstate_slice_table_state_pointers },
-   { "MI_LOAD_REGISTER_IMM", decode_load_register_imm }
+   { "MI_LOAD_REGISTER_IMM", decode_load_register_imm },
+   { "3DSTATE_PIPELINED_POINTERS", decode_pipelined_pointers }
 };
 
 void