diff options
Diffstat (limited to 'src/mesa/main')
-rw-r--r-- | src/mesa/main/blend.c | 2 | ||||
-rw-r--r-- | src/mesa/main/fbobject.c | 7 | ||||
-rw-r--r-- | src/mesa/main/framebuffer.c | 1 | ||||
-rw-r--r-- | src/mesa/main/get.c | 9 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 1 | ||||
-rw-r--r-- | src/mesa/main/state.c | 12 | ||||
-rw-r--r-- | src/mesa/main/texenv.c | 3 | ||||
-rw-r--r-- | src/mesa/main/texparam.c | 3 |
8 files changed, 29 insertions, 9 deletions
diff --git a/src/mesa/main/blend.c b/src/mesa/main/blend.c index 88bf3654c10..15b0dc759cd 100644 --- a/src/mesa/main/blend.c +++ b/src/mesa/main/blend.c @@ -863,7 +863,7 @@ void _mesa_init_color( struct gl_context * ctx ) } ctx->Color.ClampFragmentColor = GL_FIXED_ONLY_ARB; - ctx->Color._ClampFragmentColor = GL_TRUE; + ctx->Color._ClampFragmentColor = GL_FALSE; ctx->Color.ClampReadColor = GL_FIXED_ONLY_ARB; if (ctx->API == API_OPENGLES2) { diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index 67c116163db..fc2b2620bbf 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -785,6 +785,7 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx, fb->Width = 0; fb->Height = 0; fb->_AllColorBuffersFixedPoint = GL_TRUE; + fb->_HasSNormOrFloatColorBuffer = GL_FALSE; /* Start at -2 to more easily loop over all attachment points. * -2: depth buffer @@ -901,13 +902,17 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx, /* check if integer color */ fb->_IntegerColor = _mesa_is_format_integer_color(attFormat); - /* Update _AllColorBuffersFixedPoint. */ + /* Update _AllColorBuffersFixedPoint and _HasSNormOrFloatColorBuffer. */ if (i >= 0) { GLenum type = _mesa_get_format_datatype(attFormat); fb->_AllColorBuffersFixedPoint = fb->_AllColorBuffersFixedPoint && (type == GL_UNSIGNED_NORMALIZED || type == GL_SIGNED_NORMALIZED); + + fb->_HasSNormOrFloatColorBuffer = + fb->_HasSNormOrFloatColorBuffer || + type == GL_SIGNED_NORMALIZED || type == GL_FLOAT; } /* Error-check width, height, format */ diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c index 5fb36776b45..757c4b055d1 100644 --- a/src/mesa/main/framebuffer.c +++ b/src/mesa/main/framebuffer.c @@ -155,6 +155,7 @@ _mesa_initialize_window_framebuffer(struct gl_framebuffer *fb, fb->Delete = _mesa_destroy_framebuffer; fb->_Status = GL_FRAMEBUFFER_COMPLETE_EXT; fb->_AllColorBuffersFixedPoint = !visual->floatMode; + fb->_HasSNormOrFloatColorBuffer = visual->floatMode; compute_depth_max(fb); } diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index 582ef319806..244e3ead6e7 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -24,6 +24,7 @@ #include "glheader.h" #include "context.h" +#include "blend.h" #include "enable.h" #include "enums.h" #include "extensions.h" @@ -767,13 +768,13 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu break; case GL_FOG_COLOR: - if(ctx->Color._ClampFragmentColor) + if (_mesa_get_clamp_fragment_color(ctx)) COPY_4FV(v->value_float_4, ctx->Fog.Color); else COPY_4FV(v->value_float_4, ctx->Fog.ColorUnclamped); break; case GL_COLOR_CLEAR_VALUE: - if(ctx->Color._ClampFragmentColor) { + if (_mesa_get_clamp_fragment_color(ctx)) { v->value_float_4[0] = CLAMP(ctx->Color.ClearColor.f[0], 0.0F, 1.0F); v->value_float_4[1] = CLAMP(ctx->Color.ClearColor.f[1], 0.0F, 1.0F); v->value_float_4[2] = CLAMP(ctx->Color.ClearColor.f[2], 0.0F, 1.0F); @@ -782,13 +783,13 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu COPY_4FV(v->value_float_4, ctx->Color.ClearColor.f); break; case GL_BLEND_COLOR_EXT: - if(ctx->Color._ClampFragmentColor) + if (_mesa_get_clamp_fragment_color(ctx)) COPY_4FV(v->value_float_4, ctx->Color.BlendColor); else COPY_4FV(v->value_float_4, ctx->Color.BlendColorUnclamped); break; case GL_ALPHA_TEST_REF: - if(ctx->Color._ClampFragmentColor) + if (_mesa_get_clamp_fragment_color(ctx)) v->value_float = ctx->Color.AlphaRef; else v->value_float = ctx->Color.AlphaRefUnclamped; diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 40a567620ee..008f68bda08 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2662,6 +2662,7 @@ struct gl_framebuffer /* ARB_color_buffer_float */ GLboolean _AllColorBuffersFixedPoint; /* no integer, no float */ + GLboolean _HasSNormOrFloatColorBuffer; /** Array of all renderbuffer attachments, indexed by BUFFER_* tokens. */ struct gl_renderbuffer_attachment Attachment[BUFFER_COUNT]; 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); } diff --git a/src/mesa/main/texenv.c b/src/mesa/main/texenv.c index 0fe5fbd7a64..2979e6706e3 100644 --- a/src/mesa/main/texenv.c +++ b/src/mesa/main/texenv.c @@ -32,6 +32,7 @@ #include "main/glheader.h" #include "main/context.h" +#include "main/blend.h" #include "main/enums.h" #include "main/macros.h" #include "main/mtypes.h" @@ -680,7 +681,7 @@ _mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params ) if (pname == GL_TEXTURE_ENV_COLOR) { if(ctx->NewState & (_NEW_BUFFERS | _NEW_FRAG_CLAMP)) _mesa_update_state(ctx); - if(ctx->Color._ClampFragmentColor) + if (_mesa_get_clamp_fragment_color(ctx)) COPY_4FV( params, texUnit->EnvColor ); else COPY_4FV( params, texUnit->EnvColorUnclamped ); diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c index 898eabd3b0d..f60eb204e28 100644 --- a/src/mesa/main/texparam.c +++ b/src/mesa/main/texparam.c @@ -31,6 +31,7 @@ #include <stdbool.h> #include "main/glheader.h" +#include "main/blend.h" #include "main/colormac.h" #include "main/context.h" #include "main/enums.h" @@ -1415,7 +1416,7 @@ _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params ) if (ctx->NewState & (_NEW_BUFFERS | _NEW_FRAG_CLAMP)) _mesa_update_state_locked(ctx); - if (ctx->Color._ClampFragmentColor) { + if (_mesa_get_clamp_fragment_color(ctx)) { params[0] = CLAMP(obj->Sampler.BorderColor.f[0], 0.0F, 1.0F); params[1] = CLAMP(obj->Sampler.BorderColor.f[1], 0.0F, 1.0F); params[2] = CLAMP(obj->Sampler.BorderColor.f[2], 0.0F, 1.0F); |