Ryujinx-uplift/src/Ryujinx.Graphics.GAL/ResourceLayout.cs

210 lines
5.6 KiB
C#
Raw Normal View History

using System;
using System.Collections.ObjectModel;
namespace Ryujinx.Graphics.GAL
{
public enum ResourceType : byte
{
UniformBuffer,
StorageBuffer,
Texture,
Sampler,
TextureAndSampler,
Image,
BufferTexture,
[Ryujinx.Graphics.GAL] Address dotnet-format issues (#5366) * dotnet format style --severity info Some changes were manually reverted. * dotnet format analyzers --serverity info Some changes have been minimally adapted. * Restore a few unused methods and variables * Silence dotnet format IDE0052 warnings * Address dotnet format CA1816 warnings * Address or silence dotnet format CA1069 warnings * Address remaining dotnet format analyzer warnings * Address review comments * Address most dotnet format whitespace warnings * Apply dotnet format whitespace formatting A few of them have been manually reverted and the corresponding warning was silenced * Revert formatting changes for while and for-loops * Another rebase, another dotnet format run * Run dotnet format whitespace after rebase * Run dotnet format style after rebase * Run dotnet format analyzers after rebase * Run dotnet format after rebase and remove unused usings - analyzers - style - whitespace * Disable 'prefer switch expression' rule * Add comments to disabled warnings * Simplify properties and array initialization, Use const when possible, Remove trailing commas * Start working on disabled warnings * Address IDE0251 warnings * Revert "Simplify properties and array initialization, Use const when possible, Remove trailing commas" This reverts commit 9462e4136c0a2100dc28b20cf9542e06790aa67e. * dotnet format whitespace after rebase * First dotnet format pass * Address review feedback * Add trailing commas * Remove SuppressMessage for IDE0066 * Make explicit Equals implementation implicit
2023-06-28 20:20:10 +02:00
BufferImage,
}
public enum ResourceAccess : byte
{
None = 0,
Read = 1,
Write = 2,
[Ryujinx.Graphics.GAL] Address dotnet-format issues (#5366) * dotnet format style --severity info Some changes were manually reverted. * dotnet format analyzers --serverity info Some changes have been minimally adapted. * Restore a few unused methods and variables * Silence dotnet format IDE0052 warnings * Address dotnet format CA1816 warnings * Address or silence dotnet format CA1069 warnings * Address remaining dotnet format analyzer warnings * Address review comments * Address most dotnet format whitespace warnings * Apply dotnet format whitespace formatting A few of them have been manually reverted and the corresponding warning was silenced * Revert formatting changes for while and for-loops * Another rebase, another dotnet format run * Run dotnet format whitespace after rebase * Run dotnet format style after rebase * Run dotnet format analyzers after rebase * Run dotnet format after rebase and remove unused usings - analyzers - style - whitespace * Disable 'prefer switch expression' rule * Add comments to disabled warnings * Simplify properties and array initialization, Use const when possible, Remove trailing commas * Start working on disabled warnings * Address IDE0251 warnings * Revert "Simplify properties and array initialization, Use const when possible, Remove trailing commas" This reverts commit 9462e4136c0a2100dc28b20cf9542e06790aa67e. * dotnet format whitespace after rebase * First dotnet format pass * Address review feedback * Add trailing commas * Remove SuppressMessage for IDE0066 * Make explicit Equals implementation implicit
2023-06-28 20:20:10 +02:00
ReadWrite = Read | Write,
}
[Flags]
public enum ResourceStages : byte
{
None = 0,
Compute = 1 << 0,
Vertex = 1 << 1,
TessellationControl = 1 << 2,
TessellationEvaluation = 1 << 3,
Geometry = 1 << 4,
[Ryujinx.Graphics.GAL] Address dotnet-format issues (#5366) * dotnet format style --severity info Some changes were manually reverted. * dotnet format analyzers --serverity info Some changes have been minimally adapted. * Restore a few unused methods and variables * Silence dotnet format IDE0052 warnings * Address dotnet format CA1816 warnings * Address or silence dotnet format CA1069 warnings * Address remaining dotnet format analyzer warnings * Address review comments * Address most dotnet format whitespace warnings * Apply dotnet format whitespace formatting A few of them have been manually reverted and the corresponding warning was silenced * Revert formatting changes for while and for-loops * Another rebase, another dotnet format run * Run dotnet format whitespace after rebase * Run dotnet format style after rebase * Run dotnet format analyzers after rebase * Run dotnet format after rebase and remove unused usings - analyzers - style - whitespace * Disable 'prefer switch expression' rule * Add comments to disabled warnings * Simplify properties and array initialization, Use const when possible, Remove trailing commas * Start working on disabled warnings * Address IDE0251 warnings * Revert "Simplify properties and array initialization, Use const when possible, Remove trailing commas" This reverts commit 9462e4136c0a2100dc28b20cf9542e06790aa67e. * dotnet format whitespace after rebase * First dotnet format pass * Address review feedback * Add trailing commas * Remove SuppressMessage for IDE0066 * Make explicit Equals implementation implicit
2023-06-28 20:20:10 +02:00
Fragment = 1 << 5,
}
public readonly struct ResourceDescriptor : IEquatable<ResourceDescriptor>
{
public int Binding { get; }
public int Count { get; }
public ResourceType Type { get; }
public ResourceStages Stages { get; }
public ResourceDescriptor(int binding, int count, ResourceType type, ResourceStages stages)
{
Binding = binding;
Count = count;
Type = type;
Stages = stages;
}
public override int GetHashCode()
{
return HashCode.Combine(Binding, Count, Type, Stages);
}
public override bool Equals(object obj)
{
return obj is ResourceDescriptor other && Equals(other);
}
public bool Equals(ResourceDescriptor other)
{
return Binding == other.Binding && Count == other.Count && Type == other.Type && Stages == other.Stages;
}
[Ryujinx.Graphics.GAL] Address dotnet-format issues (#5366) * dotnet format style --severity info Some changes were manually reverted. * dotnet format analyzers --serverity info Some changes have been minimally adapted. * Restore a few unused methods and variables * Silence dotnet format IDE0052 warnings * Address dotnet format CA1816 warnings * Address or silence dotnet format CA1069 warnings * Address remaining dotnet format analyzer warnings * Address review comments * Address most dotnet format whitespace warnings * Apply dotnet format whitespace formatting A few of them have been manually reverted and the corresponding warning was silenced * Revert formatting changes for while and for-loops * Another rebase, another dotnet format run * Run dotnet format whitespace after rebase * Run dotnet format style after rebase * Run dotnet format analyzers after rebase * Run dotnet format after rebase and remove unused usings - analyzers - style - whitespace * Disable 'prefer switch expression' rule * Add comments to disabled warnings * Simplify properties and array initialization, Use const when possible, Remove trailing commas * Start working on disabled warnings * Address IDE0251 warnings * Revert "Simplify properties and array initialization, Use const when possible, Remove trailing commas" This reverts commit 9462e4136c0a2100dc28b20cf9542e06790aa67e. * dotnet format whitespace after rebase * First dotnet format pass * Address review feedback * Add trailing commas * Remove SuppressMessage for IDE0066 * Make explicit Equals implementation implicit
2023-06-28 20:20:10 +02:00
public static bool operator ==(ResourceDescriptor left, ResourceDescriptor right)
{
return left.Equals(right);
}
public static bool operator !=(ResourceDescriptor left, ResourceDescriptor right)
{
return !(left == right);
}
}
public readonly struct ResourceUsage : IEquatable<ResourceUsage>
{
public int Binding { get; }
public ResourceType Type { get; }
public ResourceStages Stages { get; }
public ResourceAccess Access { get; }
public ResourceUsage(int binding, ResourceType type, ResourceStages stages, ResourceAccess access)
{
Binding = binding;
Type = type;
Stages = stages;
Access = access;
}
public override int GetHashCode()
{
return HashCode.Combine(Binding, Type, Stages, Access);
}
public override bool Equals(object obj)
{
return obj is ResourceUsage other && Equals(other);
}
public bool Equals(ResourceUsage other)
{
return Binding == other.Binding && Type == other.Type && Stages == other.Stages && Access == other.Access;
}
[Ryujinx.Graphics.GAL] Address dotnet-format issues (#5366) * dotnet format style --severity info Some changes were manually reverted. * dotnet format analyzers --serverity info Some changes have been minimally adapted. * Restore a few unused methods and variables * Silence dotnet format IDE0052 warnings * Address dotnet format CA1816 warnings * Address or silence dotnet format CA1069 warnings * Address remaining dotnet format analyzer warnings * Address review comments * Address most dotnet format whitespace warnings * Apply dotnet format whitespace formatting A few of them have been manually reverted and the corresponding warning was silenced * Revert formatting changes for while and for-loops * Another rebase, another dotnet format run * Run dotnet format whitespace after rebase * Run dotnet format style after rebase * Run dotnet format analyzers after rebase * Run dotnet format after rebase and remove unused usings - analyzers - style - whitespace * Disable 'prefer switch expression' rule * Add comments to disabled warnings * Simplify properties and array initialization, Use const when possible, Remove trailing commas * Start working on disabled warnings * Address IDE0251 warnings * Revert "Simplify properties and array initialization, Use const when possible, Remove trailing commas" This reverts commit 9462e4136c0a2100dc28b20cf9542e06790aa67e. * dotnet format whitespace after rebase * First dotnet format pass * Address review feedback * Add trailing commas * Remove SuppressMessage for IDE0066 * Make explicit Equals implementation implicit
2023-06-28 20:20:10 +02:00
public static bool operator ==(ResourceUsage left, ResourceUsage right)
{
return left.Equals(right);
}
public static bool operator !=(ResourceUsage left, ResourceUsage right)
{
return !(left == right);
}
}
public readonly struct ResourceDescriptorCollection
{
public ReadOnlyCollection<ResourceDescriptor> Descriptors { get; }
public ResourceDescriptorCollection(ReadOnlyCollection<ResourceDescriptor> descriptors)
{
Descriptors = descriptors;
}
public override int GetHashCode()
{
[Ryujinx.Graphics.GAL] Address dotnet-format issues (#5366) * dotnet format style --severity info Some changes were manually reverted. * dotnet format analyzers --serverity info Some changes have been minimally adapted. * Restore a few unused methods and variables * Silence dotnet format IDE0052 warnings * Address dotnet format CA1816 warnings * Address or silence dotnet format CA1069 warnings * Address remaining dotnet format analyzer warnings * Address review comments * Address most dotnet format whitespace warnings * Apply dotnet format whitespace formatting A few of them have been manually reverted and the corresponding warning was silenced * Revert formatting changes for while and for-loops * Another rebase, another dotnet format run * Run dotnet format whitespace after rebase * Run dotnet format style after rebase * Run dotnet format analyzers after rebase * Run dotnet format after rebase and remove unused usings - analyzers - style - whitespace * Disable 'prefer switch expression' rule * Add comments to disabled warnings * Simplify properties and array initialization, Use const when possible, Remove trailing commas * Start working on disabled warnings * Address IDE0251 warnings * Revert "Simplify properties and array initialization, Use const when possible, Remove trailing commas" This reverts commit 9462e4136c0a2100dc28b20cf9542e06790aa67e. * dotnet format whitespace after rebase * First dotnet format pass * Address review feedback * Add trailing commas * Remove SuppressMessage for IDE0066 * Make explicit Equals implementation implicit
2023-06-28 20:20:10 +02:00
HashCode hasher = new();
if (Descriptors != null)
{
foreach (var descriptor in Descriptors)
{
hasher.Add(descriptor);
}
}
return hasher.ToHashCode();
}
public override bool Equals(object obj)
{
return obj is ResourceDescriptorCollection other && Equals(other);
}
public bool Equals(ResourceDescriptorCollection other)
{
if ((Descriptors == null) != (other.Descriptors == null))
{
return false;
}
if (Descriptors != null)
{
if (Descriptors.Count != other.Descriptors.Count)
{
return false;
}
for (int index = 0; index < Descriptors.Count; index++)
{
if (!Descriptors[index].Equals(other.Descriptors[index]))
{
return false;
}
}
}
return true;
}
[Ryujinx.Graphics.GAL] Address dotnet-format issues (#5366) * dotnet format style --severity info Some changes were manually reverted. * dotnet format analyzers --serverity info Some changes have been minimally adapted. * Restore a few unused methods and variables * Silence dotnet format IDE0052 warnings * Address dotnet format CA1816 warnings * Address or silence dotnet format CA1069 warnings * Address remaining dotnet format analyzer warnings * Address review comments * Address most dotnet format whitespace warnings * Apply dotnet format whitespace formatting A few of them have been manually reverted and the corresponding warning was silenced * Revert formatting changes for while and for-loops * Another rebase, another dotnet format run * Run dotnet format whitespace after rebase * Run dotnet format style after rebase * Run dotnet format analyzers after rebase * Run dotnet format after rebase and remove unused usings - analyzers - style - whitespace * Disable 'prefer switch expression' rule * Add comments to disabled warnings * Simplify properties and array initialization, Use const when possible, Remove trailing commas * Start working on disabled warnings * Address IDE0251 warnings * Revert "Simplify properties and array initialization, Use const when possible, Remove trailing commas" This reverts commit 9462e4136c0a2100dc28b20cf9542e06790aa67e. * dotnet format whitespace after rebase * First dotnet format pass * Address review feedback * Add trailing commas * Remove SuppressMessage for IDE0066 * Make explicit Equals implementation implicit
2023-06-28 20:20:10 +02:00
public static bool operator ==(ResourceDescriptorCollection left, ResourceDescriptorCollection right)
{
return left.Equals(right);
}
public static bool operator !=(ResourceDescriptorCollection left, ResourceDescriptorCollection right)
{
return !(left == right);
}
}
public readonly struct ResourceUsageCollection
{
public ReadOnlyCollection<ResourceUsage> Usages { get; }
public ResourceUsageCollection(ReadOnlyCollection<ResourceUsage> usages)
{
Usages = usages;
}
}
public readonly struct ResourceLayout
{
public ReadOnlyCollection<ResourceDescriptorCollection> Sets { get; }
public ReadOnlyCollection<ResourceUsageCollection> SetUsages { get; }
public ResourceLayout(
ReadOnlyCollection<ResourceDescriptorCollection> sets,
ReadOnlyCollection<ResourceUsageCollection> setUsages)
{
Sets = sets;
SetUsages = setUsages;
}
}
}