GroupMemoryBarrier() public static method

Blocks execution of all threads in a group until all group shared accesses have been completed.
This method is an intrinsic and can only be used within a shader on the GPU. Using it on the CPU is undefined behavior.
public static GroupMemoryBarrier ( ) : void
return void
Exemplo n.º 1
0
        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];
            }
        }