glapi: comment-out TIMEOUT_IGNORED
[mesa.git] / src / mesa / vbo / vbo_exec_draw.c
index bfe9ef0a483550345247b89ac026219dd5f3ffa8..4f43856016cd0438c28a3215da09498940fde853 100644 (file)
@@ -35,6 +35,9 @@
 #include "vbo_context.h"
 
 
+#if FEATURE_beginend
+
+
 static void
 vbo_exec_debug_verts( struct vbo_exec_context *exec )
 {
@@ -51,7 +54,7 @@ vbo_exec_debug_verts( struct vbo_exec_context *exec )
       struct _mesa_prim *prim = &exec->vtx.prim[i];
       _mesa_printf("   prim %d: %s%s %d..%d %s %s\n",
                   i, 
-                  _mesa_lookup_enum_by_nr(prim->mode),
+                  _mesa_lookup_prim_by_nr(prim->mode),
                   prim->weak ? " (weak)" : "",
                   prim->start, 
                   prim->start + prim->count,
@@ -172,6 +175,7 @@ vbo_exec_bind_arrays( GLcontext *ctx )
          exec->vtx.inputs[attr] = &vbo->legacy_currval[attr];
       }
       for (attr = 0; attr < MAT_ATTRIB_MAX; attr++) {
+         ASSERT(attr + 16 < Elements(exec->vtx.inputs));
          exec->vtx.inputs[attr + 16] = &vbo->mat_currval[attr];
       }
       map = vbo->map_vp_none;
@@ -184,6 +188,7 @@ vbo_exec_bind_arrays( GLcontext *ctx )
        */
       for (attr = 0; attr < 16; attr++) {
          exec->vtx.inputs[attr] = &vbo->legacy_currval[attr];
+         ASSERT(attr + 16 < Elements(exec->vtx.inputs));
          exec->vtx.inputs[attr + 16] = &vbo->generic_currval[attr];
       }
       map = vbo->map_vp_arb;
@@ -212,13 +217,17 @@ vbo_exec_bind_arrays( GLcontext *ctx )
 
       if (exec->vtx.attrsz[src]) {
          /* override the default array set above */
+         ASSERT(attr < Elements(exec->vtx.inputs));
+         ASSERT(attr < Elements(exec->vtx.arrays)); /* arrays[] */
          exec->vtx.inputs[attr] = &arrays[attr];
 
-         if (exec->vtx.bufferobj->Name) {
+         if (_mesa_is_bufferobj(exec->vtx.bufferobj)) {
             /* a real buffer obj: Ptr is an offset, not a pointer*/
             GLsizeiptr offset;
             assert(exec->vtx.bufferobj->Pointer);  /* buf should be mapped */
-            offset = (GLbyte *) data - (GLbyte *) exec->vtx.bufferobj->Pointer;
+            offset = (GLbyte *) data -
+              (GLbyte *) exec->vtx.bufferobj->Pointer +
+              exec->vtx.bufferobj->Offset;
             assert(offset >= 0);
             arrays[attr].Ptr = (void *) offset;
          }
@@ -251,7 +260,7 @@ vbo_exec_vtx_unmap( struct vbo_exec_context *exec )
 {
    GLenum target = GL_ARRAY_BUFFER_ARB;
 
-   if (exec->vtx.bufferobj->Name) {
+   if (_mesa_is_bufferobj(exec->vtx.bufferobj)) {
       GLcontext *ctx = exec->ctx;
       
       if (ctx->Driver.FlushMappedBufferRange) {
@@ -291,7 +300,7 @@ vbo_exec_vtx_map( struct vbo_exec_context *exec )
                               MESA_MAP_NOWAIT_BIT;
    const GLenum usage = GL_STREAM_DRAW_ARB;
    
-   if (exec->vtx.bufferobj->Name == 0)
+   if (!_mesa_is_bufferobj(exec->vtx.bufferobj))
       return;
 
    if (exec->vtx.buffer_map != NULL) {
@@ -365,7 +374,7 @@ vbo_exec_vtx_flush( struct vbo_exec_context *exec, GLboolean unmap )
          if (ctx->NewState)
             _mesa_update_state( ctx );
 
-         if (exec->vtx.bufferobj->Name) {
+         if (_mesa_is_bufferobj(exec->vtx.bufferobj)) {
             vbo_exec_vtx_unmap( exec );
          }
 
@@ -378,12 +387,13 @@ vbo_exec_vtx_flush( struct vbo_exec_context *exec, GLboolean unmap )
                                       exec->vtx.prim, 
                                       exec->vtx.prim_count,
                                       NULL,
+                                      GL_TRUE,
                                       0,
                                       exec->vtx.vert_count - 1);
 
         /* If using a real VBO, get new storage -- unless asked not to.
           */
-         if (exec->vtx.bufferobj->Name && !unmap) {
+         if (_mesa_is_bufferobj(exec->vtx.bufferobj) && !unmap) {
             vbo_exec_vtx_map( exec );
          }
       }
@@ -392,12 +402,13 @@ vbo_exec_vtx_flush( struct vbo_exec_context *exec, GLboolean unmap )
    /* May have to unmap explicitly if we didn't draw:
     */
    if (unmap && 
-       exec->vtx.bufferobj->Name &&
+       _mesa_is_bufferobj(exec->vtx.bufferobj) &&
        exec->vtx.buffer_map) {
       vbo_exec_vtx_unmap( exec );
    }
 
-   if (unmap) 
+
+   if (unmap || exec->vtx.vertex_size == 0)
       exec->vtx.max_vert = 0;
    else
       exec->vtx.max_vert = ((VBO_VERT_BUFFER_SIZE - exec->vtx.buffer_used) / 
@@ -407,3 +418,6 @@ vbo_exec_vtx_flush( struct vbo_exec_context *exec, GLboolean unmap )
    exec->vtx.prim_count = 0;
    exec->vtx.vert_count = 0;
 }
+
+
+#endif /* FEATURE_beginend */