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

See merge request ryubing/ryujinx!47
This commit is contained in:
MrKev 2025-06-11 17:58:27 -05:00 committed by LotP
parent d03ae9c164
commit ea027d65a7
309 changed files with 1018 additions and 1247 deletions

View file

@ -14,7 +14,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions
{
_infoTable = new InstInfo[(int)Instruction.Count];
#pragma warning disable IDE0055 // Disable formatting
#pragma warning disable IDE0055 // Disable formatting
Add(Instruction.AtomicAdd, InstType.AtomicBinary, "atomicAdd");
Add(Instruction.AtomicAnd, InstType.AtomicBinary, "atomicAnd");
Add(Instruction.AtomicCompareAndSwap, InstType.AtomicTernary, "atomicCompSwap");

View file

@ -1,5 +1,4 @@
using System;
using System.Diagnostics.CodeAnalysis;
namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions
{

View file

@ -5,11 +5,10 @@ using Spv.Generator;
using System;
using System.Collections.Generic;
using Instruction = Spv.Generator.Instruction;
using IrOperandType = Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandType;
namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
{
using IrOperandType = IntermediateRepresentation.OperandType;
partial class CodeGenContext : Module
{
private const uint SpirvVersionMajor = 1;

View file

@ -6,12 +6,11 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using static Spv.Specification;
using SpvInstruction = Spv.Generator.Instruction;
using SpvLiteralInteger = Spv.Generator.LiteralInteger;
namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
{
using SpvInstruction = Spv.Generator.Instruction;
using SpvLiteralInteger = Spv.Generator.LiteralInteger;
static class Instructions
{
private const MemorySemanticsMask DefaultMemorySemantics =
@ -27,7 +26,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
{
_instTable = new Func<CodeGenContext, AstOperation, OperationResult>[(int)Instruction.Count];
#pragma warning disable IDE0055 // Disable formatting
#pragma warning disable IDE0055 // Disable formatting
Add(Instruction.Absolute, GenerateAbsolute);
Add(Instruction.Add, GenerateAdd);
Add(Instruction.AtomicAdd, GenerateAtomicAdd);

View file

@ -6,14 +6,13 @@ using System;
using System.Collections.Generic;
using System.Threading;
using static Spv.Specification;
using SpvInstruction = Spv.Generator.Instruction;
using SpvInstructionPool = Spv.Generator.GeneratorPool<Spv.Generator.Instruction>;
using SpvLiteralInteger = Spv.Generator.LiteralInteger;
using SpvLiteralIntegerPool = Spv.Generator.GeneratorPool<Spv.Generator.LiteralInteger>;
namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
{
using SpvInstruction = Spv.Generator.Instruction;
using SpvInstructionPool = Spv.Generator.GeneratorPool<Spv.Generator.Instruction>;
using SpvLiteralInteger = Spv.Generator.LiteralInteger;
using SpvLiteralIntegerPool = Spv.Generator.GeneratorPool<Spv.Generator.LiteralInteger>;
static class SpirvGenerator
{
// Resource pools for Spirv generation. Note: Increase count when more threads are being used.

View file

@ -3664,9 +3664,9 @@ namespace Ryujinx.Graphics.Shader.Decoders
readonly struct InstLepc
{
#pragma warning disable IDE0052 // Remove unread private member
private readonly ulong _opcode;
#pragma warning restore IDE0052
public InstLepc(ulong opcode) => _opcode = opcode;
}
@ -4181,9 +4181,9 @@ namespace Ryujinx.Graphics.Shader.Decoders
readonly struct InstRam
{
#pragma warning disable IDE0052 // Remove unread private member
private readonly ulong _opcode;
#pragma warning restore IDE0052
public InstRam(ulong opcode) => _opcode = opcode;
}
@ -4252,9 +4252,9 @@ namespace Ryujinx.Graphics.Shader.Decoders
readonly struct InstRtt
{
#pragma warning disable IDE0052 // Remove unread private member
private readonly ulong _opcode;
#pragma warning restore IDE0052
public InstRtt(ulong opcode) => _opcode = opcode;
}
@ -4270,9 +4270,9 @@ namespace Ryujinx.Graphics.Shader.Decoders
readonly struct InstSam
{
#pragma warning disable IDE0052 // Remove unread private member
private readonly ulong _opcode;
#pragma warning restore IDE0052
public InstSam(ulong opcode) => _opcode = opcode;
}

View file

@ -31,7 +31,7 @@ namespace Ryujinx.Graphics.Shader.Decoders
_opCodes = new TableEntry[1 << EncodingBits];
#region Instructions
#pragma warning disable IDE0055 // Disable formatting
#pragma warning disable IDE0055 // Disable formatting
Add("1110111110100xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", InstName.Al2p, InstEmit.Al2p, InstProps.Rd | InstProps.Ra);
Add("1110111111011xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", InstName.Ald, InstEmit.Ald, InstProps.Rd | InstProps.Ra);
Add("1110111111110xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", InstName.Ast, InstEmit.Ast, InstProps.Ra | InstProps.Rb2 | InstProps.Rc);

View file

@ -22,9 +22,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
public static void Depbar(EmitterContext context)
{
#pragma warning disable IDE0059 // Remove unnecessary value assignment
InstDepbar op = context.GetOp<InstDepbar>();
#pragma warning restore IDE0059
_ = context.GetOp<InstDepbar>();
// No operation.
}

View file

@ -510,9 +510,8 @@ namespace Ryujinx.Graphics.Shader.Instructions
aLow = context.BitwiseNot(aLow);
aHigh = context.BitwiseNot(aHigh);
#pragma warning disable IDE0059 // Remove unnecessary value assignment
aLow = AddWithCarry(context, aLow, Const(1), out Operand aLowCOut);
#pragma warning restore IDE0059
_ = AddWithCarry(context, aLow, Const(1), out Operand aLowCOut);
aHigh = context.IAdd(aHigh, aLowCOut);
}

View file

@ -219,9 +219,8 @@ namespace Ryujinx.Graphics.Shader.Instructions
else
{
res = context.ISubtract(srcA, srcB);
#pragma warning disable IDE0059 // Remove unnecessary value assignment
res = context.IAdd(res, context.BitwiseNot(GetCF()));
#pragma warning restore IDE0059
_ = context.IAdd(res, context.BitwiseNot(GetCF()));
switch (cond)
{

View file

@ -1,5 +1,4 @@
using System;
using System.Diagnostics.CodeAnalysis;
namespace Ryujinx.Graphics.Shader.IntermediateRepresentation
{

View file

@ -25,7 +25,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
{
_infoTbl = new InstInfo[(int)Instruction.Count];
#pragma warning disable IDE0055 // Disable formatting
#pragma warning disable IDE0055 // Disable formatting
// Inst Destination type Source 1 type Source 2 type Source 3 type Source 4 type
Add(Instruction.AtomicAdd, AggregateType.U32, AggregateType.S32, AggregateType.S32, AggregateType.U32);
Add(Instruction.AtomicAnd, AggregateType.U32, AggregateType.S32, AggregateType.S32, AggregateType.U32);

View file

@ -52,7 +52,7 @@ namespace Ryujinx.Graphics.Shader
{
return format switch
{
#pragma warning disable IDE0055 // Disable formatting
#pragma warning disable IDE0055 // Disable formatting
TextureFormat.R8Unorm => "r8",
TextureFormat.R8Snorm => "r8_snorm",
TextureFormat.R8Uint => "r8ui",

View file

@ -1,5 +1,4 @@
using System;
using System.Diagnostics.CodeAnalysis;
namespace Ryujinx.Graphics.Shader.Translation
{

View file

@ -103,7 +103,7 @@ namespace Ryujinx.Graphics.Shader.Translation
this.BranchIfFalse(lblVertexInBounds, isVertexOob);
this.Return();
this.MarkLabel(lblVertexInBounds);
MarkLabel(lblVertexInBounds);
Operand outputInstanceOffset = this.Load(StorageKind.Input, IoVariable.GlobalId, Const(1));
Operand instanceCount = this.Load(StorageKind.ConstantBuffer, vertexInfoCbBinding, Const((int)VertexInfoBufferField.VertexCounts), Const(1));
@ -116,7 +116,7 @@ namespace Ryujinx.Graphics.Shader.Translation
this.BranchIfFalse(lblInstanceInBounds, isInstanceOob);
this.Return();
this.MarkLabel(lblInstanceInBounds);
MarkLabel(lblInstanceInBounds);
if (TranslatorContext.Stage == ShaderStage.Vertex)
{
@ -469,7 +469,7 @@ namespace Ryujinx.Graphics.Shader.Translation
this.BranchIfTrue(alphaPassLabel, alphaPass);
this.Discard();
this.MarkLabel(alphaPassLabel);
MarkLabel(alphaPassLabel);
}
}
@ -556,7 +556,7 @@ namespace Ryujinx.Graphics.Shader.Translation
Operand lblLoopHead = Label();
Operand lblExit = Label();
this.MarkLabel(lblLoopHead);
MarkLabel(lblLoopHead);
Operand writtenIndices = this.Load(StorageKind.LocalMemory, ResourceManager.LocalGeometryOutputIndexCountMemoryId);
@ -581,7 +581,7 @@ namespace Ryujinx.Graphics.Shader.Translation
this.Branch(lblLoopHead);
this.MarkLabel(lblExit);
MarkLabel(lblExit);
}
}
@ -617,7 +617,7 @@ namespace Ryujinx.Graphics.Shader.Translation
this.BranchIfTrue(a2cDitherEndLabel, opaque);
this.Discard();
this.MarkLabel(a2cDitherEndLabel);
MarkLabel(a2cDitherEndLabel);
}
public Operation[] GetOperations()