[Mesa-dev] [PATCH 3/3] draw: clean up setting stream out information a bit
sroland at vmware.com
sroland at vmware.com
Fri Aug 23 14:10:47 PDT 2013
From: Roland Scheidegger <sroland at vmware.com>
In particular noone is interested in the vertex count, so drop that,
and also drop the duplicated num_primitives_generated /
so.primitives_storage_needed variables in drivers. I am unable for now to figure
out if primitives_storage_needed in SO stats (used for d3d10) should
increase if SO is disabled, though the equivalent num_primitives_generated
used for OpenGL definitely should increase. In any case we were only counting
when SO is active both in softpipe and llvmpipe anyway so don't pretend there's
an independent num_primitives_generated counter which would count always.
(This means the PIPE_QUERY_PRIMITIVES_GENERATED count will still be wrong just
as before, should eventually fix this by doing either separate counting for this
query or adjust the code so it always counts this even if SO is inactive depending
on what's correct for d3d10.)
---
src/gallium/auxiliary/draw/draw_pt_so_emit.c | 4 ----
src/gallium/auxiliary/draw/draw_vbuf.h | 1 -
src/gallium/docs/source/context.rst | 2 ++
src/gallium/drivers/llvmpipe/lp_context.h | 1 -
src/gallium/drivers/llvmpipe/lp_query.c | 12 ++++++------
src/gallium/drivers/llvmpipe/lp_setup_vbuf.c | 16 +++++++++++-----
src/gallium/drivers/softpipe/sp_context.h | 1 -
src/gallium/drivers/softpipe/sp_prim_vbuf.c | 16 +++++++++++-----
src/gallium/drivers/softpipe/sp_query.c | 20 +++++++++-----------
9 files changed, 39 insertions(+), 34 deletions(-)
diff --git a/src/gallium/auxiliary/draw/draw_pt_so_emit.c b/src/gallium/auxiliary/draw/draw_pt_so_emit.c
index a6d1da4..7cef17c 100644
--- a/src/gallium/auxiliary/draw/draw_pt_so_emit.c
+++ b/src/gallium/auxiliary/draw/draw_pt_so_emit.c
@@ -48,7 +48,6 @@ struct pt_so_emit {
boolean use_pre_clip_pos;
int pos_idx;
unsigned emitted_primitives;
- unsigned emitted_vertices;
unsigned generated_primitives;
};
@@ -214,7 +213,6 @@ static void so_emit_prim(struct pt_so_emit *so,
}
}
}
- so->emitted_vertices += num_vertices;
++so->emitted_primitives;
}
@@ -274,7 +272,6 @@ void draw_pt_so_emit( struct pt_so_emit *emit,
if (!draw->so.num_targets)
return;
- emit->emitted_vertices = 0;
emit->emitted_primitives = 0;
emit->generated_primitives = 0;
emit->input_vertex_stride = input_verts->stride;
@@ -302,7 +299,6 @@ void draw_pt_so_emit( struct pt_so_emit *emit,
render->set_stream_output_info(render,
emit->emitted_primitives,
- emit->emitted_vertices,
emit->generated_primitives);
}
diff --git a/src/gallium/auxiliary/draw/draw_vbuf.h b/src/gallium/auxiliary/draw/draw_vbuf.h
index bf1c73c..2df0c0e 100644
--- a/src/gallium/auxiliary/draw/draw_vbuf.h
+++ b/src/gallium/auxiliary/draw/draw_vbuf.h
@@ -125,7 +125,6 @@ struct vbuf_render {
*/
void (*set_stream_output_info)( struct vbuf_render *vbufr,
unsigned primitive_count,
- unsigned vertices_count,
unsigned primitive_generated );
/**
diff --git a/src/gallium/docs/source/context.rst b/src/gallium/docs/source/context.rst
index bfd58a4..95f6b22 100644
--- a/src/gallium/docs/source/context.rst
+++ b/src/gallium/docs/source/context.rst
@@ -350,6 +350,8 @@ the result of
``PIPE_QUERY_PRIMITIVES_EMITTED`` and
the number of primitives that would have been written to stream output buffers
if they had infinite space available (primitives_storage_needed), in this order.
+XXX the 2nd value is equivalent to ``PIPE_QUERY_PRIMITIVES_GENERATED`` but it is
+unclear if it should be increased if stream output is not active.
``PIPE_QUERY_SO_OVERFLOW_PREDICATE`` returns a boolean value indicating
whether the stream output targets have overflowed as a result of the
diff --git a/src/gallium/drivers/llvmpipe/lp_context.h b/src/gallium/drivers/llvmpipe/lp_context.h
index fc948a7..106288a 100644
--- a/src/gallium/drivers/llvmpipe/lp_context.h
+++ b/src/gallium/drivers/llvmpipe/lp_context.h
@@ -92,7 +92,6 @@ struct llvmpipe_context {
struct draw_so_target *so_targets[PIPE_MAX_SO_BUFFERS];
int num_so_targets;
struct pipe_query_data_so_statistics so_stats;
- unsigned num_primitives_generated;
struct pipe_query_data_pipeline_statistics pipeline_statistics;
unsigned active_statistics_queries;
diff --git a/src/gallium/drivers/llvmpipe/lp_query.c b/src/gallium/drivers/llvmpipe/lp_query.c
index 4fb707b..e6cae16 100644
--- a/src/gallium/drivers/llvmpipe/lp_query.c
+++ b/src/gallium/drivers/llvmpipe/lp_query.c
@@ -207,15 +207,15 @@ llvmpipe_begin_query(struct pipe_context *pipe, struct pipe_query *q)
pq->num_primitives_written = llvmpipe->so_stats.num_primitives_written;
break;
case PIPE_QUERY_PRIMITIVES_GENERATED:
- pq->num_primitives_generated = llvmpipe->num_primitives_generated;
+ pq->num_primitives_generated = llvmpipe->so_stats.primitives_storage_needed;
break;
case PIPE_QUERY_SO_STATISTICS:
pq->num_primitives_written = llvmpipe->so_stats.num_primitives_written;
- pq->num_primitives_generated = llvmpipe->num_primitives_generated;
+ pq->num_primitives_generated = llvmpipe->so_stats.primitives_storage_needed;
break;
case PIPE_QUERY_SO_OVERFLOW_PREDICATE:
pq->num_primitives_written = llvmpipe->so_stats.num_primitives_written;
- pq->num_primitives_generated = llvmpipe->num_primitives_generated;
+ pq->num_primitives_generated = llvmpipe->so_stats.primitives_storage_needed;
break;
case PIPE_QUERY_PIPELINE_STATISTICS:
/* reset our cache */
@@ -253,19 +253,19 @@ llvmpipe_end_query(struct pipe_context *pipe, struct pipe_query *q)
break;
case PIPE_QUERY_PRIMITIVES_GENERATED:
pq->num_primitives_generated =
- llvmpipe->num_primitives_generated - pq->num_primitives_generated;
+ llvmpipe->so_stats.primitives_storage_needed - pq->num_primitives_generated;
break;
case PIPE_QUERY_SO_STATISTICS:
pq->num_primitives_written =
llvmpipe->so_stats.num_primitives_written - pq->num_primitives_written;
pq->num_primitives_generated =
- llvmpipe->num_primitives_generated - pq->num_primitives_generated;
+ llvmpipe->so_stats.primitives_storage_needed - pq->num_primitives_generated;
break;
case PIPE_QUERY_SO_OVERFLOW_PREDICATE:
pq->num_primitives_written =
llvmpipe->so_stats.num_primitives_written - pq->num_primitives_written;
pq->num_primitives_generated =
- llvmpipe->num_primitives_generated - pq->num_primitives_generated;
+ llvmpipe->so_stats.primitives_storage_needed - pq->num_primitives_generated;
break;
case PIPE_QUERY_PIPELINE_STATISTICS:
pq->stats.ia_vertices =
diff --git a/src/gallium/drivers/llvmpipe/lp_setup_vbuf.c b/src/gallium/drivers/llvmpipe/lp_setup_vbuf.c
index 9e69591..1a1486a 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup_vbuf.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup_vbuf.c
@@ -534,17 +534,23 @@ lp_setup_vbuf_destroy(struct vbuf_render *vbr)
lp_setup_destroy(setup);
}
+/*
+ * FIXME: it is unclear if primitives_storage_needed (which is generally
+ * the same as pipe query num_primitives_generated) should increase
+ * if SO is disabled for d3d10, but for GL we definitely need to
+ * increase num_primitives_generated and this is only called for active
+ * SO. If it must not increase for d3d10 need to disambiguate the counters
+ * in the driver and do some work for getting correct values, if it should
+ * increase too should call this from outside streamout code.
+ */
static void
-lp_setup_so_info(struct vbuf_render *vbr, uint primitives, uint vertices,
- uint prim_generated)
+lp_setup_so_info(struct vbuf_render *vbr, uint primitives, uint prim_generated)
{
struct lp_setup_context *setup = lp_setup_context(vbr);
struct llvmpipe_context *lp = llvmpipe_context(setup->pipe);
lp->so_stats.num_primitives_written += primitives;
- lp->so_stats.primitives_storage_needed +=
- vertices * 4 /*sizeof(float|int32)*/ * 4 /*x,y,z,w*/;
- lp->num_primitives_generated += prim_generated;
+ lp->so_stats.primitives_storage_needed += prim_generated;
}
static void
diff --git a/src/gallium/drivers/softpipe/sp_context.h b/src/gallium/drivers/softpipe/sp_context.h
index e8de81a..7f5272d 100644
--- a/src/gallium/drivers/softpipe/sp_context.h
+++ b/src/gallium/drivers/softpipe/sp_context.h
@@ -90,7 +90,6 @@ struct softpipe_context {
unsigned num_so_targets;
struct pipe_query_data_so_statistics so_stats;
- unsigned num_primitives_generated;
struct pipe_query_data_pipeline_statistics pipeline_statistics;
unsigned active_statistics_queries;
diff --git a/src/gallium/drivers/softpipe/sp_prim_vbuf.c b/src/gallium/drivers/softpipe/sp_prim_vbuf.c
index 80c6450..52d87ed 100644
--- a/src/gallium/drivers/softpipe/sp_prim_vbuf.c
+++ b/src/gallium/drivers/softpipe/sp_prim_vbuf.c
@@ -587,17 +587,23 @@ sp_vbuf_draw_arrays(struct vbuf_render *vbr, uint start, uint nr)
}
}
+/*
+ * FIXME: it is unclear if primitives_storage_needed (which is generally
+ * the same as pipe query num_primitives_generated) should increase
+ * if SO is disabled for d3d10, but for GL we definitely need to
+ * increase num_primitives_generated and this is only called for active
+ * SO. If it must not increase for d3d10 need to disambiguate the counters
+ * in the driver and do some work for getting correct values, if it should
+ * increase too should call this from outside streamout code.
+ */
static void
-sp_vbuf_so_info(struct vbuf_render *vbr, uint primitives, uint vertices,
- uint prim_generated)
+sp_vbuf_so_info(struct vbuf_render *vbr, uint primitives, uint prim_generated)
{
struct softpipe_vbuf_render *cvbr = softpipe_vbuf_render(vbr);
struct softpipe_context *softpipe = cvbr->softpipe;
softpipe->so_stats.num_primitives_written += primitives;
- softpipe->so_stats.primitives_storage_needed +=
- vertices * 4 /*sizeof(float|int32)*/ * 4 /*x,y,z,w*/;
- softpipe->num_primitives_generated += prim_generated;
+ softpipe->so_stats.primitives_storage_needed += prim_generated;
}
static void
diff --git a/src/gallium/drivers/softpipe/sp_query.c b/src/gallium/drivers/softpipe/sp_query.c
index ca15f03..99c5d4c 100644
--- a/src/gallium/drivers/softpipe/sp_query.c
+++ b/src/gallium/drivers/softpipe/sp_query.c
@@ -42,8 +42,6 @@ struct softpipe_query {
uint64_t start;
uint64_t end;
struct pipe_query_data_so_statistics so;
- unsigned num_primitives_generated;
-
struct pipe_query_data_pipeline_statistics stats;
};
@@ -100,7 +98,7 @@ softpipe_begin_query(struct pipe_context *pipe, struct pipe_query *q)
break;
case PIPE_QUERY_SO_STATISTICS:
sq->so.num_primitives_written = softpipe->so_stats.num_primitives_written;
- sq->so.primitives_storage_needed = softpipe->num_primitives_generated;
+ sq->so.primitives_storage_needed = softpipe->so_stats.primitives_storage_needed;
break;
case PIPE_QUERY_SO_OVERFLOW_PREDICATE:
sq->end = FALSE;
@@ -109,7 +107,7 @@ softpipe_begin_query(struct pipe_context *pipe, struct pipe_query *q)
sq->so.num_primitives_written = softpipe->so_stats.num_primitives_written;
break;
case PIPE_QUERY_PRIMITIVES_GENERATED:
- sq->num_primitives_generated = softpipe->num_primitives_generated;
+ sq->so.primitives_storage_needed = softpipe->so_stats.primitives_storage_needed;
break;
case PIPE_QUERY_TIMESTAMP:
case PIPE_QUERY_GPU_FINISHED:
@@ -155,23 +153,23 @@ softpipe_end_query(struct pipe_context *pipe, struct pipe_query *q)
case PIPE_QUERY_SO_OVERFLOW_PREDICATE:
sq->so.num_primitives_written =
softpipe->so_stats.num_primitives_written - sq->so.num_primitives_written;
- sq->num_primitives_generated =
- softpipe->num_primitives_generated - sq->num_primitives_generated;
- sq->end = sq->num_primitives_generated > sq->so.num_primitives_written;
+ sq->so.primitives_storage_needed =
+ softpipe->so_stats.primitives_storage_needed - sq->so.primitives_storage_needed;
+ sq->end = sq->so.primitives_storage_needed > sq->so.num_primitives_written;
break;
case PIPE_QUERY_SO_STATISTICS:
sq->so.num_primitives_written =
softpipe->so_stats.num_primitives_written - sq->so.num_primitives_written;
sq->so.primitives_storage_needed =
- softpipe->num_primitives_generated - sq->so.primitives_storage_needed;
+ softpipe->so_stats.primitives_storage_needed - sq->so.primitives_storage_needed;
break;
case PIPE_QUERY_PRIMITIVES_EMITTED:
sq->so.num_primitives_written =
softpipe->so_stats.num_primitives_written - sq->so.num_primitives_written;
break;
case PIPE_QUERY_PRIMITIVES_GENERATED:
- sq->num_primitives_generated =
- softpipe->num_primitives_generated - sq->num_primitives_generated;
+ sq->so.primitives_storage_needed =
+ softpipe->so_stats.primitives_storage_needed - sq->so.primitives_storage_needed;
break;
case PIPE_QUERY_GPU_FINISHED:
case PIPE_QUERY_TIMESTAMP_DISJOINT:
@@ -243,7 +241,7 @@ softpipe_get_query_result(struct pipe_context *pipe,
*result = sq->so.num_primitives_written;
break;
case PIPE_QUERY_PRIMITIVES_GENERATED:
- *result = sq->num_primitives_generated;
+ *result = sq->so.primitives_storage_needed;
break;
case PIPE_QUERY_OCCLUSION_PREDICATE:
vresult->b = sq->end - sq->start != 0;
--
1.7.9.5
More information about the mesa-dev
mailing list