ID3D12CommandQueue interface (d3d12.h)

Provides methods for submitting command lists, synchronizing command list execution, instrumenting the command queue, and updating resource tile mappings.

Inheritance

The ID3D12CommandQueue interface inherits from ID3D12Pageable. ID3D12CommandQueue also has these types of members:

Methods

The ID3D12CommandQueue interface has these methods.

 
ID3D12CommandQueue::BeginEvent

Not intended to be called directly.  Use the PIX event runtime to insert events into a command queue. (ID3D12CommandQueue.BeginEvent)
ID3D12CommandQueue::CopyTileMappings

Copies mappings from a source reserved resource to a destination reserved resource.
ID3D12CommandQueue::EndEvent

Not intended to be called directly.  Use the PIX event runtime to insert events into a command queue. (ID3D12CommandQueue.EndEvent)
ID3D12CommandQueue::ExecuteCommandLists

Submits an array of command lists for execution.
ID3D12CommandQueue::GetClockCalibration

This method samples the CPU and GPU timestamp counters at the same moment in time.
ID3D12CommandQueue::GetDesc

Gets the description of the command queue.
ID3D12CommandQueue::GetTimestampFrequency

This method is used to determine the rate at which the GPU timestamp counter increments.
ID3D12CommandQueue::SetMarker

Not intended to be called directly.  Use the PIX event runtime to insert events into a command queue. (ID3D12CommandQueue.SetMarker)
ID3D12CommandQueue::Signal

Updates a fence to a specified value.
ID3D12CommandQueue::UpdateTileMappings

Updates mappings of tile locations in reserved resources to memory locations in a resource heap.
ID3D12CommandQueue::Wait

Queues a GPU-side wait, and returns immediately. A GPU-side wait is where the GPU waits until the specified fence reaches or exceeds the specified value.

Remarks

Use ID3D12Device::CreateCommandQueue to create a command queue object.

Examples

The D3D12nBodyGravity sample uses ID3D12CommandQueue as follows:

Header file declarations.

// Compute objects.
ComPtr<ID3D12CommandAllocator> m_computeAllocator[ThreadCount];
ComPtr<ID3D12CommandQueue> m_computeCommandQueue[ThreadCount];
ComPtr<ID3D12GraphicsCommandList> m_computeCommandList[ThreadCount];

Asynchronous compute thread.

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

ID3D12Pageable