From: sam me@sam.st
This test is an adaptation of the corresponding d3d9 test.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54898 --- dlls/d3d8/tests/device.c | 99 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+)
diff --git a/dlls/d3d8/tests/device.c b/dlls/d3d8/tests/device.c index 6a585458bae..b6f64502de8 100644 --- a/dlls/d3d8/tests/device.c +++ b/dlls/d3d8/tests/device.c @@ -10910,6 +10910,104 @@ static void test_window_position(void) IDirect3D8_Release(d3d); }
+static void test_filter(void) +{ + static const struct + { + BOOL has_texture; + DWORD filters[7]; + } + tests[] = + { + { + TRUE, + { + D3DTEXF_NONE, + D3DTEXF_POINT, + D3DTEXF_LINEAR, + D3DTEXF_ANISOTROPIC, + D3DTEXF_FLATCUBIC, + D3DTEXF_GAUSSIANCUBIC, + 0xdeadbeef, + }, + }, + { + FALSE, + { + D3DTEXF_NONE, + D3DTEXF_POINT, + D3DTEXF_LINEAR, + D3DTEXF_ANISOTROPIC, + D3DTEXF_FLATCUBIC, + D3DTEXF_GAUSSIANCUBIC, + 0xdeadbeef, + }, + } + }; + + unsigned int i, mag, min, mip; + IDirect3DTexture8 *texture; + IDirect3DDevice8 *device; + IDirect3D8 *d3d; + ULONG refcount; + DWORD passes; + HWND window; + HRESULT hr; + + d3d = Direct3DCreate8(D3D_SDK_VERSION); + ok(!!d3d, "Failed to create a D3D object.\n"); + + window = create_window(); + if (!(device = create_device(d3d, window, NULL))) + { + skip("Failed to create a D3D device, skipping tests.\n"); + IDirect3D8_Release(d3d); + DestroyWindow(window); + return; + } + + hr = IDirect3DDevice8_CreateTexture(device, 128, 128, 0, 0, D3DFMT_X8R8G8B8, D3DPOOL_MANAGED, &texture); + ok(SUCCEEDED(hr), "Failed to create texture, hr %#lx.\n", hr); + + for (i = 0; i < ARRAY_SIZE(tests); ++i) + for (mag = 0; mag < ARRAY_SIZE(tests[i].filters); ++mag) + for (min = 0; min < ARRAY_SIZE(tests[i].filters); ++min) + for (mip = 0; mip < ARRAY_SIZE(tests[i].filters); ++mip) + { + if (tests[i].has_texture) + { + hr = IDirect3DDevice8_SetTexture(device, 0, (IDirect3DBaseTexture8 *)texture); + ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr); + } + else + { + hr = IDirect3DDevice8_SetTexture(device, 0, NULL); + ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr); + } + + hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_MAGFILTER, tests[i].filters[mag]); + ok(SUCCEEDED(hr), "Failed to set sampler state, hr %#lx.\n", hr); + hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_MINFILTER, tests[i].filters[min]); + ok(SUCCEEDED(hr), "Failed to set sampler state, hr %#lx.\n", hr); + hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_MIPFILTER, tests[i].filters[mip]); + ok(SUCCEEDED(hr), "Failed to set sampler state, hr %#lx.\n", hr); + + passes = 0xdeadbeef; + hr = IDirect3DDevice8_ValidateDevice(device, &passes); + ok(SUCCEEDED(hr), "Failed to validate device, hr %#lx.\n", hr); + ok(passes && passes != 0xdeadbeef, "Got unexpected passes %#lx.\n", passes); + } + + hr = IDirect3DDevice8_SetTexture(device, 0, NULL); + ok(SUCCEEDED(hr), "Failed to set texture, hr %#lx.\n", hr); + IDirect3DTexture8_Release(texture); + + refcount = IDirect3DDevice8_Release(device); + ok(!refcount, "Device has %lu references left.\n", refcount); + IDirect3D8_Release(d3d); + DestroyWindow(window); +} + START_TEST(device) { HMODULE d3d8_handle = GetModuleHandleA("d3d8.dll"); @@ -11031,6 +11129,7 @@ START_TEST(device) test_creation_parameters(); test_cursor_clipping(); test_window_position(); + test_filter();
UnregisterClassA("d3d8_test_wc", GetModuleHandleA(NULL)); }