mesa: Eliminate dd_function_table::MapBuffer
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>
This commit is contained in:
parent
cccc7412c2
commit
28249bd260
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue