diff options
author | Marek Olšák <[email protected]> | 2011-08-30 19:10:06 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2011-09-02 22:39:56 +0200 |
commit | 5572de8e7e71a15cefe6425b3e082c721052ef1e (patch) | |
tree | 75f5f7bdf80a9a1c8b478904562ecc30b59b031d /src/mesa/main/bufferobj.c | |
parent | 0a33ac5413d6217a30b70d4ec6e11389872616d0 (diff) |
mesa: handle zero-size buffers in MapBuffer and ranges in MapBufferRange (v3)
Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/mesa/main/bufferobj.c')
-rw-r--r-- | src/mesa/main/bufferobj.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index c453f9c8554..a303401748c 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -1004,6 +1004,12 @@ _mesa_MapBufferARB(GLenum target, GLenum access) return NULL; } + if (!bufObj->Size) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, + "glMapBuffer(buffer size = 0)"); + return NULL; + } + ASSERT(ctx->Driver.MapBufferRange); map = ctx->Driver.MapBufferRange(ctx, 0, bufObj->Size, accessFlags, bufObj); if (!map) { @@ -1410,7 +1416,23 @@ _mesa_MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, "glMapBufferRange(buffer already mapped)"); return NULL; } - + + if (!bufObj->Size) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, + "glMapBufferRange(buffer size = 0)"); + return NULL; + } + + /* Mapping zero bytes should return a non-null pointer. */ + if (!length) { + static long dummy = 0; + bufObj->Pointer = &dummy; + bufObj->Length = length; + bufObj->Offset = offset; + bufObj->AccessFlags = access; + return bufObj->Pointer; + } + ASSERT(ctx->Driver.MapBufferRange); map = ctx->Driver.MapBufferRange(ctx, offset, length, access, bufObj); if (!map) { |