From aecdb21be8f4cd4963d20fa42c2c7291ece874e6 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Mon, 3 Oct 2016 16:37:25 -0700 Subject: mesa: Reorganize check_textarget(). Having one top-level switch statement covering all known texture targets will make the next change easier to implement. Signed-off-by: Kenneth Graunke Reviewed-by: Timothy Arceri --- src/mesa/main/fbobject.c | 80 ++++++++++++++++++++++-------------------------- 1 file changed, 37 insertions(+), 43 deletions(-) (limited to 'src/mesa/main') diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index 09da6b70d87..f8899e6dfb9 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -2991,54 +2991,48 @@ check_textarget(struct gl_context *ctx, int dims, GLenum target, { bool err = false; - switch (dims) { - case 1: - switch (textarget) { - case GL_TEXTURE_1D: - break; - case GL_TEXTURE_1D_ARRAY: - err = !ctx->Extensions.EXT_texture_array; - break; - default: - err = true; - } + switch (textarget) { + case GL_TEXTURE_1D: + err = dims != 1; break; - case 2: - switch (textarget) { - case GL_TEXTURE_2D: - break; - case GL_TEXTURE_RECTANGLE: - err = _mesa_is_gles(ctx) - || !ctx->Extensions.NV_texture_rectangle; - break; - case GL_TEXTURE_CUBE_MAP_POSITIVE_X: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: - err = !ctx->Extensions.ARB_texture_cube_map; - break; - case GL_TEXTURE_2D_ARRAY: - err = (_mesa_is_gles(ctx) && ctx->Version < 30) - || !ctx->Extensions.EXT_texture_array; - break; - case GL_TEXTURE_2D_MULTISAMPLE: - case GL_TEXTURE_2D_MULTISAMPLE_ARRAY: - err = (_mesa_is_gles(ctx) || - !ctx->Extensions.ARB_texture_multisample) && - !_mesa_is_gles31(ctx); - break; - default: - err = true; - } + case GL_TEXTURE_1D_ARRAY: + err = dims != 1 || !ctx->Extensions.EXT_texture_array; break; - case 3: - if (textarget != GL_TEXTURE_3D) - err = true; + case GL_TEXTURE_2D: + err = dims != 2; + break; + case GL_TEXTURE_2D_ARRAY: + err = dims != 2 || !ctx->Extensions.EXT_texture_array || + (_mesa_is_gles(ctx) && ctx->Version < 30); + break; + case GL_TEXTURE_2D_MULTISAMPLE: + case GL_TEXTURE_2D_MULTISAMPLE_ARRAY: + err = dims != 2 || + !ctx->Extensions.ARB_texture_multisample || + (_mesa_is_gles(ctx) && ctx->Version < 31); + break; + case GL_TEXTURE_RECTANGLE: + err = dims != 2 || _mesa_is_gles(ctx) || + !ctx->Extensions.NV_texture_rectangle; + break; + case GL_TEXTURE_CUBE_MAP: + case GL_TEXTURE_CUBE_MAP_ARRAY: + err = true; + break; + case GL_TEXTURE_CUBE_MAP_POSITIVE_X: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: + err = dims != 2 || !ctx->Extensions.ARB_texture_cube_map; + break; + case GL_TEXTURE_3D: + err = dims != 3; break; default: err = true; + break; } if (err) { -- cgit v1.2.3