ID3D12GraphicsCommandList::ExecuteBundle メソッド (d3d12.h)

バンドルを実行します。

構文

void ExecuteBundle(
  [in] ID3D12GraphicsCommandList *pCommandList
);

パラメーター

[in] pCommandList

種類: ID3D12GraphicsCommandList*

実行するバンドルを決定する ID3D12GraphicsCommandList を指定します。

戻り値

なし

解説

バンドルは、パイプライン状態オブジェクトとプリミティブ トポロジを除き、 ExecuteBundle が呼び出される親コマンド リストからすべての状態を継承します。 バンドルに設定されているすべての状態は、親コマンド リストの状態に影響します。 ExecuteBundle は述語演算ではないことに注意してください。

ランタイム検証

ランタイムは、"呼び出し先" がバンドルであり、"呼び出し元" が直接コマンド リストであることを検証します。 ランタイムは、バンドルが閉じられたことも検証します。 コントラクトに違反した場合、ランタイムはサイレントモードで呼び出しを削除します。 検証エラーが発生すると、 Close は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
Library D3d12.lib
[DLL] D3d12.dll

こちらもご覧ください

ID3D12GraphicsCommandList