Mesa (master): vc4: Add support for color masking.
Eric Anholt
anholt at kemper.freedesktop.org
Mon Aug 18 22:28:04 UTC 2014
Module: Mesa
Branch: master
Commit: c1db622215e772fb94760ea2dbe97eacf2e6c4cb
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c1db622215e772fb94760ea2dbe97eacf2e6c4cb
Author: Eric Anholt <eric at anholt.net>
Date: Mon Aug 18 11:46:58 2014 -0700
vc4: Add support for color masking.
This gets fbo-colormask-formats working for core formats, which increases
my confidence in some of the swizzle and blend handling.
---
src/gallium/drivers/vc4/vc4_program.c | 37 +++++++++++++++++++++------------
1 file changed, 24 insertions(+), 13 deletions(-)
diff --git a/src/gallium/drivers/vc4/vc4_program.c b/src/gallium/drivers/vc4/vc4_program.c
index f125870..0210ebc 100644
--- a/src/gallium/drivers/vc4/vc4_program.c
+++ b/src/gallium/drivers/vc4/vc4_program.c
@@ -872,9 +872,8 @@ vc4_blend_func(struct tgsi_to_qir *trans,
*/
static void
vc4_blend(struct tgsi_to_qir *trans, struct qreg *result,
- struct qreg *src_color)
+ struct qreg *dst_color, struct qreg *src_color)
{
- struct qcompile *c = trans->c;
struct pipe_rt_blend_state *blend = &trans->fs_key->blend;
if (!blend->blend_enable) {
@@ -883,15 +882,6 @@ vc4_blend(struct tgsi_to_qir *trans, struct qreg *result,
return;
}
- qir_emit(c, qir_inst(QOP_TLB_COLOR_READ, c->undef,
- c->undef, c->undef));
- struct qreg dst_color[4];
- for (int i = 0; i < 4; i++) {
- dst_color[i] = qir_R4_UNPACK(c, i);
-
- /* XXX: Swizzles? */
- }
-
struct qreg src_blend[4], dst_blend[4];
for (int i = 0; i < 3; i++) {
src_blend[i] = vc4_blend_channel(trans,
@@ -932,13 +922,34 @@ emit_frag_end(struct tgsi_to_qir *trans)
const struct util_format_description *format_desc =
util_format_description(trans->fs_key->color_format);
- struct qreg output_color[4] = {
+ struct qreg src_color[4] = {
trans->outputs[0], trans->outputs[1],
trans->outputs[2], trans->outputs[3],
};
+ struct qreg dst_color[4] = { c->undef, c->undef, c->undef, c->undef };
+ if (trans->fs_key->blend.blend_enable ||
+ trans->fs_key->blend.colormask != 0xf) {
+ qir_emit(c, qir_inst(QOP_TLB_COLOR_READ, c->undef,
+ c->undef, c->undef));
+ for (int i = 0; i < 4; i++) {
+ dst_color[i] = qir_R4_UNPACK(c, i);
+
+ /* XXX: Swizzles? */
+ }
+ }
+
struct qreg blend_color[4];
- vc4_blend(trans, blend_color, output_color);
+ vc4_blend(trans, blend_color, dst_color, src_color);
+
+ /* If the bit isn't set in the color mask, then just return the
+ * original dst color, instead.
+ */
+ for (int i = 0; i < 4; i++) {
+ if (!(trans->fs_key->blend.colormask & (1 << i))) {
+ blend_color[i] = dst_color[i];
+ }
+ }
/* Debug: Sometimes you're getting a black output and just want to see
* if the FS is getting executed at all. Spam magenta into the color
More information about the mesa-commit
mailing list