Commit 8333e7f2 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

d3d9/tests: Add a test for sample masks.

parent 5eadfb09
......@@ -26739,6 +26739,96 @@ static void test_alpha_to_coverage(void)
DestroyWindow(window);
}
static void test_sample_mask(void)
{
IDirect3DSurface9 *rt, *ms_rt;
struct surface_readback rb;
IDirect3DDevice9 *device;
IDirect3D9 *d3d;
ULONG refcount;
DWORD colour;
HWND window;
HRESULT hr;
static const struct
{
struct vec3 position;
DWORD diffuse;
}
quad[] =
{
{{-1.0f, -1.0f, 0.1f}, 0xffffffff},
{{-1.0f, 1.0f, 0.1f}, 0xffffffff},
{{ 1.0f, -1.0f, 0.1f}, 0xffffffff},
{{ 1.0f, 1.0f, 0.1f}, 0xffffffff},
};
window = create_window();
d3d = Direct3DCreate9(D3D_SDK_VERSION);
ok(!!d3d, "Failed to create a D3D object.\n");
if (FAILED(IDirect3D9_CheckDeviceMultiSampleType(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
D3DFMT_A8R8G8B8, TRUE, D3DMULTISAMPLE_2_SAMPLES, NULL)))
{
skip("Multisampling not supported for D3DFMT_A8R8G8B8.\n");
IDirect3D9_Release(d3d);
DestroyWindow(window);
return;
}
if (!(device = create_device(d3d, window, window, TRUE)))
{
skip("Failed to create a 3D device.\n");
IDirect3D9_Release(d3d);
DestroyWindow(window);
return;
}
hr = IDirect3DDevice9_CreateRenderTarget(device, 128, 128,
D3DFMT_A8R8G8B8, D3DMULTISAMPLE_NONE, 0, FALSE, &rt, NULL);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice9_CreateRenderTarget(device, 128, 128,
D3DFMT_A8R8G8B8, D3DMULTISAMPLE_2_SAMPLES, 0, FALSE, &ms_rt, NULL);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice9_SetRenderTarget(device, 0, ms_rt);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice9_SetDepthStencilSurface(device, NULL);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice9_BeginScene(device);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice9_SetRenderState(device, D3DRS_MULTISAMPLEMASK, 0x5);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff0000, 0.0f, 0);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(quad[0]));
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice9_StretchRect(device, ms_rt, NULL, rt, NULL, D3DTEXF_POINT);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
get_rt_readback(rt, &rb);
colour = get_readback_color(&rb, 64, 64);
todo_wine ok(color_match(colour, 0xffff8080, 1), "Got unexpected colour %08x.\n", colour);
release_surface_readback(&rb);
hr = IDirect3DDevice9_EndScene(device);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
IDirect3DSurface9_Release(ms_rt);
IDirect3DSurface9_Release(rt);
refcount = IDirect3DDevice9_Release(device);
ok(!refcount, "Device has %u references left.\n", refcount);
IDirect3D9_Release(d3d);
DestroyWindow(window);
}
START_TEST(visual)
{
D3DADAPTER_IDENTIFIER9 identifier;
......@@ -26886,4 +26976,5 @@ START_TEST(visual)
test_draw_mapped_buffer();
test_sample_attached_rendertarget();
test_alpha_to_coverage();
test_sample_mask();
}
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