aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/swrast
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2006-04-27 02:50:31 +0000
committerBrian Paul <[email protected]>2006-04-27 02:50:31 +0000
commitc4fe46f0b8b45407ea40500b869ae1beca71063c (patch)
tree49278ff60f8e6af5f127cff10c266565245f2f4c /src/mesa/swrast
parent444cd293fd69d1848b2c55f75674d563e0582fba (diff)
fixes for CHAN_BITS!=8
Diffstat (limited to 'src/mesa/swrast')
-rw-r--r--src/mesa/swrast/s_accum.c20
-rw-r--r--src/mesa/swrast/s_logic.c2
-rw-r--r--src/mesa/swrast/s_texcombine.c41
3 files changed, 38 insertions, 25 deletions
diff --git a/src/mesa/swrast/s_accum.c b/src/mesa/swrast/s_accum.c
index cf6dab912b9..a159e804976 100644
--- a/src/mesa/swrast/s_accum.c
+++ b/src/mesa/swrast/s_accum.c
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 6.5
+ * Version: 6.5.1
*
- * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -35,6 +35,9 @@
#include "s_span.h"
+/* XXX this would have to change for accum buffers with more or less
+ * than 16 bits per color channel.
+ */
#define ACCUM_SCALE16 32767.0
@@ -419,9 +422,6 @@ accum_load(GLcontext *ctx, GLfloat value,
}
}
}
- else {
- /* other types someday */
- }
}
@@ -462,7 +462,8 @@ accum_return(GLcontext *ctx, GLfloat value,
if (accumRb->DataType == GL_SHORT ||
accumRb->DataType == GL_UNSIGNED_SHORT) {
const GLfloat scale = value * CHAN_MAXF / ACCUM_SCALE16;
- GLuint buffer, i;
+ GLuint buffer;
+ GLint i;
/* XXX maybe transpose the 'i' and 'buffer' loops??? */
for (i = 0; i < height; i++) {
@@ -496,10 +497,17 @@ accum_return(GLcontext *ctx, GLfloat value,
/* scaled integer (or float) accum buffer */
GLint j;
for (j = 0; j < width; j++) {
+#if CHAN_BITS==32
+ GLchan r = acc[j * 4 + 0] * scale;
+ GLchan g = acc[j * 4 + 1] * scale;
+ GLchan b = acc[j * 4 + 2] * scale;
+ GLchan a = acc[j * 4 + 3] * scale;
+#else
GLint r = IROUND( (GLfloat) (acc[j * 4 + 0]) * scale );
GLint g = IROUND( (GLfloat) (acc[j * 4 + 1]) * scale );
GLint b = IROUND( (GLfloat) (acc[j * 4 + 2]) * scale );
GLint a = IROUND( (GLfloat) (acc[j * 4 + 3]) * scale );
+#endif
rgba[j][RCOMP] = CLAMP( r, 0, CHAN_MAX );
rgba[j][GCOMP] = CLAMP( g, 0, CHAN_MAX );
rgba[j][BCOMP] = CLAMP( b, 0, CHAN_MAX );
diff --git a/src/mesa/swrast/s_logic.c b/src/mesa/swrast/s_logic.c
index ff3c3fc2f14..60458c2b804 100644
--- a/src/mesa/swrast/s_logic.c
+++ b/src/mesa/swrast/s_logic.c
@@ -216,7 +216,7 @@ _swrast_logicop_rgba_span(GLcontext *ctx, struct gl_renderbuffer *rb,
ASSERT(span->end < MAX_WIDTH);
ASSERT(span->arrayMask & SPAN_RGBA);
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
+ ASSERT(rb->DataType == CHAN_TYPE);
if (span->arrayMask & SPAN_XY) {
_swrast_get_values(ctx, rb, span->end, span->array->x, span->array->y,
diff --git a/src/mesa/swrast/s_texcombine.c b/src/mesa/swrast/s_texcombine.c
index 3c9fdc4d757..db77ad8bc3e 100644
--- a/src/mesa/swrast/s_texcombine.c
+++ b/src/mesa/swrast/s_texcombine.c
@@ -36,6 +36,11 @@
#define PROD(A,B) ( (GLuint)(A) * ((GLuint)(B)+1) )
#define S_PROD(A,B) ( (GLint)(A) * ((GLint)(B)+1) )
+#if CHAN_BITS == 32
+typedef GLfloat ChanTemp;
+#else
+typedef GLuint ChanTemp;
+#endif
/**
@@ -996,10 +1001,10 @@ texture_apply( const GLcontext *ctx,
break;
case GL_LUMINANCE:
for (i=0;i<n;i++) {
- GLuint Lt = texel[i][RCOMP];
- GLuint r = rgba[i][RCOMP] + Lt;
- GLuint g = rgba[i][GCOMP] + Lt;
- GLuint b = rgba[i][BCOMP] + Lt;
+ ChanTemp Lt = texel[i][RCOMP];
+ ChanTemp r = rgba[i][RCOMP] + Lt;
+ ChanTemp g = rgba[i][GCOMP] + Lt;
+ ChanTemp b = rgba[i][BCOMP] + Lt;
rgba[i][RCOMP] = MIN2(r, CHAN_MAX);
rgba[i][GCOMP] = MIN2(g, CHAN_MAX);
rgba[i][BCOMP] = MIN2(b, CHAN_MAX);
@@ -1008,10 +1013,10 @@ texture_apply( const GLcontext *ctx,
break;
case GL_LUMINANCE_ALPHA:
for (i=0;i<n;i++) {
- GLuint Lt = texel[i][RCOMP];
- GLuint r = rgba[i][RCOMP] + Lt;
- GLuint g = rgba[i][GCOMP] + Lt;
- GLuint b = rgba[i][BCOMP] + Lt;
+ ChanTemp Lt = texel[i][RCOMP];
+ ChanTemp r = rgba[i][RCOMP] + Lt;
+ ChanTemp g = rgba[i][GCOMP] + Lt;
+ ChanTemp b = rgba[i][BCOMP] + Lt;
rgba[i][RCOMP] = MIN2(r, CHAN_MAX);
rgba[i][GCOMP] = MIN2(g, CHAN_MAX);
rgba[i][BCOMP] = MIN2(b, CHAN_MAX);
@@ -1021,10 +1026,10 @@ texture_apply( const GLcontext *ctx,
case GL_INTENSITY:
for (i=0;i<n;i++) {
GLchan It = texel[i][RCOMP];
- GLuint r = rgba[i][RCOMP] + It;
- GLuint g = rgba[i][GCOMP] + It;
- GLuint b = rgba[i][BCOMP] + It;
- GLuint a = rgba[i][ACOMP] + It;
+ ChanTemp r = rgba[i][RCOMP] + It;
+ ChanTemp g = rgba[i][GCOMP] + It;
+ ChanTemp b = rgba[i][BCOMP] + It;
+ ChanTemp a = rgba[i][ACOMP] + It;
rgba[i][RCOMP] = MIN2(r, CHAN_MAX);
rgba[i][GCOMP] = MIN2(g, CHAN_MAX);
rgba[i][BCOMP] = MIN2(b, CHAN_MAX);
@@ -1033,9 +1038,9 @@ texture_apply( const GLcontext *ctx,
break;
case GL_RGB:
for (i=0;i<n;i++) {
- GLuint r = rgba[i][RCOMP] + texel[i][RCOMP];
- GLuint g = rgba[i][GCOMP] + texel[i][GCOMP];
- GLuint b = rgba[i][BCOMP] + texel[i][BCOMP];
+ ChanTemp r = rgba[i][RCOMP] + texel[i][RCOMP];
+ ChanTemp g = rgba[i][GCOMP] + texel[i][GCOMP];
+ ChanTemp b = rgba[i][BCOMP] + texel[i][BCOMP];
rgba[i][RCOMP] = MIN2(r, CHAN_MAX);
rgba[i][GCOMP] = MIN2(g, CHAN_MAX);
rgba[i][BCOMP] = MIN2(b, CHAN_MAX);
@@ -1044,9 +1049,9 @@ texture_apply( const GLcontext *ctx,
break;
case GL_RGBA:
for (i=0;i<n;i++) {
- GLuint r = rgba[i][RCOMP] + texel[i][RCOMP];
- GLuint g = rgba[i][GCOMP] + texel[i][GCOMP];
- GLuint b = rgba[i][BCOMP] + texel[i][BCOMP];
+ ChanTemp r = rgba[i][RCOMP] + texel[i][RCOMP];
+ ChanTemp g = rgba[i][GCOMP] + texel[i][GCOMP];
+ ChanTemp b = rgba[i][BCOMP] + texel[i][BCOMP];
rgba[i][RCOMP] = MIN2(r, CHAN_MAX);
rgba[i][GCOMP] = MIN2(g, CHAN_MAX);
rgba[i][BCOMP] = MIN2(b, CHAN_MAX);