Revert "Structural and Memory Safety Improvements, Analyzer Cleanup (ryubing/ryujinx!47)"

This reverts merge request !47
This commit is contained in:
GreemDev 2025-06-15 20:45:26 -05:00
parent faf9e3cdd7
commit 77a797f154
307 changed files with 1245 additions and 1016 deletions

View file

@ -98,7 +98,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
/// </summary>
unsafe struct ComputeClassState
{
#pragma warning disable CS0649 // Field is never assigned to
public uint SetObject;
public readonly int SetObjectClassId => (int)(SetObject & 0xFFFF);
public readonly int SetObjectEngineId => (int)((SetObject >> 16) & 0x1F);
@ -430,6 +430,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
public readonly int StopShaderPerformanceCounterCounterMask => (int)(StopShaderPerformanceCounter & 0xFF);
public fixed uint Reserved33E8[6];
public Array256<uint> SetMmeShadowScratch;
#pragma warning restore CS0649
}
}

View file

@ -179,7 +179,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma
/// </summary>
unsafe struct DmaClassState
{
#pragma warning disable CS0649 // Field is never assigned to
public fixed uint Reserved00[64];
public uint Nop;
public fixed uint Reserved104[15];
@ -266,6 +266,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma
public fixed uint Reserved740[629];
public uint PmTriggerEnd;
public fixed uint Reserved1118[2490];
#pragma warning restore CS0649
}
}

View file

@ -7,7 +7,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma
/// </summary>
struct DmaTexture
{
#pragma warning disable CS0649 // Field is never assigned to
public MemoryLayout MemoryLayout;
public int Width;
public int Height;
@ -15,6 +15,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma
public int RegionZ;
public ushort RegionX;
public ushort RegionY;
#pragma warning restore CS0649
}
}

View file

@ -25,9 +25,9 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
struct CompressedMethod
{
#pragma warning disable CS0649 // Field is never assigned to
public uint Method;
#pragma warning restore CS0649
public readonly int MethodAddressOld => (int)((Method >> 2) & 0x7FF);
public readonly int MethodAddress => (int)(Method & 0xFFF);
public readonly int SubdeviceMask => (int)((Method >> 4) & 0xFFF);

View file

@ -36,15 +36,15 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
struct GPEntry
{
#pragma warning disable CS0649 // Field is never assigned to
public uint Entry0;
#pragma warning restore CS0649
public readonly Entry0Fetch Entry0Fetch => (Entry0Fetch)(Entry0 & 0x1);
public readonly int Entry0Get => (int)((Entry0 >> 2) & 0x3FFFFFFF);
public readonly int Entry0Operand => (int)(Entry0);
#pragma warning disable CS0649 // Field is never assigned to
public uint Entry1;
#pragma warning restore CS0649
public readonly int Entry1GetHi => (int)(Entry1 & 0xFF);
public readonly Entry1Priv Entry1Priv => (Entry1Priv)((Entry1 >> 8) & 0x1);
public readonly Entry1Level Entry1Level => (Entry1Level)((Entry1 >> 9) & 0x1);

View file

@ -151,7 +151,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
/// </summary>
struct GPFifoClassState
{
#pragma warning disable CS0649 // Field is never assigned to
public uint SetObject;
public readonly int SetObjectNvclass => (int)(SetObject & 0xFFFF);
public readonly int SetObjectEngine => (int)((SetObject >> 16) & 0x1F);
@ -228,6 +228,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
public uint LoadMmeStartAddressRamPointer;
public uint LoadMmeStartAddressRam;
public uint SetMmeShadowRamControl;
#pragma warning restore CS0649
}
}

View file

@ -113,7 +113,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.InlineToMemory
/// </summary>
unsafe struct InlineToMemoryClassState
{
#pragma warning disable CS0649 // Field is never assigned to
public uint SetObject;
public readonly int SetObjectClassId => (int)(SetObject & 0xFFFF);
public readonly int SetObjectEngineId => (int)((SetObject >> 16) & 0x1F);
@ -178,6 +178,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.InlineToMemory
public uint SetI2mSpareNoop03;
public fixed uint Reserved200[3200];
public Array256<uint> SetMmeShadowScratch;
#pragma warning restore CS0649
}
}

View file

