summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary
diff options
context:
space:
mode:
authorIlia Mirkin <[email protected]>2014-12-02 21:32:01 -0500
committerIlia Mirkin <[email protected]>2014-12-06 18:18:20 -0500
commit97fef2db5c2c6ec0b22bf5b7d968a4dc4b218363 (patch)
treec3497376757a667870654f8435d6997bfb93a962 /src/gallium/auxiliary
parent6b0196934509ac76293581f7ca69a3399ffb2e0a (diff)
freedreno/a3xx: fix alpha-blending on RGBX formats
Expert debugging assistance provided by Chris Forbes. Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Rob Clark <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r--src/gallium/auxiliary/Makefile.sources1
-rw-r--r--src/gallium/auxiliary/util/u_blend.h25
2 files changed, 26 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/Makefile.sources b/src/gallium/auxiliary/Makefile.sources
index 862626461b1..ab794e16441 100644
--- a/src/gallium/auxiliary/Makefile.sources
+++ b/src/gallium/auxiliary/Makefile.sources
@@ -168,6 +168,7 @@ C_SOURCES := \
util/u_atomic.h \
util/u_bitmask.c \
util/u_bitmask.h \
+ util/u_blend.h \
util/u_blit.c \
util/u_blit.h \
util/u_blitter.c \
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 */