From d79c950eebc3614d44e688172ffeb59fb6cfd3fa Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 18 Aug 2016 09:55:49 +0100 Subject: mesa: Rearrange legal_texobj_target to look more like _mesa_legal_get_tex_level_parameter_target This makes it a bit easier to add support for more features in different APIs. Signed-off-by: Ian Romanick Reviewed-by: Ilia Mirkin Reviewed-by: Kenneth Graunke --- src/mesa/main/texstorage.c | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/src/mesa/main/texstorage.c b/src/mesa/main/texstorage.c index ab8324f176e..e319fa5c334 100644 --- a/src/mesa/main/texstorage.c +++ b/src/mesa/main/texstorage.c @@ -51,11 +51,31 @@ static GLboolean legal_texobj_target(struct gl_context *ctx, GLuint dims, GLenum target) { - if (_mesa_is_gles3(ctx) - && target != GL_TEXTURE_2D - && target != GL_TEXTURE_CUBE_MAP - && target != GL_TEXTURE_3D - && target != GL_TEXTURE_2D_ARRAY) + if (dims < 1 || dims > 3) { + _mesa_problem(ctx, "invalid dims=%u in legal_texobj_target()", dims); + return GL_FALSE; + } + + switch (dims) { + case 2: + switch (target) { + case GL_TEXTURE_2D: + return GL_TRUE; + case GL_TEXTURE_CUBE_MAP: + return ctx->Extensions.ARB_texture_cube_map; + } + break; + case 3: + switch (target) { + case GL_TEXTURE_3D: + return GL_TRUE; + case GL_TEXTURE_2D_ARRAY: + return ctx->Extensions.EXT_texture_array; + } + break; + } + + if (!_mesa_is_desktop_gl(ctx)) return GL_FALSE; switch (dims) { @@ -69,10 +89,8 @@ legal_texobj_target(struct gl_context *ctx, GLuint dims, GLenum target) } case 2: switch (target) { - case GL_TEXTURE_2D: case GL_PROXY_TEXTURE_2D: return GL_TRUE; - case GL_TEXTURE_CUBE_MAP: case GL_PROXY_TEXTURE_CUBE_MAP: return ctx->Extensions.ARB_texture_cube_map; case GL_TEXTURE_RECTANGLE: @@ -86,10 +104,8 @@ legal_texobj_target(struct gl_context *ctx, GLuint dims, GLenum target) } case 3: switch (target) { - case GL_TEXTURE_3D: case GL_PROXY_TEXTURE_3D: return GL_TRUE; - case GL_TEXTURE_2D_ARRAY: case GL_PROXY_TEXTURE_2D_ARRAY: return ctx->Extensions.EXT_texture_array; case GL_TEXTURE_CUBE_MAP_ARRAY: @@ -99,8 +115,7 @@ legal_texobj_target(struct gl_context *ctx, GLuint dims, GLenum target) return GL_FALSE; } default: - _mesa_problem(ctx, "invalid dims=%u in legal_texobj_target()", dims); - return GL_FALSE; + unreachable("impossible dimensions"); } } -- cgit v1.2.3