> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# CreateCommandList

> CreateCommandList (Direct3D 12 on XBOX) — Creates a command list. XBOX Direct3D 12 graphics reference.

Creates a command list.

## Syntax

```cpp theme={null}
HRESULT CreateCommandList(
    UINT nodeMask,
    D3D12_COMMAND_LIST_TYPE type,
    ID3D12CommandAllocator  pCommandAllocator,
    ID3D12PipelineState  pInitialState,
    const IID & riid,
    void  ppCommandList
)
```

### Parameters

*nodeMask \[in]*\
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](https://learn.microsoft.com/en-us/windows/win32/direct3d12/multi-engine).

*type \[in]*\
Type: D3D12\_COMMAND\_LIST\_TYPE

Specifies the type of command list to create.

*pCommandAllocator \[in]*\
Type: ID3D12CommandAllocator \*

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

*pInitialState \[in, optional]*\
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).

*riid \[in]*\
Type: const IID &

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

*ppCommandList \[out]*\
Type: void \*\*

A pointer to a memory block that receives a pointer to the [ID3D12CommandList](/reference/graphics/d3d12/interfaces/id3d12commandlist/id3d12commandlist_public) or [ID3D12GraphicsCommandList](/reference/graphics/d3d12_xs/interfaces/ID3D12GraphicsCommandList/id3d12graphicscommandlist_xs) interface for the command list.

### Return value

Type: HRESULT

If the function succeeds, it returns **S\_OK**. Otherwise, it returns an [**HRESULT**](https://learn.microsoft.com/en-us/windows/desktop/com/structure-of-com-error-codes) [error code](https://learn.microsoft.com/en-us/windows/win32/com/com-error-codes-10).

| Return value   | Description                                              |
| -------------- | -------------------------------------------------------- |
| E\_OUTOFMEMORY | There is insufficient memory to create the command list. |

See [Direct3D 12 return codes](https://learn.microsoft.com/en-us/windows/win32/direct3d12/d3d12-graphics-reference-returnvalues) for other possible return values.

## Remarks

The device creates command lists from the command allocator.

## Examples

The [D3D12Bundles](https://learn.microsoft.com/en-us/windows/win32/direct3d12/working-samples) sample uses **ID3D12Device::CreateCommandList** as follows.

Create the pipeline objects.

```cpp theme={null}
ComPtr<ID3D12CommandAllocator> m_commandAllocator;
ComPtr<ID3D12GraphicsCommandList> m_commandList;
```

Create a command allocator.

```cpp theme={null}
ThrowIfFailed(m_device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&m_commandAllocator)));
```

Creating the direct command list.

```cpp theme={null}
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](https://learn.microsoft.com/en-us/windows/win32/direct3d12/notes-on-example-code).

## Requirements

**Header:** d3d12\_xs.h or d3d12\_x.h\
**Library:** d3d12\_xs.lib or d3d12\_x.lib\
**Supported Platforms**: XBOX Series consoles and XBOX One family

## See Also

[ID3D12Device](/reference/graphics/d3d12_x/interfaces/id3d12device/id3d12device)

[ID3D12GraphicsCommandList::Reset](/reference/graphics/d3d12/interfaces/id3d12graphicscommandlist/methods/id3d12graphicscommandlist_reset_public)


## Related topics

- [CreateCommandList1 (XBOX Series consoles)](/reference/graphics/d3d12/interfaces/id3d12device4/methods/id3d12device4_createcommandlist1_public.md)
- [Create Command](/build/core-features/common/game-streaming/tak-command-line-tool/game-streaming-tak-command-line-create-command.md)
- [CreateCommandAllocator](/reference/graphics/d3d12/interfaces/id3d12device/methods/id3d12device_createcommandallocator_public.md)
- [CreatePlacedResource](/reference/graphics/d3d12/interfaces/id3d12device/methods/id3d12device_createplacedresource_public.md)
- [SHAPE_FLOWGRAPH_COMMAND](/reference/audio/shapeflowgraph/structs/shape_flowgraph_command.md)
