From 97fef2db5c2c6ec0b22bf5b7d968a4dc4b218363 Mon Sep 17 00:00:00 2001 From: Ilia Mirkin Date: Tue, 2 Dec 2014 21:32:01 -0500 Subject: freedreno/a3xx: fix alpha-blending on RGBX formats Expert debugging assistance provided by Chris Forbes. Signed-off-by: Ilia Mirkin Reviewed-by: Rob Clark --- src/gallium/auxiliary/util/u_blend.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/gallium/auxiliary/util/u_blend.h (limited to 'src/gallium/auxiliary/util') diff --git a/src/gallium/auxiliary/util/u_blend.h b/src/gallium/auxiliary/util/u_blend.h new file mode 100644 index 00000000000..2485c34d418 --- /dev/null +++ b/src/gallium/auxiliary/util/u_blend.h @@ -0,0 +1,25 @@ +#ifndef U_BLEND_H +#define U_BLEND_H + +#include "pipe/p_state.h" + +/** + * When faking RGBX render target formats with RGBA ones, the blender is still + * supposed to treat the destination's alpha channel as 1 instead of the + * garbage that's there. Return a blend factor that will take that into + * account. + */ +static INLINE int +util_blend_dst_alpha_to_one(int factor) +{ + switch (factor) { + case PIPE_BLENDFACTOR_DST_ALPHA: + return PIPE_BLENDFACTOR_ONE; + case PIPE_BLENDFACTOR_INV_DST_ALPHA: + return PIPE_BLENDFACTOR_ZERO; + default: + return factor; + } +} + +#endif /* U_BLEND_H */ -- cgit v1.2.3