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;