diff options
author | Luca Barbieri <luca@luca-barbieri.com> | 2010-08-25 00:00:16 +0200 |
---|---|---|
committer | Luca Barbieri <luca@luca-barbieri.com> | 2010-09-05 18:01:35 +0200 |
commit | 9940a3e31c2fb76cc3d28b15ea78dde369825107 (patch) | |
tree | 6f03e91413c702ceb4326ddcf006571c41361518 | |
parent | 6244c446e3beed5473b4e811d10787e4019f59d6 (diff) |
mesa: introduce derived _ClampXxxColor state resolving FIXED_ONLY
To do this, we make ClampColor call FLUSH_VERTICES with the appropriate
_NEW flag.
We introduce _NEW_FRAG_CLAMP since fragment clamping has wide-ranging
effects, despite being in the Color attrib group.
This may be easily changed by s/_NEW_FRAG_CLAMP/_NEW_COLOR/g
-rw-r--r-- | src/mesa/main/blend.c | 7 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 7 | ||||
-rw-r--r-- | src/mesa/main/state.c | 38 |
3 files changed, 51 insertions, 1 deletions
diff --git a/src/mesa/main/blend.c b/src/mesa/main/blend.c index 952c2bb6aa..94f85d8778 100644 --- a/src/mesa/main/blend.c +++ b/src/mesa/main/blend.c @@ -555,7 +555,7 @@ _mesa_ColorMaskIndexed( GLuint buf, GLboolean red, GLboolean green, } -extern void GLAPIENTRY +void GLAPIENTRY _mesa_ClampColorARB(GLenum target, GLenum clamp) { GET_CURRENT_CONTEXT(ctx); @@ -569,12 +569,15 @@ _mesa_ClampColorARB(GLenum target, GLenum clamp) switch (target) { case GL_CLAMP_VERTEX_COLOR_ARB: + FLUSH_VERTICES(ctx, _NEW_LIGHT); ctx->Light.ClampVertexColor = clamp; break; case GL_CLAMP_FRAGMENT_COLOR_ARB: + FLUSH_VERTICES(ctx, _NEW_FRAG_CLAMP); ctx->Color.ClampFragmentColor = clamp; break; case GL_CLAMP_READ_COLOR_ARB: + FLUSH_VERTICES(ctx, _NEW_COLOR); ctx->Color.ClampReadColor = clamp; break; default: @@ -632,7 +635,9 @@ void _mesa_init_color( GLcontext * ctx ) } ctx->Color.ClampFragmentColor = GL_FIXED_ONLY_ARB; + ctx->Color._ClampFragmentColor = GL_TRUE; ctx->Color.ClampReadColor = GL_FIXED_ONLY_ARB; + ctx->Color._ClampReadColor = GL_TRUE; } /*@}*/ diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 68eb768514..ee6aaceb93 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -690,7 +690,9 @@ struct gl_colorbuffer_attrib GLboolean DitherFlag; /**< Dither enable flag */ GLenum ClampFragmentColor; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */ + GLboolean _ClampFragmentColor; /** < with GL_FIXED_ONLY_ARB resolved */ GLenum ClampReadColor; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */ + GLboolean _ClampReadColor; /** < with GL_FIXED_ONLY_ARB resolved */ }; @@ -894,6 +896,7 @@ struct gl_light_attrib GLbitfield ColorMaterialBitmask; /**< bitmask formed from Face and Mode */ GLboolean ColorMaterialEnabled; GLenum ClampVertexColor; + GLboolean _ClampVertexColor; struct gl_light EnabledList; /**< List sentinel */ @@ -2876,9 +2879,13 @@ struct gl_matrix_stack #define _NEW_CURRENT_ATTRIB 0x10000000 /**< __GLcontextRec::Current */ #define _NEW_PROGRAM_CONSTANTS 0x20000000 #define _NEW_BUFFER_OBJECT 0x40000000 +#define _NEW_FRAG_CLAMP 0x80000000 #define _NEW_ALL ~0 /*@}*/ +/* TODO: decide whether to make this a new flag or not */ + + /** * \name Bits to track array state changes diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index 4a3dffe4cf..b71d068f4d 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -443,6 +443,35 @@ update_color(GLcontext *ctx) ctx->Color._LogicOpEnabled = RGBA_LOGICOP_ENABLED(ctx); } +static void +update_clamp_fragment_color(GLcontext *ctx) +{ + if(ctx->Color.ClampFragmentColor == GL_FIXED_ONLY_ARB) + ctx->Color._ClampFragmentColor = !ctx->DrawBuffer || !ctx->DrawBuffer->Visual.floatMode; + else + ctx->Color._ClampFragmentColor = ctx->Color.ClampFragmentColor; +} + +static void +update_clamp_vertex_color(GLcontext *ctx) +{ + if(ctx->Light.ClampVertexColor == GL_FIXED_ONLY_ARB) + ctx->Light._ClampVertexColor = !ctx->DrawBuffer || !ctx->DrawBuffer->Visual.floatMode; + else + ctx->Light._ClampVertexColor = ctx->Light.ClampVertexColor; +} + +static void +update_clamp_read_color(GLcontext *ctx) +{ + if(ctx->Color.ClampReadColor == GL_FIXED_ONLY_ARB) + ctx->Color._ClampReadColor = !ctx->ReadBuffer || !ctx->ReadBuffer->Visual.floatMode; + else + ctx->Color._ClampReadColor = ctx->Color.ClampReadColor; +} + + + /* * Check polygon state and set DD_TRI_CULL_FRONT_BACK and/or DD_TRI_OFFSET @@ -601,6 +630,9 @@ _mesa_update_state_locked( GLcontext *ctx ) if (new_state & _NEW_LIGHT) _mesa_update_lighting( ctx ); + if (new_state & (_NEW_LIGHT | _NEW_BUFFERS)) + update_clamp_vertex_color(ctx); + if (new_state & (_NEW_STENCIL | _NEW_BUFFERS)) _mesa_update_stencil( ctx ); @@ -619,6 +651,12 @@ _mesa_update_state_locked( GLcontext *ctx ) if (new_state & _NEW_COLOR) update_color( ctx ); + if (new_state & (_NEW_COLOR | _NEW_BUFFERS)) + update_clamp_read_color(ctx); + + if(new_state & (_NEW_FRAG_CLAMP | _NEW_BUFFERS)) + update_clamp_fragment_color(ctx); + #if 0 if (new_state & (_NEW_POINT | _NEW_LINE | _NEW_POLYGON | _NEW_LIGHT | _NEW_STENCIL | _DD_NEW_SEPARATE_SPECULAR)) |