mesa: Eliminate dd_function_table::MapBuffer
authorIan Romanick <ian.d.romanick@intel.com>
Mon, 22 Aug 2011 01:34:27 +0000 (18:34 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Tue, 23 Aug 2011 21:52:11 +0000 (14:52 -0700)
Replace all calls to dd_function_table::MapBuffer with appropriate
calls to dd_function_table::MapBufferRange, then remove all the cruft.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Acked-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
24 files changed:
src/mesa/drivers/dri/i965/brw_draw_upload.c
src/mesa/drivers/dri/intel/intel_buffer_objects.c
src/mesa/drivers/dri/intel/intel_pixel_bitmap.c
src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c
src/mesa/drivers/dri/r300/r300_draw.c
src/mesa/drivers/dri/r600/evergreen_render.c
src/mesa/drivers/dri/r600/r700_render.c
src/mesa/drivers/dri/radeon/radeon_buffer_objects.c
src/mesa/drivers/x11/xm_dd.c
src/mesa/main/api_arrayelt.c
src/mesa/main/api_validate.c
src/mesa/main/bufferobj.c
src/mesa/main/dd.h
src/mesa/main/dlist.c
src/mesa/main/pbo.c
src/mesa/main/texgetimage.c
src/mesa/state_tracker/st_cb_bufferobjects.c
src/mesa/tnl/t_draw.c
src/mesa/vbo/vbo_exec_array.c
src/mesa/vbo/vbo_exec_draw.c
src/mesa/vbo/vbo_rebase.c
src/mesa/vbo/vbo_save_api.c
src/mesa/vbo/vbo_save_draw.c
src/mesa/vbo/vbo_split_copy.c

index 9acec45799a6c8b3bd5f0a0cc4e538ec07a7422e..ed1964f5a6fcc2a349db8d18a2926b7d36c97d4e 100644 (file)
@@ -689,7 +689,11 @@ static void brw_prepare_indices(struct brw_context *brw)
        * rebase it into a temporary.
        */
        if ((get_size(index_buffer->type) - 1) & offset) {
-           GLubyte *map = ctx->Driver.MapBuffer(ctx, GL_WRITE_ONLY, bufferobj);
+           GLubyte *map = ctx->Driver.MapBufferRange(ctx,
+                                                    0,
+                                                    bufferobj->Size,
+                                                    GL_MAP_WRITE_BIT,
+                                                    bufferobj);
            map += offset;
 
           intel_upload_data(&brw->intel, map, ib_size, ib_type_size,
index 1a0f5486c4f2d996b7a83c9909b6d6c59552d98d..d908975fc87a03ca11f0502e3524f0d08e21741d 100644 (file)
@@ -295,64 +295,7 @@ intel_bufferobj_get_subdata(struct gl_context * ctx,
 
 
 /**
- * Called via glMapBufferARB().
- */
-static void *
-intel_bufferobj_map(struct gl_context * ctx,
-                    GLenum access, struct gl_buffer_object *obj)
-{
-   struct intel_context *intel = intel_context(ctx);
-   struct intel_buffer_object *intel_obj = intel_buffer_object(obj);
-   GLboolean read_only = (access == GL_READ_ONLY_ARB);
-   GLboolean write_only = (access == GL_WRITE_ONLY_ARB);
-
-   assert(intel_obj);
-
-   if (intel_obj->sys_buffer) {
-      if (!read_only && intel_obj->source) {
-        release_buffer(intel_obj);
-      }
-
-      if (!intel_obj->buffer || intel_obj->source) {
-        obj->Pointer = intel_obj->sys_buffer;
-        obj->Length = obj->Size;
-        obj->Offset = 0;
-        return obj->Pointer;
-      }
-
-      free(intel_obj->sys_buffer);
-      intel_obj->sys_buffer = NULL;
-   }
-
-   /* Flush any existing batchbuffer that might reference this data. */
-   if (drm_intel_bo_references(intel->batch.bo, intel_obj->buffer))
-      intel_flush(ctx);
-
-   if (intel_obj->region)
-      intel_bufferobj_cow(intel, intel_obj);
-
-   if (intel_obj->buffer == NULL) {
-      obj->Pointer = NULL;
-      return NULL;
-   }
-
-   if (write_only) {
-      drm_intel_gem_bo_map_gtt(intel_obj->buffer);
-      intel_obj->mapped_gtt = GL_TRUE;
-   } else {
-      drm_intel_bo_map(intel_obj->buffer, !read_only);
-      intel_obj->mapped_gtt = GL_FALSE;
-   }
-
-   obj->Pointer = intel_obj->buffer->virtual;
-   obj->Length = obj->Size;
-   obj->Offset = 0;
-
-   return obj->Pointer;
-}
-
-/**
- * Called via glMapBufferRange().
+ * Called via glMapBufferRange and glMapBuffer
  *
  * The goal of this extension is to allow apps to accumulate their rendering
  * at the same time as they accumulate their buffer object.  Without it,
@@ -760,15 +703,18 @@ intel_bufferobj_copy_subdata(struct gl_context *ctx,
        * not overlap.
        */
       if (src == dst) {
-        char *ptr = intel_bufferobj_map(ctx, GL_READ_WRITE, dst);
+        char *ptr = intel_bufferobj_map_range(ctx, 0, dst->Size,
+                                              GL_MAP_READ_BIT, dst);
         memmove(ptr + write_offset, ptr + read_offset, size);
         intel_bufferobj_unmap(ctx, dst);
       } else {
         const char *src_ptr;
         char *dst_ptr;
 
-        src_ptr =  intel_bufferobj_map(ctx, GL_READ_ONLY, src);
-        dst_ptr =  intel_bufferobj_map(ctx, GL_WRITE_ONLY, dst);
+        src_ptr =  intel_bufferobj_map_range(ctx, 0, src->Size,
+                                             GL_MAP_READ_BIT, src);
+        dst_ptr =  intel_bufferobj_map_range(ctx, 0, dst->Size,
+                                             GL_MAP_WRITE_BIT, dst);
 
         memcpy(dst_ptr + write_offset, src_ptr + read_offset, size);
 
@@ -923,7 +869,6 @@ intelInitBufferObjectFuncs(struct dd_function_table *functions)
    functions->BufferData = intel_bufferobj_data;
    functions->BufferSubData = intel_bufferobj_subdata;
    functions->GetBufferSubData = intel_bufferobj_get_subdata;
-   functions->MapBuffer = intel_bufferobj_map;
    functions->MapBufferRange = intel_bufferobj_map_range;
    functions->FlushMappedBufferRange = intel_bufferobj_flush_mapped_range;
    functions->UnmapBuffer = intel_bufferobj_unmap;
index 44d79534ffdb2da71a47393dda08756e712d1587..d9873a303eed17c7bc8099d3e6b92cadec84f4a5 100644 (file)
@@ -74,9 +74,9 @@ static const GLubyte *map_pbo( struct gl_context *ctx,
       return NULL;
    }
 
-   buf = (GLubyte *) ctx->Driver.MapBuffer(ctx,
-                                          GL_READ_ONLY_ARB,
-                                          unpack->BufferObj);
+   buf = (GLubyte *) ctx->Driver.MapBufferRange(ctx, 0, unpack->BufferObj->Size,
+                                               GL_MAP_READ_BIT,
+                                               unpack->BufferObj);
    if (!buf) {
       _mesa_error(ctx, GL_INVALID_OPERATION, "glBitmap(PBO is mapped)");
       return NULL;
index cf892a893f864eb27c3e40dca5fc7389c46133a4..433590c41813c9289fd5b6c50a29e76024f347fe 100644 (file)
@@ -122,22 +122,6 @@ nouveau_bufferobj_get_subdata(struct gl_context *ctx, GLintptrARB offset,
        memcpy(data, get_bufferobj_map(obj, NOUVEAU_BO_RD) + offset, size);
 }
 
-static void *
-nouveau_bufferobj_map(struct gl_context *ctx, GLenum access,
-                  struct gl_buffer_object *obj)
-{
-       unsigned flags = 0;
-
-       if (access == GL_READ_ONLY_ARB ||
-           access == GL_READ_WRITE_ARB)
-               flags |= GL_MAP_READ_BIT;
-       if (access == GL_WRITE_ONLY_ARB ||
-           access == GL_READ_WRITE_ARB)
-               flags |= GL_MAP_WRITE_BIT;
-
-       return ctx->Driver.MapBufferRange(ctx, 0, obj->Size, flags, obj);
-}
-
 static void *
 nouveau_bufferobj_map_range(struct gl_context *ctx, GLenum target, GLintptr offset,
                            GLsizeiptr length, GLbitfield access,
@@ -188,7 +172,6 @@ nouveau_bufferobj_functions_init(struct dd_function_table *functions)
        functions->BufferData = nouveau_bufferobj_data;
        functions->BufferSubData = nouveau_bufferobj_subdata;
        functions->GetBufferSubData = nouveau_bufferobj_get_subdata;
-       functions->MapBuffer = nouveau_bufferobj_map;
        functions->MapBufferRange = nouveau_bufferobj_map_range;
        functions->UnmapBuffer = nouveau_bufferobj_unmap;
 }
index ba37923736c37303fcf5420d7bdee1990ba5469e..5587c16dd44680bac9495bdc8c945d8aa7dbd9b3 100644 (file)
@@ -84,7 +84,8 @@ static void r300FixupIndexBuffer(struct gl_context *ctx, const struct _mesa_inde
        GLboolean mapped_named_bo = GL_FALSE;
 
        if (mesa_ind_buf->obj->Name && !mesa_ind_buf->obj->Pointer) {
-               ctx->Driver.MapBuffer(ctx, GL_READ_ONLY_ARB, mesa_ind_buf->obj);
+               ctx->Driver.MapBufferRange(ctx, 0, mesa_ind_buf->obj->Size,
+                                          GL_MAP_READ_BIT, mesa_ind_buf->obj);
                mapped_named_bo = GL_TRUE;
                assert(mesa_ind_buf->obj->Pointer != NULL);
        }
@@ -163,7 +164,10 @@ static void r300SetupIndexBuffer(struct gl_context *ctx, const struct _mesa_inde
                GLboolean mapped_named_bo = GL_FALSE;
 
                if (mesa_ind_buf->obj->Name && !mesa_ind_buf->obj->Pointer) {
-                       ctx->Driver.MapBuffer(ctx, GL_READ_ONLY_ARB, mesa_ind_buf->obj);
+                       ctx->Driver.MapBufferRange(ctx, 0,
+                                                  mesa_ind_buf->obj->Size,
+                                                  GL_MAP_READ_BIT,
+                                                  mesa_ind_buf->obj);
                        assert(mesa_ind_buf->obj->Pointer != NULL);
                        mapped_named_bo = GL_TRUE;
                }
@@ -235,7 +239,8 @@ static void r300ConvertAttrib(struct gl_context *ctx, int count, const struct gl
 
        if (input->BufferObj->Name) {
                if (!input->BufferObj->Pointer) {
-                       ctx->Driver.MapBuffer(ctx, GL_READ_ONLY_ARB, input->BufferObj);
+                       ctx->Driver.MapBufferRange(ctx, 0, input->BufferObj->Size,
+                                             GL_MAP_READ_BIT, input->BufferObj);
                        mapped_named_bo = GL_TRUE;
                }
 
@@ -302,7 +307,8 @@ static void r300AlignDataToDword(struct gl_context *ctx, const struct gl_client_
        radeon_bo_map(attr->bo, 1);
 
        if (!input->BufferObj->Pointer) {
-               ctx->Driver.MapBuffer(ctx, GL_READ_ONLY_ARB, input->BufferObj);
+               ctx->Driver.MapBufferRange(ctx, 0, input->BufferObj->Size,
+                                          GL_MAP_READ_BIT, input->BufferObj);
                mapped_named_bo = GL_TRUE;
        }
 
index e82f4d445f59b6018f47f53203e2e479d42a2515..74563caf47c9cf0bfb2576a49a12b9db9e05eb6b 100644 (file)
@@ -403,7 +403,8 @@ static void evergreenConvertAttrib(struct gl_context *ctx, int count,
     {
         if (!input->BufferObj->Pointer) 
         {
-            ctx->Driver.MapBuffer(ctx, GL_READ_ONLY_ARB, input->BufferObj);
+           ctx->Driver.MapBufferRange(ctx, 0, input->BufferObj->Size,
+                                      GL_MAP_READ_BIT, input->BufferObj);
             mapped_named_bo = GL_TRUE;
         }
 
@@ -470,7 +471,8 @@ static void evergreenFixupIndexBuffer(struct gl_context *ctx, const struct _mesa
 
     if (mesa_ind_buf->obj->Name && !mesa_ind_buf->obj->Pointer)
     {
-        ctx->Driver.MapBuffer(ctx, GL_READ_ONLY_ARB, mesa_ind_buf->obj);
+        ctx->Driver.MapBufferRange(ctx, 0, mesa_ind_buf->obj->Size,
+                                  GL_MAP_READ_BIT, mesa_ind_buf->obj);
         mapped_named_bo = GL_TRUE;
         assert(mesa_ind_buf->obj->Pointer != NULL);
     }
@@ -606,7 +608,8 @@ static void evergreenSetupIndexBuffer(struct gl_context *ctx, const struct _mesa
 
         if (mesa_ind_buf->obj->Name && !mesa_ind_buf->obj->Pointer)
         {
-               ctx->Driver.MapBuffer(ctx, GL_READ_ONLY_ARB, mesa_ind_buf->obj);
+               ctx->Driver.MapBufferRange(ctx, 0, mesa_ind_buf->obj->Size,
+                                          GL_MAP_READ_BIT, mesa_ind_buf->obj);
                assert(mesa_ind_buf->obj->Pointer != NULL);
                mapped_named_bo = GL_TRUE;
         }
@@ -655,7 +658,8 @@ static void evergreenAlignDataToDword(struct gl_context *ctx,
 
     if (!input->BufferObj->Pointer) 
     {
-        ctx->Driver.MapBuffer(ctx, GL_READ_ONLY_ARB, input->BufferObj);
+       ctx->Driver.MapBufferRange(ctx, 0, input->BufferObj->Size,
+                                  GL_MAP_READ_BIT, input->BufferObj->obj);
         mapped_named_bo = GL_TRUE;
     }
 
index 52a6f7cc45e399d914b6b61e4454409bd732a564..a565c9f2087da0f4d25a03c3b9c9bc737ee29909 100644 (file)
@@ -490,7 +490,8 @@ static void r700ConvertAttrib(struct gl_context *ctx, int count,
     {
         if (!input->BufferObj->Pointer) 
         {
-            ctx->Driver.MapBuffer(ctx, GL_READ_ONLY_ARB, input->BufferObj);
+          ctx->Driver.MapBufferRange(ctx, 0, input->BufferObj->Size,
+                                     GL_MAP_READ_BIT, input->BufferObj);
             mapped_named_bo = GL_TRUE;
         }
 
@@ -564,7 +565,8 @@ static void r700AlignDataToDword(struct gl_context *ctx,
 
     if (!input->BufferObj->Pointer) 
     {
-        ctx->Driver.MapBuffer(ctx, GL_READ_ONLY_ARB, input->BufferObj);
+        ctx->Driver.MapBufferRange(ctx, 0, input->BufferObj->Size,
+                                  GL_MAP_READ_BIT, input->BufferObj);
         mapped_named_bo = GL_TRUE;
     }
 
@@ -727,7 +729,8 @@ static void r700FixupIndexBuffer(struct gl_context *ctx, const struct _mesa_inde
 
     if (mesa_ind_buf->obj->Name && !mesa_ind_buf->obj->Pointer)
     {
-        ctx->Driver.MapBuffer(ctx, GL_READ_ONLY_ARB, mesa_ind_buf->obj);
+       ctx->Driver.MapBufferRange(ctx, 0, mesa_ind_buf->obj->Size,
+                                  GL_MAP_READ_BIT, mesa_ind_buf->obj);
         mapped_named_bo = GL_TRUE;
         assert(mesa_ind_buf->obj->Pointer != NULL);
     }
@@ -813,7 +816,8 @@ static void r700SetupIndexBuffer(struct gl_context *ctx, const struct _mesa_inde
 
         if (mesa_ind_buf->obj->Name && !mesa_ind_buf->obj->Pointer)
         {
-               ctx->Driver.MapBuffer(ctx, GL_READ_ONLY_ARB, mesa_ind_buf->obj);
+               ctx->Driver.MapBufferRange(ctx, 0, mesa_ind_buf->obj->Size,
+                                          GL_MAP_READ_BIT, mesa_ind_buf->obj);
                assert(mesa_ind_buf->obj->Pointer != NULL);
                mapped_named_bo = GL_TRUE;
         }
index e106d98c38e4d82e0040d37be1675475897dd856..7b59c0377f8dd73687952c5fd9b679ae4ad8506b 100644 (file)
@@ -169,36 +169,7 @@ radeonGetBufferSubData(struct gl_context * ctx,
 }
 
 /**
- * Called via glMapBufferARB()
- */
-static void *
-radeonMapBuffer(struct gl_context * ctx,
-                GLenum access,
-                struct gl_buffer_object *obj)
-{
-    struct radeon_buffer_object *radeon_obj = get_radeon_buffer_object(obj);
-
-    if (access == GL_WRITE_ONLY_ARB) {
-        ctx->Driver.Flush(ctx);
-    }
-
-    if (radeon_obj->bo == NULL) {
-        obj->Pointer = NULL;
-        return NULL;
-    }
-
-    radeon_bo_map(radeon_obj->bo, access == GL_WRITE_ONLY_ARB);
-
-    obj->Pointer = radeon_obj->bo->ptr;
-    obj->Length = obj->Size;
-    obj->Offset = 0;
-
-    return obj->Pointer;
-}
-
-
-/**
- * Called via glMapBufferRange()
+ * Called via glMapBuffer() and glMapBufferRange()
  */
 static void *
 radeonMapBufferRange(struct gl_context * ctx,
@@ -257,7 +228,6 @@ radeonInitBufferObjectFuncs(struct dd_function_table *functions)
     functions->BufferData = radeonBufferData;
     functions->BufferSubData = radeonBufferSubData;
     functions->GetBufferSubData = radeonGetBufferSubData;
-    functions->MapBuffer = radeonMapBuffer;
     functions->MapBufferRange = radeonMapBufferRange;
     functions->UnmapBuffer = radeonUnmapBuffer;
 }
index fe00bdd520d607e74e9dd9d444993ae6d23b0189..3a5d0ae04fcb2a07466cc2a33b5b3cc9589d806c 100644 (file)
@@ -454,9 +454,10 @@ xmesa_DrawPixels_8R8G8B( struct gl_context *ctx,
                         "glDrawPixels(invalid PBO access)");
             return;
          }
-         buf = (GLubyte *) ctx->Driver.MapBuffer(ctx,
-                                                 GL_READ_ONLY_ARB,
-                                                 unpack->BufferObj);
+         buf = (GLubyte *) ctx->Driver.MapBufferRange(ctx, 0,
+                                                     unpack->BufferObj->Size,
+                                                     GL_MAP_READ_BIT,
+                                                     unpack->BufferObj);
          if (!buf) {
             /* buffer is already mapped - that's an error */
             _mesa_error(ctx, GL_INVALID_OPERATION,
@@ -587,10 +588,10 @@ xmesa_DrawPixels_5R6G5B( struct gl_context *ctx,
                         "glDrawPixels(invalid PBO access)");
             return;
          }
-         buf = (GLubyte *) ctx->Driver.MapBuffer(ctx,
-                                                 GL_PIXEL_UNPACK_BUFFER_EXT,
-                                                 GL_READ_ONLY_ARB,
-                                                 unpack->BufferObj);
+         buf = (GLubyte *) ctx->Driver.MapBufferRange(ctx, 0
+                                                     unpack->BufferObj->Size,
+                                                     GL_MAP_READ_BIT,
+                                                     unpack->BufferObj);
          if (!buf) {
             /* buffer is already mapped - that's an error */
             _mesa_error(ctx, GL_INVALID_OPERATION,
index 8e1e3ff8dd59e0674d8b14350a0178ab2980524a..b93a057e68bfe4d05efa72a08e7fc3d3351f4d26 100644 (file)
@@ -1602,7 +1602,10 @@ void _ae_map_vbos( struct gl_context *ctx )
       _ae_update_state(ctx);
 
    for (i = 0; i < actx->nr_vbos; i++)
-      ctx->Driver.MapBuffer(ctx, GL_READ_ONLY, actx->vbo[i]);
+      ctx->Driver.MapBufferRange(ctx, 0,
+                                actx->vbo[i]->Size,
+                                GL_MAP_READ_BIT,
+                                actx->vbo[i]);
 
    if (actx->nr_vbos)
       actx->mapped_vbos = GL_TRUE;
index 507d0ce6883cada1813958c2c213c49c3f40fd7f..699b414f5021581e687e0fa8c5ca7ca2c7ebedd7 100644 (file)
@@ -65,7 +65,8 @@ _mesa_max_buffer_index(struct gl_context *ctx, GLuint count, GLenum type,
 
    if (_mesa_is_bufferobj(elementBuf)) {
       /* elements are in a user-defined buffer object.  need to map it */
-      map = ctx->Driver.MapBuffer(ctx, GL_READ_ONLY, elementBuf);
+      map = ctx->Driver.MapBufferRange(ctx, 0, elementBuf->Size,
+                                      GL_MAP_READ_BIT, elementBuf);
       /* Actual address is the sum of pointers */
       indices = (const GLvoid *) ADD_POINTERS(map, (const GLubyte *) indices);
    }
index 47af8b59587a42063948e365efabcc09461e9229..c453f9c8554dc8198ba13071f24342ad212b2dc6 100644 (file)
@@ -431,38 +431,6 @@ _mesa_buffer_get_subdata( struct gl_context *ctx, GLintptrARB offset,
 }
 
 
-/**
- * Default callback for \c dd_function_tabel::MapBuffer().
- *
- * The function parameters will have been already tested for errors.
- *
- * \param ctx     GL context.
- * \param target  Buffer object target on which to operate.
- * \param access  Information about how the buffer will be accessed.
- * \param bufObj  Object to be mapped.
- * \return  A pointer to the object's internal data store that can be accessed
- *          by the processor
- *
- * \sa glMapBufferARB, dd_function_table::MapBuffer
- */
-static void *
-_mesa_buffer_map( struct gl_context *ctx, GLenum access,
-                 struct gl_buffer_object *bufObj )
-{
-   (void) ctx;
-   (void) access;
-   /* Just return a direct pointer to the data */
-   if (_mesa_bufferobj_mapped(bufObj)) {
-      /* already mapped! */
-      return NULL;
-   }
-   bufObj->Pointer = bufObj->Data;
-   bufObj->Length = bufObj->Size;
-   bufObj->Offset = 0;
-   return bufObj->Pointer;
-}
-
-
 /**
  * Default fallback for \c dd_function_table::MapBufferRange().
  * Called via glMapBufferRange().
@@ -537,8 +505,10 @@ _mesa_copy_buffer_subdata(struct gl_context *ctx,
    assert(!_mesa_bufferobj_mapped(src));
    assert(!_mesa_bufferobj_mapped(dst));
 
-   srcPtr = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_READ_ONLY, src);
-   dstPtr = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_WRITE_ONLY, dst);
+   srcPtr = (GLubyte *) ctx->Driver.MapBufferRange(ctx, 0, src->Size,
+                                                  GL_MAP_READ_BIT, src);
+   dstPtr = (GLubyte *) ctx->Driver.MapBufferRange(ctx, 0, dst->Size,
+                                                  GL_MAP_WRITE_BIT, dst);
 
    if (srcPtr && dstPtr)
       memcpy(dstPtr + writeOffset, srcPtr + readOffset, size);
@@ -704,7 +674,6 @@ _mesa_init_buffer_object_functions(struct dd_function_table *driver)
    driver->BufferData = _mesa_buffer_data;
    driver->BufferSubData = _mesa_buffer_subdata;
    driver->GetBufferSubData = _mesa_buffer_get_subdata;
-   driver->MapBuffer = _mesa_buffer_map;
    driver->UnmapBuffer = _mesa_buffer_unmap;
 
    /* GL_ARB_map_buffer_range */
@@ -1035,8 +1004,8 @@ _mesa_MapBufferARB(GLenum target, GLenum access)
       return NULL;
    }
 
-   ASSERT(ctx->Driver.MapBuffer);
-   map = ctx->Driver.MapBuffer( ctx, access, bufObj );
+   ASSERT(ctx->Driver.MapBufferRange);
+   map = ctx->Driver.MapBufferRange(ctx, 0, bufObj->Size, accessFlags, bufObj);
    if (!map) {
       _mesa_error(ctx, GL_OUT_OF_MEMORY, "glMapBufferARB(map failed)");
       return NULL;
index 8dfea937f3717ea9a1d8d696b1c3b9cc1c1df20e..fcf40ecf102be7b383b2d77d930737f45d4cff3d 100644 (file)
@@ -706,9 +706,6 @@ struct dd_function_table {
                             GLintptrARB offset, GLsizeiptrARB size,
                             GLvoid *data, struct gl_buffer_object *obj );
 
-   void * (*MapBuffer)( struct gl_context *ctx, GLenum access,
-                       struct gl_buffer_object *obj );
-
    void (*CopyBufferSubData)( struct gl_context *ctx,
                               struct gl_buffer_object *src,
                               struct gl_buffer_object *dst,
index a135810ed276a36b764612aeccb3e6bd297f8712..6e075b4e54b51f99580661cb7e43bd3ed564a4cf 100644 (file)
@@ -894,7 +894,8 @@ unpack_image(struct gl_context *ctx, GLuint dimensions,
       GLvoid *image;
 
       map = (GLubyte *)
-         ctx->Driver.MapBuffer(ctx, GL_READ_ONLY_ARB, unpack->BufferObj);
+         ctx->Driver.MapBufferRange(ctx, 0, unpack->BufferObj->Size,
+                                   GL_MAP_READ_BIT, unpack->BufferObj);
       if (!map) {
          /* unable to map src buffer! */
          _mesa_error(ctx, GL_INVALID_OPERATION, "unable to map PBO");
index ce362b9e44443f5cf1d5d8340a72c8ec43b2f7ab..4e7e6f925ccbc39af83746a86e17ba2c8b0d9dd8 100644 (file)
@@ -128,9 +128,10 @@ _mesa_map_pbo_source(struct gl_context *ctx,
 
    if (_mesa_is_bufferobj(unpack->BufferObj)) {
       /* unpack from PBO */
-      buf = (GLubyte *) ctx->Driver.MapBuffer(ctx,
-                                              GL_READ_ONLY_ARB,
-                                              unpack->BufferObj);
+      buf = (GLubyte *) ctx->Driver.MapBufferRange(ctx, 0,
+                                                  unpack->BufferObj->Size,
+                                                  GL_MAP_READ_BIT,
+                                                  unpack->BufferObj);
       if (!buf)
          return NULL;
 
@@ -223,9 +224,10 @@ _mesa_map_pbo_dest(struct gl_context *ctx,
 
    if (_mesa_is_bufferobj(pack->BufferObj)) {
       /* pack into PBO */
-      buf = (GLubyte *) ctx->Driver.MapBuffer(ctx,
-                                              GL_WRITE_ONLY_ARB,
-                                              pack->BufferObj);
+      buf = (GLubyte *) ctx->Driver.MapBufferRange(ctx, 0,
+                                                  pack->BufferObj->Size,
+                                                  GL_MAP_WRITE_BIT,
+                                                  pack->BufferObj);
       if (!buf)
          return NULL;
 
@@ -326,8 +328,9 @@ _mesa_validate_pbo_teximage(struct gl_context *ctx, GLuint dimensions,
       return NULL;
    }
 
-   buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_READ_ONLY_ARB,
-                                          unpack->BufferObj);
+   buf = (GLubyte *) ctx->Driver.MapBufferRange(ctx, 0, unpack->BufferObj->Size,
+                                               GL_MAP_READ_BIT,
+                                               unpack->BufferObj);
    if (!buf) {
       _mesa_error(ctx, GL_INVALID_OPERATION, funcName, "(PBO is mapped)");
       return NULL;
@@ -363,7 +366,10 @@ _mesa_validate_pbo_compressed_teximage(struct gl_context *ctx,
       return NULL;
    }
 
-   buf = (GLubyte*) ctx->Driver.MapBuffer(ctx, GL_READ_ONLY_ARB, packing->BufferObj);
+   buf = (GLubyte*) ctx->Driver.MapBufferRange(ctx, 0,
+                                              packing->BufferObj->Size,
+                                              GL_MAP_READ_BIT,
+                                              packing->BufferObj);
    if (!buf) {
       _mesa_error(ctx, GL_INVALID_OPERATION, funcName, "(PBO is mapped");
       return NULL;
index a54da7160c71dd4f1d7ffeedbced7fea17a8c9a9..b2ebb0de4755ea6c205db6f6fd0b7e93612b0282 100644 (file)
@@ -441,7 +441,8 @@ _mesa_get_teximage(struct gl_context *ctx, GLenum target, GLint level,
        * texture data to the PBO if the PBO is in VRAM along with the texture.
        */
       GLubyte *buf = (GLubyte *)
-         ctx->Driver.MapBuffer(ctx, GL_WRITE_ONLY_ARB, ctx->Pack.BufferObj);
+         ctx->Driver.MapBufferRange(ctx, 0, ctx->Pack.BufferObj->Size,
+                                   GL_MAP_WRITE_BIT, ctx->Pack.BufferObj);
       if (!buf) {
          /* out of memory or other unexpected error */
          _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexImage(map PBO failed)");
@@ -498,7 +499,8 @@ _mesa_get_compressed_teximage(struct gl_context *ctx, GLenum target, GLint level
    if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) {
       /* pack texture image into a PBO */
       GLubyte *buf = (GLubyte *)
-         ctx->Driver.MapBuffer(ctx, GL_WRITE_ONLY_ARB, ctx->Pack.BufferObj);
+         ctx->Driver.MapBufferRange(ctx, 0, ctx->Pack.BufferObj->Size,
+                                   GL_MAP_WRITE_BIT, ctx->Pack.BufferObj);
       if (!buf) {
          /* out of memory or other unexpected error */
          _mesa_error(ctx, GL_OUT_OF_MEMORY,
index dd2eca7bc96b4c2b580dcd2ff0b59f1788308277..a451b44049e70d0509bc4d3445b4dfec4e557b52 100644 (file)
@@ -235,48 +235,6 @@ static long st_bufferobj_zero_length = 0;
 
 
 
-/**
- * Called via glMapBufferARB().
- */
-static void *
-st_bufferobj_map(struct gl_context *ctx, GLenum access,
-                 struct gl_buffer_object *obj)
-{
-   struct st_buffer_object *st_obj = st_buffer_object(obj);
-   uint flags;
-
-   switch (access) {
-   case GL_WRITE_ONLY:
-      flags = PIPE_TRANSFER_WRITE;
-      break;
-   case GL_READ_ONLY:
-      flags = PIPE_TRANSFER_READ;
-      break;
-   case GL_READ_WRITE:
-   default:
-      flags = PIPE_TRANSFER_READ_WRITE;
-      break;      
-   }
-
-   /* Handle zero-size buffers here rather than in drivers */
-   if (obj->Size == 0) {
-      obj->Pointer = &st_bufferobj_zero_length;
-   }
-   else {
-      obj->Pointer = pipe_buffer_map(st_context(ctx)->pipe,
-                                     st_obj->buffer,
-                                     flags,
-                                     &st_obj->transfer);
-   }
-
-   if (obj->Pointer) {
-      obj->Offset = 0;
-      obj->Length = obj->Size;
-   }
-   return obj->Pointer;
-}
-
-
 /**
  * Called via glMapBufferRange().
  */
@@ -442,7 +400,6 @@ st_init_bufferobject_functions(struct dd_function_table *functions)
    functions->BufferData = st_bufferobj_data;
    functions->BufferSubData = st_bufferobj_subdata;
    functions->GetBufferSubData = st_bufferobj_get_subdata;
-   functions->MapBuffer = st_bufferobj_map;
    functions->MapBufferRange = st_bufferobj_map_range;
    functions->FlushMappedBufferRange = st_bufferobj_flush_mapped_range;
    functions->UnmapBuffer = st_bufferobj_unmap;
index 7351f6f3be6647f9c9003b7e4be91be4ee3b45d5..a23d17543910266845a236d04c094cd834b71a11 100644 (file)
@@ -280,9 +280,9 @@ static void bind_inputs( struct gl_context *ctx,
         if (!inputs[i]->BufferObj->Pointer) {
            bo[*nr_bo] = inputs[i]->BufferObj;
            (*nr_bo)++;
-           ctx->Driver.MapBuffer(ctx, 
-                                 GL_READ_ONLY_ARB,
-                                 inputs[i]->BufferObj);
+           ctx->Driver.MapBufferRange(ctx, 0, inputs[i]->BufferObj->Size,
+                                      GL_MAP_READ_BIT,
+                                      inputs[i]->BufferObj);
            
            assert(inputs[i]->BufferObj->Pointer);
         }
@@ -349,9 +349,8 @@ static void bind_indices( struct gl_context *ctx,
    if (ib->obj->Name && !ib->obj->Pointer) {
       bo[*nr_bo] = ib->obj;
       (*nr_bo)++;
-      ctx->Driver.MapBuffer(ctx, 
-                           GL_READ_ONLY_ARB,
-                           ib->obj);
+      ctx->Driver.MapBufferRange(ctx, 0, ib->obj->Size, GL_MAP_READ_BIT,
+                                ib->obj);
 
       assert(ib->obj->Pointer);
    }
index 8359a7f1529f1329aaced9e3c91ba1a604919602..484e1a85e41b979823407be81eb938492e41758d 100644 (file)
@@ -96,7 +96,8 @@ vbo_get_minmax_index(struct gl_context *ctx,
 
    if (_mesa_is_bufferobj(ib->obj)) {
       const GLvoid *map =
-         ctx->Driver.MapBuffer(ctx, GL_READ_ONLY, ib->obj);
+         ctx->Driver.MapBufferRange(ctx, 0, ib->obj->Size, GL_MAP_READ_BIT,
+                                   ib->obj);
       indices = ADD_POINTERS(map, ib->ptr);
    } else {
       indices = ib->ptr;
@@ -195,7 +196,8 @@ check_array_data(struct gl_context *ctx, struct gl_client_array *array,
          if (!array->BufferObj->Pointer) {
             /* need to map now */
             array->BufferObj->Pointer =
-               ctx->Driver.MapBuffer(ctx, GL_READ_ONLY, array->BufferObj);
+               ctx->Driver.MapBufferRange(ctx, 0, array->BufferObj->Size,
+                                         GL_MAP_READ_BIT, array->BufferObj);
          }
          data = ADD_POINTERS(data, array->BufferObj->Pointer);
       }
@@ -254,9 +256,10 @@ check_draw_elements_data(struct gl_context *ctx, GLsizei count, GLenum elemType,
    GLint i, k;
 
    if (_mesa_is_bufferobj(ctx->Array.ElementArrayBufferObj)) {
-      elemMap = ctx->Driver.MapBuffer(ctx,
-                                      GL_READ_ONLY,
-                                      ctx->Array.ElementArrayBufferObj);
+      elemMap = ctx->Driver.MapBufferRange(ctx, 0,
+                                          ctx->Array.ElementArrayBufferObj->Size,
+                                          GL_MAP_READ_BIT,
+                                          ctx->Array.ElementArrayBufferObj);
       elements = ADD_POINTERS(elements, elemMap);
    }
 
@@ -347,7 +350,8 @@ print_draw_arrays(struct gl_context *ctx,
             bufName);
 
       if (bufName) {
-         GLubyte *p = ctx->Driver.MapBuffer(ctx, GL_READ_ONLY_ARB, bufObj);
+         GLubyte *p = ctx->Driver.MapBufferRange(ctx, 0, bufObj->Size,
+                                                GL_MAP_READ_BIT, bufObj);
          int offset = (int) (GLintptr) exec->array.inputs[i]->Ptr;
          float *f = (float *) (p + offset);
          int *k = (int *) f;
@@ -710,9 +714,11 @@ vbo_exec_DrawArraysInstanced(GLenum mode, GLint start, GLsizei count,
 static void
 dump_element_buffer(struct gl_context *ctx, GLenum type)
 {
-   const GLvoid *map = ctx->Driver.MapBuffer(ctx,
-                                             GL_READ_ONLY,
-                                             ctx->Array.ElementArrayBufferObj);
+   const GLvoid *map =
+      ctx->Driver.MapBufferRange(ctx, 0,
+                                ctx->Array.ElementArrayBufferObj->Size,
+                                GL_MAP_READ_BIT,
+                                ctx->Array.ElementArrayBufferObj);
    switch (type) {
    case GL_UNSIGNED_BYTE:
       {
index 2dc6066179650de6a94141b2891a9fea00ffb2da..25436c6d6d2c755fd39a736207e62eac6aeac557 100644 (file)
@@ -296,7 +296,6 @@ vbo_exec_vtx_map( struct vbo_exec_context *exec )
 {
    struct gl_context *ctx = exec->ctx;
    const GLenum target = GL_ARRAY_BUFFER_ARB;
-   const GLenum access = GL_READ_WRITE_ARB; /* for MapBuffer */
    const GLenum accessRange = GL_MAP_WRITE_BIT |  /* for MapBufferRange */
                               GL_MAP_INVALIDATE_RANGE_BIT |
                               GL_MAP_UNSYNCHRONIZED_BIT |
@@ -310,8 +309,7 @@ vbo_exec_vtx_map( struct vbo_exec_context *exec )
    assert(!exec->vtx.buffer_map);
    assert(!exec->vtx.buffer_ptr);
 
-   if (VBO_VERT_BUFFER_SIZE > exec->vtx.buffer_used + 1024 &&
-       ctx->Driver.MapBufferRange) {
+   if (VBO_VERT_BUFFER_SIZE > exec->vtx.buffer_used + 1024) {
       /* The VBO exists and there's room for more */
       exec->vtx.buffer_map = 
          (GLfloat *)ctx->Driver.MapBufferRange(ctx, 
@@ -332,15 +330,11 @@ vbo_exec_vtx_map( struct vbo_exec_context *exec )
                              NULL, usage, exec->vtx.bufferobj);
 
 
-      if (ctx->Driver.MapBufferRange)
-         exec->vtx.buffer_map = 
-            (GLfloat *)ctx->Driver.MapBufferRange(ctx,
-                                                  0, VBO_VERT_BUFFER_SIZE,
-                                                  accessRange,
-                                                  exec->vtx.bufferobj);
-      if (!exec->vtx.buffer_map)
-         exec->vtx.buffer_map =
-            (GLfloat *)ctx->Driver.MapBuffer(ctx, access, exec->vtx.bufferobj);
+      exec->vtx.buffer_map =
+        (GLfloat *)ctx->Driver.MapBufferRange(ctx,
+                                              0, VBO_VERT_BUFFER_SIZE,
+                                              accessRange,
+                                              exec->vtx.bufferobj);
       assert(exec->vtx.buffer_map);
       exec->vtx.buffer_ptr = exec->vtx.buffer_map;
    }
index e10908d5ece1262094a01549d707d054659f8209..a1eab752ad6518928335cf56a99cd997e3a65cd5 100644 (file)
@@ -159,7 +159,8 @@ void vbo_rebase_prims( struct gl_context *ctx,
       void *ptr;
 
       if (map_ib) 
-        ctx->Driver.MapBuffer(ctx, GL_READ_ONLY_ARB, ib->obj);
+        ctx->Driver.MapBufferRange(ctx, 0, ib->obj->Size, GL_MAP_READ_BIT,
+                                   ib->obj);
 
 
       ptr = ADD_POINTERS(ib->obj->Pointer, ib->ptr);
index f90f00c5aae745263775630bbcd6855138dce414..ad36e93329c450a63b45a1cd3ee3b7e56aad2bc8 100644 (file)
@@ -232,10 +232,10 @@ map_vertex_store(struct gl_context *ctx,
    assert(vertex_store->bufferobj);
    assert(!vertex_store->buffer);
    vertex_store->buffer =
-      (GLfloat *) ctx->Driver.MapBuffer(ctx,
-                                        GL_WRITE_ONLY,      /* not used */
-                                        vertex_store->
-                                        bufferobj);
+      (GLfloat *) ctx->Driver.MapBufferRange(ctx, 0,
+                                            vertex_store->bufferobj->Size,
+                                            GL_MAP_WRITE_BIT,    /* not used */
+                                            vertex_store->bufferobj);
 
    assert(vertex_store->buffer);
    return vertex_store->buffer + vertex_store->used;
index e7996f29307e77848e5f16a6849b6d31e6a50049..6cda831aa856ef92a41d4072758aa23da10f66b2 100644 (file)
@@ -217,9 +217,11 @@ static void
 vbo_save_loopback_vertex_list(struct gl_context *ctx,
                               const struct vbo_save_vertex_list *list)
 {
-   const char *buffer = ctx->Driver.MapBuffer(ctx, 
-                                             GL_READ_ONLY, /* ? */
-                                              list->vertex_store->bufferobj);
+   const char *buffer =
+      ctx->Driver.MapBufferRange(ctx, 0,
+                                list->vertex_store->bufferobj->Size,
+                                GL_MAP_READ_BIT, /* ? */
+                                list->vertex_store->bufferobj);
 
    vbo_loopback_vertex_list(ctx,
                             (const GLfloat *)(buffer + list->buffer_offset),
index 8dc5aa0ed76726d100a95af646b04906f6a1f293..40906e389177f229a864f5528eb6aba46b3de5cf 100644 (file)
@@ -444,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_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);
@@ -459,7 +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_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);