From: Matteo Bruni Subject: [PATCH 3/5] d3d9/tests: Add a test for DrawIndexedPrimitiveUP(). Message-Id: <20170118203532.26128-3-mbruni@codeweavers.com> Date: Wed, 18 Jan 2017 21:35:30 +0100 In-Reply-To: <20170118203532.26128-1-mbruni@codeweavers.com> References: <20170118203532.26128-1-mbruni@codeweavers.com> Signed-off-by: Matteo Bruni --- dlls/d3d9/tests/visual.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c index 4213779..4bea1e1 100644 --- a/dlls/d3d9/tests/visual.c +++ b/dlls/d3d9/tests/visual.c @@ -22242,6 +22242,99 @@ done: DestroyWindow(window); } +static void test_drawindexedprimitiveup(void) +{ + static const struct vertex + { + struct vec3 position; + DWORD diffuse; + } + quad[] = + { + {{-1.0f, -1.0f, 0.1f}, 0xff00ff00}, + {{-1.0f, 1.0f, 0.1f}, 0xff0000ff}, + {{ 1.0f, -1.0f, 0.1f}, 0xffff0000}, + {{ 1.0f, 1.0f, 0.1f}, 0xff0000ff}, + + {{-1.0f, -1.0f, 0.1f}, 0xff0000ff}, + {{-1.0f, 1.0f, 0.1f}, 0xff00ff00}, + {{ 1.0f, -1.0f, 0.1f}, 0xffff0000}, + {{ 1.0f, 1.0f, 0.1f}, 0xff00ff00}, + }; + static const unsigned short indices[] = {0, 1, 2, 3, 4, 5, 6, 7}; + IDirect3DDevice9 *device; + IDirect3D9 *d3d; + ULONG refcount; + D3DCOLOR color; + HWND window; + HRESULT hr; + + window = create_window(); + d3d = Direct3DCreate9(D3D_SDK_VERSION); + ok(!!d3d, "Failed to create a D3D object.\n"); + + if (!(device = create_device(d3d, window, window, TRUE))) + { + skip("Failed to create a D3D device.\n"); + IDirect3D9_Release(d3d); + DestroyWindow(window); + return; + } + + hr = IDirect3DDevice9_SetRenderState(device, D3DRS_CLIPPING, FALSE); + ok(SUCCEEDED(hr), "Failed to disable clipping, hr %#x.\n", hr); + hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, FALSE); + ok(SUCCEEDED(hr), "Failed to disable Z test, hr %#x.\n", hr); + hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE); + ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr); + + hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE); + ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr); + + hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0); + ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr); + + hr = IDirect3DDevice9_BeginScene(device); + ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr); + hr = IDirect3DDevice9_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 4, 4, 2, indices + 4, D3DFMT_INDEX16, quad, sizeof(*quad)); + ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr); + hr = IDirect3DDevice9_EndScene(device); + ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr); + + color = getPixelColor(device, 160, 120); + ok(color_match(color, 0x0040bf00, 1), "Got unexpected color 0x%08x.\n", color); + color = getPixelColor(device, 480, 120); + ok(color_match(color, 0x0040bf00, 1), "Got unexpected color 0x%08x.\n", color); + color = getPixelColor(device, 160, 360); + ok(color_match(color, 0x00404080, 1), "Got unexpected color 0x%08x.\n", color); + color = getPixelColor(device, 480, 360); + ok(color_match(color, 0x00bf4000, 1), "Got unexpected color 0x%08x.\n", color); + + hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0); + ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr); + + hr = IDirect3DDevice9_BeginScene(device); + ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr); + hr = IDirect3DDevice9_DrawIndexedPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 0, 4, 2, indices, D3DFMT_INDEX16, quad, sizeof(*quad)); + ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr); + hr = IDirect3DDevice9_EndScene(device); + ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr); + + color = getPixelColor(device, 160, 120); + ok(color_match(color, 0x004000bf, 1), "Got unexpected color 0x%08x.\n", color); + color = getPixelColor(device, 480, 120); + ok(color_match(color, 0x004000bf, 1), "Got unexpected color 0x%08x.\n", color); + color = getPixelColor(device, 160, 360); + ok(color_match(color, 0x00408040, 1), "Got unexpected color 0x%08x.\n", color); + color = getPixelColor(device, 480, 360); + ok(color_match(color, 0x00bf0040, 1), "Got unexpected color 0x%08x.\n", color); + + refcount = IDirect3DDevice9_Release(device); + ok(!refcount, "Device has %u references left.\n", refcount); + IDirect3D9_Release(d3d); + DestroyWindow(window); +} + START_TEST(visual) { D3DADAPTER_IDENTIFIER9 identifier; @@ -22370,4 +22463,5 @@ START_TEST(visual) test_evict_bound_resources(); test_max_index16(); test_backbuffer_resize(); + test_drawindexedprimitiveup(); } -- 2.10.2