vkd3d-utils: Implement version reflection.

This commit is contained in:
Shaun Ren 2024-10-16 19:08:50 -04:00 committed by Henri Verbeet
parent a3b8aaf679
commit 7408ab145a
Notes: Henri Verbeet 2024-10-21 18:41:50 +02:00
Approved-by: Elizabeth Figura (@zfigura)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1194
2 changed files with 22 additions and 8 deletions

View File

@ -1057,13 +1057,20 @@ static HRESULT d3d12_reflection_init(struct d3d12_reflection *reflection, const
} }
if (FAILED(hr = parse_rdef(reflection, &section->data))) if (FAILED(hr = parse_rdef(reflection, &section->data)))
{ goto fail;
vkd3d_shader_free_scan_signature_info(&reflection->signature_info);
vkd3d_shader_free_dxbc(&dxbc_desc);
return hr;
}
found_rdef = true; found_rdef = true;
} }
else if (section->tag == TAG_SHDR || section->tag == TAG_SHEX)
{
const uint32_t *version;
if (!(version = get_data_ptr(&section->data, 0, 1, sizeof(*version))))
{
hr = E_INVALIDARG;
goto fail;
}
reflection->desc.Version = *version;
}
} }
reflection->desc.InputParameters = reflection->signature_info.input.element_count; 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); vkd3d_shader_free_dxbc(&dxbc_desc);
return S_OK; 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) HRESULT WINAPI D3DReflect(const void *data, SIZE_T data_size, REFIID iid, void **reflection)

View File

@ -1630,6 +1630,7 @@ static void test_reflection(void)
{ {
const char *source; const char *source;
const char *profile; const char *profile;
UINT version;
const D3D12_SHADER_INPUT_BIND_DESC *bindings; const D3D12_SHADER_INPUT_BIND_DESC *bindings;
size_t binding_count; size_t binding_count;
const struct shader_buffer *buffers; const struct shader_buffer *buffers;
@ -1638,9 +1639,9 @@ static void test_reflection(void)
} }
tests[] = tests[] =
{ {
{vs_source, "vs_5_0", vs_bindings, ARRAY_SIZE(vs_bindings), vs_buffers, ARRAY_SIZE(vs_buffers), D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY}, {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", ps_bindings, ARRAY_SIZE(ps_bindings), ps_buffers, ARRAY_SIZE(ps_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", ps51_bindings, ARRAY_SIZE(ps51_bindings), ps51_buffers, ARRAY_SIZE(ps51_buffers), 0} {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) 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); hr = ID3D12ShaderReflection_GetDesc(reflection, &shader_desc);
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); 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.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); ok(shader_desc.BoundResources == tests[t].binding_count, "Got %u resources.\n", shader_desc.BoundResources);