From 9becbd7d728fc2002c176dfd9d1d1aae86f86b12 Mon Sep 17 00:00:00 2001 From: TSRBerry <20988865+TSRBerry@users.noreply.github.com> Date: Wed, 28 Jun 2023 08:59:13 +0200 Subject: [PATCH] [Ryujinx.Graphics.Shader] Address dotnet-format issues (#5373) * dotnet format style --severity info Some changes were manually reverted. * Restore a few unused methods and variables * Silence dotnet format IDE0060 warnings * Silence dotnet format IDE0052 warnings * Silence dotnet format IDE0059 warnings * Address or silence dotnet format CA1069 warnings * Address or silence dotnet format CA2211 warnings * Address review comments * Fix formatting for switch expressions * 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 * Format if-blocks correctly * Run dotnet format whitespace after rebase * Run dotnet format style after rebase * Run dotnet format whitespace after rebase * Run dotnet format style after rebase * Run dotnet format after rebase and remove unused usings - analyzers - style - whitespace * Disable 'prefer switch expression' rule * Add comments to disabled warnings * Fix naming rule violation, Convert shader properties to auto-property and convert values to const * Simplify properties and array initialization, Use const when possible, Remove trailing commas * Run dotnet format after rebase * Address IDE0251 warnings * Address a few disabled IDE0060 warnings * Silence IDE0060 in .editorconfig * Run dotnet format after rebase * 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 * Fix naming rule violations * Add trailing commas * Remove unused members and most unnecessary value assignments * Remove more unnecessary assignments * Remove NRE suppressor --- src/Ryujinx.Graphics.Shader/AlphaTestOp.cs | 4 +- src/Ryujinx.Graphics.Shader/AttributeType.cs | 8 +- .../BufferDescriptor.cs | 2 +- .../BufferUsageFlags.cs | 2 +- .../CodeGen/Glsl/CodeGenContext.cs | 2 +- .../CodeGen/Glsl/Declarations.cs | 24 +- .../CodeGen/Glsl/DefaultNames.cs | 4 +- .../CodeGen/Glsl/GlslGenerator.cs | 9 +- .../HelperFunctions/HelperFunctionNames.cs | 10 +- .../CodeGen/Glsl/Instructions/InstGen.cs | 2 +- .../Glsl/Instructions/InstGenBallot.cs | 2 +- .../CodeGen/Glsl/Instructions/InstGenCall.cs | 2 +- .../CodeGen/Glsl/Instructions/InstGenFSI.cs | 2 +- .../Glsl/Instructions/InstGenHelper.cs | 8 +- .../Glsl/Instructions/InstGenMemory.cs | 52 +- .../Glsl/Instructions/InstGenPacking.cs | 2 +- .../Glsl/Instructions/InstGenVector.cs | 2 +- .../CodeGen/Glsl/Instructions/InstInfo.cs | 6 +- .../CodeGen/Glsl/Instructions/InstType.cs | 32 +- .../CodeGen/Glsl/Instructions/IoMap.cs | 6 +- .../CodeGen/Glsl/NumberFormatter.cs | 2 +- .../CodeGen/Glsl/OperandManager.cs | 22 +- .../CodeGen/Glsl/TypeConversion.cs | 28 +- .../CodeGen/Spirv/CodeGenContext.cs | 31 +- .../CodeGen/Spirv/Declarations.cs | 21 +- .../CodeGen/Spirv/EnumConversion.cs | 2 +- .../CodeGen/Spirv/Instructions.cs | 124 +- .../CodeGen/Spirv/IoMap.cs | 12 +- .../CodeGen/Spirv/OperationResult.cs | 2 +- .../CodeGen/Spirv/SpirvGenerator.cs | 38 +- .../CodeGen/Spirv/TextureMeta.cs | 2 +- src/Ryujinx.Graphics.Shader/Constants.cs | 2 +- src/Ryujinx.Graphics.Shader/Decoders/Block.cs | 6 +- .../Decoders/DecodedFunction.cs | 2 +- .../Decoders/DecodedProgram.cs | 2 +- .../Decoders/Decoder.cs | 73 +- .../Decoders/InstDecoders.cs | 1180 +++++++++-------- .../Decoders/InstName.cs | 2 +- .../Decoders/InstOp.cs | 2 +- .../Decoders/InstProps.cs | 4 +- .../Decoders/InstTable.cs | 8 +- .../Decoders/Register.cs | 8 +- .../Decoders/RegisterConsts.cs | 6 +- .../Decoders/RegisterType.cs | 2 +- src/Ryujinx.Graphics.Shader/InputTopology.cs | 8 +- .../Instructions/AttributeMap.cs | 9 +- .../Instructions/InstEmit.cs | 102 +- .../Instructions/InstEmitAluHelper.cs | 17 +- .../Instructions/InstEmitAttribute.cs | 6 +- .../Instructions/InstEmitBarrier.cs | 4 +- .../Instructions/InstEmitBitfield.cs | 2 +- .../Instructions/InstEmitConditionCode.cs | 5 +- .../Instructions/InstEmitConversion.cs | 7 +- .../Instructions/InstEmitFloatArithmetic.cs | 5 +- .../Instructions/InstEmitFloatComparison.cs | 29 +- .../Instructions/InstEmitFloatMinMax.cs | 2 +- .../Instructions/InstEmitFlowControl.cs | 26 +- .../Instructions/InstEmitHelper.cs | 64 +- .../Instructions/InstEmitIntegerArithmetic.cs | 4 +- .../Instructions/InstEmitIntegerComparison.cs | 23 +- .../Instructions/InstEmitIntegerLogical.cs | 11 +- .../Instructions/InstEmitIntegerMinMax.cs | 2 +- .../Instructions/InstEmitMemory.cs | 47 +- .../Instructions/InstEmitMove.cs | 4 +- .../Instructions/InstEmitMultifunction.cs | 2 +- .../Instructions/InstEmitNop.cs | 4 +- .../Instructions/InstEmitPredicate.cs | 2 +- .../Instructions/InstEmitShift.cs | 2 +- .../Instructions/InstEmitSurface.cs | 41 +- .../Instructions/InstEmitTexture.cs | 21 +- .../Instructions/InstEmitVideoArithmetic.cs | 5 +- .../Instructions/InstEmitVideoMinMax.cs | 2 +- .../Instructions/InstEmitWarp.cs | 5 +- .../Instructions/InstEmitter.cs | 2 +- .../Instructions/Lop3Expression.cs | 49 +- .../IntermediateRepresentation/BasicBlock.cs | 6 +- .../IntermediateRepresentation/CommentNode.cs | 2 +- .../IntermediateRepresentation/Function.cs | 2 +- .../IntermediateRepresentation/INode.cs | 2 +- .../IntermediateRepresentation/Instruction.cs | 6 +- .../IntermediateRepresentation/IoVariable.cs | 4 +- .../IntermediateRepresentation/IrConsts.cs | 4 +- .../IntermediateRepresentation/Operand.cs | 10 +- .../OperandHelper.cs | 2 +- .../IntermediateRepresentation/OperandType.cs | 4 +- .../IntermediateRepresentation/Operation.cs | 4 +- .../IntermediateRepresentation/PhiNode.cs | 12 +- .../IntermediateRepresentation/StorageKind.cs | 4 +- .../TextureFlags.cs | 44 +- .../TextureOperation.cs | 2 +- src/Ryujinx.Graphics.Shader/OutputTopology.cs | 21 +- src/Ryujinx.Graphics.Shader/SamplerType.cs | 22 +- .../ShaderIdentification.cs | 4 +- src/Ryujinx.Graphics.Shader/ShaderProgram.cs | 2 +- .../ShaderProgramInfo.cs | 2 +- src/Ryujinx.Graphics.Shader/ShaderStage.cs | 4 +- .../StructuredIr/AstAssignment.cs | 4 +- .../StructuredIr/AstBlock.cs | 6 +- .../StructuredIr/AstBlockType.cs | 4 +- .../StructuredIr/AstBlockVisitor.cs | 2 +- .../StructuredIr/AstComment.cs | 2 +- .../StructuredIr/AstHelper.cs | 9 +- .../StructuredIr/AstNode.cs | 2 +- .../StructuredIr/AstOperand.cs | 6 +- .../StructuredIr/AstOperation.cs | 16 +- .../StructuredIr/AstOptimizer.cs | 8 +- .../StructuredIr/AstTextureOperation.cs | 2 +- .../StructuredIr/BufferDefinition.cs | 2 +- .../StructuredIr/BufferLayout.cs | 4 +- .../StructuredIr/GotoElimination.cs | 39 +- .../StructuredIr/GotoStatement.cs | 8 +- .../StructuredIr/HelperFunctionsMask.cs | 14 +- .../StructuredIr/IAstNode.cs | 2 +- .../StructuredIr/InstructionInfo.cs | 6 +- .../StructuredIr/IoDefinition.cs | 2 +- .../StructuredIr/MemoryDefinition.cs | 2 +- .../StructuredIr/OperandInfo.cs | 4 +- .../StructuredIr/PhiFunctions.cs | 4 +- .../StructuredIr/ShaderProperties.cs | 2 +- .../StructuredIr/StructureType.cs | 2 +- .../StructuredIr/StructuredFunction.cs | 2 +- .../StructuredIr/StructuredProgram.cs | 35 +- .../StructuredIr/StructuredProgramContext.cs | 15 +- .../StructuredIr/StructuredProgramInfo.cs | 2 +- src/Ryujinx.Graphics.Shader/SupportBuffer.cs | 24 +- src/Ryujinx.Graphics.Shader/TessPatchType.cs | 6 +- src/Ryujinx.Graphics.Shader/TessSpacing.cs | 6 +- .../TextureDescriptor.cs | 12 +- src/Ryujinx.Graphics.Shader/TextureFormat.cs | 6 +- src/Ryujinx.Graphics.Shader/TextureHandle.cs | 2 +- .../TextureUsageFlags.cs | 2 +- .../Translation/AggregateType.cs | 6 +- .../Translation/AttributeConsts.cs | 2 +- .../Translation/ControlFlowGraph.cs | 16 +- .../Translation/Dominance.cs | 2 +- .../Translation/EmitterContext.cs | 11 +- .../Translation/EmitterContextInsts.cs | 2 +- .../Translation/FeatureFlags.cs | 4 +- .../Translation/FunctionMatch.cs | 39 +- .../Translation/HelperFunctionManager.cs | 23 +- .../Translation/HelperFunctionName.cs | 4 +- .../Optimizations/BindlessElimination.cs | 8 +- .../Optimizations/BindlessToIndexed.cs | 14 +- .../Optimizations/BranchElimination.cs | 4 +- .../Optimizations/ConstantFolding.cs | 14 +- .../Optimizations/DoubleToFloat.cs | 4 +- .../Optimizations/GlobalToStorage.cs | 63 +- .../Translation/Optimizations/Optimizer.cs | 20 +- .../Optimizations/Simplification.cs | 2 +- .../Translation/Optimizations/Utils.cs | 2 +- .../Translation/RegisterUsage.cs | 38 +- .../Translation/ResourceManager.cs | 34 +- .../Translation/Rewriter.cs | 75 +- .../Translation/ShaderConfig.cs | 66 +- .../Translation/ShaderHeader.cs | 20 +- .../Translation/ShaderIdentifier.cs | 4 +- .../Translation/Ssa.cs | 23 +- .../Translation/TargetApi.cs | 2 +- .../Translation/TargetLanguage.cs | 2 +- .../Translation/TranslationFlags.cs | 8 +- .../Translation/Translator.cs | 14 +- .../Translation/TranslatorContext.cs | 11 +- 162 files changed, 1611 insertions(+), 1627 deletions(-) diff --git a/src/Ryujinx.Graphics.Shader/AlphaTestOp.cs b/src/Ryujinx.Graphics.Shader/AlphaTestOp.cs index 57c0d1314..13958ea48 100644 --- a/src/Ryujinx.Graphics.Shader/AlphaTestOp.cs +++ b/src/Ryujinx.Graphics.Shader/AlphaTestOp.cs @@ -9,6 +9,6 @@ namespace Ryujinx.Graphics.Shader Greater, NotEqual, GreaterOrEqual, - Always + Always, } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/AttributeType.cs b/src/Ryujinx.Graphics.Shader/AttributeType.cs index 4e6cad596..50a39945b 100644 --- a/src/Ryujinx.Graphics.Shader/AttributeType.cs +++ b/src/Ryujinx.Graphics.Shader/AttributeType.cs @@ -8,7 +8,7 @@ namespace Ryujinx.Graphics.Shader // Generic types. Float, Sint, - Uint + Uint, } static class AttributeTypeExtensions @@ -20,7 +20,7 @@ namespace Ryujinx.Graphics.Shader AttributeType.Float => "vec4", AttributeType.Sint => "ivec4", AttributeType.Uint => "uvec4", - _ => throw new ArgumentException($"Invalid attribute type \"{type}\".") + _ => throw new ArgumentException($"Invalid attribute type \"{type}\"."), }; } @@ -31,8 +31,8 @@ namespace Ryujinx.Graphics.Shader AttributeType.Float => AggregateType.FP32, AttributeType.Sint => AggregateType.S32, AttributeType.Uint => AggregateType.U32, - _ => throw new ArgumentException($"Invalid attribute type \"{type}\".") + _ => throw new ArgumentException($"Invalid attribute type \"{type}\"."), }; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/BufferDescriptor.cs b/src/Ryujinx.Graphics.Shader/BufferDescriptor.cs index 410c1991d..d1da95393 100644 --- a/src/Ryujinx.Graphics.Shader/BufferDescriptor.cs +++ b/src/Ryujinx.Graphics.Shader/BufferDescriptor.cs @@ -37,4 +37,4 @@ namespace Ryujinx.Graphics.Shader return this; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/BufferUsageFlags.cs b/src/Ryujinx.Graphics.Shader/BufferUsageFlags.cs index ab81d5756..a69fa46a4 100644 --- a/src/Ryujinx.Graphics.Shader/BufferUsageFlags.cs +++ b/src/Ryujinx.Graphics.Shader/BufferUsageFlags.cs @@ -13,6 +13,6 @@ namespace Ryujinx.Graphics.Shader /// /// Buffer is written to. /// - Write = 1 << 0 + Write = 1 << 0, } } diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/CodeGenContext.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/CodeGenContext.cs index 9eb20f6f8..551e5cefa 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/CodeGenContext.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/CodeGenContext.cs @@ -92,4 +92,4 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl return indentation; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs index 08e8eb195..94b850e7b 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs @@ -244,16 +244,6 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl } } - private static string GetTfLayout(TransformFeedbackOutput tfOutput) - { - if (tfOutput.Valid) - { - return $"layout (xfb_buffer = {tfOutput.Buffer}, xfb_offset = {tfOutput.Offset}, xfb_stride = {tfOutput.Stride}) "; - } - - return string.Empty; - } - public static void DeclareLocals(CodeGenContext context, StructuredFunction function) { foreach (AstOperand decl in function.Locals) @@ -294,7 +284,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl AggregateType.Vector4 | AggregateType.FP64 => "dvec4", AggregateType.Vector4 | AggregateType.S32 => "ivec4", AggregateType.Vector4 | AggregateType.U32 => "uvec4", - _ => throw new ArgumentException($"Invalid variable type \"{type}\".") + _ => throw new ArgumentException($"Invalid variable type \"{type}\"."), }; } @@ -315,7 +305,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl string layout = buffer.Layout switch { BufferLayout.Std140 => "std140", - _ => "std430" + _ => "std430", }; string set = string.Empty; @@ -507,7 +497,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl { PixelImap.Constant => "flat ", PixelImap.ScreenLinear => "noperspective ", - _ => string.Empty + _ => string.Empty, }; } @@ -524,7 +514,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl 2 => "vec2", 3 => "vec3", 4 => "vec4", - _ => "float" + _ => "float", }; context.AppendLine($"layout (location = {attr}) in {type} {name};"); @@ -611,7 +601,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl 2 => "vec2", 3 => "vec3", 4 => "vec4", - _ => "float" + _ => "float", }; string xfb = string.Empty; @@ -647,7 +637,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl { AttributeType.Sint => "ivec4", AttributeType.Uint => "uvec4", - _ => "vec4" + _ => "vec4", }; if (context.Config.GpuAccessor.QueryHostReducedPrecision() && context.Config.Stage == ShaderStage.Vertex && attr == 0) @@ -721,4 +711,4 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl context.AppendLine(); } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/DefaultNames.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/DefaultNames.cs index e909dcf04..842228edf 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/DefaultNames.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/DefaultNames.cs @@ -5,7 +5,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl public const string LocalNamePrefix = "temp"; public const string SamplerNamePrefix = "tex"; - public const string ImageNamePrefix = "img"; + public const string ImageNamePrefix = "img"; public const string PerPatchAttributePrefix = "patch_attr_"; public const string IAttributePrefix = "in_attr"; @@ -15,4 +15,4 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl public const string UndefinedName = "undef"; } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/GlslGenerator.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/GlslGenerator.cs index fe0d275b6..0140c1b93 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/GlslGenerator.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/GlslGenerator.cs @@ -13,7 +13,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl public static string Generate(StructuredProgramInfo info, ShaderConfig config) { - CodeGenContext context = new CodeGenContext(info, config); + CodeGenContext context = new(info, config); Declarations.Declare(context, info); @@ -74,7 +74,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl private static void PrintBlock(CodeGenContext context, AstBlock block, bool isMainFunction) { - AstBlockVisitor visitor = new AstBlockVisitor(block); + AstBlockVisitor visitor = new(block); visitor.BlockEntered += (sender, e) => { @@ -96,7 +96,8 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl context.AppendLine($"if ({GetCondExpr(context, e.Block.Condition)})"); break; - default: throw new InvalidOperationException($"Found unexpected block type \"{e.Block.Type}\"."); + default: + throw new InvalidOperationException($"Found unexpected block type \"{e.Block.Type}\"."); } context.EnterScope(); @@ -173,4 +174,4 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl return ReinterpretCast(context, cond, srcType, AggregateType.Bool); } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/HelperFunctions/HelperFunctionNames.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/HelperFunctions/HelperFunctionNames.cs index 21c435475..221802727 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/HelperFunctions/HelperFunctionNames.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/HelperFunctions/HelperFunctionNames.cs @@ -5,10 +5,10 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl public static string MultiplyHighS32 = "Helper_MultiplyHighS32"; public static string MultiplyHighU32 = "Helper_MultiplyHighU32"; - public static string Shuffle = "Helper_Shuffle"; + public static string Shuffle = "Helper_Shuffle"; public static string ShuffleDown = "Helper_ShuffleDown"; - public static string ShuffleUp = "Helper_ShuffleUp"; - public static string ShuffleXor = "Helper_ShuffleXor"; - public static string SwizzleAdd = "Helper_SwizzleAdd"; + public static string ShuffleUp = "Helper_ShuffleUp"; + public static string ShuffleXor = "Helper_ShuffleXor"; + public static string SwizzleAdd = "Helper_SwizzleAdd"; } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGen.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGen.cs index b2577a999..9208ceead 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGen.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGen.cs @@ -197,4 +197,4 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions throw new InvalidOperationException($"Unexpected instruction type \"{info.Type}\"."); } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenBallot.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenBallot.cs index 68793c5dd..9a2bfef0c 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenBallot.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenBallot.cs @@ -24,4 +24,4 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions } } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenCall.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenCall.cs index 2df6960d9..0618ba8a3 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenCall.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenCall.cs @@ -26,4 +26,4 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions return $"{function.Name}({string.Join(", ", args)})"; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenFSI.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenFSI.cs index f61a53cbe..a3d68028f 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenFSI.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenFSI.cs @@ -26,4 +26,4 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions return null; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenHelper.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenHelper.cs index 8b0b744ad..c3d52b2c5 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenHelper.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenHelper.cs @@ -14,6 +14,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions { _infoTable = new InstInfo[(int)Instruction.Count]; +#pragma warning disable IDE0055 // Disable formatting Add(Instruction.AtomicAdd, InstType.AtomicBinary, "atomicAdd"); Add(Instruction.AtomicAnd, InstType.AtomicBinary, "atomicAnd"); Add(Instruction.AtomicCompareAndSwap, InstType.AtomicTernary, "atomicCompSwap"); @@ -125,6 +126,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions Add(Instruction.VoteAll, InstType.CallUnary, "allInvocationsARB"); Add(Instruction.VoteAllEqual, InstType.CallUnary, "allInvocationsEqualARB"); Add(Instruction.VoteAny, InstType.CallUnary, "anyInvocationARB"); +#pragma warning restore IDE0055 } private static void Add(Instruction inst, InstType flags, string opName = null, int precedence = 0) @@ -163,7 +165,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions { // If the node isn't a operation, then it can only be a operand, // and those never needs to be surrounded in parenthesis. - if (!(node is AstOperation operation)) + if (node is not AstOperation operation) { // This is sort of a special case, if this is a negative constant, // and it is consumed by a unary operation, we need to put on the parenthesis, @@ -208,7 +210,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions private static bool IsNegativeConst(IAstNode node) { - if (!(node is AstOperand operand)) + if (node is not AstOperand operand) { return false; } @@ -216,4 +218,4 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions return operand.Type == OperandType.Constant && operand.Value < 0; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenMemory.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenMemory.cs index 99376ffb2..e0faed298 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenMemory.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenMemory.cs @@ -3,7 +3,6 @@ using Ryujinx.Graphics.Shader.StructuredIr; using Ryujinx.Graphics.Shader.Translation; using System; using System.Text; - using static Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions.InstGenHelper; using static Ryujinx.Graphics.Shader.StructuredIr.InstructionInfo; @@ -42,14 +41,16 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions } } - bool isArray = (texOp.Type & SamplerType.Array) != 0; + bool isArray = (texOp.Type & SamplerType.Array) != 0; bool isIndexed = (texOp.Type & SamplerType.Indexed) != 0; var texCallBuilder = new StringBuilder(); if (texOp.Inst == Instruction.ImageAtomic) { - texCallBuilder.Append((texOp.Flags & TextureFlags.AtomicMask) switch { + texCallBuilder.Append((texOp.Flags & TextureFlags.AtomicMask) switch + { +#pragma warning disable IDE0055 // Disable formatting TextureFlags.Add => "imageAtomicAdd", TextureFlags.Minimum => "imageAtomicMin", TextureFlags.Maximum => "imageAtomicMax", @@ -61,6 +62,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions TextureFlags.Swap => "imageAtomicExchange", TextureFlags.CAS => "imageAtomicCompSwap", _ => "imageAtomicAdd", +#pragma warning restore IDE0055 }); } else @@ -131,7 +133,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions { AggregateType.S32 => NumberFormatter.FormatInt(0), AggregateType.U32 => NumberFormatter.FormatUint(0), - _ => NumberFormatter.FormatFloat(0) + _ => NumberFormatter.FormatFloat(0), }; } } @@ -140,7 +142,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions { AggregateType.S32 => "i", AggregateType.U32 => "u", - _ => string.Empty + _ => string.Empty, }; Append($"{prefix}vec4({string.Join(", ", cElems)})"); @@ -159,7 +161,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions { TextureFlags.Increment => NumberFormatter.FormatInt(1, type), // TODO: Clamp value TextureFlags.Decrement => NumberFormatter.FormatInt(-1, type), // TODO: Clamp value - _ => Src(type) + _ => Src(type), }; Append(value); @@ -248,25 +250,25 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions { AstTextureOperation texOp = (AstTextureOperation)operation; - bool isBindless = (texOp.Flags & TextureFlags.Bindless) != 0; - bool isGather = (texOp.Flags & TextureFlags.Gather) != 0; + bool isBindless = (texOp.Flags & TextureFlags.Bindless) != 0; + bool isGather = (texOp.Flags & TextureFlags.Gather) != 0; bool hasDerivatives = (texOp.Flags & TextureFlags.Derivatives) != 0; - bool intCoords = (texOp.Flags & TextureFlags.IntCoords) != 0; - bool hasLodBias = (texOp.Flags & TextureFlags.LodBias) != 0; - bool hasLodLevel = (texOp.Flags & TextureFlags.LodLevel) != 0; - bool hasOffset = (texOp.Flags & TextureFlags.Offset) != 0; - bool hasOffsets = (texOp.Flags & TextureFlags.Offsets) != 0; + bool intCoords = (texOp.Flags & TextureFlags.IntCoords) != 0; + bool hasLodBias = (texOp.Flags & TextureFlags.LodBias) != 0; + bool hasLodLevel = (texOp.Flags & TextureFlags.LodLevel) != 0; + bool hasOffset = (texOp.Flags & TextureFlags.Offset) != 0; + bool hasOffsets = (texOp.Flags & TextureFlags.Offsets) != 0; - bool isArray = (texOp.Type & SamplerType.Array) != 0; - bool isIndexed = (texOp.Type & SamplerType.Indexed) != 0; + bool isArray = (texOp.Type & SamplerType.Array) != 0; + bool isIndexed = (texOp.Type & SamplerType.Indexed) != 0; bool isMultisample = (texOp.Type & SamplerType.Multisample) != 0; - bool isShadow = (texOp.Type & SamplerType.Shadow) != 0; + bool isShadow = (texOp.Type & SamplerType.Shadow) != 0; bool colorIsVector = isGather || !isShadow; SamplerType type = texOp.Type & SamplerType.Mask; - bool is2D = type == SamplerType.Texture2D; + bool is2D = type == SamplerType.Texture2D; bool isCube = type == SamplerType.TextureCube; // 2D Array and Cube shadow samplers with LOD level or bias requires an extension. @@ -500,14 +502,14 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions if (hasLodBias) { - Append(Src(AggregateType.FP32)); + Append(Src(AggregateType.FP32)); } // textureGather* optional extra component index, // not needed for shadow samplers. if (isGather && !isShadow) { - Append(Src(AggregateType.S32)); + Append(Src(AggregateType.S32)); } texCall += ")" + (colorIsVector ? GetMaskMultiDest(texOp.Index) : ""); @@ -584,7 +586,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions { case StorageKind.ConstantBuffer: case StorageKind.StorageBuffer: - if (!(operation.GetSource(srcIndex++) is AstOperand bindingIndex) || bindingIndex.Type != OperandType.Constant) + if (operation.GetSource(srcIndex++) is not AstOperand bindingIndex || bindingIndex.Type != OperandType.Constant) { throw new InvalidOperationException($"First input of {operation.Inst} with {storageKind} storage must be a constant operand."); } @@ -594,7 +596,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions ? context.Config.Properties.ConstantBuffers[binding] : context.Config.Properties.StorageBuffers[binding]; - if (!(operation.GetSource(srcIndex++) is AstOperand fieldIndex) || fieldIndex.Type != OperandType.Constant) + if (operation.GetSource(srcIndex++) is not AstOperand fieldIndex || fieldIndex.Type != OperandType.Constant) { throw new InvalidOperationException($"Second input of {operation.Inst} with {storageKind} storage must be a constant operand."); } @@ -606,7 +608,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions case StorageKind.LocalMemory: case StorageKind.SharedMemory: - if (!(operation.GetSource(srcIndex++) is AstOperand bindingId) || bindingId.Type != OperandType.Constant) + if (operation.GetSource(srcIndex++) is not AstOperand { Type: OperandType.Constant } bindingId) { throw new InvalidOperationException($"First input of {operation.Inst} with {storageKind} storage must be a constant operand."); } @@ -623,7 +625,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions case StorageKind.InputPerPatch: case StorageKind.Output: case StorageKind.OutputPerPatch: - if (!(operation.GetSource(srcIndex++) is AstOperand varId) || varId.Type != OperandType.Constant) + if (operation.GetSource(srcIndex++) is not AstOperand varId || varId.Type != OperandType.Constant) { throw new InvalidOperationException($"First input of {operation.Inst} with {storageKind} storage must be a constant operand."); } @@ -636,7 +638,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions if (context.Config.HasPerLocationInputOrOutput(ioVariable, isOutput)) { - if (!(operation.GetSource(srcIndex++) is AstOperand vecIndex) || vecIndex.Type != OperandType.Constant) + if (operation.GetSource(srcIndex++) is not AstOperand vecIndex || vecIndex.Type != OperandType.Constant) { throw new InvalidOperationException($"Second input of {operation.Inst} with {storageKind} storage must be a constant operand."); } @@ -733,4 +735,4 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions return swizzle; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenPacking.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenPacking.cs index 5a888e9c5..ad84c4850 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenPacking.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenPacking.cs @@ -53,4 +53,4 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions return $".{"xy".AsSpan(index, 1)}"; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenVector.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenVector.cs index f09ea2e8a..70174a5ba 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenVector.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenVector.cs @@ -29,4 +29,4 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions } } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstInfo.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstInfo.cs index 7b2a6b464..a784e2bb3 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstInfo.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstInfo.cs @@ -10,9 +10,9 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions public InstInfo(InstType type, string opName, int precedence) { - Type = type; - OpName = opName; + Type = type; + OpName = opName; Precedence = precedence; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstType.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstType.cs index 84e36cdd6..56985ae08 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstType.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstType.cs @@ -1,33 +1,35 @@ using System; +using System.Diagnostics.CodeAnalysis; namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions { [Flags] + [SuppressMessage("Design", "CA1069: Enums values should not be duplicated")] enum InstType { - OpNullary = Op | 0, - OpUnary = Op | 1, - OpBinary = Op | 2, + OpNullary = Op | 0, + OpUnary = Op | 1, + OpBinary = Op | 2, OpBinaryCom = Op | 2 | Commutative, - OpTernary = Op | 3, + OpTernary = Op | 3, - CallNullary = Call | 0, - CallUnary = Call | 1, - CallBinary = Call | 2, - CallTernary = Call | 3, + CallNullary = Call | 0, + CallUnary = Call | 1, + CallBinary = Call | 2, + CallTernary = Call | 3, CallQuaternary = Call | 4, // The atomic instructions have one extra operand, // for the storage slot and offset pair. - AtomicBinary = Call | Atomic | 3, + AtomicBinary = Call | Atomic | 3, AtomicTernary = Call | Atomic | 4, Commutative = 1 << 8, - Op = 1 << 9, - Call = 1 << 10, - Atomic = 1 << 11, - Special = 1 << 12, + Op = 1 << 9, + Call = 1 << 10, + Atomic = 1 << 11, + Special = 1 << 12, - ArityMask = 0xff + ArityMask = 0xff, } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/IoMap.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/IoMap.cs index 2a73b8b07..3f88d2b32 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/IoMap.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/IoMap.cs @@ -28,7 +28,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions IoVariable.FragmentOutputColor => GetFragmentOutputColorVariableName(config, location), IoVariable.FragmentOutputDepth => ("gl_FragDepth", AggregateType.FP32), IoVariable.FrontColorDiffuse => ("gl_FrontColor", AggregateType.Vector4 | AggregateType.FP32), // Deprecated. - IoVariable.FrontColorSpecular => ("gl_FrontSecondaryColor", AggregateType.Vector4 | AggregateType.FP32), // Deprecated. + IoVariable.FrontColorSpecular => ("gl_FrontSecondaryColor", AggregateType.Vector4 | AggregateType.FP32), // Deprecated. IoVariable.FrontFacing => ("gl_FrontFacing", AggregateType.Bool), IoVariable.InstanceId => ("gl_InstanceID", AggregateType.S32), IoVariable.InstanceIndex => ("gl_InstanceIndex", AggregateType.S32), @@ -56,7 +56,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions IoVariable.VertexIndex => ("gl_VertexIndex", AggregateType.S32), IoVariable.ViewportIndex => ("gl_ViewportIndex", AggregateType.S32), IoVariable.ViewportMask => ("gl_ViewportMask", AggregateType.Array | AggregateType.S32), - _ => (null, AggregateType.Invalid) + _ => (null, AggregateType.Invalid), }; } @@ -139,4 +139,4 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions return (name, config.GetUserDefinedType(location, isOutput)); } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/NumberFormatter.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/NumberFormatter.cs index eb27e9bf1..28e44c900 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/NumberFormatter.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/NumberFormatter.cs @@ -101,4 +101,4 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl return "0x" + value.ToString("X", CultureInfo.InvariantCulture) + "u"; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/OperandManager.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/OperandManager.cs index 4f6ca642c..0ca3b55fc 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/OperandManager.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/OperandManager.cs @@ -5,7 +5,6 @@ using Ryujinx.Graphics.Shader.Translation; using System; using System.Collections.Generic; using System.Diagnostics; - using static Ryujinx.Graphics.Shader.StructuredIr.InstructionInfo; namespace Ryujinx.Graphics.Shader.CodeGen.Glsl @@ -14,7 +13,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl { private static readonly string[] _stagePrefixes = new string[] { "cp", "vp", "tcp", "tep", "gp", "fp" }; - private Dictionary _locals; + private readonly Dictionary _locals; public OperandManager() { @@ -38,7 +37,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl OperandType.Constant => NumberFormatter.FormatInt(operand.Value), OperandType.LocalVariable => _locals[operand], OperandType.Undefined => DefaultNames.UndefinedName, - _ => throw new ArgumentException($"Invalid operand type \"{operand.Type}\".") + _ => throw new ArgumentException($"Invalid operand type \"{operand.Type}\"."), }; } @@ -96,11 +95,6 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl return _stagePrefixes[index]; } - private static char GetSwizzleMask(int value) - { - return "xyzw"[value]; - } - public static string GetArgumentName(int argIndex) { return $"{DefaultNames.ArgumentNamePrefix}{argIndex}"; @@ -119,12 +113,12 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl { case StorageKind.ConstantBuffer: case StorageKind.StorageBuffer: - if (!(operation.GetSource(0) is AstOperand bindingIndex) || bindingIndex.Type != OperandType.Constant) + if (operation.GetSource(0) is not AstOperand bindingIndex || bindingIndex.Type != OperandType.Constant) { throw new InvalidOperationException($"First input of {operation.Inst} with {operation.StorageKind} storage must be a constant operand."); } - if (!(operation.GetSource(1) is AstOperand fieldIndex) || fieldIndex.Type != OperandType.Constant) + if (operation.GetSource(1) is not AstOperand fieldIndex || fieldIndex.Type != OperandType.Constant) { throw new InvalidOperationException($"Second input of {operation.Inst} with {operation.StorageKind} storage must be a constant operand."); } @@ -138,7 +132,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl case StorageKind.LocalMemory: case StorageKind.SharedMemory: - if (!(operation.GetSource(0) is AstOperand bindingId) || bindingId.Type != OperandType.Constant) + if (operation.GetSource(0) is not AstOperand { Type: OperandType.Constant } bindingId) { throw new InvalidOperationException($"First input of {operation.Inst} with {operation.StorageKind} storage must be a constant operand."); } @@ -153,7 +147,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl case StorageKind.InputPerPatch: case StorageKind.Output: case StorageKind.OutputPerPatch: - if (!(operation.GetSource(0) is AstOperand varId) || varId.Type != OperandType.Constant) + if (operation.GetSource(0) is not AstOperand varId || varId.Type != OperandType.Constant) { throw new InvalidOperationException($"First input of {operation.Inst} with {operation.StorageKind} storage must be a constant operand."); } @@ -166,7 +160,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl if (context.Config.HasPerLocationInputOrOutput(ioVariable, isOutput)) { - if (!(operation.GetSource(1) is AstOperand vecIndex) || vecIndex.Type != OperandType.Constant) + if (operation.GetSource(1) is not AstOperand vecIndex || vecIndex.Type != OperandType.Constant) { throw new InvalidOperationException($"Second input of {operation.Inst} with {operation.StorageKind} storage must be a constant operand."); } @@ -232,4 +226,4 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl } } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/TypeConversion.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/TypeConversion.cs index 22c8623ce..3d7d0d0c1 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/TypeConversion.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/TypeConversion.cs @@ -10,9 +10,9 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl { public static string ReinterpretCast( CodeGenContext context, - IAstNode node, - AggregateType srcType, - AggregateType dstType) + IAstNode node, + AggregateType srcType, + AggregateType dstType) { if (node is AstOperand operand && operand.Type == OperandType.Constant) { @@ -38,18 +38,24 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl { switch (dstType) { - case AggregateType.Bool: return $"(floatBitsToInt({expr}) != 0)"; - case AggregateType.S32: return $"floatBitsToInt({expr})"; - case AggregateType.U32: return $"floatBitsToUint({expr})"; + case AggregateType.Bool: + return $"(floatBitsToInt({expr}) != 0)"; + case AggregateType.S32: + return $"floatBitsToInt({expr})"; + case AggregateType.U32: + return $"floatBitsToUint({expr})"; } } else if (dstType == AggregateType.FP32) { switch (srcType) { - case AggregateType.Bool: return $"intBitsToFloat({ReinterpretBoolToInt(expr, node, AggregateType.S32)})"; - case AggregateType.S32: return $"intBitsToFloat({expr})"; - case AggregateType.U32: return $"uintBitsToFloat({expr})"; + case AggregateType.Bool: + return $"intBitsToFloat({ReinterpretBoolToInt(expr, node, AggregateType.S32)})"; + case AggregateType.S32: + return $"intBitsToFloat({expr})"; + case AggregateType.U32: + return $"uintBitsToFloat({expr})"; } } else if (srcType == AggregateType.Bool) @@ -76,7 +82,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl private static string ReinterpretBoolToInt(string expr, IAstNode node, AggregateType dstType) { - string trueExpr = NumberFormatter.FormatInt(IrConsts.True, dstType); + string trueExpr = NumberFormatter.FormatInt(IrConsts.True, dstType); string falseExpr = NumberFormatter.FormatInt(IrConsts.False, dstType); expr = InstGenHelper.Enclose(expr, node, Instruction.ConditionalSelect, isLhs: false); @@ -84,4 +90,4 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl return $"({expr} ? {trueExpr} : {falseExpr})"; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/CodeGenContext.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/CodeGenContext.cs index a4daaa67e..9956e90a3 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/CodeGenContext.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/CodeGenContext.cs @@ -1,13 +1,14 @@ -using Ryujinx.Graphics.Shader.StructuredIr; +using Ryujinx.Graphics.Shader.IntermediateRepresentation; +using Ryujinx.Graphics.Shader.StructuredIr; using Ryujinx.Graphics.Shader.Translation; using Spv.Generator; using System; using System.Collections.Generic; using static Spv.Specification; +using Instruction = Spv.Generator.Instruction; namespace Ryujinx.Graphics.Shader.CodeGen.Spirv { - using IrConsts = IntermediateRepresentation.IrConsts; using IrOperandType = IntermediateRepresentation.OperandType; partial class CodeGenContext : Module @@ -36,15 +37,15 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv public Dictionary OutputsPerPatch { get; } = new Dictionary(); public StructuredFunction CurrentFunction { get; set; } - private readonly Dictionary _locals = new Dictionary(); - private readonly Dictionary _localForArgs = new Dictionary(); - private readonly Dictionary _funcArgs = new Dictionary(); - private readonly Dictionary _functions = new Dictionary(); + private readonly Dictionary _locals = new(); + private readonly Dictionary _localForArgs = new(); + private readonly Dictionary _funcArgs = new(); + private readonly Dictionary _functions = new(); private class BlockState { private int _entryCount; - private readonly List _labels = new List(); + private readonly List _labels = new(); public Instruction GetNextLabel(CodeGenContext context) { @@ -67,7 +68,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv } } - private readonly Dictionary _labels = new Dictionary(); + private readonly Dictionary _labels = new(); public Dictionary LoopTargets { get; set; } @@ -98,7 +99,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv InputTopology.LinesAdjacency => 2, InputTopology.Triangles => 3, InputTopology.TrianglesAdjacency => 3, - _ => throw new InvalidOperationException($"Invalid input topology \"{inPrimitive}\".") + _ => throw new InvalidOperationException($"Invalid input topology \"{inPrimitive}\"."), }; } @@ -222,7 +223,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv IrOperandType.Constant => GetConstant(type, operand), IrOperandType.LocalVariable => GetLocal(type, operand), IrOperandType.Undefined => GetUndefined(type), - _ => throw new ArgumentException($"Invalid operand type \"{operand.Type}\".") + _ => throw new ArgumentException($"Invalid operand type \"{operand.Type}\"."), }; } @@ -259,7 +260,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv AggregateType.Bool => ConstantFalse(TypeBool()), AggregateType.FP32 => Constant(TypeFP32(), 0f), AggregateType.FP64 => Constant(TypeFP64(), 0d), - _ => Constant(GetType(type), 0) + _ => Constant(GetType(type), 0), }; } @@ -272,7 +273,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv AggregateType.FP64 => Constant(TypeFP64(), (double)BitConverter.Int32BitsToSingle(operand.Value)), AggregateType.S32 => Constant(TypeS32(), operand.Value), AggregateType.U32 => Constant(TypeU32(), (uint)operand.Value), - _ => throw new ArgumentException($"Invalid type \"{type}\".") + _ => throw new ArgumentException($"Invalid type \"{type}\"."), }; } @@ -328,7 +329,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv AggregateType.Vector2 => 2, AggregateType.Vector3 => 3, AggregateType.Vector4 => 4, - _ => 1 + _ => 1, }; return TypeVector(GetType(type & ~AggregateType.ElementCountMask), vectorLength); @@ -342,7 +343,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv AggregateType.FP64 => TypeFP64(), AggregateType.S32 => TypeS32(), AggregateType.U32 => TypeU32(), - _ => throw new ArgumentException($"Invalid attribute type \"{type}\".") + _ => throw new ArgumentException($"Invalid attribute type \"{type}\"."), }; } @@ -359,7 +360,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv } else if (srcType == AggregateType.Bool) { - var intTrue = Constant(TypeS32(), IrConsts.True); + var intTrue = Constant(TypeS32(), IrConsts.True); var intFalse = Constant(TypeS32(), IrConsts.False); return BitcastIfNeeded(dstType, AggregateType.S32, Select(TypeS32(), value, intTrue, intFalse)); diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/Declarations.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/Declarations.cs index 59acea4f6..da1e385a7 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/Declarations.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/Declarations.cs @@ -1,5 +1,4 @@ -using Ryujinx.Common; -using Ryujinx.Graphics.Shader.IntermediateRepresentation; +using Ryujinx.Graphics.Shader.IntermediateRepresentation; using Ryujinx.Graphics.Shader.StructuredIr; using Ryujinx.Graphics.Shader.Translation; using Spv.Generator; @@ -14,7 +13,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv { static class Declarations { - private static readonly string[] StagePrefixes = new string[] { "cp", "vp", "tcp", "tep", "gp", "fp" }; + private static readonly string[] _stagePrefixes = { "cp", "vp", "tcp", "tep", "gp", "fp" }; public static void DeclareParameters(CodeGenContext context, StructuredFunction function) { @@ -107,7 +106,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv private static void DeclareBuffers(CodeGenContext context, IEnumerable buffers, bool isBuffer) { - HashSet decoratedTypes = new HashSet(); + HashSet decoratedTypes = new(); foreach (BufferDefinition buffer in buffers) { @@ -199,7 +198,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv SamplerType.Texture3D => Dim.Dim3D, SamplerType.TextureCube => Dim.Cube, SamplerType.TextureBuffer => Dim.Buffer, - _ => throw new InvalidOperationException($"Invalid sampler type \"{descriptor.Type & SamplerType.Mask}\".") + _ => throw new InvalidOperationException($"Invalid sampler type \"{descriptor.Type & SamplerType.Mask}\"."), }; var imageType = context.TypeImage( @@ -282,7 +281,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv SamplerType.Texture3D => Dim.Dim3D, SamplerType.TextureCube => Dim.Cube, SamplerType.TextureBuffer => Dim.Buffer, - _ => throw new ArgumentException($"Invalid sampler type \"{type & SamplerType.Mask}\".") + _ => throw new ArgumentException($"Invalid sampler type \"{type & SamplerType.Mask}\"."), }; } @@ -330,7 +329,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv TextureFormat.R10G10B10A2Unorm => ImageFormat.Rgb10A2, TextureFormat.R10G10B10A2Uint => ImageFormat.Rgb10a2ui, TextureFormat.R11G11B10Float => ImageFormat.R11fG11fB10f, - _ => throw new ArgumentException($"Invalid texture format \"{format}\".") + _ => throw new ArgumentException($"Invalid texture format \"{format}\"."), }; } @@ -352,7 +351,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv (_, AggregateType varType) = IoMap.GetSpirvBuiltIn(ioVariable); AggregateType elemType = varType & AggregateType.ElementTypeMask; - if (elemType == AggregateType.S32 || elemType == AggregateType.U32) + if (elemType is AggregateType.S32 or AggregateType.U32) { iq = PixelImap.Constant; } @@ -410,7 +409,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv 2 => AggregateType.Vector2, 3 => AggregateType.Vector3, 4 => AggregateType.Vector4, - _ => AggregateType.Invalid + _ => AggregateType.Invalid, }; } @@ -420,7 +419,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv if (!isPerPatch && IoMap.IsPerVertex(ioVariable, context.Config.Stage, isOutput)) { int arraySize = context.Config.Stage == ShaderStage.Geometry ? context.InputVertices : 32; - spvType = context.TypeArray(spvType, context.Constant(context.TypeU32(), (LiteralInteger)arraySize)); + spvType = context.TypeArray(spvType, context.Constant(context.TypeU32(), arraySize)); if (context.Config.GpPassthrough && context.Config.GpuAccessor.QueryHostSupportsGeometryShaderPassthrough()) { @@ -542,7 +541,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv private static string GetStagePrefix(ShaderStage stage) { - return StagePrefixes[(int)stage]; + return _stagePrefixes[(int)stage]; } } } diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/EnumConversion.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/EnumConversion.cs index 72541774d..2bb7e8369 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/EnumConversion.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/EnumConversion.cs @@ -15,7 +15,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv ShaderStage.TessellationEvaluation => ExecutionModel.TessellationEvaluation, ShaderStage.Geometry => ExecutionModel.Geometry, ShaderStage.Fragment => ExecutionModel.Fragment, - _ => throw new ArgumentException($"Invalid shader stage \"{stage}\".") + _ => throw new ArgumentException($"Invalid shader stage \"{stage}\"."), }; } } diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/Instructions.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/Instructions.cs index b451f7a48..a53b40b24 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/Instructions.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/Instructions.cs @@ -14,19 +14,20 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv static class Instructions { - private const MemorySemanticsMask DefaultMemorySemantics = + private const MemorySemanticsMask DefaultMemorySemantics = MemorySemanticsMask.ImageMemory | MemorySemanticsMask.AtomicCounterMemory | MemorySemanticsMask.WorkgroupMemory | MemorySemanticsMask.UniformMemory | MemorySemanticsMask.AcquireRelease; - private static readonly Func[] InstTable; + private static readonly Func[] _instTable; static Instructions() { - InstTable = new Func[(int)Instruction.Count]; + _instTable = new Func[(int)Instruction.Count]; +#pragma warning disable IDE0055 // Disable formatting Add(Instruction.Absolute, GenerateAbsolute); Add(Instruction.Add, GenerateAdd); Add(Instruction.AtomicAdd, GenerateAtomicAdd); @@ -141,16 +142,17 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv Add(Instruction.VoteAll, GenerateVoteAll); Add(Instruction.VoteAllEqual, GenerateVoteAllEqual); Add(Instruction.VoteAny, GenerateVoteAny); +#pragma warning restore IDE0055 } private static void Add(Instruction inst, Func handler) { - InstTable[(int)(inst & Instruction.Mask)] = handler; + _instTable[(int)(inst & Instruction.Mask)] = handler; } public static OperationResult Generate(CodeGenContext context, AstOperation operation) { - var handler = InstTable[(int)(operation.Inst & Instruction.Mask)]; + var handler = _instTable[(int)(operation.Inst & Instruction.Mask)]; if (handler != null) { return handler(context, operation); @@ -305,7 +307,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv Debug.Assert(funcId.Type == OperandType.Constant); - (var function, var spvFunc) = context.GetFunction(funcId.Value); + var (function, spvFunc) = context.GetFunction(funcId.Value); var args = new SpvInstruction[operation.SourcesCount - 1]; var spvLocals = context.GetLocalForArgsPointers(funcId.Value); @@ -615,7 +617,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv }); } - bool isArray = (texOp.Type & SamplerType.Array) != 0; + bool isArray = (texOp.Type & SamplerType.Array) != 0; bool isIndexed = (texOp.Type & SamplerType.Indexed) != 0; int srcIndex = isBindless ? 1 : 0; @@ -625,11 +627,9 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv return context.Get(type, texOp.GetSource(srcIndex++)); } - SpvInstruction index = null; - if (isIndexed) { - index = Src(AggregateType.S32); + Src(AggregateType.S32); } int coordsCount = texOp.Type.GetDimensions(); @@ -657,9 +657,9 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv SpvInstruction value = Src(componentType); - (var imageType, var imageVariable) = context.Images[new TextureMeta(texOp.CbufSlot, texOp.Handle, texOp.Format)]; + (SpvInstruction imageType, SpvInstruction imageVariable) = context.Images[new TextureMeta(texOp.CbufSlot, texOp.Handle, texOp.Format)]; - var image = context.Load(imageType, imageVariable); + context.Load(imageType, imageVariable); SpvInstruction resultType = context.GetType(componentType); SpvInstruction imagePointerType = context.TypePointer(StorageClass.Image, resultType); @@ -670,21 +670,21 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv var result = (texOp.Flags & TextureFlags.AtomicMask) switch { - TextureFlags.Add => context.AtomicIAdd(resultType, pointer, one, zero, value), - TextureFlags.Minimum => componentType == AggregateType.S32 + TextureFlags.Add => context.AtomicIAdd(resultType, pointer, one, zero, value), + TextureFlags.Minimum => componentType == AggregateType.S32 ? context.AtomicSMin(resultType, pointer, one, zero, value) : context.AtomicUMin(resultType, pointer, one, zero, value), - TextureFlags.Maximum => componentType == AggregateType.S32 + TextureFlags.Maximum => componentType == AggregateType.S32 ? context.AtomicSMax(resultType, pointer, one, zero, value) : context.AtomicUMax(resultType, pointer, one, zero, value), - TextureFlags.Increment => context.AtomicIIncrement(resultType, pointer, one, zero), - TextureFlags.Decrement => context.AtomicIDecrement(resultType, pointer, one, zero), + TextureFlags.Increment => context.AtomicIIncrement(resultType, pointer, one, zero), + TextureFlags.Decrement => context.AtomicIDecrement(resultType, pointer, one, zero), TextureFlags.BitwiseAnd => context.AtomicAnd(resultType, pointer, one, zero, value), - TextureFlags.BitwiseOr => context.AtomicOr(resultType, pointer, one, zero, value), + TextureFlags.BitwiseOr => context.AtomicOr(resultType, pointer, one, zero, value), TextureFlags.BitwiseXor => context.AtomicXor(resultType, pointer, one, zero, value), - TextureFlags.Swap => context.AtomicExchange(resultType, pointer, one, zero, value), - TextureFlags.CAS => context.AtomicCompareExchange(resultType, pointer, one, zero, zero, Src(componentType), value), - _ => context.AtomicIAdd(resultType, pointer, one, zero, value), + TextureFlags.Swap => context.AtomicExchange(resultType, pointer, one, zero, value), + TextureFlags.CAS => context.AtomicCompareExchange(resultType, pointer, one, zero, zero, Src(componentType), value), + _ => context.AtomicIAdd(resultType, pointer, one, zero, value), }; return new OperationResult(componentType, result); @@ -704,7 +704,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv return GetZeroOperationResult(context, texOp, componentType, isVector: true); } - bool isArray = (texOp.Type & SamplerType.Array) != 0; + bool isArray = (texOp.Type & SamplerType.Array) != 0; bool isIndexed = (texOp.Type & SamplerType.Indexed) != 0; int srcIndex = isBindless ? 1 : 0; @@ -714,11 +714,9 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv return context.Get(type, texOp.GetSource(srcIndex++)); } - SpvInstruction index = null; - if (isIndexed) { - index = Src(AggregateType.S32); + Src(AggregateType.S32); } int coordsCount = texOp.Type.GetDimensions(); @@ -744,7 +742,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv pCoords = Src(AggregateType.S32); } - (var imageType, var imageVariable) = context.Images[new TextureMeta(texOp.CbufSlot, texOp.Handle, texOp.Format)]; + var (imageType, imageVariable) = context.Images[new TextureMeta(texOp.CbufSlot, texOp.Handle, texOp.Format)]; var image = context.Load(imageType, imageVariable); var imageComponentType = context.GetType(componentType); @@ -768,7 +766,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv return OperationResult.Invalid; } - bool isArray = (texOp.Type & SamplerType.Array) != 0; + bool isArray = (texOp.Type & SamplerType.Array) != 0; bool isIndexed = (texOp.Type & SamplerType.Indexed) != 0; int srcIndex = isBindless ? 1 : 0; @@ -778,11 +776,9 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv return context.Get(type, texOp.GetSource(srcIndex++)); } - SpvInstruction index = null; - if (isIndexed) { - index = Src(AggregateType.S32); + Src(AggregateType.S32); } int coordsCount = texOp.Type.GetDimensions(); @@ -833,7 +829,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv var texel = context.CompositeConstruct(context.TypeVector(context.GetType(componentType), ComponentsCount), cElems); - (var imageType, var imageVariable) = context.Images[new TextureMeta(texOp.CbufSlot, texOp.Handle, texOp.Format)]; + var (imageType, imageVariable) = context.Images[new TextureMeta(texOp.CbufSlot, texOp.Handle, texOp.Format)]; var image = context.Load(imageType, imageVariable); @@ -886,11 +882,9 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv return context.Get(type, texOp.GetSource(srcIndex++)); } - SpvInstruction index = null; - if (isIndexed) { - index = Src(AggregateType.S32); + Src(AggregateType.S32); } int pCount = texOp.Type.GetDimensions(); @@ -916,7 +910,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv var meta = new TextureMeta(texOp.CbufSlot, texOp.Handle, texOp.Format); - (_, var sampledImageType, var sampledImageVariable) = context.Samplers[meta]; + var (_, sampledImageType, sampledImageVariable) = context.Samplers[meta]; var image = context.Load(sampledImageType, sampledImageVariable); @@ -973,7 +967,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv loopBlock = loopBlock.Parent; } - (var loopTarget, var continueTarget) = context.LoopTargets[loopBlock]; + (_, SpvInstruction continueTarget) = context.LoopTargets[loopBlock]; context.Branch(continueTarget); @@ -1278,19 +1272,19 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv { AstTextureOperation texOp = (AstTextureOperation)operation; - bool isBindless = (texOp.Flags & TextureFlags.Bindless) != 0; - bool isGather = (texOp.Flags & TextureFlags.Gather) != 0; + bool isBindless = (texOp.Flags & TextureFlags.Bindless) != 0; + bool isGather = (texOp.Flags & TextureFlags.Gather) != 0; bool hasDerivatives = (texOp.Flags & TextureFlags.Derivatives) != 0; - bool intCoords = (texOp.Flags & TextureFlags.IntCoords) != 0; - bool hasLodBias = (texOp.Flags & TextureFlags.LodBias) != 0; - bool hasLodLevel = (texOp.Flags & TextureFlags.LodLevel) != 0; - bool hasOffset = (texOp.Flags & TextureFlags.Offset) != 0; - bool hasOffsets = (texOp.Flags & TextureFlags.Offsets) != 0; + bool intCoords = (texOp.Flags & TextureFlags.IntCoords) != 0; + bool hasLodBias = (texOp.Flags & TextureFlags.LodBias) != 0; + bool hasLodLevel = (texOp.Flags & TextureFlags.LodLevel) != 0; + bool hasOffset = (texOp.Flags & TextureFlags.Offset) != 0; + bool hasOffsets = (texOp.Flags & TextureFlags.Offsets) != 0; - bool isArray = (texOp.Type & SamplerType.Array) != 0; - bool isIndexed = (texOp.Type & SamplerType.Indexed) != 0; + bool isArray = (texOp.Type & SamplerType.Array) != 0; + bool isIndexed = (texOp.Type & SamplerType.Indexed) != 0; bool isMultisample = (texOp.Type & SamplerType.Multisample) != 0; - bool isShadow = (texOp.Type & SamplerType.Shadow) != 0; + bool isShadow = (texOp.Type & SamplerType.Shadow) != 0; bool colorIsVector = isGather || !isShadow; @@ -1307,11 +1301,9 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv return context.Get(type, texOp.GetSource(srcIndex++)); } - SpvInstruction index = null; - if (isIndexed) { - index = Src(AggregateType.S32); + Src(AggregateType.S32); } int coordsCount = texOp.Type.GetDimensions(); @@ -1395,7 +1387,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv derivatives = new[] { AssembleDerivativesVector(coordsCount), // dPdx - AssembleDerivativesVector(coordsCount) // dPdy + AssembleDerivativesVector(coordsCount), // dPdy }; } @@ -1445,7 +1437,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv AssembleOffsetVector(coordsCount), AssembleOffsetVector(coordsCount), AssembleOffsetVector(coordsCount), - AssembleOffsetVector(coordsCount) + AssembleOffsetVector(coordsCount), }; } @@ -1474,7 +1466,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv // not needed for shadow samplers. if (isGather && !isShadow) { - compIdx = Src(AggregateType.S32); + compIdx = Src(AggregateType.S32); } var operandsList = new List(); @@ -1521,7 +1513,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv var meta = new TextureMeta(texOp.CbufSlot, texOp.Handle, texOp.Format); - (var imageType, var sampledImageType, var sampledImageVariable) = context.Samplers[meta]; + var (imageType, sampledImageType, sampledImageVariable) = context.Samplers[meta]; var image = context.Load(sampledImageType, sampledImageVariable); @@ -1595,16 +1587,14 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv bool isIndexed = (texOp.Type & SamplerType.Indexed) != 0; - SpvInstruction index = null; - if (isIndexed) { - index = context.GetS32(texOp.GetSource(0)); + context.GetS32(texOp.GetSource(0)); } var meta = new TextureMeta(texOp.CbufSlot, texOp.Handle, texOp.Format); - (var imageType, var sampledImageType, var sampledImageVariable) = context.Samplers[meta]; + (SpvInstruction imageType, SpvInstruction sampledImageType, SpvInstruction sampledImageVariable) = context.Samplers[meta]; var image = context.Load(sampledImageType, sampledImageVariable); image = context.Image(imageType, image); @@ -1809,12 +1799,12 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv { case StorageKind.ConstantBuffer: case StorageKind.StorageBuffer: - if (!(operation.GetSource(srcIndex++) is AstOperand bindingIndex) || bindingIndex.Type != OperandType.Constant) + if (operation.GetSource(srcIndex++) is not AstOperand bindingIndex || bindingIndex.Type != OperandType.Constant) { throw new InvalidOperationException($"First input of {operation.Inst} with {storageKind} storage must be a constant operand."); } - if (!(operation.GetSource(srcIndex) is AstOperand fieldIndex) || fieldIndex.Type != OperandType.Constant) + if (operation.GetSource(srcIndex) is not AstOperand fieldIndex || fieldIndex.Type != OperandType.Constant) { throw new InvalidOperationException($"Second input of {operation.Inst} with {storageKind} storage must be a constant operand."); } @@ -1833,7 +1823,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv case StorageKind.LocalMemory: case StorageKind.SharedMemory: - if (!(operation.GetSource(srcIndex++) is AstOperand bindingId) || bindingId.Type != OperandType.Constant) + if (operation.GetSource(srcIndex++) is not AstOperand { Type: OperandType.Constant } bindingId) { throw new InvalidOperationException($"First input of {operation.Inst} with {storageKind} storage must be a constant operand."); } @@ -1856,7 +1846,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv case StorageKind.InputPerPatch: case StorageKind.Output: case StorageKind.OutputPerPatch: - if (!(operation.GetSource(srcIndex++) is AstOperand varId) || varId.Type != OperandType.Constant) + if (operation.GetSource(srcIndex++) is not AstOperand varId || varId.Type != OperandType.Constant) { throw new InvalidOperationException($"First input of {operation.Inst} with {storageKind} storage must be a constant operand."); } @@ -1869,7 +1859,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv if (context.Config.HasPerLocationInputOrOutput(ioVariable, isOutput)) { - if (!(operation.GetSource(srcIndex++) is AstOperand vecIndex) || vecIndex.Type != OperandType.Constant) + if (operation.GetSource(srcIndex++) is not AstOperand vecIndex || vecIndex.Type != OperandType.Constant) { throw new InvalidOperationException($"Second input of {operation.Inst} with {storageKind} storage must be a constant operand."); } @@ -1964,7 +1954,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv private static SpvInstruction GetScalarInput(CodeGenContext context, IoVariable ioVariable) { - (_, var varType) = IoMap.GetSpirvBuiltIn(ioVariable); + var (_, varType) = IoMap.GetSpirvBuiltIn(ioVariable); varType &= AggregateType.ElementTypeMask; var ioDefinition = new IoDefinition(StorageKind.Input, ioVariable); @@ -2061,10 +2051,10 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv return new OperationResult(AggregateType.Bool, emitB(context.TypeBool(), context.Get(AggregateType.Bool, source))); } - private static OperationResult GenerateUnaryFP32( - CodeGenContext context, - AstOperation operation, - Func emit) + private static OperationResult GenerateUnaryFP32( + CodeGenContext context, + AstOperation operation, + Func emit) { var source = operation.GetSource(0); return new OperationResult(AggregateType.FP32, emit(context.TypeFP32(), context.GetFP32(source))); diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/IoMap.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/IoMap.cs index d2ff0085c..8a6103237 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/IoMap.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/IoMap.cs @@ -45,7 +45,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv IoVariable.VertexIndex => (BuiltIn.VertexIndex, AggregateType.S32), IoVariable.ViewportIndex => (BuiltIn.ViewportIndex, AggregateType.S32), IoVariable.ViewportMask => (BuiltIn.ViewportMaskNV, AggregateType.Array | AggregateType.S32), - _ => (default, AggregateType.Invalid) + _ => (default, AggregateType.Invalid), }; } @@ -58,7 +58,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv IoVariable.TessellationLevelOuter => 4, IoVariable.ViewportMask => 1, IoVariable.UserDefined => MaxAttributes, - _ => 1 + _ => 1, }; } @@ -74,13 +74,11 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv case IoVariable.ClipDistance: case IoVariable.PointCoord: case IoVariable.ViewportMask: - return !isOutput && - (stage == ShaderStage.TessellationControl || - stage == ShaderStage.TessellationEvaluation || - stage == ShaderStage.Geometry); + return !isOutput && + stage is ShaderStage.TessellationControl or ShaderStage.TessellationEvaluation or ShaderStage.Geometry; } return false; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/OperationResult.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/OperationResult.cs index f80c8110b..a6e8e91f6 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/OperationResult.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/OperationResult.cs @@ -5,7 +5,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv { readonly struct OperationResult { - public static OperationResult Invalid => new OperationResult(AggregateType.Invalid, null); + public static OperationResult Invalid => new(AggregateType.Invalid, null); public AggregateType Type { get; } public Instruction Value { get; } diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/SpirvGenerator.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/SpirvGenerator.cs index 5c736b605..c8fcd75a1 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/SpirvGenerator.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/SpirvGenerator.cs @@ -17,15 +17,15 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv { // Resource pools for Spirv generation. Note: Increase count when more threads are being used. private const int GeneratorPoolCount = 1; - private static ObjectPool InstructionPool; - private static ObjectPool IntegerPool; - private static object PoolLock; + private static readonly ObjectPool _instructionPool; + private static readonly ObjectPool _integerPool; + private static readonly object _poolLock; static SpirvGenerator() { - InstructionPool = new (() => new SpvInstructionPool(), GeneratorPoolCount); - IntegerPool = new (() => new SpvLiteralIntegerPool(), GeneratorPoolCount); - PoolLock = new object(); + _instructionPool = new(() => new SpvInstructionPool(), GeneratorPoolCount); + _integerPool = new(() => new SpvLiteralIntegerPool(), GeneratorPoolCount); + _poolLock = new object(); } private const HelperFunctionsMask NeedsInvocationIdMask = @@ -40,13 +40,13 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv SpvInstructionPool instPool; SpvLiteralIntegerPool integerPool; - lock (PoolLock) + lock (_poolLock) { - instPool = InstructionPool.Allocate(); - integerPool = IntegerPool.Allocate(); + instPool = _instructionPool.Allocate(); + integerPool = _integerPool.Allocate(); } - CodeGenContext context = new CodeGenContext(info, config, instPool, integerPool); + CodeGenContext context = new(info, config, instPool, integerPool); context.AddCapability(Capability.GroupNonUniformBallot); context.AddCapability(Capability.GroupNonUniformShuffle); @@ -133,10 +133,10 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv byte[] result = context.Generate(); - lock (PoolLock) + lock (_poolLock) { - InstructionPool.Release(instPool); - IntegerPool.Release(integerPool); + _instructionPool.Release(instPool); + _integerPool.Release(integerPool); } return result; @@ -144,7 +144,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv private static void Generate(CodeGenContext context, StructuredProgramInfo info, int funcIndex) { - (var function, var spvFunc) = context.GetFunction(funcIndex); + var (function, spvFunc) = context.GetFunction(funcIndex); context.CurrentFunction = function; context.AddFunction(spvFunc); @@ -160,7 +160,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv Generate(context, function.MainBlock); // Functions must always end with a return. - if (!(function.MainBlock.Last is AstOperation operation) || + if (function.MainBlock.Last is not AstOperation operation || (operation.Inst != Instruction.Return && operation.Inst != Instruction.Discard)) { context.Return(); @@ -232,7 +232,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv InputTopology.LinesAdjacency => ExecutionMode.InputLinesAdjacency, InputTopology.Triangles => ExecutionMode.Triangles, InputTopology.TrianglesAdjacency => ExecutionMode.InputTrianglesAdjacency, - _ => throw new InvalidOperationException($"Invalid input topology \"{inputTopology}\".") + _ => throw new InvalidOperationException($"Invalid input topology \"{inputTopology}\"."), }); context.AddExecutionMode(spvFunc, ExecutionMode.Invocations, (SpvLiteralInteger)context.Config.ThreadsPerInputPrimitive); @@ -242,7 +242,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv OutputTopology.PointList => ExecutionMode.OutputPoints, OutputTopology.LineStrip => ExecutionMode.OutputLineStrip, OutputTopology.TriangleStrip => ExecutionMode.OutputTriangleStrip, - _ => throw new InvalidOperationException($"Invalid output topology \"{context.Config.OutputTopology}\".") + _ => throw new InvalidOperationException($"Invalid output topology \"{context.Config.OutputTopology}\"."), }); int maxOutputVertices = context.Config.GpPassthrough ? context.InputVertices : context.Config.MaxOutputVertices; @@ -294,7 +294,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv private static void Generate(CodeGenContext context, AstBlock block) { - AstBlockVisitor visitor = new AstBlockVisitor(block); + AstBlockVisitor visitor = new(block); var loopTargets = new Dictionary(); @@ -346,7 +346,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv // if the condition is true. AstBlock mergeBlock = e.Block.Parent; - (var loopTarget, var continueTarget) = loopTargets[e.Block]; + var (loopTarget, continueTarget) = loopTargets[e.Block]; context.Branch(continueTarget); context.AddLabel(continueTarget); diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/TextureMeta.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/TextureMeta.cs index 4de056037..56ea9a2a6 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/TextureMeta.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/TextureMeta.cs @@ -1,4 +1,4 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv { readonly record struct TextureMeta(int CbufSlot, int Handle, TextureFormat Format); -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Constants.cs b/src/Ryujinx.Graphics.Shader/Constants.cs index 39d6b2381..cff2c37a0 100644 --- a/src/Ryujinx.Graphics.Shader/Constants.cs +++ b/src/Ryujinx.Graphics.Shader/Constants.cs @@ -17,4 +17,4 @@ namespace Ryujinx.Graphics.Shader public const int TfeBufferBaseBinding = 1; public const int TfeBuffersCount = 4; } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Decoders/Block.cs b/src/Ryujinx.Graphics.Shader/Decoders/Block.cs index 7d94e3f9a..1a694898b 100644 --- a/src/Ryujinx.Graphics.Shader/Decoders/Block.cs +++ b/src/Ryujinx.Graphics.Shader/Decoders/Block.cs @@ -92,7 +92,7 @@ namespace Ryujinx.Graphics.Shader.Decoders pushOpInfo.Consumers.Add(rightBlock, local); } - foreach ((ulong key, SyncTarget value) in SyncTargets) + foreach ((ulong key, SyncTarget value) in SyncTargets) { rightBlock.SyncTargets.Add(key, value); } @@ -148,7 +148,7 @@ namespace Ryujinx.Graphics.Shader.Decoders { if (OpCodes.Count != 0) { - return OpCodes[OpCodes.Count - 1]; + return OpCodes[^1]; } return default; @@ -165,4 +165,4 @@ namespace Ryujinx.Graphics.Shader.Decoders PushOpCodes.Add(new PushOpInfo(op)); } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Decoders/DecodedFunction.cs b/src/Ryujinx.Graphics.Shader/Decoders/DecodedFunction.cs index 7a172fe6f..49cd3a30a 100644 --- a/src/Ryujinx.Graphics.Shader/Decoders/DecodedFunction.cs +++ b/src/Ryujinx.Graphics.Shader/Decoders/DecodedFunction.cs @@ -45,4 +45,4 @@ namespace Ryujinx.Graphics.Shader.Decoders } } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Decoders/DecodedProgram.cs b/src/Ryujinx.Graphics.Shader/Decoders/DecodedProgram.cs index 2dd60155e..7776ccc52 100644 --- a/src/Ryujinx.Graphics.Shader/Decoders/DecodedProgram.cs +++ b/src/Ryujinx.Graphics.Shader/Decoders/DecodedProgram.cs @@ -54,4 +54,4 @@ namespace Ryujinx.Graphics.Shader.Decoders return GetEnumerator(); } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Decoders/Decoder.cs b/src/Ryujinx.Graphics.Shader/Decoders/Decoder.cs index 4e6c6a5df..ba31c0205 100644 --- a/src/Ryujinx.Graphics.Shader/Decoders/Decoder.cs +++ b/src/Ryujinx.Graphics.Shader/Decoders/Decoder.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; using System.Linq; using System.Runtime.CompilerServices; - using static Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandHelper; namespace Ryujinx.Graphics.Shader.Decoders @@ -12,8 +11,8 @@ namespace Ryujinx.Graphics.Shader.Decoders { public static DecodedProgram Decode(ShaderConfig config, ulong startAddress) { - Queue functionsQueue = new Queue(); - Dictionary functionsVisited = new Dictionary(); + Queue functionsQueue = new(); + Dictionary functionsVisited = new(); DecodedFunction EnqueueFunction(ulong address) { @@ -30,9 +29,9 @@ namespace Ryujinx.Graphics.Shader.Decoders while (functionsQueue.TryDequeue(out DecodedFunction currentFunction)) { - List blocks = new List(); - Queue workQueue = new Queue(); - Dictionary visited = new Dictionary(); + List blocks = new(); + Queue workQueue = new(); + Dictionary visited = new(); Block GetBlock(ulong blkAddress) { @@ -168,7 +167,7 @@ namespace Ryujinx.Graphics.Shader.Decoders { index = 0; - int left = 0; + int left = 0; int right = blocks.Count - 1; while (left <= right) @@ -273,12 +272,12 @@ namespace Ryujinx.Graphics.Shader.Decoders int offset; int count = 1; bool isStore = false; - bool indexed = false; + bool indexed; bool perPatch = false; if (name == InstName.Ast) { - InstAst opAst = new InstAst(opCode); + InstAst opAst = new(opCode); count = (int)opAst.AlSize + 1; offset = opAst.Imm11; indexed = opAst.Phys; @@ -287,7 +286,7 @@ namespace Ryujinx.Graphics.Shader.Decoders } else if (name == InstName.Ald) { - InstAld opAld = new InstAld(opCode); + InstAld opAld = new(opCode); count = (int)opAld.AlSize + 1; offset = opAld.Imm11; indexed = opAld.Phys; @@ -296,7 +295,7 @@ namespace Ryujinx.Graphics.Shader.Decoders } else /* if (name == InstName.Ipa) */ { - InstIpa opIpa = new InstIpa(opCode); + InstIpa opIpa = new(opCode); offset = opIpa.Imm10; indexed = opIpa.Idx; } @@ -370,7 +369,7 @@ namespace Ryujinx.Graphics.Shader.Decoders private static bool IsUnconditional(ref InstOp op) { - InstConditional condOp = new InstConditional(op.RawOpCode); + InstConditional condOp = new(op.RawOpCode); if ((op.Name == InstName.Bra || op.Name == InstName.Exit) && condOp.Ccc != Ccc.T) { @@ -391,9 +390,9 @@ namespace Ryujinx.Graphics.Shader.Decoders if (lastOp.Name == InstName.Brx && block.Successors.Count == (hasNext ? 1 : 0)) { - HashSet visited = new HashSet(); + HashSet visited = new(); - InstBrx opBrx = new InstBrx(lastOp.RawOpCode); + InstBrx opBrx = new(lastOp.RawOpCode); ulong baseOffset = lastOp.GetAbsoluteAddress(); // An indirect branch could go anywhere, @@ -437,7 +436,7 @@ namespace Ryujinx.Graphics.Shader.Decoders // On a successful match, "BaseOffset" is the offset in bytes where the jump offsets are // located on the constant buffer, and "UpperBound" is the total number of offsets for the BRX, minus 1. - HashSet visited = new HashSet(); + HashSet visited = new(); var ldcLocation = FindFirstRegWrite(visited, new BlockLocation(block, block.OpCodes.Count - 1), brxReg); if (ldcLocation.Block == null || ldcLocation.Block.OpCodes[ldcLocation.Index].Name != InstName.Ldc) @@ -507,7 +506,7 @@ namespace Ryujinx.Graphics.Shader.Decoders private static BlockLocation FindFirstRegWrite(HashSet visited, BlockLocation location, int regIndex) { - Queue toVisit = new Queue(); + Queue toVisit = new(); toVisit.Enqueue(location); visited.Add(location.Block); @@ -554,10 +553,10 @@ namespace Ryujinx.Graphics.Shader.Decoders { Brk, Cont, - Sync + Sync, } - private struct PathBlockState + private readonly struct PathBlockState { public Block Block { get; } @@ -565,37 +564,37 @@ namespace Ryujinx.Graphics.Shader.Decoders { None, PopPushOp, - PushBranchOp + PushBranchOp, } - private RestoreType _restoreType; + private readonly RestoreType _restoreType; - private ulong _restoreValue; - private MergeType _restoreMergeType; + private readonly ulong _restoreValue; + private readonly MergeType _restoreMergeType; public bool ReturningFromVisit => _restoreType != RestoreType.None; public PathBlockState(Block block) { - Block = block; - _restoreType = RestoreType.None; - _restoreValue = 0; + Block = block; + _restoreType = RestoreType.None; + _restoreValue = 0; _restoreMergeType = default; } public PathBlockState(int oldStackSize) { - Block = null; - _restoreType = RestoreType.PopPushOp; - _restoreValue = (ulong)oldStackSize; + Block = null; + _restoreType = RestoreType.PopPushOp; + _restoreValue = (ulong)oldStackSize; _restoreMergeType = default; } public PathBlockState(ulong syncAddress, MergeType mergeType) { - Block = null; - _restoreType = RestoreType.PushBranchOp; - _restoreValue = syncAddress; + Block = null; + _restoreType = RestoreType.PushBranchOp; + _restoreValue = syncAddress; _restoreMergeType = mergeType; } @@ -622,9 +621,9 @@ namespace Ryujinx.Graphics.Shader.Decoders Block target = blocks[pushOp.GetAbsoluteAddress()]; - Stack workQueue = new Stack(); - HashSet visited = new HashSet(); - Stack<(ulong, MergeType)> branchStack = new Stack<(ulong, MergeType)>(); + Stack workQueue = new(); + HashSet visited = new(); + Stack<(ulong, MergeType)> branchStack = new(); void Push(PathBlockState pbs) { @@ -759,7 +758,7 @@ namespace Ryujinx.Graphics.Shader.Decoders { InstName.Pbk => MergeType.Brk, InstName.Pcnt => MergeType.Cont, - _ => MergeType.Sync + _ => MergeType.Sync, }; } @@ -769,8 +768,8 @@ namespace Ryujinx.Graphics.Shader.Decoders { InstName.Brk => MergeType.Brk, InstName.Cont => MergeType.Cont, - _ => MergeType.Sync + _ => MergeType.Sync, }; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Decoders/InstDecoders.cs b/src/Ryujinx.Graphics.Shader/Decoders/InstDecoders.cs index c7c506ec4..8bf5671ac 100644 --- a/src/Ryujinx.Graphics.Shader/Decoders/InstDecoders.cs +++ b/src/Ryujinx.Graphics.Shader/Decoders/InstDecoders.cs @@ -684,7 +684,7 @@ namespace Ryujinx.Graphics.Shader.Decoders Texture2DLodZeroMultisample = 0x6, Texture3DLodZero = 0x7, Texture2DArrayLodZero = 0x8, - Texture2DLodLevelOffset = 0xc + Texture2DLodLevelOffset = 0xc, } enum TexComp @@ -848,18 +848,18 @@ namespace Ryujinx.Graphics.Shader.Decoders S16h0 = 3, } - struct InstConditional + readonly struct InstConditional { - private ulong _opcode; + private readonly ulong _opcode; public InstConditional(ulong opcode) => _opcode = opcode; public int Pred => (int)((_opcode >> 16) & 0x7); public bool PredInv => (_opcode & 0x80000) != 0; public Ccc Ccc => (Ccc)(_opcode & 0x1F); } - struct InstAl2p + readonly struct InstAl2p { - private ulong _opcode; + private readonly ulong _opcode; public InstAl2p(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -871,9 +871,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public int DestPred => (int)((_opcode >> 44) & 0x7); } - struct InstAld + readonly struct InstAld { - private ulong _opcode; + private readonly ulong _opcode; public InstAld(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -887,9 +887,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool Phys => !P && Imm11 == 0 && SrcA != RegisterConsts.RegisterZeroIndex; } - struct InstAst + readonly struct InstAst { - private ulong _opcode; + private readonly ulong _opcode; public InstAst(ulong opcode) => _opcode = opcode; public int SrcA => (int)((_opcode >> 8) & 0xFF); public int SrcB => (int)(_opcode & 0xFF); @@ -902,9 +902,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool Phys => !P && Imm11 == 0 && SrcA != RegisterConsts.RegisterZeroIndex; } - struct InstAtom + readonly struct InstAtom { - private ulong _opcode; + private readonly ulong _opcode; public InstAtom(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -917,9 +917,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool E => (_opcode & 0x1000000000000) != 0; } - struct InstAtomCas + readonly struct InstAtomCas { - private ulong _opcode; + private readonly ulong _opcode; public InstAtomCas(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -930,9 +930,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool E => (_opcode & 0x1000000000000) != 0; } - struct InstAtoms + readonly struct InstAtoms { - private ulong _opcode; + private readonly ulong _opcode; public InstAtoms(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -944,9 +944,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public AtomOp AtomOp => (AtomOp)((_opcode >> 52) & 0xF); } - struct InstAtomsCas + readonly struct InstAtomsCas { - private ulong _opcode; + private readonly ulong _opcode; public InstAtomsCas(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -956,9 +956,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public int AtomsBcRz => (int)((_opcode >> 28) & 0x3); } - struct InstB2r + readonly struct InstB2r { - private ulong _opcode; + private readonly ulong _opcode; public InstB2r(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int DestPred => (int)((_opcode >> 45) & 0x7); @@ -968,9 +968,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public BarMode Mode => (BarMode)((_opcode >> 32) & 0x3); } - struct InstBar + readonly struct InstBar { - private ulong _opcode; + private readonly ulong _opcode; public InstBar(ulong opcode) => _opcode = opcode; public int SrcA => (int)((_opcode >> 8) & 0xFF); public int Imm12 => (int)((_opcode >> 20) & 0xFFF); @@ -984,9 +984,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool BFixBar => (_opcode & 0x80000000000) != 0; } - struct InstBfeR + readonly struct InstBfeR { - private ulong _opcode; + private readonly ulong _opcode; public InstBfeR(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -998,9 +998,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool Brev => (_opcode & 0x10000000000) != 0; } - struct InstBfeI + readonly struct InstBfeI { - private ulong _opcode; + private readonly ulong _opcode; public InstBfeI(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -1012,9 +1012,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool Brev => (_opcode & 0x10000000000) != 0; } - struct InstBfeC + readonly struct InstBfeC { - private ulong _opcode; + private readonly ulong _opcode; public InstBfeC(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -1027,9 +1027,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool Brev => (_opcode & 0x10000000000) != 0; } - struct InstBfiR + readonly struct InstBfiR { - private ulong _opcode; + private readonly ulong _opcode; public InstBfiR(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -1040,9 +1040,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool WriteCC => (_opcode & 0x800000000000) != 0; } - struct InstBfiI + readonly struct InstBfiI { - private ulong _opcode; + private readonly ulong _opcode; public InstBfiI(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -1053,9 +1053,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool WriteCC => (_opcode & 0x800000000000) != 0; } - struct InstBfiC + readonly struct InstBfiC { - private ulong _opcode; + private readonly ulong _opcode; public InstBfiC(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -1067,9 +1067,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool WriteCC => (_opcode & 0x800000000000) != 0; } - struct InstBfiRc + readonly struct InstBfiRc { - private ulong _opcode; + private readonly ulong _opcode; public InstBfiRc(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -1081,17 +1081,17 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool WriteCC => (_opcode & 0x800000000000) != 0; } - struct InstBpt + readonly struct InstBpt { - private ulong _opcode; + private readonly ulong _opcode; public InstBpt(ulong opcode) => _opcode = opcode; public int Imm20 => (int)((_opcode >> 20) & 0xFFFFF); public Bpt Bpt => (Bpt)((_opcode >> 6) & 0x7); } - struct InstBra + readonly struct InstBra { - private ulong _opcode; + private readonly ulong _opcode; public InstBra(ulong opcode) => _opcode = opcode; public int Pred => (int)((_opcode >> 16) & 0x7); public bool PredInv => (_opcode & 0x80000) != 0; @@ -1102,18 +1102,18 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool U => (_opcode & 0x80) != 0; } - struct InstBrk + readonly struct InstBrk { - private ulong _opcode; + private readonly ulong _opcode; public InstBrk(ulong opcode) => _opcode = opcode; public int Pred => (int)((_opcode >> 16) & 0x7); public bool PredInv => (_opcode & 0x80000) != 0; public Ccc Ccc => (Ccc)(_opcode & 0x1F); } - struct InstBrx + readonly struct InstBrx { - private ulong _opcode; + private readonly ulong _opcode; public InstBrx(ulong opcode) => _opcode = opcode; public int SrcA => (int)((_opcode >> 8) & 0xFF); public int Pred => (int)((_opcode >> 16) & 0x7); @@ -1124,18 +1124,18 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool Lmt => (_opcode & 0x40) != 0; } - struct InstCal + readonly struct InstCal { - private ulong _opcode; + private readonly ulong _opcode; public InstCal(ulong opcode) => _opcode = opcode; public bool Ca => (_opcode & 0x20) != 0; public int Imm24 => (int)((_opcode >> 20) & 0xFFFFFF); public bool Inc => (_opcode & 0x40) != 0; } - struct InstCctl + readonly struct InstCctl { - private ulong _opcode; + private readonly ulong _opcode; public InstCctl(ulong opcode) => _opcode = opcode; public int SrcA => (int)((_opcode >> 8) & 0xFF); public int Pred => (int)((_opcode >> 16) & 0x7); @@ -1146,9 +1146,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public CctlOp CctlOp => (CctlOp)(_opcode & 0xF); } - struct InstCctll + readonly struct InstCctll { - private ulong _opcode; + private readonly ulong _opcode; public InstCctll(ulong opcode) => _opcode = opcode; public int SrcA => (int)((_opcode >> 8) & 0xFF); public int Pred => (int)((_opcode >> 16) & 0x7); @@ -1158,9 +1158,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public CctlOp CctlOp => (CctlOp)(_opcode & 0xF); } - struct InstCctlt + readonly struct InstCctlt { - private ulong _opcode; + private readonly ulong _opcode; public InstCctlt(ulong opcode) => _opcode = opcode; public int Pred => (int)((_opcode >> 16) & 0x7); public bool PredInv => (_opcode & 0x80000) != 0; @@ -1168,26 +1168,26 @@ namespace Ryujinx.Graphics.Shader.Decoders public CctltOp CctltOp => (CctltOp)(_opcode & 0x3); } - struct InstCctltR + readonly struct InstCctltR { - private ulong _opcode; + private readonly ulong _opcode; public InstCctltR(ulong opcode) => _opcode = opcode; public int SrcC => (int)((_opcode >> 39) & 0xFF); public CctltOp CctltOp => (CctltOp)(_opcode & 0x3); } - struct InstCont + readonly struct InstCont { - private ulong _opcode; + private readonly ulong _opcode; public InstCont(ulong opcode) => _opcode = opcode; public int Pred => (int)((_opcode >> 16) & 0x7); public bool PredInv => (_opcode & 0x80000) != 0; public Ccc Ccc => (Ccc)(_opcode & 0x1F); } - struct InstCset + readonly struct InstCset { - private ulong _opcode; + private readonly ulong _opcode; public InstCset(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int Pred => (int)((_opcode >> 16) & 0x7); @@ -1200,9 +1200,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public BoolOp Bop => (BoolOp)((_opcode >> 45) & 0x3); } - struct InstCsetp + readonly struct InstCsetp { - private ulong _opcode; + private readonly ulong _opcode; public InstCsetp(ulong opcode) => _opcode = opcode; public int Pred => (int)((_opcode >> 16) & 0x7); public bool PredInv => (_opcode & 0x80000) != 0; @@ -1215,9 +1215,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public BoolOp Bop => (BoolOp)((_opcode >> 45) & 0x3); } - struct InstCs2r + readonly struct InstCs2r { - private ulong _opcode; + private readonly ulong _opcode; public InstCs2r(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int Pred => (int)((_opcode >> 16) & 0x7); @@ -1225,9 +1225,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public SReg SReg => (SReg)((_opcode >> 20) & 0xFF); } - struct InstDaddR + readonly struct InstDaddR { - private ulong _opcode; + private readonly ulong _opcode; public InstDaddR(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -1242,9 +1242,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public RoundMode RoundMode => (RoundMode)((_opcode >> 39) & 0x3); } - struct InstDaddI + readonly struct InstDaddI { - private ulong _opcode; + private readonly ulong _opcode; public InstDaddI(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -1259,9 +1259,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public RoundMode RoundMode => (RoundMode)((_opcode >> 39) & 0x3); } - struct InstDaddC + readonly struct InstDaddC { - private ulong _opcode; + private readonly ulong _opcode; public InstDaddC(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -1277,9 +1277,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public RoundMode RoundMode => (RoundMode)((_opcode >> 39) & 0x3); } - struct InstDepbar + readonly struct InstDepbar { - private ulong _opcode; + private readonly ulong _opcode; public InstDepbar(ulong opcode) => _opcode = opcode; public int Pred => (int)((_opcode >> 16) & 0x7); public bool PredInv => (_opcode & 0x80000) != 0; @@ -1289,9 +1289,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public int Imm6 => (int)(_opcode & 0x3F); } - struct InstDfmaR + readonly struct InstDfmaR { - private ulong _opcode; + private readonly ulong _opcode; public InstDfmaR(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -1305,9 +1305,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool NegA => (_opcode & 0x1000000000000) != 0; } - struct InstDfmaI + readonly struct InstDfmaI { - private ulong _opcode; + private readonly ulong _opcode; public InstDfmaI(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -1321,9 +1321,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool NegA => (_opcode & 0x1000000000000) != 0; } - struct InstDfmaC + readonly struct InstDfmaC { - private ulong _opcode; + private readonly ulong _opcode; public InstDfmaC(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -1338,9 +1338,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool NegA => (_opcode & 0x1000000000000) != 0; } - struct InstDfmaRc + readonly struct InstDfmaRc { - private ulong _opcode; + private readonly ulong _opcode; public InstDfmaRc(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -1355,9 +1355,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool NegA => (_opcode & 0x1000000000000) != 0; } - struct InstDmnmxR + readonly struct InstDmnmxR { - private ulong _opcode; + private readonly ulong _opcode; public InstDmnmxR(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -1373,9 +1373,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool SrcPredInv => (_opcode & 0x40000000000) != 0; } - struct InstDmnmxI + readonly struct InstDmnmxI { - private ulong _opcode; + private readonly ulong _opcode; public InstDmnmxI(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -1391,9 +1391,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool SrcPredInv => (_opcode & 0x40000000000) != 0; } - struct InstDmnmxC + readonly struct InstDmnmxC { - private ulong _opcode; + private readonly ulong _opcode; public InstDmnmxC(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -1410,9 +1410,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool SrcPredInv => (_opcode & 0x40000000000) != 0; } - struct InstDmulR + readonly struct InstDmulR { - private ulong _opcode; + private readonly ulong _opcode; public InstDmulR(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -1424,9 +1424,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool NegA => (_opcode & 0x1000000000000) != 0; } - struct InstDmulI + readonly struct InstDmulI { - private ulong _opcode; + private readonly ulong _opcode; public InstDmulI(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -1438,9 +1438,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool NegA => (_opcode & 0x1000000000000) != 0; } - struct InstDmulC + readonly struct InstDmulC { - private ulong _opcode; + private readonly ulong _opcode; public InstDmulC(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -1453,9 +1453,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool NegA => (_opcode & 0x1000000000000) != 0; } - struct InstDsetR + readonly struct InstDsetR { - private ulong _opcode; + private readonly ulong _opcode; public InstDsetR(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -1474,9 +1474,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool SrcPredInv => (_opcode & 0x40000000000) != 0; } - struct InstDsetI + readonly struct InstDsetI { - private ulong _opcode; + private readonly ulong _opcode; public InstDsetI(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -1495,9 +1495,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool SrcPredInv => (_opcode & 0x40000000000) != 0; } - struct InstDsetC + readonly struct InstDsetC { - private ulong _opcode; + private readonly ulong _opcode; public InstDsetC(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -1517,9 +1517,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool SrcPredInv => (_opcode & 0x40000000000) != 0; } - struct InstDsetpR + readonly struct InstDsetpR { - private ulong _opcode; + private readonly ulong _opcode; public InstDsetpR(ulong opcode) => _opcode = opcode; public int SrcA => (int)((_opcode >> 8) & 0xFF); public int SrcB => (int)((_opcode >> 20) & 0xFF); @@ -1537,9 +1537,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public int DestPredInv => (int)(_opcode & 0x7); } - struct InstDsetpI + readonly struct InstDsetpI { - private ulong _opcode; + private readonly ulong _opcode; public InstDsetpI(ulong opcode) => _opcode = opcode; public int SrcA => (int)((_opcode >> 8) & 0xFF); public int Imm20 => (int)((_opcode >> 37) & 0x80000) | (int)((_opcode >> 20) & 0x7FFFF); @@ -1557,9 +1557,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public int DestPredInv => (int)(_opcode & 0x7); } - struct InstDsetpC + readonly struct InstDsetpC { - private ulong _opcode; + private readonly ulong _opcode; public InstDsetpC(ulong opcode) => _opcode = opcode; public int SrcA => (int)((_opcode >> 8) & 0xFF); public int CbufSlot => (int)((_opcode >> 34) & 0x1F); @@ -1578,9 +1578,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public int DestPredInv => (int)(_opcode & 0x7); } - struct InstExit + readonly struct InstExit { - private ulong _opcode; + private readonly ulong _opcode; public InstExit(ulong opcode) => _opcode = opcode; public int Pred => (int)((_opcode >> 16) & 0x7); public bool PredInv => (_opcode & 0x80000) != 0; @@ -1588,9 +1588,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool KeepRefCnt => (_opcode & 0x20) != 0; } - struct InstF2fR + readonly struct InstF2fR { - private ulong _opcode; + private readonly ulong _opcode; public InstF2fR(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcB => (int)((_opcode >> 20) & 0xFF); @@ -1607,9 +1607,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool Sat => (_opcode & 0x4000000000000) != 0; } - struct InstF2fI + readonly struct InstF2fI { - private ulong _opcode; + private readonly ulong _opcode; public InstF2fI(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int Imm20 => (int)((_opcode >> 37) & 0x80000) | (int)((_opcode >> 20) & 0x7FFFF); @@ -1626,9 +1626,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool Sat => (_opcode & 0x4000000000000) != 0; } - struct InstF2fC + readonly struct InstF2fC { - private ulong _opcode; + private readonly ulong _opcode; public InstF2fC(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int CbufSlot => (int)((_opcode >> 34) & 0x1F); @@ -1646,9 +1646,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool Sat => (_opcode & 0x4000000000000) != 0; } - struct InstF2iR + readonly struct InstF2iR { - private ulong _opcode; + private readonly ulong _opcode; public InstF2iR(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcB => (int)((_opcode >> 20) & 0xFF); @@ -1664,9 +1664,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public RoundMode2 RoundMode => (RoundMode2)((_opcode >> 39) & 0x3); } - struct InstF2iI + readonly struct InstF2iI { - private ulong _opcode; + private readonly ulong _opcode; public InstF2iI(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int Imm20 => (int)((_opcode >> 37) & 0x80000) | (int)((_opcode >> 20) & 0x7FFFF); @@ -1682,9 +1682,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public RoundMode2 RoundMode => (RoundMode2)((_opcode >> 39) & 0x3); } - struct InstF2iC + readonly struct InstF2iC { - private ulong _opcode; + private readonly ulong _opcode; public InstF2iC(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int CbufSlot => (int)((_opcode >> 34) & 0x1F); @@ -1701,9 +1701,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public RoundMode2 RoundMode => (RoundMode2)((_opcode >> 39) & 0x3); } - struct InstFaddR + readonly struct InstFaddR { - private ulong _opcode; + private readonly ulong _opcode; public InstFaddR(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -1720,9 +1720,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public RoundMode RoundMode => (RoundMode)((_opcode >> 39) & 0x3); } - struct InstFaddI + readonly struct InstFaddI { - private ulong _opcode; + private readonly ulong _opcode; public InstFaddI(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -1739,9 +1739,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public RoundMode RoundMode => (RoundMode)((_opcode >> 39) & 0x3); } - struct InstFaddC + readonly struct InstFaddC { - private ulong _opcode; + private readonly ulong _opcode; public InstFaddC(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -1759,9 +1759,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public RoundMode RoundMode => (RoundMode)((_opcode >> 39) & 0x3); } - struct InstFadd32i + readonly struct InstFadd32i { - private ulong _opcode; + private readonly ulong _opcode; public InstFadd32i(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -1776,9 +1776,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool NegB => (_opcode & 0x20000000000000) != 0; } - struct InstFchkR + readonly struct InstFchkR { - private ulong _opcode; + private readonly ulong _opcode; public InstFchkR(ulong opcode) => _opcode = opcode; public int DestPred => (int)((_opcode >> 3) & 0x7); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -1792,9 +1792,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public ChkModeF ChkModeF => (ChkModeF)((_opcode >> 39) & 0x3F); } - struct InstFchkI + readonly struct InstFchkI { - private ulong _opcode; + private readonly ulong _opcode; public InstFchkI(ulong opcode) => _opcode = opcode; public int DestPred => (int)((_opcode >> 3) & 0x7); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -1808,9 +1808,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public ChkModeF ChkModeF => (ChkModeF)((_opcode >> 39) & 0x3F); } - struct InstFchkC + readonly struct InstFchkC { - private ulong _opcode; + private readonly ulong _opcode; public InstFchkC(ulong opcode) => _opcode = opcode; public int DestPred => (int)((_opcode >> 3) & 0x7); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -1825,9 +1825,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public ChkModeF ChkModeF => (ChkModeF)((_opcode >> 39) & 0x3F); } - struct InstFcmpR + readonly struct InstFcmpR { - private ulong _opcode; + private readonly ulong _opcode; public InstFcmpR(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -1839,9 +1839,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool Ftz => (_opcode & 0x800000000000) != 0; } - struct InstFcmpI + readonly struct InstFcmpI { - private ulong _opcode; + private readonly ulong _opcode; public InstFcmpI(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -1853,9 +1853,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool Ftz => (_opcode & 0x800000000000) != 0; } - struct InstFcmpC + readonly struct InstFcmpC { - private ulong _opcode; + private readonly ulong _opcode; public InstFcmpC(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -1868,9 +1868,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool Ftz => (_opcode & 0x800000000000) != 0; } - struct InstFcmpRc + readonly struct InstFcmpRc { - private ulong _opcode; + private readonly ulong _opcode; public InstFcmpRc(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -1883,9 +1883,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool Ftz => (_opcode & 0x800000000000) != 0; } - struct InstFfmaR + readonly struct InstFfmaR { - private ulong _opcode; + private readonly ulong _opcode; public InstFfmaR(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -1901,9 +1901,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public Fmz Fmz => (Fmz)((_opcode >> 53) & 0x3); } - struct InstFfmaI + readonly struct InstFfmaI { - private ulong _opcode; + private readonly ulong _opcode; public InstFfmaI(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -1919,9 +1919,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public Fmz Fmz => (Fmz)((_opcode >> 53) & 0x3); } - struct InstFfmaC + readonly struct InstFfmaC { - private ulong _opcode; + private readonly ulong _opcode; public InstFfmaC(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -1938,9 +1938,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public Fmz Fmz => (Fmz)((_opcode >> 53) & 0x3); } - struct InstFfmaRc + readonly struct InstFfmaRc { - private ulong _opcode; + private readonly ulong _opcode; public InstFfmaRc(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -1957,9 +1957,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public Fmz Fmz => (Fmz)((_opcode >> 53) & 0x3); } - struct InstFfma32i + readonly struct InstFfma32i { - private ulong _opcode; + private readonly ulong _opcode; public InstFfma32i(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -1973,9 +1973,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public Fmz Fmz => (Fmz)((_opcode >> 53) & 0x3); } - struct InstFloR + readonly struct InstFloR { - private ulong _opcode; + private readonly ulong _opcode; public InstFloR(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcB => (int)((_opcode >> 20) & 0xFF); @@ -1987,9 +1987,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool NegB => (_opcode & 0x10000000000) != 0; } - struct InstFloI + readonly struct InstFloI { - private ulong _opcode; + private readonly ulong _opcode; public InstFloI(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int Imm20 => (int)((_opcode >> 37) & 0x80000) | (int)((_opcode >> 20) & 0x7FFFF); @@ -2001,9 +2001,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool NegB => (_opcode & 0x10000000000) != 0; } - struct InstFloC + readonly struct InstFloC { - private ulong _opcode; + private readonly ulong _opcode; public InstFloC(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int CbufSlot => (int)((_opcode >> 34) & 0x1F); @@ -2016,9 +2016,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool NegB => (_opcode & 0x10000000000) != 0; } - struct InstFmnmxR + readonly struct InstFmnmxR { - private ulong _opcode; + private readonly ulong _opcode; public InstFmnmxR(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -2035,9 +2035,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool SrcPredInv => (_opcode & 0x40000000000) != 0; } - struct InstFmnmxI + readonly struct InstFmnmxI { - private ulong _opcode; + private readonly ulong _opcode; public InstFmnmxI(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -2054,9 +2054,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool SrcPredInv => (_opcode & 0x40000000000) != 0; } - struct InstFmnmxC + readonly struct InstFmnmxC { - private ulong _opcode; + private readonly ulong _opcode; public InstFmnmxC(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -2074,9 +2074,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool SrcPredInv => (_opcode & 0x40000000000) != 0; } - struct InstFmulR + readonly struct InstFmulR { - private ulong _opcode; + private readonly ulong _opcode; public InstFmulR(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -2091,9 +2091,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool Sat => (_opcode & 0x4000000000000) != 0; } - struct InstFmulI + readonly struct InstFmulI { - private ulong _opcode; + private readonly ulong _opcode; public InstFmulI(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -2108,9 +2108,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool Sat => (_opcode & 0x4000000000000) != 0; } - struct InstFmulC + readonly struct InstFmulC { - private ulong _opcode; + private readonly ulong _opcode; public InstFmulC(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -2126,9 +2126,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool Sat => (_opcode & 0x4000000000000) != 0; } - struct InstFmul32i + readonly struct InstFmul32i { - private ulong _opcode; + private readonly ulong _opcode; public InstFmul32i(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -2140,9 +2140,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool WriteCC => (_opcode & 0x10000000000000) != 0; } - struct InstFsetR + readonly struct InstFsetR { - private ulong _opcode; + private readonly ulong _opcode; public InstFsetR(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -2162,9 +2162,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool BVal => (_opcode & 0x10000000000000) != 0; } - struct InstFsetC + readonly struct InstFsetC { - private ulong _opcode; + private readonly ulong _opcode; public InstFsetC(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -2185,9 +2185,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool BVal => (_opcode & 0x10000000000000) != 0; } - struct InstFsetI + readonly struct InstFsetI { - private ulong _opcode; + private readonly ulong _opcode; public InstFsetI(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -2207,9 +2207,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool BVal => (_opcode & 0x10000000000000) != 0; } - struct InstFsetpR + readonly struct InstFsetpR { - private ulong _opcode; + private readonly ulong _opcode; public InstFsetpR(ulong opcode) => _opcode = opcode; public int DestPred => (int)((_opcode >> 3) & 0x7); public int DestPredInv => (int)(_opcode & 0x7); @@ -2229,9 +2229,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool Ftz => (_opcode & 0x800000000000) != 0; } - struct InstFsetpI + readonly struct InstFsetpI { - private ulong _opcode; + private readonly ulong _opcode; public InstFsetpI(ulong opcode) => _opcode = opcode; public int DestPred => (int)((_opcode >> 3) & 0x7); public int DestPredInv => (int)(_opcode & 0x7); @@ -2251,9 +2251,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool Ftz => (_opcode & 0x800000000000) != 0; } - struct InstFsetpC + readonly struct InstFsetpC { - private ulong _opcode; + private readonly ulong _opcode; public InstFsetpC(ulong opcode) => _opcode = opcode; public int DestPred => (int)((_opcode >> 3) & 0x7); public int DestPredInv => (int)(_opcode & 0x7); @@ -2274,9 +2274,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool Ftz => (_opcode & 0x800000000000) != 0; } - struct InstFswzadd + readonly struct InstFswzadd { - private ulong _opcode; + private readonly ulong _opcode; public InstFswzadd(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -2290,23 +2290,23 @@ namespace Ryujinx.Graphics.Shader.Decoders public int PnWord => (int)((_opcode >> 28) & 0xFF); } - struct InstGetcrsptr + readonly struct InstGetcrsptr { - private ulong _opcode; + private readonly ulong _opcode; public InstGetcrsptr(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); } - struct InstGetlmembase + readonly struct InstGetlmembase { - private ulong _opcode; + private readonly ulong _opcode; public InstGetlmembase(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); } - struct InstHadd2R + readonly struct InstHadd2R { - private ulong _opcode; + private readonly ulong _opcode; public InstHadd2R(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -2324,9 +2324,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool Ftz => (_opcode & 0x8000000000) != 0; } - struct InstHadd2I + readonly struct InstHadd2I { - private ulong _opcode; + private readonly ulong _opcode; public InstHadd2I(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -2342,9 +2342,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool Ftz => (_opcode & 0x8000000000) != 0; } - struct InstHadd2C + readonly struct InstHadd2C { - private ulong _opcode; + private readonly ulong _opcode; public InstHadd2C(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -2362,9 +2362,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool Ftz => (_opcode & 0x8000000000) != 0; } - struct InstHadd232i + readonly struct InstHadd232i { - private ulong _opcode; + private readonly ulong _opcode; public InstHadd232i(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -2377,9 +2377,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool Ftz => (_opcode & 0x80000000000000) != 0; } - struct InstHfma2R + readonly struct InstHfma2R { - private ulong _opcode; + private readonly ulong _opcode; public InstHfma2R(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -2397,9 +2397,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public Fmz Fmz => (Fmz)((_opcode >> 37) & 0x3); } - struct InstHfma2I + readonly struct InstHfma2I { - private ulong _opcode; + private readonly ulong _opcode; public InstHfma2I(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -2416,9 +2416,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public Fmz Fmz => (Fmz)((_opcode >> 57) & 0x3); } - struct InstHfma2C + readonly struct InstHfma2C { - private ulong _opcode; + private readonly ulong _opcode; public InstHfma2C(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -2436,9 +2436,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public Fmz Fmz => (Fmz)((_opcode >> 57) & 0x3); } - struct InstHfma2Rc + readonly struct InstHfma2Rc { - private ulong _opcode; + private readonly ulong _opcode; public InstHfma2Rc(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -2456,9 +2456,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public Fmz Fmz => (Fmz)((_opcode >> 57) & 0x3); } - struct InstHfma232i + readonly struct InstHfma232i { - private ulong _opcode; + private readonly ulong _opcode; public InstHfma232i(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -2470,9 +2470,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public Fmz Fmz => (Fmz)((_opcode >> 57) & 0x3); } - struct InstHmul2R + readonly struct InstHmul2R { - private ulong _opcode; + private readonly ulong _opcode; public InstHmul2R(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -2489,9 +2489,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public Fmz Fmz => (Fmz)((_opcode >> 39) & 0x3); } - struct InstHmul2I + readonly struct InstHmul2I { - private ulong _opcode; + private readonly ulong _opcode; public InstHmul2I(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -2507,9 +2507,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public Fmz Fmz => (Fmz)((_opcode >> 39) & 0x3); } - struct InstHmul2C + readonly struct InstHmul2C { - private ulong _opcode; + private readonly ulong _opcode; public InstHmul2C(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -2526,9 +2526,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public Fmz Fmz => (Fmz)((_opcode >> 39) & 0x3); } - struct InstHmul232i + readonly struct InstHmul232i { - private ulong _opcode; + private readonly ulong _opcode; public InstHmul232i(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -2540,9 +2540,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public Fmz Fmz => (Fmz)((_opcode >> 55) & 0x3); } - struct InstHset2R + readonly struct InstHset2R { - private ulong _opcode; + private readonly ulong _opcode; public InstHset2R(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -2563,9 +2563,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool Ftz => (_opcode & 0x4000000000000) != 0; } - struct InstHset2I + readonly struct InstHset2I { - private ulong _opcode; + private readonly ulong _opcode; public InstHset2I(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -2584,9 +2584,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool Ftz => (_opcode & 0x40000000000000) != 0; } - struct InstHset2C + readonly struct InstHset2C { - private ulong _opcode; + private readonly ulong _opcode; public InstHset2C(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -2606,9 +2606,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool Ftz => (_opcode & 0x40000000000000) != 0; } - struct InstHsetp2R + readonly struct InstHsetp2R { - private ulong _opcode; + private readonly ulong _opcode; public InstHsetp2R(ulong opcode) => _opcode = opcode; public int DestPred => (int)((_opcode >> 3) & 0x7); public int DestPredInv => (int)(_opcode & 0x7); @@ -2630,9 +2630,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public HalfSwizzle BSwizzle => (HalfSwizzle)((_opcode >> 28) & 0x3); } - struct InstHsetp2I + readonly struct InstHsetp2I { - private ulong _opcode; + private readonly ulong _opcode; public InstHsetp2I(ulong opcode) => _opcode = opcode; public int DestPred => (int)((_opcode >> 3) & 0x7); public int DestPredInv => (int)(_opcode & 0x7); @@ -2652,9 +2652,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public HalfSwizzle ASwizzle => (HalfSwizzle)((_opcode >> 47) & 0x3); } - struct InstHsetp2C + readonly struct InstHsetp2C { - private ulong _opcode; + private readonly ulong _opcode; public InstHsetp2C(ulong opcode) => _opcode = opcode; public int DestPred => (int)((_opcode >> 3) & 0x7); public int DestPredInv => (int)(_opcode & 0x7); @@ -2676,9 +2676,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public HalfSwizzle ASwizzle => (HalfSwizzle)((_opcode >> 47) & 0x3); } - struct InstI2fR + readonly struct InstI2fR { - private ulong _opcode; + private readonly ulong _opcode; public InstI2fR(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcB => (int)((_opcode >> 20) & 0xFF); @@ -2693,9 +2693,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public DstFmt DstFmt => (DstFmt)((_opcode >> 8) & 0x3); } - struct InstI2fI + readonly struct InstI2fI { - private ulong _opcode; + private readonly ulong _opcode; public InstI2fI(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int Imm20 => (int)((_opcode >> 37) & 0x80000) | (int)((_opcode >> 20) & 0x7FFFF); @@ -2710,9 +2710,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public DstFmt DstFmt => (DstFmt)((_opcode >> 8) & 0x3); } - struct InstI2fC + readonly struct InstI2fC { - private ulong _opcode; + private readonly ulong _opcode; public InstI2fC(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int CbufSlot => (int)((_opcode >> 34) & 0x1F); @@ -2728,9 +2728,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public DstFmt DstFmt => (DstFmt)((_opcode >> 8) & 0x3); } - struct InstI2iR + readonly struct InstI2iR { - private ulong _opcode; + private readonly ulong _opcode; public InstI2iR(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcB => (int)((_opcode >> 20) & 0xFF); @@ -2745,9 +2745,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public ISrcDstFmt ISrcFmt => (ISrcDstFmt)((int)((_opcode >> 11) & 0x4) | (int)((_opcode >> 10) & 0x3)); } - struct InstI2iI + readonly struct InstI2iI { - private ulong _opcode; + private readonly ulong _opcode; public InstI2iI(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int Imm20 => (int)((_opcode >> 37) & 0x80000) | (int)((_opcode >> 20) & 0x7FFFF); @@ -2762,9 +2762,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public ISrcDstFmt ISrcFmt => (ISrcDstFmt)((int)((_opcode >> 11) & 0x4) | (int)((_opcode >> 10) & 0x3)); } - struct InstI2iC + readonly struct InstI2iC { - private ulong _opcode; + private readonly ulong _opcode; public InstI2iC(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int CbufSlot => (int)((_opcode >> 34) & 0x1F); @@ -2780,9 +2780,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public ISrcDstFmt ISrcFmt => (ISrcDstFmt)((int)((_opcode >> 11) & 0x4) | (int)((_opcode >> 10) & 0x3)); } - struct InstIaddR + readonly struct InstIaddR { - private ulong _opcode; + private readonly ulong _opcode; public InstIaddR(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -2795,9 +2795,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool X => (_opcode & 0x80000000000) != 0; } - struct InstIaddI + readonly struct InstIaddI { - private ulong _opcode; + private readonly ulong _opcode; public InstIaddI(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -2810,9 +2810,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool X => (_opcode & 0x80000000000) != 0; } - struct InstIaddC + readonly struct InstIaddC { - private ulong _opcode; + private readonly ulong _opcode; public InstIaddC(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -2826,9 +2826,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool X => (_opcode & 0x80000000000) != 0; } - struct InstIadd32i + readonly struct InstIadd32i { - private ulong _opcode; + private readonly ulong _opcode; public InstIadd32i(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -2841,9 +2841,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool X => (_opcode & 0x20000000000000) != 0; } - struct InstIadd3R + readonly struct InstIadd3R { - private ulong _opcode; + private readonly ulong _opcode; public InstIadd3R(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -2862,9 +2862,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public HalfSelect Cpart => (HalfSelect)((_opcode >> 31) & 0x3); } - struct InstIadd3I + readonly struct InstIadd3I { - private ulong _opcode; + private readonly ulong _opcode; public InstIadd3I(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -2879,9 +2879,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool X => (_opcode & 0x1000000000000) != 0; } - struct InstIadd3C + readonly struct InstIadd3C { - private ulong _opcode; + private readonly ulong _opcode; public InstIadd3C(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -2897,9 +2897,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool X => (_opcode & 0x1000000000000) != 0; } - struct InstIcmpR + readonly struct InstIcmpR { - private ulong _opcode; + private readonly ulong _opcode; public InstIcmpR(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -2911,9 +2911,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool Signed => (_opcode & 0x1000000000000) != 0; } - struct InstIcmpI + readonly struct InstIcmpI { - private ulong _opcode; + private readonly ulong _opcode; public InstIcmpI(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -2925,9 +2925,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool Signed => (_opcode & 0x1000000000000) != 0; } - struct InstIcmpC + readonly struct InstIcmpC { - private ulong _opcode; + private readonly ulong _opcode; public InstIcmpC(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -2940,9 +2940,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool Signed => (_opcode & 0x1000000000000) != 0; } - struct InstIcmpRc + readonly struct InstIcmpRc { - private ulong _opcode; + private readonly ulong _opcode; public InstIcmpRc(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -2955,17 +2955,17 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool Signed => (_opcode & 0x1000000000000) != 0; } - struct InstIde + readonly struct InstIde { - private ulong _opcode; + private readonly ulong _opcode; public InstIde(ulong opcode) => _opcode = opcode; public int Imm16 => (int)((_opcode >> 20) & 0xFFFF); public bool Di => (_opcode & 0x20) != 0; } - struct InstIdpR + readonly struct InstIdpR { - private ulong _opcode; + private readonly ulong _opcode; public InstIdpR(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -2979,9 +2979,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool SrcBSign => (_opcode & 0x800000000000) != 0; } - struct InstIdpC + readonly struct InstIdpC { - private ulong _opcode; + private readonly ulong _opcode; public InstIdpC(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -2996,9 +2996,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool SrcBSign => (_opcode & 0x800000000000) != 0; } - struct InstImadR + readonly struct InstImadR { - private ulong _opcode; + private readonly ulong _opcode; public InstImadR(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -3015,9 +3015,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool ASigned => (_opcode & 0x1000000000000) != 0; } - struct InstImadI + readonly struct InstImadI { - private ulong _opcode; + private readonly ulong _opcode; public InstImadI(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -3034,9 +3034,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool ASigned => (_opcode & 0x1000000000000) != 0; } - struct InstImadC + readonly struct InstImadC { - private ulong _opcode; + private readonly ulong _opcode; public InstImadC(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -3054,9 +3054,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool ASigned => (_opcode & 0x1000000000000) != 0; } - struct InstImadRc + readonly struct InstImadRc { - private ulong _opcode; + private readonly ulong _opcode; public InstImadRc(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -3074,9 +3074,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool ASigned => (_opcode & 0x1000000000000) != 0; } - struct InstImad32i + readonly struct InstImad32i { - private ulong _opcode; + private readonly ulong _opcode; public InstImad32i(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -3090,9 +3090,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool Hilo => (_opcode & 0x20000000000000) != 0; } - struct InstImadspR + readonly struct InstImadspR { - private ulong _opcode; + private readonly ulong _opcode; public InstImadspR(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -3105,9 +3105,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public ImadspASelect CSelect => (ImadspASelect)((int)((_opcode >> 50) & 0x6) | (int)((_opcode >> 48) & 0x1)); } - struct InstImadspI + readonly struct InstImadspI { - private ulong _opcode; + private readonly ulong _opcode; public InstImadspI(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -3120,9 +3120,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public ImadspASelect CSelect => (ImadspASelect)((int)((_opcode >> 50) & 0x6) | (int)((_opcode >> 48) & 0x1)); } - struct InstImadspC + readonly struct InstImadspC { - private ulong _opcode; + private readonly ulong _opcode; public InstImadspC(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -3136,9 +3136,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public ImadspASelect CSelect => (ImadspASelect)((int)((_opcode >> 50) & 0x6) | (int)((_opcode >> 48) & 0x1)); } - struct InstImadspRc + readonly struct InstImadspRc { - private ulong _opcode; + private readonly ulong _opcode; public InstImadspRc(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -3152,9 +3152,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public ImadspASelect CSelect => (ImadspASelect)((int)((_opcode >> 50) & 0x6) | (int)((_opcode >> 48) & 0x1)); } - struct InstImnmxR + readonly struct InstImnmxR { - private ulong _opcode; + private readonly ulong _opcode; public InstImnmxR(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -3168,9 +3168,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool SrcPredInv => (_opcode & 0x40000000000) != 0; } - struct InstImnmxI + readonly struct InstImnmxI { - private ulong _opcode; + private readonly ulong _opcode; public InstImnmxI(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -3184,9 +3184,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool SrcPredInv => (_opcode & 0x40000000000) != 0; } - struct InstImnmxC + readonly struct InstImnmxC { - private ulong _opcode; + private readonly ulong _opcode; public InstImnmxC(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -3201,9 +3201,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool SrcPredInv => (_opcode & 0x40000000000) != 0; } - struct InstImulR + readonly struct InstImulR { - private ulong _opcode; + private readonly ulong _opcode; public InstImulR(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -3216,9 +3216,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool Hilo => (_opcode & 0x8000000000) != 0; } - struct InstImulI + readonly struct InstImulI { - private ulong _opcode; + private readonly ulong _opcode; public InstImulI(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -3231,9 +3231,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool Hilo => (_opcode & 0x8000000000) != 0; } - struct InstImulC + readonly struct InstImulC { - private ulong _opcode; + private readonly ulong _opcode; public InstImulC(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -3247,9 +3247,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool Hilo => (_opcode & 0x8000000000) != 0; } - struct InstImul32i + readonly struct InstImul32i { - private ulong _opcode; + private readonly ulong _opcode; public InstImul32i(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -3262,9 +3262,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool WriteCC => (_opcode & 0x10000000000000) != 0; } - struct InstIpa + readonly struct InstIpa { - private ulong _opcode; + private readonly ulong _opcode; public InstIpa(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -3281,9 +3281,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool SrcPredInv => (_opcode & 0x4000000000000) != 0; } - struct InstIsberd + readonly struct InstIsberd { - private ulong _opcode; + private readonly ulong _opcode; public InstIsberd(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -3295,9 +3295,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool P => (_opcode & 0x80000000) != 0; } - struct InstIscaddR + readonly struct InstIscaddR { - private ulong _opcode; + private readonly ulong _opcode; public InstIscaddR(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -3309,9 +3309,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public AvgMode AvgMode => (AvgMode)((_opcode >> 48) & 0x3); } - struct InstIscaddI + readonly struct InstIscaddI { - private ulong _opcode; + private readonly ulong _opcode; public InstIscaddI(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -3323,9 +3323,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public AvgMode AvgMode => (AvgMode)((_opcode >> 48) & 0x3); } - struct InstIscaddC + readonly struct InstIscaddC { - private ulong _opcode; + private readonly ulong _opcode; public InstIscaddC(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -3338,9 +3338,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public AvgMode AvgMode => (AvgMode)((_opcode >> 48) & 0x3); } - struct InstIscadd32i + readonly struct InstIscadd32i { - private ulong _opcode; + private readonly ulong _opcode; public InstIscadd32i(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -3351,9 +3351,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public int Imm5 => (int)((_opcode >> 53) & 0x1F); } - struct InstIsetR + readonly struct InstIsetR { - private ulong _opcode; + private readonly ulong _opcode; public InstIsetR(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -3370,9 +3370,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool X => (_opcode & 0x80000000000) != 0; } - struct InstIsetI + readonly struct InstIsetI { - private ulong _opcode; + private readonly ulong _opcode; public InstIsetI(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -3389,9 +3389,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool X => (_opcode & 0x80000000000) != 0; } - struct InstIsetC + readonly struct InstIsetC { - private ulong _opcode; + private readonly ulong _opcode; public InstIsetC(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -3409,9 +3409,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool X => (_opcode & 0x80000000000) != 0; } - struct InstIsetpR + readonly struct InstIsetpR { - private ulong _opcode; + private readonly ulong _opcode; public InstIsetpR(ulong opcode) => _opcode = opcode; public int SrcA => (int)((_opcode >> 8) & 0xFF); public int SrcB => (int)((_opcode >> 20) & 0xFF); @@ -3427,9 +3427,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public int DestPredInv => (int)(_opcode & 0x7); } - struct InstIsetpI + readonly struct InstIsetpI { - private ulong _opcode; + private readonly ulong _opcode; public InstIsetpI(ulong opcode) => _opcode = opcode; public int SrcA => (int)((_opcode >> 8) & 0xFF); public int Imm20 => (int)((_opcode >> 37) & 0x80000) | (int)((_opcode >> 20) & 0x7FFFF); @@ -3445,9 +3445,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public int DestPredInv => (int)(_opcode & 0x7); } - struct InstIsetpC + readonly struct InstIsetpC { - private ulong _opcode; + private readonly ulong _opcode; public InstIsetpC(ulong opcode) => _opcode = opcode; public int SrcA => (int)((_opcode >> 8) & 0xFF); public int CbufSlot => (int)((_opcode >> 34) & 0x1F); @@ -3464,18 +3464,18 @@ namespace Ryujinx.Graphics.Shader.Decoders public int DestPredInv => (int)(_opcode & 0x7); } - struct InstJcal + readonly struct InstJcal { - private ulong _opcode; + private readonly ulong _opcode; public InstJcal(ulong opcode) => _opcode = opcode; public int Imm32 => (int)(_opcode >> 20); public bool Ca => (_opcode & 0x20) != 0; public bool Inc => (_opcode & 0x40) != 0; } - struct InstJmp + readonly struct InstJmp { - private ulong _opcode; + private readonly ulong _opcode; public InstJmp(ulong opcode) => _opcode = opcode; public int SrcA => (int)((_opcode >> 8) & 0xFF); public int Pred => (int)((_opcode >> 16) & 0x7); @@ -3487,9 +3487,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool U => (_opcode & 0x80) != 0; } - struct InstJmx + readonly struct InstJmx { - private ulong _opcode; + private readonly ulong _opcode; public InstJmx(ulong opcode) => _opcode = opcode; public int SrcA => (int)((_opcode >> 8) & 0xFF); public int Pred => (int)((_opcode >> 16) & 0x7); @@ -3500,18 +3500,18 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool Lmt => (_opcode & 0x40) != 0; } - struct InstKil + readonly struct InstKil { - private ulong _opcode; + private readonly ulong _opcode; public InstKil(ulong opcode) => _opcode = opcode; public int Pred => (int)((_opcode >> 16) & 0x7); public bool PredInv => (_opcode & 0x80000) != 0; public Ccc Ccc => (Ccc)(_opcode & 0x1F); } - struct InstLd + readonly struct InstLd { - private ulong _opcode; + private readonly ulong _opcode; public InstLd(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -3524,9 +3524,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public int Imm32 => (int)(_opcode >> 20); } - struct InstLdc + readonly struct InstLdc { - private ulong _opcode; + private readonly ulong _opcode; public InstLdc(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -3538,9 +3538,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public int CbufOffset => (int)((_opcode >> 20) & 0xFFFF); } - struct InstLdg + readonly struct InstLdg { - private ulong _opcode; + private readonly ulong _opcode; public InstLdg(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -3552,9 +3552,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public int Imm24 => (int)((_opcode >> 20) & 0xFFFFFF); } - struct InstLdl + readonly struct InstLdl { - private ulong _opcode; + private readonly ulong _opcode; public InstLdl(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -3565,9 +3565,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public int Imm24 => (int)((_opcode >> 20) & 0xFFFFFF); } - struct InstLds + readonly struct InstLds { - private ulong _opcode; + private readonly ulong _opcode; public InstLds(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -3578,9 +3578,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public int Imm24 => (int)((_opcode >> 20) & 0xFFFFFF); } - struct InstLeaR + readonly struct InstLeaR { - private ulong _opcode; + private readonly ulong _opcode; public InstLeaR(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -3594,9 +3594,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public int DestPred => (int)((_opcode >> 48) & 0x7); } - struct InstLeaI + readonly struct InstLeaI { - private ulong _opcode; + private readonly ulong _opcode; public InstLeaI(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -3610,9 +3610,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public int DestPred => (int)((_opcode >> 48) & 0x7); } - struct InstLeaC + readonly struct InstLeaC { - private ulong _opcode; + private readonly ulong _opcode; public InstLeaC(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -3627,9 +3627,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public int DestPred => (int)((_opcode >> 48) & 0x7); } - struct InstLeaHiR + readonly struct InstLeaHiR { - private ulong _opcode; + private readonly ulong _opcode; public InstLeaHiR(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -3644,9 +3644,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public int DestPred => (int)((_opcode >> 48) & 0x7); } - struct InstLeaHiC + readonly struct InstLeaHiC { - private ulong _opcode; + private readonly ulong _opcode; public InstLeaHiC(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -3662,22 +3662,24 @@ namespace Ryujinx.Graphics.Shader.Decoders public int DestPred => (int)((_opcode >> 48) & 0x7); } - struct InstLepc + readonly struct InstLepc { - private ulong _opcode; +#pragma warning disable IDE0052 // Remove unread private member + private readonly ulong _opcode; +#pragma warning restore IDE0052 public InstLepc(ulong opcode) => _opcode = opcode; } - struct InstLongjmp + readonly struct InstLongjmp { - private ulong _opcode; + private readonly ulong _opcode; public InstLongjmp(ulong opcode) => _opcode = opcode; public Ccc Ccc => (Ccc)(_opcode & 0x1F); } - struct InstLopR + readonly struct InstLopR { - private ulong _opcode; + private readonly ulong _opcode; public InstLopR(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -3693,9 +3695,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool NegB => (_opcode & 0x10000000000) != 0; } - struct InstLopI + readonly struct InstLopI { - private ulong _opcode; + private readonly ulong _opcode; public InstLopI(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -3711,9 +3713,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool NegB => (_opcode & 0x10000000000) != 0; } - struct InstLopC + readonly struct InstLopC { - private ulong _opcode; + private readonly ulong _opcode; public InstLopC(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -3730,9 +3732,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool NegB => (_opcode & 0x10000000000) != 0; } - struct InstLop3R + readonly struct InstLop3R { - private ulong _opcode; + private readonly ulong _opcode; public InstLop3R(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -3747,9 +3749,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public int Imm => (int)((_opcode >> 28) & 0xFF); } - struct InstLop3I + readonly struct InstLop3I { - private ulong _opcode; + private readonly ulong _opcode; public InstLop3I(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -3762,9 +3764,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public int Imm => (int)((_opcode >> 48) & 0xFF); } - struct InstLop3C + readonly struct InstLop3C { - private ulong _opcode; + private readonly ulong _opcode; public InstLop3C(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -3778,9 +3780,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public int Imm => (int)((_opcode >> 48) & 0xFF); } - struct InstLop32i + readonly struct InstLop32i { - private ulong _opcode; + private readonly ulong _opcode; public InstLop32i(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -3794,9 +3796,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool NegB => (_opcode & 0x100000000000000) != 0; } - struct InstMembar + readonly struct InstMembar { - private ulong _opcode; + private readonly ulong _opcode; public InstMembar(ulong opcode) => _opcode = opcode; public int Pred => (int)((_opcode >> 16) & 0x7); public bool PredInv => (_opcode & 0x80000) != 0; @@ -3804,9 +3806,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public Ivall Ivall => (Ivall)(_opcode & 0x3); } - struct InstMovR + readonly struct InstMovR { - private ulong _opcode; + private readonly ulong _opcode; public InstMovR(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 20) & 0xFF); @@ -3815,9 +3817,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public int QuadMask => (int)((_opcode >> 39) & 0xF); } - struct InstMovI + readonly struct InstMovI { - private ulong _opcode; + private readonly ulong _opcode; public InstMovI(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int Imm20 => (int)((_opcode >> 37) & 0x80000) | (int)((_opcode >> 20) & 0x7FFFF); @@ -3826,9 +3828,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public int QuadMask => (int)((_opcode >> 39) & 0xF); } - struct InstMovC + readonly struct InstMovC { - private ulong _opcode; + private readonly ulong _opcode; public InstMovC(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int CbufSlot => (int)((_opcode >> 34) & 0x1F); @@ -3838,9 +3840,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public int QuadMask => (int)((_opcode >> 39) & 0xF); } - struct InstMov32i + readonly struct InstMov32i { - private ulong _opcode; + private readonly ulong _opcode; public InstMov32i(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int Imm32 => (int)(_opcode >> 20); @@ -3849,9 +3851,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public int QuadMask => (int)((_opcode >> 12) & 0xF); } - struct InstMufu + readonly struct InstMufu { - private ulong _opcode; + private readonly ulong _opcode; public InstMufu(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -3863,9 +3865,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool Sat => (_opcode & 0x4000000000000) != 0; } - struct InstNop + readonly struct InstNop { - private ulong _opcode; + private readonly ulong _opcode; public InstNop(ulong opcode) => _opcode = opcode; public int Pred => (int)((_opcode >> 16) & 0x7); public bool PredInv => (_opcode & 0x80000) != 0; @@ -3874,9 +3876,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public Ccc Ccc => (Ccc)((_opcode >> 8) & 0x1F); } - struct InstOutR + readonly struct InstOutR { - private ulong _opcode; + private readonly ulong _opcode; public InstOutR(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -3886,9 +3888,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public OutType OutType => (OutType)((_opcode >> 39) & 0x3); } - struct InstOutI + readonly struct InstOutI { - private ulong _opcode; + private readonly ulong _opcode; public InstOutI(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -3898,9 +3900,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public OutType OutType => (OutType)((_opcode >> 39) & 0x3); } - struct InstOutC + readonly struct InstOutC { - private ulong _opcode; + private readonly ulong _opcode; public InstOutC(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -3911,9 +3913,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public OutType OutType => (OutType)((_opcode >> 39) & 0x3); } - struct InstP2rR + readonly struct InstP2rR { - private ulong _opcode; + private readonly ulong _opcode; public InstP2rR(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -3924,9 +3926,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool Ccpr => (_opcode & 0x10000000000) != 0; } - struct InstP2rI + readonly struct InstP2rI { - private ulong _opcode; + private readonly ulong _opcode; public InstP2rI(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -3937,9 +3939,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool Ccpr => (_opcode & 0x10000000000) != 0; } - struct InstP2rC + readonly struct InstP2rC { - private ulong _opcode; + private readonly ulong _opcode; public InstP2rC(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -3951,32 +3953,32 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool Ccpr => (_opcode & 0x10000000000) != 0; } - struct InstPbk + readonly struct InstPbk { - private ulong _opcode; + private readonly ulong _opcode; public InstPbk(ulong opcode) => _opcode = opcode; public int Imm24 => (int)((_opcode >> 20) & 0xFFFFFF); public bool Ca => (_opcode & 0x20) != 0; } - struct InstPcnt + readonly struct InstPcnt { - private ulong _opcode; + private readonly ulong _opcode; public InstPcnt(ulong opcode) => _opcode = opcode; public int Imm24 => (int)((_opcode >> 20) & 0xFFFFFF); public bool Ca => (_opcode & 0x20) != 0; } - struct InstPexit + readonly struct InstPexit { - private ulong _opcode; + private readonly ulong _opcode; public InstPexit(ulong opcode) => _opcode = opcode; public int Imm24 => (int)((_opcode >> 20) & 0xFFFFFF); } - struct InstPixld + readonly struct InstPixld { - private ulong _opcode; + private readonly ulong _opcode; public InstPixld(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -3987,17 +3989,17 @@ namespace Ryujinx.Graphics.Shader.Decoders public int Imm8 => (int)((_opcode >> 20) & 0xFF); } - struct InstPlongjmp + readonly struct InstPlongjmp { - private ulong _opcode; + private readonly ulong _opcode; public InstPlongjmp(ulong opcode) => _opcode = opcode; public int Imm24 => (int)((_opcode >> 20) & 0xFFFFFF); public bool Ca => (_opcode & 0x20) != 0; } - struct InstPopcR + readonly struct InstPopcR { - private ulong _opcode; + private readonly ulong _opcode; public InstPopcR(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcB => (int)((_opcode >> 20) & 0xFF); @@ -4006,9 +4008,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool NegB => (_opcode & 0x10000000000) != 0; } - struct InstPopcI + readonly struct InstPopcI { - private ulong _opcode; + private readonly ulong _opcode; public InstPopcI(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int Imm20 => (int)((_opcode >> 37) & 0x80000) | (int)((_opcode >> 20) & 0x7FFFF); @@ -4017,9 +4019,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool NegB => (_opcode & 0x10000000000) != 0; } - struct InstPopcC + readonly struct InstPopcC { - private ulong _opcode; + private readonly ulong _opcode; public InstPopcC(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int CbufSlot => (int)((_opcode >> 34) & 0x1F); @@ -4029,18 +4031,18 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool NegB => (_opcode & 0x10000000000) != 0; } - struct InstPret + readonly struct InstPret { - private ulong _opcode; + private readonly ulong _opcode; public InstPret(ulong opcode) => _opcode = opcode; public bool Ca => (_opcode & 0x20) != 0; public int Imm24 => (int)((_opcode >> 20) & 0xFFFFFF); public bool Inc => (_opcode & 0x40) != 0; } - struct InstPrmtR + readonly struct InstPrmtR { - private ulong _opcode; + private readonly ulong _opcode; public InstPrmtR(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -4051,9 +4053,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public PMode PMode => (PMode)((_opcode >> 48) & 0xF); } - struct InstPrmtI + readonly struct InstPrmtI { - private ulong _opcode; + private readonly ulong _opcode; public InstPrmtI(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -4064,9 +4066,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public PMode PMode => (PMode)((_opcode >> 48) & 0xF); } - struct InstPrmtC + readonly struct InstPrmtC { - private ulong _opcode; + private readonly ulong _opcode; public InstPrmtC(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -4078,9 +4080,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public PMode PMode => (PMode)((_opcode >> 48) & 0xF); } - struct InstPrmtRc + readonly struct InstPrmtRc { - private ulong _opcode; + private readonly ulong _opcode; public InstPrmtRc(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -4092,9 +4094,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public PMode PMode => (PMode)((_opcode >> 48) & 0xF); } - struct InstPset + readonly struct InstPset { - private ulong _opcode; + private readonly ulong _opcode; public InstPset(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int Pred => (int)((_opcode >> 16) & 0x7); @@ -4111,9 +4113,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool BVal => (_opcode & 0x100000000000) != 0; } - struct InstPsetp + readonly struct InstPsetp { - private ulong _opcode; + private readonly ulong _opcode; public InstPsetp(ulong opcode) => _opcode = opcode; public int DestPred => (int)((_opcode >> 3) & 0x7); public int Pred => (int)((_opcode >> 16) & 0x7); @@ -4129,9 +4131,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public BoolOp BoolOpC => (BoolOp)((_opcode >> 45) & 0x3); } - struct InstR2b + readonly struct InstR2b { - private ulong _opcode; + private readonly ulong _opcode; public InstR2b(ulong opcode) => _opcode = opcode; public int SrcB => (int)((_opcode >> 20) & 0xFF); public int Pred => (int)((_opcode >> 16) & 0x7); @@ -4140,9 +4142,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public int Name => (int)((_opcode >> 28) & 0xF); } - struct InstR2pR + readonly struct InstR2pR { - private ulong _opcode; + private readonly ulong _opcode; public InstR2pR(ulong opcode) => _opcode = opcode; public int SrcA => (int)((_opcode >> 8) & 0xFF); public int SrcB => (int)((_opcode >> 20) & 0xFF); @@ -4152,9 +4154,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool Ccpr => (_opcode & 0x10000000000) != 0; } - struct InstR2pI + readonly struct InstR2pI { - private ulong _opcode; + private readonly ulong _opcode; public InstR2pI(ulong opcode) => _opcode = opcode; public int SrcA => (int)((_opcode >> 8) & 0xFF); public int Imm20 => (int)((_opcode >> 37) & 0x80000) | (int)((_opcode >> 20) & 0x7FFFF); @@ -4164,9 +4166,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool Ccpr => (_opcode & 0x10000000000) != 0; } - struct InstR2pC + readonly struct InstR2pC { - private ulong _opcode; + private readonly ulong _opcode; public InstR2pC(ulong opcode) => _opcode = opcode; public int SrcA => (int)((_opcode >> 8) & 0xFF); public int CbufSlot => (int)((_opcode >> 34) & 0x1F); @@ -4177,15 +4179,17 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool Ccpr => (_opcode & 0x10000000000) != 0; } - struct InstRam + readonly struct InstRam { - private ulong _opcode; +#pragma warning disable IDE0052 // Remove unread private member + private readonly ulong _opcode; +#pragma warning restore IDE0052 public InstRam(ulong opcode) => _opcode = opcode; } - struct InstRed + readonly struct InstRed { - private ulong _opcode; + private readonly ulong _opcode; public InstRed(ulong opcode) => _opcode = opcode; public int SrcA => (int)((_opcode >> 8) & 0xFF); public int SrcB => (int)(_opcode & 0xFF); @@ -4197,18 +4201,18 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool E => (_opcode & 0x1000000000000) != 0; } - struct InstRet + readonly struct InstRet { - private ulong _opcode; + private readonly ulong _opcode; public InstRet(ulong opcode) => _opcode = opcode; public int Pred => (int)((_opcode >> 16) & 0x7); public bool PredInv => (_opcode & 0x80000) != 0; public Ccc Ccc => (Ccc)(_opcode & 0x1F); } - struct InstRroR + readonly struct InstRroR { - private ulong _opcode; + private readonly ulong _opcode; public InstRroR(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcB => (int)((_opcode >> 20) & 0xFF); @@ -4219,9 +4223,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool RroOp => (_opcode & 0x8000000000) != 0; } - struct InstRroI + readonly struct InstRroI { - private ulong _opcode; + private readonly ulong _opcode; public InstRroI(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int Imm20 => (int)((_opcode >> 37) & 0x80000) | (int)((_opcode >> 20) & 0x7FFFF); @@ -4232,9 +4236,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool RroOp => (_opcode & 0x8000000000) != 0; } - struct InstRroC + readonly struct InstRroC { - private ulong _opcode; + private readonly ulong _opcode; public InstRroC(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int CbufSlot => (int)((_opcode >> 34) & 0x1F); @@ -4246,15 +4250,17 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool RroOp => (_opcode & 0x8000000000) != 0; } - struct InstRtt + readonly struct InstRtt { - private ulong _opcode; +#pragma warning disable IDE0052 // Remove unread private member + private readonly ulong _opcode; +#pragma warning restore IDE0052 public InstRtt(ulong opcode) => _opcode = opcode; } - struct InstS2r + readonly struct InstS2r { - private ulong _opcode; + private readonly ulong _opcode; public InstS2r(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int Pred => (int)((_opcode >> 16) & 0x7); @@ -4262,15 +4268,17 @@ namespace Ryujinx.Graphics.Shader.Decoders public SReg SReg => (SReg)((_opcode >> 20) & 0xFF); } - struct InstSam + readonly struct InstSam { - private ulong _opcode; +#pragma warning disable IDE0052 // Remove unread private member + private readonly ulong _opcode; +#pragma warning restore IDE0052 public InstSam(ulong opcode) => _opcode = opcode; } - struct InstSelR + readonly struct InstSelR { - private ulong _opcode; + private readonly ulong _opcode; public InstSelR(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -4281,9 +4289,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool SrcPredInv => (_opcode & 0x40000000000) != 0; } - struct InstSelI + readonly struct InstSelI { - private ulong _opcode; + private readonly ulong _opcode; public InstSelI(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -4294,9 +4302,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool SrcPredInv => (_opcode & 0x40000000000) != 0; } - struct InstSelC + readonly struct InstSelC { - private ulong _opcode; + private readonly ulong _opcode; public InstSelC(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -4308,23 +4316,23 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool SrcPredInv => (_opcode & 0x40000000000) != 0; } - struct InstSetcrsptr + readonly struct InstSetcrsptr { - private ulong _opcode; + private readonly ulong _opcode; public InstSetcrsptr(ulong opcode) => _opcode = opcode; public int SrcA => (int)((_opcode >> 8) & 0xFF); } - struct InstSetlmembase + readonly struct InstSetlmembase { - private ulong _opcode; + private readonly ulong _opcode; public InstSetlmembase(ulong opcode) => _opcode = opcode; public int SrcA => (int)((_opcode >> 8) & 0xFF); } - struct InstShfLR + readonly struct InstShfLR { - private ulong _opcode; + private readonly ulong _opcode; public InstShfLR(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -4338,9 +4346,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public MaxShift MaxShift => (MaxShift)((_opcode >> 37) & 0x3); } - struct InstShfRR + readonly struct InstShfRR { - private ulong _opcode; + private readonly ulong _opcode; public InstShfRR(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -4354,9 +4362,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public MaxShift MaxShift => (MaxShift)((_opcode >> 37) & 0x3); } - struct InstShfLI + readonly struct InstShfLI { - private ulong _opcode; + private readonly ulong _opcode; public InstShfLI(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -4370,9 +4378,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public int Imm6 => (int)((_opcode >> 20) & 0x3F); } - struct InstShfRI + readonly struct InstShfRI { - private ulong _opcode; + private readonly ulong _opcode; public InstShfRI(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -4386,9 +4394,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public int Imm6 => (int)((_opcode >> 20) & 0x3F); } - struct InstShfl + readonly struct InstShfl { - private ulong _opcode; + private readonly ulong _opcode; public InstShfl(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -4404,9 +4412,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public int DestPred => (int)((_opcode >> 48) & 0x7); } - struct InstShlR + readonly struct InstShlR { - private ulong _opcode; + private readonly ulong _opcode; public InstShlR(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -4418,9 +4426,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool M => (_opcode & 0x8000000000) != 0; } - struct InstShlI + readonly struct InstShlI { - private ulong _opcode; + private readonly ulong _opcode; public InstShlI(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -4432,9 +4440,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool M => (_opcode & 0x8000000000) != 0; } - struct InstShlC + readonly struct InstShlC { - private ulong _opcode; + private readonly ulong _opcode; public InstShlC(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -4447,9 +4455,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool M => (_opcode & 0x8000000000) != 0; } - struct InstShrR + readonly struct InstShrR { - private ulong _opcode; + private readonly ulong _opcode; public InstShrR(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -4463,9 +4471,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool M => (_opcode & 0x8000000000) != 0; } - struct InstShrI + readonly struct InstShrI { - private ulong _opcode; + private readonly ulong _opcode; public InstShrI(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -4479,9 +4487,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool M => (_opcode & 0x8000000000) != 0; } - struct InstShrC + readonly struct InstShrC { - private ulong _opcode; + private readonly ulong _opcode; public InstShrC(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -4496,17 +4504,17 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool M => (_opcode & 0x8000000000) != 0; } - struct InstSsy + readonly struct InstSsy { - private ulong _opcode; + private readonly ulong _opcode; public InstSsy(ulong opcode) => _opcode = opcode; public int Imm24 => (int)((_opcode >> 20) & 0xFFFFFF); public bool Ca => (_opcode & 0x20) != 0; } - struct InstSt + readonly struct InstSt { - private ulong _opcode; + private readonly ulong _opcode; public InstSt(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -4519,9 +4527,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public int Imm32 => (int)(_opcode >> 20); } - struct InstStg + readonly struct InstStg { - private ulong _opcode; + private readonly ulong _opcode; public InstStg(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -4533,9 +4541,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public int Imm24 => (int)((_opcode >> 20) & 0xFFFFFF); } - struct InstStl + readonly struct InstStl { - private ulong _opcode; + private readonly ulong _opcode; public InstStl(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -4546,17 +4554,17 @@ namespace Ryujinx.Graphics.Shader.Decoders public int Imm24 => (int)((_opcode >> 20) & 0xFFFFFF); } - struct InstStp + readonly struct InstStp { - private ulong _opcode; + private readonly ulong _opcode; public InstStp(ulong opcode) => _opcode = opcode; public bool Wait => (_opcode & 0x80000000) != 0; public int Imm8 => (int)((_opcode >> 20) & 0xFF); } - struct InstSts + readonly struct InstSts { - private ulong _opcode; + private readonly ulong _opcode; public InstSts(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -4566,9 +4574,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public int Imm24 => (int)((_opcode >> 20) & 0xFFFFFF); } - struct InstSuatomB + readonly struct InstSuatomB { - private ulong _opcode; + private readonly ulong _opcode; public InstSuatomB(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -4583,9 +4591,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool Ba => (_opcode & 0x10000000) != 0; } - struct InstSuatom + readonly struct InstSuatom { - private ulong _opcode; + private readonly ulong _opcode; public InstSuatom(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -4600,9 +4608,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool Ba => (_opcode & 0x10000000) != 0; } - struct InstSuatomB2 + readonly struct InstSuatomB2 { - private ulong _opcode; + private readonly ulong _opcode; public InstSuatomB2(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -4618,9 +4626,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool Ba => (_opcode & 0x10000000) != 0; } - struct InstSuatomCasB + readonly struct InstSuatomCasB { - private ulong _opcode; + private readonly ulong _opcode; public InstSuatomCasB(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -4635,9 +4643,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool Ba => (_opcode & 0x10000000) != 0; } - struct InstSuatomCas + readonly struct InstSuatomCas { - private ulong _opcode; + private readonly ulong _opcode; public InstSuatomCas(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -4652,9 +4660,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool Ba => (_opcode & 0x10000000) != 0; } - struct InstSuldDB + readonly struct InstSuldDB { - private ulong _opcode; + private readonly ulong _opcode; public InstSuldDB(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -4669,9 +4677,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public SuSize Size => (SuSize)((_opcode >> 20) & 0x7); } - struct InstSuldD + readonly struct InstSuldD { - private ulong _opcode; + private readonly ulong _opcode; public InstSuldD(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -4686,9 +4694,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public SuSize Size => (SuSize)((_opcode >> 20) & 0x7); } - struct InstSuldB + readonly struct InstSuldB { - private ulong _opcode; + private readonly ulong _opcode; public InstSuldB(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -4702,9 +4710,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public SuRgba Rgba => (SuRgba)((_opcode >> 20) & 0xF); } - struct InstSuld + readonly struct InstSuld { - private ulong _opcode; + private readonly ulong _opcode; public InstSuld(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -4718,9 +4726,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public SuRgba Rgba => (SuRgba)((_opcode >> 20) & 0xF); } - struct InstSuredB + readonly struct InstSuredB { - private ulong _opcode; + private readonly ulong _opcode; public InstSuredB(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -4734,9 +4742,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public SuatomSize Size => (SuatomSize)((_opcode >> 20) & 0x7); } - struct InstSured + readonly struct InstSured { - private ulong _opcode; + private readonly ulong _opcode; public InstSured(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -4750,9 +4758,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public SuatomSize Size => (SuatomSize)((_opcode >> 20) & 0x7); } - struct InstSustDB + readonly struct InstSustDB { - private ulong _opcode; + private readonly ulong _opcode; public InstSustDB(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -4766,9 +4774,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public SuSize Size => (SuSize)((_opcode >> 20) & 0x7); } - struct InstSustD + readonly struct InstSustD { - private ulong _opcode; + private readonly ulong _opcode; public InstSustD(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -4782,9 +4790,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public SuSize Size => (SuSize)((_opcode >> 20) & 0x7); } - struct InstSustB + readonly struct InstSustB { - private ulong _opcode; + private readonly ulong _opcode; public InstSustB(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -4797,9 +4805,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public SuRgba Rgba => (SuRgba)((_opcode >> 20) & 0xF); } - struct InstSust + readonly struct InstSust { - private ulong _opcode; + private readonly ulong _opcode; public InstSust(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -4812,18 +4820,18 @@ namespace Ryujinx.Graphics.Shader.Decoders public SuRgba Rgba => (SuRgba)((_opcode >> 20) & 0xF); } - struct InstSync + readonly struct InstSync { - private ulong _opcode; + private readonly ulong _opcode; public InstSync(ulong opcode) => _opcode = opcode; public int Pred => (int)((_opcode >> 16) & 0x7); public bool PredInv => (_opcode & 0x80000) != 0; public Ccc Ccc => (Ccc)(_opcode & 0x1F); } - struct InstTex + readonly struct InstTex { - private ulong _opcode; + private readonly ulong _opcode; public InstTex(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -4842,9 +4850,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool Nodep => (_opcode & 0x2000000000000) != 0; } - struct InstTexB + readonly struct InstTexB { - private ulong _opcode; + private readonly ulong _opcode; public InstTexB(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -4862,9 +4870,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool Nodep => (_opcode & 0x2000000000000) != 0; } - struct InstTexs + readonly struct InstTexs { - private ulong _opcode; + private readonly ulong _opcode; public InstTexs(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -4878,9 +4886,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public int Dest2 => (int)((_opcode >> 28) & 0xFF); } - struct InstTld + readonly struct InstTld { - private ulong _opcode; + private readonly ulong _opcode; public InstTld(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -4898,9 +4906,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public TexDim Dim => (TexDim)((_opcode >> 28) & 0x7); } - struct InstTldB + readonly struct InstTldB { - private ulong _opcode; + private readonly ulong _opcode; public InstTldB(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -4917,9 +4925,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public TexDim Dim => (TexDim)((_opcode >> 28) & 0x7); } - struct InstTlds + readonly struct InstTlds { - private ulong _opcode; + private readonly ulong _opcode; public InstTlds(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -4933,9 +4941,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public int Dest2 => (int)((_opcode >> 28) & 0xFF); } - struct InstTld4 + readonly struct InstTld4 { - private ulong _opcode; + private readonly ulong _opcode; public InstTld4(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -4954,9 +4962,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool Nodep => (_opcode & 0x2000000000000) != 0; } - struct InstTld4B + readonly struct InstTld4B { - private ulong _opcode; + private readonly ulong _opcode; public InstTld4B(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -4974,9 +4982,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool Nodep => (_opcode & 0x2000000000000) != 0; } - struct InstTld4s + readonly struct InstTld4s { - private ulong _opcode; + private readonly ulong _opcode; public InstTld4s(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -4991,9 +4999,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public int Dest2 => (int)((_opcode >> 28) & 0xFF); } - struct InstTmml + readonly struct InstTmml { - private ulong _opcode; + private readonly ulong _opcode; public InstTmml(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -5007,9 +5015,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public TexDim Dim => (TexDim)((_opcode >> 28) & 0x7); } - struct InstTmmlB + readonly struct InstTmmlB { - private ulong _opcode; + private readonly ulong _opcode; public InstTmmlB(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -5022,9 +5030,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public TexDim Dim => (TexDim)((_opcode >> 28) & 0x7); } - struct InstTxa + readonly struct InstTxa { - private ulong _opcode; + private readonly ulong _opcode; public InstTxa(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -5036,9 +5044,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public int WMask => (int)((_opcode >> 31) & 0xF); } - struct InstTxd + readonly struct InstTxd { - private ulong _opcode; + private readonly ulong _opcode; public InstTxd(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -5054,9 +5062,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public TexDim Dim => (TexDim)((_opcode >> 28) & 0x7); } - struct InstTxdB + readonly struct InstTxdB { - private ulong _opcode; + private readonly ulong _opcode; public InstTxdB(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -5071,9 +5079,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public TexDim Dim => (TexDim)((_opcode >> 28) & 0x7); } - struct InstTxq + readonly struct InstTxq { - private ulong _opcode; + private readonly ulong _opcode; public InstTxq(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -5085,9 +5093,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public TexQuery TexQuery => (TexQuery)((_opcode >> 22) & 0x3F); } - struct InstTxqB + readonly struct InstTxqB { - private ulong _opcode; + private readonly ulong _opcode; public InstTxqB(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -5098,9 +5106,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public TexQuery TexQuery => (TexQuery)((_opcode >> 22) & 0x3F); } - struct InstVabsdiff + readonly struct InstVabsdiff { - private ulong _opcode; + private readonly ulong _opcode; public InstVabsdiff(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -5117,9 +5125,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool BVideo => (_opcode & 0x4000000000000) != 0; } - struct InstVabsdiff4 + readonly struct InstVabsdiff4 { - private ulong _opcode; + private readonly ulong _opcode; public InstVabsdiff4(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -5138,9 +5146,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public BSelect4 Bsel4 => (BSelect4)((_opcode >> 28) & 0xF); } - struct InstVadd + readonly struct InstVadd { - private ulong _opcode; + private readonly ulong _opcode; public InstVadd(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -5159,9 +5167,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool BVideo => (_opcode & 0x4000000000000) != 0; } - struct InstVmad + readonly struct InstVmad { - private ulong _opcode; + private readonly ulong _opcode; public InstVmad(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -5179,9 +5187,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool BVideo => (_opcode & 0x4000000000000) != 0; } - struct InstVmnmx + readonly struct InstVmnmx { - private ulong _opcode; + private readonly ulong _opcode; public InstVmnmx(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -5200,9 +5208,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool BVideo => (_opcode & 0x4000000000000) != 0; } - struct InstVote + readonly struct InstVote { - private ulong _opcode; + private readonly ulong _opcode; public InstVote(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int Pred => (int)((_opcode >> 16) & 0x7); @@ -5213,9 +5221,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public int VpDest => (int)((_opcode >> 45) & 0x7); } - struct InstVotevtg + readonly struct InstVotevtg { - private ulong _opcode; + private readonly ulong _opcode; public InstVotevtg(ulong opcode) => _opcode = opcode; public int Pred => (int)((_opcode >> 16) & 0x7); public bool PredInv => (_opcode & 0x80000) != 0; @@ -5223,9 +5231,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public int Imm28 => (int)((_opcode >> 20) & 0xFFFFFFF); } - struct InstVset + readonly struct InstVset { - private ulong _opcode; + private readonly ulong _opcode; public InstVset(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -5241,9 +5249,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool BVideo => (_opcode & 0x4000000000000) != 0; } - struct InstVsetp + readonly struct InstVsetp { - private ulong _opcode; + private readonly ulong _opcode; public InstVsetp(ulong opcode) => _opcode = opcode; public int SrcA => (int)((_opcode >> 8) & 0xFF); public int SrcB => (int)((_opcode >> 20) & 0xFF); @@ -5261,9 +5269,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool BVideo => (_opcode & 0x4000000000000) != 0; } - struct InstVshl + readonly struct InstVshl { - private ulong _opcode; + private readonly ulong _opcode; public InstVshl(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -5281,9 +5289,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool BVideo => (_opcode & 0x4000000000000) != 0; } - struct InstVshr + readonly struct InstVshr { - private ulong _opcode; + private readonly ulong _opcode; public InstVshr(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -5301,9 +5309,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool BVideo => (_opcode & 0x4000000000000) != 0; } - struct InstXmadR + readonly struct InstXmadR { - private ulong _opcode; + private readonly ulong _opcode; public InstXmadR(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -5322,9 +5330,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool HiloB => (_opcode & 0x800000000) != 0; } - struct InstXmadI + readonly struct InstXmadI { - private ulong _opcode; + private readonly ulong _opcode; public InstXmadI(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -5342,9 +5350,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool Psl => (_opcode & 0x1000000000) != 0; } - struct InstXmadC + readonly struct InstXmadC { - private ulong _opcode; + private readonly ulong _opcode; public InstXmadC(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -5364,9 +5372,9 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool ASigned => (_opcode & 0x1000000000000) != 0; } - struct InstXmadRc + readonly struct InstXmadRc { - private ulong _opcode; + private readonly ulong _opcode; public InstXmadRc(ulong opcode) => _opcode = opcode; public int Dest => (int)(_opcode & 0xFF); public int SrcA => (int)((_opcode >> 8) & 0xFF); @@ -5383,4 +5391,4 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool BSigned => (_opcode & 0x2000000000000) != 0; public bool ASigned => (_opcode & 0x1000000000000) != 0; } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Decoders/InstName.cs b/src/Ryujinx.Graphics.Shader/Decoders/InstName.cs index 9c79b7a5c..04ad9391f 100644 --- a/src/Ryujinx.Graphics.Shader/Decoders/InstName.cs +++ b/src/Ryujinx.Graphics.Shader/Decoders/InstName.cs @@ -185,4 +185,4 @@ namespace Ryujinx.Graphics.Shader.Decoders Vshr, Xmad, } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Decoders/InstOp.cs b/src/Ryujinx.Graphics.Shader/Decoders/InstOp.cs index 39244e647..045257dc6 100644 --- a/src/Ryujinx.Graphics.Shader/Decoders/InstOp.cs +++ b/src/Ryujinx.Graphics.Shader/Decoders/InstOp.cs @@ -24,4 +24,4 @@ namespace Ryujinx.Graphics.Shader.Decoders return (ulong)((long)Address + (((int)(RawOpCode >> 20) << 8) >> 8) + 8); } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Decoders/InstProps.cs b/src/Ryujinx.Graphics.Shader/Decoders/InstProps.cs index 3f39e631d..14cdcd060 100644 --- a/src/Ryujinx.Graphics.Shader/Decoders/InstProps.cs +++ b/src/Ryujinx.Graphics.Shader/Decoders/InstProps.cs @@ -26,6 +26,6 @@ namespace Ryujinx.Graphics.Shader.Decoders Tex = 1 << 12, TexB = 1 << 13, Bra = 1 << 14, - NoPred = 1 << 15 + NoPred = 1 << 15, } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Decoders/InstTable.cs b/src/Ryujinx.Graphics.Shader/Decoders/InstTable.cs index eaa77930b..35367b8df 100644 --- a/src/Ryujinx.Graphics.Shader/Decoders/InstTable.cs +++ b/src/Ryujinx.Graphics.Shader/Decoders/InstTable.cs @@ -24,13 +24,14 @@ namespace Ryujinx.Graphics.Shader.Decoders } } - private static TableEntry[] _opCodes; + private static readonly TableEntry[] _opCodes; static InstTable() { _opCodes = new TableEntry[1 << EncodingBits]; #region Instructions +#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); @@ -325,6 +326,7 @@ namespace Ryujinx.Graphics.Shader.Decoders Add("0011011x00xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", InstName.Xmad, InstEmit.XmadI, InstProps.Rd | InstProps.Ra | InstProps.Ib | InstProps.Rc); Add("0100111xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", InstName.Xmad, InstEmit.XmadC, InstProps.Rd | InstProps.Ra | InstProps.Rc); Add("010100010xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", InstName.Xmad, InstEmit.XmadRc, InstProps.Rd | InstProps.Ra | InstProps.Rc); +#pragma warning restore IDE0055 #endregion } @@ -357,7 +359,7 @@ namespace Ryujinx.Graphics.Shader.Decoders xMask = ~xMask; - TableEntry entry = new TableEntry(name, emitter, props, xBits); + TableEntry entry = new(name, emitter, props, xBits); for (int index = 0; index < (1 << xBits); index++) { @@ -387,4 +389,4 @@ namespace Ryujinx.Graphics.Shader.Decoders return new InstOp(address, opCode, InstName.Invalid, null, InstProps.None); } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Decoders/Register.cs b/src/Ryujinx.Graphics.Shader/Decoders/Register.cs index e375096dd..2e6d61996 100644 --- a/src/Ryujinx.Graphics.Shader/Decoders/Register.cs +++ b/src/Ryujinx.Graphics.Shader/Decoders/Register.cs @@ -8,13 +8,13 @@ namespace Ryujinx.Graphics.Shader.Decoders public RegisterType Type { get; } - public bool IsRZ => Type == RegisterType.Gpr && Index == RegisterConsts.RegisterZeroIndex; + public bool IsRZ => Type == RegisterType.Gpr && Index == RegisterConsts.RegisterZeroIndex; public bool IsPT => Type == RegisterType.Predicate && Index == RegisterConsts.PredicateTrueIndex; public Register(int index, RegisterType type) { Index = index; - Type = type; + Type = type; } public override int GetHashCode() @@ -30,7 +30,7 @@ namespace Ryujinx.Graphics.Shader.Decoders public bool Equals(Register other) { return other.Index == Index && - other.Type == Type; + other.Type == Type; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Decoders/RegisterConsts.cs b/src/Ryujinx.Graphics.Shader/Decoders/RegisterConsts.cs index d381f9543..416fba966 100644 --- a/src/Ryujinx.Graphics.Shader/Decoders/RegisterConsts.cs +++ b/src/Ryujinx.Graphics.Shader/Decoders/RegisterConsts.cs @@ -2,12 +2,12 @@ namespace Ryujinx.Graphics.Shader.Decoders { static class RegisterConsts { - public const int GprsCount = 255; + public const int GprsCount = 255; public const int PredsCount = 7; public const int FlagsCount = 4; public const int TotalCount = GprsCount + PredsCount + FlagsCount; - public const int RegisterZeroIndex = GprsCount; + public const int RegisterZeroIndex = GprsCount; public const int PredicateTrueIndex = PredsCount; } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Decoders/RegisterType.cs b/src/Ryujinx.Graphics.Shader/Decoders/RegisterType.cs index 648f816a2..c870464ff 100644 --- a/src/Ryujinx.Graphics.Shader/Decoders/RegisterType.cs +++ b/src/Ryujinx.Graphics.Shader/Decoders/RegisterType.cs @@ -6,4 +6,4 @@ namespace Ryujinx.Graphics.Shader.Decoders Gpr, Predicate, } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/InputTopology.cs b/src/Ryujinx.Graphics.Shader/InputTopology.cs index da3329090..ebd2930e4 100644 --- a/src/Ryujinx.Graphics.Shader/InputTopology.cs +++ b/src/Ryujinx.Graphics.Shader/InputTopology.cs @@ -6,7 +6,7 @@ namespace Ryujinx.Graphics.Shader Lines, LinesAdjacency, Triangles, - TrianglesAdjacency + TrianglesAdjacency, } static class InputTopologyExtensions @@ -20,7 +20,7 @@ namespace Ryujinx.Graphics.Shader InputTopology.LinesAdjacency => "lines_adjacency", InputTopology.Triangles => "triangles", InputTopology.TrianglesAdjacency => "triangles_adjacency", - _ => "points" + _ => "points", }; } @@ -33,8 +33,8 @@ namespace Ryujinx.Graphics.Shader InputTopology.LinesAdjacency => 2, InputTopology.Triangles or InputTopology.TrianglesAdjacency => 3, - _ => 1 + _ => 1, }; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Instructions/AttributeMap.cs b/src/Ryujinx.Graphics.Shader/Instructions/AttributeMap.cs index 562fb8d53..5e572f5a7 100644 --- a/src/Ryujinx.Graphics.Shader/Instructions/AttributeMap.cs +++ b/src/Ryujinx.Graphics.Shader/Instructions/AttributeMap.cs @@ -1,7 +1,6 @@ using Ryujinx.Graphics.Shader.IntermediateRepresentation; using Ryujinx.Graphics.Shader.Translation; using System.Collections.Generic; - using static Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandHelper; namespace Ryujinx.Graphics.Shader.Instructions @@ -21,10 +20,10 @@ namespace Ryujinx.Graphics.Shader.Instructions Tessellation = TessellationControl | TessellationEvaluation, VertexTessellationGeometry = Vertex | Tessellation | Geometry, TessellationGeometryFragment = Tessellation | Geometry | Fragment, - AllGraphics = Vertex | Tessellation | Geometry | Fragment + AllGraphics = Vertex | Tessellation | Geometry | Fragment, } - private struct AttributeEntry + private readonly struct AttributeEntry { public int BaseOffset { get; } public AggregateType Type { get; } @@ -344,8 +343,8 @@ namespace Ryujinx.Graphics.Shader.Instructions AggregateType.Vector2 => 2, AggregateType.Vector3 => 3, AggregateType.Vector4 => 4, - _ => 1 + _ => 1, }; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Instructions/InstEmit.cs b/src/Ryujinx.Graphics.Shader/Instructions/InstEmit.cs index 963a5c656..f105505dd 100644 --- a/src/Ryujinx.Graphics.Shader/Instructions/InstEmit.cs +++ b/src/Ryujinx.Graphics.Shader/Instructions/InstEmit.cs @@ -7,352 +7,352 @@ namespace Ryujinx.Graphics.Shader.Instructions { public static void AtomCas(EmitterContext context) { - InstAtomCas op = context.GetOp(); + context.GetOp(); context.Config.GpuAccessor.Log("Shader instruction AtomCas is not implemented."); } public static void AtomsCas(EmitterContext context) { - InstAtomsCas op = context.GetOp(); + context.GetOp(); context.Config.GpuAccessor.Log("Shader instruction AtomsCas is not implemented."); } public static void B2r(EmitterContext context) { - InstB2r op = context.GetOp(); + context.GetOp(); context.Config.GpuAccessor.Log("Shader instruction B2r is not implemented."); } public static void Bpt(EmitterContext context) { - InstBpt op = context.GetOp(); + context.GetOp(); context.Config.GpuAccessor.Log("Shader instruction Bpt is not implemented."); } public static void Cctl(EmitterContext context) { - InstCctl op = context.GetOp(); + context.GetOp(); context.Config.GpuAccessor.Log("Shader instruction Cctl is not implemented."); } public static void Cctll(EmitterContext context) { - InstCctll op = context.GetOp(); + context.GetOp(); context.Config.GpuAccessor.Log("Shader instruction Cctll is not implemented."); } public static void Cctlt(EmitterContext context) { - InstCctlt op = context.GetOp(); + context.GetOp(); context.Config.GpuAccessor.Log("Shader instruction Cctlt is not implemented."); } public static void Cs2r(EmitterContext context) { - InstCs2r op = context.GetOp(); + context.GetOp(); context.Config.GpuAccessor.Log("Shader instruction Cs2r is not implemented."); } public static void FchkR(EmitterContext context) { - InstFchkR op = context.GetOp(); + context.GetOp(); context.Config.GpuAccessor.Log("Shader instruction FchkR is not implemented."); } public static void FchkI(EmitterContext context) { - InstFchkI op = context.GetOp(); + context.GetOp(); context.Config.GpuAccessor.Log("Shader instruction FchkI is not implemented."); } public static void FchkC(EmitterContext context) { - InstFchkC op = context.GetOp(); + context.GetOp(); context.Config.GpuAccessor.Log("Shader instruction FchkC is not implemented."); } public static void Getcrsptr(EmitterContext context) { - InstGetcrsptr op = context.GetOp(); + context.GetOp(); context.Config.GpuAccessor.Log("Shader instruction Getcrsptr is not implemented."); } public static void Getlmembase(EmitterContext context) { - InstGetlmembase op = context.GetOp(); + context.GetOp(); context.Config.GpuAccessor.Log("Shader instruction Getlmembase is not implemented."); } public static void Ide(EmitterContext context) { - InstIde op = context.GetOp(); + context.GetOp(); context.Config.GpuAccessor.Log("Shader instruction Ide is not implemented."); } public static void IdpR(EmitterContext context) { - InstIdpR op = context.GetOp(); + context.GetOp(); context.Config.GpuAccessor.Log("Shader instruction IdpR is not implemented."); } public static void IdpC(EmitterContext context) { - InstIdpC op = context.GetOp(); + context.GetOp(); context.Config.GpuAccessor.Log("Shader instruction IdpC is not implemented."); } public static void ImadspR(EmitterContext context) { - InstImadspR op = context.GetOp(); + context.GetOp(); context.Config.GpuAccessor.Log("Shader instruction ImadspR is not implemented."); } public static void ImadspI(EmitterContext context) { - InstImadspI op = context.GetOp(); + context.GetOp(); context.Config.GpuAccessor.Log("Shader instruction ImadspI is not implemented."); } public static void ImadspC(EmitterContext context) { - InstImadspC op = context.GetOp(); + context.GetOp(); context.Config.GpuAccessor.Log("Shader instruction ImadspC is not implemented."); } public static void ImadspRc(EmitterContext context) { - InstImadspRc op = context.GetOp(); + context.GetOp(); context.Config.GpuAccessor.Log("Shader instruction ImadspRc is not implemented."); } public static void Jcal(EmitterContext context) { - InstJcal op = context.GetOp(); + context.GetOp(); context.Config.GpuAccessor.Log("Shader instruction Jcal is not implemented."); } public static void Jmp(EmitterContext context) { - InstJmp op = context.GetOp(); + context.GetOp(); context.Config.GpuAccessor.Log("Shader instruction Jmp is not implemented."); } public static void Jmx(EmitterContext context) { - InstJmx op = context.GetOp(); + context.GetOp(); context.Config.GpuAccessor.Log("Shader instruction Jmx is not implemented."); } public static void Ld(EmitterContext context) { - InstLd op = context.GetOp(); + context.GetOp(); context.Config.GpuAccessor.Log("Shader instruction Ld is not implemented."); } public static void Lepc(EmitterContext context) { - InstLepc op = context.GetOp(); + context.GetOp(); context.Config.GpuAccessor.Log("Shader instruction Lepc is not implemented."); } public static void Longjmp(EmitterContext context) { - InstLongjmp op = context.GetOp(); + context.GetOp(); context.Config.GpuAccessor.Log("Shader instruction Longjmp is not implemented."); } public static void Pexit(EmitterContext context) { - InstPexit op = context.GetOp(); + context.GetOp(); context.Config.GpuAccessor.Log("Shader instruction Pexit is not implemented."); } public static void Pixld(EmitterContext context) { - InstPixld op = context.GetOp(); + context.GetOp(); context.Config.GpuAccessor.Log("Shader instruction Pixld is not implemented."); } public static void Plongjmp(EmitterContext context) { - InstPlongjmp op = context.GetOp(); + context.GetOp(); context.Config.GpuAccessor.Log("Shader instruction Plongjmp is not implemented."); } public static void Pret(EmitterContext context) { - InstPret op = context.GetOp(); + context.GetOp(); context.Config.GpuAccessor.Log("Shader instruction Pret is not implemented."); } public static void PrmtR(EmitterContext context) { - InstPrmtR op = context.GetOp(); + context.GetOp(); context.Config.GpuAccessor.Log("Shader instruction PrmtR is not implemented."); } public static void PrmtI(EmitterContext context) { - InstPrmtI op = context.GetOp(); + context.GetOp(); context.Config.GpuAccessor.Log("Shader instruction PrmtI is not implemented."); } public static void PrmtC(EmitterContext context) { - InstPrmtC op = context.GetOp(); + context.GetOp(); context.Config.GpuAccessor.Log("Shader instruction PrmtC is not implemented."); } public static void PrmtRc(EmitterContext context) { - InstPrmtRc op = context.GetOp(); + context.GetOp(); context.Config.GpuAccessor.Log("Shader instruction PrmtRc is not implemented."); } public static void R2b(EmitterContext context) { - InstR2b op = context.GetOp(); + context.GetOp(); context.Config.GpuAccessor.Log("Shader instruction R2b is not implemented."); } public static void Ram(EmitterContext context) { - InstRam op = context.GetOp(); + context.GetOp(); context.Config.GpuAccessor.Log("Shader instruction Ram is not implemented."); } public static void Rtt(EmitterContext context) { - InstRtt op = context.GetOp(); + context.GetOp(); context.Config.GpuAccessor.Log("Shader instruction Rtt is not implemented."); } public static void Sam(EmitterContext context) { - InstSam op = context.GetOp(); + context.GetOp(); context.Config.GpuAccessor.Log("Shader instruction Sam is not implemented."); } public static void Setcrsptr(EmitterContext context) { - InstSetcrsptr op = context.GetOp(); + context.GetOp(); context.Config.GpuAccessor.Log("Shader instruction Setcrsptr is not implemented."); } public static void Setlmembase(EmitterContext context) { - InstSetlmembase op = context.GetOp(); + context.GetOp(); context.Config.GpuAccessor.Log("Shader instruction Setlmembase is not implemented."); } public static void St(EmitterContext context) { - InstSt op = context.GetOp(); + context.GetOp(); context.Config.GpuAccessor.Log("Shader instruction St is not implemented."); } public static void Stp(EmitterContext context) { - InstStp op = context.GetOp(); + context.GetOp(); context.Config.GpuAccessor.Log("Shader instruction Stp is not implemented."); } public static void Txa(EmitterContext context) { - InstTxa op = context.GetOp(); + context.GetOp(); context.Config.GpuAccessor.Log("Shader instruction Txa is not implemented."); } public static void Vabsdiff(EmitterContext context) { - InstVabsdiff op = context.GetOp(); + context.GetOp(); context.Config.GpuAccessor.Log("Shader instruction Vabsdiff is not implemented."); } public static void Vabsdiff4(EmitterContext context) { - InstVabsdiff4 op = context.GetOp(); + context.GetOp(); context.Config.GpuAccessor.Log("Shader instruction Vabsdiff4 is not implemented."); } public static void Vadd(EmitterContext context) { - InstVadd op = context.GetOp(); + context.GetOp(); context.Config.GpuAccessor.Log("Shader instruction Vadd is not implemented."); } public static void Votevtg(EmitterContext context) { - InstVotevtg op = context.GetOp(); + context.GetOp(); context.Config.GpuAccessor.Log("Shader instruction Votevtg is not implemented."); } public static void Vset(EmitterContext context) { - InstVset op = context.GetOp(); + context.GetOp(); context.Config.GpuAccessor.Log("Shader instruction Vset is not implemented."); } public static void Vshl(EmitterContext context) { - InstVshl op = context.GetOp(); + context.GetOp(); context.Config.GpuAccessor.Log("Shader instruction Vshl is not implemented."); } public static void Vshr(EmitterContext context) { - InstVshr op = context.GetOp(); + context.GetOp(); context.Config.GpuAccessor.Log("Shader instruction Vshr is not implemented."); } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitAluHelper.cs b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitAluHelper.cs index 879075bae..4370560d7 100644 --- a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitAluHelper.cs +++ b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitAluHelper.cs @@ -2,7 +2,6 @@ using Ryujinx.Graphics.Shader.Decoders; using Ryujinx.Graphics.Shader.IntermediateRepresentation; using Ryujinx.Graphics.Shader.Translation; using System; - using static Ryujinx.Graphics.Shader.Instructions.InstEmitHelper; using static Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandHelper; @@ -18,7 +17,7 @@ namespace Ryujinx.Graphics.Shader.Instructions IDstFmt.S16 => short.MinValue, IDstFmt.U32 => uint.MinValue, IDstFmt.S32 => int.MinValue, - _ => throw new ArgumentException($"The type \"{type}\" is not a supported integer type.") + _ => throw new ArgumentException($"The type \"{type}\" is not a supported integer type."), }; } @@ -30,7 +29,7 @@ namespace Ryujinx.Graphics.Shader.Instructions IDstFmt.S16 => short.MaxValue, IDstFmt.U32 => uint.MaxValue, IDstFmt.S32 => int.MaxValue, - _ => throw new ArgumentException($"The type \"{type}\" is not a supported integer type.") + _ => throw new ArgumentException($"The type \"{type}\" is not a supported integer type."), }; } @@ -44,7 +43,7 @@ namespace Ryujinx.Graphics.Shader.Instructions ISrcDstFmt.S16 => short.MinValue, ISrcDstFmt.U32 => uint.MinValue, ISrcDstFmt.S32 => int.MinValue, - _ => throw new ArgumentException($"The type \"{type}\" is not a supported integer type.") + _ => throw new ArgumentException($"The type \"{type}\" is not a supported integer type."), }; } @@ -58,7 +57,7 @@ namespace Ryujinx.Graphics.Shader.Instructions ISrcDstFmt.S16 => short.MaxValue, ISrcDstFmt.U32 => uint.MaxValue, ISrcDstFmt.S32 => int.MaxValue, - _ => throw new ArgumentException($"The type \"{type}\" is not a supported integer type.") + _ => throw new ArgumentException($"The type \"{type}\" is not a supported integer type."), }; } @@ -69,7 +68,7 @@ namespace Ryujinx.Graphics.Shader.Instructions BoolOp.And => context.BitwiseAnd(input, pred), BoolOp.Or => context.BitwiseOr(input, pred), BoolOp.Xor => context.BitwiseExclusiveOr(input, pred), - _ => input + _ => input, }; } @@ -89,7 +88,7 @@ namespace Ryujinx.Graphics.Shader.Instructions VectorSelect.S8B3 => SignExtendTo32(context, context.ShiftRightU32(src, Const(24)), 8), VectorSelect.S16H0 => SignExtendTo32(context, context.ShiftRightU32(src, Const(0)), 16), VectorSelect.S16H1 => SignExtendTo32(context, context.ShiftRightU32(src, Const(16)), 16), - _ => src + _ => src, }; } @@ -134,7 +133,7 @@ namespace Ryujinx.Graphics.Shader.Instructions } context.Copy(GetZF(), context.FPCompareEqual(dest, zero, fpType)); - context.Copy(GetNF(), context.FPCompareLess (dest, zero, fpType)); + context.Copy(GetNF(), context.FPCompareLess(dest, zero, fpType)); } } @@ -157,4 +156,4 @@ namespace Ryujinx.Graphics.Shader.Instructions return result; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitAttribute.cs b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitAttribute.cs index 76b2e0783..1876847c4 100644 --- a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitAttribute.cs +++ b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitAttribute.cs @@ -33,7 +33,7 @@ namespace Ryujinx.Graphics.Shader.Instructions for (int index = 0; index < (int)op.AlSize + 1; index++) { - Register rd = new Register(op.Dest + index, RegisterType.Gpr); + Register rd = new(op.Dest + index, RegisterType.Gpr); if (rd.IsRZ) { @@ -91,7 +91,7 @@ namespace Ryujinx.Graphics.Shader.Instructions break; } - Register rd = new Register(op.SrcB + index, RegisterType.Gpr); + Register rd = new(op.SrcB + index, RegisterType.Gpr); if (op.Phys) { @@ -380,4 +380,4 @@ namespace Ryujinx.Graphics.Shader.Instructions return false; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitBarrier.cs b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitBarrier.cs index f3114c6e4..ae5e078f6 100644 --- a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitBarrier.cs +++ b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitBarrier.cs @@ -22,7 +22,9 @@ namespace Ryujinx.Graphics.Shader.Instructions public static void Depbar(EmitterContext context) { +#pragma warning disable IDE0059 // Remove unnecessary value assignment InstDepbar op = context.GetOp(); +#pragma warning restore IDE0059 // No operation. } @@ -41,4 +43,4 @@ namespace Ryujinx.Graphics.Shader.Instructions } } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitBitfield.cs b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitBitfield.cs index 719252696..3a8419698 100644 --- a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitBitfield.cs +++ b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitBitfield.cs @@ -191,4 +191,4 @@ namespace Ryujinx.Graphics.Shader.Instructions context.Copy(GetDest(rd), res); } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitConditionCode.cs b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitConditionCode.cs index 74ac76029..b5580a37a 100644 --- a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitConditionCode.cs +++ b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitConditionCode.cs @@ -1,7 +1,6 @@ using Ryujinx.Graphics.Shader.Decoders; using Ryujinx.Graphics.Shader.IntermediateRepresentation; using Ryujinx.Graphics.Shader.Translation; - using static Ryujinx.Graphics.Shader.Instructions.InstEmitAluHelper; using static Ryujinx.Graphics.Shader.Instructions.InstEmitHelper; using static Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandHelper; @@ -80,8 +79,8 @@ namespace Ryujinx.Graphics.Shader.Instructions Ccc.Oft => GetVF(), Ccc.Rle => context.BitwiseOr(GetNF(), GetZF()), Ccc.Rgt => context.BitwiseNot(context.BitwiseOr(GetNF(), GetZF())), - _ => Const(defaultCond) + _ => Const(defaultCond), }; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitConversion.cs b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitConversion.cs index bebd96dd9..8d59023ae 100644 --- a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitConversion.cs +++ b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitConversion.cs @@ -2,7 +2,6 @@ using Ryujinx.Graphics.Shader.Decoders; using Ryujinx.Graphics.Shader.IntermediateRepresentation; using Ryujinx.Graphics.Shader.Translation; using System; - using static Ryujinx.Graphics.Shader.Instructions.InstEmitAluHelper; using static Ryujinx.Graphics.Shader.Instructions.InstEmitHelper; using static Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandHelper; @@ -140,7 +139,7 @@ namespace Ryujinx.Graphics.Shader.Instructions IntegerRound.Floor => context.FPFloor(srcB, srcType.ToInstFPType()), IntegerRound.Ceil => context.FPCeiling(srcB, srcType.ToInstFPType()), IntegerRound.Trunc => context.FPTruncate(srcB, srcType.ToInstFPType()), - _ => srcB + _ => srcB, }; } @@ -191,7 +190,7 @@ namespace Ryujinx.Graphics.Shader.Instructions RoundMode2.Floor => context.FPFloor(srcB, fpType), RoundMode2.Ceil => context.FPCeiling(srcB, fpType), RoundMode2.Trunc => context.FPTruncate(srcB, fpType), - _ => srcB + _ => srcB, }; if (!isSignedInt) @@ -422,4 +421,4 @@ namespace Ryujinx.Graphics.Shader.Instructions return type == DstFmt.F64 ? Instruction.FP64 : Instruction.FP32; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitFloatArithmetic.cs b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitFloatArithmetic.cs index 29803c31e..ab643b5c6 100644 --- a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitFloatArithmetic.cs +++ b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitFloatArithmetic.cs @@ -1,7 +1,6 @@ using Ryujinx.Graphics.Shader.Decoders; using Ryujinx.Graphics.Shader.IntermediateRepresentation; using Ryujinx.Graphics.Shader.Translation; - using static Ryujinx.Graphics.Shader.Instructions.InstEmitAluHelper; using static Ryujinx.Graphics.Shader.Instructions.InstEmitHelper; using static Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandHelper; @@ -458,7 +457,7 @@ namespace Ryujinx.Graphics.Shader.Instructions MultiplyScale.M2 => ConstF(2f), MultiplyScale.M4 => ConstF(4f), MultiplyScale.M8 => ConstF(8f), - _ => ConstF(1f) // Invalid, behave as if it had no scale. + _ => ConstF(1f), // Invalid, behave as if it had no scale. }; if (scaleConst.AsFloat() == 1f) @@ -529,4 +528,4 @@ namespace Ryujinx.Graphics.Shader.Instructions context.Copy(GetDest(rd), GetHalfPacked(context, swizzle, res, rd)); } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitFloatComparison.cs b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitFloatComparison.cs index 8f99ddb3c..59ad7a5de 100644 --- a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitFloatComparison.cs +++ b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitFloatComparison.cs @@ -2,7 +2,6 @@ using Ryujinx.Graphics.Shader.Decoders; using Ryujinx.Graphics.Shader.IntermediateRepresentation; using Ryujinx.Graphics.Shader.Translation; using System; - using static Ryujinx.Graphics.Shader.Instructions.InstEmitAluHelper; using static Ryujinx.Graphics.Shader.Instructions.InstEmitHelper; using static Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandHelper; @@ -484,8 +483,8 @@ namespace Ryujinx.Graphics.Shader.Instructions } else { - Operand low = context.BitwiseAnd(res[0], Const(0xffff)); - Operand high = context.ShiftLeft (res[1], Const(16)); + Operand low = context.BitwiseAnd(res[0], Const(0xffff)); + Operand high = context.ShiftLeft(res[1], Const(16)); Operand packed = context.BitwiseOr(low, high); @@ -546,20 +545,16 @@ namespace Ryujinx.Graphics.Shader.Instructions } else { - Instruction inst; - - switch (cond & ~FComp.Nan) + var inst = (cond & ~FComp.Nan) switch { - case FComp.Lt: inst = Instruction.CompareLess; break; - case FComp.Eq: inst = Instruction.CompareEqual; break; - case FComp.Le: inst = Instruction.CompareLessOrEqual; break; - case FComp.Gt: inst = Instruction.CompareGreater; break; - case FComp.Ne: inst = Instruction.CompareNotEqual; break; - case FComp.Ge: inst = Instruction.CompareGreaterOrEqual; break; - - default: throw new ArgumentException($"Unexpected condition \"{cond}\"."); - } - + FComp.Lt => Instruction.CompareLess, + FComp.Eq => Instruction.CompareEqual, + FComp.Le => Instruction.CompareLessOrEqual, + FComp.Gt => Instruction.CompareGreater, + FComp.Ne => Instruction.CompareNotEqual, + FComp.Ge => Instruction.CompareGreaterOrEqual, + _ => throw new ArgumentException($"Unexpected condition \"{cond}\"."), + }; res = context.Add(inst | fpType, Local(), srcA, srcB); if ((cond & FComp.Nan) != 0) @@ -572,4 +567,4 @@ namespace Ryujinx.Graphics.Shader.Instructions return res; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitFloatMinMax.cs b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitFloatMinMax.cs index 412a5305a..5757e4fb0 100644 --- a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitFloatMinMax.cs +++ b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitFloatMinMax.cs @@ -103,4 +103,4 @@ namespace Ryujinx.Graphics.Shader.Instructions SetFPZnFlags(context, res, writeCC, fpType); } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitFlowControl.cs b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitFlowControl.cs index 736963552..fc1a696fa 100644 --- a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitFlowControl.cs +++ b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitFlowControl.cs @@ -3,8 +3,6 @@ using Ryujinx.Graphics.Shader.IntermediateRepresentation; using Ryujinx.Graphics.Shader.Translation; using System.Collections.Generic; using System.Linq; - -using static Ryujinx.Graphics.Shader.Instructions.InstEmitHelper; using static Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandHelper; namespace Ryujinx.Graphics.Shader.Instructions @@ -13,14 +11,14 @@ namespace Ryujinx.Graphics.Shader.Instructions { public static void Bra(EmitterContext context) { - InstBra op = context.GetOp(); + context.GetOp(); EmitBranch(context, context.CurrBlock.Successors[^1].Address); } public static void Brk(EmitterContext context) { - InstBrk op = context.GetOp(); + context.GetOp(); EmitBrkContSync(context); } @@ -123,7 +121,7 @@ namespace Ryujinx.Graphics.Shader.Instructions public static void Cal(EmitterContext context) { - InstCal op = context.GetOp(); + context.GetOp(); DecodedFunction function = context.Program.GetFunctionByAddress(context.CurrOp.GetAbsoluteAddress()); @@ -147,7 +145,7 @@ namespace Ryujinx.Graphics.Shader.Instructions public static void Cont(EmitterContext context) { - InstCont op = context.GetOp(); + context.GetOp(); EmitBrkContSync(context); } @@ -185,28 +183,28 @@ namespace Ryujinx.Graphics.Shader.Instructions public static void Kil(EmitterContext context) { - InstKil op = context.GetOp(); + context.GetOp(); context.Discard(); } public static void Pbk(EmitterContext context) { - InstPbk op = context.GetOp(); + context.GetOp(); EmitPbkPcntSsy(context); } public static void Pcnt(EmitterContext context) { - InstPcnt op = context.GetOp(); + context.GetOp(); EmitPbkPcntSsy(context); } public static void Ret(EmitterContext context) { - InstRet op = context.GetOp(); + context.GetOp(); if (context.IsNonMain) { @@ -220,14 +218,14 @@ namespace Ryujinx.Graphics.Shader.Instructions public static void Ssy(EmitterContext context) { - InstSsy op = context.GetOp(); + context.GetOp(); EmitPbkPcntSsy(context); } public static void Sync(EmitterContext context) { - InstSync op = context.GetOp(); + context.GetOp(); EmitBrkContSync(context); } @@ -275,7 +273,7 @@ namespace Ryujinx.Graphics.Shader.Instructions private static void EmitBranch(EmitterContext context, ulong address) { InstOp op = context.CurrOp; - InstConditional opCond = new InstConditional(op.RawOpCode); + InstConditional opCond = new(op.RawOpCode); // If we're branching to the next instruction, then the branch // is useless and we can ignore it. @@ -321,4 +319,4 @@ namespace Ryujinx.Graphics.Shader.Instructions } } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitHelper.cs b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitHelper.cs index 0ba4667ea..8638fb8f2 100644 --- a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitHelper.cs +++ b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitHelper.cs @@ -3,7 +3,6 @@ using Ryujinx.Graphics.Shader.IntermediateRepresentation; using Ryujinx.Graphics.Shader.Translation; using System; using System.Runtime.CompilerServices; - using static Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandHelper; namespace Ryujinx.Graphics.Shader.Instructions @@ -111,7 +110,7 @@ namespace Ryujinx.Graphics.Shader.Instructions return new Operand[] { ConstF((float)Unsafe.As(ref low)), - ConstF((float)Unsafe.As(ref high)) + ConstF((float)Unsafe.As(ref high)), }; } @@ -123,7 +122,7 @@ namespace Ryujinx.Graphics.Shader.Instructions return new Operand[] { ConstF((float)Unsafe.As(ref low)), - ConstF((float)Unsafe.As(ref high)) + ConstF((float)Unsafe.As(ref high)), }; } @@ -139,56 +138,51 @@ namespace Ryujinx.Graphics.Shader.Instructions public static Operand[] GetHalfUnpacked(EmitterContext context, Operand src, HalfSwizzle swizzle) { - switch (swizzle) + return swizzle switch { - case HalfSwizzle.F16: - return new Operand[] - { + HalfSwizzle.F16 => new Operand[] + { context.UnpackHalf2x16Low (src), - context.UnpackHalf2x16High(src) - }; - - case HalfSwizzle.F32: return new Operand[] { src, src }; - - case HalfSwizzle.H0H0: - return new Operand[] + context.UnpackHalf2x16High(src), + }, + HalfSwizzle.F32 => new Operand[] { src, src }, + HalfSwizzle.H0H0 => new Operand[] { context.UnpackHalf2x16Low(src), - context.UnpackHalf2x16Low(src) - }; - - case HalfSwizzle.H1H1: - return new Operand[] + context.UnpackHalf2x16Low(src), + }, + HalfSwizzle.H1H1 => new Operand[] { context.UnpackHalf2x16High(src), - context.UnpackHalf2x16High(src) - }; - } - - throw new ArgumentException($"Invalid swizzle \"{swizzle}\"."); + context.UnpackHalf2x16High(src), + }, + _ => throw new ArgumentException($"Invalid swizzle \"{swizzle}\"."), + }; } public static Operand GetHalfPacked(EmitterContext context, OFmt swizzle, Operand[] results, int rd) { switch (swizzle) { - case OFmt.F16: return context.PackHalf2x16(results[0], results[1]); + case OFmt.F16: + return context.PackHalf2x16(results[0], results[1]); - case OFmt.F32: return results[0]; + case OFmt.F32: + return results[0]; case OFmt.MrgH0: - { - Operand h1 = GetHalfDest(context, rd, isHigh: true); + { + Operand h1 = GetHalfDest(context, rd, isHigh: true); - return context.PackHalf2x16(results[0], h1); - } + return context.PackHalf2x16(results[0], h1); + } case OFmt.MrgH1: - { - Operand h0 = GetHalfDest(context, rd, isHigh: false); + { + Operand h0 = GetHalfDest(context, rd, isHigh: false); - return context.PackHalf2x16(h0, results[1]); - } + return context.PackHalf2x16(h0, results[1]); + } } throw new ArgumentException($"Invalid swizzle \"{swizzle}\"."); @@ -263,4 +257,4 @@ namespace Ryujinx.Graphics.Shader.Instructions return context.BitwiseAnd(src, Const(mask)); } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitIntegerArithmetic.cs b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitIntegerArithmetic.cs index 374e3d614..c06f4671f 100644 --- a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitIntegerArithmetic.cs +++ b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitIntegerArithmetic.cs @@ -510,7 +510,9 @@ 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 aHigh = context.IAdd(aHigh, aLowCOut); } @@ -696,4 +698,4 @@ namespace Ryujinx.Graphics.Shader.Instructions SetZnFlags(context, res, setCC: true, extended: extended); } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitIntegerComparison.cs b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitIntegerComparison.cs index dcdb189fb..18d4e3d19 100644 --- a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitIntegerComparison.cs +++ b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitIntegerComparison.cs @@ -2,7 +2,6 @@ using Ryujinx.Graphics.Shader.Decoders; using Ryujinx.Graphics.Shader.IntermediateRepresentation; using Ryujinx.Graphics.Shader.Translation; using System; - using static Ryujinx.Graphics.Shader.Instructions.InstEmitAluHelper; using static Ryujinx.Graphics.Shader.Instructions.InstEmitHelper; using static Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandHelper; @@ -220,7 +219,9 @@ 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 switch (cond) { @@ -287,17 +288,25 @@ namespace Ryujinx.Graphics.Shader.Instructions IComp.Gt => Instruction.CompareGreaterU32, IComp.Ne => Instruction.CompareNotEqual, IComp.Ge => Instruction.CompareGreaterOrEqualU32, - _ => throw new InvalidOperationException($"Unexpected condition \"{cond}\".") + _ => throw new InvalidOperationException($"Unexpected condition \"{cond}\"."), }; if (isSigned) { switch (cond) { - case IComp.Lt: inst = Instruction.CompareLess; break; - case IComp.Le: inst = Instruction.CompareLessOrEqual; break; - case IComp.Gt: inst = Instruction.CompareGreater; break; - case IComp.Ge: inst = Instruction.CompareGreaterOrEqual; break; + case IComp.Lt: + inst = Instruction.CompareLess; + break; + case IComp.Le: + inst = Instruction.CompareLessOrEqual; + break; + case IComp.Gt: + inst = Instruction.CompareGreater; + break; + case IComp.Ge: + inst = Instruction.CompareGreaterOrEqual; + break; } } @@ -307,4 +316,4 @@ namespace Ryujinx.Graphics.Shader.Instructions return res; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitIntegerLogical.cs b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitIntegerLogical.cs index 1f3f66ae4..5993c93dd 100644 --- a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitIntegerLogical.cs +++ b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitIntegerLogical.cs @@ -1,7 +1,6 @@ using Ryujinx.Graphics.Shader.Decoders; using Ryujinx.Graphics.Shader.IntermediateRepresentation; using Ryujinx.Graphics.Shader.Translation; - using static Ryujinx.Graphics.Shader.Instructions.InstEmitAluHelper; using static Ryujinx.Graphics.Shader.Instructions.InstEmitHelper; using static Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandHelper; @@ -103,10 +102,10 @@ namespace Ryujinx.Graphics.Shader.Instructions Operand res = logicOp switch { - LogicOp.And => res = context.BitwiseAnd(srcA, srcB), - LogicOp.Or => res = context.BitwiseOr(srcA, srcB), - LogicOp.Xor => res = context.BitwiseExclusiveOr(srcA, srcB), - _ => srcB + LogicOp.And => context.BitwiseAnd(srcA, srcB), + LogicOp.Or => context.BitwiseOr(srcA, srcB), + LogicOp.Xor => context.BitwiseExclusiveOr(srcA, srcB), + _ => srcB, }; EmitLopPredWrite(context, res, predOp, destPred); @@ -164,4 +163,4 @@ namespace Ryujinx.Graphics.Shader.Instructions } } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitIntegerMinMax.cs b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitIntegerMinMax.cs index 73930ed1f..739e94413 100644 --- a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitIntegerMinMax.cs +++ b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitIntegerMinMax.cs @@ -68,4 +68,4 @@ namespace Ryujinx.Graphics.Shader.Instructions // TODO: X flags. } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitMemory.cs b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitMemory.cs index 40312f4a4..006c14b54 100644 --- a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitMemory.cs +++ b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitMemory.cs @@ -2,7 +2,6 @@ using Ryujinx.Graphics.Shader.Decoders; using Ryujinx.Graphics.Shader.IntermediateRepresentation; using Ryujinx.Graphics.Shader.Translation; using System.Numerics; - using static Ryujinx.Graphics.Shader.Instructions.InstEmitHelper; using static Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandHelper; @@ -48,7 +47,7 @@ namespace Ryujinx.Graphics.Shader.Instructions AtomsSize.S32 => AtomSize.S32, AtomsSize.U64 => AtomSize.U64, AtomsSize.S64 => AtomSize.S64, - _ => AtomSize.U32 + _ => AtomSize.U32, }; Operand id = Const(context.Config.ResourceManager.SharedMemoryId); @@ -85,7 +84,7 @@ namespace Ryujinx.Graphics.Shader.Instructions for (int index = 0; index < count; index++) { - Register dest = new Register(op.Dest + index, RegisterType.Gpr); + Register dest = new(op.Dest + index, RegisterType.Gpr); if (dest.IsRZ) { @@ -309,14 +308,14 @@ namespace Ryujinx.Graphics.Shader.Instructions { LsSize2.B64 => 2, LsSize2.B128 => 4, - _ => 1 + _ => 1, }; Operand baseOffset = context.Copy(srcA); for (int index = 0; index < count; index++) { - Register dest = new Register(rd + index, RegisterType.Gpr); + Register dest = new(rd + index, RegisterType.Gpr); if (dest.IsRZ) { @@ -354,7 +353,7 @@ namespace Ryujinx.Graphics.Shader.Instructions for (int index = 0; index < count; index++) { - Register dest = new Register(rd + index, RegisterType.Gpr); + Register dest = new(rd + index, RegisterType.Gpr); if (dest.IsRZ) { @@ -390,7 +389,7 @@ namespace Ryujinx.Graphics.Shader.Instructions { LsSize2.B64 => 2, LsSize2.B128 => 4, - _ => 1 + _ => 1, }; Operand baseOffset = context.Copy(srcA); @@ -476,22 +475,18 @@ namespace Ryujinx.Graphics.Shader.Instructions LsSize.S8 => StorageKind.GlobalMemoryS8, LsSize.U16 => StorageKind.GlobalMemoryU16, LsSize.S16 => StorageKind.GlobalMemoryS16, - _ => StorageKind.GlobalMemory + _ => StorageKind.GlobalMemory, }; } private static int GetVectorCount(LsSize size) { - switch (size) + return size switch { - case LsSize.B64: - return 2; - case LsSize.B128: - case LsSize.UB128: - return 4; - } - - return 1; + LsSize.B64 => 2, + LsSize.B128 or LsSize.UB128 => 4, + _ => 1, + }; } private static (Operand, Operand) Get40BitsAddress( @@ -544,10 +539,18 @@ namespace Ryujinx.Graphics.Shader.Instructions switch (size) { - case LsSize.U8: value = ZeroExtendTo32(context, value, 8); break; - case LsSize.U16: value = ZeroExtendTo32(context, value, 16); break; - case LsSize.S8: value = SignExtendTo32(context, value, 8); break; - case LsSize.S16: value = SignExtendTo32(context, value, 16); break; + case LsSize.U8: + value = ZeroExtendTo32(context, value, 8); + break; + case LsSize.U16: + value = ZeroExtendTo32(context, value, 16); + break; + case LsSize.S8: + value = SignExtendTo32(context, value, 8); + break; + case LsSize.S16: + value = SignExtendTo32(context, value, 16); + break; } return value; @@ -578,4 +581,4 @@ namespace Ryujinx.Graphics.Shader.Instructions return value; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitMove.cs b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitMove.cs index e12177f7d..f6c3bf6f0 100644 --- a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitMove.cs +++ b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitMove.cs @@ -212,7 +212,7 @@ namespace Ryujinx.Graphics.Shader.Instructions int count = ccpr ? RegisterConsts.FlagsCount : RegisterConsts.PredsCount; RegisterType type = ccpr ? RegisterType.Flag : RegisterType.Predicate; int shift = (int)byteSel * 8; - + for (int bit = 0; bit < count; bit++) { Operand flag = Register(bit, type); @@ -228,4 +228,4 @@ namespace Ryujinx.Graphics.Shader.Instructions context.Copy(GetDest(rd), res); } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitMultifunction.cs b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitMultifunction.cs index 1ea7d3214..86f154bdb 100644 --- a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitMultifunction.cs +++ b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitMultifunction.cs @@ -94,4 +94,4 @@ namespace Ryujinx.Graphics.Shader.Instructions context.Copy(GetDest(rd), srcB); } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitNop.cs b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitNop.cs index 011440071..28ee927d8 100644 --- a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitNop.cs +++ b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitNop.cs @@ -7,9 +7,9 @@ namespace Ryujinx.Graphics.Shader.Instructions { public static void Nop(EmitterContext context) { - InstNop op = context.GetOp(); + context.GetOp(); // No operation. } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitPredicate.cs b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitPredicate.cs index 79919624e..630162ade 100644 --- a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitPredicate.cs +++ b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitPredicate.cs @@ -113,4 +113,4 @@ namespace Ryujinx.Graphics.Shader.Instructions context.Copy(dest, res); } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitShift.cs b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitShift.cs index 2873cad88..ee0dac155 100644 --- a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitShift.cs +++ b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitShift.cs @@ -246,4 +246,4 @@ namespace Ryujinx.Graphics.Shader.Instructions context.Copy(GetDest(rd), res); } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitSurface.cs b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitSurface.cs index 3d94b8938..78fc313d8 100644 --- a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitSurface.cs +++ b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitSurface.cs @@ -4,7 +4,6 @@ using Ryujinx.Graphics.Shader.Translation; using System; using System.Collections.Generic; using System.Numerics; - using static Ryujinx.Graphics.Shader.Instructions.InstEmitHelper; using static Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandHelper; @@ -221,7 +220,7 @@ namespace Ryujinx.Graphics.Shader.Instructions Operand destOperand = dest != RegisterConsts.RegisterZeroIndex ? Register(dest, RegisterType.Gpr) : null; - List sourcesList = new List(); + List sourcesList = new(); if (isBindless) { @@ -325,7 +324,7 @@ namespace Ryujinx.Graphics.Shader.Instructions return context.Copy(Register(srcA++, RegisterType.Gpr)); } - List sourcesList = new List(); + List sourcesList = new(); if (isBindless) { @@ -445,10 +444,18 @@ namespace Ryujinx.Graphics.Shader.Instructions switch (size) { - case SuSize.U8: context.Copy(dests[0], ZeroExtendTo32(context, dests[0], 8)); break; - case SuSize.U16: context.Copy(dests[0], ZeroExtendTo32(context, dests[0], 16)); break; - case SuSize.S8: context.Copy(dests[0], SignExtendTo32(context, dests[0], 8)); break; - case SuSize.S16: context.Copy(dests[0], SignExtendTo32(context, dests[0], 16)); break; + case SuSize.U8: + context.Copy(dests[0], ZeroExtendTo32(context, dests[0], 8)); + break; + case SuSize.U16: + context.Copy(dests[0], ZeroExtendTo32(context, dests[0], 16)); + break; + case SuSize.S8: + context.Copy(dests[0], SignExtendTo32(context, dests[0], 8)); + break; + case SuSize.S16: + context.Copy(dests[0], SignExtendTo32(context, dests[0], 16)); + break; } } } @@ -493,7 +500,7 @@ namespace Ryujinx.Graphics.Shader.Instructions return context.Copy(Register(srcB++, RegisterType.Gpr)); } - List sourcesList = new List(); + List sourcesList = new(); if (isBindless) { @@ -600,7 +607,7 @@ namespace Ryujinx.Graphics.Shader.Instructions return context.Copy(Register(srcB++, RegisterType.Gpr)); } - List sourcesList = new List(); + List sourcesList = new(); if (isBindless) { @@ -699,7 +706,7 @@ namespace Ryujinx.Graphics.Shader.Instructions SuatomSize.S64 => 3, SuatomSize.Sd32 => 2, SuatomSize.Sd64 => 3, - _ => 2 + _ => 2, }; } @@ -715,7 +722,7 @@ namespace Ryujinx.Graphics.Shader.Instructions SuatomSize.S64 => TextureFormat.R32G32Uint, SuatomSize.Sd32 => TextureFormat.R32Uint, SuatomSize.Sd64 => TextureFormat.R32G32Uint, - _ => TextureFormat.R32Uint + _ => TextureFormat.R32Uint, }; } @@ -732,7 +739,7 @@ namespace Ryujinx.Graphics.Shader.Instructions SuatomOp.Or => TextureFlags.BitwiseOr, SuatomOp.Xor => TextureFlags.BitwiseXor, SuatomOp.Exch => TextureFlags.Swap, - _ => TextureFlags.Add + _ => TextureFlags.Add, }; } @@ -743,7 +750,7 @@ namespace Ryujinx.Graphics.Shader.Instructions SuSize.B64 => 2, SuSize.B128 => 4, SuSize.UB128 => 4, - _ => 1 + _ => 1, }; } @@ -759,7 +766,7 @@ namespace Ryujinx.Graphics.Shader.Instructions SuSize.B64 => 3, SuSize.B128 => 4, SuSize.UB128 => 4, - _ => 2 + _ => 2, }; } @@ -775,7 +782,7 @@ namespace Ryujinx.Graphics.Shader.Instructions SuSize.B64 => TextureFormat.R32G32Uint, SuSize.B128 => TextureFormat.R32G32B32A32Uint, SuSize.UB128 => TextureFormat.R32G32B32A32Uint, - _ => TextureFormat.R32Uint + _ => TextureFormat.R32Uint, }; } @@ -789,8 +796,8 @@ namespace Ryujinx.Graphics.Shader.Instructions SuDim._2d => SamplerType.Texture2D, SuDim._2dArray => SamplerType.Texture2D | SamplerType.Array, SuDim._3d => SamplerType.Texture3D, - _ => SamplerType.None + _ => SamplerType.None, }; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitTexture.cs b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitTexture.cs index caa9a7759..3701325e2 100644 --- a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitTexture.cs +++ b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitTexture.cs @@ -4,7 +4,6 @@ using Ryujinx.Graphics.Shader.Translation; using System; using System.Collections.Generic; using System.Numerics; - using static Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandHelper; namespace Ryujinx.Graphics.Shader.Instructions @@ -14,7 +13,7 @@ namespace Ryujinx.Graphics.Shader.Instructions private static readonly int[,] _maskLut = new int[,] { { 0b0001, 0b0010, 0b0100, 0b1000, 0b0011, 0b1001, 0b1010, 0b1100 }, - { 0b0111, 0b1011, 0b1101, 0b1110, 0b1111, 0b0000, 0b0000, 0b0000 } + { 0b0111, 0b1011, 0b1101, 0b1110, 0b1111, 0b0000, 0b0000, 0b0000 }, }; public const bool Sample1DAs2D = true; @@ -23,7 +22,7 @@ namespace Ryujinx.Graphics.Shader.Instructions { Texs, Tlds, - Tld4s + Tld4s, } public static void Tex(EmitterContext context) @@ -207,7 +206,7 @@ namespace Ryujinx.Graphics.Shader.Instructions Operand arrayIndex = isArray ? Ra() : null; - List sourcesList = new List(); + List sourcesList = new(); if (isBindless) { @@ -353,7 +352,7 @@ namespace Ryujinx.Graphics.Shader.Instructions return; } - List sourcesList = new List(); + List sourcesList = new(); Operand Ra() { @@ -722,7 +721,7 @@ namespace Ryujinx.Graphics.Shader.Instructions Operand arrayIndex = isArray ? Ra() : null; - List sourcesList = new List(); + List sourcesList = new(); SamplerType type = ConvertSamplerType(dimensions); TextureFlags flags = TextureFlags.Gather; @@ -864,7 +863,7 @@ namespace Ryujinx.Graphics.Shader.Instructions TextureFlags flags = TextureFlags.None; - List sourcesList = new List(); + List sourcesList = new(); if (isBindless) { @@ -996,7 +995,7 @@ namespace Ryujinx.Graphics.Shader.Instructions TextureFlags flags = TextureFlags.Derivatives; - List sourcesList = new List(); + List sourcesList = new(); if (isBindless) { @@ -1126,7 +1125,7 @@ namespace Ryujinx.Graphics.Shader.Instructions return context.Copy(Register(srcA++, RegisterType.Gpr)); } - List sourcesList = new List(); + List sourcesList = new(); if (isBindless) { @@ -1195,7 +1194,7 @@ namespace Ryujinx.Graphics.Shader.Instructions TexDim.Array3d => SamplerType.Texture3D | SamplerType.Array, TexDim.Cube => SamplerType.TextureCube, TexDim.ArrayCube => SamplerType.TextureCube | SamplerType.Array, - _ => throw new ArgumentException($"Invalid texture dimensions \"{dimensions}\".") + _ => throw new ArgumentException($"Invalid texture dimensions \"{dimensions}\"."), }; } @@ -1309,4 +1308,4 @@ namespace Ryujinx.Graphics.Shader.Instructions return TextureFlags.None; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitVideoArithmetic.cs b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitVideoArithmetic.cs index 2d84c5bdb..a0e9fb384 100644 --- a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitVideoArithmetic.cs +++ b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitVideoArithmetic.cs @@ -1,7 +1,6 @@ using Ryujinx.Graphics.Shader.Decoders; using Ryujinx.Graphics.Shader.IntermediateRepresentation; using Ryujinx.Graphics.Shader.Translation; - using static Ryujinx.Graphics.Shader.Instructions.InstEmitHelper; using static Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandHelper; @@ -77,7 +76,7 @@ namespace Ryujinx.Graphics.Shader.Instructions { VideoScale.Shr7 => 7, VideoScale.Shr15 => 15, - _ => 0 + _ => 0, }; if (shift != 0) @@ -115,4 +114,4 @@ namespace Ryujinx.Graphics.Shader.Instructions // TODO: CC. } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitVideoMinMax.cs b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitVideoMinMax.cs index 67b185ab5..d52c972bc 100644 --- a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitVideoMinMax.cs +++ b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitVideoMinMax.cs @@ -180,4 +180,4 @@ namespace Ryujinx.Graphics.Shader.Instructions context.Copy(Register(op.DestPredInv, RegisterType.Predicate), p1Res); } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitWarp.cs b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitWarp.cs index 3c8336139..67dc3398b 100644 --- a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitWarp.cs +++ b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitWarp.cs @@ -1,7 +1,6 @@ using Ryujinx.Graphics.Shader.Decoders; using Ryujinx.Graphics.Shader.IntermediateRepresentation; using Ryujinx.Graphics.Shader.Translation; - using static Ryujinx.Graphics.Shader.Instructions.InstEmitHelper; using static Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandHelper; @@ -39,7 +38,7 @@ namespace Ryujinx.Graphics.Shader.Instructions ShflMode.Up => context.ShuffleUp(srcA, srcB, srcC), ShflMode.Down => context.ShuffleDown(srcA, srcB, srcC), ShflMode.Bfly => context.ShuffleXor(srcA, srcB, srcC), - _ => (null, null) + _ => (null, null), }; context.Copy(GetDest(op.Dest), res); @@ -81,4 +80,4 @@ namespace Ryujinx.Graphics.Shader.Instructions } } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitter.cs b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitter.cs index 91c740b68..e1cef26d8 100644 --- a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitter.cs +++ b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitter.cs @@ -3,4 +3,4 @@ using Ryujinx.Graphics.Shader.Translation; namespace Ryujinx.Graphics.Shader.Instructions { delegate void InstEmitter(EmitterContext context); -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Instructions/Lop3Expression.cs b/src/Ryujinx.Graphics.Shader/Instructions/Lop3Expression.cs index 6217ce530..6846ea8d6 100644 --- a/src/Ryujinx.Graphics.Shader/Instructions/Lop3Expression.cs +++ b/src/Ryujinx.Graphics.Shader/Instructions/Lop3Expression.cs @@ -1,6 +1,5 @@ using Ryujinx.Graphics.Shader.IntermediateRepresentation; using Ryujinx.Graphics.Shader.Translation; - using static Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandHelper; namespace Ryujinx.Graphics.Shader.Instructions @@ -9,27 +8,27 @@ namespace Ryujinx.Graphics.Shader.Instructions { private enum TruthTable : byte { - False = 0x00, // false - True = 0xff, // true - In = 0xf0, // a - And2 = 0xc0, // a & b - Or2 = 0xfc, // a | b - Xor2 = 0x3c, // a ^ b - And3 = 0x80, // a & b & c - Or3 = 0xfe, // a | b | c - XorAnd = 0x60, // a & (b ^ c) - XorOr = 0xf6, // a | (b ^ c) - OrAnd = 0xe0, // a & (b | c) - AndOr = 0xf8, // a | (b & c) - Onehot = 0x16, // (a & !b & !c) | (!a & b & !c) | (!a & !b & c) - Only one value is true. - Majority = 0xe8, // Popcount(a, b, c) >= 2 - Gamble = 0x81, // (a & b & c) | (!a & !b & !c) - All on or all off + False = 0x00, // false + True = 0xff, // true + In = 0xf0, // a + And2 = 0xc0, // a & b + Or2 = 0xfc, // a | b + Xor2 = 0x3c, // a ^ b + And3 = 0x80, // a & b & c + Or3 = 0xfe, // a | b | c + XorAnd = 0x60, // a & (b ^ c) + XorOr = 0xf6, // a | (b ^ c) + OrAnd = 0xe0, // a & (b | c) + AndOr = 0xf8, // a | (b & c) + Onehot = 0x16, // (a & !b & !c) | (!a & b & !c) | (!a & !b & c) - Only one value is true. + Majority = 0xe8, // Popcount(a, b, c) >= 2 + Gamble = 0x81, // (a & b & c) | (!a & !b & !c) - All on or all off InverseGamble = 0x7e, // Inverse of Gamble - Dot = 0x1a, // a ^ (c | (a & b)) - Mux = 0xca, // a ? b : c - AndXor = 0x78, // a ^ (b & c) - OrXor = 0x1e, // a ^ (b | c) - Xor3 = 0x96, // a ^ b ^ c + Dot = 0x1a, // a ^ (c | (a & b)) + Mux = 0xca, // a ? b : c + AndXor = 0x78, // a ^ (b & c) + OrXor = 0x1e, // a ^ (b | c) + Xor3 = 0x96, // a ^ b ^ c } public static Operand GetFromTruthTable(EmitterContext context, Operand srcA, Operand srcB, Operand srcC, int imm) @@ -41,7 +40,7 @@ namespace Ryujinx.Graphics.Shader.Instructions Operand x = srcA; Operand y = srcB; Operand z = srcC; - + if ((i & 0x01) != 0) { (x, y) = (y, x); @@ -98,6 +97,7 @@ namespace Ryujinx.Graphics.Shader.Instructions { return imm switch { +#pragma warning disable IDE0055 // Disable formatting TruthTable.False => Const(0), TruthTable.True => Const(-1), TruthTable.In => x, @@ -118,7 +118,8 @@ namespace Ryujinx.Graphics.Shader.Instructions TruthTable.AndXor => context.BitwiseExclusiveOr(x, context.BitwiseAnd(y, z)), TruthTable.OrXor => context.BitwiseExclusiveOr(x, context.BitwiseOr(y, z)), TruthTable.Xor3 => context.BitwiseExclusiveOr(x, context.BitwiseExclusiveOr(y, z)), - _ => null + _ => null, +#pragma warning restore IDE0055 }; } @@ -138,4 +139,4 @@ namespace Ryujinx.Graphics.Shader.Instructions return (TruthTable)result; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/BasicBlock.cs b/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/BasicBlock.cs index 2aca118b7..637e120e1 100644 --- a/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/BasicBlock.cs +++ b/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/BasicBlock.cs @@ -83,9 +83,9 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation case Instruction.Discard: case Instruction.Return: return true; + default: + return false; } - - return false; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/CommentNode.cs b/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/CommentNode.cs index d4d87b067..1d33a9b02 100644 --- a/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/CommentNode.cs +++ b/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/CommentNode.cs @@ -9,4 +9,4 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation Comment = comment; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/Function.cs b/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/Function.cs index e535c3fc2..a5f3e0a8c 100644 --- a/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/Function.cs +++ b/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/Function.cs @@ -20,4 +20,4 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation OutArgumentsCount = outArgumentsCount; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/INode.cs b/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/INode.cs index 0f545e56f..d5eae00b7 100644 --- a/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/INode.cs +++ b/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/INode.cs @@ -12,4 +12,4 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation void SetSource(int index, Operand operand); } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/Instruction.cs b/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/Instruction.cs index de41a2cf7..808cc7ed6 100644 --- a/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/Instruction.cs +++ b/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/Instruction.cs @@ -1,8 +1,10 @@ using System; +using System.Diagnostics.CodeAnalysis; namespace Ryujinx.Graphics.Shader.IntermediateRepresentation { [Flags] + [SuppressMessage("Design", "CA1069: Enums values should not be duplicated")] enum Instruction { Absolute = 1, @@ -130,7 +132,7 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation FP32 = 1 << 16, FP64 = 1 << 17, - Mask = 0xffff + Mask = 0xffff, } static class InstructionExtensions @@ -161,4 +163,4 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation return inst == Instruction.Lod || inst == Instruction.TextureSize; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/IoVariable.cs b/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/IoVariable.cs index fb9b57bdd..fdee83451 100644 --- a/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/IoVariable.cs +++ b/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/IoVariable.cs @@ -43,6 +43,6 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation VertexId, VertexIndex, ViewportIndex, - ViewportMask + ViewportMask, } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/IrConsts.cs b/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/IrConsts.cs index c264e47d1..cc9d6cc20 100644 --- a/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/IrConsts.cs +++ b/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/IrConsts.cs @@ -3,6 +3,6 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation static class IrConsts { public const int False = 0; - public const int True = -1; + public const int True = -1; } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/Operand.cs b/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/Operand.cs index 1df88a3d9..6648457f0 100644 --- a/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/Operand.cs +++ b/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/Operand.cs @@ -7,7 +7,7 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation class Operand { private const int CbufSlotBits = 5; - private const int CbufSlotLsb = 32 - CbufSlotBits; + private const int CbufSlotLsb = 32 - CbufSlotBits; private const int CbufSlotMask = (1 << CbufSlotBits) - 1; public OperandType Type { get; } @@ -30,19 +30,19 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation public Operand(OperandType type, int value) : this() { - Type = type; + Type = type; Value = value; } public Operand(Register reg) : this() { - Type = OperandType.Register; + Type = OperandType.Register; Value = PackRegInfo(reg.Index, reg.Type); } public Operand(int slot, int offset) : this() { - Type = OperandType.ConstantBuffer; + Type = OperandType.ConstantBuffer; Value = PackCbufInfo(slot, offset); } @@ -76,4 +76,4 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation return BitConverter.Int32BitsToSingle(Value); } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/OperandHelper.cs b/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/OperandHelper.cs index 37c349e82..f88313552 100644 --- a/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/OperandHelper.cs +++ b/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/OperandHelper.cs @@ -59,4 +59,4 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation return new Operand(OperandType.Undefined); } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/OperandType.cs b/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/OperandType.cs index 4d2da734e..7dbd9d25d 100644 --- a/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/OperandType.cs +++ b/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/OperandType.cs @@ -8,6 +8,6 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation Label, LocalVariable, Register, - Undefined + Undefined, } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/Operation.cs b/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/Operation.cs index 425cfd909..f5396a884 100644 --- a/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/Operation.cs +++ b/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/Operation.cs @@ -62,7 +62,7 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation public Operation(Instruction inst, int index, Operand[] dests, Operand[] sources) : this(sources) { - Inst = inst; + Inst = inst; Index = index; if (dests != null) @@ -286,4 +286,4 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation } } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/PhiNode.cs b/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/PhiNode.cs index 8fa25ae9b..6c95c7bdd 100644 --- a/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/PhiNode.cs +++ b/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/PhiNode.cs @@ -15,21 +15,21 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation public int DestsCount => _dest != null ? 1 : 0; - private HashSet _blocks; + private readonly HashSet _blocks; private class PhiSource { - public BasicBlock Block { get; } - public Operand Operand { get; set; } + public BasicBlock Block { get; } + public Operand Operand { get; set; } public PhiSource(BasicBlock block, Operand operand) { - Block = block; + Block = block; Operand = operand; } } - private List _sources; + private readonly List _sources; public int SourcesCount => _sources.Count; @@ -104,4 +104,4 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation _sources[index].Operand = source; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/StorageKind.cs b/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/StorageKind.cs index 20576a454..669c12816 100644 --- a/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/StorageKind.cs +++ b/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/StorageKind.cs @@ -17,7 +17,7 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation GlobalMemoryS8, // TODO: Remove this and store type as a field on the Operation class itself. GlobalMemoryS16, // TODO: Remove this and store type as a field on the Operation class itself. GlobalMemoryU8, // TODO: Remove this and store type as a field on the Operation class itself. - GlobalMemoryU16 // TODO: Remove this and store type as a field on the Operation class itself. + GlobalMemoryU16, // TODO: Remove this and store type as a field on the Operation class itself. } static class StorageKindExtensions @@ -42,4 +42,4 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation storageKind == StorageKind.OutputPerPatch; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/TextureFlags.cs b/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/TextureFlags.cs index 6c20e856f..51ff09cf8 100644 --- a/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/TextureFlags.cs +++ b/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/TextureFlags.cs @@ -1,32 +1,34 @@ using System; +using System.Diagnostics.CodeAnalysis; namespace Ryujinx.Graphics.Shader.IntermediateRepresentation { [Flags] + [SuppressMessage("Design", "CA1069: Enums values should not be duplicated")] enum TextureFlags { - None = 0, - Bindless = 1 << 0, - Gather = 1 << 1, + None = 0, + Bindless = 1 << 0, + Gather = 1 << 1, Derivatives = 1 << 2, - IntCoords = 1 << 3, - LodBias = 1 << 4, - LodLevel = 1 << 5, - Offset = 1 << 6, - Offsets = 1 << 7, - Coherent = 1 << 8, + IntCoords = 1 << 3, + LodBias = 1 << 4, + LodLevel = 1 << 5, + Offset = 1 << 6, + Offsets = 1 << 7, + Coherent = 1 << 8, - AtomicMask = 15 << 16, + AtomicMask = 15 << 16, - Add = 0 << 16, - Minimum = 1 << 16, - Maximum = 2 << 16, - Increment = 3 << 16, - Decrement = 4 << 16, - BitwiseAnd = 5 << 16, - BitwiseOr = 6 << 16, - BitwiseXor = 7 << 16, - Swap = 8 << 16, - CAS = 9 << 16 + Add = 0 << 16, + Minimum = 1 << 16, + Maximum = 2 << 16, + Increment = 3 << 16, + Decrement = 4 << 16, + BitwiseAnd = 5 << 16, + BitwiseOr = 6 << 16, + BitwiseXor = 7 << 16, + Swap = 8 << 16, + CAS = 9 << 16, } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/TextureOperation.cs b/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/TextureOperation.cs index 6ab868cdc..b467fe533 100644 --- a/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/TextureOperation.cs +++ b/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/TextureOperation.cs @@ -66,4 +66,4 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation Flags |= TextureFlags.LodLevel; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/OutputTopology.cs b/src/Ryujinx.Graphics.Shader/OutputTopology.cs index 6f977becb..dc4b304ad 100644 --- a/src/Ryujinx.Graphics.Shader/OutputTopology.cs +++ b/src/Ryujinx.Graphics.Shader/OutputTopology.cs @@ -2,23 +2,22 @@ namespace Ryujinx.Graphics.Shader { enum OutputTopology { - PointList = 1, - LineStrip = 6, - TriangleStrip = 7 + PointList = 1, + LineStrip = 6, + TriangleStrip = 7, } static class OutputTopologyExtensions { public static string ToGlslString(this OutputTopology topology) { - switch (topology) + return topology switch { - case OutputTopology.LineStrip: return "line_strip"; - case OutputTopology.PointList: return "points"; - case OutputTopology.TriangleStrip: return "triangle_strip"; - } - - return "points"; + OutputTopology.LineStrip => "line_strip", + OutputTopology.PointList => "points", + OutputTopology.TriangleStrip => "triangle_strip", + _ => "points", + }; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/SamplerType.cs b/src/Ryujinx.Graphics.Shader/SamplerType.cs index 620f4ccf3..85e97368f 100644 --- a/src/Ryujinx.Graphics.Shader/SamplerType.cs +++ b/src/Ryujinx.Graphics.Shader/SamplerType.cs @@ -15,10 +15,10 @@ namespace Ryujinx.Graphics.Shader Mask = 0xff, - Array = 1 << 8, - Indexed = 1 << 9, + Array = 1 << 8, + Indexed = 1 << 9, Multisample = 1 << 10, - Shadow = 1 << 11 + Shadow = 1 << 11, } static class SamplerTypeExtensions @@ -32,7 +32,7 @@ namespace Ryujinx.Graphics.Shader SamplerType.Texture2D => 2, SamplerType.Texture3D => 3, SamplerType.TextureCube => 3, - _ => throw new ArgumentException($"Invalid sampler type \"{type}\".") + _ => throw new ArgumentException($"Invalid sampler type \"{type}\"."), }; } @@ -45,7 +45,7 @@ namespace Ryujinx.Graphics.Shader SamplerType.Texture2D => "sampler2D", SamplerType.Texture3D => "sampler3D", SamplerType.TextureCube => "samplerCube", - _ => throw new ArgumentException($"Invalid sampler type \"{type}\".") + _ => throw new ArgumentException($"Invalid sampler type \"{type}\"."), }; if ((type & SamplerType.Multisample) != 0) @@ -75,7 +75,7 @@ namespace Ryujinx.Graphics.Shader SamplerType.Texture2D => "image2D", SamplerType.Texture3D => "image3D", SamplerType.TextureCube => "imageCube", - _ => throw new ArgumentException($"Invalid sampler type \"{type}\".") + _ => throw new ArgumentException($"Invalid sampler type \"{type}\"."), }; if ((type & SamplerType.Multisample) != 0) @@ -90,11 +90,15 @@ namespace Ryujinx.Graphics.Shader switch (componentType) { - case AggregateType.U32: typeName = 'u' + typeName; break; - case AggregateType.S32: typeName = 'i' + typeName; break; + case AggregateType.U32: + typeName = 'u' + typeName; + break; + case AggregateType.S32: + typeName = 'i' + typeName; + break; } return typeName; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/ShaderIdentification.cs b/src/Ryujinx.Graphics.Shader/ShaderIdentification.cs index 3f0157626..551e318c0 100644 --- a/src/Ryujinx.Graphics.Shader/ShaderIdentification.cs +++ b/src/Ryujinx.Graphics.Shader/ShaderIdentification.cs @@ -3,6 +3,6 @@ namespace Ryujinx.Graphics.Shader public enum ShaderIdentification { None, - GeometryLayerPassthrough + GeometryLayerPassthrough, } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/ShaderProgram.cs b/src/Ryujinx.Graphics.Shader/ShaderProgram.cs index 29fff21e6..9e62491bf 100644 --- a/src/Ryujinx.Graphics.Shader/ShaderProgram.cs +++ b/src/Ryujinx.Graphics.Shader/ShaderProgram.cs @@ -32,4 +32,4 @@ namespace Ryujinx.Graphics.Shader Code = line + Environment.NewLine + Code; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/ShaderProgramInfo.cs b/src/Ryujinx.Graphics.Shader/ShaderProgramInfo.cs index 30f0ffaa2..e87769bb9 100644 --- a/src/Ryujinx.Graphics.Shader/ShaderProgramInfo.cs +++ b/src/Ryujinx.Graphics.Shader/ShaderProgramInfo.cs @@ -48,4 +48,4 @@ namespace Ryujinx.Graphics.Shader FragmentOutputMap = fragmentOutputMap; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/ShaderStage.cs b/src/Ryujinx.Graphics.Shader/ShaderStage.cs index f16fe3281..f6cfe4bb2 100644 --- a/src/Ryujinx.Graphics.Shader/ShaderStage.cs +++ b/src/Ryujinx.Graphics.Shader/ShaderStage.cs @@ -9,7 +9,7 @@ namespace Ryujinx.Graphics.Shader Geometry, Fragment, - Count + Count, } public static class ShaderStageExtensions @@ -24,4 +24,4 @@ namespace Ryujinx.Graphics.Shader return stage == ShaderStage.Vertex || stage == ShaderStage.Fragment || stage == ShaderStage.Compute; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/AstAssignment.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/AstAssignment.cs index bb3fe7af4..efda774c6 100644 --- a/src/Ryujinx.Graphics.Shader/StructuredIr/AstAssignment.cs +++ b/src/Ryujinx.Graphics.Shader/StructuredIr/AstAssignment.cs @@ -27,9 +27,9 @@ namespace Ryujinx.Graphics.Shader.StructuredIr public AstAssignment(IAstNode destination, IAstNode source) { Destination = destination; - Source = source; + Source = source; AddDef(destination, this); } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/AstBlock.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/AstBlock.cs index 2f34bee83..826dbff88 100644 --- a/src/Ryujinx.Graphics.Shader/StructuredIr/AstBlock.cs +++ b/src/Ryujinx.Graphics.Shader/StructuredIr/AstBlock.cs @@ -29,7 +29,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr } } - private LinkedList _nodes; + private readonly LinkedList _nodes; public IAstNode First => _nodes.First?.Value; public IAstNode Last => _nodes.Last?.Value; @@ -38,7 +38,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr public AstBlock(AstBlockType type, IAstNode condition = null) { - Type = type; + Type = type; Condition = condition; _nodes = new LinkedList(); @@ -114,4 +114,4 @@ namespace Ryujinx.Graphics.Shader.StructuredIr return GetEnumerator(); } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/AstBlockType.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/AstBlockType.cs index c12efda90..a7dcc72a1 100644 --- a/src/Ryujinx.Graphics.Shader/StructuredIr/AstBlockType.cs +++ b/src/Ryujinx.Graphics.Shader/StructuredIr/AstBlockType.cs @@ -7,6 +7,6 @@ namespace Ryujinx.Graphics.Shader.StructuredIr Else, ElseIf, Main, - While + While, } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/AstBlockVisitor.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/AstBlockVisitor.cs index 10d5dce0a..16efeff72 100644 --- a/src/Ryujinx.Graphics.Shader/StructuredIr/AstBlockVisitor.cs +++ b/src/Ryujinx.Graphics.Shader/StructuredIr/AstBlockVisitor.cs @@ -65,4 +65,4 @@ namespace Ryujinx.Graphics.Shader.StructuredIr } } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/AstComment.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/AstComment.cs index dabe623fd..1c82e646f 100644 --- a/src/Ryujinx.Graphics.Shader/StructuredIr/AstComment.cs +++ b/src/Ryujinx.Graphics.Shader/StructuredIr/AstComment.cs @@ -9,4 +9,4 @@ namespace Ryujinx.Graphics.Shader.StructuredIr Comment = comment; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/AstHelper.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/AstHelper.cs index 7aa0409b6..06d13c90b 100644 --- a/src/Ryujinx.Graphics.Shader/StructuredIr/AstHelper.cs +++ b/src/Ryujinx.Graphics.Shader/StructuredIr/AstHelper.cs @@ -49,9 +49,10 @@ namespace Ryujinx.Graphics.Shader.StructuredIr public static AstOperand Local(AggregateType type) { - AstOperand local = new AstOperand(OperandType.LocalVariable); - - local.VarType = type; + AstOperand local = new(OperandType.LocalVariable) + { + VarType = type, + }; return local; } @@ -71,4 +72,4 @@ namespace Ryujinx.Graphics.Shader.StructuredIr return node.LLNode.Previous?.Value; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/AstNode.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/AstNode.cs index c667aac98..0b8246171 100644 --- a/src/Ryujinx.Graphics.Shader/StructuredIr/AstNode.cs +++ b/src/Ryujinx.Graphics.Shader/StructuredIr/AstNode.cs @@ -8,4 +8,4 @@ namespace Ryujinx.Graphics.Shader.StructuredIr public LinkedListNode LLNode { get; set; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/AstOperand.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/AstOperand.cs index 473aa2e7b..b64b96b8d 100644 --- a/src/Ryujinx.Graphics.Shader/StructuredIr/AstOperand.cs +++ b/src/Ryujinx.Graphics.Shader/StructuredIr/AstOperand.cs @@ -29,10 +29,10 @@ namespace Ryujinx.Graphics.Shader.StructuredIr Value = operand.Value; } - public AstOperand(OperandType type, int value = 0) : this() + public AstOperand(OperandType type, int value = 0) : this() { - Type = type; + Type = type; Value = value; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/AstOperation.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/AstOperation.cs index 4cf729d09..46555a85a 100644 --- a/src/Ryujinx.Graphics.Shader/StructuredIr/AstOperation.cs +++ b/src/Ryujinx.Graphics.Shader/StructuredIr/AstOperation.cs @@ -14,7 +14,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr public int Index { get; } - private IAstNode[] _sources; + private readonly IAstNode[] _sources; public int SourcesCount => _sources.Length; @@ -77,12 +77,18 @@ namespace Ryujinx.Graphics.Shader.StructuredIr switch (componentsCount) { - case 2: type |= AggregateType.Vector2; break; - case 3: type |= AggregateType.Vector3; break; - case 4: type |= AggregateType.Vector4; break; + case 2: + type |= AggregateType.Vector2; + break; + case 3: + type |= AggregateType.Vector3; + break; + case 4: + type |= AggregateType.Vector4; + break; } return type; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/AstOptimizer.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/AstOptimizer.cs index b71ae2c41..4fb5d02b3 100644 --- a/src/Ryujinx.Graphics.Shader/StructuredIr/AstOptimizer.cs +++ b/src/Ryujinx.Graphics.Shader/StructuredIr/AstOptimizer.cs @@ -17,7 +17,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr // (this makes comparison with the disassembly easier). if (!context.Config.Options.Flags.HasFlag(TranslationFlags.DebugMode)) { - AstBlockVisitor visitor = new AstBlockVisitor(mainBlock); + AstBlockVisitor visitor = new(mainBlock); foreach (IAstNode node in visitor.Visit()) { @@ -45,7 +45,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr private static bool IsWorthPropagating(IAstNode source) { - if (!(source is AstOperation srcOp)) + if (source is not AstOperation srcOp) { return false; } @@ -87,7 +87,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr private static void RemoveEmptyBlocks(AstBlock mainBlock) { - Queue pending = new Queue(); + Queue pending = new(); pending.Enqueue(mainBlock); @@ -152,4 +152,4 @@ namespace Ryujinx.Graphics.Shader.StructuredIr } } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/AstTextureOperation.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/AstTextureOperation.cs index a4e097eb6..4ff2035a8 100644 --- a/src/Ryujinx.Graphics.Shader/StructuredIr/AstTextureOperation.cs +++ b/src/Ryujinx.Graphics.Shader/StructuredIr/AstTextureOperation.cs @@ -28,4 +28,4 @@ namespace Ryujinx.Graphics.Shader.StructuredIr Handle = handle; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/BufferDefinition.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/BufferDefinition.cs index 5afebc75f..e27594804 100644 --- a/src/Ryujinx.Graphics.Shader/StructuredIr/BufferDefinition.cs +++ b/src/Ryujinx.Graphics.Shader/StructuredIr/BufferDefinition.cs @@ -17,4 +17,4 @@ namespace Ryujinx.Graphics.Shader.StructuredIr Type = type; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/BufferLayout.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/BufferLayout.cs index 43a866626..1c25ed34d 100644 --- a/src/Ryujinx.Graphics.Shader/StructuredIr/BufferLayout.cs +++ b/src/Ryujinx.Graphics.Shader/StructuredIr/BufferLayout.cs @@ -3,6 +3,6 @@ namespace Ryujinx.Graphics.Shader.StructuredIr enum BufferLayout { Std140, - Std430 + Std430, } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/GotoElimination.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/GotoElimination.cs index 8bcf9d9c9..3ca1266f6 100644 --- a/src/Ryujinx.Graphics.Shader/StructuredIr/GotoElimination.cs +++ b/src/Ryujinx.Graphics.Shader/StructuredIr/GotoElimination.cs @@ -1,7 +1,6 @@ using Ryujinx.Graphics.Shader.IntermediateRepresentation; using System; using System.Collections.Generic; - using static Ryujinx.Graphics.Shader.StructuredIr.AstHelper; namespace Ryujinx.Graphics.Shader.StructuredIr @@ -110,16 +109,16 @@ namespace Ryujinx.Graphics.Shader.StructuredIr if (lLevel > rLevel) { - block = lBlock; + block = lBlock; blockLvl = lLevel; - other = rBlock; + other = rBlock; otherLvl = rLevel; } else /* if (rLevel > lLevel) */ { - block = rBlock; + block = rBlock; blockLvl = rLevel; - other = lBlock; + other = lBlock; otherLvl = lLevel; } @@ -144,7 +143,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr AstBlock[] path = BackwardsPath(block, ParentBlock(stmt.Label)); - AstBlock loopFirstStmt = path[path.Length - 1]; + AstBlock loopFirstStmt = path[^1]; if (loopFirstStmt.Type == AstBlockType.Else) { @@ -194,7 +193,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr loopBlock.AddAfter(child, stmt.Goto); - block = loopBlock; + block = loopBlock; gLevel = loopLevel; } } @@ -252,7 +251,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr for (int index = path.Length - 1; index >= 0; index--) { AstBlock child = path[index]; - AstBlock last = child; + AstBlock last = child; if (child.Type == AstBlockType.If) { @@ -265,7 +264,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr else if (child.Type == AstBlockType.Else) { // Modify the matching if condition to force the else to be entered by the goto. - if (!(Previous(child) is AstBlock ifBlock) || ifBlock.Type != AstBlockType.If) + if (Previous(child) is not AstBlock ifBlock || ifBlock.Type != AstBlockType.If) { throw new InvalidOperationException("Found an else without a matching if."); } @@ -332,7 +331,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr { AstBlock block = ParentBlock(stmt.Goto); - AstBlock newBlock = new AstBlock(AstBlockType.If, stmt.Condition); + AstBlock newBlock = new(AstBlockType.If, stmt.Condition); block.AddAfter(stmt.Goto, newBlock); @@ -340,11 +339,11 @@ namespace Ryujinx.Graphics.Shader.StructuredIr } private static AstBlock Enclose( - AstBlock block, + AstBlock block, AstBlockType type, - IAstNode cond, - IAstNode first, - IAstNode last = null) + IAstNode cond, + IAstNode first, + IAstNode last = null) { if (first == last) { @@ -367,7 +366,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr return first as AstBlock; } - AstBlock newBlock = new AstBlock(type, cond); + AstBlock newBlock = new(type, cond); block.AddBefore(first, newBlock); @@ -387,7 +386,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr private static bool BlockMatches(IAstNode node, AstBlockType type, IAstNode cond) { - if (!(node is AstBlock block)) + if (node is not AstBlock block) { return false; } @@ -399,7 +398,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr { if (lCond is AstOperation lCondOp && lCondOp.Inst == Instruction.LogicalNot) { - if (!(rCond is AstOperation rCondOp) || rCondOp.Inst != lCondOp.Inst) + if (rCond is not AstOperation rCondOp || rCondOp.Inst != lCondOp.Inst) { return false; } @@ -418,7 +417,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr return block.Parent; } - while (!(node is AstBlock)) + while (node is not AstBlock) { node = node.Parent; } @@ -430,7 +429,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr { AstBlock block = bottom; - List path = new List(); + List path = new(); while (block != top) { @@ -456,4 +455,4 @@ namespace Ryujinx.Graphics.Shader.StructuredIr return level; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/GotoStatement.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/GotoStatement.cs index 25216e55f..4607a16c1 100644 --- a/src/Ryujinx.Graphics.Shader/StructuredIr/GotoStatement.cs +++ b/src/Ryujinx.Graphics.Shader/StructuredIr/GotoStatement.cs @@ -4,7 +4,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr { class GotoStatement { - public AstOperation Goto { get; } + public AstOperation Goto { get; } public AstAssignment Label { get; } public IAstNode Condition => Label.Destination; @@ -15,9 +15,9 @@ namespace Ryujinx.Graphics.Shader.StructuredIr public GotoStatement(AstOperation branch, AstAssignment label, bool isLoop) { - Goto = branch; - Label = label; + Goto = branch; + Label = label; IsLoop = isLoop; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/HelperFunctionsMask.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/HelperFunctionsMask.cs index ed910f96d..73ce90827 100644 --- a/src/Ryujinx.Graphics.Shader/StructuredIr/HelperFunctionsMask.cs +++ b/src/Ryujinx.Graphics.Shader/StructuredIr/HelperFunctionsMask.cs @@ -7,11 +7,11 @@ namespace Ryujinx.Graphics.Shader.StructuredIr { MultiplyHighS32 = 1 << 2, MultiplyHighU32 = 1 << 3, - Shuffle = 1 << 4, - ShuffleDown = 1 << 5, - ShuffleUp = 1 << 6, - ShuffleXor = 1 << 7, - SwizzleAdd = 1 << 10, - FSI = 1 << 11 + Shuffle = 1 << 4, + ShuffleDown = 1 << 5, + ShuffleUp = 1 << 6, + ShuffleXor = 1 << 7, + SwizzleAdd = 1 << 10, + FSI = 1 << 11, } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/IAstNode.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/IAstNode.cs index 5ececbb5e..248d8d69f 100644 --- a/src/Ryujinx.Graphics.Shader/StructuredIr/IAstNode.cs +++ b/src/Ryujinx.Graphics.Shader/StructuredIr/IAstNode.cs @@ -8,4 +8,4 @@ namespace Ryujinx.Graphics.Shader.StructuredIr LinkedListNode LLNode { get; set; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/InstructionInfo.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/InstructionInfo.cs index b08478ad3..6cd0fd086 100644 --- a/src/Ryujinx.Graphics.Shader/StructuredIr/InstructionInfo.cs +++ b/src/Ryujinx.Graphics.Shader/StructuredIr/InstructionInfo.cs @@ -19,12 +19,13 @@ namespace Ryujinx.Graphics.Shader.StructuredIr } } - private static InstInfo[] _infoTbl; + private static readonly InstInfo[] _infoTbl; static InstructionInfo() { _infoTbl = new InstInfo[(int)Instruction.Count]; +#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); @@ -130,6 +131,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr Add(Instruction.VoteAll, AggregateType.Bool, AggregateType.Bool); Add(Instruction.VoteAllEqual, AggregateType.Bool, AggregateType.Bool); Add(Instruction.VoteAny, AggregateType.Bool, AggregateType.Bool); +#pragma warning restore IDE0055v } private static void Add(Instruction inst, AggregateType destType, params AggregateType[] srcTypes) @@ -201,4 +203,4 @@ namespace Ryujinx.Graphics.Shader.StructuredIr return _infoTbl[(int)(inst & Instruction.Mask)].SrcTypes.Length == 1; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/IoDefinition.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/IoDefinition.cs index 21a1b3f08..0a0681fa4 100644 --- a/src/Ryujinx.Graphics.Shader/StructuredIr/IoDefinition.cs +++ b/src/Ryujinx.Graphics.Shader/StructuredIr/IoDefinition.cs @@ -41,4 +41,4 @@ namespace Ryujinx.Graphics.Shader.StructuredIr return $"{StorageKind}.{IoVariable}.{Location}.{Component}"; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/MemoryDefinition.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/MemoryDefinition.cs index c0bb750e7..3ea69fde1 100644 --- a/src/Ryujinx.Graphics.Shader/StructuredIr/MemoryDefinition.cs +++ b/src/Ryujinx.Graphics.Shader/StructuredIr/MemoryDefinition.cs @@ -15,4 +15,4 @@ namespace Ryujinx.Graphics.Shader.StructuredIr ArrayLength = arrayLength; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/OperandInfo.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/OperandInfo.cs index 48060f6b9..638a5298f 100644 --- a/src/Ryujinx.Graphics.Shader/StructuredIr/OperandInfo.cs +++ b/src/Ryujinx.Graphics.Shader/StructuredIr/OperandInfo.cs @@ -25,8 +25,8 @@ namespace Ryujinx.Graphics.Shader.StructuredIr OperandType.Argument => AggregateType.S32, OperandType.Constant => AggregateType.S32, OperandType.Undefined => AggregateType.S32, - _ => throw new ArgumentException($"Invalid operand type \"{type}\".") + _ => throw new ArgumentException($"Invalid operand type \"{type}\"."), }; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/PhiFunctions.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/PhiFunctions.cs index 541ca298e..8b1cb9c56 100644 --- a/src/Ryujinx.Graphics.Shader/StructuredIr/PhiFunctions.cs +++ b/src/Ryujinx.Graphics.Shader/StructuredIr/PhiFunctions.cs @@ -30,7 +30,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr BasicBlock srcBlock = phi.GetBlock(index); - Operation copyOp = new Operation(Instruction.Copy, phi.Dest, src); + Operation copyOp = new(Instruction.Copy, phi.Dest, src); srcBlock.Append(copyOp); } @@ -42,4 +42,4 @@ namespace Ryujinx.Graphics.Shader.StructuredIr } } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/ShaderProperties.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/ShaderProperties.cs index c6132ef8c..1da5cb657 100644 --- a/src/Ryujinx.Graphics.Shader/StructuredIr/ShaderProperties.cs +++ b/src/Ryujinx.Graphics.Shader/StructuredIr/ShaderProperties.cs @@ -48,4 +48,4 @@ namespace Ryujinx.Graphics.Shader.StructuredIr return id; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/StructureType.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/StructureType.cs index 17f497386..fdf824f57 100644 --- a/src/Ryujinx.Graphics.Shader/StructuredIr/StructureType.cs +++ b/src/Ryujinx.Graphics.Shader/StructuredIr/StructureType.cs @@ -2,7 +2,7 @@ using Ryujinx.Graphics.Shader.Translation; namespace Ryujinx.Graphics.Shader.StructuredIr { - struct StructureField + readonly struct StructureField { public AggregateType Type { get; } public string Name { get; } diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredFunction.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredFunction.cs index 61c4fed73..aa5e13867 100644 --- a/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredFunction.cs +++ b/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredFunction.cs @@ -39,4 +39,4 @@ namespace Ryujinx.Graphics.Shader.StructuredIr : InArguments[index]; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgram.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgram.cs index 9d12a73cd..a4e6444b0 100644 --- a/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgram.cs +++ b/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgram.cs @@ -10,7 +10,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr { public static StructuredProgramInfo MakeStructuredProgram(IReadOnlyList functions, ShaderConfig config) { - StructuredProgramContext context = new StructuredProgramContext(config); + StructuredProgramContext context = new(config); for (int funcIndex = 0; funcIndex < functions.Count; funcIndex++) { @@ -20,7 +20,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr AggregateType returnType = function.ReturnsValue ? AggregateType.S32 : AggregateType.Void; - AggregateType[] inArguments = new AggregateType[function.InArgumentsCount]; + AggregateType[] inArguments = new AggregateType[function.InArgumentsCount]; AggregateType[] outArguments = new AggregateType[function.OutArgumentsCount]; for (int i = 0; i < inArguments.Length; i++) @@ -79,7 +79,6 @@ namespace Ryujinx.Graphics.Shader.StructuredIr { IoVariable ioVariable = (IoVariable)operation.GetSource(0).Value; bool isOutput = storageKind.IsOutput(); - bool perPatch = storageKind.IsPerPatch(); int location = 0; int component = 0; @@ -169,9 +168,15 @@ namespace Ryujinx.Graphics.Shader.StructuredIr switch (componentsCount) { - case 2: destType |= AggregateType.Vector2; break; - case 3: destType |= AggregateType.Vector3; break; - case 4: destType |= AggregateType.Vector4; break; + case 2: + destType |= AggregateType.Vector2; + break; + case 3: + destType |= AggregateType.Vector3; + break; + case 4: + destType |= AggregateType.Vector4; + break; } AstOperand destVec = context.NewTemp(destType); @@ -181,7 +186,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr for (int i = 0; i < operation.DestsCount; i++) { AstOperand dest = context.GetOperand(operation.GetDest(i)); - AstOperand index = new AstOperand(OperandType.Constant, i); + AstOperand index = new(OperandType.Constant, i); dest.VarType = destElemType; @@ -202,7 +207,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr } bool isCondSel = inst == Instruction.ConditionalSelect; - bool isCopy = inst == Instruction.Copy; + bool isCopy = inst == Instruction.Copy; if (isCondSel || isCopy) { @@ -304,9 +309,9 @@ namespace Ryujinx.Graphics.Shader.StructuredIr private static AggregateType GetVarTypeFromUses(Operand dest) { - HashSet visited = new HashSet(); + HashSet visited = new(); - Queue pending = new Queue(); + Queue pending = new(); bool Enqueue(Operand operand) { @@ -385,7 +390,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr { Instruction.ImageLoad or Instruction.TextureSample => true, - _ => false + _ => false, }; } @@ -396,7 +401,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr Instruction.Branch or Instruction.BranchIfFalse or Instruction.BranchIfTrue => true, - _ => false + _ => false, }; } @@ -408,7 +413,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr Instruction.BitwiseExclusiveOr or Instruction.BitwiseNot or Instruction.BitwiseOr => true, - _ => false + _ => false, }; } @@ -420,8 +425,8 @@ namespace Ryujinx.Graphics.Shader.StructuredIr Instruction.BitwiseExclusiveOr => Instruction.LogicalExclusiveOr, Instruction.BitwiseNot => Instruction.LogicalNot, Instruction.BitwiseOr => Instruction.LogicalOr, - _ => throw new ArgumentException($"Unexpected instruction \"{inst}\".") + _ => throw new ArgumentException($"Unexpected instruction \"{inst}\"."), }; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramContext.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramContext.cs index a4d079914..019fc332b 100644 --- a/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramContext.cs +++ b/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramContext.cs @@ -3,7 +3,6 @@ using Ryujinx.Graphics.Shader.Translation; using System.Collections.Generic; using System.Linq; using System.Numerics; - using static Ryujinx.Graphics.Shader.StructuredIr.AstHelper; namespace Ryujinx.Graphics.Shader.StructuredIr @@ -165,7 +164,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr // this is not valid as the loop condition would be evaluated, // and it could erroneously jump back to the start of the loop. bool inRange = - block.Branch.Index < _currEndIndex || + block.Branch.Index < _currEndIndex || (block.Branch.Index == _currEndIndex && block.Branch.Index < _loopEndIndex); bool isLoop = block.Branch.Index <= block.Index; @@ -184,11 +183,11 @@ namespace Ryujinx.Graphics.Shader.StructuredIr AddNode(Assign(gotoTempAsg.Destination, cond)); - AstOperation branch = new AstOperation(branchOp.Inst); + AstOperation branch = new(branchOp.Inst); AddNode(branch); - GotoStatement gotoStmt = new GotoStatement(branch, gotoTempAsg, isLoop); + GotoStatement gotoStmt = new(branch, gotoTempAsg, isLoop); _gotos.Add(gotoStmt); } @@ -236,13 +235,13 @@ namespace Ryujinx.Graphics.Shader.StructuredIr private void NewBlock(AstBlockType type, IAstNode cond, int endIndex) { - AstBlock childBlock = new AstBlock(type, cond); + AstBlock childBlock = new(type, cond); AddNode(childBlock); _blockStack.Push((_currBlock, _currEndIndex, _loopEndIndex)); - _currBlock = childBlock; + _currBlock = childBlock; _currEndIndex = endIndex; if (type == AstBlockType.DoWhile) @@ -316,7 +315,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr new AstOperand(OperandType.Constant, binding), new AstOperand(OperandType.Constant, 0), new AstOperand(OperandType.Constant, vecIndex), - new AstOperand(OperandType.Constant, elemIndex) + new AstOperand(OperandType.Constant, elemIndex), }; return new AstOperation(Instruction.Load, StorageKind.ConstantBuffer, false, sources, sources.Length); @@ -349,4 +348,4 @@ namespace Ryujinx.Graphics.Shader.StructuredIr return astOperand; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramInfo.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramInfo.cs index c51041467..4f18c7fd7 100644 --- a/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramInfo.cs +++ b/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgramInfo.cs @@ -33,4 +33,4 @@ namespace Ryujinx.Graphics.Shader.StructuredIr IoDefinitions = new HashSet(); } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/SupportBuffer.cs b/src/Ryujinx.Graphics.Shader/SupportBuffer.cs index 5eb7fe467..24a99345a 100644 --- a/src/Ryujinx.Graphics.Shader/SupportBuffer.cs +++ b/src/Ryujinx.Graphics.Shader/SupportBuffer.cs @@ -20,22 +20,22 @@ namespace Ryujinx.Graphics.Shader FragmentIsBgra, ViewportInverse, FragmentRenderScaleCount, - RenderScale + RenderScale, } public struct SupportBuffer { internal const int Binding = 0; - public static int FieldSize; - public static int RequiredSize; + public static readonly int FieldSize; + public static readonly int RequiredSize; - public static int FragmentAlphaTestOffset; - public static int FragmentIsBgraOffset; - public static int ViewportInverseOffset; - public static int FragmentRenderScaleCountOffset; - public static int GraphicsRenderScaleOffset; - public static int ComputeRenderScaleOffset; + public static readonly int FragmentAlphaTestOffset; + public static readonly int FragmentIsBgraOffset; + public static readonly int ViewportInverseOffset; + public static readonly int FragmentRenderScaleCountOffset; + public static readonly int GraphicsRenderScaleOffset; + public static readonly int ComputeRenderScaleOffset; public const int FragmentIsBgraCount = 8; // One for the render target, 64 for the textures, and 8 for the images. @@ -51,7 +51,7 @@ namespace Ryujinx.Graphics.Shader FieldSize = Unsafe.SizeOf>(); RequiredSize = Unsafe.SizeOf(); - SupportBuffer instance = new SupportBuffer(); + SupportBuffer instance = new(); FragmentAlphaTestOffset = OffsetOf(ref instance, ref instance.FragmentAlphaTest); FragmentIsBgraOffset = OffsetOf(ref instance, ref instance.FragmentIsBgra); @@ -69,7 +69,7 @@ namespace Ryujinx.Graphics.Shader new StructureField(AggregateType.Array | AggregateType.U32, "s_is_bgra", FragmentIsBgraCount), new StructureField(AggregateType.Vector4 | AggregateType.FP32, "s_viewport_inverse"), new StructureField(AggregateType.S32, "s_frag_scale_count"), - new StructureField(AggregateType.Array | AggregateType.FP32, "s_render_scale", RenderScaleMaxCount) + new StructureField(AggregateType.Array | AggregateType.FP32, "s_render_scale", RenderScaleMaxCount), }); } @@ -81,4 +81,4 @@ namespace Ryujinx.Graphics.Shader // Render scale max count: 1 + 64 + 8. First scale is fragment output scale, others are textures/image inputs. public Array73> RenderScale; } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/TessPatchType.cs b/src/Ryujinx.Graphics.Shader/TessPatchType.cs index 2361b69f8..76be22fd4 100644 --- a/src/Ryujinx.Graphics.Shader/TessPatchType.cs +++ b/src/Ryujinx.Graphics.Shader/TessPatchType.cs @@ -4,7 +4,7 @@ namespace Ryujinx.Graphics.Shader { Isolines = 0, Triangles = 1, - Quads = 2 + Quads = 2, } static class TessPatchTypeExtensions @@ -15,8 +15,8 @@ namespace Ryujinx.Graphics.Shader { TessPatchType.Isolines => "isolines", TessPatchType.Quads => "quads", - _ => "triangles" + _ => "triangles", }; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/TessSpacing.cs b/src/Ryujinx.Graphics.Shader/TessSpacing.cs index 35c44190c..6035366c1 100644 --- a/src/Ryujinx.Graphics.Shader/TessSpacing.cs +++ b/src/Ryujinx.Graphics.Shader/TessSpacing.cs @@ -4,7 +4,7 @@ namespace Ryujinx.Graphics.Shader { EqualSpacing = 0, FractionalEventSpacing = 1, - FractionalOddSpacing = 2 + FractionalOddSpacing = 2, } static class TessSpacingExtensions @@ -15,8 +15,8 @@ namespace Ryujinx.Graphics.Shader { TessSpacing.FractionalEventSpacing => "fractional_even_spacing", TessSpacing.FractionalOddSpacing => "fractional_odd_spacing", - _ => "equal_spacing" + _ => "equal_spacing", }; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/TextureDescriptor.cs b/src/Ryujinx.Graphics.Shader/TextureDescriptor.cs index 85ea9adbe..626faa695 100644 --- a/src/Ryujinx.Graphics.Shader/TextureDescriptor.cs +++ b/src/Ryujinx.Graphics.Shader/TextureDescriptor.cs @@ -16,12 +16,12 @@ namespace Ryujinx.Graphics.Shader public TextureDescriptor(int binding, SamplerType type, TextureFormat format, int cbufSlot, int handleIndex) { - Binding = binding; - Type = type; - Format = format; - CbufSlot = cbufSlot; + Binding = binding; + Type = type; + Format = format; + CbufSlot = cbufSlot; HandleIndex = handleIndex; - Flags = TextureUsageFlags.None; + Flags = TextureUsageFlags.None; } public TextureDescriptor SetFlag(TextureUsageFlags flag) @@ -31,4 +31,4 @@ namespace Ryujinx.Graphics.Shader return this; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/TextureFormat.cs b/src/Ryujinx.Graphics.Shader/TextureFormat.cs index d4c8b96be..f6e57fe8f 100644 --- a/src/Ryujinx.Graphics.Shader/TextureFormat.cs +++ b/src/Ryujinx.Graphics.Shader/TextureFormat.cs @@ -43,7 +43,7 @@ namespace Ryujinx.Graphics.Shader R32G32B32A32Sint, R10G10B10A2Unorm, R10G10B10A2Uint, - R11G11B10Float + R11G11B10Float, } static class TextureFormatExtensions @@ -52,6 +52,7 @@ namespace Ryujinx.Graphics.Shader { return format switch { +#pragma warning disable IDE0055 // Disable formatting TextureFormat.R8Unorm => "r8", TextureFormat.R8Snorm => "r8_snorm", TextureFormat.R8Uint => "r8ui", @@ -91,7 +92,8 @@ namespace Ryujinx.Graphics.Shader TextureFormat.R10G10B10A2Unorm => "rgb10_a2", TextureFormat.R10G10B10A2Uint => "rgb10_a2ui", TextureFormat.R11G11B10Float => "r11f_g11f_b10f", - _ => string.Empty + _ => string.Empty, +#pragma warning restore IDE0055 }; } diff --git a/src/Ryujinx.Graphics.Shader/TextureHandle.cs b/src/Ryujinx.Graphics.Shader/TextureHandle.cs index a59c8cd4a..fc9ab2d67 100644 --- a/src/Ryujinx.Graphics.Shader/TextureHandle.cs +++ b/src/Ryujinx.Graphics.Shader/TextureHandle.cs @@ -8,7 +8,7 @@ namespace Ryujinx.Graphics.Shader CombinedSampler = 0, // Must be 0. SeparateSamplerHandle = 1, SeparateSamplerId = 2, - SeparateConstantSamplerHandle = 3 + SeparateConstantSamplerHandle = 3, } public static class TextureHandle diff --git a/src/Ryujinx.Graphics.Shader/TextureUsageFlags.cs b/src/Ryujinx.Graphics.Shader/TextureUsageFlags.cs index 2419a1de4..3ad1685b6 100644 --- a/src/Ryujinx.Graphics.Shader/TextureUsageFlags.cs +++ b/src/Ryujinx.Graphics.Shader/TextureUsageFlags.cs @@ -14,6 +14,6 @@ namespace Ryujinx.Graphics.Shader ResScaleUnsupported = 1 << 0, NeedsScaleValue = 1 << 1, ImageStore = 1 << 2, - ImageCoherent = 1 << 3 + ImageCoherent = 1 << 3, } } diff --git a/src/Ryujinx.Graphics.Shader/Translation/AggregateType.cs b/src/Ryujinx.Graphics.Shader/Translation/AggregateType.cs index a54eddc59..def8f1a9d 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/AggregateType.cs +++ b/src/Ryujinx.Graphics.Shader/Translation/AggregateType.cs @@ -1,8 +1,10 @@ using System; +using System.Diagnostics.CodeAnalysis; namespace Ryujinx.Graphics.Shader.Translation { [Flags] + [SuppressMessage("Design", "CA1069: Enums values should not be duplicated")] enum AggregateType { Invalid, @@ -23,7 +25,7 @@ namespace Ryujinx.Graphics.Shader.Translation Vector3 = 2 << ElementCountShift, Vector4 = 3 << ElementCountShift, - Array = 1 << 10 + Array = 1 << 10, } static class AggregateTypeExtensions @@ -37,7 +39,7 @@ namespace Ryujinx.Graphics.Shader.Translation AggregateType.S32 or AggregateType.U32 => 4, AggregateType.FP64 => 8, - _ => 0 + _ => 0, }; switch (type & AggregateType.ElementCountMask) diff --git a/src/Ryujinx.Graphics.Shader/Translation/AttributeConsts.cs b/src/Ryujinx.Graphics.Shader/Translation/AttributeConsts.cs index 683b0d8ac..f749cecb8 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/AttributeConsts.cs +++ b/src/Ryujinx.Graphics.Shader/Translation/AttributeConsts.cs @@ -33,4 +33,4 @@ namespace Ryujinx.Graphics.Shader.Translation public const int UserAttributePerPatchBase = 0x18; public const int UserAttributePerPatchEnd = 0x200; } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Translation/ControlFlowGraph.cs b/src/Ryujinx.Graphics.Shader/Translation/ControlFlowGraph.cs index 65328fd7f..9b07c28f1 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/ControlFlowGraph.cs +++ b/src/Ryujinx.Graphics.Shader/Translation/ControlFlowGraph.cs @@ -13,11 +13,11 @@ namespace Ryujinx.Graphics.Shader.Translation { Blocks = blocks; - HashSet visited = new HashSet(); + HashSet visited = new(); - Stack blockStack = new Stack(); + Stack blockStack = new(); - List postOrderBlocks = new List(blocks.Length); + List postOrderBlocks = new(blocks.Length); PostOrderMap = new int[blocks.Length]; @@ -50,9 +50,9 @@ namespace Ryujinx.Graphics.Shader.Translation public static ControlFlowGraph Create(Operation[] operations) { - Dictionary labels = new Dictionary(); + Dictionary labels = new(); - List blocks = new List(); + List blocks = new(); BasicBlock currentBlock = null; @@ -68,7 +68,7 @@ namespace Ryujinx.Graphics.Shader.Translation void NewNextBlock() { - BasicBlock block = new BasicBlock(blocks.Count); + BasicBlock block = new(blocks.Count); blocks.Add(block); @@ -110,7 +110,7 @@ namespace Ryujinx.Graphics.Shader.Translation currentBlock.Operations.AddLast(operation); } - needsNewBlock = operation.Inst == Instruction.Branch || + needsNewBlock = operation.Inst == Instruction.Branch || operation.Inst == Instruction.BranchIfTrue || operation.Inst == Instruction.BranchIfFalse; @@ -173,4 +173,4 @@ namespace Ryujinx.Graphics.Shader.Translation return false; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Translation/Dominance.cs b/src/Ryujinx.Graphics.Shader/Translation/Dominance.cs index 09c2eb0fd..cd651ce08 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/Dominance.cs +++ b/src/Ryujinx.Graphics.Shader/Translation/Dominance.cs @@ -91,4 +91,4 @@ namespace Ryujinx.Graphics.Shader.Translation } } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Translation/EmitterContext.cs b/src/Ryujinx.Graphics.Shader/Translation/EmitterContext.cs index 87e5457f9..9eedc3f91 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/EmitterContext.cs +++ b/src/Ryujinx.Graphics.Shader/Translation/EmitterContext.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Diagnostics; using System.Numerics; using System.Runtime.CompilerServices; - using static Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandHelper; namespace Ryujinx.Graphics.Shader.Translation @@ -84,7 +83,7 @@ namespace Ryujinx.Graphics.Shader.Translation public Operand Add(Instruction inst, Operand dest = null, params Operand[] sources) { - Operation operation = new Operation(inst, dest, sources); + Operation operation = new(inst, dest, sources); _operations.Add(operation); @@ -93,7 +92,7 @@ namespace Ryujinx.Graphics.Shader.Translation public Operand Add(Instruction inst, StorageKind storageKind, Operand dest = null, params Operand[] sources) { - Operation operation = new Operation(inst, storageKind, dest, sources); + Operation operation = new(inst, storageKind, dest, sources); _operations.Add(operation); @@ -104,7 +103,7 @@ namespace Ryujinx.Graphics.Shader.Translation { Operand[] dests = new[] { dest.Item1, dest.Item2 }; - Operation operation = new Operation(inst, 0, dests, sources); + Operation operation = new(inst, 0, dests, sources); Add(operation); @@ -430,7 +429,7 @@ namespace Ryujinx.Graphics.Shader.Translation AlphaTestOp.Less => Instruction.CompareLess, AlphaTestOp.LessOrEqual => Instruction.CompareLessOrEqual, AlphaTestOp.NotEqual => Instruction.CompareNotEqual, - _ => 0 + _ => 0, }; Debug.Assert(comparator != 0, $"Invalid alpha test operation \"{alphaTestOp}\"."); @@ -532,4 +531,4 @@ namespace Ryujinx.Graphics.Shader.Translation return _operations.ToArray(); } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Translation/EmitterContextInsts.cs b/src/Ryujinx.Graphics.Shader/Translation/EmitterContextInsts.cs index 0ba26107c..c2f1b790f 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/EmitterContextInsts.cs +++ b/src/Ryujinx.Graphics.Shader/Translation/EmitterContextInsts.cs @@ -850,4 +850,4 @@ namespace Ryujinx.Graphics.Shader.Translation return context.Add(Instruction.VoteAny, Local(), a); } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Translation/FeatureFlags.cs b/src/Ryujinx.Graphics.Shader/Translation/FeatureFlags.cs index 59d35d906..9d4d032af 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/FeatureFlags.cs +++ b/src/Ryujinx.Graphics.Shader/Translation/FeatureFlags.cs @@ -13,7 +13,7 @@ namespace Ryujinx.Graphics.Shader.Translation // Affected by resolution scaling. IntegerSampling = 1 << 0, - FragCoordXY = 1 << 1, + FragCoordXY = 1 << 1, Bindless = 1 << 2, InstanceId = 1 << 3, @@ -23,6 +23,6 @@ namespace Ryujinx.Graphics.Shader.Translation OaIndexing = 1 << 8, FixedFuncAttr = 1 << 9, LocalMemory = 1 << 10, - SharedMemory = 1 << 11 + SharedMemory = 1 << 11, } } diff --git a/src/Ryujinx.Graphics.Shader/Translation/FunctionMatch.cs b/src/Ryujinx.Graphics.Shader/Translation/FunctionMatch.cs index 073e120a3..714a9d68c 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/FunctionMatch.cs +++ b/src/Ryujinx.Graphics.Shader/Translation/FunctionMatch.cs @@ -7,11 +7,11 @@ namespace Ryujinx.Graphics.Shader.Translation { static class FunctionMatch { - private static IPatternTreeNode[] _fsiGetAddressTree = PatternTrees.GetFsiGetAddress(); - private static IPatternTreeNode[] _fsiGetAddressV2Tree = PatternTrees.GetFsiGetAddressV2(); - private static IPatternTreeNode[] _fsiIsLastWarpThreadPatternTree = PatternTrees.GetFsiIsLastWarpThread(); - private static IPatternTreeNode[] _fsiBeginPatternTree = PatternTrees.GetFsiBeginPattern(); - private static IPatternTreeNode[] _fsiEndPatternTree = PatternTrees.GetFsiEndPattern(); + private static readonly IPatternTreeNode[] _fsiGetAddressTree = PatternTrees.GetFsiGetAddress(); + private static readonly IPatternTreeNode[] _fsiGetAddressV2Tree = PatternTrees.GetFsiGetAddressV2(); + private static readonly IPatternTreeNode[] _fsiIsLastWarpThreadPatternTree = PatternTrees.GetFsiIsLastWarpThread(); + private static readonly IPatternTreeNode[] _fsiBeginPatternTree = PatternTrees.GetFsiBeginPattern(); + private static readonly IPatternTreeNode[] _fsiEndPatternTree = PatternTrees.GetFsiEndPattern(); public static void RunPass(DecodedProgram program) { @@ -113,7 +113,7 @@ namespace Ryujinx.Graphics.Shader.Translation private enum TreeNodeType : byte { Op, - Label + Label, } private class TreeNode @@ -150,9 +150,9 @@ namespace Ryujinx.Graphics.Shader.Translation private static TreeNode[] BuildTree(Block[] blocks) { - List nodes = new List(); + List nodes = new(); - Dictionary labels = new Dictionary(); + Dictionary labels = new(); TreeNodeUse[] predDefs = new TreeNodeUse[RegisterConsts.PredsCount]; TreeNodeUse[] gprDefs = new TreeNodeUse[RegisterConsts.GprsCount]; @@ -223,7 +223,7 @@ namespace Ryujinx.Graphics.Shader.Translation if (block.Predecessors.Count > 1) { - TreeNode label = new TreeNode(order++); + TreeNode label = new(order++); nodes.Add(label); labels.Add(block.Address, label); } @@ -232,7 +232,7 @@ namespace Ryujinx.Graphics.Shader.Translation { InstOp op = block.OpCodes[opIndex]; - TreeNode node = new TreeNode(op, IsOrderDependant(op.Name) ? order : (byte)0); + TreeNode node = new(op, IsOrderDependant(op.Name) ? order : (byte)0); // Add uses. @@ -288,7 +288,7 @@ namespace Ryujinx.Graphics.Shader.Translation InstProps.SPd => 30, InstProps.TPd => 51, InstProps.VPd => 45, - _ => throw new InvalidOperationException($"Table has unknown predicate destination {pdType}.") + _ => throw new InvalidOperationException($"Table has unknown predicate destination {pdType}."), }; byte predIndex = (byte)((op.RawOpCode >> bit) & 7); @@ -350,7 +350,7 @@ namespace Ryujinx.Graphics.Shader.Translation public IPatternTreeNode Node { get; } public int Index { get; } public bool Inverted { get; } - public PatternTreeNodeUse Inv => new PatternTreeNodeUse(Index, !Inverted, Node); + public PatternTreeNodeUse Inv => new(Index, !Inverted, Node); private PatternTreeNodeUse(int index, bool inverted, IPatternTreeNode node) { @@ -373,7 +373,7 @@ namespace Ryujinx.Graphics.Shader.Translation public TreeNodeType Type { get; } public byte Order { get; } public bool IsImm { get; } - public PatternTreeNodeUse Out => new PatternTreeNodeUse(0, this); + public PatternTreeNodeUse Out => new(0, this); public PatternTreeNode(InstName name, Func match, TreeNodeType type = TreeNodeType.Op, byte order = 0, bool isImm = false) { @@ -435,7 +435,7 @@ namespace Ryujinx.Graphics.Shader.Translation } DecodedFunction callTarget = program.GetFunctionByAddress(callOp.GetAbsoluteAddress()); - TreeNode[] callTargetTree = null; + TreeNode[] callTargetTree; if (callTarget == null || !Matches(_fsiIsLastWarpThreadPatternTree, callTargetTree = BuildTree(callTarget.Blocks))) { @@ -548,7 +548,7 @@ namespace Ryujinx.Graphics.Shader.Translation .Use(PT) .Use(orderingTicketValue).Out), Iadd(x: true, 0, 405).Use(PT).Use(RZ), - Ret().Use(PT) + Ret().Use(PT), }; } @@ -576,7 +576,7 @@ namespace Ryujinx.Graphics.Shader.Translation .Use(PT) .Use(orderingTicketValue).Out).Out), Iadd(x: true, 0, 405).Use(PT).Use(RZ), - Ret().Use(PT) + Ret().Use(PT), }; } @@ -603,7 +603,7 @@ namespace Ryujinx.Graphics.Shader.Translation .Use(threadKillValue).OutAt(1)) .Use(RZ).Out).OutAt(1)).Out) .Use(laneIdValue), - Ret().Use(PT) + Ret().Use(PT), }; } @@ -638,7 +638,7 @@ namespace Ryujinx.Graphics.Shader.Translation .Use(PT) .Use(addressLowValue).Out).Inv) .Use(label.Out), - Ret().Use(PT) + Ret().Use(PT), }; } @@ -684,7 +684,7 @@ namespace Ryujinx.Graphics.Shader.Translation .Use(incrementValue) .Use(popcResult) .Use(RZ).Out).Out), - Ret().Use(PT) + Ret().Use(PT), }; } @@ -806,7 +806,6 @@ namespace Ryujinx.Graphics.Shader.Translation private static PatternTreeNodeUse PT => PTOrRZ(); private static PatternTreeNodeUse RZ => PTOrRZ(); - private static PatternTreeNodeUse Undef => new PatternTreeNodeUse(0, null); private static PatternTreeNodeUse CallArg(int index) { diff --git a/src/Ryujinx.Graphics.Shader/Translation/HelperFunctionManager.cs b/src/Ryujinx.Graphics.Shader/Translation/HelperFunctionManager.cs index 51a396821..2addff5c0 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/HelperFunctionManager.cs +++ b/src/Ryujinx.Graphics.Shader/Translation/HelperFunctionManager.cs @@ -1,7 +1,6 @@ using Ryujinx.Graphics.Shader.IntermediateRepresentation; using System; using System.Collections.Generic; - using static Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandHelper; namespace Ryujinx.Graphics.Shader.Translation @@ -65,13 +64,13 @@ namespace Ryujinx.Graphics.Shader.Translation HelperFunctionName.ConvertFloatToDouble => GenerateConvertFloatToDoubleFunction(), HelperFunctionName.TexelFetchScale => GenerateTexelFetchScaleFunction(), HelperFunctionName.TextureSizeUnscale => GenerateTextureSizeUnscaleFunction(), - _ => throw new ArgumentException($"Invalid function name {functionName}") + _ => throw new ArgumentException($"Invalid function name {functionName}"), }; } - private Function GenerateConvertDoubleToFloatFunction() + private static Function GenerateConvertDoubleToFloatFunction() { - EmitterContext context = new EmitterContext(); + EmitterContext context = new(); Operand valueLow = Argument(0); Operand valueHigh = Argument(1); @@ -119,9 +118,9 @@ namespace Ryujinx.Graphics.Shader.Translation return new Function(ControlFlowGraph.Create(context.GetOperations()).Blocks, "ConvertDoubleToFloat", true, 2, 0); } - private Function GenerateConvertFloatToDoubleFunction() + private static Function GenerateConvertFloatToDoubleFunction() { - EmitterContext context = new EmitterContext(); + EmitterContext context = new(); Operand value = Argument(0); @@ -164,13 +163,13 @@ namespace Ryujinx.Graphics.Shader.Translation HelperFunctionName.SharedAtomicMinS32 => GenerateSharedAtomicSigned(id, isMin: true), HelperFunctionName.SharedStore8 => GenerateSharedStore8(id), HelperFunctionName.SharedStore16 => GenerateSharedStore16(id), - _ => throw new ArgumentException($"Invalid function name {functionName}") + _ => throw new ArgumentException($"Invalid function name {functionName}"), }; } private static Function GenerateSharedAtomicSigned(int id, bool isMin) { - EmitterContext context = new EmitterContext(); + EmitterContext context = new(); Operand wordOffset = Argument(0); Operand value = Argument(1); @@ -199,7 +198,7 @@ namespace Ryujinx.Graphics.Shader.Translation private static Function GenerateSharedStore(int id, int bitSize) { - EmitterContext context = new EmitterContext(); + EmitterContext context = new(); Operand offset = Argument(0); Operand value = Argument(1); @@ -219,7 +218,7 @@ namespace Ryujinx.Graphics.Shader.Translation private Function GenerateTexelFetchScaleFunction() { - EmitterContext context = new EmitterContext(); + EmitterContext context = new(); Operand input = Argument(0); Operand samplerIndex = Argument(1); @@ -270,7 +269,7 @@ namespace Ryujinx.Graphics.Shader.Translation private Function GenerateTextureSizeUnscaleFunction() { - EmitterContext context = new EmitterContext(); + EmitterContext context = new(); Operand input = Argument(0); Operand samplerIndex = Argument(1); @@ -328,4 +327,4 @@ namespace Ryujinx.Graphics.Shader.Translation } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Translation/HelperFunctionName.cs b/src/Ryujinx.Graphics.Shader/Translation/HelperFunctionName.cs index 984f2d047..e5af17355 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/HelperFunctionName.cs +++ b/src/Ryujinx.Graphics.Shader/Translation/HelperFunctionName.cs @@ -9,6 +9,6 @@ namespace Ryujinx.Graphics.Shader.Translation SharedStore8, SharedStore16, TexelFetchScale, - TextureSizeUnscale + TextureSizeUnscale, } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Translation/Optimizations/BindlessElimination.cs b/src/Ryujinx.Graphics.Shader/Translation/Optimizations/BindlessElimination.cs index 0c196c4d0..bb25c1602 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/Optimizations/BindlessElimination.cs +++ b/src/Ryujinx.Graphics.Shader/Translation/Optimizations/BindlessElimination.cs @@ -16,7 +16,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations // - Both sources of the OR operation comes from a constant buffer. for (LinkedListNode node = block.Operations.First; node != null; node = node.Next) { - if (!(node.Value is TextureOperation texOp)) + if (node.Value is not TextureOperation texOp) { continue; } @@ -47,7 +47,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations continue; } - if (!(bindlessHandle.AsgOp is Operation handleCombineOp)) + if (bindlessHandle.AsgOp is not Operation handleCombineOp) { continue; } @@ -66,9 +66,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations // and having a "canonical" representation simplifies some checks below. if (src0.Type == OperandType.Constant && src1.Type != OperandType.Constant) { - Operand temp = src1; - src1 = src0; - src0 = temp; + (src0, src1) = (src1, src0); } TextureHandleType handleType = TextureHandleType.SeparateSamplerHandle; diff --git a/src/Ryujinx.Graphics.Shader/Translation/Optimizations/BindlessToIndexed.cs b/src/Ryujinx.Graphics.Shader/Translation/Optimizations/BindlessToIndexed.cs index 9a3ae1b8f..f966a4fc5 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/Optimizations/BindlessToIndexed.cs +++ b/src/Ryujinx.Graphics.Shader/Translation/Optimizations/BindlessToIndexed.cs @@ -17,7 +17,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations // The base offset of the array of handles on the constant buffer is the constant offset. for (LinkedListNode node = block.Operations.First; node != null; node = node.Next) { - if (!(node.Value is TextureOperation texOp)) + if (node.Value is not TextureOperation texOp) { continue; } @@ -27,7 +27,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations continue; } - if (!(texOp.GetSource(0).AsgOp is Operation handleAsgOp)) + if (texOp.GetSource(0).AsgOp is not Operation handleAsgOp) { continue; } @@ -64,17 +64,17 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations // Plus this whole transform is fundamentally flawed as-is since we have no way to know the array size. // Eventually, this should be entirely removed in favor of a implementation that supports true bindless // texture access. - if (!(ldcSrc2.AsgOp is Operation shrOp) || shrOp.Inst != Instruction.ShiftRightU32) + if (ldcSrc2.AsgOp is not Operation shrOp || shrOp.Inst != Instruction.ShiftRightU32) { continue; } - if (!(shrOp.GetSource(0).AsgOp is Operation shrOp2) || shrOp2.Inst != Instruction.ShiftRightU32) + if (shrOp.GetSource(0).AsgOp is not Operation shrOp2 || shrOp2.Inst != Instruction.ShiftRightU32) { continue; } - if (!(shrOp2.GetSource(0).AsgOp is Operation addOp) || addOp.Inst != Instruction.Add) + if (shrOp2.GetSource(0).AsgOp is not Operation addOp || addOp.Inst != Instruction.Add) { continue; } @@ -92,7 +92,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations Operand source = addOp.GetSource(0); - Operation shrBy3 = new Operation(Instruction.ShiftRightU32, index, source, Const(3)); + Operation shrBy3 = new(Instruction.ShiftRightU32, index, source, Const(3)); block.Operations.AddBefore(node, shrBy3); @@ -106,4 +106,4 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations config.SetUsedTexture(texOp.Inst, texOp.Type, texOp.Format, texOp.Flags, texOp.CbufSlot, handle); } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Translation/Optimizations/BranchElimination.cs b/src/Ryujinx.Graphics.Shader/Translation/Optimizations/BranchElimination.cs index c87d14748..bd2eceda5 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/Optimizations/BranchElimination.cs +++ b/src/Ryujinx.Graphics.Shader/Translation/Optimizations/BranchElimination.cs @@ -31,7 +31,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations return false; } - if (!(nextBlock.Operations.First?.Value is Operation next)) + if (nextBlock.Operations.First?.Value is not Operation next) { return false; } @@ -61,4 +61,4 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations return block; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Translation/Optimizations/ConstantFolding.cs b/src/Ryujinx.Graphics.Shader/Translation/Optimizations/ConstantFolding.cs index 4caadb737..0cca0ac6c 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/Optimizations/ConstantFolding.cs +++ b/src/Ryujinx.Graphics.Shader/Translation/Optimizations/ConstantFolding.cs @@ -1,7 +1,6 @@ using Ryujinx.Common.Utilities; using Ryujinx.Graphics.Shader.IntermediateRepresentation; using System; - using static Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandHelper; namespace Ryujinx.Graphics.Shader.Translation.Optimizations @@ -262,8 +261,8 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations private static int GetBitfieldExtractValue(Operation operation) { - int value = operation.GetSource(0).Value; - int lsb = operation.GetSource(1).Value; + int value = operation.GetSource(0).Value; + int lsb = operation.GetSource(1).Value; int length = operation.GetSource(2).Value; return value.Extract(lsb, length); @@ -278,13 +277,6 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations operation.TurnIntoCopy(ConstF((float)BitConverter.UInt16BitsToHalf((ushort)value))); } - private static void FPNegate(Operation operation) - { - float value = operation.GetSource(0).AsFloat(); - - operation.TurnIntoCopy(ConstF(-value)); - } - private static void EvaluateUnary(Operation operation, Func op) { int x = operation.GetSource(0).Value; @@ -356,4 +348,4 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations operation.TurnIntoCopy(ConstF(op(x, y, z))); } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Translation/Optimizations/DoubleToFloat.cs b/src/Ryujinx.Graphics.Shader/Translation/Optimizations/DoubleToFloat.cs index 42bce5cc2..aec95a9cc 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/Optimizations/DoubleToFloat.cs +++ b/src/Ryujinx.Graphics.Shader/Translation/Optimizations/DoubleToFloat.cs @@ -11,7 +11,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations { for (LinkedListNode node = block.Operations.First; node != null; node = node.Next) { - if (node.Value is not Operation operation) + if (node.Value is not Operation) { continue; } @@ -67,4 +67,4 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations } } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Translation/Optimizations/GlobalToStorage.cs b/src/Ryujinx.Graphics.Shader/Translation/Optimizations/GlobalToStorage.cs index 9d260c678..2433aeb20 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/Optimizations/GlobalToStorage.cs +++ b/src/Ryujinx.Graphics.Shader/Translation/Optimizations/GlobalToStorage.cs @@ -2,7 +2,6 @@ using Ryujinx.Graphics.Shader.IntermediateRepresentation; using System; using System.Collections.Generic; using System.Linq; - using static Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandHelper; namespace Ryujinx.Graphics.Shader.Translation.Optimizations @@ -14,12 +13,12 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations enum LsMemoryType { Local, - Shared + Shared, } private class GtsContext { - private struct Entry + private readonly struct Entry { public readonly int FunctionId; public readonly Instruction Inst; @@ -42,7 +41,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations } } - private struct LsKey : IEquatable + private readonly struct LsKey : IEquatable { public readonly Operand BaseOffset; public readonly int ConstOffset; @@ -127,7 +126,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations public void AddMemoryTargetCb(LsMemoryType type, Operand baseOffset, int constOffset, uint targetCb, SearchResult result) { - LsKey key = new LsKey(baseOffset, constOffset, type); + LsKey key = new(baseOffset, constOffset, type); if (!_sharedEntries.TryGetValue(key, out Dictionary targetCbs)) { @@ -162,7 +161,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations public bool TryGetMemoryTargetCb(LsMemoryType type, Operand baseOffset, int constOffset, out SearchResult result) { - LsKey key = new LsKey(baseOffset, constOffset, type); + LsKey key = new(baseOffset, constOffset, type); if (_sharedEntries.TryGetValue(key, out Dictionary targetCbs) && targetCbs.Count == 1) { @@ -182,9 +181,9 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations } } - private struct SearchResult + private readonly struct SearchResult { - public static SearchResult NotFound => new SearchResult(-1, 0); + public static SearchResult NotFound => new(-1, 0); public bool Found => SbCbSlot != -1; public int SbCbSlot { get; } public int SbCbOffset { get; } @@ -208,13 +207,13 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations public static void RunPass(HelperFunctionManager hfm, BasicBlock[] blocks, ShaderConfig config) { - GtsContext gtsContext = new GtsContext(hfm); + GtsContext gtsContext = new(hfm); foreach (BasicBlock block in blocks) { for (LinkedListNode node = block.Operations.First; node != null; node = node.Next) { - if (!(node.Value is Operation operation)) + if (node.Value is not Operation operation) { continue; } @@ -315,8 +314,8 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations int alignment = config.GpuAccessor.QueryHostStorageBufferOffsetAlignment(); - Operation maskOp = new Operation(Instruction.BitwiseAnd, baseAddressMasked, new[] { baseAddress, Const(-alignment) }); - Operation subOp = new Operation(Instruction.Subtract, hostOffset, new[] { globalAddress, baseAddressMasked }); + Operation maskOp = new(Instruction.BitwiseAnd, baseAddressMasked, baseAddress, Const(-alignment)); + Operation subOp = new(Instruction.Subtract, hostOffset, globalAddress, baseAddressMasked); node.List.AddBefore(node, maskOp); node.List.AddBefore(node, subOp); @@ -327,7 +326,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations { Operand newOffset = Local(); - Operation addOp = new Operation(Instruction.Add, newOffset, new[] { offset, Const(result.ConstOffset) }); + Operation addOp = new(Instruction.Add, newOffset, offset, Const(result.ConstOffset)); node.List.AddBefore(node, addOp); @@ -394,26 +393,26 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations if (operation.Inst == Instruction.AtomicCompareAndSwap) { - sources = new Operand[] + sources = new[] { Const(binding), Const(0), wordOffset, operation.GetSource(operation.SourcesCount - 2), - operation.GetSource(operation.SourcesCount - 1) + operation.GetSource(operation.SourcesCount - 1), }; } else if (isStore) { - sources = new Operand[] { Const(binding), Const(0), wordOffset, operation.GetSource(operation.SourcesCount - 1) }; + sources = new[] { Const(binding), Const(0), wordOffset, operation.GetSource(operation.SourcesCount - 1) }; } else { - sources = new Operand[] { Const(binding), Const(0), wordOffset }; + sources = new[] { Const(binding), Const(0), wordOffset }; } - Operation shiftOp = new Operation(Instruction.ShiftRightU32, wordOffset, new[] { offset, Const(2) }); - Operation storageOp = new Operation(operation.Inst, StorageKind.StorageBuffer, operation.Dest, sources); + Operation shiftOp = new(Instruction.ShiftRightU32, wordOffset, offset, Const(2)); + Operation storageOp = new(operation.Inst, StorageKind.StorageBuffer, operation.Dest, sources); node.List.AddBefore(node, shiftOp); LinkedListNode newNode = node.List.AddBefore(node, storageOp); @@ -455,7 +454,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations bool returnsValue = operation.Dest != null; Operand returnValue = returnsValue ? Local() : null; - Operation callOp = new Operation(Instruction.Call, returnValue, sources); + Operation callOp = new(Instruction.Call, returnValue, sources); LinkedListNode newNode = node.List.AddBefore(node, callOp); @@ -480,7 +479,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations SearchResult result, out int functionId) { - List targetCbs = new List() { PackCbSlotAndOffset(result.SbCbSlot, result.SbCbOffset) }; + List targetCbs = new() { PackCbSlotAndOffset(result.SbCbSlot, result.SbCbOffset) }; if (gtsContext.TryGetFunctionId(operation, isMultiTarget: false, targetCbs, out functionId)) { @@ -498,7 +497,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations inArgumentsCount = 2; } - EmitterContext context = new EmitterContext(); + EmitterContext context = new(); Operand offset = Argument(0); Operand compare = null; @@ -542,7 +541,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations string functionName = GetFunctionName(operation, isMultiTarget: false, targetCbs); - Function function = new Function( + Function function = new( ControlFlowGraph.Create(context.GetOperations()).Blocks, functionName, returnsValue, @@ -561,9 +560,9 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations Operation operation, out int functionId) { - Queue phis = new Queue(); - HashSet visited = new HashSet(); - List targetCbs = new List(); + Queue phis = new(); + HashSet visited = new(); + List targetCbs = new(); Operand globalAddress = operation.GetSource(0); @@ -644,7 +643,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations inArgumentsCount = 3; } - EmitterContext context = new EmitterContext(); + EmitterContext context = new(); Operand globalAddressLow = Argument(0); Operand globalAddressHigh = Argument(1); @@ -684,7 +683,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations value = Argument(2); } - SearchResult result = new SearchResult(sbCbSlot, sbCbOffset); + SearchResult result = new(sbCbSlot, sbCbOffset); int alignment = config.GpuAccessor.QueryHostStorageBufferOffsetAlignment(); @@ -731,7 +730,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations string functionName = GetFunctionName(operation, isMultiTarget: true, targetCbs); - Function function = new Function( + Function function = new( ControlFlowGraph.Create(context.GetOperations()).Blocks, functionName, returnsValue, @@ -763,7 +762,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations StorageKind.GlobalMemoryS16 => "S16", StorageKind.GlobalMemoryU8 => "U8", StorageKind.GlobalMemoryU16 => "U16", - _ => string.Empty + _ => string.Empty, }; if (isMultiTarget) @@ -871,7 +870,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations StorageKind.GlobalMemoryU8 => 8, StorageKind.GlobalMemoryS16 or StorageKind.GlobalMemoryU16 => 16, - _ => 32 + _ => 32, }; if (bitSize < 32) @@ -1137,4 +1136,4 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations return false; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Translation/Optimizations/Optimizer.cs b/src/Ryujinx.Graphics.Shader/Translation/Optimizations/Optimizer.cs index 8d2669c0d..e7805027f 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/Optimizations/Optimizer.cs +++ b/src/Ryujinx.Graphics.Shader/Translation/Optimizations/Optimizer.cs @@ -60,7 +60,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations bool isUnused = IsUnused(node.Value); - if (!(node.Value is Operation operation) || isUnused) + if (node.Value is not Operation operation || isUnused) { if (node.Value is PhiNode phi && !isUnused) { @@ -93,7 +93,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations modified = true; } else if ((operation.Inst == Instruction.PackHalf2x16 && PropagatePack(operation)) || - (operation.Inst == Instruction.ShuffleXor && MatchDdxOrDdy(operation))) + (operation.Inst == Instruction.ShuffleXor && MatchDdxOrDdy(operation))) { if (DestHasNoUses(operation)) { @@ -124,7 +124,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations // the destination operand. Operand dest = copyOp.Dest; - Operand src = copyOp.GetSource(0); + Operand src = copyOp.GetSource(0); INode[] uses = dest.UseOps.ToArray(); @@ -199,7 +199,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations foreach (INode useNode in uses) { - if (!(useNode is Operation operation) || operation.Inst != Instruction.UnpackHalf2x16) + if (useNode is not Operation operation || operation.Inst != Instruction.UnpackHalf2x16) { continue; } @@ -248,12 +248,12 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations foreach (INode use in uses) { - if (!(use is Operation test)) + if (use is not Operation test) { continue; } - if (!(use is Operation useOp) || useOp.Inst != Instruction.SwizzleAdd) + if (use is not Operation useOp || useOp.Inst != Instruction.SwizzleAdd) { continue; } @@ -323,7 +323,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations Operand rhs = operation.GetSource(1); // Check LHS of the the main multiplication operation. We expect an input being multiplied by gl_FragCoord.w. - if (!(lhs.AsgOp is Operation attrMulOp) || attrMulOp.Inst != (Instruction.FP32 | Instruction.Multiply)) + if (lhs.AsgOp is not Operation attrMulOp || attrMulOp.Inst != (Instruction.FP32 | Instruction.Multiply)) { return; } @@ -338,7 +338,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations } // RHS of the main multiplication should be a reciprocal operation (1.0 / x). - if (!(rhs.AsgOp is Operation reciprocalOp) || reciprocalOp.Inst != (Instruction.FP32 | Instruction.Divide)) + if (rhs.AsgOp is not Operation reciprocalOp || reciprocalOp.Inst != (Instruction.FP32 | Instruction.Divide)) { return; } @@ -368,7 +368,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations // from all the use lists on the operands that this node uses. block.Operations.Remove(llNode); - Queue nodes = new Queue(); + Queue nodes = new(); nodes.Enqueue(llNode.Value); @@ -457,4 +457,4 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations return true; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Translation/Optimizations/Simplification.cs b/src/Ryujinx.Graphics.Shader/Translation/Optimizations/Simplification.cs index 9b78c8aaa..a509fcb42 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/Optimizations/Simplification.cs +++ b/src/Ryujinx.Graphics.Shader/Translation/Optimizations/Simplification.cs @@ -202,4 +202,4 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations return operand.Value == comparand; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Translation/Optimizations/Utils.cs b/src/Ryujinx.Graphics.Shader/Translation/Optimizations/Utils.cs index ffbd16f85..baf8e66e7 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/Optimizations/Utils.cs +++ b/src/Ryujinx.Graphics.Shader/Translation/Optimizations/Utils.cs @@ -14,7 +14,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations public static bool IsInputLoad(INode node, IoVariable ioVariable, int elemIndex) { - if (!(node is Operation operation) || + if (node is not Operation operation || operation.Inst != Instruction.Load || operation.StorageKind != StorageKind.Input || operation.SourcesCount != 2) diff --git a/src/Ryujinx.Graphics.Shader/Translation/RegisterUsage.cs b/src/Ryujinx.Graphics.Shader/Translation/RegisterUsage.cs index 9e31831de..e27e47070 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/RegisterUsage.cs +++ b/src/Ryujinx.Graphics.Shader/Translation/RegisterUsage.cs @@ -10,7 +10,7 @@ namespace Ryujinx.Graphics.Shader.Translation static class RegisterUsage { private const int RegsCount = 256; - private const int RegsMask = RegsCount - 1; + private const int RegsMask = RegsCount - 1; private const int GprMasks = 4; private const int PredMasks = 1; @@ -36,7 +36,7 @@ namespace Ryujinx.Graphics.Shader.Translation FlagMask = flagMask; } - public long GetMask(int index) + public readonly long GetMask(int index) { return index switch { @@ -46,7 +46,7 @@ namespace Ryujinx.Graphics.Shader.Translation 3 => GprMask3, 4 => PredMask, 5 => FlagMask, - _ => throw new ArgumentOutOfRangeException(nameof(index)) + _ => throw new ArgumentOutOfRangeException(nameof(index)), }; } @@ -93,12 +93,12 @@ namespace Ryujinx.Graphics.Shader.Translation return !x.Equals(y); } - public override bool Equals(object obj) + public readonly override bool Equals(object obj) { return obj is RegisterMask regMask && Equals(regMask); } - public bool Equals(RegisterMask other) + public readonly bool Equals(RegisterMask other) { return GprMask0 == other.GprMask0 && GprMask1 == other.GprMask1 && @@ -108,7 +108,7 @@ namespace Ryujinx.Graphics.Shader.Translation FlagMask == other.FlagMask; } - public override int GetHashCode() + public readonly override int GetHashCode() { return HashCode.Combine(GprMask0, GprMask1, GprMask2, GprMask3, PredMask, FlagMask); } @@ -121,18 +121,18 @@ namespace Ryujinx.Graphics.Shader.Translation public FunctionRegisterUsage(Register[] inArguments, Register[] outArguments) { - InArguments = inArguments; + InArguments = inArguments; OutArguments = outArguments; } } public static FunctionRegisterUsage RunPass(ControlFlowGraph cfg) { - List inArguments = new List(); - List outArguments = new List(); + List inArguments = new(); + List outArguments = new(); // Compute local register inputs and outputs used inside blocks. - RegisterMask[] localInputs = new RegisterMask[cfg.Blocks.Length]; + RegisterMask[] localInputs = new RegisterMask[cfg.Blocks.Length]; RegisterMask[] localOutputs = new RegisterMask[cfg.Blocks.Length]; foreach (BasicBlock block in cfg.Blocks) @@ -165,11 +165,11 @@ namespace Ryujinx.Graphics.Shader.Translation // Compute global register inputs and outputs used across blocks. RegisterMask[] globalCmnOutputs = new RegisterMask[cfg.Blocks.Length]; - RegisterMask[] globalInputs = new RegisterMask[cfg.Blocks.Length]; + RegisterMask[] globalInputs = new RegisterMask[cfg.Blocks.Length]; RegisterMask[] globalOutputs = new RegisterMask[cfg.Blocks.Length]; - RegisterMask allOutputs = new RegisterMask(); - RegisterMask allCmnOutputs = new RegisterMask(-1L, -1L, -1L, -1L, -1L, -1L); + RegisterMask allOutputs = new(); + RegisterMask allCmnOutputs = new(-1L, -1L, -1L, -1L, -1L, -1L); bool modified; @@ -389,14 +389,14 @@ namespace Ryujinx.Graphics.Shader.Translation mask &= ~(1L << bit); - Register register = new Register(baseRegIndex + bit, regType); + Register register = new(baseRegIndex + bit, regType); if (fillArgsList) { inArguments.Add(register); } - Operation copyOp = new Operation(Instruction.Copy, OperandHelper.Register(register), OperandHelper.Argument(argIndex++)); + Operation copyOp = new(Instruction.Copy, OperandHelper.Register(register), OperandHelper.Argument(argIndex++)); if (node == null) { @@ -429,14 +429,14 @@ namespace Ryujinx.Graphics.Shader.Translation mask &= ~(1L << bit); - Register register = new Register(baseRegIndex + bit, regType); + Register register = new(baseRegIndex + bit, regType); if (fillArgsList) { outArguments.Add(register); } - Operation copyOp = new Operation(Instruction.Copy, OperandHelper.Argument(argIndex++), OperandHelper.Register(register)); + Operation copyOp = new(Instruction.Copy, OperandHelper.Argument(argIndex++), OperandHelper.Register(register)); if (node == null) { @@ -475,7 +475,7 @@ namespace Ryujinx.Graphics.Shader.Translation private static bool EndsWithReturn(BasicBlock block) { - if (!(block.GetLastOp() is Operation operation)) + if (block.GetLastOp() is not Operation operation) { return false; } @@ -483,4 +483,4 @@ namespace Ryujinx.Graphics.Shader.Translation return operation.Inst == Instruction.Return; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Translation/ResourceManager.cs b/src/Ryujinx.Graphics.Shader/Translation/ResourceManager.cs index 3a46f6e4e..f3a5ba6c4 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/ResourceManager.cs +++ b/src/Ryujinx.Graphics.Shader/Translation/ResourceManager.cs @@ -13,10 +13,9 @@ namespace Ryujinx.Graphics.Shader.Translation private const int DefaultLocalMemorySize = 128; private const int DefaultSharedMemorySize = 4096; - private static readonly string[] _stagePrefixes = new string[] { "cp", "vp", "tcp", "tep", "gp", "fp" }; + private static readonly string[] _stagePrefixes = { "cp", "vp", "tcp", "tep", "gp", "fp" }; private readonly IGpuAccessor _gpuAccessor; - private readonly ShaderProperties _properties; private readonly string _stagePrefix; private readonly int[] _cbSlotToBindingMap; @@ -31,12 +30,12 @@ namespace Ryujinx.Graphics.Shader.Translation public int LocalMemoryId { get; private set; } public int SharedMemoryId { get; private set; } - public ShaderProperties Properties => _properties; + public ShaderProperties Properties { get; } public ResourceManager(ShaderStage stage, IGpuAccessor gpuAccessor, ShaderProperties properties) { _gpuAccessor = gpuAccessor; - _properties = properties; + Properties = properties; _stagePrefix = GetShaderStagePrefix(stage); _cbSlotToBindingMap = new int[18]; @@ -83,7 +82,7 @@ namespace Ryujinx.Graphics.Shader.Translation size = DefaultSharedMemorySize; } - var smem = new MemoryDefinition("shared_memory", AggregateType.Array | AggregateType.U32, BitUtils.DivRoundUp(size, sizeof(uint))); + var smem = new MemoryDefinition("shared_memory", AggregateType.Array | AggregateType.U32, BitUtils.DivRoundUp(size, sizeof(uint))); SharedMemoryId = Properties.AddSharedMemory(smem); } @@ -211,7 +210,7 @@ namespace Ryujinx.Graphics.Shader.Translation (int sbCbSlot, int sbCbOffset) = UnpackSbCbInfo(key); descriptors[descriptorIndex++] = new BufferDescriptor(binding, slot, sbCbSlot, sbCbOffset) { - Flags = (_sbSlotWritten & (1u << slot)) != 0 ? BufferUsageFlags.Write : BufferUsageFlags.None + Flags = (_sbSlotWritten & (1u << slot)) != 0 ? BufferUsageFlags.Write : BufferUsageFlags.None, }; } } @@ -226,39 +225,34 @@ namespace Ryujinx.Graphics.Shader.Translation private void AddNewConstantBuffer(int binding, string name) { - StructureType type = new StructureType(new[] + StructureType type = new(new[] { - new StructureField(AggregateType.Array | AggregateType.Vector4 | AggregateType.FP32, "data", Constants.ConstantBufferSize / 16) + new StructureField(AggregateType.Array | AggregateType.Vector4 | AggregateType.FP32, "data", Constants.ConstantBufferSize / 16), }); - _properties.AddConstantBuffer(binding, new BufferDefinition(BufferLayout.Std140, 0, binding, name, type)); + Properties.AddConstantBuffer(binding, new BufferDefinition(BufferLayout.Std140, 0, binding, name, type)); } private void AddNewStorageBuffer(int binding, string name) { - StructureType type = new StructureType(new[] + StructureType type = new(new[] { - new StructureField(AggregateType.Array | AggregateType.U32, "data", 0) + new StructureField(AggregateType.Array | AggregateType.U32, "data", 0), }); - _properties.AddStorageBuffer(binding, new BufferDefinition(BufferLayout.Std430, 1, binding, name, type)); + Properties.AddStorageBuffer(binding, new BufferDefinition(BufferLayout.Std430, 1, binding, name, type)); } public static string GetShaderStagePrefix(ShaderStage stage) { uint index = (uint)stage; - if (index >= _stagePrefixes.Length) - { - return "invalid"; - } - - return _stagePrefixes[index]; + return index >= _stagePrefixes.Length ? "invalid" : _stagePrefixes[index]; } private static int PackSbCbInfo(int sbCbSlot, int sbCbOffset) { - return sbCbOffset | ((int)sbCbSlot << 16); + return sbCbOffset | (sbCbSlot << 16); } private static (int, int) UnpackSbCbInfo(int key) @@ -266,4 +260,4 @@ namespace Ryujinx.Graphics.Shader.Translation return ((byte)(key >> 16), (ushort)key); } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Translation/Rewriter.cs b/src/Ryujinx.Graphics.Shader/Translation/Rewriter.cs index f5a524a0f..42e3ecee3 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/Rewriter.cs +++ b/src/Ryujinx.Graphics.Shader/Translation/Rewriter.cs @@ -4,7 +4,6 @@ using Ryujinx.Graphics.Shader.Translation.Optimizations; using System.Collections.Generic; using System.Diagnostics; using System.Linq; - using static Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandHelper; namespace Ryujinx.Graphics.Shader.Translation @@ -134,7 +133,7 @@ namespace Ryujinx.Graphics.Shader.Translation AggregateType.Vector2 => 2, AggregateType.Vector3 => 3, AggregateType.Vector4 => 4, - _ => 1 + _ => 1, }; if (elemCount == 1) @@ -154,9 +153,9 @@ namespace Ryujinx.Graphics.Shader.Translation inputs[srcIndex] = operation.GetSource(srcIndex); } - inputs[inputs.Length - 1] = Const(i); + inputs[^1] = Const(i); - Operation loadOp = new Operation(Instruction.Load, StorageKind.ConstantBuffer, value, inputs); + Operation loadOp = new(Instruction.Load, StorageKind.ConstantBuffer, value, inputs); node.List.AddBefore(node, loadOp); @@ -169,8 +168,8 @@ namespace Ryujinx.Graphics.Shader.Translation Operand isCurrentIndex = Local(); Operand selection = Local(); - Operation compareOp = new Operation(Instruction.CompareEqual, isCurrentIndex, new Operand[] { elemIndex, Const(i) }); - Operation selectOp = new Operation(Instruction.ConditionalSelect, selection, new Operand[] { isCurrentIndex, value, result }); + Operation compareOp = new(Instruction.CompareEqual, isCurrentIndex, new Operand[] { elemIndex, Const(i) }); + Operation selectOp = new(Instruction.ConditionalSelect, selection, new Operand[] { isCurrentIndex, value, result }); node.List.AddBefore(node, compareOp); node.List.AddBefore(node, selectOp); @@ -267,10 +266,8 @@ namespace Ryujinx.Graphics.Shader.Translation { TextureOperation texOp = (TextureOperation)node.Value; - bool isBindless = (texOp.Flags & TextureFlags.Bindless) != 0; - bool intCoords = (texOp.Flags & TextureFlags.IntCoords) != 0; - - bool isArray = (texOp.Type & SamplerType.Array) != 0; + bool isBindless = (texOp.Flags & TextureFlags.Bindless) != 0; + bool intCoords = (texOp.Flags & TextureFlags.IntCoords) != 0; bool isIndexed = (texOp.Type & SamplerType.Indexed) != 0; int coordsCount = texOp.Type.GetDimensions(); @@ -318,10 +315,7 @@ namespace Ryujinx.Graphics.Shader.Translation { TextureOperation texOp = (TextureOperation)node.Value; - bool isBindless = (texOp.Flags & TextureFlags.Bindless) != 0; - bool intCoords = (texOp.Flags & TextureFlags.IntCoords) != 0; - - bool isArray = (texOp.Type & SamplerType.Array) != 0; + bool isBindless = (texOp.Flags & TextureFlags.Bindless) != 0; bool isIndexed = (texOp.Type & SamplerType.Indexed) != 0; if (texOp.Inst == Instruction.TextureSize && @@ -383,8 +377,8 @@ namespace Ryujinx.Graphics.Shader.Translation TextureOperation texOp = (TextureOperation)node.Value; - bool isBindless = (texOp.Flags & TextureFlags.Bindless) != 0; - bool intCoords = (texOp.Flags & TextureFlags.IntCoords) != 0; + bool isBindless = (texOp.Flags & TextureFlags.Bindless) != 0; + bool intCoords = (texOp.Flags & TextureFlags.IntCoords) != 0; bool isCoordNormalized = isBindless || config.GpuAccessor.QueryTextureCoordNormalized(texOp.Handle, texOp.CbufSlot); @@ -393,7 +387,6 @@ namespace Ryujinx.Graphics.Shader.Translation return node; } - bool isArray = (texOp.Type & SamplerType.Array) != 0; bool isIndexed = (texOp.Type & SamplerType.Indexed) != 0; int coordsCount = texOp.Type.GetDimensions(); @@ -453,7 +446,7 @@ namespace Ryujinx.Graphics.Shader.Translation TextureOperation texOp = (TextureOperation)node.Value; bool isBindless = (texOp.Flags & TextureFlags.Bindless) != 0; - bool isGather = (texOp.Flags & TextureFlags.Gather) != 0; + bool isGather = (texOp.Flags & TextureFlags.Gather) != 0; int gatherBiasPrecision = config.GpuAccessor.QueryHostGatherBiasPrecision(); @@ -462,10 +455,12 @@ namespace Ryujinx.Graphics.Shader.Translation return node; } +#pragma warning disable IDE0059 // Remove unnecessary value assignment bool intCoords = (texOp.Flags & TextureFlags.IntCoords) != 0; - bool isArray = (texOp.Type & SamplerType.Array) != 0; + bool isArray = (texOp.Type & SamplerType.Array) != 0; bool isIndexed = (texOp.Type & SamplerType.Indexed) != 0; +#pragma warning restore IDE0059 int coordsCount = texOp.Type.GetDimensions(); int coordsIndex = isBindless || isIndexed ? 1 : 0; @@ -536,7 +531,7 @@ namespace Ryujinx.Graphics.Shader.Translation TextureOperation texOp = (TextureOperation)node.Value; - bool hasOffset = (texOp.Flags & TextureFlags.Offset) != 0; + bool hasOffset = (texOp.Flags & TextureFlags.Offset) != 0; bool hasOffsets = (texOp.Flags & TextureFlags.Offsets) != 0; bool hasInvalidOffset = (hasOffset || hasOffsets) && !config.GpuAccessor.QueryHostSupportsNonConstantTextureOffset(); @@ -548,16 +543,16 @@ namespace Ryujinx.Graphics.Shader.Translation return node; } - bool isGather = (texOp.Flags & TextureFlags.Gather) != 0; + bool isGather = (texOp.Flags & TextureFlags.Gather) != 0; bool hasDerivatives = (texOp.Flags & TextureFlags.Derivatives) != 0; - bool intCoords = (texOp.Flags & TextureFlags.IntCoords) != 0; - bool hasLodBias = (texOp.Flags & TextureFlags.LodBias) != 0; - bool hasLodLevel = (texOp.Flags & TextureFlags.LodLevel) != 0; + bool intCoords = (texOp.Flags & TextureFlags.IntCoords) != 0; + bool hasLodBias = (texOp.Flags & TextureFlags.LodBias) != 0; + bool hasLodLevel = (texOp.Flags & TextureFlags.LodLevel) != 0; - bool isArray = (texOp.Type & SamplerType.Array) != 0; - bool isIndexed = (texOp.Type & SamplerType.Indexed) != 0; + bool isArray = (texOp.Type & SamplerType.Array) != 0; + bool isIndexed = (texOp.Type & SamplerType.Indexed) != 0; bool isMultisample = (texOp.Type & SamplerType.Multisample) != 0; - bool isShadow = (texOp.Type & SamplerType.Shadow) != 0; + bool isShadow = (texOp.Type & SamplerType.Shadow) != 0; int coordsCount = texOp.Type.GetDimensions(); @@ -647,12 +642,12 @@ namespace Ryujinx.Graphics.Shader.Translation if (hasLodBias) { - sources[dstIndex++] = texOp.GetSource(srcIndex++); + sources[dstIndex++] = texOp.GetSource(srcIndex++); } if (isGather && !isShadow) { - sources[dstIndex++] = texOp.GetSource(srcIndex++); + sources[dstIndex++] = texOp.GetSource(srcIndex++); } int coordsIndex = isBindless || isIndexed ? 1 : 0; @@ -712,7 +707,7 @@ namespace Ryujinx.Graphics.Shader.Translation newSources[coordsIndex + index] = coordPlusOffset; } - TextureOperation newTexOp = new TextureOperation( + TextureOperation newTexOp = new( Instruction.TextureSample, texOp.Type, texOp.Format, @@ -771,7 +766,7 @@ namespace Ryujinx.Graphics.Shader.Translation } } - TextureOperation newTexOp = new TextureOperation( + TextureOperation newTexOp = new( Instruction.TextureSample, texOp.Type, texOp.Format, @@ -862,13 +857,13 @@ namespace Ryujinx.Graphics.Shader.Translation int maxPositive = format switch { - TextureFormat.R8Snorm => sbyte.MaxValue, - TextureFormat.R8G8Snorm => sbyte.MaxValue, - TextureFormat.R8G8B8A8Snorm => sbyte.MaxValue, - TextureFormat.R16Snorm => short.MaxValue, - TextureFormat.R16G16Snorm => short.MaxValue, + TextureFormat.R8Snorm => sbyte.MaxValue, + TextureFormat.R8G8Snorm => sbyte.MaxValue, + TextureFormat.R8G8B8A8Snorm => sbyte.MaxValue, + TextureFormat.R16Snorm => short.MaxValue, + TextureFormat.R16G16Snorm => short.MaxValue, TextureFormat.R16G16B16A16Snorm => short.MaxValue, - _ => 0 + _ => 0, }; // The value being 0 means that the format is not a SNORM format, @@ -886,8 +881,8 @@ namespace Ryujinx.Graphics.Shader.Translation INode[] uses = dest.UseOps.ToArray(); - Operation convOp = new Operation(Instruction.ConvertS32ToFP32, Local(), dest); - Operation normOp = new Operation(Instruction.FP32 | Instruction.Multiply, Local(), convOp.Dest, ConstF(1f / maxPositive)); + Operation convOp = new(Instruction.ConvertS32ToFP32, Local(), dest); + Operation normOp = new(Instruction.FP32 | Instruction.Multiply, Local(), convOp.Dest, ConstF(1f / maxPositive)); node = node.List.AddAfter(node, convOp); node = node.List.AddAfter(node, normOp); @@ -990,4 +985,4 @@ namespace Ryujinx.Graphics.Shader.Translation return false; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Translation/ShaderConfig.cs b/src/Ryujinx.Graphics.Shader/Translation/ShaderConfig.cs index e50c9a845..e93a709c2 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/ShaderConfig.cs +++ b/src/Ryujinx.Graphics.Shader/Translation/ShaderConfig.cs @@ -126,9 +126,9 @@ namespace Ryujinx.Graphics.Shader.Translation public ShaderConfig(ShaderStage stage, IGpuAccessor gpuAccessor, TranslationOptions options, int localMemorySize) { - Stage = stage; - GpuAccessor = gpuAccessor; - Options = options; + Stage = stage; + GpuAccessor = gpuAccessor; + Options = options; LocalMemorySize = localMemorySize; _transformFeedbackDefinitions = new Dictionary(); @@ -138,35 +138,35 @@ namespace Ryujinx.Graphics.Shader.Translation gpuAccessor.QueryTransformFeedbackEnabled() && gpuAccessor.QueryHostSupportsTransformFeedback(); - UsedInputAttributesPerPatch = new HashSet(); + UsedInputAttributesPerPatch = new HashSet(); UsedOutputAttributesPerPatch = new HashSet(); _usedTextures = new Dictionary(); - _usedImages = new Dictionary(); + _usedImages = new Dictionary(); ResourceManager = new ResourceManager(stage, gpuAccessor, new ShaderProperties()); if (!gpuAccessor.QueryHostSupportsTransformFeedback() && gpuAccessor.QueryTransformFeedbackEnabled()) { - StructureType tfeInfoStruct = new StructureType(new StructureField[] + StructureType tfeInfoStruct = new(new StructureField[] { - new StructureField(AggregateType.Array | AggregateType.U32, "base_offset", 4), - new StructureField(AggregateType.U32, "vertex_count") + new(AggregateType.Array | AggregateType.U32, "base_offset", 4), + new(AggregateType.U32, "vertex_count"), }); - BufferDefinition tfeInfoBuffer = new BufferDefinition(BufferLayout.Std430, 1, Constants.TfeInfoBinding, "tfe_info", tfeInfoStruct); + BufferDefinition tfeInfoBuffer = new(BufferLayout.Std430, 1, Constants.TfeInfoBinding, "tfe_info", tfeInfoStruct); Properties.AddStorageBuffer(Constants.TfeInfoBinding, tfeInfoBuffer); - StructureType tfeDataStruct = new StructureType(new StructureField[] + StructureType tfeDataStruct = new(new StructureField[] { - new StructureField(AggregateType.Array | AggregateType.U32, "data", 0) + new(AggregateType.Array | AggregateType.U32, "data", 0), }); for (int i = 0; i < Constants.TfeBuffersCount; i++) { int binding = Constants.TfeBufferBaseBinding + i; - BufferDefinition tfeDataBuffer = new BufferDefinition(BufferLayout.Std430, 1, binding, $"tfe_data{i}", tfeDataStruct); + BufferDefinition tfeDataBuffer = new(BufferLayout.Std430, 1, binding, $"tfe_data{i}", tfeDataStruct); Properties.AddStorageBuffer(binding, tfeDataBuffer); } } @@ -180,8 +180,8 @@ namespace Ryujinx.Graphics.Shader.Translation TranslationOptions options) : this(stage, gpuAccessor, options, 0) { ThreadsPerInputPrimitive = 1; - OutputTopology = outputTopology; - MaxOutputVertices = maxOutputVertices; + OutputTopology = outputTopology; + MaxOutputVertices = maxOutputVertices; } public ShaderConfig( @@ -189,15 +189,15 @@ namespace Ryujinx.Graphics.Shader.Translation IGpuAccessor gpuAccessor, TranslationOptions options) : this(header.Stage, gpuAccessor, options, GetLocalMemorySize(header)) { - GpPassthrough = header.Stage == ShaderStage.Geometry && header.GpPassthrough; + GpPassthrough = header.Stage == ShaderStage.Geometry && header.GpPassthrough; ThreadsPerInputPrimitive = header.ThreadsPerInputPrimitive; - OutputTopology = header.OutputTopology; - MaxOutputVertices = header.MaxOutputVertexCount; - ImapTypes = header.ImapTypes; - OmapTargets = header.OmapTargets; - OmapSampleMask = header.OmapSampleMask; - OmapDepth = header.OmapDepth; - LastInVertexPipeline = header.Stage < ShaderStage.Fragment; + OutputTopology = header.OutputTopology; + MaxOutputVertices = header.MaxOutputVertexCount; + ImapTypes = header.ImapTypes; + OmapTargets = header.OmapTargets; + OmapSampleMask = header.OmapSampleMask; + OmapDepth = header.OmapDepth; + LastInVertexPipeline = header.Stage < ShaderStage.Fragment; } private static int GetLocalMemorySize(ShaderHeader header) @@ -524,7 +524,7 @@ namespace Ryujinx.Graphics.Shader.Translation // Regular and per-patch input/output locations can't overlap, // so we must assign on our location using unused regular input/output locations. - Dictionary locationsMap = new Dictionary(); + Dictionary locationsMap = new(); int freeMask = ~UsedOutputAttributes; @@ -718,7 +718,7 @@ namespace Ryujinx.Graphics.Shader.Translation { AccurateType = accurateType, Type = type, - UsageFlags = usageFlags + UsageFlags = usageFlags, }; if (dict.TryGetValue(info, out var existingMeta)) @@ -797,24 +797,6 @@ namespace Ryujinx.Graphics.Shader.Translation return default; } - private static int FindDescriptorIndex(TextureDescriptor[] array, AstTextureOperation texOp) - { - for (int i = 0; i < array.Length; i++) - { - var descriptor = array[i]; - - if (descriptor.Type == texOp.Type && - descriptor.CbufSlot == texOp.CbufSlot && - descriptor.HandleIndex == texOp.Handle && - descriptor.Format == texOp.Format) - { - return i; - } - } - - return -1; - } - private static int FindDescriptorIndex(TextureDescriptor[] array, TextureOperation texOp, bool ignoreType = false) { for (int i = 0; i < array.Length; i++) diff --git a/src/Ryujinx.Graphics.Shader/Translation/ShaderHeader.cs b/src/Ryujinx.Graphics.Shader/Translation/ShaderHeader.cs index 01f7f08ad..39f01b1ce 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/ShaderHeader.cs +++ b/src/Ryujinx.Graphics.Shader/Translation/ShaderHeader.cs @@ -9,7 +9,7 @@ namespace Ryujinx.Graphics.Shader.Translation Unused = 0, Constant = 1, Perspective = 2, - ScreenLinear = 3 + ScreenLinear = 3, } readonly struct ImapPixelType @@ -29,9 +29,19 @@ namespace Ryujinx.Graphics.Shader.Translation public PixelImap GetFirstUsedType() { - if (X != PixelImap.Unused) return X; - if (Y != PixelImap.Unused) return Y; - if (Z != PixelImap.Unused) return Z; + if (X != PixelImap.Unused) + { + return X; + } + if (Y != PixelImap.Unused) + { + return Y; + } + if (Z != PixelImap.Unused) + { + return Z; + } + return W; } } @@ -155,4 +165,4 @@ namespace Ryujinx.Graphics.Shader.Translation OmapDepth = type2Omap.Extract(1); } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Translation/ShaderIdentifier.cs b/src/Ryujinx.Graphics.Shader/Translation/ShaderIdentifier.cs index 684004379..e9c259942 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/ShaderIdentifier.cs +++ b/src/Ryujinx.Graphics.Shader/Translation/ShaderIdentifier.cs @@ -43,7 +43,7 @@ namespace Ryujinx.Graphics.Shader.Translation foreach (INode node in block.Operations) { - if (!(node is Operation operation)) + if (node is not Operation operation) { continue; } @@ -84,7 +84,7 @@ namespace Ryujinx.Graphics.Shader.Translation } writesLayer = true; - layerInputAttr = srcAttributeAsgOp.GetSource(1).Value * 4 + srcAttributeAsgOp.GetSource(3).Value;; + layerInputAttr = srcAttributeAsgOp.GetSource(1).Value * 4 + srcAttributeAsgOp.GetSource(3).Value; } else { diff --git a/src/Ryujinx.Graphics.Shader/Translation/Ssa.cs b/src/Ryujinx.Graphics.Shader/Translation/Ssa.cs index 16b8b9240..89aaa3b44 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/Ssa.cs +++ b/src/Ryujinx.Graphics.Shader/Translation/Ssa.cs @@ -1,7 +1,6 @@ using Ryujinx.Graphics.Shader.Decoders; using Ryujinx.Graphics.Shader.IntermediateRepresentation; using System.Collections.Generic; - using static Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandHelper; namespace Ryujinx.Graphics.Shader.Translation @@ -12,9 +11,9 @@ namespace Ryujinx.Graphics.Shader.Translation private class DefMap { - private Dictionary _map; + private readonly Dictionary _map; - private long[] _phiMasks; + private readonly long[] _phiMasks; public DefMap() { @@ -38,7 +37,7 @@ namespace Ryujinx.Graphics.Shader.Translation int key = GetKeyFromRegister(reg); int index = key / 64; - int bit = key & 63; + int bit = key & 63; long mask = 1L << bit; @@ -57,7 +56,7 @@ namespace Ryujinx.Graphics.Shader.Translation int key = GetKeyFromRegister(reg); int index = key / 64; - int bit = key & 63; + int bit = key & 63; return (_phiMasks[index] & (1L << bit)) != 0; } @@ -65,8 +64,8 @@ namespace Ryujinx.Graphics.Shader.Translation private class LocalDefMap { - private Operand[] _map; - private int[] _uses; + private readonly Operand[] _map; + private readonly int[] _uses; public int UseCount { get; private set; } public LocalDefMap() @@ -111,7 +110,7 @@ namespace Ryujinx.Graphics.Shader.Translation private readonly struct Definition { public BasicBlock Block { get; } - public Operand Local { get; } + public Operand Local { get; } public Definition(BasicBlock block, Operand local) { @@ -123,14 +122,14 @@ namespace Ryujinx.Graphics.Shader.Translation public static void Rename(BasicBlock[] blocks) { DefMap[] globalDefs = new DefMap[blocks.Length]; - LocalDefMap localDefs = new LocalDefMap(); + LocalDefMap localDefs = new(); for (int blkIndex = 0; blkIndex < blocks.Length; blkIndex++) { globalDefs[blkIndex] = new DefMap(); } - Queue dfPhiBlocks = new Queue(); + Queue dfPhiBlocks = new(); // First pass, get all defs and locals uses. for (int blkIndex = 0; blkIndex < blocks.Length; blkIndex++) @@ -303,7 +302,7 @@ namespace Ryujinx.Graphics.Shader.Translation // then use the definition from that Phi. Operand local = Local(); - PhiNode phi = new PhiNode(local); + PhiNode phi = new(local); AddPhi(block, phi); @@ -373,4 +372,4 @@ namespace Ryujinx.Graphics.Shader.Translation } } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Translation/TargetApi.cs b/src/Ryujinx.Graphics.Shader/Translation/TargetApi.cs index 6ac235a40..519600937 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/TargetApi.cs +++ b/src/Ryujinx.Graphics.Shader/Translation/TargetApi.cs @@ -3,6 +3,6 @@ namespace Ryujinx.Graphics.Shader.Translation public enum TargetApi { OpenGL, - Vulkan + Vulkan, } } diff --git a/src/Ryujinx.Graphics.Shader/Translation/TargetLanguage.cs b/src/Ryujinx.Graphics.Shader/Translation/TargetLanguage.cs index 8314b223c..863c7447b 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/TargetLanguage.cs +++ b/src/Ryujinx.Graphics.Shader/Translation/TargetLanguage.cs @@ -4,6 +4,6 @@ namespace Ryujinx.Graphics.Shader.Translation { Glsl, Spirv, - Arb + Arb, } } diff --git a/src/Ryujinx.Graphics.Shader/Translation/TranslationFlags.cs b/src/Ryujinx.Graphics.Shader/Translation/TranslationFlags.cs index 1874dec3b..df1e76a1f 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/TranslationFlags.cs +++ b/src/Ryujinx.Graphics.Shader/Translation/TranslationFlags.cs @@ -7,8 +7,8 @@ namespace Ryujinx.Graphics.Shader.Translation { None = 0, - VertexA = 1 << 0, - Compute = 1 << 1, - DebugMode = 1 << 2 + VertexA = 1 << 0, + Compute = 1 << 1, + DebugMode = 1 << 2, } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Translation/Translator.cs b/src/Ryujinx.Graphics.Shader/Translation/Translator.cs index 255030a4b..010c80db1 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/Translator.cs +++ b/src/Ryujinx.Graphics.Shader/Translation/Translator.cs @@ -45,14 +45,14 @@ namespace Ryujinx.Graphics.Shader.Translation } } - List funcs = new List(functions.Length); + List funcs = new(functions.Length); for (int i = 0; i < functions.Length; i++) { funcs.Add(null); } - HelperFunctionManager hfm = new HelperFunctionManager(funcs, config.Stage); + HelperFunctionManager hfm = new(funcs, config.Stage); for (int i = 0; i < functions.Length; i++) { @@ -65,7 +65,7 @@ namespace Ryujinx.Graphics.Shader.Translation { var fru = frus[i]; - inArgumentsCount = fru.InArguments.Length; + inArgumentsCount = fru.InArguments.Length; outArgumentsCount = fru.OutArguments.Length; } @@ -95,7 +95,7 @@ namespace Ryujinx.Graphics.Shader.Translation { TargetLanguage.Glsl => new ShaderProgram(info, TargetLanguage.Glsl, GlslGenerator.Generate(sInfo, config)), TargetLanguage.Spirv => new ShaderProgram(info, TargetLanguage.Spirv, SpirvGenerator.Generate(sInfo, config)), - _ => throw new NotImplementedException(config.Options.TargetLanguage.ToString()) + _ => throw new NotImplementedException(config.Options.TargetLanguage.ToString()), }; } @@ -149,7 +149,7 @@ namespace Ryujinx.Graphics.Shader.Translation for (int index = 0; index < functions.Length; index++) { - EmitterContext context = new EmitterContext(program, config, index != 0); + EmitterContext context = new(program, config, index != 0); if (initializeOutputs && index == 0) { @@ -306,7 +306,7 @@ namespace Ryujinx.Graphics.Shader.Translation context.Add(new CommentNode(dbgComment)); } - InstConditional opConditional = new InstConditional(op.RawOpCode); + InstConditional opConditional = new(op.RawOpCode); bool noPred = op.Props.HasFlag(InstProps.NoPred); if (!noPred && opConditional.Pred == RegisterConsts.PredicateTrueIndex && opConditional.PredInv) @@ -367,4 +367,4 @@ namespace Ryujinx.Graphics.Shader.Translation } } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Shader/Translation/TranslatorContext.cs b/src/Ryujinx.Graphics.Shader/Translation/TranslatorContext.cs index 13c5e0e40..40a79c544 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/TranslatorContext.cs +++ b/src/Ryujinx.Graphics.Shader/Translation/TranslatorContext.cs @@ -7,7 +7,6 @@ using System; using System.Collections.Generic; using System.Linq; using System.Numerics; - using static Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandHelper; using static Ryujinx.Graphics.Shader.Translation.Translator; @@ -16,7 +15,7 @@ namespace Ryujinx.Graphics.Shader.Translation public class TranslatorContext { private readonly DecodedProgram _program; - private ShaderConfig _config; + private readonly ShaderConfig _config; public ulong Address { get; } @@ -59,7 +58,7 @@ namespace Ryujinx.Graphics.Shader.Translation // temporary variable, as long that attribute is written by shader A. FunctionCode[] output = new FunctionCode[a.Length + b.Length - 1]; - List ops = new List(a.Length + b.Length); + List ops = new(a.Length + b.Length); Operand[] temps = new Operand[AttributeConsts.UserAttributesCount * 4]; @@ -205,9 +204,9 @@ namespace Ryujinx.Graphics.Shader.Translation break; } - ShaderConfig config = new ShaderConfig(ShaderStage.Geometry, outputTopology, maxOutputVertices, GpuAccessor, _config.Options); + ShaderConfig config = new(ShaderStage.Geometry, outputTopology, maxOutputVertices, GpuAccessor, _config.Options); - EmitterContext context = new EmitterContext(default, config, false); + EmitterContext context = new(default, config, false); for (int v = 0; v < maxOutputVertices; v++) { @@ -263,7 +262,7 @@ namespace Ryujinx.Graphics.Shader.Translation { TargetLanguage.Glsl => new ShaderProgram(info, TargetLanguage.Glsl, GlslGenerator.Generate(sInfo, config)), TargetLanguage.Spirv => new ShaderProgram(info, TargetLanguage.Spirv, SpirvGenerator.Generate(sInfo, config)), - _ => throw new NotImplementedException(config.Options.TargetLanguage.ToString()) + _ => throw new NotImplementedException(config.Options.TargetLanguage.ToString()), }; } }