summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2012-06-10 18:41:58 -0700
committerIan Romanick <[email protected]>2012-08-17 09:14:36 -0700
commit9e4fde85e46f406b37ad372487fbff4ed51c65e4 (patch)
tree9b1e55e7646b142c137e4f8810f3cc610a773dd1 /src/mesa
parent63396ce4c0fe067f69d1b53d0408627a421c4678 (diff)
mesa: Add explicit target checking to GetTexLevelParameter[if]v().
Previously, it relied on _mesa_max_texture_levels() for texture target error checking. This was somewhat dodgy, as _mesa_max_texture_levels() is called in seven diferent places, not all of which necessarily accept the same list of targets. I copied the list of legal targets from _mesa_max_texture_levels(), so this patch should not introduce any change in behavior. Future patches will cause the two to diverge. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/main/texparam.c41
1 files changed, 38 insertions, 3 deletions
diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c
index 690fd6c2562..fe4115c4e3b 100644
--- a/src/mesa/main/texparam.c
+++ b/src/mesa/main/texparam.c
@@ -871,6 +871,40 @@ _mesa_TexParameterIuiv(GLenum target, GLenum pname, const GLuint *params)
}
+static GLboolean
+legal_get_tex_level_parameter_target(struct gl_context *ctx, GLenum target)
+{
+ switch (target) {
+ case GL_TEXTURE_1D:
+ case GL_PROXY_TEXTURE_1D:
+ case GL_TEXTURE_2D:
+ case GL_PROXY_TEXTURE_2D:
+ case GL_TEXTURE_3D:
+ case GL_PROXY_TEXTURE_3D:
+ return GL_TRUE;
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB:
+ case GL_PROXY_TEXTURE_CUBE_MAP_ARB:
+ return ctx->Extensions.ARB_texture_cube_map;
+ case GL_TEXTURE_RECTANGLE_NV:
+ case GL_PROXY_TEXTURE_RECTANGLE_NV:
+ return ctx->Extensions.NV_texture_rectangle;
+ case GL_TEXTURE_1D_ARRAY_EXT:
+ case GL_PROXY_TEXTURE_1D_ARRAY_EXT:
+ case GL_TEXTURE_2D_ARRAY_EXT:
+ case GL_PROXY_TEXTURE_2D_ARRAY_EXT:
+ return (ctx->Extensions.MESA_texture_array ||
+ ctx->Extensions.EXT_texture_array);
+ default:
+ return GL_FALSE;
+ }
+}
+
+
void GLAPIENTRY
_mesa_GetTexLevelParameterfv( GLenum target, GLint level,
GLenum pname, GLfloat *params )
@@ -901,14 +935,15 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
texUnit = _mesa_get_current_tex_unit(ctx);
- /* this will catch bad target values */
- maxLevels = _mesa_max_texture_levels(ctx, target);
- if (maxLevels == 0) {
+ if (!legal_get_tex_level_parameter_target(ctx, target)) {
_mesa_error(ctx, GL_INVALID_ENUM,
"glGetTexLevelParameter[if]v(target=0x%x)", target);
return;
}
+ maxLevels = _mesa_max_texture_levels(ctx, target);
+ assert(maxLevels != 0);
+
if (level < 0 || level >= maxLevels) {
_mesa_error( ctx, GL_INVALID_VALUE, "glGetTexLevelParameter[if]v" );
return;