aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/main/texparam.c
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/mesa/main/texparam.c')
-rw-r--r--mesalib/src/mesa/main/texparam.c89
1 files changed, 18 insertions, 71 deletions
diff --git a/mesalib/src/mesa/main/texparam.c b/mesalib/src/mesa/main/texparam.c
index 7c59d119f..b7ed50dd5 100644
--- a/mesalib/src/mesa/main/texparam.c
+++ b/mesalib/src/mesa/main/texparam.c
@@ -118,14 +118,15 @@ validate_texture_wrap_mode(struct gl_context * ctx, GLenum target, GLenum wrap)
/**
* Get current texture object for given target.
* Return NULL if any error (and record the error).
- * Note that this is different from _mesa_select_tex_object() in that proxy
- * targets are not accepted.
+ * Note that this is different from _mesa_get_current_tex_object() in that
+ * proxy targets are not accepted.
* Only the glGetTexLevelParameter() functions accept proxy targets.
*/
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];
}
@@ -784,7 +734,7 @@ _mesa_TexParameterf(GLenum target, GLenum pname, GLfloat param)
}
if (ctx->Driver.TexParameter && need_update) {
- ctx->Driver.TexParameter(ctx, target, texObj, pname, &param);
+ ctx->Driver.TexParameter(ctx, texObj, pname, &param);
}
}
@@ -855,7 +805,7 @@ _mesa_TexParameterfv(GLenum target, GLenum pname, const GLfloat *params)
}
if (ctx->Driver.TexParameter && need_update) {
- ctx->Driver.TexParameter(ctx, target, texObj, pname, params);
+ ctx->Driver.TexParameter(ctx, texObj, pname, params);
}
}
@@ -898,7 +848,7 @@ _mesa_TexParameteri(GLenum target, GLenum pname, GLint param)
if (ctx->Driver.TexParameter && need_update) {
GLfloat fparam = (GLfloat) param;
- ctx->Driver.TexParameter(ctx, target, texObj, pname, &fparam);
+ ctx->Driver.TexParameter(ctx, texObj, pname, &fparam);
}
}
@@ -954,7 +904,7 @@ _mesa_TexParameteriv(GLenum target, GLenum pname, const GLint *params)
fparams[2] = INT_TO_FLOAT(params[2]);
fparams[3] = INT_TO_FLOAT(params[3]);
}
- ctx->Driver.TexParameter(ctx, target, texObj, pname, fparams);
+ ctx->Driver.TexParameter(ctx, texObj, pname, fparams);
}
}
@@ -1081,7 +1031,7 @@ get_tex_level_parameter_image(struct gl_context *ctx,
GLenum pname, GLint *params)
{
const struct gl_texture_image *img = NULL;
- gl_format texFormat;
+ mesa_format texFormat;
img = _mesa_select_tex_image(ctx, texObj, target, level);
if (!img || img->TexFormat == MESA_FORMAT_NONE) {
@@ -1169,7 +1119,7 @@ get_tex_level_parameter_image(struct gl_context *ctx,
if (ctx->Version < 30 &&
!ctx->Extensions.EXT_texture_shared_exponent)
goto invalid_pname;
- *params = texFormat == MESA_FORMAT_RGB9_E5_FLOAT ? 5 : 0;
+ *params = texFormat == MESA_FORMAT_R9G9B9E5_FLOAT ? 5 : 0;
break;
/* GL_ARB_texture_compression */
@@ -1237,7 +1187,7 @@ get_tex_level_parameter_buffer(struct gl_context *ctx,
GLenum pname, GLint *params)
{
const struct gl_buffer_object *bo = texObj->BufferObject;
- gl_format texFormat = texObj->_BufferObjectFormat;
+ mesa_format texFormat = texObj->_BufferObjectFormat;
GLenum internalFormat = texObj->BufferObjectFormat;
GLenum baseFormat = _mesa_get_format_base_format(texFormat);
@@ -1356,7 +1306,6 @@ void GLAPIENTRY
_mesa_GetTexLevelParameteriv( GLenum target, GLint level,
GLenum pname, GLint *params )
{
- const struct gl_texture_unit *texUnit;
struct gl_texture_object *texObj;
GLint maxLevels;
GET_CURRENT_CONTEXT(ctx);
@@ -1367,8 +1316,6 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
return;
}
- texUnit = _mesa_get_current_tex_unit(ctx);
-
if (!legal_get_tex_level_parameter_target(ctx, target)) {
_mesa_error(ctx, GL_INVALID_ENUM,
"glGetTexLevelParameter[if]v(target=0x%x)", target);
@@ -1383,7 +1330,7 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
return;
}
- texObj = _mesa_select_tex_object(ctx, texUnit, target);
+ texObj = _mesa_get_current_tex_object(ctx, target);
if (target == GL_TEXTURE_BUFFER)
get_tex_level_parameter_buffer(ctx, texObj, pname, params);