godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
88.33k stars 20k forks source link

Poor performance until MSAA setting increased (nVidia driver bug?) #76285

Open jitspoe opened 1 year ago

jitspoe commented 1 year ago

Godot version

3.1-3.5

System information

Windows 8.1, Windows 10, Linux, GLES 2

Issue description

I suspect this is an issue with nVidia's drivers, not Godot, but I've run into this rather strange issue where sometimes, typically when video memory is low, the framerate of my game will absolutely tank. If I increase the MSAA setting, it will usually go back to normal. I can then set the MSAA back to what it was before and it will be fine (ex: 4x MSAA to 8x MSAA then back to 4x).

It has plagued my project (Fist of the Forgotten) for years, and I've had it happen on multiple computers with multiple operating systems and multiple video cards, all nVidia.

It seems to happen on my GTX 970 at around 3.5/4 gigs used (Windows 8.1). It very rarely happens on my RTX 3080 (on Windows 10) as that has a lot more memory, but I have had it happen a couple times after running for a while with a bunch of stuff eating up video memory. It sometimes happens on a fresh boot on my Linux machine which has an old GTX 285.

Somebody said I should report this in any case, though. Maybe there's a way to work around it even if it is a driver bug. I've been half tempted to switch MSAA settings up and then back after the game has been running for a few seconds to work around it myself.

Steps to reproduce

Use an old nVidia card or have < 0.5 gigs of video memory free. Launch the Fist of the Forgotten demo. If the framerate is really low (like sub-40), go into the video settings, change the MSAA to a higher value, then change it back. Note the game runs much better.

Minimal reproduction project

It's a pretty rare occurrence on modern hardware, so I'm not sure what the minimal reproduction case is, but it can be reproduced with the Fist of the Forgotten demo on Steam for sure. If a more minimal case is needed, I can see about firing up my old Linux machine and see if I can make something that reproduces it.

bitsawer commented 1 year ago

It seems to happen on my GTX 970 at around 3.5/4 gigs used (Windows 8.1)

NVIDIA GTX 970 has an infamous memory issue and they were sued for it in a class-action lawsuit:

After the GTX 970 rolled out in September 2014, gamers started to notice that the card’s performance would suffer when it used more than 3.5GB of the card’s 4GB of VRAM.

Nvidia later admitted that the design of the card was to blame, which split the card’s memory into 3.5GB and 512MB segments. Nvidia’s CEO later explained that the memory segmentation was an inventive way to make the GTX 970 a 4GB card when it normally would’ve been 3GB.

No idea about other cards, but could be that updating some settings gives the driver a chance to evict currently unused or invalidated resources from GPU memory which might help temporarily.

Calinou commented 1 year ago

Are you sure this isn't an issue with GPU clocks? MSAA could push the card to a higher power state as it's more demanding. Set the power management mode to Prefer Maximum Performance in the NVIDIA Control Panel or nvidia-settings.

jitspoe commented 1 year ago

Are you sure this isn't an issue with GPU clocks? MSAA could push the card to a higher power state as it's more demanding. Set the power management mode to Prefer Maximum Performance in the NVIDIA Control Panel or nvidia-settings.

I don't think so. I have not seen this issue happen elsewhere. It seems to only happen when the GPU is low on resources.