ID3D12GraphicsCommandList::D rawIndexedInstanced メソッド (d3d12.h)

インデックス付きインスタンス化されたプリミティブを描画します。

構文

void DrawIndexedInstanced(
  [in] UINT IndexCountPerInstance,
  [in] UINT InstanceCount,
  [in] UINT StartIndexLocation,
  [in] INT  BaseVertexLocation,
  [in] UINT StartInstanceLocation
);

パラメーター

[in] IndexCountPerInstance

型: UINT

各インスタンスのインデックス バッファーから読み取られたインデックスの数。

[in] InstanceCount

型: UINT

描画するインスタンスの数。

[in] StartIndexLocation

型: UINT

インデックス バッファーから GPU によって読み取られた最初のインデックスの場所。

[in] BaseVertexLocation

型: INT

頂点バッファーから頂点を読み取る前に、各インデックスに追加された値。

[in] StartInstanceLocation

型: UINT

頂点バッファーからインスタンスごとのデータを読み取る前に、各インデックスに追加された値。

戻り値

なし

解説

描画 API は、レンダリング パイプラインに作業を送信します。

インスタンス化では、同じジオメトリを再利用してシーン内に複数のオブジェクトを描画することで、パフォーマンスが拡張される場合があります。 インスタンス化の例の 1 つは、異なる位置と色で同じオブジェクトを描画することです。 インスタンス化には複数の頂点バッファーが必要です。頂点ごとのデータには少なくとも 1 つ、インスタンスごとのデータには 2 つ目のバッファーが必要です。

D3D12Bundles サンプルでは、ID3D12GraphicsCommandList::D rawIndexedInstanced を次のように使用します。

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
Library D3d12.lib
[DLL] D3d12.dll

こちらもご覧ください

ID3D12GraphicsCommandList