Merge commit 'origin/gallium-0.1' into gallium-0.2
[mesa.git] / src / mesa / vbo / vbo_exec_draw.c
index 7ec431a237694770771cb14768dbc6a994c330a8..5bf3d836db57224b8bc11d45ccc12cdc2c613e93 100644 (file)
@@ -150,6 +150,7 @@ static void vbo_exec_bind_arrays( GLcontext *ctx )
    GLubyte *data = exec->vtx.buffer_map;
    const GLuint *map;
    GLuint attr;
+   GLbitfield varying_inputs = 0x0;
 
    /* Install the default (ie Current) attributes first, then overlay
     * all active ones.
@@ -200,7 +201,6 @@ static void vbo_exec_bind_arrays( GLcontext *ctx )
             /* Ptr into ordinary app memory */
             arrays[attr].Ptr = (void *) data;
          }
-
         arrays[attr].Size = exec->vtx.attrsz[src];
         arrays[attr].StrideB = exec->vtx.vertex_size * sizeof(GLfloat);
         arrays[attr].Stride = exec->vtx.vertex_size * sizeof(GLfloat);
@@ -212,8 +212,11 @@ static void vbo_exec_bind_arrays( GLcontext *ctx )
         arrays[attr]._MaxElement = count; /* ??? */
 
         data += exec->vtx.attrsz[src] * sizeof(GLfloat);
+         varying_inputs |= 1<<attr;
       }
    }
+
+   _mesa_set_varying_vp_inputs( ctx, varying_inputs );
 }
 
 
@@ -243,8 +246,14 @@ void vbo_exec_vtx_flush( struct vbo_exec_context *exec )
          */
         vbo_exec_bind_arrays( ctx );
 
-        ctx->Driver.UnmapBuffer(ctx, target, exec->vtx.bufferobj);
-        exec->vtx.buffer_map = NULL;
+         if (ctx->NewState)
+            _mesa_update_state( ctx );
+
+         /* if using a real VBO, unmap it before drawing */
+         if (exec->vtx.bufferobj->Name) {
+            ctx->Driver.UnmapBuffer(ctx, target, exec->vtx.bufferobj);
+            exec->vtx.buffer_map = NULL;
+         }
 
         vbo_context(ctx)->draw_prims( ctx, 
                                       exec->vtx.inputs, 
@@ -254,11 +263,12 @@ void vbo_exec_vtx_flush( struct vbo_exec_context *exec )
                                       0,
                                       exec->vtx.vert_count - 1);
 
-        /* Get new data:
-         */
-        ctx->Driver.BufferData(ctx, target, size, NULL, usage, exec->vtx.bufferobj);
-        exec->vtx.buffer_map
-           = ctx->Driver.MapBuffer(ctx, target, access, exec->vtx.bufferobj);
+        /* If using a real VBO, get new storage */
+         if (exec->vtx.bufferobj->Name) {
+            ctx->Driver.BufferData(ctx, target, size, NULL, usage, exec->vtx.bufferobj);
+            exec->vtx.buffer_map = 
+               ctx->Driver.MapBuffer(ctx, target, access, exec->vtx.bufferobj);
+         }
       }
    }