using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using ComputeSharp.SourceGeneration.Extensions;
using ComputeSharp.SourceGeneration.Helpers;
namespace ComputeSharp.D2D1.SourceGenerators.Models;
///
/// A model representing gathered info on a shader dispatch data.
///
/// The description on shader instance fields.
/// The size of the shader constant buffer.
internal sealed record DispatchDataInfo(ImmutableArray FieldInfos, int ConstantBufferSizeInBytes)
{
///
public bool Equals(DispatchDataInfo? obj) => Comparer.Default.Equals(this, obj);
///
public override int GetHashCode() => Comparer.Default.GetHashCode(this);
///
/// An implementation for .
///
private sealed class Comparer : Comparer
{
///
protected override void AddToHashCode(ref HashCode hashCode, DispatchDataInfo obj)
{
hashCode.AddRange(obj.FieldInfos);
hashCode.Add(obj.ConstantBufferSizeInBytes);
}
///
protected override bool AreEqual(DispatchDataInfo x, DispatchDataInfo y)
{
return
x.FieldInfos.SequenceEqual(y.FieldInfos) &&
x.ConstantBufferSizeInBytes == y.ConstantBufferSizeInBytes;
}
}
}