ID3D12CommandList
COM公式ドキュメント
ID3D12GraphicsCommandList の継承元となるインターフェイスです。GPU が実行するコマンドの順序付けられた集合を表し、グラフィックス用以外のコマンドリスト(コンピュートやコピーなど)へも拡張できるようになっています。
解説(Remarks)
コマンドリストオブジェクトを作成するには、ID3D12Device::CreateCommandList を使用します。
ID3D12CommandList から派生する ID3D12GraphicsCommandList も参照してください。
コマンドリストは、グラフィックス処理ユニット (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 リファレンスのサンプルコードを参照してください。
メソッド 1
vtbl = vtable インデックス(0始まり)。HSP等からCOMメソッドをインデックス指定で呼ぶ際に使用します。0〜2 は IUnknown。
コマンドリストの種類 (direct、bundle、compute、copy など) を取得します。
戻り値
このメソッドは、コマンドリストの種類を D3D12_COMMAND_LIST_TYPE 列挙定数 (direct、bundle、compute、copy など) として返します。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
HSP用 COM定義
#usecom / #comfunc によるHSPのCOM呼び出し定義。数字は vtbl インデックス(0始まり)。クラスIDが無い場合 #usecom の末尾は "{}"、ある場合は "{CLSID}"。
#define global IID_ID3D12CommandList "{7116D91C-E7E4-47CE-B8C6-EC8168F437E5}"
#usecom global ID3D12CommandList IID_ID3D12CommandList "{}"
#comfunc global ID3D12CommandList_GetType 8
; ※数字は vtbl インデックス(0始まり)。0/1/2 は IUnknown(QueryInterface/AddRef/Release)。
; ※このインターフェースは直接 CoCreateInstance するクラスIDが無いため "{}"(他メソッド/アクティベーションで取得)。