diff --git a/src/ComputeSharp.D2D1Interop.SourceGenerators/Extensions/IEqualityComparerExtensions.cs b/src/ComputeSharp.D2D1Interop.SourceGenerators/Extensions/IEqualityComparerExtensions.cs deleted file mode 100644 index 70c4e95b..00000000 --- a/src/ComputeSharp.D2D1Interop.SourceGenerators/Extensions/IEqualityComparerExtensions.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.Immutable; - -namespace ComputeSharp.D2D1Interop.SourceGenerators.Extensions; - -/// -/// Extension methods for . -/// -internal static class IEqualityComparerExtensions -{ - /// - /// Gets an for an sequence. - /// - /// The type of items to compare. - /// The compare for individual items. - public static IEqualityComparer> ForImmutableArray(this IEqualityComparer comparer) - { - return new Comparer(comparer); - } - - /// - /// An implementation for an value. - /// - public sealed class Comparer : IEqualityComparer> - { - /// - /// The comparer. - /// - private readonly IEqualityComparer comparer; - - /// - /// Creates a new instance with the specified parameters. - /// - /// The comparer. - public Comparer(IEqualityComparer comparer) - { - this.comparer = comparer; - } - - /// - public bool Equals(ImmutableArray x, ImmutableArray y) - { - return - x == y || - x.SequenceEqual(y, this.comparer); - } - - /// - public int GetHashCode(ImmutableArray obj) - { - HashCode hashCode = default; - - hashCode.AddRange(obj, this.comparer); - - return hashCode.ToHashCode(); - } - } -} diff --git a/src/ComputeSharp.D2D1Interop.SourceGenerators/Models/DispatchIdInfo.cs b/src/ComputeSharp.D2D1Interop.SourceGenerators/Models/DispatchIdInfo.cs deleted file mode 100644 index 4d0dd6fb..00000000 --- a/src/ComputeSharp.D2D1Interop.SourceGenerators/Models/DispatchIdInfo.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.Immutable; -using ComputeSharp.D2D1Interop.SourceGenerators.Extensions; - -namespace ComputeSharp.D2D1Interop.SourceGenerators.Models; - -/// -/// A model representing gathered info on a shader dispatch id. -/// -/// The list of delegate field names for the shader. -internal sealed record DispatchIdInfo(ImmutableArray Delegates) -{ - /// - /// An implementation for . - /// - public sealed class Comparer : IEqualityComparer - { - /// - /// The singleton instance. - /// - public static Comparer Default { get; } = new(); - - /// - public bool Equals(DispatchIdInfo? x, DispatchIdInfo? y) - { - if (x is null && y is null) - { - return true; - } - - if (x is null || y is null) - { - return false; - } - - if (ReferenceEquals(x, y)) - { - return true; - } - - return x.Delegates.SequenceEqual(y.Delegates); - } - - /// - public int GetHashCode(DispatchIdInfo obj) - { - HashCode hashCode = default; - - hashCode.AddRange(obj.Delegates); - - return hashCode.ToHashCode(); - } - } -} diff --git a/src/ComputeSharp.D2D1Interop.SourceGenerators/Models/DispatchMetadataInfo.cs b/src/ComputeSharp.D2D1Interop.SourceGenerators/Models/DispatchMetadataInfo.cs deleted file mode 100644 index 490a7def..00000000 --- a/src/ComputeSharp.D2D1Interop.SourceGenerators/Models/DispatchMetadataInfo.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.Immutable; -using ComputeSharp.D2D1Interop.SourceGenerators.Extensions; - -namespace ComputeSharp.D2D1Interop.SourceGenerators.Models; - -/// -/// A model containing info on shader dispatch metadata. -/// -/// The size of the shader root signature, in 32 bit constants. -/// Whether or not the static sampler is used. -/// The sequence of resource descriptors for the shader. -internal sealed record DispatchMetadataInfo( - int Root32BitConstantCount, - bool IsSamplerUsed, - ImmutableArray ResourceDescriptors) -{ - /// - /// An implementation for . - /// - public sealed class Comparer : IEqualityComparer - { - /// - /// The singleton instance. - /// - public static Comparer Default { get; } = new(); - - /// - public bool Equals(DispatchMetadataInfo? x, DispatchMetadataInfo? y) - { - if (x is null && y is null) - { - return true; - } - - if (x is null || y is null) - { - return false; - } - - if (ReferenceEquals(x, y)) - { - return true; - } - - return - x.Root32BitConstantCount == y.Root32BitConstantCount && - x.IsSamplerUsed == y.IsSamplerUsed && - x.ResourceDescriptors.SequenceEqual(y.ResourceDescriptors, ResourceDescriptor.Comparer.Default); - } - - /// - public int GetHashCode(DispatchMetadataInfo obj) - { - HashCode hashCode = default; - - hashCode.Add(obj.Root32BitConstantCount); - hashCode.Add(obj.IsSamplerUsed); - hashCode.AddRange(obj.ResourceDescriptors, ResourceDescriptor.Comparer.Default); - - return hashCode.ToHashCode(); - } - } -} \ No newline at end of file diff --git a/src/ComputeSharp.D2D1Interop.SourceGenerators/Models/FieldInfo.cs b/src/ComputeSharp.D2D1Interop.SourceGenerators/Models/FieldInfo.cs index 74f70236..aa8961c3 100644 --- a/src/ComputeSharp.D2D1Interop.SourceGenerators/Models/FieldInfo.cs +++ b/src/ComputeSharp.D2D1Interop.SourceGenerators/Models/FieldInfo.cs @@ -10,14 +10,6 @@ namespace ComputeSharp.D2D1Interop.SourceGenerators.Models; /// internal abstract record FieldInfo { - /// - /// A captured resource (either a buffer or a texture). - /// - /// The name of the resource field. - /// The full metadata name for the resource type. - /// The offset for the resource within the root signature. - public sealed record Resource(string FieldName, string TypeName, int Offset) : FieldInfo; - /// /// A captured primitive value (either a scalar, a vector, or a linear matrix). /// @@ -71,14 +63,7 @@ internal abstract record FieldInfo return true; } - if (x is Resource resourceX && y is Resource resourceY) - { - return - resourceX.FieldName == resourceY.FieldName && - resourceX.TypeName == resourceY.TypeName && - resourceX.Offset == resourceY.Offset; - } - else if (x is Primitive primitiveX && y is Primitive primitiveY) + if (x is Primitive primitiveX && y is Primitive primitiveY) { return primitiveX.FieldPath.SequenceEqual(primitiveY.FieldPath) && @@ -104,8 +89,6 @@ internal abstract record FieldInfo { switch (obj) { - case Resource resource: - return HashCode.Combine(resource.FieldName, resource.TypeName, resource.Offset); case Primitive primitive: { HashCode hashCode = default; diff --git a/src/ComputeSharp.D2D1Interop.SourceGenerators/Models/HlslMethodSourceInfo.cs b/src/ComputeSharp.D2D1Interop.SourceGenerators/Models/HlslMethodSourceInfo.cs deleted file mode 100644 index a2540c98..00000000 --- a/src/ComputeSharp.D2D1Interop.SourceGenerators/Models/HlslMethodSourceInfo.cs +++ /dev/null @@ -1,73 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.Immutable; -using ComputeSharp.D2D1Interop.SourceGenerators.Extensions; - -namespace ComputeSharp.D2D1Interop.SourceGenerators.Models; - -/// -/// A model for extracted info on a processed HLSL method. -/// -/// The metadata name for the method. -/// The meethod entry point. -/// The discovered declared types. -/// The discovered defined constants. -/// The dependent captured methods. -internal sealed record HlslMethodSourceInfo( - string MetadataName, - string EntryPoint, - ImmutableArray<(string Name, string Definition)> DefinedTypes, - ImmutableArray<(string Name, string Value)> DefinedConstants, - ImmutableArray<(string Signature, string Definition)> DependentMethods) -{ - /// - /// An implementation for . - /// - public sealed class Comparer : IEqualityComparer - { - /// - /// The singleton instance. - /// - public static Comparer Default { get; } = new(); - - /// - public bool Equals(HlslMethodSourceInfo? x, HlslMethodSourceInfo? y) - { - if (x is null && y is null) - { - return true; - } - - if (x is null || y is null) - { - return false; - } - - if (ReferenceEquals(x, y)) - { - return true; - } - - return - x.MetadataName == y.MetadataName && - x.EntryPoint == y.EntryPoint && - x.DefinedTypes.SequenceEqual(y.DefinedTypes) && - x.DefinedConstants.SequenceEqual(y.DefinedConstants) && - x.DependentMethods.SequenceEqual(y.DependentMethods); - } - - /// - public int GetHashCode(HlslMethodSourceInfo obj) - { - HashCode hashCode = default; - - hashCode.Add(obj.MetadataName); - hashCode.Add(obj.EntryPoint); - hashCode.AddRange(obj.DefinedTypes); - hashCode.AddRange(obj.DefinedConstants); - hashCode.AddRange(obj.DependentMethods); - - return hashCode.ToHashCode(); - } - } -} diff --git a/src/ComputeSharp.D2D1Interop.SourceGenerators/Models/ParameterInfo.cs b/src/ComputeSharp.D2D1Interop.SourceGenerators/Models/ParameterInfo.cs deleted file mode 100644 index d6e2c9cd..00000000 --- a/src/ComputeSharp.D2D1Interop.SourceGenerators/Models/ParameterInfo.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace ComputeSharp.D2D1Interop.SourceGenerators.Models; - -/// -/// A model describing info on a constructor parameter. -/// -/// The fully qualified type name. -/// The parameter name. -internal sealed record ParameterInfo(string Type, string Name); diff --git a/src/ComputeSharp.D2D1Interop.SourceGenerators/Models/ResourceDescriptor.cs b/src/ComputeSharp.D2D1Interop.SourceGenerators/Models/ResourceDescriptor.cs deleted file mode 100644 index 92d34da7..00000000 --- a/src/ComputeSharp.D2D1Interop.SourceGenerators/Models/ResourceDescriptor.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace ComputeSharp.D2D1Interop.SourceGenerators.Models; - -/// -/// A resource descriptor for a captured resource in a shader. -/// -/// The type id for the resource. -/// The offset of the resource in its containing register. -/// The offset of the resource descriptor in the shader root signature. -internal sealed record ResourceDescriptor(int TypeId, int RegisterOffset, int Offset) -{ - /// - /// An implementation for . - /// - public sealed class Comparer : IEqualityComparer - { - /// - /// The singleton instance. - /// - public static Comparer Default { get; } = new(); - - /// - public bool Equals(ResourceDescriptor? x, ResourceDescriptor? y) - { - if (x is null && y is null) - { - return true; - } - - if (x is null || y is null) - { - return false; - } - - if (ReferenceEquals(x, y)) - { - return true; - } - - return - x.TypeId == y.TypeId && - x.RegisterOffset == y.RegisterOffset && - x.Offset == y.Offset; - } - - /// - public int GetHashCode(ResourceDescriptor obj) - { - return HashCode.Combine(obj.TypeId, obj.RegisterOffset, obj.Offset); - } - } -} diff --git a/src/ComputeSharp.D2D1Interop.SourceGenerators/Models/ThreadIdsInfo.cs b/src/ComputeSharp.D2D1Interop.SourceGenerators/Models/ThreadIdsInfo.cs deleted file mode 100644 index cb001432..00000000 --- a/src/ComputeSharp.D2D1Interop.SourceGenerators/Models/ThreadIdsInfo.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace ComputeSharp.D2D1Interop.SourceGenerators.Models; - -/// -/// A model representing gathered info on a embedded thread ids. -/// -/// Whether the values are diascarded. -/// The thread ids value for the X axis. -/// The thread ids value for the Y axis. -/// The thread ids value for the Z axis. -internal sealed record ThreadIdsInfo(bool IsDefault, int X, int Y, int Z) -{ - /// - /// An implementation for . - /// - public sealed class Comparer : IEqualityComparer - { - /// - /// The singleton instance. - /// - public static Comparer Default { get; } = new(); - - /// - public bool Equals(ThreadIdsInfo? x, ThreadIdsInfo? y) - { - if (x is null && y is null) - { - return true; - } - - if (x is null || y is null) - { - return false; - } - - if (ReferenceEquals(x, y)) - { - return true; - } - - return - x.IsDefault == y.IsDefault && - x.X == y.X && - x.Y == y.Y && - x.Z == y.Y; - } - - /// - public int GetHashCode(ThreadIdsInfo obj) - { - return HashCode.Combine(obj.IsDefault, obj.X, obj.Y, obj.Z); - } - } -} diff --git a/src/ComputeSharp.SourceGenerators/Models/ParameterInfo.cs b/src/ComputeSharp.SourceGenerators/Models/ParameterInfo.cs deleted file mode 100644 index 137df444..00000000 --- a/src/ComputeSharp.SourceGenerators/Models/ParameterInfo.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace ComputeSharp.SourceGenerators.Models; - -/// -/// A model describing info on a constructor parameter. -/// -/// The fully qualified type name. -/// The parameter name. -internal sealed record ParameterInfo(string Type, string Name);