diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2014-03-10 15:17:51 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2014-03-10 14:54:53 +0000 |
commit | 0075c90d3192ba90ff1ae8a7b04bfc3ff4fccda7 (patch) | |
tree | d3abb1d89eb2875027bcd75ce4bb6b3c9c780f04 | |
parent | f0b70ca660416af42be8b3f76f9e38a81dcac464 (diff) |
sna/gen2: Fix alpha blending with 8bit destination surfaces
On gen2 (like gen3), 8-bit destination surfaces are read into the Green
channel (and written to from the Green channel). Therefore the expected
alpha blending must instead be converted to colour blending.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=75818
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | src/sna/gen2_render.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/src/sna/gen2_render.c b/src/sna/gen2_render.c index da7049c1..3de0a8fe 100644 --- a/src/sna/gen2_render.c +++ b/src/sna/gen2_render.c @@ -425,14 +425,28 @@ static uint32_t gen2_get_blend_cntl(int op, sblend = gen2_blend_op[op].src_blend; dblend = gen2_blend_op[op].dst_blend; - /* If there's no dst alpha channel, adjust the blend op so that - * we'll treat it as always 1. - */ - if (PICT_FORMAT_A(dst_format) == 0 && gen2_blend_op[op].dst_alpha) { - if (sblend == BLENDFACTOR_DST_ALPHA) - sblend = BLENDFACTOR_ONE; - else if (sblend == BLENDFACTOR_INV_DST_ALPHA) - sblend = BLENDFACTOR_ZERO; + if (gen2_blend_op[op].dst_alpha) { + /* If there's no dst alpha channel, adjust the blend op so that + * we'll treat it as always 1. + */ + if (PICT_FORMAT_A(dst_format) == 0) { + if (sblend == BLENDFACTOR_DST_ALPHA) + sblend = BLENDFACTOR_ONE; + else if (sblend == BLENDFACTOR_INV_DST_ALPHA) + sblend = BLENDFACTOR_ZERO; + } + + /* gen2 engine reads 8bit color buffer into green channel + * in cases like color buffer blending etc., and also writes + * back green channel. So with dst_alpha blend we should use + * color factor. + */ + if (dst_format == PICT_a8) { + if (sblend == BLENDFACTOR_DST_ALPHA) + sblend = BLENDFACTOR_DST_COLR; + else if (sblend == BLENDFACTOR_INV_DST_ALPHA) + sblend = BLENDFACTOR_INV_DST_COLR; + } } /* If the source alpha is being used, then we should only be in a case |