[PATCH 1/3] d3d9/tests: The device restores the mode settings from the registry (v2).

Henri Verbeet hverbeet at gmail.com
Wed Oct 29 06:10:01 CDT 2014


On 27 October 2014 23:28, Stefan Dösinger <stefan at codeweavers.com> wrote:
> +    IDirect3D9_GetAdapterDisplayMode(d3d9, D3DADAPTER_DEFAULT, &d3ddm);
> +    adapter_mode_count = IDirect3D9_GetAdapterModeCount(d3d9, D3DADAPTER_DEFAULT, d3ddm.Format);
Shouldn't "d3ddm.Format" just be "D3DFMT_A8R8G8B8" here, since the
test is using create_device()?

> +    modes = HeapAlloc(GetProcessHeap(), 0, sizeof(*modes) * adapter_mode_count);
> +    for (i = 0; i < adapter_mode_count; ++i)
> +    {
> +        UINT j;
> +
> +        hr = IDirect3D9_EnumAdapterModes(d3d9, D3DADAPTER_DEFAULT, d3ddm.Format, i, &d3ddm2);
> +        ok(SUCCEEDED(hr), "Failed to enumerate display mode, hr %#x.\n", hr);
> +
> +        if (d3ddm2.Width == screen_width && d3ddm2.Height == screen_height)
> +            continue;
Given the nature of this test, we'd probably want to retrieve
"screen_width" and "screen_height" with EnumDisplaySettingsW() and
ENUM_REGISTRY_SETTINGS, and perhaps also make sure they match the
current settings before running any tests.

> +        /* The r200 driver on Windows XP enumerates modes like 320x200 and 320x240 but
> +         * refuses to create a device at these sizes. */
> +        if (d3ddm2.Width < 640 || d3ddm2.Height < 480)
> +            continue;
> +
> +        for (j = 0; j < mode_count; ++j)
> +        {
> +            if (modes[j].w == d3ddm2.Width && modes[j].h == d3ddm2.Height)
> +                break;
> +        }
> +        if (j == mode_count)
> +        {
> +            modes[j].w = d3ddm2.Width;
> +            modes[j].h = d3ddm2.Height;
> +            ++mode_count;
> +        }
> +    }
> +
> +    /* Make sure the d3d mode is smaller or equal in both width and height
> +     * than the mode passed to ChangeDisplaySettings. Otherwise Windows
> +     * shrinks the window to the ChangeDisplaySettings parameters + 12. */
> +    d3ddm.Width = d3ddm.Height = d3ddm2.Width = d3ddm2.Height = ~0U;
> +    for (i = 0; i < mode_count; i++)
> +    {
> +        if (modes[i].w < d3ddm.Width && modes[i].h < d3ddm.Height)
> +        {
> +            d3ddm.Width = modes[i].w;
> +            d3ddm.Height = modes[i].h;
> +        }
> +    }
> +    for (i = 0; i < mode_count; i++)
> +    {
> +        if (modes[i].w < d3ddm.Width || modes[i].h < d3ddm.Height)
> +            continue;
> +        if (modes[i].w == d3ddm.Width && modes[i].h == d3ddm.Height)
> +            continue;
> +        d3ddm2.Width = modes[i].w;
> +        d3ddm2.Height = modes[i].h;
> +        break;
> +    }
> +
> +    HeapFree(GetProcessHeap(), 0, modes);
> +    if (d3ddm2.Width == ~0U)
> +    {
> +        skip("Could not find adequate modes, skipping mode tests.\n");
> +        IDirect3D9_Release(d3d9);
> +        return;
> +    }
This looks fairly complicated, but in the end you just need two
display modes that satisfy a couple of conditions. I suspect this code
could be simplified a fair bit. Of course that probably also applies
to test_reset() where this looks borrowed from.



More information about the wine-devel mailing list