[Mesa-dev] [PATCH 3/7] main: Refactor _mesa_texture_buffer_range.
Laura Ekstrand
laura at jlekstrand.net
Wed Mar 4 16:41:21 PST 2015
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]
---
src/mesa/main/teximage.c | 58 ++++++++++++++++++------------------------------
src/mesa/main/teximage.h | 6 ++---
2 files changed, 25 insertions(+), 39 deletions(-)
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 6374ec9..706c76b 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -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
diff --git a/src/mesa/main/teximage.h b/src/mesa/main/teximage.h
index 9468650..db6b648 100644
--- a/src/mesa/main/teximage.h
+++ b/src/mesa/main/teximage.h
@@ -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);
/*@}*/
--
2.1.0
More information about the mesa-dev
mailing list