ID3D12CommandList 介面 (d3d12.h)
ID3D12GraphicsCommandList繼承的介面。 它代表 GPU 執行的已排序命令集,同時允許擴充功能支援其他命令清單,而不只是圖形 (的命令清單,例如計算和複製) 。
繼承
ID3D12CommandList介面繼承自ID3D12DeviceChild。 ID3D12CommandList 也有下列類型的成員:
方法
ID3D12CommandList介面具有這些方法。
ID3D12CommandList::GetType 取得命令清單的類型,例如直接、配套、計算或複製。 |
備註
使用 ID3D12Device::CreateCommandList 來建立命令清單物件。
另請參閱 ID3D12GraphicsCommandList,其衍生自 ID3D12CommandList。
命令清單會對應至圖形處理單位 (GPU) 執行的一組命令。 命令會設定狀態、繪製、清除、複製等等。
Direct3D 12 命令清單僅支援這 2 個層級的間接存取:
- 直接命令清單會對應至 GPU 可執行檔命令緩衝區。
- 套件組合只能直接透過直接命令清單執行。
範例
D3D12nBodyGravity範例使用ID3D12CommandList,如下所示:
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 |