Switch LoadDispatchMetadata() to incremental
このコミットが含まれているのは:
1 親
f2a556e63b
コミット
c6172032bd
5ファイル変更
+326
-1
検索条件に一致するファイルはありません
@@ -0,0 +1,65 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using ComputeSharp.SourceGenerators.Extensions;
|
||||
|
||||
namespace ComputeSharp.SourceGenerators.Models;
|
||||
|
||||
/// <summary>
|
||||
/// A model containing info on shader dispatch metadata.
|
||||
/// </summary>
|
||||
/// <param name="Root32BitConstantCount">The size of the shader root signature, in 32 bit constants.</param>
|
||||
/// <param name="IsSamplerUsed">Whether or not the static sampler is used.</param>
|
||||
/// <param name="ResourceDescriptors">The sequence of resource descriptors for the shader.</param>
|
||||
internal sealed record DispatchMetadataInfo(
|
||||
int Root32BitConstantCount,
|
||||
bool IsSamplerUsed,
|
||||
ImmutableArray<ResourceDescriptor> ResourceDescriptors)
|
||||
{
|
||||
/// <summary>
|
||||
/// An <see cref="IEqualityComparer{T}"/> implementation for <see cref="DispatchMetadataInfo"/>.
|
||||
/// </summary>
|
||||
public sealed class Comparer : IEqualityComparer<DispatchMetadataInfo>
|
||||
{
|
||||
/// <summary>
|
||||
/// The singleton <see cref="Comparer"/> instance.
|
||||
/// </summary>
|
||||
public static Comparer Default { get; } = new();
|
||||
|
||||
/// <inheritdoc/>
|
||||
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);
|
||||
}
|
||||
|
||||
/// <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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ComputeSharp.SourceGenerators.Models;
|
||||
|
||||
/// <summary>
|
||||
/// A resource descriptor for a captured resource in a shader.
|
||||
/// </summary>
|
||||
/// <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);
|
||||
}
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする