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

This commit is contained in:
Henri Verbeet 2014-04-22 09:02:12 +02:00 committed by Alexandre Julliard
parent f1706b0387
commit 25d2de7b93

View File

@ -2606,44 +2606,53 @@ done:
* clipped when D3DPMISCCAPS_CLIPTLVERTS is set, clamped when it isn't. * clipped when D3DPMISCCAPS_CLIPTLVERTS is set, clamped when it isn't.
* - The viewport's MinZ/MaxZ is irrelevant for this. * - The viewport's MinZ/MaxZ is irrelevant for this.
*/ */
static void depth_clamp_test(IDirect3DDevice8 *device) static void depth_clamp_test(void)
{ {
const struct tvertex quad1[] = IDirect3DDevice8 *device;
D3DVIEWPORT8 vp;
IDirect3D8 *d3d;
D3DCOLOR color;
ULONG refcount;
D3DCAPS8 caps;
HWND window;
HRESULT hr;
static const struct tvertex quad1[] =
{ {
{ 0.0f, 0.0f, 5.0f, 1.0f, 0xff002b7f}, { 0.0f, 0.0f, 5.0f, 1.0f, 0xff002b7f},
{640.0f, 0.0f, 5.0f, 1.0f, 0xff002b7f}, {640.0f, 0.0f, 5.0f, 1.0f, 0xff002b7f},
{ 0.0f, 480.0f, 5.0f, 1.0f, 0xff002b7f}, { 0.0f, 480.0f, 5.0f, 1.0f, 0xff002b7f},
{640.0f, 480.0f, 5.0f, 1.0f, 0xff002b7f}, {640.0f, 480.0f, 5.0f, 1.0f, 0xff002b7f},
}; };
const struct tvertex quad2[] = static const struct tvertex quad2[] =
{ {
{ 0.0f, 300.0f, 10.0f, 1.0f, 0xfff9e814}, { 0.0f, 300.0f, 10.0f, 1.0f, 0xfff9e814},
{640.0f, 300.0f, 10.0f, 1.0f, 0xfff9e814}, {640.0f, 300.0f, 10.0f, 1.0f, 0xfff9e814},
{ 0.0f, 360.0f, 10.0f, 1.0f, 0xfff9e814}, { 0.0f, 360.0f, 10.0f, 1.0f, 0xfff9e814},
{640.0f, 360.0f, 10.0f, 1.0f, 0xfff9e814}, {640.0f, 360.0f, 10.0f, 1.0f, 0xfff9e814},
}; };
const struct tvertex quad3[] = static const struct tvertex quad3[] =
{ {
{112.0f, 108.0f, 5.0f, 1.0f, 0xffffffff}, {112.0f, 108.0f, 5.0f, 1.0f, 0xffffffff},
{208.0f, 108.0f, 5.0f, 1.0f, 0xffffffff}, {208.0f, 108.0f, 5.0f, 1.0f, 0xffffffff},
{112.0f, 204.0f, 5.0f, 1.0f, 0xffffffff}, {112.0f, 204.0f, 5.0f, 1.0f, 0xffffffff},
{208.0f, 204.0f, 5.0f, 1.0f, 0xffffffff}, {208.0f, 204.0f, 5.0f, 1.0f, 0xffffffff},
}; };
const struct tvertex quad4[] = static const struct tvertex quad4[] =
{ {
{ 42.0f, 41.0f, 10.0f, 1.0f, 0xffffffff}, { 42.0f, 41.0f, 10.0f, 1.0f, 0xffffffff},
{112.0f, 41.0f, 10.0f, 1.0f, 0xffffffff}, {112.0f, 41.0f, 10.0f, 1.0f, 0xffffffff},
{ 42.0f, 108.0f, 10.0f, 1.0f, 0xffffffff}, { 42.0f, 108.0f, 10.0f, 1.0f, 0xffffffff},
{112.0f, 108.0f, 10.0f, 1.0f, 0xffffffff}, {112.0f, 108.0f, 10.0f, 1.0f, 0xffffffff},
}; };
const struct vertex quad5[] = static const struct vertex quad5[] =
{ {
{ -0.5f, 0.5f, 10.0f, 0xff14f914}, { -0.5f, 0.5f, 10.0f, 0xff14f914},
{ 0.5f, 0.5f, 10.0f, 0xff14f914}, { 0.5f, 0.5f, 10.0f, 0xff14f914},
{ -0.5f, -0.5f, 10.0f, 0xff14f914}, { -0.5f, -0.5f, 10.0f, 0xff14f914},
{ 0.5f, -0.5f, 10.0f, 0xff14f914}, { 0.5f, -0.5f, 10.0f, 0xff14f914},
}; };
const struct vertex quad6[] = static const struct vertex quad6[] =
{ {
{ -1.0f, 0.5f, 10.0f, 0xfff91414}, { -1.0f, 0.5f, 10.0f, 0xfff91414},
{ 1.0f, 0.5f, 10.0f, 0xfff91414}, { 1.0f, 0.5f, 10.0f, 0xfff91414},
@ -2651,10 +2660,18 @@ static void depth_clamp_test(IDirect3DDevice8 *device)
{ 1.0f, 0.25f, 10.0f, 0xfff91414}, { 1.0f, 0.25f, 10.0f, 0xfff91414},
}; };
D3DVIEWPORT8 vp; window = CreateWindowA("static", "d3d8_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
D3DCOLOR color; 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");
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), "Failed to get device caps, hr %#x.\n", hr);
vp.X = 0; vp.X = 0;
vp.Y = 0; vp.Y = 0;
@ -2663,9 +2680,6 @@ static void depth_clamp_test(IDirect3DDevice8 *device)
vp.MinZ = 0.0; vp.MinZ = 0.0;
vp.MaxZ = 7.5; vp.MaxZ = 7.5;
hr = IDirect3DDevice8_GetDeviceCaps(device, &caps);
ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
hr = IDirect3DDevice8_SetViewport(device, &vp); hr = IDirect3DDevice8_SetViewport(device, &vp);
ok(SUCCEEDED(hr), "SetViewport failed, hr %#x.\n", hr); ok(SUCCEEDED(hr), "SetViewport failed, hr %#x.\n", hr);
@ -2747,10 +2761,11 @@ static void depth_clamp_test(IDirect3DDevice8 *device)
hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL); hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
ok(SUCCEEDED(hr), "Present failed (0x%08x)\n", hr); ok(SUCCEEDED(hr), "Present failed (0x%08x)\n", hr);
vp.MinZ = 0.0; refcount = IDirect3DDevice8_Release(device);
vp.MaxZ = 1.0; ok(!refcount, "Device has %u references left.\n", refcount);
hr = IDirect3DDevice8_SetViewport(device, &vp); done:
ok(SUCCEEDED(hr), "SetViewport failed, hr %#x.\n", hr); IDirect3D8_Release(d3d);
DestroyWindow(window);
} }
static void depth_buffer_test(void) static void depth_buffer_test(void)
@ -5014,7 +5029,6 @@ START_TEST(visual)
} }
test_sanity(device_ptr); test_sanity(device_ptr);
depth_clamp_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);
@ -5022,6 +5036,7 @@ cleanup:
IDirect3D8_Release(d3d); IDirect3D8_Release(d3d);
DestroyWindow(window); DestroyWindow(window);
depth_clamp_test();
lighting_test(); lighting_test();
clear_test(); clear_test();
fog_test(); fog_test();