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

# CreateCommandAllocator

> Creates a command allocator object.

Creates a command allocator object.

## Syntax

```cpp theme={null}
HRESULT CreateCommandAllocator(
    D3D12_COMMAND_LIST_TYPE type,
    const IID & riid,
    void  ppCommandAllocator
)
```

### Parameters

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

A [D3D12\_COMMAND\_LIST\_TYPE](https://docs.xbox.com/reference/graphics/d3d12_x/enums/d3d12_command_list_type.md)-typed value that specifies the type of command allocator to create.
The type of command allocator can be the type that records either direct command lists or bundles.

*riid*\
Type: const IID &

The globally unique identifier (**GUID**) for the command allocator interface ([ID3D12CommandAllocator](https://docs.xbox.com/reference/graphics/d3d12_x/interfaces/ID3D12CommandAllocator/id3d12commandallocator.md)).
The **REFIID**, or **GUID**, of the interface to the command allocator can be obtained by using the \_\_uuidof() macro.
For example, \_\_uuidof(ID3D12CommandAllocator) will get the **GUID** of the interface to a command allocator.

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

A pointer to a memory block that receives a pointer to the [ID3D12CommandAllocator](https://docs.xbox.com/reference/graphics/d3d12_x/interfaces/ID3D12CommandAllocator/id3d12commandallocator.md) interface for the command allocator.

### Return value

Type: HRESULT

This method returns **E\_OUTOFMEMORY** if there is insufficient memory to create the command allocator.
See [Direct3D 12 Return Codes](https://learn.microsoft.com/en-us/windows/desktop/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/desktop/direct3d12/working-samples) sample uses **ID3D12Device::CreateCommandAllocator** as follows:

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

```

Refer to the [Example Code in the D3D12 Reference](https://learn.microsoft.com/en-us/windows/desktop/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](https://docs.xbox.com/reference/graphics/d3d12_x/interfaces/id3d12device/id3d12device.md)


## Related topics

- [CreateCommandList](https://docs.xbox.com/reference/graphics/d3d12/interfaces/id3d12device/methods/id3d12device_createcommandlist_public.md)
- [ID3D12CommandAllocator::Reset](https://docs.xbox.com/reference/graphics/d3d12/interfaces/id3d12commandallocator/methods/id3d12commandallocator_reset_public.md)
- [Quickstart for multiplayer servers (MpsAllocator Sample)](https://docs.xbox.com/services/playfab/multiplayer/servers/mps-allocator-sample.md)
- [D3D12_AUTO_BREADCRUMB_NODE](https://docs.xbox.com/reference/graphics/d3d12/structs/d3d12_auto_breadcrumb_node_public.md)
- [XALLOC_ALLOCATOR_IDS](https://docs.xbox.com/reference/system/xmem/enums/xalloc_allocator_ids.md)
