Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/d3d10core/d3d10core_main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/dlls/d3d10core/d3d10core_main.c b/dlls/d3d10core/d3d10core_main.c index d364be90d6da..5a9a4a211c15 100644 --- a/dlls/d3d10core/d3d10core_main.c +++ b/dlls/d3d10core/d3d10core_main.c @@ -29,11 +29,13 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d10core); HRESULT WINAPI D3D11CoreCreateDevice(IDXGIFactory *factory, IDXGIAdapter *adapter, unsigned int flags, const D3D_FEATURE_LEVEL *feature_levels, unsigned int level_count, ID3D11Device **device);
+HRESULT WINAPI D3D11CoreRegisterLayers(void); + HRESULT WINAPI D3D10CoreRegisterLayers(void) { TRACE("\n");
- return E_NOTIMPL; + return D3D11CoreRegisterLayers(); }
HRESULT WINAPI D3D10CoreCreateDevice(IDXGIFactory *factory, IDXGIAdapter *adapter,
If D3D11CoreRegisterLayers is not found in module.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dxgi/dxgi_main.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/dlls/dxgi/dxgi_main.c b/dlls/dxgi/dxgi_main.c index 83c3f3734a77..006ab3708440 100644 --- a/dlls/dxgi/dxgi_main.c +++ b/dlls/dxgi/dxgi_main.c @@ -106,8 +106,8 @@ static HRESULT register_d3d10core_layers(HMODULE d3d10core)
if (!dxgi_main.d3d10core) { - HRESULT hr; - HRESULT (WINAPI *d3d11core_register_layers)(void); + HRESULT hr = E_FAIL; + HRESULT (WINAPI *register_layers)(void); HMODULE mod; BOOL ret;
@@ -117,8 +117,10 @@ static HRESULT register_d3d10core_layers(HMODULE d3d10core) return E_FAIL; }
- d3d11core_register_layers = (void *)GetProcAddress(mod, "D3D11CoreRegisterLayers"); - hr = d3d11core_register_layers(); + if ((register_layers = (void *)GetProcAddress(mod, "D3D11CoreRegisterLayers")) || + (register_layers = (void *)GetProcAddress(mod, "D3D10CoreRegisterLayers"))) + hr = register_layers(); + if (FAILED(hr)) { ERR("Failed to register d3d11 layers, returning %#x.\n", hr);
Instead of using D3D11CoreCreateDevice.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/d3d10core/Makefile.in | 2 +- dlls/d3d10core/d3d10core_main.c | 22 ++++++++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/dlls/d3d10core/Makefile.in b/dlls/d3d10core/Makefile.in index cf7efb274189..e56e38c188c2 100644 --- a/dlls/d3d10core/Makefile.in +++ b/dlls/d3d10core/Makefile.in @@ -1,6 +1,6 @@ MODULE = d3d10core.dll IMPORTLIB = d3d10core -IMPORTS = d3d11 +IMPORTS = d3d11 dxgi
EXTRADLLFLAGS = -mno-cygwin
diff --git a/dlls/d3d10core/d3d10core_main.c b/dlls/d3d10core/d3d10core_main.c index 5a9a4a211c15..ce3cf7860657 100644 --- a/dlls/d3d10core/d3d10core_main.c +++ b/dlls/d3d10core/d3d10core_main.c @@ -22,12 +22,12 @@ #include "initguid.h"
#define COBJMACROS -#include "d3d11.h" +#include "d3d10.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d10core);
-HRESULT WINAPI D3D11CoreCreateDevice(IDXGIFactory *factory, IDXGIAdapter *adapter, unsigned int flags, - const D3D_FEATURE_LEVEL *feature_levels, unsigned int level_count, ID3D11Device **device); +HRESULT WINAPI DXGID3D10CreateDevice(HMODULE d3d10core, IDXGIFactory *factory, IDXGIAdapter *adapter, + unsigned int flags, const D3D_FEATURE_LEVEL *feature_levels, unsigned int level_count, void **device);
HRESULT WINAPI D3D11CoreRegisterLayers(void);
@@ -41,20 +41,26 @@ HRESULT WINAPI D3D10CoreRegisterLayers(void) HRESULT WINAPI D3D10CoreCreateDevice(IDXGIFactory *factory, IDXGIAdapter *adapter, unsigned int flags, D3D_FEATURE_LEVEL feature_level, ID3D10Device **device) { - ID3D11Device *device11; + IUnknown *dxgi_device; + HMODULE d3d10core; HRESULT hr;
TRACE("factory %p, adapter %p, flags %#x, feature_level %#x, device %p.\n", factory, adapter, flags, feature_level, device);
- if (FAILED(hr = D3D11CoreCreateDevice(factory, adapter, flags, &feature_level, 1, &device11))) + d3d10core = GetModuleHandleA("d3d10core.dll"); + hr = DXGID3D10CreateDevice(d3d10core, factory, adapter, flags, &feature_level, 1, (void **)&dxgi_device); + if (FAILED(hr)) + { + WARN("Failed to create device, returning %#x.\n", hr); return hr; + }
- hr = ID3D11Device_QueryInterface(device11, &IID_ID3D10Device, (void **)device); - ID3D11Device_Release(device11); + hr = IUnknown_QueryInterface(dxgi_device, &IID_ID3D10Device, (void **)device); + IUnknown_Release(dxgi_device); if (FAILED(hr)) { - ERR("Device should implement ID3D10Device, returning E_FAIL.\n"); + ERR("Failed to query ID3D10Device interface, returning E_FAIL.\n"); return E_FAIL; }
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=71824
Your paranoid android.
=== debiant (64 bit WoW report) ===
d3d10core: d3d10core.c:4786: Test failed: Got unexpected CPrimitives count: 3.
UPlay overlay tries to detect the device D3D version by querying this interface first. On D3D11 games, and as we are incorrectly advertising ID3D10Device, it decides to use D3D10 hooks and crashes the game after ~10 minutes.
This is happening with Splinter Cell: Blacklist for instance.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/d3d11/d3d11_main.c | 8 ++++++++ dlls/d3d11/d3d11_private.h | 6 ++++++ dlls/d3d11/device.c | 6 ++++-- dlls/d3d11/tests/d3d11.c | 16 ++++++++-------- 4 files changed, 26 insertions(+), 10 deletions(-)
diff --git a/dlls/d3d11/d3d11_main.c b/dlls/d3d11/d3d11_main.c index a5854a93cc31..65bb14b49d01 100644 --- a/dlls/d3d11/d3d11_main.c +++ b/dlls/d3d11/d3d11_main.c @@ -107,6 +107,7 @@ HRESULT WINAPI D3D11CoreRegisterLayers(void) HRESULT WINAPI D3D11CoreCreateDevice(IDXGIFactory *factory, IDXGIAdapter *adapter, UINT flags, const D3D_FEATURE_LEVEL *feature_levels, UINT levels, ID3D11Device **device) { + struct d3d_device *d3d_device; IUnknown *dxgi_device; HMODULE d3d11; HRESULT hr; @@ -130,6 +131,13 @@ HRESULT WINAPI D3D11CoreCreateDevice(IDXGIFactory *factory, IDXGIAdapter *adapte return E_FAIL; }
+ if (!(d3d_device = impl_from_ID3D11Device(*device))) + { + ERR("Failed to retrieve device impl, returning E_FAIL.\n"); + return E_FAIL; + } + d3d_device->d3d11_only = 1; + return S_OK; }
diff --git a/dlls/d3d11/d3d11_private.h b/dlls/d3d11/d3d11_private.h index 48c76959fae0..8ac2d5285045 100644 --- a/dlls/d3d11/d3d11_private.h +++ b/dlls/d3d11/d3d11_private.h @@ -537,6 +537,7 @@ struct d3d_device LONG refcount;
D3D_FEATURE_LEVEL feature_level; + int d3d11_only;
struct d3d11_immediate_context immediate_context;
@@ -552,6 +553,11 @@ struct d3d_device UINT stencil_ref; };
+static inline struct d3d_device *impl_from_ID3D11Device(ID3D11Device *iface) +{ + return CONTAINING_RECORD((ID3D11Device2 *)iface, struct d3d_device, ID3D11Device2_iface); +} + static inline struct d3d_device *impl_from_ID3D11Device2(ID3D11Device2 *iface) { return CONTAINING_RECORD(iface, struct d3d_device, ID3D11Device2_iface); diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c index 7544bc86f4bc..0be722c0189d 100644 --- a/dlls/d3d11/device.c +++ b/dlls/d3d11/device.c @@ -3881,8 +3881,9 @@ static HRESULT STDMETHODCALLTYPE d3d_device_inner_QueryInterface(IUnknown *iface { *out = &device->ID3D11Device2_iface; } - else if (IsEqualGUID(riid, &IID_ID3D10Device1) - || IsEqualGUID(riid, &IID_ID3D10Device)) + else if (!device->d3d11_only && + (IsEqualGUID(riid, &IID_ID3D10Device1) + || IsEqualGUID(riid, &IID_ID3D10Device))) { *out = &device->ID3D10Device1_iface; } @@ -6229,6 +6230,7 @@ void d3d_device_init(struct d3d_device *device, void *outer_unknown) device->refcount = 1; /* COM aggregation always takes place */ device->outer_unk = outer_unknown; + device->d3d11_only = 0;
d3d11_immediate_context_init(&device->immediate_context, device); ID3D11DeviceContext1_Release(&device->immediate_context.ID3D11DeviceContext1_iface); diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c index 3ae05537a1e7..f4c678217bc1 100644 --- a/dlls/d3d11/tests/d3d11.c +++ b/dlls/d3d11/tests/d3d11.c @@ -2110,8 +2110,8 @@ static void test_device_interfaces(const D3D_FEATURE_LEVEL feature_level) check_interface(device, &IID_IDXGIDevice, TRUE, FALSE); check_interface(device, &IID_IDXGIDevice1, TRUE, FALSE); check_interface(device, &IID_ID3D10Multithread, TRUE, TRUE); /* Not available on all Windows versions. */ - todo_wine check_interface(device, &IID_ID3D10Device, FALSE, FALSE); - todo_wine check_interface(device, &IID_ID3D10Device1, FALSE, FALSE); + check_interface(device, &IID_ID3D10Device, FALSE, FALSE); + check_interface(device, &IID_ID3D10Device1, FALSE, FALSE); check_interface(device, &IID_ID3D11InfoQueue, enable_debug_layer, FALSE);
hr = ID3D11Device_QueryInterface(device, &IID_IDXGIDevice, (void **)&dxgi_device); @@ -2487,7 +2487,7 @@ static void test_texture1d_interfaces(void)
d3d10_device = (ID3D10Device *)0xdeadbeef; ID3D10Texture1D_GetDevice(d3d10_texture, &d3d10_device); - todo_wine ok(!d3d10_device, "Test %u: Got unexpected device pointer %p, expected NULL.\n", i, d3d10_device); + ok(!d3d10_device, "Test %u: Got unexpected device pointer %p, expected NULL.\n", i, d3d10_device); if (d3d10_device) ID3D10Device_Release(d3d10_device);
ID3D10Texture1D_Release(d3d10_texture); @@ -2884,7 +2884,7 @@ static void test_texture2d_interfaces(void)
d3d10_device = (ID3D10Device *)0xdeadbeef; ID3D10Texture2D_GetDevice(d3d10_texture, &d3d10_device); - todo_wine ok(!d3d10_device, "Test %u: Got unexpected device pointer %p, expected NULL.\n", i, d3d10_device); + ok(!d3d10_device, "Test %u: Got unexpected device pointer %p, expected NULL.\n", i, d3d10_device); if (d3d10_device) ID3D10Device_Release(d3d10_device);
ID3D10Texture2D_Release(d3d10_texture); @@ -3143,7 +3143,7 @@ static void test_texture3d_interfaces(void)
d3d10_device = (ID3D10Device *)0xdeadbeef; ID3D10Texture3D_GetDevice(d3d10_texture, &d3d10_device); - todo_wine ok(!d3d10_device, "Test %u: Got unexpected device pointer %p, expected NULL.\n", i, d3d10_device); + ok(!d3d10_device, "Test %u: Got unexpected device pointer %p, expected NULL.\n", i, d3d10_device); if (d3d10_device) ID3D10Device_Release(d3d10_device);
ID3D10Texture3D_Release(d3d10_texture); @@ -3432,7 +3432,7 @@ static void test_create_buffer(void)
d3d10_device = (ID3D10Device *)0xdeadbeef; ID3D10Buffer_GetDevice(d3d10_buffer, &d3d10_device); - todo_wine ok(!d3d10_device, "Test %u: Got unexpected device pointer %p, expected NULL.\n", i, d3d10_device); + ok(!d3d10_device, "Test %u: Got unexpected device pointer %p, expected NULL.\n", i, d3d10_device); if (d3d10_device) ID3D10Device_Release(d3d10_device);
ID3D10Buffer_Release(d3d10_buffer); @@ -6592,8 +6592,8 @@ static void test_device_context_state(void) return; }
- todo_wine check_interface(device, &IID_ID3D10Device, FALSE, FALSE); - todo_wine check_interface(device, &IID_ID3D10Device1, FALSE, FALSE); + check_interface(device, &IID_ID3D10Device, FALSE, FALSE); + check_interface(device, &IID_ID3D10Device1, FALSE, FALSE);
feature_level = ID3D11Device1_GetFeatureLevel(device); ID3D11Device1_GetImmediateContext1(device, &context);
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=71825
Your paranoid android.
=== w1064v1809_he (32 bit report) ===
d3d11: d3d11.c:5775: Test failed: Got unexpected IAVertices count: 0. d3d11.c:5776: Test failed: Got unexpected IAPrimitives count: 0. d3d11.c:5777: Test failed: Got unexpected VSInvocations count: 0. d3d11.c:5780: Test failed: Got unexpected CInvocations count: 0. d3d11.c:5781: Test failed: Got unexpected CPrimitives count: 0.