计算着色器中线程的编号

ID3D11DeviceContext::Dispatch Method

Execute a command list from a thread group.

Syntax

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

Parameters

ThreadGroupCountX [in]

UINT

The number of groups dispatched in the x direction. ThreadGroupCountX must be less than 64k.

ThreadGroupCountY [in]

UINT

The number of groups dispatched in the y direction. ThreadGroupCountY must be less than 64k.

ThreadGroupCountZ [in]

UINT

The number of groups dispatched in the z direction. ThreadGroupCountZ must be less than 64k. In feature level 10 the value for ThreadGroupCountZ must be 1.

Return Value

void

Returns nothing.

Remarks

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文章来源地址https://uudwc.com/A/2YGx6

原文地址:https://blog.csdn.net/xiaoyafang123/article/details/132473984

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请联系站长进行投诉反馈,一经查实,立即删除!

上一篇 2023年08月26日 12:08
下一篇 2023年08月26日 12:09