aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/vbo
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2013-10-18 11:23:37 +0200
committermarha <marha@users.sourceforge.net>2013-10-18 11:23:37 +0200
commitb8a77c943fa53005b6cdb1ab792acf5ff0a131be (patch)
treee10b1a509f6773de3e547ac5332cf6e0a4e07617 /mesalib/src/mesa/vbo
parent9e23b44bfe1e6e85231b1c07d945cadf0c868648 (diff)
downloadvcxsrv-b8a77c943fa53005b6cdb1ab792acf5ff0a131be.tar.gz
vcxsrv-b8a77c943fa53005b6cdb1ab792acf5ff0a131be.tar.bz2
vcxsrv-b8a77c943fa53005b6cdb1ab792acf5ff0a131be.zip
mesa pixman git update 18 okt 2013
pixman commit 3c2f4b651747c1ac484c39d5128cae5483094342 mesa commit 9aad1ba70fad7bfa45778faa5a91235f8302264f
Diffstat (limited to 'mesalib/src/mesa/vbo')
-rw-r--r--mesalib/src/mesa/vbo/vbo_save_api.c39
1 files changed, 31 insertions, 8 deletions
diff --git a/mesalib/src/mesa/vbo/vbo_save_api.c b/mesalib/src/mesa/vbo/vbo_save_api.c
index b5f951787..411c00604 100644
--- a/mesalib/src/mesa/vbo/vbo_save_api.c
+++ b/mesalib/src/mesa/vbo/vbo_save_api.c
@@ -237,16 +237,31 @@ GLfloat *
vbo_save_map_vertex_store(struct gl_context *ctx,
struct vbo_save_vertex_store *vertex_store)
{
+ const GLbitfield access = (GL_MAP_WRITE_BIT |
+ GL_MAP_INVALIDATE_RANGE_BIT |
+ GL_MAP_UNSYNCHRONIZED_BIT |
+ GL_MAP_FLUSH_EXPLICIT_BIT);
+
assert(vertex_store->bufferobj);
- assert(!vertex_store->buffer);
+ assert(!vertex_store->buffer); /* the buffer should not be mapped */
+
if (vertex_store->bufferobj->Size > 0) {
- vertex_store->buffer =
- (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;
+ /* Map the remaining free space in the VBO */
+ GLintptr offset = vertex_store->used * sizeof(GLfloat);
+ GLsizeiptr size = vertex_store->bufferobj->Size - offset;
+ GLfloat *range = (GLfloat *)
+ ctx->Driver.MapBufferRange(ctx, offset, size, access,
+ vertex_store->bufferobj);
+ if (range) {
+ /* compute address of start of whole buffer (needed elsewhere) */
+ vertex_store->buffer = range - vertex_store->used;
+ assert(vertex_store->buffer);
+ return range;
+ }
+ else {
+ vertex_store->buffer = NULL;
+ return NULL;
+ }
}
else {
/* probably ran out of memory for buffers */
@@ -260,6 +275,14 @@ vbo_save_unmap_vertex_store(struct gl_context *ctx,
struct vbo_save_vertex_store *vertex_store)
{
if (vertex_store->bufferobj->Size > 0) {
+ GLintptr offset = 0;
+ GLsizeiptr length = vertex_store->used * sizeof(GLfloat)
+ - vertex_store->bufferobj->Offset;
+
+ /* Explicitly flush the region we wrote to */
+ ctx->Driver.FlushMappedBufferRange(ctx, offset, length,
+ vertex_store->bufferobj);
+
ctx->Driver.UnmapBuffer(ctx, vertex_store->bufferobj);
}
vertex_store->buffer = NULL;