Export (0) Print
Expand All

numthreads

Defines the number of threads to be executed in a single thread group when a compute shader is dispatched (see ID3D11DeviceContext::Dispatch).



numthreads(X, Y, Z)	   


The X, Y and Z values indicate the size of the thread group in a particular direction and the total of X*Y*Z gives the number of threads in the group. The ability to specify the size of the thread group across three dimensions allows individual threads to be accessed in a manner that logically 2D and 3D data structures.

For example, if a compute shader is doing 4x4 matrix addition then numthreads could be set to numthreads(4,4,1) and the indexing in the individual threads would automatically match the matrix entries. The compute shader could also declare a thread group with the same number of threads (16) using numthreads(16,1,1), however it would then have to calculate the current matrix entry based on the current thread number.

The allowable parameter values for numthreads depends on the compute shader version.

Compute ShaderMaximum ZMaximum Threads (X*Y*Z)
cs_4_x1768
cs_5_0641024

 

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

This attribute is supported in the following types of shaders:

VertexHullDomainGeometryPixelCompute
x

 

Related topics

Shader Model 5

 

 

Community Additions

ADD
Show:
© 2015 Microsoft