-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Description
The default desired_maximum_frame_latency of 2 causes crashes with dx12.
Repro steps
Run any of the wgpu examples with dx12. (it might only crash on amd? @cwfitzgerald said on matrix that it worked fine on his nvidia gpu)
Expected vs observed behavior
Expected: Doesn't crash.
Observed: Crashes immediately. (setting desired_maximum_frame_latency to 3 or higher doesn't crash)
Extra materials
This line has a few issues
Line 666 in adf1e3b
| let swap_chain_buffer = (config.maximum_frame_latency + 1).min(3); |
+1 seems to be what causes the crash and the .min(3) means you can never have more than 3 even if you set maximum_frame_latency to eg. 10 because you made a video player that doesn't care about input latency but about smoothness and performance).
ERROR log: ID3D12CommandQueue::ExecuteCommandLists: A command list, which writes to a swapchain back buffer, may only be executed when that back buffer is the back buffer that will be presented during the next call to Present*. Such a back buffer is also referred to as the "current back buffer". Swap Chain: 0x0000021394DF6D10:'Unnamed Object' - Current Back Buffer Buffer: 0x000002139A18A650:'Unnamed ID3D12Resource Object' - Attempted Write Buffer: 0x000002139A18F180:'Unnamed ID3D12Resource Object' [ STATE_SETTING ERROR #907: EXECUTECOMMANDLISTS_WRONGSWAPCHAINBUFFERREFERENCE]
At first I thought it was because we were creating more swap_chain buffers than what gets passed to SetMaximumFrameLatency, but that was incorrect (you can have a higher number of swap_chain buffers than what you passed to SetMaximumFrameLatency).
The issue appears to be something to do with the resources we use when creating the wgpu-hal dx12 SwapChain being maximum_frame_latency sized, but creating the raw swap_chain with maximum_frame_latency + 1 swap_chain_buffers.
Line 818 in adf1e3b
| *swapchain = Some(SwapChain { |
Platform
wgpu 0.19, windows 11, amd 6800xt