Merge pull request #712 from Sergio0694/dev/remove-vector-projections
Remove .NET vector types projections, add Matrix3x2/Matrix4x4 implicit conversions
このコミットが含まれているのは:
8ファイル変更
+97
-4
検索条件に一致するファイルはありません
差分なしでファイル名を変更。
差分なしでファイル名を変更。
@@ -0,0 +1,37 @@
|
||||
using System.Numerics;
|
||||
|
||||
#pragma warning disable CS0660, CS0661
|
||||
|
||||
namespace ComputeSharp;
|
||||
|
||||
/// <inheritdoc cref="Float3x2"/>
|
||||
partial struct Float3x2
|
||||
{
|
||||
/// <summary>
|
||||
/// Casts a <see cref="Float3x2"/> value to a <see cref="Vector2"/> one.
|
||||
/// </summary>
|
||||
/// <param name="xy">The input <see cref="Float3x2"/> value to cast.</param>
|
||||
public static unsafe implicit operator Matrix3x2(Float3x2 xy) => *(Matrix3x2*)&xy;
|
||||
|
||||
/// <summary>
|
||||
/// Casts a <see cref="Vector2"/> value to a <see cref="Float3x2"/> one.
|
||||
/// </summary>
|
||||
/// <param name="xy">The input <see cref="Vector2"/> value to cast.</param>
|
||||
public static unsafe implicit operator Float3x2(Matrix3x2 xy) => *(Float3x2*)&xy;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Float4x4"/>
|
||||
partial struct Float4x4
|
||||
{
|
||||
/// <summary>
|
||||
/// Casts a <see cref="Float4x4"/> value to a <see cref="Vector2"/> one.
|
||||
/// </summary>
|
||||
/// <param name="xy">The input <see cref="Float4x4"/> value to cast.</param>
|
||||
public static unsafe implicit operator Matrix4x4(Float4x4 xy) => *(Matrix4x4*)&xy;
|
||||
|
||||
/// <summary>
|
||||
/// Casts a <see cref="Vector2"/> value to a <see cref="Float4x4"/> one.
|
||||
/// </summary>
|
||||
/// <param name="xy">The input <see cref="Vector2"/> value to cast.</param>
|
||||
public static unsafe implicit operator Float4x4(Matrix4x4 xy) => *(Float4x4*)&xy;
|
||||
}
|
||||
@@ -365,7 +365,7 @@ internal static partial class HlslKnownTypes
|
||||
/// <returns>The same list as input, but in a valid HLSL declaration order.</returns>
|
||||
private static IEnumerable<INamedTypeSymbol> OrderByDependency(IEnumerable<INamedTypeSymbol> types, IReadOnlyCollection<INamedTypeSymbol> invalidTypes)
|
||||
{
|
||||
Queue<(INamedTypeSymbol Type, HashSet<INamedTypeSymbol> Fields)> queue = new();
|
||||
Queue<(INamedTypeSymbol Type, HashSet<INamedTypeSymbol> Fields)> queue = [];
|
||||
|
||||
// Build a mapping of type dependencies for all the captured types. A type depends on another
|
||||
// when the latter is a field in the first type. HLSL requires custom types to be declared in
|
||||
|
||||
@@ -20,7 +20,7 @@ internal sealed class DynamicCache<TKey, TValue>
|
||||
/// <summary>
|
||||
/// The backing <see cref="ConcurrentDictionary{TKey, TValue}"/> instance for the cache.
|
||||
/// </summary>
|
||||
private readonly ConcurrentDictionary<Entry, TValue> map = new();
|
||||
private readonly ConcurrentDictionary<Entry, TValue> map = [];
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="ConditionalWeakTable{TKey, TValue}"/> tracking dead entries to remove.
|
||||
|
||||
@@ -16,7 +16,7 @@ internal readonly unsafe struct ID3D12CommandListPool(D3D12_COMMAND_LIST_TYPE d3
|
||||
/// <summary>
|
||||
/// The queue of <see cref="D3D12CommandListBundle"/> items with the available command lists.
|
||||
/// </summary>
|
||||
private readonly Queue<D3D12CommandListBundle> d3D12CommandListBundleQueue = new();
|
||||
private readonly Queue<D3D12CommandListBundle> d3D12CommandListBundleQueue = [];
|
||||
|
||||
/// <summary>
|
||||
/// Rents a <see cref="ID3D12GraphicsCommandList"/> and <see cref="ID3D12CommandAllocator"/> pair.
|
||||
|
||||
@@ -228,7 +228,7 @@ unsafe partial class GraphicsDevice
|
||||
/// <summary>
|
||||
/// The shared <see cref="ConcurrentQueue{T}"/> holding the reusable <see cref="WaitForFenceValueTaskSource"/> instances.
|
||||
/// </summary>
|
||||
private static readonly ConcurrentQueue<WaitForFenceValueTaskSource> ValueTaskSourceQueue = new();
|
||||
private static readonly ConcurrentQueue<WaitForFenceValueTaskSource> ValueTaskSourceQueue = [];
|
||||
|
||||
/// <summary>
|
||||
/// The approximate count of currently enqueued instances in <see cref="ValueTaskSourceQueue"/>.
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
using System.Numerics;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace ComputeSharp.Tests;
|
||||
|
||||
[TestClass]
|
||||
public partial class HlslPrimitiveTests
|
||||
{
|
||||
[TestMethod]
|
||||
public void Float3x2_ImplicitConversions()
|
||||
{
|
||||
Matrix3x2 m3x2 = new(1, 2, 3, 4, 5, 6);
|
||||
|
||||
float3x2 f3x2 = m3x2;
|
||||
|
||||
Assert.AreEqual(m3x2.M11, f3x2.M11);
|
||||
Assert.AreEqual(m3x2.M12, f3x2.M12);
|
||||
Assert.AreEqual(m3x2.M21, f3x2.M21);
|
||||
Assert.AreEqual(m3x2.M22, f3x2.M22);
|
||||
Assert.AreEqual(m3x2.M31, f3x2.M31);
|
||||
Assert.AreEqual(m3x2.M32, f3x2.M32);
|
||||
|
||||
Matrix3x2 roundTrip3x2 = f3x2;
|
||||
|
||||
Assert.AreEqual(m3x2, roundTrip3x2);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Float4x4_ImplicitConversions()
|
||||
{
|
||||
Matrix4x4 m4x4 = new(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
|
||||
|
||||
float4x4 f4x4 = m4x4;
|
||||
|
||||
Assert.AreEqual(m4x4.M11, f4x4.M11);
|
||||
Assert.AreEqual(m4x4.M12, f4x4.M12);
|
||||
Assert.AreEqual(m4x4.M13, f4x4.M13);
|
||||
Assert.AreEqual(m4x4.M14, f4x4.M14);
|
||||
Assert.AreEqual(m4x4.M21, f4x4.M21);
|
||||
Assert.AreEqual(m4x4.M22, f4x4.M22);
|
||||
Assert.AreEqual(m4x4.M23, f4x4.M23);
|
||||
Assert.AreEqual(m4x4.M24, f4x4.M24);
|
||||
Assert.AreEqual(m4x4.M31, f4x4.M31);
|
||||
Assert.AreEqual(m4x4.M32, f4x4.M32);
|
||||
Assert.AreEqual(m4x4.M33, f4x4.M33);
|
||||
Assert.AreEqual(m4x4.M34, f4x4.M34);
|
||||
Assert.AreEqual(m4x4.M41, f4x4.M41);
|
||||
Assert.AreEqual(m4x4.M42, f4x4.M42);
|
||||
Assert.AreEqual(m4x4.M43, f4x4.M43);
|
||||
Assert.AreEqual(m4x4.M44, f4x4.M44);
|
||||
|
||||
Matrix4x4 roundTrip4x4 = f4x4;
|
||||
|
||||
Assert.AreEqual(m4x4, roundTrip4x4);
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする