Signed-off-by: Jactry Zeng jzeng@codeweavers.com --- dlls/mfplat/main.c | 26 +++++++++++++++++++-- dlls/mfplat/tests/Makefile.in | 2 +- dlls/mfplat/tests/mfplat.c | 44 +++++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 3 deletions(-)
diff --git a/dlls/mfplat/main.c b/dlls/mfplat/main.c index 706251b3e0..d213935c3a 100644 --- a/dlls/mfplat/main.c +++ b/dlls/mfplat/main.c @@ -31,6 +31,7 @@ #include "initguid.h" #include "ole2.h" #include "propsys.h" +#include "dxgi.h"
#include "wine/debug.h" #include "wine/list.h" @@ -7623,6 +7624,7 @@ struct dxgi_device_manager IMFDXGIDeviceManager IMFDXGIDeviceManager_iface; LONG refcount; UINT token; + IDXGIDevice *device; };
static struct dxgi_device_manager *impl_from_IMFDXGIDeviceManager(IMFDXGIDeviceManager *iface) @@ -7666,6 +7668,8 @@ static ULONG WINAPI dxgi_device_manager_Release(IMFDXGIDeviceManager *iface)
if (!refcount) { + if (manager->device) + IDXGIDevice_Release(manager->device); heap_free(manager); }
@@ -7704,9 +7708,26 @@ static HRESULT WINAPI dxgi_device_manager_OpenDeviceHandle(IMFDXGIDeviceManager
static HRESULT WINAPI dxgi_device_manager_ResetDevice(IMFDXGIDeviceManager *iface, IUnknown *device, UINT token) { - FIXME("(%p, %p, %u): stub.\n", iface, device, token); + struct dxgi_device_manager *manager = impl_from_IMFDXGIDeviceManager(iface); + IDXGIDevice *dxgi_device; + HRESULT hr;
- return E_NOTIMPL; + TRACE("(%p, %p, %u).\n", iface, device, token); + + if (!device || token != manager->token) + return E_INVALIDARG; + + hr = IUnknown_QueryInterface(device, &IID_IDXGIDevice, (void **)&dxgi_device); + if (SUCCEEDED(hr)) + { + if (manager->device) + IDXGIDevice_Release(manager->device); + manager->device = dxgi_device; + } + else + hr = E_INVALIDARG; + + return hr; }
static HRESULT WINAPI dxgi_device_manager_TestDevice(IMFDXGIDeviceManager *iface, HANDLE device) @@ -7753,6 +7774,7 @@ HRESULT WINAPI MFCreateDXGIDeviceManager(UINT *token, IMFDXGIDeviceManager **man object->IMFDXGIDeviceManager_iface.lpVtbl = &dxgi_device_manager_vtbl; object->refcount = 1; object->token = GetTickCount(); + object->device = NULL;
TRACE("Created device manager: %p, token: %u.\n", object, object->token);
diff --git a/dlls/mfplat/tests/Makefile.in b/dlls/mfplat/tests/Makefile.in index c58a0463e5..dafb429142 100644 --- a/dlls/mfplat/tests/Makefile.in +++ b/dlls/mfplat/tests/Makefile.in @@ -1,5 +1,5 @@ TESTDLL = mfplat.dll -IMPORTS = ole32 mfplat mfuuid propsys uuid +IMPORTS = ole32 mfplat mfuuid propsys uuid d3d11
C_SRCS = \ mfplat.c diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index e0029ab4ff..721ec120ef 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -38,7 +38,10 @@ #include "wine/test.h" #include "wine/heap.h"
+#define D3D11_INIT_GUID #include "initguid.h" +#include "d3d11_4.h" + DEFINE_GUID(DUMMY_CLSID, 0x12345678,0x1234,0x1234,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19); DEFINE_GUID(DUMMY_GUID1, 0x12345678,0x1234,0x1234,0x21,0x21,0x21,0x21,0x21,0x21,0x21,0x21); DEFINE_GUID(DUMMY_GUID2, 0x12345678,0x1234,0x1234,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22); @@ -3709,6 +3712,7 @@ if (0) static void test_dxgi_device_manager(void) { IMFDXGIDeviceManager *manager, *manager2; + ID3D11Device *d3d11_dev, *d3d11_dev2; UINT token, token2; HRESULT hr;
@@ -3740,7 +3744,47 @@ static void test_dxgi_device_manager(void) ok(manager != manager2, "got wrong pointer: %p.\n", manager2); EXPECT_REF(manager, 1);
+ hr = D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, D3D11_CREATE_DEVICE_VIDEO_SUPPORT, + NULL, 0, D3D11_SDK_VERSION, &d3d11_dev, NULL, NULL); + ok(hr == S_OK, "D3D11CreateDevice failed: %#x.\n", hr); + EXPECT_REF(d3d11_dev, 1); + + hr = IMFDXGIDeviceManager_ResetDevice(manager, (IUnknown *)d3d11_dev, token - 1); + ok(hr == E_INVALIDARG, "IMFDXGIDeviceManager_ResetDevice should failed: %#x.\n", hr); + EXPECT_REF(d3d11_dev, 1); + + hr = IMFDXGIDeviceManager_ResetDevice(manager, NULL, token); + ok(hr == E_INVALIDARG, "IMFDXGIDeviceManager_ResetDevice should failed: %#x.\n", hr); + + hr = IMFDXGIDeviceManager_ResetDevice(manager, (IUnknown *)d3d11_dev, token); + ok(hr == S_OK, "IMFDXGIDeviceManager_ResetDevice failed: %#x.\n", hr); + EXPECT_REF(manager, 1); + EXPECT_REF(d3d11_dev, 2); + + hr = IMFDXGIDeviceManager_ResetDevice(manager, (IUnknown *)manager2, token); + ok(hr == E_INVALIDARG, "IMFDXGIDeviceManager_ResetDevice should failed: %#x.\n", hr); + EXPECT_REF(manager2, 1); + EXPECT_REF(d3d11_dev, 2); + + hr = IMFDXGIDeviceManager_ResetDevice(manager, (IUnknown *)d3d11_dev, token); + ok(hr == S_OK, "IMFDXGIDeviceManager_ResetDevice failed: %#x.\n", hr); + EXPECT_REF(manager, 1); + EXPECT_REF(d3d11_dev, 2); + + hr = D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, + NULL, 0, D3D11_SDK_VERSION, &d3d11_dev2, NULL, NULL); + ok(hr == S_OK, "D3D11CreateDevice failed: %#x.\n", hr); + EXPECT_REF(d3d11_dev2, 1); + hr = IMFDXGIDeviceManager_ResetDevice(manager, (IUnknown *)d3d11_dev2, token); + ok(hr == S_OK, "IMFDXGIDeviceManager_ResetDevice failed: %#x.\n", hr); + EXPECT_REF(manager, 1); + EXPECT_REF(d3d11_dev2, 2); + EXPECT_REF(d3d11_dev, 1); + IMFDXGIDeviceManager_Release(manager); + EXPECT_REF(d3d11_dev2, 1); + ID3D11Device_Release(d3d11_dev); + ID3D11Device_Release(d3d11_dev2); IMFDXGIDeviceManager_Release(manager2); }