main: Refactor _mesa_texture_buffer_range.

Changes how the caller is identified in error messages, moves a check for
ARB_texture_buffer_object from the entry points to the shared code in
_mesa_texture_buffer_range, and removes an unused argument (GLenum target).

v2: Review from Anuj Phogat
   - Split rebase of Tex[ture]Buffer[Range]

Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
This commit is contained in:
Laura Ekstrand 2015-03-04 14:31:29 -08:00
parent d03337306a
commit 6b78a1fb89
2 changed files with 25 additions and 39 deletions

View file

@ -5243,24 +5243,34 @@ _mesa_validate_texbuffer_format(const struct gl_context *ctx,
void
_mesa_texture_buffer_range(struct gl_context *ctx,
struct gl_texture_object *texObj, GLenum target,
struct gl_texture_object *texObj,
GLenum internalFormat,
struct gl_buffer_object *bufObj,
GLintptr offset, GLsizeiptr size, bool range,
bool dsa)
GLintptr offset, GLsizeiptr size,
const char *caller)
{
mesa_format format;
FLUSH_VERTICES(ctx, 0);
/* NOTE: ARB_texture_buffer_object has interactions with
* the compatibility profile that are not implemented.
*/
if (!(ctx->API == API_OPENGL_CORE &&
ctx->Extensions.ARB_texture_buffer_object)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"%s(ARB_texture_buffer_object is not"
" implemented for the compatibility profile)", caller);
return;
}
format = _mesa_validate_texbuffer_format(ctx, internalFormat);
if (format == MESA_FORMAT_NONE) {
_mesa_error(ctx, GL_INVALID_ENUM,
"glTex%sBuffer%s(internalFormat 0x%x)", dsa ? "ture" : "",
range ? "Range" : "", internalFormat);
"%s(internalFormat 0x%x)", caller, internalFormat);
return;
}
FLUSH_VERTICES(ctx, 0);
_mesa_lock_texture(ctx, texObj);
{
_mesa_reference_buffer_object(ctx, &texObj->BufferObject, bufObj);
@ -5294,15 +5304,6 @@ _mesa_TexBuffer(GLenum target, GLenum internalFormat, GLuint buffer)
return;
}
/* NOTE: ARB_texture_buffer_object has interactions with
* the compatibility profile that are not implemented.
*/
if (!(ctx->API == API_OPENGL_CORE &&
ctx->Extensions.ARB_texture_buffer_object)) {
_mesa_error(ctx, GL_INVALID_OPERATION, "glTexBuffer");
return;
}
if (buffer) {
bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glTexBuffer");
if (!bufObj)
@ -5314,8 +5315,8 @@ _mesa_TexBuffer(GLenum target, GLenum internalFormat, GLuint buffer)
if (!texObj)
return;
_mesa_texture_buffer_range(ctx, texObj, target, internalFormat, bufObj, 0,
buffer ? -1 : 0, false, false);
_mesa_texture_buffer_range(ctx, texObj, internalFormat, bufObj, 0,
buffer ? -1 : 0, "glTexBuffer");
}
@ -5335,12 +5336,6 @@ _mesa_TexBufferRange(GLenum target, GLenum internalFormat, GLuint buffer,
return;
}
if (!(ctx->API == API_OPENGL_CORE &&
ctx->Extensions.ARB_texture_buffer_range)) {
_mesa_error(ctx, GL_INVALID_OPERATION, "glTexBufferRange");
return;
}
bufObj = _mesa_lookup_bufferobj(ctx, buffer);
if (bufObj) {
if (offset < 0 ||
@ -5367,8 +5362,8 @@ _mesa_TexBufferRange(GLenum target, GLenum internalFormat, GLuint buffer,
if (!texObj)
return;
_mesa_texture_buffer_range(ctx, texObj, target, internalFormat, bufObj,
offset, size, true, false);
_mesa_texture_buffer_range(ctx, texObj, internalFormat, bufObj,
offset, size, "glTexBufferRange");
}
void GLAPIENTRY
@ -5379,15 +5374,6 @@ _mesa_TextureBuffer(GLuint texture, GLenum internalFormat, GLuint buffer)
GET_CURRENT_CONTEXT(ctx);
/* NOTE: ARB_texture_buffer_object has interactions with
* the compatibility profile that are not implemented.
*/
if (!(ctx->API == API_OPENGL_CORE &&
ctx->Extensions.ARB_texture_buffer_object)) {
_mesa_error(ctx, GL_INVALID_OPERATION, "glTextureBuffer");
return;
}
if (buffer) {
bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glTextureBuffer");
if (!bufObj)
@ -5406,8 +5392,8 @@ _mesa_TextureBuffer(GLuint texture, GLenum internalFormat, GLuint buffer)
return;
}
_mesa_texture_buffer_range(ctx, texObj, texObj->Target, internalFormat,
bufObj, 0, buffer ? -1 : 0, false, true);
_mesa_texture_buffer_range(ctx, texObj, internalFormat,
bufObj, 0, buffer ? -1 : 0, "glTextureBuffer");
}
static GLboolean

View file

@ -209,11 +209,11 @@ _mesa_texture_image_multisample(struct gl_context *ctx, GLuint dims,
extern void
_mesa_texture_buffer_range(struct gl_context *ctx,
struct gl_texture_object *texObj, GLenum target,
struct gl_texture_object *texObj,
GLenum internalFormat,
struct gl_buffer_object *bufObj,
GLintptr offset, GLsizeiptr size, bool range,
bool dsa);
GLintptr offset, GLsizeiptr size,
const char *caller);
/*@}*/