d3d9/tests: Add test for evicting bound resources.

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Józef Kucia 2016-11-03 12:21:12 +01:00 committed by Alexandre Julliard
parent aa11efc4af
commit 5b0cd6fa3e
1 changed files with 138 additions and 0 deletions

View File

@ -21931,6 +21931,143 @@ done:
DestroyWindow(window);
}
static void test_evict_bound_resources(void)
{
IDirect3DVertexBuffer9 *vb;
IDirect3DIndexBuffer9 *ib;
IDirect3DDevice9 *device;
IDirect3D9 *d3d9;
ULONG refcount;
D3DCOLOR color;
HWND window;
void *data;
HRESULT hr;
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
{
struct vec3 position;
DWORD diffuse;
}
green_quad[] =
{
{{-1.0f, -1.0f, 0.1f}, D3DCOLOR_ARGB(0x7f, 0x00, 0xff, 0x00)},
{{-1.0f, 1.0f, 0.1f}, D3DCOLOR_ARGB(0x7f, 0x00, 0xff, 0x00)},
{{ 1.0f, -1.0f, 0.1f}, D3DCOLOR_ARGB(0x7f, 0x00, 0xff, 0x00)},
{{ 1.0f, 1.0f, 0.1f}, D3DCOLOR_ARGB(0x7f, 0x00, 0xff, 0x00)},
};
static const unsigned short indices[] = {0, 1, 2, 3, 2, 1};
window = create_window();
d3d9 = Direct3DCreate9(D3D_SDK_VERSION);
ok(!!d3d9, "Failed to create a D3D object.\n");
if (!(device = create_device(d3d9, window, window, TRUE)))
{
skip("Failed to create a D3D device.\n");
IDirect3D9_Release(d3d9);
DestroyWindow(window);
return;
}
hr = IDirect3DDevice9_CreateIndexBuffer(device, sizeof(indices), 0,
D3DFMT_INDEX16, D3DPOOL_MANAGED, &ib, NULL);
ok(SUCCEEDED(hr), "Failed to create index buffer, hr %#x.\n", hr);
hr = IDirect3DDevice9_CreateVertexBuffer(device, sizeof(green_quad), 0,
D3DFVF_XYZ | D3DFVF_DIFFUSE, D3DPOOL_MANAGED, &vb, NULL);
ok(SUCCEEDED(hr), "Failed to create vertex buffer, hr %#x.\n", hr);
hr = IDirect3DDevice9_SetTransform(device, D3DTS_WORLD, &mat);
ok(SUCCEEDED(hr), "Failed to set world transform, hr %#x.\n", hr);
hr = IDirect3DDevice9_SetTransform(device, D3DTS_VIEW, &mat);
ok(SUCCEEDED(hr), "Failed to set view transform, hr %#x.\n", hr);
hr = IDirect3DDevice9_SetTransform(device, D3DTS_PROJECTION, &mat);
ok(SUCCEEDED(hr), "Failed to set projection transform, hr %#x.\n", hr);
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_FOGENABLE, FALSE);
ok(SUCCEEDED(hr), "Failed to disable fog, hr %#x.\n", hr);
hr = IDirect3DDevice9_SetRenderState(device, D3DRS_STENCILENABLE, FALSE);
ok(SUCCEEDED(hr), "Failed to disable stencil test, hr %#x.\n", hr);
hr = IDirect3DDevice9_SetRenderState(device, D3DRS_CULLMODE, D3DCULL_NONE);
ok(SUCCEEDED(hr), "Failed to disable culling, hr %#x.\n", hr);
hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
ok(SUCCEEDED(hr), "Failed to disable lighting, hr %#x.\n", hr);
hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ALPHABLENDENABLE, FALSE);
ok(SUCCEEDED(hr), "Failed to disable blending, hr %#x.\n", hr);
hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
ok(SUCCEEDED(hr), "Failed to set color op, hr %#x.\n", hr);
hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
ok(SUCCEEDED(hr), "Failed to set color arg, hr %#x.\n", hr);
hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
ok(SUCCEEDED(hr), "Failed to set alpha op, hr %#x.\n", hr);
hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE);
ok(SUCCEEDED(hr), "Failed to set alpha arg, hr %#x.\n", hr);
hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
hr = IDirect3DVertexBuffer9_Lock(vb, 0, sizeof(green_quad), (void **)&data, 0);
ok(hr == D3D_OK, "Failed to lock vertex buffer, hr %#x.\n", hr);
memcpy(data, green_quad, sizeof(green_quad));
hr = IDirect3DVertexBuffer9_Unlock(vb);
ok(hr == D3D_OK, "Failed to unlock vertex buffer, hr %#x.\n", hr);
hr = IDirect3DIndexBuffer9_Lock(ib, 0, sizeof(indices), (void **)&data, 0);
ok(hr == D3D_OK, "Failed to lock index buffer, hr %#x.\n", hr);
memcpy(data, indices, sizeof(indices));
hr = IDirect3DIndexBuffer9_Unlock(ib);
ok(hr == D3D_OK, "Failed to unlock index buffer, hr %#x.\n", hr);
hr = IDirect3DDevice9_SetIndices(device, ib);
ok(hr == D3D_OK, "Failed to set index buffer, hr %#x.\n", hr);
hr = IDirect3DDevice9_SetStreamSource(device, 0, vb, 0, 4 * sizeof(DWORD));
ok(hr == D3D_OK, "Failed to set stream source, 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_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, 0, 0, 4, 0, 2);
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, 320, 240);
ok(color_match(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
hr = IDirect3DDevice9_EvictManagedResources(device);
ok(hr == D3D_OK, "Failed to evict managed resources, 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_DrawIndexedPrimitive(device, D3DPT_TRIANGLELIST, 0, 0, 4, 0, 2);
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, 320, 240);
ok(color_match(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);
IDirect3DIndexBuffer9_Release(ib);
IDirect3DVertexBuffer9_Release(vb);
refcount = IDirect3DDevice9_Release(device);
ok(!refcount, "Device has %u references left.\n", refcount);
IDirect3D9_Release(d3d9);
DestroyWindow(window);
}
START_TEST(visual)
{
D3DADAPTER_IDENTIFIER9 identifier;
@ -22056,4 +22193,5 @@ START_TEST(visual)
test_color_clamping();
test_line_antialiasing_blending();
test_dsy();
test_evict_bound_resources();
}