2020-06-22 12:45:29 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2020 Nikolay Sivov
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
#include "wine/test.h"
|
|
|
|
#include "d3d9.h"
|
|
|
|
|
|
|
|
#include "initguid.h"
|
|
|
|
#include "dxva2api.h"
|
|
|
|
|
2020-10-19 16:10:40 +02:00
|
|
|
static unsigned int get_refcount(void *object)
|
2020-06-22 12:45:29 +02:00
|
|
|
{
|
2020-10-19 16:10:40 +02:00
|
|
|
IUnknown *iface = object;
|
|
|
|
IUnknown_AddRef(iface);
|
|
|
|
return IUnknown_Release(iface);
|
2020-06-22 12:45:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HWND create_window(void)
|
|
|
|
{
|
|
|
|
RECT r = {0, 0, 640, 480};
|
|
|
|
|
|
|
|
AdjustWindowRect(&r, WS_OVERLAPPEDWINDOW | WS_VISIBLE, FALSE);
|
|
|
|
|
|
|
|
return CreateWindowA("static", "d3d9_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
|
|
|
|
0, 0, r.right - r.left, r.bottom - r.top, NULL, NULL, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static IDirect3DDevice9 *create_device(IDirect3D9 *d3d9, HWND focus_window)
|
|
|
|
{
|
|
|
|
D3DPRESENT_PARAMETERS present_parameters = {0};
|
|
|
|
IDirect3DDevice9 *device = NULL;
|
|
|
|
|
|
|
|
present_parameters.BackBufferWidth = 640;
|
|
|
|
present_parameters.BackBufferHeight = 480;
|
|
|
|
present_parameters.BackBufferFormat = D3DFMT_A8R8G8B8;
|
|
|
|
present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
|
|
|
present_parameters.hDeviceWindow = focus_window;
|
|
|
|
present_parameters.Windowed = TRUE;
|
|
|
|
present_parameters.EnableAutoDepthStencil = TRUE;
|
|
|
|
present_parameters.AutoDepthStencilFormat = D3DFMT_D24S8;
|
|
|
|
|
|
|
|
IDirect3D9_CreateDevice(d3d9, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, focus_window,
|
|
|
|
D3DCREATE_HARDWARE_VERTEXPROCESSING, &present_parameters, &device);
|
|
|
|
|
|
|
|
return device;
|
|
|
|
}
|
|
|
|
|
2020-09-17 13:25:35 +02:00
|
|
|
static void test_surface_desc(IDirect3DSurface9 *surface)
|
|
|
|
{
|
|
|
|
D3DSURFACE_DESC desc = { 0 };
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = IDirect3DSurface9_GetDesc(surface, &desc);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-09-17 13:25:35 +02:00
|
|
|
|
|
|
|
ok(desc.Format == D3DFMT_X8R8G8B8, "Unexpected format %d.\n", desc.Format);
|
|
|
|
ok(desc.Type == D3DRTYPE_SURFACE, "Unexpected type %d.\n", desc.Type);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(!desc.Usage, "Unexpected usage %ld.\n", desc.Usage);
|
2020-09-17 13:25:35 +02:00
|
|
|
ok(desc.Pool == D3DPOOL_DEFAULT, "Unexpected pool %d.\n", desc.Pool);
|
|
|
|
ok(desc.MultiSampleType == D3DMULTISAMPLE_NONE, "Unexpected multisample type %d.\n", desc.MultiSampleType);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(!desc.MultiSampleQuality, "Unexpected multisample quality %ld.\n", desc.MultiSampleQuality);
|
2020-09-17 13:25:35 +02:00
|
|
|
ok(desc.Width == 64, "Unexpected width %u.\n", desc.Width);
|
|
|
|
ok(desc.Height == 64, "Unexpected height %u.\n", desc.Height);
|
|
|
|
}
|
|
|
|
|
2021-04-08 11:19:38 +02:00
|
|
|
static void init_video_desc(DXVA2_VideoDesc *video_desc, D3DFORMAT format)
|
|
|
|
{
|
|
|
|
memset(video_desc, 0, sizeof(*video_desc));
|
|
|
|
video_desc->SampleWidth = 64;
|
|
|
|
video_desc->SampleHeight = 64;
|
|
|
|
video_desc->Format = format;
|
|
|
|
}
|
|
|
|
|
2020-06-22 12:45:29 +02:00
|
|
|
static void test_device_manager(void)
|
|
|
|
{
|
|
|
|
IDirectXVideoProcessorService *processor_service;
|
2020-06-23 13:31:17 +02:00
|
|
|
IDirectXVideoAccelerationService *accel_service;
|
|
|
|
IDirect3DDevice9 *device, *device2, *device3;
|
2020-09-18 16:25:15 +02:00
|
|
|
IDirectXVideoProcessorService *proc_service;
|
2020-06-22 12:45:29 +02:00
|
|
|
IDirect3DDeviceManager9 *manager;
|
2020-09-17 13:25:35 +02:00
|
|
|
IDirect3DSurface9 *surfaces[2];
|
2020-09-18 16:25:15 +02:00
|
|
|
DXVA2_VideoDesc video_desc;
|
2020-06-22 12:45:29 +02:00
|
|
|
int refcount, refcount2;
|
|
|
|
HANDLE handle, handle1;
|
2020-09-18 16:25:15 +02:00
|
|
|
D3DFORMAT *formats;
|
|
|
|
UINT token, count;
|
2020-06-22 12:45:29 +02:00
|
|
|
IDirect3D9 *d3d;
|
2021-04-08 11:19:38 +02:00
|
|
|
unsigned int i;
|
2020-06-22 12:45:29 +02:00
|
|
|
HWND window;
|
2020-10-12 13:19:23 +02:00
|
|
|
GUID *guids;
|
2020-06-22 12:45:29 +02:00
|
|
|
HRESULT hr;
|
2020-06-30 11:35:59 +02:00
|
|
|
RECT rect;
|
2020-06-22 12:45:29 +02:00
|
|
|
|
2021-04-08 11:19:38 +02:00
|
|
|
static const D3DFORMAT rt_formats[] =
|
|
|
|
{
|
|
|
|
D3DFMT_A8R8G8B8,
|
|
|
|
D3DFMT_X8R8G8B8,
|
|
|
|
D3DFMT_YUY2,
|
2021-06-07 18:34:15 +02:00
|
|
|
MAKEFOURCC('A','Y','U','V'),
|
2021-04-08 11:19:38 +02:00
|
|
|
};
|
|
|
|
static const D3DFORMAT rt_unsupported_formats[] =
|
|
|
|
{
|
|
|
|
D3DFMT_A1R5G5B5,
|
|
|
|
D3DFMT_X1R5G5B5,
|
|
|
|
D3DFMT_A2R10G10B10,
|
|
|
|
D3DFMT_A8B8G8R8,
|
|
|
|
D3DFMT_X8B8G8R8,
|
|
|
|
D3DFMT_R5G6B5,
|
|
|
|
D3DFMT_UYVY,
|
|
|
|
};
|
|
|
|
|
2020-06-22 12:45:29 +02:00
|
|
|
window = create_window();
|
|
|
|
d3d = Direct3DCreate9(D3D_SDK_VERSION);
|
|
|
|
ok(!!d3d, "Failed to create a D3D object.\n");
|
|
|
|
if (!(device = create_device(d3d, window)))
|
|
|
|
{
|
|
|
|
skip("Failed to create a D3D device, skipping tests.\n");
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = DXVA2CreateDirect3DDeviceManager9(&token, &manager);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-06-22 12:45:29 +02:00
|
|
|
|
|
|
|
hr = IDirect3DDeviceManager9_OpenDeviceHandle(manager, &handle);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == DXVA2_E_NOT_INITIALIZED, "Unexpected hr %#lx.\n", hr);
|
2020-06-22 12:45:29 +02:00
|
|
|
|
2020-06-30 11:35:59 +02:00
|
|
|
hr = IDirect3DDeviceManager9_LockDevice(manager, 0, &device2, FALSE);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == DXVA2_E_NOT_INITIALIZED, "Unexpected hr %#lx.\n", hr);
|
2020-06-30 11:35:59 +02:00
|
|
|
|
2020-10-21 08:46:28 +02:00
|
|
|
hr = IDirect3DDeviceManager9_CloseDeviceHandle(manager, 0);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == E_HANDLE, "Unexpected hr %#lx.\n", hr);
|
2020-10-21 08:46:28 +02:00
|
|
|
|
2020-06-22 12:45:29 +02:00
|
|
|
/* Invalid token. */
|
|
|
|
hr = IDirect3DDeviceManager9_ResetDevice(manager, device, token + 1);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
|
2020-06-22 12:45:29 +02:00
|
|
|
|
|
|
|
hr = IDirect3DDeviceManager9_ResetDevice(manager, device, token);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-10-19 16:10:40 +02:00
|
|
|
refcount = get_refcount(device);
|
2020-06-22 12:45:29 +02:00
|
|
|
|
2020-10-21 08:46:28 +02:00
|
|
|
hr = IDirect3DDeviceManager9_CloseDeviceHandle(manager, 0);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == E_HANDLE, "Unexpected hr %#lx.\n", hr);
|
2020-10-21 08:46:28 +02:00
|
|
|
|
2020-06-22 12:45:29 +02:00
|
|
|
handle1 = NULL;
|
|
|
|
hr = IDirect3DDeviceManager9_OpenDeviceHandle(manager, &handle1);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-10-21 08:46:28 +02:00
|
|
|
ok(!!handle1, "Unexpected handle value.\n");
|
2020-06-22 12:45:29 +02:00
|
|
|
|
2020-10-19 16:10:40 +02:00
|
|
|
refcount2 = get_refcount(device);
|
2020-06-22 12:45:29 +02:00
|
|
|
ok(refcount2 == refcount, "Unexpected refcount %d.\n", refcount);
|
|
|
|
|
|
|
|
handle = NULL;
|
|
|
|
hr = IDirect3DDeviceManager9_OpenDeviceHandle(manager, &handle);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-06-22 12:45:29 +02:00
|
|
|
ok(handle != handle1, "Unexpected handle.\n");
|
2020-06-22 12:45:30 +02:00
|
|
|
|
2020-06-22 12:45:29 +02:00
|
|
|
hr = IDirect3DDeviceManager9_CloseDeviceHandle(manager, handle);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-06-22 12:45:29 +02:00
|
|
|
|
|
|
|
/* Already closed. */
|
|
|
|
hr = IDirect3DDeviceManager9_CloseDeviceHandle(manager, handle);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == E_HANDLE, "Unexpected hr %#lx.\n", hr);
|
2020-06-22 12:45:29 +02:00
|
|
|
|
|
|
|
handle = NULL;
|
|
|
|
hr = IDirect3DDeviceManager9_OpenDeviceHandle(manager, &handle);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-06-22 12:45:29 +02:00
|
|
|
|
|
|
|
hr = IDirect3DDeviceManager9_CloseDeviceHandle(manager, handle1);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-06-22 12:45:29 +02:00
|
|
|
|
|
|
|
hr = IDirect3DDeviceManager9_TestDevice(manager, handle1);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == E_HANDLE, "Unexpected hr %#lx.\n", hr);
|
2020-06-22 12:45:29 +02:00
|
|
|
|
2020-10-21 08:46:28 +02:00
|
|
|
hr = IDirect3DDeviceManager9_TestDevice(manager, 0);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == E_HANDLE, "Unexpected hr %#lx.\n", hr);
|
2020-10-21 08:46:28 +02:00
|
|
|
|
2020-06-22 12:45:29 +02:00
|
|
|
handle = NULL;
|
|
|
|
hr = IDirect3DDeviceManager9_OpenDeviceHandle(manager, &handle);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-06-22 12:45:29 +02:00
|
|
|
|
|
|
|
handle1 = NULL;
|
|
|
|
hr = IDirect3DDeviceManager9_OpenDeviceHandle(manager, &handle1);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-06-22 12:45:29 +02:00
|
|
|
|
|
|
|
hr = IDirect3DDeviceManager9_GetVideoService(manager, handle, &IID_IDirectXVideoProcessorService,
|
|
|
|
(void **)&processor_service);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-06-22 12:45:31 +02:00
|
|
|
IDirectXVideoProcessorService_Release(processor_service);
|
2020-06-22 12:45:29 +02:00
|
|
|
|
|
|
|
device2 = create_device(d3d, window);
|
2020-06-30 11:35:59 +02:00
|
|
|
|
2020-06-22 12:45:29 +02:00
|
|
|
hr = IDirect3DDeviceManager9_ResetDevice(manager, device2, token);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-06-22 12:45:29 +02:00
|
|
|
|
|
|
|
hr = IDirect3DDeviceManager9_GetVideoService(manager, handle, &IID_IDirectXVideoProcessorService,
|
|
|
|
(void **)&processor_service);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == DXVA2_E_NEW_VIDEO_DEVICE, "Unexpected hr %#lx.\n", hr);
|
2020-06-22 12:45:29 +02:00
|
|
|
|
|
|
|
hr = IDirect3DDeviceManager9_TestDevice(manager, handle);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == DXVA2_E_NEW_VIDEO_DEVICE, "Unexpected hr %#lx.\n", hr);
|
2020-06-22 12:45:29 +02:00
|
|
|
|
2020-06-30 11:35:59 +02:00
|
|
|
hr = IDirect3DDeviceManager9_CloseDeviceHandle(manager, handle);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-06-30 11:35:59 +02:00
|
|
|
|
|
|
|
/* Lock/Unlock. */
|
|
|
|
hr = IDirect3DDeviceManager9_OpenDeviceHandle(manager, &handle);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-06-30 11:35:59 +02:00
|
|
|
|
|
|
|
hr = IDirect3DDeviceManager9_LockDevice(manager, handle, &device3, FALSE);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-06-30 11:35:59 +02:00
|
|
|
ok(device2 == device3, "Unexpected device pointer.\n");
|
|
|
|
IDirect3DDevice9_Release(device3);
|
|
|
|
|
|
|
|
hr = IDirect3DDeviceManager9_UnlockDevice(manager, handle, FALSE);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-06-30 11:35:59 +02:00
|
|
|
|
|
|
|
hr = IDirect3DDeviceManager9_UnlockDevice(manager, handle, FALSE);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
|
2020-06-30 11:35:59 +02:00
|
|
|
|
|
|
|
hr = IDirect3DDeviceManager9_UnlockDevice(manager, (HANDLE)((ULONG_PTR)handle + 100), FALSE);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
|
2020-06-30 11:35:59 +02:00
|
|
|
|
|
|
|
/* Locked with one handle, unlock with another. */
|
|
|
|
hr = IDirect3DDeviceManager9_OpenDeviceHandle(manager, &handle1);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-06-30 11:35:59 +02:00
|
|
|
|
|
|
|
hr = IDirect3DDeviceManager9_LockDevice(manager, handle, &device3, FALSE);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-06-30 11:35:59 +02:00
|
|
|
ok(device2 == device3, "Unexpected device pointer.\n");
|
|
|
|
IDirect3DDevice9_Release(device3);
|
|
|
|
|
|
|
|
hr = IDirect3DDeviceManager9_UnlockDevice(manager, handle1, FALSE);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
|
2020-06-30 11:35:59 +02:00
|
|
|
|
|
|
|
/* Closing unlocks the device. */
|
|
|
|
hr = IDirect3DDeviceManager9_CloseDeviceHandle(manager, handle);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-06-30 11:35:59 +02:00
|
|
|
|
|
|
|
hr = IDirect3DDeviceManager9_LockDevice(manager, handle1, &device3, FALSE);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-06-30 11:35:59 +02:00
|
|
|
ok(device2 == device3, "Unexpected device pointer.\n");
|
|
|
|
IDirect3DDevice9_Release(device3);
|
|
|
|
|
|
|
|
hr = IDirect3DDeviceManager9_CloseDeviceHandle(manager, handle1);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-06-30 11:35:59 +02:00
|
|
|
|
|
|
|
/* Open two handles. */
|
|
|
|
hr = IDirect3DDeviceManager9_OpenDeviceHandle(manager, &handle);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-06-30 11:35:59 +02:00
|
|
|
|
|
|
|
hr = IDirect3DDeviceManager9_OpenDeviceHandle(manager, &handle1);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-06-30 11:35:59 +02:00
|
|
|
|
|
|
|
hr = IDirect3DDeviceManager9_LockDevice(manager, handle, &device3, FALSE);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-06-30 11:35:59 +02:00
|
|
|
ok(device2 == device3, "Unexpected device pointer.\n");
|
|
|
|
IDirect3DDevice9_Release(device3);
|
|
|
|
|
|
|
|
hr = IDirect3DDeviceManager9_LockDevice(manager, handle1, &device3, FALSE);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == DXVA2_E_VIDEO_DEVICE_LOCKED, "Unexpected hr %#lx.\n", hr);
|
2020-06-30 11:35:59 +02:00
|
|
|
|
|
|
|
hr = IDirect3DDeviceManager9_CloseDeviceHandle(manager, handle1);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-06-30 11:35:59 +02:00
|
|
|
|
|
|
|
hr = IDirect3DDeviceManager9_CloseDeviceHandle(manager, handle);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-06-30 11:35:59 +02:00
|
|
|
|
|
|
|
/* State saving function. */
|
|
|
|
hr = IDirect3DDeviceManager9_OpenDeviceHandle(manager, &handle);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-06-30 11:35:59 +02:00
|
|
|
|
|
|
|
hr = IDirect3DDeviceManager9_LockDevice(manager, handle, &device3, FALSE);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-06-30 11:35:59 +02:00
|
|
|
ok(device2 == device3, "Unexpected device pointer.\n");
|
|
|
|
|
|
|
|
SetRect(&rect, 50, 60, 70, 80);
|
|
|
|
hr = IDirect3DDevice9_SetScissorRect(device3, &rect);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-06-30 11:35:59 +02:00
|
|
|
|
|
|
|
hr = IDirect3DDeviceManager9_UnlockDevice(manager, handle, TRUE);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-06-30 11:35:59 +02:00
|
|
|
|
|
|
|
SetRect(&rect, 30, 60, 70, 80);
|
|
|
|
hr = IDirect3DDevice9_SetScissorRect(device3, &rect);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-06-30 11:35:59 +02:00
|
|
|
|
|
|
|
IDirect3DDevice9_Release(device3);
|
|
|
|
|
|
|
|
hr = IDirect3DDeviceManager9_LockDevice(manager, handle, &device3, FALSE);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-06-30 11:35:59 +02:00
|
|
|
ok(device2 == device3, "Unexpected device pointer.\n");
|
|
|
|
|
|
|
|
hr = IDirect3DDevice9_GetScissorRect(device3, &rect);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-06-30 11:35:59 +02:00
|
|
|
ok(rect.left == 50 && rect.top == 60 && rect.right == 70 && rect.bottom == 80,
|
|
|
|
"Got unexpected scissor rect %s.\n", wine_dbgstr_rect(&rect));
|
|
|
|
|
|
|
|
IDirect3DDevice9_Release(device3);
|
|
|
|
|
|
|
|
hr = IDirect3DDeviceManager9_UnlockDevice(manager, handle, TRUE);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-06-30 11:35:59 +02:00
|
|
|
|
|
|
|
hr = IDirect3DDeviceManager9_CloseDeviceHandle(manager, handle);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-06-30 11:35:59 +02:00
|
|
|
|
2020-06-23 13:31:17 +02:00
|
|
|
/* Acceleration service. */
|
|
|
|
hr = DXVA2CreateVideoService(device, &IID_IDirectXVideoAccelerationService, (void **)&accel_service);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-06-23 13:31:17 +02:00
|
|
|
|
2020-09-17 13:25:35 +02:00
|
|
|
surfaces[0] = surfaces[1] = NULL;
|
|
|
|
hr = IDirectXVideoAccelerationService_CreateSurface(accel_service, 64, 64, 0, D3DFMT_X8R8G8B8,
|
|
|
|
D3DPOOL_DEFAULT, 0, DXVA2_VideoProcessorRenderTarget, surfaces, NULL);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-09-17 13:25:35 +02:00
|
|
|
ok(!!surfaces[0] && !surfaces[1], "Unexpected surfaces.\n");
|
|
|
|
IDirect3DSurface9_Release(surfaces[0]);
|
|
|
|
|
2020-06-23 13:31:17 +02:00
|
|
|
hr = IDirectXVideoAccelerationService_CreateSurface(accel_service, 64, 64, 1, D3DFMT_X8R8G8B8,
|
2020-09-17 13:25:35 +02:00
|
|
|
D3DPOOL_DEFAULT, 0, DXVA2_VideoProcessorRenderTarget, surfaces, NULL);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-09-17 13:25:35 +02:00
|
|
|
ok(!!surfaces[0] && !!surfaces[1], "Unexpected surfaces.\n");
|
|
|
|
test_surface_desc(surfaces[0]);
|
|
|
|
IDirect3DSurface9_Release(surfaces[0]);
|
|
|
|
IDirect3DSurface9_Release(surfaces[1]);
|
2020-06-23 13:31:17 +02:00
|
|
|
|
|
|
|
IDirectXVideoAccelerationService_Release(accel_service);
|
|
|
|
|
2020-09-18 16:25:15 +02:00
|
|
|
/* RT formats. */
|
|
|
|
hr = DXVA2CreateVideoService(device, &IID_IDirectXVideoProcessorService, (void **)&proc_service);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-09-18 16:25:15 +02:00
|
|
|
|
2021-04-08 11:19:38 +02:00
|
|
|
init_video_desc(&video_desc, D3DFMT_A8R8G8B8);
|
2020-09-18 16:25:15 +02:00
|
|
|
|
2020-10-12 13:19:23 +02:00
|
|
|
hr = IDirectXVideoProcessorService_GetVideoProcessorDeviceGuids(proc_service, &video_desc, &count, &guids);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-10-12 13:19:23 +02:00
|
|
|
ok(count, "Unexpected format count %u.\n", count);
|
|
|
|
CoTaskMemFree(guids);
|
|
|
|
|
2021-04-08 11:19:38 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(rt_formats); ++i)
|
|
|
|
{
|
|
|
|
init_video_desc(&video_desc, rt_formats[i]);
|
|
|
|
|
2021-06-07 18:34:15 +02:00
|
|
|
count = 0;
|
|
|
|
hr = IDirectXVideoProcessorService_GetVideoProcessorDeviceGuids(proc_service, &video_desc, &count, &guids);
|
2022-01-27 20:15:56 +01:00
|
|
|
todo_wine_if(rt_formats[i] == MAKEFOURCC('A','Y','U','V'))
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2021-10-29 14:18:26 +02:00
|
|
|
if (FAILED(hr)) continue;
|
2021-06-07 18:34:15 +02:00
|
|
|
ok(count > 0, "Unexpected device count.\n");
|
|
|
|
CoTaskMemFree(guids);
|
|
|
|
|
2021-04-08 11:19:38 +02:00
|
|
|
count = 0;
|
|
|
|
hr = IDirectXVideoProcessorService_GetVideoProcessorRenderTargets(proc_service, &DXVA2_VideoProcSoftwareDevice,
|
|
|
|
&video_desc, &count, &formats);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx, format %d.\n", hr, rt_formats[i]);
|
2021-04-08 11:19:38 +02:00
|
|
|
ok(count == 2, "Unexpected format count %u.\n", count);
|
|
|
|
if (count == 2)
|
|
|
|
ok(formats[0] == D3DFMT_X8R8G8B8 && formats[1] == D3DFMT_A8R8G8B8, "Unexpected formats %d,%d.\n",
|
|
|
|
formats[0], formats[1]);
|
|
|
|
CoTaskMemFree(formats);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(rt_unsupported_formats); ++i)
|
|
|
|
{
|
|
|
|
init_video_desc(&video_desc, rt_unsupported_formats[i]);
|
|
|
|
|
|
|
|
hr = IDirectXVideoProcessorService_GetVideoProcessorRenderTargets(proc_service, &DXVA2_VideoProcSoftwareDevice,
|
|
|
|
&video_desc, &count, &formats);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == E_FAIL, "Unexpected hr %#lx, format %d.\n", hr, rt_unsupported_formats[i]);
|
2021-04-08 11:19:38 +02:00
|
|
|
}
|
2020-09-18 16:25:15 +02:00
|
|
|
|
|
|
|
IDirectXVideoProcessorService_Release(proc_service);
|
|
|
|
|
2020-06-23 13:31:17 +02:00
|
|
|
hr = IDirect3DDeviceManager9_OpenDeviceHandle(manager, &handle);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-06-23 13:31:17 +02:00
|
|
|
|
|
|
|
hr = IDirect3DDeviceManager9_GetVideoService(manager, handle, &IID_IDirectXVideoAccelerationService,
|
|
|
|
(void **)&accel_service);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-06-23 13:31:17 +02:00
|
|
|
|
|
|
|
hr = IDirect3DDeviceManager9_CloseDeviceHandle(manager, handle);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-06-23 13:31:17 +02:00
|
|
|
|
2020-09-17 13:25:35 +02:00
|
|
|
hr = IDirectXVideoAccelerationService_CreateSurface(accel_service, 64, 64, 0, D3DFMT_X8R8G8B8,
|
|
|
|
D3DPOOL_DEFAULT, 0, DXVA2_VideoProcessorRenderTarget, surfaces, NULL);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-06-23 13:31:17 +02:00
|
|
|
|
2020-09-17 13:25:35 +02:00
|
|
|
hr = IDirect3DSurface9_GetDevice(surfaces[0], &device3);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-09-17 13:25:35 +02:00
|
|
|
ok(device2 == device3, "Unexpected device.\n");
|
|
|
|
IDirect3DDevice9_Release(device3);
|
2020-06-23 13:31:17 +02:00
|
|
|
|
2020-09-17 13:25:35 +02:00
|
|
|
IDirect3DSurface9_Release(surfaces[0]);
|
2020-06-23 13:31:17 +02:00
|
|
|
|
|
|
|
IDirectXVideoAccelerationService_Release(accel_service);
|
|
|
|
|
2020-06-22 12:45:29 +02:00
|
|
|
IDirect3DDevice9_Release(device);
|
|
|
|
IDirect3DDevice9_Release(device2);
|
|
|
|
|
|
|
|
IDirect3DDeviceManager9_Release(manager);
|
|
|
|
|
|
|
|
done:
|
|
|
|
IDirect3D9_Release(d3d);
|
|
|
|
DestroyWindow(window);
|
|
|
|
}
|
|
|
|
|
2020-10-19 16:10:40 +02:00
|
|
|
static void test_video_processor(void)
|
|
|
|
{
|
|
|
|
IDirectXVideoProcessorService *service, *service2;
|
2021-11-02 20:05:38 +01:00
|
|
|
IDirectXVideoProcessor *processor, *processor2;
|
2020-10-19 16:10:40 +02:00
|
|
|
IDirect3DDeviceManager9 *manager;
|
2021-11-02 20:05:38 +01:00
|
|
|
DXVA2_VideoProcessorCaps caps;
|
|
|
|
DXVA2_VideoDesc video_desc;
|
|
|
|
IDirect3DDevice9 *device;
|
2020-10-19 16:10:40 +02:00
|
|
|
HANDLE handle, handle1;
|
2021-11-02 20:05:38 +01:00
|
|
|
D3DFORMAT format;
|
2020-10-19 16:10:40 +02:00
|
|
|
IDirect3D9 *d3d;
|
|
|
|
HWND window;
|
|
|
|
UINT token;
|
|
|
|
HRESULT hr;
|
|
|
|
GUID guid;
|
|
|
|
|
|
|
|
window = create_window();
|
|
|
|
d3d = Direct3DCreate9(D3D_SDK_VERSION);
|
|
|
|
ok(!!d3d, "Failed to create a D3D object.\n");
|
|
|
|
if (!(device = create_device(d3d, window)))
|
|
|
|
{
|
|
|
|
skip("Failed to create a D3D device, skipping tests.\n");
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = DXVA2CreateDirect3DDeviceManager9(&token, &manager);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-10-19 16:10:40 +02:00
|
|
|
|
|
|
|
hr = IDirect3DDeviceManager9_ResetDevice(manager, device, token);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-10-19 16:10:40 +02:00
|
|
|
|
|
|
|
handle = NULL;
|
|
|
|
hr = IDirect3DDeviceManager9_OpenDeviceHandle(manager, &handle);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-10-19 16:10:40 +02:00
|
|
|
|
|
|
|
handle1 = NULL;
|
|
|
|
hr = IDirect3DDeviceManager9_OpenDeviceHandle(manager, &handle1);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-10-19 16:10:40 +02:00
|
|
|
|
|
|
|
ok(get_refcount(manager) == 1, "Unexpected refcount %u.\n", get_refcount(manager));
|
|
|
|
|
|
|
|
hr = IDirect3DDeviceManager9_GetVideoService(manager, handle, &IID_IDirectXVideoProcessorService,
|
|
|
|
(void **)&service);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-10-19 16:10:40 +02:00
|
|
|
|
|
|
|
memset(&video_desc, 0, sizeof(video_desc));
|
|
|
|
video_desc.SampleWidth = 64;
|
|
|
|
video_desc.SampleHeight = 64;
|
|
|
|
video_desc.Format = D3DFMT_A8R8G8B8;
|
|
|
|
|
2021-11-02 20:05:38 +01:00
|
|
|
/* Number of substreams does not include reference stream. */
|
|
|
|
hr = IDirectXVideoProcessorService_CreateVideoProcessor(service, &DXVA2_VideoProcSoftwareDevice, &video_desc,
|
|
|
|
D3DFMT_A8R8G8B8, 16, &processor);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
|
2021-11-02 20:05:38 +01:00
|
|
|
|
|
|
|
hr = IDirectXVideoProcessorService_CreateVideoProcessor(service, &DXVA2_VideoProcSoftwareDevice, &video_desc,
|
|
|
|
D3DFMT_A8R8G8B8, 15, &processor);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2021-11-02 20:05:38 +01:00
|
|
|
IDirectXVideoProcessor_Release(processor);
|
|
|
|
|
|
|
|
hr = IDirectXVideoProcessorService_CreateVideoProcessor(service, &DXVA2_VideoProcSoftwareDevice, &video_desc,
|
|
|
|
D3DFMT_A8R8G8B8, 0, &processor);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2021-11-02 20:05:38 +01:00
|
|
|
IDirectXVideoProcessor_Release(processor);
|
|
|
|
|
2020-10-19 16:10:40 +02:00
|
|
|
hr = IDirectXVideoProcessorService_CreateVideoProcessor(service, &DXVA2_VideoProcSoftwareDevice, &video_desc,
|
|
|
|
D3DFMT_A8R8G8B8, 1, &processor);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-10-19 16:10:40 +02:00
|
|
|
|
2021-11-02 20:05:38 +01:00
|
|
|
hr = IDirectXVideoProcessor_GetVideoProcessorCaps(processor, &caps);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2021-11-02 20:05:38 +01:00
|
|
|
ok(caps.DeviceCaps == DXVA2_VPDev_SoftwareDevice, "Unexpected device type %#x.\n", caps.DeviceCaps);
|
|
|
|
ok(caps.InputPool == D3DPOOL_SYSTEMMEM, "Unexpected input pool %#x.\n", caps.InputPool);
|
|
|
|
ok(!caps.NumForwardRefSamples, "Unexpected sample count.\n");
|
|
|
|
ok(!caps.NumBackwardRefSamples, "Unexpected sample count.\n");
|
|
|
|
ok(!caps.Reserved, "Unexpected field.\n");
|
|
|
|
ok(caps.DeinterlaceTechnology == DXVA2_DeinterlaceTech_Unknown, "Unexpected deinterlace technology %#x.\n",
|
|
|
|
caps.DeinterlaceTechnology);
|
|
|
|
ok(!caps.ProcAmpControlCaps, "Unexpected proc amp mask %#x.\n", caps.ProcAmpControlCaps);
|
|
|
|
ok(caps.VideoProcessorOperations == (DXVA2_VideoProcess_PlanarAlpha | DXVA2_VideoProcess_YUV2RGB |
|
|
|
|
DXVA2_VideoProcess_StretchX | DXVA2_VideoProcess_StretchY | DXVA2_VideoProcess_SubRects |
|
|
|
|
DXVA2_VideoProcess_SubStreams | DXVA2_VideoProcess_SubStreamsExtended | DXVA2_VideoProcess_YUV2RGBExtended),
|
|
|
|
"Unexpected processor operations %#x.\n", caps.VideoProcessorOperations);
|
|
|
|
ok(caps.NoiseFilterTechnology == DXVA2_NoiseFilterTech_Unsupported, "Unexpected noise filter technology %#x.\n",
|
|
|
|
caps.NoiseFilterTechnology);
|
|
|
|
ok(caps.DetailFilterTechnology == DXVA2_DetailFilterTech_Unsupported, "Unexpected detail filter technology %#x.\n",
|
|
|
|
caps.DetailFilterTechnology);
|
|
|
|
|
2020-10-19 16:10:40 +02:00
|
|
|
hr = IDirectXVideoProcessorService_CreateVideoProcessor(service, &DXVA2_VideoProcSoftwareDevice, &video_desc,
|
|
|
|
D3DFMT_A8R8G8B8, 1, &processor2);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-10-19 16:10:40 +02:00
|
|
|
ok(processor2 != processor, "Unexpected instance.\n");
|
|
|
|
|
|
|
|
hr = IDirectXVideoProcessor_GetCreationParameters(processor, NULL, NULL, NULL, NULL);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == E_INVALIDARG, "Unexpected hr %#lx.\n", hr);
|
2020-10-19 16:10:40 +02:00
|
|
|
|
|
|
|
hr = IDirectXVideoProcessor_GetCreationParameters(processor, &guid, NULL, NULL, NULL);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-10-19 16:10:40 +02:00
|
|
|
ok(IsEqualGUID(&guid, &DXVA2_VideoProcSoftwareDevice), "Unexpected device guid.\n");
|
2020-10-19 16:10:41 +02:00
|
|
|
|
2020-10-19 16:10:40 +02:00
|
|
|
hr = IDirectXVideoProcessor_GetCreationParameters(processor, NULL, NULL, &format, NULL);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-10-19 16:10:40 +02:00
|
|
|
ok(format == D3DFMT_A8R8G8B8, "Unexpected format %u.\n", format);
|
2020-10-19 16:10:41 +02:00
|
|
|
|
2020-10-19 16:10:40 +02:00
|
|
|
IDirectXVideoProcessor_Release(processor);
|
|
|
|
IDirectXVideoProcessor_Release(processor2);
|
|
|
|
|
|
|
|
hr = IDirect3DDeviceManager9_GetVideoService(manager, handle, &IID_IDirectXVideoProcessorService,
|
|
|
|
(void **)&service2);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-10-19 16:10:40 +02:00
|
|
|
ok(service == service2, "Unexpected pointer.\n");
|
|
|
|
|
|
|
|
IDirectXVideoProcessorService_Release(service2);
|
|
|
|
IDirectXVideoProcessorService_Release(service);
|
|
|
|
|
|
|
|
hr = IDirect3DDeviceManager9_CloseDeviceHandle(manager, handle);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-10-19 16:10:40 +02:00
|
|
|
|
|
|
|
hr = IDirect3DDeviceManager9_CloseDeviceHandle(manager, handle1);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2020-10-19 16:10:40 +02:00
|
|
|
|
|
|
|
IDirect3DDevice9_Release(device);
|
|
|
|
IDirect3DDeviceManager9_Release(manager);
|
|
|
|
|
|
|
|
done:
|
|
|
|
IDirect3D9_Release(d3d);
|
|
|
|
DestroyWindow(window);
|
|
|
|
}
|
|
|
|
|
2021-11-23 13:21:45 +01:00
|
|
|
static BOOL check_format_list(D3DFORMAT format, const D3DFORMAT *list, unsigned int count)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
for (i = 0; i < count; ++i)
|
|
|
|
if (list[i] == format) return TRUE;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_progressive_device(void)
|
|
|
|
{
|
|
|
|
static const unsigned int processor_ops = DXVA2_VideoProcess_YUV2RGB |
|
|
|
|
DXVA2_VideoProcess_StretchX | DXVA2_VideoProcess_StretchY;
|
|
|
|
IDirectXVideoProcessorService *service;
|
|
|
|
IDirectXVideoProcessor *processor;
|
|
|
|
IDirect3DDeviceManager9 *manager;
|
|
|
|
D3DFORMAT format, *rt_formats;
|
|
|
|
DXVA2_VideoProcessorCaps caps;
|
|
|
|
DXVA2_VideoDesc video_desc;
|
|
|
|
IDirect3DDevice9 *device;
|
|
|
|
unsigned int count, i, j;
|
|
|
|
GUID guid, *guids;
|
|
|
|
IDirect3D9 *d3d;
|
|
|
|
HANDLE handle;
|
|
|
|
HWND window;
|
|
|
|
UINT token;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
static const D3DFORMAT input_formats[] =
|
|
|
|
{
|
|
|
|
D3DFMT_X8R8G8B8,
|
|
|
|
D3DFMT_YUY2,
|
|
|
|
MAKEFOURCC('N','V','1','2'),
|
|
|
|
};
|
|
|
|
|
|
|
|
static const D3DFORMAT support_rt_formats[] =
|
|
|
|
{
|
|
|
|
D3DFMT_X8R8G8B8,
|
|
|
|
MAKEFOURCC('N','V','1','2'),
|
|
|
|
D3DFMT_YUY2,
|
|
|
|
};
|
|
|
|
|
|
|
|
window = create_window();
|
|
|
|
d3d = Direct3DCreate9(D3D_SDK_VERSION);
|
|
|
|
ok(!!d3d, "Failed to create a D3D object.\n");
|
|
|
|
if (!(device = create_device(d3d, window)))
|
|
|
|
{
|
|
|
|
skip("Failed to create a D3D device, skipping tests.\n");
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = DXVA2CreateDirect3DDeviceManager9(&token, &manager);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2021-11-23 13:21:45 +01:00
|
|
|
|
|
|
|
hr = IDirect3DDeviceManager9_ResetDevice(manager, device, token);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2021-11-23 13:21:45 +01:00
|
|
|
|
|
|
|
handle = NULL;
|
|
|
|
hr = IDirect3DDeviceManager9_OpenDeviceHandle(manager, &handle);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2021-11-23 13:21:45 +01:00
|
|
|
|
|
|
|
hr = IDirect3DDeviceManager9_GetVideoService(manager, handle, &IID_IDirectXVideoProcessorService,
|
|
|
|
(void **)&service);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2021-11-23 13:21:45 +01:00
|
|
|
|
|
|
|
memset(&video_desc, 0, sizeof(video_desc));
|
|
|
|
video_desc.SampleWidth = 64;
|
|
|
|
video_desc.SampleHeight = 64;
|
|
|
|
video_desc.Format = MAKEFOURCC('N','V','1','2');
|
|
|
|
|
|
|
|
hr = IDirectXVideoProcessorService_CreateVideoProcessor(service, &DXVA2_VideoProcProgressiveDevice, &video_desc,
|
|
|
|
D3DFMT_A8R8G8B8, 0, &processor);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
win_skip("VideoProcProgressiveDevice is not supported.\n");
|
|
|
|
goto unsupported;
|
|
|
|
}
|
|
|
|
IDirectXVideoProcessor_Release(processor);
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(input_formats); ++i)
|
|
|
|
{
|
|
|
|
init_video_desc(&video_desc, input_formats[i]);
|
|
|
|
|
|
|
|
/* Check that progressive device is returned for given input format. */
|
|
|
|
count = 0;
|
|
|
|
hr = IDirectXVideoProcessorService_GetVideoProcessorDeviceGuids(service, &video_desc, &count, &guids);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2021-11-23 13:21:45 +01:00
|
|
|
ok(count > 0, "Unexpected device count.\n");
|
|
|
|
for (j = 0; j < count; ++j)
|
|
|
|
{
|
|
|
|
if (IsEqualGUID(&guids[j], &DXVA2_VideoProcProgressiveDevice)) break;
|
|
|
|
}
|
|
|
|
ok(j < count, "Expected progressive device for format %#x.\n", input_formats[i]);
|
|
|
|
CoTaskMemFree(guids);
|
|
|
|
|
|
|
|
count = 0;
|
|
|
|
hr = IDirectXVideoProcessorService_GetVideoProcessorRenderTargets(service, &DXVA2_VideoProcProgressiveDevice,
|
|
|
|
&video_desc, &count, &rt_formats);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx, format %d.\n", hr, input_formats[i]);
|
2021-11-23 13:21:45 +01:00
|
|
|
ok(count > 0, "Unexpected format count %u.\n", count);
|
|
|
|
for (j = 0; j < count; ++j)
|
|
|
|
{
|
|
|
|
ok(check_format_list(rt_formats[j], support_rt_formats, ARRAY_SIZE(support_rt_formats)),
|
|
|
|
"Unexpected rt format %#x for input format %#x.\n", rt_formats[j], input_formats[i]);
|
|
|
|
}
|
|
|
|
CoTaskMemFree(rt_formats);
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&video_desc, 0, sizeof(video_desc));
|
|
|
|
video_desc.SampleWidth = 64;
|
|
|
|
video_desc.SampleHeight = 64;
|
|
|
|
video_desc.Format = MAKEFOURCC('N','V','1','2');
|
|
|
|
|
|
|
|
hr = IDirectXVideoProcessorService_CreateVideoProcessor(service, &DXVA2_VideoProcProgressiveDevice, &video_desc,
|
|
|
|
D3DFMT_A8R8G8B8, 0, &processor);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2021-11-23 13:21:45 +01:00
|
|
|
|
|
|
|
hr = IDirectXVideoProcessor_GetVideoProcessorCaps(processor, &caps);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2021-11-23 13:21:45 +01:00
|
|
|
ok(caps.DeviceCaps == DXVA2_VPDev_HardwareDevice, "Unexpected device type %#x.\n", caps.DeviceCaps);
|
|
|
|
ok(!caps.NumForwardRefSamples, "Unexpected sample count.\n");
|
|
|
|
ok(!caps.NumBackwardRefSamples, "Unexpected sample count.\n");
|
|
|
|
ok(!caps.Reserved, "Unexpected field.\n");
|
|
|
|
ok((caps.VideoProcessorOperations & processor_ops) == processor_ops, "Unexpected processor operations %#x.\n",
|
|
|
|
caps.VideoProcessorOperations);
|
|
|
|
|
|
|
|
hr = IDirectXVideoProcessor_GetCreationParameters(processor, &guid, NULL, &format, NULL);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2021-11-23 13:21:45 +01:00
|
|
|
ok(IsEqualGUID(&guid, &DXVA2_VideoProcProgressiveDevice), "Unexpected device guid.\n");
|
|
|
|
ok(format == D3DFMT_A8R8G8B8, "Unexpected format %u.\n", format);
|
|
|
|
|
|
|
|
IDirectXVideoProcessor_Release(processor);
|
|
|
|
|
|
|
|
unsupported:
|
|
|
|
IDirectXVideoProcessorService_Release(service);
|
|
|
|
|
|
|
|
hr = IDirect3DDeviceManager9_CloseDeviceHandle(manager, handle);
|
2022-02-20 17:31:32 +01:00
|
|
|
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
2021-11-23 13:21:45 +01:00
|
|
|
|
|
|
|
IDirect3DDevice9_Release(device);
|
|
|
|
IDirect3DDeviceManager9_Release(manager);
|
|
|
|
|
|
|
|
done:
|
|
|
|
IDirect3D9_Release(d3d);
|
|
|
|
DestroyWindow(window);
|
|
|
|
}
|
|
|
|
|
2020-06-22 12:45:29 +02:00
|
|
|
START_TEST(dxva2)
|
|
|
|
{
|
|
|
|
test_device_manager();
|
2020-10-19 16:10:40 +02:00
|
|
|
test_video_processor();
|
2021-11-23 13:21:45 +01:00
|
|
|
test_progressive_device();
|
2020-06-22 12:45:29 +02:00
|
|
|
}
|