ID3D12Device::CreateCommandList method (d3d12.h)

Creates a command list.

Syntax

HRESULT CreateCommandList(
  [in]           UINT                    nodeMask,
  [in]           D3D12_COMMAND_LIST_TYPE type,
  [in]           ID3D12CommandAllocator  *pCommandAllocator,
  [in, optional] ID3D12PipelineState     *pInitialState,
  [in]           REFIID                  riid,
  [out]          void                    **ppCommandList
);

Parameters

[in] nodeMask

Type: UINT

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.

[in] type

Type: D3D12_COMMAND_LIST_TYPE

Specifies the type of command list to create.

[in] pCommandAllocator

Type: ID3D12CommandAllocator*

A pointer to the command allocator object from which the device creates command lists.

[in, optional] pInitialState

Type: ID3D12PipelineState*

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).

[in] riid

Type: REFIID

A reference to the globally unique identifier (GUID) of the command list interface to return in ppCommandList.

[out] ppCommandList

Type: void**

A pointer to a memory block that receives a pointer to the ID3D12CommandList or ID3D12GraphicsCommandList interface for the command list.

Return value

Type: HRESULT

If the function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Return value Description
E_OUTOFMEMORY There is insufficient memory to create the command list.

See Direct3D 12 return codes for other possible return values.

Remarks

The device creates command lists from the command allocator.

Examples

The D3D12Bundles sample uses ID3D12Device::CreateCommandList as follows.

Create the pipeline objects.

ComPtr<ID3D12CommandAllocator> m_commandAllocator;
ComPtr<ID3D12GraphicsCommandList> m_commandList;

Create a command allocator.

ThrowIfFailed(m_device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&m_commandAllocator)));

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.

Requirements

Requirement Value
Target Platform Windows
Header d3d12.h
Library D3D12.lib
DLL D3D12.dll

See also

ID3D12Device

ID3D12GraphicsCommandList::Reset