aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/tnl/t_draw.c
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2014-02-06 19:24:23 +0100
committerMarek Olšák <[email protected]>2014-02-25 16:07:33 +0100
commitdca350201e00c7cf1cfb009158f4abf27fbc96d2 (patch)
tree8e331dfaa4ab2b623ee559f14fb1f678be6ba5df /src/mesa/tnl/t_draw.c
parent86e68b0f1f7f5ff58b38653978acaa736ae3d01c (diff)
mesa: allow buffers to be mapped multiple times
OpenGL allows a buffer to be mapped only once, but we also map buffers internally, e.g. in the software primitive restart fallback, for PBOs, vbo_get_minmax_index, etc. This has always been a problem, but it will be a bigger problem with persistent buffer mappings, which will prevent all Mesa functions from mapping buffers for internal purposes. This adds a driver interface to core Mesa which supports multiple buffer mappings and allows 2 mappings: one for the GL user and one for Mesa. Note that Gallium supports an unlimited number of buffer and texture mappings, so it's not really an issue for Gallium. v2: fix unmapping in xm_dd.c, remove the GL errors there v3: fix the intel driver (by Fredrik) Reviewed-by: Fredrik Höglund <[email protected]>
Diffstat (limited to 'src/mesa/tnl/t_draw.c')
-rw-r--r--src/mesa/tnl/t_draw.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/mesa/tnl/t_draw.c b/src/mesa/tnl/t_draw.c
index 8e5af96277f..2755ae62d49 100644
--- a/src/mesa/tnl/t_draw.c
+++ b/src/mesa/tnl/t_draw.c
@@ -279,17 +279,18 @@ static void bind_inputs( struct gl_context *ctx,
const void *ptr;
if (inputs[i]->BufferObj->Name) {
- if (!inputs[i]->BufferObj->Pointer) {
+ if (!inputs[i]->BufferObj->Mappings[MAP_INTERNAL].Pointer) {
bo[*nr_bo] = inputs[i]->BufferObj;
(*nr_bo)++;
ctx->Driver.MapBufferRange(ctx, 0, inputs[i]->BufferObj->Size,
GL_MAP_READ_BIT,
- inputs[i]->BufferObj);
+ inputs[i]->BufferObj,
+ MAP_INTERNAL);
- assert(inputs[i]->BufferObj->Pointer);
+ assert(inputs[i]->BufferObj->Mappings[MAP_INTERNAL].Pointer);
}
- ptr = ADD_POINTERS(inputs[i]->BufferObj->Pointer,
+ ptr = ADD_POINTERS(inputs[i]->BufferObj->Mappings[MAP_INTERNAL].Pointer,
inputs[i]->Ptr);
}
else
@@ -348,17 +349,19 @@ static void bind_indices( struct gl_context *ctx,
return;
}
- if (_mesa_is_bufferobj(ib->obj) && !_mesa_bufferobj_mapped(ib->obj)) {
+ if (_mesa_is_bufferobj(ib->obj) &&
+ !_mesa_bufferobj_mapped(ib->obj, MAP_INTERNAL)) {
/* if the buffer object isn't mapped yet, map it now */
bo[*nr_bo] = ib->obj;
(*nr_bo)++;
ptr = ctx->Driver.MapBufferRange(ctx, (GLsizeiptr) ib->ptr,
ib->count * vbo_sizeof_ib_type(ib->type),
- GL_MAP_READ_BIT, ib->obj);
- assert(ib->obj->Pointer);
+ GL_MAP_READ_BIT, ib->obj,
+ MAP_INTERNAL);
+ assert(ib->obj->Mappings[MAP_INTERNAL].Pointer);
} else {
/* user-space elements, or buffer already mapped */
- ptr = ADD_POINTERS(ib->obj->Pointer, ib->ptr);
+ ptr = ADD_POINTERS(ib->obj->Mappings[MAP_INTERNAL].Pointer, ib->ptr);
}
if (ib->type == GL_UNSIGNED_INT && VB->Primitive[0].basevertex == 0) {
@@ -403,7 +406,7 @@ static void unmap_vbos( struct gl_context *ctx,
{
GLuint i;
for (i = 0; i < nr_bo; i++) {
- ctx->Driver.UnmapBuffer(ctx, bo[i]);
+ ctx->Driver.UnmapBuffer(ctx, bo[i], MAP_INTERNAL);
}
}