Reading beyond the length of a variable size array in SSBOs

Hi all,

I found a little bug in the cinder sample dealing with compute shaders (ParticleSphereCS), where a few particles don’t get touched by the compute process because there aren’t enough work groups, basically because this call:

gl::dispatchCompute( NUM_PARTICLES / WORK_GROUP_SIZE, 1, 1 );

where NUM_PARTICLES is not a multiple of WORK_GROUP_SIZE. A quick fix was to just add 1 there, causing the last work group to process a full 128 particles, although the buffer in there won’t be large enough (there’s only 64 particles in the last group dispatched). My question is, does anyone know if this is a problem, which might lead to a bad access with some graphics cards? I can’t find any relevant documentation on the subject although it seems to work. Of course ideally you’d just make your particle count a multiple of the work group size…

cheers,
Rich