From 7b3c47ba2ec28531b1342331396c0ac28fe3e4c2 Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Thu, 2 May 2024 22:07:13 -0500 Subject: [PATCH] vkd3d-shader/tpf: Write the field offset in bytes. --- libs/vkd3d-shader/tpf.c | 2 +- tests/hlsl_d3d12.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/libs/vkd3d-shader/tpf.c b/libs/vkd3d-shader/tpf.c index c98667de..4e3bef96 100644 --- a/libs/vkd3d-shader/tpf.c +++ b/libs/vkd3d-shader/tpf.c @@ -3090,7 +3090,7 @@ static void write_sm4_type(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *b put_u32(buffer, field->name_bytecode_offset); put_u32(buffer, field->type->bytecode_offset); - put_u32(buffer, field->reg_offset[HLSL_REGSET_NUMERIC]); + put_u32(buffer, field->reg_offset[HLSL_REGSET_NUMERIC] * sizeof(float)); } type->bytecode_offset = put_u32(buffer, vkd3d_make_u32(D3D_SVC_STRUCT, D3D_SVT_VOID)); put_u32(buffer, vkd3d_make_u32(1, hlsl_type_component_count(array_type))); diff --git a/tests/hlsl_d3d12.c b/tests/hlsl_d3d12.c index 4d03efd5..4ab08816 100644 --- a/tests/hlsl_d3d12.c +++ b/tests/hlsl_d3d12.c @@ -1333,7 +1333,7 @@ static void check_type_desc_(int line, const D3D12_SHADER_TYPE_DESC *type, const ok_(line)(type->Columns == expect->Columns, "Got %u columns.\n", type->Columns); ok_(line)(type->Elements == expect->Elements, "Got %u elements.\n", type->Elements); ok_(line)(type->Members == expect->Members, "Got %u members.\n", type->Members); - ok_(line)(type->Offset == expect->Offset, "Got %u members.\n", type->Members); + ok_(line)(type->Offset == expect->Offset, "Got offset %u.\n", type->Offset); ok_(line)(!strcmp(type->Name, expect->Name), "Got name \"%s\".\n", type->Name); } #define check_type_desc(a, b) check_type_desc_(__LINE__, a, b) @@ -1407,7 +1407,7 @@ static void test_reflection(void) static const D3D12_SHADER_TYPE_DESC r_field_types[] = { {D3D_SVC_SCALAR, D3D_SVT_FLOAT, 1, 1, 0, 0, 0, "float"}, - {D3D_SVC_SCALAR, D3D_SVT_FLOAT, 1, 4, 0, 0, 0, "float4"}, + {D3D_SVC_VECTOR, D3D_SVT_FLOAT, 1, 4, 0, 0, 16, "float4"}, }; static const struct shader_variable globals_vars = @@ -1519,7 +1519,7 @@ static void test_reflection(void) static const D3D12_SHADER_TYPE_DESC ps_h_field_types[] = { {D3D_SVC_SCALAR, D3D_SVT_FLOAT, 1, 1, 0, 0, 0, "float"}, - {D3D_SVC_SCALAR, D3D_SVT_FLOAT, 1, 1, 0, 0, 0, "float"}, + {D3D_SVC_SCALAR, D3D_SVT_FLOAT, 1, 1, 0, 0, 4, "float"}, }; static const D3D12_SHADER_TYPE_DESC ps_i_field_types[] = @@ -1588,10 +1588,10 @@ static void test_reflection(void) for (unsigned int j = 0; j < buffer_desc.Variables; ++j) { const struct shader_variable *expect = &expect_buffer->vars[j]; + D3D12_SHADER_TYPE_DESC type_desc, field_desc; ID3D12ShaderReflectionType *type, *field; ID3D12ShaderReflectionVariable *var; D3D12_SHADER_VARIABLE_DESC var_desc; - D3D12_SHADER_TYPE_DESC type_desc; vkd3d_test_push_context("Variable %u", j); @@ -1623,9 +1623,9 @@ static void test_reflection(void) vkd3d_test_push_context("Field %u", k); field = ID3D12ShaderReflectionType_GetMemberTypeByIndex(type, k); - hr = ID3D12ShaderReflectionType_GetDesc(field, &type_desc); + hr = ID3D12ShaderReflectionType_GetDesc(field, &field_desc); ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); - check_type_desc(&type_desc, &expect->field_types[k]); + check_type_desc(&field_desc, &expect->field_types[k]); vkd3d_test_pop_context(); }