Module: wine Branch: master Commit: ccc1ce9fe3a4b688e6ba8a9f029eb6f65aa31bbe URL: http://source.winehq.org/git/wine.git/?a=commit;h=ccc1ce9fe3a4b688e6ba8a9f02...
Author: Stefan Dösinger stefan@codeweavers.com Date: Tue Aug 27 12:36:21 2013 +0200
d3d8/tests: Add a volume texture locking test.
---
dlls/d3d8/tests/device.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 85 insertions(+), 0 deletions(-)
diff --git a/dlls/d3d8/tests/device.c b/dlls/d3d8/tests/device.c index 28dce38..a48982e 100644 --- a/dlls/d3d8/tests/device.c +++ b/dlls/d3d8/tests/device.c @@ -4891,6 +4891,90 @@ done:
}
+static void test_volume_locking(void) +{ + IDirect3DDevice8 *device; + IDirect3D8 *d3d8; + HWND window; + HRESULT hr; + IDirect3DVolumeTexture8 *texture; + unsigned int i; + D3DLOCKED_BOX locked_box; + ULONG refcount; + D3DCAPS8 caps; + static const struct + { + D3DPOOL pool; + DWORD usage; + HRESULT create_hr, lock_hr; + } + tests[] = + { + { D3DPOOL_DEFAULT, 0, D3D_OK, D3DERR_INVALIDCALL }, + { D3DPOOL_DEFAULT, D3DUSAGE_DYNAMIC, D3D_OK, D3D_OK }, + { D3DPOOL_SYSTEMMEM, 0, D3D_OK, D3D_OK }, + { D3DPOOL_SYSTEMMEM, D3DUSAGE_DYNAMIC, D3D_OK, D3D_OK }, + { D3DPOOL_MANAGED, 0, D3D_OK, D3D_OK }, + { D3DPOOL_MANAGED, D3DUSAGE_DYNAMIC, D3DERR_INVALIDCALL, D3D_OK }, + { D3DPOOL_SCRATCH, 0, D3D_OK, D3D_OK }, + { D3DPOOL_SCRATCH, D3DUSAGE_DYNAMIC, D3DERR_INVALIDCALL, D3D_OK }, + }; + + if (!(d3d8 = pDirect3DCreate8(D3D_SDK_VERSION))) + { + skip("Failed to create IDirect3D8 object, skipping tests.\n"); + return; + } + + window = CreateWindowA("static", "d3d8_test", WS_OVERLAPPEDWINDOW, + 0, 0, 640, 480, 0, 0, 0, 0); + if (!(device = create_device(d3d8, window, window, TRUE))) + { + skip("Failed to create a D3D device, skipping tests.\n"); + IDirect3D8_Release(d3d8); + DestroyWindow(window); + return; + } + + hr = IDirect3DDevice8_GetDeviceCaps(device, &caps); + ok(SUCCEEDED(hr), "Failed to get caps, hr %#x.\n", hr); + if (!(caps.TextureCaps & D3DPTEXTURECAPS_VOLUMEMAP)) + { + skip("Volume textures not supported, skipping test.\n"); + goto out; + } + + for (i = 0; i < sizeof(tests) / sizeof(*tests); i++) + { + hr = IDirect3DDevice8_CreateVolumeTexture(device, 4, 4, 4, 1, tests[i].usage, + D3DFMT_A8R8G8B8, tests[i].pool, &texture); + ok(hr == tests[i].create_hr, "Creating volume texture pool=%u, usage=%#x returned %#x, expected %#x.\n", + tests[i].pool, tests[i].usage, hr, tests[i].create_hr); + if (FAILED(hr)) + continue; + + locked_box.pBits = (void *)0xdeadbeef; + hr = IDirect3DVolumeTexture8_LockBox(texture, 0, &locked_box, NULL, 0); + ok(hr == tests[i].lock_hr, "Lock returned %#x, expected %#x.\n", hr, tests[i].lock_hr); + if (SUCCEEDED(hr)) + { + hr = IDirect3DVolumeTexture8_UnlockBox(texture, 0); + ok(SUCCEEDED(hr), "Failed to unlock volume texture, hr %#x.\n", hr); + } + else + { + ok (locked_box.pBits == NULL, "Failed lock set pBits = %p, expected NULL.\n", locked_box.pBits); + } + IDirect3DVolumeTexture8_Release(texture); + } + +out: + refcount = IDirect3DDevice8_Release(device); + ok(!refcount, "Device has %u references left.\n", refcount); + IDirect3D8_Release(d3d8); + DestroyWindow(window); +} + START_TEST(device) { HMODULE d3d8_handle = LoadLibraryA( "d3d8.dll" ); @@ -4968,6 +5052,7 @@ START_TEST(device) test_swvp_buffer(); test_rtpatch(); test_npot_textures(); + test_volume_locking(); } UnregisterClassA("d3d8_test_wc", GetModuleHandleA(NULL)); }