diff options
Diffstat (limited to 'mesalib/src/mesa/swrast/s_texfilter.c')
-rw-r--r-- | mesalib/src/mesa/swrast/s_texfilter.c | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/mesalib/src/mesa/swrast/s_texfilter.c b/mesalib/src/mesa/swrast/s_texfilter.c index a7a190ab6..dd3761986 100644 --- a/mesalib/src/mesa/swrast/s_texfilter.c +++ b/mesalib/src/mesa/swrast/s_texfilter.c @@ -159,11 +159,12 @@ linear_texel_locations(GLenum wrapMode, GLint size, GLfloat s, GLint *i0, GLint *i1, GLfloat *weight) { + const struct swrast_texture_image *swImg = swrast_texture_image_const(img); GLfloat u; switch (wrapMode) { case GL_REPEAT: u = s * size - 0.5F; - if (img->_IsPowerOfTwo) { + if (swImg->_IsPowerOfTwo) { *i0 = IFLOOR(u) & (size - 1); *i1 = (*i0 + 1) & (size - 1); } @@ -285,6 +286,7 @@ nearest_texel_location(GLenum wrapMode, const struct gl_texture_image *img, GLint size, GLfloat s) { + const struct swrast_texture_image *swImg = swrast_texture_image_const(img); GLint i; switch (wrapMode) { @@ -292,7 +294,7 @@ nearest_texel_location(GLenum wrapMode, /* s limited to [0,1) */ /* i limited to [0,size-1] */ i = IFLOOR(s * size); - if (img->_IsPowerOfTwo) + if (swImg->_IsPowerOfTwo) i &= (size - 1); else i = REMAINDER(i, size); @@ -1173,7 +1175,7 @@ sample_2d_linear_repeat(struct gl_context *ctx, ASSERT(tObj->Sampler.WrapS == GL_REPEAT); ASSERT(tObj->Sampler.WrapT == GL_REPEAT); ASSERT(img->Border == 0); - ASSERT(img->_IsPowerOfTwo); + ASSERT(swImg->_IsPowerOfTwo); linear_repeat_texel_location(width, texcoord[0], &i0, &i1, &wi); linear_repeat_texel_location(height, texcoord[1], &j0, &j1, &wj); @@ -1320,10 +1322,11 @@ sample_linear_2d(struct gl_context *ctx, { GLuint i; struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel]; + const struct swrast_texture_image *swImg = swrast_texture_image_const(image); (void) lambda; if (tObj->Sampler.WrapS == GL_REPEAT && tObj->Sampler.WrapT == GL_REPEAT && - image->_IsPowerOfTwo && + swImg->_IsPowerOfTwo && image->Border == 0) { for (i = 0; i < n; i++) { sample_2d_linear_repeat(ctx, tObj, image, texcoords[i], rgba[i]); @@ -1352,6 +1355,7 @@ opt_sample_rgb_2d(struct gl_context *ctx, const GLfloat lambda[], GLfloat rgba[][4]) { const struct gl_texture_image *img = tObj->Image[0][tObj->BaseLevel]; + const struct swrast_texture_image *swImg = swrast_texture_image_const(img); const GLfloat width = (GLfloat) img->Width; const GLfloat height = (GLfloat) img->Height; const GLint colMask = img->Width - 1; @@ -1364,7 +1368,7 @@ opt_sample_rgb_2d(struct gl_context *ctx, ASSERT(tObj->Sampler.WrapT==GL_REPEAT); ASSERT(img->Border==0); ASSERT(img->TexFormat == MESA_FORMAT_RGB888); - ASSERT(img->_IsPowerOfTwo); + ASSERT(swImg->_IsPowerOfTwo); for (k=0; k<n; k++) { GLint i = IFLOOR(texcoords[k][0] * width) & colMask; @@ -1394,6 +1398,7 @@ opt_sample_rgba_2d(struct gl_context *ctx, const GLfloat lambda[], GLfloat rgba[][4]) { const struct gl_texture_image *img = tObj->Image[0][tObj->BaseLevel]; + const struct swrast_texture_image *swImg = swrast_texture_image_const(img); const GLfloat width = (GLfloat) img->Width; const GLfloat height = (GLfloat) img->Height; const GLint colMask = img->Width - 1; @@ -1406,7 +1411,7 @@ opt_sample_rgba_2d(struct gl_context *ctx, ASSERT(tObj->Sampler.WrapT==GL_REPEAT); ASSERT(img->Border==0); ASSERT(img->TexFormat == MESA_FORMAT_RGBA8888); - ASSERT(img->_IsPowerOfTwo); + ASSERT(swImg->_IsPowerOfTwo); for (i = 0; i < n; i++) { const GLint col = IFLOOR(texcoords[i][0] * width) & colMask; @@ -1429,13 +1434,14 @@ sample_lambda_2d(struct gl_context *ctx, const GLfloat lambda[], GLfloat rgba[][4]) { const struct gl_texture_image *tImg = tObj->Image[0][tObj->BaseLevel]; + const struct swrast_texture_image *swImg = swrast_texture_image_const(tImg); GLuint minStart, minEnd; /* texels with minification */ GLuint magStart, magEnd; /* texels with magnification */ const GLboolean repeatNoBorderPOT = (tObj->Sampler.WrapS == GL_REPEAT) && (tObj->Sampler.WrapT == GL_REPEAT) && (tImg->Border == 0 && (tImg->Width == tImg->RowStride)) - && tImg->_IsPowerOfTwo; + && swImg->_IsPowerOfTwo; ASSERT(lambda != NULL); compute_min_mag_ranges(tObj, n, lambda, @@ -1579,8 +1585,10 @@ sample_2d_ewa(struct gl_context *ctx, const struct gl_texture_image *img = tObj->Image[0][level]; const struct gl_texture_image *mostDetailedImage = tObj->Image[0][tObj->BaseLevel]; - GLfloat tex_u=-0.5 + texcoord[0] * mostDetailedImage->WidthScale * scaling; - GLfloat tex_v=-0.5 + texcoord[1] * mostDetailedImage->HeightScale * scaling; + const struct swrast_texture_image *swImg = + swrast_texture_image_const(mostDetailedImage); + GLfloat tex_u=-0.5 + texcoord[0] * swImg->WidthScale * scaling; + GLfloat tex_v=-0.5 + texcoord[1] * swImg->HeightScale * scaling; GLfloat ux = dudx * scaling; GLfloat vx = dvdx * scaling; @@ -1787,6 +1795,7 @@ sample_lambda_2d_aniso(struct gl_context *ctx, const GLfloat lambda_iso[], GLfloat rgba[][4]) { const struct gl_texture_image *tImg = tObj->Image[0][tObj->BaseLevel]; + const struct swrast_texture_image *swImg = swrast_texture_image_const(tImg); const GLfloat maxEccentricity = tObj->Sampler.MaxAnisotropy * tObj->Sampler.MaxAnisotropy; @@ -1829,8 +1838,8 @@ sample_lambda_2d_aniso(struct gl_context *ctx, create_filter_table(); } - texW = tImg->WidthScale; - texH = tImg->HeightScale; + texW = swImg->WidthScale; + texH = swImg->HeightScale; for (i = 0; i < n; i++) { const GLfloat invQ = (q == 0.0F) ? 1.0F : (1.0F / q); @@ -3634,17 +3643,20 @@ _swrast_choose_texture_sample_func( struct gl_context *ctx, else { /* check for a few optimized cases */ const struct gl_texture_image *img = t->Image[0][t->BaseLevel]; + const struct swrast_texture_image *swImg = + swrast_texture_image_const(img); + ASSERT(t->Sampler.MinFilter == GL_NEAREST); if (t->Sampler.WrapS == GL_REPEAT && t->Sampler.WrapT == GL_REPEAT && - img->_IsPowerOfTwo && + swImg->_IsPowerOfTwo && img->Border == 0 && img->TexFormat == MESA_FORMAT_RGB888) { return &opt_sample_rgb_2d; } else if (t->Sampler.WrapS == GL_REPEAT && t->Sampler.WrapT == GL_REPEAT && - img->_IsPowerOfTwo && + swImg->_IsPowerOfTwo && img->Border == 0 && img->TexFormat == MESA_FORMAT_RGBA8888) { return &opt_sample_rgba_2d; |