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

# Dispatch

> Exécute un nuanceur de calcul sur un groupe de threads.

Exécute une liste de commandes à partir d'un groupe de threads.

## Syntaxe

```cpp theme={null}
void Dispatch(
    UINT ThreadGroupCountX,
    UINT ThreadGroupCountY,
    UINT ThreadGroupCountZ
)
```

### Paramètres

*ThreadGroupCountX \[in]*\
Type : UINT

Nombre de groupes distribués dans la direction x. <i>ThreadGroupCountX</i> doit être inférieur ou égal à D3D11\_CS\_DISPATCH\_MAX\_THREAD\_GROUPS\_PER\_DIMENSION (65535).

*ThreadGroupCountY \[in]*\
Type : UINT

Nombre de groupes distribués dans la direction y. <i>ThreadGroupCountY</i> doit être inférieur ou égal à D3D11\_CS\_DISPATCH\_MAX\_THREAD\_GROUPS\_PER\_DIMENSION (65535).

*ThreadGroupCountZ \[in]*\
Type : UINT

Nombre de groupes distribués dans la direction z.  <i>ThreadGroupCountZ</i> doit être inférieur ou égal à D3D11\_CS\_DISPATCH\_MAX\_THREAD\_GROUPS\_PER\_DIMENSION (65535).
Au niveau de fonctionnalité 10, la valeur de <i>ThreadGroupCountZ</i> doit être 1.

### Valeur de retour

Type : void

Aucune.

## Remarques

Vous appelez la méthode **Dispatch** pour exécuter des commandes dans un nuanceur de calcul. Un nuanceur de calcul peut être exécuté sur de nombreux threads en parallèle, au sein d'un groupe de threads. Indexez un thread particulier, au sein d'un groupe de threads, à l'aide d'un vecteur 3D
donné par (x,y,z).

#### Exemples

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

```cpp theme={null}
// Run the particle simulation using the compute shader.
void D3D12nBodyGravity::Simulate(UINT threadIndex)
{
ID3D12GraphicsCommandList* pCommandList = m_computeCommandList[threadIndex].Get();

UINT srvIndex;
UINT uavIndex;
ID3D12Resource *pUavResource;
if (m_srvIndex[threadIndex] == 0)
{
srvIndex = SrvParticlePosVelo0;
uavIndex = UavParticlePosVelo1;
pUavResource = m_particleBuffer1[threadIndex].Get();
}
else
{
srvIndex = SrvParticlePosVelo1;
uavIndex = UavParticlePosVelo0;
pUavResource = m_particleBuffer0[threadIndex].Get();
}

pCommandList->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(pUavResource, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE, D3D12_RESOURCE_STATE_UNORDERED_ACCESS));

pCommandList->SetPipelineState(m_computeState.Get());
pCommandList->SetComputeRootSignature(m_computeRootSignature.Get());

ID3D12DescriptorHeap* ppHeaps[] = { m_srvUavHeap.Get() };
pCommandList->SetDescriptorHeaps(_countof(ppHeaps), ppHeaps);

CD3DX12_GPU_DESCRIPTOR_HANDLE srvHandle(m_srvUavHeap->GetGPUDescriptorHandleForHeapStart(), srvIndex + threadIndex, m_srvUavDescriptorSize);
CD3DX12_GPU_DESCRIPTOR_HANDLE uavHandle(m_srvUavHeap->GetGPUDescriptorHandleForHeapStart(), uavIndex + threadIndex, m_srvUavDescriptorSize);

pCommandList->SetComputeRootConstantBufferView(RootParameterCB, m_constantBufferCS->GetGPUVirtualAddress());
pCommandList->SetComputeRootDescriptorTable(RootParameterSRV, srvHandle);
pCommandList->SetComputeRootDescriptorTable(RootParameterUAV, uavHandle);

pCommandList->Dispatch(static_cast<int>(ceil(ParticleCount / 128.0f)), 1, 1);

pCommandList->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(pUavResource, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE));
}

```

Consultez l'[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-CA/reference/graphics/d3d12_xs/interfaces/ID3D12GraphicsCommandList/id3d12graphicscommandlist_xs)


## Related topics

- [XTaskQueueDispatch](/fr-CA/reference/system/xtaskqueue/functions/xtaskqueuedispatch.md)
- [IGameInputDispatcher::Dispatch](/fr-CA/reference/input/gameinput/interfaces/IGameInputDispatcher/methods/igameinputdispatcher_dispatch.md)
- [XTaskQueueDispatchMode](/fr-CA/reference/system/xtaskqueue/enums/xtaskqueuedispatchmode.md)
- [DispatchRays (consoles XBOX Series)](/fr-CA/reference/graphics/d3d12/interfaces/id3d12graphicscommandlist4/methods/id3d12graphicscommandlist4_dispatchrays_public.md)
- [D3D12_DISPATCH_ARGUMENTS](/fr-CA/reference/graphics/d3d12/structs/d3d12_dispatch_arguments_public.md)
