Commit 6244c446 authored by Luca Barbieri's avatar Luca Barbieri

mesa: add unclamped color parameters

parent 64d0a0f0
......@@ -918,10 +918,10 @@ _mesa_PopAttrib(void)
color = (const struct gl_colorbuffer_attrib *) attr->data;
_mesa_ClearIndex((GLfloat) color->ClearIndex);
_mesa_ClearColor(color->ClearColor[0],
color->ClearColor[1],
color->ClearColor[2],
color->ClearColor[3]);
_mesa_ClearColor(color->ClearColorUnclamped[0],
color->ClearColorUnclamped[1],
color->ClearColorUnclamped[2],
color->ClearColorUnclamped[3]);
_mesa_IndexMask(color->IndexMask);
if (!ctx->Extensions.EXT_draw_buffers2) {
_mesa_ColorMask((GLboolean) (color->ColorMask[0][0] != 0),
......@@ -969,7 +969,7 @@ _mesa_PopAttrib(void)
_mesa_DrawBuffer(color->DrawBuffer[0]);
}
_mesa_set_enable(ctx, GL_ALPHA_TEST, color->AlphaEnabled);
_mesa_AlphaFunc(color->AlphaFunc, color->AlphaRef);
_mesa_AlphaFunc(color->AlphaFunc, color->AlphaRefUnclamped);
if (ctx->Color.BlendEnabled != color->BlendEnabled) {
if (ctx->Extensions.EXT_draw_buffers2) {
GLuint i;
......@@ -996,10 +996,10 @@ _mesa_PopAttrib(void)
_mesa_BlendEquationSeparateEXT(color->BlendEquationRGB,
color->BlendEquationA);
}
_mesa_BlendColor(color->BlendColor[0],
color->BlendColor[1],
color->BlendColor[2],
color->BlendColor[3]);
_mesa_BlendColor(color->BlendColorUnclamped[0],
color->BlendColorUnclamped[1],
color->BlendColorUnclamped[2],
color->BlendColorUnclamped[3]);
_mesa_LogicOp(color->LogicOp);
_mesa_set_enable(ctx, GL_COLOR_LOGIC_OP,
color->ColorLogicOpEnabled);
......
......@@ -334,19 +334,24 @@ _mesa_BlendColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha )
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
tmp[0] = CLAMP( red, 0.0F, 1.0F );
tmp[1] = CLAMP( green, 0.0F, 1.0F );
tmp[2] = CLAMP( blue, 0.0F, 1.0F );
tmp[3] = CLAMP( alpha, 0.0F, 1.0F );
tmp[0] = red;
tmp[1] = green;
tmp[2] = blue;
tmp[3] = alpha;
if (TEST_EQ_4V(tmp, ctx->Color.BlendColor))
if (TEST_EQ_4V(tmp, ctx->Color.BlendColorUnclamped))
return;
FLUSH_VERTICES(ctx, _NEW_COLOR);
COPY_4FV( ctx->Color.BlendColor, tmp );
COPY_4FV( ctx->Color.BlendColorUnclamped, tmp );
ctx->Color.BlendColor[0] = CLAMP(tmp[0], 0.0F, 1.0F);
ctx->Color.BlendColor[1] = CLAMP(tmp[1], 0.0F, 1.0F);
ctx->Color.BlendColor[2] = CLAMP(tmp[2], 0.0F, 1.0F);
ctx->Color.BlendColor[3] = CLAMP(tmp[3], 0.0F, 1.0F);
if (ctx->Driver.BlendColor)
(*ctx->Driver.BlendColor)(ctx, tmp);
(*ctx->Driver.BlendColor)(ctx, ctx->Color.BlendColor);
}
......@@ -375,13 +380,13 @@ _mesa_AlphaFunc( GLenum func, GLclampf ref )
case GL_NOTEQUAL:
case GL_GEQUAL:
case GL_ALWAYS:
ref = CLAMP(ref, 0.0F, 1.0F);
if (ctx->Color.AlphaFunc == func && ctx->Color.AlphaRef == ref)
if (ctx->Color.AlphaFunc == func && ctx->Color.AlphaRefUnclamped == ref)
return; /* no change */
FLUSH_VERTICES(ctx, _NEW_COLOR);
ctx->Color.AlphaFunc = func;
ctx->Color.AlphaRefUnclamped = ref;
ref = CLAMP(ref, 0.0F, 1.0F);
ctx->Color.AlphaRef = ref;
if (ctx->Driver.AlphaFunc)
......@@ -600,6 +605,7 @@ void _mesa_init_color( GLcontext * ctx )
memset(ctx->Color.ColorMask, 0xff, sizeof(ctx->Color.ColorMask));
ctx->Color.ClearIndex = 0;
ASSIGN_4V( ctx->Color.ClearColor, 0, 0, 0, 0 );
ASSIGN_4V( ctx->Color.ClearColorUnclamped, 0, 0, 0, 0 );
ctx->Color.AlphaEnabled = GL_FALSE;
ctx->Color.AlphaFunc = GL_ALWAYS;
ctx->Color.AlphaRef = 0;
......@@ -611,6 +617,7 @@ void _mesa_init_color( GLcontext * ctx )
ctx->Color.BlendEquationRGB = GL_FUNC_ADD;
ctx->Color.BlendEquationA = GL_FUNC_ADD;
ASSIGN_4V( ctx->Color.BlendColor, 0.0, 0.0, 0.0, 0.0 );
ASSIGN_4V( ctx->Color.BlendColorUnclamped, 0.0, 0.0, 0.0, 0.0 );
ctx->Color.IndexLogicOpEnabled = GL_FALSE;
ctx->Color.ColorLogicOpEnabled = GL_FALSE;
ctx->Color._LogicOpEnabled = GL_FALSE;
......
......@@ -77,19 +77,27 @@ _mesa_ClearColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha )
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
tmp[0] = CLAMP(red, 0.0F, 1.0F);
tmp[1] = CLAMP(green, 0.0F, 1.0F);
tmp[2] = CLAMP(blue, 0.0F, 1.0F);
tmp[3] = CLAMP(alpha, 0.0F, 1.0F);
tmp[0] = red;
tmp[1] = green;
tmp[2] = blue;
tmp[3] = alpha;
if (TEST_EQ_4V(tmp, ctx->Color.ClearColor))
if (TEST_EQ_4V(tmp, ctx->Color.ClearColorUnclamped))
return; /* no change */
FLUSH_VERTICES(ctx, _NEW_COLOR);
COPY_4V(ctx->Color.ClearColor, tmp);
COPY_4V(ctx->Color.ClearColorUnclamped, tmp);
ctx->Color.ClearColor[0] = CLAMP(tmp[0], 0.0F, 1.0F);
ctx->Color.ClearColor[1] = CLAMP(tmp[1], 0.0F, 1.0F);
ctx->Color.ClearColor[2] = CLAMP(tmp[2], 0.0F, 1.0F);
ctx->Color.ClearColor[3] = CLAMP(tmp[3], 0.0F, 1.0F);
if (ctx->Driver.ClearColor) {
/* it's OK to call glClearColor in CI mode but it should be a NOP */
/* we pass the clamped color, since all drivers that need this don't
* support GL_ARB_color_buffer_float
*/
(*ctx->Driver.ClearColor)(ctx, ctx->Color.ClearColor);
}
}
......
......@@ -145,6 +145,10 @@ _mesa_Fogfv( GLenum pname, const GLfloat *params )
if (TEST_EQ_4V(ctx->Fog.Color, params))
return;
FLUSH_VERTICES(ctx, _NEW_FOG);
ctx->Fog.ColorUnclamped[0] = params[0];
ctx->Fog.ColorUnclamped[1] = params[1];
ctx->Fog.ColorUnclamped[2] = params[2];
ctx->Fog.ColorUnclamped[3] = params[3];
ctx->Fog.Color[0] = CLAMP(params[0], 0.0F, 1.0F);
ctx->Fog.Color[1] = CLAMP(params[1], 0.0F, 1.0F);
ctx->Fog.Color[2] = CLAMP(params[2], 0.0F, 1.0F);
......@@ -184,6 +188,7 @@ void _mesa_init_fog( GLcontext * ctx )
ctx->Fog.Enabled = GL_FALSE;
ctx->Fog.Mode = GL_EXP;
ASSIGN_4V( ctx->Fog.Color, 0.0, 0.0, 0.0, 0.0 );
ASSIGN_4V( ctx->Fog.ColorUnclamped, 0.0, 0.0, 0.0, 0.0 );
ctx->Fog.Index = 0.0;
ctx->Fog.Density = 1.0;
ctx->Fog.Start = 0.0;
......
......@@ -639,7 +639,8 @@ struct gl_accum_attrib
struct gl_colorbuffer_attrib
{
GLuint ClearIndex; /**< Index to use for glClear */
GLclampf ClearColor[4]; /**< Color to use for glClear */
GLfloat ClearColorUnclamped[4]; /**< Color to use for glClear*/
GLclampf ClearColor[4]; /**< Color to use for glClear */
GLuint IndexMask; /**< Color index write mask */
GLubyte ColorMask[MAX_DRAW_BUFFERS][4];/**< Each flag is 0xff or 0x0 */
......@@ -652,6 +653,7 @@ struct gl_colorbuffer_attrib
/*@{*/
GLboolean AlphaEnabled; /**< Alpha test enabled flag */
GLenum AlphaFunc; /**< Alpha test function */
GLfloat AlphaRefUnclamped;
GLclampf AlphaRef; /**< Alpha reference value */
/*@}*/
......@@ -666,6 +668,12 @@ struct gl_colorbuffer_attrib
GLenum BlendDstA; /**< GL_INGR_blend_func_separate */
GLenum BlendEquationRGB; /**< Blending equation */
GLenum BlendEquationA; /**< GL_EXT_blend_equation_separate */
/* NOTE: this does _not_ depend on fragment clamping or any other clamping control,
* only on the fixed-pointness of the render target.
* The query does however depend on fragment color clamping.
*/
GLfloat BlendColorUnclamped[4]; /**< Blending color */
GLfloat BlendColor[4]; /**< Blending color */
/*@}*/
......@@ -779,6 +787,7 @@ struct gl_eval_attrib
struct gl_fog_attrib
{
GLboolean Enabled; /**< Fog enabled flag */
GLfloat ColorUnclamped[4]; /**< Fog color */
GLfloat Color[4]; /**< Fog color */
GLfloat Density; /**< Density >= 0.0 */
GLfloat Start; /**< Start distance in eye coords */
......@@ -1389,7 +1398,8 @@ struct gl_texture_unit
GLbitfield _ReallyEnabled; /**< 0 or exactly one of TEXTURE_*_BIT flags */
GLenum EnvMode; /**< GL_MODULATE, GL_DECAL, GL_BLEND, etc. */
GLfloat EnvColor[4];
GLclampf EnvColor[4];
GLfloat EnvColorUnclamped[4];
struct gl_texgen GenS;
struct gl_texgen GenT;
......
......@@ -94,14 +94,14 @@ set_env_color(GLcontext *ctx,
const GLfloat *color)
{
GLfloat tmp[4];
tmp[0] = CLAMP(color[0], 0.0F, 1.0F);
tmp[1] = CLAMP(color[1], 0.0F, 1.0F);
tmp[2] = CLAMP(color[2], 0.0F, 1.0F);
tmp[3] = CLAMP(color[3], 0.0F, 1.0F);
if (TEST_EQ_4V(tmp, texUnit->EnvColor))
if (TEST_EQ_4V(color, texUnit->EnvColorUnclamped))
return;
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
COPY_4FV(texUnit->EnvColor, tmp);
COPY_4FV(texUnit->EnvColorUnclamped, color);
texUnit->EnvColor[0] = CLAMP(color[0], 0.0F, 1.0F);
texUnit->EnvColor[1] = CLAMP(color[1], 0.0F, 1.0F);
texUnit->EnvColor[2] = CLAMP(color[2], 0.0F, 1.0F);
texUnit->EnvColor[3] = CLAMP(color[3], 0.0F, 1.0F);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment