Skip to content

DX12 crash with wpgu 0.19 when desired_maximum_frame_latency < 3 #5088

@Elabajaba

Description

@Elabajaba

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    backend: dx12Issues with DX12 or DXGItype: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions