Switch to EquatableArray<T> in ComputeSharp.D2D1 models
このコミットが含まれているのは:
1 親
23e5300dee
コミット
4def9f65a9
14ファイル変更
+29
-472
検索条件に一致するファイルはありません
+1
-1
@@ -87,7 +87,7 @@ partial class D2DPixelShaderSourceGenerator
|
||||
// <METHOD_BODY>
|
||||
return
|
||||
MethodDeclaration(returnType, Identifier(bytecodeInfo.MethodName))
|
||||
.AddModifiers(bytecodeInfo.Modifiers.Select(Token).ToArray())
|
||||
.AddModifiers(bytecodeInfo.Modifiers.Select(static m => Token((SyntaxKind)m)).ToArray())
|
||||
.AddAttributeLists(
|
||||
AttributeList(SingletonSeparatedList(
|
||||
Attribute(IdentifierName("global::System.CodeDom.Compiler.GeneratedCode"))
|
||||
|
||||
@@ -41,7 +41,7 @@ public sealed partial class D2DPixelShaderSourceGenerator : IIncrementalGenerato
|
||||
token.ThrowIfCancellationRequested();
|
||||
|
||||
// Get the remaining info for the current shader
|
||||
ImmutableArray<SyntaxKind> modifiers = methodDeclaration.Modifiers.Select(token => token.Kind()).ToImmutableArray();
|
||||
ImmutableArray<ushort> modifiers = methodDeclaration.Modifiers.Select(token => (ushort)token.Kind()).ToImmutableArray();
|
||||
string methodName = methodSymbol.Name;
|
||||
string? invalidReturnType = Execute.GetInvalidReturnType(diagnostics, methodSymbol);
|
||||
D2D1ShaderProfile shaderProfile = Execute.GetShaderProfile(diagnostics, methodSymbol);
|
||||
@@ -63,7 +63,7 @@ public sealed partial class D2DPixelShaderSourceGenerator : IIncrementalGenerato
|
||||
// Output the diagnostics
|
||||
context.ReportDiagnostics(
|
||||
shaderInfoWithErrors
|
||||
.Select(static (item, _) => item.Diagnostcs)
|
||||
.Select(static (item, _) => item.Diagnostcs.AsImmutableArray())
|
||||
.WithComparer(EqualityComparer<DiagnosticInfo>.Default.ForImmutableArray()));
|
||||
|
||||
// Compile the requested shader bytecodes
|
||||
|
||||
@@ -135,7 +135,7 @@ public sealed partial class ID2D1ShaderGenerator : IIncrementalGenerator
|
||||
// Output the diagnostics, if any
|
||||
context.ReportDiagnostics(
|
||||
shaderInfoWithErrors
|
||||
.Select(static (item, _) => item.Diagnostcs)
|
||||
.Select(static (item, _) => item.Diagnostcs.AsImmutableArray())
|
||||
.WithComparer(EqualityComparer<DiagnosticInfo>.Default.ForImmutableArray()));
|
||||
|
||||
// Get the GetInputCount() info (hierarchy and input count)
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using ComputeSharp.SourceGeneration.Extensions;
|
||||
using ComputeSharp.SourceGeneration.Helpers;
|
||||
using ComputeSharp.SourceGeneration.Models;
|
||||
|
||||
@@ -16,40 +12,4 @@ namespace ComputeSharp.D2D1.SourceGenerators.Models;
|
||||
internal sealed record D2D1PixelShaderSourceInfo(
|
||||
HierarchyInfo Hierarchy,
|
||||
HlslShaderMethodSourceInfo HlslShaderMethodSource,
|
||||
ImmutableArray<DiagnosticInfo> Diagnostcs)
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public bool Equals(D2D1PixelShaderSourceInfo? obj)
|
||||
{
|
||||
return Comparer.Default.Equals(this, obj);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Comparer.Default.GetHashCode(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An <see cref="IEqualityComparer{T}"/> implementation for <see cref="D2D1PixelShaderSourceInfo"/>.
|
||||
/// </summary>
|
||||
private sealed class Comparer : Comparer<D2D1PixelShaderSourceInfo, Comparer>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
protected override void AddToHashCode(ref HashCode hashCode, D2D1PixelShaderSourceInfo obj)
|
||||
{
|
||||
hashCode.Add(obj.Hierarchy);
|
||||
hashCode.Add(obj.HlslShaderMethodSource);
|
||||
hashCode.AddRange(obj.Diagnostcs);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override bool AreEqual(D2D1PixelShaderSourceInfo x, D2D1PixelShaderSourceInfo y)
|
||||
{
|
||||
return
|
||||
x.Hierarchy == y.Hierarchy &&
|
||||
x.HlslShaderMethodSource == y.HlslShaderMethodSource &&
|
||||
x.Diagnostcs.SequenceEqual(y.Diagnostcs);
|
||||
}
|
||||
}
|
||||
}
|
||||
EquatableArray<DiagnosticInfo> Diagnostcs);
|
||||
@@ -1,7 +1,3 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using ComputeSharp.SourceGeneration.Extensions;
|
||||
using ComputeSharp.SourceGeneration.Helpers;
|
||||
using ComputeSharp.SourceGeneration.Models;
|
||||
|
||||
@@ -28,52 +24,4 @@ internal sealed record D2D1ShaderInfo(
|
||||
OutputBufferInfo OutputBuffer,
|
||||
InputDescriptionsInfo InputDescriptions,
|
||||
D2D1PixelOptions PixelOptions,
|
||||
ImmutableArray<DiagnosticInfo> Diagnostcs)
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public bool Equals(D2D1ShaderInfo? obj)
|
||||
{
|
||||
return Comparer.Default.Equals(this, obj);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Comparer.Default.GetHashCode(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An <see cref="IEqualityComparer{T}"/> implementation for <see cref="D2D1ShaderInfo"/>.
|
||||
/// </summary>
|
||||
private sealed class Comparer : Comparer<D2D1ShaderInfo, Comparer>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
protected override void AddToHashCode(ref HashCode hashCode, D2D1ShaderInfo obj)
|
||||
{
|
||||
hashCode.Add(obj.Hierarchy);
|
||||
hashCode.Add(obj.DispatchData);
|
||||
hashCode.Add(obj.InputTypes);
|
||||
hashCode.Add(obj.ResourceTextureDescriptions);
|
||||
hashCode.Add(obj.HlslShaderSource);
|
||||
hashCode.Add(obj.OutputBuffer);
|
||||
hashCode.Add(obj.InputDescriptions);
|
||||
hashCode.Add(obj.PixelOptions);
|
||||
hashCode.AddRange(obj.Diagnostcs);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override bool AreEqual(D2D1ShaderInfo x, D2D1ShaderInfo y)
|
||||
{
|
||||
return
|
||||
x.Hierarchy == y.Hierarchy &&
|
||||
x.DispatchData == y.DispatchData &&
|
||||
x.InputTypes == y.InputTypes &&
|
||||
x.ResourceTextureDescriptions == y.ResourceTextureDescriptions &&
|
||||
x.HlslShaderSource == y.HlslShaderSource &&
|
||||
x.OutputBuffer == y.OutputBuffer &&
|
||||
x.InputDescriptions == y.InputDescriptions &&
|
||||
x.PixelOptions == y.PixelOptions &&
|
||||
x.Diagnostcs.SequenceEqual(y.Diagnostcs);
|
||||
}
|
||||
}
|
||||
}
|
||||
EquatableArray<DiagnosticInfo> Diagnostcs);
|
||||
@@ -1,7 +1,3 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using ComputeSharp.SourceGeneration.Extensions;
|
||||
using ComputeSharp.SourceGeneration.Helpers;
|
||||
|
||||
namespace ComputeSharp.D2D1.SourceGenerators.Models;
|
||||
@@ -11,38 +7,4 @@ namespace ComputeSharp.D2D1.SourceGenerators.Models;
|
||||
/// </summary>
|
||||
/// <param name="FieldInfos">The description on shader instance fields.</param>
|
||||
/// <param name="ConstantBufferSizeInBytes">The size of the shader constant buffer.</param>
|
||||
internal sealed record DispatchDataInfo(ImmutableArray<FieldInfo> FieldInfos, int ConstantBufferSizeInBytes)
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public bool Equals(DispatchDataInfo? obj)
|
||||
{
|
||||
return Comparer.Default.Equals(this, obj);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Comparer.Default.GetHashCode(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An <see cref="IEqualityComparer{T}"/> implementation for <see cref="DispatchDataInfo"/>.
|
||||
/// </summary>
|
||||
private sealed class Comparer : Comparer<DispatchDataInfo, Comparer>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
protected override void AddToHashCode(ref HashCode hashCode, DispatchDataInfo obj)
|
||||
{
|
||||
hashCode.AddRange(obj.FieldInfos);
|
||||
hashCode.Add(obj.ConstantBufferSizeInBytes);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override bool AreEqual(DispatchDataInfo x, DispatchDataInfo y)
|
||||
{
|
||||
return
|
||||
x.FieldInfos.SequenceEqual(y.FieldInfos) &&
|
||||
x.ConstantBufferSizeInBytes == y.ConstantBufferSizeInBytes;
|
||||
}
|
||||
}
|
||||
}
|
||||
internal sealed record DispatchDataInfo(EquatableArray<FieldInfo> FieldInfos, int ConstantBufferSizeInBytes);
|
||||
@@ -1,7 +1,3 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using ComputeSharp.SourceGeneration.Extensions;
|
||||
using ComputeSharp.SourceGeneration.Helpers;
|
||||
|
||||
namespace ComputeSharp.D2D1.SourceGenerators.Models;
|
||||
@@ -13,42 +9,4 @@ namespace ComputeSharp.D2D1.SourceGenerators.Models;
|
||||
/// <param name="ShaderProfile">The shader profile to use to compile the shader, if requested.</param>
|
||||
/// <param name="CompileOptions">The compile options to use to compile the shader.</param>
|
||||
/// <param name="Bytecode">The compiled shader bytecode, if available.</param>
|
||||
internal sealed record EmbeddedBytecodeInfo(string HlslSource, D2D1ShaderProfile? ShaderProfile, D2D1CompileOptions? CompileOptions, ImmutableArray<byte> Bytecode)
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public bool Equals(EmbeddedBytecodeInfo? obj)
|
||||
{
|
||||
return Comparer.Default.Equals(this, obj);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Comparer.Default.GetHashCode(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An <see cref="IEqualityComparer{T}"/> implementation for <see cref="EmbeddedBytecodeInfo"/>.
|
||||
/// </summary>
|
||||
private sealed class Comparer : Comparer<EmbeddedBytecodeInfo, Comparer>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
protected override void AddToHashCode(ref HashCode hashCode, EmbeddedBytecodeInfo obj)
|
||||
{
|
||||
hashCode.Add(obj.HlslSource);
|
||||
hashCode.Add(obj.ShaderProfile);
|
||||
hashCode.Add(obj.CompileOptions);
|
||||
hashCode.AddBytes(obj.Bytecode.AsSpan());
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override bool AreEqual(EmbeddedBytecodeInfo x, EmbeddedBytecodeInfo y)
|
||||
{
|
||||
return
|
||||
x.HlslSource == y.HlslSource &&
|
||||
x.ShaderProfile == y.ShaderProfile &&
|
||||
x.CompileOptions == y.CompileOptions &&
|
||||
x.Bytecode.SequenceEqual(y.Bytecode);
|
||||
}
|
||||
}
|
||||
}
|
||||
internal sealed record EmbeddedBytecodeInfo(string HlslSource, D2D1ShaderProfile? ShaderProfile, D2D1CompileOptions? CompileOptions, EquatableArray<byte> Bytecode);
|
||||
@@ -1,64 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Runtime.InteropServices;
|
||||
using ComputeSharp.SourceGeneration.Extensions;
|
||||
using ComputeSharp.SourceGeneration.Helpers;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
|
||||
namespace ComputeSharp.D2D1.SourceGenerators.Models;
|
||||
|
||||
/// <summary>
|
||||
/// A model representing info on a shader method that has requested to be precompiled at build time.
|
||||
/// </summary>
|
||||
/// <param name="Modifiers">The modifiers for the annotated method.</param>
|
||||
/// <param name="Modifiers">The modifiers for the annotated method (these are <see cref="Microsoft.CodeAnalysis.CSharp.SyntaxKind"/> values, which can't be equated directly).</param>
|
||||
/// <param name="MethodName">The name of the annotated method.</param>
|
||||
/// <param name="InvalidReturnType">The fully qualified name of the return type, if invalid.</param>
|
||||
/// <param name="HlslSource">The HLSL source.</param>
|
||||
/// <param name="Bytecode">The compiled shader bytecode, if available.</param>
|
||||
internal sealed record EmbeddedBytecodeMethodInfo(
|
||||
ImmutableArray<SyntaxKind> Modifiers,
|
||||
EquatableArray<ushort> Modifiers,
|
||||
string MethodName,
|
||||
string? InvalidReturnType,
|
||||
string HlslSource,
|
||||
ImmutableArray<byte> Bytecode)
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public bool Equals(EmbeddedBytecodeMethodInfo? obj)
|
||||
{
|
||||
return Comparer.Default.Equals(this, obj);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Comparer.Default.GetHashCode(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An <see cref="IEqualityComparer{T}"/> implementation for <see cref="EmbeddedBytecodeMethodInfo"/>.
|
||||
/// </summary>
|
||||
private sealed class Comparer : Comparer<EmbeddedBytecodeMethodInfo, Comparer>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
protected override void AddToHashCode(ref HashCode hashCode, EmbeddedBytecodeMethodInfo obj)
|
||||
{
|
||||
hashCode.AddRange(obj.Modifiers);
|
||||
hashCode.Add(obj.MethodName);
|
||||
hashCode.Add(obj.InvalidReturnType);
|
||||
hashCode.Add(obj.HlslSource);
|
||||
hashCode.AddBytes(obj.Bytecode.AsSpan());
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override bool AreEqual(EmbeddedBytecodeMethodInfo x, EmbeddedBytecodeMethodInfo y)
|
||||
{
|
||||
return
|
||||
MemoryMarshal.Cast<SyntaxKind, ushort>(x.Modifiers.AsSpan()).SequenceEqual(MemoryMarshal.Cast<SyntaxKind, ushort>(y.Modifiers.AsSpan())) &&
|
||||
x.MethodName == y.MethodName &&
|
||||
x.InvalidReturnType == y.InvalidReturnType &&
|
||||
x.HlslSource == y.HlslSource &&
|
||||
x.Bytecode.SequenceEqual(y.Bytecode);
|
||||
}
|
||||
}
|
||||
}
|
||||
EquatableArray<byte> Bytecode);
|
||||
@@ -1,7 +1,3 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using ComputeSharp.SourceGeneration.Extensions;
|
||||
using ComputeSharp.SourceGeneration.Helpers;
|
||||
|
||||
namespace ComputeSharp.D2D1.SourceGenerators.Models;
|
||||
@@ -17,43 +13,7 @@ internal abstract record FieldInfo
|
||||
/// <param name="FieldPath">The path of the field with respect to the shader instance.</param>
|
||||
/// <param name="TypeName">The full metadata name for the primitive type.</param>
|
||||
/// <param name="Offset">The byte offset of the value within the root signature.</param>
|
||||
public sealed record Primitive(ImmutableArray<string> FieldPath, string TypeName, int Offset) : FieldInfo
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public bool Equals(Primitive? obj)
|
||||
{
|
||||
return Comparer.Default.Equals(this, obj);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Comparer.Default.GetHashCode(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An <see cref="IEqualityComparer{T}"/> implementation for <see cref="Primitive"/>.
|
||||
/// </summary>
|
||||
private sealed class Comparer : Comparer<Primitive, Comparer>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
protected override void AddToHashCode(ref HashCode hashCode, Primitive obj)
|
||||
{
|
||||
hashCode.AddRange(obj.FieldPath);
|
||||
hashCode.Add(obj.TypeName);
|
||||
hashCode.Add(obj.Offset);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override bool AreEqual(Primitive x, Primitive y)
|
||||
{
|
||||
return
|
||||
x.FieldPath.SequenceEqual(y.FieldPath) &&
|
||||
x.TypeName == y.TypeName &&
|
||||
x.Offset == y.Offset;
|
||||
}
|
||||
}
|
||||
}
|
||||
public sealed record Primitive(EquatableArray<string> FieldPath, string TypeName, int Offset) : FieldInfo;
|
||||
|
||||
/// <summary>
|
||||
/// A captured non linear matrix value.
|
||||
@@ -65,52 +25,10 @@ internal abstract record FieldInfo
|
||||
/// <param name="Columns">The number of columns in the matrix.</param>
|
||||
/// <param name="Offsets">The sequence of byte offsets for each row within the root signature.</param>
|
||||
public sealed record NonLinearMatrix(
|
||||
ImmutableArray<string> FieldPath,
|
||||
EquatableArray<string> FieldPath,
|
||||
string TypeName,
|
||||
string ElementName,
|
||||
int Rows,
|
||||
int Columns,
|
||||
ImmutableArray<int> Offsets) : FieldInfo
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public bool Equals(NonLinearMatrix? obj)
|
||||
{
|
||||
return Comparer.Default.Equals(this, obj);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Comparer.Default.GetHashCode(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An <see cref="IEqualityComparer{T}"/> implementation for <see cref="NonLinearMatrix"/>.
|
||||
/// </summary>
|
||||
private sealed class Comparer : Comparer<NonLinearMatrix, Comparer>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
protected override void AddToHashCode(ref HashCode hashCode, NonLinearMatrix obj)
|
||||
{
|
||||
hashCode.AddRange(obj.FieldPath);
|
||||
hashCode.Add(obj.TypeName);
|
||||
hashCode.Add(obj.ElementName);
|
||||
hashCode.Add(obj.Rows);
|
||||
hashCode.Add(obj.Columns);
|
||||
hashCode.AddRange(obj.Offsets);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override bool AreEqual(NonLinearMatrix x, NonLinearMatrix y)
|
||||
{
|
||||
return
|
||||
x.FieldPath.SequenceEqual(y.FieldPath) &&
|
||||
x.TypeName == y.TypeName &&
|
||||
x.ElementName == y.ElementName &&
|
||||
x.Rows == y.Rows &&
|
||||
x.Columns == y.Columns &&
|
||||
x.Offsets.SequenceEqual(y.Offsets);
|
||||
}
|
||||
}
|
||||
}
|
||||
EquatableArray<int> Offsets) : FieldInfo;
|
||||
}
|
||||
@@ -1,16 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Immutable;
|
||||
using System.Runtime.InteropServices;
|
||||
using ComputeSharp.SourceGeneration.Extensions;
|
||||
using ComputeSharp.SourceGeneration.Helpers;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
|
||||
namespace ComputeSharp.D2D1.SourceGenerators.Models;
|
||||
|
||||
/// <summary>
|
||||
/// A model for extracted info on a processed HLSL shader method.
|
||||
/// </summary>
|
||||
/// <param name="Modifiers">The modifiers for the annotated method.</param>
|
||||
/// <param name="Modifiers">The modifiers for the annotated method (these are <see cref="Microsoft.CodeAnalysis.CSharp.SyntaxKind"/> values, which can't be equated directly).</param>
|
||||
/// <param name="MethodName">The name of the annotated method.</param>
|
||||
/// <param name="InvalidReturnType">The fully qualified name of the return type, if invalid.</param>
|
||||
/// <param name="HlslSource">The HLSL source.</param>
|
||||
@@ -18,54 +13,10 @@ namespace ComputeSharp.D2D1.SourceGenerators.Models;
|
||||
/// <param name="CompileOptions">The compile options to use to compile the shader.</param>
|
||||
/// <param name="HasErrors">Whether any errors have been detected, and therefore the shader compilation should be skipped.</param>
|
||||
internal sealed record HlslShaderMethodSourceInfo(
|
||||
ImmutableArray<SyntaxKind> Modifiers,
|
||||
EquatableArray<ushort> Modifiers,
|
||||
string MethodName,
|
||||
string? InvalidReturnType,
|
||||
string HlslSource,
|
||||
D2D1ShaderProfile ShaderProfile,
|
||||
D2D1CompileOptions CompileOptions,
|
||||
bool HasErrors)
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public bool Equals(HlslShaderMethodSourceInfo? obj)
|
||||
{
|
||||
return Comparer.Default.Equals(this, obj);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Comparer.Default.GetHashCode(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An <see cref="IEqualityComparer{T}"/> implementation for <see cref="HlslShaderMethodSourceInfo"/>.
|
||||
/// </summary>
|
||||
private sealed class Comparer : Comparer<HlslShaderMethodSourceInfo, Comparer>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
protected override void AddToHashCode(ref HashCode hashCode, HlslShaderMethodSourceInfo obj)
|
||||
{
|
||||
hashCode.AddRange(obj.Modifiers);
|
||||
hashCode.Add(obj.MethodName);
|
||||
hashCode.Add(obj.InvalidReturnType);
|
||||
hashCode.Add(obj.HlslSource);
|
||||
hashCode.Add(obj.ShaderProfile);
|
||||
hashCode.Add(obj.CompileOptions);
|
||||
hashCode.Add(obj.HasErrors);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override bool AreEqual(HlslShaderMethodSourceInfo x, HlslShaderMethodSourceInfo y)
|
||||
{
|
||||
return
|
||||
MemoryMarshal.Cast<SyntaxKind, ushort>(x.Modifiers.AsSpan()).SequenceEqual(MemoryMarshal.Cast<SyntaxKind, ushort>(y.Modifiers.AsSpan())) &&
|
||||
x.MethodName == y.MethodName &&
|
||||
x.InvalidReturnType == y.InvalidReturnType &&
|
||||
x.HlslSource == y.HlslSource &&
|
||||
x.ShaderProfile == y.ShaderProfile &&
|
||||
x.CompileOptions == y.CompileOptions &&
|
||||
x.HasErrors == y.HasErrors;
|
||||
}
|
||||
}
|
||||
}
|
||||
bool HasErrors);
|
||||
@@ -1,6 +1,3 @@
|
||||
using System;
|
||||
using System.Collections.Immutable;
|
||||
using ComputeSharp.SourceGeneration.Extensions;
|
||||
using ComputeSharp.SourceGeneration.Helpers;
|
||||
|
||||
namespace ComputeSharp.D2D1.SourceGenerators.Models;
|
||||
@@ -9,35 +6,4 @@ namespace ComputeSharp.D2D1.SourceGenerators.Models;
|
||||
/// A model representing gathered input descriptions for a shader.
|
||||
/// </summary>
|
||||
/// <param name="InputDescriptions">The input descriptions for a given shader.</param>
|
||||
internal sealed record InputDescriptionsInfo(ImmutableArray<InputDescription> InputDescriptions)
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public bool Equals(InputDescriptionsInfo? obj)
|
||||
{
|
||||
return Comparer.Default.Equals(this, obj);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Comparer.Default.GetHashCode(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An <see cref="IEqualityComparer{T}"/> implementation for <see cref="InputDescriptionsInfo"/>.
|
||||
/// </summary>
|
||||
private sealed class Comparer : Comparer<InputDescriptionsInfo, Comparer>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
protected override void AddToHashCode(ref HashCode hashCode, InputDescriptionsInfo obj)
|
||||
{
|
||||
hashCode.AddRange(obj.InputDescriptions);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override bool AreEqual(InputDescriptionsInfo x, InputDescriptionsInfo y)
|
||||
{
|
||||
return x.InputDescriptions.SequenceEqual(y.InputDescriptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
internal sealed record InputDescriptionsInfo(EquatableArray<InputDescription> InputDescriptions);
|
||||
@@ -1,7 +1,3 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using ComputeSharp.SourceGeneration.Extensions;
|
||||
using ComputeSharp.SourceGeneration.Helpers;
|
||||
|
||||
namespace ComputeSharp.D2D1.SourceGenerators.Models;
|
||||
@@ -10,35 +6,4 @@ namespace ComputeSharp.D2D1.SourceGenerators.Models;
|
||||
/// A model representing gathered info on a shader input types.
|
||||
/// </summary>
|
||||
/// <param name="InputTypes">The input types for a given shader.</param>
|
||||
internal sealed record InputTypesInfo(ImmutableArray<uint> InputTypes)
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public bool Equals(InputTypesInfo? obj)
|
||||
{
|
||||
return Comparer.Default.Equals(this, obj);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Comparer.Default.GetHashCode(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An <see cref="IEqualityComparer{T}"/> implementation for <see cref="InputTypesInfo"/>.
|
||||
/// </summary>
|
||||
private sealed class Comparer : Comparer<InputTypesInfo, Comparer>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
protected override void AddToHashCode(ref HashCode hashCode, InputTypesInfo obj)
|
||||
{
|
||||
hashCode.AddRange(obj.InputTypes);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override bool AreEqual(InputTypesInfo x, InputTypesInfo y)
|
||||
{
|
||||
return x.InputTypes.SequenceEqual(y.InputTypes);
|
||||
}
|
||||
}
|
||||
}
|
||||
internal sealed record InputTypesInfo(EquatableArray<uint> InputTypes);
|
||||
@@ -1,6 +1,3 @@
|
||||
using System;
|
||||
using System.Collections.Immutable;
|
||||
using ComputeSharp.SourceGeneration.Extensions;
|
||||
using ComputeSharp.SourceGeneration.Helpers;
|
||||
|
||||
namespace ComputeSharp.D2D1.SourceGenerators.Models;
|
||||
@@ -9,35 +6,4 @@ namespace ComputeSharp.D2D1.SourceGenerators.Models;
|
||||
/// A model representing gathered resource texture descriptions for a shader.
|
||||
/// </summary>
|
||||
/// <param name="ResourceTextureDescriptions">The resource textures for the current shader.</param>
|
||||
internal sealed record ResourceTextureDescriptionsInfo(ImmutableArray<ResourceTextureDescription> ResourceTextureDescriptions)
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public bool Equals(ResourceTextureDescriptionsInfo? obj)
|
||||
{
|
||||
return Comparer.Default.Equals(this, obj);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Comparer.Default.GetHashCode(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An <see cref="IEqualityComparer{T}"/> implementation for <see cref="ResourceTextureDescriptionsInfo"/>.
|
||||
/// </summary>
|
||||
private sealed class Comparer : Comparer<ResourceTextureDescriptionsInfo, Comparer>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
protected override void AddToHashCode(ref HashCode hashCode, ResourceTextureDescriptionsInfo obj)
|
||||
{
|
||||
hashCode.AddRange(obj.ResourceTextureDescriptions);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override bool AreEqual(ResourceTextureDescriptionsInfo x, ResourceTextureDescriptionsInfo y)
|
||||
{
|
||||
return x.ResourceTextureDescriptions.SequenceEqual(y.ResourceTextureDescriptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
internal sealed record ResourceTextureDescriptionsInfo(EquatableArray<ResourceTextureDescription> ResourceTextureDescriptions);
|
||||
@@ -70,6 +70,15 @@ internal readonly struct EquatableArray<T> : IEquatable<EquatableArray<T>>, IEnu
|
||||
get => AsImmutableArray().IsEmpty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the current array is default or empty.
|
||||
/// </summary>
|
||||
public bool IsDefaultOrEmpty
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => AsImmutableArray().IsDefaultOrEmpty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the length of the current array.
|
||||
/// </summary>
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする