[Mesa-dev] [PATCH 2/5] mesa: introduce clear color type in color context.
Dave Airlie
airlied at gmail.com
Mon Sep 12 05:17:28 PDT 2011
From: Dave Airlie <airlied at redhat.com>
This adds a clear color type and introduces setting it to GL_FLOAT
in the appropriate places.
Signed-off-by: Dave Airlie <airlied at redhat.com>
---
src/mesa/main/blend.c | 1 +
src/mesa/main/clear.c | 39 ++++++++++++++++++++++++++++++---------
src/mesa/main/mtypes.h | 2 +-
3 files changed, 32 insertions(+), 10 deletions(-)
diff --git a/src/mesa/main/blend.c b/src/mesa/main/blend.c
index e1a6577..7b0ebd7 100644
--- a/src/mesa/main/blend.c
+++ b/src/mesa/main/blend.c
@@ -797,6 +797,7 @@ void _mesa_init_color( struct gl_context * ctx )
ctx->Color.ClearIndex = 0;
ASSIGN_4V( ctx->Color.ClearColor.f, 0, 0, 0, 0 );
ASSIGN_4V( ctx->Color.ClearColorUnclamped.f, 0, 0, 0, 0 );
+ ctx->Color._ClearColorType = GL_FLOAT;
ctx->Color.AlphaEnabled = GL_FALSE;
ctx->Color.AlphaFunc = GL_ALWAYS;
ctx->Color.AlphaRef = 0;
diff --git a/src/mesa/main/clear.c b/src/mesa/main/clear.c
index ecf2907..3754756 100644
--- a/src/mesa/main/clear.c
+++ b/src/mesa/main/clear.c
@@ -89,6 +89,7 @@ _mesa_ClearColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha )
FLUSH_VERTICES(ctx, _NEW_COLOR);
COPY_4V(ctx->Color.ClearColorUnclamped.f, tmp);
+ ctx->Color._ClearColorType = GL_FLOAT;
ctx->Color.ClearColor.cl[0] = CLAMP(tmp[0], 0.0F, 1.0F);
ctx->Color.ClearColor.cl[1] = CLAMP(tmp[1], 0.0F, 1.0F);
ctx->Color.ClearColor.cl[2] = CLAMP(tmp[2], 0.0F, 1.0F);
@@ -99,7 +100,7 @@ _mesa_ClearColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha )
/* we pass the clamped color, since all drivers that need this don't
* support GL_ARB_color_buffer_float
*/
- (*ctx->Driver.ClearColor)(ctx, GL_FLOAT, ctx->Color.ClearColor);
+ (*ctx->Driver.ClearColor)(ctx, ctx->Color._ClearColorType, ctx->Color.ClearColor);
}
}
@@ -127,10 +128,11 @@ _mesa_ClearColorIiEXT(GLint r, GLint g, GLint b, GLint a)
/* XXX we should eventually have a float/int/uint union for
* the ctx->Color.ClearColor state.
*/
+ ctx->Color._ClearColorType = GL_FLOAT;
COPY_4V(ctx->Color.ClearColor.f, tmp);
if (ctx->Driver.ClearColor) {
- ctx->Driver.ClearColor(ctx, GL_FLOAT, ctx->Color.ClearColor);
+ ctx->Driver.ClearColor(ctx, ctx->Color._ClearColorType, ctx->Color.ClearColor);
}
}
@@ -158,10 +160,11 @@ _mesa_ClearColorIuiEXT(GLuint r, GLuint g, GLuint b, GLuint a)
/* XXX we should eventually have a float/int/uint union for
* the ctx->Color.ClearColor state.
*/
+ ctx->Color._ClearColorType = GL_FLOAT;
COPY_4V(ctx->Color.ClearColor.f, tmp);
if (ctx->Driver.ClearColor) {
- ctx->Driver.ClearColor(ctx, GL_FLOAT, ctx->Color.ClearColor);
+ ctx->Driver.ClearColor(ctx, ctx->Color._ClearColorType, ctx->Color.ClearColor);
}
}
@@ -369,18 +372,24 @@ _mesa_ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *value)
* need a new ctx->Driver.ClearBuffer() hook....
*/
union gl_clear_color clearSave;
+ GLenum clearColorTypeSave;
+
/* save color */
+ clearColorTypeSave = ctx->Color._ClearColorType;
COPY_4V(clearSave.cl, ctx->Color.ClearColor.cl);
/* set color */
+ ctx->Color._ClearColorType = GL_FLOAT;
COPY_4V_CAST(ctx->Color.ClearColor.cl, value, GLclampf);
if (ctx->Driver.ClearColor)
- ctx->Driver.ClearColor(ctx, GL_FLOAT, ctx->Color.ClearColor);
+ ctx->Driver.ClearColor(ctx, ctx->Color._ClearColorType,
+ ctx->Color.ClearColor);
/* clear buffer(s) */
ctx->Driver.Clear(ctx, mask);
/* restore color */
+ ctx->Color._ClearColorType = clearColorTypeSave;
COPY_4V(ctx->Color.ClearColor.cl, clearSave.cl);
if (ctx->Driver.ClearColor)
- ctx->Driver.ClearColor(ctx, GL_FLOAT, clearSave);
+ ctx->Driver.ClearColor(ctx, clearColorTypeSave, clearSave);
}
}
break;
@@ -423,18 +432,24 @@ _mesa_ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *value)
* need a new ctx->Driver.ClearBuffer() hook....
*/
union gl_clear_color clearSave;
+ GLenum clearColorTypeSave;
+
/* save color */
+ clearColorTypeSave = ctx->Color._ClearColorType;
COPY_4V(clearSave.cl, ctx->Color.ClearColor.cl);
/* set color */
+ ctx->Color._ClearColorType = GL_FLOAT;
COPY_4V_CAST(ctx->Color.ClearColor.cl, value, GLclampf);
if (ctx->Driver.ClearColor)
- ctx->Driver.ClearColor(ctx, GL_FLOAT, ctx->Color.ClearColor);
+ ctx->Driver.ClearColor(ctx, ctx->Color._ClearColorType,
+ ctx->Color.ClearColor);
/* clear buffer(s) */
ctx->Driver.Clear(ctx, mask);
/* restore color */
+ ctx->Color._ClearColorType = clearColorTypeSave;
COPY_4V(ctx->Color.ClearColor.cl, clearSave.cl);
if (ctx->Driver.ClearColor)
- ctx->Driver.ClearColor(ctx, GL_FLOAT, clearSave);
+ ctx->Driver.ClearColor(ctx, clearColorTypeSave, clearSave);
}
}
break;
@@ -496,18 +511,24 @@ _mesa_ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *value)
}
else if (mask) {
union gl_clear_color clearSave;
+ GLenum clearColorTypeSave;
+
/* save color */
+ clearColorTypeSave = ctx->Color._ClearColorType;
COPY_4V(clearSave.cl, ctx->Color.ClearColor.cl);
/* set color */
+ ctx->Color._ClearColorType = GL_FLOAT;
COPY_4V_CAST(ctx->Color.ClearColor.cl, value, GLclampf);
if (ctx->Driver.ClearColor)
- ctx->Driver.ClearColor(ctx, GL_FLOAT, ctx->Color.ClearColor);
+ ctx->Driver.ClearColor(ctx, ctx->Color._ClearColorType,
+ ctx->Color.ClearColor);
/* clear buffer(s) */
ctx->Driver.Clear(ctx, mask);
/* restore color */
+ ctx->Color._ClearColorType = clearColorTypeSave;
COPY_4V(ctx->Color.ClearColor.cl, clearSave.cl);
if (ctx->Driver.ClearColor)
- ctx->Driver.ClearColor(ctx, GL_FLOAT, clearSave);
+ ctx->Driver.ClearColor(ctx, clearColorTypeSave, clearSave);
}
}
break;
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 04f1436..29d6add 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -732,7 +732,7 @@ struct gl_colorbuffer_attrib
GLuint ClearIndex; /**< Index to use for glClear */
union gl_clear_color ClearColorUnclamped; /**< Color to use for glClear*/
union gl_clear_color ClearColor; /**< Color to use for glClear*/
-
+ GLenum _ClearColorType; /**< Type of Color passed, GL_FLOAT, GL_INT, GL_UNSIGNED_INT */
GLuint IndexMask; /**< Color index write mask */
GLubyte ColorMask[MAX_DRAW_BUFFERS][4];/**< Each flag is 0xff or 0x0 */
--
1.7.6
More information about the mesa-dev
mailing list