doitsujin / dxvk

Vulkan-based implementation of D3D8, 9, 10 and 11 for Linux / Wine
zlib License
13.42k stars 867 forks source link

[d3d11][regression] Vindictus - Rendering issues #4405

Closed NorbertHarangozo closed 1 month ago

NorbertHarangozo commented 1 month ago

One of the commits in #4293 started causing rendering issues. I captured a video to showcase the problem. The problem only seems to happen when d3d11.cachedDynamicResources is set (which is set to 'cr' by default to boost performance).

I tried to bisect it down to the exact commit, but it didn't build for two commits, so I had to skip those.

Bisect output ``` [norbi@Norbi-PC dxvk]$ git bisect start Already on 'master' Your branch is up to date with 'origin/master'. status: waiting for both good and bad commits [norbi@Norbi-PC dxvk]$ git bisect bad 5e5c283149e74990153e12ecefb75de6d400947f status: waiting for good commit(s), bad commit known [norbi@Norbi-PC dxvk]$ git bisect good 06baa48c2b32b9b0daabe6f536f2d393b5c3b78a Bisecting: 20 revisions left to test after this (roughly 4 steps) [088ba404a6cc59b80b91c0ce57d46d92df27193f] [dxvk] Rework buffer view creation [norbi@Norbi-PC dxvk]$ git bisect good Bisecting: 10 revisions left to test after this (roughly 3 steps) [bbd2461c8fb126f502ed6c7b2a1fe8907f76a3f0] [dxvk] Reimplement sparse buffer support [norbi@Norbi-PC dxvk]$ git bisect bad Bisecting: 4 revisions left to test after this (roughly 2 steps) [428b1087a06745b1754d514bc3636f9dda17b426] [dxvk] Implement shared cache statistics [norbi@Norbi-PC dxvk]$ git bisect bad Bisecting: 2 revisions left to test after this (roughly 1 step) [4db0007af348d872c6f5b3346a5fa1ef810296e1] [dxvk] Implement local allocation cache [norbi@Norbi-PC dxvk]$ git bisect skip Bisecting: 2 revisions left to test after this (roughly 1 step) [9a51849920bcdf3b0b68dae631b65c72aae69220] [d3d11] Use allocation cache for dynamic buffers [norbi@Norbi-PC dxvk]$ git bisect skip Bisecting: 2 revisions left to test after this (roughly 1 step) [2722a416752efdb9dbdb11de15f401ba1b8653b3] [dxvk] Implement shared allocation cache [norbi@Norbi-PC dxvk]$ git bisect bad Bisecting: 1 revision left to test after this (roughly 1 step) [93547aec8d0152466639f9b34d1ef379f5496e71] [dxvk] Do not track buffer view objects [norbi@Norbi-PC dxvk]$ git bisect good There are only 'skip'ped commits left to test. The first bad commit could be any of: 4db0007af348d872c6f5b3346a5fa1ef810296e1 9a51849920bcdf3b0b68dae631b65c72aae69220 2722a416752efdb9dbdb11de15f401ba1b8653b3 We cannot bisect more! ```

Software information

Vindictus, D3D11 mode

System information

Apitrace file(s)

I tried capturing traces which can be found here.

The one captured on Windows is fairly short, the capturing process was super slow there. I didn't see the problem when I replayed it, not even when I set d3d11.cachedDynamicResources to 'cr' to match the built-in config for the game.

There are two traces captured with Proton, both of them were using DXVK, I couldn't replay them because d3dretrace threw an error (unknown event), with different numbers for each trace.

I tried to capture a trace with WineD3D as well, but the game crashed with that.

Log files

Info level

Vindictus_x64_d3d11.log Vindictus_x64_dxgi.log

Debug level

Vindictus_x64_d3d11.log Vindictus_x64_dxgi.log

doitsujin commented 1 month ago

Can repro in game, thanks for at least trying to trace the damn thing though even if it didn't really work out.

I didn't see the problem when I replayed it, not even when I set d3d11.cachedDynamicResources to 'cr' to match the built-in config for the game.

FYI, apitrace fakes its own exe name in a way that's visible to DXVK, so any app profiles for the actual game will automatically apply to replaying any trace recorded from it as well.

doitsujin commented 1 month ago

Starting to look like a game bug, zeroing memory in Map fixes it and I can't see any hints of our memory allocator doing the wrong thing. Need to test a few things to come up with a workaround, because zeroing on every map is prohibitively expensive.

Edit: Zeroing mapped memory on free works too. It's still extremely expensive on the CPU to the point where it takes more time than doing anything Vulkan-related, but that seems to be the only thing that makes the game actually happy.

NorbertHarangozo commented 1 month ago

I just had a look at the vindictus-fix branch.

I can confirm that it fixes the issue and the performance impact is very minimal, at least coming from my limited testing. It's way better than not having the d3d11.cachedDynamicResources config and still ends up being faster than AMD's D3D11 driver on Windows.