Signed-off-by: Józef Kucia jkucia@codeweavers.com --- dlls/dxgi/tests/device.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
diff --git a/dlls/dxgi/tests/device.c b/dlls/dxgi/tests/device.c index a102ed89aa6d..daa4f657e0b8 100644 --- a/dlls/dxgi/tests/device.c +++ b/dlls/dxgi/tests/device.c @@ -19,6 +19,7 @@ #include <assert.h> #define COBJMACROS #include "initguid.h" +#include "dxgi1_6.h" #include "d3d11.h" #include "wine/test.h"
@@ -2305,6 +2306,7 @@ static void test_create_factory(void) { IDXGIFactory1 *factory; IUnknown *iface; + ULONG refcount; HRESULT hr;
iface = (void *)0xdeadbeef; @@ -2333,6 +2335,17 @@ static void test_create_factory(void) ok(hr == E_NOINTERFACE, "Got unexpected hr %#x.\n", hr); ok(!iface, "Got unexpected iface %p.\n", iface);
+ iface = NULL; + hr = CreateDXGIFactory(&IID_IDXGIFactory2, (void **)&iface); + todo_wine + ok(hr == S_OK || broken(hr == E_NOINTERFACE) /* Not available on all Windows versions. */, + "Got unexpected hr %#x.\n", hr); + if (SUCCEEDED(hr)) + { + refcount = IUnknown_Release(iface); + ok(!refcount, "Factory has %u references left.\n", refcount); + } + if (!pCreateDXGIFactory1) { win_skip("CreateDXGIFactory1 not available, skipping tests.\n"); @@ -2362,6 +2375,17 @@ static void test_create_factory(void) hr = pCreateDXGIFactory1(&IID_IDXGIFactory1, (void **)&iface); ok(SUCCEEDED(hr), "Failed to create factory with IID_IDXGIFactory1, hr %#x.\n", hr); IUnknown_Release(iface); + + iface = NULL; + hr = CreateDXGIFactory1(&IID_IDXGIFactory2, (void **)&iface); + todo_wine + ok(hr == S_OK || broken(hr == E_NOINTERFACE) /* Not available on all Windows versions. */, + "Got unexpected hr %#x.\n", hr); + if (SUCCEEDED(hr)) + { + refcount = IUnknown_Release(iface); + ok(!refcount, "Factory has %u references left.\n", refcount); + } }
static void test_private_data(void)
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- dlls/d3d10_1/tests/d3d10_1.c | 98 ++++++++++++++++++++------------------------ 1 file changed, 44 insertions(+), 54 deletions(-)
diff --git a/dlls/d3d10_1/tests/d3d10_1.c b/dlls/d3d10_1/tests/d3d10_1.c index e1d6d4c97c28..3e1a099c75f9 100644 --- a/dlls/d3d10_1/tests/d3d10_1.c +++ b/dlls/d3d10_1/tests/d3d10_1.c @@ -68,6 +68,31 @@ static ID3D10Device1 *create_device(const struct device_desc *desc) return NULL; }
+#define check_interface(a, b, c, d) check_interface_(__LINE__, a, b, c, d) +static HRESULT check_interface_(unsigned int line, void *iface, REFIID iid, BOOL supported, BOOL is_broken) +{ + HRESULT hr, expected_hr, broken_hr; + IUnknown *unknown = iface, *out; + + if (supported) + { + expected_hr = S_OK; + broken_hr = E_NOINTERFACE; + } + else + { + expected_hr = E_NOINTERFACE; + broken_hr = S_OK; + } + + hr = IUnknown_QueryInterface(unknown, iid, (void **)&out); + ok_(__FILE__, line)(hr == expected_hr || broken(is_broken && hr == broken_hr), + "Got hr %#x, expected %#x.\n", hr, expected_hr); + if (SUCCEEDED(hr)) + IUnknown_Release(out); + return hr; +} + static void test_create_device(void) { D3D10_FEATURE_LEVEL1 feature_level, supported_feature_level; @@ -265,13 +290,14 @@ static void test_device_interfaces(void) continue; }
- hr = ID3D10Device1_QueryInterface(device, &IID_IUnknown, (void **)&iface); - ok(SUCCEEDED(hr), "Device should implement IUnknown interface, hr %#x.\n", hr); - IUnknown_Release(iface); - - hr = ID3D10Device1_QueryInterface(device, &IID_IDXGIObject, (void **)&iface); - ok(SUCCEEDED(hr), "Device should implement IDXGIObject interface, hr %#x.\n", hr); - IUnknown_Release(iface); + check_interface(device, &IID_IUnknown, TRUE, FALSE); + check_interface(device, &IID_IDXGIObject, TRUE, FALSE); + 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. */ + check_interface(device, &IID_ID3D10Device, TRUE, FALSE); + check_interface(device, &IID_ID3D10InfoQueue, FALSE, FALSE); /* Non-debug mode. */ + check_interface(device, &IID_ID3D11Device, TRUE, TRUE); /* Not available on all Windows versions. */
hr = ID3D10Device1_QueryInterface(device, &IID_IDXGIDevice, (void **)&dxgi_device); ok(SUCCEEDED(hr), "Device should implement IDXGIDevice.\n"); @@ -288,27 +314,6 @@ static void test_device_interfaces(void) IDXGIAdapter_Release(dxgi_adapter); IDXGIDevice_Release(dxgi_device);
- hr = ID3D10Device1_QueryInterface(device, &IID_IDXGIDevice1, (void **)&iface); - ok(SUCCEEDED(hr), "Device should implement IDXGIDevice1.\n"); - IUnknown_Release(iface); - - hr = ID3D10Device1_QueryInterface(device, &IID_ID3D10Multithread, (void **)&iface); - ok(SUCCEEDED(hr) || broken(hr == E_NOINTERFACE) /* Not available on all Windows versions. */, - "Device should implement ID3D10Multithread interface, hr %#x.\n", hr); - if (SUCCEEDED(hr)) IUnknown_Release(iface); - - hr = ID3D10Device1_QueryInterface(device, &IID_ID3D10InfoQueue, (void **)&iface); - ok(hr == E_NOINTERFACE, "Found ID3D10InfoQueue interface in non-debug mode, hr %#x.\n", hr); - - hr = ID3D10Device1_QueryInterface(device, &IID_ID3D10Device, (void **)&iface); - ok(SUCCEEDED(hr), "Device should implement ID3D10Device interface, hr %#x.\n", hr); - IUnknown_Release(iface); - - hr = ID3D10Device1_QueryInterface(device, &IID_ID3D11Device, (void **)&iface); - ok(SUCCEEDED(hr) || broken(hr == E_NOINTERFACE) /* Not available on all Windows versions. */, - "Device should implement ID3D11Device interface, hr %#x.\n", hr); - if (SUCCEEDED(hr)) IUnknown_Release(iface); - refcount = ID3D10Device1_Release(device); ok(!refcount, "Device has %u references left.\n", refcount); } @@ -325,9 +330,8 @@ static void test_device_interfaces(void) continue; }
- hr = ID3D10Device1_QueryInterface(device, &IID_ID3D10InfoQueue, (void **)&iface); - todo_wine ok(hr == S_OK, "Device should implement ID3D10InfoQueue interface, hr %#x.\n", hr); - if (SUCCEEDED(hr)) IUnknown_Release(iface); + todo_wine + check_interface(device, &IID_ID3D10InfoQueue, TRUE, FALSE);
refcount = ID3D10Device1_Release(device); ok(!refcount, "Device has %u references left.\n", refcount); @@ -345,7 +349,6 @@ static void test_create_shader_resource_view(void) ID3D10Device *tmp_device; ID3D10Device1 *device; ID3D10Buffer *buffer; - IUnknown *iface; HRESULT hr;
if (!(device = create_device(NULL))) @@ -387,13 +390,9 @@ static void test_create_shader_resource_view(void) ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount); ID3D10Device_Release(tmp_device);
- hr = ID3D10ShaderResourceView1_QueryInterface(srview, &IID_ID3D10ShaderResourceView, (void **)&iface); - ok(SUCCEEDED(hr), "Shader resource view should implement ID3D10ShaderResourceView.\n"); - IUnknown_Release(iface); - hr = ID3D10ShaderResourceView1_QueryInterface(srview, &IID_ID3D11ShaderResourceView, (void **)&iface); - ok(SUCCEEDED(hr) || broken(hr == E_NOINTERFACE) /* Not available on all Windows versions. */, - "Shader resource view should implement ID3D11ShaderResourceView.\n"); - if (SUCCEEDED(hr)) IUnknown_Release(iface); + check_interface(srview, &IID_ID3D10ShaderResourceView, TRUE, FALSE); + /* Not available on all Windows versions. */ + check_interface(srview, &IID_ID3D11ShaderResourceView, TRUE, TRUE);
ID3D10ShaderResourceView1_Release(srview); ID3D10Buffer_Release(buffer); @@ -424,13 +423,9 @@ static void test_create_shader_resource_view(void) U(srv_desc).Texture2D.MostDetailedMip); ok(U(srv_desc).Texture2D.MipLevels == 10, "Got unexpected MipLevels %u.\n", U(srv_desc).Texture2D.MipLevels);
- hr = ID3D10ShaderResourceView1_QueryInterface(srview, &IID_ID3D10ShaderResourceView, (void **)&iface); - ok(SUCCEEDED(hr), "Shader resource view should implement ID3D10ShaderResourceView.\n"); - IUnknown_Release(iface); - hr = ID3D10ShaderResourceView1_QueryInterface(srview, &IID_ID3D11ShaderResourceView, (void **)&iface); - ok(SUCCEEDED(hr) || broken(hr == E_NOINTERFACE) /* Not available on all Windows versions. */, - "Shader resource view should implement ID3D11ShaderResourceView.\n"); - if (SUCCEEDED(hr)) IUnknown_Release(iface); + check_interface(srview, &IID_ID3D10ShaderResourceView, TRUE, FALSE); + /* Not available on all Windows versions. */ + check_interface(srview, &IID_ID3D11ShaderResourceView, TRUE, TRUE);
ID3D10ShaderResourceView1_Release(srview); ID3D10Texture2D_Release(texture); @@ -536,7 +531,6 @@ static void test_create_blend_state(void) ID3D10Device1 *device; ID3D10Device *tmp; unsigned int i, j; - IUnknown *iface; HRESULT hr;
if (!(device = create_device(NULL))) @@ -609,13 +603,9 @@ static void test_create_blend_state(void) obtained_desc.RenderTarget[0].RenderTargetWriteMask, i); }
- hr = ID3D10BlendState1_QueryInterface(blend_state1, &IID_ID3D10BlendState, (void **)&iface); - ok(SUCCEEDED(hr), "Blend state should implement ID3D10BlendState.\n"); - IUnknown_Release(iface); - hr = ID3D10BlendState1_QueryInterface(blend_state1, &IID_ID3D11BlendState, (void **)&iface); - ok(SUCCEEDED(hr) || broken(hr == E_NOINTERFACE) /* Not available on all Windows versions. */, - "Blend state should implement ID3D11BlendState.\n"); - if (SUCCEEDED(hr)) IUnknown_Release(iface); + check_interface(blend_state1, &IID_ID3D10BlendState, TRUE, FALSE); + /* Not available on all Windows versions. */ + check_interface(blend_state1, &IID_ID3D11BlendState, TRUE, TRUE);
refcount = ID3D10BlendState1_Release(blend_state1); ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
Signed-off-by: Józef Kucia jkucia@codeweavers.com ---
For D3D12.
We may consider adding a registry key to disable newer DXGI interface if they cause a lot of problems.
--- dlls/dxgi/adapter.c | 6 +- dlls/dxgi/device.c | 2 +- dlls/dxgi/dxgi_private.h | 5 +- dlls/dxgi/factory.c | 165 ++++++++++++++++++++++++++++++++++++++--------- dlls/dxgi/tests/device.c | 2 - 5 files changed, 141 insertions(+), 39 deletions(-)
diff --git a/dlls/dxgi/adapter.c b/dlls/dxgi/adapter.c index 7564d37d32b7..f5b70fc221d3 100644 --- a/dlls/dxgi/adapter.c +++ b/dlls/dxgi/adapter.c @@ -69,7 +69,7 @@ static ULONG STDMETHODCALLTYPE dxgi_adapter_Release(IDXGIAdapter1 *iface) if (!refcount) { wined3d_private_store_cleanup(&adapter->private_store); - IDXGIFactory1_Release(&adapter->factory->IDXGIFactory1_iface); + IDXGIFactory2_Release(&adapter->factory->IDXGIFactory2_iface); HeapFree(GetProcessHeap(), 0, adapter); }
@@ -112,7 +112,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_adapter_GetParent(IDXGIAdapter1 *iface, RE
TRACE("iface %p, iid %s, parent %p.\n", iface, debugstr_guid(iid), parent);
- return IDXGIFactory1_QueryInterface(&adapter->factory->IDXGIFactory1_iface, iid, parent); + return IDXGIFactory2_QueryInterface(&adapter->factory->IDXGIFactory2_iface, iid, parent); }
static HRESULT STDMETHODCALLTYPE dxgi_adapter_EnumOutputs(IDXGIAdapter1 *iface, @@ -273,7 +273,7 @@ static void dxgi_adapter_init(struct dxgi_adapter *adapter, struct dxgi_factory wined3d_private_store_init(&adapter->private_store); adapter->ordinal = ordinal; adapter->factory = factory; - IDXGIFactory1_AddRef(&adapter->factory->IDXGIFactory1_iface); + IDXGIFactory2_AddRef(&adapter->factory->IDXGIFactory2_iface); }
HRESULT dxgi_adapter_create(struct dxgi_factory *factory, UINT ordinal, struct dxgi_adapter **adapter) diff --git a/dlls/dxgi/device.c b/dlls/dxgi/device.c index 9e62e25b01f3..eb6877fa0a34 100644 --- a/dlls/dxgi/device.c +++ b/dlls/dxgi/device.c @@ -374,7 +374,7 @@ HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *l void *layer_base; HRESULT hr;
- if (!(dxgi_factory = unsafe_impl_from_IDXGIFactory1((IDXGIFactory1 *)factory))) + if (!(dxgi_factory = unsafe_impl_from_IDXGIFactory2((IDXGIFactory2 *)factory))) { WARN("This is not the factory we're looking for.\n"); return E_FAIL; diff --git a/dlls/dxgi/dxgi_private.h b/dlls/dxgi/dxgi_private.h index 34bb6fc73402..b960fa21b824 100644 --- a/dlls/dxgi/dxgi_private.h +++ b/dlls/dxgi/dxgi_private.h @@ -34,6 +34,7 @@ #ifdef DXGI_INIT_GUID #include "initguid.h" #endif +#include "dxgi1_6.h" #include "wine/wined3d.h" #include "wine/winedxgi.h"
@@ -103,7 +104,7 @@ HRESULT dxgi_set_private_data_interface(struct wined3d_private_store *store, /* IDXGIFactory */ struct dxgi_factory { - IDXGIFactory1 IDXGIFactory1_iface; + IDXGIFactory2 IDXGIFactory2_iface; LONG refcount; struct wined3d_private_store private_store; struct wined3d *wined3d; @@ -113,7 +114,7 @@ struct dxgi_factory
HRESULT dxgi_factory_create(REFIID riid, void **factory, BOOL extended) DECLSPEC_HIDDEN; HWND dxgi_factory_get_device_window(struct dxgi_factory *factory) DECLSPEC_HIDDEN; -struct dxgi_factory *unsafe_impl_from_IDXGIFactory1(IDXGIFactory1 *iface) DECLSPEC_HIDDEN; +struct dxgi_factory *unsafe_impl_from_IDXGIFactory2(IDXGIFactory2 *iface) DECLSPEC_HIDDEN;
/* IDXGIDevice */ struct dxgi_device diff --git a/dlls/dxgi/factory.c b/dlls/dxgi/factory.c index d54eea9cad92..106efb5124ee 100644 --- a/dlls/dxgi/factory.c +++ b/dlls/dxgi/factory.c @@ -24,18 +24,19 @@
WINE_DEFAULT_DEBUG_CHANNEL(dxgi);
-static inline struct dxgi_factory *impl_from_IDXGIFactory1(IDXGIFactory1 *iface) +static inline struct dxgi_factory *impl_from_IDXGIFactory2(IDXGIFactory2 *iface) { - return CONTAINING_RECORD(iface, struct dxgi_factory, IDXGIFactory1_iface); + return CONTAINING_RECORD(iface, struct dxgi_factory, IDXGIFactory2_iface); }
-static HRESULT STDMETHODCALLTYPE dxgi_factory_QueryInterface(IDXGIFactory1 *iface, REFIID iid, void **out) +static HRESULT STDMETHODCALLTYPE dxgi_factory_QueryInterface(IDXGIFactory2 *iface, REFIID iid, void **out) { - struct dxgi_factory *factory = impl_from_IDXGIFactory1(iface); + struct dxgi_factory *factory = impl_from_IDXGIFactory2(iface);
TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
- if ((factory->extended && IsEqualGUID(iid, &IID_IDXGIFactory1)) + if (IsEqualGUID(iid, &IID_IDXGIFactory2) + || (factory->extended && IsEqualGUID(iid, &IID_IDXGIFactory1)) || IsEqualGUID(iid, &IID_IDXGIFactory) || IsEqualGUID(iid, &IID_IDXGIObject) || IsEqualGUID(iid, &IID_IUnknown)) @@ -51,9 +52,9 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_QueryInterface(IDXGIFactory1 *ifac return E_NOINTERFACE; }
-static ULONG STDMETHODCALLTYPE dxgi_factory_AddRef(IDXGIFactory1 *iface) +static ULONG STDMETHODCALLTYPE dxgi_factory_AddRef(IDXGIFactory2 *iface) { - struct dxgi_factory *factory = impl_from_IDXGIFactory1(iface); + struct dxgi_factory *factory = impl_from_IDXGIFactory2(iface); ULONG refcount = InterlockedIncrement(&factory->refcount);
TRACE("%p increasing refcount to %u.\n", iface, refcount); @@ -61,9 +62,9 @@ static ULONG STDMETHODCALLTYPE dxgi_factory_AddRef(IDXGIFactory1 *iface) return refcount; }
-static ULONG STDMETHODCALLTYPE dxgi_factory_Release(IDXGIFactory1 *iface) +static ULONG STDMETHODCALLTYPE dxgi_factory_Release(IDXGIFactory2 *iface) { - struct dxgi_factory *factory = impl_from_IDXGIFactory1(iface); + struct dxgi_factory *factory = impl_from_IDXGIFactory2(iface); ULONG refcount = InterlockedDecrement(&factory->refcount);
TRACE("%p decreasing refcount to %u.\n", iface, refcount); @@ -83,37 +84,37 @@ static ULONG STDMETHODCALLTYPE dxgi_factory_Release(IDXGIFactory1 *iface) return refcount; }
-static HRESULT STDMETHODCALLTYPE dxgi_factory_SetPrivateData(IDXGIFactory1 *iface, +static HRESULT STDMETHODCALLTYPE dxgi_factory_SetPrivateData(IDXGIFactory2 *iface, REFGUID guid, UINT data_size, const void *data) { - struct dxgi_factory *factory = impl_from_IDXGIFactory1(iface); + struct dxgi_factory *factory = impl_from_IDXGIFactory2(iface);
TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface, debugstr_guid(guid), data_size, data);
return dxgi_set_private_data(&factory->private_store, guid, data_size, data); }
-static HRESULT STDMETHODCALLTYPE dxgi_factory_SetPrivateDataInterface(IDXGIFactory1 *iface, +static HRESULT STDMETHODCALLTYPE dxgi_factory_SetPrivateDataInterface(IDXGIFactory2 *iface, REFGUID guid, const IUnknown *object) { - struct dxgi_factory *factory = impl_from_IDXGIFactory1(iface); + struct dxgi_factory *factory = impl_from_IDXGIFactory2(iface);
TRACE("iface %p, guid %s, object %p.\n", iface, debugstr_guid(guid), object);
return dxgi_set_private_data_interface(&factory->private_store, guid, object); }
-static HRESULT STDMETHODCALLTYPE dxgi_factory_GetPrivateData(IDXGIFactory1 *iface, +static HRESULT STDMETHODCALLTYPE dxgi_factory_GetPrivateData(IDXGIFactory2 *iface, REFGUID guid, UINT *data_size, void *data) { - struct dxgi_factory *factory = impl_from_IDXGIFactory1(iface); + struct dxgi_factory *factory = impl_from_IDXGIFactory2(iface);
TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface, debugstr_guid(guid), data_size, data);
return dxgi_get_private_data(&factory->private_store, guid, data_size, data); }
-static HRESULT STDMETHODCALLTYPE dxgi_factory_GetParent(IDXGIFactory1 *iface, REFIID iid, void **parent) +static HRESULT STDMETHODCALLTYPE dxgi_factory_GetParent(IDXGIFactory2 *iface, REFIID iid, void **parent) { WARN("iface %p, iid %s, parent %p.\n", iface, debugstr_guid(iid), parent);
@@ -122,10 +123,10 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_GetParent(IDXGIFactory1 *iface, RE return E_NOINTERFACE; }
-static HRESULT STDMETHODCALLTYPE dxgi_factory_EnumAdapters1(IDXGIFactory1 *iface, +static HRESULT STDMETHODCALLTYPE dxgi_factory_EnumAdapters1(IDXGIFactory2 *iface, UINT adapter_idx, IDXGIAdapter1 **adapter) { - struct dxgi_factory *factory = impl_from_IDXGIFactory1(iface); + struct dxgi_factory *factory = impl_from_IDXGIFactory2(iface); struct dxgi_adapter *adapter_object; UINT adapter_count; HRESULT hr; @@ -158,7 +159,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_EnumAdapters1(IDXGIFactory1 *iface return S_OK; }
-static HRESULT STDMETHODCALLTYPE dxgi_factory_EnumAdapters(IDXGIFactory1 *iface, +static HRESULT STDMETHODCALLTYPE dxgi_factory_EnumAdapters(IDXGIFactory2 *iface, UINT adapter_idx, IDXGIAdapter **adapter) { TRACE("iface %p, adapter_idx %u, adapter %p.\n", iface, adapter_idx, adapter); @@ -166,21 +167,21 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_EnumAdapters(IDXGIFactory1 *iface, return dxgi_factory_EnumAdapters1(iface, adapter_idx, (IDXGIAdapter1 **)adapter); }
-static HRESULT STDMETHODCALLTYPE dxgi_factory_MakeWindowAssociation(IDXGIFactory1 *iface, HWND window, UINT flags) +static HRESULT STDMETHODCALLTYPE dxgi_factory_MakeWindowAssociation(IDXGIFactory2 *iface, HWND window, UINT flags) { FIXME("iface %p, window %p, flags %#x stub!\n", iface, window, flags);
return S_OK; }
-static HRESULT STDMETHODCALLTYPE dxgi_factory_GetWindowAssociation(IDXGIFactory1 *iface, HWND *window) +static HRESULT STDMETHODCALLTYPE dxgi_factory_GetWindowAssociation(IDXGIFactory2 *iface, HWND *window) { FIXME("iface %p, window %p stub!\n", iface, window);
return E_NOTIMPL; }
-static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChain(IDXGIFactory1 *iface, +static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChain(IDXGIFactory2 *iface, IUnknown *device, DXGI_SWAP_CHAIN_DESC *desc, IDXGISwapChain **swapchain) { struct wined3d_swapchain *wined3d_swapchain; @@ -258,7 +259,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChain(IDXGIFactory1 *ifa return S_OK; }
-static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSoftwareAdapter(IDXGIFactory1 *iface, +static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSoftwareAdapter(IDXGIFactory2 *iface, HMODULE swrast, IDXGIAdapter **adapter) { FIXME("iface %p, swrast %p, adapter %p stub!\n", iface, swrast, adapter); @@ -266,14 +267,104 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSoftwareAdapter(IDXGIFactory return E_NOTIMPL; }
-static BOOL STDMETHODCALLTYPE dxgi_factory_IsCurrent(IDXGIFactory1 *iface) +static BOOL STDMETHODCALLTYPE dxgi_factory_IsCurrent(IDXGIFactory2 *iface) { FIXME("iface %p stub!\n", iface);
return TRUE; }
-static const struct IDXGIFactory1Vtbl dxgi_factory_vtbl = +static BOOL STDMETHODCALLTYPE dxgi_factory_IsWindowedStereoEnabled(IDXGIFactory2 *iface) +{ + FIXME("iface %p stub!\n", iface); + + return FALSE; +} + +static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChainForHwnd(IDXGIFactory2 *iface, + IUnknown *device, HWND window, const DXGI_SWAP_CHAIN_DESC1 *swapchain_desc, + const DXGI_SWAP_CHAIN_FULLSCREEN_DESC *fullscreen_desc, + IDXGIOutput *output, IDXGISwapChain1 **swapchain) +{ + FIXME("iface %p, device %p, window %p, swapchain_desc %p, fullscreen_desc %p, " + "output %p, swapchain %p stub!\n", + iface, device, window, swapchain_desc, fullscreen_desc, output, swapchain); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChainForCoreWindow(IDXGIFactory2 *iface, + IUnknown *device, IUnknown *window, const DXGI_SWAP_CHAIN_DESC1 *desc, + IDXGIOutput *output, IDXGISwapChain1 **swapchain) +{ + FIXME("iface %p, device %p, window %p, desc %p, output %p, swapchain %p stub!\n", + iface, device, window, desc, output, swapchain); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE dxgi_factory_GetSharedResourceAdapterLuid(IDXGIFactory2 *iface, + HANDLE resource, LUID *luid) +{ + FIXME("iface %p, resource %p, luid %p stub!\n", iface, resource, luid); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE dxgi_factory_RegisterOcclusionStatusWindow(IDXGIFactory2 *iface, + HWND window, UINT message, DWORD *cookie) +{ + FIXME("iface %p, window %p, message %#x, cookie %p stub!\n", + iface, window, message, cookie); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE dxgi_factory_RegisterStereoStatusEvent(IDXGIFactory2 *iface, + HANDLE event, DWORD *cookie) +{ + FIXME("iface %p, event %p, cookie %p stub!\n", iface, event, cookie); + + return E_NOTIMPL; +} + +static void STDMETHODCALLTYPE dxgi_factory_UnregisterStereoStatus(IDXGIFactory2 *iface, DWORD cookie) +{ + FIXME("iface %p, cookie %#x stub!n", iface, cookie); +} + +static HRESULT STDMETHODCALLTYPE dxgi_factory_RegisterStereoStatusWindow(IDXGIFactory2 *iface, + HWND window, UINT message, DWORD *cookie) +{ + FIXME("iface %p, window %p, message %#x, cookie %p stub!\n", + iface, window, message, cookie); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE dxgi_factory_RegisterOcclusionStatusEvent(IDXGIFactory2 *iface, + HANDLE event, DWORD *cookie) +{ + FIXME("iface %p, event %p, cookie %p stub!\n", iface, event, cookie); + + return E_NOTIMPL; +} + +static void STDMETHODCALLTYPE dxgi_factory_UnregisterOcclusionStatus(IDXGIFactory2 *iface, DWORD cookie) +{ + FIXME("iface %p, cookie %#x stub!\n", iface, cookie); +} + +static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChainForComposition(IDXGIFactory2 *iface, + IUnknown *device, const DXGI_SWAP_CHAIN_DESC1 *desc, IDXGIOutput *output, IDXGISwapChain1 **swapchain) +{ + FIXME("iface %p, device %p, desc %p, output %p, swapchain %p stub!\n", + iface, device, desc, output, swapchain); + + return E_NOTIMPL; +} + +static const struct IDXGIFactory2Vtbl dxgi_factory_vtbl = { dxgi_factory_QueryInterface, dxgi_factory_AddRef, @@ -287,21 +378,34 @@ static const struct IDXGIFactory1Vtbl dxgi_factory_vtbl = dxgi_factory_GetWindowAssociation, dxgi_factory_CreateSwapChain, dxgi_factory_CreateSoftwareAdapter, + /* IDXGIFactory1 methods */ dxgi_factory_EnumAdapters1, dxgi_factory_IsCurrent, + /* IDXGIFactory2 methods */ + dxgi_factory_IsWindowedStereoEnabled, + dxgi_factory_CreateSwapChainForHwnd, + dxgi_factory_CreateSwapChainForCoreWindow, + dxgi_factory_GetSharedResourceAdapterLuid, + dxgi_factory_RegisterOcclusionStatusWindow, + dxgi_factory_RegisterStereoStatusEvent, + dxgi_factory_UnregisterStereoStatus, + dxgi_factory_RegisterStereoStatusWindow, + dxgi_factory_RegisterOcclusionStatusEvent, + dxgi_factory_UnregisterOcclusionStatus, + dxgi_factory_CreateSwapChainForComposition, };
-struct dxgi_factory *unsafe_impl_from_IDXGIFactory1(IDXGIFactory1 *iface) +struct dxgi_factory *unsafe_impl_from_IDXGIFactory2(IDXGIFactory2 *iface) { if (!iface) return NULL; assert(iface->lpVtbl == &dxgi_factory_vtbl); - return CONTAINING_RECORD(iface, struct dxgi_factory, IDXGIFactory1_iface); + return CONTAINING_RECORD(iface, struct dxgi_factory, IDXGIFactory2_iface); }
static HRESULT dxgi_factory_init(struct dxgi_factory *factory, BOOL extended) { - factory->IDXGIFactory1_iface.lpVtbl = &dxgi_factory_vtbl; + factory->IDXGIFactory2_iface.lpVtbl = &dxgi_factory_vtbl; factory->refcount = 1; wined3d_private_store_init(&factory->private_store);
@@ -336,9 +440,8 @@ HRESULT dxgi_factory_create(REFIID riid, void **factory, BOOL extended)
TRACE("Created factory %p.\n", object);
- hr = IDXGIFactory1_QueryInterface(&object->IDXGIFactory1_iface, riid, factory); - IDXGIFactory1_Release(&object->IDXGIFactory1_iface); - + hr = IDXGIFactory2_QueryInterface(&object->IDXGIFactory2_iface, riid, factory); + IDXGIFactory2_Release(&object->IDXGIFactory2_iface); return hr; }
diff --git a/dlls/dxgi/tests/device.c b/dlls/dxgi/tests/device.c index daa4f657e0b8..e76c8fe0a932 100644 --- a/dlls/dxgi/tests/device.c +++ b/dlls/dxgi/tests/device.c @@ -2337,7 +2337,6 @@ static void test_create_factory(void)
iface = NULL; hr = CreateDXGIFactory(&IID_IDXGIFactory2, (void **)&iface); - todo_wine ok(hr == S_OK || broken(hr == E_NOINTERFACE) /* Not available on all Windows versions. */, "Got unexpected hr %#x.\n", hr); if (SUCCEEDED(hr)) @@ -2378,7 +2377,6 @@ static void test_create_factory(void)
iface = NULL; hr = CreateDXGIFactory1(&IID_IDXGIFactory2, (void **)&iface); - todo_wine ok(hr == S_OK || broken(hr == E_NOINTERFACE) /* Not available on all Windows versions. */, "Got unexpected hr %#x.\n", hr); if (SUCCEEDED(hr))
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- dlls/d3d10_1/tests/d3d10_1.c | 4 +- dlls/d3d11/tests/d3d11.c | 2 + dlls/dxgi/dxgi_private.h | 2 +- dlls/dxgi/swapchain.c | 238 +++++++++++++++++++++++++++++++++---------- dlls/dxgi/tests/device.c | 16 ++- 5 files changed, 207 insertions(+), 55 deletions(-)
diff --git a/dlls/d3d10_1/tests/d3d10_1.c b/dlls/d3d10_1/tests/d3d10_1.c index 3e1a099c75f9..47c7c86380b5 100644 --- a/dlls/d3d10_1/tests/d3d10_1.c +++ b/dlls/d3d10_1/tests/d3d10_1.c @@ -19,7 +19,7 @@
#define COBJMACROS #include "initguid.h" -#include "d3d11.h" +#include "d3d11_1.h" #include "wine/test.h"
static const D3D10_FEATURE_LEVEL1 d3d10_feature_levels[] = @@ -164,6 +164,8 @@ static void test_create_device(void) supported_feature_level, D3D10_1_SDK_VERSION, &swapchain_desc, &swapchain, &device); ok(SUCCEEDED(hr), "D3D10CreateDeviceAndSwapChain1 failed %#x.\n", hr);
+ check_interface(swapchain, &IID_IDXGISwapChain1, TRUE, FALSE); + memset(&obtained_desc, 0, sizeof(obtained_desc)); hr = IDXGISwapChain_GetDesc(swapchain, &obtained_desc); ok(SUCCEEDED(hr), "GetDesc failed %#x.\n", hr); diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c index 74c0488f068a..dca2515d0ec7 100644 --- a/dlls/d3d11/tests/d3d11.c +++ b/dlls/d3d11/tests/d3d11.c @@ -1523,6 +1523,8 @@ static void test_create_device(void) &swapchain_desc, &swapchain, &device, NULL, NULL); ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+ check_interface(swapchain, &IID_IDXGISwapChain1, TRUE, FALSE); + memset(&obtained_desc, 0, sizeof(obtained_desc)); hr = IDXGISwapChain_GetDesc(swapchain, &obtained_desc); ok(SUCCEEDED(hr), "GetDesc failed %#x.\n", hr); diff --git a/dlls/dxgi/dxgi_private.h b/dlls/dxgi/dxgi_private.h index b960fa21b824..8b0924941199 100644 --- a/dlls/dxgi/dxgi_private.h +++ b/dlls/dxgi/dxgi_private.h @@ -159,7 +159,7 @@ struct dxgi_adapter *unsafe_impl_from_IDXGIAdapter1(IDXGIAdapter1 *iface) DECLSP /* IDXGISwapChain */ struct dxgi_swapchain { - IDXGISwapChain IDXGISwapChain_iface; + IDXGISwapChain1 IDXGISwapChain1_iface; LONG refcount; struct wined3d_private_store private_store; struct wined3d_swapchain *wined3d_swapchain; diff --git a/dlls/dxgi/swapchain.c b/dlls/dxgi/swapchain.c index 2b61327f0d38..eca68c3e5e35 100644 --- a/dlls/dxgi/swapchain.c +++ b/dlls/dxgi/swapchain.c @@ -24,21 +24,22 @@
WINE_DEFAULT_DEBUG_CHANNEL(dxgi);
-static inline struct dxgi_swapchain *impl_from_IDXGISwapChain(IDXGISwapChain *iface) +static inline struct dxgi_swapchain *impl_from_IDXGISwapChain1(IDXGISwapChain1 *iface) { - return CONTAINING_RECORD(iface, struct dxgi_swapchain, IDXGISwapChain_iface); + return CONTAINING_RECORD(iface, struct dxgi_swapchain, IDXGISwapChain1_iface); }
/* IUnknown methods */
-static HRESULT STDMETHODCALLTYPE dxgi_swapchain_QueryInterface(IDXGISwapChain *iface, REFIID riid, void **object) +static HRESULT STDMETHODCALLTYPE dxgi_swapchain_QueryInterface(IDXGISwapChain1 *iface, REFIID riid, void **object) { TRACE("iface %p, riid %s, object %p\n", iface, debugstr_guid(riid), object);
if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IDXGIObject) || IsEqualGUID(riid, &IID_IDXGIDeviceSubObject) - || IsEqualGUID(riid, &IID_IDXGISwapChain)) + || IsEqualGUID(riid, &IID_IDXGISwapChain) + || IsEqualGUID(riid, &IID_IDXGISwapChain1)) { IUnknown_AddRef(iface); *object = iface; @@ -51,9 +52,9 @@ static HRESULT STDMETHODCALLTYPE dxgi_swapchain_QueryInterface(IDXGISwapChain *i return E_NOINTERFACE; }
-static ULONG STDMETHODCALLTYPE dxgi_swapchain_AddRef(IDXGISwapChain *iface) +static ULONG STDMETHODCALLTYPE dxgi_swapchain_AddRef(IDXGISwapChain1 *iface) { - struct dxgi_swapchain *This = impl_from_IDXGISwapChain(iface); + struct dxgi_swapchain *This = impl_from_IDXGISwapChain1(iface); ULONG refcount = InterlockedIncrement(&This->refcount);
TRACE("%p increasing refcount to %u\n", This, refcount); @@ -68,9 +69,9 @@ static ULONG STDMETHODCALLTYPE dxgi_swapchain_AddRef(IDXGISwapChain *iface) return refcount; }
-static ULONG STDMETHODCALLTYPE dxgi_swapchain_Release(IDXGISwapChain *iface) +static ULONG STDMETHODCALLTYPE dxgi_swapchain_Release(IDXGISwapChain1 *iface) { - struct dxgi_swapchain *swapchain = impl_from_IDXGISwapChain(iface); + struct dxgi_swapchain *swapchain = impl_from_IDXGISwapChain1(iface); ULONG refcount = InterlockedDecrement(&swapchain->refcount);
TRACE("%p decreasing refcount to %u.\n", swapchain, refcount); @@ -97,39 +98,39 @@ static ULONG STDMETHODCALLTYPE dxgi_swapchain_Release(IDXGISwapChain *iface)
/* IDXGIObject methods */
-static HRESULT STDMETHODCALLTYPE dxgi_swapchain_SetPrivateData(IDXGISwapChain *iface, +static HRESULT STDMETHODCALLTYPE dxgi_swapchain_SetPrivateData(IDXGISwapChain1 *iface, REFGUID guid, UINT data_size, const void *data) { - struct dxgi_swapchain *swapchain = impl_from_IDXGISwapChain(iface); + struct dxgi_swapchain *swapchain = impl_from_IDXGISwapChain1(iface);
TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface, debugstr_guid(guid), data_size, data);
return dxgi_set_private_data(&swapchain->private_store, guid, data_size, data); }
-static HRESULT STDMETHODCALLTYPE dxgi_swapchain_SetPrivateDataInterface(IDXGISwapChain *iface, +static HRESULT STDMETHODCALLTYPE dxgi_swapchain_SetPrivateDataInterface(IDXGISwapChain1 *iface, REFGUID guid, const IUnknown *object) { - struct dxgi_swapchain *swapchain = impl_from_IDXGISwapChain(iface); + struct dxgi_swapchain *swapchain = impl_from_IDXGISwapChain1(iface);
TRACE("iface %p, guid %s, object %p.\n", iface, debugstr_guid(guid), object);
return dxgi_set_private_data_interface(&swapchain->private_store, guid, object); }
-static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetPrivateData(IDXGISwapChain *iface, +static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetPrivateData(IDXGISwapChain1 *iface, REFGUID guid, UINT *data_size, void *data) { - struct dxgi_swapchain *swapchain = impl_from_IDXGISwapChain(iface); + struct dxgi_swapchain *swapchain = impl_from_IDXGISwapChain1(iface);
TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface, debugstr_guid(guid), data_size, data);
return dxgi_get_private_data(&swapchain->private_store, guid, data_size, data); }
-static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetParent(IDXGISwapChain *iface, REFIID riid, void **parent) +static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetParent(IDXGISwapChain1 *iface, REFIID riid, void **parent) { - struct dxgi_swapchain *swapchain = impl_from_IDXGISwapChain(iface); + struct dxgi_swapchain *swapchain = impl_from_IDXGISwapChain1(iface);
TRACE("iface %p, riid %s, parent %p.\n", iface, debugstr_guid(riid), parent);
@@ -145,9 +146,9 @@ static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetParent(IDXGISwapChain *iface,
/* IDXGIDeviceSubObject methods */
-static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetDevice(IDXGISwapChain *iface, REFIID riid, void **device) +static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetDevice(IDXGISwapChain1 *iface, REFIID riid, void **device) { - struct dxgi_swapchain *swapchain = impl_from_IDXGISwapChain(iface); + struct dxgi_swapchain *swapchain = impl_from_IDXGISwapChain1(iface);
TRACE("iface %p, riid %s, device %p.\n", iface, debugstr_guid(riid), device);
@@ -161,29 +162,21 @@ static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetDevice(IDXGISwapChain *iface, return IWineDXGIDevice_QueryInterface(swapchain->device, riid, device); }
-/* IDXGISwapChain methods */ +/* IDXGISwapChain1 methods */
-static HRESULT STDMETHODCALLTYPE dxgi_swapchain_Present(IDXGISwapChain *iface, UINT sync_interval, UINT flags) +static HRESULT STDMETHODCALLTYPE dxgi_swapchain_Present(IDXGISwapChain1 *iface, UINT sync_interval, UINT flags) { - struct dxgi_swapchain *This = impl_from_IDXGISwapChain(iface); - HRESULT hr; - - TRACE("iface %p, sync_interval %u, flags %#x\n", iface, sync_interval, flags); - - if (sync_interval) FIXME("Unimplemented sync interval %u\n", sync_interval); - if (flags) FIXME("Unimplemented flags %#x\n", flags); + struct dxgi_swapchain *swapchain = impl_from_IDXGISwapChain1(iface);
- wined3d_mutex_lock(); - hr = wined3d_swapchain_present(This->wined3d_swapchain, NULL, NULL, NULL, 0); - wined3d_mutex_unlock(); + TRACE("iface %p, sync_interval %u, flags %#x.\n", iface, sync_interval, flags);
- return hr; + return IDXGISwapChain1_Present1(&swapchain->IDXGISwapChain1_iface, sync_interval, flags, NULL); }
-static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetBuffer(IDXGISwapChain *iface, +static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetBuffer(IDXGISwapChain1 *iface, UINT buffer_idx, REFIID riid, void **surface) { - struct dxgi_swapchain *This = impl_from_IDXGISwapChain(iface); + struct dxgi_swapchain *This = impl_from_IDXGISwapChain1(iface); struct wined3d_texture *texture; IUnknown *parent; HRESULT hr; @@ -206,10 +199,10 @@ static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetBuffer(IDXGISwapChain *iface, return hr; }
-static HRESULT STDMETHODCALLTYPE DECLSPEC_HOTPATCH dxgi_swapchain_SetFullscreenState(IDXGISwapChain *iface, +static HRESULT STDMETHODCALLTYPE DECLSPEC_HOTPATCH dxgi_swapchain_SetFullscreenState(IDXGISwapChain1 *iface, BOOL fullscreen, IDXGIOutput *target) { - struct dxgi_swapchain *swapchain = impl_from_IDXGISwapChain(iface); + struct dxgi_swapchain *swapchain = impl_from_IDXGISwapChain1(iface); struct wined3d_swapchain_desc swapchain_desc; HRESULT hr;
@@ -227,7 +220,7 @@ static HRESULT STDMETHODCALLTYPE DECLSPEC_HOTPATCH dxgi_swapchain_SetFullscreenS { IDXGIOutput_AddRef(target); } - else if (FAILED(hr = IDXGISwapChain_GetContainingOutput(iface, &target))) + else if (FAILED(hr = IDXGISwapChain1_GetContainingOutput(iface, &target))) { WARN("Failed to get default target output for swapchain, hr %#x.\n", hr); return hr; @@ -255,10 +248,10 @@ static HRESULT STDMETHODCALLTYPE DECLSPEC_HOTPATCH dxgi_swapchain_SetFullscreenS return hr; }
-static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetFullscreenState(IDXGISwapChain *iface, +static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetFullscreenState(IDXGISwapChain1 *iface, BOOL *fullscreen, IDXGIOutput **target) { - struct dxgi_swapchain *swapchain = impl_from_IDXGISwapChain(iface); + struct dxgi_swapchain *swapchain = impl_from_IDXGISwapChain1(iface);
TRACE("iface %p, fullscreen %p, target %p.\n", iface, fullscreen, target);
@@ -275,15 +268,18 @@ static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetFullscreenState(IDXGISwapChai return S_OK; }
-static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetDesc(IDXGISwapChain *iface, DXGI_SWAP_CHAIN_DESC *desc) +static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetDesc(IDXGISwapChain1 *iface, DXGI_SWAP_CHAIN_DESC *desc) { - struct dxgi_swapchain *swapchain = impl_from_IDXGISwapChain(iface); + struct dxgi_swapchain *swapchain = impl_from_IDXGISwapChain1(iface); struct wined3d_swapchain_desc wined3d_desc;
FIXME("iface %p, desc %p partial stub!\n", iface, desc);
- if (desc == NULL) + if (!desc) + { + WARN("Invalid pointer.\n"); return E_INVALIDARG; + }
wined3d_mutex_lock(); wined3d_swapchain_get_desc(swapchain->wined3d_swapchain, &wined3d_desc); @@ -308,10 +304,10 @@ static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetDesc(IDXGISwapChain *iface, D return S_OK; }
-static HRESULT STDMETHODCALLTYPE dxgi_swapchain_ResizeBuffers(IDXGISwapChain *iface, +static HRESULT STDMETHODCALLTYPE dxgi_swapchain_ResizeBuffers(IDXGISwapChain1 *iface, UINT buffer_count, UINT width, UINT height, DXGI_FORMAT format, UINT flags) { - struct dxgi_swapchain *swapchain = impl_from_IDXGISwapChain(iface); + struct dxgi_swapchain *swapchain = impl_from_IDXGISwapChain1(iface); struct wined3d_swapchain_desc wined3d_desc; struct wined3d_texture *texture; IUnknown *parent; @@ -346,17 +342,20 @@ static HRESULT STDMETHODCALLTYPE dxgi_swapchain_ResizeBuffers(IDXGISwapChain *if return hr; }
-static HRESULT STDMETHODCALLTYPE dxgi_swapchain_ResizeTarget(IDXGISwapChain *iface, +static HRESULT STDMETHODCALLTYPE dxgi_swapchain_ResizeTarget(IDXGISwapChain1 *iface, const DXGI_MODE_DESC *target_mode_desc) { - struct dxgi_swapchain *swapchain = impl_from_IDXGISwapChain(iface); + struct dxgi_swapchain *swapchain = impl_from_IDXGISwapChain1(iface); struct wined3d_display_mode mode; HRESULT hr;
TRACE("iface %p, target_mode_desc %p.\n", iface, target_mode_desc);
if (!target_mode_desc) + { + WARN("Invalid pointer.\n"); return DXGI_ERROR_INVALID_CALL; + }
TRACE("Mode: %s.\n", debug_dxgi_mode(target_mode_desc));
@@ -372,9 +371,9 @@ static HRESULT STDMETHODCALLTYPE dxgi_swapchain_ResizeTarget(IDXGISwapChain *ifa return hr; }
-static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetContainingOutput(IDXGISwapChain *iface, IDXGIOutput **output) +static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetContainingOutput(IDXGISwapChain1 *iface, IDXGIOutput **output) { - struct dxgi_swapchain *swapchain = impl_from_IDXGISwapChain(iface); + struct dxgi_swapchain *swapchain = impl_from_IDXGISwapChain1(iface); IDXGIAdapter *adapter; IDXGIDevice *device; HRESULT hr; @@ -409,21 +408,144 @@ static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetContainingOutput(IDXGISwapCha return hr; }
-static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetFrameStatistics(IDXGISwapChain *iface, DXGI_FRAME_STATISTICS *stats) +static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetFrameStatistics(IDXGISwapChain1 *iface, + DXGI_FRAME_STATISTICS *stats) { FIXME("iface %p, stats %p stub!\n", iface, stats);
return E_NOTIMPL; }
-static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetLastPresentCount(IDXGISwapChain *iface, UINT *last_present_count) +static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetLastPresentCount(IDXGISwapChain1 *iface, + UINT *last_present_count) { FIXME("iface %p, last_present_count %p stub!\n", iface, last_present_count);
return E_NOTIMPL; }
-static const struct IDXGISwapChainVtbl dxgi_swapchain_vtbl = +/* IDXGISwapChain1 methods */ + +static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetDesc1(IDXGISwapChain1 *iface, DXGI_SWAP_CHAIN_DESC1 *desc) +{ + FIXME("iface %p, desc %p stub!\n", iface, desc); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetFullscreenDesc(IDXGISwapChain1 *iface, + DXGI_SWAP_CHAIN_FULLSCREEN_DESC *desc) +{ + FIXME("iface %p, desc %p stub!\n", iface, desc); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetHwnd(IDXGISwapChain1 *iface, HWND *hwnd) +{ + struct dxgi_swapchain *swapchain = impl_from_IDXGISwapChain1(iface); + struct wined3d_swapchain_desc wined3d_desc; + + TRACE("iface %p, hwnd %p.\n", iface, hwnd); + + if (!hwnd) + { + WARN("Invalid pointer.\n"); + return DXGI_ERROR_INVALID_CALL; + } + + wined3d_mutex_lock(); + wined3d_swapchain_get_desc(swapchain->wined3d_swapchain, &wined3d_desc); + wined3d_mutex_unlock(); + + *hwnd = wined3d_desc.device_window; + return S_OK; +} + +static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetCoreWindow(IDXGISwapChain1 *iface, + REFIID iid, void **core_window) +{ + FIXME("iface %p, iid %s, core_window %p stub!\n", iface, debugstr_guid(iid), core_window); + + if (core_window) + *core_window = NULL; + + return DXGI_ERROR_INVALID_CALL; +} + +static HRESULT STDMETHODCALLTYPE dxgi_swapchain_Present1(IDXGISwapChain1 *iface, + UINT sync_interval, UINT flags, const DXGI_PRESENT_PARAMETERS *present_parameters) +{ + struct dxgi_swapchain *swapchain = impl_from_IDXGISwapChain1(iface); + HRESULT hr; + + TRACE("iface %p, sync_interval %u, flags %#x, present_parameters %p.\n", + iface, sync_interval, flags, present_parameters); + + if (sync_interval) + FIXME("Unimplemented sync interval %u.\n", sync_interval); + if (flags) + FIXME("Unimplemented flags %#x.\n", flags); + if (present_parameters) + FIXME("Ignored present parameters %p.\n", present_parameters); + + wined3d_mutex_lock(); + hr = wined3d_swapchain_present(swapchain->wined3d_swapchain, NULL, NULL, NULL, 0); + wined3d_mutex_unlock(); + + return hr; +} + +static BOOL STDMETHODCALLTYPE dxgi_swapchain_IsTemporaryMonoSupported(IDXGISwapChain1 *iface) +{ + FIXME("iface %p stub!\n", iface); + + return FALSE; +} + +static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetRestrictToOutput(IDXGISwapChain1 *iface, IDXGIOutput **output) +{ + FIXME("iface %p, output %p stub!\n", iface, output); + + if (!output) + { + WARN("Invalid pointer.\n"); + return E_INVALIDARG; + } + + *output = NULL; + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE dxgi_swapchain_SetBackgroundColor(IDXGISwapChain1 *iface, const DXGI_RGBA *color) +{ + FIXME("iface %p, color %p stub!\n", iface, color); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetBackgroundColor(IDXGISwapChain1 *iface, DXGI_RGBA *color) +{ + FIXME("iface %p, color %p stub!\n", iface, color); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE dxgi_swapchain_SetRotation(IDXGISwapChain1 *iface, DXGI_MODE_ROTATION rotation) +{ + FIXME("iface %p, rotation %#x stub!\n", iface, rotation); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetRotation(IDXGISwapChain1 *iface, DXGI_MODE_ROTATION *rotation) +{ + FIXME("iface %p, rotation %p stub!\n", iface, rotation); + + return E_NOTIMPL; +} + +static const struct IDXGISwapChain1Vtbl dxgi_swapchain_vtbl = { /* IUnknown methods */ dxgi_swapchain_QueryInterface, @@ -447,6 +569,18 @@ static const struct IDXGISwapChainVtbl dxgi_swapchain_vtbl = dxgi_swapchain_GetContainingOutput, dxgi_swapchain_GetFrameStatistics, dxgi_swapchain_GetLastPresentCount, + /* IDXGISwapChain1 methods */ + dxgi_swapchain_GetDesc1, + dxgi_swapchain_GetFullscreenDesc, + dxgi_swapchain_GetHwnd, + dxgi_swapchain_GetCoreWindow, + dxgi_swapchain_Present1, + dxgi_swapchain_IsTemporaryMonoSupported, + dxgi_swapchain_GetRestrictToOutput, + dxgi_swapchain_SetBackgroundColor, + dxgi_swapchain_GetBackgroundColor, + dxgi_swapchain_SetRotation, + dxgi_swapchain_GetRotation, };
static void STDMETHODCALLTYPE dxgi_swapchain_wined3d_object_released(void *parent) @@ -488,7 +622,7 @@ HRESULT dxgi_swapchain_init(struct dxgi_swapchain *swapchain, struct dxgi_device swapchain->factory = NULL; }
- swapchain->IDXGISwapChain_iface.lpVtbl = &dxgi_swapchain_vtbl; + swapchain->IDXGISwapChain1_iface.lpVtbl = &dxgi_swapchain_vtbl; swapchain->refcount = 1; wined3d_mutex_lock(); wined3d_private_store_init(&swapchain->private_store); @@ -517,7 +651,7 @@ HRESULT dxgi_swapchain_init(struct dxgi_swapchain *swapchain, struct dxgi_device goto cleanup; }
- if (FAILED(hr = IDXGISwapChain_GetContainingOutput(&swapchain->IDXGISwapChain_iface, + if (FAILED(hr = IDXGISwapChain1_GetContainingOutput(&swapchain->IDXGISwapChain1_iface, &swapchain->target))) { WARN("Failed to get target output for fullscreen swapchain, hr %#x.\n", hr); diff --git a/dlls/dxgi/tests/device.c b/dlls/dxgi/tests/device.c index e76c8fe0a932..0cba72a2b2d9 100644 --- a/dlls/dxgi/tests/device.c +++ b/dlls/dxgi/tests/device.c @@ -871,6 +871,7 @@ static void test_create_swapchain(void) IDXGIDevice *device, *bgra_device; ULONG refcount, expected_refcount; IUnknown *obj, *obj2, *parent; + IDXGISwapChain1 *swapchain1; RECT *expected_client_rect; IDXGISwapChain *swapchain; IDXGISurface1 *surface; @@ -878,6 +879,7 @@ static void test_create_swapchain(void) IDXGIFactory *factory; IDXGIOutput *target; BOOL fullscreen; + HWND window; HRESULT hr;
const struct refresh_rates refresh_list[] = @@ -955,7 +957,19 @@ static void test_create_swapchain(void) refcount = IUnknown_Release(parent); todo_wine ok(refcount == 4, "Got unexpected refcount %u.\n", refcount);
- IDXGISwapChain_Release(swapchain); + hr = IDXGISwapChain_QueryInterface(swapchain, &IID_IDXGISwapChain1, (void **)&swapchain1); + ok(hr == S_OK || broken(hr == E_NOINTERFACE) /* Not available on all Windows versions. */, + "Failed to query IDXGISwapChain1 interface, hr %#x.\n", hr); + if (SUCCEEDED(hr)) + { + hr = IDXGISwapChain1_GetHwnd(swapchain1, &window); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + ok(window == creation_desc.OutputWindow, "Got unexpected window %p.\n", window); + IDXGISwapChain1_Release(swapchain1); + } + + refcount = IDXGISwapChain_Release(swapchain); + ok(!refcount, "Swapchain has %u references left.\n", refcount);
refcount = get_refcount((IUnknown *)factory); ok(refcount == 2, "Got unexpected refcount %u.\n", refcount);
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- dlls/dxgi/factory.c | 151 ++++++++++++++++++++++++++++++----------------- dlls/dxgi/tests/device.c | 8 ++- 2 files changed, 105 insertions(+), 54 deletions(-)
diff --git a/dlls/dxgi/factory.c b/dlls/dxgi/factory.c index 106efb5124ee..1d699f5552fa 100644 --- a/dlls/dxgi/factory.c +++ b/dlls/dxgi/factory.c @@ -184,15 +184,90 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_GetWindowAssociation(IDXGIFactory2 static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChain(IDXGIFactory2 *iface, IUnknown *device, DXGI_SWAP_CHAIN_DESC *desc, IDXGISwapChain **swapchain) { + struct dxgi_factory *factory = impl_from_IDXGIFactory2(iface); + DXGI_SWAP_CHAIN_FULLSCREEN_DESC fullscreen_desc; + DXGI_SWAP_CHAIN_DESC1 swapchain_desc; + + TRACE("iface %p, device %p, desc %p, swapchain %p.\n", iface, device, desc, swapchain); + + if (!desc) + { + WARN("Invalid pointer.\n"); + return DXGI_ERROR_INVALID_CALL; + } + + swapchain_desc.Width = desc->BufferDesc.Width; + swapchain_desc.Height = desc->BufferDesc.Height; + swapchain_desc.Format = desc->BufferDesc.Format; + swapchain_desc.Stereo = FALSE; + swapchain_desc.SampleDesc = desc->SampleDesc; + swapchain_desc.BufferUsage = desc->BufferUsage; + swapchain_desc.BufferCount = desc->BufferCount; + swapchain_desc.Scaling = DXGI_SCALING_STRETCH; + swapchain_desc.SwapEffect = desc->SwapEffect; + swapchain_desc.AlphaMode = DXGI_ALPHA_MODE_IGNORE; + swapchain_desc.Flags = desc->Flags; + + fullscreen_desc.RefreshRate = desc->BufferDesc.RefreshRate; + fullscreen_desc.ScanlineOrdering = desc->BufferDesc.ScanlineOrdering; + fullscreen_desc.Scaling = desc->BufferDesc.Scaling; + fullscreen_desc.Windowed = desc->Windowed; + + return IDXGIFactory2_CreateSwapChainForHwnd(&factory->IDXGIFactory2_iface, + device, desc->OutputWindow, &swapchain_desc, &fullscreen_desc, NULL, + (IDXGISwapChain1 **)swapchain); +} + +static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSoftwareAdapter(IDXGIFactory2 *iface, + HMODULE swrast, IDXGIAdapter **adapter) +{ + FIXME("iface %p, swrast %p, adapter %p stub!\n", iface, swrast, adapter); + + return E_NOTIMPL; +} + +static BOOL STDMETHODCALLTYPE dxgi_factory_IsCurrent(IDXGIFactory2 *iface) +{ + FIXME("iface %p stub!\n", iface); + + return TRUE; +} + +static BOOL STDMETHODCALLTYPE dxgi_factory_IsWindowedStereoEnabled(IDXGIFactory2 *iface) +{ + FIXME("iface %p stub!\n", iface); + + return FALSE; +} + +static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChainForHwnd(IDXGIFactory2 *iface, + IUnknown *device, HWND window, const DXGI_SWAP_CHAIN_DESC1 *swapchain_desc, + const DXGI_SWAP_CHAIN_FULLSCREEN_DESC *fullscreen_desc, + IDXGIOutput *output, IDXGISwapChain1 **swapchain) +{ struct wined3d_swapchain *wined3d_swapchain; struct wined3d_swapchain_desc wined3d_desc; unsigned int min_buffer_count; IWineDXGIDevice *dxgi_device; HRESULT hr;
- FIXME("iface %p, device %p, desc %p, swapchain %p partial stub!\n", iface, device, desc, swapchain); + FIXME("iface %p, device %p, window %p, swapchain_desc %p, fullscreen_desc %p, " + "output %p, swapchain %p partial stub!\n", + iface, device, window, swapchain_desc, fullscreen_desc, output, swapchain);
- switch (desc->SwapEffect) + if (!device || !swapchain_desc || !swapchain) + { + WARN("Invalid pointer.\n"); + return DXGI_ERROR_INVALID_CALL; + } + + if (swapchain_desc->Stereo) + { + FIXME("Stereo swapchains are not supported.\n"); + return DXGI_ERROR_UNSUPPORTED; + } + + switch (swapchain_desc->SwapEffect) { case DXGI_SWAP_EFFECT_DISCARD: case DXGI_SWAP_EFFECT_SEQUENTIAL: @@ -205,42 +280,46 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChain(IDXGIFactory2 *ifa break;
default: - WARN("Invalid swap effect %u used, returning DXGI_ERROR_INVALID_CALL.\n", desc->SwapEffect); + WARN("Invalid swap effect %u used.\n", swapchain_desc->SwapEffect); return DXGI_ERROR_INVALID_CALL; }
- if (desc->BufferCount < min_buffer_count || desc->BufferCount > 16) + if (swapchain_desc->BufferCount < min_buffer_count || swapchain_desc->BufferCount > 16) { - WARN("BufferCount is %u, returning DXGI_ERROR_INVALID_CALL.\n", desc->BufferCount); + WARN("BufferCount is %u.\n", swapchain_desc->BufferCount); return DXGI_ERROR_INVALID_CALL; } - if (!desc->OutputWindow) + if (!window) { FIXME("No output window, should use factory output window.\n"); }
- hr = IUnknown_QueryInterface(device, &IID_IWineDXGIDevice, (void **)&dxgi_device); - if (FAILED(hr)) + if (FAILED(hr = IUnknown_QueryInterface(device, &IID_IWineDXGIDevice, (void **)&dxgi_device))) { ERR("This is not the device we're looking for\n"); return hr; }
- FIXME("Ignoring SwapEffect %#x.\n", desc->SwapEffect); - - wined3d_desc.backbuffer_width = desc->BufferDesc.Width; - wined3d_desc.backbuffer_height = desc->BufferDesc.Height; - wined3d_desc.backbuffer_format = wined3dformat_from_dxgi_format(desc->BufferDesc.Format); - wined3d_desc.backbuffer_count = desc->BufferCount; + if (swapchain_desc->Scaling != DXGI_SCALING_STRETCH) + FIXME("Ignoring scaling %#x.\n", swapchain_desc->Scaling); + if (swapchain_desc->SwapEffect) + FIXME("Ignoring swap effect %#x.\n", swapchain_desc->SwapEffect); + if (swapchain_desc->AlphaMode != DXGI_ALPHA_MODE_IGNORE) + FIXME("Ignoring alpha mode %#x.\n", swapchain_desc->AlphaMode); + + wined3d_desc.backbuffer_width = swapchain_desc->Width; + wined3d_desc.backbuffer_height = swapchain_desc->Height; + wined3d_desc.backbuffer_format = wined3dformat_from_dxgi_format(swapchain_desc->Format); + wined3d_desc.backbuffer_count = swapchain_desc->BufferCount; wined3d_sample_desc_from_dxgi(&wined3d_desc.multisample_type, - &wined3d_desc.multisample_quality, &desc->SampleDesc); + &wined3d_desc.multisample_quality, &swapchain_desc->SampleDesc); wined3d_desc.swap_effect = WINED3D_SWAP_EFFECT_DISCARD; - wined3d_desc.device_window = desc->OutputWindow; - wined3d_desc.windowed = desc->Windowed; + wined3d_desc.device_window = window; + wined3d_desc.windowed = fullscreen_desc ? fullscreen_desc->Windowed : TRUE; wined3d_desc.enable_auto_depth_stencil = FALSE; wined3d_desc.auto_depth_stencil_format = 0; - wined3d_desc.flags = wined3d_swapchain_flags_from_dxgi(desc->Flags); - wined3d_desc.refresh_rate = dxgi_rational_to_uint(&desc->BufferDesc.RefreshRate); + wined3d_desc.flags = wined3d_swapchain_flags_from_dxgi(swapchain_desc->Flags); + wined3d_desc.refresh_rate = fullscreen_desc ? dxgi_rational_to_uint(&fullscreen_desc->RefreshRate) : 0; wined3d_desc.swap_interval = WINED3DPRESENT_INTERVAL_DEFAULT; wined3d_desc.auto_restore_display_mode = TRUE;
@@ -259,40 +338,6 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChain(IDXGIFactory2 *ifa return S_OK; }
-static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSoftwareAdapter(IDXGIFactory2 *iface, - HMODULE swrast, IDXGIAdapter **adapter) -{ - FIXME("iface %p, swrast %p, adapter %p stub!\n", iface, swrast, adapter); - - return E_NOTIMPL; -} - -static BOOL STDMETHODCALLTYPE dxgi_factory_IsCurrent(IDXGIFactory2 *iface) -{ - FIXME("iface %p stub!\n", iface); - - return TRUE; -} - -static BOOL STDMETHODCALLTYPE dxgi_factory_IsWindowedStereoEnabled(IDXGIFactory2 *iface) -{ - FIXME("iface %p stub!\n", iface); - - return FALSE; -} - -static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChainForHwnd(IDXGIFactory2 *iface, - IUnknown *device, HWND window, const DXGI_SWAP_CHAIN_DESC1 *swapchain_desc, - const DXGI_SWAP_CHAIN_FULLSCREEN_DESC *fullscreen_desc, - IDXGIOutput *output, IDXGISwapChain1 **swapchain) -{ - FIXME("iface %p, device %p, window %p, swapchain_desc %p, fullscreen_desc %p, " - "output %p, swapchain %p stub!\n", - iface, device, window, swapchain_desc, fullscreen_desc, output, swapchain); - - return E_NOTIMPL; -} - static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChainForCoreWindow(IDXGIFactory2 *iface, IUnknown *device, IUnknown *window, const DXGI_SWAP_CHAIN_DESC1 *desc, IDXGIOutput *output, IDXGISwapChain1 **swapchain) diff --git a/dlls/dxgi/tests/device.c b/dlls/dxgi/tests/device.c index 0cba72a2b2d9..c98df5e8d065 100644 --- a/dlls/dxgi/tests/device.c +++ b/dlls/dxgi/tests/device.c @@ -932,8 +932,14 @@ static void test_create_swapchain(void) refcount = get_refcount((IUnknown *)device); ok(refcount == 2, "Got unexpected refcount %u.\n", refcount);
+ hr = IDXGIFactory_CreateSwapChain(factory, NULL, &creation_desc, &swapchain); + ok(hr == DXGI_ERROR_INVALID_CALL, "Got unexpected hr %#x.\n", hr); + hr = IDXGIFactory_CreateSwapChain(factory, obj, NULL, &swapchain); + ok(hr == DXGI_ERROR_INVALID_CALL, "Got unexpected hr %#x.\n", hr); + hr = IDXGIFactory_CreateSwapChain(factory, obj, &creation_desc, NULL); + ok(hr == DXGI_ERROR_INVALID_CALL, "Got unexpected hr %#x.\n", hr); hr = IDXGIFactory_CreateSwapChain(factory, obj, &creation_desc, &swapchain); - ok(SUCCEEDED(hr), "CreateSwapChain failed, hr %#x.\n", hr); + ok(SUCCEEDED(hr), "Failed to create swapchain, hr %#x.\n", hr);
refcount = get_refcount((IUnknown *)adapter); ok(refcount == expected_refcount, "Got refcount %u, expected %u.\n", refcount, expected_refcount);
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- dlls/dxgi/adapter.c | 6 +-- dlls/dxgi/device.c | 2 +- dlls/dxgi/dxgi_private.h | 4 +- dlls/dxgi/factory.c | 117 ++++++++++++++++++++++++++++++----------------- 4 files changed, 80 insertions(+), 49 deletions(-)
diff --git a/dlls/dxgi/adapter.c b/dlls/dxgi/adapter.c index f5b70fc221d3..5440f2a64517 100644 --- a/dlls/dxgi/adapter.c +++ b/dlls/dxgi/adapter.c @@ -69,7 +69,7 @@ static ULONG STDMETHODCALLTYPE dxgi_adapter_Release(IDXGIAdapter1 *iface) if (!refcount) { wined3d_private_store_cleanup(&adapter->private_store); - IDXGIFactory2_Release(&adapter->factory->IDXGIFactory2_iface); + IDXGIFactory4_Release(&adapter->factory->IDXGIFactory4_iface); HeapFree(GetProcessHeap(), 0, adapter); }
@@ -112,7 +112,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_adapter_GetParent(IDXGIAdapter1 *iface, RE
TRACE("iface %p, iid %s, parent %p.\n", iface, debugstr_guid(iid), parent);
- return IDXGIFactory2_QueryInterface(&adapter->factory->IDXGIFactory2_iface, iid, parent); + return IDXGIFactory4_QueryInterface(&adapter->factory->IDXGIFactory4_iface, iid, parent); }
static HRESULT STDMETHODCALLTYPE dxgi_adapter_EnumOutputs(IDXGIAdapter1 *iface, @@ -273,7 +273,7 @@ static void dxgi_adapter_init(struct dxgi_adapter *adapter, struct dxgi_factory wined3d_private_store_init(&adapter->private_store); adapter->ordinal = ordinal; adapter->factory = factory; - IDXGIFactory2_AddRef(&adapter->factory->IDXGIFactory2_iface); + IDXGIFactory4_AddRef(&adapter->factory->IDXGIFactory4_iface); }
HRESULT dxgi_adapter_create(struct dxgi_factory *factory, UINT ordinal, struct dxgi_adapter **adapter) diff --git a/dlls/dxgi/device.c b/dlls/dxgi/device.c index eb6877fa0a34..2539ca272606 100644 --- a/dlls/dxgi/device.c +++ b/dlls/dxgi/device.c @@ -374,7 +374,7 @@ HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *l void *layer_base; HRESULT hr;
- if (!(dxgi_factory = unsafe_impl_from_IDXGIFactory2((IDXGIFactory2 *)factory))) + if (!(dxgi_factory = unsafe_impl_from_IDXGIFactory4((IDXGIFactory4 *)factory))) { WARN("This is not the factory we're looking for.\n"); return E_FAIL; diff --git a/dlls/dxgi/dxgi_private.h b/dlls/dxgi/dxgi_private.h index 8b0924941199..eb11b7f65299 100644 --- a/dlls/dxgi/dxgi_private.h +++ b/dlls/dxgi/dxgi_private.h @@ -104,7 +104,7 @@ HRESULT dxgi_set_private_data_interface(struct wined3d_private_store *store, /* IDXGIFactory */ struct dxgi_factory { - IDXGIFactory2 IDXGIFactory2_iface; + IDXGIFactory4 IDXGIFactory4_iface; LONG refcount; struct wined3d_private_store private_store; struct wined3d *wined3d; @@ -114,7 +114,7 @@ struct dxgi_factory
HRESULT dxgi_factory_create(REFIID riid, void **factory, BOOL extended) DECLSPEC_HIDDEN; HWND dxgi_factory_get_device_window(struct dxgi_factory *factory) DECLSPEC_HIDDEN; -struct dxgi_factory *unsafe_impl_from_IDXGIFactory2(IDXGIFactory2 *iface) DECLSPEC_HIDDEN; +struct dxgi_factory *unsafe_impl_from_IDXGIFactory4(IDXGIFactory4 *iface) DECLSPEC_HIDDEN;
/* IDXGIDevice */ struct dxgi_device diff --git a/dlls/dxgi/factory.c b/dlls/dxgi/factory.c index 1d699f5552fa..1c9284b343de 100644 --- a/dlls/dxgi/factory.c +++ b/dlls/dxgi/factory.c @@ -24,18 +24,20 @@
WINE_DEFAULT_DEBUG_CHANNEL(dxgi);
-static inline struct dxgi_factory *impl_from_IDXGIFactory2(IDXGIFactory2 *iface) +static inline struct dxgi_factory *impl_from_IDXGIFactory4(IDXGIFactory4 *iface) { - return CONTAINING_RECORD(iface, struct dxgi_factory, IDXGIFactory2_iface); + return CONTAINING_RECORD(iface, struct dxgi_factory, IDXGIFactory4_iface); }
-static HRESULT STDMETHODCALLTYPE dxgi_factory_QueryInterface(IDXGIFactory2 *iface, REFIID iid, void **out) +static HRESULT STDMETHODCALLTYPE dxgi_factory_QueryInterface(IDXGIFactory4 *iface, REFIID iid, void **out) { - struct dxgi_factory *factory = impl_from_IDXGIFactory2(iface); + struct dxgi_factory *factory = impl_from_IDXGIFactory4(iface);
TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
- if (IsEqualGUID(iid, &IID_IDXGIFactory2) + if (IsEqualGUID(iid, &IID_IDXGIFactory4) + || IsEqualGUID(iid, &IID_IDXGIFactory3) + || IsEqualGUID(iid, &IID_IDXGIFactory2) || (factory->extended && IsEqualGUID(iid, &IID_IDXGIFactory1)) || IsEqualGUID(iid, &IID_IDXGIFactory) || IsEqualGUID(iid, &IID_IDXGIObject) @@ -52,9 +54,9 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_QueryInterface(IDXGIFactory2 *ifac return E_NOINTERFACE; }
-static ULONG STDMETHODCALLTYPE dxgi_factory_AddRef(IDXGIFactory2 *iface) +static ULONG STDMETHODCALLTYPE dxgi_factory_AddRef(IDXGIFactory4 *iface) { - struct dxgi_factory *factory = impl_from_IDXGIFactory2(iface); + struct dxgi_factory *factory = impl_from_IDXGIFactory4(iface); ULONG refcount = InterlockedIncrement(&factory->refcount);
TRACE("%p increasing refcount to %u.\n", iface, refcount); @@ -62,9 +64,9 @@ static ULONG STDMETHODCALLTYPE dxgi_factory_AddRef(IDXGIFactory2 *iface) return refcount; }
-static ULONG STDMETHODCALLTYPE dxgi_factory_Release(IDXGIFactory2 *iface) +static ULONG STDMETHODCALLTYPE dxgi_factory_Release(IDXGIFactory4 *iface) { - struct dxgi_factory *factory = impl_from_IDXGIFactory2(iface); + struct dxgi_factory *factory = impl_from_IDXGIFactory4(iface); ULONG refcount = InterlockedDecrement(&factory->refcount);
TRACE("%p decreasing refcount to %u.\n", iface, refcount); @@ -84,37 +86,37 @@ static ULONG STDMETHODCALLTYPE dxgi_factory_Release(IDXGIFactory2 *iface) return refcount; }
-static HRESULT STDMETHODCALLTYPE dxgi_factory_SetPrivateData(IDXGIFactory2 *iface, +static HRESULT STDMETHODCALLTYPE dxgi_factory_SetPrivateData(IDXGIFactory4 *iface, REFGUID guid, UINT data_size, const void *data) { - struct dxgi_factory *factory = impl_from_IDXGIFactory2(iface); + struct dxgi_factory *factory = impl_from_IDXGIFactory4(iface);
TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface, debugstr_guid(guid), data_size, data);
return dxgi_set_private_data(&factory->private_store, guid, data_size, data); }
-static HRESULT STDMETHODCALLTYPE dxgi_factory_SetPrivateDataInterface(IDXGIFactory2 *iface, +static HRESULT STDMETHODCALLTYPE dxgi_factory_SetPrivateDataInterface(IDXGIFactory4 *iface, REFGUID guid, const IUnknown *object) { - struct dxgi_factory *factory = impl_from_IDXGIFactory2(iface); + struct dxgi_factory *factory = impl_from_IDXGIFactory4(iface);
TRACE("iface %p, guid %s, object %p.\n", iface, debugstr_guid(guid), object);
return dxgi_set_private_data_interface(&factory->private_store, guid, object); }
-static HRESULT STDMETHODCALLTYPE dxgi_factory_GetPrivateData(IDXGIFactory2 *iface, +static HRESULT STDMETHODCALLTYPE dxgi_factory_GetPrivateData(IDXGIFactory4 *iface, REFGUID guid, UINT *data_size, void *data) { - struct dxgi_factory *factory = impl_from_IDXGIFactory2(iface); + struct dxgi_factory *factory = impl_from_IDXGIFactory4(iface);
TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface, debugstr_guid(guid), data_size, data);
return dxgi_get_private_data(&factory->private_store, guid, data_size, data); }
-static HRESULT STDMETHODCALLTYPE dxgi_factory_GetParent(IDXGIFactory2 *iface, REFIID iid, void **parent) +static HRESULT STDMETHODCALLTYPE dxgi_factory_GetParent(IDXGIFactory4 *iface, REFIID iid, void **parent) { WARN("iface %p, iid %s, parent %p.\n", iface, debugstr_guid(iid), parent);
@@ -123,10 +125,10 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_GetParent(IDXGIFactory2 *iface, RE return E_NOINTERFACE; }
-static HRESULT STDMETHODCALLTYPE dxgi_factory_EnumAdapters1(IDXGIFactory2 *iface, +static HRESULT STDMETHODCALLTYPE dxgi_factory_EnumAdapters1(IDXGIFactory4 *iface, UINT adapter_idx, IDXGIAdapter1 **adapter) { - struct dxgi_factory *factory = impl_from_IDXGIFactory2(iface); + struct dxgi_factory *factory = impl_from_IDXGIFactory4(iface); struct dxgi_adapter *adapter_object; UINT adapter_count; HRESULT hr; @@ -159,7 +161,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_EnumAdapters1(IDXGIFactory2 *iface return S_OK; }
-static HRESULT STDMETHODCALLTYPE dxgi_factory_EnumAdapters(IDXGIFactory2 *iface, +static HRESULT STDMETHODCALLTYPE dxgi_factory_EnumAdapters(IDXGIFactory4 *iface, UINT adapter_idx, IDXGIAdapter **adapter) { TRACE("iface %p, adapter_idx %u, adapter %p.\n", iface, adapter_idx, adapter); @@ -167,24 +169,24 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_EnumAdapters(IDXGIFactory2 *iface, return dxgi_factory_EnumAdapters1(iface, adapter_idx, (IDXGIAdapter1 **)adapter); }
-static HRESULT STDMETHODCALLTYPE dxgi_factory_MakeWindowAssociation(IDXGIFactory2 *iface, HWND window, UINT flags) +static HRESULT STDMETHODCALLTYPE dxgi_factory_MakeWindowAssociation(IDXGIFactory4 *iface, HWND window, UINT flags) { FIXME("iface %p, window %p, flags %#x stub!\n", iface, window, flags);
return S_OK; }
-static HRESULT STDMETHODCALLTYPE dxgi_factory_GetWindowAssociation(IDXGIFactory2 *iface, HWND *window) +static HRESULT STDMETHODCALLTYPE dxgi_factory_GetWindowAssociation(IDXGIFactory4 *iface, HWND *window) { FIXME("iface %p, window %p stub!\n", iface, window);
return E_NOTIMPL; }
-static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChain(IDXGIFactory2 *iface, +static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChain(IDXGIFactory4 *iface, IUnknown *device, DXGI_SWAP_CHAIN_DESC *desc, IDXGISwapChain **swapchain) { - struct dxgi_factory *factory = impl_from_IDXGIFactory2(iface); + struct dxgi_factory *factory = impl_from_IDXGIFactory4(iface); DXGI_SWAP_CHAIN_FULLSCREEN_DESC fullscreen_desc; DXGI_SWAP_CHAIN_DESC1 swapchain_desc;
@@ -213,12 +215,12 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChain(IDXGIFactory2 *ifa fullscreen_desc.Scaling = desc->BufferDesc.Scaling; fullscreen_desc.Windowed = desc->Windowed;
- return IDXGIFactory2_CreateSwapChainForHwnd(&factory->IDXGIFactory2_iface, + return IDXGIFactory4_CreateSwapChainForHwnd(&factory->IDXGIFactory4_iface, device, desc->OutputWindow, &swapchain_desc, &fullscreen_desc, NULL, (IDXGISwapChain1 **)swapchain); }
-static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSoftwareAdapter(IDXGIFactory2 *iface, +static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSoftwareAdapter(IDXGIFactory4 *iface, HMODULE swrast, IDXGIAdapter **adapter) { FIXME("iface %p, swrast %p, adapter %p stub!\n", iface, swrast, adapter); @@ -226,21 +228,21 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSoftwareAdapter(IDXGIFactory return E_NOTIMPL; }
-static BOOL STDMETHODCALLTYPE dxgi_factory_IsCurrent(IDXGIFactory2 *iface) +static BOOL STDMETHODCALLTYPE dxgi_factory_IsCurrent(IDXGIFactory4 *iface) { FIXME("iface %p stub!\n", iface);
return TRUE; }
-static BOOL STDMETHODCALLTYPE dxgi_factory_IsWindowedStereoEnabled(IDXGIFactory2 *iface) +static BOOL STDMETHODCALLTYPE dxgi_factory_IsWindowedStereoEnabled(IDXGIFactory4 *iface) { FIXME("iface %p stub!\n", iface);
return FALSE; }
-static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChainForHwnd(IDXGIFactory2 *iface, +static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChainForHwnd(IDXGIFactory4 *iface, IUnknown *device, HWND window, const DXGI_SWAP_CHAIN_DESC1 *swapchain_desc, const DXGI_SWAP_CHAIN_FULLSCREEN_DESC *fullscreen_desc, IDXGIOutput *output, IDXGISwapChain1 **swapchain) @@ -338,7 +340,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChainForHwnd(IDXGIFactor return S_OK; }
-static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChainForCoreWindow(IDXGIFactory2 *iface, +static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChainForCoreWindow(IDXGIFactory4 *iface, IUnknown *device, IUnknown *window, const DXGI_SWAP_CHAIN_DESC1 *desc, IDXGIOutput *output, IDXGISwapChain1 **swapchain) { @@ -348,7 +350,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChainForCoreWindow(IDXGI return E_NOTIMPL; }
-static HRESULT STDMETHODCALLTYPE dxgi_factory_GetSharedResourceAdapterLuid(IDXGIFactory2 *iface, +static HRESULT STDMETHODCALLTYPE dxgi_factory_GetSharedResourceAdapterLuid(IDXGIFactory4 *iface, HANDLE resource, LUID *luid) { FIXME("iface %p, resource %p, luid %p stub!\n", iface, resource, luid); @@ -356,7 +358,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_GetSharedResourceAdapterLuid(IDXGI return E_NOTIMPL; }
-static HRESULT STDMETHODCALLTYPE dxgi_factory_RegisterOcclusionStatusWindow(IDXGIFactory2 *iface, +static HRESULT STDMETHODCALLTYPE dxgi_factory_RegisterOcclusionStatusWindow(IDXGIFactory4 *iface, HWND window, UINT message, DWORD *cookie) { FIXME("iface %p, window %p, message %#x, cookie %p stub!\n", @@ -365,7 +367,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_RegisterOcclusionStatusWindow(IDXG return E_NOTIMPL; }
-static HRESULT STDMETHODCALLTYPE dxgi_factory_RegisterStereoStatusEvent(IDXGIFactory2 *iface, +static HRESULT STDMETHODCALLTYPE dxgi_factory_RegisterStereoStatusEvent(IDXGIFactory4 *iface, HANDLE event, DWORD *cookie) { FIXME("iface %p, event %p, cookie %p stub!\n", iface, event, cookie); @@ -373,12 +375,12 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_RegisterStereoStatusEvent(IDXGIFac return E_NOTIMPL; }
-static void STDMETHODCALLTYPE dxgi_factory_UnregisterStereoStatus(IDXGIFactory2 *iface, DWORD cookie) +static void STDMETHODCALLTYPE dxgi_factory_UnregisterStereoStatus(IDXGIFactory4 *iface, DWORD cookie) { FIXME("iface %p, cookie %#x stub!n", iface, cookie); }
-static HRESULT STDMETHODCALLTYPE dxgi_factory_RegisterStereoStatusWindow(IDXGIFactory2 *iface, +static HRESULT STDMETHODCALLTYPE dxgi_factory_RegisterStereoStatusWindow(IDXGIFactory4 *iface, HWND window, UINT message, DWORD *cookie) { FIXME("iface %p, window %p, message %#x, cookie %p stub!\n", @@ -387,7 +389,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_RegisterStereoStatusWindow(IDXGIFa return E_NOTIMPL; }
-static HRESULT STDMETHODCALLTYPE dxgi_factory_RegisterOcclusionStatusEvent(IDXGIFactory2 *iface, +static HRESULT STDMETHODCALLTYPE dxgi_factory_RegisterOcclusionStatusEvent(IDXGIFactory4 *iface, HANDLE event, DWORD *cookie) { FIXME("iface %p, event %p, cookie %p stub!\n", iface, event, cookie); @@ -395,12 +397,12 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_RegisterOcclusionStatusEvent(IDXGI return E_NOTIMPL; }
-static void STDMETHODCALLTYPE dxgi_factory_UnregisterOcclusionStatus(IDXGIFactory2 *iface, DWORD cookie) +static void STDMETHODCALLTYPE dxgi_factory_UnregisterOcclusionStatus(IDXGIFactory4 *iface, DWORD cookie) { FIXME("iface %p, cookie %#x stub!\n", iface, cookie); }
-static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChainForComposition(IDXGIFactory2 *iface, +static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChainForComposition(IDXGIFactory4 *iface, IUnknown *device, const DXGI_SWAP_CHAIN_DESC1 *desc, IDXGIOutput *output, IDXGISwapChain1 **swapchain) { FIXME("iface %p, device %p, desc %p, output %p, swapchain %p stub!\n", @@ -409,7 +411,31 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChainForComposition(IDXG return E_NOTIMPL; }
-static const struct IDXGIFactory2Vtbl dxgi_factory_vtbl = +static UINT STDMETHODCALLTYPE dxgi_factory_GetCreationFlags(IDXGIFactory4 *iface) +{ + FIXME("iface %p stub!\n", iface); + + return 0; +} + +static HRESULT STDMETHODCALLTYPE dxgi_factory_EnumAdapterByLuid(IDXGIFactory4 *iface, + LUID luid, REFIID iid, void **adapter) +{ + FIXME("iface %p, luid %08x:%08x, iid %s, adapter %p stub!\n", + iface, luid.HighPart, luid.LowPart, debugstr_guid(iid), adapter); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE dxgi_factory_EnumWarpAdapter(IDXGIFactory4 *iface, + REFIID iid, void **adapter) +{ + FIXME("iface %p, iid %s, adapter %p stub!\n", iface, debugstr_guid(iid), adapter); + + return E_NOTIMPL; +} + +static const struct IDXGIFactory4Vtbl dxgi_factory_vtbl = { dxgi_factory_QueryInterface, dxgi_factory_AddRef, @@ -438,19 +464,24 @@ static const struct IDXGIFactory2Vtbl dxgi_factory_vtbl = dxgi_factory_RegisterOcclusionStatusEvent, dxgi_factory_UnregisterOcclusionStatus, dxgi_factory_CreateSwapChainForComposition, + /* IDXGIFactory3 methods */ + dxgi_factory_GetCreationFlags, + /* IDXGIFactory4 methods */ + dxgi_factory_EnumAdapterByLuid, + dxgi_factory_EnumWarpAdapter, };
-struct dxgi_factory *unsafe_impl_from_IDXGIFactory2(IDXGIFactory2 *iface) +struct dxgi_factory *unsafe_impl_from_IDXGIFactory4(IDXGIFactory4 *iface) { if (!iface) return NULL; assert(iface->lpVtbl == &dxgi_factory_vtbl); - return CONTAINING_RECORD(iface, struct dxgi_factory, IDXGIFactory2_iface); + return CONTAINING_RECORD(iface, struct dxgi_factory, IDXGIFactory4_iface); }
static HRESULT dxgi_factory_init(struct dxgi_factory *factory, BOOL extended) { - factory->IDXGIFactory2_iface.lpVtbl = &dxgi_factory_vtbl; + factory->IDXGIFactory4_iface.lpVtbl = &dxgi_factory_vtbl; factory->refcount = 1; wined3d_private_store_init(&factory->private_store);
@@ -485,8 +516,8 @@ HRESULT dxgi_factory_create(REFIID riid, void **factory, BOOL extended)
TRACE("Created factory %p.\n", object);
- hr = IDXGIFactory2_QueryInterface(&object->IDXGIFactory2_iface, riid, factory); - IDXGIFactory2_Release(&object->IDXGIFactory2_iface); + hr = IDXGIFactory4_QueryInterface(&object->IDXGIFactory4_iface, riid, factory); + IDXGIFactory4_Release(&object->IDXGIFactory4_iface); return hr; }
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- dlls/dxgi/dxgi.spec | 1 + dlls/dxgi/dxgi_main.c | 22 ++++++++++++++++------ include/dxgi1_3.idl | 6 ++++++ 3 files changed, 23 insertions(+), 6 deletions(-)
diff --git a/dlls/dxgi/dxgi.spec b/dlls/dxgi/dxgi.spec index 3270a532cbb6..801e6a4283c0 100644 --- a/dlls/dxgi/dxgi.spec +++ b/dlls/dxgi/dxgi.spec @@ -1,4 +1,5 @@ @ stdcall CreateDXGIFactory(ptr ptr) @ stdcall CreateDXGIFactory1(ptr ptr) +@ stdcall CreateDXGIFactory2(long ptr ptr) @ stdcall DXGID3D10CreateDevice(ptr ptr ptr long ptr long ptr) @ stdcall DXGID3D10RegisterLayers(ptr long) diff --git a/dlls/dxgi/dxgi_main.c b/dlls/dxgi/dxgi_main.c index 60ff3c1260b6..36cf73bfeca8 100644 --- a/dlls/dxgi/dxgi_main.c +++ b/dlls/dxgi/dxgi_main.c @@ -56,18 +56,28 @@ BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, void *reserved) return TRUE; }
-HRESULT WINAPI CreateDXGIFactory1(REFIID riid, void **factory) +HRESULT WINAPI CreateDXGIFactory2(UINT flags, REFIID iid, void **factory) { - TRACE("riid %s, factory %p\n", debugstr_guid(riid), factory); + TRACE("flags %#x, iid %s, factory %p.\n", flags, debugstr_guid(iid), factory);
- return dxgi_factory_create(riid, factory, TRUE); + if (flags) + FIXME("Ignoring flags %#x.\n", flags); + + return dxgi_factory_create(iid, factory, TRUE); +} + +HRESULT WINAPI CreateDXGIFactory1(REFIID iid, void **factory) +{ + TRACE("iid %s, factory %p.\n", debugstr_guid(iid), factory); + + return dxgi_factory_create(iid, factory, TRUE); }
-HRESULT WINAPI CreateDXGIFactory(REFIID riid, void **factory) +HRESULT WINAPI CreateDXGIFactory(REFIID iid, void **factory) { - TRACE("riid %s, factory %p\n", debugstr_guid(riid), factory); + TRACE("iid %s, factory %p.\n", debugstr_guid(iid), factory);
- return dxgi_factory_create(riid, factory, FALSE); + return dxgi_factory_create(iid, factory, FALSE); }
static BOOL get_layer(enum dxgi_device_layer_id id, struct dxgi_device_layer *layer) diff --git a/include/dxgi1_3.idl b/include/dxgi1_3.idl index 5ea20ddb7764..bafea047752a 100644 --- a/include/dxgi1_3.idl +++ b/include/dxgi1_3.idl @@ -223,3 +223,9 @@ interface IDXGIOutput3 : IDXGIOutput2 [out] UINT *flags ); } + +cpp_quote("#define DXGI_CREATE_FACTORY_DEBUG 0x1") + +[local] HRESULT __stdcall CreateDXGIFactory2(UINT flags, REFIID iid, void **factory); + +[local] HRESULT __stdcall DXGIGetDebugInterface1(UINT flags, REFIID iid, void **debug);