summaryrefslogtreecommitdiffstats
path: root/src/mesa/swrast
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2002-06-15 03:03:06 +0000
committerBrian Paul <[email protected]>2002-06-15 03:03:06 +0000
commit8afe7de8deaf3c9613fd68b344de8c52b02b1879 (patch)
treef600a192c9d0136faea8864a53eabc819eeb791f /src/mesa/swrast
parent8bdd0dc8d0e9c9cb2c71fbdd4c77e982cfc0b350 (diff)
Implemented GL_NV_texture_rectangle extension.
Replace struct gl_texure_object's Dimension w/ Target field. Added _EnabledUnits to struct gl_texture_attrib - the _ReallyEnabled field is obsolete, but still present for now. This effectively removes the 8-texture units limit, 32 units now possible, but unlikely! New TEXTURE_1D/2D/3D/CUBE/RECT_BIT tokens for unit->_ReallyEnabled field. Updated device drivers to use ctx->Texture._EnabledUnits.
Diffstat (limited to 'src/mesa/swrast')
-rw-r--r--src/mesa/swrast/s_aaline.c6
-rw-r--r--src/mesa/swrast/s_aatriangle.c8
-rw-r--r--src/mesa/swrast/s_context.c10
-rw-r--r--src/mesa/swrast/s_copypix.c6
-rw-r--r--src/mesa/swrast/s_drawpix.c6
-rw-r--r--src/mesa/swrast/s_lines.c6
-rw-r--r--src/mesa/swrast/s_points.c8
-rw-r--r--src/mesa/swrast/s_pointtemp.h4
-rw-r--r--src/mesa/swrast/s_span.c14
-rw-r--r--src/mesa/swrast/s_texture.c216
-rw-r--r--src/mesa/swrast/s_triangle.c15
11 files changed, 248 insertions, 51 deletions
diff --git a/src/mesa/swrast/s_aaline.c b/src/mesa/swrast/s_aaline.c
index a3a041d0e42..5805fb3d062 100644
--- a/src/mesa/swrast/s_aaline.c
+++ b/src/mesa/swrast/s_aaline.c
@@ -1,4 +1,4 @@
-/* $Id: s_aaline.c,v 1.14 2002/04/19 14:05:50 brianp Exp $ */
+/* $Id: s_aaline.c,v 1.15 2002/06/15 03:03:10 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -513,8 +513,8 @@ _swrast_choose_aa_line_function(GLcontext *ctx)
if (ctx->Visual.rgbMode) {
/* RGBA */
- if (ctx->Texture._ReallyEnabled) {
- if (ctx->Texture._ReallyEnabled > TEXTURE0_ANY) {
+ if (ctx->Texture._EnabledUnits != 0) {
+ if (ctx->Texture._EnabledUnits > 1) {
/* Multitextured! */
if (ctx->Light.Model.ColorControl==GL_SEPARATE_SPECULAR_COLOR ||
ctx->Fog.ColorSumEnabled)
diff --git a/src/mesa/swrast/s_aatriangle.c b/src/mesa/swrast/s_aatriangle.c
index ea939a5369f..66796dff35b 100644
--- a/src/mesa/swrast/s_aatriangle.c
+++ b/src/mesa/swrast/s_aatriangle.c
@@ -1,4 +1,4 @@
-/* $Id: s_aatriangle.c,v 1.23 2002/03/16 18:02:07 brianp Exp $ */
+/* $Id: s_aatriangle.c,v 1.24 2002/06/15 03:03:11 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -450,9 +450,9 @@ _mesa_set_aa_triangle_function(GLcontext *ctx)
{
ASSERT(ctx->Polygon.SmoothFlag);
- if (ctx->Texture._ReallyEnabled) {
+ if (ctx->Texture._EnabledUnits != 0) {
if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) {
- if (ctx->Texture._ReallyEnabled > TEXTURE0_ANY) {
+ if (ctx->Texture._EnabledUnits > 1) {
SWRAST_CONTEXT(ctx)->Triangle = spec_multitex_aa_tri;
}
else {
@@ -460,7 +460,7 @@ _mesa_set_aa_triangle_function(GLcontext *ctx)
}
}
else {
- if (ctx->Texture._ReallyEnabled > TEXTURE0_ANY) {
+ if (ctx->Texture._EnabledUnits > 1) {
SWRAST_CONTEXT(ctx)->Triangle = multitex_aa_tri;
}
else {
diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c
index e0180d1ca78..a4f59df8ae3 100644
--- a/src/mesa/swrast/s_context.c
+++ b/src/mesa/swrast/s_context.c
@@ -1,4 +1,4 @@
-/* $Id: s_context.c,v 1.34 2002/06/15 02:38:17 brianp Exp $ */
+/* $Id: s_context.c,v 1.35 2002/06/15 03:03:11 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -60,7 +60,7 @@ _swrast_update_rasterflags( GLcontext *ctx )
const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask);
if (colorMask != 0xffffffff) RasterMask |= MASKING_BIT;
if (ctx->Color.ColorLogicOpEnabled) RasterMask |= LOGIC_OP_BIT;
- if (ctx->Texture._ReallyEnabled) RasterMask |= TEXTURE_BIT;
+ if (ctx->Texture._EnabledUnits) RasterMask |= TEXTURE_BIT;
}
else {
if (ctx->Color.IndexMask != 0xffffffff) RasterMask |= MASKING_BIT;
@@ -220,7 +220,7 @@ _swrast_validate_triangle( GLcontext *ctx,
swrast->choose_triangle( ctx );
if ((ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) &&
- !ctx->Texture._ReallyEnabled) {
+ ctx->Texture._EnabledUnits == 0) {
swrast->SpecTriangle = swrast->Triangle;
swrast->Triangle = _swrast_add_spec_terms_triangle;
}
@@ -237,7 +237,7 @@ _swrast_validate_line( GLcontext *ctx, const SWvertex *v0, const SWvertex *v1 )
swrast->choose_line( ctx );
if ((ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) &&
- !ctx->Texture._ReallyEnabled) {
+ ctx->Texture._EnabledUnits == 0) {
swrast->SpecLine = swrast->Line;
swrast->Line = _swrast_add_spec_terms_line;
}
@@ -255,7 +255,7 @@ _swrast_validate_point( GLcontext *ctx, const SWvertex *v0 )
swrast->choose_point( ctx );
if ((ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) &&
- !ctx->Texture._ReallyEnabled) {
+ ctx->Texture._EnabledUnits == 0) {
swrast->SpecPoint = swrast->Point;
swrast->Point = _swrast_add_spec_terms_point;
}
diff --git a/src/mesa/swrast/s_copypix.c b/src/mesa/swrast/s_copypix.c
index bea0af48833..2c6bd263123 100644
--- a/src/mesa/swrast/s_copypix.c
+++ b/src/mesa/swrast/s_copypix.c
@@ -1,4 +1,4 @@
-/* $Id: s_copypix.c,v 1.37 2002/04/19 14:05:50 brianp Exp $ */
+/* $Id: s_copypix.c,v 1.38 2002/06/15 03:03:11 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -257,7 +257,7 @@ copy_conv_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
span->color.rgba[i][ACOMP] = (GLchan) CLAMP(a, 0, CHAN_MAX);
}
- if (ctx->Pixel.PixelTextureEnabled && ctx->Texture._ReallyEnabled) {
+ if (ctx->Pixel.PixelTextureEnabled && ctx->Texture._EnabledUnits) {
span->end = width;
_swrast_pixel_texture(ctx, span);
}
@@ -500,7 +500,7 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
UNDEFARRAY(rgbaFloat); /* mac 32k limitation */
}
- if (ctx->Pixel.PixelTextureEnabled && ctx->Texture._ReallyEnabled) {
+ if (ctx->Pixel.PixelTextureEnabled && ctx->Texture._EnabledUnits) {
span->end = width;
_swrast_pixel_texture(ctx, span);
}
diff --git a/src/mesa/swrast/s_drawpix.c b/src/mesa/swrast/s_drawpix.c
index ab2dec8e192..0bee50400f8 100644
--- a/src/mesa/swrast/s_drawpix.c
+++ b/src/mesa/swrast/s_drawpix.c
@@ -1,4 +1,4 @@
-/* $Id: s_drawpix.c,v 1.34 2002/06/15 02:38:17 brianp Exp $ */
+/* $Id: s_drawpix.c,v 1.35 2002/06/15 03:03:11 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -116,7 +116,7 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
_mesa_span_default_fog(ctx, span);
if ((SWRAST_CONTEXT(ctx)->_RasterMask & ~CLIP_BIT) == 0
- && ctx->Texture._ReallyEnabled == 0
+ && ctx->Texture._EnabledUnits == 0
&& unpack->Alignment == 1
&& !unpack->SwapBytes
&& !unpack->LsbFirst) {
@@ -817,7 +817,7 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y,
(ctx->Pixel.HistogramEnabled && ctx->Histogram.Sink))
continue;
- if (ctx->Pixel.PixelTextureEnabled && ctx->Texture._ReallyEnabled) {
+ if (ctx->Pixel.PixelTextureEnabled && ctx->Texture._EnabledUnits) {
span->end = width;
_swrast_pixel_texture(ctx, span);
}
diff --git a/src/mesa/swrast/s_lines.c b/src/mesa/swrast/s_lines.c
index 19cc6f0cc3c..e9e9c670d74 100644
--- a/src/mesa/swrast/s_lines.c
+++ b/src/mesa/swrast/s_lines.c
@@ -1,4 +1,4 @@
-/* $Id: s_lines.c,v 1.29 2002/04/19 14:05:50 brianp Exp $ */
+/* $Id: s_lines.c,v 1.30 2002/06/15 03:03:11 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -771,8 +771,8 @@ _swrast_choose_line( GLcontext *ctx )
_swrast_choose_aa_line_function(ctx);
ASSERT(swrast->Triangle);
}
- else if (ctx->Texture._ReallyEnabled) {
- if (ctx->Texture._ReallyEnabled > TEXTURE0_ANY ||
+ else if (ctx->Texture._EnabledUnits) {
+ if (ctx->Texture._EnabledUnits > 1 ||
(ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)) {
/* multi-texture and/or separate specular color */
if (ctx->Light.ShadeModel == GL_SMOOTH)
diff --git a/src/mesa/swrast/s_points.c b/src/mesa/swrast/s_points.c
index d84fc7bd94e..0c060f16efe 100644
--- a/src/mesa/swrast/s_points.c
+++ b/src/mesa/swrast/s_points.c
@@ -1,4 +1,4 @@
-/* $Id: s_points.c,v 1.18 2002/05/27 17:04:53 brianp Exp $ */
+/* $Id: s_points.c,v 1.19 2002/06/15 03:03:11 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -215,7 +215,7 @@ _swrast_choose_point( GLcontext *ctx )
if (ctx->Point._Attenuated || ctx->VertexProgram.PointSizeEnabled) {
USE(atten_antialiased_rgba_point);
}
- else if (ctx->Texture._ReallyEnabled) {
+ else if (ctx->Texture._EnabledUnits) {
USE(antialiased_tex_rgba_point);
}
else {
@@ -228,7 +228,7 @@ _swrast_choose_point( GLcontext *ctx )
}
else if (ctx->Point._Attenuated || ctx->VertexProgram.PointSizeEnabled) {
if (rgbMode) {
- if (ctx->Texture._ReallyEnabled) {
+ if (ctx->Texture._EnabledUnits) {
if (ctx->Point.SmoothFlag) {
USE(atten_antialiased_rgba_point);
}
@@ -245,7 +245,7 @@ _swrast_choose_point( GLcontext *ctx )
USE(atten_general_ci_point);
}
}
- else if (ctx->Texture._ReallyEnabled && rgbMode) {
+ else if (ctx->Texture._EnabledUnits && rgbMode) {
/* textured */
USE(textured_rgba_point);
}
diff --git a/src/mesa/swrast/s_pointtemp.h b/src/mesa/swrast/s_pointtemp.h
index 1865e1a7d3a..1fc8ba39f4c 100644
--- a/src/mesa/swrast/s_pointtemp.h
+++ b/src/mesa/swrast/s_pointtemp.h
@@ -1,4 +1,4 @@
-/* $Id: s_pointtemp.h,v 1.16 2002/05/27 17:04:53 brianp Exp $ */
+/* $Id: s_pointtemp.h,v 1.17 2002/06/15 03:03:11 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -284,7 +284,7 @@ NAME ( GLcontext *ctx, const SWvertex *vert )
ASSERT(span->end > 0);
#if FLAGS & (TEXTURE | SPRITE)
- if (ctx->Texture._ReallyEnabled)
+ if (ctx->Texture._EnabledUnits)
_mesa_write_texture_span(ctx, span);
else
_mesa_write_rgba_span(ctx, span);
diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c
index 0a1e3176083..a3271d7806d 100644
--- a/src/mesa/swrast/s_span.c
+++ b/src/mesa/swrast/s_span.c
@@ -1,4 +1,4 @@
-/* $Id: s_span.c,v 1.43 2002/06/15 02:38:17 brianp Exp $ */
+/* $Id: s_span.c,v 1.44 2002/06/15 03:03:11 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -345,7 +345,7 @@ interpolate_texcoords(GLcontext *ctx, struct sw_span *span)
ASSERT(span->interpMask & SPAN_TEXTURE);
ASSERT(!(span->arrayMask & SPAN_TEXTURE));
- if (ctx->Texture._ReallyEnabled & ~TEXTURE0_ANY) {
+ if (ctx->Texture._EnabledUnits > 1) {
/* multitexture */
GLuint u;
span->arrayMask |= SPAN_TEXTURE;
@@ -355,8 +355,8 @@ interpolate_texcoords(GLcontext *ctx, struct sw_span *span)
const struct gl_texture_image *img = obj->Image[obj->BaseLevel];
GLboolean needLambda = (obj->MinFilter != obj->MagFilter);
if (needLambda) {
- const GLfloat texW = (GLfloat) img->Width;
- const GLfloat texH = (GLfloat) img->Height;
+ const GLfloat texW = (GLfloat) img->WidthScale;
+ const GLfloat texH = (GLfloat) img->HeightScale;
const GLfloat dsdx = span->texStepX[u][0];
const GLfloat dsdy = span->texStepY[u][0];
const GLfloat dtdx = span->texStepX[u][1];
@@ -432,8 +432,8 @@ interpolate_texcoords(GLcontext *ctx, struct sw_span *span)
span->arrayMask |= SPAN_TEXTURE;
if (needLambda) {
/* just texture unit 0, with lambda */
- const GLfloat texW = (GLfloat) img->Width;
- const GLfloat texH = (GLfloat) img->Height;
+ const GLfloat texW = (GLfloat) img->WidthScale;
+ const GLfloat texH = (GLfloat) img->HeightScale;
const GLfloat dsdx = span->texStepX[0][0];
const GLfloat dsdy = span->texStepY[0][0];
const GLfloat dtdx = span->texStepX[0][1];
@@ -1137,7 +1137,7 @@ _mesa_write_texture_span( GLcontext *ctx, struct sw_span *span)
span->primitive == GL_POLYGON || span->primitive == GL_BITMAP);
ASSERT(span->end <= MAX_WIDTH);
ASSERT((span->interpMask & span->arrayMask) == 0);
- ASSERT(ctx->Texture._ReallyEnabled);
+ ASSERT(ctx->Texture._EnabledUnits);
/*
printf("%s() interp 0x%x array 0x%x\n", __FUNCTION__, span->interpMask, span->arrayMask);
diff --git a/src/mesa/swrast/s_texture.c b/src/mesa/swrast/s_texture.c
index 97a8447c306..ab8b00abee0 100644
--- a/src/mesa/swrast/s_texture.c
+++ b/src/mesa/swrast/s_texture.c
@@ -1,4 +1,4 @@
-/* $Id: s_texture.c,v 1.62 2002/05/02 00:59:20 brianp Exp $ */
+/* $Id: s_texture.c,v 1.63 2002/06/15 03:03:11 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -2016,6 +2016,187 @@ sample_lambda_cube( GLcontext *ctx, GLuint texUnit,
}
+/**********************************************************************/
+/* Texture Rectangle Sampling Functions */
+/**********************************************************************/
+
+static void
+sample_nearest_rect(GLcontext *ctx, GLuint texUnit,
+ const struct gl_texture_object *tObj, GLuint n,
+ GLfloat texcoords[][4], const GLfloat lambda[],
+ GLchan rgba[][4])
+{
+ const struct gl_texture_image *img = tObj->Image[0];
+ const GLfloat width = (GLfloat) img->Width;
+ const GLfloat height = (GLfloat) img->Height;
+ const GLint width_minus_1 = img->Width - 1;
+ const GLint height_minus_1 = img->Height - 1;
+ GLuint i;
+
+ (void) texUnit;
+ (void) lambda;
+
+ ASSERT(tObj->WrapS == GL_CLAMP ||
+ tObj->WrapS == GL_CLAMP_TO_EDGE ||
+ tObj->WrapS == GL_CLAMP_TO_BORDER_ARB);
+ ASSERT(tObj->WrapT == GL_CLAMP ||
+ tObj->WrapT == GL_CLAMP_TO_EDGE ||
+ tObj->WrapT == GL_CLAMP_TO_BORDER_ARB);
+ ASSERT(img->Format != GL_COLOR_INDEX);
+
+ /* XXX move Wrap mode tests outside of loops for common cases */
+ for (i = 0; i < n; i++) {
+ GLint row, col;
+ /* NOTE: we DO NOT use [0, 1] texture coordinates! */
+ if (tObj->WrapS == GL_CLAMP) {
+ col = IFLOOR( CLAMP(texcoords[i][0], 0.0F, width) );
+ }
+ else if (tObj->WrapS == GL_CLAMP_TO_EDGE) {
+ col = IFLOOR( CLAMP(texcoords[i][0], 0.5F, width - 0.5F) );
+ }
+ else {
+ col = IFLOOR( CLAMP(texcoords[i][0], -0.5F, width + 0.5F) );
+ }
+ if (tObj->WrapT == GL_CLAMP) {
+ row = IFLOOR( CLAMP(texcoords[i][1], 0.0F, height) );
+ }
+ else if (tObj->WrapT == GL_CLAMP_TO_EDGE) {
+ row = IFLOOR( CLAMP(texcoords[i][1], 0.5F, height - 0.5F) );
+ }
+ else {
+ row = IFLOOR( CLAMP(texcoords[i][1], -0.5F, height + 0.5F) );
+ }
+
+ col = CLAMP(col, 0, width_minus_1);
+ row = CLAMP(row, 0, height_minus_1);
+
+ (*img->FetchTexel)(img, col, row, 0, (GLvoid *) rgba[i]);
+ }
+}
+
+
+static void
+sample_linear_rect(GLcontext *ctx, GLuint texUnit,
+ const struct gl_texture_object *tObj, GLuint n,
+ GLfloat texcoords[][4],
+ const GLfloat lambda[], GLchan rgba[][4])
+{
+ const struct gl_texture_image *img = tObj->Image[0];
+ const GLfloat width = (GLfloat) img->Width;
+ const GLfloat height = (GLfloat) img->Height;
+ const GLint width_minus_1 = img->Width - 1;
+ const GLint height_minus_1 = img->Height - 1;
+ GLuint i;
+
+ (void) texUnit;
+ (void) lambda;
+
+ ASSERT(tObj->WrapS == GL_CLAMP ||
+ tObj->WrapS == GL_CLAMP_TO_EDGE ||
+ tObj->WrapS == GL_CLAMP_TO_BORDER_ARB);
+ ASSERT(tObj->WrapT == GL_CLAMP ||
+ tObj->WrapT == GL_CLAMP_TO_EDGE ||
+ tObj->WrapT == GL_CLAMP_TO_BORDER_ARB);
+ ASSERT(img->Format != GL_COLOR_INDEX);
+
+ /* XXX lots of opportunity for optimization in this loop */
+ for (i = 0; i < n; i++) {
+ GLfloat frow, fcol;
+ GLint row0, col0, row1, col1;
+ GLchan t00[4], t01[4], t10[4], t11[4];
+ GLfloat a, b, w00, w01, w10, w11;
+
+ /* NOTE: we DO NOT use [0, 1] texture coordinates! */
+ if (tObj->WrapS == GL_CLAMP) {
+ fcol = CLAMP(texcoords[i][0], 0.0F, width);
+ }
+ else if (tObj->WrapS == GL_CLAMP_TO_EDGE) {
+ fcol = CLAMP(texcoords[i][0], 0.5F, width - 0.5F);
+ }
+ else {
+ fcol = CLAMP(texcoords[i][0], -0.5F, width + 0.5F);
+ }
+ if (tObj->WrapT == GL_CLAMP) {
+ frow = CLAMP(texcoords[i][1], 0.0F, height);
+ }
+ else if (tObj->WrapT == GL_CLAMP_TO_EDGE) {
+ frow = CLAMP(texcoords[i][1], 0.5F, height - 0.5F);
+ }
+ else {
+ frow = CLAMP(texcoords[i][1], -0.5F, height + 0.5F);
+ }
+
+ /* compute integer rows/columns */
+ col0 = IFLOOR(fcol);
+ col1 = col0 + 1;
+ col0 = CLAMP(col0, 0, width_minus_1);
+ col1 = CLAMP(col1, 0, width_minus_1);
+ row0 = IFLOOR(frow);
+ row1 = row0 + 1;
+ row0 = CLAMP(row0, 0, height_minus_1);
+ row1 = CLAMP(row1, 0, height_minus_1);
+
+ /* get four texel samples */
+ (*img->FetchTexel)(img, col0, row0, 0, (GLvoid *) t00);
+ (*img->FetchTexel)(img, col1, row0, 0, (GLvoid *) t10);
+ (*img->FetchTexel)(img, col0, row1, 0, (GLvoid *) t01);
+ (*img->FetchTexel)(img, col1, row1, 0, (GLvoid *) t11);
+
+ /* compute sample weights */
+ a = FRAC(fcol);
+ b = FRAC(frow);
+ w00 = (1.0F-a) * (1.0F-b);
+ w10 = a * (1.0F-b);
+ w01 = (1.0F-a) * b ;
+ w11 = a * b ;
+
+ /* compute weighted average of samples */
+ rgba[i][0] = w00 * t00[0] + w10 * t10[0] + w01 * t01[0] + w11 * t11[0];
+ rgba[i][1] = w00 * t00[1] + w10 * t10[1] + w01 * t01[1] + w11 * t11[1];
+ rgba[i][2] = w00 * t00[2] + w10 * t10[2] + w01 * t01[2] + w11 * t11[2];
+ rgba[i][3] = w00 * t00[3] + w10 * t10[3] + w01 * t01[3] + w11 * t11[3];
+ }
+}
+
+
+static void
+sample_lambda_rect( GLcontext *ctx, GLuint texUnit,
+ const struct gl_texture_object *tObj, GLuint n,
+ GLfloat texcoords[][4], const GLfloat lambda[],
+ GLchan rgba[][4])
+{
+ GLuint minStart, minEnd, magStart, magEnd;
+
+ /* We only need lambda to decide between minification and magnification.
+ * There is no mipmapping with rectangular textures.
+ */
+ compute_min_mag_ranges(SWRAST_CONTEXT(ctx)->_MinMagThresh[texUnit],
+ n, lambda, &minStart, &minEnd, &magStart, &magEnd);
+
+ if (minStart < minEnd) {
+ if (tObj->MinFilter == GL_NEAREST) {
+ sample_nearest_rect( ctx, texUnit, tObj, minEnd - minStart,
+ texcoords + minStart, NULL, rgba + minStart);
+ }
+ else {
+ sample_linear_rect( ctx, texUnit, tObj, minEnd - minStart,
+ texcoords + minStart, NULL, rgba + minStart);
+ }
+ }
+ if (magStart < magEnd) {
+ if (tObj->MagFilter == GL_NEAREST) {
+ sample_nearest_rect( ctx, texUnit, tObj, magEnd - magStart,
+ texcoords + magStart, NULL, rgba + magStart);
+ }
+ else {
+ sample_linear_rect( ctx, texUnit, tObj, magEnd - magStart,
+ texcoords + magStart, NULL, rgba + magStart);
+ }
+ }
+}
+
+
+
/*
* Sample a shadow/depth texture.
*/
@@ -2036,7 +2217,9 @@ sample_depth_texture( GLcontext *ctx, GLuint unit,
(void) unit;
ASSERT(tObj->Image[tObj->BaseLevel]->Format == GL_DEPTH_COMPONENT);
- ASSERT(tObj->Dimensions == 1 || tObj->Dimensions == 2);
+ ASSERT(tObj->Target == GL_TEXTURE_1D ||
+ tObj->Target == GL_TEXTURE_2D ||
+ tObj->Target == GL_TEXTURE_RECTANGLE_NV);
/* XXXX if tObj->MinFilter != tObj->MagFilter, we're ignoring lambda */
@@ -2064,6 +2247,7 @@ sample_depth_texture( GLcontext *ctx, GLuint unit,
for (i = 0; i < n; i++) {
GLfloat depthSample;
GLint col, row;
+ /* XXX fix for texture rectangle! */
COMPUTE_NEAREST_TEXEL_LOCATION(tObj->WrapS, texcoords[i][0], width, col);
COMPUTE_NEAREST_TEXEL_LOCATION(tObj->WrapT, texcoords[i][1], height, row);
depthSample = *((const GLfloat *) texImage->Data + row * width + col);
@@ -2134,6 +2318,7 @@ sample_depth_texture( GLcontext *ctx, GLuint unit,
GLfloat u, v;
GLuint useBorderTexel;
+ /* XXX fix for texture rectangle! */
COMPUTE_LINEAR_TEXEL_LOCATIONS(tObj->WrapS, texcoords[i][0], u, width, i0, i1);
COMPUTE_LINEAR_TEXEL_LOCATIONS(tObj->WrapT, texcoords[i][1], v, height,j0, j1);
@@ -2317,7 +2502,7 @@ sample_depth_texture2(const GLcontext *ctx,
const GLchan ambient = texObj->ShadowAmbient;
GLboolean lequal, gequal;
- if (texObj->Dimensions != 2) {
+ if (texObj->Target != GL_TEXTURE_2D) {
_mesa_problem(ctx, "only 2-D depth textures supported at this time");
return;
}
@@ -2435,8 +2620,8 @@ _swrast_choose_texture_sample_func( GLcontext *ctx, GLuint texUnit,
}
}
- switch (t->Dimensions) {
- case 1:
+ switch (t->Target) {
+ case GL_TEXTURE_1D:
if (format == GL_DEPTH_COMPONENT) {
swrast->TextureSample[texUnit] = sample_depth_texture;
}
@@ -2451,7 +2636,7 @@ _swrast_choose_texture_sample_func( GLcontext *ctx, GLuint texUnit,
swrast->TextureSample[texUnit] = sample_nearest_1d;
}
break;
- case 2:
+ case GL_TEXTURE_2D:
if (format == GL_DEPTH_COMPONENT) {
swrast->TextureSample[texUnit] = sample_depth_texture;
}
@@ -2480,7 +2665,7 @@ _swrast_choose_texture_sample_func( GLcontext *ctx, GLuint texUnit,
swrast->TextureSample[texUnit] = sample_nearest_2d;
}
break;
- case 3:
+ case GL_TEXTURE_3D:
if (needLambda) {
swrast->TextureSample[texUnit] = sample_lambda_3d;
}
@@ -2492,7 +2677,7 @@ _swrast_choose_texture_sample_func( GLcontext *ctx, GLuint texUnit,
swrast->TextureSample[texUnit] = sample_nearest_3d;
}
break;
- case 6: /* cube map */
+ case GL_TEXTURE_CUBE_MAP_ARB:
if (needLambda) {
swrast->TextureSample[texUnit] = sample_lambda_cube;
}
@@ -2504,8 +2689,20 @@ _swrast_choose_texture_sample_func( GLcontext *ctx, GLuint texUnit,
swrast->TextureSample[texUnit] = sample_nearest_cube;
}
break;
+ case GL_TEXTURE_RECTANGLE_NV:
+ if (needLambda) {
+ swrast->TextureSample[texUnit] = sample_lambda_rect;
+ }
+ else if (t->MinFilter == GL_LINEAR) {
+ swrast->TextureSample[texUnit] = sample_linear_rect;
+ }
+ else {
+ ASSERT(t->MinFilter == GL_NEAREST);
+ swrast->TextureSample[texUnit] = sample_nearest_rect;
+ }
+ break;
default:
- _mesa_problem(ctx, "invalid dimensions in _swrast_choose_texture_sample_func");
+ _mesa_problem(ctx, "invalid target in _swrast_choose_texture_sample_func");
}
}
}
@@ -2640,7 +2837,6 @@ texture_combine( const GLcontext *ctx, GLuint unit, GLuint n,
return;
argRGB[j] = (const GLchan (*)[4])
(texelBuffer + srcUnit * (n * 4 * sizeof(GLchan)));
- printf("unit %d from unit %d\n", unit, srcUnit);
}
}
diff --git a/src/mesa/swrast/s_triangle.c b/src/mesa/swrast/s_triangle.c
index 1816624d67a..bdbdde76b83 100644
--- a/src/mesa/swrast/s_triangle.c
+++ b/src/mesa/swrast/s_triangle.c
@@ -1,4 +1,4 @@
-/* $Id: s_triangle.c,v 1.58 2002/04/19 14:05:50 brianp Exp $ */
+/* $Id: s_triangle.c,v 1.59 2002/06/15 03:03:12 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -124,7 +124,7 @@ static void flat_rgba_triangle( GLcontext *ctx,
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define SETUP_CODE \
- ASSERT(!ctx->Texture._ReallyEnabled); \
+ ASSERT(ctx->Texture._EnabledUnits == 0); \
ASSERT(ctx->Light.ShadeModel==GL_FLAT); \
span->interpMask |= SPAN_RGBA; \
span->red = ChanToFixed(v2->color[0]); \
@@ -161,7 +161,7 @@ static void smooth_rgba_triangle( GLcontext *ctx,
#define SETUP_CODE \
{ \
/* texturing must be off */ \
- ASSERT(!ctx->Texture._ReallyEnabled); \
+ ASSERT(ctx->Texture._EnabledUnits == 0); \
ASSERT(ctx->Light.ShadeModel==GL_SMOOTH); \
}
@@ -1116,7 +1116,7 @@ _swrast_choose_triangle( GLcontext *ctx )
}
}
- if (ctx->Texture._ReallyEnabled) {
+ if (ctx->Texture._EnabledUnits) {
/* 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;
@@ -1130,7 +1130,8 @@ _swrast_choose_triangle( GLcontext *ctx )
envMode = ctx->Texture.Unit[0].EnvMode;
/* First see if we can used an optimized 2-D texture function */
- if (ctx->Texture._ReallyEnabled==TEXTURE0_2D
+ if (ctx->Texture._EnabledUnits == 1
+ && ctx->Texture.Unit[0]._ReallyEnabled == TEXTURE_2D_BIT
&& texObj2D->WrapS==GL_REPEAT
&& texObj2D->WrapT==GL_REPEAT
&& texImg->Border==0
@@ -1172,7 +1173,7 @@ _swrast_choose_triangle( GLcontext *ctx )
}
else {
/* general case textured triangles */
- if (ctx->Texture._ReallyEnabled > TEXTURE0_ANY) {
+ if (ctx->Texture._EnabledUnits > 1) {
USE(multitextured_triangle);
}
else {
@@ -1181,7 +1182,7 @@ _swrast_choose_triangle( GLcontext *ctx )
}
}
else {
- ASSERT(!ctx->Texture._ReallyEnabled);
+ ASSERT(!ctx->Texture._EnabledUnits);
if (ctx->Light.ShadeModel==GL_SMOOTH) {
/* smooth shaded, no texturing, stippled or some raster ops */
if (rgbmode) {