> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# DrawIndexedInstanced

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

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

## 構文

```cpp theme={null}
void DrawIndexedInstanced(
    UINT IndexCountPerInstance,
    UINT InstanceCount,
    UINT StartIndexLocation,
    INT BaseVertexLocation,
    UINT StartInstanceLocation
)
```

### パラメーター

*IndexCountPerInstance \[in]*\
型: UINT

各インスタンスについてインデックス バッファーから読み取るインデックスの数。

*InstanceCount \[in]*\
型: UINT

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

*StartIndexLocation \[in]*\
型: UINT

GPU がインデックス バッファーから読み取る最初のインデックスの位置。

*BaseVertexLocation \[in]*\
型: INT

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

*StartInstanceLocation \[in]*\
型: UINT

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

### 戻り値

型: void

なし。

## 解説

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

インスタンス化は、同じジオメトリを再利用してシーン内の複数のオブジェクトを描画することにより、パフォーマンスを向上させる可能性があります。インスタンス化の一例として、同じオブジェクトを異なる位置と色で描画することが挙げられます。インスタンス化には複数の頂点バッファーが必要です。少なくとも 1 つは頂点単位のデータ用、もう 1 つはインスタンス単位のデータ用です。

#### 例

[D3D12Bundles](https://learn.microsoft.com/en-us/windows/desktop/direct3d12/working-samples) サンプルでは、**ID3D12GraphicsCommandList::DrawIndexedInstanced** を次のように使用しています。

```cpp theme={null}
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 リファレンスのサンプル コード](https://learn.microsoft.com/en-us/windows/desktop/direct3d12/notes-on-example-code) を参照してください。

<div class="code" />

## 要件

**ヘッダー:** d3d12\_xs.h または d3d12\_x.h\
**ライブラリ:** d3d12\_xs.lib または d3d12\_x.lib\
**サポートされるプラットフォーム**: XBOX Series 本体および XBOX One ファミリ

## 関連項目

[ID3D12GraphicsCommandList](/reference/graphics/d3d12_xs/interfaces/ID3D12GraphicsCommandList/id3d12graphicscommandlist_xs)


## Related topics

- [D3D12_DRAW_INDEXED_ARGUMENTS](/ja-jp/reference/graphics/d3d12/structs/d3d12_draw_indexed_arguments_public.md)
- [NDA トピック ディレクトリ - Microsoft Learn 公開版へのリンク](/ja-jp/nda/nda-topic-directory.md)
- [DrawInstanced](/ja-jp/reference/graphics/d3d12/interfaces/id3d12graphicscommandlist/methods/id3d12graphicscommandlist_drawinstanced_public.md)
- [D3D12_DRAW_ARGUMENTS](/ja-jp/reference/graphics/d3d12/structs/d3d12_draw_arguments_public.md)
- [XblTournamentGameResult](/ja-jp/reference/live/xsapi-c/multiplayer_c/enums/xbltournamentgameresult.md)
