summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca Barbieri <luca@luca-barbieri.com>2010-08-26 18:24:30 +0200
committerLuca Barbieri <luca@luca-barbieri.com>2010-09-05 18:11:24 +0200
commitd98ee6407e82cb7f5c952b2ed8a709d4a0fcbd93 (patch)
treec6e2f77e32762117f169c86ab0df4b27f483d3ba
parent2020034159dfa82cc23f2e3434c2927ac8f4c5a5 (diff)
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.
-rw-r--r--src/gallium/drivers/softpipe/sp_quad_fs.c21
-rw-r--r--src/gallium/drivers/softpipe/sp_screen.c4
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 90f4787d59..fa6c0efaed 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 9082a9683c..1206a5aa4f 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;
}