mirror of https://github.com/SixLabors/ImageSharp
5 changed files with 592 additions and 74 deletions
@ -0,0 +1,151 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
using System.Numerics; |
|||
using System.Runtime.CompilerServices; |
|||
using System.Runtime.Intrinsics; |
|||
|
|||
namespace SixLabors.ImageSharp.PixelFormats.Utils; |
|||
|
|||
internal static partial class Vector4Converters |
|||
{ |
|||
/// <summary>
|
|||
/// Defines a stateful component transform for each register width used by the shared traversal.
|
|||
/// </summary>
|
|||
private interface IStatefulVector4Operator |
|||
{ |
|||
/// <summary>
|
|||
/// Transforms one pixel represented by four components.
|
|||
/// </summary>
|
|||
/// <param name="source">The source components.</param>
|
|||
/// <returns>The transformed components.</returns>
|
|||
Vector4 Invoke(Vector4 source); |
|||
|
|||
/// <summary>
|
|||
/// Transforms one pixel represented by the four single-precision lanes in a 128-bit register.
|
|||
/// </summary>
|
|||
/// <param name="source">The source components.</param>
|
|||
/// <returns>The transformed components.</returns>
|
|||
Vector128<float> Invoke(Vector128<float> source); |
|||
|
|||
/// <summary>
|
|||
/// Transforms two pixels represented by the eight single-precision lanes in a 256-bit register.
|
|||
/// </summary>
|
|||
/// <param name="source">The source components.</param>
|
|||
/// <returns>The transformed components.</returns>
|
|||
Vector256<float> Invoke(Vector256<float> source); |
|||
|
|||
/// <summary>
|
|||
/// Transforms four pixels represented by the sixteen single-precision lanes in a 512-bit register.
|
|||
/// </summary>
|
|||
/// <param name="source">The source components.</param>
|
|||
/// <returns>The transformed components.</returns>
|
|||
Vector512<float> Invoke(Vector512<float> source); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Carries the component state for a multiply-then-add transform.
|
|||
/// </summary>
|
|||
private readonly struct MultiplyThenAddOperator : IStatefulVector4Operator |
|||
{ |
|||
private readonly Vector512<float> multiplier; |
|||
private readonly Vector512<float> offset; |
|||
|
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="MultiplyThenAddOperator"/> struct.
|
|||
/// </summary>
|
|||
/// <param name="multiplier">The component-wise multiplier.</param>
|
|||
/// <param name="offset">The component-wise offset applied after multiplication.</param>
|
|||
public MultiplyThenAddOperator(Vector4 multiplier, Vector4 offset) |
|||
{ |
|||
Vector128<float> multiplier128 = multiplier.AsVector128(); |
|||
Vector128<float> offset128 = offset.AsVector128(); |
|||
Vector256<float> multiplier256 = Vector256.Create(multiplier128, multiplier128); |
|||
Vector256<float> offset256 = Vector256.Create(offset128, offset128); |
|||
|
|||
// Expanding the invariant state once prevents the width-specific Invoke methods
|
|||
// from rebuilding identical lane groups for every vector processed by the loop.
|
|||
this.multiplier = Vector512.Create(multiplier256, multiplier256); |
|||
this.offset = Vector512.Create(offset256, offset256); |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public Vector4 Invoke(Vector4 source) |
|||
{ |
|||
Vector128<float> result = |
|||
(source.AsVector128() * this.multiplier.GetLower().GetLower()) |
|||
+ this.offset.GetLower().GetLower(); |
|||
|
|||
return result.AsVector4(); |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public Vector128<float> Invoke(Vector128<float> source) |
|||
=> (source * this.multiplier.GetLower().GetLower()) + this.offset.GetLower().GetLower(); |
|||
|
|||
/// <inheritdoc />
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public Vector256<float> Invoke(Vector256<float> source) |
|||
=> (source * this.multiplier.GetLower()) + this.offset.GetLower(); |
|||
|
|||
/// <inheritdoc />
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public Vector512<float> Invoke(Vector512<float> source) |
|||
=> (source * this.multiplier) + this.offset; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Carries the component state for an add-then-divide transform.
|
|||
/// </summary>
|
|||
private readonly struct AddThenDivideOperator : IStatefulVector4Operator |
|||
{ |
|||
private readonly Vector512<float> offset; |
|||
private readonly Vector512<float> divisor; |
|||
|
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="AddThenDivideOperator"/> struct.
|
|||
/// </summary>
|
|||
/// <param name="offset">The component-wise offset applied before division.</param>
|
|||
/// <param name="divisor">The component-wise divisor.</param>
|
|||
public AddThenDivideOperator(Vector4 offset, Vector4 divisor) |
|||
{ |
|||
Vector128<float> offset128 = offset.AsVector128(); |
|||
Vector128<float> divisor128 = divisor.AsVector128(); |
|||
Vector256<float> offset256 = Vector256.Create(offset128, offset128); |
|||
Vector256<float> divisor256 = Vector256.Create(divisor128, divisor128); |
|||
|
|||
// All register widths consume prefixes of this repeated four-pixel state,
|
|||
// so one construction serves the wide loop and every narrower remainder.
|
|||
this.offset = Vector512.Create(offset256, offset256); |
|||
this.divisor = Vector512.Create(divisor256, divisor256); |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public Vector4 Invoke(Vector4 source) |
|||
{ |
|||
Vector128<float> result = |
|||
(source.AsVector128() + this.offset.GetLower().GetLower()) |
|||
/ this.divisor.GetLower().GetLower(); |
|||
|
|||
return result.AsVector4(); |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public Vector128<float> Invoke(Vector128<float> source) |
|||
=> (source + this.offset.GetLower().GetLower()) / this.divisor.GetLower().GetLower(); |
|||
|
|||
/// <inheritdoc />
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public Vector256<float> Invoke(Vector256<float> source) |
|||
=> (source + this.offset.GetLower()) / this.divisor.GetLower(); |
|||
|
|||
/// <inheritdoc />
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|||
public Vector512<float> Invoke(Vector512<float> source) |
|||
=> (source + this.offset) / this.divisor; |
|||
} |
|||
} |
|||
@ -0,0 +1,207 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
using System.Numerics; |
|||
using System.Runtime.CompilerServices; |
|||
using System.Runtime.InteropServices; |
|||
using System.Runtime.Intrinsics; |
|||
using BenchmarkDotNet.Attributes; |
|||
using SixLabors.ImageSharp.PixelFormats.Utils; |
|||
|
|||
namespace SixLabors.ImageSharp.Benchmarks.General.PixelConversion; |
|||
|
|||
/// <summary>
|
|||
/// Compares operator-driven affine vector transforms with the duplicated traversals they replace.
|
|||
/// </summary>
|
|||
[Config(typeof(Config.Short))] |
|||
public class Vector4AffineTransform |
|||
{ |
|||
private static readonly Vector4 Multiplier = new(255F, 2F, 65535F, .5F); |
|||
private static readonly Vector4 Offset = new(17F, -1F, 32768F, 3F); |
|||
private static readonly Vector4 Divisor = new(255F, 2F, 65535F, .5F); |
|||
|
|||
private Vector4[] current; |
|||
private Vector4[] baseline; |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the number of vectors transformed by each invocation.
|
|||
/// </summary>
|
|||
[Params(1, 3, 4, 17, 256, 4096)] |
|||
public int Count { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Creates identical non-uniform buffers for the current and baseline traversals.
|
|||
/// </summary>
|
|||
[GlobalSetup] |
|||
public void Setup() |
|||
{ |
|||
this.current = new Vector4[this.Count]; |
|||
|
|||
for (int i = 0; i < this.current.Length; i++) |
|||
{ |
|||
this.current[i] = new Vector4(i + .25F, i + .5F, i + .75F, i + 1F); |
|||
} |
|||
|
|||
this.baseline = [.. this.current]; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Executes the operator-driven multiply-then-add traversal.
|
|||
/// </summary>
|
|||
[Benchmark] |
|||
public void CurrentMultiplyThenAdd() |
|||
=> Vector4Converters.MultiplyThenAdd(this.current, Multiplier, Offset); |
|||
|
|||
/// <summary>
|
|||
/// Executes the duplicated multiply-then-add traversal.
|
|||
/// </summary>
|
|||
[Benchmark(Baseline = true)] |
|||
public void BaselineMultiplyThenAdd() |
|||
=> BaselineMultiplyThenAdd(this.baseline, Multiplier, Offset); |
|||
|
|||
/// <summary>
|
|||
/// Executes the operator-driven add-then-divide traversal.
|
|||
/// </summary>
|
|||
[Benchmark] |
|||
public void CurrentAddThenDivide() |
|||
=> Vector4Converters.AddThenDivide(this.current, Offset, Divisor); |
|||
|
|||
/// <summary>
|
|||
/// Executes the duplicated add-then-divide traversal.
|
|||
/// </summary>
|
|||
[Benchmark] |
|||
public void BaselineAddThenDivide() |
|||
=> BaselineAddThenDivide(this.baseline, Offset, Divisor); |
|||
|
|||
/// <summary>
|
|||
/// Retains the multiply-then-add traversal being replaced for direct measurement.
|
|||
/// </summary>
|
|||
/// <param name="vectors">The vectors to transform.</param>
|
|||
/// <param name="multiplier">The component-wise multiplier.</param>
|
|||
/// <param name="offset">The component-wise offset.</param>
|
|||
internal static void BaselineMultiplyThenAdd(Span<Vector4> vectors, Vector4 multiplier, Vector4 offset) |
|||
{ |
|||
ref Vector4 vectorBase = ref MemoryMarshal.GetReference(vectors); |
|||
int index = 0; |
|||
|
|||
if (Vector512.IsHardwareAccelerated) |
|||
{ |
|||
int vectorsPerVector = Vector512<float>.Count / Vector128<float>.Count; |
|||
Vector256<float> multiplier256 = Vector256.Create(multiplier.AsVector128(), multiplier.AsVector128()); |
|||
Vector256<float> offset256 = Vector256.Create(offset.AsVector128(), offset.AsVector128()); |
|||
Vector512<float> multiplier512 = Vector512.Create(multiplier256, multiplier256); |
|||
Vector512<float> offset512 = Vector512.Create(offset256, offset256); |
|||
|
|||
for (; index <= vectors.Length - vectorsPerVector; index += vectorsPerVector) |
|||
{ |
|||
ref Vector512<float> vector = ref Unsafe.As<Vector4, Vector512<float>>( |
|||
ref Unsafe.Add(ref vectorBase, (uint)index)); |
|||
|
|||
vector = (vector * multiplier512) + offset512; |
|||
} |
|||
} |
|||
|
|||
if (Vector256.IsHardwareAccelerated) |
|||
{ |
|||
int vectorsPerVector = Vector256<float>.Count / Vector128<float>.Count; |
|||
Vector256<float> multiplier256 = Vector256.Create(multiplier.AsVector128(), multiplier.AsVector128()); |
|||
Vector256<float> offset256 = Vector256.Create(offset.AsVector128(), offset.AsVector128()); |
|||
|
|||
for (; index <= vectors.Length - vectorsPerVector; index += vectorsPerVector) |
|||
{ |
|||
ref Vector256<float> vector = ref Unsafe.As<Vector4, Vector256<float>>( |
|||
ref Unsafe.Add(ref vectorBase, (uint)index)); |
|||
|
|||
vector = (vector * multiplier256) + offset256; |
|||
} |
|||
} |
|||
|
|||
if (Vector128.IsHardwareAccelerated) |
|||
{ |
|||
Vector128<float> multiplier128 = multiplier.AsVector128(); |
|||
Vector128<float> offset128 = offset.AsVector128(); |
|||
|
|||
for (; index < vectors.Length; index++) |
|||
{ |
|||
ref Vector128<float> vector = ref Unsafe.As<Vector4, Vector128<float>>( |
|||
ref Unsafe.Add(ref vectorBase, (uint)index)); |
|||
|
|||
vector = (vector * multiplier128) + offset128; |
|||
} |
|||
|
|||
return; |
|||
} |
|||
|
|||
for (; index < vectors.Length; index++) |
|||
{ |
|||
ref Vector4 vector = ref Unsafe.Add(ref vectorBase, (uint)index); |
|||
vector = (vector * multiplier) + offset; |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Retains the add-then-divide traversal being replaced for direct measurement.
|
|||
/// </summary>
|
|||
/// <param name="vectors">The vectors to transform.</param>
|
|||
/// <param name="offset">The component-wise offset.</param>
|
|||
/// <param name="divisor">The component-wise divisor.</param>
|
|||
internal static void BaselineAddThenDivide(Span<Vector4> vectors, Vector4 offset, Vector4 divisor) |
|||
{ |
|||
ref Vector4 vectorBase = ref MemoryMarshal.GetReference(vectors); |
|||
int index = 0; |
|||
|
|||
if (Vector512.IsHardwareAccelerated) |
|||
{ |
|||
int vectorsPerVector = Vector512<float>.Count / Vector128<float>.Count; |
|||
Vector256<float> offset256 = Vector256.Create(offset.AsVector128(), offset.AsVector128()); |
|||
Vector256<float> divisor256 = Vector256.Create(divisor.AsVector128(), divisor.AsVector128()); |
|||
Vector512<float> offset512 = Vector512.Create(offset256, offset256); |
|||
Vector512<float> divisor512 = Vector512.Create(divisor256, divisor256); |
|||
|
|||
for (; index <= vectors.Length - vectorsPerVector; index += vectorsPerVector) |
|||
{ |
|||
ref Vector512<float> vector = ref Unsafe.As<Vector4, Vector512<float>>( |
|||
ref Unsafe.Add(ref vectorBase, (uint)index)); |
|||
|
|||
vector = (vector + offset512) / divisor512; |
|||
} |
|||
} |
|||
|
|||
if (Vector256.IsHardwareAccelerated) |
|||
{ |
|||
int vectorsPerVector = Vector256<float>.Count / Vector128<float>.Count; |
|||
Vector256<float> offset256 = Vector256.Create(offset.AsVector128(), offset.AsVector128()); |
|||
Vector256<float> divisor256 = Vector256.Create(divisor.AsVector128(), divisor.AsVector128()); |
|||
|
|||
for (; index <= vectors.Length - vectorsPerVector; index += vectorsPerVector) |
|||
{ |
|||
ref Vector256<float> vector = ref Unsafe.As<Vector4, Vector256<float>>( |
|||
ref Unsafe.Add(ref vectorBase, (uint)index)); |
|||
|
|||
vector = (vector + offset256) / divisor256; |
|||
} |
|||
} |
|||
|
|||
if (Vector128.IsHardwareAccelerated) |
|||
{ |
|||
Vector128<float> offset128 = offset.AsVector128(); |
|||
Vector128<float> divisor128 = divisor.AsVector128(); |
|||
|
|||
for (; index < vectors.Length; index++) |
|||
{ |
|||
ref Vector128<float> vector = ref Unsafe.As<Vector4, Vector128<float>>( |
|||
ref Unsafe.Add(ref vectorBase, (uint)index)); |
|||
|
|||
vector = (vector + offset128) / divisor128; |
|||
} |
|||
|
|||
return; |
|||
} |
|||
|
|||
for (; index < vectors.Length; index++) |
|||
{ |
|||
ref Vector4 vector = ref Unsafe.Add(ref vectorBase, (uint)index); |
|||
vector = (vector + offset) / divisor; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,73 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
using System.Numerics; |
|||
using BenchmarkDotNet.Attributes; |
|||
using SixLabors.ImageSharp.PixelFormats.Utils; |
|||
|
|||
namespace SixLabors.ImageSharp.Benchmarks.General.PixelConversion; |
|||
|
|||
/// <summary>
|
|||
/// Exposes every stateful affine operator and traversal remainder for assembly inspection.
|
|||
/// </summary>
|
|||
[Config(typeof(Config.Analysis))] |
|||
public class Vector4AffineTransformAssembly |
|||
{ |
|||
private static readonly Vector4 Multiplier = new(255F, 2F, 65535F, .5F); |
|||
private static readonly Vector4 Offset = new(17F, -1F, 32768F, 3F); |
|||
private static readonly Vector4 Divisor = new(255F, 2F, 65535F, .5F); |
|||
|
|||
private Vector4[] vectors; |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the number of vectors transformed by each invocation.
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// Three vectors exercise the 256- and 128-bit stages. Seventeen vectors exercise
|
|||
/// the 512-bit loop and leave one vector for the 128-bit remainder.
|
|||
/// </remarks>
|
|||
[Params(3, 17)] |
|||
public int Count { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Creates a non-uniform input buffer.
|
|||
/// </summary>
|
|||
[GlobalSetup] |
|||
public void Setup() |
|||
{ |
|||
this.vectors = new Vector4[this.Count]; |
|||
|
|||
for (int i = 0; i < this.vectors.Length; i++) |
|||
{ |
|||
this.vectors[i] = new Vector4(i + .25F, i + .5F, i + .75F, i + 1F); |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Executes the multiply-then-add stateful operator.
|
|||
/// </summary>
|
|||
[Benchmark] |
|||
public void MultiplyThenAdd() |
|||
=> Vector4Converters.MultiplyThenAdd(this.vectors, Multiplier, Offset); |
|||
|
|||
/// <summary>
|
|||
/// Executes the add-then-divide stateful operator.
|
|||
/// </summary>
|
|||
[Benchmark] |
|||
public void AddThenDivide() |
|||
=> Vector4Converters.AddThenDivide(this.vectors, Offset, Divisor); |
|||
|
|||
/// <summary>
|
|||
/// Executes the multiply-then-add traversal being replaced for assembly comparison.
|
|||
/// </summary>
|
|||
[Benchmark] |
|||
public void BaselineMultiplyThenAdd() |
|||
=> Vector4AffineTransform.BaselineMultiplyThenAdd(this.vectors, Multiplier, Offset); |
|||
|
|||
/// <summary>
|
|||
/// Executes the add-then-divide traversal being replaced for assembly comparison.
|
|||
/// </summary>
|
|||
[Benchmark] |
|||
public void BaselineAddThenDivide() |
|||
=> Vector4AffineTransform.BaselineAddThenDivide(this.vectors, Offset, Divisor); |
|||
} |
|||
@ -0,0 +1,122 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
using System.Numerics; |
|||
using SixLabors.ImageSharp.PixelFormats.Utils; |
|||
using SixLabors.ImageSharp.Tests.TestUtilities; |
|||
|
|||
namespace SixLabors.ImageSharp.Tests.PixelFormats; |
|||
|
|||
/// <summary>
|
|||
/// Verifies the shared stateful traversal used by affine pixel-vector conversions.
|
|||
/// </summary>
|
|||
[Trait("Category", "PixelFormats")] |
|||
public class Vector4ConvertersTests |
|||
{ |
|||
private static readonly int[] Lengths = [0, 1, 2, 3, 4, 5, 7, 8, 15, 16, 17, 257]; |
|||
|
|||
/// <summary>
|
|||
/// Verifies multiply-then-add behavior for every SIMD boundary and the software fallback.
|
|||
/// </summary>
|
|||
[Fact] |
|||
public void MultiplyThenAddMatchesComponentArithmeticAcrossHardwareWidths() |
|||
=> FeatureTestRunner.RunWithHwIntrinsicsFeature( |
|||
AssertMultiplyThenAddMatchesComponentArithmetic, |
|||
HwIntrinsics.AllowAll |
|||
| HwIntrinsics.DisableAVX512F |
|||
| HwIntrinsics.DisableAVX |
|||
| HwIntrinsics.DisableHWIntrinsic); |
|||
|
|||
/// <summary>
|
|||
/// Verifies add-then-divide behavior for every SIMD boundary and the software fallback.
|
|||
/// </summary>
|
|||
[Fact] |
|||
public void AddThenDivideMatchesComponentArithmeticAcrossHardwareWidths() |
|||
=> FeatureTestRunner.RunWithHwIntrinsicsFeature( |
|||
AssertAddThenDivideMatchesComponentArithmetic, |
|||
HwIntrinsics.AllowAll |
|||
| HwIntrinsics.DisableAVX512F |
|||
| HwIntrinsics.DisableAVX |
|||
| HwIntrinsics.DisableHWIntrinsic); |
|||
|
|||
/// <summary>
|
|||
/// Compares the multiply-then-add traversal with independently evaluated component expressions.
|
|||
/// </summary>
|
|||
private static void AssertMultiplyThenAddMatchesComponentArithmetic() |
|||
{ |
|||
Vector4 multiplier = new(2F, -3F, .5F, 4F); |
|||
Vector4 offset = new(-7F, 11F, 13F, -17F); |
|||
|
|||
foreach (int length in Lengths) |
|||
{ |
|||
Vector4[] actual = CreateSource(length); |
|||
Vector4[] expected = new Vector4[length]; |
|||
|
|||
for (int i = 0; i < expected.Length; i++) |
|||
{ |
|||
Vector4 value = actual[i]; |
|||
|
|||
expected[i] = new Vector4( |
|||
(value.X * multiplier.X) + offset.X, |
|||
(value.Y * multiplier.Y) + offset.Y, |
|||
(value.Z * multiplier.Z) + offset.Z, |
|||
(value.W * multiplier.W) + offset.W); |
|||
} |
|||
|
|||
Vector4Converters.MultiplyThenAdd(actual, multiplier, offset); |
|||
|
|||
Assert.Equal(expected, actual); |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Compares the add-then-divide traversal with independently evaluated component expressions.
|
|||
/// </summary>
|
|||
private static void AssertAddThenDivideMatchesComponentArithmetic() |
|||
{ |
|||
Vector4 offset = new(-7F, 11F, 13F, -17F); |
|||
Vector4 divisor = new(2F, -3F, .5F, 4F); |
|||
|
|||
foreach (int length in Lengths) |
|||
{ |
|||
Vector4[] actual = CreateSource(length); |
|||
Vector4[] expected = new Vector4[length]; |
|||
|
|||
for (int i = 0; i < expected.Length; i++) |
|||
{ |
|||
Vector4 value = actual[i]; |
|||
|
|||
expected[i] = new Vector4( |
|||
(value.X + offset.X) / divisor.X, |
|||
(value.Y + offset.Y) / divisor.Y, |
|||
(value.Z + offset.Z) / divisor.Z, |
|||
(value.W + offset.W) / divisor.W); |
|||
} |
|||
|
|||
Vector4Converters.AddThenDivide(actual, offset, divisor); |
|||
|
|||
Assert.Equal(expected, actual); |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Creates non-uniform values that expose component ordering and traversal overlap errors.
|
|||
/// </summary>
|
|||
/// <param name="length">The number of vectors to create.</param>
|
|||
/// <returns>The populated vector buffer.</returns>
|
|||
private static Vector4[] CreateSource(int length) |
|||
{ |
|||
Vector4[] result = new Vector4[length]; |
|||
|
|||
for (int i = 0; i < result.Length; i++) |
|||
{ |
|||
result[i] = new Vector4( |
|||
(i * 17F) - 31F, |
|||
(i * -23F) + 37F, |
|||
(i * .25F) - 41F, |
|||
(i * 3F) + 43F); |
|||
} |
|||
|
|||
return result; |
|||
} |
|||
} |
|||
Loading…
Reference in new issue