Skip to content

Latest commit

 

History

History
142 lines (105 loc) · 4.51 KB

nn-d3d12-id3d12commandqueue.md

File metadata and controls

142 lines (105 loc) · 4.51 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name
NN:d3d12.ID3D12CommandQueue
ID3D12CommandQueue (d3d12.h)
Provides methods for submitting command lists, synchronizing command list execution, instrumenting the command queue, and updating resource tile mappings.
ID3D12CommandQueue
ID3D12CommandQueue interface
ID3D12CommandQueue interface
described
d3d12/ID3D12CommandQueue
direct3d12.id3d12commandqueue
direct3d12\id3d12commandqueue.htm
direct3d12
88A4E8BA-02B9-48A1-8E46-2D2560544539
12/05/2018
ID3D12CommandQueue, ID3D12CommandQueue interface, ID3D12CommandQueue interface,described, d3d12/ID3D12CommandQueue, direct3d12.id3d12commandqueue
d3d12.h
Windows
D3D12.lib
D3D12.dll
Windows
19H1
ID3D12CommandQueue
d3d12/ID3D12CommandQueue
c++
APIRef
kbSyntax
COM
D3D12.dll
ID3D12CommandQueue

ID3D12CommandQueue interface

-description

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:

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

-see-also

Core Interfaces

ID3D12Pageable