radeon/r200/r300: don't clean non-emitted state.
[mesa.git] / src / mesa / vbo / vbo_save_draw.c
index 617c5a77baf28b3e09d08d40b7f13f5ab233e7e0..d834fa1f2e75994d76d33a1b9c67b52102b2eb0d 100644 (file)
@@ -46,20 +46,31 @@ static void _playback_copy_to_current( GLcontext *ctx,
                                       const struct vbo_save_vertex_list *node )
 {
    struct vbo_context *vbo = vbo_context(ctx);
-   GLfloat vertex[VBO_ATTRIB_MAX * 4], *data = vertex;
+   GLfloat vertex[VBO_ATTRIB_MAX * 4];
+   GLfloat *data;
    GLuint i, offset;
 
-   if (node->count)
-      offset = (node->buffer_offset + 
-               (node->count-1) * node->vertex_size * sizeof(GLfloat));
-   else
-      offset = node->buffer_offset;
+   if (node->current_size == 0)
+      return;
 
-   ctx->Driver.GetBufferSubData( ctx, 0, offset, 
-                                node->vertex_size * sizeof(GLfloat), 
-                                data, node->vertex_store->bufferobj );
+   if (node->current_data) {
+      data = node->current_data;
+   }
+   else {
+      data = vertex;
+
+      if (node->count)
+         offset = (node->buffer_offset + 
+                   (node->count-1) * node->vertex_size * sizeof(GLfloat));
+      else
+         offset = node->buffer_offset;
 
-   data += node->attrsz[0]; /* skip vertex position */
+      ctx->Driver.GetBufferSubData( ctx, 0, offset, 
+                                    node->vertex_size * sizeof(GLfloat), 
+                                    data, node->vertex_store->bufferobj );
+
+      data += node->attrsz[0]; /* skip vertex position */
+   }
 
    for (i = VBO_ATTRIB_POS+1 ; i < VBO_ATTRIB_MAX ; i++) {
       if (node->attrsz[i]) {
@@ -115,7 +126,7 @@ static void vbo_bind_vertex_list( GLcontext *ctx,
    struct vbo_context *vbo = vbo_context(ctx);
    struct vbo_save_context *save = &vbo->save;
    struct gl_client_array *arrays = save->arrays;
-   GLuint data = node->buffer_offset;
+   GLuint buffer_offset = node->buffer_offset;
    const GLuint *map;
    GLuint attr;
    GLubyte node_attrsz[VBO_ATTRIB_MAX];  /* copy of node->attrsz[] */
@@ -170,7 +181,7 @@ static void vbo_bind_vertex_list( GLcontext *ctx,
          /* override the default array set above */
          save->inputs[attr] = &arrays[attr];
 
-        arrays[attr].Ptr = (const GLubyte *) data;
+        arrays[attr].Ptr = (const GLubyte *) NULL + buffer_offset;
         arrays[attr].Size = node->attrsz[src];
         arrays[attr].StrideB = node->vertex_size * sizeof(GLfloat);
         arrays[attr].Stride = node->vertex_size * sizeof(GLfloat);
@@ -184,7 +195,7 @@ static void vbo_bind_vertex_list( GLcontext *ctx,
         
         assert(arrays[attr].BufferObj->Name);
 
-        data += node->attrsz[src] * sizeof(GLfloat);
+        buffer_offset += node->attrsz[src] * sizeof(GLfloat);
          varying_inputs |= 1<<attr;
       }
    }
@@ -268,6 +279,7 @@ void vbo_save_playback_vertex_list( GLcontext *ctx, void *data )
                                    node->prim, 
                                    node->prim_count,
                                    NULL,
+                                   GL_TRUE,
                                    0,  /* Node is a VBO, so this is ok */
                                    node->count - 1);
    }