Monday, November 7, 2022
HomeGame Developmentunity - Reliably addressing compute buffer when utilizing giant numbers of threads

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


I am making an attempt to maneuver a 262,144 [2^18] factors (stars) in a compute shader and am struggling to reliably deal with the information 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 appropriately). As my complete variety of stars exceeds that quantity (and so they’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 am doing is including a continuing offset each body, the one clarification I can give you is that I am producing the ID incorrectly, wrapping round and successfully updating random stars

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

With an eye fixed to calling the next in future

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

What is the appropriate approach from inside the compute shader to get an id that varies from 0 to numDispatchedThreads - 1, the place numDispatchedThreads exceeds 65,536?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments