tgsi/ureg: handle redundant declarations in ureg_DECL_system_value
authorMarek Olšák <marek.olsak@amd.com>
Thu, 7 Jan 2016 22:37:53 +0000 (23:37 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Fri, 8 Jan 2016 19:06:22 +0000 (20:06 +0100)
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
src/gallium/auxiliary/tgsi/tgsi_ureg.c

index 964272386b31211080b05b43dfc5f0dc26d98b6a..5b78542413e0150113c472412844d8de1c48c1de 100644 (file)
@@ -322,7 +322,14 @@ ureg_DECL_system_value(struct ureg_program *ureg,
                        unsigned semantic_name,
                        unsigned semantic_index)
 {
-   unsigned i = 0;
+   unsigned i;
+
+   for (i = 0; i < ureg->nr_system_values; i++) {
+      if (ureg->system_value[i].semantic_name == semantic_name &&
+          ureg->system_value[i].semantic_index == semantic_index) {
+         goto out;
+      }
+   }
 
    if (ureg->nr_system_values < UREG_MAX_SYSTEM_VALUE) {
       ureg->system_value[ureg->nr_system_values].semantic_name = semantic_name;
@@ -333,6 +340,7 @@ ureg_DECL_system_value(struct ureg_program *ureg,
       set_bad(ureg);
    }
 
+out:
    return ureg_src_register(TGSI_FILE_SYSTEM_VALUE, i);
 }