summaryrefslogtreecommitdiff
path: root/src/mesa/swrast
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2002-10-04 19:10:06 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2002-10-04 19:10:06 +0000
commitfc80ad6e62fb2b53d53756593099330477a44c52 (patch)
tree0b47f3ee84d613dfa2264d6f23e5c2a60cecc9ba /src/mesa/swrast
parentf782b8189e718974a40d72ac4f6b8d213ca99e1e (diff)
Changed a number of context fields from GLchan to GLfloat (such as ClearColor).
Also changed parameter types for some driver functions (like ctx->Driver.Clear- Color). Updated all the device drivers. Someday, we want to support 8, 16 and 32-bit channels dynamically at runtime.
Diffstat (limited to 'src/mesa/swrast')
-rw-r--r--src/mesa/swrast/s_alpha.c6
-rw-r--r--src/mesa/swrast/s_alphabuf.c30
-rw-r--r--src/mesa/swrast/s_buffers.c32
-rw-r--r--src/mesa/swrast/s_texture.c44
4 files changed, 58 insertions, 54 deletions
diff --git a/src/mesa/swrast/s_alpha.c b/src/mesa/swrast/s_alpha.c
index 79e27d5755..5cbfe8617a 100644
--- a/src/mesa/swrast/s_alpha.c
+++ b/src/mesa/swrast/s_alpha.c
@@ -1,4 +1,4 @@
-/* $Id: s_alpha.c,v 1.11 2002/08/07 00:45:07 brianp Exp $ */
+/* $Id: s_alpha.c,v 1.12 2002/10/04 19:10:12 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -50,11 +50,13 @@ GLint
_mesa_alpha_test( const GLcontext *ctx, struct sw_span *span )
{
const GLchan (*rgba)[4] = (const GLchan (*)[4]) span->array->rgba;
- const GLchan ref = ctx->Color.AlphaRef;
+ GLchan ref;
const GLuint n = span->end;
GLubyte *mask = span->array->mask;
GLuint i;
+ CLAMPED_FLOAT_TO_CHAN(ref, ctx->Color.AlphaRef);
+
if (span->arrayMask & SPAN_RGBA) {
/* Use the array values */
switch (ctx->Color.AlphaFunc) {
diff --git a/src/mesa/swrast/s_alphabuf.c b/src/mesa/swrast/s_alphabuf.c
index b303c0fc76..2eab878a23 100644
--- a/src/mesa/swrast/s_alphabuf.c
+++ b/src/mesa/swrast/s_alphabuf.c
@@ -1,8 +1,8 @@
-/* $Id: s_alphabuf.c,v 1.11 2002/07/09 01:22:52 brianp Exp $ */
+/* $Id: s_alphabuf.c,v 1.12 2002/10/04 19:10:12 brianp Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 4.0.2
+ * Version: 4.1
*
* Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
*
@@ -51,7 +51,7 @@ _mesa_alloc_alpha_buffers( GLframebuffer *buffer )
if (buffer->FrontLeftAlpha) {
MESA_PBUFFER_FREE( buffer->FrontLeftAlpha );
}
- buffer->FrontLeftAlpha = (GLchan *) MESA_PBUFFER_ALLOC( bytes );
+ buffer->FrontLeftAlpha = MESA_PBUFFER_ALLOC( bytes );
if (!buffer->FrontLeftAlpha) {
/* out of memory */
_mesa_error( NULL, GL_OUT_OF_MEMORY,
@@ -62,7 +62,7 @@ _mesa_alloc_alpha_buffers( GLframebuffer *buffer )
if (buffer->BackLeftAlpha) {
MESA_PBUFFER_FREE( buffer->BackLeftAlpha );
}
- buffer->BackLeftAlpha = (GLchan *) MESA_PBUFFER_ALLOC( bytes );
+ buffer->BackLeftAlpha = MESA_PBUFFER_ALLOC( bytes );
if (!buffer->BackLeftAlpha) {
/* out of memory */
_mesa_error( NULL, GL_OUT_OF_MEMORY,
@@ -74,7 +74,7 @@ _mesa_alloc_alpha_buffers( GLframebuffer *buffer )
if (buffer->FrontRightAlpha) {
MESA_PBUFFER_FREE( buffer->FrontRightAlpha );
}
- buffer->FrontRightAlpha = (GLchan *) MESA_PBUFFER_ALLOC( bytes );
+ buffer->FrontRightAlpha = MESA_PBUFFER_ALLOC( bytes );
if (!buffer->FrontRightAlpha) {
/* out of memory */
_mesa_error( NULL, GL_OUT_OF_MEMORY,
@@ -85,7 +85,7 @@ _mesa_alloc_alpha_buffers( GLframebuffer *buffer )
if (buffer->BackRightAlpha) {
MESA_PBUFFER_FREE( buffer->BackRightAlpha );
}
- buffer->BackRightAlpha = (GLchan *) MESA_PBUFFER_ALLOC( bytes );
+ buffer->BackRightAlpha = MESA_PBUFFER_ALLOC( bytes );
if (!buffer->BackRightAlpha) {
/* out of memory */
_mesa_error( NULL, GL_OUT_OF_MEMORY,
@@ -113,16 +113,16 @@ _mesa_clear_alpha_buffers( GLcontext *ctx )
if (bufferBit & ctx->Color._DrawDestMask) {
GLchan *buffer;
if (bufferBit == FRONT_LEFT_BIT) {
- buffer = ctx->DrawBuffer->FrontLeftAlpha;
+ buffer = (GLchan *) ctx->DrawBuffer->FrontLeftAlpha;
}
else if (bufferBit == FRONT_RIGHT_BIT) {
- buffer = ctx->DrawBuffer->FrontRightAlpha;
+ buffer = (GLchan *) ctx->DrawBuffer->FrontRightAlpha;
}
else if (bufferBit == BACK_LEFT_BIT) {
- buffer = ctx->DrawBuffer->BackLeftAlpha;
+ buffer = (GLchan *) ctx->DrawBuffer->BackLeftAlpha;
}
else {
- buffer = ctx->DrawBuffer->BackRightAlpha;
+ buffer = (GLchan *) ctx->DrawBuffer->BackRightAlpha;
}
if (ctx->Scissor.Enabled) {
@@ -173,20 +173,20 @@ GLchan *get_alpha_buffer( GLcontext *ctx )
{
switch (ctx->Color._DriverDrawBuffer) {
case GL_FRONT_LEFT:
- return ctx->DrawBuffer->FrontLeftAlpha;
+ return (GLchan *) ctx->DrawBuffer->FrontLeftAlpha;
break;
case GL_BACK_LEFT:
- return ctx->DrawBuffer->BackLeftAlpha;
+ return (GLchan *) ctx->DrawBuffer->BackLeftAlpha;
break;
case GL_FRONT_RIGHT:
- return ctx->DrawBuffer->FrontRightAlpha;
+ return (GLchan *) ctx->DrawBuffer->FrontRightAlpha;
break;
case GL_BACK_RIGHT:
- return ctx->DrawBuffer->BackRightAlpha;
+ return (GLchan *) ctx->DrawBuffer->BackRightAlpha;
break;
default:
_mesa_problem(ctx, "Bad DriverDrawBuffer in _mesa_write_alpha_span()");
- return ctx->DrawBuffer->FrontLeftAlpha; /* aribitrary */
+ return (GLchan *) ctx->DrawBuffer->FrontLeftAlpha; /* aribitrary */
}
}
diff --git a/src/mesa/swrast/s_buffers.c b/src/mesa/swrast/s_buffers.c
index dcfa26f5e2..1b07eb0bef 100644
--- a/src/mesa/swrast/s_buffers.c
+++ b/src/mesa/swrast/s_buffers.c
@@ -1,4 +1,4 @@
-/* $Id: s_buffers.c,v 1.12 2002/07/09 01:22:52 brianp Exp $ */
+/* $Id: s_buffers.c,v 1.13 2002/10/04 19:10:12 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -26,6 +26,7 @@
#include "glheader.h"
+#include "colormac.h"
#include "macros.h"
#include "mem.h"
@@ -53,19 +54,17 @@ clear_color_buffer_with_masking( GLcontext *ctx )
if (ctx->Visual.rgbMode) {
/* RGBA mode */
- const GLchan r = ctx->Color.ClearColor[0];
- const GLchan g = ctx->Color.ClearColor[1];
- const GLchan b = ctx->Color.ClearColor[2];
- const GLchan a = ctx->Color.ClearColor[3];
+ GLchan clearColor[4];
GLint i;
+ CLAMPED_FLOAT_TO_CHAN(clearColor[RCOMP], ctx->Color.ClearColor[0]);
+ CLAMPED_FLOAT_TO_CHAN(clearColor[GCOMP], ctx->Color.ClearColor[1]);
+ CLAMPED_FLOAT_TO_CHAN(clearColor[BCOMP], ctx->Color.ClearColor[2]);
+ CLAMPED_FLOAT_TO_CHAN(clearColor[ACOMP], ctx->Color.ClearColor[3]);
for (i = 0; i < height; i++) {
GLchan rgba[MAX_WIDTH][4];
GLint j;
for (j = 0; j < width; j++) {
- rgba[j][RCOMP] = r;
- rgba[j][GCOMP] = g;
- rgba[j][BCOMP] = b;
- rgba[j][ACOMP] = a;
+ COPY_CHAN4(rgba[j], clearColor);
}
_mesa_mask_rgba_array( ctx, width, x, y + i, rgba );
(*swrast->Driver.WriteRGBASpan)( ctx, width, x, y + i,
@@ -104,20 +103,19 @@ clear_color_buffer(GLcontext *ctx)
if (ctx->Visual.rgbMode) {
/* RGBA mode */
- const GLchan r = ctx->Color.ClearColor[0];
- const GLchan g = ctx->Color.ClearColor[1];
- const GLchan b = ctx->Color.ClearColor[2];
- const GLchan a = ctx->Color.ClearColor[3];
+ GLchan clearColor[4];
GLchan span[MAX_WIDTH][4];
GLint i;
+ CLAMPED_FLOAT_TO_CHAN(clearColor[RCOMP], ctx->Color.ClearColor[0]);
+ CLAMPED_FLOAT_TO_CHAN(clearColor[GCOMP], ctx->Color.ClearColor[1]);
+ CLAMPED_FLOAT_TO_CHAN(clearColor[BCOMP], ctx->Color.ClearColor[2]);
+ CLAMPED_FLOAT_TO_CHAN(clearColor[ACOMP], ctx->Color.ClearColor[3]);
+
ASSERT(*((GLuint *) &ctx->Color.ColorMask) == 0xffffffff);
for (i = 0; i < width; i++) {
- span[i][RCOMP] = r;
- span[i][GCOMP] = g;
- span[i][BCOMP] = b;
- span[i][ACOMP] = a;
+ COPY_CHAN4(span[i], clearColor);
}
for (i = 0; i < height; i++) {
(*swrast->Driver.WriteRGBASpan)( ctx, width, x, y + i,
diff --git a/src/mesa/swrast/s_texture.c b/src/mesa/swrast/s_texture.c
index b8428c9a66..d816104638 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.67 2002/09/23 16:37:15 brianp Exp $ */
+/* $Id: s_texture.c,v 1.68 2002/10/04 19:10:13 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -417,7 +417,7 @@ sample_1d_nearest(GLcontext *ctx,
if (i < 0 || i >= (GLint) img->Width) {
/* Need this test for GL_CLAMP_TO_BORDER_ARB mode */
- COPY_CHAN4(rgba, tObj->BorderColor);
+ COPY_CHAN4(rgba, tObj->_BorderChan);
}
else {
(*img->FetchTexel)(img, i, 0, 0, (GLvoid *) rgba);
@@ -469,7 +469,7 @@ sample_1d_linear(GLcontext *ctx,
GLchan t0[4], t1[4]; /* texels */
if (useBorderColor & I0BIT) {
- COPY_CHAN4(t0, tObj->BorderColor);
+ COPY_CHAN4(t0, tObj->_BorderChan);
}
else {
(*img->FetchTexel)(img, i0, 0, 0, (GLvoid *) t0);
@@ -478,7 +478,7 @@ sample_1d_linear(GLcontext *ctx,
}
}
if (useBorderColor & I1BIT) {
- COPY_CHAN4(t1, tObj->BorderColor);
+ COPY_CHAN4(t1, tObj->_BorderChan);
}
else {
(*img->FetchTexel)(img, i1, 0, 0, (GLvoid *) t1);
@@ -746,7 +746,7 @@ sample_2d_nearest(GLcontext *ctx,
if (i < 0 || i >= (GLint) img->Width || j < 0 || j >= (GLint) img->Height) {
/* Need this test for GL_CLAMP_TO_BORDER_ARB mode */
- COPY_CHAN4(rgba, tObj->BorderColor);
+ COPY_CHAN4(rgba, tObj->_BorderChan);
}
else {
(*img->FetchTexel)(img, i, j, 0, (GLvoid *) rgba);
@@ -814,7 +814,7 @@ sample_2d_linear(GLcontext *ctx,
GLchan t11[4];
if (useBorderColor & (I0BIT | J0BIT)) {
- COPY_CHAN4(t00, tObj->BorderColor);
+ COPY_CHAN4(t00, tObj->_BorderChan);
}
else {
(*img->FetchTexel)(img, i0, j0, 0, (GLvoid *) t00);
@@ -823,7 +823,7 @@ sample_2d_linear(GLcontext *ctx,
}
}
if (useBorderColor & (I1BIT | J0BIT)) {
- COPY_CHAN4(t10, tObj->BorderColor);
+ COPY_CHAN4(t10, tObj->_BorderChan);
}
else {
(*img->FetchTexel)(img, i1, j0, 0, (GLvoid *) t10);
@@ -832,7 +832,7 @@ sample_2d_linear(GLcontext *ctx,
}
}
if (useBorderColor & (I0BIT | J1BIT)) {
- COPY_CHAN4(t01, tObj->BorderColor);
+ COPY_CHAN4(t01, tObj->_BorderChan);
}
else {
(*img->FetchTexel)(img, i0, j1, 0, (GLvoid *) t01);
@@ -841,7 +841,7 @@ sample_2d_linear(GLcontext *ctx,
}
}
if (useBorderColor & (I1BIT | J1BIT)) {
- COPY_CHAN4(t11, tObj->BorderColor);
+ COPY_CHAN4(t11, tObj->_BorderChan);
}
else {
(*img->FetchTexel)(img, i1, j1, 0, (GLvoid *) t11);
@@ -1334,7 +1334,7 @@ sample_3d_nearest(GLcontext *ctx,
j < 0 || j >= (GLint) img->Height ||
k < 0 || k >= (GLint) img->Depth) {
/* Need this test for GL_CLAMP_TO_BORDER_ARB mode */
- COPY_CHAN4(rgba, tObj->BorderColor);
+ COPY_CHAN4(rgba, tObj->_BorderChan);
}
else {
(*img->FetchTexel)(img, i, j, k, (GLvoid *) rgba);
@@ -1417,7 +1417,7 @@ sample_3d_linear(GLcontext *ctx,
GLchan t100[4], t110[4], t101[4], t111[4];
if (useBorderColor & (I0BIT | J0BIT | K0BIT)) {
- COPY_CHAN4(t000, tObj->BorderColor);
+ COPY_CHAN4(t000, tObj->_BorderChan);
}
else {
(*img->FetchTexel)(img, i0, j0, k0, (GLvoid *) t000);
@@ -1426,7 +1426,7 @@ sample_3d_linear(GLcontext *ctx,
}
}
if (useBorderColor & (I1BIT | J0BIT | K0BIT)) {
- COPY_CHAN4(t100, tObj->BorderColor);
+ COPY_CHAN4(t100, tObj->_BorderChan);
}
else {
(*img->FetchTexel)(img, i1, j0, k0, (GLvoid *) t100);
@@ -1435,7 +1435,7 @@ sample_3d_linear(GLcontext *ctx,
}
}
if (useBorderColor & (I0BIT | J1BIT | K0BIT)) {
- COPY_CHAN4(t010, tObj->BorderColor);
+ COPY_CHAN4(t010, tObj->_BorderChan);
}
else {
(*img->FetchTexel)(img, i0, j1, k0, (GLvoid *) t010);
@@ -1444,7 +1444,7 @@ sample_3d_linear(GLcontext *ctx,
}
}
if (useBorderColor & (I1BIT | J1BIT | K0BIT)) {
- COPY_CHAN4(t110, tObj->BorderColor);
+ COPY_CHAN4(t110, tObj->_BorderChan);
}
else {
(*img->FetchTexel)(img, i1, j1, k0, (GLvoid *) t110);
@@ -1454,7 +1454,7 @@ sample_3d_linear(GLcontext *ctx,
}
if (useBorderColor & (I0BIT | J0BIT | K1BIT)) {
- COPY_CHAN4(t001, tObj->BorderColor);
+ COPY_CHAN4(t001, tObj->_BorderChan);
}
else {
(*img->FetchTexel)(img, i0, j0, k1, (GLvoid *) t001);
@@ -1463,7 +1463,7 @@ sample_3d_linear(GLcontext *ctx,
}
}
if (useBorderColor & (I1BIT | J0BIT | K1BIT)) {
- COPY_CHAN4(t101, tObj->BorderColor);
+ COPY_CHAN4(t101, tObj->_BorderChan);
}
else {
(*img->FetchTexel)(img, i1, j0, k1, (GLvoid *) t101);
@@ -1472,7 +1472,7 @@ sample_3d_linear(GLcontext *ctx,
}
}
if (useBorderColor & (I0BIT | J1BIT | K1BIT)) {
- COPY_CHAN4(t011, tObj->BorderColor);
+ COPY_CHAN4(t011, tObj->_BorderChan);
}
else {
(*img->FetchTexel)(img, i0, j1, k1, (GLvoid *) t011);
@@ -1481,7 +1481,7 @@ sample_3d_linear(GLcontext *ctx,
}
}
if (useBorderColor & (I1BIT | J1BIT | K1BIT)) {
- COPY_CHAN4(t111, tObj->BorderColor);
+ COPY_CHAN4(t111, tObj->_BorderChan);
}
else {
(*img->FetchTexel)(img, i1, j1, k1, (GLvoid *) t111);
@@ -2212,7 +2212,7 @@ sample_depth_texture( GLcontext *ctx, GLuint unit,
const struct gl_texture_image *texImage = tObj->Image[baseLevel];
const GLuint width = texImage->Width;
const GLuint height = texImage->Height;
- const GLchan ambient = tObj->ShadowAmbient;
+ const GLchan ambient;
GLenum function;
GLchan result;
@@ -2223,6 +2223,8 @@ sample_depth_texture( GLcontext *ctx, GLuint unit,
tObj->Target == GL_TEXTURE_2D ||
tObj->Target == GL_TEXTURE_RECTANGLE_NV);
+ UNCLAMPED_FLOAT_TO_CHAN(ambient, tObj->ShadowAmbient);
+
/* XXXX if tObj->MinFilter != tObj->MagFilter, we're ignoring lambda */
/* XXX this could be precomputed and saved in the texture object */
@@ -2501,7 +2503,7 @@ sample_depth_texture2(const GLcontext *ctx,
const struct gl_texture_image *texImage = texObj->Image[baseLevel];
const GLuint width = texImage->Width;
const GLuint height = texImage->Height;
- const GLchan ambient = texObj->ShadowAmbient;
+ GLchan ambient;
GLboolean lequal, gequal;
if (texObj->Target != GL_TEXTURE_2D) {
@@ -2523,6 +2525,8 @@ sample_depth_texture2(const GLcontext *ctx,
return;
}
+ UNCLAMPED_FLOAT_TO_CHAN(ambient, tObj->ShadowAmbient);
+
if (texObj->CompareOperator == GL_TEXTURE_LEQUAL_R_SGIX) {
lequal = GL_TRUE;
gequal = GL_FALSE;