@ -469,11 +469,12 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
for (int i = 0; i < maxDrawCount; i++)
{
FifoWord count = FetchParam();
_ = FetchParam(); // Instance count
#pragma warning disable IDE0059 // Remove unnecessary value assignment
FifoWord instanceCount = FetchParam();
FifoWord firstIndex = FetchParam();
_ = FetchParam(); // First vertex
_ = FetchParam(); // First instance
FifoWord firstVertex = FetchParam();
FifoWord firstInstance = FetchParam();
#pragma warning restore IDE0059
if (i == 0)
{

View file

@ -9,7 +9,9 @@ namespace Ryujinx.Graphics.Gpu.Engine
[StructLayout(LayoutKind.Sequential, Size = 1024)]
struct MmeShadowScratch
{
#pragma warning disable CS0169 // The private field is never used
private uint _e0;
#pragma warning restore CS0169
public ref uint this[int index] => ref AsSpan()[index];
public Span<uint> AsSpan() => MemoryMarshal.CreateSpan(ref _e0, 256);
}

View file

@ -16,8 +16,9 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
private int _inlineIndexBufferSize;
private int _inlineIndexCount;
private uint[] _buffer;
#pragma warning disable IDE0051 // Remove unused private member
private readonly int _bufferOffset;
#pragma warning restore IDE0051
/// <summary>
/// Indicates if any index buffer data has been pushed.

View file

@ -1,3 +1,5 @@
using System.Diagnostics.CodeAnalysis;
namespace Ryujinx.Graphics.Gpu.Engine.Threed
{
/// <summary>

View file

@ -26,8 +26,9 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct TessMode
{
#pragma warning disable CS0649 // Field is never assigned to
public uint Packed;
#pragma warning restore CS0649
/// <summary>
/// Unpacks the tessellation abstract patch type.
@ -62,7 +63,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct TfBufferState
{
#pragma warning disable CS0649 // Field is never assigned to
public Boolean32 Enable;
public GpuVa Address;
public int Size;
@ -70,7 +71,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
public uint Padding0;
public uint Padding1;
public uint Padding2;
#pragma warning restore CS0649
}
/// <summary>
@ -78,12 +79,12 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct TfState
{
#pragma warning disable CS0649 // Field is never assigned to
public int BufferIndex;
public int VaryingsCount;
public int Stride;
public uint Padding;
#pragma warning restore CS0649
}
/// <summary>
@ -91,7 +92,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct RtColorState
{
#pragma warning disable CS0649 // Field is never assigned to
public GpuVa Address;
public int WidthOrStride;
public int Height;
@ -107,7 +108,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
public int Padding3;
public int Padding4;
public int Padding5;
#pragma warning restore CS0649
}
/// <summary>
@ -115,7 +116,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct ViewportTransform
{
#pragma warning disable CS0649 // Field is never assigned to
public float ScaleX;
public float ScaleY;
public float ScaleZ;
@ -124,6 +125,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
public float TranslateZ;
public uint Swizzle;
public uint SubpixelPrecisionBias;
#pragma warning restore CS0649
/// <summary>
/// Unpacks viewport swizzle of the position X component.
@ -167,14 +169,14 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct ViewportExtents
{
#pragma warning disable CS0649 // Field is never assigned to
public ushort X;
public ushort Width;
public ushort Y;
public ushort Height;
public float DepthNear;
public float DepthFar;
#pragma warning restore CS0649
}
/// <summary>
@ -182,10 +184,10 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct VertexBufferDrawState
{
#pragma warning disable CS0649 // Field is never assigned to
public int First;
public int Count;
#pragma warning restore CS0649
}
/// <summary>
@ -193,12 +195,12 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct ClearColors
{
#pragma warning disable CS0649 // Field is never assigned to
public float Red;
public float Green;
public float Blue;
public float Alpha;
#pragma warning restore CS0649
}
/// <summary>
@ -206,11 +208,11 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct DepthBiasState
{
#pragma warning disable CS0649 // Field is never assigned to
public Boolean32 PointEnable;
public Boolean32 LineEnable;
public Boolean32 FillEnable;
#pragma warning restore CS0649
}
/// <summary>
@ -229,14 +231,14 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct ScissorState
{
#pragma warning disable CS0649 // Field is never assigned to
public Boolean32 Enable;
public ushort X1;
public ushort X2;
public ushort Y1;
public ushort Y2;
public uint Padding;
#pragma warning restore CS0649
}
/// <summary>
@ -244,11 +246,11 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct StencilBackMasks
{
#pragma warning disable CS0649 // Field is never assigned to
public int FuncRef;
public int Mask;
public int FuncMask;
#pragma warning restore CS0649
}
/// <summary>
@ -256,12 +258,12 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct RtDepthStencilState
{
#pragma warning disable CS0649 // Field is never assigned to
public GpuVa Address;
public ZetaFormat Format;
public MemoryLayout MemoryLayout;
public int LayerSize;
#pragma warning restore CS0649
}
/// <summary>
@ -269,12 +271,12 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct ScreenScissorState
{
#pragma warning disable CS0649 // Field is never assigned to
public ushort X;
public ushort Width;
public ushort Y;
public ushort Height;
#pragma warning restore CS0649
}
/// <summary>
@ -317,8 +319,9 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct VertexAttribState
{
#pragma warning disable CS0649 // Field is never assigned to
public uint Attribute;
#pragma warning restore CS0649
/// <summary>
/// Unpacks the index of the vertex buffer this attribute belongs to.
@ -380,8 +383,9 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct RtControl
{
#pragma warning disable CS0649 // Field is never assigned to
public uint Packed;
#pragma warning restore CS0649
/// <summary>
/// Unpacks the number of active draw buffers.
@ -408,7 +412,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct Size3D
{
#pragma warning disable CS0649 // Field is never assigned to
public int Width;
public int Height;
public ushort Depth;
@ -418,6 +422,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
{
return (Flags & 1) == 0;
}
#pragma warning restore CS0649
}
/// <summary>
@ -425,7 +430,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct StencilTestState
{
#pragma warning disable CS0649 // Field is never assigned to
public Boolean32 Enable;
public StencilOp FrontSFail;
public StencilOp FrontDpFail;
@ -434,7 +439,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
public int FrontFuncRef;
public int FrontFuncMask;
public int FrontMask;
#pragma warning restore CS0649
}
/// <summary>
@ -452,11 +457,12 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct RgbHalf
{
#pragma warning disable CS0649 // Field is never assigned to
public uint R;
public uint G;
public uint B;
public uint Padding;
#pragma warning restore CS0649
/// <summary>
/// Unpacks the red color component as a 16-bit float value.
@ -506,10 +512,10 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct PoolState
{
#pragma warning disable CS0649 // Field is never assigned to
public GpuVa Address;
public int MaximumId;
#pragma warning restore CS0649
}
/// <summary>
@ -517,13 +523,13 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct StencilBackTestState
{
#pragma warning disable CS0649 // Field is never assigned to
public Boolean32 TwoSided;
public StencilOp BackSFail;
public StencilOp BackDpFail;
public StencilOp BackDpPass;
public CompareOp BackFunc;
#pragma warning restore CS0649
}
/// <summary>
@ -531,10 +537,10 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct PrimitiveRestartState
{
#pragma warning disable CS0649 // Field is never assigned to
public Boolean32 Enable;
public int Index;
#pragma warning restore CS0649
}
/// <summary>
@ -543,12 +549,12 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct IndexBufferState
{
#pragma warning disable CS0649 // Field is never assigned to
public GpuVa Address;
public GpuVa EndAddress;
public IndexType Type;
public int First;
#pragma warning restore CS0649
}
/// <summary>
@ -556,11 +562,11 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct FaceState
{
#pragma warning disable CS0649 // Field is never assigned to
public Boolean32 CullEnable;
public FrontFace FrontFace;
public Face CullFace;
#pragma warning restore CS0649
}
/// <summary>
@ -578,10 +584,10 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct LogicalOpState
{
#pragma warning disable CS0649 // Field is never assigned to
public Boolean32 Enable;
public LogicalOp LogicalOp;
#pragma warning restore CS0649
}
/// <summary>
@ -639,10 +645,11 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct VertexBufferState
{
#pragma warning disable CS0649 // Field is never assigned to
public uint Control;
public GpuVa Address;
public int Divisor;
#pragma warning restore CS0649
/// <summary>
/// Vertex buffer stride, defined as the number of bytes occupied by each vertex in memory.
@ -668,7 +675,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct BlendStateCommon
{
#pragma warning disable CS0649 // Field is never assigned to
public Boolean32 SeparateAlpha;
public BlendOp ColorOp;
public BlendFactor ColorSrcFactor;
@ -677,7 +684,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
public BlendFactor AlphaSrcFactor;
public uint Unknown0x1354;
public BlendFactor AlphaDstFactor;
#pragma warning restore CS0649
}
/// <summary>
@ -685,7 +692,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct BlendState
{
#pragma warning disable CS0649 // Field is never assigned to
public Boolean32 SeparateAlpha;
public BlendOp ColorOp;
public BlendFactor ColorSrcFactor;
@ -694,7 +701,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
public BlendFactor AlphaSrcFactor;
public BlendFactor AlphaDstFactor;
public uint Padding;
#pragma warning restore CS0649
}
/// <summary>
@ -702,7 +709,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct ShaderState
{
#pragma warning disable CS0649 // Field is never assigned to
public uint Control;
public uint Offset;
public uint Unknown0x8;
@ -719,6 +726,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
public uint Unknown0x34;
public uint Unknown0x38;
public uint Unknown0x3c;
#pragma warning restore CS0649
/// <summary>
/// Unpacks shader enable information.
@ -736,16 +744,16 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct UniformBufferState
{
#pragma warning disable CS0649 // Field is never assigned to
public int Size;
public GpuVa Address;
public int Offset;
#pragma warning restore CS0649
}
unsafe struct ThreedClassState : IShadowState
{
#pragma warning disable CS0649 // Field is never assigned to
public uint SetObject;
public readonly int SetObjectClassId => (int)(SetObject & 0xFFFF);
public readonly int SetObjectEngineId => (int)((SetObject >> 16) & 0x1F);
@ -1044,6 +1052,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
public Array4<Array32<uint>> TfVaryingLocations;
public fixed uint Reserved2A00[640];
public Array256<uint> SetMmeShadowScratch;
#pragma warning restore CS0649
}
}

View file

@ -486,10 +486,10 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
/// </summary>
struct RenderSolidPrimPoint
{
#pragma warning disable CS0649 // Field is never assigned to
public uint SetX;
public uint Y;
#pragma warning restore CS0649
}
/// <summary>
@ -497,7 +497,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
/// </summary>
unsafe struct TwodClassState : IShadowState
{
#pragma warning disable CS0649 // Field is never assigned to
public uint SetObject;
public readonly int SetObjectClassId => (int)(SetObject & 0xFFFF);
public readonly int SetObjectEngineId => (int)((SetObject >> 16) & 0x1F);
@ -811,6 +811,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
public readonly bool MmeDmaWriteMethodBarrierV => (MmeDmaWriteMethodBarrier & 0x1) != 0;
public fixed uint ReservedDF0[2436];
public Array256<uint> SetMmeShadowScratch;
#pragma warning restore CS0649
}
}

View file

@ -7,7 +7,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
/// </summary>
struct TwodTexture
{
#pragma warning disable CS0649 // Field is never assigned to
public ColorFormat Format;
public Boolean32 LinearLayout;
public MemoryLayout MemoryLayout;
@ -17,6 +17,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
public int Width;
public int Height;
public GpuVa Address;
#pragma warning restore CS0649
}
}

View file

@ -5,9 +5,10 @@ namespace Ryujinx.Graphics.Gpu.Engine.Types
/// </summary>
struct GpuVa
{
#pragma warning disable CS0649 // Field is never assigned to
public uint High;
public uint Low;
#pragma warning restore CS0649
/// <summary>
/// Packs the split address into a 64-bits address value.

View file

@ -5,8 +5,9 @@ namespace Ryujinx.Graphics.Gpu.Engine.Types
/// </summary>
struct MemoryLayout
{
#pragma warning disable CS0649 // Field is never assigned to
public uint Packed;
#pragma warning restore CS0649
public readonly int UnpackGobBlocksInX()
{

View file

@ -5,11 +5,12 @@ namespace Ryujinx.Graphics.Gpu.Engine.Types
/// </summary>
struct SbDescriptor
{
#pragma warning disable CS0649 // Field is never assigned to
public uint AddressLow;
public uint AddressHigh;
public int Size;
public int Padding;
#pragma warning restore CS0649
public readonly ulong PackAddress()
{