Antarmuka ID3D12CommandList (d3d12.h)
Antarmuka tempat ID3D12GraphicsCommandList mewarisi. Ini mewakili sekumpulan perintah yang diurutkan yang dijalankan GPU, sambil memungkinkan ekstensi untuk mendukung daftar perintah lain daripada hanya untuk grafik (seperti komputasi dan salinan).
Warisan
Antarmuka ID3D12CommandList mewarisi dari ID3D12DeviceChild. ID3D12CommandList juga memiliki jenis anggota berikut:
Metode
Antarmuka ID3D12CommandList memiliki metode ini.
ID3D12CommandList::GetType Mendapatkan jenis daftar perintah, seperti direct, bundel, komputasi, atau salinan. |
Keterangan
Gunakan ID3D12Device::CreateCommandList untuk membuat objek daftar perintah.
Lihat juga ID3D12GraphicsCommandList, yang berasal dari ID3D12CommandList.
Daftar perintah sesuai dengan sekumpulan perintah yang dijalankan unit pemrosesan grafis (GPU). Perintah mengatur status, menggambar, menghapus, menyalin, dan sebagainya.
Daftar perintah Direct3D 12 hanya mendukung 2 tingkat tidak langsung ini:
- Daftar perintah langsung sesuai dengan buffer perintah yang dapat dijalankan GPU.
- Bundel hanya dapat dijalankan langsung melalui daftar perintah langsung.
Contoh
Sampel D3D12nBodyGravity menggunakan ID3D12CommandList sebagai berikut:
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;
}
Lihat Contoh Kode dalam Referensi D3D12.
Persyaratan
Target Platform | Windows |
Header | d3d12.h |