DX12 Create swap chain take a CommandQueue instead of a Device?

Started by
3 comments, last by Hodgman 5 years, 4 months ago

Hi,

I'm curious about why CreateSwapChainForHwnd  in DX12 takes a CmdQueue?  ?

It's far from the DirectX philosophy: 

Device: Create Things

CmdQueue: Take Actions

Does anyone know more about this?

Advertisement

This is just a guess -

You only need 1 device, but in theory you can have multiple queues.

 

This is a comment from some tutorial code -

"Swap chain needs the queue so that it can force a flush on it."

A swapchain creates things AND submits work. Since you can have multiple command queues belonging to the same device, the app needs to be explicit about which one should have the work submitted against it. And since you can get from the command queue to the device, there's no reason to pass both the device and queue, just the queue is sufficient.

Yeah the swap-chain is a bit more of a high-level object, different from most of the D3D12 low level design. Partly, this is because it's a DXGI object, not a purely D3D12-only object.

It actually creates a collection of resources (the chain of buffers that alternate between being rendered to and being displayed), manages some synchronization of that buffer-swapping work, and submits the actual commands to display a buffer to the screen.

This topic is closed to new replies.

Advertisement