protonscr

RE2: VkBufferView creation can overflow available memory

vkd3dclosed
HansKristian-Work/vkd3d-proton#266 · opened 2020-09-08 by HansKristian-Work · updated 2020-10-28 · 9 comments · github
HHansKristian-Work 2020-09-08 github

The hashmap approach has some flaws if apps create objects which cannot be reused. See https://github.com/HansKristian-Work/vkd3d-proton/issues/259

KK0bin 2020-09-08 github

Here's the kind of buffer views that cause the problems in RE2:
create buffer view dxgi format: 0, structure stride: 4, element size: 4, size: 96, offset: 0 flags: 0 (logged in
vkd3d_create_buffer_view_for_resource)

Ffsyy 2020-09-14 github

in this thread they say this patch is the cause for crashing Horizon Zero Dawn every 10-20 minutes

https://github.com/ValveSoftware/Proton/issues/4125#issuecomment-691735117
https://github.com/ValveSoftware/Proton/issues/4125#issuecomment-691812754

didn't try it myself but wanted to mention it here.

RRoyShapiro 2020-09-14 github

Here to confirm that reverting the following commits:

daf9f5c69fb69ab87672e61ee6c71ec2fb16d218
5a9d132b20de854f751d4c606c9546e6c34f5c4c
73d578e5abe5658bd8f9cca330a2f7a8f48e0465
684c658e22930f3f77488f77afb590d6889920a4

as suggested by @intersectRaven in the comment linked in the previous post has allowed me to progress much further in Resident Evil 2's The 4th Survivor mode, specifically to the point where I was genuinely defeated by the enemies and then manually quit the game successfully. That is, I did not encounter the freeze we are discussing here. Previously (without reverting the commits) I could reliably reproduce the freeze every time within 5-7 minutes of gameplay at max.

I did, however, notice, that during gameplay the fps has steadily decreased from around 50 fps in the main menu on launch to around 30 fps in the main menu when I quit after gameplay.

Edit:
I've also tested HZD with those commits reverted. And while it still freezes eventually, the non-interrupted playtime has increased dramatically, from mere 10-15 minutes to 40 minutes in one case and over 3 hours and 15 minutes in another, after which I still got a freeze. Still, this is vast improvement.

RRoyShapiro 2020-10-21 github

@Emanem recently did an analysis of this issue, it may help: https://github.com/ValveSoftware/Proton/issues/4125#issuecomment-713530577
Also, I've tried compiling with SSBO enabled, both the WIP and the current master, and in RE2 I get the same, visualy, kind of crash as I did before, only faster. The framerate has also suffered significantly (lost about 15-20 fps compared to non-SSBO version), and, in the WIP version (https://github.com/HansKristian-Work/vkd3d-proton/pull/298) , I was getting objects, including parts of the level, appearing and disappearing out of view at odd angles.
Running Nvidia, driver version 452.06 (so, not the latest & greatest).

Edit: Been retesting today with commit https://github.com/HansKristian-Work/vkd3d-proton/commit/16f09a0ba0606390f410d0de45efa8cb40b26689 and the game crashed again in a similar fashion, however this time I've got a visible error message:
image
Hope this helps.

Ddoitsujin maintainer 2020-10-23 github

We already knew what the problem is. And no, the proposed solution in the thread to limit the view cache is not viable since this would mean going back to reference-counted views, which is extremely inefficient.

Do note that the SSBO path is effectively disabled on Nvidia GPUs right now due to driver/hardware limitations and games just being buggy (the flickering objects you were seeing are caused by a game bug). We are already working on a proper solution that can deal with broken games, but these things take time.

The framerate has also suffered significantly (lost about 15-20 fps compared to non-SSBO version)

What's your GPU and what exactly is your baseline? "15-20 fps" is completely meaningless since you could be running the game at 200 FPS or at 40.

Performance is still pretty much the same as without the SSBO code on my AMD card. If raw SSBOs are somehow slower than texel buffer views on (some) Nvidia hardware, there's not much we can do about that, and the solution for the crashing issue will most likely reduce performance further. You're free to use an older vkd3d build for the time being.

RRoyShapiro 2020-10-23 github

@doitsujin Thank you for the information!
The GPU used is specifically an Asus DUAL-RTX2070-8G, in non-SSBO builds I used to get ~51fps in cutscenes (intro to the 4th survivor of Re2) and ~29-~45 fps during gameplay. With SSBO I get ~40 fps in the same cutscene and ~21-27 fps during gameplay, with occasional drops below 20. Everything else, besides vkd3d build version is the same for both tests.
Specific game settings attached in case they are somehow useful: re2_config.zip

...is effectively disabled on Nvidia GPUs right now due to driver/hardware limitations ... We are already working on a proper solution that can deal with broken games, but these things take time.

Thanks, good to know!
On the side note, it's funny how Nvidia drivers seem to be causing issues these days, I'm far more used to having issues with AMD drivers ever since it was still ATI.

EEmanem 2020-10-23 github

@doitsujin Thanks for the feedback - out of curiosity, did I get it right that in case of H:ZD with the cache we are exhausting resources on the driver side?
If this is the issue, how do you guys plant to tackle it? Really curious from a technical perspective.

@RoyShapiro True - Nvidia used to have better drivers with more resilient functionality, now it appears that these days such drivers are not great...

Ddoitsujin maintainer 2020-10-23 github

If this is the issue, how do you guys plant to tackle it? Really curious from a technical perspective.

Basically we'll have to enable SSBOs for everyone, but implement indexing and bound checking manually in order to deal with alignment issues. It's a pain in the arse, but that's the only way to avoid creating buffer views like crazy.

Ddoitsujin maintainer 2020-10-23 github

Haven't tested RE2/3 yet, but https://github.com/doitsujin/vkd3d/tree/offset-buffers should (in theory) work.

Edit: nvm, this breaks the game completely for some reason.