Switch [ShaderMethod] generator to incremental

このコミットが含まれているのは:
Sergio Pedri committed 2021-12-08 11:17:07 +01:00
1 親 6269267bf0
コミット d1fabb6fed
7ファイル変更
+236 -173

検索条件に一致するファイルはありません

+73
ファイルの表示
@@ -0,0 +1,73 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using ComputeSharp.SourceGenerators.Extensions;
namespace ComputeSharp.SourceGenerators.Models;
/// <summary>
/// A model for extracted info on a processed HLSL method.
/// </summary>
/// <param name="MetadataName">The metadata name for the method.</param>
/// <param name="EntryPoint">The meethod entry point.</param>
/// <param name="DefinedTypes">The discovered declared types.</param>
/// <param name="DefinedConstants">The discovered defined constants.</param>
/// <param name="DependentMethods">The dependent captured methods.</param>
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)
{
/// <summary>
/// An <see cref="IEqualityComparer{T}"/> implementation for <see cref="HlslMethodSourceInfo"/>.
/// </summary>
public sealed class Comparer : IEqualityComparer<HlslMethodSourceInfo>
{
/// <summary>
/// The singleton <see cref="Comparer"/> instance.
/// </summary>
public static Comparer Default { get; } = new();
/// <inheritdoc/>
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);
}
/// <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();
}
}
}
@@ -22,7 +22,7 @@ namespace ComputeSharp.SourceGenerators.Models;
/// <param name="DefinedConstants">The names of defined constants.</param>
/// <param name="MethodSignatures">The signatures for captured methods.</param>
/// <param name="Delegates">The list of delegate fields.</param>
internal sealed record HlslSourceInfo(
internal sealed record HlslShaderSourceInfo(
string HeaderAndThreadsX,
string ThreadsY,
string ThreadsZ,
@@ -39,9 +39,9 @@ internal sealed record HlslSourceInfo(
ImmutableArray<string> Delegates)
{
/// <summary>
/// An <see cref="IEqualityComparer{T}"/> implementation for <see cref="HlslSourceInfo"/>.
/// An <see cref="IEqualityComparer{T}"/> implementation for <see cref="HlslShaderSourceInfo"/>.
/// </summary>
public sealed class Comparer : IEqualityComparer<HlslSourceInfo>
public sealed class Comparer : IEqualityComparer<HlslShaderSourceInfo>
{
/// <summary>
/// The singleton <see cref="Comparer"/> instance.
@@ -49,7 +49,7 @@ internal sealed record HlslSourceInfo(
public static Comparer Default { get; } = new();
/// <inheritdoc/>
public bool Equals(HlslSourceInfo? x, HlslSourceInfo? y)
public bool Equals(HlslShaderSourceInfo? x, HlslShaderSourceInfo? y)
{
if (x is null && y is null)
{
@@ -84,7 +84,7 @@ internal sealed record HlslSourceInfo(
}
/// <inheritdoc/>
public int GetHashCode(HlslSourceInfo obj)
public int GetHashCode(HlslShaderSourceInfo obj)
{
HashCode hashCode = default;