mesa: don't ever set NullBufferObj in gl_vertex_array_binding
[mesa.git] / src / mesa / main / draw.c
index c77bbade008678846a321dce2c3fb4543c568d9c..5bb254e00d2621191b064096518ecca22afca963 100644 (file)
@@ -90,7 +90,7 @@ check_array_data(struct gl_context *ctx, struct gl_vertex_array_object *vao,
                          array->Format.Type, array->Format.Size,
                          binding->Stride);
                   printf("  Address/offset %p in Buffer Object %u\n",
-                         array->Ptr, bo->Name);
+                         array->Ptr, bo ? bo->Name : 0);
                   f[k] = 1.0F;  /* XXX replace the bad value! */
                }
                /*assert(!IS_INF_OR_NAN(f[k])); */
@@ -255,7 +255,7 @@ print_draw_arrays(struct gl_context *ctx,
              "ptr %p  Bufobj %u\n",
              gl_vert_attrib_name((gl_vert_attrib) i),
              array->Format.Size, binding->Stride,
-             array->Ptr, bufObj->Name);
+             array->Ptr, bufObj ? bufObj->Name : 0);
 
       if (_mesa_is_bufferobj(bufObj)) {
          GLubyte *p = bufObj->Mappings[MAP_INTERNAL].Pointer;
@@ -1216,12 +1216,18 @@ _mesa_validated_multidrawelements(struct gl_context *ctx, GLenum mode,
       }
    }
 
-   /* If the index buffer isn't in a VBO, then treating the application's
-    * subranges of the index buffer as one large index buffer may lead to
-    * us reading unmapped memory.
-    */
-   if (!_mesa_is_bufferobj(ctx->Array.VAO->IndexBufferObj))
-      fallback = GL_TRUE;
+   if (ctx->Const.MultiDrawWithUserIndices) {
+      /* Check whether prim[i].start would overflow. */
+      if (((max_index_ptr - min_index_ptr) >> ib.index_size_shift) > UINT_MAX)
+         fallback = GL_TRUE;
+   } else {
+      /* If the index buffer isn't in a VBO, then treating the application's
+       * subranges of the index buffer as one large index buffer may lead to
+       * us reading unmapped memory.
+       */
+      if (!_mesa_is_bufferobj(ctx->Array.VAO->IndexBufferObj))
+         fallback = GL_TRUE;
+   }
 
    if (!fallback) {
       struct _mesa_prim *prim;