Hacker News new | ask | show | jobs
by Arelius 1947 days ago
> cmdList->Dispatch(dispatchSize/64, 1, 1);

> [numthreads(64, 1, 1)] > void main(uint3 threadIdx : SV_DispatchThreadID) {

the dispatch size (x, y, and z) are multiplied by the numthreads components (Some compiler SIMD stuff requires this) And that sum total threads (x * y * z) are launched. the index of the thread this particular invocation is launched on is left in threadIdx, you can then use that index to read and write from other buffers.

This is HLSL, but the same generally applies to most APIs. Then more of this just becomes implicit and behind the scenes for shaders dispatched in other contexts, since more is known implicitly about the context, and more is done by other units of the hardware.