ID3D11DeviceContext::Dispatch method (d3d11.h)

Execute a command list from a thread group.

Syntax

void Dispatch(
  [in] UINT ThreadGroupCountX,
  [in] UINT ThreadGroupCountY,
  [in] UINT ThreadGroupCountZ
);

Parameters

[in] ThreadGroupCountX

Type: UINT

The number of groups dispatched in the x direction. ThreadGroupCountX must be less than or equal to D3D11_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION (65535).

[in] ThreadGroupCountY

Type: UINT

The number of groups dispatched in the y direction. ThreadGroupCountY must be less than or equal to D3D11_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION (65535).

[in] ThreadGroupCountZ

Type: UINT

The number of groups dispatched in the z direction. ThreadGroupCountZ must be less than or equal to D3D11_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION (65535). In feature level 10 the value for ThreadGroupCountZ must be 1.

Return value

None

Remarks

You call the Dispatch method to execute commands in a compute shader. A compute shader can be run on many threads in parallel, within a thread group. Index a particular thread, within a thread group using a 3D vector given by (x,y,z).

In the following illustration, assume a thread group with 50 threads where the size of the group is given by (5,5,2). A single thread is identified from a thread group with 50 threads in it, using the vector (4,1,1).

Illustration of a single thread within a thread group of 50 threads

The following illustration shows the relationship between the parameters passed to ID3D11DeviceContext::Dispatch, Dispatch(5,3,2), the values specified in the numthreads attribute, numthreads(10,8,3), and values that will passed to the compute shader for the thread-related system values (SV_GroupIndex,SV_DispatchThreadID,SV_GroupThreadID,SV_GroupID).

Illustration of the relationship between Dispatch, thread groups, and threads

Requirements

Requirement Value
Target Platform Windows
Header d3d11.h
Library D3D11.lib

See also

ID3D11DeviceContext