[Mesa-dev] [PATCH 05/27] i965: Move brw_emit_query_begin() to the render ring prelude.

Kenneth Graunke kenneth at whitecape.org
Wed Nov 13 17:52:10 PST 2013

Without hardware contexts, the pipeline statistics registers are
free-running and include data from every 3D application running.

In order to find out the contributions of one particular context, we
need to take a snapshot at the start and end of each batch.

Previously, we emitted the PIPE_CONTROL necessary to capture
PS_DEPTH_COUNT when drawing primitives.  Special tracking ensured it
happened only on the first draw of the batch, rather than on every draw.

Moving this to brw_new_batch increases symmetry, since the final
snapshot has always been in brw_finish_batch, which is just a few lines
below.  It should be basically equivalent.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
Cc: Eric Anholt <eric at anholt.net>
Cc: Carl Worth <cworth at cworth.org>
Cc: Juha-Pekka Heikkilä <juha-pekka.heikkila at intel.com>
 src/mesa/drivers/dri/i965/brw_draw_upload.c   | 2 --
 src/mesa/drivers/dri/i965/intel_batchbuffer.c | 8 ++++++++
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c b/src/mesa/drivers/dri/i965/brw_draw_upload.c
index 57b81df..89404b0 100644
--- a/src/mesa/drivers/dri/i965/brw_draw_upload.c
+++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c
@@ -614,8 +614,6 @@ static void brw_emit_vertices(struct brw_context *brw)
-   brw_emit_query_begin(brw);
    nr_elements = brw->vb.nr_enabled + brw->vs.prog_data->uses_vertexid;
    /* If the VS doesn't read any inputs (calculating vertex position from
diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.c b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
index 7598955..cadc569 100644
--- a/src/mesa/drivers/dri/i965/intel_batchbuffer.c
+++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
@@ -182,6 +182,11 @@ do_batch_dump(struct brw_context *brw)
 intel_batchbuffer_emit_render_ring_prelude(struct brw_context *brw)
+   /* Without hardware contexts, we need to capture the pipeline statistics
+    * registers at the start and end of each render ring batch, so we can see
+    * what that batch contributed.  Emit state packets to write them to a BO.
+    */
+   brw_emit_query_begin(brw);
@@ -234,6 +239,9 @@ brw_new_batch(struct brw_context *brw)
 static void
 brw_finish_batch(struct brw_context *brw)
+   /* Capture the closing pipeline statistics register values necessary to
+    * support query objects (in the non-hardware context world).
+    */
    if (brw->curbe.curbe_bo) {

More information about the mesa-dev mailing list