summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2013-11-23 12:16:57 -0800
committerIan Romanick <ian.d.romanick@intel.com>2014-02-02 16:49:08 +0100
commita722454dac284e31564d62e537976070bba1eaf8 (patch)
tree6af1c45d454bfbb8939a0ba6b6798d6801a83f8e /src
parent35e7027dab14b059344d7b93404c76d451ea2baf (diff)
mesa: Use common _mesa_tex_target_to_index in tex param code
TEXTURE_BUFFER_INDEX has to be specially called out because it is not allowed in any of the glTexParameter or glGetTexParameter functions. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Brian Paul <brianp@vmware.com>
Diffstat (limited to 'src')
-rw-r--r--src/mesa/main/texparam.c66
1 files changed, 8 insertions, 58 deletions
diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c
index 0931ace749b..b7ed50dd5d6 100644
--- a/src/mesa/main/texparam.c
+++ b/src/mesa/main/texparam.c
@@ -126,6 +126,7 @@ static struct gl_texture_object *
get_texobj(struct gl_context *ctx, GLenum target, GLboolean get)
{
struct gl_texture_unit *texUnit;
+ int targetIndex;
if (ctx->Texture.CurrentUnit >= ctx->Const.MaxCombinedTextureImageUnits) {
_mesa_error(ctx, GL_INVALID_OPERATION,
@@ -135,66 +136,15 @@ get_texobj(struct gl_context *ctx, GLenum target, GLboolean get)
texUnit = _mesa_get_current_tex_unit(ctx);
- switch (target) {
- case GL_TEXTURE_1D:
- if (_mesa_is_desktop_gl(ctx))
- return texUnit->CurrentTex[TEXTURE_1D_INDEX];
- break;
- case GL_TEXTURE_2D:
- return texUnit->CurrentTex[TEXTURE_2D_INDEX];
- case GL_TEXTURE_3D:
- if (ctx->API != API_OPENGLES)
- return texUnit->CurrentTex[TEXTURE_3D_INDEX];
- break;
- case GL_TEXTURE_CUBE_MAP:
- if (ctx->Extensions.ARB_texture_cube_map) {
- return texUnit->CurrentTex[TEXTURE_CUBE_INDEX];
- }
- break;
- case GL_TEXTURE_RECTANGLE_NV:
- if (_mesa_is_desktop_gl(ctx)
- && ctx->Extensions.NV_texture_rectangle) {
- return texUnit->CurrentTex[TEXTURE_RECT_INDEX];
- }
- break;
- case GL_TEXTURE_1D_ARRAY_EXT:
- if (_mesa_is_desktop_gl(ctx) && ctx->Extensions.EXT_texture_array) {
- return texUnit->CurrentTex[TEXTURE_1D_ARRAY_INDEX];
- }
- break;
- case GL_TEXTURE_2D_ARRAY_EXT:
- if ((_mesa_is_desktop_gl(ctx) || _mesa_is_gles3(ctx))
- && ctx->Extensions.EXT_texture_array) {
- return texUnit->CurrentTex[TEXTURE_2D_ARRAY_INDEX];
- }
- break;
- case GL_TEXTURE_EXTERNAL_OES:
- if (_mesa_is_gles(ctx) && ctx->Extensions.OES_EGL_image_external) {
- return texUnit->CurrentTex[TEXTURE_EXTERNAL_INDEX];
- }
- break;
- case GL_TEXTURE_CUBE_MAP_ARRAY:
- if (ctx->Extensions.ARB_texture_cube_map_array) {
- return texUnit->CurrentTex[TEXTURE_CUBE_ARRAY_INDEX];
- }
- break;
- case GL_TEXTURE_2D_MULTISAMPLE:
- if (ctx->Extensions.ARB_texture_multisample) {
- return texUnit->CurrentTex[TEXTURE_2D_MULTISAMPLE_INDEX];
- }
- break;
- case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
- if (ctx->Extensions.ARB_texture_multisample) {
- return texUnit->CurrentTex[TEXTURE_2D_MULTISAMPLE_ARRAY_INDEX];
- }
- break;
- default:
- ;
+ targetIndex = _mesa_tex_target_to_index(ctx, target);
+ if (targetIndex < 0 || targetIndex == TEXTURE_BUFFER_INDEX) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "gl%sTexParameter(target)", get ? "Get" : "");
+ return NULL;
}
+ assert(targetIndex < NUM_TEXTURE_TARGETS);
- _mesa_error(ctx, GL_INVALID_ENUM,
- "gl%sTexParameter(target)", get ? "Get" : "");
- return NULL;
+ return texUnit->CurrentTex[targetIndex];
}