aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2020-01-22 22:38:09 -0500
committerMarek Olšák <[email protected]>2020-02-14 18:16:27 -0500
commitfd6636ebc06d55b59851701c436b8b97f50fd7f4 (patch)
tree9227ae4b2461b4e07f72c71646ed4f0d4b21543b /src/mesa/main
parent1d933728024f907236ffe95da5f5f0eabf6052c7 (diff)
st/mesa: simplify determination whether a draw needs min/max index
Reviewed-by: Mathias Fröhlich <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3829>
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/arrayobj.c3
-rw-r--r--src/mesa/main/arrayobj.h14
-rw-r--r--src/mesa/main/attrib.c2
-rw-r--r--src/mesa/main/mtypes.h6
-rw-r--r--src/mesa/main/varray.c11
5 files changed, 36 insertions, 0 deletions
diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c
index 331dc1a3c68..6dbd09b39ec 100644
--- a/src/mesa/main/arrayobj.c
+++ b/src/mesa/main/arrayobj.c
@@ -611,9 +611,12 @@ _mesa_update_vao_derived_arrays(struct gl_context *ctx,
const GLbitfield enabled = vao->Enabled;
/* VBO array bits. */
const GLbitfield vbos = vao->VertexAttribBufferMask;
+ const GLbitfield divisor_is_nonzero = vao->NonZeroDivisorMask;
/* Compute and store effectively enabled and mapped vbo arrays */
vao->_EffEnabledVBO = _mesa_vao_enable_to_vp_inputs(mode, enabled & vbos);
+ vao->_EffEnabledNonZeroDivisor =
+ _mesa_vao_enable_to_vp_inputs(mode, enabled & divisor_is_nonzero);
/* Walk those enabled arrays that have a real vbo attached */
GLbitfield mask = enabled;
while (mask) {
diff --git a/src/mesa/main/arrayobj.h b/src/mesa/main/arrayobj.h
index 584e6d818cf..19ab65b3242 100644
--- a/src/mesa/main/arrayobj.h
+++ b/src/mesa/main/arrayobj.h
@@ -212,6 +212,20 @@ _mesa_draw_user_array_bits(const struct gl_context *ctx)
/**
+ * Return which enabled vertex attributes have a non-zero instance divisor.
+ *
+ * Needs the a fully updated VAO ready for draw.
+ */
+static inline GLbitfield
+_mesa_draw_nonzero_divisor_bits(const struct gl_context *ctx)
+{
+ const struct gl_vertex_array_object *const vao = ctx->Array._DrawVAO;
+ assert(vao->NewArrays == 0);
+ return ~vao->_EffEnabledNonZeroDivisor & ctx->Array._DrawVAOEnabledAttribs;
+}
+
+
+/**
* Return enabled current values attribute bits for draw.
*/
static inline GLbitfield
diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index b2756354f1f..133f1a8c424 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -1580,8 +1580,10 @@ copy_array_object(struct gl_context *ctx,
/* Enabled must be the same than on push */
dest->Enabled = src->Enabled;
dest->_EffEnabledVBO = src->_EffEnabledVBO;
+ dest->_EffEnabledNonZeroDivisor = src->_EffEnabledNonZeroDivisor;
/* The bitmask of bound VBOs needs to match the VertexBinding array */
dest->VertexAttribBufferMask = src->VertexAttribBufferMask;
+ dest->NonZeroDivisorMask = src->NonZeroDivisorMask;
dest->_AttributeMapMode = src->_AttributeMapMode;
dest->NewArrays = src->NewArrays;
}
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 0da926e67ff..db4921d0106 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1547,6 +1547,9 @@ struct gl_vertex_array_object
/** Mask indicating which vertex arrays have vertex buffer associated. */
GLbitfield VertexAttribBufferMask;
+ /** Mask indicating which vertex arrays have a non-zero instance divisor. */
+ GLbitfield NonZeroDivisorMask;
+
/** Mask of VERT_BIT_* values indicating which arrays are enabled */
GLbitfield Enabled;
@@ -1559,6 +1562,9 @@ struct gl_vertex_array_object
*/
GLbitfield _EffEnabledVBO;
+ /** Same as _EffEnabledVBO, but for instance divisors. */
+ GLbitfield _EffEnabledNonZeroDivisor;
+
/** Denotes the way the position/generic0 attribute is mapped */
gl_attribute_map_mode _AttributeMapMode;
diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index 7ef0de7734a..2f6aefc9ccb 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -174,6 +174,11 @@ _mesa_vertex_attrib_binding(struct gl_context *ctx,
else
vao->VertexAttribBufferMask &= ~array_bit;
+ if (vao->BufferBinding[bindingIndex].InstanceDivisor)
+ vao->NonZeroDivisorMask |= array_bit;
+ else
+ vao->NonZeroDivisorMask &= ~array_bit;
+
vao->BufferBinding[array->BufferBindingIndex]._BoundArrays &= ~array_bit;
vao->BufferBinding[bindingIndex]._BoundArrays |= array_bit;
@@ -250,6 +255,12 @@ vertex_binding_divisor(struct gl_context *ctx,
if (binding->InstanceDivisor != divisor) {
binding->InstanceDivisor = divisor;
+
+ if (divisor)
+ vao->NonZeroDivisorMask |= binding->_BoundArrays;
+ else
+ vao->NonZeroDivisorMask &= ~binding->_BoundArrays;
+
vao->NewArrays |= vao->Enabled & binding->_BoundArrays;
}
}