Allow first != 0 in mesa CVA handling, and add more error checking.
authorEric Anholt <eric@anholt.net>
Sat, 2 Feb 2008 10:54:13 +0000 (02:54 -0800)
committerEric Anholt <eric@anholt.net>
Tue, 5 Feb 2008 02:24:16 +0000 (18:24 -0800)
src/mesa/main/attrib.c
src/mesa/main/varray.c
src/mesa/main/varray.h

index 07ec285eeb7836b913e572d34abea9106b2decc2..66e6aadc0f0afbb0a9bf7a629356ea67ecdd6ce4 100644 (file)
@@ -1399,8 +1399,10 @@ _mesa_PopClientAttrib(void)
             adjust_buffer_object_ref_counts(&ctx->Array, -1);
         
             ctx->Array.ActiveTexture = data->ActiveTexture;
-           ctx->Array.LockFirst = data->LockFirst;
-           ctx->Array.LockCount = data->LockCount;
+           if (data->LockCount != 0)
+              _mesa_LockArraysEXT(data->LockFirst, data->LockCount);
+           else
+              _mesa_UnlockArraysEXT();
 
            _mesa_BindVertexArrayAPPLE( data->ArrayObj->Name );
            
index fe4a7c684f6344bd84aa8cb94324de71e3953419..11720e4073b9fc3f0d1a16950e74058b76ec9be3 100644 (file)
@@ -809,16 +809,22 @@ _mesa_LockArraysEXT(GLint first, GLsizei count)
    if (MESA_VERBOSE & VERBOSE_API)
       _mesa_debug(ctx, "glLockArrays %d %d\n", first, count);
 
-   if (first == 0 && count > 0 &&
-       count <= (GLint) ctx->Const.MaxArrayLockSize) {
-      ctx->Array.LockFirst = first;
-      ctx->Array.LockCount = count;
+   if (first < 0) {
+      _mesa_error( ctx, GL_INVALID_VALUE, "glLockArraysEXT(first)" );
+      return;
    }
-   else {
-      ctx->Array.LockFirst = 0;
-      ctx->Array.LockCount = 0;
+   if (count <= 0) {
+      _mesa_error( ctx, GL_INVALID_VALUE, "glLockArraysEXT(count)" );
+      return;
+   }
+   if (ctx->Array.LockCount != 0) {
+      _mesa_error( ctx, GL_INVALID_OPERATION, "glLockArraysEXT(reentry)" );
+      return;
    }
 
+   ctx->Array.LockFirst = first;
+   ctx->Array.LockCount = count;
+
    ctx->NewState |= _NEW_ARRAY;
    ctx->Array.NewState |= _NEW_ARRAY_ALL;
 
@@ -836,6 +842,11 @@ _mesa_UnlockArraysEXT( void )
    if (MESA_VERBOSE & VERBOSE_API)
       _mesa_debug(ctx, "glUnlockArrays\n");
 
+   if (ctx->Array.LockCount == 0) {
+      _mesa_error( ctx, GL_INVALID_OPERATION, "glUnlockArraysEXT(reexit)" );
+      return;
+   }
+
    ctx->Array.LockFirst = 0;
    ctx->Array.LockCount = 0;
    ctx->NewState |= _NEW_ARRAY;
index 3589735f68442c2b083ff1807297158d3915cf19..bb2d21b469b71af19c1956844ea2a9353d2f8003 100644 (file)
@@ -146,6 +146,11 @@ _mesa_MultiModeDrawElementsIBM( const GLenum * mode, const GLsizei * count,
                                GLenum type, const GLvoid * const * indices,
                                GLsizei primcount, GLint modestride );
 
+extern void GLAPIENTRY
+_mesa_LockArraysEXT(GLint first, GLsizei count);
+
+extern void GLAPIENTRY
+_mesa_UnlockArraysEXT( void );
 
 extern void
 _mesa_init_varray( GLcontext * ctx );