Hacker News new | ask | show | jobs
by Arelius 1951 days ago
I mean they are a bit. They are programs that fit pretty arbitrarily into other parts of the rendering pipeline. I recommend starting with Compute Shaders as those end up being just a big parallel map on your dispatch size. A lot less pipeline to understand.

The other key thing to understand, is that a GPU is across a network (PCI-X network generally) So when you call dispatch, your generally sending a message (encoding a command in a command buffer) to do the work later on on a different device.

1 comments

> 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.