Share via


Metodo ID3D12GraphicsCommandList::ExecuteBundle (d3d12.h)

Esegue un bundle.

Sintassi

void ExecuteBundle(
  [in] ID3D12GraphicsCommandList *pCommandList
);

Parametri

[in] pCommandList

Tipo: ID3D12GraphicsCommandList*

Specifica l'ID3D12GraphicsCommandList che determina l'aggregazione da eseguire.

Valore restituito

nessuno

Osservazioni

I bundle ereditano tutto lo stato dall'elenco di comandi padre in cui viene chiamato ExecuteBundle , ad eccezione dell'oggetto stato della pipeline e della topologia primitiva. Tutto lo stato impostato in un bundle influirà sullo stato dell'elenco di comandi padre. Si noti che ExecuteBundle non è un'operazione predicata.

Convalida del runtime

Il runtime convaliderà che il "chiamato" sia un bundle e che il "chiamante" sia un elenco di comandi diretto. Il runtime convaliderà anche che il bundle sia stato chiuso. Se il contratto viene violato, il runtime elimina automaticamente la chiamata. L'errore di convalida comporterà la restituzione di E_INVALIDARG chiusura .

Livello di debug

Il livello di debug genererà un avviso negli stessi casi in cui il runtime avrà esito negativo. Il livello di debug genera un avviso se viene impostato un predicato quando viene chiamato ExecuteCommandList . Inoltre, il livello di debug genererà un errore se rileva che qualsiasi riferimento di risorsa dall'elenco di comandi è stato eliminato definitivamente.

Il livello di debug convaliderà anche che l'allocatore di comando associato al bundle non sia stato reimpostato dopo la chiamata di Close nell'elenco di comandi. Questa convalida viene eseguita in fase executeBundle e quando l'elenco di comandi padre viene eseguito in una coda di comandi.

Esempio

L'esempio D3D12Bundles usa ID3D12GraphicsCommandList::ExecuteBundle come indicato di seguito:

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

Vedere Codice di esempio nel riferimento D3D12.

Requisiti

Requisito Valore
Piattaforma di destinazione Windows
Intestazione d3d12.h
Libreria D3d12.lib
DLL D3d12.dll

Vedi anche

ID3D12GraphicsCommandList