[Mesa-dev] [PATCH 2/4] i965/gen7: Flush the batch between transform feedbacks.

Eric Anholt eric at anholt.net
Mon Jan 2 11:37:45 PST 2012


We need the kernel to reset our pointers to 0 in between.  Note that
the initialization of function pointer had to move to after
InitContext since we didn't have intel->gen set up yet.

Fixes piglit EXT_transform_feedback/immediate-reuse
---
 src/mesa/drivers/dri/i965/brw_context.c    |   13 ++++++++++---
 src/mesa/drivers/dri/i965/brw_context.h    |    5 +++++
 src/mesa/drivers/dri/i965/gen7_sol_state.c |   16 ++++++++++++++++
 3 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
index f5c9d7a..48c141c 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -109,7 +109,8 @@ static void brwPrepareExecBegin(struct gl_context *ctx)
    }
 }
 
-static void brwInitDriverFunctions( struct dd_function_table *functions )
+static void brwInitDriverFunctions(struct intel_screen *screen,
+				   struct dd_function_table *functions)
 {
    intelInitDriverFunctions( functions );
 
@@ -118,7 +119,11 @@ static void brwInitDriverFunctions( struct dd_function_table *functions )
 
    functions->PrepareExecBegin = brwPrepareExecBegin;
    functions->BeginTransformFeedback = brw_begin_transform_feedback;
-   functions->EndTransformFeedback = brw_end_transform_feedback;
+
+   if (screen->gen >= 7)
+      functions->EndTransformFeedback = gen7_end_transform_feedback;
+   else
+      functions->EndTransformFeedback = brw_end_transform_feedback;
 }
 
 bool
@@ -127,6 +132,8 @@ brwCreateContext(int api,
 		 __DRIcontext *driContextPriv,
 	         void *sharedContextPrivate)
 {
+   __DRIscreen *sPriv = driContextPriv->driScreenPriv;
+   struct intel_screen *screen = sPriv->driverPrivate;
    struct dd_function_table functions;
    struct brw_context *brw = rzalloc(NULL, struct brw_context);
    struct intel_context *intel = &brw->intel;
@@ -138,7 +145,7 @@ brwCreateContext(int api,
       return false;
    }
 
-   brwInitDriverFunctions( &functions );
+   brwInitDriverFunctions(screen, &functions);
 
    if (!intelInitContext( intel, api, mesaVis, driContextPriv,
 			  sharedContextPrivate, &functions )) {
diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index fb41fd1..873e172 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -1093,6 +1093,11 @@ void
 brw_end_transform_feedback(struct gl_context *ctx,
                            struct gl_transform_feedback_object *obj);
 
+/* gen7_sol_state.c */
+void
+gen7_end_transform_feedback(struct gl_context *ctx,
+			    struct gl_transform_feedback_object *obj);
+
 
 
 /*======================================================================
diff --git a/src/mesa/drivers/dri/i965/gen7_sol_state.c b/src/mesa/drivers/dri/i965/gen7_sol_state.c
index 6cf68e2..ba9fb67 100644
--- a/src/mesa/drivers/dri/i965/gen7_sol_state.c
+++ b/src/mesa/drivers/dri/i965/gen7_sol_state.c
@@ -255,3 +255,19 @@ const struct brw_tracked_state gen7_sol_state = {
    },
    .emit = upload_sol_state,
 };
+
+void
+gen7_end_transform_feedback(struct gl_context *ctx,
+			    struct gl_transform_feedback_object *obj)
+{
+   /* Because we have to rely on the kernel to reset our SO write offsets, and
+    * we only get to do it once per batchbuffer, flush the batch after feedback
+    * so another transform feedback can get the write offset reset it needs.
+    *
+    * This also covers any cache flushing required.
+    */
+   struct brw_context *brw = brw_context(ctx);
+   struct intel_context *intel = &brw->intel;
+
+   intel_batchbuffer_flush(intel);
+}
-- 
1.7.7.3



More information about the mesa-dev mailing list