ID3D12CommandQueue 介面 (d3d12.h)

提供提交命令清單、同步處理命令清單執行、檢測命令佇列,以及更新資源磚對應的方法。

繼承

ID3D12CommandQueue介面繼承自ID3D12PageableID3D12CommandQueue 也有下列類型的成員:

方法

ID3D12CommandQueue介面具有這些方法。

 
ID3D12CommandQueue::BeginEvent

不適合直接呼叫。  使用 PIX 事件執行時間,將事件插入命令佇列中。 (ID3D12CommandQueue.BeginEvent)
ID3D12CommandQueue::CopyTileMappings

將對應從來源保留資源複製到目的地保留資源。
ID3D12CommandQueue::EndEvent

不適合直接呼叫。  使用 PIX 事件執行時間,將事件插入命令佇列中。 (ID3D12CommandQueue.EndEvent)
ID3D12CommandQueue::ExecuteCommandLists

提交命令清單的陣列以供執行。
ID3D12CommandQueue::GetClockCalibration

此方法會同時取樣 CPU 和 GPU 時間戳記計數器。
ID3D12CommandQueue::GetDesc

取得命令佇列的描述。
ID3D12CommandQueue::GetTimestampFrequency

這個方法可用來判斷 GPU 時間戳記計數器遞增的速率。
ID3D12CommandQueue::SetMarker

不適合直接呼叫。  使用 PIX 事件執行時間,將事件插入命令佇列中。 (ID3D12CommandQueue.SetMarker)
ID3D12CommandQueue::Signal

更新指定值的柵欄。
ID3D12CommandQueue::UpdateTileMappings

更新將保留資源中的磚位置對應至資源堆積中的記憶體位置。
ID3D12CommandQueue::Wait

將 GPU 端等候排入佇列,並立即傳回。 GPU 端等候是 GPU 等候到指定柵欄達到或超過指定值的位置。

備註

使用 ID3D12Device::CreateCommandQueue 來建立命令佇列物件。

範例

D3D12nBodyGravity範例會使用ID3D12CommandQueue,如下所示:

標頭檔宣告。

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

非同步計算執行緒。

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;
}

請參閱 D3D12 參考中的範例程式碼

需求

   
目標平台 Windows
標頭 d3d12.h

另請參閱

核心介面

ID3D12Pageable