Direct3D 12 - CreateCommandAllocator

Purpose

The CreateCommandAllocator function allocates a command allocator object. A command allocator is an object that manages command buffers, which are used to execute graphics and compute operations. The command allocator is used to manage the command buffer resources.

Syntax

D3D12_COMMAND_ALLOCATOR_HANDLE CreateCommandAllocator(
    D3D12_DEVICE_HDEVICE,
    D3D12_COMMAND_ALLOCATOR_TYPE type,
    const D3D12_COMMAND_ALLOCATOR_DESC* desc
)

Parameters

Return Value

The function returns a handle to the created command allocator. If the operation fails, the function returns 0.

Example

Creating a Graphics Command Allocator

                D3D12_COMMAND_ALLOCATOR_DESC desc;
                ZeroMemory(&desc, sizeof(D3D12_COMMAND_ALLOCATOR_DESC));
                desc.Usage = D3D12_COMMAND_ALLOCATOR_USAGE_DEFAULT;
                desc.Type = D3D12_COMMAND_ALLOCATOR_TYPE_GRAPHICS;

                D3D12_COMMAND_ALLOCATOR_HANDLE graphicsAllocator = CreateCommandAllocator(device, D3D12_COMMAND_ALLOCATOR_TYPE_GRAPHICS, &desc);

                if (graphicsAllocator == 0) {
                    // Handle error
                }