mesa: avoid valgrind warning due to opaque only being set sometimes
[mesa.git] / src / mesa / main / bufferobj.c
index 22073dd28b81b6adfcc1266123aca29275a4c376..885a99decf436e377827c37eb8fcefae14fc327b 100644 (file)
@@ -44,6 +44,7 @@
 #include "glformats.h"
 #include "texstore.h"
 #include "transformfeedback.h"
+#include "varray.h"
 
 
 /* Debug flags */
@@ -1020,7 +1021,8 @@ bind_buffer_object(struct gl_context *ctx, GLenum target, GLuint buffer)
 
    bindTarget = get_buffer_target(ctx, target);
    if (!bindTarget) {
-      _mesa_error(ctx, GL_INVALID_ENUM, "glBindBufferARB(target 0x%x)", target);
+      _mesa_error(ctx, GL_INVALID_ENUM, "glBindBufferARB(target %s)",
+                  _mesa_enum_to_string(target));
       return;
    }
 
@@ -1198,11 +1200,13 @@ _mesa_multi_bind_lookup_bufferobj(struct gl_context *ctx,
  */
 static void
 unbind(struct gl_context *ctx,
-       struct gl_buffer_object **ptr,
+       struct gl_vertex_array_object *vao, unsigned index,
        struct gl_buffer_object *obj)
 {
-   if (*ptr == obj) {
-      _mesa_reference_buffer_object(ctx, ptr, ctx->Shared->NullBufferObj);
+   if (vao->VertexBinding[index].BufferObj == obj) {
+      _mesa_bind_vertex_buffer(ctx, vao, index, ctx->Shared->NullBufferObj,
+                               vao->VertexBinding[index].Offset,
+                               vao->VertexBinding[index].Stride);
    }
 }
 
@@ -1301,7 +1305,7 @@ _mesa_DeleteBuffers(GLsizei n, const GLuint *ids)
 
          /* unbind any vertex pointers bound to this buffer */
          for (j = 0; j < ARRAY_SIZE(vao->VertexBinding); j++) {
-            unbind(ctx, &vao->VertexBinding[j].BufferObj, bufObj);
+            unbind(ctx, vao, j, bufObj);
          }
 
          if (ctx->Array.ArrayBufferObj == bufObj) {
@@ -1764,7 +1768,7 @@ _mesa_buffer_sub_data(struct gl_context *ctx, struct gl_buffer_object *bufObj,
                       const char *func)
 {
    if (!buffer_object_subdata_range_good(ctx, bufObj, offset, size,
-                                         false, func)) {
+                                         true, func)) {
       /* error already recorded */
       return;
    }
@@ -3966,7 +3970,7 @@ _mesa_InvalidateBufferSubData(GLuint buffer, GLintptr offset,
    bufObj = _mesa_lookup_bufferobj(ctx, buffer);
    if (!bufObj || bufObj == &DummyBufferObject) {
       _mesa_error(ctx, GL_INVALID_VALUE,
-                  "glInvalidateBufferSubData(name = 0x%x) invalid object",
+                  "glInvalidateBufferSubData(name = %u) invalid object",
                   buffer);
       return;
    }
@@ -4017,7 +4021,7 @@ _mesa_InvalidateBufferData(GLuint buffer)
    bufObj = _mesa_lookup_bufferobj(ctx, buffer);
    if (!bufObj || bufObj == &DummyBufferObject) {
       _mesa_error(ctx, GL_INVALID_VALUE,
-                  "glInvalidateBufferData(name = 0x%x) invalid object",
+                  "glInvalidateBufferData(name = %u) invalid object",
                   buffer);
       return;
    }