Module: Mesa
Branch: master
Commit: dffe7260cd5f9c70df4b817c26a4268ddad2475c
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=dffe7260cd5f9c70df4b817c26a4268ddad2475c

Author: Eric Anholt <e...@anholt.net>
Date:   Mon Nov 16 20:45:46 2015 -0800

vc4: Fix uniform reordering to support reading the same uniform twice.

This does actually happen in the wild (particularly fabs of a uniform), so
we'd like to support it.

---

 src/gallium/drivers/vc4/vc4_reorder_uniforms.c |   26 ++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/src/gallium/drivers/vc4/vc4_reorder_uniforms.c 
b/src/gallium/drivers/vc4/vc4_reorder_uniforms.c
index 7f11fba..85a0c95 100644
--- a/src/gallium/drivers/vc4/vc4_reorder_uniforms.c
+++ b/src/gallium/drivers/vc4/vc4_reorder_uniforms.c
@@ -44,18 +44,28 @@ qir_reorder_uniforms(struct vc4_compile *c)
         uint32_t next_uniform = 0;
 
         list_for_each_entry(struct qinst, inst, &c->instructions, link) {
+                uint32_t new = ~0;
+
                 for (int i = 0; i < qir_get_op_nsrc(inst->op); i++) {
                         if (inst->src[i].file != QFILE_UNIF)
                                 continue;
 
-                        uint32_t new = next_uniform++;
-                        if (uniform_index_size <= new) {
-                                uniform_index_size =
-                                        MAX2(uniform_index_size * 2, 16);
-                                uniform_index =
-                                        realloc(uniform_index,
-                                                uniform_index_size *
-                                                sizeof(uint32_t));
+                        if (new == ~0) {
+                                new = next_uniform++;
+                                if (uniform_index_size <= new) {
+                                        uniform_index_size =
+                                                MAX2(uniform_index_size * 2, 
16);
+                                        uniform_index =
+                                                realloc(uniform_index,
+                                                        uniform_index_size *
+                                                        sizeof(uint32_t));
+                                }
+                        } else {
+                                /* If we've got two uniform references in this
+                                 * instruction, they need to be the same
+                                 * uniform value.
+                                 */
+                                assert(inst->src[i].index == 
uniform_index[new]);
                         }
 
                         uniform_index[new] = inst->src[i].index;

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to