From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d3dcompiler_43/compiler.c | 36 +++++++++++++++++++++++++++------ dlls/d3dcompiler_43/tests/asm.c | 12 +++-------- 2 files changed, 33 insertions(+), 15 deletions(-)
diff --git a/dlls/d3dcompiler_43/compiler.c b/dlls/d3dcompiler_43/compiler.c index 18efcb85001..e68ee6b6cec 100644 --- a/dlls/d3dcompiler_43/compiler.c +++ b/dlls/d3dcompiler_43/compiler.c @@ -672,9 +672,12 @@ HRESULT WINAPI D3DDisassemble(const void *data, SIZE_T size, UINT flags, const c { struct vkd3d_shader_compile_info compile_info; enum vkd3d_shader_source_type source_type; - struct vkd3d_shader_code asm_code; + struct vkd3d_shader_code source, asm_code; + struct vkd3d_shader_dxbc_desc desc; const char *ptr = data; + unsigned int i; char *messages; + uint32_t token; HRESULT hr; int ret;
@@ -692,15 +695,36 @@ HRESULT WINAPI D3DDisassemble(const void *data, SIZE_T size, UINT flags, const c return E_INVALIDARG; #endif
- if (size >= 4 && read_u32(&ptr) == TAG_DXBC) + source.code = data; + source.size = size; + + source_type = VKD3D_SHADER_SOURCE_D3D_BYTECODE; + if (vkd3d_shader_parse_dxbc(&source, 0, &desc, NULL) >= 0) + { source_type = VKD3D_SHADER_SOURCE_DXBC_TPF; - else - source_type = VKD3D_SHADER_SOURCE_D3D_BYTECODE; + + for (i = 0; i < desc.section_count; ++i) + { + if (TAG_FX10 == desc.sections[i].tag) + { + source = desc.sections[i].data; + source_type = VKD3D_SHADER_SOURCE_FX; + break; + } + } + + vkd3d_shader_free_dxbc(&desc); + } + else if (size >= 4) + { + token = read_u32(&ptr); + if ((token & 0xffff0000) == 0xfeff0000) + source_type = VKD3D_SHADER_SOURCE_FX; + }
compile_info.type = VKD3D_SHADER_STRUCTURE_TYPE_COMPILE_INFO; compile_info.next = NULL; - compile_info.source.code = data; - compile_info.source.size = size; + compile_info.source = source; compile_info.source_type = source_type; compile_info.target_type = VKD3D_SHADER_TARGET_D3D_ASM; compile_info.options = NULL; diff --git a/dlls/d3dcompiler_43/tests/asm.c b/dlls/d3dcompiler_43/tests/asm.c index 001ec979c23..95ea11e17b5 100644 --- a/dlls/d3dcompiler_43/tests/asm.c +++ b/dlls/d3dcompiler_43/tests/asm.c @@ -1760,28 +1760,22 @@ static void test_disassemble_shader(void) hr = D3DCompile(fx_4_0, strlen(fx_4_0), NULL, NULL, NULL, "", "fx_4_0", 0, 0, &blob, NULL); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); hr = D3DDisassemble(ID3D10Blob_GetBufferPointer(blob), ID3D10Blob_GetBufferSize(blob), 0, NULL, &blob2); - todo_wine ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); - if (SUCCEEDED(hr)) - ID3D10Blob_Release(blob2); + ID3D10Blob_Release(blob2); ID3D10Blob_Release(blob);
hr = D3DCompile(fx_4_0, strlen(fx_4_0), NULL, NULL, NULL, "", "fx_4_1", 0, 0, &blob, NULL); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); hr = D3DDisassemble(ID3D10Blob_GetBufferPointer(blob), ID3D10Blob_GetBufferSize(blob), 0, NULL, &blob2); - todo_wine ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); - if (SUCCEEDED(hr)) - ID3D10Blob_Release(blob2); + ID3D10Blob_Release(blob2); ID3D10Blob_Release(blob);
hr = D3DCompile(fx_5_0, strlen(fx_5_0), NULL, NULL, NULL, "", "fx_5_0", 0, 0, &blob, NULL); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); hr = D3DDisassemble(ID3D10Blob_GetBufferPointer(blob), ID3D10Blob_GetBufferSize(blob), 0, NULL, &blob2); - todo_wine ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); - if (SUCCEEDED(hr)) - ID3D10Blob_Release(blob2); + ID3D10Blob_Release(blob2); ID3D10Blob_Release(blob); }