diff options
author | Brian Paul <[email protected]> | 2001-09-19 22:21:13 +0000 |
---|---|---|
committer | Brian Paul <[email protected]> | 2001-09-19 22:21:13 +0000 |
commit | 7152305e0a7d963f49c05bc530e495dc3ad82e3b (patch) | |
tree | 7740156820301e87dce098f8769b55582d117c69 | |
parent | 7c4268176eaaeb45003db4d5042a518b84c9f6dc (diff) |
GL_ADD texture mode was incorrect, renamed some vars
-rw-r--r-- | src/mesa/swrast/s_triangle.c | 97 |
1 files changed, 49 insertions, 48 deletions
diff --git a/src/mesa/swrast/s_triangle.c b/src/mesa/swrast/s_triangle.c index cc447ac5707..02c27d52968 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.38 2001/09/19 20:30:44 kschultz Exp $ */ +/* $Id: s_triangle.c,v 1.39 2001/09/19 22:21:13 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -344,11 +344,16 @@ struct affine_info GLint fixedToDepthShift; }; + +/* This function can handle GL_NEAREST or GL_LINEAR sampling of 2D RGB or RGBA + * textures with GL_REPLACE, GL_MODULATE, GL_BLEND, GL_DECAL or GL_ADD + * texture env modes. + */ static void affine_span(GLcontext *ctx, struct triangle_span *span, struct affine_info *info) { - GLchan tmp_col[4]; + GLchan sample[4]; /* the filtered texture sample */ /* Instead of defining a function for each mode, a test is done * between the outer and inner loops. This is to reduce code size @@ -357,75 +362,71 @@ affine_span(GLcontext *ctx, struct triangle_span *span, */ #define NEAREST_RGB \ - tmp_col[RCOMP] = tex00[RCOMP]; \ - tmp_col[GCOMP] = tex00[GCOMP]; \ - tmp_col[BCOMP] = tex00[BCOMP]; \ - tmp_col[ACOMP] = CHAN_MAX + sample[RCOMP] = tex00[RCOMP]; \ + sample[GCOMP] = tex00[GCOMP]; \ + sample[BCOMP] = tex00[BCOMP]; \ + sample[ACOMP] = CHAN_MAX #define LINEAR_RGB \ - tmp_col[RCOMP] = (ti * (si * tex00[0] + sf * tex01[0]) + \ + sample[RCOMP] = (ti * (si * tex00[0] + sf * tex01[0]) + \ tf * (si * tex10[0] + sf * tex11[0])) >> 2 * FIXED_SHIFT; \ - tmp_col[GCOMP] = (ti * (si * tex00[1] + sf * tex01[1]) + \ + sample[GCOMP] = (ti * (si * tex00[1] + sf * tex01[1]) + \ tf * (si * tex10[1] + sf * tex11[1])) >> 2 * FIXED_SHIFT; \ - tmp_col[BCOMP] = (ti * (si * tex00[2] + sf * tex01[2]) + \ + sample[BCOMP] = (ti * (si * tex00[2] + sf * tex01[2]) + \ tf * (si * tex10[2] + sf * tex11[2])) >> 2 * FIXED_SHIFT; \ - tmp_col[ACOMP] = CHAN_MAX + sample[ACOMP] = CHAN_MAX -#define NEAREST_RGBA COPY_CHAN4(tmp_col, tex00) +#define NEAREST_RGBA COPY_CHAN4(sample, tex00) #define LINEAR_RGBA \ - tmp_col[RCOMP] = (ti * (si * tex00[0] + sf * tex01[0]) + \ + sample[RCOMP] = (ti * (si * tex00[0] + sf * tex01[0]) + \ tf * (si * tex10[0] + sf * tex11[0])) >> 2 * FIXED_SHIFT;\ - tmp_col[GCOMP] = (ti * (si * tex00[1] + sf * tex01[1]) + \ + sample[GCOMP] = (ti * (si * tex00[1] + sf * tex01[1]) + \ tf * (si * tex10[1] + sf * tex11[1])) >> 2 * FIXED_SHIFT;\ - tmp_col[BCOMP] = (ti * (si * tex00[2] + sf * tex01[2]) + \ + sample[BCOMP] = (ti * (si * tex00[2] + sf * tex01[2]) + \ tf * (si * tex10[2] + sf * tex11[2])) >> 2 * FIXED_SHIFT;\ - tmp_col[ACOMP] = (ti * (si * tex00[3] + sf * tex01[3]) + \ + sample[ACOMP] = (ti * (si * tex00[3] + sf * tex01[3]) + \ tf * (si * tex10[3] + sf * tex11[3])) >> 2 * FIXED_SHIFT #define MODULATE \ - dest[RCOMP] = span->red * (tmp_col[RCOMP] + 1u) >> (FIXED_SHIFT + 8); \ - dest[GCOMP] = span->green * (tmp_col[GCOMP] + 1u) >> (FIXED_SHIFT + 8); \ - dest[BCOMP] = span->blue * (tmp_col[BCOMP] + 1u) >> (FIXED_SHIFT + 8); \ - dest[ACOMP] = span->alpha * (tmp_col[ACOMP] + 1u) >> (FIXED_SHIFT + 8) + dest[RCOMP] = span->red * (sample[RCOMP] + 1u) >> (FIXED_SHIFT + 8); \ + dest[GCOMP] = span->green * (sample[GCOMP] + 1u) >> (FIXED_SHIFT + 8); \ + dest[BCOMP] = span->blue * (sample[BCOMP] + 1u) >> (FIXED_SHIFT + 8); \ + dest[ACOMP] = span->alpha * (sample[ACOMP] + 1u) >> (FIXED_SHIFT + 8) #define DECAL \ - dest[RCOMP] = ((CHAN_MAX - tmp_col[ACOMP]) * span->red + \ - ((tmp_col[ACOMP] + 1) * tmp_col[RCOMP] << FIXED_SHIFT)) \ + dest[RCOMP] = ((CHAN_MAX - sample[ACOMP]) * span->red + \ + ((sample[ACOMP] + 1) * sample[RCOMP] << FIXED_SHIFT)) \ >> (FIXED_SHIFT + 8); \ - dest[GCOMP] = ((CHAN_MAX - tmp_col[ACOMP]) * span->green + \ - ((tmp_col[ACOMP] + 1) * tmp_col[GCOMP] << FIXED_SHIFT)) \ + dest[GCOMP] = ((CHAN_MAX - sample[ACOMP]) * span->green + \ + ((sample[ACOMP] + 1) * sample[GCOMP] << FIXED_SHIFT)) \ >> (FIXED_SHIFT + 8); \ - dest[BCOMP] = ((CHAN_MAX - tmp_col[ACOMP]) * span->blue + \ - ((tmp_col[ACOMP] + 1) * tmp_col[BCOMP] << FIXED_SHIFT)) \ + dest[BCOMP] = ((CHAN_MAX - sample[ACOMP]) * span->blue + \ + ((sample[ACOMP] + 1) * sample[BCOMP] << FIXED_SHIFT)) \ >> (FIXED_SHIFT + 8); \ dest[ACOMP] = FixedToInt(span->alpha) #define BLEND \ - dest[RCOMP] = ((CHAN_MAX - tmp_col[RCOMP]) * span->red \ - + (tmp_col[RCOMP] + 1) * info->er) >> (FIXED_SHIFT + 8); \ - dest[GCOMP] = ((CHAN_MAX - tmp_col[GCOMP]) * span->green \ - + (tmp_col[GCOMP] + 1) * info->eg) >> (FIXED_SHIFT + 8); \ - dest[BCOMP] = ((CHAN_MAX - tmp_col[BCOMP]) * span->blue \ - + (tmp_col[BCOMP] + 1) * info->eb) >> (FIXED_SHIFT + 8); \ - dest[ACOMP] = span->alpha * (tmp_col[ACOMP] + 1) >> (FIXED_SHIFT + 8) + dest[RCOMP] = ((CHAN_MAX - sample[RCOMP]) * span->red \ + + (sample[RCOMP] + 1) * info->er) >> (FIXED_SHIFT + 8); \ + dest[GCOMP] = ((CHAN_MAX - sample[GCOMP]) * span->green \ + + (sample[GCOMP] + 1) * info->eg) >> (FIXED_SHIFT + 8); \ + dest[BCOMP] = ((CHAN_MAX - sample[BCOMP]) * span->blue \ + + (sample[BCOMP] + 1) * info->eb) >> (FIXED_SHIFT + 8); \ + dest[ACOMP] = span->alpha * (sample[ACOMP] + 1) >> (FIXED_SHIFT + 8) -#define REPLACE COPY_CHAN4(dest, tmp_col) - -#define I2CHAN_CLAMP(I) (GLchan) ((I) & CHAN_MAX) - /* equivalent to '(GLchan) MIN2((I),CHAN_MAX)' */ +#define REPLACE COPY_CHAN4(dest, sample) #define ADD \ - dest[RCOMP] = MIN2(((span->red << 8) + \ - (tmp_col[RCOMP] + 1) * info->er) \ - >> (FIXED_SHIFT + 8), CHAN_MAX); \ - dest[GCOMP] = MIN2(((span->green << 8) + \ - (tmp_col[GCOMP] + 1) * info->eg) \ - >> (FIXED_SHIFT + 8), CHAN_MAX); \ - dest[RCOMP] = MIN2(((span->blue << 8) + \ - (tmp_col[BCOMP] + 1) * info->eb) \ - >> (FIXED_SHIFT + 8), CHAN_MAX); \ - dest[ACOMP] = span->alpha * (tmp_col[ACOMP] + 1) >> (FIXED_SHIFT + 8) + { \ + GLint rSum = FixedToInt(span->red) + (GLint) sample[RCOMP]; \ + GLint gSum = FixedToInt(span->green) + (GLint) sample[GCOMP]; \ + GLint bSum = FixedToInt(span->blue) + (GLint) sample[BCOMP]; \ + dest[RCOMP] = MIN2(rSum, CHAN_MAX); \ + dest[GCOMP] = MIN2(gSum, CHAN_MAX); \ + dest[BCOMP] = MIN2(bSum, CHAN_MAX); \ + dest[ACOMP] = span->alpha * (sample[ACOMP] + 1) >> (FIXED_SHIFT + 8); \ + } /* shortcuts */ @@ -687,7 +688,7 @@ struct persp_info GLint smask, tmask; GLint twidth_log2; const GLchan *texture; - GLchan er, eg, eb, ea; + GLchan er, eg, eb, ea; /* texture env color */ GLint tbytesline, tsize; GLint fixedToDepthShift; }; @@ -697,7 +698,7 @@ static void fast_persp_span(GLcontext *ctx, struct triangle_span *span, struct persp_info *info) { - GLchan tmp_col[4]; + GLchan sample[4]; /* the filtered texture sample */ /* Instead of defining a function for each mode, a test is done * between the outer and inner loops. This is to reduce code size |