public void Execute() { int index = ThreadIds.X / 2; bool isWritingToGroupShared = ThreadIds.X % 2 == 0; if (isWritingToGroupShared) { cache[index] = index; } Hlsl.GroupMemoryBarrier(); if (!isWritingToGroupShared) { buffer[index] = cache[index]; } }