mesa: Make glBindBufferBase/glBindBufferRange() work on just-genned names.
authorEric Anholt <eric@anholt.net>
Tue, 26 Jun 2012 20:17:08 +0000 (13:17 -0700)
committerEric Anholt <eric@anholt.net>
Tue, 7 Aug 2012 20:54:50 +0000 (13:54 -0700)
commit56e82e30cb60368bb3605f95130732f5edbab0a0
tree9bc9c6ea3da679a9aae4000c2031ab8389690993
parenta75f2681d26aecad185895c1c2f13dd542281ff9
mesa: Make glBindBufferBase/glBindBufferRange() work on just-genned names.

In between glGenBuffers() and glBindBuffer(), the buffer object points to this
dummy buffer with a name of 0, and a glBindBufferBase() would point to that.
It seems pretty clear, given that glBindBufferBase() only cares about the
current size of the buffer at render time, that it should bind up the buffer
that you passed in instead of pointing it at this useless dummy buffer.

However, what should glBindBufferRange() do?  As of this patch, it will
promote the genned buffer to a proper buffer like it had been
glBindBuffer()ed, and then detect that the size is greater than the buffer's
current size of 0 and throw INVALID_VALUE.  It seems like the most reasonable
answer here.

Note that this also changes the behavior of these two on non-glGenBuffers() bo
names.  We haven't yet set up the error throwing for glBindBuffers() on gl
3.1+, and my assumption is that these two functions should inherit their
behavior on un-genned names from glBindBuffers().

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/main/bufferobj.c