diff options
author | Eric Anholt <[email protected]> | 2015-02-01 14:09:12 -0800 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2015-02-01 16:07:24 -0800 |
commit | 753c327151ed7d23218879149950f0028b0e7b4d (patch) | |
tree | 774c100fc3f8eece689127dcdffdc02aa6be741b /src/gallium/drivers | |
parent | 05080324135be4374e260b8e03c862ea1967727b (diff) |
vc4: Kill a bunch of color write calculation when colormask is all off.
I could have done this in the bit that generates the ANDs and ORs, but
it's probably generally useful. Sadly, I still need this even if I move
to NIR, because I can't yet express my read of the destination color in
NIR, which I would need to move my blend/logicop/colormask handling into
NIR.
total uniforms in shared programs: 13497 -> 13455 (-0.31%)
uniforms in affected programs: 101 -> 59 (-41.58%)
total instructions in shared programs: 40797 -> 40296 (-1.23%)
instructions in affected programs: 1639 -> 1138 (-30.57%)
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r-- | src/gallium/drivers/vc4/vc4_opt_algebraic.c | 43 |
1 files changed, 35 insertions, 8 deletions
diff --git a/src/gallium/drivers/vc4/vc4_opt_algebraic.c b/src/gallium/drivers/vc4/vc4_opt_algebraic.c index d36bb2d6596..994fa907f77 100644 --- a/src/gallium/drivers/vc4/vc4_opt_algebraic.c +++ b/src/gallium/drivers/vc4/vc4_opt_algebraic.c @@ -100,7 +100,7 @@ replace_with_mov(struct vc4_compile *c, struct qinst *inst, struct qreg arg) } static bool -add_replace_zero(struct vc4_compile *c, +replace_x_0_with_x(struct vc4_compile *c, struct qinst **defs, struct qinst *inst, int arg) @@ -112,7 +112,7 @@ add_replace_zero(struct vc4_compile *c, } static bool -fmul_replace_zero(struct vc4_compile *c, +replace_x_0_with_0(struct vc4_compile *c, struct qinst **defs, struct qinst *inst, int arg) @@ -217,16 +217,16 @@ qir_opt_algebraic(struct vc4_compile *c) break; case QOP_ADD: - if (add_replace_zero(c, defs, inst, 0) || - add_replace_zero(c, defs, inst, 1)) { + if (replace_x_0_with_x(c, defs, inst, 0) || + replace_x_0_with_x(c, defs, inst, 1)) { progress = true; break; } break; case QOP_FADD: - if (add_replace_zero(c, defs, inst, 0) || - add_replace_zero(c, defs, inst, 1)) { + if (replace_x_0_with_x(c, defs, inst, 0) || + replace_x_0_with_x(c, defs, inst, 1)) { progress = true; break; } @@ -262,8 +262,8 @@ qir_opt_algebraic(struct vc4_compile *c) break; case QOP_FMUL: - if (fmul_replace_zero(c, defs, inst, 0) || - fmul_replace_zero(c, defs, inst, 1) || + if (replace_x_0_with_0(c, defs, inst, 0) || + replace_x_0_with_0(c, defs, inst, 1) || fmul_replace_one(c, defs, inst, 0) || fmul_replace_one(c, defs, inst, 1)) { progress = true; @@ -271,6 +271,33 @@ qir_opt_algebraic(struct vc4_compile *c) } break; + case QOP_AND: + if (replace_x_0_with_0(c, defs, inst, 0) || + replace_x_0_with_0(c, defs, inst, 1)) { + progress = true; + break; + } + + if (is_constant_value(c, defs, inst->src[0], ~0)) { + replace_with_mov(c, inst, inst->src[1]); + progress = true; + break; + } + if (is_constant_value(c, defs, inst->src[1], ~0)) { + replace_with_mov(c, inst, inst->src[0]); + progress = true; + break; + } + break; + + case QOP_OR: + if (replace_x_0_with_x(c, defs, inst, 0) || + replace_x_0_with_x(c, defs, inst, 1)) { + progress = true; + break; + } + break; + default: break; } |