ilo: add ILO_3D_PIPELINE_WRITE_STATISTICS
authorChia-I Wu <olvaffe@gmail.com>
Sun, 2 Mar 2014 05:36:08 +0000 (13:36 +0800)
committerChia-I Wu <olvaffe@gmail.com>
Mon, 10 Mar 2014 08:43:53 +0000 (16:43 +0800)
The command writes statistics registers to the specified bo.

src/gallium/drivers/ilo/ilo_3d_pipeline.c
src/gallium/drivers/ilo/ilo_3d_pipeline.h
src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c
src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.h
src/gallium/drivers/ilo/ilo_3d_pipeline_gen7.c

index a821282e4fe798ac8211edd1b7853f55a56b4022..e5f82d0a580d195733a3ce411c1d60b83f2069bf 100644 (file)
@@ -257,6 +257,17 @@ ilo_3d_pipeline_emit_write_depth_count(struct ilo_3d_pipeline *p,
    p->emit_write_depth_count(p, bo, index);
 }
 
+/**
+ * Emit MI_STORE_REGISTER_MEM to store statistics registers.
+ */
+void
+ilo_3d_pipeline_emit_write_statistics(struct ilo_3d_pipeline *p,
+                                      struct intel_bo *bo, int index)
+{
+   handle_invalid_batch_bo(p, true);
+   p->emit_write_statistics(p, bo, index);
+}
+
 void
 ilo_3d_pipeline_emit_rectlist(struct ilo_3d_pipeline *p,
                               const struct ilo_blitter *blitter)
index 0574d7479e6920f0cfcbf74c1a7940341ad18948..90c626e52744424a3b2437c9ed2394db021b97c5 100644 (file)
@@ -50,6 +50,7 @@ enum ilo_3d_pipeline_action {
    ILO_3D_PIPELINE_FLUSH,
    ILO_3D_PIPELINE_WRITE_TIMESTAMP,
    ILO_3D_PIPELINE_WRITE_DEPTH_COUNT,
+   ILO_3D_PIPELINE_WRITE_STATISTICS,
    ILO_3D_PIPELINE_RECTLIST,
 };
 
@@ -83,6 +84,9 @@ struct ilo_3d_pipeline {
    void (*emit_write_depth_count)(struct ilo_3d_pipeline *pipeline,
                                   struct intel_bo *bo, int index);
 
+   void (*emit_write_statistics)(struct ilo_3d_pipeline *pipeline,
+                                 struct intel_bo *bo, int index);
+
    void (*emit_rectlist)(struct ilo_3d_pipeline *pipeline,
                          const struct ilo_blitter *blitter);
 
@@ -176,6 +180,10 @@ void
 ilo_3d_pipeline_emit_write_depth_count(struct ilo_3d_pipeline *p,
                                        struct intel_bo *bo, int index);
 
+void
+ilo_3d_pipeline_emit_write_statistics(struct ilo_3d_pipeline *p,
+                                      struct intel_bo *bo, int index);
+
 void
 ilo_3d_pipeline_emit_rectlist(struct ilo_3d_pipeline *p,
                               const struct ilo_blitter *blitter);
index 2cfde297a9a18a13582d52f2ecbba2d6a4ab934b..6cc5e039c8db9f4c7493098fa7f2867a28674b5b 100644 (file)
@@ -1524,6 +1524,45 @@ ilo_3d_pipeline_emit_write_depth_count_gen6(struct ilo_3d_pipeline *p,
          true, p->cp);
 }
 
