DirectX 12 Command List

MSDN

The ID3D12CommandList interface represents a command list. A command list is a container for commands that can be executed to draw primitives, set up shaders, and manage resources. Command lists are the primary mechanism for submitting commands to the DirectX 12 graphics API.

Overview

The command list is a fundamental object in DirectX 12. It’s designed to improve performance by batching commands and allowing for efficient submission to the graphics pipeline. Command lists can be reused, reducing overhead. You create a command list and then add commands to it. Once all commands have been added, you submit the entire command list for execution.

Key Concepts

Here are some key concepts related to command lists:

Command List Creation

Command lists are created using the ID3D12CommandList1::CreateCommandList function. This function allocates a command buffer and creates a command list associated with it.

Example Code


ID3D12CommandList* pCommandList = nullptr;
HRESULT hr = pCommandList->CreateCommandList(
    D3D12_COMMAND_LIST_TYPE_DEFAULT,
    nullptr,
    nullptr,
    &pCommandList
);

Submitting Commands

To execute the commands in a command list, you must submit it to the device using the ID3D12CommandList1::CloseCommandList function. This function performs the necessary actions to execute the commands, such as updating command slot states and updating resource states. This function must be called to signal that the command list is ready to be executed.

Example Code


HRESULT hr = pCommandList->CloseCommandList();

Related Topics

See the following topics for more information: