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) {
}
+/**
+ * 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.
*/
/* 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;
}
/** 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;
*/
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;
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;
if (binding->InstanceDivisor != divisor) {
binding->InstanceDivisor = divisor;
+
+ if (divisor)
+ vao->NonZeroDivisorMask |= binding->_BoundArrays;
+ else
+ vao->NonZeroDivisorMask &= ~binding->_BoundArrays;
+
vao->NewArrays |= vao->Enabled & binding->_BoundArrays;
}
}
GLbitfield userbuf_attribs = inputs_read & _mesa_draw_user_array_bits(ctx);
*has_user_vertex_buffers = userbuf_attribs != 0;
+ st->draw_needs_minmax_index =
+ (userbuf_attribs & ~_mesa_draw_nonzero_divisor_bits(ctx)) != 0;
while (mask) {
/* The attribute index to start pulling a binding */
vbuffer[bufidx].buffer.user = ptr;
vbuffer[bufidx].is_user_buffer = true;
vbuffer[bufidx].buffer_offset = 0;
-
- if (!binding->InstanceDivisor)
- st->draw_needs_minmax_index = true;
}
vbuffer[bufidx].stride = binding->Stride; /* in bytes */
unsigned num_velements;
bool uses_user_vertex_buffers;
- st->draw_needs_minmax_index = false;
-
/* ST_NEW_VERTEX_ARRAYS alias ctx->DriverFlags.NewArray */
/* Setup arrays */
st_setup_arrays(st, vp, vp_variant, velements, vbuffer, &num_vbuffers,