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>
This commit is contained in:
Chris Wilson 2014-03-10 15:17:51 +00:00
parent f0b70ca660
commit 0075c90d31
1 changed files with 22 additions and 8 deletions

View File

@ -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