Module: wine Branch: master Commit: 38f3f839438ababa4ae413a9195edfe63b785a53 URL: https://gitlab.winehq.org/wine/wine/-/commit/38f3f839438ababa4ae413a9195edfe...
Author: Sebastian Mayr me@sam.st Date: Thu May 18 11:22:46 2023 +0200
d3d8/tests: Test IDirect3DDevice8::ValidateDevice() with various min, mag and mip filters.
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 | 67 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+)
diff --git a/dlls/d3d8/tests/device.c b/dlls/d3d8/tests/device.c index 6a585458bae..ec6f2ce51b3 100644 --- a/dlls/d3d8/tests/device.c +++ b/dlls/d3d8/tests/device.c @@ -10910,6 +10910,72 @@ static void test_window_position(void) IDirect3D8_Release(d3d); }
+static void test_filter(void) +{ + unsigned int mag, min, mip; + IDirect3DTexture8 *texture; + IDirect3DDevice8 *device; + BOOL has_texture; + 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 (has_texture = FALSE; has_texture <= TRUE; ++has_texture) + for (mag = 0; mag <= D3DTEXF_GAUSSIANCUBIC + 1; ++mag) + for (min = 0; min <= D3DTEXF_GAUSSIANCUBIC + 1; ++min) + for (mip = 0; mip <= D3DTEXF_GAUSSIANCUBIC + 1; ++mip) + { + if (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, mag); + ok(SUCCEEDED(hr), "Failed to set sampler state, hr %#lx.\n", hr); + hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_MINFILTER, min); + ok(SUCCEEDED(hr), "Failed to set sampler state, hr %#lx.\n", hr); + hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_MIPFILTER, 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 +11097,7 @@ START_TEST(device) test_creation_parameters(); test_cursor_clipping(); test_window_position(); + test_filter();
UnregisterClassA("d3d8_test_wc", GetModuleHandleA(NULL)); }