HansKristian-Work / vkd3d-proton

Fork of VKD3D. Development branches for Proton's Direct3D 12 implementation.
GNU Lesser General Public License v2.1
1.75k stars 183 forks source link

Ghost of Tsushima - Enabling Nvidia Reflex causes stutter/freezes #2008

Closed shelterx closed 2 weeks ago

shelterx commented 1 month ago

Ghost of Tsushima

Enabling Nvidia Reflex causes the game to occasionaly freeze up for half a second while playing. And enabling FSR3 causes the game to randomly lock up, sound can be heard but nothing renders. Just mentioning it for reference, not sure if this is a vkd3d-proton problem.

Not sure how to capture the Reflex issue, so I have no log currently.

esullivan-nvidia commented 1 month ago

Thanks for the report. I unfortunately wasn't able to reproduce the stutters you described when Reflex was enabled, or the freeze with FSR3+Reflex. Could you confirm if dxvk-nvapi is built with the following commit for the Proton build you are using: https://github.com/jp7677/dxvk-nvapi/commit/35b9fe598977c3380012165f9c75086e6f12b33f.

Without that commit it is possible the game is occasionally providing a previously used frame id, resulting in vkd3d-proton having to recreate the swapchain. It would also be useful to provide the output of adding PROTON_LOG=1 to your steam command options.

shelterx commented 1 month ago

I have that commit. But it feels like there are many variables to consider here. I tried with Proton Experimental, Reflex seems ok now. But FSR3 still locks up after a while. There are weird microstutters going on, this seems unrelated to Reflex/FSR3. Very noticeble when you look down and walk... Wayland, 144hz monitor. Very high settings, DLSS off, Dynamic scaling off.

Update: Did a comparison with Windows, everything is silky smooth there, FPS is about 30-40 more with the same settings (FSR3/DLSS FG off), no stutter.

HansKristian-Work commented 1 month ago

resulting in vkd3d-proton having to recreate the swapchain.

This will never happen in recent vkd3d-proton.

VKD3D_QUEUE_PROFILE=/tmp/profile.json should log reflex behavior.

shelterx commented 3 weeks ago

Here's a vkd3d.log with the FSR3 Framegen hang...

vkd3d.log

shelterx commented 3 weeks ago

And Reflex log, I can't say I experience much issues with Reflex and proton experimental tho' but I also don't notice much of a difference with it on vs off either. profile.zip

shelterx commented 3 weeks ago

Regarding the FSR3 hang, it seems like you need to disable NVAPI. PROTON_DISABLE_NVAPI=1 makes FSR3 work and there's no more stutter either and the game seems very smooth.

Unfortunately it also disables reflex and DLAA. But now you know the reason behind the FSR3 hang and stutter at least, it's related to something in NVAPI.

(I did also notice that turning off vsync and limit the framerate with mangohud makes the stutter return for some reason, seems like the game doesn't like it)

Saancreed commented 3 weeks ago

But now you know the reason behind the FSR3 hang and stutter at least, it's related to something in NVAPI.

Fwiw last week I made a few attempts at figuring out why exactly is NVAPI causing this weirdness here but I couldn't. The game is doing some… unexpected things with NvAPI_D3D12_SetAsyncFrameMarker which causes a log spam from vkd3d-proton due to d3d12_low_latency_device_SetLatencyMarker: PRESENT_START_NV is non-monotonic but it appears to be presenting with each frame ID only once anyway so it should not cause issues like the stutter you're experiencing.

I'll try to take another look at this soon but I don't think I'll be able to find anything more than that.

shelterx commented 3 weeks ago

@Saancreed Thank you. I have done some testing here also and it seems like the short freezes is very random with Reflex on. Sometimes it just doesn't happen.

Regarding the other issues (general stutter and FSR3 locking up), perhaps it's just one of those games that doesn't like NVAPI, it runs great without it.

Update: Seems like something is happening with the "frametimes" when NVAPI is enabled, without NVAPI the frametime graph in mangohud is "flat". With NVAPI enabled the frametime graph is showing very small spikes all the time.

Saancreed commented 2 weeks ago

@shelterx I believe I have a workaround for NVAPI thing.

Get nvapi64.dll from https://github.com/jp7677/dxvk-nvapi/actions/runs/9523021510, install it into your Wine prefix (or if you're using Proton replace the one that comes with it) then launch the game with DXVK_NVAPI_GPU_ARCH=GA100 in the environment. You should see info:dxvk-nvapi:NvAPI_GPU_GetArchInfo: GPU Architecture overriden to GA100 in the logs if you did it correctly.

shelterx commented 2 weeks ago

@Saancreed Wow, nice find! This actually works flawlessly (I enabled FSR3, DLAA, Reflex) Now the question is, what causes it when using Ada and not Ampare? Driver issue or something else?

Saancreed commented 2 weeks ago

Of all things a driver issue seems very unlikely, after we aren't changing its behavior in any way, we're only lying to the game about GPU architecture. I'd suspect a game bug or an issue with some SDK it uses, like Streamline or NVNGX stuff, but the latter would be quite scary because then many other games could also be affected.

shelterx commented 2 weeks ago

I saw this PR, https://github.com/HansKristian-Work/vkd3d-proton/pull/2014 I tried it, didn't change anything regarding this issue anyway.

shelterx commented 2 weeks ago

Should I close this? Or do the vkd3d-proton devs want it open?

shelterx commented 2 weeks ago

It's fixed and works with NVAPI quirk. Again, nice find @Saancreed