From 5e3d64d067b4b645f6427df01d6540dfb051d937 Mon Sep 17 00:00:00 2001 From: Jesse Natalie Date: Sun, 2 Jan 2022 11:57:34 -0800 Subject: [PATCH] microsoft/compiler: Semantic table should be de-duped for multi-row semantics too Reviewed-by: Boris Brezillon Reviewed-by: Bill Kristiansen Part-of: --- src/microsoft/compiler/dxil_signature.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/microsoft/compiler/dxil_signature.c b/src/microsoft/compiler/dxil_signature.c index 6d9990d7572..3d134aa5a7c 100644 --- a/src/microsoft/compiler/dxil_signature.c +++ b/src/microsoft/compiler/dxil_signature.c @@ -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);