[Mesa-dev] [PATCH 4/5] st/mesa: push clear color int->float translation into state tracker
Dave Airlie
airlied at gmail.com
Mon Sep 12 05:17:30 PDT 2011
From: Dave Airlie <airlied at redhat.com>
this is still incorrect, because we need to pass the type + native values
down via gallium.
Signed-off-by: Dave Airlie <airlied at redhat.com>
---
src/mesa/state_tracker/st_cb_clear.c | 14 ++++++++------
src/mesa/state_tracker/st_format.c | 29 +++++++++++++++++++++++++++++
src/mesa/state_tracker/st_format.h | 4 ++++
3 files changed, 41 insertions(+), 6 deletions(-)
diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c
index 211e1bf..c2c485b 100644
--- a/src/mesa/state_tracker/st_cb_clear.c
+++ b/src/mesa/state_tracker/st_cb_clear.c
@@ -323,9 +323,10 @@ clear_with_quad(struct gl_context *ctx,
set_vertex_shader(st);
if (ctx->DrawBuffer->_ColorDrawBuffers[0]) {
- st_translate_color(ctx->Color.ClearColorUnclamped.f,
- ctx->DrawBuffer->_ColorDrawBuffers[0]->_BaseFormat,
- clearColor);
+ st_translate_clear_color(ctx->Color.ClearColorUnclamped,
+ ctx->Color._ClearColorType,
+ ctx->DrawBuffer->_ColorDrawBuffers[0]->_BaseFormat,
+ clearColor);
}
/* draw quad matching scissor rect */
@@ -582,9 +583,10 @@ st_Clear(struct gl_context *ctx, GLbitfield mask)
clear_buffers |= PIPE_CLEAR_DEPTHSTENCIL;
if (ctx->DrawBuffer->_ColorDrawBuffers[0]) {
- st_translate_color(ctx->Color.ClearColor.cl,
- ctx->DrawBuffer->_ColorDrawBuffers[0]->_BaseFormat,
- clearColor);
+ st_translate_clear_color(ctx->Color.ClearColorUnclamped,
+ ctx->Color._ClearColorType,
+ ctx->DrawBuffer->_ColorDrawBuffers[0]->_BaseFormat,
+ clearColor);
}
st->pipe->clear(st->pipe, clear_buffers, ctx->Color.ClearColorUnclamped.f,
diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c
index bd4f086..ff72924 100644
--- a/src/mesa/state_tracker/st_format.c
+++ b/src/mesa/state_tracker/st_format.c
@@ -1486,3 +1486,32 @@ st_translate_color(const GLfloat colorIn[4], GLenum baseFormat,
COPY_4V(colorOut, colorIn);
}
}
+
+void
+st_translate_clear_color(const union gl_clear_color colorIn,
+ GLenum color_type, GLenum baseFormat,
+ GLfloat colorOut[4])
+{
+ GLfloat tmp[4];
+ switch (color_type) {
+ case GL_FLOAT:
+ default:
+ st_translate_color(colorIn.f, baseFormat, colorOut);
+ return;
+ break;
+ case GL_UNSIGNED_INT:
+ tmp[0] = (GLfloat)colorIn.i[0];
+ tmp[1] = (GLfloat)colorIn.i[1];
+ tmp[2] = (GLfloat)colorIn.i[2];
+ tmp[3] = (GLfloat)colorIn.i[3];
+ break;
+ case GL_INT:
+ tmp[0] = (GLfloat)colorIn.ui[0];
+ tmp[1] = (GLfloat)colorIn.ui[1];
+ tmp[2] = (GLfloat)colorIn.ui[2];
+ tmp[3] = (GLfloat)colorIn.ui[3];
+ break;
+ }
+ st_translate_color(tmp, baseFormat, colorOut);
+}
+
diff --git a/src/mesa/state_tracker/st_format.h b/src/mesa/state_tracker/st_format.h
index 1c1f596..5096a6a 100644
--- a/src/mesa/state_tracker/st_format.h
+++ b/src/mesa/state_tracker/st_format.h
@@ -83,5 +83,9 @@ extern void
st_translate_color(const GLfloat colorIn[4], GLenum baseFormat,
GLfloat colorOut[4]);
+void
+st_translate_clear_color(const union gl_clear_color colorIn,
+ GLenum color_type, GLenum baseFormat,
+ GLfloat colorOut[4]);
#endif /* ST_FORMAT_H */
--
1.7.6
More information about the mesa-dev
mailing list