Commit 9940a3e3 authored by Luca Barbieri's avatar Luca Barbieri

mesa: introduce derived _ClampXxxColor state resolving FIXED_ONLY

To do this, we make ClampColor call FLUSH_VERTICES with the appropriate
_NEW flag.

We introduce _NEW_FRAG_CLAMP since fragment clamping has wide-ranging
effects, despite being in the Color attrib group.

This may be easily changed by s/_NEW_FRAG_CLAMP/_NEW_COLOR/g
parent 6244c446
......@@ -555,7 +555,7 @@ _mesa_ColorMaskIndexed( GLuint buf, GLboolean red, GLboolean green,
}
extern void GLAPIENTRY
void GLAPIENTRY
_mesa_ClampColorARB(GLenum target, GLenum clamp)
{
GET_CURRENT_CONTEXT(ctx);
......@@ -569,12 +569,15 @@ _mesa_ClampColorARB(GLenum target, GLenum clamp)
switch (target) {
case GL_CLAMP_VERTEX_COLOR_ARB:
FLUSH_VERTICES(ctx, _NEW_LIGHT);
ctx->Light.ClampVertexColor = clamp;
break;
case GL_CLAMP_FRAGMENT_COLOR_ARB:
FLUSH_VERTICES(ctx, _NEW_FRAG_CLAMP);
ctx->Color.ClampFragmentColor = clamp;
break;
case GL_CLAMP_READ_COLOR_ARB:
FLUSH_VERTICES(ctx, _NEW_COLOR);
ctx->Color.ClampReadColor = clamp;
break;
default:
......@@ -632,7 +635,9 @@ void _mesa_init_color( GLcontext * ctx )
}
ctx->Color.ClampFragmentColor = GL_FIXED_ONLY_ARB;
ctx->Color._ClampFragmentColor = GL_TRUE;
ctx->Color.ClampReadColor = GL_FIXED_ONLY_ARB;
ctx->Color._ClampReadColor = GL_TRUE;
}
/*@}*/
......@@ -690,7 +690,9 @@ struct gl_colorbuffer_attrib
GLboolean DitherFlag; /**< Dither enable flag */
GLenum ClampFragmentColor; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */
GLboolean _ClampFragmentColor; /** < with GL_FIXED_ONLY_ARB resolved */
GLenum ClampReadColor; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */
GLboolean _ClampReadColor; /** < with GL_FIXED_ONLY_ARB resolved */
};
......@@ -894,6 +896,7 @@ struct gl_light_attrib
GLbitfield ColorMaterialBitmask; /**< bitmask formed from Face and Mode */
GLboolean ColorMaterialEnabled;
GLenum ClampVertexColor;
GLboolean _ClampVertexColor;
struct gl_light EnabledList; /**< List sentinel */
......@@ -2876,9 +2879,13 @@ struct gl_matrix_stack
#define _NEW_CURRENT_ATTRIB 0x10000000 /**< __GLcontextRec::Current */
#define _NEW_PROGRAM_CONSTANTS 0x20000000
#define _NEW_BUFFER_OBJECT 0x40000000
#define _NEW_FRAG_CLAMP 0x80000000
#define _NEW_ALL ~0
/*@}*/
/* TODO: decide whether to make this a new flag or not */
/**
* \name Bits to track array state changes
......
......@@ -443,6 +443,35 @@ update_color(GLcontext *ctx)
ctx->Color._LogicOpEnabled = RGBA_LOGICOP_ENABLED(ctx);
}
static void
update_clamp_fragment_color(GLcontext *ctx)
{
if(ctx->Color.ClampFragmentColor == GL_FIXED_ONLY_ARB)
ctx->Color._ClampFragmentColor = !ctx->DrawBuffer || !ctx->DrawBuffer->Visual.floatMode;
else
ctx->Color._ClampFragmentColor = ctx->Color.ClampFragmentColor;
}
static void
update_clamp_vertex_color(GLcontext *ctx)
{
if(ctx->Light.ClampVertexColor == GL_FIXED_ONLY_ARB)
ctx->Light._ClampVertexColor = !ctx->DrawBuffer || !ctx->DrawBuffer->Visual.floatMode;
else
ctx->Light._ClampVertexColor = ctx->Light.ClampVertexColor;
}
static void
update_clamp_read_color(GLcontext *ctx)
{
if(ctx->Color.ClampReadColor == GL_FIXED_ONLY_ARB)
ctx->Color._ClampReadColor = !ctx->ReadBuffer || !ctx->ReadBuffer->Visual.floatMode;
else
ctx->Color._ClampReadColor = ctx->Color.ClampReadColor;
}
/*
* Check polygon state and set DD_TRI_CULL_FRONT_BACK and/or DD_TRI_OFFSET
......@@ -601,6 +630,9 @@ _mesa_update_state_locked( GLcontext *ctx )
if (new_state & _NEW_LIGHT)
_mesa_update_lighting( ctx );
if (new_state & (_NEW_LIGHT | _NEW_BUFFERS))
update_clamp_vertex_color(ctx);
if (new_state & (_NEW_STENCIL | _NEW_BUFFERS))
_mesa_update_stencil( ctx );
......@@ -619,6 +651,12 @@ _mesa_update_state_locked( GLcontext *ctx )
if (new_state & _NEW_COLOR)
update_color( ctx );
if (new_state & (_NEW_COLOR | _NEW_BUFFERS))
update_clamp_read_color(ctx);
if(new_state & (_NEW_FRAG_CLAMP | _NEW_BUFFERS))
update_clamp_fragment_color(ctx);
#if 0
if (new_state & (_NEW_POINT | _NEW_LINE | _NEW_POLYGON | _NEW_LIGHT
| _NEW_STENCIL | _DD_NEW_SEPARATE_SPECULAR))
......
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