ID3D12Device::CreateCommandList method (d3d12.h)
Creates a command list.
HRESULT CreateCommandList( [in] UINT nodeMask, [in] D3D12_COMMAND_LIST_TYPE type, [in] ID3D12CommandAllocator *pCommandAllocator, [in, optional] ID3D12PipelineState *pInitialState, [in] REFIID riid, [out] void **ppCommandList );
For single-GPU operation, set this to zero. If there are multiple GPU nodes, then set a bit to identify the node (the device's physical adapter) for which to create the command list. Each bit in the mask corresponds to a single node. Only one bit must be set. Also see Multi-adapter systems.
Specifies the type of command list to create.
A pointer to the command allocator object from which the device creates command lists.
[in, optional] pInitialState
An optional pointer to the pipeline state object that contains the initial pipeline state for the command list. If it is
nullptr, then the runtime sets a dummy initial pipeline state, so that drivers don't have to deal with undefined state. The overhead for this is low, particularly for a command list, for which the overall cost of recording the command list likely dwarfs the cost of a single initial state setting. So there's little cost in not setting the initial pipeline state parameter, if doing so is inconvenient.
For bundles, on the other hand, it might make more sense to try to set the initial state parameter (since bundles are likely smaller overall, and can be reused frequently).
A reference to the globally unique identifier (GUID) of the command list interface to return in ppCommandList.
|E_OUTOFMEMORY||There is insufficient memory to create the command list.|
See Direct3D 12 return codes for other possible return values.
The device creates command lists from the command allocator.
The D3D12Bundles sample uses ID3D12Device::CreateCommandList as follows.
Create the pipeline objects.
ComPtr<ID3D12CommandAllocator> m_commandAllocator; ComPtr<ID3D12GraphicsCommandList> m_commandList;
Create a command allocator.
Creating the direct command list.
ThrowIfFailed(m_device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, m_commandAllocator.Get(), nullptr, IID_PPV_ARGS(&m_commandList)));
Refer to the Example Code in the D3D12 Reference.