summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca Barbieri <luca@luca-barbieri.com>2010-08-26 18:04:26 +0200
committerLuca Barbieri <luca@luca-barbieri.com>2010-09-05 18:01:36 +0200
commita55ac3c300c189616627c05d924c40a8b55bfafa (patch)
treef8bdf82a428d3fbf2e527a2f4ccf23b1d28beba9
parent9940a3e31c2fb76cc3d28b15ea78dde369825107 (diff)
mesa: clamp color queries if and only if fragment clamping is enabled
-rw-r--r--src/mesa/main/get.c43
-rw-r--r--src/mesa/main/texenv.c7
-rw-r--r--src/mesa/main/texparam.c21
3 files changed, 62 insertions, 9 deletions
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index a3cb5ec168..5dc71159e3 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -129,6 +129,7 @@ enum value_extra {
EXTRA_VERSION_31,
EXTRA_VERSION_32,
EXTRA_NEW_BUFFERS,
+ EXTRA_NEW_FRAG_CLAMP,
EXTRA_VALID_DRAW_BUFFER,
EXTRA_VALID_TEXTURE_UNIT,
EXTRA_FLUSH_CURRENT,
@@ -220,6 +221,11 @@ static const int extra_new_buffers[] = {
EXTRA_END
};
+static const int extra_new_frag_clamp[] = {
+ EXTRA_NEW_FRAG_CLAMP,
+ EXTRA_END
+};
+
static const int extra_valid_draw_buffer[] = {
EXTRA_VALID_DRAW_BUFFER,
EXTRA_END
@@ -348,7 +354,7 @@ static const struct value_desc values[] = {
{ GL_BLEND, CONTEXT_BIT0(Color.BlendEnabled), NO_EXTRA },
{ GL_BLEND_SRC, CONTEXT_ENUM(Color.BlendSrcRGB), NO_EXTRA },
{ GL_BLUE_BITS, BUFFER_INT(Visual.blueBits), extra_new_buffers },
- { GL_COLOR_CLEAR_VALUE, CONTEXT_FIELD(Color.ClearColor[0], TYPE_FLOATN_4), NO_EXTRA },
+ { GL_COLOR_CLEAR_VALUE, LOC_CUSTOM, TYPE_FLOATN_4, 0, extra_new_frag_clamp },
{ GL_COLOR_WRITEMASK, LOC_CUSTOM, TYPE_INT_4, 0, NO_EXTRA },
{ GL_CULL_FACE, CONTEXT_BOOL(Polygon.CullFlag), NO_EXTRA },
{ GL_CULL_FACE_MODE, CONTEXT_ENUM(Polygon.CullFaceMode), NO_EXTRA },
@@ -481,7 +487,7 @@ static const struct value_desc values[] = {
{ GL_LIGHT_MODEL_TWO_SIDE, CONTEXT_BOOL(Light.Model.TwoSide), NO_EXTRA },
{ GL_ALPHA_TEST, CONTEXT_BOOL(Color.AlphaEnabled), NO_EXTRA },
{ GL_ALPHA_TEST_FUNC, CONTEXT_ENUM(Color.AlphaFunc), NO_EXTRA },
- { GL_ALPHA_TEST_REF, CONTEXT_FIELD(Color.AlphaRef, TYPE_FLOATN), NO_EXTRA },
+ { GL_ALPHA_TEST_REF, LOC_CUSTOM, TYPE_FLOATN, 0, extra_new_frag_clamp },
{ GL_BLEND_DST, CONTEXT_ENUM(Color.BlendDstRGB), NO_EXTRA },
{ GL_CLIP_PLANE0, CONTEXT_BIT0(Transform.ClipPlanesEnabled), NO_EXTRA },
{ GL_CLIP_PLANE1, CONTEXT_BIT1(Transform.ClipPlanesEnabled), NO_EXTRA },
@@ -500,7 +506,7 @@ static const struct value_desc values[] = {
extra_flush_current_valid_texture_unit },
{ GL_DISTANCE_ATTENUATION_EXT, CONTEXT_FLOAT3(Point.Params[0]), NO_EXTRA },
{ GL_FOG, CONTEXT_BOOL(Fog.Enabled), NO_EXTRA },
- { GL_FOG_COLOR, CONTEXT_FIELD(Fog.Color[0], TYPE_FLOATN_4), NO_EXTRA },
+ { GL_FOG_COLOR, LOC_CUSTOM, TYPE_FLOATN_4, 0, extra_new_frag_clamp },
{ GL_FOG_DENSITY, CONTEXT_FLOAT(Fog.Density), NO_EXTRA },
{ GL_FOG_END, CONTEXT_FLOAT(Fog.End), NO_EXTRA },
{ GL_FOG_HINT, CONTEXT_ENUM(Hint.Fog), NO_EXTRA },
@@ -635,7 +641,7 @@ static const struct value_desc values[] = {
/* GL_ARB_draw_buffers */
{ GL_MAX_DRAW_BUFFERS_ARB, CONTEXT_INT(Const.MaxDrawBuffers), NO_EXTRA },
- { GL_BLEND_COLOR_EXT, CONTEXT_FIELD(Color.BlendColor[0], TYPE_FLOATN_4), NO_EXTRA },
+ { GL_BLEND_COLOR_EXT, LOC_CUSTOM, TYPE_FLOATN_4, 0, extra_new_frag_clamp },
/* GL_ARB_fragment_program */
{ GL_MAX_TEXTURE_IMAGE_UNITS_ARB, /* == GL_MAX_TEXTURE_IMAGE_UNITS_NV */
CONTEXT_INT(Const.MaxTextureImageUnits),
@@ -1631,6 +1637,31 @@ find_custom_value(GLcontext *ctx, const struct value_desc *d, union value *v)
case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES:
v->value_int = ctx->Array.ArrayObj->PointSize.BufferObj->Name;
break;
+
+ case GL_FOG_COLOR:
+ if(ctx->Color._ClampFragmentColor)
+ 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)
+ COPY_4FV(v->value_float_4, ctx->Color.ClearColor);
+ else
+ COPY_4FV(v->value_float_4, ctx->Color.ClearColorUnclamped);
+ break;
+ case GL_BLEND_COLOR_EXT:
+ if(ctx->Color._ClampFragmentColor)
+ 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)
+ v->value_float = ctx->Color.AlphaRef;
+ else
+ v->value_float = ctx->Color.AlphaRefUnclamped;
+ break;
}
}
@@ -1678,6 +1709,10 @@ check_extra(GLcontext *ctx, const char *func, const struct value_desc *d)
enabled++;
}
break;
+ case EXTRA_NEW_FRAG_CLAMP:
+ if (ctx->NewState & (_NEW_BUFFERS | _NEW_FRAG_CLAMP))
+ _mesa_update_state(ctx);
+ break;
case EXTRA_NEW_BUFFERS:
if (ctx->NewState & _NEW_BUFFERS)
_mesa_update_state(ctx);
diff --git a/src/mesa/main/texenv.c b/src/mesa/main/texenv.c
index 1b1095c540..376ab6ea5e 100644
--- a/src/mesa/main/texenv.c
+++ b/src/mesa/main/texenv.c
@@ -801,7 +801,12 @@ _mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params )
if (target == GL_TEXTURE_ENV) {
if (pname == GL_TEXTURE_ENV_COLOR) {
- COPY_4FV( params, texUnit->EnvColor );
+ if(ctx->NewState & (_NEW_BUFFERS | _NEW_FRAG_CLAMP))
+ _mesa_update_state(ctx);
+ if(ctx->Color._ClampFragmentColor)
+ COPY_4FV( params, texUnit->EnvColor );
+ else
+ COPY_4FV( params, texUnit->EnvColorUnclamped );
}
else {
GLint val = get_texenvi(ctx, texUnit, pname);
diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c
index 745a0aeec9..e38de17281 100644
--- a/src/mesa/main/texparam.c
+++ b/src/mesa/main/texparam.c
@@ -39,6 +39,7 @@
#include "main/texparam.h"
#include "main/teximage.h"
#include "main/texstate.h"
+#include "main/state.h"
#include "program/prog_instruction.h"
@@ -1081,10 +1082,22 @@ _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params )
*params = ENUM_TO_FLOAT(obj->WrapR);
break;
case GL_TEXTURE_BORDER_COLOR:
- params[0] = CLAMP(obj->BorderColor.f[0], 0.0F, 1.0F);
- params[1] = CLAMP(obj->BorderColor.f[1], 0.0F, 1.0F);
- params[2] = CLAMP(obj->BorderColor.f[2], 0.0F, 1.0F);
- params[3] = CLAMP(obj->BorderColor.f[3], 0.0F, 1.0F);
+ if(ctx->NewState & (_NEW_BUFFERS | _NEW_FRAG_CLAMP))
+ _mesa_update_state_locked(ctx);
+ if(ctx->Color._ClampFragmentColor)
+ {
+ params[0] = CLAMP(obj->BorderColor.f[0], 0.0F, 1.0F);
+ params[1] = CLAMP(obj->BorderColor.f[1], 0.0F, 1.0F);
+ params[2] = CLAMP(obj->BorderColor.f[2], 0.0F, 1.0F);
+ params[3] = CLAMP(obj->BorderColor.f[3], 0.0F, 1.0F);
+ }
+ else
+ {
+ params[0] = obj->BorderColor.f[0];
+ params[1] = obj->BorderColor.f[1];
+ params[2] = obj->BorderColor.f[2];
+ params[3] = obj->BorderColor.f[3];
+ }
break;
case GL_TEXTURE_RESIDENT:
{