View Full Version : Compute shader and barrier

03-18-2014, 10:05 AM
Hi all!

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);
if(result==0) break;
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 :
before glDispatchCompute;

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

Any ideas?

03-21-2014, 06:55 AM
Solution :
The buffer in withch i read write have to use qualifier restrict.
Just use atomic operation without barrier need...