iris: primitives generated query support
authorKenneth Graunke <kenneth@whitecape.org>
Fri, 28 Sep 2018 10:07:54 +0000 (12:07 +0200)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 21 Feb 2019 18:26:08 +0000 (10:26 -0800)
src/gallium/drivers/iris/iris_context.h
src/gallium/drivers/iris/iris_query.c
src/gallium/drivers/iris/iris_state.c

index 1d51316c62598e7e8733f635719d622b4e04c97b..fdf531ef7e316a7e3deaac822b05fda145a4e7d0 100644 (file)
@@ -405,6 +405,10 @@ struct iris_context {
 
       struct pipe_stream_output_target *so_target[PIPE_MAX_SO_BUFFERS];
       bool streamout_active;
+
+      /** Is a PIPE_QUERY_PRIMITIVES_GENERATED query active? */
+      bool prims_generated_query_active;
+
       /** 3DSTATE_STREAMOUT and 3DSTATE_SO_DECL_LIST packets */
       uint32_t *streamout;
 
index 374e9bf2065aa1acc1edf2ec08b1bc9a9ed76bdf..5383c1f81dfd323cc704002f11f0cd4aea279f47 100644 (file)
 #include "iris_resource.h"
 #include "iris_screen.h"
 
-#define IA_VERTICES_COUNT               0x2310
-#define IA_PRIMITIVES_COUNT             0x2318
-#define VS_INVOCATION_COUNT             0x2320
-#define HS_INVOCATION_COUNT             0x2300
-#define DS_INVOCATION_COUNT             0x2308
-#define GS_INVOCATION_COUNT             0x2328
-#define GS_PRIMITIVES_COUNT             0x2330
-#define CL_INVOCATION_COUNT             0x2338
-#define CL_PRIMITIVES_COUNT             0x2340
-#define PS_INVOCATION_COUNT             0x2348
-#define CS_INVOCATION_COUNT             0x2290
-#define PS_DEPTH_COUNT                  0x2350
-
-#define GEN6_SO_PRIM_STORAGE_NEEDED     0x2280
-#define GEN7_SO_PRIM_STORAGE_NEEDED(n)  (0x5240 + (n) * 8)
-
-#define GEN6_SO_NUM_PRIMS_WRITTEN       0x2288
-#define GEN7_SO_NUM_PRIMS_WRITTEN(n)    (0x5200 + (n) * 8)
+#define IA_VERTICES_COUNT          0x2310
+#define IA_PRIMITIVES_COUNT        0x2318
+#define VS_INVOCATION_COUNT        0x2320
+#define HS_INVOCATION_COUNT        0x2300
+#define DS_INVOCATION_COUNT        0x2308
+#define GS_INVOCATION_COUNT        0x2328
+#define GS_PRIMITIVES_COUNT        0x2330
+#define CL_INVOCATION_COUNT        0x2338
+#define CL_PRIMITIVES_COUNT        0x2340
+#define PS_INVOCATION_COUNT        0x2348
+#define CS_INVOCATION_COUNT        0x2290
+#define PS_DEPTH_COUNT             0x2350
+
+#define SO_PRIM_STORAGE_NEEDED(n)  (0x5240 + (n) * 8)
+
+#define SO_NUM_PRIMS_WRITTEN(n)    (0x5200 + (n) * 8)
 
 #define CS_GPR(n) (0x2600 + (n) * 8)
 
@@ -198,6 +196,15 @@ write_value(struct iris_context *ice, struct iris_query *q, unsigned offset)
                            PIPE_CONTROL_WRITE_TIMESTAMP,
                            offset);
       break;
+   case PIPE_QUERY_PRIMITIVES_GENERATED:
+      iris_emit_pipe_control_flush(batch,
+                                   PIPE_CONTROL_CS_STALL |
+                                   PIPE_CONTROL_STALL_AT_SCOREBOARD);
+      ice->vtbl.store_register_mem64(batch,
+                                     q->index == 0 ? CL_INVOCATION_COUNT :
+                                     SO_PRIM_STORAGE_NEEDED(q->index),
+                                     q->bo, offset, false);
+      break;
    case PIPE_QUERY_PIPELINE_STATISTICS: {
       static const uint32_t index_to_reg[] = {
          IA_VERTICES_COUNT,
@@ -340,6 +347,11 @@ iris_begin_query(struct pipe_context *ctx, struct pipe_query *query)
    q->result = 0ull;
    q->ready = false;
 
+   if (q->type == PIPE_QUERY_PRIMITIVES_GENERATED && q->index == 0) {
+      ice->state.prims_generated_query_active = true;
+      ice->state.dirty |= IRIS_DIRTY_STREAMOUT;
+   }
+
    write_availability(ice, q, false);
    write_value(ice, q, offsetof(struct iris_query_snapshots, start));
 
@@ -352,6 +364,11 @@ iris_end_query(struct pipe_context *ctx, struct pipe_query *query)
    struct iris_context *ice = (void *) ctx;
    struct iris_query *q = (void *) query;
 
+   if (q->type == PIPE_QUERY_PRIMITIVES_GENERATED && q->index == 0) {
+      ice->state.prims_generated_query_active = true;
+      ice->state.dirty |= IRIS_DIRTY_STREAMOUT;
+   }
+
    write_value(ice, q, offsetof(struct iris_query_snapshots, end));
    write_availability(ice, q, true);
 
index 7882061453c373dc551290a6e6b853740fc7d6e5..391b6f71bbc237e79020854c7f067b05d1db7e2c 100644 (file)
@@ -3705,8 +3705,8 @@ iris_upload_dirty_render_state(struct iris_context *ice,
             sol.SOFunctionEnable = true;
             sol.SOStatisticsEnable = true;
 
-            // XXX: GL_PRIMITIVES_GENERATED query
-            sol.RenderingDisable = cso_rast->rasterizer_discard;
+            sol.RenderingDisable = cso_rast->rasterizer_discard &&
+                                   !ice->state.prims_generated_query_active;
             sol.ReorderMode = cso_rast->flatshade_first ? LEADING : TRAILING;
          }