X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fswrast%2Fs_texfilter.c;h=9e44fba3daf146c4c39634acef67a1278f595dac;hb=dd90d304f2751cbd3ca9a961c8e54d37aaa47d91;hp=bb4e38623c923d67923a43bd766d8630937adc54;hpb=b0edb9c38a6c63175e4fafdbb54102c4f4a94e2c;p=mesa.git diff --git a/src/mesa/swrast/s_texfilter.c b/src/mesa/swrast/s_texfilter.c index bb4e38623c9..9e44fba3daf 100644 --- a/src/mesa/swrast/s_texfilter.c +++ b/src/mesa/swrast/s_texfilter.c @@ -1,6 +1,6 @@ /* * Mesa 3-D graphics library - * Version: 6.5.3 + * Version: 7.0.3 * * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * @@ -23,11 +23,11 @@ */ -#include "glheader.h" -#include "context.h" -#include "colormac.h" -#include "imports.h" -#include "texformat.h" +#include "main/glheader.h" +#include "main/context.h" +#include "main/colormac.h" +#include "main/imports.h" +#include "main/texformat.h" #include "s_context.h" #include "s_texfilter.h" @@ -342,6 +342,7 @@ lerp_rgba_3d(GLchan result[4], GLfloat a, GLfloat b, GLfloat c, break; \ default: \ _mesa_problem(ctx, "Bad wrap mode"); \ + return; \ } \ } @@ -462,6 +463,7 @@ lerp_rgba_3d(GLchan result[4], GLfloat a, GLfloat b, GLfloat c, break; \ default: \ _mesa_problem(ctx, "Bad wrap mode"); \ + return; \ } \ } @@ -1036,7 +1038,7 @@ sample_2d_linear_repeat(GLcontext *ctx, ASSERT(tObj->WrapS == GL_REPEAT); ASSERT(tObj->WrapT == GL_REPEAT); ASSERT(img->Border == 0); - ASSERT(img->_BaseFormat != GL_COLOR_INDEX); + ASSERT(img->TexFormat->BaseFormat != GL_COLOR_INDEX); ASSERT(img->_IsPowerOfTwo); COMPUTE_LINEAR_REPEAT_TEXEL_LOCATION(texcoord[0], u, width, i0, i1); @@ -1191,7 +1193,8 @@ sample_linear_2d( GLcontext *ctx, (void) lambda; if (tObj->WrapS == GL_REPEAT && tObj->WrapT == GL_REPEAT && - image->_IsPowerOfTwo) { + image->_IsPowerOfTwo && + image->Border == 0) { for (i=0;iWrapS==GL_REPEAT); ASSERT(tObj->WrapT==GL_REPEAT); ASSERT(img->Border==0); - ASSERT(img->_BaseFormat==GL_RGB); + ASSERT(img->TexFormat->MesaFormat==MESA_FORMAT_RGB); ASSERT(img->_IsPowerOfTwo); for (k=0; kWrapS==GL_REPEAT); ASSERT(tObj->WrapT==GL_REPEAT); ASSERT(img->Border==0); - ASSERT(img->_BaseFormat==GL_RGBA); + ASSERT(img->TexFormat->MesaFormat==MESA_FORMAT_RGBA); ASSERT(img->_IsPowerOfTwo); for (i = 0; i < n; i++) { @@ -1301,7 +1304,7 @@ sample_lambda_2d( GLcontext *ctx, const GLboolean repeatNoBorderPOT = (tObj->WrapS == GL_REPEAT) && (tObj->WrapT == GL_REPEAT) && (tImg->Border == 0 && (tImg->Width == tImg->RowStride)) - && (tImg->_BaseFormat != GL_COLOR_INDEX) + && (tImg->TexFormat->BaseFormat != GL_COLOR_INDEX) && tImg->_IsPowerOfTwo; ASSERT(lambda != NULL); @@ -1316,16 +1319,10 @@ sample_lambda_2d( GLcontext *ctx, if (repeatNoBorderPOT) { switch (tImg->TexFormat->MesaFormat) { case MESA_FORMAT_RGB: - case MESA_FORMAT_RGB888: - /*case MESA_FORMAT_BGR888:*/ opt_sample_rgb_2d(ctx, tObj, m, texcoords + minStart, NULL, rgba + minStart); break; case MESA_FORMAT_RGBA: - case MESA_FORMAT_RGBA8888: - case MESA_FORMAT_ARGB8888: - /*case MESA_FORMAT_ABGR8888:*/ - /*case MESA_FORMAT_BGRA8888:*/ opt_sample_rgba_2d(ctx, tObj, m, texcoords + minStart, NULL, rgba + minStart); break; @@ -1379,16 +1376,10 @@ sample_lambda_2d( GLcontext *ctx, if (repeatNoBorderPOT) { switch (tImg->TexFormat->MesaFormat) { case MESA_FORMAT_RGB: - case MESA_FORMAT_RGB888: - /*case MESA_FORMAT_BGR888:*/ opt_sample_rgb_2d(ctx, tObj, m, texcoords + magStart, NULL, rgba + magStart); break; case MESA_FORMAT_RGBA: - case MESA_FORMAT_RGBA8888: - case MESA_FORMAT_ARGB8888: - /*case MESA_FORMAT_ABGR8888:*/ - /*case MESA_FORMAT_BGRA8888:*/ opt_sample_rgba_2d(ctx, tObj, m, texcoords + magStart, NULL, rgba + magStart); break; @@ -1865,8 +1856,19 @@ sample_cube_nearest_mipmap_nearest(GLcontext *ctx, for (i = 0; i < n; i++) { const struct gl_texture_image **images; GLfloat newCoord[4]; - GLint level = nearest_mipmap_level(tObj, lambda[i]); + GLint level; images = choose_cube_face(tObj, texcoord[i], newCoord); + + /* XXX we actually need to recompute lambda here based on the newCoords. + * But we would need the texcoords of adjacent fragments to compute that + * properly, and we don't have those here. + * For now, do an approximation: subtracting 1 from the chosen mipmap + * level seems to work in some test cases. + * The same adjustment is done in the next few functions. + */ + level = nearest_mipmap_level(tObj, lambda[i]); + level = MAX2(level - 1, 0); + sample_2d_nearest(ctx, tObj, images[level], newCoord, rgba[i]); } } @@ -1884,6 +1886,7 @@ sample_cube_linear_mipmap_nearest(GLcontext *ctx, const struct gl_texture_image **images; GLfloat newCoord[4]; GLint level = nearest_mipmap_level(tObj, lambda[i]); + level = MAX2(level - 1, 0); /* see comment above */ images = choose_cube_face(tObj, texcoord[i], newCoord); sample_2d_linear(ctx, tObj, images[level], newCoord, rgba[i]); } @@ -1902,6 +1905,7 @@ sample_cube_nearest_mipmap_linear(GLcontext *ctx, const struct gl_texture_image **images; GLfloat newCoord[4]; GLint level = linear_mipmap_level(tObj, lambda[i]); + level = MAX2(level - 1, 0); /* see comment above */ images = choose_cube_face(tObj, texcoord[i], newCoord); if (level >= tObj->_MaxLevel) { sample_2d_nearest(ctx, tObj, images[tObj->_MaxLevel], @@ -1930,6 +1934,7 @@ sample_cube_linear_mipmap_linear(GLcontext *ctx, const struct gl_texture_image **images; GLfloat newCoord[4]; GLint level = linear_mipmap_level(tObj, lambda[i]); + level = MAX2(level - 1, 0); /* see comment above */ images = choose_cube_face(tObj, texcoord[i], newCoord); if (level >= tObj->_MaxLevel) { sample_2d_linear(ctx, tObj, images[tObj->_MaxLevel], @@ -2095,7 +2100,7 @@ sample_nearest_rect(GLcontext *ctx, ASSERT(tObj->WrapT == GL_CLAMP || tObj->WrapT == GL_CLAMP_TO_EDGE || tObj->WrapT == GL_CLAMP_TO_BORDER); - ASSERT(img->_BaseFormat != GL_COLOR_INDEX); + ASSERT(img->TexFormat->BaseFormat != GL_COLOR_INDEX); for (i = 0; i < n; i++) { GLint row, col; @@ -2131,7 +2136,7 @@ sample_linear_rect(GLcontext *ctx, ASSERT(tObj->WrapT == GL_CLAMP || tObj->WrapT == GL_CLAMP_TO_EDGE || tObj->WrapT == GL_CLAMP_TO_BORDER); - ASSERT(img->_BaseFormat != GL_COLOR_INDEX); + ASSERT(img->TexFormat->BaseFormat != GL_COLOR_INDEX); /* XXX lots of opportunity for optimization in this loop */ for (i = 0; i < n; i++) { @@ -2873,8 +2878,8 @@ sample_depth_texture( GLcontext *ctx, (void) lambda; - ASSERT(tObj->Image[0][tObj->BaseLevel]->_BaseFormat == GL_DEPTH_COMPONENT || - tObj->Image[0][tObj->BaseLevel]->_BaseFormat == GL_DEPTH_STENCIL_EXT); + ASSERT(img->TexFormat->BaseFormat == GL_DEPTH_COMPONENT || + img->TexFormat->BaseFormat == GL_DEPTH_STENCIL_EXT); ASSERT(tObj->Target == GL_TEXTURE_1D || tObj->Target == GL_TEXTURE_2D || @@ -3242,7 +3247,7 @@ sample_depth_texture2(const GLcontext *ctx, * GL_TEXTURE_COMPARE_SGIX == GL_TRUE but the current texture object * isn't a depth texture. */ - if (texImage->_BaseFormat != GL_DEPTH_COMPONENT) { + if (texImage->TexFormat->BaseFormat != GL_DEPTH_COMPONENT) { _mesa_problem(ctx,"GL_TEXTURE_COMPARE_SGIX enabled with non-depth texture"); return; } @@ -3345,7 +3350,7 @@ _swrast_choose_texture_sample_func( GLcontext *ctx, } else { const GLboolean needLambda = (GLboolean) (t->MinFilter != t->MagFilter); - const GLenum format = t->Image[0][t->BaseLevel]->_BaseFormat; + const GLenum format = t->Image[0][t->BaseLevel]->TexFormat->BaseFormat; switch (t->Target) { case GL_TEXTURE_1D: