• Zebediah Figura's avatar
    d3d9: Cache the output mode list. · 0ee74e9f
    Zebediah Figura authored
    Garou: Mark of the Wolves calls IDirect3D9::GetAdapterModeCount() on every
    frame. This results in calling EnumDisplaySettingsExW() once per available mode,
    which is a very slow operation, both on Windows and Wine.
    
    Manual testing shows that Windows caches the mode list (as well as the adapter
    list, which is already cached in Wine) in Direct3D 9 and lower. Calls to
    GetAdapterModeCount() and EnumAdapterDisplayModes() are fast, and they also do
    not change if monitors are added or removed.
    
    DXGI behaves differently, however. The list of outputs attached to an adapter is
    cached—that is, calls to IDXGIAdapter::EnumOutputs() are fast, and return stale
    data. However, at least some other calls are slow and do not seem to be cached,
    including IDXGIOutput::GetDisplayModeList() and IDXGIOutput::GetDesc().
    
    ddraw is also slow and uncached. Since all testing was done on Windows 10 (for
    lack of available older hardware to test with) it is not unlikely that ddraw was
    reimplemented over dxgi on newer Windows, and that older Windows versions would
    be fast and cached, but this is speculation. In any case I have not included
    patches to cache ddraw modes.
    
    Tests were done on Windows 10 21H2, both on real hardware with NVidia drivers
    and on software drivers via qemu/KVM. In the latter case only speed could be
    tested, but this was consistent with the results from the NVidia machine.
    0ee74e9f
ddraw.c 170 KB