summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c
diff options
context:
space:
mode:
authorRoland Scheidegger <sroland@vmware.com>2013-07-18 02:05:34 +0200
committerRoland Scheidegger <sroland@vmware.com>2013-07-18 19:03:35 +0200
commite57b98bad33b13ba02b11144709dd09af2ea8c95 (patch)
tree1c3c497cb01649b0736f2694245b0c87cefb6947 /src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c
parent0d7f087483d014305ec96a84ce5a28355f843c86 (diff)
llvmpipe: fix blending with SRC_ALPHA_SATURATE with some formats without alpha
We were fixing up the blend factor to ZERO, however this only works correctly with fixed point render buffers where the input values are clamped to 0/1 (because src_alpha_saturate is min(As, 1-Ad) so can be negative with unclamped inputs). Haven't seen any failure anywhere due to that with fixed point SNORM buffers (which clamp inputs to -1/1) but it should apply there as well (snorm blending is rare, even opengl 4.3 doesn't require snorm rendertargets at all, d3d10 requires them but they are not blendable). Doesn't look like piglit hits this though (some internal testing hits the float case at least). (With legacy OpenGL we could theoretically still use the fixup to zero if the fragment color clamp is enabled, but we can't detect that easily since we don't support native clamping hence it gets baked into the shader.) Reviewed-by: Jose Fonseca <jfonseca@vmware.com> Reviewed-by: Zack Rusin <zackr@vmware.com>
Diffstat (limited to 'src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c')
-rw-r--r--src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c b/src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c
index c4d04a26873..377eaa5a6e0 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c
@@ -114,10 +114,20 @@ lp_build_blend_factor_unswizzled(struct lp_build_blend_aos_context *bld,
if(alpha)
return bld->base.one;
else {
- if(!bld->inv_dst)
- bld->inv_dst = lp_build_comp(&bld->base, bld->dst);
- if(!bld->saturate)
- bld->saturate = lp_build_min(&bld->base, src_alpha, bld->inv_dst);
+ /*
+ * if there's separate src_alpha there's no dst alpha hence the complement
+ * is zero but for unclamped float inputs min can be non-zero (negative).
+ */
+ if (bld->src_alpha) {
+ if (!bld->saturate)
+ bld->saturate = lp_build_min(&bld->base, src_alpha, bld->base.zero);
+ }
+ else {
+ if(!bld->inv_dst)
+ bld->inv_dst = lp_build_comp(&bld->base, bld->dst);
+ if(!bld->saturate)
+ bld->saturate = lp_build_min(&bld->base, src_alpha, bld->inv_dst);
+ }
return bld->saturate;
}
case PIPE_BLENDFACTOR_CONST_COLOR: