i965: Split BeginTransformFeedback hook into Gen6 and Gen7+ variants.
authorKenneth Graunke <kenneth@whitecape.org>
Mon, 20 May 2013 22:25:28 +0000 (15:25 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Tue, 21 May 2013 20:29:40 +0000 (13:29 -0700)
Most of the work in BeginTransformFeedback is only necessary on Gen6.
We may as well just skip it on Gen7+.

v2: Add an intel->gen == 6 assert.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
src/mesa/drivers/dri/i965/brw_context.c
src/mesa/drivers/dri/i965/brw_context.h
src/mesa/drivers/dri/i965/gen6_sol.c
src/mesa/drivers/dri/i965/gen7_sol_state.c

index 405580f5310dbfc050b6240f4c333055530b14c0..56c42ba337828e8c28f2c45463f82eee5324b0d8 100644 (file)
@@ -94,12 +94,14 @@ static void brwInitDriverFunctions(struct intel_screen *screen,
       gen4_init_queryobj_functions(functions);
 
    functions->QuerySamplesForFormat = brw_query_samples_for_format;
-   functions->BeginTransformFeedback = brw_begin_transform_feedback;
 
-   if (screen->gen >= 7)
+   if (screen->gen >= 7) {
+      functions->BeginTransformFeedback = gen7_begin_transform_feedback;
       functions->EndTransformFeedback = gen7_end_transform_feedback;
-   else
+   } else {
+      functions->BeginTransformFeedback = brw_begin_transform_feedback;
       functions->EndTransformFeedback = brw_end_transform_feedback;
+   }
 
    if (screen->gen >= 6)
       functions->GetSamplePosition = gen6_get_sample_position;
index be49078b1e32692d23687a3d58017d7fd78073ed..60b713d37f604db1a17368709c52cd0c4cb352f6 100644 (file)
@@ -1228,6 +1228,9 @@ brw_end_transform_feedback(struct gl_context *ctx,
 
 /* gen7_sol_state.c */
 void
+gen7_begin_transform_feedback(struct gl_context *ctx, GLenum mode,
+                              struct gl_transform_feedback_object *obj);
+void
 gen7_end_transform_feedback(struct gl_context *ctx,
                            struct gl_transform_feedback_object *obj);
 
index cdd6e74c8652eaf680c9c7f450b61fd7c6f6ff77..0215a9b2c7f0be76dde3bd39adb54c7f0b41b691 100644 (file)
@@ -145,6 +145,8 @@ brw_begin_transform_feedback(struct gl_context *ctx, GLenum mode,
    struct gl_transform_feedback_object *xfb_obj =
       ctx->TransformFeedback.CurrentObject;
 
+   assert(intel->gen == 6);
+
    /* Compute the maximum number of vertices that we can write without
     * overflowing any of the buffers currently being used for feedback.
     */
@@ -152,36 +154,25 @@ brw_begin_transform_feedback(struct gl_context *ctx, GLenum mode,
       = _mesa_compute_max_transform_feedback_vertices(xfb_obj,
                                                       linked_xfb_info);
 
-   if (intel->gen == 6) {
-      /* Initialize the SVBI 0 register to zero and set the maximum index. */
+   /* Initialize the SVBI 0 register to zero and set the maximum index. */
+   BEGIN_BATCH(4);
+   OUT_BATCH(_3DSTATE_GS_SVB_INDEX << 16 | (4 - 2));
+   OUT_BATCH(0); /* SVBI 0 */
+   OUT_BATCH(0); /* starting index */
+   OUT_BATCH(max_index);
+   ADVANCE_BATCH();
+
+   /* Initialize the rest of the unused streams to sane values.  Otherwise,
+    * they may indicate that there is no room to write data and prevent
+    * anything from happening at all.
+    */
+   for (int i = 1; i < 4; i++) {
       BEGIN_BATCH(4);
       OUT_BATCH(_3DSTATE_GS_SVB_INDEX << 16 | (4 - 2));
-      OUT_BATCH(0); /* SVBI 0 */
+      OUT_BATCH(i << SVB_INDEX_SHIFT);
       OUT_BATCH(0); /* starting index */
-      OUT_BATCH(max_index);
+      OUT_BATCH(0xffffffff);
       ADVANCE_BATCH();
-
-      /* Initialize the rest of the unused streams to sane values.  Otherwise,
-       * they may indicate that there is no room to write data and prevent
-       * anything from happening at all.
-       */
-      for (int i = 1; i < 4; i++) {
-         BEGIN_BATCH(4);
-         OUT_BATCH(_3DSTATE_GS_SVB_INDEX << 16 | (4 - 2));
-         OUT_BATCH(i << SVB_INDEX_SHIFT);
-         OUT_BATCH(0); /* starting index */
-         OUT_BATCH(0xffffffff);
-         ADVANCE_BATCH();
-      }
-   } else if (intel->gen >= 7) {
-      /* Reset the SOL buffer offset register. */
-      for (int i = 0; i < 4; i++) {
-         BEGIN_BATCH(3);
-         OUT_BATCH(MI_LOAD_REGISTER_IMM | (3 - 2));
-         OUT_BATCH(GEN7_SO_WRITE_OFFSET(i));
-         OUT_BATCH(0);
-         ADVANCE_BATCH();
-      }
    }
 }
 
index 2c4b7f99a05a01ca0e61aca00df965512b3520bf..8dfac01ff022e40881a15ddfca84570dccb4cfe7 100644 (file)
@@ -253,6 +253,23 @@ const struct brw_tracked_state gen7_sol_state = {
    .emit = upload_sol_state,
 };
 
+void
+gen7_begin_transform_feedback(struct gl_context *ctx, GLenum mode,
+                              struct gl_transform_feedback_object *obj)
+{
+   struct brw_context *brw = brw_context(ctx);
+   struct intel_context *intel = &brw->intel;
+
+   /* Reset the SOL buffer offset register. */
+   for (int i = 0; i < 4; i++) {
+      BEGIN_BATCH(3);
+      OUT_BATCH(MI_LOAD_REGISTER_IMM | (3 - 2));
+      OUT_BATCH(GEN7_SO_WRITE_OFFSET(i));
+      OUT_BATCH(0);
+      ADVANCE_BATCH();
+   }
+}
+
 void
 gen7_end_transform_feedback(struct gl_context *ctx,
                            struct gl_transform_feedback_object *obj)