diff options
author | Brian Paul <brian.paul@tungstengraphics.com> | 2005-12-08 00:51:28 +0000 |
---|---|---|
committer | Brian Paul <brian.paul@tungstengraphics.com> | 2005-12-08 00:51:28 +0000 |
commit | 4fc07ba77915861bf1b193527b6c6a2d5eca624b (patch) | |
tree | 51c19c1c89a3b2ecd1742e6421d9b9a67742f99d | |
parent | a8c469c3b6ae5a37fd354aa095ff21de0a6fe587 (diff) |
Back-port OSMesaColorClamp() function/feature from trunk. See bug 4917.
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | docs/VERSIONS | 7 | ||||
-rw-r--r-- | include/GL/osmesa.h | 13 | ||||
-rw-r--r-- | src/mesa/drivers/osmesa/osmesa.c | 14 | ||||
-rw-r--r-- | src/mesa/main/blend.c | 3 | ||||
-rw-r--r-- | src/mesa/main/context.c | 6 | ||||
-rw-r--r-- | src/mesa/main/image.c | 2 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 9 | ||||
-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 |
11 files changed, 61 insertions, 16 deletions
@@ -377,7 +377,7 @@ tarballs: rm_depend lib_gz demo_gz glut_gz lib_bz2 demo_bz2 glut_bz2 lib_zip dem rm_depend: - @for dep in $(DEPEND_FILES) ; do \ + for dep in $(DEPEND_FILES) ; do \ rm -f $$dep ; \ touch $$dep ; \ done diff --git a/docs/VERSIONS b/docs/VERSIONS index 52d394bd4fa..017d958d5f4 100644 --- a/docs/VERSIONS +++ b/docs/VERSIONS @@ -1421,3 +1421,10 @@ Mesa Version History - fixed occasional triangle color interpolation problem on VMS - work around invalid free() call (bug 5131) - fixed BSD X server compilation problem by including stdint.h + + +6.4.2 + New: + - added OSMesaColorClamp() function/feature + Bug fixes: + - fixed some problems when building on Windows diff --git a/include/GL/osmesa.h b/include/GL/osmesa.h index ef645905c4d..8d559783ff5 100644 --- a/include/GL/osmesa.h +++ b/include/GL/osmesa.h @@ -61,8 +61,8 @@ extern "C" { #define OSMESA_MAJOR_VERSION 6 -#define OSMESA_MINOR_VERSION 3 -#define OSMESA_PATCH_VERSION 0 +#define OSMESA_MINOR_VERSION 4 +#define OSMESA_PATCH_VERSION 2 @@ -267,6 +267,15 @@ GLAPI OSMESAproc GLAPIENTRY OSMesaGetProcAddress( const char *funcName ); + +/** + * Enable/disable color clamping, off by default. + * New in Mesa 6.4.2 + */ +GLAPI void GLAPIENTRY +OSMesaColorClamp(GLboolean enable); + + #if defined(__BEOS__) || defined(__QUICKDRAW__) #pragma export off #endif diff --git a/src/mesa/drivers/osmesa/osmesa.c b/src/mesa/drivers/osmesa/osmesa.c index b2b3539ca3c..36823c70680 100644 --- a/src/mesa/drivers/osmesa/osmesa.c +++ b/src/mesa/drivers/osmesa/osmesa.c @@ -1333,3 +1333,17 @@ OSMesaGetProcAddress( const char *funcName ) } return _glapi_get_proc_address(funcName); } + + +GLAPI void GLAPIENTRY +OSMesaColorClamp(GLboolean enable) +{ + OSMesaContext osmesa = OSMesaGetCurrentContext(); + + if (enable == GL_TRUE) { + osmesa->mesa.Color.ClampFragmentColor = GL_TRUE; + } + else { + osmesa->mesa.Color.ClampFragmentColor = GL_FIXED_ONLY_ARB; + } +} diff --git a/src/mesa/main/blend.c b/src/mesa/main/blend.c index 61b2b17c0c3..aebc70421ab 100644 --- a/src/mesa/main/blend.c +++ b/src/mesa/main/blend.c @@ -574,6 +574,9 @@ void _mesa_init_color( GLcontext * ctx ) else { ctx->Color.DrawBuffer[0] = GL_FRONT; } + + ctx->Color.ClampFragmentColor = GL_FIXED_ONLY_ARB; + ctx->Color.ClampReadColor = GL_FIXED_ONLY_ARB; } /*@}*/ diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 25a3f6a37d4..11f50b42ce4 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1072,12 +1072,6 @@ init_attrib_groups( GLcontext *ctx ) ctx->NewState = _NEW_ALL; ctx->ErrorValue = (GLenum) GL_NO_ERROR; ctx->_Facing = 0; -#if CHAN_TYPE == GL_FLOAT - ctx->ClampFragmentColors = GL_FALSE; /* XXX temporary */ -#else - ctx->ClampFragmentColors = GL_TRUE; -#endif - ctx->ClampVertexColors = GL_TRUE; return GL_TRUE; } diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index bd0c5ba1f85..e7b9fbbfb69 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -1070,7 +1070,7 @@ _mesa_pack_rgba_span_float( GLcontext *ctx, if (dstFormat == GL_LUMINANCE || dstFormat == GL_LUMINANCE_ALPHA) { /* compute luminance values */ - if (ctx->ClampFragmentColors) { + if (ctx->Color.ClampReadColor == GL_TRUE) { for (i = 0; i < n; i++) { GLfloat sum = rgba[i][RCOMP] + rgba[i][GCOMP] + rgba[i][BCOMP]; luminance[i] = CLAMP(sum, 0.0F, 1.0F); diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 2a0bbd94211..fbf18e0a705 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -539,6 +539,9 @@ struct gl_colorbuffer_attrib /*@}*/ GLboolean DitherFlag; /**< Dither enable flag */ + + GLenum ClampFragmentColor; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */ + GLenum ClampReadColor; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */ }; @@ -2846,12 +2849,6 @@ struct __GLcontextRec * We don't have a better way to communicate this value from * swrast_setup to swrast. */ - /** \name Color clamping (tentative part of GL_ARB_color_clamp_control) */ - /*@{*/ - GLboolean ClampFragmentColors; - GLboolean ClampVertexColors; - /*@}*/ - /** \name For debugging/development only */ /*@{*/ GLboolean FirstTimeCurrent; diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c index a127038454d..9ace5bb4c7b 100644 --- a/src/mesa/swrast/s_context.c +++ b/src/mesa/swrast/s_context.c @@ -108,6 +108,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 5f5efdc22ae..e3b8cbd2619 100644 --- a/src/mesa/swrast/s_context.h +++ b/src/mesa/swrast/s_context.h @@ -246,6 +246,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 cf9c1a737b1..fa3a46a849f 100644 --- a/src/mesa/swrast/s_span.c +++ b/src/mesa/swrast/s_span.c @@ -1306,6 +1306,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); |