vc4: Reuse uniform_data/contents indices when making uniforms.
authorEric Anholt <eric@anholt.net>
Fri, 24 Oct 2014 16:16:59 +0000 (17:16 +0100)
committerEric Anholt <eric@anholt.net>
Fri, 24 Oct 2014 17:04:26 +0000 (18:04 +0100)
This allows vc4_opt_cse.c to CSE-away operations involving the same
uniform values.

total instructions in shared programs: 37341 -> 36906 (-1.16%)
instructions in affected programs:     10233 -> 9798 (-4.25%)
total uniforms in shared programs: 10523 -> 10320 (-1.93%)
uniforms in affected programs:     2467 -> 2264 (-8.23%)

src/gallium/drivers/vc4/vc4_program.c

index 0674e4fd01a95fdba948cc0a8863ae4160ee81eb..c6b7edb9aef8cf00d783b6007166ed386b4d1495 100644 (file)
@@ -114,6 +114,13 @@ add_uniform(struct vc4_compile *c,
             enum quniform_contents contents,
             uint32_t data)
 {
+        for (int i = 0; i < c->num_uniforms; i++) {
+                if (c->uniform_contents[i] == contents &&
+                    c->uniform_data[i] == data) {
+                        return (struct qreg) { QFILE_UNIF, i };
+                }
+        }
+
         uint32_t uniform = c->num_uniforms++;
         struct qreg u = { QFILE_UNIF, uniform };