Commit 574fd3d3 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

dxva2: Implement CreateSurface().

parent 7c1b534a
......@@ -19,6 +19,7 @@
#define COBJMACROS
#include <stdarg.h>
#include <limits.h>
#include "windef.h"
#include "winbase.h"
#include "d3d9.h"
......@@ -132,12 +133,40 @@ static ULONG WINAPI device_manager_processor_service_Release(IDirectXVideoProces
static HRESULT WINAPI device_manager_processor_service_CreateSurface(IDirectXVideoProcessorService *iface,
UINT width, UINT height, UINT backbuffers, D3DFORMAT format, D3DPOOL pool, DWORD usage, DWORD dxvaType,
IDirect3DSurface9 **surface, HANDLE *shared_handle)
IDirect3DSurface9 **surfaces, HANDLE *shared_handle)
{
FIXME("%p, %u, %u, %u, %u, %u, %u, %u, %p, %p.\n", iface, width, height, backbuffers, format, pool, usage, dxvaType,
surface, shared_handle);
struct device_manager *manager = impl_from_IDirectXVideoProcessorService(iface);
unsigned int i, j;
HRESULT hr;
return E_NOTIMPL;
TRACE("%p, %u, %u, %u, %u, %u, %u, %u, %p, %p.\n", iface, width, height, backbuffers, format, pool, usage, dxvaType,
surfaces, shared_handle);
if (backbuffers >= UINT_MAX)
return E_INVALIDARG;
memset(surfaces, 0, (backbuffers + 1) * sizeof(*surfaces));
for (i = 0; i < backbuffers + 1; ++i)
{
if (FAILED(hr = IDirect3DDevice9_CreateOffscreenPlainSurface(manager->device, width, height, format,
pool, &surfaces[i], NULL)))
break;
}
if (FAILED(hr))
{
for (j = 0; j < i; ++j)
{
if (surfaces[j])
{
IDirect3DSurface9_Release(surfaces[j]);
surfaces[j] = NULL;
}
}
}
return hr;
}
static HRESULT WINAPI device_manager_processor_service_RegisterVideoProcessorSoftwareDevice(
......
......@@ -59,13 +59,31 @@ static IDirect3DDevice9 *create_device(IDirect3D9 *d3d9, HWND focus_window)
return device;
}
static void test_surface_desc(IDirect3DSurface9 *surface)
{
D3DSURFACE_DESC desc = { 0 };
HRESULT hr;
hr = IDirect3DSurface9_GetDesc(surface, &desc);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
ok(desc.Format == D3DFMT_X8R8G8B8, "Unexpected format %d.\n", desc.Format);
ok(desc.Type == D3DRTYPE_SURFACE, "Unexpected type %d.\n", desc.Type);
ok(desc.Usage == 0, "Unexpected usage %d.\n", desc.Usage);
ok(desc.Pool == D3DPOOL_DEFAULT, "Unexpected pool %d.\n", desc.Pool);
ok(desc.MultiSampleType == D3DMULTISAMPLE_NONE, "Unexpected multisample type %d.\n", desc.MultiSampleType);
ok(desc.MultiSampleQuality == 0, "Unexpected multisample quality %d.\n", desc.MultiSampleQuality);
ok(desc.Width == 64, "Unexpected width %u.\n", desc.Width);
ok(desc.Height == 64, "Unexpected height %u.\n", desc.Height);
}
static void test_device_manager(void)
{
IDirectXVideoProcessorService *processor_service;
IDirectXVideoAccelerationService *accel_service;
IDirect3DDevice9 *device, *device2, *device3;
IDirect3DDeviceManager9 *manager;
IDirect3DSurface9 *surface;
IDirect3DSurface9 *surfaces[2];
int refcount, refcount2;
HANDLE handle, handle1;
IDirect3D9 *d3d;
......@@ -262,12 +280,20 @@ static void test_device_manager(void)
hr = DXVA2CreateVideoService(device, &IID_IDirectXVideoAccelerationService, (void **)&accel_service);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
surfaces[0] = surfaces[1] = NULL;
hr = IDirectXVideoAccelerationService_CreateSurface(accel_service, 64, 64, 0, D3DFMT_X8R8G8B8,
D3DPOOL_DEFAULT, 0, DXVA2_VideoProcessorRenderTarget, surfaces, NULL);
ok(hr == S_OK, "Failed to create a surface, hr %#x.\n", hr);
ok(!!surfaces[0] && !surfaces[1], "Unexpected surfaces.\n");
IDirect3DSurface9_Release(surfaces[0]);
hr = IDirectXVideoAccelerationService_CreateSurface(accel_service, 64, 64, 1, D3DFMT_X8R8G8B8,
D3DPOOL_DEFAULT, 0, DXVA2_VideoProcessorRenderTarget, &surface, NULL);
todo_wine
D3DPOOL_DEFAULT, 0, DXVA2_VideoProcessorRenderTarget, surfaces, NULL);
ok(hr == S_OK, "Failed to create a surface, hr %#x.\n", hr);
if (SUCCEEDED(hr))
IDirect3DSurface9_Release(surface);
ok(!!surfaces[0] && !!surfaces[1], "Unexpected surfaces.\n");
test_surface_desc(surfaces[0]);
IDirect3DSurface9_Release(surfaces[0]);
IDirect3DSurface9_Release(surfaces[1]);
IDirectXVideoAccelerationService_Release(accel_service);
......@@ -281,20 +307,16 @@ todo_wine
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
hr = IDirectXVideoAccelerationService_CreateSurface(accel_service, 64, 64, 0, D3DFMT_X8R8G8B8,
D3DPOOL_DEFAULT, 0, DXVA2_VideoProcessorRenderTarget, surfaces, NULL);
ok(hr == S_OK, "Failed to create a surface, hr %#x.\n", hr);
if (SUCCEEDED(hr))
{
hr = IDirect3DSurface9_GetDevice(surface, &device3);
hr = IDirect3DSurface9_GetDevice(surfaces[0], &device3);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
ok(device2 == device3, "Unexpected device.\n");
IDirect3DDevice9_Release(device3);
IDirect3DSurface9_Release(surface);
}
IDirect3DSurface9_Release(surfaces[0]);
IDirectXVideoAccelerationService_Release(accel_service);
......
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