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

> 스레드 그룹에서 컴퓨트 셰이더를 실행합니다.

스레드 그룹에서 명령 목록을 실행합니다.

## 구문

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

### 매개 변수

*ThreadGroupCountX \[in]*\
형식: UINT

x 방향으로 디스패치되는 그룹 수입니다. <i>ThreadGroupCountX</i>는 D3D11\_CS\_DISPATCH\_MAX\_THREAD\_GROUPS\_PER\_DIMENSION(65535) 이하여야 합니다.

*ThreadGroupCountY \[in]*\
형식: UINT

y 방향으로 디스패치되는 그룹 수입니다. <i>ThreadGroupCountY</i>는 D3D11\_CS\_DISPATCH\_MAX\_THREAD\_GROUPS\_PER\_DIMENSION(65535) 이하여야 합니다.

*ThreadGroupCountZ \[in]*\
형식: UINT

z 방향으로 디스패치되는 그룹 수입니다. <i>ThreadGroupCountZ</i>는 D3D11\_CS\_DISPATCH\_MAX\_THREAD\_GROUPS\_PER\_DIMENSION(65535) 이하여야 합니다.
기능 수준 10에서 <i>ThreadGroupCountZ</i>의 값은 1이어야 합니다.

### 반환 값

형식: void

없음.

## 설명

컴퓨트 셰이더에서 명령을 실행하려면 **Dispatch** 메서드를 호출하세요. 컴퓨트 셰이더는 스레드 그룹 내에서 여러 스레드에서 병렬로 실행될 수 있습니다. (x,y,z)로 지정된 3D 벡터를 사용하여
스레드 그룹 내의 특정 스레드를 인덱싱합니다.

#### 예제

[D3D12nBodyGravity](https://learn.microsoft.com/en-us/windows/desktop/direct3d12/working-samples) 샘플은 다음과 같이 **ID3D12GraphicsCommandList::Dispatch**를 사용합니다:

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

```

[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

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