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

# SetDescriptorHeaps

> Modifie les tas de descripteurs actuellement liés qui sont associés à une liste de commandes.

Modifie les tas de descripteurs actuellement liés qui sont associés à une liste de commandes.

## Syntaxe

```cpp theme={null}
void SetDescriptorHeaps(
    UINT NumDescriptorHeaps,
     ID3D12DescriptorHeap* ppDescriptorHeaps
)
```

### Paramètres

*NumDescriptorHeaps*\
Type : UINT

Nombre de tas de descripteurs à lier.

*ppDescriptorHeaps*\
Type : \[in] **[ID3D12DescriptorHeap](/fr-CA/reference/graphics/d3d12/interfaces/id3d12descriptorheap/id3d12descriptorheap_public)**\*

Un pointeur vers un tableau d'objets [ID3D12DescriptorHeap](/fr-CA/reference/graphics/d3d12/interfaces/id3d12descriptorheap/id3d12descriptorheap_public) pour les tas à définir sur la liste de commandes.

Vous pouvez seulement lier des tas de descripteurs de type [**D3D12\_DESCRIPTOR\_HEAP\_TYPE\_CBV\_SRV\_UAV**](/fr-CA/reference/graphics/d3d12/interfaces/id3d12graphicscommandlist/methods/id3d12graphicscommandlist_setdescriptorheaps_public) et [**D3D12\_DESCRIPTOR\_HEAP\_TYPE\_SAMPLER**](/fr-CA/reference/graphics/d3d12/interfaces/id3d12graphicscommandlist/methods/id3d12graphicscommandlist_setdescriptorheaps_public).

Un seul tas de descripteurs de chaque type peut être défini à la fois, ce qui signifie qu'un maximum de 2 tas (un échantillonneur, un CBV/SRV/UAV) peut être défini à la fois.

### Valeur de retour

Type : void

Aucune.

## Remarques

**SetDescriptorHeaps** peut être appelée sur un bundle, mais les tas de descripteurs du bundle doivent correspondre au tas de descripteurs de la liste de commandes appelante. Pour plus d'informations sur les restrictions relatives aux bundles, consultez [Creating and Recording Command Lists and Bundles](https://learn.microsoft.com/en-us/windows/desktop/direct3d12/recording-command-lists-and-bundles).

Tous les tas définis précédemment sont annulés par l'appel. Au plus un tas de chaque type visible par les nuanceurs peut être défini dans l'appel.

La modification des tas de descripteurs peut entraîner un vidage du pipeline sur certains matériels. Pour cette raison, il est recommandé d'utiliser un seul tas visible par les nuanceurs de chaque type et de le définir une fois par image, plutôt que de modifier régulièrement les tas de descripteurs liés. Utilisez plutôt [**ID3D12Device::CopyDescriptors**](/fr-CA/reference/graphics/d3d12/interfaces/id3d12device/methods/id3d12device_copydescriptors_public) et [**ID3D12Device::CopyDescriptorsSimple**](/fr-CA/reference/graphics/d3d12/interfaces/id3d12device/methods/id3d12device_copydescriptorssimple_public) pour copier les descripteurs requis des tas opaques pour les nuanceurs vers le tas unique visible par les nuanceurs, au besoin pendant le rendu.

## Exemples

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

```cpp theme={null}
void D3D12Bundles::PopulateCommandList(FrameResource* pFrameResource)
{
// Command list allocators can only be reset when the associated
// command lists have finished execution on the GPU; apps should use
// fences to determine GPU execution progress.
ThrowIfFailed(m_pCurrentFrameResource->m_commandAllocator->Reset());

// However, when ExecuteCommandList() is called on a particular command
// list, that command list can then be reset at any time and must be before
// re-recording.
ThrowIfFailed(m_commandList->Reset(m_pCurrentFrameResource->m_commandAllocator.Get(), m_pipelineState1.Get()));

// Set necessary state.
m_commandList->SetGraphicsRootSignature(m_rootSignature.Get());

ID3D12DescriptorHeap* ppHeaps[] = { m_cbvSrvHeap.Get(), m_samplerHeap.Get() };
m_commandList->SetDescriptorHeaps(_countof(ppHeaps), ppHeaps);

m_commandList->RSSetViewports(1, &m_viewport);
m_commandList->RSSetScissorRects(1, &m_scissorRect);

// Indicate that the back buffer will be used as a render target.
m_commandList->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(m_renderTargets[m_frameIndex].Get(), D3D12_RESOURCE_STATE_PRESENT, D3D12_RESOURCE_STATE_RENDER_TARGET));

CD3DX12_CPU_DESCRIPTOR_HANDLE rtvHandle(m_rtvHeap->GetCPUDescriptorHandleForHeapStart(), m_frameIndex, m_rtvDescriptorSize);
CD3DX12_CPU_DESCRIPTOR_HANDLE dsvHandle(m_dsvHeap->GetCPUDescriptorHandleForHeapStart());
m_commandList->OMSetRenderTargets(1, &rtvHandle, FALSE, &dsvHandle);

// Record commands.
const float clearColor[] = { 0.0f, 0.2f, 0.4f, 1.0f };
m_commandList->ClearRenderTargetView(rtvHandle, clearColor, 0, nullptr);
m_commandList->ClearDepthStencilView(m_dsvHeap->GetCPUDescriptorHandleForHeapStart(), D3D12_CLEAR_FLAG_DEPTH, 1.0f, 0, 0, nullptr);

if (UseBundles)
{
// Execute the prebuilt bundle.
m_commandList->ExecuteBundle(pFrameResource->m_bundle.Get());
}
else
{
// Populate a new command list.
pFrameResource->PopulateCommandList(m_commandList.Get(), m_pipelineState1.Get(), m_pipelineState2.Get(), m_currentFrameResourceIndex, m_numIndices, &m_indexBufferView,
&m_vertexBufferView, m_cbvSrvHeap.Get(), m_cbvSrvDescriptorSize, m_samplerHeap.Get(), m_rootSignature.Get());
}

// Indicate that the back buffer will now be used to present.
m_commandList->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(m_renderTargets[m_frameIndex].Get(), D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_PRESENT));

ThrowIfFailed(m_commandList->Close());
}
```

Consultez [Example Code in the D3D12 Reference](https://learn.microsoft.com/en-us/windows/desktop/direct3d12/notes-on-example-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

[Tas de descripteurs](https://learn.microsoft.com/en-us/windows/desktop/direct3d12/descriptor-heaps)

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


## Related topics

- [ClearUnorderedAccessViewFloat](/fr-CA/reference/graphics/d3d12/interfaces/id3d12graphicscommandlist/methods/id3d12graphicscommandlist_clearunorderedaccessviewfloat_public.md)
- [ClearUnorderedAccessViewUint](/fr-CA/reference/graphics/d3d12/interfaces/id3d12graphicscommandlist/methods/id3d12graphicscommandlist_clearunorderedaccessviewuint_public.md)
- [CreateDescriptorHeap](/fr-CA/reference/graphics/d3d12/interfaces/id3d12device/methods/id3d12device_createdescriptorheap_public.md)
- [ID3D12DescriptorHeap](/fr-CA/reference/graphics/d3d12/interfaces/id3d12descriptorheap/id3d12descriptorheap_public.md)
- [D3D12_DESCRIPTOR_HEAP_TYPE](/fr-CA/reference/graphics/d3d12/enums/d3d12_descriptor_heap_type_public.md)
