Elden Ring hits this particularly nasty pattern:
011c:info:dxgi_vk_swap_chain_Present: PRESENT
01fc:info:d3d12_command_list_BeginQuery: BeginQuery
01fc:info:d3d12_command_list_EndQuery: EndQuery
01fc:info:d3d12_command_list_ResolveQueryData: ResolveQuery: type 0, start_index 6404, query_count 1.
01fc:info:d3d12_command_list_BeginQuery: BeginQuery
01fc:info:d3d12_command_list_EndQuery: EndQuery
01fc:info:d3d12_command_list_ResolveQueryData: ResolveQuery: type 0, start_index 6210, query_count 1.
01fc:info:d3d12_command_list_BeginQuery: BeginQuery
01fc:info:d3d12_command_list_EndQuery: EndQuery
01fc:info:d3d12_command_list_ResolveQueryData: ResolveQuery: type 0, start_index 3074, query_count 1.
01fc:info:d3d12_command_list_BeginQuery: BeginQuery
01fc:info:d3d12_command_list_EndQuery: EndQuery
01fc:info:d3d12_command_list_ResolveQueryData: ResolveQuery: type 0, start_index 832, query_count 1.
01fc:info:d3d12_command_list_BeginQuery: BeginQuery
01fc:info:d3d12_command_list_EndQuery: EndQuery
01fc:info:d3d12_command_list_ResolveQueryData: ResolveQuery: type 0, start_index 7618, query_count 1.
01fc:info:d3d12_command_list_BeginQuery: BeginQuery
01fc:info:d3d12_command_list_EndQuery: EndQuery
01fc:info:d3d12_command_list_ResolveQueryData: ResolveQuery: type 0, start_index 7682, query_count 1.
01fc:info:d3d12_command_list_BeginQuery: BeginQuery
01fc:info:d3d12_command_list_EndQuery: EndQuery
01fc:info:d3d12_command_list_ResolveQueryData: ResolveQuery: type 0, start_index 4544, query_count 1.
... 100+ of these.
This is worst possible scenario.
@HansKristian-Work, is this something you plan on exploring at some point? Performance in Elden Ring doesn't seem to be great, to say the least. I wonder how significant of an impact this could have on it.
Pretty sure performance in Elden Ring is comparable to windows, as long as you keep ray tracing disabled, which the game enables by default.
@mbriar, performance can be both comparable with Windows and not great at the same time 😅
On Steam Deck I see that the bottleneck for FPS is neither CPU nor GPU in the areas I tested. The GPU utilization is much higher than the CPU utilization but never hits more than ~85% at any point (regardless of graphics settings, with ray tracing disabled). Such behavior usually indicates that there is some kind of excessive synchronization involved.
Oddly enough, I can actually get 7-10% higher FPS and significantly more consistent frame times by setting the GPU clock to a constant of 1400MHz (out of 1600MHz maximum). When doing so I'm also hitting 99% GPU utilization. I'm not certain why that is but my best guess is that the lower clock results in some GPU computations taking more time and in turn resulting in synchronization points being waited on less often. Waiting less often means less bubbles in various pipelines and better consistent utilization of the GPU hardware.
Anyway, the improvement described in this issue sounds like a potential driver optimization to compensate for what seems to be inefficient application behavior. DX12 drivers on Windows may or may not have implemented this optimization. Either way, it shouldn't stop us from attempting to do so.
Pretty sure @doitsujin wrote optimizations for this pattern ages ago.
When doing so I'm also hitting 99% GPU utilization.
Try VKD3D_SWAPCHAIN_LATENCY_FRAMES=3. It's possible the game ends up with 2, and we hit case of too much sync.
VKD3D_SWAPCHAIN_LATENCY_FRAMES=3.x1 2024-06
If we end up with one physical query + virtual query, it should be possible to resolve directly without going through compute shader.
It should be possible to do a fast path where if there is no virtual query that overlaps a single physical one, it should be possible to implement the query resolve without any dedicated barriers.