i965: Port 3DSTATE_VF to genxml and simplify the implementation.
authorKenneth Graunke <kenneth@whitecape.org>
Thu, 4 May 2017 08:17:29 +0000 (01:17 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Sat, 6 May 2017 22:43:43 +0000 (15:43 -0700)
The whole "it might be used for non-indexed draws" thing is no longer
true - it turns out this was a mistake, and removed in OpenGL 4.5.
(See Marek's commit 96cbc1ca29e0b1f4f4d6c868b8449999aecb9080.)  So
we can simplify this and just program 0 for non-indexed draws.

We can also use #if blocks to remove the atom on Ivybridge/Baytrail,
now that they have a separate atom list from Haswell.  No more runtime
checks.

Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
src/mesa/drivers/dri/i965/brw_primitive_restart.c
src/mesa/drivers/dri/i965/brw_state.h
src/mesa/drivers/dri/i965/genX_state_upload.c

index 8e5a58af4046fa5c29ddec5363db5683b7bb91c8..3dc221e1cfb784b91192ee3a787cc6487d513cfb 100644 (file)
@@ -177,43 +177,3 @@ brw_handle_primitive_restart(struct gl_context *ctx,
    /* The primitive restart draw was completed, so return true. */
    return GL_TRUE;
 }
-
-static void
-haswell_upload_cut_index(struct brw_context *brw)
-{
-   struct gl_context *ctx = &brw->ctx;
-
-   /* Don't trigger on Ivybridge */
-   if (brw->gen < 8 && !brw->is_haswell)
-      return;
-
-   const unsigned cut_index_setting =
-      ctx->Array._PrimitiveRestart ? HSW_CUT_INDEX_ENABLE : 0;
-
-   /* BRW_NEW_INDEX_BUFFER */
-   unsigned cut_index;
-   if (brw->ib.ib) {
-      cut_index = _mesa_primitive_restart_index(ctx, brw->ib.index_size);
-   } else {
-      /* There's no index buffer, but primitive restart may still apply
-       * to glDrawArrays and such.  FIXED_INDEX mode only applies to drawing
-       * operations that use an index buffer, so we can ignore it and use
-       * the GL restart index directly.
-       */
-      cut_index = ctx->Array.RestartIndex;
-   }
-
-   BEGIN_BATCH(2);
-   OUT_BATCH(_3DSTATE_VF << 16 | cut_index_setting | (2 - 2));
-   OUT_BATCH(cut_index);
-   ADVANCE_BATCH();
-}
-
-const struct brw_tracked_state haswell_cut_index = {
-   .dirty = {
-      .mesa  = _NEW_TRANSFORM,
-      .brw   = BRW_NEW_BLORP |
-               BRW_NEW_INDEX_BUFFER,
-   },
-   .emit = haswell_upload_cut_index,
-};
index d2d3d7c2c0df556b944e6e652f6253e8a916d378..7eda06c81d1c4a8a196d71fe3bd31cfa8896f9dd 100644 (file)
@@ -113,7 +113,6 @@ extern const struct brw_tracked_state gen7_depthbuffer;
 extern const struct brw_tracked_state gen7_l3_state;
 extern const struct brw_tracked_state gen7_push_constant_space;
 extern const struct brw_tracked_state gen7_urb;
-extern const struct brw_tracked_state haswell_cut_index;
 extern const struct brw_tracked_state gen8_index_buffer;
 extern const struct brw_tracked_state gen8_pma_fix;
 extern const struct brw_tracked_state gen8_vf_topology;
index b6aa7c84d1db8145470423e4e49c7e9ef4885dbf..ca05817e19c0e480bcdec3d5e3247ab0ee7e413c 100644 (file)
@@ -53,6 +53,7 @@
 #include "main/shaderapi.h"
 #include "main/stencil.h"
 #include "main/transformfeedback.h"
+#include "main/varray.h"
 #include "main/viewport.h"
 
 UNUSED static void *
@@ -837,6 +838,30 @@ static const struct brw_tracked_state genX(vertices) = {
    .emit = genX(emit_vertices),
 };
 
+#if GEN_IS_HASWELL || GEN_GEN >= 8
+static void
+genX(upload_cut_index)(struct brw_context *brw)
+{
+   const struct gl_context *ctx = &brw->ctx;
+
+   brw_batch_emit(brw, GENX(3DSTATE_VF), vf) {
+      if (ctx->Array._PrimitiveRestart && brw->ib.ib) {
+         vf.IndexedDrawCutIndexEnable = true;
+         vf.CutIndex = _mesa_primitive_restart_index(ctx, brw->ib.index_size);
+      }
+   }
+}
+
+const struct brw_tracked_state genX(cut_index) = {
+   .dirty = {
+      .mesa  = _NEW_TRANSFORM,
+      .brw   = BRW_NEW_BLORP |
+               BRW_NEW_INDEX_BUFFER,
+   },
+   .emit = genX(upload_cut_index),
+};
+#endif
+
 #if GEN_GEN >= 6
 /**
  * Determine the appropriate attribute override value to store into the
@@ -4012,7 +4037,9 @@ genX(init_atoms)(struct brw_context *brw)
       &brw_index_buffer,
       &genX(vertices),
 
-      &haswell_cut_index,
+#if GEN_IS_HASWELL
+      &genX(cut_index),
+#endif
    };
 #elif GEN_GEN >= 8
    static const struct brw_tracked_state *render_atoms[] =
@@ -4105,7 +4132,7 @@ genX(init_atoms)(struct brw_context *brw)
       &gen8_index_buffer,
       &genX(vertices),
 
-      &haswell_cut_index,
+      &genX(cut_index),
       &gen8_pma_fix,
    };
 #endif