mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-12-22 23:35:32 +00:00
Make structs readonly when applicable (#4002)
* Make all structs readonly when applicable. It should reduce amount of needless defensive copies * Make structs with trivial boilerplate equality code record structs * Remove unnecessary readonly modifiers from TextureCreateInfo * Make BitMap structs readonly too
This commit is contained in:
parent
ae13f0ab4d
commit
4da44e09cb
|
@ -89,6 +89,7 @@ csharp_style_conditional_delegate_call = true:suggestion
|
||||||
# Modifier preferences
|
# Modifier preferences
|
||||||
csharp_prefer_static_local_function = true:suggestion
|
csharp_prefer_static_local_function = true:suggestion
|
||||||
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:silent
|
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:silent
|
||||||
|
csharp_style_prefer_readonly_struct = true
|
||||||
|
|
||||||
# Code-block preferences
|
# Code-block preferences
|
||||||
csharp_prefer_braces = true:silent
|
csharp_prefer_braces = true:silent
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
namespace ARMeilleure.CodeGen.RegisterAllocators
|
namespace ARMeilleure.CodeGen.RegisterAllocators
|
||||||
{
|
{
|
||||||
struct AllocationResult
|
readonly struct AllocationResult
|
||||||
{
|
{
|
||||||
public int IntUsedRegisters { get; }
|
public int IntUsedRegisters { get; }
|
||||||
public int VecUsedRegisters { get; }
|
public int VecUsedRegisters { get; }
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace ARMeilleure.CodeGen.RegisterAllocators
|
||||||
{
|
{
|
||||||
private class ParallelCopy
|
private class ParallelCopy
|
||||||
{
|
{
|
||||||
private struct Copy
|
private readonly struct Copy
|
||||||
{
|
{
|
||||||
public Register Dest { get; }
|
public Register Dest { get; }
|
||||||
public Register Source { get; }
|
public Register Source { get; }
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace ARMeilleure.CodeGen.RegisterAllocators
|
||||||
{
|
{
|
||||||
class HybridAllocator : IRegisterAllocator
|
class HybridAllocator : IRegisterAllocator
|
||||||
{
|
{
|
||||||
private struct BlockInfo
|
private readonly struct BlockInfo
|
||||||
{
|
{
|
||||||
public bool HasCall { get; }
|
public bool HasCall { get; }
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ using System;
|
||||||
|
|
||||||
namespace ARMeilleure.CodeGen.RegisterAllocators
|
namespace ARMeilleure.CodeGen.RegisterAllocators
|
||||||
{
|
{
|
||||||
struct RegisterMasks
|
readonly struct RegisterMasks
|
||||||
{
|
{
|
||||||
public int IntAvailableRegisters { get; }
|
public int IntAvailableRegisters { get; }
|
||||||
public int VecAvailableRegisters { get; }
|
public int VecAvailableRegisters { get; }
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
namespace ARMeilleure.CodeGen.X86
|
namespace ARMeilleure.CodeGen.X86
|
||||||
{
|
{
|
||||||
struct IntrinsicInfo
|
readonly struct IntrinsicInfo
|
||||||
{
|
{
|
||||||
public X86Instruction Inst { get; }
|
public X86Instruction Inst { get; }
|
||||||
public IntrinsicType Type { get; }
|
public IntrinsicType Type { get; }
|
||||||
|
|
|
@ -2,7 +2,7 @@ using ARMeilleure.Instructions;
|
||||||
|
|
||||||
namespace ARMeilleure.Decoders
|
namespace ARMeilleure.Decoders
|
||||||
{
|
{
|
||||||
struct InstDescriptor
|
readonly struct InstDescriptor
|
||||||
{
|
{
|
||||||
public static InstDescriptor Undefined => new InstDescriptor(InstName.Und, InstEmit.Und);
|
public static InstDescriptor Undefined => new InstDescriptor(InstName.Und, InstEmit.Und);
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace ARMeilleure.Decoders
|
||||||
|
|
||||||
private const int FastLookupSize = 0x1000;
|
private const int FastLookupSize = 0x1000;
|
||||||
|
|
||||||
private struct InstInfo
|
private readonly struct InstInfo
|
||||||
{
|
{
|
||||||
public int Mask { get; }
|
public int Mask { get; }
|
||||||
public int Value { get; }
|
public int Value { get; }
|
||||||
|
|
|
@ -6,7 +6,7 @@ namespace ARMeilleure.Diagnostics
|
||||||
{
|
{
|
||||||
static class Symbols
|
static class Symbols
|
||||||
{
|
{
|
||||||
private struct RangedSymbol
|
private readonly struct RangedSymbol
|
||||||
{
|
{
|
||||||
public readonly ulong Start;
|
public readonly ulong Start;
|
||||||
public readonly ulong End;
|
public readonly ulong End;
|
||||||
|
|
|
@ -3,7 +3,7 @@ using static ARMeilleure.IntermediateRepresentation.Operand.Factory;
|
||||||
|
|
||||||
namespace ARMeilleure.IntermediateRepresentation
|
namespace ARMeilleure.IntermediateRepresentation
|
||||||
{
|
{
|
||||||
struct PhiOperation
|
readonly struct PhiOperation
|
||||||
{
|
{
|
||||||
private readonly Operation _operation;
|
private readonly Operation _operation;
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ using System;
|
||||||
|
|
||||||
namespace ARMeilleure.IntermediateRepresentation
|
namespace ARMeilleure.IntermediateRepresentation
|
||||||
{
|
{
|
||||||
struct Register : IEquatable<Register>
|
readonly struct Register : IEquatable<Register>
|
||||||
{
|
{
|
||||||
public int Index { get; }
|
public int Index { get; }
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ using System.Diagnostics.CodeAnalysis;
|
||||||
|
|
||||||
namespace ARMeilleure.Translation.Cache
|
namespace ARMeilleure.Translation.Cache
|
||||||
{
|
{
|
||||||
struct CacheEntry : IComparable<CacheEntry>
|
readonly struct CacheEntry : IComparable<CacheEntry>
|
||||||
{
|
{
|
||||||
public int Offset { get; }
|
public int Offset { get; }
|
||||||
public int Size { get; }
|
public int Size { get; }
|
||||||
|
|
|
@ -6,7 +6,7 @@ namespace ARMeilleure.Translation.Cache
|
||||||
{
|
{
|
||||||
class CacheMemoryAllocator
|
class CacheMemoryAllocator
|
||||||
{
|
{
|
||||||
private struct MemoryBlock : IComparable<MemoryBlock>
|
private readonly struct MemoryBlock : IComparable<MemoryBlock>
|
||||||
{
|
{
|
||||||
public int Offset { get; }
|
public int Offset { get; }
|
||||||
public int Size { get; }
|
public int Size { get; }
|
||||||
|
|
|
@ -2,7 +2,7 @@ using ARMeilleure.IntermediateRepresentation;
|
||||||
|
|
||||||
namespace ARMeilleure.Translation
|
namespace ARMeilleure.Translation
|
||||||
{
|
{
|
||||||
struct CompilerContext
|
readonly struct CompilerContext
|
||||||
{
|
{
|
||||||
public ControlFlowGraph Cfg { get; }
|
public ControlFlowGraph Cfg { get; }
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace ARMeilleure.Translation
|
||||||
private const int RegsCount = 32;
|
private const int RegsCount = 32;
|
||||||
private const int RegsMask = RegsCount - 1;
|
private const int RegsMask = RegsCount - 1;
|
||||||
|
|
||||||
private struct RegisterMask : IEquatable<RegisterMask>
|
private readonly struct RegisterMask : IEquatable<RegisterMask>
|
||||||
{
|
{
|
||||||
public long IntMask => Mask.GetElement(0);
|
public long IntMask => Mask.GetElement(0);
|
||||||
public long VecMask => Mask.GetElement(1);
|
public long VecMask => Mask.GetElement(1);
|
||||||
|
|
|
@ -293,7 +293,7 @@ namespace ARMeilleure.Translation
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private struct Range
|
private readonly struct Range
|
||||||
{
|
{
|
||||||
public ulong Start { get; }
|
public ulong Start { get; }
|
||||||
public ulong End { get; }
|
public ulong End { get; }
|
||||||
|
|
|
@ -4,7 +4,7 @@ using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace SoundIOSharp
|
namespace SoundIOSharp
|
||||||
{
|
{
|
||||||
public struct SoundIOChannelLayout
|
public readonly struct SoundIOChannelLayout
|
||||||
{
|
{
|
||||||
public static int BuiltInCount
|
public static int BuiltInCount
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
namespace SoundIOSharp
|
namespace SoundIOSharp
|
||||||
{
|
{
|
||||||
public struct SoundIOSampleRateRange
|
public readonly struct SoundIOSampleRateRange
|
||||||
{
|
{
|
||||||
internal SoundIOSampleRateRange(int min, int max)
|
internal SoundIOSampleRateRange(int min, int max)
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,7 +20,7 @@ namespace Ryujinx.Ava.Ui.Windows
|
||||||
|
|
||||||
private const int CutOffLuminosity = 64;
|
private const int CutOffLuminosity = 64;
|
||||||
|
|
||||||
private struct PaletteColor
|
private readonly struct PaletteColor
|
||||||
{
|
{
|
||||||
public int Qck { get; }
|
public int Qck { get; }
|
||||||
public byte R { get; }
|
public byte R { get; }
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace Ryujinx.Common.Logging
|
||||||
|
|
||||||
public static event EventHandler<LogEventArgs> Updated;
|
public static event EventHandler<LogEventArgs> Updated;
|
||||||
|
|
||||||
public struct Log
|
public readonly struct Log
|
||||||
{
|
{
|
||||||
internal readonly LogLevel Level;
|
internal readonly LogLevel Level;
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ namespace Ryujinx.Common.Memory
|
||||||
/// This is useful to keep the Array representation when possible to avoid copies.
|
/// This is useful to keep the Array representation when possible to avoid copies.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T">Element Type</typeparam>
|
/// <typeparam name="T">Element Type</typeparam>
|
||||||
public ref struct SpanOrArray<T> where T : unmanaged
|
public readonly ref struct SpanOrArray<T> where T : unmanaged
|
||||||
{
|
{
|
||||||
public readonly T[] Array;
|
public readonly T[] Array;
|
||||||
public readonly ReadOnlySpan<T> Span;
|
public readonly ReadOnlySpan<T> Span;
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace Ryujinx.Cpu
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Stores handlers for the various CPU exceptions.
|
/// Stores handlers for the various CPU exceptions.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public struct ExceptionCallbacks
|
public readonly struct ExceptionCallbacks
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handler for CPU interrupts triggered using <see cref="IExecutionContext.RequestInterrupt"/>.
|
/// Handler for CPU interrupts triggered using <see cref="IExecutionContext.RequestInterrupt"/>.
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Device
|
namespace Ryujinx.Graphics.Device
|
||||||
{
|
{
|
||||||
public struct RwCallback
|
public readonly struct RwCallback
|
||||||
{
|
{
|
||||||
public Action<int> Write { get; }
|
public Action<int> Write { get; }
|
||||||
public Func<int> Read { get; }
|
public Func<int> Read { get; }
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
namespace Ryujinx.Graphics.GAL
|
namespace Ryujinx.Graphics.GAL
|
||||||
{
|
{
|
||||||
public struct BlendDescriptor
|
public readonly struct BlendDescriptor
|
||||||
{
|
{
|
||||||
public bool Enable { get; }
|
public bool Enable { get; }
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
namespace Ryujinx.Graphics.GAL
|
namespace Ryujinx.Graphics.GAL
|
||||||
{
|
{
|
||||||
public struct BufferAssignment
|
public readonly struct BufferAssignment
|
||||||
{
|
{
|
||||||
public readonly int Binding;
|
public readonly int Binding;
|
||||||
public readonly BufferRange Range;
|
public readonly BufferRange Range;
|
||||||
|
|
|
@ -1,22 +1,14 @@
|
||||||
using System;
|
using System.Runtime.InteropServices;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.GAL
|
namespace Ryujinx.Graphics.GAL
|
||||||
{
|
{
|
||||||
[StructLayout(LayoutKind.Sequential, Size = 8)]
|
[StructLayout(LayoutKind.Sequential, Size = 8)]
|
||||||
public struct BufferHandle : IEquatable<BufferHandle>
|
public readonly record struct BufferHandle
|
||||||
{
|
{
|
||||||
private readonly ulong _value;
|
private readonly ulong _value;
|
||||||
|
|
||||||
public static BufferHandle Null => new BufferHandle(0);
|
public static BufferHandle Null => new BufferHandle(0);
|
||||||
|
|
||||||
private BufferHandle(ulong value) => _value = value;
|
private BufferHandle(ulong value) => _value = value;
|
||||||
|
|
||||||
public override bool Equals(object obj) => obj is BufferHandle handle && Equals(handle);
|
|
||||||
public bool Equals([AllowNull] BufferHandle other) => other._value == _value;
|
|
||||||
public override int GetHashCode() => _value.GetHashCode();
|
|
||||||
public static bool operator ==(BufferHandle left, BufferHandle right) => left.Equals(right);
|
|
||||||
public static bool operator !=(BufferHandle left, BufferHandle right) => !(left == right);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
namespace Ryujinx.Graphics.GAL
|
namespace Ryujinx.Graphics.GAL
|
||||||
{
|
{
|
||||||
public struct BufferRange
|
public readonly struct BufferRange
|
||||||
{
|
{
|
||||||
private static readonly BufferRange _empty = new BufferRange(BufferHandle.Null, 0, 0);
|
private static readonly BufferRange _empty = new BufferRange(BufferHandle.Null, 0, 0);
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ using Ryujinx.Graphics.Shader.Translation;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.GAL
|
namespace Ryujinx.Graphics.GAL
|
||||||
{
|
{
|
||||||
public struct Capabilities
|
public readonly struct Capabilities
|
||||||
{
|
{
|
||||||
public readonly TargetApi Api;
|
public readonly TargetApi Api;
|
||||||
public readonly string VendorName;
|
public readonly string VendorName;
|
||||||
|
|
|
@ -1,32 +1,4 @@
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.GAL
|
namespace Ryujinx.Graphics.GAL
|
||||||
{
|
{
|
||||||
public struct ColorF : IEquatable<ColorF>
|
public readonly record struct ColorF(float Red, float Green, float Blue, float Alpha);
|
||||||
{
|
|
||||||
public float Red { get; }
|
|
||||||
public float Green { get; }
|
|
||||||
public float Blue { get; }
|
|
||||||
public float Alpha { get; }
|
|
||||||
|
|
||||||
public ColorF(float red, float green, float blue, float alpha)
|
|
||||||
{
|
|
||||||
Red = red;
|
|
||||||
Green = green;
|
|
||||||
Blue = blue;
|
|
||||||
Alpha = alpha;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Equals(ColorF color) => Red == color.Red &&
|
|
||||||
Green == color.Green &&
|
|
||||||
Blue == color.Blue &&
|
|
||||||
Alpha == color.Alpha;
|
|
||||||
|
|
||||||
public override bool Equals(object obj) => (obj is ColorF color) && Equals(color);
|
|
||||||
|
|
||||||
public override int GetHashCode() => HashCode.Combine(Red, Green, Blue, Alpha);
|
|
||||||
|
|
||||||
public static bool operator ==(ColorF l, ColorF r) => l.Equals(r);
|
|
||||||
public static bool operator !=(ColorF l, ColorF r) => !l.Equals(r);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
namespace Ryujinx.Graphics.GAL
|
namespace Ryujinx.Graphics.GAL
|
||||||
{
|
{
|
||||||
public struct DepthTestDescriptor
|
public readonly struct DepthTestDescriptor
|
||||||
{
|
{
|
||||||
public bool TestEnable { get; }
|
public bool TestEnable { get; }
|
||||||
public bool WriteEnable { get; }
|
public bool WriteEnable { get; }
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
namespace Ryujinx.Graphics.GAL
|
namespace Ryujinx.Graphics.GAL
|
||||||
{
|
{
|
||||||
public struct DeviceInfo
|
public readonly struct DeviceInfo
|
||||||
{
|
{
|
||||||
public readonly string Id;
|
public readonly string Id;
|
||||||
public readonly string Vendor;
|
public readonly string Vendor;
|
||||||
|
|
|
@ -2,7 +2,7 @@ using Ryujinx.Common;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.GAL
|
namespace Ryujinx.Graphics.GAL
|
||||||
{
|
{
|
||||||
public struct Extents2D
|
public readonly struct Extents2D
|
||||||
{
|
{
|
||||||
public int X1 { get; }
|
public int X1 { get; }
|
||||||
public int Y1 { get; }
|
public int Y1 { get; }
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
namespace Ryujinx.Graphics.GAL
|
namespace Ryujinx.Graphics.GAL
|
||||||
{
|
{
|
||||||
public struct Extents2DF
|
public readonly struct Extents2DF
|
||||||
{
|
{
|
||||||
public float X1 { get; }
|
public float X1 { get; }
|
||||||
public float Y1 { get; }
|
public float Y1 { get; }
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
namespace Ryujinx.Graphics.GAL
|
namespace Ryujinx.Graphics.GAL
|
||||||
{
|
{
|
||||||
public struct HardwareInfo
|
public readonly struct HardwareInfo
|
||||||
{
|
{
|
||||||
public string GpuVendor { get; }
|
public string GpuVendor { get; }
|
||||||
public string GpuModel { get; }
|
public string GpuModel { get; }
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
namespace Ryujinx.Graphics.GAL
|
namespace Ryujinx.Graphics.GAL
|
||||||
{
|
{
|
||||||
public struct ImageCrop
|
public readonly struct ImageCrop
|
||||||
{
|
{
|
||||||
public int Left { get; }
|
public int Left { get; }
|
||||||
public int Right { get; }
|
public int Right { get; }
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
namespace Ryujinx.Graphics.GAL
|
namespace Ryujinx.Graphics.GAL
|
||||||
{
|
{
|
||||||
public struct MultisampleDescriptor
|
public readonly struct MultisampleDescriptor
|
||||||
{
|
{
|
||||||
public bool AlphaToCoverageEnable { get; }
|
public bool AlphaToCoverageEnable { get; }
|
||||||
public bool AlphaToCoverageDitherEnable { get; }
|
public bool AlphaToCoverageDitherEnable { get; }
|
||||||
|
|
|
@ -6,7 +6,7 @@ namespace Ryujinx.Graphics.GAL
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Descriptor for a pipeline buffer binding.
|
/// Descriptor for a pipeline buffer binding.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public struct BufferPipelineDescriptor
|
public readonly struct BufferPipelineDescriptor
|
||||||
{
|
{
|
||||||
public bool Enable { get; }
|
public bool Enable { get; }
|
||||||
public int Stride { get; }
|
public int Stride { get; }
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
namespace Ryujinx.Graphics.GAL
|
namespace Ryujinx.Graphics.GAL
|
||||||
{
|
{
|
||||||
public struct Rectangle<T> where T : unmanaged
|
public readonly struct Rectangle<T> where T : unmanaged
|
||||||
{
|
{
|
||||||
public T X { get; }
|
public T X { get; }
|
||||||
public T Y { get; }
|
public T Y { get; }
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
namespace Ryujinx.Graphics.GAL
|
namespace Ryujinx.Graphics.GAL
|
||||||
{
|
{
|
||||||
public struct SamplerCreateInfo
|
public readonly struct SamplerCreateInfo
|
||||||
{
|
{
|
||||||
public MinFilter MinFilter { get; }
|
public MinFilter MinFilter { get; }
|
||||||
public MagFilter MagFilter { get; }
|
public MagFilter MagFilter { get; }
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
namespace Ryujinx.Graphics.GAL
|
namespace Ryujinx.Graphics.GAL
|
||||||
{
|
{
|
||||||
public struct ScreenCaptureImageInfo
|
public readonly struct ScreenCaptureImageInfo
|
||||||
{
|
{
|
||||||
public ScreenCaptureImageInfo(int width, int height, bool isBgra, byte[] data, bool flipX, bool flipY)
|
public ScreenCaptureImageInfo(int width, int height, bool isBgra, byte[] data, bool flipX, bool flipY)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.GAL
|
namespace Ryujinx.Graphics.GAL
|
||||||
{
|
{
|
||||||
public struct ShaderBindings
|
public readonly struct ShaderBindings
|
||||||
{
|
{
|
||||||
public IReadOnlyCollection<int> UniformBufferBindings { get; }
|
public IReadOnlyCollection<int> UniformBufferBindings { get; }
|
||||||
public IReadOnlyCollection<int> StorageBufferBindings { get; }
|
public IReadOnlyCollection<int> StorageBufferBindings { get; }
|
||||||
|
|
|
@ -3,7 +3,7 @@ using Ryujinx.Graphics.Shader.Translation;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.GAL
|
namespace Ryujinx.Graphics.GAL
|
||||||
{
|
{
|
||||||
public struct ShaderSource
|
public readonly struct ShaderSource
|
||||||
{
|
{
|
||||||
public string Code { get; }
|
public string Code { get; }
|
||||||
public byte[] BinaryCode { get; }
|
public byte[] BinaryCode { get; }
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
namespace Ryujinx.Graphics.GAL
|
namespace Ryujinx.Graphics.GAL
|
||||||
{
|
{
|
||||||
public struct StencilTestDescriptor
|
public readonly struct StencilTestDescriptor
|
||||||
{
|
{
|
||||||
public bool TestEnable { get; }
|
public bool TestEnable { get; }
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ using System.Numerics;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.GAL
|
namespace Ryujinx.Graphics.GAL
|
||||||
{
|
{
|
||||||
public struct TextureCreateInfo : IEquatable<TextureCreateInfo>
|
public readonly struct TextureCreateInfo : IEquatable<TextureCreateInfo>
|
||||||
{
|
{
|
||||||
public int Width { get; }
|
public int Width { get; }
|
||||||
public int Height { get; }
|
public int Height { get; }
|
||||||
|
@ -62,42 +62,42 @@ namespace Ryujinx.Graphics.GAL
|
||||||
SwizzleA = swizzleA;
|
SwizzleA = swizzleA;
|
||||||
}
|
}
|
||||||
|
|
||||||
public readonly int GetMipSize(int level)
|
public int GetMipSize(int level)
|
||||||
{
|
{
|
||||||
return GetMipStride(level) * GetLevelHeight(level) * GetLevelDepth(level);
|
return GetMipStride(level) * GetLevelHeight(level) * GetLevelDepth(level);
|
||||||
}
|
}
|
||||||
|
|
||||||
public readonly int GetMipSize2D(int level)
|
public int GetMipSize2D(int level)
|
||||||
{
|
{
|
||||||
return GetMipStride(level) * GetLevelHeight(level);
|
return GetMipStride(level) * GetLevelHeight(level);
|
||||||
}
|
}
|
||||||
|
|
||||||
public readonly int GetMipStride(int level)
|
public int GetMipStride(int level)
|
||||||
{
|
{
|
||||||
return BitUtils.AlignUp(GetLevelWidth(level) * BytesPerPixel, 4);
|
return BitUtils.AlignUp(GetLevelWidth(level) * BytesPerPixel, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly int GetLevelWidth(int level)
|
private int GetLevelWidth(int level)
|
||||||
{
|
{
|
||||||
return BitUtils.DivRoundUp(GetLevelSize(Width, level), BlockWidth);
|
return BitUtils.DivRoundUp(GetLevelSize(Width, level), BlockWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly int GetLevelHeight(int level)
|
private int GetLevelHeight(int level)
|
||||||
{
|
{
|
||||||
return BitUtils.DivRoundUp(GetLevelSize(Height, level), BlockHeight);
|
return BitUtils.DivRoundUp(GetLevelSize(Height, level), BlockHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly int GetLevelDepth(int level)
|
private int GetLevelDepth(int level)
|
||||||
{
|
{
|
||||||
return Target == Target.Texture3D ? GetLevelSize(Depth, level) : GetLayers();
|
return Target == Target.Texture3D ? GetLevelSize(Depth, level) : GetLayers();
|
||||||
}
|
}
|
||||||
|
|
||||||
public readonly int GetDepthOrLayers()
|
public int GetDepthOrLayers()
|
||||||
{
|
{
|
||||||
return Target == Target.Texture3D ? Depth : GetLayers();
|
return Target == Target.Texture3D ? Depth : GetLayers();
|
||||||
}
|
}
|
||||||
|
|
||||||
public readonly int GetLayers()
|
public int GetLayers()
|
||||||
{
|
{
|
||||||
if (Target == Target.Texture2DArray ||
|
if (Target == Target.Texture2DArray ||
|
||||||
Target == Target.Texture2DMultisampleArray ||
|
Target == Target.Texture2DMultisampleArray ||
|
||||||
|
@ -113,7 +113,7 @@ namespace Ryujinx.Graphics.GAL
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public readonly int GetLevelsClamped()
|
public int GetLevelsClamped()
|
||||||
{
|
{
|
||||||
int maxSize = Width;
|
int maxSize = Width;
|
||||||
|
|
||||||
|
|
|
@ -1,40 +1,4 @@
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.GAL
|
namespace Ryujinx.Graphics.GAL
|
||||||
{
|
{
|
||||||
public struct VertexAttribDescriptor : IEquatable<VertexAttribDescriptor>
|
public readonly record struct VertexAttribDescriptor(int BufferIndex, int Offset, bool IsZero, Format Format);
|
||||||
{
|
|
||||||
public int BufferIndex { get; }
|
|
||||||
public int Offset { get; }
|
|
||||||
|
|
||||||
public bool IsZero { get; }
|
|
||||||
|
|
||||||
public Format Format { get; }
|
|
||||||
|
|
||||||
public VertexAttribDescriptor(int bufferIndex, int offset, bool isZero, Format format)
|
|
||||||
{
|
|
||||||
BufferIndex = bufferIndex;
|
|
||||||
Offset = offset;
|
|
||||||
IsZero = isZero;
|
|
||||||
Format = format;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool Equals(object obj)
|
|
||||||
{
|
|
||||||
return obj is VertexAttribDescriptor other && Equals(other);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Equals(VertexAttribDescriptor other)
|
|
||||||
{
|
|
||||||
return BufferIndex == other.BufferIndex &&
|
|
||||||
Offset == other.Offset &&
|
|
||||||
IsZero == other.IsZero &&
|
|
||||||
Format == other.Format;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override int GetHashCode()
|
|
||||||
{
|
|
||||||
return HashCode.Combine(BufferIndex, Offset, IsZero, Format);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
namespace Ryujinx.Graphics.GAL
|
namespace Ryujinx.Graphics.GAL
|
||||||
{
|
{
|
||||||
public struct VertexBufferDescriptor
|
public readonly struct VertexBufferDescriptor
|
||||||
{
|
{
|
||||||
public BufferRange Buffer { get; }
|
public BufferRange Buffer { get; }
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
namespace Ryujinx.Graphics.GAL
|
namespace Ryujinx.Graphics.GAL
|
||||||
{
|
{
|
||||||
public struct Viewport
|
public readonly struct Viewport
|
||||||
{
|
{
|
||||||
public Rectangle<float> Region { get; }
|
public Rectangle<float> Region { get; }
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// FIFO word.
|
/// FIFO word.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
struct FifoWord
|
readonly struct FifoWord
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// GPU virtual address where the word is located in memory.
|
/// GPU virtual address where the word is located in memory.
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Macroo High-level implementation table entry.
|
/// Macroo High-level implementation table entry.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
struct TableEntry
|
readonly struct TableEntry
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Name of the Macro function.
|
/// Name of the Macro function.
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// State update callback entry, with the callback function and associated field names.
|
/// State update callback entry, with the callback function and associated field names.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
struct StateUpdateCallbackEntry
|
readonly struct StateUpdateCallbackEntry
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Callback function, to be called if the register was written as the state needs to be updated.
|
/// Callback function, to be called if the register was written as the state needs to be updated.
|
||||||
|
|
|
@ -5,7 +5,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents texture format information.
|
/// Represents texture format information.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
struct FormatInfo
|
readonly struct FormatInfo
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A default, generic RGBA8 texture format.
|
/// A default, generic RGBA8 texture format.
|
||||||
|
|
|
@ -7,7 +7,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||||
/// Texture binding information.
|
/// Texture binding information.
|
||||||
/// This is used for textures that needs to be accessed from shaders.
|
/// This is used for textures that needs to be accessed from shaders.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
struct TextureBindingInfo
|
readonly struct TextureBindingInfo
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Shader sampler target type.
|
/// Shader sampler target type.
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||||
/// </summary>
|
/// </summary>
|
||||||
class TextureCache : IDisposable
|
class TextureCache : IDisposable
|
||||||
{
|
{
|
||||||
private struct OverlapInfo
|
private readonly struct OverlapInfo
|
||||||
{
|
{
|
||||||
public TextureViewCompatibility Compatibility { get; }
|
public TextureViewCompatibility Compatibility { get; }
|
||||||
public int FirstLayer { get; }
|
public int FirstLayer { get; }
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// An overlapping texture group with a given view compatibility.
|
/// An overlapping texture group with a given view compatibility.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
struct TextureIncompatibleOverlap
|
readonly struct TextureIncompatibleOverlap
|
||||||
{
|
{
|
||||||
public readonly TextureGroup Group;
|
public readonly TextureGroup Group;
|
||||||
public readonly TextureViewCompatibility Compatibility;
|
public readonly TextureViewCompatibility Compatibility;
|
||||||
|
|
|
@ -6,7 +6,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Texture information.
|
/// Texture information.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
struct TextureInfo
|
readonly struct TextureInfo
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Address of the texture in GPU mapped memory.
|
/// Address of the texture in GPU mapped memory.
|
||||||
|
|
|
@ -5,7 +5,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Memory range used for buffers.
|
/// Memory range used for buffers.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
struct BufferBounds
|
readonly struct BufferBounds
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Region virtual address.
|
/// Region virtual address.
|
||||||
|
|
|
@ -7,7 +7,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A buffer binding to apply to a buffer texture.
|
/// A buffer binding to apply to a buffer texture.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
struct BufferTextureBinding
|
readonly struct BufferTextureBinding
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Shader stage accessing the texture.
|
/// Shader stage accessing the texture.
|
||||||
|
|
|
@ -8,7 +8,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
||||||
/// </summary>
|
/// </summary>
|
||||||
class CounterCache
|
class CounterCache
|
||||||
{
|
{
|
||||||
private struct CounterEntry
|
private readonly struct CounterEntry
|
||||||
{
|
{
|
||||||
public ulong Address { get; }
|
public ulong Address { get; }
|
||||||
public ICounterEvent Event { get; }
|
public ICounterEvent Event { get; }
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents an operation to perform on the <see cref="_fileWriterWorkerQueue"/>.
|
/// Represents an operation to perform on the <see cref="_fileWriterWorkerQueue"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private struct CacheFileOperationTask
|
private readonly struct CacheFileOperationTask
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The type of operation to perform.
|
/// The type of operation to perform.
|
||||||
|
@ -46,7 +46,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Background shader cache write information.
|
/// Background shader cache write information.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private struct AddShaderData
|
private readonly struct AddShaderData
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Cached shader program.
|
/// Cached shader program.
|
||||||
|
|
|
@ -3,7 +3,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Guest shader code and constant buffer data accessed by the shader.
|
/// Guest shader code and constant buffer data accessed by the shader.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
struct GuestCodeAndCbData
|
readonly struct GuestCodeAndCbData
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Maxwell binary shader code.
|
/// Maxwell binary shader code.
|
||||||
|
|
|
@ -37,7 +37,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Program validation entry.
|
/// Program validation entry.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private struct ProgramEntry
|
private readonly struct ProgramEntry
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Cached shader program.
|
/// Cached shader program.
|
||||||
|
@ -90,7 +90,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Translated shader compilation entry.
|
/// Translated shader compilation entry.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private struct ProgramCompilation
|
private readonly struct ProgramCompilation
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Translated shader stages.
|
/// Translated shader stages.
|
||||||
|
@ -143,7 +143,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Program translation entry.
|
/// Program translation entry.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private struct AsyncProgramTranslation
|
private readonly struct AsyncProgramTranslation
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Guest code for each active stage.
|
/// Guest code for each active stage.
|
||||||
|
|
|
@ -3,7 +3,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// State used by the <see cref="GpuAccessor"/>.
|
/// State used by the <see cref="GpuAccessor"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
struct GpuChannelComputeState
|
readonly struct GpuChannelComputeState
|
||||||
{
|
{
|
||||||
// New fields should be added to the end of the struct to keep disk shader cache compatibility.
|
// New fields should be added to the end of the struct to keep disk shader cache compatibility.
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// State used by the <see cref="GpuAccessor"/>.
|
/// State used by the <see cref="GpuAccessor"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
struct GpuChannelPoolState : IEquatable<GpuChannelPoolState>
|
readonly struct GpuChannelPoolState : IEquatable<GpuChannelPoolState>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// GPU virtual address of the texture pool.
|
/// GPU virtual address of the texture pool.
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.HashTable
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Entry for a given data size.
|
/// Entry for a given data size.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private struct SizeEntry
|
private readonly struct SizeEntry
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Size for the data that will be stored on the hash table on this entry.
|
/// Size for the data that will be stored on the hash table on this entry.
|
||||||
|
|
|
@ -26,7 +26,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const TranslationFlags DefaultFlags = TranslationFlags.DebugMode;
|
public const TranslationFlags DefaultFlags = TranslationFlags.DebugMode;
|
||||||
|
|
||||||
private struct TranslatedShader
|
private readonly struct TranslatedShader
|
||||||
{
|
{
|
||||||
public readonly CachedShaderStage Shader;
|
public readonly CachedShaderStage Shader;
|
||||||
public readonly ShaderProgram Program;
|
public readonly ShaderProgram Program;
|
||||||
|
@ -38,7 +38,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private struct TranslatedShaderVertexPair
|
private readonly struct TranslatedShaderVertexPair
|
||||||
{
|
{
|
||||||
public readonly CachedShaderStage VertexA;
|
public readonly CachedShaderStage VertexA;
|
||||||
public readonly CachedShaderStage VertexB;
|
public readonly CachedShaderStage VertexB;
|
||||||
|
@ -59,7 +59,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
||||||
private readonly Dictionary<ulong, CachedShaderProgram> _cpPrograms;
|
private readonly Dictionary<ulong, CachedShaderProgram> _cpPrograms;
|
||||||
private readonly Dictionary<ShaderAddresses, CachedShaderProgram> _gpPrograms;
|
private readonly Dictionary<ShaderAddresses, CachedShaderProgram> _gpPrograms;
|
||||||
|
|
||||||
private struct ProgramToSave
|
private readonly struct ProgramToSave
|
||||||
{
|
{
|
||||||
public readonly CachedShaderProgram CachedProgram;
|
public readonly CachedShaderProgram CachedProgram;
|
||||||
public readonly IProgram HostProgram;
|
public readonly IProgram HostProgram;
|
||||||
|
|
|
@ -7,7 +7,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Shader code accessor.
|
/// Shader code accessor.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
struct ShaderCodeAccessor : IDataAccessor
|
readonly struct ShaderCodeAccessor : IDataAccessor
|
||||||
{
|
{
|
||||||
private readonly MemoryManager _memoryManager;
|
private readonly MemoryManager _memoryManager;
|
||||||
private readonly ulong _baseAddress;
|
private readonly ulong _baseAddress;
|
||||||
|
|
|
@ -5,7 +5,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Paths where shader code was dumped on disk.
|
/// Paths where shader code was dumped on disk.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
struct ShaderDumpPaths
|
readonly struct ShaderDumpPaths
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Path where the full shader code with header was dumped, or null if not dumped.
|
/// Path where the full shader code with header was dumped, or null if not dumped.
|
||||||
|
|
|
@ -121,7 +121,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Texture binding information, used to identify each texture accessed by the shader.
|
/// Texture binding information, used to identify each texture accessed by the shader.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private struct TextureKey : IEquatable<TextureKey>
|
private readonly record struct TextureKey
|
||||||
{
|
{
|
||||||
// New fields should be added to the end of the struct to keep disk shader cache compatibility.
|
// New fields should be added to the end of the struct to keep disk shader cache compatibility.
|
||||||
|
|
||||||
|
@ -152,21 +152,6 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
||||||
Handle = handle;
|
Handle = handle;
|
||||||
CbufSlot = cbufSlot;
|
CbufSlot = cbufSlot;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Equals(object obj)
|
|
||||||
{
|
|
||||||
return obj is TextureKey textureKey && Equals(textureKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Equals(TextureKey other)
|
|
||||||
{
|
|
||||||
return StageIndex == other.StageIndex && Handle == other.Handle && CbufSlot == other.CbufSlot;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override int GetHashCode()
|
|
||||||
{
|
|
||||||
return HashCode.Combine(StageIndex, Handle, CbufSlot);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly Dictionary<TextureKey, Box<TextureSpecializationState>> _textureSpecialization;
|
private readonly Dictionary<TextureKey, Box<TextureSpecializationState>> _textureSpecialization;
|
||||||
|
|
|
@ -20,7 +20,7 @@ namespace Ryujinx.Graphics.Gpu
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Texture presented on the window.
|
/// Texture presented on the window.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private struct PresentationTexture
|
private readonly struct PresentationTexture
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Texture cache where the texture might be located.
|
/// Texture cache where the texture might be located.
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace Ryujinx.Graphics.Host1x
|
||||||
{
|
{
|
||||||
public sealed class Host1xDevice : IDisposable
|
public sealed class Host1xDevice : IDisposable
|
||||||
{
|
{
|
||||||
private struct Command
|
private readonly struct Command
|
||||||
{
|
{
|
||||||
public int[] Buffer { get; }
|
public int[] Buffer { get; }
|
||||||
public long ContextId { get; }
|
public long ContextId { get; }
|
||||||
|
|
|
@ -7,7 +7,7 @@ namespace Ryujinx.Graphics.Host1x
|
||||||
{
|
{
|
||||||
private readonly SynchronizationManager _syncMgr;
|
private readonly SynchronizationManager _syncMgr;
|
||||||
|
|
||||||
private struct SyncptIncr
|
private readonly struct SyncptIncr
|
||||||
{
|
{
|
||||||
public uint Id { get; }
|
public uint Id { get; }
|
||||||
public ClassId ClassId { get; }
|
public ClassId ClassId { get; }
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
namespace Ryujinx.Graphics.Nvdec
|
namespace Ryujinx.Graphics.Nvdec
|
||||||
{
|
{
|
||||||
public struct FrameDecodedEventArgs
|
public readonly struct FrameDecodedEventArgs
|
||||||
{
|
{
|
||||||
public CodecId CodecId { get; }
|
public CodecId CodecId { get; }
|
||||||
public uint LumaOffset { get; }
|
public uint LumaOffset { get; }
|
||||||
|
|
|
@ -3,7 +3,7 @@ using Ryujinx.Graphics.Nvdec.Image;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Nvdec
|
namespace Ryujinx.Graphics.Nvdec
|
||||||
{
|
{
|
||||||
struct ResourceManager
|
readonly struct ResourceManager
|
||||||
{
|
{
|
||||||
public MemoryManager Gmm { get; }
|
public MemoryManager Gmm { get; }
|
||||||
public SurfaceCache Cache { get; }
|
public SurfaceCache Cache { get; }
|
||||||
|
|
|
@ -2,7 +2,7 @@ using OpenTK.Graphics.OpenGL;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.OpenGL
|
namespace Ryujinx.Graphics.OpenGL
|
||||||
{
|
{
|
||||||
struct FormatInfo
|
readonly struct FormatInfo
|
||||||
{
|
{
|
||||||
public int Components { get; }
|
public int Components { get; }
|
||||||
public bool Normalized { get; }
|
public bool Normalized { get; }
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions
|
namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions
|
||||||
{
|
{
|
||||||
struct InstInfo
|
readonly struct InstInfo
|
||||||
{
|
{
|
||||||
public InstType Type { get; }
|
public InstType Type { get; }
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
|
||||||
{
|
{
|
||||||
private static readonly string[] StagePrefixes = new string[] { "cp", "vp", "tcp", "tep", "gp", "fp" };
|
private static readonly string[] StagePrefixes = new string[] { "cp", "vp", "tcp", "tep", "gp", "fp" };
|
||||||
|
|
||||||
private struct BuiltInAttribute
|
private readonly struct BuiltInAttribute
|
||||||
{
|
{
|
||||||
public string Name { get; }
|
public string Name { get; }
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ using Spv.Generator;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
||||||
{
|
{
|
||||||
struct OperationResult
|
readonly struct OperationResult
|
||||||
{
|
{
|
||||||
public static OperationResult Invalid => new OperationResult(AggregateType.Invalid, null);
|
public static OperationResult Invalid => new OperationResult(AggregateType.Invalid, null);
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Delegate cache for SPIR-V instruction generators. Avoids delegate allocation when passing generators as arguments.
|
/// Delegate cache for SPIR-V instruction generators. Avoids delegate allocation when passing generators as arguments.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal struct SpirvDelegates
|
internal readonly struct SpirvDelegates
|
||||||
{
|
{
|
||||||
// Unary
|
// Unary
|
||||||
public readonly FuncUnaryInstruction GlslFAbs;
|
public readonly FuncUnaryInstruction GlslFAbs;
|
||||||
|
|
|
@ -1,33 +1,4 @@
|
||||||
using System;
|
namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
|
|
||||||
{
|
{
|
||||||
struct TextureMeta : IEquatable<TextureMeta>
|
readonly record struct TextureMeta(int CbufSlot, int Handle, TextureFormat Format);
|
||||||
{
|
|
||||||
public int CbufSlot { get; }
|
|
||||||
public int Handle { get; }
|
|
||||||
public TextureFormat Format { get; }
|
|
||||||
|
|
||||||
public TextureMeta(int cbufSlot, int handle, TextureFormat format)
|
|
||||||
{
|
|
||||||
CbufSlot = cbufSlot;
|
|
||||||
Handle = handle;
|
|
||||||
Format = format;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool Equals(object obj)
|
|
||||||
{
|
|
||||||
return obj is TextureMeta other && Equals(other);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Equals(TextureMeta other)
|
|
||||||
{
|
|
||||||
return CbufSlot == other.CbufSlot && Handle == other.Handle && Format == other.Format;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override int GetHashCode()
|
|
||||||
{
|
|
||||||
return HashCode.Combine(CbufSlot, Handle, Format);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -17,7 +17,7 @@ namespace Ryujinx.Graphics.Shader.Decoders
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct SyncTarget
|
readonly struct SyncTarget
|
||||||
{
|
{
|
||||||
public PushOpInfo PushOpInfo { get; }
|
public PushOpInfo PushOpInfo { get; }
|
||||||
public int PushOpId { get; }
|
public int PushOpId { get; }
|
||||||
|
|
|
@ -4,7 +4,7 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Shader.Decoders
|
namespace Ryujinx.Graphics.Shader.Decoders
|
||||||
{
|
{
|
||||||
struct DecodedProgram : IEnumerable<DecodedFunction>
|
readonly struct DecodedProgram : IEnumerable<DecodedFunction>
|
||||||
{
|
{
|
||||||
public DecodedFunction MainFunction { get; }
|
public DecodedFunction MainFunction { get; }
|
||||||
private readonly IReadOnlyDictionary<ulong, DecodedFunction> _functions;
|
private readonly IReadOnlyDictionary<ulong, DecodedFunction> _functions;
|
||||||
|
|
|
@ -473,7 +473,7 @@ namespace Ryujinx.Graphics.Shader.Decoders
|
||||||
op = Unsafe.As<ulong, T>(ref rawOp);
|
op = Unsafe.As<ulong, T>(ref rawOp);
|
||||||
}
|
}
|
||||||
|
|
||||||
private struct BlockLocation
|
private readonly struct BlockLocation
|
||||||
{
|
{
|
||||||
public Block Block { get; }
|
public Block Block { get; }
|
||||||
public int Index { get; }
|
public int Index { get; }
|
||||||
|
|
|
@ -6,7 +6,7 @@ namespace Ryujinx.Graphics.Shader.Decoders
|
||||||
{
|
{
|
||||||
private const int EncodingBits = 14;
|
private const int EncodingBits = 14;
|
||||||
|
|
||||||
private struct TableEntry
|
private readonly struct TableEntry
|
||||||
{
|
{
|
||||||
public InstName Name { get; }
|
public InstName Name { get; }
|
||||||
public InstEmitter Emitter { get; }
|
public InstEmitter Emitter { get; }
|
||||||
|
|
|
@ -2,7 +2,7 @@ using System;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Shader.Decoders
|
namespace Ryujinx.Graphics.Shader.Decoders
|
||||||
{
|
{
|
||||||
struct Register : IEquatable<Register>
|
readonly struct Register : IEquatable<Register>
|
||||||
{
|
{
|
||||||
public int Index { get; }
|
public int Index { get; }
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
|
||||||
{
|
{
|
||||||
static class InstructionInfo
|
static class InstructionInfo
|
||||||
{
|
{
|
||||||
private struct InstInfo
|
private readonly struct InstInfo
|
||||||
{
|
{
|
||||||
public VariableType DestType { get; }
|
public VariableType DestType { get; }
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Shader.StructuredIr
|
namespace Ryujinx.Graphics.Shader.StructuredIr
|
||||||
{
|
{
|
||||||
struct TransformFeedbackOutput
|
readonly struct TransformFeedbackOutput
|
||||||
{
|
{
|
||||||
public readonly bool Valid;
|
public readonly bool Valid;
|
||||||
public readonly int Buffer;
|
public readonly int Buffer;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Shader.Translation
|
namespace Ryujinx.Graphics.Shader.Translation
|
||||||
{
|
{
|
||||||
struct AttributeInfo
|
readonly struct AttributeInfo
|
||||||
{
|
{
|
||||||
private static readonly Dictionary<int, AttributeInfo> _builtInAttributes = new Dictionary<int, AttributeInfo>()
|
private static readonly Dictionary<int, AttributeInfo> _builtInAttributes = new Dictionary<int, AttributeInfo>()
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,7 +21,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||||
|
|
||||||
public int OperationsCount => _operations.Count;
|
public int OperationsCount => _operations.Count;
|
||||||
|
|
||||||
private struct BrxTarget
|
private readonly struct BrxTarget
|
||||||
{
|
{
|
||||||
public readonly Operand Selector;
|
public readonly Operand Selector;
|
||||||
public readonly int ExpectedValue;
|
public readonly int ExpectedValue;
|
||||||
|
|
|
@ -87,7 +87,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private struct TreeNodeUse
|
private readonly struct TreeNodeUse
|
||||||
{
|
{
|
||||||
public TreeNode Node { get; }
|
public TreeNode Node { get; }
|
||||||
public int Index { get; }
|
public int Index { get; }
|
||||||
|
@ -345,7 +345,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||||
bool Matches(in InstOp opInfo);
|
bool Matches(in InstOp opInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
private struct PatternTreeNodeUse
|
private readonly struct PatternTreeNodeUse
|
||||||
{
|
{
|
||||||
public IPatternTreeNode Node { get; }
|
public IPatternTreeNode Node { get; }
|
||||||
public int Index { get; }
|
public int Index { get; }
|
||||||
|
|
|
@ -114,7 +114,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct FunctionRegisterUsage
|
public readonly struct FunctionRegisterUsage
|
||||||
{
|
{
|
||||||
public Register[] InArguments { get; }
|
public Register[] InArguments { get; }
|
||||||
public Register[] OutArguments { get; }
|
public Register[] OutArguments { get; }
|
||||||
|
|
|
@ -69,36 +69,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||||
private int _usedStorageBuffers;
|
private int _usedStorageBuffers;
|
||||||
private int _usedStorageBuffersWrite;
|
private int _usedStorageBuffersWrite;
|
||||||
|
|
||||||
private struct TextureInfo : IEquatable<TextureInfo>
|
private readonly record struct TextureInfo(int CbufSlot, int Handle, bool Indexed, TextureFormat Format);
|
||||||
{
|
|
||||||
public int CbufSlot { get; }
|
|
||||||
public int Handle { get; }
|
|
||||||
public bool Indexed { get; }
|
|
||||||
public TextureFormat Format { get; }
|
|
||||||
|
|
||||||
public TextureInfo(int cbufSlot, int handle, bool indexed, TextureFormat format)
|
|
||||||
{
|
|
||||||
CbufSlot = cbufSlot;
|
|
||||||
Handle = handle;
|
|
||||||
Indexed = indexed;
|
|
||||||
Format = format;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool Equals(object obj)
|
|
||||||
{
|
|
||||||
return obj is TextureInfo other && Equals(other);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Equals(TextureInfo other)
|
|
||||||
{
|
|
||||||
return CbufSlot == other.CbufSlot && Handle == other.Handle && Indexed == other.Indexed && Format == other.Format;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override int GetHashCode()
|
|
||||||
{
|
|
||||||
return HashCode.Combine(CbufSlot, Handle, Indexed, Format);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private struct TextureMeta
|
private struct TextureMeta
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||||
ScreenLinear = 3
|
ScreenLinear = 3
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ImapPixelType
|
readonly struct ImapPixelType
|
||||||
{
|
{
|
||||||
public PixelImap X { get; }
|
public PixelImap X { get; }
|
||||||
public PixelImap Y { get; }
|
public PixelImap Y { get; }
|
||||||
|
|
|
@ -108,7 +108,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private struct Definition
|
private readonly struct Definition
|
||||||
{
|
{
|
||||||
public BasicBlock Block { get; }
|
public BasicBlock Block { get; }
|
||||||
public Operand Local { get; }
|
public Operand Local { get; }
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
namespace Ryujinx.Graphics.Shader.Translation
|
namespace Ryujinx.Graphics.Shader.Translation
|
||||||
{
|
{
|
||||||
public struct TranslationOptions
|
public readonly struct TranslationOptions
|
||||||
{
|
{
|
||||||
public TargetLanguage TargetLanguage { get; }
|
public TargetLanguage TargetLanguage { get; }
|
||||||
public TargetApi TargetApi { get; }
|
public TargetApi TargetApi { get; }
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||||
{
|
{
|
||||||
private const int HeaderSize = 0x50;
|
private const int HeaderSize = 0x50;
|
||||||
|
|
||||||
internal struct FunctionCode
|
internal readonly struct FunctionCode
|
||||||
{
|
{
|
||||||
public Operation[] Code { get; }
|
public Operation[] Code { get; }
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
namespace Ryujinx.Graphics.Texture
|
namespace Ryujinx.Graphics.Texture
|
||||||
{
|
{
|
||||||
public struct Region
|
public readonly struct Region
|
||||||
{
|
{
|
||||||
public int Offset { get; }
|
public int Offset { get; }
|
||||||
public int Size { get; }
|
public int Size { get; }
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
namespace Ryujinx.Graphics.Texture
|
namespace Ryujinx.Graphics.Texture
|
||||||
{
|
{
|
||||||
public struct Size
|
public readonly struct Size
|
||||||
{
|
{
|
||||||
public int Width { get; }
|
public int Width { get; }
|
||||||
public int Height { get; }
|
public int Height { get; }
|
||||||
|
|
|
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Texture
|
namespace Ryujinx.Graphics.Texture
|
||||||
{
|
{
|
||||||
public struct SizeInfo
|
public readonly struct SizeInfo
|
||||||
{
|
{
|
||||||
private readonly int[] _mipOffsets;
|
private readonly int[] _mipOffsets;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
namespace Ryujinx.Graphics.Texture.Utils
|
namespace Ryujinx.Graphics.Texture.Utils
|
||||||
{
|
{
|
||||||
struct BC7ModeInfo
|
readonly struct BC7ModeInfo
|
||||||
{
|
{
|
||||||
public readonly int SubsetCount;
|
public readonly int SubsetCount;
|
||||||
public readonly int PartitionBitCount;
|
public readonly int PartitionBitCount;
|
||||||
|
|
|
@ -3,7 +3,7 @@ using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Vic.Image
|
namespace Ryujinx.Graphics.Vic.Image
|
||||||
{
|
{
|
||||||
struct Surface : IDisposable
|
readonly struct Surface : IDisposable
|
||||||
{
|
{
|
||||||
private readonly int _bufferIndex;
|
private readonly int _bufferIndex;
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue