draw: add support for collecting primitives generated outside streamout
authorDave Airlie <airlied@redhat.com>
Mon, 2 Dec 2019 04:37:42 +0000 (14:37 +1000)
committerDave Airlie <airlied@redhat.com>
Thu, 5 Dec 2019 20:48:30 +0000 (06:48 +1000)
GL/gallium require gathering primitives generated outside streamout
stats. This introduces the draw interfaces to enabling collecting this.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
src/gallium/auxiliary/draw/draw_context.c
src/gallium/auxiliary/draw/draw_context.h
src/gallium/auxiliary/draw/draw_private.h
src/gallium/auxiliary/draw/draw_pt_so_emit.c

index 59bcd0dd510271a854c0f6f5c88018ba107c1d60..5e2e2580fb666940ac960220f572f88206f992b1 100644 (file)
@@ -1155,6 +1155,15 @@ draw_collect_pipeline_statistics(struct draw_context *draw,
    draw->collect_statistics = enable;
 }
 
+/**
+ * Enable/disable primitives generated gathering.
+ */
+void draw_collect_primitives_generated(struct draw_context *draw,
+                                       bool enable)
+{
+   draw->collect_primgen = enable;
+}
+
 /**
  * Computes clipper invocation statistics.
  *
index fefda82133809f2004d15b830f5f3e74578be7c1..0170f13e73557fdfd8875450f15a69780073f4f8 100644 (file)
@@ -312,6 +312,9 @@ void draw_set_force_passthrough( struct draw_context *draw,
 void draw_collect_pipeline_statistics(struct draw_context *draw,
                                       boolean enable);
 
+void draw_collect_primitives_generated(struct draw_context *draw,
+                                       bool eanble);
+
 /*******************************************************************************
  * Draw pipeline 
  */
index 3aa355b179e5da319d5c006398ed3c792d01c1e0..86e90c76f888d6bcb7474d8e6299d13bc3aff9eb 100644 (file)
@@ -348,6 +348,8 @@ struct draw_context
    struct pipe_query_data_pipeline_statistics statistics;
    boolean collect_statistics;
 
+   bool collect_primgen;
+
    struct draw_assembler *ia;
 
    void *driver_private;
index ea3169f32b1b3023bbbfa0ad20a59904b0e3ca31..6cb38fb9a5e74d7222de1f68361a6ed0987abeaf 100644 (file)
@@ -36,6 +36,7 @@
 #include "pipe/p_state.h"
 
 #include "util/u_math.h"
+#include "util/u_prim.h"
 #include "util/u_memory.h"
 
 struct pt_so_emit {
@@ -273,8 +274,20 @@ void draw_pt_so_emit( struct pt_so_emit *emit,
    struct vbuf_render *render = draw->render;
    unsigned start, i, stream;
 
-   if (!emit->has_so)
+   if (!emit->has_so) {
+      if (draw->collect_primgen) {
+         unsigned i;
+         unsigned total = 0;
+         for (i = 0; i < input_prims->primitive_count; i++) {
+            total +=
+               u_decomposed_prims_for_vertices(input_prims->prim,
+                                               input_prims->primitive_lengths[i]);
+         }
+         render->set_stream_output_info(render,
+                                        0, 0, total);
+      }
       return;
+   }
 
    if (!draw->so.num_targets)
       return;