Command queue
In order to submit command list to the GPU, a command queue is required. Command queues come in various different types, corresponding to the type of command lists allowed to be submitted to it:
Type | Purpose |
---|---|
D3D12_COMMAND_LIST_TYPE_DIRECT | Allows all operations, whether they are graphics, compute or copy. Despite every command type being allowed, only command lists with type DIRECT are allowed to be submitted. |
D3D12_COMMAND_LIST_TYPE_COMPUTE | Allows compute and copy operations. A separate copy-only queue can be beneficial, as it is these days increasingly common for GPUs to have special compute-only queues, whereas multiple graphics queues are uncommon. On these implementations, using extra compute queues can result in extra performance, although |
D3D12_COMMAND_LIST_TYPE_COPY | Exclusively allows copy operations to take place in command lists submitted to this queue. This queue is primarily intended to copy resources between GPU-local memory and global system RAM, and not so much for copying data from one location to another location on the same GPU. |
Creation of a command queue is not significantly different from creating a device. It should be noted that here there is also a Debug variant that should be used if you are intending on using the debug SDK layers.
ID3D12CommandQueue* commandQueue;
result = renderer->device->lpVtbl->CreateCommandQueue(
renderer->device,
&(D3D12_COMMAND_QUEUE_DESC) { .Type = D3D12_COMMAND_LIST_TYPE_DIRECT },
&IID_ID3D12CommandQueue,
(void**)&renderer->commandQueue
);
if ( !SUCCEEDED(result) )
return; // Failure!