aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/vbo/vbo_save_api.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2013-10-18 11:59:15 +0200
committermarha <marha@users.sourceforge.net>2013-10-18 11:59:15 +0200
commitb821fe861f33d7e8a39fe4c7d885b7ff379dc476 (patch)
tree7b3c0b22d35eadf598cff3965413a96c76d5ad39 /mesalib/src/mesa/vbo/vbo_save_api.c
parent56e12b1310b1b52d00bc27e919d915255af5bf03 (diff)
parentb8a77c943fa53005b6cdb1ab792acf5ff0a131be (diff)
downloadvcxsrv-b821fe861f33d7e8a39fe4c7d885b7ff379dc476.tar.gz
vcxsrv-b821fe861f33d7e8a39fe4c7d885b7ff379dc476.tar.bz2
vcxsrv-b821fe861f33d7e8a39fe4c7d885b7ff379dc476.zip
Merge remote-tracking branch 'origin/released'
* origin/released: mesa pixman git update 18 okt 2013 Conflicts: mesalib/include/GL/glext.h mesalib/include/GL/glxext.h
Diffstat (limited to 'mesalib/src/mesa/vbo/vbo_save_api.c')
-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;