diff options
author | Marek Olšák <[email protected]> | 2013-03-28 01:56:01 +0100 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2013-04-06 23:57:06 +0200 |
commit | 755648c37fc7a54ed0b11c868fd4c7fe28b2f861 (patch) | |
tree | af74440ff60de156f3f19b7ddcea229b686a063c /src/mesa/main/state.c | |
parent | 21d407c1b8bf3be1eff87121d528d03c240ce207 (diff) |
mesa: don't set _ClampFragmentColor to TRUE if it has no effect
This should reduce shader recompilations with drivers that emulate fragment
color clamping, because we want the clamping to be enabled only if there is
a signed normalized or floating-point colorbuffer.
Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/mesa/main/state.c')
-rw-r--r-- | src/mesa/main/state.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index c94a2449930..73c5a1c263f 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -314,7 +314,17 @@ update_multisample(struct gl_context *ctx) static void update_clamp_fragment_color(struct gl_context *ctx) { - ctx->Color._ClampFragmentColor = _mesa_get_clamp_fragment_color(ctx); + struct gl_framebuffer *fb = ctx->DrawBuffer; + + /* Don't clamp if: + * - there is no colorbuffer + * - all colorbuffers are unsigned normalized, so clamping has no effect + * - there is an integer colorbuffer + */ + if (!fb || !fb->_HasSNormOrFloatColorBuffer || fb->_IntegerColor) + ctx->Color._ClampFragmentColor = GL_FALSE; + else + ctx->Color._ClampFragmentColor = _mesa_get_clamp_fragment_color(ctx); } |