mesa: move readbuffer tests
[mesa.git] / src / mesa / main / state.c
index 7b41b8f4da479f862518eeaae04633bc83b0250c..140a998df2ec82a5cc267f8c6a4955d6db33c9ce 100644 (file)
@@ -75,6 +75,16 @@ compute_max_element(struct gl_client_array *array)
 {
    assert(array->Enabled);
    if (array->BufferObj->Name) {
+      GLsizeiptrARB offset = (GLsizeiptrARB) array->Ptr;
+      GLsizeiptrARB obj_size = (GLsizeiptrARB) array->BufferObj->Size;
+
+      if (offset < obj_size) {
+        array->_MaxElement = (obj_size - offset +
+                              array->StrideB -
+                              array->_ElementSize) / array->StrideB;
+      } else {
+        array->_MaxElement = 0;
+      }
       /* Compute the max element we can access in the VBO without going
        * out of bounds.
        */
@@ -536,8 +546,9 @@ _mesa_update_state_locked( GLcontext *ctx )
 
    /* Determine which state flags effect vertex/fragment program state */
    if (ctx->FragmentProgram._MaintainTexEnvProgram) {
-      prog_flags |= (_NEW_TEXTURE | _NEW_FOG | _DD_NEW_SEPARATE_SPECULAR |
-                    _NEW_ARRAY);
+      prog_flags |= (_NEW_TEXTURE | _NEW_FOG |
+                    _NEW_ARRAY | _NEW_LIGHT | _NEW_POINT | _NEW_RENDERMODE |
+                    _NEW_PROGRAM);
    }
    if (ctx->VertexProgram._MaintainTnlProgram) {
       prog_flags |= (_NEW_ARRAY | _NEW_TEXTURE | _NEW_TEXTURE_MATRIX |
@@ -702,6 +713,6 @@ _mesa_set_vp_override(GLcontext *ctx, GLboolean flag)
       /* Set one of the bits which will trigger fragment program
        * regeneration:
        */
-      ctx->NewState |= _NEW_ARRAY; 
+      ctx->NewState |= _NEW_PROGRAM;
    }
 }