I’m working on a compute shader that generate a tree (a new kind of bsp tree), first i build the nodes of my tree, then i need to connect nodes togethers. I use an uvec4 that contains indexs of next nodes.
At the begining, all index are equal to 0. i use atomicCompSwap fill the node link :
if node.link.x =0, i can connect another node so i do like this :
current = rootNodeIndex;
//some test to know wich link to use
result = atomicCompSwap(mynode[current].link.x,0, insertion_point);
else current = result
then if result = 0 link was created, in the other case node is linked and i need to go to the next one.
I try to add before and after…
And in C++ code i use :
my node strucutre is in SSBO in read/write access.
It doesnt work…the result is not correct… seems to be problem with atomic operations…