vc4: Also consider uniform 0 in uniform lowering.
authorEric Anholt <eric@anholt.net>
Thu, 16 Jul 2015 21:30:28 +0000 (14:30 -0700)
committerEric Anholt <eric@anholt.net>
Fri, 17 Jul 2015 19:25:55 +0000 (12:25 -0700)
The hash table considers key 0 to be the empty key.

src/gallium/drivers/vc4/vc4_qir_lower_uniforms.c

index 910c89dca797c2a11e11aeca8b871407f8495f9c..f087c3b81b5455cbde63fd5ea398e85d2813e641 100644 (file)
@@ -52,7 +52,7 @@ static void
 add_uniform(struct hash_table *ht, struct qreg reg)
 {
         struct hash_entry *entry;
-        void *key = (void *)(uintptr_t)reg.index;
+        void *key = (void *)(uintptr_t)(reg.index + 1);
 
         entry = _mesa_hash_table_search(ht, key);
         if (entry) {
@@ -66,7 +66,7 @@ static void
 remove_uniform(struct hash_table *ht, struct qreg reg)
 {
         struct hash_entry *entry;
-        void *key = (void *)(uintptr_t)reg.index;
+        void *key = (void *)(uintptr_t)(reg.index + 1);
 
         entry = _mesa_hash_table_search(ht, key);
         assert(entry);
@@ -122,7 +122,7 @@ qir_lower_uniforms(struct vc4_compile *c)
                 struct hash_entry *entry;
                 hash_table_foreach(ht, entry) {
                         uint32_t count = (uintptr_t)entry->data;
-                        uint32_t index = (uintptr_t)entry->key;
+                        uint32_t index = (uintptr_t)entry->key - 1;
                         if (count > max_count) {
                                 max_count = count;
                                 max_index = index;