Merge branch 'master' of git://anongit.freedesktop.org/mesa/mesa
[mesa.git] / src / mesa / vbo / vbo_split_copy.c
index bce401744dae7509ab8d00877aa82267a8de8721..40906e389177f229a864f5528eb6aba46b3de5cf 100644 (file)
@@ -49,7 +49,7 @@
  */
 struct copy_context {
 
-   GLcontext *ctx;
+   struct gl_context *ctx;
    const struct gl_client_array **array;
    const struct _mesa_prim *prim;
    GLuint nr_prims;
@@ -137,7 +137,7 @@ check_flush( struct copy_context *copy )
  * Dump the parameters/info for a vbo->draw() call.
  */
 static void
-dump_draw_info(GLcontext *ctx,
+dump_draw_info(struct gl_context *ctx,
                const struct gl_client_array **arrays,
                const struct _mesa_prim *prims,
                GLuint nr_prims,
@@ -196,7 +196,7 @@ flush( struct copy_context *copy )
               &copy->dstib,
               GL_TRUE,
               0,
-              copy->dstbuf_nr );
+              copy->dstbuf_nr - 1 );
 
    /* Reset all pointers: 
     */
@@ -222,6 +222,7 @@ begin( struct copy_context *copy, GLenum mode, GLboolean begin_flag )
 
    prim->mode = mode;
    prim->begin = begin_flag;
+   prim->num_instances = 1;
 }
 
 
@@ -419,7 +420,7 @@ replay_elts( struct copy_context *copy )
 static void
 replay_init( struct copy_context *copy )
 {
-   GLcontext *ctx = copy->ctx;
+   struct gl_context *ctx = copy->ctx;
    GLuint i;
    GLuint offset;
    const GLvoid *srcptr;
@@ -443,7 +444,7 @@ replay_init( struct copy_context *copy )
         copy->vertex_size += attr_size(copy->array[i]);
       
         if (_mesa_is_bufferobj(vbo) && !_mesa_bufferobj_mapped(vbo)) 
-           ctx->Driver.MapBuffer(ctx, GL_ARRAY_BUFFER, GL_READ_ONLY, vbo);
+           ctx->Driver.MapBufferRange(ctx, 0, vbo->Size, GL_MAP_READ_BIT, vbo);
 
         copy->varying[j].src_ptr = ADD_POINTERS(vbo->Pointer,
                                                 copy->array[i]->Ptr);
@@ -458,8 +459,8 @@ replay_init( struct copy_context *copy )
     */
    if (_mesa_is_bufferobj(copy->ib->obj) &&
        !_mesa_bufferobj_mapped(copy->ib->obj)) 
-      ctx->Driver.MapBuffer(ctx, GL_ELEMENT_ARRAY_BUFFER, GL_READ_ONLY,
-                           copy->ib->obj);
+      ctx->Driver.MapBufferRange(ctx, 0, copy->ib->obj->Size, GL_MAP_READ_BIT,
+                                copy->ib->obj);
 
    srcptr = (const GLubyte *) ADD_POINTERS(copy->ib->obj->Pointer,
                                            copy->ib->ptr);
@@ -518,6 +519,7 @@ replay_init( struct copy_context *copy )
       dst->Enabled = GL_TRUE;
       dst->Normalized = src->Normalized; 
       dst->BufferObj = ctx->Shared->NullBufferObj;
+      dst->_ElementSize = src->_ElementSize;
       dst->_MaxElement = copy->dstbuf_size; /* may be less! */
 
       offset += copy->varying[i].size;
@@ -548,7 +550,7 @@ replay_init( struct copy_context *copy )
 static void
 replay_finish( struct copy_context *copy )
 {
-   GLcontext *ctx = copy->ctx;
+   struct gl_context *ctx = copy->ctx;
    GLuint i;
 
    /* Free our vertex and index buffers: 
@@ -562,14 +564,14 @@ replay_finish( struct copy_context *copy )
    for (i = 0; i < copy->nr_varying; i++) {
       struct gl_buffer_object *vbo = copy->varying[i].array->BufferObj;
       if (_mesa_is_bufferobj(vbo) && _mesa_bufferobj_mapped(vbo)) 
-        ctx->Driver.UnmapBuffer(ctx, GL_ARRAY_BUFFER, vbo);
+        ctx->Driver.UnmapBuffer(ctx, vbo);
    }
 
    /* Unmap index buffer:
     */
    if (_mesa_is_bufferobj(copy->ib->obj) &&
        _mesa_bufferobj_mapped(copy->ib->obj)) {
-      ctx->Driver.UnmapBuffer(ctx, GL_ELEMENT_ARRAY_BUFFER, copy->ib->obj);
+      ctx->Driver.UnmapBuffer(ctx, copy->ib->obj);
    }
 }
 
@@ -577,7 +579,7 @@ replay_finish( struct copy_context *copy )
 /**
  * Split VBO into smaller pieces, draw the pieces.
  */
-void vbo_split_copy( GLcontext *ctx,
+void vbo_split_copy( struct gl_context *ctx,
                     const struct gl_client_array *arrays[],
                     const struct _mesa_prim *prim,
                     GLuint nr_prims,