+void
+ilo_3d_pipeline_emit_write_statistics_gen6(struct ilo_3d_pipeline *p,
+                                           struct intel_bo *bo, int index)
+{
+   uint32_t regs[] = {
+      IA_VERTICES_COUNT,
+      IA_PRIMITIVES_COUNT,
+      VS_INVOCATION_COUNT,
+      GS_INVOCATION_COUNT,
+      GS_PRIMITIVES_COUNT,
+      CL_INVOCATION_COUNT,
+      CL_PRIMITIVES_COUNT,
+      PS_INVOCATION_COUNT,
+      p->dev->gen >= ILO_GEN(7) ? HS_INVOCATION_COUNT : 0,
+      p->dev->gen >= ILO_GEN(7) ? DS_INVOCATION_COUNT : 0,
+      0,
+   };
+   int i;
+
+   p->emit_flush(p);
+
+   for (i = 0; i < Elements(regs); i++) {
+      const uint32_t bo_offset = (index + i) * sizeof(uint64_t);
+
+      if (regs[i]) {
+         /* store lower 32 bits */
+         gen6_emit_MI_STORE_REGISTER_MEM(p->dev,
+               bo, bo_offset, regs[i], p->cp);
+         /* store higher 32 bits */
+         gen6_emit_MI_STORE_REGISTER_MEM(p->dev,
+               bo, bo_offset + 4, regs[i] + 4, p->cp);
+      }
+      else {
+         gen6_emit_MI_STORE_DATA_IMM(p->dev,
+               bo, bo_offset, 0, true, p->cp);
+      }
+   }
+}
+
 static void
 gen6_rectlist_vs_to_sf(struct ilo_3d_pipeline *p,
                        const struct ilo_blitter *blitter,
@@ -1883,6 +1922,19 @@ ilo_3d_pipeline_estimate_size_gen6(struct ilo_3d_pipeline *p,
       size = ilo_gpe_gen6_estimate_command_size(p->dev,
             ILO_GPE_GEN6_PIPE_CONTROL, 1) * 3;
       break;
+   case ILO_3D_PIPELINE_WRITE_STATISTICS:
+      {
+         const int num_regs = 8;
+         const int num_pads = 3;
+
+         size = ilo_gpe_gen6_estimate_command_size(p->dev,
+               ILO_GPE_GEN6_PIPE_CONTROL, 1);
+         size += ilo_gpe_gen6_estimate_command_size(p->dev,
+               ILO_GPE_GEN6_MI_STORE_REGISTER_MEM, 1) * 2 * num_regs;
+         size += ilo_gpe_gen6_estimate_command_size(p->dev,
+               ILO_GPE_GEN6_MI_STORE_DATA_IMM, 1) * num_pads;
+      }
+      break;
    case ILO_3D_PIPELINE_RECTLIST:
       size = 64 + 256; /* states + commands */
       break;
@@ -1903,5 +1955,6 @@ ilo_3d_pipeline_init_gen6(struct ilo_3d_pipeline *p)
    p->emit_flush = ilo_3d_pipeline_emit_flush_gen6;
    p->emit_write_timestamp = ilo_3d_pipeline_emit_write_timestamp_gen6;
    p->emit_write_depth_count = ilo_3d_pipeline_emit_write_depth_count_gen6;
+   p->emit_write_statistics = ilo_3d_pipeline_emit_write_statistics_gen6;
    p->emit_rectlist = ilo_3d_pipeline_emit_rectlist_gen6;
 }
index c6f48ebbe7c4fcb6e3bbe5b8613480e98e944684..7e375919eede74adf37d99623ce2fa60bd277c08 100644 (file)
@@ -160,6 +160,10 @@ void
 ilo_3d_pipeline_emit_write_depth_count_gen6(struct ilo_3d_pipeline *p,
                                             struct intel_bo *bo, int index);
 
+void
+ilo_3d_pipeline_emit_write_statistics_gen6(struct ilo_3d_pipeline *p,
+                                           struct intel_bo *bo, int index);
+
 void
 ilo_3d_pipeline_init_gen6(struct ilo_3d_pipeline *p);
 
index 953e3e32b549257e7f11d8fa63b9535b80287f0e..5ed8b7e1e6abf7c7e67547814577ebd595f56ae6 100644 (file)
@@ -1039,6 +1039,19 @@ ilo_3d_pipeline_estimate_size_gen7(struct ilo_3d_pipeline *p,
       size = ilo_gpe_gen7_estimate_command_size(p->dev,
             ILO_GPE_GEN7_PIPE_CONTROL, 1);
       break;
+   case ILO_3D_PIPELINE_WRITE_STATISTICS:
+      {
+         const int num_regs = 10;
+         const int num_pads = 1;
+
+         size = ilo_gpe_gen7_estimate_command_size(p->dev,
+               ILO_GPE_GEN7_PIPE_CONTROL, 1);
+         size += ilo_gpe_gen7_estimate_command_size(p->dev,
+               ILO_GPE_GEN7_MI_STORE_REGISTER_MEM, 1) * 2 * num_regs;
+         size += ilo_gpe_gen7_estimate_command_size(p->dev,
+               ILO_GPE_GEN7_MI_STORE_DATA_IMM, 1) * num_pads;
+      }
+      break;
    case ILO_3D_PIPELINE_RECTLIST:
       size = 64 + 256; /* states + commands */
       break;
@@ -1059,5 +1072,6 @@ ilo_3d_pipeline_init_gen7(struct ilo_3d_pipeline *p)
    p->emit_flush = ilo_3d_pipeline_emit_flush_gen6;
    p->emit_write_timestamp = ilo_3d_pipeline_emit_write_timestamp_gen6;
    p->emit_write_depth_count = ilo_3d_pipeline_emit_write_depth_count_gen6;
+   p->emit_write_statistics = ilo_3d_pipeline_emit_write_statistics_gen6;
    p->emit_rectlist = ilo_3d_pipeline_emit_rectlist_gen7;
 }