From cd74461d6dabae4e702de61a90533d811aa0a3fb Mon Sep 17 00:00:00 2001 From: Giovanni Mascellani Date: Tue, 8 Oct 2024 16:26:53 +0200 Subject: [PATCH] vkd3d-shader/ir: Set the signature sort indices in shader_signature_merge(). Since the sort index is just a convenience field it is more appropriate to only set it where it is required, instead of requiring all frontends and passes to retain sensible values for it. --- libs/vkd3d-shader/dxbc.c | 2 -- libs/vkd3d-shader/ir.c | 3 +++ libs/vkd3d-shader/vkd3d_shader_private.h | 3 +++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/libs/vkd3d-shader/dxbc.c b/libs/vkd3d-shader/dxbc.c index 93fc993e..f6ac8e08 100644 --- a/libs/vkd3d-shader/dxbc.c +++ b/libs/vkd3d-shader/dxbc.c @@ -419,8 +419,6 @@ static int shader_parse_signature(const struct vkd3d_shader_dxbc_section_desc *s const char *name; uint32_t mask; - e[i].sort_index = i; - if (has_stream_index) e[i].stream_index = read_u32(&ptr); else diff --git a/libs/vkd3d-shader/ir.c b/libs/vkd3d-shader/ir.c index 4e9fed07..14cf23e8 100644 --- a/libs/vkd3d-shader/ir.c +++ b/libs/vkd3d-shader/ir.c @@ -1471,6 +1471,9 @@ static bool shader_signature_merge(struct shader_signature *s, uint8_t range_map return false; memcpy(elements, s->elements, element_count * sizeof(*elements)); + for (i = 0; i < element_count; ++i) + elements[i].sort_index = i; + qsort(elements, element_count, sizeof(elements[0]), signature_element_register_compare); for (i = 0, new_count = 0; i < element_count; i = j, elements[new_count++] = *e) diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index 9aee685f..aab94f77 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -1061,6 +1061,9 @@ enum vkd3d_shader_input_sysval_semantic struct signature_element { + /* sort_index is not a property of the signature element, it is just a + * convenience field used to retain the original order in a signature and + * recover it after having permuted the signature itself. */ unsigned int sort_index; const char *semantic_name; unsigned int semantic_index;