diff options
author | Marek Olšák <[email protected]> | 2014-02-06 19:24:23 +0100 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2014-02-25 16:07:33 +0100 |
commit | dca350201e00c7cf1cfb009158f4abf27fbc96d2 (patch) | |
tree | 8e331dfaa4ab2b623ee559f14fb1f678be6ba5df /src/mesa/vbo/vbo_save_api.c | |
parent | 86e68b0f1f7f5ff58b38653978acaa736ae3d01c (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/vbo/vbo_save_api.c')
-rw-r--r-- | src/mesa/vbo/vbo_save_api.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c index b86ced5bf89..1c6b91942d5 100644 --- a/src/mesa/vbo/vbo_save_api.c +++ b/src/mesa/vbo/vbo_save_api.c @@ -253,7 +253,8 @@ vbo_save_map_vertex_store(struct gl_context *ctx, GLsizeiptr size = vertex_store->bufferobj->Size - offset; GLfloat *range = (GLfloat *) ctx->Driver.MapBufferRange(ctx, offset, size, access, - vertex_store->bufferobj); + vertex_store->bufferobj, + MAP_INTERNAL); if (range) { /* compute address of start of whole buffer (needed elsewhere) */ vertex_store->buffer = range - vertex_store->used; @@ -279,13 +280,14 @@ vbo_save_unmap_vertex_store(struct gl_context *ctx, if (vertex_store->bufferobj->Size > 0) { GLintptr offset = 0; GLsizeiptr length = vertex_store->used * sizeof(GLfloat) - - vertex_store->bufferobj->Offset; + - vertex_store->bufferobj->Mappings[MAP_INTERNAL].Offset; /* Explicitly flush the region we wrote to */ ctx->Driver.FlushMappedBufferRange(ctx, offset, length, - vertex_store->bufferobj); + vertex_store->bufferobj, + MAP_INTERNAL); - ctx->Driver.UnmapBuffer(ctx, vertex_store->bufferobj); + ctx->Driver.UnmapBuffer(ctx, vertex_store->bufferobj, MAP_INTERNAL); } vertex_store->buffer = NULL; } @@ -1118,6 +1120,7 @@ _save_OBE_DrawElements(GLenum mode, GLsizei count, GLenum type, { GET_CURRENT_CONTEXT(ctx); struct vbo_save_context *save = &vbo_context(ctx)->save; + struct gl_buffer_object *indexbuf = ctx->Array.VAO->IndexBufferObj; GLint i; if (!_mesa_is_valid_prim_mode(ctx, mode)) { @@ -1140,9 +1143,9 @@ _save_OBE_DrawElements(GLenum mode, GLsizei count, GLenum type, _ae_map_vbos(ctx); - if (_mesa_is_bufferobj(ctx->Array.VAO->IndexBufferObj)) + if (_mesa_is_bufferobj(indexbuf)) indices = - ADD_POINTERS(ctx->Array.VAO->IndexBufferObj->Pointer, indices); + ADD_POINTERS(indexbuf->Mappings[MAP_INTERNAL].Pointer, indices); vbo_save_NotifyBegin(ctx, (mode | VBO_SAVE_PRIM_WEAK | VBO_SAVE_PRIM_NO_CURRENT_UPDATE)); |