InterlockedMax() public static method

Performs a guaranteed atomic max.
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 InterlockedMax ( int destination, int value ) : void
destination int The destination value.
value int The input value.
return void
コード例 #1
0
        public void Execute(ThreadIds id)
        {
            var currentMax = 0;

            for (var j = 0; j < iterations; j++)
            {
                var i = (id.X * iterations) + j;
                if (i * 3 >= coordinatesSize)
                {
                    return;
                }
                var pX = (int)Hlsl.Floor(((coordinates[i * 3] - left) / (right - left)) * width);
                var pY = (int)Hlsl.Floor(((coordinates[(i * 3) + 2] - top) / (bottom - top)) * height);
                if (pX < 0 || pX >= width || pY < 0 || pY >= height)
                {
                    continue;
                }
                var denIndex = pX + (pY * width);
                density[denIndex]++;
                if (density[denIndex] > currentMax)
                {
                    currentMax = density[denIndex];
                }
            }

            Hlsl.InterlockedMax(maxDensity[0], currentMax);
            //if (currentMax > maxDensity[0]) { maxDensity[0] = currentMax; }
        }