summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorDylan Noblesmith <[email protected]>2013-09-20 11:55:41 -0400
committerKenneth Graunke <[email protected]>2013-09-24 11:29:17 -0700
commit49f8fc64de4d06fd516f15cc77449d33f0b85714 (patch)
treef0994ecb30979ad3633a30811f0b5048e7a314d2 /src/mesa/main
parentea3847b12e8968c3d1644dd032f1ba1ad132e7c9 (diff)
mesa: remove handcounted magic number
Also make it a compile-time error with STATIC_ASSERT. Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/teximage.c33
1 files changed, 20 insertions, 13 deletions
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index b719fc856a1..c1261138da1 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -661,22 +661,29 @@ _mesa_delete_texture_image(struct gl_context *ctx,
GLboolean
_mesa_is_proxy_texture(GLenum target)
{
+ unsigned i;
+ static const GLenum targets[] = {
+ GL_PROXY_TEXTURE_1D,
+ GL_PROXY_TEXTURE_2D,
+ GL_PROXY_TEXTURE_3D,
+ GL_PROXY_TEXTURE_CUBE_MAP,
+ GL_PROXY_TEXTURE_RECTANGLE,
+ GL_PROXY_TEXTURE_1D_ARRAY,
+ GL_PROXY_TEXTURE_2D_ARRAY,
+ GL_PROXY_TEXTURE_CUBE_MAP_ARRAY,
+ GL_PROXY_TEXTURE_2D_MULTISAMPLE,
+ GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY
+ };
/*
- * NUM_TEXTURE_TARGETS should match number of terms below, except there's no
+ * NUM_TEXTURE_TARGETS should match number of terms above, except there's no
* proxy for GL_TEXTURE_BUFFER and GL_TEXTURE_EXTERNAL_OES.
*/
- assert(NUM_TEXTURE_TARGETS == 10 + 2);
-
- return (target == GL_PROXY_TEXTURE_1D ||
- target == GL_PROXY_TEXTURE_2D ||
- target == GL_PROXY_TEXTURE_3D ||
- target == GL_PROXY_TEXTURE_CUBE_MAP_ARB ||
- target == GL_PROXY_TEXTURE_RECTANGLE_NV ||
- target == GL_PROXY_TEXTURE_1D_ARRAY_EXT ||
- target == GL_PROXY_TEXTURE_2D_ARRAY_EXT ||
- target == GL_PROXY_TEXTURE_CUBE_MAP_ARRAY ||
- target == GL_PROXY_TEXTURE_2D_MULTISAMPLE ||
- target == GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY);
+ STATIC_ASSERT(NUM_TEXTURE_TARGETS == Elements(targets) + 2);
+
+ for (i = 0; i < Elements(targets); ++i)
+ if (target == targets[i])
+ return GL_TRUE;
+ return GL_FALSE;
}