Home Game Development unity – Reliably addressing compute buffer when utilizing massive numbers of threads

unity – Reliably addressing compute buffer when utilizing massive numbers of threads

0
unity – Reliably addressing compute buffer when utilizing massive numbers of threads

[ad_1]

I’m making an attempt to maneuver a 262,144 [2^18] factors (stars) in a compute shader and am struggling to reliably tackle the info in a buffer.

I perceive that there is a three-dimensional array SV_DispatchThreadID that gives an index for the thread within the thread group.

My {hardware} can run 65,536 threads per thread group (assuming I’ve understood the terminology accurately). As my complete variety of stars exceeds that quantity (they usually’re rendered), unity have to be making a number of calls beneath the covers(?)

In any case, I’ve:

[numthreads(64, 64, 16)]
void BuildStars(uint3 id3 : SV_DispatchThreadID, uint id1 : SV_GroupIndex) {
    int id = id3.x 
            + id3.y * 64
            + id3.z * 4096;
    ...

[To simplify things, I’m only attempting to use 32,768 stars to begin with, meaning I’m ignoring id1 for the moment. I’d hoped to be able to add id += id1 * 65536, but I haven’t got that far yet]

The motion of the celebs is inconsistent. Some transfer way more quickly than others, some do not transfer in any respect.

As all I’m doing is including a continuing offset each body, the one rationalization I can provide you with is that I’m producing the ID incorrectly, wrapping round and successfully updating random stars

mapComputeShader.Dispatch(Kernel("MoveStars"), 64, 64, 8);

With a watch to calling the next in future

mapComputeShader.Dispatch(Kernel("MoveStars"), 64, 64, 64);

What’s the proper manner from throughout the compute shader to get an id that varies from 0 to numDispatchedThreads - 1, the place numDispatchedThreads exceeds 65,536?

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here