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

# SetAllocatorCallbackX (XBOX One 系列)

> 為命令配置器設定配置回呼函式。

為命令配置器設定配置回呼函式。

## 語法

```cpp theme={null}
void SetAllocatorCallbackX(  
         D3D12XBOX_COMMAND_ALLOCATOR_CALLBACK pCallback,  
         UINT64 Context  
)  
```

### 參數

*pCallback*   \_In\_\
類型：D3D12XBOX\_COMMAND\_ALLOCATOR\_CALLBACK

指向 **D3D12XBOX\_COMMAND\_ALLOCATOR\_CALLBACK** 定義的指標。請注意，D3D12XBOX\_COMMAND\_ALLOCATOR\_CALLBACK 的定義如下：

```cpp theme={null}
typedef void* (*D3D12XBOX_COMMAND_ALLOCATOR_CALLBACK)(
        ID3D12CommandAllocator* pCommandAllocator,
        ID3D12CommandList* pCommandList,
        UINT XMemAllocType,
        SIZE_T SizeInBytes,
        UINT AlignmentInBytes,
        UINT Flags,
        UINT64 Context); 
```

*Context*   \_In\_\
類型：UINT64

傳遞給回呼的使用者定義值。

### 傳回值

類型：void

## 備註

您可以為命令配置器建立使用者定義的回呼函式，以處理配置器執行的所有記憶體配置。設定回呼後，回呼必須負責依照指定的大小、對齊方式和 [XALLOC\_ATTRIBUTES](https://learn.microsoft.com/en-us/gaming/gdk/_content/gc/reference/system/xmem/structs/xalloc_attributes) 記憶體類型來滿足記憶體配置要求，並將配置傳回給執行階段。回呼必須追蹤這些配置，並在不再使用時明確解除配置。

如需命令清單和命令配置器的詳細資訊，請參閱[建立及記錄命令清單和套件組合](https://learn.microsoft.com/en-us/windows/win32/direct3d12/recording-command-lists-and-bundles#creating-command-lists)。

<Note>
  在命令配置器上呼叫 [Reset](https://learn.microsoft.com/en-us/windows/desktop/api/d3d12/nf-d3d12-id3d12commandallocator-reset) 之前，您不得解除配置記憶體。
</Note>

## 需求

**標頭:** d3d12\_x.h

**程式庫:** d3d12\_x.lib

**支援的平台:** XBOX One 系列

## 另請參閱

[ID3D12CommandAllocator](/zh-TW/reference/graphics/d3d12_x/interfaces/ID3D12CommandAllocator/id3d12commandallocator)\
[CreateCommandAllocator](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-id3d12device-createcommandallocator)


## Related topics

- [XALLOC_ALLOCATOR_IDS](/zh-CN/reference/system/xmem/enums/xalloc_allocator_ids.md)
- [CreateCommandAllocator](/zh-CN/reference/graphics/d3d12/interfaces/id3d12device/methods/id3d12device_createcommandallocator_public.md)
- [ID3D12CommandAllocator::Reset](/zh-CN/reference/graphics/d3d12/interfaces/id3d12commandallocator/methods/id3d12commandallocator_reset_public.md)
- [XErrorSetCallback](/zh-CN/reference/system/xerror/functions/xerrorsetcallback.md)
- [chat_manager::set_memory_callbacks](/zh-CN/reference/chat/gamechat2/classes/chat_manager/methods/chat_manager_set_memory_callbacks.md)
