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

# CreateCommandAllocator

> コマンド アロケーター オブジェクトを作成します。

コマンド アロケーター オブジェクトを作成します。

## 構文

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

### パラメーター

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

作成するコマンド アロケーターのタイプを指定する [D3D12\_COMMAND\_LIST\_TYPE](/reference/graphics/d3d12_x/enums/d3d12_command_list_type) 型の値。
コマンド アロケーターのタイプには、ダイレクト コマンド リストを記録するタイプ、またはバンドルを記録するタイプがあります。

*riid*\
型: const IID &

コマンド アロケーター インターフェイス ([ID3D12CommandAllocator](/reference/graphics/d3d12_x/interfaces/ID3D12CommandAllocator/id3d12commandallocator)) のグローバル一意識別子 (**GUID**)。
コマンド アロケーターのインターフェイスの **REFIID** または **GUID** は、\_\_uuidof() マクロを使用して取得できます。
たとえば、\_\_uuidof(ID3D12CommandAllocator) は、コマンド アロケーターのインターフェイスの **GUID** を取得します。

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

コマンド アロケーターの [ID3D12CommandAllocator](/reference/graphics/d3d12_x/interfaces/ID3D12CommandAllocator/id3d12commandallocator) インターフェイスへのポインターを受け取るメモリ ブロックへのポインター。

### 戻り値

型: HRESULT

コマンド アロケーターを作成するのに十分なメモリがない場合、このメソッドは **E\_OUTOFMEMORY** を返します。
その他の戻り値については、[Direct3D 12 の戻りコード](https://learn.microsoft.com/en-us/windows/desktop/direct3d12/d3d12-graphics-reference-returnvalues) を参照してください。

## 解説

デバイスはコマンド アロケーターからコマンド リストを作成します。

#### 例

[D3D12Bundles](https://learn.microsoft.com/en-us/windows/desktop/direct3d12/working-samples) サンプルでは、**ID3D12Device::CreateCommandAllocator** を次のように使用しています。

```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)));

```

[D3D12 リファレンスのサンプル コード](https://learn.microsoft.com/en-us/windows/desktop/direct3d12/notes-on-example-code) を参照してください。

<div class="code" />

## 要件

**ヘッダー:** d3d12\_xs.h または d3d12\_x.h\
**ライブラリ:** d3d12\_xs.lib または d3d12\_x.lib\
**サポートされているプラットフォーム**: XBOX Series 本体および XBOX One ファミリ

## 関連項目

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


## Related topics

- [ID3D12CommandAllocator::Reset](/ja-jp/reference/graphics/d3d12/interfaces/id3d12commandallocator/methods/id3d12commandallocator_reset_public.md)
- [CreateCommandList](/ja-jp/reference/graphics/d3d12/interfaces/id3d12device/methods/id3d12device_createcommandlist_public.md)
- [XALLOC_ALLOCATOR_IDS](/ja-jp/reference/system/xmem/enums/xalloc_allocator_ids.md)
- [CreateCommandQueue](/ja-jp/reference/graphics/d3d12/interfaces/id3d12device/methods/id3d12device_createcommandqueue_public.md)
- [CreateCommandSignature](/ja-jp/reference/graphics/d3d12/interfaces/id3d12device/methods/id3d12device_createcommandsignature_public.md)
