ID3D12PipelineState-Schnittstelle (d3d12.h)

Stellt den Zustand aller derzeit festgelegten Shader sowie bestimmter fester Funktionszustandsobjekte dar.

Vererbung

Die ID3D12PipelineState-Schnittstelle erbt von ID3D12Pageable. ID3D12PipelineState verfügt auch über folgende Membertypen:

Methoden

Die ID3D12PipelineState-Schnittstelle verfügt über diese Methoden.

 
ID3D12PipelineState::GetCachedBlob

Ruft das zwischengespeicherte Blob ab, das den Pipelinestatus darstellt.

Hinweise

Verwenden Sie ID3D12Device::CreateGraphicsPipelineState oder ID3D12Device::CreateComputePipelineState , um ein Pipelinezustandsobjekt (Pipeline State Object, PSO) zu erstellen.

Ein Pipelinezustandsobjekt entspricht einem erheblichen Teil des Zustands der Grafikverarbeitungseinheit (GRAPHICS Processing Unit, GPU). Dieser Zustand umfasst alle derzeit festgelegten Shader und bestimmte feste Funktionszustandsobjekte. Die einzige Möglichkeit zum Ändern der im Pipelineobjekt enthaltenen Zustände besteht darin, das aktuell gebundene Pipelineobjekt zu ändern.

Beispiele

Im D3D12DynamicIndexing-Beispiel wird ID3D12PipelineState wie folgt verwendet:

Deklarieren Sie die Pipelineobjekte.

// 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;

Initialisieren eines Bündels.

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

Im D3D12Bundles-Beispiel wird ID3D12PipelineState wie folgt verwendet:

Wenn Sie die Befehlslisten auffüllen, beachten Sie den abwechselnden 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);
        }
    }
}

Weitere Informationen finden Sie im Beispielcode in der D3D12-Referenz.

Anforderungen

   
Zielplattform Windows
Kopfzeile d3d12.h

Weitere Informationen

Kernschnittstellen

ID3D12Pageable