mesa: Support BindBuffer{Base,Offset,Range} with a buffer of 0.

_mesa_lookup_bufferobj returns NULL for 0, which caused us to say
"there's no such buffer object" and raise an error, rather than
correctly binding the shared NullBufferObj.

Now you can unbind your buffers.

NOTE: This is a candidate for stable release branches.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Brian Paul <brianp@vmware.com>
(cherry picked from commit 05b086ce93)
This commit is contained in:
Kenneth Graunke 2012-06-04 00:48:23 -07:00 committed by Ian Romanick
parent a8fed44e9e
commit 5fde348eb8

View file

@ -497,7 +497,12 @@ _mesa_BindBufferRange(GLenum target, GLuint index,
return;
}
bufObj = _mesa_lookup_bufferobj(ctx, buffer);
if (buffer == 0) {
bufObj = ctx->Shared->NullBufferObj;
} else {
bufObj = _mesa_lookup_bufferobj(ctx, buffer);
}
if (!bufObj) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glBindBufferRange(invalid buffer=%u)", buffer);
@ -545,7 +550,12 @@ _mesa_BindBufferBase(GLenum target, GLuint index, GLuint buffer)
return;
}
bufObj = _mesa_lookup_bufferobj(ctx, buffer);
if (buffer == 0) {
bufObj = ctx->Shared->NullBufferObj;
} else {
bufObj = _mesa_lookup_bufferobj(ctx, buffer);
}
if (!bufObj) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glBindBufferBase(invalid buffer=%u)", buffer);
@ -601,7 +611,12 @@ _mesa_BindBufferOffsetEXT(GLenum target, GLuint index, GLuint buffer,
return;
}
bufObj = _mesa_lookup_bufferobj(ctx, buffer);
if (buffer == 0) {
bufObj = ctx->Shared->NullBufferObj;
} else {
bufObj = _mesa_lookup_bufferobj(ctx, buffer);
}
if (!bufObj) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glBindBufferOffsetEXT(invalid buffer=%u)", buffer);