Module: wine Branch: master Commit: 08c34e3f83ffb27c8fc41ecdeadc8b38bb028305 URL: https://gitlab.winehq.org/wine/wine/-/commit/08c34e3f83ffb27c8fc41ecdeadc8b3...
Author: Zebediah Figura zfigura@codeweavers.com Date: Fri Apr 19 14:13:22 2024 -0500
ddraw/tests: Test GetVertexBufferDesc().
---
dlls/ddraw/tests/ddraw4.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++ dlls/ddraw/tests/ddraw7.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 142 insertions(+)
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c index 6cf58c3b29a..a0e4fe18c31 100644 --- a/dlls/ddraw/tests/ddraw4.c +++ b/dlls/ddraw/tests/ddraw4.c @@ -19663,6 +19663,76 @@ static void test_multiple_devices(void) DestroyWindow(window); }
+static void test_vb_desc(void) +{ + IDirect3DVertexBuffer *vb; + D3DVERTEXBUFFERDESC desc; + IDirectDraw4 *ddraw; + IDirect3D3 *d3d; + ULONG refcount; + HWND window; + HRESULT hr; + + static const DWORD caps_tests[] = + { + 0, + D3DVBCAPS_WRITEONLY, + D3DVBCAPS_SYSTEMMEMORY, + D3DVBCAPS_SYSTEMMEMORY | D3DVBCAPS_WRITEONLY + }; + + static const DWORD fvf_tests[] = {D3DFVF_XYZ, D3DFVF_XYZRHW}; + + ddraw = create_ddraw(); + ok(!!ddraw, "Failed to create a ddraw object.\n"); + window = create_window(); + ok(!!window, "Failed to create a window.\n"); + hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); + ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#lx.\n", hr); + + hr = IDirectDraw4_QueryInterface(ddraw, &IID_IDirect3D3, (void **)&d3d); + if (FAILED(hr)) + { + skip("D3D interface is not available, skipping test.\n"); + IDirectDraw4_Release(ddraw); + return; + } + + for (unsigned int i = 0; i < ARRAY_SIZE(caps_tests); ++i) + { + for (unsigned int j = 0; j < ARRAY_SIZE(fvf_tests); ++j) + { + winetest_push_context("caps %#lx, fvf %#lx", caps_tests[i], fvf_tests[j]); + + desc.dwSize = sizeof(desc); + desc.dwCaps = caps_tests[i]; + desc.dwFVF = fvf_tests[j]; + desc.dwNumVertices = 256; + + hr = IDirect3D3_CreateVertexBuffer(d3d, &desc, &vb, 0, NULL); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + memset(&desc, 0, sizeof(desc)); + hr = IDirect3DVertexBuffer_GetVertexBufferDesc(vb, &desc); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + ok(!desc.dwSize, "Got size %lu.\n", desc.dwSize); + ok(desc.dwCaps == caps_tests[i], "Got caps %#lx.\n", desc.dwCaps); + ok(desc.dwFVF == fvf_tests[j], "Got FVF %#lx.\n", desc.dwFVF); + ok(desc.dwNumVertices == 256, "Got %lu vertices.\n", desc.dwNumVertices); + + IDirect3DVertexBuffer_Release(vb); + + winetest_pop_context(); + } + } + + IDirect3D3_Release(d3d); + DestroyWindow(window); + refcount = IDirectDraw4_Release(ddraw); + ok(!refcount, "Device has %lu references left.\n", refcount); +} + START_TEST(ddraw4) { DDDEVICEIDENTIFIER identifier; @@ -19805,4 +19875,5 @@ START_TEST(ddraw4) test_filling_convention(); test_enum_devices(); test_multiple_devices(); + test_vb_desc(); } diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c index 3b2bc281328..e222e798ffe 100644 --- a/dlls/ddraw/tests/ddraw7.c +++ b/dlls/ddraw/tests/ddraw7.c @@ -20119,6 +20119,76 @@ static void test_multiple_devices(void) DestroyWindow(window); }
+static void test_vb_desc(void) +{ + IDirect3DVertexBuffer7 *vb; + D3DVERTEXBUFFERDESC desc; + IDirectDraw7 *ddraw; + IDirect3D7 *d3d; + ULONG refcount; + HWND window; + HRESULT hr; + + static const DWORD caps_tests[] = + { + 0, + D3DVBCAPS_WRITEONLY, + D3DVBCAPS_SYSTEMMEMORY, + D3DVBCAPS_SYSTEMMEMORY | D3DVBCAPS_WRITEONLY + }; + + static const DWORD fvf_tests[] = {D3DFVF_XYZ, D3DFVF_XYZRHW}; + + ddraw = create_ddraw(); + ok(!!ddraw, "Failed to create a ddraw object.\n"); + window = create_window(); + ok(!!window, "Failed to create a window.\n"); + hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); + ok(hr == DD_OK, "SetCooperativeLevel failed, hr %#lx.\n", hr); + + hr = IDirectDraw7_QueryInterface(ddraw, &IID_IDirect3D7, (void **)&d3d); + if (FAILED(hr)) + { + skip("D3D interface is not available, skipping test.\n"); + IDirectDraw7_Release(ddraw); + return; + } + + for (unsigned int i = 0; i < ARRAY_SIZE(caps_tests); ++i) + { + for (unsigned int j = 0; j < ARRAY_SIZE(fvf_tests); ++j) + { + winetest_push_context("caps %#lx, fvf %#lx", caps_tests[i], fvf_tests[j]); + + desc.dwSize = sizeof(desc); + desc.dwCaps = caps_tests[i]; + desc.dwFVF = fvf_tests[j]; + desc.dwNumVertices = 256; + + hr = IDirect3D7_CreateVertexBuffer(d3d, &desc, &vb, 0); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + memset(&desc, 0, sizeof(desc)); + hr = IDirect3DVertexBuffer7_GetVertexBufferDesc(vb, &desc); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + ok(!desc.dwSize, "Got size %lu.\n", desc.dwSize); + ok(desc.dwCaps == caps_tests[i], "Got caps %#lx.\n", desc.dwCaps); + ok(desc.dwFVF == fvf_tests[j], "Got FVF %#lx.\n", desc.dwFVF); + ok(desc.dwNumVertices == 256, "Got %lu vertices.\n", desc.dwNumVertices); + + IDirect3DVertexBuffer7_Release(vb); + + winetest_pop_context(); + } + } + + IDirect3D7_Release(d3d); + DestroyWindow(window); + refcount = IDirectDraw7_Release(ddraw); + ok(!refcount, "Device has %lu references left.\n", refcount); +} + START_TEST(ddraw7) { DDDEVICEIDENTIFIER2 identifier; @@ -20295,4 +20365,5 @@ START_TEST(ddraw7) run_for_each_device_type(test_user_memory); test_flip_3d(); test_multiple_devices(); + test_vb_desc(); }