From 873965b49f283ad028dd4e0e5b7e93a758c84993 Mon Sep 17 00:00:00 2001 From: marha Date: Mon, 26 Sep 2011 17:04:30 +0200 Subject: fontconfig libX11 libXext libXft libXmu mesa git update 26 sep 2011 --- mesalib/src/mesa/swrast/s_context.h | 5 +++-- mesalib/src/mesa/swrast/s_fragprog.c | 6 ++++-- mesalib/src/mesa/swrast/s_span.c | 7 +++++-- mesalib/src/mesa/swrast/s_texfilter.c | 38 +++++++++++++++++++++++------------ mesalib/src/mesa/swrast/s_texture.c | 23 ++++++++++++++++++++- mesalib/src/mesa/swrast/s_triangle.c | 5 ++++- 6 files changed, 63 insertions(+), 21 deletions(-) (limited to 'mesalib/src/mesa/swrast') diff --git a/mesalib/src/mesa/swrast/s_context.h b/mesalib/src/mesa/swrast/s_context.h index 8357483a2..1e0bfc0f9 100644 --- a/mesalib/src/mesa/swrast/s_context.h +++ b/mesalib/src/mesa/swrast/s_context.h @@ -139,11 +139,12 @@ struct swrast_texture_image { struct gl_texture_image Base; -#if 0 + GLboolean _IsPowerOfTwo; /**< Are all dimensions powers of two? */ + /** used for mipmap LOD computation */ GLfloat WidthScale, HeightScale, DepthScale; - GLboolean _IsPowerOfTwo; /**< Are all dimensions powers of two? */ +#if 0 GLubyte *Data; /**< The actual texture data in malloc'd memory */ GLint TexelSize; /**< bytes per texel block */ diff --git a/mesalib/src/mesa/swrast/s_fragprog.c b/mesalib/src/mesa/swrast/s_fragprog.c index b6bfeaed4..9513b1c46 100644 --- a/mesalib/src/mesa/swrast/s_fragprog.c +++ b/mesalib/src/mesa/swrast/s_fragprog.c @@ -103,8 +103,10 @@ fetch_texel_deriv( struct gl_context *ctx, const GLfloat texcoord[4], if (texObj) { const struct gl_texture_image *texImg = texObj->Image[0][texObj->BaseLevel]; - const GLfloat texW = (GLfloat) texImg->WidthScale; - const GLfloat texH = (GLfloat) texImg->HeightScale; + const struct swrast_texture_image *swImg = + swrast_texture_image_const(texImg); + const GLfloat texW = (GLfloat) swImg->WidthScale; + const GLfloat texH = (GLfloat) swImg->HeightScale; GLfloat lambda; GLfloat rgba[4]; diff --git a/mesalib/src/mesa/swrast/s_span.c b/mesalib/src/mesa/swrast/s_span.c index 16ff7ff02..4631ff3d5 100644 --- a/mesalib/src/mesa/swrast/s_span.c +++ b/mesalib/src/mesa/swrast/s_span.c @@ -490,6 +490,9 @@ interpolate_texcoords(struct gl_context *ctx, SWspan *span) if (obj) { const struct gl_texture_image *img = obj->Image[0][obj->BaseLevel]; + const struct swrast_texture_image *swImg = + swrast_texture_image_const(img); + needLambda = (obj->Sampler.MinFilter != obj->Sampler.MagFilter) || ctx->FragmentProgram._Current; /* LOD is calculated directly in the ansiotropic filter, we can @@ -499,8 +502,8 @@ interpolate_texcoords(struct gl_context *ctx, SWspan *span) obj->Sampler.MinFilter == GL_LINEAR_MIPMAP_LINEAR) { needLambda = GL_FALSE; } - texW = img->WidthScale; - texH = img->HeightScale; + texW = swImg->WidthScale; + texH = swImg->HeightScale; } else { /* using a fragment program */ 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; kImage[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; diff --git a/mesalib/src/mesa/swrast/s_texture.c b/mesalib/src/mesa/swrast/s_texture.c index 7e3fc2806..aa073753f 100644 --- a/mesalib/src/mesa/swrast/s_texture.c +++ b/mesalib/src/mesa/swrast/s_texture.c @@ -67,6 +67,7 @@ _swrast_alloc_texture_image_buffer(struct gl_context *ctx, gl_format format, GLsizei width, GLsizei height, GLsizei depth) { + struct swrast_texture_image *swImg = swrast_texture_image(texImage); GLuint bytes = _mesa_format_image_size(format, width, height, depth); /* This _should_ be true (revisit if these ever fail) */ @@ -77,6 +78,26 @@ _swrast_alloc_texture_image_buffer(struct gl_context *ctx, assert(!texImage->Data); texImage->Data = _mesa_align_malloc(bytes, 512); + if ((width == 1 || _mesa_is_pow_two(texImage->Width2)) && + (height == 1 || _mesa_is_pow_two(texImage->Height2)) && + (depth == 1 || _mesa_is_pow_two(texImage->Depth2))) + swImg->_IsPowerOfTwo = GL_TRUE; + else + swImg->_IsPowerOfTwo = GL_FALSE; + + /* Compute Width/Height/DepthScale for mipmap lod computation */ + if (texImage->TexObject->Target == GL_TEXTURE_RECTANGLE_NV) { + /* scale = 1.0 since texture coords directly map to texels */ + swImg->WidthScale = 1.0; + swImg->HeightScale = 1.0; + swImg->DepthScale = 1.0; + } + else { + swImg->WidthScale = (GLfloat) texImage->Width; + swImg->HeightScale = (GLfloat) texImage->Height; + swImg->DepthScale = (GLfloat) texImage->Depth; + } + return texImage->Data != NULL; } @@ -88,7 +109,7 @@ void _swrast_free_texture_image_buffer(struct gl_context *ctx, struct gl_texture_image *texImage) { - if (texImage->Data && !texImage->IsClientData) { + if (texImage->Data) { _mesa_align_free(texImage->Data); } diff --git a/mesalib/src/mesa/swrast/s_triangle.c b/mesalib/src/mesa/swrast/s_triangle.c index 8a9671aa0..77bd2a359 100644 --- a/mesalib/src/mesa/swrast/s_triangle.c +++ b/mesalib/src/mesa/swrast/s_triangle.c @@ -1038,11 +1038,14 @@ _swrast_choose_triangle( struct gl_context *ctx ) /* Ugh, we do a _lot_ of tests to pick the best textured tri func */ const struct gl_texture_object *texObj2D; const struct gl_texture_image *texImg; + const struct swrast_texture_image *swImg; GLenum minFilter, magFilter, envMode; gl_format format; texObj2D = ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX]; texImg = texObj2D ? texObj2D->Image[0][texObj2D->BaseLevel] : NULL; + swImg = swrast_texture_image_const(texImg); + format = texImg ? texImg->TexFormat : MESA_FORMAT_NONE; minFilter = texObj2D ? texObj2D->Sampler.MinFilter : GL_NONE; magFilter = texObj2D ? texObj2D->Sampler.MagFilter : GL_NONE; @@ -1057,7 +1060,7 @@ _swrast_choose_triangle( struct gl_context *ctx ) && texObj2D->Sampler.WrapS == GL_REPEAT && texObj2D->Sampler.WrapT == GL_REPEAT && texObj2D->_Swizzle == SWIZZLE_NOOP - && texImg->_IsPowerOfTwo + && swImg->_IsPowerOfTwo && texImg->Border == 0 && texImg->Width == texImg->RowStride && (format == MESA_FORMAT_RGB888 || format == MESA_FORMAT_RGBA8888) -- cgit v1.2.3