Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jkotas committed May 19, 2021
1 parent 2aea56a commit ccc58e5
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,28 @@ public static Vector128<ulong> AsUInt64<T>(this Vector128<T> vector)
/// <returns><paramref name="value" /> reinterpreted as a new <see cref="Vector128{Single}" />.</returns>
public static Vector128<float> AsVector128(this Vector2 value)
{
return new Vector4(value, 0.0f, 0.0f).AsVector128();
// return new Vector4(value, 0.0f, 0.0f).AsVector128();

// Workaround https://github.com/dotnet/runtime/issues/52959
Vector4 value4 = default;
value4.X = value.X;
value4.Y = value.Y;
return Unsafe.As<Vector4, Vector128<float>>(ref value4);
}

/// <summary>Reinterprets a <see cref="Vector3" /> as a new <see cref="Vector128{Single}" />.</summary>
/// <param name="value">The vector to reinterpret.</param>
/// <returns><paramref name="value" /> reinterpreted as a new <see cref="Vector128{Single}" />.</returns>
public static Vector128<float> AsVector128(this Vector3 value)
{
return new Vector4(value, 0.0f).AsVector128();
// return new Vector4(value, 0.0f).AsVector128();

// Workaround https://github.com/dotnet/runtime/issues/52959
Vector4 value4 = default;
value4.X = value.X;
value4.Y = value.Y;
value4.Z = value.Z;
return Unsafe.As<Vector4, Vector128<float>>(ref value4);
}

/// <summary>Reinterprets a <see cref="Vector4" /> as a new <see cref="Vector128{Single}" />.</summary>
Expand Down

0 comments on commit ccc58e5

Please sign in to comment.