summaryrefslogtreecommitdiffstats
path: root/src/mesa/swrast
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2011-09-21 18:54:53 -0600
committerBrian Paul <[email protected]>2011-09-22 10:44:57 -0600
commit980f6f1b37ca88529b3e000235156eab93254fac (patch)
treeaa35b265eb89284d160ca6211322204efebb3e5c /src/mesa/swrast
parenteaf376ba354db11f7729452060570b48a029c9a0 (diff)
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 <[email protected]>
Diffstat (limited to 'src/mesa/swrast')
-rw-r--r--src/mesa/swrast/s_context.h2
-rw-r--r--src/mesa/swrast/s_fragprog.c6
-rw-r--r--src/mesa/swrast/s_span.c7
-rw-r--r--src/mesa/swrast/s_texfilter.c11
-rw-r--r--src/mesa/swrast/s_texture.c13
5 files changed, 30 insertions, 9 deletions
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;
}