From 67d4a5b15cfd8583c19a5776b0ec1564b60239eb Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Sun, 23 Aug 2009 23:50:27 +0100 Subject: mesa/swrast: use one fewer divide in swrast's choose_cube_face also Same change as for softpipe --- src/mesa/swrast/s_texfilter.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/mesa/swrast/s_texfilter.c') diff --git a/src/mesa/swrast/s_texfilter.c b/src/mesa/swrast/s_texfilter.c index 6b1f934647..216c107e3f 100644 --- a/src/mesa/swrast/s_texfilter.c +++ b/src/mesa/swrast/s_texfilter.c @@ -1905,8 +1905,12 @@ choose_cube_face(const struct gl_texture_object *texObj, } } - newCoord[0] = ( sc / ma + 1.0F ) * 0.5F; - newCoord[1] = ( tc / ma + 1.0F ) * 0.5F; + { + const float ima = 1.0F / ma; + newCoord[0] = ( sc * ima + 1.0F ) * 0.5F; + newCoord[1] = ( tc * ima + 1.0F ) * 0.5F; + } + return (const struct gl_texture_image **) texObj->Image[face]; } -- cgit v1.2.3 From d504a7669d7b71229c2d15503a095d71ee1584e6 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 21 Sep 2009 08:32:43 -0600 Subject: swrast: fix cube face selection If arx and ary are equal, we still want to choose from one of them, and not arz. This is the same as Michal's softpipe fix. --- src/mesa/swrast/s_texfilter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/mesa/swrast/s_texfilter.c') diff --git a/src/mesa/swrast/s_texfilter.c b/src/mesa/swrast/s_texfilter.c index 6b1f934647..efe6f23474 100644 --- a/src/mesa/swrast/s_texfilter.c +++ b/src/mesa/swrast/s_texfilter.c @@ -1862,7 +1862,7 @@ choose_cube_face(const struct gl_texture_object *texObj, GLuint face; GLfloat sc, tc, ma; - if (arx > ary && arx > arz) { + if (arx >= ary && arx >= arz) { if (rx >= 0.0F) { face = FACE_POS_X; sc = -rz; @@ -1876,7 +1876,7 @@ choose_cube_face(const struct gl_texture_object *texObj, ma = arx; } } - else if (ary > arx && ary > arz) { + else if (ary >= arx && ary >= arz) { if (ry >= 0.0F) { face = FACE_POS_Y; sc = rx; -- cgit v1.2.3 From 1f7c914ad0beea8a29c1a171c7cd1a12f2efe0fa Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 30 Sep 2009 20:28:45 -0600 Subject: mesa: replace gl_texture_format with gl_format Now gl_texture_image::TexFormat is a simple MESA_FORMAT_x enum. ctx->Driver.ChooseTexture format also returns a MESA_FORMAT_x. gl_texture_format will go away next. --- src/mesa/swrast/s_texfilter.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'src/mesa/swrast/s_texfilter.c') diff --git a/src/mesa/swrast/s_texfilter.c b/src/mesa/swrast/s_texfilter.c index 004d4e05ae..11c8f9256a 100644 --- a/src/mesa/swrast/s_texfilter.c +++ b/src/mesa/swrast/s_texfilter.c @@ -745,7 +745,7 @@ get_border_color(const struct gl_texture_object *tObj, const struct gl_texture_image *img, GLfloat rgba[4]) { - switch (img->TexFormat->BaseFormat) { + switch (img->_BaseFormat) { case GL_RGB: rgba[0] = tObj->BorderColor[0]; rgba[1] = tObj->BorderColor[1]; @@ -1152,7 +1152,7 @@ sample_2d_linear_repeat(GLcontext *ctx, ASSERT(tObj->WrapS == GL_REPEAT); ASSERT(tObj->WrapT == GL_REPEAT); ASSERT(img->Border == 0); - ASSERT(img->TexFormat->BaseFormat != GL_COLOR_INDEX); + ASSERT(img->_BaseFormat != GL_COLOR_INDEX); ASSERT(img->_IsPowerOfTwo); linear_repeat_texel_location(width, texcoord[0], &i0, &i1, &wi); @@ -1343,7 +1343,7 @@ opt_sample_rgb_2d(GLcontext *ctx, ASSERT(tObj->WrapS==GL_REPEAT); ASSERT(tObj->WrapT==GL_REPEAT); ASSERT(img->Border==0); - ASSERT(img->TexFormat->MesaFormat==MESA_FORMAT_RGB); + ASSERT(img->TexFormat == MESA_FORMAT_RGB); ASSERT(img->_IsPowerOfTwo); for (k=0; kWrapS==GL_REPEAT); ASSERT(tObj->WrapT==GL_REPEAT); ASSERT(img->Border==0); - ASSERT(img->TexFormat->MesaFormat==MESA_FORMAT_RGBA); + ASSERT(img->TexFormat == MESA_FORMAT_RGBA); ASSERT(img->_IsPowerOfTwo); for (i = 0; i < n; i++) { @@ -1414,7 +1414,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->TexFormat->BaseFormat != GL_COLOR_INDEX) + && (tImg->_BaseFormat != GL_COLOR_INDEX) && tImg->_IsPowerOfTwo; ASSERT(lambda != NULL); @@ -1427,7 +1427,7 @@ sample_lambda_2d(GLcontext *ctx, switch (tObj->MinFilter) { case GL_NEAREST: if (repeatNoBorderPOT) { - switch (tImg->TexFormat->MesaFormat) { + switch (tImg->TexFormat) { case MESA_FORMAT_RGB: opt_sample_rgb_2d(ctx, tObj, m, texcoords + minStart, NULL, rgba + minStart); @@ -1484,7 +1484,7 @@ sample_lambda_2d(GLcontext *ctx, switch (tObj->MagFilter) { case GL_NEAREST: if (repeatNoBorderPOT) { - switch (tImg->TexFormat->MesaFormat) { + switch (tImg->TexFormat) { case MESA_FORMAT_RGB: opt_sample_rgb_2d(ctx, tObj, m, texcoords + magStart, NULL, rgba + magStart); @@ -2152,7 +2152,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->TexFormat->BaseFormat != GL_COLOR_INDEX); + ASSERT(img->_BaseFormat != GL_COLOR_INDEX); for (i = 0; i < n; i++) { GLint row, col; @@ -2186,7 +2186,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->TexFormat->BaseFormat != GL_COLOR_INDEX); + ASSERT(img->_BaseFormat != GL_COLOR_INDEX); for (i = 0; i < n; i++) { GLint i0, j0, i1, j1; @@ -2973,8 +2973,8 @@ sample_depth_texture( GLcontext *ctx, (void) lambda; - ASSERT(img->TexFormat->BaseFormat == GL_DEPTH_COMPONENT || - img->TexFormat->BaseFormat == GL_DEPTH_STENCIL_EXT); + ASSERT(img->_BaseFormat == GL_DEPTH_COMPONENT || + img->_BaseFormat == GL_DEPTH_STENCIL_EXT); ASSERT(tObj->Target == GL_TEXTURE_1D || tObj->Target == GL_TEXTURE_2D || @@ -3154,7 +3154,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]->TexFormat->BaseFormat; + const GLenum format = t->Image[0][t->BaseLevel]->_BaseFormat; switch (t->Target) { case GL_TEXTURE_1D: @@ -3189,14 +3189,14 @@ _swrast_choose_texture_sample_func( GLcontext *ctx, t->WrapT == GL_REPEAT && img->_IsPowerOfTwo && img->Border == 0 && - img->TexFormat->MesaFormat == MESA_FORMAT_RGB) { + img->TexFormat == MESA_FORMAT_RGB) { return &opt_sample_rgb_2d; } else if (t->WrapS == GL_REPEAT && t->WrapT == GL_REPEAT && img->_IsPowerOfTwo && img->Border == 0 && - img->TexFormat->MesaFormat == MESA_FORMAT_RGBA) { + img->TexFormat == MESA_FORMAT_RGBA) { return &opt_sample_rgba_2d; } else { -- cgit v1.2.3 From 3fa7dbf368bb060220e9f78e666b00d6827166a6 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 30 Sep 2009 21:00:16 -0600 Subject: mesa: remove GLchan-based formats; use hw 8-bit/channel formats instead Removed: MESA_FORMAT_RGBA, RGB, ALPHA, LUMINANCE, LUMINANCE_ALPHA, INTENSITY. --- src/mesa/swrast/s_texfilter.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'src/mesa/swrast/s_texfilter.c') diff --git a/src/mesa/swrast/s_texfilter.c b/src/mesa/swrast/s_texfilter.c index 11c8f9256a..6cba8ed34b 100644 --- a/src/mesa/swrast/s_texfilter.c +++ b/src/mesa/swrast/s_texfilter.c @@ -1343,17 +1343,17 @@ opt_sample_rgb_2d(GLcontext *ctx, ASSERT(tObj->WrapS==GL_REPEAT); ASSERT(tObj->WrapT==GL_REPEAT); ASSERT(img->Border==0); - ASSERT(img->TexFormat == MESA_FORMAT_RGB); + ASSERT(img->TexFormat == MESA_FORMAT_RGB888); ASSERT(img->_IsPowerOfTwo); for (k=0; kData) + 3*pos; - rgba[k][RCOMP] = CHAN_TO_FLOAT(texel[0]); - rgba[k][GCOMP] = CHAN_TO_FLOAT(texel[1]); - rgba[k][BCOMP] = CHAN_TO_FLOAT(texel[2]); + GLubyte *texel = ((GLubyte *) img->Data) + 3*pos; + rgba[k][RCOMP] = UBYTE_TO_FLOAT(texel[0]); + rgba[k][GCOMP] = UBYTE_TO_FLOAT(texel[1]); + rgba[k][BCOMP] = UBYTE_TO_FLOAT(texel[2]); } } @@ -1384,18 +1384,18 @@ opt_sample_rgba_2d(GLcontext *ctx, ASSERT(tObj->WrapS==GL_REPEAT); ASSERT(tObj->WrapT==GL_REPEAT); ASSERT(img->Border==0); - ASSERT(img->TexFormat == MESA_FORMAT_RGBA); + ASSERT(img->TexFormat == MESA_FORMAT_RGBA8888); ASSERT(img->_IsPowerOfTwo); for (i = 0; i < n; i++) { const GLint col = IFLOOR(texcoords[i][0] * width) & colMask; const GLint row = IFLOOR(texcoords[i][1] * height) & rowMask; const GLint pos = (row << shift) | col; - const GLchan *texel = ((GLchan *) img->Data) + (pos << 2); /* pos*4 */ - rgba[i][RCOMP] = CHAN_TO_FLOAT(texel[0]); - rgba[i][GCOMP] = CHAN_TO_FLOAT(texel[1]); - rgba[i][BCOMP] = CHAN_TO_FLOAT(texel[2]); - rgba[i][ACOMP] = CHAN_TO_FLOAT(texel[3]); + const GLubyte *texel = ((GLubyte *) img->Data) + (pos << 2); /* pos*4 */ + rgba[i][RCOMP] = UBYTE_TO_FLOAT(texel[0]); + rgba[i][GCOMP] = UBYTE_TO_FLOAT(texel[1]); + rgba[i][BCOMP] = UBYTE_TO_FLOAT(texel[2]); + rgba[i][ACOMP] = UBYTE_TO_FLOAT(texel[3]); } } @@ -1428,11 +1428,11 @@ sample_lambda_2d(GLcontext *ctx, case GL_NEAREST: if (repeatNoBorderPOT) { switch (tImg->TexFormat) { - case MESA_FORMAT_RGB: + case MESA_FORMAT_RGB888: opt_sample_rgb_2d(ctx, tObj, m, texcoords + minStart, NULL, rgba + minStart); break; - case MESA_FORMAT_RGBA: + case MESA_FORMAT_RGBA8888: opt_sample_rgba_2d(ctx, tObj, m, texcoords + minStart, NULL, rgba + minStart); break; @@ -1485,11 +1485,11 @@ sample_lambda_2d(GLcontext *ctx, case GL_NEAREST: if (repeatNoBorderPOT) { switch (tImg->TexFormat) { - case MESA_FORMAT_RGB: + case MESA_FORMAT_RGB888: opt_sample_rgb_2d(ctx, tObj, m, texcoords + magStart, NULL, rgba + magStart); break; - case MESA_FORMAT_RGBA: + case MESA_FORMAT_RGBA8888: opt_sample_rgba_2d(ctx, tObj, m, texcoords + magStart, NULL, rgba + magStart); break; @@ -3137,7 +3137,7 @@ null_sample_func( GLcontext *ctx, rgba[i][RCOMP] = 0; rgba[i][GCOMP] = 0; rgba[i][BCOMP] = 0; - rgba[i][ACOMP] = CHAN_MAX; + rgba[i][ACOMP] = 1.0; } } @@ -3189,14 +3189,14 @@ _swrast_choose_texture_sample_func( GLcontext *ctx, t->WrapT == GL_REPEAT && img->_IsPowerOfTwo && img->Border == 0 && - img->TexFormat == MESA_FORMAT_RGB) { + img->TexFormat == MESA_FORMAT_RGB888) { return &opt_sample_rgb_2d; } else if (t->WrapS == GL_REPEAT && t->WrapT == GL_REPEAT && img->_IsPowerOfTwo && img->Border == 0 && - img->TexFormat == MESA_FORMAT_RGBA) { + img->TexFormat == MESA_FORMAT_RGBA8888) { return &opt_sample_rgba_2d; } else { -- cgit v1.2.3 From 8c36ca707ca8879d6f888de7733ffb6b04ddc48a Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 30 Sep 2009 22:50:05 -0600 Subject: swrast: fix some texformat regressions Need to be careful with component ordering for MESA_FORMAT_RGB888 and MESA_FORMAT_RGBA8888. --- src/mesa/swrast/s_texfilter.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/mesa/swrast/s_texfilter.c') diff --git a/src/mesa/swrast/s_texfilter.c b/src/mesa/swrast/s_texfilter.c index 6cba8ed34b..db03c6aa39 100644 --- a/src/mesa/swrast/s_texfilter.c +++ b/src/mesa/swrast/s_texfilter.c @@ -1351,9 +1351,9 @@ opt_sample_rgb_2d(GLcontext *ctx, GLint j = IFLOOR(texcoords[k][1] * height) & rowMask; GLint pos = (j << shift) | i; GLubyte *texel = ((GLubyte *) img->Data) + 3*pos; - rgba[k][RCOMP] = UBYTE_TO_FLOAT(texel[0]); + rgba[k][RCOMP] = UBYTE_TO_FLOAT(texel[2]); rgba[k][GCOMP] = UBYTE_TO_FLOAT(texel[1]); - rgba[k][BCOMP] = UBYTE_TO_FLOAT(texel[2]); + rgba[k][BCOMP] = UBYTE_TO_FLOAT(texel[0]); } } @@ -1392,10 +1392,10 @@ opt_sample_rgba_2d(GLcontext *ctx, const GLint row = IFLOOR(texcoords[i][1] * height) & rowMask; const GLint pos = (row << shift) | col; const GLubyte *texel = ((GLubyte *) img->Data) + (pos << 2); /* pos*4 */ - rgba[i][RCOMP] = UBYTE_TO_FLOAT(texel[0]); - rgba[i][GCOMP] = UBYTE_TO_FLOAT(texel[1]); - rgba[i][BCOMP] = UBYTE_TO_FLOAT(texel[2]); - rgba[i][ACOMP] = UBYTE_TO_FLOAT(texel[3]); + rgba[i][RCOMP] = UBYTE_TO_FLOAT(texel[3]); + rgba[i][GCOMP] = UBYTE_TO_FLOAT(texel[2]); + rgba[i][BCOMP] = UBYTE_TO_FLOAT(texel[1]); + rgba[i][ACOMP] = UBYTE_TO_FLOAT(texel[0]); } } -- cgit v1.2.3 From 1e7517f059b1f3601502a199b05453eabfe56cdb Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 28 Oct 2009 19:38:12 -0600 Subject: swrast: fix texel decoding in opt_sample_rgba_2d() --- src/mesa/swrast/s_texfilter.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/mesa/swrast/s_texfilter.c') diff --git a/src/mesa/swrast/s_texfilter.c b/src/mesa/swrast/s_texfilter.c index db03c6aa39..0bb988e3ef 100644 --- a/src/mesa/swrast/s_texfilter.c +++ b/src/mesa/swrast/s_texfilter.c @@ -1391,11 +1391,11 @@ opt_sample_rgba_2d(GLcontext *ctx, const GLint col = IFLOOR(texcoords[i][0] * width) & colMask; const GLint row = IFLOOR(texcoords[i][1] * height) & rowMask; const GLint pos = (row << shift) | col; - const GLubyte *texel = ((GLubyte *) img->Data) + (pos << 2); /* pos*4 */ - rgba[i][RCOMP] = UBYTE_TO_FLOAT(texel[3]); - rgba[i][GCOMP] = UBYTE_TO_FLOAT(texel[2]); - rgba[i][BCOMP] = UBYTE_TO_FLOAT(texel[1]); - rgba[i][ACOMP] = UBYTE_TO_FLOAT(texel[0]); + const GLuint texel = *((GLuint *) img->Data + pos); + rgba[i][RCOMP] = UBYTE_TO_FLOAT( (texel >> 24) ); + rgba[i][GCOMP] = UBYTE_TO_FLOAT( (texel >> 16) & 0xff ); + rgba[i][BCOMP] = UBYTE_TO_FLOAT( (texel >> 8) & 0xff ); + rgba[i][ACOMP] = UBYTE_TO_FLOAT( (texel ) & 0xff ); } } -- cgit v1.2.3