----- Original Message -----
> I wonder if, instead of sending statistics down the pipe with through vbuf,
> it would be simpler to just have
>
> void draw_statistics_start(struct draw_context *draw)
> void draw_statistics_end(struct draw_context *draw,
> struct pipe_query_data_pipeline_statistics
> *out_statistics)
>
> It seems to me that thist would map nicely to the pipe query calls. Of
> course, the setup/fragment statistics would need to be filled independently,
> and the draw module would need to flush in these calls.
I started this way and ended up rewriting it because I didn't like the fact
that the interface was different than for the stream-output queries. I figured
that if we'll be switching we'll need to switch both, otherwise the interface
is just going to be a mess. Also, from the users of the module it comes down to
the same thing - that draw module gives it the statistics for the current run,
how the callers handle that data is really independent of the interface.
> This would also allow to accumulate multiple statistics across multiple draws
> nicely, and probably less overhead.
That's a feature that's important. I implemented it on top of this patch with
the simple diff I'm attaching (I'd merge them both into a single pass but it's
going to be easier for everyone to see what's going on with just the diff).
z
diff --git a/src/gallium/drivers/llvmpipe/lp_draw_arrays.c b/src/gallium/drivers/llvmpipe/lp_draw_arrays.c
index 8b7903b..e8a5880 100644
--- a/src/gallium/drivers/llvmpipe/lp_draw_arrays.c
+++ b/src/gallium/drivers/llvmpipe/lp_draw_arrays.c
@@ -108,10 +108,6 @@ llvmpipe_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info)
draw_vs_attach_so(lp->vs->draw_data, &lp->gs->shader.stream_output);
}
}
- if (lp->active_statistics_queries) {
- memset(&lp->pipeline_statistics, 0,
- sizeof(lp->pipeline_statistics));
- }
draw_collect_pipeline_statistics(draw,
lp->active_statistics_queries > 0);
diff --git a/src/gallium/drivers/llvmpipe/lp_query.c b/src/gallium/drivers/llvmpipe/lp_query.c
index 319a070..96e1e3f 100644
--- a/src/gallium/drivers/llvmpipe/lp_query.c
+++ b/src/gallium/drivers/llvmpipe/lp_query.c
@@ -195,7 +195,12 @@ llvmpipe_begin_query(struct pipe_context *pipe, struct pipe_query *q)
}
if (pq->type == PIPE_QUERY_PIPELINE_STATISTICS) {
- memset(&pq->stats, 0, sizeof(pq->stats));
+ /* reset our cache */
+ if (llvmpipe->active_statistics_queries == 0) {
+ memset(&llvmpipe->pipeline_statistics, 0,
+ sizeof(llvmpipe->pipeline_statistics));
+ }
+ memcpy(&pq->stats, &llvmpipe->pipeline_statistics, sizeof(pq->stats));
llvmpipe->active_statistics_queries++;
}
@@ -228,7 +233,23 @@ llvmpipe_end_query(struct pipe_context *pipe, struct pipe_query *q)
}
if (pq->type == PIPE_QUERY_PIPELINE_STATISTICS) {
- pq->stats = llvmpipe->pipeline_statistics;
+ pq->stats.ia_vertices =
+ llvmpipe->pipeline_statistics.ia_vertices - pq->stats.ia_vertices;
+ pq->stats.ia_primitives =
+ llvmpipe->pipeline_statistics.ia_primitives - pq->stats.ia_primitives;
+ pq->stats.vs_invocations =
+ llvmpipe->pipeline_statistics.vs_invocations - pq->stats.vs_invocations;
+ pq->stats.gs_invocations =
+ llvmpipe->pipeline_statistics.gs_invocations - pq->stats.gs_invocations;
+ pq->stats.gs_primitives =
+ llvmpipe->pipeline_statistics.gs_primitives - pq->stats.gs_primitives;
+ pq->stats.c_invocations =
+ llvmpipe->pipeline_statistics.c_invocations - pq->stats.c_invocations;
+ pq->stats.c_primitives =
+ llvmpipe->pipeline_statistics.c_primitives - pq->stats.c_primitives;
+ pq->stats.ps_invocations =
+ llvmpipe->pipeline_statistics.ps_invocations - pq->stats.ps_invocations;
+
llvmpipe->active_statistics_queries--;
}
diff --git a/src/gallium/drivers/llvmpipe/lp_setup_vbuf.c b/src/gallium/drivers/llvmpipe/lp_setup_vbuf.c
index f2a1f21..8173994 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup_vbuf.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup_vbuf.c
@@ -555,17 +555,17 @@ lp_setup_pipeline_statistics(
struct lp_setup_context *setup = lp_setup_context(vbr);
struct llvmpipe_context *llvmpipe = llvmpipe_context(setup->pipe);
- llvmpipe->pipeline_statistics.ia_vertices =
+ llvmpipe->pipeline_statistics.ia_vertices +=
stats->ia_vertices;
- llvmpipe->pipeline_statistics.ia_primitives =
+ llvmpipe->pipeline_statistics.ia_primitives +=
stats->ia_primitives;
- llvmpipe->pipeline_statistics.vs_invocations =
+ llvmpipe->pipeline_statistics.vs_invocations +=
stats->vs_invocations;
- llvmpipe->pipeline_statistics.gs_invocations =
+ llvmpipe->pipeline_statistics.gs_invocations +=
stats->gs_invocations;
- llvmpipe->pipeline_statistics.gs_primitives =
+ llvmpipe->pipeline_statistics.gs_primitives +=
stats->gs_primitives;
- llvmpipe->pipeline_statistics.c_invocations =
+ llvmpipe->pipeline_statistics.c_invocations +=
stats->c_invocations;
}
diff --git a/src/gallium/drivers/softpipe/sp_draw_arrays.c b/src/gallium/drivers/softpipe/sp_draw_arrays.c
index 570644e..4378312 100644
--- a/src/gallium/drivers/softpipe/sp_draw_arrays.c
+++ b/src/gallium/drivers/softpipe/sp_draw_arrays.c
@@ -105,10 +105,6 @@ softpipe_draw_vbo(struct pipe_context *pipe,
draw_set_mapped_so_targets(draw, sp->num_so_targets,
sp->so_targets);
- if (sp->active_statistics_queries) {
- memset(&sp->pipeline_statistics, 0,
- sizeof(sp->pipeline_statistics));
- }
draw_collect_pipeline_statistics(draw,
sp->active_statistics_queries > 0);
diff --git a/src/gallium/drivers/softpipe/sp_prim_vbuf.c b/src/gallium/drivers/softpipe/sp_prim_vbuf.c
index b4962ba..5d0b5e1 100644
--- a/src/gallium/drivers/softpipe/sp_prim_vbuf.c
+++ b/src/gallium/drivers/softpipe/sp_prim_vbuf.c
@@ -608,17 +608,17 @@ sp_vbuf_pipeline_statistics(
struct softpipe_vbuf_render *cvbr = softpipe_vbuf_render(vbr);
struct softpipe_context *softpipe = cvbr->softpipe;
- softpipe->pipeline_statistics.ia_vertices =
+ softpipe->pipeline_statistics.ia_vertices +=
stats->ia_vertices;
- softpipe->pipeline_statistics.ia_primitives =
+ softpipe->pipeline_statistics.ia_primitives +=
stats->ia_primitives;
- softpipe->pipeline_statistics.vs_invocations =
+ softpipe->pipeline_statistics.vs_invocations +=
stats->vs_invocations;
- softpipe->pipeline_statistics.gs_invocations =
+ softpipe->pipeline_statistics.gs_invocations +=
stats->gs_invocations;
- softpipe->pipeline_statistics.gs_primitives =
+ softpipe->pipeline_statistics.gs_primitives +=
stats->gs_primitives;
- softpipe->pipeline_statistics.c_invocations =
+ softpipe->pipeline_statistics.c_invocations +=
stats->c_invocations;
}
diff --git a/src/gallium/drivers/softpipe/sp_query.c b/src/gallium/drivers/softpipe/sp_query.c
index 34a8d5e..62411de 100644
--- a/src/gallium/drivers/softpipe/sp_query.c
+++ b/src/gallium/drivers/softpipe/sp_query.c
@@ -110,7 +110,13 @@ softpipe_begin_query(struct pipe_context *pipe, struct pipe_query *q)
case PIPE_QUERY_GPU_FINISHED:
break;
case PIPE_QUERY_PIPELINE_STATISTICS:
- memset(&sq->stats, 0, sizeof(sq->stats));
+ /* reset our cache */
+ if (softpipe->active_statistics_queries == 0) {
+ memset(&softpipe->pipeline_statistics, 0,
+ sizeof(softpipe->pipeline_statistics));
+ }
+ memcpy(&sq->stats, &softpipe->pipeline_statistics,
+ sizeof(sq->stats));
softpipe->active_statistics_queries++;
break;
default:
@@ -153,8 +159,23 @@ softpipe_end_query(struct pipe_context *pipe, struct pipe_query *q)
case PIPE_QUERY_GPU_FINISHED:
break;
case PIPE_QUERY_PIPELINE_STATISTICS:
- memcpy(&sq->stats, &softpipe->pipeline_statistics,
- sizeof(struct pipe_query_data_pipeline_statistics));;
+ sq->stats.ia_vertices =
+ softpipe->pipeline_statistics.ia_vertices - sq->stats.ia_vertices;
+ sq->stats.ia_primitives =
+ softpipe->pipeline_statistics.ia_primitives - sq->stats.ia_primitives;
+ sq->stats.vs_invocations =
+ softpipe->pipeline_statistics.vs_invocations - sq->stats.vs_invocations;
+ sq->stats.gs_invocations =
+ softpipe->pipeline_statistics.gs_invocations - sq->stats.gs_invocations;
+ sq->stats.gs_primitives =
+ softpipe->pipeline_statistics.gs_primitives - sq->stats.gs_primitives;
+ sq->stats.c_invocations =
+ softpipe->pipeline_statistics.c_invocations - sq->stats.c_invocations;
+ sq->stats.c_primitives =
+ softpipe->pipeline_statistics.c_primitives - sq->stats.c_primitives;
+ sq->stats.ps_invocations =
+ softpipe->pipeline_statistics.ps_invocations - sq->stats.ps_invocations;
+
softpipe->active_statistics_queries--;
break;
default:
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev