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

Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Matteo Bruni 2018-06-06 00:32:37 +02:00 committed by Alexandre Julliard
parent 893b9977ed
commit f5766a929d
2 changed files with 41 additions and 5 deletions

View File

@ -2861,10 +2861,11 @@ static void test_draw_primitive(void)
D3DDECL_END() D3DDECL_END()
}; };
IDirect3DVertexBuffer9 *vertex_buffer, *current_vb;
IDirect3DIndexBuffer9 *index_buffer, *current_ib;
IDirect3DVertexDeclaration9 *vertex_declaration; IDirect3DVertexDeclaration9 *vertex_declaration;
IDirect3DVertexBuffer9 *vertex_buffer;
IDirect3DIndexBuffer9 *index_buffer;
IDirect3DDevice9 *device; IDirect3DDevice9 *device;
UINT offset, stride;
IDirect3D9 *d3d9; IDirect3D9 *d3d9;
ULONG refcount; ULONG refcount;
HWND window; HWND window;
@ -2918,16 +2919,31 @@ static void test_draw_primitive(void)
hr = IDirect3DDevice9_DrawPrimitive(device, D3DPT_TRIANGLELIST, 0, 2); hr = IDirect3DDevice9_DrawPrimitive(device, D3DPT_TRIANGLELIST, 0, 2);
ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); 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)); hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLELIST, 2, quad, sizeof(*quad));
ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); 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); hr = IDirect3DDevice9_SetIndices(device, NULL);
ok(SUCCEEDED(hr), "SetIndices failed, hr %#x.\n", hr); ok(SUCCEEDED(hr), "SetIndices failed, hr %#x.\n", hr);
hr = IDirect3DDevice9_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, 0 /* BaseVertexIndex */, hr = IDirect3DDevice9_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, 0 /* BaseVertexIndex */,
0 /* MinIndex */, 4 /* NumVerts */, 0 /* StartIndex */, 2 /*PrimCount */); 0 /* MinIndex */, 4 /* NumVerts */, 0 /* StartIndex */, 2 /*PrimCount */);
ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); 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); hr = IDirect3DDevice9_SetIndices(device, index_buffer);
ok(SUCCEEDED(hr), "SetIndices failed, hr %#x.\n", hr); ok(SUCCEEDED(hr), "SetIndices failed, hr %#x.\n", hr);
hr = IDirect3DDevice9_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, 0 /* BaseVertexIndex */, hr = IDirect3DDevice9_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, 0 /* BaseVertexIndex */,
@ -2938,6 +2954,12 @@ static void test_draw_primitive(void)
indices, D3DFMT_INDEX16, quad, sizeof(*quad)); indices, D3DFMT_INDEX16, quad, sizeof(*quad));
ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); 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); hr = IDirect3DDevice9_SetVertexDeclaration(device, vertex_declaration);
ok(SUCCEEDED(hr), "SetVertexDeclaration failed, hr %#x.\n", hr); 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)); hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLELIST, 2, quad, sizeof(*quad));
ok(SUCCEEDED(hr), "DrawPrimitiveUP failed, hr %#x.\n", hr); 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); hr = IDirect3DDevice9_SetIndices(device, NULL);
ok(SUCCEEDED(hr), "SetIndices failed, hr %#x.\n", hr); ok(SUCCEEDED(hr), "SetIndices failed, hr %#x.\n", hr);
hr = IDirect3DDevice9_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, 0 /* BaseVertexIndex */, hr = IDirect3DDevice9_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, 0 /* BaseVertexIndex */,
0 /* MinIndex */, 4 /* NumVerts */, 0 /* StartIndex */, 2 /*PrimCount */); 0 /* MinIndex */, 4 /* NumVerts */, 0 /* StartIndex */, 2 /*PrimCount */);
todo_wine ok(SUCCEEDED(hr), "DrawIndexedPrimitive failed, hr %#x.\n", hr); 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); hr = IDirect3DDevice9_SetIndices(device, index_buffer);
ok(SUCCEEDED(hr), "SetIndices failed, hr %#x.\n", hr); ok(SUCCEEDED(hr), "SetIndices failed, hr %#x.\n", hr);
hr = IDirect3DDevice9_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, 0 /* BaseVertexIndex */, hr = IDirect3DDevice9_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, 0 /* BaseVertexIndex */,

View File

@ -23078,7 +23078,9 @@ static void test_drawindexedprimitiveup(void)
{{ 1.0f, 1.0f, 0.1f}, 0xff00ff00}, {{ 1.0f, 1.0f, 0.1f}, 0xff00ff00},
}; };
static const unsigned short indices[] = {0, 1, 2, 3, 4, 5, 6, 7}; static const unsigned short indices[] = {0, 1, 2, 3, 4, 5, 6, 7};
IDirect3DVertexBuffer9 *vb;
IDirect3DDevice9 *device; IDirect3DDevice9 *device;
UINT offset, stride;
IDirect3D9 *d3d; IDirect3D9 *d3d;
ULONG refcount; ULONG refcount;
D3DCOLOR color; D3DCOLOR color;
@ -23126,6 +23128,12 @@ static void test_drawindexedprimitiveup(void)
color = getPixelColor(device, 480, 360); color = getPixelColor(device, 480, 360);
ok(color_match(color, 0x00bf4000, 1), "Got unexpected color 0x%08x.\n", color); 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); hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0);
ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr); ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);