Mesa (master): mesa: remove _mesa_get_tex_unit_err() and fix error handling
Brian Paul
brianp at kemper.freedesktop.org
Thu Oct 1 14:09:22 UTC 2015
Module: Mesa
Branch: master
Commit: a9408f3ca14f2fb6286bd66bad06ee1bde0d8697
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a9408f3ca14f2fb6286bd66bad06ee1bde0d8697
Author: Brian Paul <brianp at vmware.com>
Date: Wed Sep 30 11:37:16 2015 -0600
mesa: remove _mesa_get_tex_unit_err() and fix error handling
This helper was only called from _mesa_BindTextureUnit(). It's simpler
to just inline it.
The error check / code / message in the helper was incorrect. It was
written for glBindTextures(), not glBindTextureUnit(). The correct
error for a bad texture unit number is GL_INVALID_VALUE. The error
message now reports the unit number rather than a GL_TEXTUREi enum.
Fixes a failure in piglit's arb_direct_state_access-bind-texture-unit test.
Reviewed-by: Tapani Pälli <tapani.palli at intel.com>
---
src/mesa/main/texobj.c | 9 +++++++--
src/mesa/main/texstate.h | 18 ------------------
2 files changed, 7 insertions(+), 20 deletions(-)
diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index d7654eb..105ec1e 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -1780,8 +1780,13 @@ _mesa_BindTextureUnit(GLuint unit, GLuint texture)
struct gl_texture_object *texObj;
struct gl_texture_unit *texUnit;
- /* Get the texture unit (this is an array look-up) */
- texUnit = _mesa_get_tex_unit_err(ctx, unit, "glBindTextureUnit");
+ if (unit >= _mesa_max_tex_unit(ctx)) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glBindTextureUnit(unit=%u)", unit);
+ return;
+ }
+
+ texUnit = _mesa_get_tex_unit(ctx, unit);
+ assert(texUnit);
if (!texUnit) {
return;
}
diff --git a/src/mesa/main/texstate.h b/src/mesa/main/texstate.h
index bee8c9c..52fe602 100644
--- a/src/mesa/main/texstate.h
+++ b/src/mesa/main/texstate.h
@@ -63,24 +63,6 @@ _mesa_max_tex_unit(struct gl_context *ctx)
ctx->Const.MaxTextureCoordUnits);
}
-static inline struct gl_texture_unit *
-_mesa_get_tex_unit_err(struct gl_context *ctx, GLuint unit, const char *func)
-{
- if (unit < _mesa_max_tex_unit(ctx))
- return _mesa_get_tex_unit(ctx, unit);
-
- /* Note: This error is a precedent set by glBindTextures. From the GL 4.5
- * specification (30.10.2014) Section 8.1 ("Texture Objects"):
- *
- * "An INVALID_OPERATION error is generated if first + count is greater
- * than the number of texture image units supported by the
- * implementation."
- */
- _mesa_error(ctx, GL_INVALID_OPERATION, "%s(unit=%s)", func,
- _mesa_enum_to_string(GL_TEXTURE0+unit));
- return NULL;
-}
-
extern void
_mesa_copy_texture_state( const struct gl_context *src, struct gl_context *dst );
More information about the mesa-commit
mailing list