From: Dave Airlie Date: Mon, 2 Dec 2019 04:37:42 +0000 (+1000) Subject: draw: add support for collecting primitives generated outside streamout X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5f8af9731e36cb8854f7096cd372b83022a004b4;p=mesa.git draw: add support for collecting primitives generated outside streamout GL/gallium require gathering primitives generated outside streamout stats. This introduces the draw interfaces to enabling collecting this. Reviewed-by: Roland Scheidegger --- diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c index 59bcd0dd510..5e2e2580fb6 100644 --- a/src/gallium/auxiliary/draw/draw_context.c +++ b/src/gallium/auxiliary/draw/draw_context.c @@ -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. * diff --git a/src/gallium/auxiliary/draw/draw_context.h b/src/gallium/auxiliary/draw/draw_context.h index fefda821338..0170f13e735 100644 --- a/src/gallium/auxiliary/draw/draw_context.h +++ b/src/gallium/auxiliary/draw/draw_context.h @@ -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 */ diff --git a/src/gallium/auxiliary/draw/draw_private.h b/src/gallium/auxiliary/draw/draw_private.h index 3aa355b179e..86e90c76f88 100644 --- a/src/gallium/auxiliary/draw/draw_private.h +++ b/src/gallium/auxiliary/draw/draw_private.h @@ -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; diff --git a/src/gallium/auxiliary/draw/draw_pt_so_emit.c b/src/gallium/auxiliary/draw/draw_pt_so_emit.c index ea3169f32b1..6cb38fb9a5e 100644 --- a/src/gallium/auxiliary/draw/draw_pt_so_emit.c +++ b/src/gallium/auxiliary/draw/draw_pt_so_emit.c @@ -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;