[PATCH v2 2/7] d3d8/tests: Add some tests for D3DRS_MULTISAMPLEANTIALIAS.

Zebediah Figura z.figura12 at gmail.com
Fri Apr 30 11:08:27 CDT 2021


Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
 dlls/d3d8/tests/visual.c | 144 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 144 insertions(+)

diff --git a/dlls/d3d8/tests/visual.c b/dlls/d3d8/tests/visual.c
index f25549388d0..175cd7d3514 100644
--- a/dlls/d3d8/tests/visual.c
+++ b/dlls/d3d8/tests/visual.c
@@ -4527,6 +4527,9 @@ static void resz_test(void)
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_COLORWRITEENABLE, 0xf);
     ok(SUCCEEDED(hr), "SetRenderState failed, hr %#x.\n", hr);
 
+    hr = IDirect3DDevice8_SetRenderState(device, D3DRS_MULTISAMPLEANTIALIAS, FALSE);
+    ok(hr == D3D_OK, "SetRenderState failed, hr %#x.\n", hr);
+
     /* The actual multisampled depth buffer resolve happens here */
     hr = IDirect3DDevice8_SetRenderState(device, D3DRS_POINTSIZE, 0x7fa05000);
     ok(SUCCEEDED(hr), "SetRenderState (multisampled depth buffer resolve) failed, hr %#x.\n", hr);
@@ -11146,6 +11149,146 @@ static void test_sample_mask(void)
     ok(color_match(colour, 0xffff8080, 1), "Got unexpected colour %08x.\n", colour);
     release_surface_readback(&rb);
 
+    hr = IDirect3DDevice8_SetRenderState(device, D3DRS_MULTISAMPLEANTIALIAS, FALSE);
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff0000, 0.0f, 0);
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(quad[0]));
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+    hr = IDirect3DDevice8_CopyRects(device, ms_rt, NULL, 0, rt, NULL);
+    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 = IDirect3DDevice8_EndScene(device);
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+    IDirect3DSurface8_Release(ms_rt);
+    IDirect3DSurface8_Release(rt);
+    refcount = IDirect3DDevice8_Release(device);
+    ok(!refcount, "Device has %u references left.\n", refcount);
+    IDirect3D8_Release(d3d);
+    DestroyWindow(window);
+}
+
+static void test_multisample_draw(void)
+{
+    IDirect3DSurface8 *rt, *ms_rt;
+    struct surface_readback rb;
+    IDirect3DDevice8 *device;
+    IDirect3D8 *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 = Direct3DCreate8(D3D_SDK_VERSION);
+    ok(!!d3d, "Failed to create a D3D object.\n");
+
+    if (FAILED(IDirect3D8_CheckDeviceMultiSampleType(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
+            D3DFMT_A8R8G8B8, TRUE, D3DMULTISAMPLE_2_SAMPLES)))
+    {
+        skip("Multisampling not supported for D3DFMT_A8R8G8B8.\n");
+        IDirect3D8_Release(d3d);
+        DestroyWindow(window);
+        return;
+    }
+
+    if (!(device = create_device(d3d, window, window, TRUE)))
+    {
+        skip("Failed to create a 3D device.\n");
+        IDirect3D8_Release(d3d);
+        DestroyWindow(window);
+        return;
+    }
+
+    hr = IDirect3DDevice8_CreateRenderTarget(device, 640, 480, D3DFMT_A8R8G8B8, D3DMULTISAMPLE_NONE, FALSE, &rt);
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    hr = IDirect3DDevice8_CreateRenderTarget(device, 640, 480,
+            D3DFMT_A8R8G8B8, D3DMULTISAMPLE_2_SAMPLES, FALSE, &ms_rt);
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+    hr = IDirect3DDevice8_SetRenderTarget(device, ms_rt, NULL);
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+    hr = IDirect3DDevice8_BeginScene(device);
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+    hr = IDirect3DDevice8_SetRenderState(device, D3DRS_LIGHTING, FALSE);
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    hr = IDirect3DDevice8_SetVertexShader(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+    hr = IDirect3DDevice8_SetRenderState(device, D3DRS_MULTISAMPLEANTIALIAS, TRUE);
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff000000, 0.0f, 0);
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 1, tri, sizeof(tri[0]));
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+    hr = IDirect3DDevice8_SetRenderState(device, D3DRS_MULTISAMPLEANTIALIAS, FALSE);
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    hr = IDirect3DDevice8_CopyRects(device, ms_rt, NULL, 0, rt, NULL);
+    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 = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff000000, 0.0f, 0);
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 1, tri, sizeof(tri[0]));
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+    hr = IDirect3DDevice8_CopyRects(device, ms_rt, NULL, 0, rt, NULL);
+    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 = IDirect3DDevice8_EndScene(device);
     ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
 
@@ -11235,4 +11378,5 @@ START_TEST(visual)
     test_alphatest();
     test_desktop_window();
     test_sample_mask();
+    test_multisample_draw();
 }
-- 
2.30.2




More information about the wine-devel mailing list