Commit 527882d4 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

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

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