ID3D12GraphicsCommandList::SetDescriptorHeaps 메서드(d3d12.h)

명령 목록과 연결된 현재 바인딩된 설명자 힙을 변경합니다.

구문

void SetDescriptorHeaps(
  UINT                 NumDescriptorHeaps,
  ID3D12DescriptorHeap * const *ppDescriptorHeaps
);

매개 변수

NumDescriptorHeaps

형식: [in] UINT

바인딩할 설명자 힙의 수입니다.

ppDescriptorHeaps

형식: [in] ID3D12DescriptorHeap*

명령 목록에 설정할 힙에 대한 ID3D12DescriptorHeap 개체의 배열에 대한 포인터입니다.

D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV 및 D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER 형식의 설명자 힙만 바인딩할 수 있습니다.

각 형식의 설명자 힙은 한 번에 하나씩만 설정할 수 있습니다. 즉, 최대 2개의 힙(샘플러 1개, CBV/SRV/UAV 1개)을 한 번에 설정할 수 있습니다.

반환 값

없음

설명

SetDescriptorHeaps는 번들에서 호출할 수 있지만 번들 설명자 힙이 호출 명령 목록 설명자 힙과 일치해야 합니다. 번들 제한에 대한 자세한 내용은 만들기 및 기록 명령 Lists 및 번들을 참조하세요.

이전에 설정한 모든 힙은 호출에 의해 설정되지 않습니다. 호출에서 각 셰이더 표시 형식의 최대 하나의 힙을 설정할 수 있습니다.

설명자 힙을 변경하면 일부 하드웨어에서 파이프라인 플러시가 발생할 수 있습니다. 따라서 바인딩된 설명자 힙을 정기적으로 변경하는 대신 각 형식의 단일 셰이더 표시 힙을 사용하고 프레임당 한 번 설정하는 것이 좋습니다. 대신 ID3D12Device::CopyDescriptorsID3D12Device::CopyDescriptorsSimple 을 사용하여 렌더링하는 동안 필요에 따라 셰이더 불투명 힙에서 단일 셰이더 표시 힙으로 필요한 설명자를 복사합니다.

예제

D3D12Bundles 샘플에서는 다음과 같이 ID3D12GraphicsCommandList::SetDescriptorHeaps를 사용합니다.

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

추가 정보

설명자 힙

ID3D12GraphicsCommandList