[Unity] Compute Shader Indices

Question Kid
1 min readDec 20, 2020

--

SV_DispatchThread ID (uint3)

Indices for which combined thread and thread group a compute shader is executing in. SV_DispatchThreadID is the sum of SV_GroupID * numthreads and GroupThreadID. It varies across the range specified in Dispatch and numthreads. For example, if Dispatch(2,2,2) is called on a compute shader with numthreads(3,3,3) SV_DispatchThreadID will have a range of 0..5 for each dimension.

SV_GroupID (uint3)

Indices for which thread group a compute shader is executing in. The indices are to the whole group and not an individual thread. Possible values vary across the range passed as parameters to Dispatch. For example calling Dispatch(2,1,1) results in possible values of 0,0,0 and 1,0,0.

Defines the group offset within a Dispatch call, per dimension of the dispatch call.

SV_GroupThreadID (uint3)

Indices for which an individual thread within a thread group a compute shader is executing in. SV_GroupThreadID varies across the range specified for the compute shader in the numthreads attribute. For example, if numthreads(3,2,1) was specified possible values for the SV_GroupThreadID input value have this range of values (0–2,0–1,0).

SV_GroupIndex (uint)

The “flattened” index of a compute shader thread within a thread group, which turns the multi-dimensional SV_GroupThreadID into a 1D value. SV_GroupIndex varies from 0 to (numthreadsX * numthreadsY * numThreadsZ) - 1.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Question Kid
Question Kid

Written by Question Kid

An interactive engineer based in Tokyo. CG/Unity/Coding/Book Review

No responses yet

Write a response