Commit ef5e4c79 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

d3d8/tests: Make the sanity test a normal test.

parent 5b8d3a0c
...@@ -38,20 +38,6 @@ struct vec4 ...@@ -38,20 +38,6 @@ struct vec4
float x, y, z, w; float x, y, z, w;
}; };
static HWND create_window(void)
{
WNDCLASSA wc = {0};
HWND ret;
wc.lpfnWndProc = DefWindowProcA;
wc.lpszClassName = "d3d8_test_wc";
RegisterClassA(&wc);
ret = CreateWindowA("d3d8_test_wc", "d3d8_test", WS_POPUP | WS_SYSMENU,
20, 20, 640, 480, 0, 0, 0, 0);
ShowWindow(ret, SW_SHOW);
return ret;
}
static BOOL color_match(D3DCOLOR c1, D3DCOLOR c2, BYTE max_diff) static BOOL color_match(D3DCOLOR c1, D3DCOLOR c2, BYTE max_diff)
{ {
if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff) return FALSE; if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff) return FALSE;
...@@ -126,22 +112,13 @@ out: ...@@ -126,22 +112,13 @@ out:
return ret; return ret;
} }
static IDirect3DDevice8 *init_d3d8(void) static IDirect3DDevice8 *create_device(IDirect3D8 *d3d, HWND device_window, HWND focus_window, BOOL windowed)
{ {
D3DPRESENT_PARAMETERS present_parameters; D3DPRESENT_PARAMETERS present_parameters = {0};
IDirect3DDevice8 *device = NULL; IDirect3DDevice8 *device;
IDirect3D8 *d3d8;
HRESULT hr;
if (!(d3d8 = Direct3DCreate8(D3D_SDK_VERSION))) present_parameters.Windowed = windowed;
{ present_parameters.hDeviceWindow = device_window;
skip("could not create D3D8\n");
return NULL;
}
ZeroMemory(&present_parameters, sizeof(present_parameters));
present_parameters.Windowed = TRUE;
present_parameters.hDeviceWindow = create_window();
present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD; present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
present_parameters.BackBufferWidth = 640; present_parameters.BackBufferWidth = 640;
present_parameters.BackBufferHeight = 480; present_parameters.BackBufferHeight = 480;
...@@ -149,12 +126,11 @@ static IDirect3DDevice8 *init_d3d8(void) ...@@ -149,12 +126,11 @@ static IDirect3DDevice8 *init_d3d8(void)
present_parameters.EnableAutoDepthStencil = TRUE; present_parameters.EnableAutoDepthStencil = TRUE;
present_parameters.AutoDepthStencilFormat = D3DFMT_D24S8; present_parameters.AutoDepthStencilFormat = D3DFMT_D24S8;
hr = IDirect3D8_CreateDevice(d3d8, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, if (SUCCEEDED(IDirect3D8_CreateDevice(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, focus_window,
present_parameters.hDeviceWindow, D3DCREATE_HARDWARE_VERTEXPROCESSING, &present_parameters, &device); D3DCREATE_HARDWARE_VERTEXPROCESSING, &present_parameters, &device)))
ok(hr == D3D_OK || hr == D3DERR_INVALIDCALL || broken(hr == D3DERR_NOTAVAILABLE), return device;
"IDirect3D_CreateDevice returned: %#08x\n", hr);
return device; return NULL;
} }
struct vertex struct vertex
...@@ -176,6 +152,28 @@ struct nvertex ...@@ -176,6 +152,28 @@ struct nvertex
DWORD diffuse; DWORD diffuse;
}; };
static void test_sanity(IDirect3DDevice8 *device)
{
D3DCOLOR color;
HRESULT hr;
hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff0000, 1.0f, 0);
ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
color = getPixelColor(device, 1, 1);
ok(color == 0x00ff0000, "Got unexpected color 0x%08x.\n", color);
hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff00ddee, 1.0f, 0);
ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
color = getPixelColor(device, 639, 479);
ok(color == 0x0000ddee, "Got unexpected color 0x%08x.\n", color);
hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL);
ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
}
static void lighting_test(IDirect3DDevice8 *device) static void lighting_test(IDirect3DDevice8 *device)
{ {
HRESULT hr; HRESULT hr;
...@@ -4651,51 +4649,43 @@ static void add_dirty_rect_test(IDirect3DDevice8 *device) ...@@ -4651,51 +4649,43 @@ static void add_dirty_rect_test(IDirect3DDevice8 *device)
START_TEST(visual) START_TEST(visual)
{ {
D3DADAPTER_IDENTIFIER8 identifier;
IDirect3DDevice8 *device_ptr; IDirect3DDevice8 *device_ptr;
HRESULT hr; IDirect3D8 *d3d;
DWORD color; ULONG refcount;
D3DCAPS8 caps; D3DCAPS8 caps;
HWND window;
HRESULT hr;
if (!(device_ptr = init_d3d8())) if (!(d3d = Direct3DCreate8(D3D_SDK_VERSION)))
{ {
win_skip("Could not initialize direct3d\n"); skip("Failed to create D3D8 object.\n");
return; return;
} }
IDirect3DDevice8_GetDeviceCaps(device_ptr, &caps); memset(&identifier, 0, sizeof(identifier));
hr = IDirect3D8_GetAdapterIdentifier(d3d, D3DADAPTER_DEFAULT, 0, &identifier);
/* Check for the reliability of the returned data */ ok(SUCCEEDED(hr), "Failed to get adapter identifier, hr %#x.\n", hr);
hr = IDirect3DDevice8_Clear(device_ptr, 0, NULL, D3DCLEAR_TARGET, 0xffff0000, 0.0, 0); trace("Driver string: \"%s\"\n", identifier.Driver);
if(FAILED(hr)) trace("Description string: \"%s\"\n", identifier.Description);
{ /* Only Windows XP's default VGA driver should have an empty description */
skip("Clear failed, can't assure correctness of the test results\n"); ok(identifier.Description[0] || broken(!strcmp(identifier.Driver, "vga.dll")), "Empty driver description.\n");
goto cleanup; trace("Driver version %d.%d.%d.%d\n",
} HIWORD(U(identifier.DriverVersion).HighPart), LOWORD(U(identifier.DriverVersion).HighPart),
HIWORD(U(identifier.DriverVersion).LowPart), LOWORD(U(identifier.DriverVersion).LowPart));
color = getPixelColor(device_ptr, 1, 1);
if(color !=0x00ff0000) window = CreateWindowA("static", "d3d8_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
{ 0, 0, 640, 480, NULL, NULL, NULL, NULL);
skip("Sanity check returned an incorrect color(%08x), can't assure the correctness of the tests\n", color); if (!(device_ptr = create_device(d3d, window, window, TRUE)))
{
skip("Failed to create a D3D device, skipping tests.\n");
goto cleanup; goto cleanup;
} }
IDirect3DDevice8_Present(device_ptr, NULL, NULL, NULL, NULL);
hr = IDirect3DDevice8_Clear(device_ptr, 0, NULL, D3DCLEAR_TARGET, 0xff00ddee, 0.0, 0); hr = IDirect3DDevice8_GetDeviceCaps(device_ptr, &caps);
if(FAILED(hr)) ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
{
skip("Clear failed, can't assure correctness of the test results\n");
goto cleanup;
}
color = getPixelColor(device_ptr, 639, 479);
if(color != 0x0000ddee)
{
skip("Sanity check returned an incorrect color(%08x), can't assure the correctness of the tests\n", color);
goto cleanup;
}
IDirect3DDevice8_Present(device_ptr, NULL, NULL, NULL, NULL);
/* Now run the real test */ test_sanity(device_ptr);
depth_clamp_test(device_ptr); depth_clamp_test(device_ptr);
lighting_test(device_ptr); lighting_test(device_ptr);
clear_test(device_ptr); clear_test(device_ptr);
...@@ -4733,14 +4723,9 @@ START_TEST(visual) ...@@ -4733,14 +4723,9 @@ START_TEST(visual)
volume_v16u16_test(device_ptr); volume_v16u16_test(device_ptr);
add_dirty_rect_test(device_ptr); add_dirty_rect_test(device_ptr);
refcount = IDirect3DDevice8_Release(device_ptr);
ok(!refcount, "Device has %u references left.\n", refcount);
cleanup: cleanup:
if(device_ptr) { IDirect3D8_Release(d3d);
D3DDEVICE_CREATION_PARAMETERS creation_parameters; DestroyWindow(window);
ULONG refcount;
IDirect3DDevice8_GetCreationParameters(device_ptr, &creation_parameters);
DestroyWindow(creation_parameters.hFocusWindow);
refcount = IDirect3DDevice8_Release(device_ptr);
ok(!refcount, "Device has %u references left\n", refcount);
}
} }
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