summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2016-08-18 09:55:49 +0100
committerIan Romanick <[email protected]>2016-08-26 15:03:15 -0700
commitd79c950eebc3614d44e688172ffeb59fb6cfd3fa (patch)
tree5076c7dc7ec6376c9a57978fd0b782f2c0dd6727 /src/mesa/main
parentef5bad09c4623892a358046b7ece4dcb273ad700 (diff)
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 <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/texstorage.c37
1 files 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");
}
}