Share via


ID3D12PipelineState 인터페이스(d3d12.h)

현재 설정된 모든 셰이더와 특정 고정 함수 상태 개체의 상태를 나타냅니다.

상속

ID3D12PipelineState 인터페이스는 ID3D12Pageable에서 상속됩니다. ID3D12PipelineState 에는 다음과 같은 유형의 멤버도 있습니다.

메서드

ID3D12PipelineState 인터페이스에는 이러한 메서드가 있습니다.

 
ID3D12PipelineState::GetCachedBlob

파이프라인 상태를 나타내는 캐시된 Blob을 가져옵니다.

설명

ID3D12Device::CreateGraphicsPipelineState 또는 ID3D12Device::CreateComputePipelineState를 사용하여 PSO(파이프라인 상태 개체)를 만듭니다.

파이프라인 상태 개체는 GPU(그래픽 처리 장치) 상태의 상당 부분에 해당합니다. 이 상태에는 현재 설정된 모든 셰이더와 특정 고정 함수 상태 개체가 포함됩니다. 파이프라인 개체에 포함된 상태를 변경하는 유일한 방법은 현재 바인딩된 파이프라인 개체를 변경하는 것입니다.

예제

D3D12DynamicIndexing 샘플은 다음과 같이 ID3D12PipelineState를 사용합니다.

파이프라인 개체를 선언합니다.

// Asset objects.
ComPtr<ID3D12PipelineState> m_pipelineState;
ComPtr<ID3D12PipelineState> m_computeState;
ComPtr<ID3D12GraphicsCommandList> m_commandList;
ComPtr<ID3D12Resource> m_vertexBuffer;
ComPtr<ID3D12Resource> m_vertexBufferUpload;
D3D12_VERTEX_BUFFER_VIEW m_vertexBufferView;
ComPtr<ID3D12Resource> m_particleBuffer0[ThreadCount];
ComPtr<ID3D12Resource> m_particleBuffer1[ThreadCount];
ComPtr<ID3D12Resource> m_particleBuffer0Upload[ThreadCount];
ComPtr<ID3D12Resource> m_particleBuffer1Upload[ThreadCount];
ComPtr<ID3D12Resource> m_constantBufferGS;
UINT8* m_pConstantBufferGSData;
ComPtr<ID3D12Resource> m_constantBufferCS;

번들을 초기화합니다.

void FrameResource::InitBundle(ID3D12Device* pDevice, ID3D12PipelineState* pPso,
    UINT frameResourceIndex, UINT numIndices, D3D12_INDEX_BUFFER_VIEW* pIndexBufferViewDesc, D3D12_VERTEX_BUFFER_VIEW* pVertexBufferViewDesc,
    ID3D12DescriptorHeap* pCbvSrvDescriptorHeap, UINT cbvSrvDescriptorSize, ID3D12DescriptorHeap* pSamplerDescriptorHeap, ID3D12RootSignature* pRootSignature)
{
    ThrowIfFailed(pDevice->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_BUNDLE, m_bundleAllocator.Get(), pPso, IID_PPV_ARGS(&m_bundle)));

    PopulateCommandList(m_bundle.Get(), pPso, frameResourceIndex, numIndices, pIndexBufferViewDesc,
        pVertexBufferViewDesc, pCbvSrvDescriptorHeap, cbvSrvDescriptorSize, pSamplerDescriptorHeap, pRootSignature);

    ThrowIfFailed(m_bundle->Close());
}

D3D12Bundles 샘플은 다음과 같이 ID3D12PipelineState를 사용합니다.

명령 목록을 채우면 PSO가 번갈아 표시됩니다.

void FrameResource::PopulateCommandList(ID3D12GraphicsCommandList* pCommandList, ID3D12PipelineState* pPso1, ID3D12PipelineState* pPso2,
    UINT frameResourceIndex, UINT numIndices, D3D12_INDEX_BUFFER_VIEW* pIndexBufferViewDesc, D3D12_VERTEX_BUFFER_VIEW* pVertexBufferViewDesc,
    ID3D12DescriptorHeap* pCbvSrvDescriptorHeap, UINT cbvSrvDescriptorSize, ID3D12DescriptorHeap* pSamplerDescriptorHeap, ID3D12RootSignature* pRootSignature)
{
    // If the root signature matches the root signature of the caller, then
    // bindings are inherited, otherwise the bind space is reset.
    pCommandList->SetGraphicsRootSignature(pRootSignature);

    ID3D12DescriptorHeap* ppHeaps[] = { pCbvSrvDescriptorHeap, pSamplerDescriptorHeap };
    pCommandList->SetDescriptorHeaps(_countof(ppHeaps), ppHeaps);
    pCommandList->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);

    pCommandList->IASetIndexBuffer(pIndexBufferViewDesc);

    pCommandList->IASetVertexBuffers(0, 1, pVertexBufferViewDesc);

    pCommandList->SetGraphicsRootDescriptorTable(0, pCbvSrvDescriptorHeap->GetGPUDescriptorHandleForHeapStart());
    pCommandList->SetGraphicsRootDescriptorTable(1, pSamplerDescriptorHeap->GetGPUDescriptorHandleForHeapStart());

    // Calculate the descriptor offset due to multiple frame resources.
    // 1 SRV + how many CBVs we have currently.
    UINT frameResourceDescriptorOffset = 1 + (frameResourceIndex * m_cityRowCount * m_cityColumnCount);
    CD3DX12_GPU_DESCRIPTOR_HANDLE cbvSrvHandle(pCbvSrvDescriptorHeap->GetGPUDescriptorHandleForHeapStart(), frameResourceDescriptorOffset, cbvSrvDescriptorSize);

    BOOL usePso1 = TRUE;
    for (UINT i = 0; i < m_cityRowCount; i++)
    {
        for (UINT j = 0; j < m_cityColumnCount; j++)
        {
            // Alternate which PSO to use; the pixel shader is different on 
            // each just as a PSO setting demonstration.
            pCommandList->SetPipelineState(usePso1 ? pPso1 : pPso2);
            usePso1 = !usePso1;

            // Set this city's CBV table and move to the next descriptor.
            pCommandList->SetGraphicsRootDescriptorTable(2, cbvSrvHandle);
            cbvSrvHandle.Offset(cbvSrvDescriptorSize);

            pCommandList->DrawIndexedInstanced(numIndices, 1, 0, 0, 0);
        }
    }
}

D3D12 참조의 예제 코드를 참조하세요.

요구 사항

   
대상 플랫폼 Windows
헤더 d3d12.h

참고 항목

Core 인터페이스

ID3D12Pageable