Commit 0ed3eb01 authored by Józef Kucia's avatar Józef Kucia Committed by Alexandre Julliard

d3dx9: Implement ID3DXRenderToSurface::GetDesc.

parent 5c6438e8
......@@ -28,6 +28,7 @@ struct render_to_surface
LONG ref;
IDirect3DDevice9 *device;
D3DXRTS_DESC desc;
};
static inline struct render_to_surface *impl_from_ID3DXRenderToSurface(ID3DXRenderToSurface *iface)
......@@ -91,8 +92,14 @@ static HRESULT WINAPI D3DXRenderToSurface_GetDevice(ID3DXRenderToSurface *iface,
static HRESULT WINAPI D3DXRenderToSurface_GetDesc(ID3DXRenderToSurface *iface,
D3DXRTS_DESC *desc)
{
FIXME("(%p)->(%p): stub\n", iface, desc);
return E_NOTIMPL;
struct render_to_surface *render = impl_from_ID3DXRenderToSurface(iface);
TRACE("(%p)->(%p)\n", iface, desc);
if (!desc) return D3DERR_INVALIDCALL;
*desc = render->desc;
return D3D_OK;
}
static HRESULT WINAPI D3DXRenderToSurface_BeginScene(ID3DXRenderToSurface *iface,
......@@ -147,7 +154,7 @@ HRESULT WINAPI D3DXCreateRenderToSurface(IDirect3DDevice9 *device,
{
struct render_to_surface *render;
FIXME("(%p, %u, %u, %#x, %d, %#x, %p): semi-stub\n", device, width, height, format,
TRACE("(%p, %u, %u, %#x, %d, %#x, %p)\n", device, width, height, format,
depth_stencil, depth_stencil_format, out);
if (!device || !out) return D3DERR_INVALIDCALL;
......@@ -161,6 +168,12 @@ HRESULT WINAPI D3DXCreateRenderToSurface(IDirect3DDevice9 *device,
IDirect3DDevice9_AddRef(device);
render->device = device;
render->desc.Width = width;
render->desc.Height = height;
render->desc.Format = format;
render->desc.DepthStencil = depth_stencil;
render->desc.DepthStencilFormat = depth_stencil_format;
*out = &render->ID3DXRenderToSurface_iface;
return D3D_OK;
}
......@@ -448,9 +448,20 @@ static void test_ID3DXFont(IDirect3DDevice9 *device)
void test_D3DXCreateRenderToSurface(IDirect3DDevice9 *device)
{
int i;
HRESULT hr;
ULONG ref_count;
D3DXRTS_DESC desc;
ID3DXRenderToSurface *render = (void *)0xdeadbeef;
static const D3DXRTS_DESC tests[] =
{
{ 0, 256, D3DFMT_A8R8G8B8, FALSE, D3DFMT_UNKNOWN },
{ 256, 0, D3DFMT_A8R8G8B8, FALSE, D3DFMT_UNKNOWN },
{ 256, 0, D3DFMT_A8R8G8B8, FALSE, D3DFMT_D24S8 },
{ 256, 256, D3DFMT_UNKNOWN, FALSE, D3DFMT_R8G8B8 },
{ 0, 0, D3DFMT_UNKNOWN, FALSE, D3DFMT_UNKNOWN },
{ -1, -1, MAKEFOURCC('B','A','D','F'), TRUE, MAKEFOURCC('B','A','D','F') }
};
hr = D3DXCreateRenderToSurface(NULL /* device */, 256, 256, D3DFMT_A8R8G8B8, FALSE, D3DFMT_UNKNOWN, &render);
ok(hr == D3DERR_INVALIDCALL, "D3DXCreateRenderToSurface returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
......@@ -459,21 +470,28 @@ void test_D3DXCreateRenderToSurface(IDirect3DDevice9 *device)
hr = D3DXCreateRenderToSurface(device, 256, 256, D3DFMT_A8R8G8B8, FALSE, D3DFMT_UNKNOWN, NULL /* out */);
ok(hr == D3DERR_INVALIDCALL, "D3DXCreateRenderToSurface returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
hr = D3DXCreateRenderToSurface(device, 0 /* width */, 256, D3DFMT_A8R8G8B8, FALSE, D3DFMT_UNKNOWN, &render);
ok(hr == D3D_OK, "D3DXCreateRenderToSurface returned %#x, expected %#x\n", hr, D3D_OK);
if (SUCCEEDED(hr)) ID3DXRenderToSurface_Release(render);
hr = D3DXCreateRenderToSurface(device, 256, 0 /* height */, D3DFMT_A8R8G8B8, FALSE, D3DFMT_UNKNOWN, &render);
ok(hr == D3D_OK, "D3DXCreateRenderToSurface returned %#x, expected %#x\n", hr, D3D_OK);
if (SUCCEEDED(hr)) ID3DXRenderToSurface_Release(render);
hr = D3DXCreateRenderToSurface(device, 256, 256, D3DFMT_UNKNOWN /* format */, FALSE, D3DFMT_UNKNOWN, &render);
ok(hr == D3D_OK, "D3DXCreateRenderToSurface returned %#x, expected %#x\n", hr, D3D_OK);
if (SUCCEEDED(hr)) ID3DXRenderToSurface_Release(render);
hr = D3DXCreateRenderToSurface(device, 0, 0, D3DFMT_UNKNOWN, FALSE, D3DFMT_UNKNOWN, &render);
ok(hr == D3D_OK, "D3DXCreateRenderToSurface returned %#x, expected %#x\n", hr, D3D_OK);
if (SUCCEEDED(hr)) ID3DXRenderToSurface_Release(render);
for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++)
{
hr = D3DXCreateRenderToSurface(device, tests[i].Width, tests[i].Height, tests[i].Format, tests[i].DepthStencil,
tests[i].DepthStencilFormat, &render);
ok(hr == D3D_OK, "%d: D3DXCreateRenderToSurface returned %#x, expected %#x\n", i, hr, D3D_OK);
if (SUCCEEDED(hr))
{
hr = ID3DXRenderToSurface_GetDesc(render, &desc);
ok(hr == D3D_OK, "%d: GetDesc failed %#x\n", i, hr);
if (SUCCEEDED(hr))
{
ok(desc.Width == tests[i].Width, "%d: Got width %u, expected %u\n", i, desc.Width, tests[i].Width);
ok(desc.Height == tests[i].Height, "%d: Got height %u, expected %u\n", i, desc.Height, tests[i].Height);
ok(desc.Format == tests[i].Format, "%d: Got format %#x, expected %#x\n", i, desc.Format, tests[i].Format);
ok(desc.DepthStencil == tests[i].DepthStencil, "%d: Got depth stencil %d, expected %d\n",
i, desc.DepthStencil, tests[i].DepthStencil);
ok(desc.DepthStencilFormat == tests[i].DepthStencilFormat, "%d: Got depth stencil format %#x, expected %#x\n",
i, desc.DepthStencilFormat, tests[i].DepthStencilFormat);
}
ID3DXRenderToSurface_Release(render);
}
}
/* check device ref count */
ref_count = get_ref((IUnknown *)device);
......
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