doitsujin / dxvk

Vulkan-based implementation of D3D9, D3D10 and D3D11 for Linux / Wine
zlib License
12.26k stars 785 forks source link

Weird framerate drop when re-launching DXVK games/applications with FreeSync #3999

Open definitelyuncertain opened 1 month ago

definitelyuncertain commented 1 month ago

I recently got a 2k 144 Hz ultrawide monitor with FreeSync and have since been experiencing the following peculiar issue with DXVK games:

Initially, when I install a game or application, either through Proton or in Wine standalone, it runs buttery smooth, as I expect from DXVK :-)

But when I close it and relaunch it, the framerate drops everywhere to around half of what it should be! It also stays slow on subsequent launches.

To be clear, I have done nothing else here apart from close the game and relaunch it immediately. And to be sure it wasn't in my head, I ran the Unigine Superposition benchmark, and got scores that followed the same pattern (first time around 11k, and upon relaunch, drops to 5k).

After quite a bit of digging, I found that if I disable FreeSync and enable it again (e.g by going into Plasma Wayland display settings), the pattern is reset (might take a few attempts, but it's worked so far)! That is, it runs fast one time, but slows down again upon closing and relaunching.

Equally strangely, native Linux applications, and even the same ones as above on Wine D3D without DXVK enabled don't seem to be affected at all (including the Superposition Benchmark on Wine with OpenGL, or without DXVK). My screen resolution and refresh rate also appear to be unchanged after each run regardless of what happens.

I've tried multiple Wine/Proton versions, desktops, and even distros but the problem persists. While the above workaround keeps me going for now, I'd love to get to the bottom of this as I haven't found anything online resembling this issue.

I saw nothing interesting/unusual in the console output, and in any case, the apps all ran with no errors whatsoever. Anyway, plmk what debug info I can provide.

Thanks!

Software information

Unigine Superposition Benchmark, Fallout 4, Borderlands 1 and 3, Elden Ring

System information

mbriar commented 1 month ago

Maybe post a screenshot with DXVK_HUD=full when a game is running slow.

Unigine Superposition Benchmark, Fallout 4, Borderlands 1 and 3, Elden Ring

Elden Ring is d3d12 and doesn't use DXVK, this issue sounds not something DXVK has any control over anyways.

definitelyuncertain commented 1 month ago

This is what the HUD shows when Fallout 4 is running slow:

Screenshot_20240513_001356

This is full speed:

Screenshot_20240513_001126

Apparently Elden Ring does have a DX11 launcher which runs DXVK, but you're right that the main game is DX12 which shouldn't be affected. And I think I misremember for Borderlands 3 as well which is DX12.

Not sure what's going on here, but DXVK seems to be the only affected library. I'll try out some more apps and check back.

mbriar commented 1 month ago

Do you see any difference in GPU and VRAM clocks between slow and fast? Some strange amdgpu power management issue would be the best guess i have.

definitelyuncertain commented 1 month ago

I ran it with MangoHud to get the clock info:

Fast: Screenshot_20240513_114042

Slow: Screenshot_20240513_114318

It does look like the GPU clock is running slower, and the power consumption is also lower. However, changing the power settings using CoreCtrl has no effect (I didn't run CoreCtrl for the previous tests).

I ran GravityMark and Doom (2016) demo (OpenGL) on Proton, and both are unaffected. Also did a full system upgrade with similar results.

PS: Disabling FreeSync altogether in Xorg config doesn't help either.

mbriar commented 1 month ago

However, changing the power settings using CoreCtrl has no effect

Even if you do something like echo profile_peak > /sys/class/drm/card0/device/power_dpm_force_performance_level?

ranplayer commented 1 month ago

@definitelyuncertain what's your kernel version ? I'm not sure that is your case, but I've seen performance and freesync issues with kernels higher than 6.1. There is an open issue on the amdgpu gitlab -> https://gitlab.freedesktop.org/drm/amd/-/issues/2966

definitelyuncertain commented 1 month ago

@mbriar That doesn't help (both with and without CoreCtrl), though it does add a few Hz, so thanks for the tip! :-)

@ranplayer it's 6.8.9-arch1-2.1 (the latest Arch update). I'll try booting Ubuntu 22.04 with an older kernel to see if that helps.

doitsujin commented 1 month ago

FWIW I'm on a similar setup (on paper anyway, Plasma 6 Wayland, arch, same mesa, 144hz display with VRR enabled, 6.8 kernel) and haven't had any issues with this ever. Not sure what could be going wrong at this point but nothing here is weird or expected to be broken.

Maybe try this branch, it just disables synchronizing with presentation to meet the frame latency goals provided by the app and is like the only thing that may be a bit janky in some environments, if it's not that then I'm out of ideas.

definitelyuncertain commented 1 month ago

I booted Ubuntu 22.04 with an older kernel (5.19.something), and while it didn't fix this issue, it fixed the DX12 issues with Elden Ring which is now running quite well with no other changes. Thanks @ranplayer for the suggestion!

Given all this, it seems like there is a regression in the Kernel, Mesa, and/or Wine affecting DX12, but there's also a separate DXVK issue.

@doitsujin I'm setting up the build for your branch. Will check back once I've tried it.

definitelyuncertain commented 1 month ago

@doitsujin FYI I'm getting a page fault with that branch (it works as expected when I build the master)

doitsujin commented 1 month ago

yeah i didn't test that build at all, but normally disabling extensions should really just work so not sure what's going on.