> ## 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

> Dessine des primitives indexées et instanciées.

Dessine des primitives indexées et instanciées.

## Syntaxe

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

### Paramètres

*IndexCountPerInstance \[in]*\
Type : UINT

Nombre d'index lus à partir du tampon d'index pour chaque instance.

*InstanceCount \[in]*\
Type : UINT

Nombre d'instances à dessiner.

*StartIndexLocation \[in]*\
Type : UINT

Emplacement du premier index lu par le GPU à partir du tampon d'index.

*BaseVertexLocation \[in]*\
Type : INT

Valeur ajoutée à chaque index avant la lecture d'un sommet à partir du tampon de sommets.

*StartInstanceLocation \[in]*\
Type : UINT

Valeur ajoutée à chaque index avant la lecture des données par instance à partir d'un tampon de sommets.

### Valeur renvoyée

Type : void

Aucune.

## Remarques

Une API de dessin soumet du travail au pipeline de rendu.

L'instanciation peut améliorer les performances en réutilisant la même géométrie pour dessiner plusieurs objets dans une scène. Un exemple d'instanciation consiste
à dessiner le même objet avec des positions et des couleurs différentes. L'instanciation nécessite plusieurs tampons de sommets : au moins un pour les données par sommet
et un second tampon pour les données par instance.

#### Exemples

L'exemple [D3D12Bundles](https://learn.microsoft.com/en-us/windows/desktop/direct3d12/working-samples) utilise **ID3D12GraphicsCommandList::DrawIndexedInstanced** comme suit :

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

```

Consultez [Exemple de code dans la référence D3D12](https://learn.microsoft.com/en-us/windows/desktop/direct3d12/notes-on-example-code).

<div class="code" />

## Configuration requise

**En-tête :** d3d12\_xs.h ou d3d12\_x.h\
**Bibliothèque :** d3d12\_xs.lib ou d3d12\_x.lib\
**Plateformes prises en charge** : consoles XBOX Series et famille XBOX One

## Voir aussi

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


## Related topics

- [D3D12_DRAW_INDEXED_ARGUMENTS](/fr/reference/graphics/d3d12/structs/d3d12_draw_indexed_arguments_public.md)
- [Répertoire des rubriques NDA : liens actifs vers Microsoft Learn](/fr/nda/nda-topic-directory.md)
- [DrawInstanced](/fr/reference/graphics/d3d12/interfaces/id3d12graphicscommandlist/methods/id3d12graphicscommandlist_drawinstanced_public.md)
- [D3D12_DRAW_ARGUMENTS](/fr/reference/graphics/d3d12/structs/d3d12_draw_arguments_public.md)
- [Obtenir les instances de tâche](/fr/services/playfab/api-references/rest/admin/scheduled-task/get-task-instances.md)
