Mesa (floating): softpipe: respect fragment clamping and turn on ARB_color_buffer_float
Luca Barbieri
lb at kemper.freedesktop.org
Fri Aug 27 17:25:21 UTC 2010
Module: Mesa
Branch: floating
Commit: 6e25b30ca70a2b481bd3232d45b6d854808663e9
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6e25b30ca70a2b481bd3232d45b6d854808663e9
Author: Luca Barbieri <luca at luca-barbieri.com>
Date: Thu Aug 26 18:24:30 2010 +0200
softpipe: respect fragment clamping and turn on ARB_color_buffer_float
Apparently, we were never clamping fragment colors, resulting in
broken OpenGL compliance in presence of blending, even without
floating point targets.
---
src/gallium/drivers/softpipe/sp_quad_fs.c | 21 +++++++++++++++++++++
src/gallium/drivers/softpipe/sp_screen.c | 4 ++++
2 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/src/gallium/drivers/softpipe/sp_quad_fs.c b/src/gallium/drivers/softpipe/sp_quad_fs.c
index 90f4787..fa6c0ef 100644
--- a/src/gallium/drivers/softpipe/sp_quad_fs.c
+++ b/src/gallium/drivers/softpipe/sp_quad_fs.c
@@ -97,6 +97,24 @@ coverage_quad(struct quad_stage *qs, struct quad_header *quad)
}
}
+static void
+clamp_quad_color(struct quad_stage *qs, struct quad_header *quad)
+{
+ struct softpipe_context *softpipe = qs->softpipe;
+ uint cbuf;
+
+ /* loop over colorbuffer outputs */
+ for (cbuf = 0; cbuf < softpipe->framebuffer.nr_cbufs; cbuf++) {
+ float (*quadColor)[4] = quad->output.color[cbuf];
+ unsigned i;
+ for (i = 0; i < QUAD_SIZE; i++) {
+ unsigned j;
+ for(j = 0; j < 4; ++j)
+ quadColor[i][j] = CLAMP(quadColor[i][j], 0.0f, 1.0f);
+ }
+ }
+}
+
/**
* Shade/write an array of quads
@@ -121,6 +139,9 @@ shade_quads(struct quad_stage *qs,
if (!shade_quad(qs, quads[i]))
continue; /* quad totally culled/killed */
+ if(softpipe->rasterizer->clamp_fragment_color)
+ clamp_quad_color(qs, quads[i] );
+
if (/*do_coverage*/ 0)
coverage_quad( qs, quads[i] );
diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c
index 9082a96..1206a5a 100644
--- a/src/gallium/drivers/softpipe/sp_screen.c
+++ b/src/gallium/drivers/softpipe/sp_screen.c
@@ -152,6 +152,10 @@ softpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
case PIPE_CAP_GEOMETRY_SHADER4:
return 1;
+
+ case PIPE_CAP_UNCLAMPED_VERTEX_COLOR:
+ case PIPE_CAP_UNCLAMPED_FRAGMENT_COLOR:
+ return 1;
default:
return 0;
}
More information about the mesa-commit
mailing list