From 7408ab145a21b1c7a57b70be217e3400ab2f0038 Mon Sep 17 00:00:00 2001 From: Shaun Ren Date: Wed, 16 Oct 2024 19:08:50 -0400 Subject: [PATCH] vkd3d-utils: Implement version reflection. --- libs/vkd3d-utils/reflection.c | 22 +++++++++++++++++----- tests/hlsl_d3d12.c | 8 +++++--- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/libs/vkd3d-utils/reflection.c b/libs/vkd3d-utils/reflection.c index d13ad700..35a0d909 100644 --- a/libs/vkd3d-utils/reflection.c +++ b/libs/vkd3d-utils/reflection.c @@ -1057,13 +1057,20 @@ static HRESULT d3d12_reflection_init(struct d3d12_reflection *reflection, const } if (FAILED(hr = parse_rdef(reflection, §ion->data))) - { - vkd3d_shader_free_scan_signature_info(&reflection->signature_info); - vkd3d_shader_free_dxbc(&dxbc_desc); - return hr; - } + goto fail; found_rdef = true; } + else if (section->tag == TAG_SHDR || section->tag == TAG_SHEX) + { + const uint32_t *version; + + if (!(version = get_data_ptr(§ion->data, 0, 1, sizeof(*version)))) + { + hr = E_INVALIDARG; + goto fail; + } + reflection->desc.Version = *version; + } } reflection->desc.InputParameters = reflection->signature_info.input.element_count; @@ -1073,6 +1080,11 @@ static HRESULT d3d12_reflection_init(struct d3d12_reflection *reflection, const vkd3d_shader_free_dxbc(&dxbc_desc); return S_OK; + +fail: + vkd3d_shader_free_scan_signature_info(&reflection->signature_info); + vkd3d_shader_free_dxbc(&dxbc_desc); + return hr; } HRESULT WINAPI D3DReflect(const void *data, SIZE_T data_size, REFIID iid, void **reflection) diff --git a/tests/hlsl_d3d12.c b/tests/hlsl_d3d12.c index 9b007aac..79f61a03 100644 --- a/tests/hlsl_d3d12.c +++ b/tests/hlsl_d3d12.c @@ -1630,6 +1630,7 @@ static void test_reflection(void) { const char *source; const char *profile; + UINT version; const D3D12_SHADER_INPUT_BIND_DESC *bindings; size_t binding_count; const struct shader_buffer *buffers; @@ -1638,9 +1639,9 @@ static void test_reflection(void) } tests[] = { - {vs_source, "vs_5_0", vs_bindings, ARRAY_SIZE(vs_bindings), vs_buffers, ARRAY_SIZE(vs_buffers), D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY}, - {ps_source, "ps_5_0", ps_bindings, ARRAY_SIZE(ps_bindings), ps_buffers, ARRAY_SIZE(ps_buffers), D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY}, - {ps51_source, "ps_5_1", ps51_bindings, ARRAY_SIZE(ps51_bindings), ps51_buffers, ARRAY_SIZE(ps51_buffers), 0} + {vs_source, "vs_5_0", 0x10050, vs_bindings, ARRAY_SIZE(vs_bindings), vs_buffers, ARRAY_SIZE(vs_buffers), D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY}, + {ps_source, "ps_5_0", 0x00050, ps_bindings, ARRAY_SIZE(ps_bindings), ps_buffers, ARRAY_SIZE(ps_buffers), D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY}, + {ps51_source, "ps_5_1", 0x00051, ps51_bindings, ARRAY_SIZE(ps51_bindings), ps51_buffers, ARRAY_SIZE(ps51_buffers), 0} }; for (unsigned int t = 0; t < ARRAY_SIZE(tests); ++t) @@ -1663,6 +1664,7 @@ static void test_reflection(void) hr = ID3D12ShaderReflection_GetDesc(reflection, &shader_desc); ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + ok(shader_desc.Version == tests[t].version, "Got version %#x.\n", shader_desc.Version); ok(shader_desc.ConstantBuffers == tests[t].buffer_count, "Got %u buffers.\n", shader_desc.ConstantBuffers); ok(shader_desc.BoundResources == tests[t].binding_count, "Got %u resources.\n", shader_desc.BoundResources);