microsoft/compiler: Semantic table should be de-duped for multi-row semantics too
authorJesse Natalie <jenatali@microsoft.com>
Sun, 2 Jan 2022 19:57:34 +0000 (11:57 -0800)
committerMarge Bot <emma+marge@anholt.net>
Wed, 26 Jan 2022 01:31:35 +0000 (01:31 +0000)
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14399>

src/microsoft/compiler/dxil_signature.c

index 6d9990d..3d134aa 100644 (file)
@@ -368,11 +368,15 @@ uint32_t
 append_semantic_index_to_table(struct dxil_psv_sem_index_table *table, uint32_t index,
                                uint32_t num_rows)
 {
-   if (num_rows == 1) {
-      for (unsigned i = 0; i < table->size; ++i) {
-         if (table->data[i] == index)
-            return i;
-      }
+   for (unsigned i = 0; i < table->size; ++i) {
+      unsigned j = 0;
+      for (; j < num_rows && i + j < table->size; ++j)
+         if (table->data[i + j] != index + j)
+            break;
+      if (j == num_rows)
+         return i;
+      else if (j > 0)
+         i += j - 1;
    }
    uint32_t retval = table->size;
    assert(table->size + num_rows <= 80);