From: Zebediah Figura zfigura@codeweavers.com
--- dlls/d3d9/tests/visual.c | 59 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 53 insertions(+), 6 deletions(-)
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c index bb8381cde3d..1b990301cac 100644 --- a/dlls/d3d9/tests/visual.c +++ b/dlls/d3d9/tests/visual.c @@ -27360,14 +27360,9 @@ static void test_dynamic_map_synchronization(void) }
hr = IDirect3DDevice9_CreateVertexBuffer(device, 200 * 4 * sizeof(struct dynamic_vb_vertex), - D3DUSAGE_DYNAMIC, D3DFVF_XYZ, D3DPOOL_DEFAULT, &buffer, NULL); + D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, D3DFVF_XYZ, D3DPOOL_DEFAULT, &buffer, NULL); ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
- hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff0000, 0.0f, 0); - ok(hr == D3D_OK, "Failed to clear, hr %#lx.\n", hr); - - hr = IDirect3DDevice9_BeginScene(device); - ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); hr = IDirect3DDevice9_SetStreamSource(device, 0, buffer, 0, sizeof(struct dynamic_vb_vertex)); ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE); @@ -27377,6 +27372,12 @@ static void test_dynamic_map_synchronization(void) hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE); ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
+ hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff0000, 0.0f, 0); + ok(hr == D3D_OK, "Failed to clear, hr %#lx.\n", hr); + + hr = IDirect3DDevice9_BeginScene(device); + ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); + for (y = 0; y < 200; ++y) { hr = IDirect3DVertexBuffer9_Lock(buffer, 0, 0, &data, D3DLOCK_DISCARD); @@ -27414,6 +27415,52 @@ static void test_dynamic_map_synchronization(void) hr = IDirect3DDevice9_EndScene(device); ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr);
+ IDirect3DVertexBuffer9_Release(buffer); + + /* Castlevania: Lords of Shadow 2 locks a vertex and index buffer and keeps + * both mapped for all of the draws in a frame. Test this by doing the same + * draws, but with the buffer mapped the whole time. */ + + hr = IDirect3DDevice9_CreateVertexBuffer(device, 200 * 4 * sizeof(struct dynamic_vb_vertex), + D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, D3DFVF_XYZ, D3DPOOL_DEFAULT, &buffer, NULL); + ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); + hr = IDirect3DDevice9_SetStreamSource(device, 0, buffer, 0, sizeof(struct dynamic_vb_vertex)); + ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); + + hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffff0000, 0.0f, 0); + ok(hr == D3D_OK, "Failed to clear, hr %#lx.\n", hr); + + hr = IDirect3DDevice9_BeginScene(device); + ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); + + for (y = 0; y < 200; ++y) + { + hr = IDirect3DVertexBuffer9_Lock(buffer, 0, 0, &data, D3DLOCK_DISCARD); + ok(hr == D3D_OK, "Failed to map buffer, hr %#lx.\n", hr); + + fill_dynamic_vb_quad(data, 0, y); + hr = IDirect3DDevice9_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, 0, 2); + ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); + + for (x = 1; x < 200; ++x) + { + fill_dynamic_vb_quad((struct dynamic_vb_vertex *)data + 4 * x, x, y); + hr = IDirect3DDevice9_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, 4 * x, 2); + ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); + } + + hr = IDirect3DVertexBuffer9_Unlock(buffer); + ok(hr == D3D_OK, "Failed to map buffer, hr %#lx.\n", hr); + } + + hr = IDirect3DDevice9_EndScene(device); + ok(hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); + + hr = IDirect3DDevice9_GetRenderTarget(device, 0, &rt); + ok(hr == S_OK, "Failed to get render target, hr %#lx.\n", hr); + check_rt_color_todo(rt, 0x0000ff00); + IDirect3DSurface9_Release(rt); + IDirect3DVertexBuffer9_Release(buffer); refcount = IDirect3DDevice9_Release(device); ok(!refcount, "Device has %lu references left.\n", refcount);