Ryujinx/Spv.Generator/TypeDeclarationKey.cs
riperiperi bf94f4c7d6 Some optimizations to Spv.Generator
- Dictionary for lookups of type declarations, constants, extinst
- LiteralInteger internal data format -> ushort
- Deterministic HashCode implementation to avoid spirv result not being the same between runs
- Inline operand list instead of List<T>, falls back to array if many operands. (large performance boost)

TODO: improve instruction allocation, structured program creator, ssa?
2022-06-17 22:42:43 +01:00

30 lines
903 B
C#

using System;
using System.Diagnostics.CodeAnalysis;
namespace Spv.Generator
{
internal struct TypeDeclarationKey : IEquatable<TypeDeclarationKey>
{
private Instruction _typeDeclaration;
public TypeDeclarationKey(Instruction typeDeclaration)
{
_typeDeclaration = typeDeclaration;
}
public override int GetHashCode()
{
return DeterministicHashCode.Combine(_typeDeclaration.Opcode, _typeDeclaration.GetHashCodeContent());
}
public bool Equals(TypeDeclarationKey other)
{
return _typeDeclaration.Opcode == other._typeDeclaration.Opcode && _typeDeclaration.EqualsContent(other._typeDeclaration);
}
public override bool Equals([NotNullWhen(true)] object obj)
{
return obj is TypeDeclarationKey && Equals((TypeDeclarationKey)obj);
}
}
}