mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader/hlsl: Sort signature elements by register id.
This commit is contained in:
parent
51d05c1844
commit
2a8c1b2823
Notes:
Henri Verbeet
2024-10-22 20:54:15 +02:00
Approved-by: Elizabeth Figura (@zfigura) Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1193
@ -3232,19 +3232,37 @@ static void add_section(struct hlsl_ctx *ctx, struct dxbc_writer *dxbc,
|
|||||||
ctx->result = buffer->status;
|
ctx->result = buffer->status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int signature_element_pointer_compare(const void *x, const void *y)
|
||||||
|
{
|
||||||
|
const struct signature_element *e = *(const struct signature_element **)x;
|
||||||
|
const struct signature_element *f = *(const struct signature_element **)y;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if ((ret = vkd3d_u32_compare(e->register_index, f->register_index)))
|
||||||
|
return ret;
|
||||||
|
return vkd3d_u32_compare(e->mask, f->mask);
|
||||||
|
}
|
||||||
|
|
||||||
static void tpf_write_signature(struct tpf_compiler *tpf, const struct shader_signature *signature, uint32_t tag)
|
static void tpf_write_signature(struct tpf_compiler *tpf, const struct shader_signature *signature, uint32_t tag)
|
||||||
{
|
{
|
||||||
bool output = tag == TAG_OSGN || (tag == TAG_PCSG
|
bool output = tag == TAG_OSGN || (tag == TAG_PCSG
|
||||||
&& tpf->program->shader_version.type == VKD3D_SHADER_TYPE_HULL);
|
&& tpf->program->shader_version.type == VKD3D_SHADER_TYPE_HULL);
|
||||||
|
const struct signature_element **sorted_elements;
|
||||||
struct vkd3d_bytecode_buffer buffer = {0};
|
struct vkd3d_bytecode_buffer buffer = {0};
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
put_u32(&buffer, signature->element_count);
|
put_u32(&buffer, signature->element_count);
|
||||||
put_u32(&buffer, 8); /* unknown */
|
put_u32(&buffer, 8); /* unknown */
|
||||||
|
|
||||||
|
if (!(sorted_elements = vkd3d_calloc(signature->element_count, sizeof(*sorted_elements))))
|
||||||
|
return;
|
||||||
|
for (i = 0; i < signature->element_count; ++i)
|
||||||
|
sorted_elements[i] = &signature->elements[i];
|
||||||
|
qsort(sorted_elements, signature->element_count, sizeof(*sorted_elements), signature_element_pointer_compare);
|
||||||
|
|
||||||
for (i = 0; i < signature->element_count; ++i)
|
for (i = 0; i < signature->element_count; ++i)
|
||||||
{
|
{
|
||||||
const struct signature_element *element = &signature->elements[i];
|
const struct signature_element *element = sorted_elements[i];
|
||||||
enum vkd3d_shader_sysval_semantic sysval;
|
enum vkd3d_shader_sysval_semantic sysval;
|
||||||
uint32_t used_mask = element->used_mask;
|
uint32_t used_mask = element->used_mask;
|
||||||
|
|
||||||
@ -3265,7 +3283,7 @@ static void tpf_write_signature(struct tpf_compiler *tpf, const struct shader_si
|
|||||||
|
|
||||||
for (i = 0; i < signature->element_count; ++i)
|
for (i = 0; i < signature->element_count; ++i)
|
||||||
{
|
{
|
||||||
const struct signature_element *element = &signature->elements[i];
|
const struct signature_element *element = sorted_elements[i];
|
||||||
size_t string_offset;
|
size_t string_offset;
|
||||||
|
|
||||||
string_offset = put_string(&buffer, element->semantic_name);
|
string_offset = put_string(&buffer, element->semantic_name);
|
||||||
@ -3273,6 +3291,7 @@ static void tpf_write_signature(struct tpf_compiler *tpf, const struct shader_si
|
|||||||
}
|
}
|
||||||
|
|
||||||
add_section(tpf->ctx, &tpf->dxbc, tag, &buffer);
|
add_section(tpf->ctx, &tpf->dxbc, tag, &buffer);
|
||||||
|
vkd3d_free(sorted_elements);
|
||||||
}
|
}
|
||||||
|
|
||||||
static D3D_SHADER_VARIABLE_CLASS sm4_class(const struct hlsl_type *type)
|
static D3D_SHADER_VARIABLE_CLASS sm4_class(const struct hlsl_type *type)
|
||||||
|
@ -2688,19 +2688,19 @@ static void test_signature_reflection(void)
|
|||||||
{ps1_source, "ps_4_1", false, ps1_inputs, ARRAY_SIZE(ps1_inputs), ps1_outputs, ARRAY_SIZE(ps1_outputs)},
|
{ps1_source, "ps_4_1", false, ps1_inputs, ARRAY_SIZE(ps1_inputs), ps1_outputs, ARRAY_SIZE(ps1_outputs)},
|
||||||
{ps2_source, "ps_4_0", true, ps2_inputs, ARRAY_SIZE(ps2_inputs), ps2_outputs, ARRAY_SIZE(ps2_outputs)},
|
{ps2_source, "ps_4_0", true, ps2_inputs, ARRAY_SIZE(ps2_inputs), ps2_outputs, ARRAY_SIZE(ps2_outputs)},
|
||||||
{cs1_source, "cs_5_0"},
|
{cs1_source, "cs_5_0"},
|
||||||
{ps3_source, "ps_4_0", false, ps3_inputs, ARRAY_SIZE(ps3_inputs), ps_outputs_simple, ARRAY_SIZE(ps_outputs_simple), NULL, 0, true},
|
{ps3_source, "ps_4_0", false, ps3_inputs, ARRAY_SIZE(ps3_inputs), ps_outputs_simple, ARRAY_SIZE(ps_outputs_simple)},
|
||||||
{ps4_source, "ps_4_0", false, ps4_inputs, ARRAY_SIZE(ps4_inputs), ps_outputs_simple, ARRAY_SIZE(ps_outputs_simple), NULL, 0, true},
|
{ps4_source, "ps_4_0", false, ps4_inputs, ARRAY_SIZE(ps4_inputs), ps_outputs_simple, ARRAY_SIZE(ps_outputs_simple)},
|
||||||
{ps5_source, "ps_4_0", false, ps5_inputs, ARRAY_SIZE(ps5_inputs), ps_outputs_simple, ARRAY_SIZE(ps_outputs_simple), NULL, 0, true},
|
{ps5_source, "ps_4_0", false, ps5_inputs, ARRAY_SIZE(ps5_inputs), ps_outputs_simple, ARRAY_SIZE(ps_outputs_simple)},
|
||||||
{ps6_source, "ps_4_0", false, ps6_inputs, ARRAY_SIZE(ps6_inputs), ps_outputs_simple, ARRAY_SIZE(ps_outputs_simple), NULL, 0, true},
|
{ps6_source, "ps_4_0", false, ps6_inputs, ARRAY_SIZE(ps6_inputs), ps_outputs_simple, ARRAY_SIZE(ps_outputs_simple)},
|
||||||
{ps7_source, "ps_4_0", false, ps7_inputs, ARRAY_SIZE(ps7_inputs), ps_outputs_simple, ARRAY_SIZE(ps_outputs_simple), NULL, 0, true},
|
{ps7_source, "ps_4_0", false, ps7_inputs, ARRAY_SIZE(ps7_inputs), ps_outputs_simple, ARRAY_SIZE(ps_outputs_simple)},
|
||||||
{ps8_source, "ps_4_0", false, ps8_inputs, ARRAY_SIZE(ps8_inputs), ps_outputs_simple, ARRAY_SIZE(ps_outputs_simple), NULL, 0, true},
|
{ps8_source, "ps_4_0", false, ps8_inputs, ARRAY_SIZE(ps8_inputs), ps_outputs_simple, ARRAY_SIZE(ps_outputs_simple)},
|
||||||
{ps9_source, "ps_4_0", false, ps9_inputs, ARRAY_SIZE(ps9_inputs), ps_outputs_simple, ARRAY_SIZE(ps_outputs_simple), NULL, 0, true},
|
{ps9_source, "ps_4_0", false, ps9_inputs, ARRAY_SIZE(ps9_inputs), ps_outputs_simple, ARRAY_SIZE(ps_outputs_simple)},
|
||||||
{vs3_source, "vs_4_0", false, vs3_inputs, ARRAY_SIZE(vs3_inputs), vs3_outputs, ARRAY_SIZE(vs3_outputs), NULL, 0, true},
|
{vs3_source, "vs_4_0", false, vs3_inputs, ARRAY_SIZE(vs3_inputs), vs3_outputs, ARRAY_SIZE(vs3_outputs)},
|
||||||
{ps10_source, "ps_4_0", false, ps10_inputs, ARRAY_SIZE(ps10_inputs), ps_outputs_simple, ARRAY_SIZE(ps_outputs_simple), NULL, 0, true},
|
{ps10_source, "ps_4_0", false, ps10_inputs, ARRAY_SIZE(ps10_inputs), ps_outputs_simple, ARRAY_SIZE(ps_outputs_simple)},
|
||||||
{ps11_source, "ps_4_0", false, ps11_inputs, ARRAY_SIZE(ps11_inputs), ps_outputs_simple, ARRAY_SIZE(ps_outputs_simple), NULL, 0, true},
|
{ps11_source, "ps_4_0", false, ps11_inputs, ARRAY_SIZE(ps11_inputs), ps_outputs_simple, ARRAY_SIZE(ps_outputs_simple)},
|
||||||
{ps12_source, "ps_4_0", false, ps12_inputs, ARRAY_SIZE(ps12_inputs), ps_outputs_simple, ARRAY_SIZE(ps_outputs_simple), NULL, 0, true},
|
{ps12_source, "ps_4_0", false, ps12_inputs, ARRAY_SIZE(ps12_inputs), ps_outputs_simple, ARRAY_SIZE(ps_outputs_simple)},
|
||||||
{vs4_source, "vs_4_0", false, vs4_inputs, ARRAY_SIZE(vs4_inputs), vs4_outputs, ARRAY_SIZE(vs4_outputs), NULL, 0, true},
|
{vs4_source, "vs_4_0", false, vs4_inputs, ARRAY_SIZE(vs4_inputs), vs4_outputs, ARRAY_SIZE(vs4_outputs)},
|
||||||
{vs5_source, "vs_4_0", false, vs5_inputs, ARRAY_SIZE(vs5_inputs), vs5_outputs, ARRAY_SIZE(vs5_outputs), NULL, 0, true},
|
{vs5_source, "vs_4_0", false, vs5_inputs, ARRAY_SIZE(vs5_inputs), vs5_outputs, ARRAY_SIZE(vs5_outputs)},
|
||||||
{hs1_source, "hs_5_0", false, NULL, 0, hs1_outputs, ARRAY_SIZE(hs1_outputs), hs1_patch_constants, ARRAY_SIZE(hs1_patch_constants)},
|
{hs1_source, "hs_5_0", false, NULL, 0, hs1_outputs, ARRAY_SIZE(hs1_outputs), hs1_patch_constants, ARRAY_SIZE(hs1_patch_constants)},
|
||||||
{hs2_source, "hs_5_0", false, NULL, 0, hs2_outputs, ARRAY_SIZE(hs2_outputs), hs2_patch_constants, ARRAY_SIZE(hs2_patch_constants)},
|
{hs2_source, "hs_5_0", false, NULL, 0, hs2_outputs, ARRAY_SIZE(hs2_outputs), hs2_patch_constants, ARRAY_SIZE(hs2_patch_constants)},
|
||||||
{hs3_source, "hs_5_0", false, NULL, 0, hs3_outputs, ARRAY_SIZE(hs3_outputs), hs3_patch_constants, ARRAY_SIZE(hs3_patch_constants)},
|
{hs3_source, "hs_5_0", false, NULL, 0, hs3_outputs, ARRAY_SIZE(hs3_outputs), hs3_patch_constants, ARRAY_SIZE(hs3_patch_constants)},
|
||||||
|
Loading…
Reference in New Issue
Block a user