summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/arrayobj.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/main/arrayobj.c')
-rw-r--r--src/mesa/main/arrayobj.c41
1 files changed, 27 insertions, 14 deletions
diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c
index 29bfed8f51e..3287745432f 100644
--- a/src/mesa/main/arrayobj.c
+++ b/src/mesa/main/arrayobj.c
@@ -280,15 +280,26 @@ remove_array_object( struct gl_context *ctx, struct gl_array_object *obj )
/**
- * Helper for update_arrays().
- * \return min(current min, array->_MaxElement).
+ * Helper for _mesa_update_array_object_max_element().
+ * \return min(arrayObj->VertexAttrib[*]._MaxElement).
*/
static GLuint
-update_min(GLuint min, struct gl_client_array *array)
+compute_max_element(struct gl_array_object *arrayObj, GLbitfield64 enabled)
{
- assert(array->Enabled);
- _mesa_update_array_max_element(array);
- return MIN2(min, array->_MaxElement);
+ GLuint min = ~((GLuint)0);
+
+ while (enabled) {
+ struct gl_client_array *client_array;
+ GLint attrib = ffsll(enabled) - 1;
+ enabled ^= BITFIELD64_BIT(attrib);
+
+ client_array = &arrayObj->VertexAttrib[attrib];
+ assert(client_array->Enabled);
+ _mesa_update_array_max_element(client_array);
+ min = MIN2(min, client_array->_MaxElement);
+ }
+
+ return min;
}
@@ -299,17 +310,19 @@ void
_mesa_update_array_object_max_element(struct gl_context *ctx,
struct gl_array_object *arrayObj)
{
- GLbitfield64 enabled = arrayObj->_Enabled;
- GLuint min = ~0u;
-
- while (enabled) {
- GLint attrib = ffsll(enabled) - 1;
- enabled &= ~BITFIELD64_BIT(attrib);
- min = update_min(min, &arrayObj->VertexAttrib[attrib]);
+ GLbitfield64 enabled;
+
+ if (!ctx->VertexProgram._Current ||
+ ctx->VertexProgram._Current == ctx->VertexProgram._TnlProgram) {
+ enabled = _mesa_array_object_get_enabled_ff(arrayObj);
+ } else if (ctx->VertexProgram._Current->IsNVProgram) {
+ enabled = _mesa_array_object_get_enabled_nv(arrayObj);
+ } else {
+ enabled = _mesa_array_object_get_enabled_arb(arrayObj);
}
/* _MaxElement is one past the last legal array element */
- arrayObj->_MaxElement = min;
+ arrayObj->_MaxElement = compute_max_element(arrayObj, enabled);
}