Stefan Dösinger : d3d8: Add more tests for NULL render targets.
Alexandre Julliard
julliard at winehq.org
Tue Apr 26 11:35:46 CDT 2011
Module: wine
Branch: master
Commit: e140077cc7008dcb83d76bca24c823c534950fc9
URL: http://source.winehq.org/git/wine.git/?a=commit;h=e140077cc7008dcb83d76bca24c823c534950fc9
Author: Stefan Dösinger <stefan at codeweavers.com>
Date: Mon Apr 25 20:22:50 2011 +0200
d3d8: Add more tests for NULL render targets.
---
dlls/d3d8/device.c | 16 +++++++++++++++-
dlls/d3d8/tests/device.c | 33 ++++++++++++++++++++++++++++++---
2 files changed, 45 insertions(+), 4 deletions(-)
diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c
index ae90a16..99481bf 100644
--- a/dlls/d3d8/device.c
+++ b/dlls/d3d8/device.c
@@ -1028,11 +1028,25 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetRenderTarget(IDirect3DDevice8 *ifa
{
struct wined3d_resource_desc ds_desc, rt_desc;
struct wined3d_resource *wined3d_resource;
+ IDirect3DSurface8 *orig_rt = NULL;
+
+ /* If no render target is passed in check the size against the current RT */
+ if (!pRenderTarget)
+ {
+ hr = IDirect3DDevice8_GetRenderTarget(iface, &orig_rt);
+ if (FAILED(hr))
+ {
+ wined3d_mutex_unlock();
+ return hr;
+ }
+ pSurface = (IDirect3DSurface8Impl *)orig_rt;
+ }
wined3d_resource = IWineD3DSurface_GetResource(pZSurface->wineD3DSurface);
wined3d_resource_get_desc(wined3d_resource, &ds_desc);
wined3d_resource = IWineD3DSurface_GetResource(pSurface->wineD3DSurface);
wined3d_resource_get_desc(wined3d_resource, &rt_desc);
+ if (orig_rt) IDirect3DSurface8_Release(orig_rt);
if (ds_desc.width < rt_desc.width || ds_desc.height < rt_desc.height)
{
@@ -1046,7 +1060,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetRenderTarget(IDirect3DDevice8 *ifa
if (hr == WINED3D_OK || hr == WINED3DERR_NOTFOUND)
{
hr = IWineD3DDevice_SetDepthStencilSurface(This->WineD3DDevice, pZSurface ? pZSurface->wineD3DSurface : NULL);
- if (SUCCEEDED(hr) && pSurface)
+ if (SUCCEEDED(hr) && pRenderTarget)
{
hr = IWineD3DDevice_SetRenderTarget(This->WineD3DDevice, 0, pSurface->wineD3DSurface, TRUE);
if (FAILED(hr)) IWineD3DDevice_SetDepthStencilSurface(This->WineD3DDevice, original_ds);
diff --git a/dlls/d3d8/tests/device.c b/dlls/d3d8/tests/device.c
index a9fe6f3..557eec1 100644
--- a/dlls/d3d8/tests/device.c
+++ b/dlls/d3d8/tests/device.c
@@ -1409,7 +1409,7 @@ static void test_depth_stencil_reset(void)
{
D3DPRESENT_PARAMETERS present_parameters;
D3DDISPLAYMODE display_mode;
- IDirect3DSurface8 *surface;
+ IDirect3DSurface8 *surface, *orig_rt;
IDirect3DDevice8 *device = NULL;
IDirect3D8 *d3d8;
UINT refcount;
@@ -1438,6 +1438,9 @@ static void test_depth_stencil_reset(void)
goto cleanup;
}
+ hr = IDirect3DDevice8_GetRenderTarget(device, &orig_rt);
+ ok(hr == D3D_OK, "GetRenderTarget failed with 0x%08x\n", hr);
+
hr = IDirect3DDevice8_TestCooperativeLevel(device);
ok(SUCCEEDED(hr), "TestCooperativeLevel failed with %#x\n", hr);
@@ -1446,8 +1449,9 @@ static void test_depth_stencil_reset(void)
hr = IDirect3DDevice8_GetRenderTarget(device, &surface);
ok(hr == D3D_OK, "GetRenderTarget failed with 0x%08x\n", hr);
- ok(surface != NULL, "Render target should not be NULL\n");
+ ok(surface == orig_rt, "Render target is %p, should be %p\n", surface, orig_rt);
if (surface) IDirect3DSurface8_Release(surface);
+ IDirect3DSurface8_Release(orig_rt);
hr = IDirect3DDevice8_GetDepthStencilSurface(device, &surface);
ok(hr == D3DERR_NOTFOUND, "GetDepthStencilSurface returned 0x%08x, expected D3DERR_NOTFOUND\n", hr);
@@ -2120,7 +2124,8 @@ cleanup:
static void test_depth_stencil_size(void)
{
IDirect3DDevice8 *device;
- IDirect3DSurface8 *ds, *rt, *ds_bigger;
+ IDirect3DSurface8 *ds, *rt, *ds_bigger, *ds_bigger2;
+ IDirect3DSurface8 *surf;
IDirect3D8 *d3d8;
HRESULT hr;
HWND hwnd;
@@ -2140,15 +2145,37 @@ static void test_depth_stencil_size(void)
ok(SUCCEEDED(hr), "IDirect3DDevice8_CreateDepthStencilSurface failed, hr %#x.\n", hr);
hr = IDirect3DDevice8_CreateDepthStencilSurface(device, 128, 128, D3DFMT_D24X8, D3DMULTISAMPLE_NONE, &ds_bigger);
ok(SUCCEEDED(hr), "IDirect3DDevice8_CreateDepthStencilSurface failed, hr %#x.\n", hr);
+ hr = IDirect3DDevice8_CreateDepthStencilSurface(device, 128, 128, D3DFMT_D24X8, D3DMULTISAMPLE_NONE, &ds_bigger2);
+ ok(SUCCEEDED(hr), "IDirect3DDevice8_CreateDepthStencilSurface failed, hr %#x.\n", hr);
hr = IDirect3DDevice8_SetRenderTarget(device, rt, ds);
ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice8_SetRenderTarget returned %#x, expected D3DERR_INVALIDCALL.\n", hr);
hr = IDirect3DDevice8_SetRenderTarget(device, rt, ds_bigger);
ok(SUCCEEDED(hr), "IDirect3DDevice8_CreateDepthStencilSurface failed, hr %#x.\n", hr);
+ /* try to set the small ds without changing the render target at the same time */
+ hr = IDirect3DDevice8_SetRenderTarget(device, NULL, ds);
+ ok(hr == D3DERR_INVALIDCALL, "IDirect3DDevice8_SetRenderTarget returned %#x, expected D3DERR_INVALIDCALL.\n", hr);
+ hr = IDirect3DDevice8_SetRenderTarget(device, NULL, ds_bigger2);
+ ok(SUCCEEDED(hr), "IDirect3DDevice8_CreateDepthStencilSurface failed, hr %#x.\n", hr);
+
+ hr = IDirect3DDevice8_GetRenderTarget(device, &surf);
+ ok(surf == rt, "The render target is %p, expected %p\n", surf, rt);
+ IDirect3DSurface8_Release(surf);
+ hr = IDirect3DDevice8_GetDepthStencilSurface(device, &surf);
+ ok(surf == ds_bigger2, "The depth stencil is %p, expected %p\n", surf, ds_bigger2);
+ IDirect3DSurface8_Release(surf);
+
+ hr = IDirect3DDevice8_SetRenderTarget(device, NULL, NULL);
+ ok(SUCCEEDED(hr), "IDirect3DDevice8_CreateDepthStencilSurface failed, hr %#x.\n", hr);
+ hr = IDirect3DDevice8_GetDepthStencilSurface(device, &surf);
+ ok(surf == NULL, "The depth stencil is %p, expected NULL\n", surf);
+ if (surf) IDirect3DSurface8_Release(surf);
+
IDirect3DSurface8_Release(rt);
IDirect3DSurface8_Release(ds);
IDirect3DSurface8_Release(ds_bigger);
+ IDirect3DSurface8_Release(ds_bigger2);
cleanup:
if (d3d8) IDirect3D8_Release(d3d8);
More information about the wine-cvs
mailing list