d3d8/tests: Use a separate device for shadow_test().

This commit is contained in:
Henri Verbeet 2014-04-17 08:21:19 +02:00 committed by Alexandre Julliard
parent 3068d827da
commit 527882d4e2
1 changed files with 34 additions and 28 deletions

View File

@ -3137,8 +3137,18 @@ static void intz_test(IDirect3DDevice8 *device)
IDirect3DSurface8_Release(rt);
}
static void shadow_test(IDirect3DDevice8 *device)
static void shadow_test(void)
{
IDirect3DSurface8 *original_rt, *rt;
IDirect3DDevice8 *device;
IDirect3D8 *d3d;
ULONG refcount;
D3DCAPS8 caps;
HWND window;
HRESULT hr;
DWORD ps;
UINT i;
static const DWORD ps_code[] =
{
0xffff0101, /* ps_1_1 */
@ -3153,7 +3163,7 @@ static void shadow_test(IDirect3DDevice8 *device)
0x40000001, 0x80080000, 0xa0aa0002, /* +mov r0.w, c2.z */
0x0000ffff, /* end */
};
struct
static const struct
{
D3DFORMAT format;
const char *name;
@ -3168,7 +3178,7 @@ static void shadow_test(IDirect3DDevice8 *device)
{D3DFMT_D24X4S4, "D3DFMT_D24X4S4"},
{D3DFMT_D16, "D3DFMT_D16"},
};
struct
static const struct
{
float x, y, z;
float s0, t0, p0;
@ -3181,7 +3191,7 @@ static void shadow_test(IDirect3DDevice8 *device)
{ -1.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ 1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f},
};
struct
static const struct
{
UINT x, y;
D3DCOLOR color;
@ -3198,27 +3208,27 @@ static void shadow_test(IDirect3DDevice8 *device)
{240, 60, D3DCOLOR_ARGB(0x00, 0x00, 0x00, 0x00)},
};
IDirect3DSurface8 *original_ds, *original_rt, *rt;
IDirect3D8 *d3d8;
D3DCAPS8 caps;
HRESULT hr;
DWORD ps;
UINT i;
window = CreateWindowA("static", "d3d8_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
0, 0, 640, 480, NULL, NULL, NULL, NULL);
d3d = Direct3DCreate8(D3D_SDK_VERSION);
ok(!!d3d, "Failed to create a D3D object.\n");
if (!(device = create_device(d3d, window, window, TRUE)))
{
skip("Failed to create a D3D device, skipping tests.\n");
goto done;
}
hr = IDirect3DDevice8_GetDeviceCaps(device, &caps);
ok(SUCCEEDED(hr), "GetDeviceCaps failed, hr %#x.\n", hr);
if (caps.PixelShaderVersion < D3DPS_VERSION(1, 1))
{
skip("No pixel shader 1.1 support, skipping shadow test.\n");
return;
IDirect3DDevice8_Release(device);
goto done;
}
hr = IDirect3DDevice8_GetDirect3D(device, &d3d8);
ok(SUCCEEDED(hr), "GetDirect3D failed, hr %#x.\n", hr);
hr = IDirect3DDevice8_GetRenderTarget(device, &original_rt);
ok(SUCCEEDED(hr), "GetRenderTarget failed, hr %#x.\n", hr);
hr = IDirect3DDevice8_GetDepthStencilSurface(device, &original_ds);
ok(SUCCEEDED(hr), "GetDepthStencilSurface failed, hr %#x.\n", hr);
hr = IDirect3DDevice8_CreateRenderTarget(device, 1024, 1024, D3DFMT_A8R8G8B8,
D3DMULTISAMPLE_NONE, FALSE, &rt);
@ -3268,9 +3278,9 @@ static void shadow_test(IDirect3DDevice8 *device)
IDirect3DSurface8 *ds;
unsigned int j;
hr = IDirect3D8_CheckDeviceFormat(d3d8, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8,
D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE, format);
if (FAILED(hr)) continue;
if (FAILED(IDirect3D8_CheckDeviceFormat(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
D3DFMT_X8R8G8B8, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE, format)))
continue;
hr = IDirect3DDevice8_CreateTexture(device, 1024, 1024, 1,
D3DUSAGE_DEPTHSTENCIL, format, D3DPOOL_DEFAULT, &texture);
@ -3335,19 +3345,15 @@ static void shadow_test(IDirect3DDevice8 *device)
ok(SUCCEEDED(hr), "Present failed, hr %#x.\n", hr);
}
hr = IDirect3DDevice8_SetPixelShader(device, 0);
ok(SUCCEEDED(hr), "SetPixelShader failed, hr %#x.\n", hr);
hr = IDirect3DDevice8_DeletePixelShader(device, ps);
ok(SUCCEEDED(hr), "DeletePixelShader failed, hr %#x.\n", hr);
hr = IDirect3DDevice8_SetRenderTarget(device, original_rt, original_ds);
ok(SUCCEEDED(hr), "SetRenderTarget failed, hr %#x.\n", hr);
IDirect3DSurface8_Release(original_ds);
IDirect3DSurface8_Release(original_rt);
IDirect3DSurface8_Release(rt);
IDirect3D8_Release(d3d8);
refcount = IDirect3DDevice8_Release(device);
ok(!refcount, "Device has %u references left.\n", refcount);
done:
IDirect3D8_Release(d3d);
DestroyWindow(window);
}
static void multisample_copy_rects_test(void)
@ -4816,7 +4822,6 @@ START_TEST(visual)
depth_buffer_test(device_ptr);
depth_buffer2_test(device_ptr);
intz_test(device_ptr);
shadow_test(device_ptr);
refcount = IDirect3DDevice8_Release(device_ptr);
ok(!refcount, "Device has %u references left.\n", refcount);
@ -4824,6 +4829,7 @@ cleanup:
IDirect3D8_Release(d3d);
DestroyWindow(window);
shadow_test();
multisample_copy_rects_test();
zenable_test();
resz_test();