Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/dxva2/main.c | 38 +++++++++++++++++++++++----------- dlls/dxva2/tests/dxva2.c | 44 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 69 insertions(+), 13 deletions(-)
diff --git a/dlls/dxva2/main.c b/dlls/dxva2/main.c index 7ba8d9806b1..bbee697674f 100644 --- a/dlls/dxva2/main.c +++ b/dlls/dxva2/main.c @@ -101,6 +101,7 @@ static HRESULT WINAPI device_manager_processor_service_QueryInterface(IDirectXVi REFIID riid, void **obj) { if (IsEqualIID(riid, &IID_IDirectXVideoProcessorService) || + IsEqualIID(riid, &IID_IDirectXVideoAccelerationService) || IsEqualIID(riid, &IID_IUnknown)) { *obj = iface; @@ -401,16 +402,9 @@ static HRESULT WINAPI device_manager_GetVideoService(IDirect3DDeviceManager9 *if hr = DXVA2_E_NEW_VIDEO_DEVICE; else if (!(flags & HANDLE_FLAG_OPEN)) hr = E_HANDLE; - else if (IsEqualIID(riid, &IID_IDirectXVideoProcessorService)) - { - *obj = &manager->IDirectXVideoProcessorService_iface; - IUnknown_AddRef((IUnknown *)*obj); - } else - { - WARN("Unsupported service %s.\n", debugstr_guid(riid)); - hr = E_UNEXPECTED; - } + hr = IDirectXVideoProcessorService_QueryInterface(&manager->IDirectXVideoProcessorService_iface, + riid, obj); } LeaveCriticalSection(&manager->cs);
@@ -462,11 +456,31 @@ HRESULT WINAPI DXVA2CreateDirect3DDeviceManager9(UINT *token, IDirect3DDeviceMan return S_OK; }
-HRESULT WINAPI DXVA2CreateVideoService( IDirect3DDevice9 *device, REFIID riid, void **ppv ) +HRESULT WINAPI DXVA2CreateVideoService(IDirect3DDevice9 *device, REFIID riid, void **obj) { - FIXME("(%p, %s, %p): stub\n", device, debugstr_guid(riid), ppv); + IDirect3DDeviceManager9 *manager; + HANDLE handle; + HRESULT hr; + UINT token;
- return E_NOTIMPL; + TRACE("%p, %s, %p.\n", device, debugstr_guid(riid), obj); + + if (FAILED(hr = DXVA2CreateDirect3DDeviceManager9(&token, &manager))) + return hr; + + if (FAILED(hr = IDirect3DDeviceManager9_ResetDevice(manager, device, token))) + goto done; + + if (FAILED(hr = IDirect3DDeviceManager9_OpenDeviceHandle(manager, &handle))) + goto done; + + hr = IDirect3DDeviceManager9_GetVideoService(manager, handle, riid, obj); + IDirect3DDeviceManager9_CloseDeviceHandle(manager, handle); + +done: + IDirect3DDeviceManager9_Release(manager); + + return hr; }
BOOL WINAPI DegaussMonitor( HMONITOR monitor ) diff --git a/dlls/dxva2/tests/dxva2.c b/dlls/dxva2/tests/dxva2.c index 65771fb5874..e3e8dd2e66c 100644 --- a/dlls/dxva2/tests/dxva2.c +++ b/dlls/dxva2/tests/dxva2.c @@ -62,8 +62,10 @@ static IDirect3DDevice9 *create_device(IDirect3D9 *d3d9, HWND focus_window) static void test_device_manager(void) { IDirectXVideoProcessorService *processor_service; - IDirect3DDevice9 *device, *device2; + IDirectXVideoAccelerationService *accel_service; + IDirect3DDevice9 *device, *device2, *device3; IDirect3DDeviceManager9 *manager; + IDirect3DSurface9 *surface; int refcount, refcount2; HANDLE handle, handle1; IDirect3D9 *d3d; @@ -148,6 +150,46 @@ static void test_device_manager(void) hr = IDirect3DDeviceManager9_TestDevice(manager, handle); ok(hr == DXVA2_E_NEW_VIDEO_DEVICE, "Unexpected hr %#x.\n", hr);
+ /* Acceleration service. */ + hr = DXVA2CreateVideoService(device, &IID_IDirectXVideoAccelerationService, (void **)&accel_service); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = IDirectXVideoAccelerationService_CreateSurface(accel_service, 64, 64, 1, D3DFMT_X8R8G8B8, + D3DPOOL_DEFAULT, 0, DXVA2_VideoProcessorRenderTarget, &surface, NULL); +todo_wine + ok(hr == S_OK, "Failed to create a surface, hr %#x.\n", hr); + if (SUCCEEDED(hr)) + IDirect3DSurface9_Release(surface); + + IDirectXVideoAccelerationService_Release(accel_service); + + hr = IDirect3DDeviceManager9_OpenDeviceHandle(manager, &handle); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = IDirect3DDeviceManager9_GetVideoService(manager, handle, &IID_IDirectXVideoAccelerationService, + (void **)&accel_service); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = IDirect3DDeviceManager9_CloseDeviceHandle(manager, handle); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = IDirectXVideoAccelerationService_CreateSurface(accel_service, 64, 64, 1, D3DFMT_X8R8G8B8, + D3DPOOL_DEFAULT, 0, DXVA2_VideoProcessorRenderTarget, &surface, NULL); +todo_wine + ok(hr == S_OK, "Failed to create a surface, hr %#x.\n", hr); + + if (SUCCEEDED(hr)) + { + hr = IDirect3DSurface9_GetDevice(surface, &device3); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + ok(device2 == device3, "Unexpected device.\n"); + IDirect3DDevice9_Release(device3); + + IDirect3DSurface9_Release(surface); + } + + IDirectXVideoAccelerationService_Release(accel_service); + IDirect3DDevice9_Release(device); IDirect3DDevice9_Release(device2);