* specified context or \c NULL if \c target is invalid.
*/
static inline struct gl_buffer_object *
-get_buffer(struct gl_context *ctx, GLenum target)
+get_buffer(struct gl_context *ctx, const char *func, GLenum target)
{
struct gl_buffer_object **bufObj = get_buffer_target(ctx, target);
- if (bufObj)
- return *bufObj;
- return NULL;
+
+ if (!bufObj) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "%s(target)", func);
+ return NULL;
+ }
+
+ if (!_mesa_is_bufferobj(*bufObj)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(buffer 0)", func);
+ return NULL;
+ }
+
+ return *bufObj;
}
return NULL;
}
- bufObj = get_buffer(ctx, target);
- if (!bufObj) {
- _mesa_error(ctx, GL_INVALID_ENUM, "%s(target)", caller);
- return NULL;
- }
- if (!_mesa_is_bufferobj(bufObj)) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "%s", caller);
+ bufObj = get_buffer(ctx, caller, target);
+ if (!bufObj)
return NULL;
- }
+
if (offset + size > bufObj->Size) {
_mesa_error(ctx, GL_INVALID_VALUE,
"%s(offset %lu + size %lu > buffer size %lu)", caller,
return;
}
- bufObj = get_buffer(ctx, target);
- if (!bufObj) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glBufferDataARB(target)" );
+ bufObj = get_buffer(ctx, "glBufferDataARB", target);
+ if (!bufObj)
return;
- }
- if (!_mesa_is_bufferobj(bufObj)) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glBufferDataARB(buffer 0)" );
- return;
- }
-
+
if (_mesa_bufferobj_mapped(bufObj)) {
/* Unmap the existing buffer. We'll replace it now. Not an error. */
ctx->Driver.UnmapBuffer(ctx, bufObj);
return NULL;
}
- bufObj = get_buffer(ctx, target);
- if (!bufObj) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glMapBufferARB(target)" );
- return NULL;
- }
- if (!_mesa_is_bufferobj(bufObj)) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glMapBufferARB(buffer 0)" );
+ bufObj = get_buffer(ctx, "glMapBufferARB", target);
+ if (!bufObj)
return NULL;
- }
+
if (_mesa_bufferobj_mapped(bufObj)) {
_mesa_error(ctx, GL_INVALID_OPERATION, "glMapBufferARB(already mapped)");
return NULL;
GLboolean status = GL_TRUE;
ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
- bufObj = get_buffer(ctx, target);
- if (!bufObj) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glUnmapBufferARB(target)" );
- return GL_FALSE;
- }
- if (!_mesa_is_bufferobj(bufObj)) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glUnmapBufferARB" );
+ bufObj = get_buffer(ctx, "glUnmapBufferARB", target);
+ if (!bufObj)
return GL_FALSE;
- }
+
if (!_mesa_bufferobj_mapped(bufObj)) {
_mesa_error(ctx, GL_INVALID_OPERATION, "glUnmapBufferARB");
return GL_FALSE;
struct gl_buffer_object *bufObj;
ASSERT_OUTSIDE_BEGIN_END(ctx);
- bufObj = get_buffer(ctx, target);
- if (!bufObj) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glGetBufferParameterivARB(target)" );
- return;
- }
- if (!_mesa_is_bufferobj(bufObj)) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glGetBufferParameterivARB" );
+ bufObj = get_buffer(ctx, "glGetBufferParameterivARB", target);
+ if (!bufObj)
return;
- }
switch (pname) {
case GL_BUFFER_SIZE_ARB:
struct gl_buffer_object *bufObj;
ASSERT_OUTSIDE_BEGIN_END(ctx);
- bufObj = get_buffer(ctx, target);
- if (!bufObj) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glGetBufferParameteri64v(target)" );
+ bufObj = get_buffer(ctx, "glGetBufferParameteri64v", target);
+ if (!bufObj)
return;
- }
- if (!_mesa_is_bufferobj(bufObj)) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glGetBufferParameteri64v" );
- return;
- }
switch (pname) {
case GL_BUFFER_SIZE_ARB:
return;
}
- bufObj = get_buffer(ctx, target);
- if (!bufObj) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glGetBufferPointervARB(target)" );
- return;
- }
- if (!_mesa_is_bufferobj(bufObj)) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glGetBufferPointervARB" );
+ bufObj = get_buffer(ctx, "glGetBufferPointervARB", target);
+ if (!bufObj)
return;
- }
*params = bufObj->Pointer;
}
struct gl_buffer_object *src, *dst;
ASSERT_OUTSIDE_BEGIN_END(ctx);
- src = get_buffer(ctx, readTarget);
- if (!_mesa_is_bufferobj(src)) {
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glCopyBuffserSubData(readTarget = 0x%x)", readTarget);
+ src = get_buffer(ctx, "glCopyBuffserSubData", readTarget);
+ if (!src)
return;
- }
- dst = get_buffer(ctx, writeTarget);
- if (!_mesa_is_bufferobj(dst)) {
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glCopyBuffserSubData(writeTarget = 0x%x)", writeTarget);
+ dst = get_buffer(ctx, "glCopyBuffserSubData", writeTarget);
+ if (!dst)
return;
- }
if (_mesa_bufferobj_mapped(src)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
return NULL;
}
- bufObj = get_buffer(ctx, target);
- if (!_mesa_is_bufferobj(bufObj)) {
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glMapBufferRange(target = 0x%x)", target);
+ bufObj = get_buffer(ctx, "glMapBufferRange", target);
+ if (!bufObj)
return NULL;
- }
if (offset + length > bufObj->Size) {
_mesa_error(ctx, GL_INVALID_VALUE,
return;
}
- bufObj = get_buffer(ctx, target);
- if (!bufObj) {
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glMapBufferRange(target = 0x%x)", target);
- return;
- }
-
- if (!_mesa_is_bufferobj(bufObj)) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glMapBufferRange(current buffer is 0)");
+ bufObj = get_buffer(ctx, "glMapBufferRange", target);
+ if (!bufObj)
return;
- }
if (!_mesa_bufferobj_mapped(bufObj)) {
/* buffer is not mapped */