Streamline equality comparison of generation models
このコミットが含まれているのは:
1 親
6e247639ed
コミット
6b0c1161c8
19ファイル変更
+249
-607
検索条件に一致するファイルはありません
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using ComputeSharp.SourceGeneration.Extensions;
|
||||
using ComputeSharp.SourceGeneration.Helpers;
|
||||
using ComputeSharp.SourceGeneration.Models;
|
||||
|
||||
namespace ComputeSharp.SourceGenerators.Models;
|
||||
@@ -24,31 +25,21 @@ internal sealed record DispatchDataInfo(
|
||||
/// <summary>
|
||||
/// An <see cref="IEqualityComparer{T}"/> implementation for <see cref="DispatchDataInfo"/>.
|
||||
/// </summary>
|
||||
public sealed class Comparer : IEqualityComparer<DispatchDataInfo>
|
||||
public sealed class Comparer : Comparer<DispatchDataInfo, Comparer>
|
||||
{
|
||||
/// <summary>
|
||||
/// The singleton <see cref="Comparer"/> instance.
|
||||
/// </summary>
|
||||
public static Comparer Default { get; } = new();
|
||||
/// <inheritdoc/>
|
||||
protected override void AddToHashCode(ref HashCode hashCode, DispatchDataInfo obj)
|
||||
{
|
||||
hashCode.Add(HierarchyInfo.Comparer.Default.GetHashCode(obj.Hierarchy));
|
||||
hashCode.Add(obj.Type);
|
||||
hashCode.AddRange(obj.FieldInfos, FieldInfo.Comparer.Default);
|
||||
hashCode.Add(obj.ResourceCount);
|
||||
hashCode.Add(obj.Root32BitConstantCount);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool Equals(DispatchDataInfo? x, DispatchDataInfo? y)
|
||||
protected override bool AreEqual(DispatchDataInfo x, DispatchDataInfo 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
|
||||
HierarchyInfo.Comparer.Default.Equals(x.Hierarchy, y.Hierarchy) &&
|
||||
x.Type == y.Type &&
|
||||
@@ -56,19 +47,5 @@ internal sealed record DispatchDataInfo(
|
||||
x.ResourceCount == y.ResourceCount &&
|
||||
x.Root32BitConstantCount == y.Root32BitConstantCount;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public int GetHashCode(DispatchDataInfo obj)
|
||||
{
|
||||
HashCode hashCode = default;
|
||||
|
||||
hashCode.Add(HierarchyInfo.Comparer.Default.GetHashCode(obj.Hierarchy));
|
||||
hashCode.Add(obj.Type);
|
||||
hashCode.AddRange(obj.FieldInfos, FieldInfo.Comparer.Default);
|
||||
hashCode.Add(obj.ResourceCount);
|
||||
hashCode.Add(obj.Root32BitConstantCount);
|
||||
|
||||
return hashCode.ToHashCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using ComputeSharp.SourceGeneration.Extensions;
|
||||
using ComputeSharp.SourceGeneration.Helpers;
|
||||
|
||||
namespace ComputeSharp.SourceGenerators.Models;
|
||||
|
||||
@@ -14,42 +15,18 @@ internal sealed record DispatchIdInfo(ImmutableArray<string> Delegates)
|
||||
/// <summary>
|
||||
/// An <see cref="IEqualityComparer{T}"/> implementation for <see cref="DispatchIdInfo"/>.
|
||||
/// </summary>
|
||||
public sealed class Comparer : IEqualityComparer<DispatchIdInfo>
|
||||
public sealed class Comparer : Comparer<DispatchIdInfo, Comparer>
|
||||
{
|
||||
/// <summary>
|
||||
/// The singleton <see cref="Comparer"/> instance.
|
||||
/// </summary>
|
||||
public static Comparer Default { get; } = new();
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool Equals(DispatchIdInfo? x, DispatchIdInfo? y)
|
||||
protected override void AddToHashCode(ref HashCode hashCode, DispatchIdInfo obj)
|
||||
{
|
||||
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);
|
||||
hashCode.AddRange(obj.Delegates);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public int GetHashCode(DispatchIdInfo obj)
|
||||
protected override bool AreEqual(DispatchIdInfo x, DispatchIdInfo y)
|
||||
{
|
||||
HashCode hashCode = default;
|
||||
|
||||
hashCode.AddRange(obj.Delegates);
|
||||
|
||||
return hashCode.ToHashCode();
|
||||
return x.Delegates.SequenceEqual(y.Delegates);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using ComputeSharp.SourceGeneration.Extensions;
|
||||
using ComputeSharp.SourceGeneration.Helpers;
|
||||
|
||||
namespace ComputeSharp.SourceGenerators.Models;
|
||||
|
||||
@@ -19,47 +20,23 @@ internal sealed record DispatchMetadataInfo(
|
||||
/// <summary>
|
||||
/// An <see cref="IEqualityComparer{T}"/> implementation for <see cref="DispatchMetadataInfo"/>.
|
||||
/// </summary>
|
||||
public sealed class Comparer : IEqualityComparer<DispatchMetadataInfo>
|
||||
public sealed class Comparer : Comparer<DispatchMetadataInfo, Comparer>
|
||||
{
|
||||
/// <summary>
|
||||
/// The singleton <see cref="Comparer"/> instance.
|
||||
/// </summary>
|
||||
public static Comparer Default { get; } = new();
|
||||
/// <inheritdoc/>
|
||||
protected override void AddToHashCode(ref HashCode hashCode, DispatchMetadataInfo obj)
|
||||
{
|
||||
hashCode.Add(obj.Root32BitConstantCount);
|
||||
hashCode.Add(obj.IsSamplerUsed);
|
||||
hashCode.AddRange(obj.ResourceDescriptors);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool Equals(DispatchMetadataInfo? x, DispatchMetadataInfo? y)
|
||||
protected override bool AreEqual(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);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
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();
|
||||
x.ResourceDescriptors.SequenceEqual(y.ResourceDescriptors);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using ComputeSharp.SourceGeneration.Extensions;
|
||||
using ComputeSharp.SourceGeneration.Helpers;
|
||||
|
||||
namespace ComputeSharp.SourceGenerators.Models;
|
||||
|
||||
@@ -17,49 +18,25 @@ internal sealed record EmbeddedBytecodeInfo(int X, int Y, int Z, ImmutableArray<
|
||||
/// <summary>
|
||||
/// An <see cref="IEqualityComparer{T}"/> implementation for <see cref="EmbeddedBytecodeInfo"/>.
|
||||
/// </summary>
|
||||
public sealed class Comparer : IEqualityComparer<EmbeddedBytecodeInfo>
|
||||
public sealed class Comparer : Comparer<EmbeddedBytecodeInfo, Comparer>
|
||||
{
|
||||
/// <summary>
|
||||
/// The singleton <see cref="Comparer"/> instance.
|
||||
/// </summary>
|
||||
public static Comparer Default { get; } = new();
|
||||
/// <inheritdoc/>
|
||||
protected override void AddToHashCode(ref HashCode hashCode, EmbeddedBytecodeInfo obj)
|
||||
{
|
||||
hashCode.Add(obj.X);
|
||||
hashCode.Add(obj.Y);
|
||||
hashCode.Add(obj.Z);
|
||||
hashCode.AddBytes(obj.Bytecode.AsSpan());
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool Equals(EmbeddedBytecodeInfo? x, EmbeddedBytecodeInfo? y)
|
||||
protected override bool AreEqual(EmbeddedBytecodeInfo x, EmbeddedBytecodeInfo 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.X == y.X &&
|
||||
x.Y == y.Y &&
|
||||
x.Z == y.Z &&
|
||||
x.Bytecode.SequenceEqual(y.Bytecode);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public int GetHashCode(EmbeddedBytecodeInfo obj)
|
||||
{
|
||||
HashCode hashCode = default;
|
||||
|
||||
hashCode.Add(obj.X);
|
||||
hashCode.Add(obj.Y);
|
||||
hashCode.Add(obj.Z);
|
||||
hashCode.AddBytes(obj.Bytecode.AsSpan());
|
||||
|
||||
return hashCode.ToHashCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using ComputeSharp.SourceGeneration.Extensions;
|
||||
using ComputeSharp.SourceGeneration.Helpers;
|
||||
|
||||
namespace ComputeSharp.SourceGenerators.Models;
|
||||
|
||||
@@ -46,31 +47,39 @@ internal abstract record FieldInfo
|
||||
/// <summary>
|
||||
/// An <see cref="IEqualityComparer{T}"/> implementation for <see cref="FieldInfo"/>.
|
||||
/// </summary>
|
||||
public sealed class Comparer : IEqualityComparer<FieldInfo>
|
||||
public sealed class Comparer : Comparer<FieldInfo, Comparer>
|
||||
{
|
||||
/// <summary>
|
||||
/// The singleton <see cref="Comparer"/> instance.
|
||||
/// </summary>
|
||||
public static Comparer Default { get; } = new();
|
||||
/// <inheritdoc/>
|
||||
protected override void AddToHashCode(ref HashCode hashCode, FieldInfo obj)
|
||||
{
|
||||
switch (obj)
|
||||
{
|
||||
case Resource resource:
|
||||
hashCode.Add(resource.FieldName);
|
||||
hashCode.Add(resource.TypeName);
|
||||
hashCode.Add(resource.Offset);
|
||||
break;
|
||||
case Primitive primitive:
|
||||
hashCode.AddRange(primitive.FieldPath);
|
||||
hashCode.Add(primitive.TypeName);
|
||||
hashCode.Add(primitive.Offset);
|
||||
break;
|
||||
case NonLinearMatrix matrix:
|
||||
hashCode.AddRange(matrix.FieldPath);
|
||||
hashCode.Add(matrix.TypeName);
|
||||
hashCode.Add(matrix.ElementName);
|
||||
hashCode.Add(matrix.Rows);
|
||||
hashCode.Add(matrix.Columns);
|
||||
hashCode.AddRange(matrix.Offsets);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool Equals(FieldInfo? x, FieldInfo? y)
|
||||
protected override bool AreEqual(FieldInfo x, FieldInfo 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;
|
||||
}
|
||||
|
||||
if (x is Resource resourceX && y is Resource resourceY)
|
||||
{
|
||||
return
|
||||
@@ -98,40 +107,5 @@ internal abstract record FieldInfo
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public int GetHashCode(FieldInfo obj)
|
||||
{
|
||||
switch (obj)
|
||||
{
|
||||
case Resource resource:
|
||||
return HashCode.Combine(resource.FieldName, resource.TypeName, resource.Offset);
|
||||
case Primitive primitive:
|
||||
{
|
||||
HashCode hashCode = default;
|
||||
|
||||
hashCode.AddRange(primitive.FieldPath);
|
||||
hashCode.Add(primitive.TypeName);
|
||||
hashCode.Add(primitive.Offset);
|
||||
|
||||
return hashCode.ToHashCode();
|
||||
}
|
||||
case NonLinearMatrix matrix:
|
||||
{
|
||||
HashCode hashCode = default;
|
||||
|
||||
hashCode.AddRange(matrix.FieldPath);
|
||||
hashCode.Add(matrix.TypeName);
|
||||
hashCode.Add(matrix.ElementName);
|
||||
hashCode.Add(matrix.Rows);
|
||||
hashCode.Add(matrix.Columns);
|
||||
hashCode.AddRange(matrix.Offsets);
|
||||
|
||||
return hashCode.ToHashCode();
|
||||
}
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using ComputeSharp.SourceGeneration.Extensions;
|
||||
using ComputeSharp.SourceGeneration.Helpers;
|
||||
|
||||
namespace ComputeSharp.SourceGenerators.Models;
|
||||
|
||||
@@ -23,31 +24,21 @@ internal sealed record HlslMethodSourceInfo(
|
||||
/// <summary>
|
||||
/// An <see cref="IEqualityComparer{T}"/> implementation for <see cref="HlslMethodSourceInfo"/>.
|
||||
/// </summary>
|
||||
public sealed class Comparer : IEqualityComparer<HlslMethodSourceInfo>
|
||||
public sealed class Comparer : Comparer<HlslMethodSourceInfo, Comparer>
|
||||
{
|
||||
/// <summary>
|
||||
/// The singleton <see cref="Comparer"/> instance.
|
||||
/// </summary>
|
||||
public static Comparer Default { get; } = new();
|
||||
/// <inheritdoc/>
|
||||
protected override void AddToHashCode(ref HashCode hashCode, HlslMethodSourceInfo obj)
|
||||
{
|
||||
hashCode.Add(obj.MetadataName);
|
||||
hashCode.Add(obj.EntryPoint);
|
||||
hashCode.AddRange(obj.DefinedTypes);
|
||||
hashCode.AddRange(obj.DefinedConstants);
|
||||
hashCode.AddRange(obj.DependentMethods);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool Equals(HlslMethodSourceInfo? x, HlslMethodSourceInfo? y)
|
||||
protected override bool AreEqual(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 &&
|
||||
@@ -55,19 +46,5 @@ internal sealed record HlslMethodSourceInfo(
|
||||
x.DefinedConstants.SequenceEqual(y.DefinedConstants) &&
|
||||
x.DependentMethods.SequenceEqual(y.DependentMethods);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using ComputeSharp.SourceGeneration.Extensions;
|
||||
using ComputeSharp.SourceGeneration.Helpers;
|
||||
|
||||
namespace ComputeSharp.SourceGenerators.Models;
|
||||
|
||||
@@ -41,31 +42,30 @@ internal sealed record HlslShaderSourceInfo(
|
||||
/// <summary>
|
||||
/// An <see cref="IEqualityComparer{T}"/> implementation for <see cref="HlslShaderSourceInfo"/>.
|
||||
/// </summary>
|
||||
public sealed class Comparer : IEqualityComparer<HlslShaderSourceInfo>
|
||||
public sealed class Comparer : Comparer<HlslShaderSourceInfo, Comparer>
|
||||
{
|
||||
/// <summary>
|
||||
/// The singleton <see cref="Comparer"/> instance.
|
||||
/// </summary>
|
||||
public static Comparer Default { get; } = new();
|
||||
/// <inheritdoc/>
|
||||
protected override void AddToHashCode(ref HashCode hashCode, HlslShaderSourceInfo obj)
|
||||
{
|
||||
hashCode.Add(obj.HeaderAndThreadsX);
|
||||
hashCode.Add(obj.ThreadsY);
|
||||
hashCode.Add(obj.ThreadsZ);
|
||||
hashCode.Add(obj.Defines);
|
||||
hashCode.Add(obj.StaticFieldsAndDeclaredTypes);
|
||||
hashCode.Add(obj.CapturedFieldsAndResourcesAndForwardDeclarations);
|
||||
hashCode.Add(obj.CapturedMethods);
|
||||
hashCode.Add(obj.EntryPoint);
|
||||
hashCode.Add(obj.ImplicitTextureType);
|
||||
hashCode.Add(obj.IsSamplerUsed);
|
||||
hashCode.AddRange(obj.DefinedTypes);
|
||||
hashCode.AddRange(obj.DefinedConstants);
|
||||
hashCode.AddRange(obj.MethodSignatures);
|
||||
hashCode.AddRange(obj.Delegates);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool Equals(HlslShaderSourceInfo? x, HlslShaderSourceInfo? y)
|
||||
protected override bool AreEqual(HlslShaderSourceInfo x, HlslShaderSourceInfo 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.HeaderAndThreadsX == y.HeaderAndThreadsX &&
|
||||
x.ThreadsY == y.ThreadsY &&
|
||||
@@ -82,28 +82,5 @@ internal sealed record HlslShaderSourceInfo(
|
||||
x.MethodSignatures.SequenceEqual(y.MethodSignatures) &&
|
||||
x.Delegates.SequenceEqual(y.Delegates);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public int GetHashCode(HlslShaderSourceInfo obj)
|
||||
{
|
||||
HashCode hashCode = default;
|
||||
|
||||
hashCode.Add(obj.HeaderAndThreadsX);
|
||||
hashCode.Add(obj.ThreadsY);
|
||||
hashCode.Add(obj.ThreadsZ);
|
||||
hashCode.Add(obj.Defines);
|
||||
hashCode.Add(obj.StaticFieldsAndDeclaredTypes);
|
||||
hashCode.Add(obj.CapturedFieldsAndResourcesAndForwardDeclarations);
|
||||
hashCode.Add(obj.CapturedMethods);
|
||||
hashCode.Add(obj.EntryPoint);
|
||||
hashCode.Add(obj.ImplicitTextureType);
|
||||
hashCode.Add(obj.IsSamplerUsed);
|
||||
hashCode.AddRange(obj.DefinedTypes);
|
||||
hashCode.AddRange(obj.DefinedConstants);
|
||||
hashCode.AddRange(obj.MethodSignatures);
|
||||
hashCode.AddRange(obj.Delegates);
|
||||
|
||||
return hashCode.ToHashCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ComputeSharp.SourceGenerators.Models;
|
||||
namespace ComputeSharp.SourceGenerators.Models;
|
||||
|
||||
/// <summary>
|
||||
/// A resource descriptor for a captured resource in a shader.
|
||||
@@ -9,46 +6,4 @@ namespace ComputeSharp.SourceGenerators.Models;
|
||||
/// <param name="TypeId">The type id for the resource.</param>
|
||||
/// <param name="RegisterOffset">The offset of the resource in its containing register.</param>
|
||||
/// <param name="Offset">The offset of the resource descriptor in the shader root signature.</param>
|
||||
internal sealed record ResourceDescriptor(int TypeId, int RegisterOffset, int Offset)
|
||||
{
|
||||
/// <summary>
|
||||
/// An <see cref="IEqualityComparer{T}"/> implementation for <see cref="ResourceDescriptor"/>.
|
||||
/// </summary>
|
||||
public sealed class Comparer : IEqualityComparer<ResourceDescriptor>
|
||||
{
|
||||
/// <summary>
|
||||
/// The singleton <see cref="Comparer"/> instance.
|
||||
/// </summary>
|
||||
public static Comparer Default { get; } = new();
|
||||
|
||||
/// <inheritdoc/>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public int GetHashCode(ResourceDescriptor obj)
|
||||
{
|
||||
return HashCode.Combine(obj.TypeId, obj.RegisterOffset, obj.Offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
internal sealed record ResourceDescriptor(int TypeId, int RegisterOffset, int Offset);
|
||||
@@ -1,7 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ComputeSharp.SourceGenerators.Models;
|
||||
namespace ComputeSharp.SourceGenerators.Models;
|
||||
|
||||
/// <summary>
|
||||
/// A model representing gathered info on a embedded thread ids.
|
||||
@@ -10,47 +7,4 @@ namespace ComputeSharp.SourceGenerators.Models;
|
||||
/// <param name="X">The thread ids value for the X axis.</param>
|
||||
/// <param name="Y">The thread ids value for the Y axis.</param>
|
||||
/// <param name="Z">The thread ids value for the Z axis.</param>
|
||||
internal sealed record ThreadIdsInfo(bool IsDefault, int X, int Y, int Z)
|
||||
{
|
||||
/// <summary>
|
||||
/// An <see cref="IEqualityComparer{T}"/> implementation for <see cref="ThreadIdsInfo"/>.
|
||||
/// </summary>
|
||||
public sealed class Comparer : IEqualityComparer<ThreadIdsInfo>
|
||||
{
|
||||
/// <summary>
|
||||
/// The singleton <see cref="Comparer"/> instance.
|
||||
/// </summary>
|
||||
public static Comparer Default { get; } = new();
|
||||
|
||||
/// <inheritdoc/>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public int GetHashCode(ThreadIdsInfo obj)
|
||||
{
|
||||
return HashCode.Combine(obj.IsDefault, obj.X, obj.Y, obj.Z);
|
||||
}
|
||||
}
|
||||
}
|
||||
internal sealed record ThreadIdsInfo(bool IsDefault, int X, int Y, int Z);
|
||||
新しいイシューから参照
ユーザーをブロックする