HansKristian-Work / vkd3d-proton

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

VKD3D_CONFIG=dxr significantly increases VRAM usage in Guardians of the Galaxy #1874

Open simifor opened 6 months ago

simifor commented 6 months ago

The benchmark of the game goes from taking 5.5-6GB of VRAM with VKD3D_CONFIG=nodxr to completely filling it when using VKD3D_CONFIG=dxr. The issue can be observed with amdvlk 2024.Q1.1, and radv with any commit since https://gitlab.freedesktop.org/mesa/mesa/-/commit/374bd4e1bef25ba2aeef6016ac35b41df07f3a99

Increased VRAM usage also lowers the performance in radv and amdvlk, specially in the former.

Software information

Guardians of the Galaxy with most things on low or disabled, ray tracing is also disabled. Marvel's Guardians of the Galaxy_20240117_184742 (this card has 8GB of VRAM, the game misreports the total amount when going past its limits)

System information

2.11 and later will display this issue by default as it sets VKD3D_CONFIG=dxr, in previous versions the user would have to set that up themselves for it to appear

Blisto91 commented 6 months ago

Do we know how this behaves/compares to Windows?

simifor commented 6 months ago

well, in windows the benchmark reports using 4GB of VRAM when using DX12 natively. The game will not launch for me when adding vkd3d files and dxgi into the executable's folder. gotg

shelterx commented 6 months ago

The game uses more vram on linux with Nvidia too. Generally i think that’s just how it is. I dont know the technical reason why that is tho’.

shelterx commented 6 months ago

I ran the game with RT on Ultra, all other settings on High, AFx16. The game reports that it used 9,6Gb with Nvidia. So 8,3GB with AMD on low seems too much.

@simifor Can you try a benchmark with high settings, AFx16 settings on AMD and see what VRAM usage you get?

simifor commented 6 months ago

@shelterx the benchmark repotrs 5.5GB of VRAM usage when the game is run with nodxr, and 8.4GB (which is over the card's budget) with dxr. Both tests were with high settings, AF to 16x and RT disabled

shelterx commented 6 months ago

@simifor Oh, I see. But you first wrote all tests were done in low settings which the screenshots imply. But yes, I understand what you mean now. dxr increases memory usage even if you don't have RT. Try running the game with the VKD3D_CONFIG option no_upload_hvv

simifor commented 6 months ago

@simifor Oh, I see. But you first wrote all tests were done in low settings which the screenshots imply. They were, there just isn't a big vram usage difference reported by the benchmark from gong to low to high, for whatever reason.A low preset test used 5.1GB. But yes, I understand what you mean now. dxr increases memory usage even if you don't have RT. Try running the game with the VKD3D_CONFIG option no_upload_hvv vram went down slightly, 8046MB, and even though that's slightly below the reported maximum, the performance still suffers greatly.

doitsujin commented 5 months ago

This is kind of expected though? Raytracing acceleration structures are big, and will obviously not be created when raytracing is disabled.

You could try using VKD3D_CONFIG=no_upload_hvv and see if that does anything (assuming you have ReBAR enabled), but doing so may also reduce performance.

simifor commented 5 months ago

The problem is that raytracing is disabled ingame, the only way to avoid high vram usage is to change the defautl configuration of vkd3d-proton or use an old version of mesa (or an old version of vkd3d-proton before the default got changed)

shelterx commented 5 months ago

@simifor Can't you just use VKD3D_CONFIG=nodxr ?

simifor commented 5 months ago

I can, but the problem is that other people are affected too. Most people with an 8GB VRAM card or less (only 25% of steam users have 10GB or more) would have to change an environment variable to avoid the risk of performance degradation, this doesn't seem ideal.

On Thu, Feb 29, 2024, 11:01 PM shelterx @.***> wrote:

@simifor https://github.com/simifor Can't you just use VKD3D_CONFIG=nodxr ?

— Reply to this email directly, view it on GitHub https://github.com/HansKristian-Work/vkd3d-proton/issues/1874#issuecomment-1972382377, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQZQ4EHIQWD3F7M6I5EPB6DYV7VP3AVCNFSM6AAAAABCXGHGM6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNZSGM4DEMZXG4 . You are receiving this because you were mentioned.Message ID: @.***>

shelterx commented 5 months ago

@doitsujin @simifor I don't know what VKD3D-proton do internally when dxr is enabled, but to me it seems odd that having dxr enabled increases GPU memory usage by such an amount, even if RT isn't enabled in the game. Windows obviously behaves differently here.

shelterx commented 5 months ago

For reference, I did a test with my RTX 3070 with RT enabled in the game. According to the benchmark results Windows is using ~half of of the VRAM compared to Linux. However according to MSI Afterburner and Mangohud, the VRAM usage is about the same. As a sidenote, there's ~20 FPS loss in Linux.

doitsujin commented 5 months ago

We don't allocate more memory if DXR is exposed. Memory management is up to the game.

SuperSamus commented 5 months ago

One "interesting" thing about the game, is that if it detects an AMD card but can't properly detect the driver version, the launcher will complain about outdated drivers, and the option to enable raytracing will be grayed out (both in the launcher and in the game). Proton has a patch for that.

If you are not using this patch, the VRAM usage will be normal, even though DXR is technically exposed. But if you do DXVK_CONFIG="dxgi.hideAmdGpu = True", the game will still complain about outdated drivers, but it will allow enabling raytracing (it functions perfectly fine). In that case, the VRAM usage will be increased for no reason, just like with the patch.