Example #1
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();
            }
        }