diff options
Diffstat (limited to 'mesalib/src/mesa/main/texparam.c')
-rw-r--r-- | mesalib/src/mesa/main/texparam.c | 132 |
1 files changed, 78 insertions, 54 deletions
diff --git a/mesalib/src/mesa/main/texparam.c b/mesalib/src/mesa/main/texparam.c index 9d1fdd056..db4c7a5ed 100644 --- a/mesalib/src/mesa/main/texparam.c +++ b/mesalib/src/mesa/main/texparam.c @@ -31,9 +31,10 @@ #include "main/glheader.h" +#include "main/colormac.h" #include "main/context.h" #include "main/enums.h" -#include "main/colormac.h" +#include "main/formats.h" #include "main/macros.h" #include "main/texcompress.h" #include "main/texparam.h" @@ -78,6 +79,8 @@ validate_texture_wrap_mode(GLcontext * ctx, GLenum target, GLenum wrap) /** * Get current texture object for given target. * Return NULL if any error. + * Note that this is different from _mesa_select_tex_object() in that proxy + * targets are not accepted. */ static struct gl_texture_object * get_texobj(GLcontext *ctx, GLenum target) @@ -544,13 +547,20 @@ _mesa_TexParameterf(GLenum target, GLenum pname, GLfloat param) case GL_DEPTH_TEXTURE_MODE_ARB: { /* convert float param to int */ - GLint p = (GLint) param; - need_update = set_tex_parameteri(ctx, texObj, pname, &p); + GLint p[4]; + p[0] = (GLint) param; + p[1] = p[2] = p[3] = 0; + need_update = set_tex_parameteri(ctx, texObj, pname, p); } break; default: - /* this will generate an error if pname is illegal */ - need_update = set_tex_parameterf(ctx, texObj, pname, ¶m); + { + /* this will generate an error if pname is illegal */ + GLfloat p[4]; + p[0] = param; + p[1] = p[2] = p[3] = 0.0F; + need_update = set_tex_parameterf(ctx, texObj, pname, p); + } } if (ctx->Driver.TexParameter && need_update) { @@ -585,8 +595,10 @@ _mesa_TexParameterfv(GLenum target, GLenum pname, const GLfloat *params) case GL_DEPTH_TEXTURE_MODE_ARB: { /* convert float param to int */ - GLint p = (GLint) params[0]; - need_update = set_tex_parameteri(ctx, texObj, pname, &p); + GLint p[4]; + p[0] = (GLint) params[0]; + p[1] = p[2] = p[3] = 0; + need_update = set_tex_parameteri(ctx, texObj, pname, p); } break; @@ -599,7 +611,7 @@ _mesa_TexParameterfv(GLenum target, GLenum pname, const GLfloat *params) iparams[1] = (GLint) params[1]; iparams[2] = (GLint) params[2]; iparams[3] = (GLint) params[3]; - need_update = set_tex_parameteri(ctx, target, iparams); + need_update = set_tex_parameteri(ctx, texObj, pname, iparams); } break; #endif @@ -635,14 +647,21 @@ _mesa_TexParameteri(GLenum target, GLenum pname, GLint param) case GL_TEXTURE_LOD_BIAS: case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB: { - GLfloat fparam = (GLfloat) param; + GLfloat fparam[4]; + fparam[0] = (GLfloat) param; + fparam[1] = fparam[2] = fparam[3] = 0.0F; /* convert int param to float */ - need_update = set_tex_parameterf(ctx, texObj, pname, &fparam); + need_update = set_tex_parameterf(ctx, texObj, pname, fparam); } break; default: /* this will generate an error if pname is illegal */ - need_update = set_tex_parameteri(ctx, texObj, pname, ¶m); + { + GLint iparam[4]; + iparam[0] = param; + iparam[1] = iparam[2] = iparam[3] = 0; + need_update = set_tex_parameteri(ctx, texObj, pname, iparam); + } } if (ctx->Driver.TexParameter && need_update) { @@ -684,8 +703,10 @@ _mesa_TexParameteriv(GLenum target, GLenum pname, const GLint *params) case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB: { /* convert int param to float */ - GLfloat fparam = (GLfloat) params[0]; - need_update = set_tex_parameterf(ctx, texObj, pname, &fparam); + GLfloat fparams[4]; + fparams[0] = (GLfloat) params[0]; + fparams[1] = fparams[2] = fparams[3] = 0.0F; + need_update = set_tex_parameterf(ctx, texObj, pname, fparams); } break; default: @@ -726,6 +747,7 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level, const struct gl_texture_image *img = NULL; GLboolean isProxy; GLint maxLevels; + gl_format texFormat; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); @@ -763,6 +785,8 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level, goto out; } + texFormat = img->TexFormat; + isProxy = _mesa_is_proxy_texture(target); switch (pname) { @@ -776,10 +800,9 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level, *params = img->Depth; break; case GL_TEXTURE_INTERNAL_FORMAT: - if (img->IsCompressed) { + if (_mesa_is_format_compressed(img->TexFormat)) { /* need to return the actual compressed format */ - *params = _mesa_compressed_format_to_glenum(ctx, - img->TexFormat->MesaFormat); + *params = _mesa_compressed_format_to_glenum(ctx, img->TexFormat); } else { /* return the user's requested internal format */ @@ -790,20 +813,10 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level, *params = img->Border; break; case GL_TEXTURE_RED_SIZE: - if (img->_BaseFormat == GL_RGB || img->_BaseFormat == GL_RGBA) - *params = img->TexFormat->RedBits; - else - *params = 0; - break; case GL_TEXTURE_GREEN_SIZE: - if (img->_BaseFormat == GL_RGB || img->_BaseFormat == GL_RGBA) - *params = img->TexFormat->GreenBits; - else - *params = 0; - break; case GL_TEXTURE_BLUE_SIZE: if (img->_BaseFormat == GL_RGB || img->_BaseFormat == GL_RGBA) - *params = img->TexFormat->BlueBits; + *params = _mesa_get_format_bits(texFormat, pname); else *params = 0; break; @@ -811,36 +824,44 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level, if (img->_BaseFormat == GL_ALPHA || img->_BaseFormat == GL_LUMINANCE_ALPHA || img->_BaseFormat == GL_RGBA) - *params = img->TexFormat->AlphaBits; + *params = _mesa_get_format_bits(texFormat, pname); else *params = 0; break; case GL_TEXTURE_INTENSITY_SIZE: if (img->_BaseFormat != GL_INTENSITY) *params = 0; - else if (img->TexFormat->IntensityBits > 0) - *params = img->TexFormat->IntensityBits; - else /* intensity probably stored as rgb texture */ - *params = MIN2(img->TexFormat->RedBits, img->TexFormat->GreenBits); + else { + *params = _mesa_get_format_bits(texFormat, pname); + if (*params == 0) { + /* intensity probably stored as rgb texture */ + *params = MIN2(_mesa_get_format_bits(texFormat, GL_TEXTURE_RED_SIZE), + _mesa_get_format_bits(texFormat, GL_TEXTURE_GREEN_SIZE)); + } + } break; case GL_TEXTURE_LUMINANCE_SIZE: if (img->_BaseFormat != GL_LUMINANCE && img->_BaseFormat != GL_LUMINANCE_ALPHA) *params = 0; - else if (img->TexFormat->LuminanceBits > 0) - *params = img->TexFormat->LuminanceBits; - else /* luminance probably stored as rgb texture */ - *params = MIN2(img->TexFormat->RedBits, img->TexFormat->GreenBits); + else { + *params = _mesa_get_format_bits(texFormat, pname); + if (*params == 0) { + /* luminance probably stored as rgb texture */ + *params = MIN2(_mesa_get_format_bits(texFormat, GL_TEXTURE_RED_SIZE), + _mesa_get_format_bits(texFormat, GL_TEXTURE_GREEN_SIZE)); + } + } break; case GL_TEXTURE_INDEX_SIZE_EXT: if (img->_BaseFormat == GL_COLOR_INDEX) - *params = img->TexFormat->IndexBits; + *params = _mesa_get_format_bits(texFormat, pname); else *params = 0; break; case GL_TEXTURE_DEPTH_SIZE_ARB: if (ctx->Extensions.ARB_depth_texture) - *params = img->TexFormat->DepthBits; + *params = _mesa_get_format_bits(texFormat, pname); else _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexLevelParameter[if]v(pname)"); @@ -848,7 +869,7 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level, case GL_TEXTURE_STENCIL_SIZE_EXT: if (ctx->Extensions.EXT_packed_depth_stencil || ctx->Extensions.ARB_framebuffer_object) { - *params = img->TexFormat->StencilBits; + *params = _mesa_get_format_bits(texFormat, pname); } else { _mesa_error(ctx, GL_INVALID_ENUM, @@ -858,13 +879,9 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level, /* GL_ARB_texture_compression */ case GL_TEXTURE_COMPRESSED_IMAGE_SIZE: - if (img->IsCompressed && !isProxy) { - /* Don't use ctx->Driver.CompressedTextureSize() since that - * may returned a padded hardware size. - */ - *params = _mesa_compressed_texture_size(ctx, img->Width, - img->Height, img->Depth, - img->TexFormat->MesaFormat); + if (_mesa_is_format_compressed(img->TexFormat) && !isProxy) { + *params = _mesa_format_image_size(texFormat, img->Width, + img->Height, img->Depth); } else { _mesa_error(ctx, GL_INVALID_OPERATION, @@ -872,13 +889,14 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level, } break; case GL_TEXTURE_COMPRESSED: - *params = (GLint) img->IsCompressed; + *params = (GLint) _mesa_is_format_compressed(img->TexFormat); break; /* GL_ARB_texture_float */ case GL_TEXTURE_RED_TYPE_ARB: if (ctx->Extensions.ARB_texture_float) { - *params = img->TexFormat->RedBits ? img->TexFormat->DataType : GL_NONE; + *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_RED_SIZE) ? + _mesa_get_format_datatype(texFormat) : GL_NONE; } else { _mesa_error(ctx, GL_INVALID_ENUM, @@ -887,7 +905,8 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level, break; case GL_TEXTURE_GREEN_TYPE_ARB: if (ctx->Extensions.ARB_texture_float) { - *params = img->TexFormat->GreenBits ? img->TexFormat->DataType : GL_NONE; + *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_GREEN_SIZE) ? + _mesa_get_format_datatype(texFormat) : GL_NONE; } else { _mesa_error(ctx, GL_INVALID_ENUM, @@ -896,7 +915,8 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level, break; case GL_TEXTURE_BLUE_TYPE_ARB: if (ctx->Extensions.ARB_texture_float) { - *params = img->TexFormat->BlueBits ? img->TexFormat->DataType : GL_NONE; + *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_BLUE_SIZE) ? + _mesa_get_format_datatype(texFormat) : GL_NONE; } else { _mesa_error(ctx, GL_INVALID_ENUM, @@ -905,7 +925,8 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level, break; case GL_TEXTURE_ALPHA_TYPE_ARB: if (ctx->Extensions.ARB_texture_float) { - *params = img->TexFormat->AlphaBits ? img->TexFormat->DataType : GL_NONE; + *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_ALPHA_SIZE) ? + _mesa_get_format_datatype(texFormat) : GL_NONE; } else { _mesa_error(ctx, GL_INVALID_ENUM, @@ -914,7 +935,8 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level, break; case GL_TEXTURE_LUMINANCE_TYPE_ARB: if (ctx->Extensions.ARB_texture_float) { - *params = img->TexFormat->LuminanceBits ? img->TexFormat->DataType : GL_NONE; + *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_LUMINANCE_SIZE) ? + _mesa_get_format_datatype(texFormat) : GL_NONE; } else { _mesa_error(ctx, GL_INVALID_ENUM, @@ -923,7 +945,8 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level, break; case GL_TEXTURE_INTENSITY_TYPE_ARB: if (ctx->Extensions.ARB_texture_float) { - *params = img->TexFormat->IntensityBits ? img->TexFormat->DataType : GL_NONE; + *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_INTENSITY_SIZE) ? + _mesa_get_format_datatype(texFormat) : GL_NONE; } else { _mesa_error(ctx, GL_INVALID_ENUM, @@ -932,7 +955,8 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level, break; case GL_TEXTURE_DEPTH_TYPE_ARB: if (ctx->Extensions.ARB_texture_float) { - *params = img->TexFormat->DepthBits ? img->TexFormat->DataType : GL_NONE; + *params = _mesa_get_format_bits(texFormat, GL_TEXTURE_DEPTH_SIZE) ? + _mesa_get_format_datatype(texFormat) : GL_NONE; } else { _mesa_error(ctx, GL_INVALID_ENUM, |