[PATCH] d3dcompiler: Implement D3DCompile2() using vkd3d_shader_compile().
Zebediah Figura
zfigura at codeweavers.com
Thu Mar 3 20:25:26 CST 2022
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51713
Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
---
dlls/d3dcompiler_33/Makefile.in | 3 +-
dlls/d3dcompiler_34/Makefile.in | 3 +-
dlls/d3dcompiler_35/Makefile.in | 3 +-
dlls/d3dcompiler_36/Makefile.in | 3 +-
dlls/d3dcompiler_37/Makefile.in | 3 +-
dlls/d3dcompiler_38/Makefile.in | 3 +-
dlls/d3dcompiler_39/Makefile.in | 3 +-
dlls/d3dcompiler_40/Makefile.in | 3 +-
dlls/d3dcompiler_41/Makefile.in | 3 +-
dlls/d3dcompiler_42/Makefile.in | 3 +-
dlls/d3dcompiler_43/Makefile.in | 2 +
dlls/d3dcompiler_43/compiler.c | 220 ++++++++++++++++++++++---
dlls/d3dcompiler_43/tests/hlsl_d3d11.c | 96 +++++------
dlls/d3dcompiler_43/tests/hlsl_d3d9.c | 214 +++++++++++-------------
dlls/d3dcompiler_46/Makefile.in | 3 +-
dlls/d3dcompiler_47/Makefile.in | 3 +-
16 files changed, 358 insertions(+), 210 deletions(-)
diff --git a/dlls/d3dcompiler_33/Makefile.in b/dlls/d3dcompiler_33/Makefile.in
index 7130fb48376..988230890d8 100644
--- a/dlls/d3dcompiler_33/Makefile.in
+++ b/dlls/d3dcompiler_33/Makefile.in
@@ -1,7 +1,8 @@
MODULE = d3dcompiler_33.dll
-IMPORTS = dxguid uuid
+IMPORTS = wined3d dxguid uuid
EXTRADEFS = -DD3D_COMPILER_VERSION=33
PARENTSRC = ../d3dcompiler_43
+EXTRAINCL = $(VKD3D_PE_CFLAGS)
EXTRADLLFLAGS = -Wb,--prefer-native
diff --git a/dlls/d3dcompiler_34/Makefile.in b/dlls/d3dcompiler_34/Makefile.in
index e4dfc72cae8..fb5ff5d0489 100644
--- a/dlls/d3dcompiler_34/Makefile.in
+++ b/dlls/d3dcompiler_34/Makefile.in
@@ -1,7 +1,8 @@
MODULE = d3dcompiler_34.dll
-IMPORTS = dxguid uuid
+IMPORTS = wined3d dxguid uuid
EXTRADEFS = -DD3D_COMPILER_VERSION=34
PARENTSRC = ../d3dcompiler_43
+EXTRAINCL = $(VKD3D_PE_CFLAGS)
EXTRADLLFLAGS = -Wb,--prefer-native
diff --git a/dlls/d3dcompiler_35/Makefile.in b/dlls/d3dcompiler_35/Makefile.in
index 56c87186c2e..5e94da0e14b 100644
--- a/dlls/d3dcompiler_35/Makefile.in
+++ b/dlls/d3dcompiler_35/Makefile.in
@@ -1,7 +1,8 @@
MODULE = d3dcompiler_35.dll
-IMPORTS = dxguid uuid
+IMPORTS = wined3d dxguid uuid
EXTRADEFS = -DD3D_COMPILER_VERSION=35
PARENTSRC = ../d3dcompiler_43
+EXTRAINCL = $(VKD3D_PE_CFLAGS)
EXTRADLLFLAGS = -Wb,--prefer-native
diff --git a/dlls/d3dcompiler_36/Makefile.in b/dlls/d3dcompiler_36/Makefile.in
index f23ac2cb990..3a1f13a064e 100644
--- a/dlls/d3dcompiler_36/Makefile.in
+++ b/dlls/d3dcompiler_36/Makefile.in
@@ -1,7 +1,8 @@
MODULE = d3dcompiler_36.dll
-IMPORTS = dxguid uuid
+IMPORTS = wined3d dxguid uuid
EXTRADEFS = -DD3D_COMPILER_VERSION=36
PARENTSRC = ../d3dcompiler_43
+EXTRAINCL = $(VKD3D_PE_CFLAGS)
EXTRADLLFLAGS = -Wb,--prefer-native
diff --git a/dlls/d3dcompiler_37/Makefile.in b/dlls/d3dcompiler_37/Makefile.in
index 331f5f5f068..4afb74e419a 100644
--- a/dlls/d3dcompiler_37/Makefile.in
+++ b/dlls/d3dcompiler_37/Makefile.in
@@ -1,7 +1,8 @@
MODULE = d3dcompiler_37.dll
-IMPORTS = dxguid uuid
+IMPORTS = wined3d dxguid uuid
EXTRADEFS = -DD3D_COMPILER_VERSION=37
PARENTSRC = ../d3dcompiler_43
+EXTRAINCL = $(VKD3D_PE_CFLAGS)
EXTRADLLFLAGS = -Wb,--prefer-native
diff --git a/dlls/d3dcompiler_38/Makefile.in b/dlls/d3dcompiler_38/Makefile.in
index b34c2322aae..304548baadd 100644
--- a/dlls/d3dcompiler_38/Makefile.in
+++ b/dlls/d3dcompiler_38/Makefile.in
@@ -1,7 +1,8 @@
MODULE = d3dcompiler_38.dll
-IMPORTS = dxguid uuid
+IMPORTS = wined3d dxguid uuid
EXTRADEFS = -DD3D_COMPILER_VERSION=38
PARENTSRC = ../d3dcompiler_43
+EXTRAINCL = $(VKD3D_PE_CFLAGS)
EXTRADLLFLAGS = -Wb,--prefer-native
diff --git a/dlls/d3dcompiler_39/Makefile.in b/dlls/d3dcompiler_39/Makefile.in
index cf4dc2cdd83..87cb11b9572 100644
--- a/dlls/d3dcompiler_39/Makefile.in
+++ b/dlls/d3dcompiler_39/Makefile.in
@@ -1,7 +1,8 @@
MODULE = d3dcompiler_39.dll
-IMPORTS = dxguid uuid
+IMPORTS = wined3d dxguid uuid
EXTRADEFS = -DD3D_COMPILER_VERSION=39
PARENTSRC = ../d3dcompiler_43
+EXTRAINCL = $(VKD3D_PE_CFLAGS)
EXTRADLLFLAGS = -Wb,--prefer-native
diff --git a/dlls/d3dcompiler_40/Makefile.in b/dlls/d3dcompiler_40/Makefile.in
index c8d415baf83..443132d7002 100644
--- a/dlls/d3dcompiler_40/Makefile.in
+++ b/dlls/d3dcompiler_40/Makefile.in
@@ -1,7 +1,8 @@
MODULE = d3dcompiler_40.dll
-IMPORTS = dxguid uuid
+IMPORTS = wined3d dxguid uuid
EXTRADEFS = -DD3D_COMPILER_VERSION=40
PARENTSRC = ../d3dcompiler_43
+EXTRAINCL = $(VKD3D_PE_CFLAGS)
EXTRADLLFLAGS = -Wb,--prefer-native
diff --git a/dlls/d3dcompiler_41/Makefile.in b/dlls/d3dcompiler_41/Makefile.in
index 2fa69b5a18d..a71dca88e6c 100644
--- a/dlls/d3dcompiler_41/Makefile.in
+++ b/dlls/d3dcompiler_41/Makefile.in
@@ -1,7 +1,8 @@
MODULE = d3dcompiler_41.dll
-IMPORTS = dxguid uuid
+IMPORTS = wined3d dxguid uuid
EXTRADEFS = -DD3D_COMPILER_VERSION=41
PARENTSRC = ../d3dcompiler_43
+EXTRAINCL = $(VKD3D_PE_CFLAGS)
EXTRADLLFLAGS = -Wb,--prefer-native
diff --git a/dlls/d3dcompiler_42/Makefile.in b/dlls/d3dcompiler_42/Makefile.in
index d821b888bde..ea9f0fc3faa 100644
--- a/dlls/d3dcompiler_42/Makefile.in
+++ b/dlls/d3dcompiler_42/Makefile.in
@@ -1,7 +1,8 @@
MODULE = d3dcompiler_42.dll
-IMPORTS = dxguid uuid
+IMPORTS = wined3d dxguid uuid
EXTRADEFS = -DD3D_COMPILER_VERSION=42
PARENTSRC = ../d3dcompiler_43
+EXTRAINCL = $(VKD3D_PE_CFLAGS)
EXTRADLLFLAGS = -Wb,--prefer-native
diff --git a/dlls/d3dcompiler_43/Makefile.in b/dlls/d3dcompiler_43/Makefile.in
index b527f1681d7..b69f3749626 100644
--- a/dlls/d3dcompiler_43/Makefile.in
+++ b/dlls/d3dcompiler_43/Makefile.in
@@ -1,6 +1,8 @@
MODULE = d3dcompiler_43.dll
IMPORTLIB = d3dcompiler_43
EXTRADEFS = -DD3D_COMPILER_VERSION=43
+IMPORTS = wined3d
+EXTRAINCL = $(VKD3D_PE_CFLAGS)
EXTRADLLFLAGS = -Wb,--prefer-native
diff --git a/dlls/d3dcompiler_43/compiler.c b/dlls/d3dcompiler_43/compiler.c
index 6ae51c75cd4..4d2642f17e3 100644
--- a/dlls/d3dcompiler_43/compiler.c
+++ b/dlls/d3dcompiler_43/compiler.c
@@ -1,6 +1,7 @@
/*
* Copyright 2009 Matteo Bruni
* Copyright 2010 Matteo Bruni for CodeWeavers
+ * Copyright 2016,2018 Józef Kucia for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -25,8 +26,33 @@
#include "d3dcompiler_private.h"
#include "wpp_private.h"
+#include <vkd3d_shader.h>
+
WINE_DEFAULT_DEBUG_CHANNEL(d3dcompiler);
+static HRESULT hresult_from_vkd3d_result(int vkd3d_result)
+{
+ switch (vkd3d_result)
+ {
+ case VKD3D_OK:
+ return S_OK;
+ case VKD3D_ERROR_INVALID_SHADER:
+ WARN("Invalid shader bytecode.\n");
+ /* fall-through */
+ case VKD3D_ERROR:
+ return E_FAIL;
+ case VKD3D_ERROR_OUT_OF_MEMORY:
+ return E_OUTOFMEMORY;
+ case VKD3D_ERROR_INVALID_ARGUMENT:
+ return E_INVALIDARG;
+ case VKD3D_ERROR_NOT_IMPLEMENTED:
+ return E_NOTIMPL;
+ default:
+ FIXME("Unhandled vkd3d result %d.\n", vkd3d_result);
+ return E_FAIL;
+ }
+}
+
#define D3DXERR_INVALIDDATA 0x88760b59
#define BUFFER_INITIAL_CAPACITY 256
@@ -736,39 +762,179 @@ HRESULT WINAPI D3DAssemble(const void *data, SIZE_T datasize, const char *filena
return hr;
}
-HRESULT WINAPI D3DCompile2(const void *data, SIZE_T data_size, const char *filename,
- const D3D_SHADER_MACRO *defines, ID3DInclude *include, const char *entrypoint,
- const char *target, UINT sflags, UINT eflags, UINT secondary_flags,
- const void *secondary_data, SIZE_T secondary_data_size, ID3DBlob **shader,
- ID3DBlob **error_messages)
+static int open_include(const char *filename, bool local, const char *parent_data, void *context,
+ struct vkd3d_shader_code *code)
{
+ ID3DInclude *iface = context;
+ unsigned int size = 0;
+
+ if (!iface)
+ return VKD3D_ERROR;
+
+ memset(code, 0, sizeof(*code));
+ if (FAILED(ID3DInclude_Open(iface, local ? D3D_INCLUDE_LOCAL : D3D_INCLUDE_SYSTEM,
+ filename, parent_data, &code->code, &size)))
+ return VKD3D_ERROR;
+
+ code->size = size;
+ return VKD3D_OK;
+}
+
+static void close_include(const struct vkd3d_shader_code *code, void *context)
+{
+ ID3DInclude *iface = context;
+
+ ID3DInclude_Close(iface, code->code);
+}
+
+HRESULT WINAPI D3DCompile2(const void *data, SIZE_T data_size, const char *filename,
+ const D3D_SHADER_MACRO *macros, ID3DInclude *include, const char *entry_point,
+ const char *profile, UINT flags, UINT effect_flags, UINT secondary_flags,
+ const void *secondary_data, SIZE_T secondary_data_size, ID3DBlob **shader_blob,
+ ID3DBlob **messages_blob)
+{
+ struct d3dcompiler_include_from_file include_from_file;
+ struct vkd3d_shader_preprocess_info preprocess_info;
+ struct vkd3d_shader_hlsl_source_info hlsl_info;
+ struct vkd3d_shader_compile_option options[2];
+ struct vkd3d_shader_compile_info compile_info;
+ struct vkd3d_shader_compile_option *option;
+ struct vkd3d_shader_code byte_code;
+ const D3D_SHADER_MACRO *macro;
+ size_t profile_len, i;
+ char *messages;
HRESULT hr;
+ int ret;
- TRACE("data %p, data_size %Iu, filename %s, defines %p, include %p, entrypoint %s, "
- "target %s, sflags %#x, eflags %#x, secondary_flags %#x, secondary_data %p, "
- "secondary_data_size %Iu, shader %p, error_messages %p.\n",
- data, data_size, debugstr_a(filename), defines, include, debugstr_a(entrypoint),
- debugstr_a(target), sflags, eflags, secondary_flags, secondary_data,
- secondary_data_size, shader, error_messages);
-
- if (secondary_data)
- FIXME("secondary data not implemented yet\n");
-
- if (shader) *shader = NULL;
- if (error_messages) *error_messages = NULL;
-
- EnterCriticalSection(&wpp_mutex);
-
- hr = preprocess_shader(data, data_size, filename, defines, include, error_messages);
- if (SUCCEEDED(hr))
+ static const char * const d3dbc_profiles[] =
{
- FIXME("HLSL shader compilation is not yet implemented.\n");
- hr = E_NOTIMPL;
+ "fx_2_",
+
+ "ps.1.",
+ "ps.2.",
+ "ps.3.",
+
+ "ps_1_",
+ "ps_2_",
+ "ps_3_",
+
+ "vs.1.",
+ "vs.2.",
+ "vs.3.",
+
+ "vs_1_",
+ "vs_2_",
+ "vs_3_",
+
+ "tx_1_",
+ };
+
+ TRACE("data %p, data_size %Iu, filename %s, macros %p, include %p, entry_point %s, "
+ "profile %s, flags %#x, effect_flags %#x, secondary_flags %#x, secondary_data %p, "
+ "secondary_data_size %Iu, shader_blob %p, messages_blob %p.\n",
+ data, data_size, debugstr_a(filename), macros, include, debugstr_a(entry_point),
+ debugstr_a(profile), flags, effect_flags, secondary_flags, secondary_data,
+ secondary_data_size, shader_blob, messages_blob);
+
+ if (include == D3D_COMPILE_STANDARD_FILE_INCLUDE)
+ {
+ include_from_file.ID3DInclude_iface.lpVtbl = &d3dcompiler_include_from_file_vtbl;
+ include = &include_from_file.ID3DInclude_iface;
}
- HeapFree(GetProcessHeap(), 0, wpp_output);
- LeaveCriticalSection(&wpp_mutex);
- return hr;
+ if (flags & ~D3DCOMPILE_DEBUG)
+ FIXME("Ignoring flags %#x.\n", flags);
+ if (effect_flags)
+ FIXME("Ignoring effect flags %#x.\n", effect_flags);
+ if (secondary_flags)
+ FIXME("Ignoring secondary flags %#x.\n", secondary_flags);
+
+ if (messages_blob)
+ *messages_blob = NULL;
+
+ option = &options[0];
+ option->name = VKD3D_SHADER_COMPILE_OPTION_API_VERSION;
+ option->value = VKD3D_SHADER_API_VERSION_1_3;
+
+ compile_info.type = VKD3D_SHADER_STRUCTURE_TYPE_COMPILE_INFO;
+ compile_info.next = &preprocess_info;
+ compile_info.source.code = data;
+ compile_info.source.size = data_size;
+ compile_info.source_type = VKD3D_SHADER_SOURCE_HLSL;
+ compile_info.target_type = VKD3D_SHADER_TARGET_DXBC_TPF;
+ compile_info.options = options;
+ compile_info.option_count = 1;
+ compile_info.log_level = VKD3D_SHADER_LOG_INFO;
+ compile_info.source_name = filename;
+
+ profile_len = strlen(profile);
+ for (i = 0; i < ARRAY_SIZE(d3dbc_profiles); ++i)
+ {
+ size_t len = strlen(d3dbc_profiles[i]);
+
+ if (len <= profile_len && !memcmp(profile, d3dbc_profiles[i], len))
+ {
+ compile_info.target_type = VKD3D_SHADER_TARGET_D3D_BYTECODE;
+ break;
+ }
+ }
+
+ preprocess_info.type = VKD3D_SHADER_STRUCTURE_TYPE_PREPROCESS_INFO;
+ preprocess_info.next = &hlsl_info;
+ preprocess_info.macros = (const struct vkd3d_shader_macro *)macros;
+ preprocess_info.macro_count = 0;
+ if (macros)
+ {
+ for (macro = macros; macro->Name; ++macro)
+ ++preprocess_info.macro_count;
+ }
+ preprocess_info.pfn_open_include = open_include;
+ preprocess_info.pfn_close_include = close_include;
+ preprocess_info.include_context = include;
+
+ hlsl_info.type = VKD3D_SHADER_STRUCTURE_TYPE_HLSL_SOURCE_INFO;
+ hlsl_info.next = NULL;
+ hlsl_info.profile = profile;
+ hlsl_info.entry_point = entry_point;
+ hlsl_info.secondary_code.code = secondary_data;
+ hlsl_info.secondary_code.size = secondary_data_size;
+
+ if (!(flags & D3DCOMPILE_DEBUG))
+ {
+ option = &options[compile_info.option_count++];
+ option->name = VKD3D_SHADER_COMPILE_OPTION_STRIP_DEBUG;
+ option->value = true;
+ }
+
+ ret = vkd3d_shader_compile(&compile_info, &byte_code, &messages);
+ if (messages)
+ {
+ if (messages_blob)
+ {
+ size_t size = strlen(messages);
+ if (FAILED(hr = D3DCreateBlob(size, messages_blob)))
+ {
+ vkd3d_shader_free_messages(messages);
+ vkd3d_shader_free_shader_code(&byte_code);
+ return hr;
+ }
+ memcpy(ID3D10Blob_GetBufferPointer(*messages_blob), messages, size);
+ }
+ else
+ vkd3d_shader_free_messages(messages);
+ }
+
+ if (!ret)
+ {
+ if (FAILED(hr = D3DCreateBlob(byte_code.size, shader_blob)))
+ {
+ vkd3d_shader_free_shader_code(&byte_code);
+ return hr;
+ }
+ memcpy(ID3D10Blob_GetBufferPointer(*shader_blob), byte_code.code, byte_code.size);
+ }
+
+ return hresult_from_vkd3d_result(ret);
}
HRESULT WINAPI D3DCompile(const void *data, SIZE_T data_size, const char *filename,
diff --git a/dlls/d3dcompiler_43/tests/hlsl_d3d11.c b/dlls/d3dcompiler_43/tests/hlsl_d3d11.c
index 5f7846a479b..4f52002866e 100644
--- a/dlls/d3dcompiler_43/tests/hlsl_d3d11.c
+++ b/dlls/d3dcompiler_43/tests/hlsl_d3d11.c
@@ -383,20 +383,17 @@ static void test_swizzle(void)
if (!init_test_context(&test_context))
return;
- todo_wine ps_code = compile_shader(ps_source, "ps_4_0");
- if (ps_code)
- {
- cb = create_buffer(test_context.device, D3D11_BIND_CONSTANT_BUFFER, sizeof(uniform), &uniform);
- ID3D11DeviceContext_PSSetConstantBuffers(test_context.immediate_context, 0, 1, &cb);
- draw_quad(&test_context, ps_code);
+ ps_code = compile_shader(ps_source, "ps_4_0");
+ cb = create_buffer(test_context.device, D3D11_BIND_CONSTANT_BUFFER, sizeof(uniform), &uniform);
+ ID3D11DeviceContext_PSSetConstantBuffers(test_context.immediate_context, 0, 1, &cb);
+ draw_quad(&test_context, ps_code);
- v = get_color_vec4(&test_context, 0, 0);
- ok(compare_vec4(&v, 0.0101f, 0.0303f, 0.0202f, 0.0404f, 0),
- "Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n", v.x, v.y, v.z, v.w);
+ v = get_color_vec4(&test_context, 0, 0);
+ ok(compare_vec4(&v, 0.0101f, 0.0303f, 0.0202f, 0.0404f, 0),
+ "Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n", v.x, v.y, v.z, v.w);
- ID3D11Buffer_Release(cb);
- ID3D10Blob_Release(ps_code);
- }
+ ID3D11Buffer_Release(cb);
+ ID3D10Blob_Release(ps_code);
release_test_context(&test_context);
}
@@ -421,20 +418,17 @@ static void test_math(void)
if (!init_test_context(&test_context))
return;
- todo_wine ps_code = compile_shader(ps_source, "ps_4_0");
- if (ps_code)
- {
- cb = create_buffer(test_context.device, D3D11_BIND_CONSTANT_BUFFER, sizeof(uniforms), uniforms);
- ID3D11DeviceContext_PSSetConstantBuffers(test_context.immediate_context, 0, 1, &cb);
- draw_quad(&test_context, ps_code);
+ ps_code = compile_shader(ps_source, "ps_4_0");
+ cb = create_buffer(test_context.device, D3D11_BIND_CONSTANT_BUFFER, sizeof(uniforms), uniforms);
+ ID3D11DeviceContext_PSSetConstantBuffers(test_context.immediate_context, 0, 1, &cb);
+ draw_quad(&test_context, ps_code);
- v = get_color_vec4(&test_context, 0, 0);
- ok(compare_vec4(&v, -12.43f, 9.833333f, 1.6f, 35.0f, 1),
- "Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n", v.x, v.y, v.z, v.w);
+ v = get_color_vec4(&test_context, 0, 0);
+ ok(compare_vec4(&v, -12.43f, 9.833333f, 1.6f, 35.0f, 1),
+ "Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n", v.x, v.y, v.z, v.w);
- ID3D11Buffer_Release(cb);
- ID3D10Blob_Release(ps_code);
- }
+ ID3D11Buffer_Release(cb);
+ ID3D10Blob_Release(ps_code);
release_test_context(&test_context);
}
@@ -458,29 +452,26 @@ static void test_conditionals(void)
if (!init_test_context(&test_context))
return;
- todo_wine ps_code = compile_shader(ps_source, "ps_4_0");
- if (ps_code)
+ ps_code = compile_shader(ps_source, "ps_4_0");
+ draw_quad(&test_context, ps_code);
+ init_readback(&test_context, &rb);
+
+ for (i = 0; i < 200; i += 40)
{
- draw_quad(&test_context, ps_code);
- init_readback(&test_context, &rb);
-
- for (i = 0; i < 200; i += 40)
- {
- v = get_readback_vec4(&rb, i, 0);
- ok(compare_vec4(v, 0.9f, 0.8f, 0.7f, 0.6f, 0),
- "Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n", v->x, v->y, v->z, v->w);
- }
-
- for (i = 240; i < 640; i += 40)
- {
- v = get_readback_vec4(&rb, i, 0);
- ok(compare_vec4(v, 0.1f, 0.2f, 0.3f, 0.4f, 0),
- "Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n", v->x, v->y, v->z, v->w);
- }
-
- release_readback(&test_context, &rb);
- ID3D10Blob_Release(ps_code);
+ v = get_readback_vec4(&rb, i, 0);
+ ok(compare_vec4(v, 0.9f, 0.8f, 0.7f, 0.6f, 0),
+ "Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n", v->x, v->y, v->z, v->w);
}
+
+ for (i = 240; i < 640; i += 40)
+ {
+ v = get_readback_vec4(&rb, i, 0);
+ ok(compare_vec4(v, 0.1f, 0.2f, 0.3f, 0.4f, 0),
+ "Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n", v->x, v->y, v->z, v->w);
+ }
+
+ release_readback(&test_context, &rb);
+ ID3D10Blob_Release(ps_code);
release_test_context(&test_context);
}
@@ -621,7 +612,8 @@ static void test_sampling(void)
winetest_push_context("Test %u", i);
ID3D11DeviceContext_ClearRenderTargetView(test_context.immediate_context, test_context.rtv, red);
- todo_wine ps_code = compile_shader_flags(tests[i], "ps_4_0", D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY);
+ todo_wine_if (i < 3)
+ ps_code = compile_shader_flags(tests[i], "ps_4_0", D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY);
if (ps_code)
{
draw_quad(&test_context, ps_code);
@@ -937,10 +929,12 @@ static void test_reflection(void)
static void check_parameter_desc(const D3D11_SIGNATURE_PARAMETER_DESC *desc,
const D3D11_SIGNATURE_PARAMETER_DESC *expect)
{
- ok(!strcmp(desc->SemanticName, expect->SemanticName), "Got name %s.\n", debugstr_a(desc->SemanticName));
+ todo_wine_if(strcmp(desc->SemanticName, expect->SemanticName))
+ ok(!strcmp(desc->SemanticName, expect->SemanticName), "Got name %s.\n", debugstr_a(desc->SemanticName));
ok(desc->SemanticIndex == expect->SemanticIndex, "Got index %u.\n", desc->SemanticIndex);
ok(desc->Register == expect->Register, "Got register %u.\n", desc->Register);
- ok(desc->SystemValueType == expect->SystemValueType, "Got sysval %u.\n", desc->SystemValueType);
+ todo_wine_if(desc->SystemValueType != expect->SystemValueType)
+ ok(desc->SystemValueType == expect->SystemValueType, "Got sysval %u.\n", desc->SystemValueType);
ok(desc->ComponentType == expect->ComponentType, "Got data type %u.\n", desc->ComponentType);
ok(desc->Mask == expect->Mask, "Got mask %#x.\n", desc->Mask);
todo_wine_if(desc->ReadWriteMask != expect->ReadWriteMask)
@@ -1129,7 +1123,7 @@ static void test_semantic_reflection(void)
{
winetest_push_context("Test %u", i);
- todo_wine code = compile_shader_flags(tests[i].source, tests[i].target,
+ todo_wine_if (i > 5) code = compile_shader_flags(tests[i].source, tests[i].target,
tests[i].legacy ? D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY : 0);
if (!code)
{
@@ -1143,9 +1137,9 @@ static void test_semantic_reflection(void)
hr = reflection->lpVtbl->GetDesc(reflection, &shader_desc);
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
- todo_wine ok(shader_desc.InputParameters == tests[i].input_count,
+ ok(shader_desc.InputParameters == tests[i].input_count,
"Got %u input parameters.\n", shader_desc.InputParameters);
- todo_wine ok(shader_desc.OutputParameters == tests[i].output_count,
+ ok(shader_desc.OutputParameters == tests[i].output_count,
"Got %u output parameters.\n", shader_desc.OutputParameters);
for (j = 0; j < shader_desc.InputParameters; ++j)
diff --git a/dlls/d3dcompiler_43/tests/hlsl_d3d9.c b/dlls/d3dcompiler_43/tests/hlsl_d3d9.c
index 4461a3f869f..cbf32695625 100644
--- a/dlls/d3dcompiler_43/tests/hlsl_d3d9.c
+++ b/dlls/d3dcompiler_43/tests/hlsl_d3d9.c
@@ -454,25 +454,22 @@ static void test_swizzle(void)
for (i = 0; i < ARRAY_SIZE(tests); ++i)
{
- todo_wine ps_code = compile_shader(tests[i].source, "ps_2_0");
- if (ps_code)
+ ps_code = compile_shader(tests[i].source, "ps_2_0");
+ if (i == 0)
{
- if (i == 0)
- {
- hr = pD3DXGetShaderConstantTable(ID3D10Blob_GetBufferPointer(ps_code), &constants);
- ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
- hr = ID3DXConstantTable_SetVector(constants, device, "color", &color);
- ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
- ID3DXConstantTable_Release(constants);
- }
- draw_quad(device, ps_code);
-
- v = get_color_vec4(device, 0, 0);
- ok(compare_vec4(&v, tests[i].color.x, tests[i].color.y, tests[i].color.z, tests[i].color.w, 0),
- "Test %u: Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n", i, v.x, v.y, v.z, v.w);
-
- ID3D10Blob_Release(ps_code);
+ hr = pD3DXGetShaderConstantTable(ID3D10Blob_GetBufferPointer(ps_code), &constants);
+ ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
+ hr = ID3DXConstantTable_SetVector(constants, device, "color", &color);
+ ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
+ ID3DXConstantTable_Release(constants);
}
+ draw_quad(device, ps_code);
+
+ v = get_color_vec4(device, 0, 0);
+ ok(compare_vec4(&v, tests[i].color.x, tests[i].color.y, tests[i].color.z, tests[i].color.w, 0),
+ "Test %u: Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n", i, v.x, v.y, v.z, v.w);
+
+ ID3D10Blob_Release(ps_code);
}
release_test_context(&test_context);
@@ -501,33 +498,30 @@ static void test_math(void)
return;
device = test_context.device;
- todo_wine ps_code = compile_shader(ps_source, "ps_2_0");
- if (ps_code)
- {
- hr = pD3DXGetShaderConstantTable(ID3D10Blob_GetBufferPointer(ps_code), &constants);
- ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
- hr = ID3DXConstantTable_SetFloat(constants, device, "$u", 2.5f);
- ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
- hr = ID3DXConstantTable_SetFloat(constants, device, "$v", 0.3f);
- ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
- hr = ID3DXConstantTable_SetFloat(constants, device, "$w", 0.2f);
- ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
- hr = ID3DXConstantTable_SetFloat(constants, device, "$x", 0.7f);
- ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
- hr = ID3DXConstantTable_SetFloat(constants, device, "$y", 0.1f);
- ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
- hr = ID3DXConstantTable_SetFloat(constants, device, "$z", 1.5f);
- ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
- ID3DXConstantTable_Release(constants);
+ ps_code = compile_shader(ps_source, "ps_2_0");
+ hr = pD3DXGetShaderConstantTable(ID3D10Blob_GetBufferPointer(ps_code), &constants);
+ ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
+ hr = ID3DXConstantTable_SetFloat(constants, device, "$u", 2.5f);
+ ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
+ hr = ID3DXConstantTable_SetFloat(constants, device, "$v", 0.3f);
+ ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
+ hr = ID3DXConstantTable_SetFloat(constants, device, "$w", 0.2f);
+ ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
+ hr = ID3DXConstantTable_SetFloat(constants, device, "$x", 0.7f);
+ ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
+ hr = ID3DXConstantTable_SetFloat(constants, device, "$y", 0.1f);
+ ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
+ hr = ID3DXConstantTable_SetFloat(constants, device, "$z", 1.5f);
+ ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
+ ID3DXConstantTable_Release(constants);
- draw_quad(device, ps_code);
+ draw_quad(device, ps_code);
- v = get_color_vec4(device, 0, 0);
- ok(compare_vec4(&v, -12.43f, 9.833333f, 1.6f, 35.0f, 1),
- "Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n", v.x, v.y, v.z, v.w);
+ v = get_color_vec4(device, 0, 0);
+ ok(compare_vec4(&v, -12.43f, 9.833333f, 1.6f, 35.0f, 1),
+ "Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n", v.x, v.y, v.z, v.w);
- ID3D10Blob_Release(ps_code);
- }
+ ID3D10Blob_Release(ps_code);
release_test_context(&test_context);
}
@@ -559,30 +553,27 @@ static void test_conditionals(void)
return;
device = test_context.device;
- todo_wine ps_code = compile_shader(ps_if_source, "ps_2_0");
- if (ps_code)
+ ps_code = compile_shader(ps_if_source, "ps_2_0");
+ draw_quad(device, ps_code);
+ init_readback(device, &rb);
+
+ for (i = 0; i < 200; i += 40)
{
- draw_quad(device, ps_code);
- init_readback(device, &rb);
-
- for (i = 0; i < 200; i += 40)
- {
- v = get_readback_vec4(&rb, i, 0);
- ok(compare_vec4(v, 0.9f, 0.8f, 0.7f, 0.6f, 0),
- "Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n", v->x, v->y, v->z, v->w);
- }
-
- for (i = 240; i < 640; i += 40)
- {
- v = get_readback_vec4(&rb, i, 0);
- ok(compare_vec4(v, 0.1f, 0.2f, 0.3f, 0.4f, 0),
- "Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n", v->x, v->y, v->z, v->w);
- }
-
- release_readback(&rb);
- ID3D10Blob_Release(ps_code);
+ v = get_readback_vec4(&rb, i, 0);
+ todo_wine ok(compare_vec4(v, 0.9f, 0.8f, 0.7f, 0.6f, 0),
+ "Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n", v->x, v->y, v->z, v->w);
}
+ for (i = 240; i < 640; i += 40)
+ {
+ v = get_readback_vec4(&rb, i, 0);
+ todo_wine ok(compare_vec4(v, 0.1f, 0.2f, 0.3f, 0.4f, 0),
+ "Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n", v->x, v->y, v->z, v->w);
+ }
+
+ release_readback(&rb);
+ ID3D10Blob_Release(ps_code);
+
todo_wine ps_code = compile_shader(ps_ternary_source, "ps_2_0");
if (ps_code)
{
@@ -737,17 +728,14 @@ static void test_comma(void)
if (!init_test_context(&test_context))
return;
- todo_wine ps_code = compile_shader(ps_source, "ps_2_0");
- if (ps_code)
- {
- draw_quad(test_context.device, ps_code);
+ ps_code = compile_shader(ps_source, "ps_2_0");
+ draw_quad(test_context.device, ps_code);
- v = get_color_vec4(test_context.device, 0, 0);
- ok(compare_vec4(&v, 0.6f, 0.7f, 0.8f, 0.9f, 0),
- "Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n", v.x, v.y, v.z, v.w);
+ v = get_color_vec4(test_context.device, 0, 0);
+ ok(compare_vec4(&v, 0.6f, 0.7f, 0.8f, 0.9f, 0),
+ "Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n", v.x, v.y, v.z, v.w);
- ID3D10Blob_Release(ps_code);
- }
+ ID3D10Blob_Release(ps_code);
release_test_context(&test_context);
}
@@ -774,17 +762,14 @@ static void test_return(void)
if (!init_test_context(&test_context))
return;
- todo_wine ps_code = compile_shader(void_source, "ps_2_0");
- if (ps_code)
- {
- draw_quad(test_context.device, ps_code);
+ ps_code = compile_shader(void_source, "ps_2_0");
+ draw_quad(test_context.device, ps_code);
- v = get_color_vec4(test_context.device, 0, 0);
- ok(compare_vec4(&v, 0.1f, 0.2f, 0.3f, 0.4f, 0),
- "Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n", v.x, v.y, v.z, v.w);
+ v = get_color_vec4(test_context.device, 0, 0);
+ todo_wine ok(compare_vec4(&v, 0.1f, 0.2f, 0.3f, 0.4f, 0),
+ "Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n", v.x, v.y, v.z, v.w);
- ID3D10Blob_Release(ps_code);
- }
+ ID3D10Blob_Release(ps_code);
todo_wine ps_code = compile_shader(implicit_conversion_source, "ps_2_0");
if (ps_code)
@@ -948,17 +933,14 @@ static void test_struct_assignment(void)
if (!init_test_context(&test_context))
return;
- todo_wine ps_code = compile_shader(ps_source, "ps_2_0");
- if (ps_code)
- {
- draw_quad(test_context.device, ps_code);
+ ps_code = compile_shader(ps_source, "ps_2_0");
+ draw_quad(test_context.device, ps_code);
- v = get_color_vec4(test_context.device, 0, 0);
- ok(compare_vec4(&v, 0.6f, 0.3f, 0.7f, 0.9f, 1),
- "Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n", v.x, v.y, v.z, v.w);
+ v = get_color_vec4(test_context.device, 0, 0);
+ ok(compare_vec4(&v, 0.6f, 0.3f, 0.7f, 0.9f, 1),
+ "Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n", v.x, v.y, v.z, v.w);
- ID3D10Blob_Release(ps_code);
- }
+ ID3D10Blob_Release(ps_code);
release_test_context(&test_context);
}
@@ -993,22 +975,19 @@ static void test_struct_semantics(void)
if (!init_test_context(&test_context))
return;
- todo_wine ps_code = compile_shader(ps_source, "ps_2_0");
- if (ps_code)
- {
- draw_quad(test_context.device, ps_code);
+ ps_code = compile_shader(ps_source, "ps_2_0");
+ draw_quad(test_context.device, ps_code);
- v = get_color_vec4(test_context.device, 64, 48);
- v.z = v.w = 0.0f;
- todo_wine ok(compare_vec4(&v, 0.1f, 0.1f, 0.0f, 0.0f, 4096),
- "Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n", v.x, v.y, v.z, v.w);
- v = get_color_vec4(test_context.device, 320, 240);
- v.z = v.w = 0.0f;
- todo_wine ok(compare_vec4(&v, 0.5f, 0.5f, 0.0f, 0.0f, 4096),
- "Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n", v.x, v.y, v.z, v.w);
+ v = get_color_vec4(test_context.device, 64, 48);
+ v.z = v.w = 0.0f;
+ ok(compare_vec4(&v, 0.1f, 0.1f, 0.0f, 0.0f, 4096),
+ "Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n", v.x, v.y, v.z, v.w);
+ v = get_color_vec4(test_context.device, 320, 240);
+ v.z = v.w = 0.0f;
+ ok(compare_vec4(&v, 0.5f, 0.5f, 0.0f, 0.0f, 4096),
+ "Got unexpected value {%.8e, %.8e, %.8e, %.8e}.\n", v.x, v.y, v.z, v.w);
- ID3D10Blob_Release(ps_code);
- }
+ ID3D10Blob_Release(ps_code);
release_test_context(&test_context);
}
@@ -1122,7 +1101,7 @@ static void test_samplers(void)
{
hr = IDirect3DDevice9_Clear(test_context.device, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(255, 0, 0), 1.0f, 0);
ok(hr == D3D_OK, "Test %u: Got unexpected hr %#lx.\n", i, hr);
- todo_wine ps_code = compile_shader(tests[i], "ps_2_0");
+ todo_wine_if (i < 3) ps_code = compile_shader(tests[i], "ps_2_0");
if (ps_code)
{
draw_quad(test_context.device, ps_code);
@@ -1434,12 +1413,9 @@ static void test_fail(void)
{
compiled = errors = NULL;
hr = D3DCompile(tests[i], strlen(tests[i]), NULL, NULL, NULL, "test", targets[j], 0, 0, &compiled, &errors);
- todo_wine ok(hr == E_FAIL, "Test %u, target %s: Got unexpected hr %#lx.\n", i, targets[j], hr);
- if (hr == E_FAIL)
- {
- ok(!!errors, "Test %u, target %s, expected non-NULL error blob.\n", i, targets[j]);
- ID3D10Blob_Release(errors);
- }
+ ok(hr == E_FAIL, "Test %u, target %s: Got unexpected hr %#lx.\n", i, targets[j], hr);
+ ok(!!errors, "Test %u, target %s, expected non-NULL error blob.\n", i, targets[j]);
+ ID3D10Blob_Release(errors);
ok(!compiled, "Test %u, target %s, expected no compiled shader blob.\n", i, targets[j]);
}
}
@@ -1634,7 +1610,7 @@ static void test_include(void)
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
ok(!!blob, "Got unexpected blob.\n");
}
- todo_wine_if (i == 1)
+ todo_wine_if (i != 0)
ok(!errors, "Got unexpected errors.\n");
if (blob)
{
@@ -1644,7 +1620,7 @@ static void test_include(void)
#if D3D_COMPILER_VERSION >= 46
hr = tests[i](NULL, D3D_COMPILE_STANDARD_FILE_INCLUDE, &blob, &errors);
- todo_wine_if (i == 0) ok(hr == (i == 0 ? D3DXERR_INVALIDDATA : E_FAIL), "Got unexpected hr %#lx.\n", hr);
+ todo_wine_if (i != 1) ok(hr == (i == 0 ? D3DXERR_INVALIDDATA : E_FAIL), "Got unexpected hr %#lx.\n", hr);
ok(!blob, "Got unexpected blob.\n");
ok(!!errors, "Got unexpected errors.\n");
ID3D10Blob_Release(errors);
@@ -1658,9 +1634,8 @@ static void test_include(void)
{
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
ok(!!blob, "Got unexpected blob.\n");
- }
- todo_wine_if (i == 1)
ok(!errors, "Got unexpected errors.\n");
+ }
if (blob)
{
ID3D10Blob_Release(blob);
@@ -1676,7 +1651,7 @@ static void test_include(void)
hr = D3DCompileFromFile(L"nonexistent", NULL, NULL, "main", "vs_2_0", 0, 0, &blob, &errors);
ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "Got unexpected hr %#lx.\n", hr);
ok(!blob, "Got unexpected blob.\n");
- ok(!errors, "Got unexpected errors.\n");
+ todo_wine ok(!errors, "Got unexpected errors.\n");
hr = D3DCompileFromFile(filename, NULL, NULL, "main", "ps_2_0", 0, 0, &blob, &errors);
ok(hr == E_FAIL, "Got unexpected hr %#lx.\n", hr);
@@ -1689,7 +1664,7 @@ static void test_include(void)
hr = D3DCompileFromFile(filename, NULL, &include.ID3DInclude_iface, "main", "ps_2_0", 0, 0, &blob, &errors);
todo_wine ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
todo_wine ok(!!blob, "Got unexpected blob.\n");
- ok(!errors, "Got unexpected errors.\n");
+ todo_wine ok(!errors, "Got unexpected errors.\n");
if (blob)
{
ID3D10Blob_Release(blob);
@@ -1702,7 +1677,7 @@ static void test_include(void)
hr = D3DCompileFromFile(filename, NULL, D3D_COMPILE_STANDARD_FILE_INCLUDE, "main", "ps_2_0", 0, 0, &blob, &errors);
todo_wine ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
todo_wine ok(!!blob, "Got unexpected blob.\n");
- ok(!errors, "Got unexpected errors.\n");
+ todo_wine ok(!errors, "Got unexpected errors.\n");
if (blob)
{
ID3D10Blob_Release(blob);
@@ -1733,9 +1708,8 @@ static void test_include(void)
{
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
ok(!!blob, "Got unexpected blob.\n");
- }
- todo_wine_if (i == 1)
ok(!errors, "Got unexpected errors.\n");
+ }
if (blob)
{
ID3D10Blob_Release(blob);
@@ -1748,7 +1722,7 @@ static void test_include(void)
hr = D3DCompileFromFile(L"source.ps", NULL, D3D_COMPILE_STANDARD_FILE_INCLUDE, "main", "ps_2_0", 0, 0, &blob, &errors);
todo_wine ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
todo_wine ok(!!blob, "Got unexpected blob.\n");
- ok(!errors, "Got unexpected errors.\n");
+ todo_wine ok(!errors, "Got unexpected errors.\n");
if (blob)
{
ID3D10Blob_Release(blob);
diff --git a/dlls/d3dcompiler_46/Makefile.in b/dlls/d3dcompiler_46/Makefile.in
index 066bd6fdd1c..187535772be 100644
--- a/dlls/d3dcompiler_46/Makefile.in
+++ b/dlls/d3dcompiler_46/Makefile.in
@@ -1,8 +1,9 @@
MODULE = d3dcompiler_46.dll
IMPORTLIB = d3dcompiler_46
-IMPORTS = dxguid uuid
+IMPORTS = wined3d dxguid uuid
EXTRADEFS = -DD3D_COMPILER_VERSION=46
PARENTSRC = ../d3dcompiler_43
+EXTRAINCL = $(VKD3D_PE_CFLAGS)
EXTRADLLFLAGS = -Wb,--prefer-native
diff --git a/dlls/d3dcompiler_47/Makefile.in b/dlls/d3dcompiler_47/Makefile.in
index 379f0aa4b3a..bc6ce091108 100644
--- a/dlls/d3dcompiler_47/Makefile.in
+++ b/dlls/d3dcompiler_47/Makefile.in
@@ -1,8 +1,9 @@
MODULE = d3dcompiler_47.dll
IMPORTLIB = d3dcompiler
-IMPORTS = dxguid uuid
+IMPORTS = wined3d dxguid uuid
EXTRADEFS = -DD3D_COMPILER_VERSION=47
PARENTSRC = ../d3dcompiler_43
+EXTRAINCL = $(VKD3D_PE_CFLAGS)
EXTRADLLFLAGS = -Wb,--prefer-native
--
2.35.1
More information about the wine-devel
mailing list