[PATCH 2/5] d3d9/tests: Test how state is reset after DrawPrimitive[Indexed]UP().

Matteo Bruni mbruni at codeweavers.com
Tue Jun 5 17:32:37 CDT 2018


Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
---
 dlls/d3d9/tests/device.c | 38 +++++++++++++++++++++++++++++++++-----
 dlls/d3d9/tests/visual.c |  8 ++++++++
 2 files changed, 41 insertions(+), 5 deletions(-)

diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c
index bd1890f45c5..b71058de486 100644
--- a/dlls/d3d9/tests/device.c
+++ b/dlls/d3d9/tests/device.c
@@ -2861,10 +2861,11 @@ static void test_draw_primitive(void)
         D3DDECL_END()
     };
 
+    IDirect3DVertexBuffer9 *vertex_buffer, *current_vb;
+    IDirect3DIndexBuffer9 *index_buffer, *current_ib;
     IDirect3DVertexDeclaration9 *vertex_declaration;
-    IDirect3DVertexBuffer9 *vertex_buffer;
-    IDirect3DIndexBuffer9 *index_buffer;
     IDirect3DDevice9 *device;
+    UINT offset, stride;
     IDirect3D9 *d3d9;
     ULONG refcount;
     HWND window;
@@ -2918,16 +2919,31 @@ static void test_draw_primitive(void)
     hr = IDirect3DDevice9_DrawPrimitive(device, D3DPT_TRIANGLELIST, 0, 2);
     ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
 
+    hr = IDirect3DDevice9_GetStreamSource(device, 0, &current_vb, &offset, &stride);
+    ok(SUCCEEDED(hr), "GetStreamSource failed, hr %#x.\n", hr);
+    ok(current_vb == vertex_buffer, "Unexpected vb %p.\n", current_vb);
+    ok(!offset, "Unexpected offset %u.\n", offset);
+    ok(stride == sizeof(*quad), "Unexpected stride %u.\n", stride);
+    IDirect3DVertexBuffer9_Release(current_vb);
+
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLELIST, 2, quad, sizeof(*quad));
     ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
 
+    hr = IDirect3DDevice9_GetStreamSource(device, 0, &current_vb, &offset, &stride);
+    ok(SUCCEEDED(hr), "GetStreamSource failed, hr %#x.\n", hr);
+    todo_wine ok(!current_vb, "Unexpected vb %p.\n", current_vb);
+    ok(!offset, "Unexpected offset %u.\n", offset);
+    ok(stride == sizeof(*quad), "Unexpected stride %u.\n", stride);
+    if (current_vb)
+        IDirect3DVertexBuffer9_Release(current_vb);
+
     hr = IDirect3DDevice9_SetIndices(device, NULL);
     ok(SUCCEEDED(hr), "SetIndices failed, hr %#x.\n", hr);
     hr = IDirect3DDevice9_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, 0 /* BaseVertexIndex */,
             0 /* MinIndex */, 4 /* NumVerts */, 0 /* StartIndex */, 2 /*PrimCount */);
     ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
 
-    /* Valid index buffer, NULL vertex declaration. Should fail */
+    /* Valid index buffer, NULL vertex declaration. */
     hr = IDirect3DDevice9_SetIndices(device, index_buffer);
     ok(SUCCEEDED(hr), "SetIndices failed, hr %#x.\n", hr);
     hr = IDirect3DDevice9_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, 0 /* BaseVertexIndex */,
@@ -2938,6 +2954,12 @@ static void test_draw_primitive(void)
             indices, D3DFMT_INDEX16, quad, sizeof(*quad));
     ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
 
+    hr = IDirect3DDevice9_GetIndices(device, &current_ib);
+    ok(SUCCEEDED(hr), "GetIndices failed, hr %#x.\n", hr);
+    todo_wine ok(!current_ib, "Unexpected index buffer %p.\n", current_vb);
+    if (current_ib)
+        IDirect3DIndexBuffer9_Release(current_ib);
+
     hr = IDirect3DDevice9_SetVertexDeclaration(device, vertex_declaration);
     ok(SUCCEEDED(hr), "SetVertexDeclaration failed, hr %#x.\n", hr);
 
@@ -2947,14 +2969,20 @@ static void test_draw_primitive(void)
     hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLELIST, 2, quad, sizeof(*quad));
     ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr);
 
-    /* NULL index buffer, valid vertex vertex declaration. Should succeed */
+    hr = IDirect3DDevice9_GetStreamSource(device, 0, &current_vb, &offset, &stride);
+    ok(SUCCEEDED(hr), "GetStreamSource failed, hr %#x.\n", hr);
+    ok(!current_vb, "Unexpected vb %p.\n", current_vb);
+    ok(!offset, "Unexpected offset %u.\n", offset);
+    todo_wine ok(!stride, "Unexpected stride %u.\n", stride);
+
+    /* NULL index buffer, valid vertex declaration, NULL stream source. */
     hr = IDirect3DDevice9_SetIndices(device, NULL);
     ok(SUCCEEDED(hr), "SetIndices failed, hr %#x.\n", hr);
     hr = IDirect3DDevice9_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, 0 /* BaseVertexIndex */,
             0 /* MinIndex */, 4 /* NumVerts */, 0 /* StartIndex */, 2 /*PrimCount */);
     todo_wine ok(SUCCEEDED(hr), "DrawIndexedPrimitive failed, hr %#x.\n", hr);
 
-    /* Valid index buffer and vertex declaration. Should succeed */
+    /* Valid index buffer and vertex declaration, NULL stream source. */
     hr = IDirect3DDevice9_SetIndices(device, index_buffer);
     ok(SUCCEEDED(hr), "SetIndices failed, hr %#x.\n", hr);
     hr = IDirect3DDevice9_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, 0 /* BaseVertexIndex */,
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c
index 835c8377e47..1e213abeb18 100644
--- a/dlls/d3d9/tests/visual.c
+++ b/dlls/d3d9/tests/visual.c
@@ -23078,7 +23078,9 @@ static void test_drawindexedprimitiveup(void)
         {{ 1.0f,  1.0f, 0.1f}, 0xff00ff00},
     };
     static const unsigned short indices[] = {0, 1, 2, 3, 4, 5, 6, 7};
+    IDirect3DVertexBuffer9 *vb;
     IDirect3DDevice9 *device;
+    UINT offset, stride;
     IDirect3D9 *d3d;
     ULONG refcount;
     D3DCOLOR color;
@@ -23126,6 +23128,12 @@ static void test_drawindexedprimitiveup(void)
     color = getPixelColor(device, 480, 360);
     ok(color_match(color, 0x00bf4000, 1), "Got unexpected color 0x%08x.\n", color);
 
+    hr = IDirect3DDevice9_GetStreamSource(device, 0, &vb, &offset, &stride);
+    ok(SUCCEEDED(hr), "GetStreamSource failed, hr %#x.\n", hr);
+    ok(!vb, "Unexpected vb %p.\n", vb);
+    ok(!offset, "Unexpected offset %u.\n", offset);
+    todo_wine ok(!stride, "Unexpected stride %u.\n", stride);
+
     hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0);
     ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
 
-- 
2.16.1




More information about the wine-devel mailing list