Hypothetically, say I wanted to use a compute shader to run Kernel_X using thread dimensions of (8, 1, 1).
I could set it up as:
In Script:
Shader.Dispatch(Kernel_X, 8, 1, 1);
In Shader:
[numthreads(1,1,1)]
void Kernel_X(uint id : SV_DispatchThreadID) { ... }
or I could set it up like this:
In Script:
Shader.Dispatch(Kernel_X, 1, 1, 1);
In Shader:
[numthreads(8,1,1)]
void Kernel_X(uint id : SV_DispatchThreadID) { ... }
I understand that at the end of this code, the dimensions would come out to be (8, 1, 1); however, I was wondering how switching up the numbers actually differed from each other. My guess would be that running Dispatch (Kernel_X, 8, 1, 1), "ran" a kernel of 1x1x1 8 times, while running numthreads(8,1,1) would run an 8x1x1 kernel once.
Dispatch(1, 1, 1)
andnumthreads(a * 32, b * 32, c * 32)
for thea, b, c
that are suitable for me? In fact, say the compute shader is simply rescaling the values of a texture2d, wouldn't it be best to setnumthreads(width, height, 1)
, wherewidth
andheight
are the width and height of the texture? I asked a separate question for this: https://mcmap.net/q/1922137/-how-to-properly-parallelize-rescaling-of-a-texture-in-a-compute-shader/547231. – Shellbark