SpecialKO / SpecialK

Lovingly referred to as the Swiss Army Knife of PC gaming, Special K does a bit of everything.
https://www.special-k.info/
GNU General Public License v3.0
859 stars 51 forks source link

Current DXVK implementation (as of 2.3.1) seems to trigger SK_DXGI_PresentBase twice per frame #167

Closed Kethen closed 5 months ago

Kethen commented 5 months ago

In Wine, when dxvk d3d11.dll+dxgi.dll is installed to c:/windows/system32, SpecialK can still be hooked as local dxgi.dll/d3d11.dll placed next to applications

When loaded that way (SpecialK hooking DXVK d3d11.dll and dxgi.dll), below can be observed:

  1. SpecialK actually hooks correctly, I was interested in the texture modding feature and both dumping and injecting were working
  2. However Performance is degraded
  3. Built in fps counter shows double actual application framerate

While I have not performed any runtime tracing to confirm this, this is likely caused by the fact that dxvk DxgiSwapChain::Present just calls DxgiSwapChain::Present1 with null pPresentParameters, firing both Present and Present1 hooks when an application uses Present

https://github.com/doitsujin/dxvk/blob/2b70ba8f7798107308a0c34358a9e83e77017dfd/src/dxgi/dxgi_swapchain.cpp#L305-L307

Perhaps a config options should be added to skip either DxgiSwapChain::Present1 or DxgiSwapChain::Present hooking/callback?

Kaldaien commented 5 months ago

Ugh.

I was hoping this issue would never come up. Figures it would be DXVK though.

I think the proper solution would be for SK to call Present1 (...) in its Present (...) hook and never call the original Present function. The reason I haven't done this is because there are some overlays that don't understand Present1. The Steam overlay was like that for many years.

Kaldaien commented 5 months ago

No wait, nevermind. This isn't fixable. The Steam overlay and RTSS will both crash if Present1 (...) is called.

This is better addressed if you contact the developers of DXVK instead.

Kethen commented 5 months ago

closing for now since https://github.com/doitsujin/dxvk/pull/3966 was merged

while it fixed the double fps stats, it only partially fixed the degraded performance

another cause of degraded performance seems to be related to bool SK_D3D11_EnsureMatchingDevices (ID3D11DeviceChild *pDeviceChild, ID3D11Device *pDevice) and bool SK_D3D11_EnsureMatchingDevices (IDXGISwapChain *pSwapChain, ID3D11Device *pDevice) never matching on dxvk, causing vram/pcie bandwidth issue with imgui_d3d11

will be creating a new issue when I have a better grasp of the other cause(s) of degraded performance