static public MTLRasterizationRateLayerDescriptor Create(MTLSize sampleCount, float[] horizontal, float[] vertical)
        {
            if (horizontal == null)
            {
                ObjCRuntime.ThrowHelper.ThrowArgumentNullException(nameof(horizontal));
            }
            if (vertical == null)
            {
                ObjCRuntime.ThrowHelper.ThrowArgumentNullException(nameof(vertical));
            }
            if (sampleCount.Width != horizontal.Length)
            {
                throw new ArgumentOutOfRangeException("Horizontal length should be equal to the sampleCount.Width.");
            }
            if (sampleCount.Height != vertical.Length)
            {
                throw new ArgumentOutOfRangeException("Vertical length should be equal to the sampleCount.Height.");
            }

            unsafe
            {
                fixed(void *horizontalHandle = horizontal)
                fixed(void *verticalHandle = vertical)
                {
                    return(new MTLRasterizationRateLayerDescriptor(sampleCount, (IntPtr)horizontalHandle, (IntPtr)verticalHandle));
                }
            }
        }
Example #2
0
 public MTLRegion(MTLOrigin origin, MTLSize size)
 {
     Origin = origin;
     Size   = size;
 }
Example #3
0
        public static void ConvertSparsePixelRegions(this IMTLDevice This, MTLRegion [] pixelRegions, MTLRegion [] tileRegions, MTLSize tileSize, MTLSparseTextureRegionAlignmentMode mode, nuint numRegions)
        {
            if (tileRegions == null)
            {
                ObjCRuntime.ThrowHelper.ThrowArgumentNullException(nameof(tileRegions));
            }
            if (pixelRegions == null)
            {
                ObjCRuntime.ThrowHelper.ThrowArgumentNullException(nameof(pixelRegions));
            }

            var tileRegionsHandle  = GCHandle.Alloc(tileRegions, GCHandleType.Pinned);
            var pixelRegionsHandle = GCHandle.Alloc(pixelRegions, GCHandleType.Pinned);

            try {
                IntPtr tilePtr  = tileRegionsHandle.AddrOfPinnedObject();
                IntPtr pixelPtr = pixelRegionsHandle.AddrOfPinnedObject();
                This.ConvertSparsePixelRegions(pixelPtr, tilePtr, tileSize, mode, numRegions);
            } finally {
                tileRegionsHandle.Free();
                pixelRegionsHandle.Free();
            }
        }
        public static void ConvertSparseTileRegions(this IMTLDevice This, MTLRegion [] tileRegions, MTLRegion [] pixelRegions, MTLSize tileSize, nuint numRegions)
        {
            if (tileRegions == null)
            {
                throw new ArgumentNullException(nameof(tileRegions));
            }
            if (pixelRegions == null)
            {
                throw new ArgumentNullException(nameof(pixelRegions));
            }

            var tileRegionsHandle  = GCHandle.Alloc(tileRegions, GCHandleType.Pinned);
            var pixelRegionsHandle = GCHandle.Alloc(pixelRegions, GCHandleType.Pinned);

            try {
                IntPtr tilePtr  = tileRegionsHandle.AddrOfPinnedObject();
                IntPtr pixelPtr = pixelRegionsHandle.AddrOfPinnedObject();
                This.ConvertSparseTileRegions(tilePtr, pixelPtr, tileSize, numRegions);
            } finally {
                tileRegionsHandle.Free();
                pixelRegionsHandle.Free();
            }
        }