is it worse to do for each invocation an atomicAdd on the same memory location than doing for each invocation an atomicAdd to a unique memory location? (I know, atomicAdd does not make sense when each invocation writes to another location... but this is theoretically)
I am asking, because I wrote the marching cubes algorithm and while creating the mesh I additionally want to calculate the center of mass as well.
I am doing this by having four integers in the SSBO (centerX, centerY, centerZ and countTriangles) each of these 4 integers will be increased by the atomicAdd function within the GeometryShader. When everything is done, I only need to divide the centerX/Y/Z variable by countTriangles and I am done.
if these atomics on one memory location would slow down my shader, I would outsource it to another maybe CPU function.
Thanks in advance