Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55448 Signed-off-by: Nikolay Sivov nsivov@codeweavers.com
From: Nikolay Sivov nsivov@codeweavers.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55448 Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d3dcompiler_43/compiler.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/dlls/d3dcompiler_43/compiler.c b/dlls/d3dcompiler_43/compiler.c index 6fffcfb82ab..18efcb85001 100644 --- a/dlls/d3dcompiler_43/compiler.c +++ b/dlls/d3dcompiler_43/compiler.c @@ -550,12 +550,14 @@ HRESULT WINAPI D3DCompile2(const void *data, SIZE_T data_size, const char *filen option->value = VKD3D_SHADER_COMPILE_OPTION_PACK_MATRIX_COLUMN_MAJOR; }
+ option = &options[compile_info.option_count++]; + option->name = VKD3D_SHADER_COMPILE_OPTION_BACKWARD_COMPATIBILITY; + option->value = 0; +#if D3D_COMPILER_VERSION <= 35 + option->value |= VKD3D_SHADER_COMPILE_OPTION_DOUBLE_AS_FLOAT_ALIAS; +#endif if (flags & D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY) - { - option = &options[compile_info.option_count++]; - option->name = VKD3D_SHADER_COMPILE_OPTION_BACKWARD_COMPATIBILITY; - option->value = VKD3D_SHADER_COMPILE_OPTION_BACKCOMPAT_MAP_SEMANTIC_NAMES; - } + option->value |= VKD3D_SHADER_COMPILE_OPTION_BACKCOMPAT_MAP_SEMANTIC_NAMES;
if (effect_flags & D3DCOMPILE_EFFECT_CHILD_EFFECT) {
From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d3dcompiler_43/tests/asm.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-)
diff --git a/dlls/d3dcompiler_43/tests/asm.c b/dlls/d3dcompiler_43/tests/asm.c index 55d84213e1e..001ec979c23 100644 --- a/dlls/d3dcompiler_43/tests/asm.c +++ b/dlls/d3dcompiler_43/tests/asm.c @@ -1740,7 +1740,9 @@ static const DWORD vs_2_0[] =
static void test_disassemble_shader(void) { - ID3DBlob *blob; + static const char fx_4_0[] = "technique10 {}"; + static const char fx_5_0[] = "technique11 {}"; + ID3DBlob *blob, *blob2; HRESULT hr;
hr = D3DDisassemble(vs_2_0, 0, 0, NULL, &blob); @@ -1753,6 +1755,34 @@ static void test_disassemble_shader(void) hr = D3DDisassemble(vs_2_0, sizeof(vs_2_0), 0, NULL, &blob); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); ID3D10Blob_Release(blob); + + /* Effects profiles. */ + 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(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(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(blob); }
START_TEST(asm)
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); }
Matteo Bruni (@Mystral) commented about dlls/d3dcompiler_43/compiler.c:
option->value = VKD3D_SHADER_COMPILE_OPTION_PACK_MATRIX_COLUMN_MAJOR; }
- option = &options[compile_info.option_count++];
- option->name = VKD3D_SHADER_COMPILE_OPTION_BACKWARD_COMPATIBILITY;
- option->value = 0;
+#if D3D_COMPILER_VERSION <= 35
- option->value |= VKD3D_SHADER_COMPILE_OPTION_DOUBLE_AS_FLOAT_ALIAS;
+#endif
FWIW I see no compilation failure with d3dx9_24, d3dx9_36 or d3dx9_43 (or even with d3dcompiler_43, for that matter). I do see the expected error with d3dcompiler_47. That was with a ps_2_0 target and on 32-bit, in case it matters.
I haven't tested it exhaustively yet, maybe it is in fact target-dependent and we want something more specific. Which brings me to: I think we want some tests for this [*]. I hacked something locally to look into it; I guess I should make a proper MR that you can then expand further if needed. I'll see what I can quickly come up with.
Depending on the test results, it might be that this patch is generally right e.g. it's just a matter of updating the `#if` condition, in which case I'm okay with the patch in principle.
[*] We currently don't have tests for d3dx9_xx with xx != 36 at all. Ideally we'd replicate the tests for all the DLL iterations e.g. with PARENTSRC like we do for d3dcompiler, but that opens a huge can of worms and especially now it doesn't seem to be the time, with code freeze coming very soon.
Matteo Bruni (@Mystral) commented about dlls/d3dcompiler_43/compiler.c:
#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)
Very nitpicky, but I think we consistently put the constant on the right side in this kind of comparisons.