summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre-Eric Pelloux-Prayer <[email protected]>2019-06-25 16:39:37 +0200
committerMarek Olšák <[email protected]>2019-06-28 15:41:29 -0400
commit6535964fdf77a3f4bd356b089629f783957a3cd9 (patch)
treeaf870f59f72e0744ddf4e49ebe38d8fccf950423
parent32eefb74511a4b6ff7eed169ce2a24f51ec974a0 (diff)
mesa: extract helper function for glTexParameter*
Reviewed-by: Marek Olšák <[email protected]> Signed-off-by: Marek Olšák <[email protected]>
-rw-r--r--src/mesa/main/texparam.c37
1 files changed, 24 insertions, 13 deletions
diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c
index a3ec7241986..a81036041d1 100644
--- a/src/mesa/main/texparam.c
+++ b/src/mesa/main/texparam.c
@@ -146,6 +146,28 @@ get_texobj_by_target(struct gl_context *ctx, GLenum target, GLboolean get)
return texUnit->CurrentTex[targetIndex];
}
+
+static bool
+is_texparameteri_target_valid(GLenum target)
+{
+ switch (target) {
+ case GL_TEXTURE_1D:
+ case GL_TEXTURE_1D_ARRAY:
+ case GL_TEXTURE_2D:
+ case GL_TEXTURE_2D_ARRAY:
+ case GL_TEXTURE_2D_MULTISAMPLE:
+ case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
+ case GL_TEXTURE_3D:
+ case GL_TEXTURE_CUBE_MAP:
+ case GL_TEXTURE_CUBE_MAP_ARRAY:
+ case GL_TEXTURE_RECTANGLE:
+ return true;
+ default:
+ return false;
+ }
+}
+
+
/**
* Get current texture object for given name.
* Return NULL if any error (and record the error).
@@ -161,23 +183,12 @@ get_texobj_by_name(struct gl_context *ctx, GLuint texture, const char *name)
if (!texObj)
return NULL;
- switch (texObj->Target) {
- case GL_TEXTURE_1D:
- case GL_TEXTURE_1D_ARRAY:
- case GL_TEXTURE_2D:
- case GL_TEXTURE_2D_ARRAY:
- case GL_TEXTURE_2D_MULTISAMPLE:
- case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
- case GL_TEXTURE_3D:
- case GL_TEXTURE_CUBE_MAP:
- case GL_TEXTURE_CUBE_MAP_ARRAY:
- case GL_TEXTURE_RECTANGLE:
- return texObj;
- default:
+ if (!is_texparameteri_target_valid(texObj->Target)) {
_mesa_error(ctx, GL_INVALID_OPERATION, "%s(target)", name);
return NULL;
}
+ return texObj;
}