Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/d3d9/tests/visual.c | 147 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 147 insertions(+)
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c index b7fcb100c93..b7eb6ad394e 100644 --- a/dlls/d3d9/tests/visual.c +++ b/dlls/d3d9/tests/visual.c @@ -18173,6 +18173,9 @@ static void resz_test(void) hr = IDirect3DDevice9_SetRenderState(device, D3DRS_COLORWRITEENABLE, 0xf); ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
+ hr = IDirect3DDevice9_SetRenderState(device, D3DRS_MULTISAMPLEANTIALIAS, FALSE); + ok(hr == D3D_OK, "SetRenderState failed, hr %#x.\n", hr); + /* The actual multisampled depth buffer resolve happens here */ hr = IDirect3DDevice9_SetRenderState(device, D3DRS_POINTSIZE, 0x7fa05000); ok(SUCCEEDED(hr), "SetRenderState (multisampled depth buffer resolve) failed, hr %#x.\n", hr); @@ -26903,6 +26906,149 @@ static void test_sample_mask(void) ok(color_match(colour, 0xffff8080, 1), "Got unexpected colour %08x.\n", colour); release_surface_readback(&rb);
+ hr = IDirect3DDevice9_SetRenderState(device, D3DRS_MULTISAMPLEANTIALIAS, FALSE); + 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_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); +} + +static void test_multisample_draw(void) +{ + IDirect3DSurface9 *rt, *ms_rt; + struct surface_readback rb; + IDirect3DDevice9 *device; + IDirect3D9 *d3d; + unsigned int i; + ULONG refcount; + DWORD colour; + HWND window; + HRESULT hr; + + static const struct + { + struct vec3 position; + DWORD diffuse; + } + tri[] = + { + {{ 0.9f, -0.5f, 0.0f}, 0xffffffff}, + {{-0.8f, -0.9f, 0.0f}, 0xffffffff}, + {{ 0.2f, 0.7f, 0.0f}, 0xffffffff}, + }; + + static const struct + { + unsigned int x, y; + DWORD colour_ms, colour_no_ms; + } + pixels[] = + { + {338, 407, 0xffffffff, 0xffffffff}, + {339, 407, 0xffffffff, 0xffffffff}, + {340, 407, 0xff7f7f7f, 0xffffffff}, + {341, 407, 0xff7f7f7f, 0xffffffff}, + {342, 407, 0xff7f7f7f, 0xff000000}, + {343, 407, 0xff7f7f7f, 0xff000000}, + {344, 407, 0xff000000, 0xff000000}, + {345, 407, 0xff000000, 0xff000000}, + }; + + 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, 640, 480, + D3DFMT_A8R8G8B8, D3DMULTISAMPLE_NONE, 0, FALSE, &rt, NULL); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_CreateRenderTarget(device, 640, 480, + 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_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice9_SetRenderState(device, D3DRS_MULTISAMPLEANTIALIAS, TRUE); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff000000, 0.0f, 0); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 1, tri, sizeof(tri[0])); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice9_SetRenderState(device, D3DRS_MULTISAMPLEANTIALIAS, FALSE); + 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); + for (i = 0; i < ARRAY_SIZE(pixels); ++i) + { + colour = get_readback_color(&rb, pixels[i].x, pixels[i].y); + ok(color_match(colour, pixels[i].colour_ms, 1), + "Got unexpected colour %08x at (%u, %u).\n", colour, pixels[i].x, pixels[i].y); + } + release_surface_readback(&rb); + + hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff000000, 0.0f, 0); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 1, tri, sizeof(tri[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); + for (i = 0; i < ARRAY_SIZE(pixels); ++i) + { + colour = get_readback_color(&rb, pixels[i].x, pixels[i].y); + ok(color_match(colour, pixels[i].colour_no_ms, 1), + "Got unexpected colour %08x at (%u, %u).\n", colour, pixels[i].x, pixels[i].y); + } + release_surface_readback(&rb); + hr = IDirect3DDevice9_EndScene(device); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
@@ -27062,4 +27208,5 @@ START_TEST(visual) test_sample_attached_rendertarget(); test_alpha_to_coverage(); test_sample_mask(); + test_multisample_draw(); }