From 980f6f1b37ca88529b3e000235156eab93254fac Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 21 Sep 2011 18:54:53 -0600 Subject: [PATCH] mesa: move gl_texture_image::Width/Height/DepthScale fields to swrast These fields were only used for swrast so move them into swrast_texture_image. Reviewed-by: Ian Romanick --- src/mesa/main/mtypes.h | 3 --- src/mesa/main/teximage.c | 13 ------------- src/mesa/swrast/s_context.h | 2 +- src/mesa/swrast/s_fragprog.c | 6 ++++-- src/mesa/swrast/s_span.c | 7 +++++-- src/mesa/swrast/s_texfilter.c | 11 +++++++---- src/mesa/swrast/s_texture.c | 13 +++++++++++++ 7 files changed, 30 insertions(+), 25 deletions(-) diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index a3f0deba048..dc4dd07f19b 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1254,9 +1254,6 @@ struct gl_texture_image GLuint HeightLog2; /**< = log2(Height2) */ GLuint DepthLog2; /**< = log2(Depth2) */ GLuint MaxLog2; /**< = MAX(WidthLog2, HeightLog2) */ - GLfloat WidthScale; /**< used for mipmap LOD computation */ - GLfloat HeightScale; /**< used for mipmap LOD computation */ - GLfloat DepthScale; /**< used for mipmap LOD computation */ GLboolean IsClientData; /**< Data owned by client? */ struct gl_texture_object *TexObject; /**< Pointer back to parent object */ diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 50e7b4c0794..4f7f2ed60de 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -1172,19 +1172,6 @@ _mesa_init_teximage_fields(struct gl_context *ctx, GLenum target, img->ImageOffsets[i] = i * width * height; } - /* Compute Width/Height/DepthScale for mipmap lod computation */ - if (target == GL_TEXTURE_RECTANGLE_NV) { - /* scale = 1.0 since texture coords directly map to texels */ - img->WidthScale = 1.0; - img->HeightScale = 1.0; - img->DepthScale = 1.0; - } - else { - img->WidthScale = (GLfloat) img->Width; - img->HeightScale = (GLfloat) img->Height; - img->DepthScale = (GLfloat) img->Depth; - } - img->TexFormat = format; } diff --git a/src/mesa/swrast/s_context.h b/src/mesa/swrast/s_context.h index 363115a8fea..1e0bfc0f974 100644 --- a/src/mesa/swrast/s_context.h +++ b/src/mesa/swrast/s_context.h @@ -141,10 +141,10 @@ struct swrast_texture_image GLboolean _IsPowerOfTwo; /**< Are all dimensions powers of two? */ -#if 0 /** used for mipmap LOD computation */ GLfloat WidthScale, HeightScale, DepthScale; +#if 0 GLubyte *Data; /**< The actual texture data in malloc'd memory */ GLint TexelSize; /**< bytes per texel block */ diff --git a/src/mesa/swrast/s_fragprog.c b/src/mesa/swrast/s_fragprog.c index b6bfeaed4a9..9513b1c46b4 100644 --- a/src/mesa/swrast/s_fragprog.c +++ b/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/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c index 16ff7ff0282..4631ff3d5ee 100644 --- a/src/mesa/swrast/s_span.c +++ b/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/src/mesa/swrast/s_texfilter.c b/src/mesa/swrast/s_texfilter.c index 262ad748880..dd3761986fd 100644 --- a/src/mesa/swrast/s_texfilter.c +++ b/src/mesa/swrast/s_texfilter.c @@ -1585,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; @@ -1793,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; @@ -1835,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); diff --git a/src/mesa/swrast/s_texture.c b/src/mesa/swrast/s_texture.c index 14ee0ebc600..1dcb08c0a1b 100644 --- a/src/mesa/swrast/s_texture.c +++ b/src/mesa/swrast/s_texture.c @@ -85,6 +85,19 @@ _swrast_alloc_texture_image_buffer(struct gl_context *ctx, 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; } -- 2.30.2