_mesa_update_clamp_fragment_color(struct gl_context *ctx,
const struct gl_framebuffer *drawFb)
{
+ GLboolean clamp;
+
/* Don't clamp if:
* - there is no colorbuffer
* - all colorbuffers are unsigned normalized, so clamping has no effect
*/
if (!drawFb || !drawFb->_HasSNormOrFloatColorBuffer ||
drawFb->_IntegerBuffers)
- ctx->Color._ClampFragmentColor = GL_FALSE;
+ clamp = GL_FALSE;
else
- ctx->Color._ClampFragmentColor =
- _mesa_get_clamp_fragment_color(ctx, drawFb);
+ clamp = _mesa_get_clamp_fragment_color(ctx, drawFb);
+
+ if (ctx->Color._ClampFragmentColor == clamp)
+ return;
+
+ ctx->NewDriverState |= ctx->DriverFlags.NewFragClamp;
+ ctx->Color._ClampFragmentColor = clamp;
}
/**
/** gl_context::Transform::ClipPlanesEnabled */
uint64_t NewClipPlaneEnable;
+ /** gl_context::Color::ClampFragmentColor */
+ uint64_t NewFragClamp;
+
/** gl_context::Transform::DepthClamp */
uint64_t NewDepthClamp;
/* _NEW_SCISSOR */
raster->scissor = !!ctx->Scissor.EnableFlags;
- /* _NEW_FRAG_CLAMP */
+ /* gl_driver_flags::NewFragClamp */
raster->clamp_fragment_color = !st->clamp_frag_color_in_shader &&
ctx->Color._ClampFragmentColor;
key.lower_two_sided_color = st->lower_two_sided_color &&
_mesa_vertex_program_two_side_enabled(st->ctx);
- /* _NEW_FRAG_CLAMP */
+ /* gl_driver_flags::NewFragClamp */
key.clamp_color = st->clamp_frag_color_in_shader &&
st->ctx->Color._ClampFragmentColor;
if (new_state & _NEW_FOG)
st->dirty |= ST_NEW_FS_STATE;
-
- if (new_state & _NEW_FRAG_CLAMP) {
- if (st->clamp_frag_color_in_shader)
- st->dirty |= ST_NEW_FS_STATE;
- else
- st->dirty |= ST_NEW_RASTERIZER;
- }
}
if (new_state & (_NEW_LIGHT |
f->NewClipControl = ST_NEW_VIEWPORT | ST_NEW_RASTERIZER;
f->NewClipPlane = ST_NEW_CLIP_STATE;
+ if (st->clamp_frag_color_in_shader) {
+ f->NewFragClamp = ST_NEW_FS_STATE;
+ } else {
+ f->NewFragClamp = ST_NEW_RASTERIZER;
+ }
+
if (st->clamp_frag_depth_in_shader) {
f->NewClipControl |= ST_NEW_VS_STATE | ST_NEW_GS_STATE |
ST_NEW_TES_STATE;