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

d3d9/tests: Use a separate device for alphatest_test().

parent 15a2817d
......@@ -11608,35 +11608,60 @@ static void zwriteenable_test(IDirect3DDevice9 *device) {
ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState failed with 0x%08x\n", hr);
}
static void alphatest_test(IDirect3DDevice9 *device) {
static void alphatest_test(void)
{
#define ALPHATEST_PASSED 0x0000ff00
#define ALPHATEST_FAILED 0x00ff0000
struct {
D3DCMPFUNC func;
DWORD color_less;
DWORD color_equal;
DWORD color_greater;
} testdata[] = {
{ D3DCMP_NEVER, ALPHATEST_FAILED, ALPHATEST_FAILED, ALPHATEST_FAILED },
{ D3DCMP_LESS, ALPHATEST_PASSED, ALPHATEST_FAILED, ALPHATEST_FAILED },
{ D3DCMP_EQUAL, ALPHATEST_FAILED, ALPHATEST_PASSED, ALPHATEST_FAILED },
{ D3DCMP_LESSEQUAL, ALPHATEST_PASSED, ALPHATEST_PASSED, ALPHATEST_FAILED },
{ D3DCMP_GREATER, ALPHATEST_FAILED, ALPHATEST_FAILED, ALPHATEST_PASSED },
{ D3DCMP_NOTEQUAL, ALPHATEST_PASSED, ALPHATEST_FAILED, ALPHATEST_PASSED },
{ D3DCMP_GREATEREQUAL, ALPHATEST_FAILED, ALPHATEST_PASSED, ALPHATEST_PASSED },
{ D3DCMP_ALWAYS, ALPHATEST_PASSED, ALPHATEST_PASSED, ALPHATEST_PASSED },
};
IDirect3DDevice9 *device;
unsigned int i, j;
IDirect3D9 *d3d;
D3DCOLOR color;
ULONG refcount;
D3DCAPS9 caps;
HWND window;
HRESULT hr;
DWORD color;
struct vertex quad[] = {
{ -1.0, -1.0, 0.1, ALPHATEST_PASSED | 0x80000000 },
{ 1.0, -1.0, 0.1, ALPHATEST_PASSED | 0x80000000 },
{ -1.0, 1.0, 0.1, ALPHATEST_PASSED | 0x80000000 },
{ 1.0, 1.0, 0.1, ALPHATEST_PASSED | 0x80000000 },
static const struct
{
D3DCMPFUNC func;
D3DCOLOR color_less;
D3DCOLOR color_equal;
D3DCOLOR color_greater;
}
testdata[] =
{
{D3DCMP_NEVER, ALPHATEST_FAILED, ALPHATEST_FAILED, ALPHATEST_FAILED},
{D3DCMP_LESS, ALPHATEST_PASSED, ALPHATEST_FAILED, ALPHATEST_FAILED},
{D3DCMP_EQUAL, ALPHATEST_FAILED, ALPHATEST_PASSED, ALPHATEST_FAILED},
{D3DCMP_LESSEQUAL, ALPHATEST_PASSED, ALPHATEST_PASSED, ALPHATEST_FAILED},
{D3DCMP_GREATER, ALPHATEST_FAILED, ALPHATEST_FAILED, ALPHATEST_PASSED},
{D3DCMP_NOTEQUAL, ALPHATEST_PASSED, ALPHATEST_FAILED, ALPHATEST_PASSED},
{D3DCMP_GREATEREQUAL, ALPHATEST_FAILED, ALPHATEST_PASSED, ALPHATEST_PASSED},
{D3DCMP_ALWAYS, ALPHATEST_PASSED, ALPHATEST_PASSED, ALPHATEST_PASSED},
};
static const struct vertex quad[] =
{
{-1.0f, -1.0f, 0.1f, ALPHATEST_PASSED | 0x80000000},
{-1.0f, 1.0f, 0.1f, ALPHATEST_PASSED | 0x80000000},
{ 1.0f, -1.0f, 0.1f, ALPHATEST_PASSED | 0x80000000},
{ 1.0f, 1.0f, 0.1f, ALPHATEST_PASSED | 0x80000000},
};
D3DCAPS9 caps;
window = CreateWindowA("static", "d3d9_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
0, 0, 640, 480, NULL, NULL, NULL, NULL);
d3d = Direct3DCreate9(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 = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff0000ff, 1.0f, 0);
ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr);
hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ALPHATESTENABLE, TRUE);
ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState failed with 0x%08x\n", hr);
hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
......@@ -11732,10 +11757,11 @@ static void alphatest_test(IDirect3DDevice9 *device) {
}
}
hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ALPHATESTENABLE, FALSE);
ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState failed with 0x%08x\n", hr);
hr = IDirect3DDevice9_SetPixelShader(device, NULL);
ok(hr == D3D_OK, "IDirect3DDevice9_SetPixelShader failed with 0x%08x\n", hr);
refcount = IDirect3DDevice9_Release(device);
ok(!refcount, "Device has %u references left.\n", refcount);
done:
IDirect3D9_Release(d3d);
DestroyWindow(window);
}
static void sincos_test(void)
......@@ -16419,11 +16445,11 @@ START_TEST(visual)
yuv_color_test(device_ptr);
yuv_layout_test(device_ptr);
zwriteenable_test(device_ptr);
alphatest_test(device_ptr);
cleanup_device(device_ptr);
device_ptr = NULL;
alphatest_test();
viewport_test();
test_constant_clamp_vs();
test_compare_instructions();
......
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