diff options
Diffstat (limited to 'src/mesa/swrast')
-rw-r--r-- | src/mesa/swrast/s_context.c | 6 | ||||
-rw-r--r-- | src/mesa/swrast/s_context.h | 1 | ||||
-rw-r--r-- | src/mesa/swrast/s_span.c | 14 |
3 files changed, 21 insertions, 0 deletions
diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c index 186fda0949..9d283b0589 100644 --- a/src/mesa/swrast/s_context.c +++ b/src/mesa/swrast/s_context.c @@ -105,6 +105,12 @@ _swrast_update_rasterflags( GLcontext *ctx ) rasterMask |= ATIFRAGSHADER_BIT; } +#if CHAN_TYPE == GL_FLOAT + if (ctx->Color.ClampFragmentColor == GL_TRUE) { + rasterMask |= CLAMPING_BIT; + } +#endif + SWRAST_CONTEXT(ctx)->_RasterMask = rasterMask; } diff --git a/src/mesa/swrast/s_context.h b/src/mesa/swrast/s_context.h index 3d738819e9..5cfe7627a5 100644 --- a/src/mesa/swrast/s_context.h +++ b/src/mesa/swrast/s_context.h @@ -245,6 +245,7 @@ typedef void (*swrast_tri_func)( GLcontext *ctx, const SWvertex *, #define TEXTURE_BIT 0x1000 /**< Texturing really enabled */ #define FRAGPROG_BIT 0x2000 /**< Fragment program enabled */ #define ATIFRAGSHADER_BIT 0x4000 /**< ATI Fragment shader enabled */ +#define CLAMPING_BIT 0x8000 /**< Clamp colors to [0,1] */ /*@}*/ #define _SWRAST_NEW_RASTERMASK (_NEW_BUFFERS| \ diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c index fbff31b90e..1cf743ae48 100644 --- a/src/mesa/swrast/s_span.c +++ b/src/mesa/swrast/s_span.c @@ -1276,6 +1276,20 @@ _swrast_write_rgba_span( GLcontext *ctx, struct sw_span *span) } } + /* Clamp color/alpha values over the range [0.0, 1.0] before storage */ +#if CHAN_TYPE == GL_FLOAT + if (ctx->Color.ClampFragmentColor) { + GLchan (*rgba)[4] = span->array->rgba; + GLuint i; + for (i = 0; i < span->end; i++) { + rgba[i][RCOMP] = CLAMP(rgba[i][RCOMP], 0.0, CHAN_MAXF); + rgba[i][GCOMP] = CLAMP(rgba[i][GCOMP], 0.0, CHAN_MAXF); + rgba[i][BCOMP] = CLAMP(rgba[i][BCOMP], 0.0, CHAN_MAXF); + rgba[i][ACOMP] = CLAMP(rgba[i][ACOMP], 0.0, CHAN_MAXF); + } + } +#endif + if (swrast->_RasterMask & MULTI_DRAW_BIT) { /* need to do blend/logicop separately for each color buffer */ multi_write_rgba_span(ctx, span); |