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>
/* 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,
-};
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;
#include "main/shaderapi.h"
#include "main/stencil.h"
#include "main/transformfeedback.h"
+#include "main/varray.h"
#include "main/viewport.h"
UNUSED static void *
.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
&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[] =
&gen8_index_buffer,
&genX(vertices),
- &haswell_cut_index,
+ &genX(cut_index),
&gen8_pma_fix,
};
#endif