summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2011-04-15 15:48:32 -0700
committerEric Anholt <[email protected]>2011-04-20 10:35:42 -0700
commitb2491972591788fea0e55805cea3e9be8760969b (patch)
treefcaf6fcfe23ce6d35cf01d35d00c3aa75aaf7385
parent87478cd6e3e6349abc2688b390f8845d1e21af3d (diff)
meta: Add support for ARB_color_buffer_float to _mesa_meta_DrawPixels.
Tested with piglit arb_color_buffer_float-drawpixels. Reviewed-by: Brian Paul <[email protected]>
-rw-r--r--src/mesa/drivers/common/meta.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index c92bf29c30f..27681a29139 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -92,6 +92,7 @@
#define META_TEXTURE 0x1000
#define META_VERTEX 0x2000
#define META_VIEWPORT 0x4000
+#define META_CLAMP_FRAGMENT_COLOR 0x8000
/*@}*/
@@ -180,6 +181,9 @@ struct save_state
GLint ViewportX, ViewportY, ViewportW, ViewportH;
GLclampd DepthNear, DepthFar;
+ /** META_CLAMP_FRAGMENT_COLOR */
+ GLenum ClampFragmentColor;
+
/** Miscellaneous (always disabled) */
GLboolean Lighting;
};
@@ -569,6 +573,17 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state)
_mesa_DepthRange(0.0, 1.0);
}
+ if (state & META_CLAMP_FRAGMENT_COLOR) {
+ save->ClampFragmentColor = ctx->Color.ClampFragmentColor;
+
+ /* Generally in here we want to do clamping according to whether
+ * it's for the pixel path (ClampFragmentColor is GL_TRUE),
+ * regardless of the internal implementation of the metaops.
+ */
+ if (ctx->Color.ClampFragmentColor != GL_TRUE)
+ _mesa_ClampColorARB(GL_CLAMP_FRAGMENT_COLOR, GL_FALSE);
+ }
+
/* misc */
{
save->Lighting = ctx->Light.Enabled;
@@ -833,6 +848,10 @@ _mesa_meta_end(struct gl_context *ctx)
_mesa_DepthRange(save->DepthNear, save->DepthFar);
}
+ if (state & META_CLAMP_FRAGMENT_COLOR) {
+ _mesa_ClampColorARB(GL_CLAMP_FRAGMENT_COLOR, save->ClampFragmentColor);
+ }
+
/* misc */
if (save->Lighting) {
_mesa_set_enable(ctx, GL_LIGHTING, GL_TRUE);
@@ -1803,6 +1822,14 @@ _mesa_meta_DrawPixels(struct gl_context *ctx,
texIntFormat = format;
else
texIntFormat = GL_RGBA;
+
+ /* If we're not supposed to clamp the resulting color, then just
+ * promote our texture to fully float. We could do better by
+ * just going for the matching set of channels, in floating
+ * point.
+ */
+ if (ctx->Color.ClampFragmentColor != GL_TRUE)
+ texIntFormat = GL_RGBA32F;
}
else if (_mesa_is_stencil_format(format)) {
if (ctx->Extensions.ARB_fragment_program &&
@@ -1861,6 +1888,7 @@ _mesa_meta_DrawPixels(struct gl_context *ctx,
META_TRANSFORM |
META_VERTEX |
META_VIEWPORT |
+ META_CLAMP_FRAGMENT_COLOR |
metaExtraSave));
newTex = alloc_texture(tex, width, height, texIntFormat);