From 10d343f407bddf011be3d2b79a6541815759785a Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 17 Oct 2002 15:26:38 +0000 Subject: [PATCH] patches from Gerk Huisma for float-channel rendering --- src/mesa/drivers/osmesa/osmesa.c | 14 +++---- src/mesa/swrast/s_blend.c | 71 +++++++++++++++++++++----------- src/mesa/swrast/s_tritemp.h | 6 +-- 3 files changed, 57 insertions(+), 34 deletions(-) diff --git a/src/mesa/drivers/osmesa/osmesa.c b/src/mesa/drivers/osmesa/osmesa.c index ff966c3f037..cc2081129df 100644 --- a/src/mesa/drivers/osmesa/osmesa.c +++ b/src/mesa/drivers/osmesa/osmesa.c @@ -1,4 +1,4 @@ -/* $Id: osmesa.c,v 1.91 2002/10/14 17:08:27 brianp Exp $ */ +/* $Id: osmesa.c,v 1.92 2002/10/17 15:26:38 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -672,12 +672,12 @@ OSMesaGetProcAddress( const char *funcName ) */ #if CHAN_TYPE == GL_FLOAT -#define PACK_RGBA(DST, R, G, B, A) \ -do { \ - (DST)[0] = (R < 0.0f) ? 0.0f : ((R > 1.0f) ? 1.0f : R); \ - (DST)[1] = (G < 0.0f) ? 0.0f : ((G > 1.0f) ? 1.0f : G); \ - (DST)[2] = (B < 0.0f) ? 0.0f : ((B > 1.0f) ? 1.0f : B); \ - (DST)[3] = (A < 0.0f) ? 0.0f : ((A > 1.0f) ? 1.0f : A); \ +#define PACK_RGBA(DST, R, G, B, A) \ +do { \ + (DST)[0] = MAX2( R, 0.0F ); \ + (DST)[1] = MAX2( G, 0.0F ); \ + (DST)[2] = MAX2( B, 0.0F ); \ + (DST)[3] = CLAMP(A, 0.0F, CHAN_MAXF);\ } while (0) #else #define PACK_RGBA(DST, R, G, B, A) \ diff --git a/src/mesa/swrast/s_blend.c b/src/mesa/swrast/s_blend.c index eb95bb36d33..5afc6a030c1 100644 --- a/src/mesa/swrast/s_blend.c +++ b/src/mesa/swrast/s_blend.c @@ -1,4 +1,4 @@ -/* $Id: s_blend.c,v 1.24 2002/08/07 00:45:07 brianp Exp $ */ +/* $Id: s_blend.c,v 1.25 2002/10/17 15:26:39 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -100,7 +100,7 @@ blend_transparency( GLcontext *ctx, GLuint n, const GLubyte mask[], for (i=0;iColor.BlendSrcRGB) { @@ -363,7 +386,7 @@ blend_general( GLcontext *ctx, GLuint n, const GLubyte mask[], sR = sG = sB = (GLfloat) As * ascale; break; case GL_ONE_MINUS_SRC_ALPHA: - sR = sG = sB = (GLfloat) 1.0F - (GLfloat) As * ascale; + sR = sG = sB = 1.0F - (GLfloat) As * ascale; break; case GL_DST_ALPHA: sR = sG = sB = (GLfloat) Ad * ascale; @@ -429,7 +452,7 @@ blend_general( GLcontext *ctx, GLuint n, const GLubyte mask[], sA = (GLfloat) As * ascale; break; case GL_ONE_MINUS_SRC_ALPHA: - sA = (GLfloat) 1.0F - (GLfloat) As * ascale; + sA = 1.0F - (GLfloat) As * ascale; break; case GL_DST_ALPHA: sA =(GLfloat) Ad * ascale; @@ -486,7 +509,7 @@ blend_general( GLcontext *ctx, GLuint n, const GLubyte mask[], dR = dG = dB = (GLfloat) As * ascale; break; case GL_ONE_MINUS_SRC_ALPHA: - dR = dG = dB = (GLfloat) 1.0F - (GLfloat) As * ascale; + dR = dG = dB = 1.0F - (GLfloat) As * ascale; break; case GL_DST_ALPHA: dR = dG = dB = (GLfloat) Ad * ascale; @@ -544,7 +567,7 @@ blend_general( GLcontext *ctx, GLuint n, const GLubyte mask[], dA = (GLfloat) As * ascale; break; case GL_ONE_MINUS_SRC_ALPHA: - dA = (GLfloat) 1.0F - (GLfloat) As * ascale; + dA = 1.0F - (GLfloat) As * ascale; break; case GL_DST_ALPHA: dA = (GLfloat) Ad * ascale; @@ -624,9 +647,9 @@ blend_general( GLcontext *ctx, GLuint n, const GLubyte mask[], } /* final clamping */ - rgba[i][RCOMP] = CLAMP( r, 0.0F, CHAN_MAXF ); - rgba[i][GCOMP] = CLAMP( g, 0.0F, CHAN_MAXF ); - rgba[i][BCOMP] = CLAMP( b, 0.0F, CHAN_MAXF ); + rgba[i][RCOMP] = MAX2( r, 0.0F ); + rgba[i][GCOMP] = MAX2( g, 0.0F ); + rgba[i][BCOMP] = MAX2( b, 0.0F ); rgba[i][ACOMP] = CLAMP( a, 0.0F, CHAN_MAXF ); #else if (ctx->Color.BlendEquation==GL_FUNC_ADD_EXT) { diff --git a/src/mesa/swrast/s_tritemp.h b/src/mesa/swrast/s_tritemp.h index ef5e00eb5bf..dcd1f4a8d88 100644 --- a/src/mesa/swrast/s_tritemp.h +++ b/src/mesa/swrast/s_tritemp.h @@ -1,4 +1,4 @@ -/* $Id: s_tritemp.h,v 1.39 2002/10/02 23:24:04 brianp Exp $ */ +/* $Id: s_tritemp.h,v 1.40 2002/10/17 15:26:39 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -115,7 +115,7 @@ GLfloat oneOverArea; const SWvertex *vMin, *vMid, *vMax; /* Y(vMin)<=Y(vMid)<=Y(vMax) */ float bf = SWRAST_CONTEXT(ctx)->_backface_sign; - const GLint snapMask = ~((FIXED_ONE / 16) - 1); /* for x/y coord snapping */ + const GLint snapMask = ~((FIXED_ONE / (1 << SUB_PIXEL_BITS)) - 1); /* for x/y coord snapping */ GLfixed vMin_fx, vMin_fy, vMid_fx, vMid_fy, vMax_fx, vMax_fy; struct sw_span span; @@ -206,7 +206,7 @@ if (area * bf < 0.0) return; - if (area == 0.0F || IS_INF_OR_NAN(area)) + if (IS_INF_OR_NAN(area) || area == 0.0F) return; oneOverArea = 1.0F / area; -- 2.30.2