Share via


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

각 instance 대한 인덱스 버퍼에서 읽은 인덱스 수입니다.

[in] InstanceCount

형식: UINT

그릴 인스턴스 수입니다.

[in] StartIndexLocation

형식: UINT

인덱스 버퍼에서 GPU가 읽은 첫 번째 인덱스의 위치입니다.

[in] BaseVertexLocation

형식: INT

꼭짓점 버퍼에서 꼭짓점을 읽기 전에 각 인덱스로 추가된 값입니다.

[in] StartInstanceLocation

형식: UINT

꼭짓점 버퍼에서 instance별 데이터를 읽기 전에 각 인덱스로 추가된 값입니다.

반환 값

없음

설명

그리기 API는 렌더링 파이프라인에 작업을 제출합니다.

인스턴스화는 동일한 기하 도형을 다시 사용하여 장면에 여러 개체를 그려 성능을 확장할 수 있습니다. 인스턴스화의 한 가지 예는 동일한 개체를 다른 위치와 색으로 그리는 것입니다. 인스턴스화에는 꼭짓점당 데이터에 대해 하나 이상의 꼭짓점 버퍼와 instance별 데이터에 대한 두 번째 버퍼가 필요합니다.

예제

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
라이브러리 D3d12.lib
DLL D3d12.dll

추가 정보

ID3D12GraphicsCommandList