d3d8/tests: Add test for edge antialiasing blending.
Signed-off-by: Józef Kucia <jkucia@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
5a4d218563
commit
cf09d158fe
|
@ -9352,6 +9352,182 @@ static void test_color_clamping(void)
|
||||||
DestroyWindow(window);
|
DestroyWindow(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_edge_antialiasing_blending(void)
|
||||||
|
{
|
||||||
|
IDirect3DDevice8 *device;
|
||||||
|
IDirect3D8 *d3d8;
|
||||||
|
ULONG refcount;
|
||||||
|
D3DCOLOR color;
|
||||||
|
D3DCAPS8 caps;
|
||||||
|
HWND window;
|
||||||
|
HRESULT hr;
|
||||||
|
|
||||||
|
static const D3DMATRIX mat =
|
||||||
|
{{{
|
||||||
|
1.0f, 0.0f, 0.0f, 0.0f,
|
||||||
|
0.0f, 1.0f, 0.0f, 0.0f,
|
||||||
|
0.0f, 0.0f, 1.0f, 0.0f,
|
||||||
|
0.0f, 0.0f, 0.0f, 1.0f,
|
||||||
|
}}};
|
||||||
|
static const struct
|
||||||
|
{
|
||||||
|
struct vec3 position;
|
||||||
|
DWORD diffuse;
|
||||||
|
}
|
||||||
|
green_quad[] =
|
||||||
|
{
|
||||||
|
{{-1.0f, -1.0f, 0.1f}, D3DCOLOR_ARGB(0x7f, 0x00, 0xff, 0x00)},
|
||||||
|
{{-1.0f, 1.0f, 0.1f}, D3DCOLOR_ARGB(0x7f, 0x00, 0xff, 0x00)},
|
||||||
|
{{ 1.0f, -1.0f, 0.1f}, D3DCOLOR_ARGB(0x7f, 0x00, 0xff, 0x00)},
|
||||||
|
{{ 1.0f, 1.0f, 0.1f}, D3DCOLOR_ARGB(0x7f, 0x00, 0xff, 0x00)},
|
||||||
|
};
|
||||||
|
static const struct
|
||||||
|
{
|
||||||
|
struct vec3 position;
|
||||||
|
DWORD diffuse;
|
||||||
|
}
|
||||||
|
red_quad[] =
|
||||||
|
{
|
||||||
|
{{-1.0f, -1.0f, 0.1f}, D3DCOLOR_ARGB(0xcc, 0xff, 0x00, 0x00)},
|
||||||
|
{{-1.0f, 1.0f, 0.1f}, D3DCOLOR_ARGB(0xcc, 0xff, 0x00, 0x00)},
|
||||||
|
{{ 1.0f, -1.0f, 0.1f}, D3DCOLOR_ARGB(0xcc, 0xff, 0x00, 0x00)},
|
||||||
|
{{ 1.0f, 1.0f, 0.1f}, D3DCOLOR_ARGB(0xcc, 0xff, 0x00, 0x00)},
|
||||||
|
};
|
||||||
|
|
||||||
|
window = CreateWindowA("static", "d3d8_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
|
||||||
|
0, 0, 640, 480, NULL, NULL, NULL, NULL);
|
||||||
|
d3d8 = Direct3DCreate8(D3D_SDK_VERSION);
|
||||||
|
ok(!!d3d8, "Failed to create a D3D object.\n");
|
||||||
|
if (!(device = create_device(d3d8, window, window, TRUE)))
|
||||||
|
{
|
||||||
|
skip("Failed to create a D3D device.\n");
|
||||||
|
IDirect3D8_Release(d3d8);
|
||||||
|
DestroyWindow(window);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
hr = IDirect3DDevice8_GetDeviceCaps(device, &caps);
|
||||||
|
ok(SUCCEEDED(hr), "Failed to get caps, hr %#x.\n", hr);
|
||||||
|
trace("Edge antialiasing support: %#x.\n", caps.RasterCaps & D3DPRASTERCAPS_ANTIALIASEDGES);
|
||||||
|
|
||||||
|
hr = IDirect3DDevice8_SetTransform(device, D3DTS_WORLD, &mat);
|
||||||
|
ok(SUCCEEDED(hr), "Failed to set world transform, hr %#x.\n", hr);
|
||||||
|
hr = IDirect3DDevice8_SetTransform(device, D3DTS_VIEW, &mat);
|
||||||
|
ok(SUCCEEDED(hr), "Failed to set view transform, hr %#x.\n", hr);
|
||||||
|
hr = IDirect3DDevice8_SetTransform(device, D3DTS_PROJECTION, &mat);
|
||||||
|
ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#x.\n", hr);
|
||||||
|
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_CLIPPING, FALSE);
|
||||||
|
ok(SUCCEEDED(hr), "Failed to disable clipping, hr %#x.\n", hr);
|
||||||
|
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_ZENABLE, FALSE);
|
||||||
|
ok(SUCCEEDED(hr), "Failed to disable Z test, hr %#x.\n", hr);
|
||||||
|
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGENABLE, FALSE);
|
||||||
|
ok(SUCCEEDED(hr), "Failed to disable fog, hr %#x.\n", hr);
|
||||||
|
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_STENCILENABLE, FALSE);
|
||||||
|
ok(SUCCEEDED(hr), "Failed to disable stencil test, hr %#x.\n", hr);
|
||||||
|
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_CULLMODE, D3DCULL_NONE);
|
||||||
|
ok(SUCCEEDED(hr), "Failed to disable culling, hr %#x.\n", hr);
|
||||||
|
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_LIGHTING, FALSE);
|
||||||
|
ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr);
|
||||||
|
|
||||||
|
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_ALPHABLENDENABLE, TRUE);
|
||||||
|
ok(SUCCEEDED(hr), "Failed to enable blending, hr %#x.\n", hr);
|
||||||
|
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_BLENDOP, D3DBLENDOP_ADD);
|
||||||
|
ok(SUCCEEDED(hr), "Failed to set blend op, hr %#x.\n", hr);
|
||||||
|
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
|
||||||
|
ok(SUCCEEDED(hr), "Failed to set src blend, hr %#x.\n", hr);
|
||||||
|
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_DESTBLEND, D3DBLEND_DESTALPHA);
|
||||||
|
ok(SUCCEEDED(hr), "Failed to set dest blend, hr %#x.\n", hr);
|
||||||
|
|
||||||
|
hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
|
||||||
|
ok(SUCCEEDED(hr), "Failed to set color op, hr %#x.\n", hr);
|
||||||
|
hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
|
||||||
|
ok(SUCCEEDED(hr), "Failed to set color arg, hr %#x.\n", hr);
|
||||||
|
hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
|
||||||
|
ok(SUCCEEDED(hr), "Failed to set alpha op, hr %#x.\n", hr);
|
||||||
|
hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE);
|
||||||
|
ok(SUCCEEDED(hr), "Failed to set alpha arg, hr %#x.\n", hr);
|
||||||
|
|
||||||
|
hr = IDirect3DDevice8_SetVertexShader(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
|
||||||
|
ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
|
||||||
|
|
||||||
|
hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xccff0000, 0.0f, 0);
|
||||||
|
ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
|
||||||
|
hr = IDirect3DDevice8_BeginScene(device);
|
||||||
|
ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
|
||||||
|
hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, green_quad, sizeof(*green_quad));
|
||||||
|
ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
|
||||||
|
hr = IDirect3DDevice8_EndScene(device);
|
||||||
|
ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
|
||||||
|
color = getPixelColor(device, 320, 240);
|
||||||
|
ok(color_match(color, 0x00cc7f00, 1), "Got unexpected color 0x%08x.\n", color);
|
||||||
|
|
||||||
|
hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x7f00ff00, 0.0f, 0);
|
||||||
|
ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
|
||||||
|
hr = IDirect3DDevice8_BeginScene(device);
|
||||||
|
ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
|
||||||
|
hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, red_quad, sizeof(*red_quad));
|
||||||
|
ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
|
||||||
|
hr = IDirect3DDevice8_EndScene(device);
|
||||||
|
ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
|
||||||
|
color = getPixelColor(device, 320, 240);
|
||||||
|
ok(color_match(color, 0x00cc7f00, 1), "Got unexpected color 0x%08x.\n", color);
|
||||||
|
|
||||||
|
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_ALPHABLENDENABLE, FALSE);
|
||||||
|
ok(SUCCEEDED(hr), "Failed to disable blending, hr %#x.\n", hr);
|
||||||
|
|
||||||
|
hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xccff0000, 0.0f, 0);
|
||||||
|
ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
|
||||||
|
hr = IDirect3DDevice8_BeginScene(device);
|
||||||
|
ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
|
||||||
|
hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, green_quad, sizeof(*green_quad));
|
||||||
|
ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
|
||||||
|
hr = IDirect3DDevice8_EndScene(device);
|
||||||
|
ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
|
||||||
|
color = getPixelColor(device, 320, 240);
|
||||||
|
ok(color_match(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
|
||||||
|
|
||||||
|
hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x7f00ff00, 0.0f, 0);
|
||||||
|
ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
|
||||||
|
hr = IDirect3DDevice8_BeginScene(device);
|
||||||
|
ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
|
||||||
|
hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, red_quad, sizeof(*red_quad));
|
||||||
|
ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
|
||||||
|
hr = IDirect3DDevice8_EndScene(device);
|
||||||
|
ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
|
||||||
|
color = getPixelColor(device, 320, 240);
|
||||||
|
ok(color_match(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
|
||||||
|
|
||||||
|
hr = IDirect3DDevice8_SetRenderState(device, D3DRS_EDGEANTIALIAS, TRUE);
|
||||||
|
ok(SUCCEEDED(hr), "Failed to enable edge antialiasing, hr %#x.\n", hr);
|
||||||
|
|
||||||
|
hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xccff0000, 0.0f, 0);
|
||||||
|
ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
|
||||||
|
hr = IDirect3DDevice8_BeginScene(device);
|
||||||
|
ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
|
||||||
|
hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, green_quad, sizeof(*green_quad));
|
||||||
|
ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
|
||||||
|
hr = IDirect3DDevice8_EndScene(device);
|
||||||
|
ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
|
||||||
|
color = getPixelColor(device, 320, 240);
|
||||||
|
todo_wine ok(color_match(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
|
||||||
|
|
||||||
|
hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x7f00ff00, 0.0f, 0);
|
||||||
|
ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
|
||||||
|
hr = IDirect3DDevice8_BeginScene(device);
|
||||||
|
ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
|
||||||
|
hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, red_quad, sizeof(*red_quad));
|
||||||
|
ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
|
||||||
|
hr = IDirect3DDevice8_EndScene(device);
|
||||||
|
ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
|
||||||
|
color = getPixelColor(device, 320, 240);
|
||||||
|
todo_wine ok(color_match(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
|
||||||
|
|
||||||
|
refcount = IDirect3DDevice8_Release(device);
|
||||||
|
ok(!refcount, "Device has %u references left.\n", refcount);
|
||||||
|
IDirect3D8_Release(d3d8);
|
||||||
|
DestroyWindow(window);
|
||||||
|
}
|
||||||
|
|
||||||
START_TEST(visual)
|
START_TEST(visual)
|
||||||
{
|
{
|
||||||
D3DADAPTER_IDENTIFIER8 identifier;
|
D3DADAPTER_IDENTIFIER8 identifier;
|
||||||
|
@ -9419,4 +9595,5 @@ START_TEST(visual)
|
||||||
test_multisample_init();
|
test_multisample_init();
|
||||||
test_texture_blending();
|
test_texture_blending();
|
||||||
test_color_clamping();
|
test_color_clamping();
|
||||||
|
test_edge_antialiasing_blending();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue