[PATCH 05/11] d3d8/tests: Add test showing that primitive restart must be disabled.
Józef Kucia
jkucia at codeweavers.com
Wed Dec 7 05:42:59 CST 2016
Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---
dlls/d3d8/tests/visual.c | 153 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 153 insertions(+)
diff --git a/dlls/d3d8/tests/visual.c b/dlls/d3d8/tests/visual.c
index 34d34b1..bf7058c 100644
--- a/dlls/d3d8/tests/visual.c
+++ b/dlls/d3d8/tests/visual.c
@@ -9528,6 +9528,158 @@ static void test_edge_antialiasing_blending(void)
DestroyWindow(window);
}
+/* This test shows that 0xffff is valid index in D3D8. */
+static void test_max_index16(void)
+{
+ static const D3DMATRIX mat =
+ {{{
+ 1.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 1.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 1.0f, 0.0f,
+ 0.0f, 0.0f, 0.0f, 1.0f,
+ }}};
+ static const struct vertex
+ {
+ struct vec3 position;
+ DWORD diffuse;
+ }
+ green_quad[] =
+ {
+ {{-1.0f, -1.0f, 0.1f}, D3DCOLOR_ARGB(0xff, 0x00, 0xff, 0x00)},
+ {{-1.0f, 1.0f, 0.1f}, D3DCOLOR_ARGB(0xff, 0x00, 0xff, 0x00)},
+ {{ 1.0f, -1.0f, 0.1f}, D3DCOLOR_ARGB(0xff, 0x00, 0xff, 0x00)},
+ {{ 1.0f, 1.0f, 0.1f}, D3DCOLOR_ARGB(0xff, 0x00, 0xff, 0x00)},
+ };
+ static const unsigned short indices[] = {0, 1, 2, 0xffff};
+ static const unsigned int vertex_count = 0xffff + 1;
+
+ D3DADAPTER_IDENTIFIER8 identifier;
+ IDirect3DVertexBuffer8 *vb;
+ IDirect3DIndexBuffer8 *ib;
+ IDirect3DDevice8 *device;
+ struct vertex *vb_data;
+ IDirect3D8 *d3d8;
+ ULONG refcount;
+ D3DCOLOR color;
+ D3DCAPS8 caps;
+ HWND window;
+ BYTE *data;
+ HRESULT hr;
+ BOOL warp;
+
+ window = CreateWindowA("static", "d3d8_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
+ 0, 0, 640, 480, NULL, NULL, NULL, NULL);
+ d3d8 = Direct3DCreate8(D3D_SDK_VERSION);
+ ok(!!d3d8, "Failed to create a D3D object.\n");
+
+ hr = IDirect3D8_GetAdapterIdentifier(d3d8, D3DADAPTER_DEFAULT, 0, &identifier);
+ ok(SUCCEEDED(hr), "Failed to get adapter identifier, hr %#x.\n", hr);
+ warp = adapter_is_warp(&identifier);
+
+ if (!(device = create_device(d3d8, window, window, TRUE)))
+ {
+ skip("Failed to create a D3D device.\n");
+ IDirect3D8_Release(d3d8);
+ DestroyWindow(window);
+ return;
+ }
+
+ hr = IDirect3DDevice8_GetDeviceCaps(device, &caps);
+ ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+ if (caps.MaxVertexIndex < 0xffff)
+ {
+ skip("Max vertex index is lower than 0xffff (%#x).\n", caps.MaxVertexIndex);
+ IDirect3DDevice8_Release(device);
+ IDirect3D8_Release(d3d8);
+ DestroyWindow(window);
+ return;
+ }
+
+ hr = IDirect3DDevice8_CreateVertexBuffer(device, vertex_count * sizeof(*green_quad), 0,
+ D3DFVF_XYZ | D3DFVF_DIFFUSE, D3DPOOL_MANAGED, &vb);
+ ok(SUCCEEDED(hr), "Failed to create vertex buffer, hr %#x.\n", hr);
+
+ hr = IDirect3DDevice8_CreateIndexBuffer(device, sizeof(indices), 0,
+ D3DFMT_INDEX16, D3DPOOL_MANAGED, &ib);
+ ok(SUCCEEDED(hr), "Failed to create index buffer, hr %#x.\n", hr);
+
+ hr = IDirect3DDevice8_SetTransform(device, D3DTS_WORLD, &mat);
+ ok(SUCCEEDED(hr), "Failed to set world transform, hr %#x.\n", hr);
+ hr = IDirect3DDevice8_SetTransform(device, D3DTS_VIEW, &mat);
+ ok(SUCCEEDED(hr), "Failed to set view transform, hr %#x.\n", hr);
+ hr = IDirect3DDevice8_SetTransform(device, D3DTS_PROJECTION, &mat);
+ ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#x.\n", hr);
+ hr = IDirect3DDevice8_SetRenderState(device, D3DRS_CLIPPING, FALSE);
+ ok(SUCCEEDED(hr), "Failed to disable clipping, hr %#x.\n", hr);
+ hr = IDirect3DDevice8_SetRenderState(device, D3DRS_ZENABLE, FALSE);
+ ok(SUCCEEDED(hr), "Failed to disable Z test, hr %#x.\n", hr);
+ hr = IDirect3DDevice8_SetRenderState(device, D3DRS_FOGENABLE, FALSE);
+ ok(SUCCEEDED(hr), "Failed to disable fog, hr %#x.\n", hr);
+ hr = IDirect3DDevice8_SetRenderState(device, D3DRS_STENCILENABLE, FALSE);
+ ok(SUCCEEDED(hr), "Failed to disable stencil test, hr %#x.\n", hr);
+ hr = IDirect3DDevice8_SetRenderState(device, D3DRS_CULLMODE, D3DCULL_NONE);
+ ok(SUCCEEDED(hr), "Failed to disable culling, hr %#x.\n", hr);
+ hr = IDirect3DDevice8_SetRenderState(device, D3DRS_LIGHTING, FALSE);
+ ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr);
+
+ hr = IDirect3DDevice8_SetRenderState(device, D3DRS_ALPHABLENDENABLE, FALSE);
+ ok(SUCCEEDED(hr), "Failed to disable blending, hr %#x.\n", hr);
+
+ hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
+ ok(SUCCEEDED(hr), "Failed to set color op, hr %#x.\n", hr);
+ hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
+ ok(SUCCEEDED(hr), "Failed to set color arg, hr %#x.\n", hr);
+ hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
+ ok(SUCCEEDED(hr), "Failed to set alpha op, hr %#x.\n", hr);
+ hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE);
+ ok(SUCCEEDED(hr), "Failed to set alpha arg, hr %#x.\n", hr);
+
+ hr = IDirect3DDevice8_SetVertexShader(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
+ ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
+
+ hr = IDirect3DVertexBuffer8_Lock(vb, 0, sizeof(green_quad), (BYTE **)&vb_data, 0);
+ ok(hr == D3D_OK, "Failed to lock vertex buffer, hr %#x.\n", hr);
+ vb_data[0] = green_quad[0];
+ vb_data[1] = green_quad[1];
+ vb_data[2] = green_quad[2];
+ vb_data[0xffff] = green_quad[3];
+ hr = IDirect3DVertexBuffer8_Unlock(vb);
+ ok(hr == D3D_OK, "Failed to unlock vertex buffer, hr %#x.\n", hr);
+
+ hr = IDirect3DIndexBuffer8_Lock(ib, 0, sizeof(indices), &data, 0);
+ ok(hr == D3D_OK, "Failed to lock index buffer, hr %#x.\n", hr);
+ memcpy(data, indices, sizeof(indices));
+ hr = IDirect3DIndexBuffer8_Unlock(ib);
+ ok(hr == D3D_OK, "Failed to unlock index buffer, hr %#x.\n", hr);
+
+ hr = IDirect3DDevice8_SetIndices(device, ib, 0);
+ ok(hr == D3D_OK, "Failed to set index buffer, hr %#x.\n", hr);
+ hr = IDirect3DDevice8_SetStreamSource(device, 0, vb, sizeof(struct vertex));
+ ok(hr == D3D_OK, "Failed to set stream source, hr %#x.\n", hr);
+
+ hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0);
+ ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+ hr = IDirect3DDevice8_BeginScene(device);
+ ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+ hr = IDirect3DDevice8_DrawIndexedPrimitive(device, D3DPT_TRIANGLESTRIP, 0, vertex_count, 0, 2);
+ ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+ hr = IDirect3DDevice8_EndScene(device);
+ ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+ color = getPixelColor(device, 20, 20);
+ ok(color_match(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
+ color = getPixelColor(device, 320, 240);
+ ok(color_match(color, 0x0000ff00, 1) || broken(warp), "Got unexpected color 0x%08x.\n", color);
+ color = getPixelColor(device, 620, 460);
+ ok(color_match(color, 0x0000ff00, 1) || broken(warp), "Got unexpected color 0x%08x.\n", color);
+
+ IDirect3DIndexBuffer8_Release(ib);
+ IDirect3DVertexBuffer8_Release(vb);
+ refcount = IDirect3DDevice8_Release(device);
+ ok(!refcount, "Device has %u references left.\n", refcount);
+ IDirect3D8_Release(d3d8);
+ DestroyWindow(window);
+}
+
START_TEST(visual)
{
D3DADAPTER_IDENTIFIER8 identifier;
@@ -9596,4 +9748,5 @@ START_TEST(visual)
test_texture_blending();
test_color_clamping();
test_edge_antialiasing_blending();
+ test_max_index16();
}
--
2.7.3
More information about the wine-patches
mailing list