Commit 4fc9ecda authored by Jactry Zeng's avatar Jactry Zeng Committed by Alexandre Julliard

mfplat: Implement IMFDXGIDeviceManager::ResetDevice().

parent 645cf846
......@@ -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);
......
TESTDLL = mfplat.dll
IMPORTS = ole32 mfplat mfuuid propsys uuid
IMPORTS = ole32 mfplat mfuuid propsys uuid d3d11
C_SRCS = \
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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment