public static void Shuffle4Reduce( ref ReadOnlySpan <byte> source, ref Span <byte> dest, byte control) { if (Avx2.IsSupported || Ssse3.IsSupported) { int remainder = Avx2.IsSupported ? Numerics.ModuloP2(source.Length, Vector256 <byte> .Count) : Numerics.ModuloP2(source.Length, Vector128 <byte> .Count); int adjustedCount = source.Length - remainder; if (adjustedCount > 0) { Shuffle4( source.Slice(0, adjustedCount), dest.Slice(0, adjustedCount), control); source = source.Slice(adjustedCount); dest = dest.Slice(adjustedCount); } } }
internal static void NormalizedFloatToByteSaturateReduce( ref ReadOnlySpan <float> source, ref Span <byte> dest) { DebugGuard.IsTrue(source.Length == dest.Length, nameof(source), "Input spans must be of same length!"); int remainder = Numerics.Modulo4(source.Length); int adjustedCount = source.Length - remainder; if (adjustedCount > 0) { NormalizedFloatToByteSaturate( source.Slice(0, adjustedCount), dest.Slice(0, adjustedCount)); source = source.Slice(adjustedCount); dest = dest.Slice(adjustedCount); } }
internal static void ByteToNormalizedFloatReduce( ref ReadOnlySpan <byte> source, ref Span <float> dest) { DebugGuard.IsTrue(source.Length == dest.Length, nameof(source), "Input spans must be of same length!"); if (!IsAvailable) { return; } int remainder = Numerics.ModuloP2(source.Length, Vector <byte> .Count); int adjustedCount = source.Length - remainder; if (adjustedCount > 0) { ByteToNormalizedFloat(source.Slice(0, adjustedCount), dest.Slice(0, adjustedCount)); source = source.Slice(adjustedCount); dest = dest.Slice(adjustedCount); } }
public Color(Vector4 vector) { vector = Numerics.Clamp(vector, Vector4.Zero, Vector4.One); this.boxedHighPrecisionPixel = new RgbaVector(vector.X, vector.Y, vector.Z, vector.W); this.data = default; }
internal static Vector4 PseudoRound(this Vector4 v) { Vector4 sign = Numerics.Clamp(v, new Vector4(-1), new Vector4(1)); return(v + (sign * 0.5f)); }