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 a shared and its compiled bytecode, if available.
///
/// The HLSL source for the shader.
/// The shader profile to use to compile the shader, if requested.
/// The compile options to use to compile the shader.
/// The compiled shader bytecode, if available.
internal sealed record EmbeddedBytecodeInfo(string HlslSource, D2D1ShaderProfile? ShaderProfile, D2D1CompileOptions? CompileOptions, ImmutableArray Bytecode)
{
///
/// An implementation for .
///
public sealed class Comparer : Comparer
{
///
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());
}
///
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);
}
}
}