ID3D12CommandList interface (d3d12.h)

An interface from which ID3D12GraphicsCommandList inherits. It represents an ordered set of commands that the GPU executes, while allowing for extension to support other command lists than just those for graphics (such as compute and copy).

Inheritance

The ID3D12CommandList interface inherits from ID3D12DeviceChild. ID3D12CommandList also has these types of members:

Methods

The ID3D12CommandList interface has these methods.

 
ID3D12CommandList::GetType

Gets the type of the command list, such as direct, bundle, compute, or copy.

Remarks

Use ID3D12Device::CreateCommandList to create a command list object.

See also ID3D12GraphicsCommandList, which derives from ID3D12CommandList.

A command list corresponds to a set of commands that the graphics processing unit (GPU) executes. Commands set state, draw, clear, copy, and so on.

Direct3D 12 command lists only support these 2 levels of indirection:

  • A direct command list corresponds to a command buffer that the GPU can execute.
  • A bundle can be executed only directly via a direct command list.

Examples

The D3D12nBodyGravity sample uses ID3D12CommandList as follows:

DWORD D3D12nBodyGravity::AsyncComputeThreadProc(int threadIndex)
{
    ID3D12CommandQueue* pCommandQueue = m_computeCommandQueue[threadIndex].Get();
    ID3D12CommandAllocator* pCommandAllocator = m_computeAllocator[threadIndex].Get();
    ID3D12GraphicsCommandList* pCommandList = m_computeCommandList[threadIndex].Get();
    ID3D12Fence* pFence = m_threadFences[threadIndex].Get();

    while (0 == InterlockedGetValue(&m_terminating))
    {
        // Run the particle simulation.
        Simulate(threadIndex);

        // Close and execute the command list.
        ThrowIfFailed(pCommandList->Close());
        ID3D12CommandList* ppCommandLists[] = { pCommandList };

        pCommandQueue->ExecuteCommandLists(1, ppCommandLists);

        // Wait for the compute shader to complete the simulation.
        UINT64 threadFenceValue = InterlockedIncrement(&m_threadFenceValues[threadIndex]);
        ThrowIfFailed(pCommandQueue->Signal(pFence, threadFenceValue));
        ThrowIfFailed(pFence->SetEventOnCompletion(threadFenceValue, m_threadFenceEvents[threadIndex]));
        WaitForSingleObject(m_threadFenceEvents[threadIndex], INFINITE);

        // Wait for the render thread to be done with the SRV so that
        // the next frame in the simulation can run.
        UINT64 renderContextFenceValue = InterlockedGetValue(&m_renderContextFenceValues[threadIndex]);
        if (m_renderContextFence->GetCompletedValue() < renderContextFenceValue)
        {
            ThrowIfFailed(pCommandQueue->Wait(m_renderContextFence.Get(), renderContextFenceValue));
            InterlockedExchange(&m_renderContextFenceValues[threadIndex], 0);
        }

        // Swap the indices to the SRV and UAV.
        m_srvIndex[threadIndex] = 1 - m_srvIndex[threadIndex];

        // Prepare for the next frame.
        ThrowIfFailed(pCommandAllocator->Reset());
        ThrowIfFailed(pCommandList->Reset(pCommandAllocator, m_computeState.Get()));
    }

    return 0;
}

Refer to the Example Code in the D3D12 Reference.

Requirements

Requirement Value
Target Platform Windows
Header d3d12.h

See also

Core Interfaces

ID3D12DeviceChild

ID3D12GraphicsCommandList

Setting descriptor heaps