ID3D12GraphicsCommandList::ExecuteBundle 方法 (d3d12.h)
執行套件組合。
語法
void ExecuteBundle(
[in] ID3D12GraphicsCommandList *pCommandList
);
參數
[in] pCommandList
類型: ID3D12GraphicsCommandList*
指定要執行的套件組合的 ID3D12GraphicsCommandList 。
傳回值
無
備註
套件組合會從 呼叫 ExecuteBundle 的父命令清單中繼承所有狀態,但管線狀態物件和基本拓撲除外。 套件組合中設定的所有狀態都會影響父命令清單的狀態。 請注意, ExecuteBundle 不是述詞作業。
運行時間驗證
運行時間會驗證「被呼叫者」是否為套件組合,且「呼叫端」是直接命令清單。 運行時間也會驗證套件組合是否已關閉。 如果違反合約,運行時間會以無訊息方式卸除呼叫。 驗證失敗會導致 關閉 傳回E_INVALIDARG。偵錯層
偵錯層會在運行時間失敗的相同情況下發出警告。 如果在呼叫 ExecuteCommandList 時設定述詞,偵錯層將會發出警告。 此外,如果偵錯層偵測到命令清單的任何資源參考已終結,就會發出錯誤。偵錯層也會驗證與套件組合相關聯的命令配置器尚未重設,因為已在命令清單上呼叫 Close 。 此驗證會在 ExecuteBundle 時間發生,並在命令佇列上執行父命令清單時發生。
範例
D3D12Bundles 範例使用 ID3D12GraphicsCommandList::ExecuteBundle,如下所示:
void D3D12Bundles::PopulateCommandList(FrameResource* pFrameResource)
{
// Command list allocators can only be reset when the associated
// command lists have finished execution on the GPU; apps should use
// fences to determine GPU execution progress.
ThrowIfFailed(m_pCurrentFrameResource->m_commandAllocator->Reset());
// However, when ExecuteCommandList() is called on a particular command
// list, that command list can then be reset at any time and must be before
// re-recording.
ThrowIfFailed(m_commandList->Reset(m_pCurrentFrameResource->m_commandAllocator.Get(), m_pipelineState1.Get()));
// Set necessary state.
m_commandList->SetGraphicsRootSignature(m_rootSignature.Get());
ID3D12DescriptorHeap* ppHeaps[] = { m_cbvSrvHeap.Get(), m_samplerHeap.Get() };
m_commandList->SetDescriptorHeaps(_countof(ppHeaps), ppHeaps);
m_commandList->RSSetViewports(1, &m_viewport);
m_commandList->RSSetScissorRects(1, &m_scissorRect);
// Indicate that the back buffer will be used as a render target.
m_commandList->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(m_renderTargets[m_frameIndex].Get(), D3D12_RESOURCE_STATE_PRESENT, D3D12_RESOURCE_STATE_RENDER_TARGET));
CD3DX12_CPU_DESCRIPTOR_HANDLE rtvHandle(m_rtvHeap->GetCPUDescriptorHandleForHeapStart(), m_frameIndex, m_rtvDescriptorSize);
CD3DX12_CPU_DESCRIPTOR_HANDLE dsvHandle(m_dsvHeap->GetCPUDescriptorHandleForHeapStart());
m_commandList->OMSetRenderTargets(1, &rtvHandle, FALSE, &dsvHandle);
// Record commands.
const float clearColor[] = { 0.0f, 0.2f, 0.4f, 1.0f };
m_commandList->ClearRenderTargetView(rtvHandle, clearColor, 0, nullptr);
m_commandList->ClearDepthStencilView(m_dsvHeap->GetCPUDescriptorHandleForHeapStart(), D3D12_CLEAR_FLAG_DEPTH, 1.0f, 0, 0, nullptr);
if (UseBundles)
{
// Execute the prebuilt bundle.
m_commandList->ExecuteBundle(pFrameResource->m_bundle.Get());
}
else
{
// Populate a new command list.
pFrameResource->PopulateCommandList(m_commandList.Get(), m_pipelineState1.Get(), m_pipelineState2.Get(), m_currentFrameResourceIndex, m_numIndices, &m_indexBufferView,
&m_vertexBufferView, m_cbvSrvHeap.Get(), m_cbvSrvDescriptorSize, m_samplerHeap.Get(), m_rootSignature.Get());
}
// Indicate that the back buffer will now be used to present.
m_commandList->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(m_renderTargets[m_frameIndex].Get(), D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_PRESENT));
ThrowIfFailed(m_commandList->Close());
}
請參閱 D3D12 參考中的範例程式代碼。
規格需求
需求 | 值 |
---|---|
目標平台 | Windows |
標頭 | d3d12.h |
程式庫 | D3d12.lib |
Dll | D3d12.dll |