Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DX12 crash with wpgu 0.19 when desired_maximum_frame_latency < 3 #5088

Closed
Elabajaba opened this issue Jan 18, 2024 · 0 comments · Fixed by #5091
Closed

DX12 crash with wpgu 0.19 when desired_maximum_frame_latency < 3 #5088

Elabajaba opened this issue Jan 18, 2024 · 0 comments · Fixed by #5091
Labels
api: dx12 Issues with DX12 or DXGI type: bug Something isn't working

Comments

@Elabajaba
Copy link
Contributor

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

let swap_chain_buffer = (config.maximum_frame_latency + 1).min(3);
(the +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.

*swapchain = Some(SwapChain {

Platform
wgpu 0.19, windows 11, amd 6800xt

@Wumpf Wumpf added type: bug Something isn't working api: dx12 Issues with DX12 or DXGI labels Jan 18, 2024
dtzxporter added a commit to dtzxporter/wgpu that referenced this issue Jan 18, 2024
Fixes gfx-rs#5088. Even though we're telling DX12 that the maximum frame latency should be our non-padded value, the swap chain may request any of the buffers allocated to it.
nical pushed a commit that referenced this issue Jan 19, 2024
#5091)

* Make sure to copy all of the buffers into the resource array for dx12.

Fixes #5088. Even though we're telling DX12 that the maximum frame latency should be our non-padded value, the swap chain may request any of the buffers allocated to it.

* Up the maximum frame latency on the DX12 backend to allow a larger range.
cwfitzgerald pushed a commit to cwfitzgerald/wgpu that referenced this issue Jan 21, 2024
gfx-rs#5091)

* Make sure to copy all of the buffers into the resource array for dx12.

Fixes gfx-rs#5088. Even though we're telling DX12 that the maximum frame latency should be our non-padded value, the swap chain may request any of the buffers allocated to it.

* Up the maximum frame latency on the DX12 backend to allow a larger range.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: dx12 Issues with DX12 or DXGI type: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants