From fa682d406ed60b78e42d4018d9f5cbc7f19ce00f Mon Sep 17 00:00:00 2001 From: KeatonTheBot Date: Sat, 30 Aug 2025 19:46:36 -0500 Subject: [PATCH] misc: chore: Merge into pattern --- .../CodeGen/Arm64/Arm64Optimizer.cs | 2 +- .../CodeGen/Arm64/CodeGenCommon.cs | 2 +- .../CodeGen/Arm64/CodeGenerator.cs | 11 ++-- src/ARMeilleure/CodeGen/Arm64/PreAllocator.cs | 28 +++++----- .../CodeGen/Optimizations/Optimizer.cs | 10 ++-- .../RegisterAllocators/LinearScanAllocator.cs | 5 +- src/ARMeilleure/CodeGen/X86/Assembler.cs | 2 +- src/ARMeilleure/CodeGen/X86/CodeGenerator.cs | 9 ++-- src/ARMeilleure/CodeGen/X86/PreAllocator.cs | 12 ++--- src/ARMeilleure/CodeGen/X86/X86Optimizer.cs | 12 ++--- src/ARMeilleure/Decoders/Decoder.cs | 16 ++---- src/ARMeilleure/Decoders/OpCodeMemImm.cs | 3 +- src/ARMeilleure/Diagnostics/IRDumper.cs | 3 +- .../Instructions/InstEmitMemoryEx.cs | 2 +- .../Instructions/InstEmitMemoryHelper.cs | 5 +- .../Instructions/InstEmitSimdCvt.cs | 10 ++-- .../Instructions/InstEmitSimdCvt32.cs | 2 +- .../Instructions/InstEmitSimdHelper.cs | 12 ++--- .../Instructions/InstEmitSimdHelper32.cs | 6 +-- .../Instructions/InstEmitSimdShift.cs | 8 +-- src/ARMeilleure/Instructions/SoftFloat.cs | 24 ++++----- .../IntermediateRepresentation/Operand.cs | 2 +- .../IntermediateRepresentation/OperandType.cs | 3 +- src/ARMeilleure/Memory/MemoryManagerType.cs | 4 +- src/ARMeilleure/Translation/EmitterContext.cs | 3 +- src/ARMeilleure/Translation/PTC/Ptc.cs | 3 +- .../Translation/PTC/PtcProfiler.cs | 3 +- .../OpenALHardwareDeviceDriver.cs | 2 +- .../CompatLayerHardwareDeviceDriver.cs | 4 +- .../Dummy/DummyHardwareDeviceDriver.cs | 4 +- .../Common/AudioDeviceSession.cs | 2 +- .../Renderer/Dsp/State/DelayState.cs | 2 +- .../Parameter/EffectInParameterVersion1.cs | 2 +- .../Parameter/EffectInParameterVersion2.cs | 2 +- .../Renderer/Server/AudioRenderSystem.cs | 14 ++--- .../CommandProcessingTimeEstimatorVersion2.cs | 46 ++++++++-------- .../CommandProcessingTimeEstimatorVersion3.cs | 54 +++++++++---------- .../CommandProcessingTimeEstimatorVersion4.cs | 4 +- .../CommandProcessingTimeEstimatorVersion5.cs | 12 ++--- .../SystemInterop/ForceDpiAware.cs | 2 +- src/Ryujinx.Cpu/AppleHv/HvExecutionContext.cs | 2 +- .../LightningJit/Arm32/InstName.cs | 2 +- .../Arm32/Target/Arm64/Compiler.cs | 2 +- .../Arm32/Target/Arm64/InstEmitNeonCommon.cs | 30 +++++------ .../Arm32/Target/Arm64/InstEmitNeonMove.cs | 4 +- .../Arm32/Target/Arm64/InstEmitVfpCompare.cs | 2 +- .../Arm32/Target/Arm64/InstEmitVfpConvert.cs | 2 +- .../LightningJit/Arm64/InstName.cs | 2 +- .../Arm64/Target/Arm64/Compiler.cs | 4 +- .../Arm64/Target/Arm64/Decoder.cs | 4 +- .../Arm64/Target/Arm64/InstEmitSystem.cs | 2 +- .../CodeGen/Arm64/CodeGenCommon.cs | 2 +- .../LightningJit/CodeGen/OperandType.cs | 2 +- src/Ryujinx.Graphics.GAL/Target.cs | 14 ++--- src/Ryujinx.Graphics.GAL/TextureCreateInfo.cs | 4 +- .../Engine/DeviceStateWithShadow.cs | 3 +- .../Engine/SetMmeShadowRamControlMode.cs | 2 +- .../Threed/ComputeDraw/VtgAsComputeState.cs | 2 +- .../Threed/SpecializationStateUpdater.cs | 6 +-- .../Engine/Threed/StateUpdater.cs | 2 +- src/Ryujinx.Graphics.Gpu/Image/Sampler.cs | 2 +- src/Ryujinx.Graphics.Gpu/Image/Texture.cs | 10 ++-- .../Image/TextureBindingsManager.cs | 3 +- .../Image/TextureCache.cs | 11 ++-- .../Image/TextureCompatibility.cs | 31 +++++------ src/Ryujinx.Graphics.Gpu/Image/TextureInfo.cs | 4 +- .../Image/TextureManager.cs | 2 +- src/Ryujinx.Graphics.Gpu/Image/TexturePool.cs | 5 +- src/Ryujinx.Graphics.Gpu/Memory/PteKind.cs | 2 +- .../Shader/GpuChannelGraphicsState.cs | 2 +- .../Shader/ShaderSpecializationState.cs | 2 +- src/Ryujinx.Graphics.Nvdec.Vp9/DecodeMv.cs | 10 ++-- src/Ryujinx.Graphics.Nvdec.Vp9/EntropyMv.cs | 4 +- src/Ryujinx.Graphics.Nvdec.Vp9/Types/Mv.cs | 4 +- .../Types/Vp9Common.cs | 4 +- src/Ryujinx.Graphics.OpenGL/FormatTable.cs | 6 +-- src/Ryujinx.Graphics.OpenGL/HwCapabilities.cs | 8 +-- .../Image/TextureCopy.cs | 2 +- .../Image/TextureView.cs | 2 +- src/Ryujinx.Graphics.OpenGL/VertexArray.cs | 3 +- .../CodeGen/Glsl/Declarations.cs | 6 +-- .../CodeGen/Glsl/Instructions/InstGen.cs | 4 +- .../CodeGen/Glsl/Instructions/IoMap.cs | 6 +-- .../CodeGen/Glsl/OperandManager.cs | 4 +- .../CodeGen/Spirv/IoMap.cs | 6 +-- .../CodeGen/Spirv/SpirvGenerator.cs | 15 +++--- .../Decoders/Decoder.cs | 4 +- .../Instructions/AttributeMap.cs | 6 +-- .../Instructions/InstEmitAttribute.cs | 2 +- .../Instructions/InstEmitConversion.cs | 31 ++++------- .../Instructions/InstEmitFloatComparison.cs | 2 +- .../Instructions/InstEmitMemory.cs | 12 ++--- .../Instructions/InstEmitMove.cs | 4 +- .../Instructions/InstEmitShift.cs | 2 +- .../Instructions/InstEmitSurface.cs | 4 +- .../Instructions/InstEmitTexture.cs | 23 +++----- .../IntermediateRepresentation/Instruction.cs | 6 +-- .../IntermediateRepresentation/StorageKind.cs | 14 +++-- src/Ryujinx.Graphics.Shader/ShaderStage.cs | 10 ++-- .../StructuredIr/InstructionInfo.cs | 10 ++-- .../StructuredIr/ShaderProperties.cs | 2 +- .../StructuredIr/StructuredProgram.cs | 2 +- src/Ryujinx.Graphics.Shader/TextureHandle.cs | 3 +- .../Translation/ControlFlowGraph.cs | 5 +- .../Translation/EmitterContext.cs | 4 +- .../Optimizations/GlobalToStorage.cs | 23 ++++---- .../Translation/Optimizations/Utils.cs | 2 +- .../Encoders/BC7Encoder.cs | 4 +- src/Ryujinx.Graphics.Vic/Types/FrameFormat.cs | 3 +- .../DescriptorSetTemplate.cs | 4 +- .../DescriptorSetUpdater.cs | 20 +++---- .../FormatCapabilities.cs | 6 +-- src/Ryujinx.Graphics.Vulkan/PipelineState.cs | 10 ++-- src/Ryujinx.Graphics.Vulkan/SamplerHolder.cs | 2 +- src/Ryujinx.Graphics.Vulkan/TextureStorage.cs | 4 +- src/Ryujinx.Graphics.Vulkan/TextureView.cs | 4 +- src/Ryujinx.Graphics.Vulkan/VulkanRenderer.cs | 6 +-- src/Ryujinx.HLE/Debugger/Debugger.cs | 4 +- .../FileSystem/EncryptedFileSystemCreator.cs | 2 +- .../SoftwareKeyboardApplet.cs | 6 +-- .../HOS/ArmProcessContextFactory.cs | 7 ++- .../HOS/Diagnostics/Demangler/Demangler.cs | 6 +-- .../HOS/Kernel/Ipc/KServerSession.cs | 2 +- .../HOS/Kernel/Memory/KCodeMemory.cs | 2 +- .../HOS/Kernel/Process/KProcess.cs | 24 ++++----- .../HOS/Kernel/SupervisorCall/Syscall.cs | 6 +-- .../Services/Caps/IAlbumApplicationService.cs | 2 +- .../HOS/Services/Hid/IHidServer.cs | 2 +- .../IUserLocalCommunicationService.cs | 12 ++--- .../LdnRyu/Proxy/LdnProxy.cs | 2 +- .../HOS/Services/Nfc/Nfp/NfpManager/INfp.cs | 2 +- .../NvHostChannel/NvHostChannelDeviceFile.cs | 2 +- .../NvHostCtrl/NvHostCtrlDeviceFile.cs | 18 +++---- src/Ryujinx.HLE/HOS/Services/ServerBase.cs | 8 ++- .../HOS/Services/Settings/ISettingsServer.cs | 2 +- .../HOS/Services/Sockets/Bsd/IClient.cs | 2 +- .../Sockets/Nsd/Manager/FqdnResolver.cs | 8 +-- .../SurfaceFlinger/BufferQueueConsumer.cs | 2 +- .../SurfaceFlinger/BufferQueueCore.cs | 2 +- .../Services/SurfaceFlinger/SurfaceFlinger.cs | 3 +- src/Ryujinx.HLE/HOS/TamperMachine.cs | 2 +- src/Ryujinx.HLE/Loaders/Elf/ElfSymbol.cs | 4 +- .../Hipc/HipcGenerator.cs | 2 +- .../SyscallGenerator.cs | 4 +- src/Ryujinx.Horizon/Prepo/Ipc/PrepoService.cs | 4 +- .../Detail/HardwareOpusDecoderManager.cs | 2 +- .../Sdk/Ngc/Detail/ProfanityFilterBase.cs | 2 +- .../Sdk/Sf/Cmif/ServiceDispatchTableBase.cs | 3 +- src/Ryujinx.SDL2.Common/SDL2Driver.cs | 4 +- .../App/ApplicationLibrary.cs | 2 +- .../Configuration/ConfigurationState.cs | 2 +- .../Helper/SetupValidator.cs | 2 +- src/Ryujinx/Headless/HeadlessRyujinx.Init.cs | 2 +- src/Ryujinx/Input/AvaloniaKeyboardDriver.cs | 2 +- src/Ryujinx/UI/Applet/AvaloniaHostUITheme.cs | 2 +- .../UI/ViewModels/SettingsViewModel.cs | 4 +- src/Spv.Generator/Module.cs | 10 ++-- 157 files changed, 470 insertions(+), 546 deletions(-) diff --git a/src/ARMeilleure/CodeGen/Arm64/Arm64Optimizer.cs b/src/ARMeilleure/CodeGen/Arm64/Arm64Optimizer.cs index 00ffd1958..5fd1e0953 100644 --- a/src/ARMeilleure/CodeGen/Arm64/Arm64Optimizer.cs +++ b/src/ARMeilleure/CodeGen/Arm64/Arm64Optimizer.cs @@ -254,7 +254,7 @@ namespace ARMeilleure.CodeGen.Arm64 private static bool IsMemoryLoadOrStore(Instruction inst) { - return inst == Instruction.Load || inst == Instruction.Store; + return inst is Instruction.Load or Instruction.Store; } private static bool ConstTooLong(Operand constOp, OperandType accessType) diff --git a/src/ARMeilleure/CodeGen/Arm64/CodeGenCommon.cs b/src/ARMeilleure/CodeGen/Arm64/CodeGenCommon.cs index 1f0148d5e..af5f1a8c7 100644 --- a/src/ARMeilleure/CodeGen/Arm64/CodeGenCommon.cs +++ b/src/ARMeilleure/CodeGen/Arm64/CodeGenCommon.cs @@ -52,7 +52,7 @@ namespace ARMeilleure.CodeGen.Arm64 // Any value AND all ones will be equal itself, so it's effectively a no-op. // Any value OR all ones will be equal all ones, so one can just use MOV. // Any value XOR all ones will be equal its inverse, so one can just use MVN. - if (value == 0 || value == ulong.MaxValue) + if (value is 0 or ulong.MaxValue) { immN = 0; immS = 0; diff --git a/src/ARMeilleure/CodeGen/Arm64/CodeGenerator.cs b/src/ARMeilleure/CodeGen/Arm64/CodeGenerator.cs index 74e092104..cbc86b320 100644 --- a/src/ARMeilleure/CodeGen/Arm64/CodeGenerator.cs +++ b/src/ARMeilleure/CodeGen/Arm64/CodeGenerator.cs @@ -189,8 +189,7 @@ namespace ARMeilleure.CodeGen.Arm64 // The only blocks which can have 0 successors are exit blocks. Operation last = block.Operations.Last; - Debug.Assert(last.Instruction == Instruction.Tailcall || - last.Instruction == Instruction.Return); + Debug.Assert(last.Instruction is Instruction.Tailcall or Instruction.Return); } else { @@ -464,7 +463,7 @@ namespace ARMeilleure.CodeGen.Arm64 Operand dest = operation.Destination; Operand source = operation.GetSource(0); - Debug.Assert(dest.Type == OperandType.FP32 || dest.Type == OperandType.FP64); + Debug.Assert(dest.Type is OperandType.FP32 or OperandType.FP64); Debug.Assert(dest.Type != source.Type); Debug.Assert(source.Type != OperandType.V128); @@ -483,7 +482,7 @@ namespace ARMeilleure.CodeGen.Arm64 Operand dest = operation.Destination; Operand source = operation.GetSource(0); - Debug.Assert(dest.Type == OperandType.FP32 || dest.Type == OperandType.FP64); + Debug.Assert(dest.Type is OperandType.FP32 or OperandType.FP64); Debug.Assert(dest.Type != source.Type); Debug.Assert(source.Type.IsInteger()); @@ -1463,7 +1462,7 @@ namespace ARMeilleure.CodeGen.Arm64 private static bool IsLoadOrStore(Operation operation) { - return operation.Instruction == Instruction.Load || operation.Instruction == Instruction.Store; + return operation.Instruction is Instruction.Load or Instruction.Store; } private static OperandType GetMemOpValueType(Operation operation) @@ -1553,7 +1552,7 @@ namespace ARMeilleure.CodeGen.Arm64 private static void EnsureSameReg(Operand op1, Operand op2) { - Debug.Assert(op1.Kind == OperandKind.Register || op1.Kind == OperandKind.Memory); + Debug.Assert(op1.Kind is OperandKind.Register or OperandKind.Memory); Debug.Assert(op1.Kind == op2.Kind); Debug.Assert(op1.Value == op2.Value); } diff --git a/src/ARMeilleure/CodeGen/Arm64/PreAllocator.cs b/src/ARMeilleure/CodeGen/Arm64/PreAllocator.cs index 0b8ed64af..69d4e74c5 100644 --- a/src/ARMeilleure/CodeGen/Arm64/PreAllocator.cs +++ b/src/ARMeilleure/CodeGen/Arm64/PreAllocator.cs @@ -736,19 +736,19 @@ namespace ARMeilleure.CodeGen.Arm64 { IntrinsicInfo info = IntrinsicTable.GetInfo(intrinsic & ~(Intrinsic.Arm64VTypeMask | Intrinsic.Arm64VSizeMask)); - return info.Type == IntrinsicType.ScalarBinaryRd || - info.Type == IntrinsicType.ScalarTernaryFPRdByElem || - info.Type == IntrinsicType.ScalarTernaryShlRd || - info.Type == IntrinsicType.ScalarTernaryShrRd || - info.Type == IntrinsicType.Vector128BinaryRd || - info.Type == IntrinsicType.VectorBinaryRd || - info.Type == IntrinsicType.VectorInsertByElem || - info.Type == IntrinsicType.VectorTernaryRd || - info.Type == IntrinsicType.VectorTernaryRdBitwise || - info.Type == IntrinsicType.VectorTernaryFPRdByElem || - info.Type == IntrinsicType.VectorTernaryRdByElem || - info.Type == IntrinsicType.VectorTernaryShlRd || - info.Type == IntrinsicType.VectorTernaryShrRd; + return info.Type is IntrinsicType.ScalarBinaryRd + or IntrinsicType.ScalarTernaryFPRdByElem + or IntrinsicType.ScalarTernaryShlRd + or IntrinsicType.ScalarTernaryShrRd + or IntrinsicType.Vector128BinaryRd + or IntrinsicType.VectorBinaryRd + or IntrinsicType.VectorInsertByElem + or IntrinsicType.VectorTernaryRd + or IntrinsicType.VectorTernaryRdBitwise + or IntrinsicType.VectorTernaryFPRdByElem + or IntrinsicType.VectorTernaryRdByElem + or IntrinsicType.VectorTernaryShlRd + or IntrinsicType.VectorTernaryShrRd; } private static bool HasConstSrc1(Operation node, ulong value) @@ -849,7 +849,7 @@ namespace ARMeilleure.CodeGen.Arm64 var compType = (Comparison)comp.AsInt32(); - return compType == Comparison.Equal || compType == Comparison.NotEqual; + return compType is Comparison.Equal or Comparison.NotEqual; } } diff --git a/src/ARMeilleure/CodeGen/Optimizations/Optimizer.cs b/src/ARMeilleure/CodeGen/Optimizations/Optimizer.cs index 1afc3a782..cbc6ab784 100644 --- a/src/ARMeilleure/CodeGen/Optimizations/Optimizer.cs +++ b/src/ARMeilleure/CodeGen/Optimizations/Optimizer.cs @@ -227,11 +227,11 @@ namespace ARMeilleure.CodeGen.Optimizations private static bool HasSideEffects(Operation node) { - return node.Instruction == Instruction.Call - || node.Instruction == Instruction.Tailcall - || node.Instruction == Instruction.CompareAndSwap - || node.Instruction == Instruction.CompareAndSwap16 - || node.Instruction == Instruction.CompareAndSwap8; + return node.Instruction is Instruction.Call + or Instruction.Tailcall + or Instruction.CompareAndSwap + or Instruction.CompareAndSwap16 + or Instruction.CompareAndSwap8; } private static bool IsPropagableCompare(Operation operation) diff --git a/src/ARMeilleure/CodeGen/RegisterAllocators/LinearScanAllocator.cs b/src/ARMeilleure/CodeGen/RegisterAllocators/LinearScanAllocator.cs index 8c5b73012..d78f9f621 100644 --- a/src/ARMeilleure/CodeGen/RegisterAllocators/LinearScanAllocator.cs +++ b/src/ARMeilleure/CodeGen/RegisterAllocators/LinearScanAllocator.cs @@ -847,7 +847,7 @@ namespace ARMeilleure.CodeGen.RegisterAllocators // If this is a copy (or copy-like operation), set the copy source interval as well. // This is used for register preferencing later on, which allows the copy to be eliminated // in some cases. - if (node.Instruction == Instruction.Copy || node.Instruction == Instruction.ZeroExtend32) + if (node.Instruction is Instruction.Copy or Instruction.ZeroExtend32) { Operand source = node.GetSource(0); @@ -1120,8 +1120,7 @@ namespace ARMeilleure.CodeGen.RegisterAllocators private static bool IsLocalOrRegister(OperandKind kind) { - return kind == OperandKind.LocalVariable || - kind == OperandKind.Register; + return kind is OperandKind.LocalVariable or OperandKind.Register; } } } diff --git a/src/ARMeilleure/CodeGen/X86/Assembler.cs b/src/ARMeilleure/CodeGen/X86/Assembler.cs index b4d4b9c6e..7062564e3 100644 --- a/src/ARMeilleure/CodeGen/X86/Assembler.cs +++ b/src/ARMeilleure/CodeGen/X86/Assembler.cs @@ -1477,7 +1477,7 @@ namespace ARMeilleure.CodeGen.X86 private static bool Is64Bits(OperandType type) { - return type == OperandType.I64 || type == OperandType.FP64; + return type is OperandType.I64 or OperandType.FP64; } private static bool IsImm8(ulong immediate, OperandType type) diff --git a/src/ARMeilleure/CodeGen/X86/CodeGenerator.cs b/src/ARMeilleure/CodeGen/X86/CodeGenerator.cs index fa86a5d8d..2e69be5b1 100644 --- a/src/ARMeilleure/CodeGen/X86/CodeGenerator.cs +++ b/src/ARMeilleure/CodeGen/X86/CodeGenerator.cs @@ -175,8 +175,7 @@ namespace ARMeilleure.CodeGen.X86 // The only blocks which can have 0 successors are exit blocks. Operation last = block.Operations.Last; - Debug.Assert(last.Instruction == Instruction.Tailcall || - last.Instruction == Instruction.Return); + Debug.Assert(last.Instruction is Instruction.Tailcall or Instruction.Return); } else { @@ -478,7 +477,7 @@ namespace ARMeilleure.CodeGen.X86 Debug.Assert(HardwareCapabilities.SupportsVexEncoding); Debug.Assert(dest.Kind == OperandKind.Register && src1.Kind == OperandKind.Register && src2.Kind == OperandKind.Register); - Debug.Assert(src3.Kind == OperandKind.Register || src3.Kind == OperandKind.Memory); + Debug.Assert(src3.Kind is OperandKind.Register or OperandKind.Memory); EnsureSameType(dest, src1, src2, src3); Debug.Assert(dest.Type == OperandType.V128); @@ -788,7 +787,7 @@ namespace ARMeilleure.CodeGen.X86 Operand dest = operation.Destination; Operand source = operation.GetSource(0); - Debug.Assert(dest.Type == OperandType.FP32 || dest.Type == OperandType.FP64); + Debug.Assert(dest.Type is OperandType.FP32 or OperandType.FP64); if (dest.Type == OperandType.FP32) { @@ -1723,7 +1722,7 @@ namespace ARMeilleure.CodeGen.X86 return; } - Debug.Assert(op1.Kind == OperandKind.Register || op1.Kind == OperandKind.Memory); + Debug.Assert(op1.Kind is OperandKind.Register or OperandKind.Memory); Debug.Assert(op1.Kind == op2.Kind); Debug.Assert(op1.Value == op2.Value); } diff --git a/src/ARMeilleure/CodeGen/X86/PreAllocator.cs b/src/ARMeilleure/CodeGen/X86/PreAllocator.cs index 50267c2b7..a3924d6bf 100644 --- a/src/ARMeilleure/CodeGen/X86/PreAllocator.cs +++ b/src/ARMeilleure/CodeGen/X86/PreAllocator.cs @@ -312,9 +312,9 @@ namespace ARMeilleure.CodeGen.X86 case Instruction.Extended: { - bool isBlend = node.Intrinsic == Intrinsic.X86Blendvpd || - node.Intrinsic == Intrinsic.X86Blendvps || - node.Intrinsic == Intrinsic.X86Pblendvb; + bool isBlend = node.Intrinsic is Intrinsic.X86Blendvpd + or Intrinsic.X86Blendvps + or Intrinsic.X86Pblendvb; // BLENDVPD, BLENDVPS, PBLENDVB last operand is always implied to be XMM0 when VEX is not supported. // SHA256RNDS2 always has an implied XMM0 as a last operand. @@ -513,8 +513,8 @@ namespace ARMeilleure.CodeGen.X86 Operand dest = node.Destination; Operand source = node.GetSource(0); - Debug.Assert(dest.Type == OperandType.FP32 || - dest.Type == OperandType.FP64, $"Invalid destination type \"{dest.Type}\"."); + Debug.Assert(dest.Type is OperandType.FP32 or OperandType.FP64, + $"Invalid destination type \"{dest.Type}\"."); Operation currentNode = node; @@ -761,7 +761,7 @@ namespace ARMeilleure.CodeGen.X86 var compType = (Comparison)comp.AsInt32(); - return compType == Comparison.Equal || compType == Comparison.NotEqual; + return compType is Comparison.Equal or Comparison.NotEqual; } } diff --git a/src/ARMeilleure/CodeGen/X86/X86Optimizer.cs b/src/ARMeilleure/CodeGen/X86/X86Optimizer.cs index 690ca5043..c3dcfcef9 100644 --- a/src/ARMeilleure/CodeGen/X86/X86Optimizer.cs +++ b/src/ARMeilleure/CodeGen/X86/X86Optimizer.cs @@ -248,12 +248,12 @@ namespace ARMeilleure.CodeGen.X86 private static bool IsMemoryLoadOrStore(Instruction inst) { - return inst == Instruction.Load || - inst == Instruction.Load16 || - inst == Instruction.Load8 || - inst == Instruction.Store || - inst == Instruction.Store16 || - inst == Instruction.Store8; + return inst is Instruction.Load + or Instruction.Load16 + or Instruction.Load8 + or Instruction.Store + or Instruction.Store16 + or Instruction.Store8; } } } diff --git a/src/ARMeilleure/Decoders/Decoder.cs b/src/ARMeilleure/Decoders/Decoder.cs index 3946e2f2e..f6d7bba54 100644 --- a/src/ARMeilleure/Decoders/Decoder.cs +++ b/src/ARMeilleure/Decoders/Decoder.cs @@ -254,8 +254,7 @@ namespace ARMeilleure.Decoders } // Compare and branch instructions are always conditional. - if (opCode.Instruction.Name == InstName.Cbz || - opCode.Instruction.Name == InstName.Cbnz) + if (opCode.Instruction.Name is InstName.Cbz or InstName.Cbnz) { return false; } @@ -284,7 +283,7 @@ namespace ARMeilleure.Decoders // register (Rt == 15 or (mask & (1 << 15)) != 0), and cases where there is // a write back to PC (wback == true && Rn == 15), however the later may // be "undefined" depending on the CPU, so compilers should not produce that. - if (opCode is IOpCode32Mem || opCode is IOpCode32MemMult) + if (opCode is IOpCode32Mem or IOpCode32MemMult) { int rt, rn; @@ -326,15 +325,12 @@ namespace ARMeilleure.Decoders } // Explicit branch instructions. - return opCode is IOpCode32BImm || - opCode is IOpCode32BReg; + return opCode is IOpCode32BImm or IOpCode32BReg; } private static bool IsCall(OpCode opCode) { - return opCode.Instruction.Name == InstName.Bl || - opCode.Instruction.Name == InstName.Blr || - opCode.Instruction.Name == InstName.Blx; + return opCode.Instruction.Name is InstName.Bl or InstName.Blr or InstName.Blx; } private static bool IsException(OpCode opCode) @@ -344,9 +340,7 @@ namespace ARMeilleure.Decoders private static bool IsTrap(OpCode opCode) { - return opCode.Instruction.Name == InstName.Brk || - opCode.Instruction.Name == InstName.Trap || - opCode.Instruction.Name == InstName.Und; + return opCode.Instruction.Name is InstName.Brk or InstName.Trap or InstName.Und; } public static OpCode DecodeOpCode(IMemoryManager memory, ulong address, ExecutionMode mode) diff --git a/src/ARMeilleure/Decoders/OpCodeMemImm.cs b/src/ARMeilleure/Decoders/OpCodeMemImm.cs index 4d5eeb1ed..af4d07075 100644 --- a/src/ARMeilleure/Decoders/OpCodeMemImm.cs +++ b/src/ARMeilleure/Decoders/OpCodeMemImm.cs @@ -28,8 +28,7 @@ namespace ARMeilleure.Decoders MemOp type = WBack ? (MemOp)((opCode >> 10) & 3) : MemOp.Unsigned; PostIdx = type == MemOp.PostIndexed; - Unscaled = type == MemOp.Unscaled || - type == MemOp.Unprivileged; + Unscaled = type is MemOp.Unscaled or MemOp.Unprivileged; // Unscaled and Unprivileged doesn't write back, // but they do use the 9-bits Signed Immediate. diff --git a/src/ARMeilleure/Diagnostics/IRDumper.cs b/src/ARMeilleure/Diagnostics/IRDumper.cs index 16833d085..6c58a3ea6 100644 --- a/src/ARMeilleure/Diagnostics/IRDumper.cs +++ b/src/ARMeilleure/Diagnostics/IRDumper.cs @@ -235,8 +235,7 @@ namespace ARMeilleure.Diagnostics { _builder.Append('.').Append(operation.Intrinsic); } - else if (operation.Instruction == Instruction.BranchIf || - operation.Instruction == Instruction.Compare) + else if (operation.Instruction is Instruction.BranchIf or Instruction.Compare) { comparison = true; } diff --git a/src/ARMeilleure/Instructions/InstEmitMemoryEx.cs b/src/ARMeilleure/Instructions/InstEmitMemoryEx.cs index 8c95b33c5..e4283e5a3 100644 --- a/src/ARMeilleure/Instructions/InstEmitMemoryEx.cs +++ b/src/ARMeilleure/Instructions/InstEmitMemoryEx.cs @@ -140,7 +140,7 @@ namespace ARMeilleure.Instructions if (pair) { - Debug.Assert(op.Size == 2 || op.Size == 3, "Invalid size for pairwise store."); + Debug.Assert(op.Size is 2 or 3, "Invalid size for pairwise store."); Operand t2 = GetIntOrZR(context, op.Rt2); diff --git a/src/ARMeilleure/Instructions/InstEmitMemoryHelper.cs b/src/ARMeilleure/Instructions/InstEmitMemoryHelper.cs index ccd532a6c..444ce01c4 100644 --- a/src/ARMeilleure/Instructions/InstEmitMemoryHelper.cs +++ b/src/ARMeilleure/Instructions/InstEmitMemoryHelper.cs @@ -59,7 +59,7 @@ namespace ARMeilleure.Instructions { Operand value = GetInt(context, rt); - if (ext == Extension.Sx32 || ext == Extension.Sx64) + if (ext is Extension.Sx32 or Extension.Sx64) { OperandType destType = ext == Extension.Sx64 ? OperandType.I64 : OperandType.I32; @@ -124,8 +124,7 @@ namespace ARMeilleure.Instructions private static bool IsSimd(ArmEmitterContext context) { return context.CurrOp is IOpCodeSimd && - !(context.CurrOp is OpCodeSimdMemMs || - context.CurrOp is OpCodeSimdMemSs); + !(context.CurrOp is OpCodeSimdMemMs or OpCodeSimdMemSs); } public static Operand EmitReadInt(ArmEmitterContext context, Operand address, int size) diff --git a/src/ARMeilleure/Instructions/InstEmitSimdCvt.cs b/src/ARMeilleure/Instructions/InstEmitSimdCvt.cs index a5d4744f7..cf427eeae 100644 --- a/src/ARMeilleure/Instructions/InstEmitSimdCvt.cs +++ b/src/ARMeilleure/Instructions/InstEmitSimdCvt.cs @@ -1119,7 +1119,7 @@ namespace ARMeilleure.Instructions private static Operand EmitFPConvert(ArmEmitterContext context, Operand value, int size, bool signed) { - Debug.Assert(value.Type == OperandType.I32 || value.Type == OperandType.I64); + Debug.Assert(value.Type is OperandType.I32 or OperandType.I64); Debug.Assert((uint)size < 2); OperandType type = size == 0 ? OperandType.FP32 : OperandType.FP64; @@ -1136,7 +1136,7 @@ namespace ARMeilleure.Instructions private static Operand EmitScalarFcvts(ArmEmitterContext context, Operand value, int fBits) { - Debug.Assert(value.Type == OperandType.FP32 || value.Type == OperandType.FP64); + Debug.Assert(value.Type is OperandType.FP32 or OperandType.FP64); value = EmitF2iFBitsMul(context, value, fBits); @@ -1160,7 +1160,7 @@ namespace ARMeilleure.Instructions private static Operand EmitScalarFcvtu(ArmEmitterContext context, Operand value, int fBits) { - Debug.Assert(value.Type == OperandType.FP32 || value.Type == OperandType.FP64); + Debug.Assert(value.Type is OperandType.FP32 or OperandType.FP64); value = EmitF2iFBitsMul(context, value, fBits); @@ -1184,7 +1184,7 @@ namespace ARMeilleure.Instructions private static Operand EmitF2iFBitsMul(ArmEmitterContext context, Operand value, int fBits) { - Debug.Assert(value.Type == OperandType.FP32 || value.Type == OperandType.FP64); + Debug.Assert(value.Type is OperandType.FP32 or OperandType.FP64); if (fBits == 0) { @@ -1203,7 +1203,7 @@ namespace ARMeilleure.Instructions private static Operand EmitI2fFBitsMul(ArmEmitterContext context, Operand value, int fBits) { - Debug.Assert(value.Type == OperandType.FP32 || value.Type == OperandType.FP64); + Debug.Assert(value.Type is OperandType.FP32 or OperandType.FP64); if (fBits == 0) { diff --git a/src/ARMeilleure/Instructions/InstEmitSimdCvt32.cs b/src/ARMeilleure/Instructions/InstEmitSimdCvt32.cs index b22f32c63..9cfb90e3c 100644 --- a/src/ARMeilleure/Instructions/InstEmitSimdCvt32.cs +++ b/src/ARMeilleure/Instructions/InstEmitSimdCvt32.cs @@ -635,7 +635,7 @@ namespace ARMeilleure.Instructions private static Operand EmitFPConvert(ArmEmitterContext context, Operand value, OperandType type, bool signed) { - Debug.Assert(value.Type == OperandType.I32 || value.Type == OperandType.I64); + Debug.Assert(value.Type is OperandType.I32 or OperandType.I64); if (signed) { diff --git a/src/ARMeilleure/Instructions/InstEmitSimdHelper.cs b/src/ARMeilleure/Instructions/InstEmitSimdHelper.cs index 70931eee6..860204230 100644 --- a/src/ARMeilleure/Instructions/InstEmitSimdHelper.cs +++ b/src/ARMeilleure/Instructions/InstEmitSimdHelper.cs @@ -363,7 +363,7 @@ namespace ARMeilleure.Instructions public static Operand EmitCountSetBits8(ArmEmitterContext context, Operand op) // "size" is 8 (SIMD&FP Inst.). { - Debug.Assert(op.Type == OperandType.I32 || op.Type == OperandType.I64); + Debug.Assert(op.Type is OperandType.I32 or OperandType.I64); Operand op0 = context.Subtract(op, context.BitwiseAnd(context.ShiftRightUI(op, Const(1)), Const(op.Type, 0x55L))); @@ -489,7 +489,7 @@ namespace ARMeilleure.Instructions public static Operand EmitRoundByRMode(ArmEmitterContext context, Operand op) { - Debug.Assert(op.Type == OperandType.FP32 || op.Type == OperandType.FP64); + Debug.Assert(op.Type is OperandType.FP32 or OperandType.FP64); Operand lbl1 = Label(); Operand lbl2 = Label(); @@ -1676,7 +1676,7 @@ namespace ARMeilleure.Instructions int eSize = 8 << size; Debug.Assert(op.Type == OperandType.I64); - Debug.Assert(eSize == 8 || eSize == 16 || eSize == 32 || eSize == 64); + Debug.Assert(eSize is 8 or 16 or 32 or 64); Operand lbl1 = Label(); Operand lblEnd = Label(); @@ -1709,7 +1709,7 @@ namespace ARMeilleure.Instructions int eSize = 8 << size; Debug.Assert(op.Type == OperandType.I64); - Debug.Assert(eSize == 8 || eSize == 16 || eSize == 32 || eSize == 64); + Debug.Assert(eSize is 8 or 16 or 32 or 64); Operand lblEnd = Label(); @@ -1735,7 +1735,7 @@ namespace ARMeilleure.Instructions int eSizeDst = 8 << sizeDst; Debug.Assert(op.Type == OperandType.I64); - Debug.Assert(eSizeDst == 8 || eSizeDst == 16 || eSizeDst == 32); + Debug.Assert(eSizeDst is 8 or 16 or 32); Operand lbl1 = Label(); Operand lblEnd = Label(); @@ -1768,7 +1768,7 @@ namespace ARMeilleure.Instructions int eSizeDst = 8 << sizeDst; Debug.Assert(op.Type == OperandType.I64); - Debug.Assert(eSizeDst == 8 || eSizeDst == 16 || eSizeDst == 32); + Debug.Assert(eSizeDst is 8 or 16 or 32); Operand lblEnd = Label(); diff --git a/src/ARMeilleure/Instructions/InstEmitSimdHelper32.cs b/src/ARMeilleure/Instructions/InstEmitSimdHelper32.cs index 2f021a1a1..76b9ccc29 100644 --- a/src/ARMeilleure/Instructions/InstEmitSimdHelper32.cs +++ b/src/ARMeilleure/Instructions/InstEmitSimdHelper32.cs @@ -31,7 +31,7 @@ namespace ARMeilleure.Instructions { Debug.Assert(type != OperandType.V128); - if (type == OperandType.FP64 || type == OperandType.I64) + if (type is OperandType.FP64 or OperandType.I64) { // From dreg. return context.VectorExtract(type, GetVecA32(reg >> 1), reg & 1); @@ -48,7 +48,7 @@ namespace ARMeilleure.Instructions Debug.Assert(value.Type != OperandType.V128); Operand vec, insert; - if (value.Type == OperandType.FP64 || value.Type == OperandType.I64) + if (value.Type is OperandType.FP64 or OperandType.I64) { // From dreg. vec = GetVecA32(reg >> 1); @@ -71,7 +71,7 @@ namespace ARMeilleure.Instructions public static void InsertScalar16(ArmEmitterContext context, int reg, bool top, Operand value) { - Debug.Assert(value.Type == OperandType.FP32 || value.Type == OperandType.I32); + Debug.Assert(value.Type is OperandType.FP32 or OperandType.I32); Operand vec, insert; vec = GetVecA32(reg >> 2); diff --git a/src/ARMeilleure/Instructions/InstEmitSimdShift.cs b/src/ARMeilleure/Instructions/InstEmitSimdShift.cs index ee7340adb..99bd479ac 100644 --- a/src/ARMeilleure/Instructions/InstEmitSimdShift.cs +++ b/src/ARMeilleure/Instructions/InstEmitSimdShift.cs @@ -1634,7 +1634,7 @@ namespace ARMeilleure.Instructions int eSize = 8 << size; Debug.Assert(op.Type == OperandType.I64); - Debug.Assert(eSize == 8 || eSize == 16 || eSize == 32 || eSize == 64); + Debug.Assert(eSize is 8 or 16 or 32 or 64); Operand res = context.AllocateLocal(OperandType.I64); @@ -1657,7 +1657,7 @@ namespace ARMeilleure.Instructions int eSize = 8 << size; Debug.Assert(op.Type == OperandType.I64); - Debug.Assert(eSize == 8 || eSize == 16 || eSize == 32 || eSize == 64); + Debug.Assert(eSize is 8 or 16 or 32 or 64); Operand lblEnd = Label(); @@ -1732,7 +1732,7 @@ namespace ARMeilleure.Instructions Debug.Assert(op.Type == OperandType.I64); Debug.Assert(shiftLsB.Type == OperandType.I32); - Debug.Assert(eSize == 8 || eSize == 16 || eSize == 32 || eSize == 64); + Debug.Assert(eSize is 8 or 16 or 32 or 64); Operand lbl1 = Label(); Operand lblEnd = Label(); @@ -1769,7 +1769,7 @@ namespace ARMeilleure.Instructions Debug.Assert(op.Type == OperandType.I64); Debug.Assert(shiftLsB.Type == OperandType.I32); - Debug.Assert(eSize == 8 || eSize == 16 || eSize == 32 || eSize == 64); + Debug.Assert(eSize is 8 or 16 or 32 or 64); Operand lbl1 = Label(); Operand lbl2 = Label(); diff --git a/src/ARMeilleure/Instructions/SoftFloat.cs b/src/ARMeilleure/Instructions/SoftFloat.cs index a50160cca..756b6fe17 100644 --- a/src/ARMeilleure/Instructions/SoftFloat.cs +++ b/src/ARMeilleure/Instructions/SoftFloat.cs @@ -322,7 +322,7 @@ namespace ARMeilleure.Instructions float result; - if (type == FPType.SNaN || type == FPType.QNaN) + if (type is FPType.SNaN or FPType.QNaN) { if ((context.Fpcr & FPCR.Dn) != 0) { @@ -498,7 +498,7 @@ namespace ARMeilleure.Instructions double result; - if (type == FPType.SNaN || type == FPType.QNaN) + if (type is FPType.SNaN or FPType.QNaN) { if ((context.Fpcr & FPCR.Dn) != 0) { @@ -676,7 +676,7 @@ namespace ARMeilleure.Instructions ushort resultBits; - if (type == FPType.SNaN || type == FPType.QNaN) + if (type is FPType.SNaN or FPType.QNaN) { if (altHp) { @@ -1522,7 +1522,7 @@ namespace ARMeilleure.Instructions float result; - if (type == FPType.SNaN || type == FPType.QNaN) + if (type is FPType.SNaN or FPType.QNaN) { result = FPProcessNaN(type, op, context, fpcr); } @@ -1689,7 +1689,7 @@ namespace ARMeilleure.Instructions float result; - if (type == FPType.SNaN || type == FPType.QNaN) + if (type is FPType.SNaN or FPType.QNaN) { result = FPProcessNaN(type, op, context, fpcr); } @@ -1726,7 +1726,7 @@ namespace ARMeilleure.Instructions float result; - if (type == FPType.SNaN || type == FPType.QNaN) + if (type is FPType.SNaN or FPType.QNaN) { result = FPProcessNaN(type, op, context, fpcr); } @@ -1920,7 +1920,7 @@ namespace ARMeilleure.Instructions float result; - if (type == FPType.SNaN || type == FPType.QNaN) + if (type is FPType.SNaN or FPType.QNaN) { result = FPProcessNaN(type, op, context, fpcr); } @@ -2211,7 +2211,7 @@ namespace ARMeilleure.Instructions ushort resultBits; - if (type == FPType.SNaN || type == FPType.QNaN) + if (type is FPType.SNaN or FPType.QNaN) { if (altHp) { @@ -3057,7 +3057,7 @@ namespace ARMeilleure.Instructions double result; - if (type == FPType.SNaN || type == FPType.QNaN) + if (type is FPType.SNaN or FPType.QNaN) { result = FPProcessNaN(type, op, context, fpcr); } @@ -3224,7 +3224,7 @@ namespace ARMeilleure.Instructions double result; - if (type == FPType.SNaN || type == FPType.QNaN) + if (type is FPType.SNaN or FPType.QNaN) { result = FPProcessNaN(type, op, context, fpcr); } @@ -3261,7 +3261,7 @@ namespace ARMeilleure.Instructions double result; - if (type == FPType.SNaN || type == FPType.QNaN) + if (type is FPType.SNaN or FPType.QNaN) { result = FPProcessNaN(type, op, context, fpcr); } @@ -3455,7 +3455,7 @@ namespace ARMeilleure.Instructions double result; - if (type == FPType.SNaN || type == FPType.QNaN) + if (type is FPType.SNaN or FPType.QNaN) { result = FPProcessNaN(type, op, context, fpcr); } diff --git a/src/ARMeilleure/IntermediateRepresentation/Operand.cs b/src/ARMeilleure/IntermediateRepresentation/Operand.cs index 89aefacb1..694638913 100644 --- a/src/ARMeilleure/IntermediateRepresentation/Operand.cs +++ b/src/ARMeilleure/IntermediateRepresentation/Operand.cs @@ -446,7 +446,7 @@ namespace ARMeilleure.IntermediateRepresentation Data* data = null; // If constant or register, then try to look up in the intern table before allocating. - if (kind == OperandKind.Constant || kind == OperandKind.Register) + if (kind is OperandKind.Constant or OperandKind.Register) { uint hash = (uint)HashCode.Combine(kind, type, value); diff --git a/src/ARMeilleure/IntermediateRepresentation/OperandType.cs b/src/ARMeilleure/IntermediateRepresentation/OperandType.cs index 67ebdcde4..e68d9ae74 100644 --- a/src/ARMeilleure/IntermediateRepresentation/OperandType.cs +++ b/src/ARMeilleure/IntermediateRepresentation/OperandType.cs @@ -16,8 +16,7 @@ namespace ARMeilleure.IntermediateRepresentation { public static bool IsInteger(this OperandType type) { - return type == OperandType.I32 || - type == OperandType.I64; + return type is OperandType.I32 or OperandType.I64; } public static RegisterType ToRegisterType(this OperandType type) diff --git a/src/ARMeilleure/Memory/MemoryManagerType.cs b/src/ARMeilleure/Memory/MemoryManagerType.cs index bc8ae2635..cad7c3558 100644 --- a/src/ARMeilleure/Memory/MemoryManagerType.cs +++ b/src/ARMeilleure/Memory/MemoryManagerType.cs @@ -47,12 +47,12 @@ namespace ARMeilleure.Memory { public static bool IsHostMapped(this MemoryManagerType type) { - return type == MemoryManagerType.HostMapped || type == MemoryManagerType.HostMappedUnsafe; + return type is MemoryManagerType.HostMapped or MemoryManagerType.HostMappedUnsafe; } public static bool IsHostTracked(this MemoryManagerType type) { - return type == MemoryManagerType.HostTracked || type == MemoryManagerType.HostTrackedUnsafe; + return type is MemoryManagerType.HostTracked or MemoryManagerType.HostTrackedUnsafe; } public static bool IsHostMappedOrTracked(this MemoryManagerType type) diff --git a/src/ARMeilleure/Translation/EmitterContext.cs b/src/ARMeilleure/Translation/EmitterContext.cs index e25052b55..834cac4bd 100644 --- a/src/ARMeilleure/Translation/EmitterContext.cs +++ b/src/ARMeilleure/Translation/EmitterContext.cs @@ -668,8 +668,7 @@ namespace ARMeilleure.Translation Operation last = block.Operations.Last; return last != default && - (last.Instruction == Instruction.Return || - last.Instruction == Instruction.Tailcall); + last.Instruction is Instruction.Return or Instruction.Tailcall; } public ControlFlowGraph GetControlFlowGraph() diff --git a/src/ARMeilleure/Translation/PTC/Ptc.cs b/src/ARMeilleure/Translation/PTC/Ptc.cs index d2f18c71b..75b2252c1 100644 --- a/src/ARMeilleure/Translation/PTC/Ptc.cs +++ b/src/ARMeilleure/Translation/PTC/Ptc.cs @@ -1120,8 +1120,7 @@ namespace ARMeilleure.Translation.PTC public void Close() { - if (State == PtcState.Enabled || - State == PtcState.Continuing) + if (State is PtcState.Enabled or PtcState.Continuing) { State = PtcState.Closing; } diff --git a/src/ARMeilleure/Translation/PTC/PtcProfiler.cs b/src/ARMeilleure/Translation/PTC/PtcProfiler.cs index 0ed0f4e65..695ee749f 100644 --- a/src/ARMeilleure/Translation/PTC/PtcProfiler.cs +++ b/src/ARMeilleure/Translation/PTC/PtcProfiler.cs @@ -447,8 +447,7 @@ namespace ARMeilleure.Translation.PTC public void Start() { - if (_ptc.State == PtcState.Enabled || - _ptc.State == PtcState.Continuing) + if (_ptc.State is PtcState.Enabled or PtcState.Continuing) { Enabled = true; diff --git a/src/Ryujinx.Audio.Backends.OpenAL/OpenALHardwareDeviceDriver.cs b/src/Ryujinx.Audio.Backends.OpenAL/OpenALHardwareDeviceDriver.cs index 01286992f..18965dfaf 100644 --- a/src/Ryujinx.Audio.Backends.OpenAL/OpenALHardwareDeviceDriver.cs +++ b/src/Ryujinx.Audio.Backends.OpenAL/OpenALHardwareDeviceDriver.cs @@ -178,7 +178,7 @@ namespace Ryujinx.Audio.Backends.OpenAL public bool SupportsChannelCount(uint channelCount) { - return channelCount == 1 || channelCount == 2 || channelCount == 6; + return channelCount is 1 or 2 or 6; } public bool SupportsDirection(Direction direction) diff --git a/src/Ryujinx.Audio/Backends/CompatLayer/CompatLayerHardwareDeviceDriver.cs b/src/Ryujinx.Audio/Backends/CompatLayer/CompatLayerHardwareDeviceDriver.cs index a2c2cdcd0..8bc2a6016 100644 --- a/src/Ryujinx.Audio/Backends/CompatLayer/CompatLayerHardwareDeviceDriver.cs +++ b/src/Ryujinx.Audio/Backends/CompatLayer/CompatLayerHardwareDeviceDriver.cs @@ -162,7 +162,7 @@ namespace Ryujinx.Audio.Backends.CompatLayer public bool SupportsChannelCount(uint channelCount) { - return channelCount == 1 || channelCount == 2 || channelCount == 6; + return channelCount is 1 or 2 or 6; } public bool SupportsSampleFormat(SampleFormat sampleFormat) @@ -184,7 +184,7 @@ namespace Ryujinx.Audio.Backends.CompatLayer public bool SupportsDirection(Direction direction) { - return direction == Direction.Input || direction == Direction.Output; + return direction is Direction.Input or Direction.Output; } } } diff --git a/src/Ryujinx.Audio/Backends/Dummy/DummyHardwareDeviceDriver.cs b/src/Ryujinx.Audio/Backends/Dummy/DummyHardwareDeviceDriver.cs index 3a3c1d1b1..0e33f210f 100644 --- a/src/Ryujinx.Audio/Backends/Dummy/DummyHardwareDeviceDriver.cs +++ b/src/Ryujinx.Audio/Backends/Dummy/DummyHardwareDeviceDriver.cs @@ -81,12 +81,12 @@ namespace Ryujinx.Audio.Backends.Dummy public bool SupportsDirection(Direction direction) { - return direction == Direction.Output || direction == Direction.Input; + return direction is Direction.Output or Direction.Input; } public bool SupportsChannelCount(uint channelCount) { - return channelCount == 1 || channelCount == 2 || channelCount == 6; + return channelCount is 1 or 2 or 6; } } } diff --git a/src/Ryujinx.Audio/Common/AudioDeviceSession.cs b/src/Ryujinx.Audio/Common/AudioDeviceSession.cs index a0e04c80d..6ba001e80 100644 --- a/src/Ryujinx.Audio/Common/AudioDeviceSession.cs +++ b/src/Ryujinx.Audio/Common/AudioDeviceSession.cs @@ -109,7 +109,7 @@ namespace Ryujinx.Audio.Common /// The state of the session public AudioDeviceState GetState() { - Debug.Assert(_state == AudioDeviceState.Started || _state == AudioDeviceState.Stopped); + Debug.Assert(_state is AudioDeviceState.Started or AudioDeviceState.Stopped); return _state; } diff --git a/src/Ryujinx.Audio/Renderer/Dsp/State/DelayState.cs b/src/Ryujinx.Audio/Renderer/Dsp/State/DelayState.cs index 17ad2a40d..1dfc2d28b 100644 --- a/src/Ryujinx.Audio/Renderer/Dsp/State/DelayState.cs +++ b/src/Ryujinx.Audio/Renderer/Dsp/State/DelayState.cs @@ -40,7 +40,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.State DelayFeedbackBaseGain = (1.0f - channelSpread) * FeedbackGain; - if (parameter.ChannelCount == 4 || parameter.ChannelCount == 6) + if (parameter.ChannelCount is 4 or 6) { DelayFeedbackCrossGain = channelSpread * 0.5f * FeedbackGain; } diff --git a/src/Ryujinx.Audio/Renderer/Parameter/EffectInParameterVersion1.cs b/src/Ryujinx.Audio/Renderer/Parameter/EffectInParameterVersion1.cs index 46686e3b4..73fea4c36 100644 --- a/src/Ryujinx.Audio/Renderer/Parameter/EffectInParameterVersion1.cs +++ b/src/Ryujinx.Audio/Renderer/Parameter/EffectInParameterVersion1.cs @@ -91,7 +91,7 @@ namespace Ryujinx.Audio.Renderer.Parameter /// Returns true if the channel count is valid. public static bool IsChannelCountValid(int channelCount) { - return channelCount == 1 || channelCount == 2 || channelCount == 4 || channelCount == 6; + return channelCount is 1 or 2 or 4 or 6; } } } diff --git a/src/Ryujinx.Audio/Renderer/Parameter/EffectInParameterVersion2.cs b/src/Ryujinx.Audio/Renderer/Parameter/EffectInParameterVersion2.cs index 3854c7148..779bc8fb7 100644 --- a/src/Ryujinx.Audio/Renderer/Parameter/EffectInParameterVersion2.cs +++ b/src/Ryujinx.Audio/Renderer/Parameter/EffectInParameterVersion2.cs @@ -91,7 +91,7 @@ namespace Ryujinx.Audio.Renderer.Parameter /// Returns true if the channel count is valid. public static bool IsChannelCountValid(int channelCount) { - return channelCount == 1 || channelCount == 2 || channelCount == 4 || channelCount == 6; + return channelCount is 1 or 2 or 4 or 6; } } } diff --git a/src/Ryujinx.Audio/Renderer/Server/AudioRenderSystem.cs b/src/Ryujinx.Audio/Renderer/Server/AudioRenderSystem.cs index 33082225a..81a5729f4 100644 --- a/src/Ryujinx.Audio/Renderer/Server/AudioRenderSystem.cs +++ b/src/Ryujinx.Audio/Renderer/Server/AudioRenderSystem.cs @@ -532,13 +532,13 @@ namespace Ryujinx.Audio.Renderer.Server CommandType commandType = command.CommandType; - if (commandType == CommandType.AdpcmDataSourceVersion1 || - commandType == CommandType.AdpcmDataSourceVersion2 || - commandType == CommandType.PcmInt16DataSourceVersion1 || - commandType == CommandType.PcmInt16DataSourceVersion2 || - commandType == CommandType.PcmFloatDataSourceVersion1 || - commandType == CommandType.PcmFloatDataSourceVersion2 || - commandType == CommandType.Performance) + if (commandType is CommandType.AdpcmDataSourceVersion1 + or CommandType.AdpcmDataSourceVersion2 + or CommandType.PcmInt16DataSourceVersion1 + or CommandType.PcmInt16DataSourceVersion2 + or CommandType.PcmFloatDataSourceVersion1 + or CommandType.PcmFloatDataSourceVersion2 + or CommandType.Performance) { break; } diff --git a/src/Ryujinx.Audio/Renderer/Server/CommandProcessingTimeEstimatorVersion2.cs b/src/Ryujinx.Audio/Renderer/Server/CommandProcessingTimeEstimatorVersion2.cs index ef1326924..1e9b6c53e 100644 --- a/src/Ryujinx.Audio/Renderer/Server/CommandProcessingTimeEstimatorVersion2.cs +++ b/src/Ryujinx.Audio/Renderer/Server/CommandProcessingTimeEstimatorVersion2.cs @@ -20,7 +20,7 @@ namespace Ryujinx.Audio.Renderer.Server public uint Estimate(PerformanceCommand command) { - Debug.Assert(_sampleCount == 160 || _sampleCount == 240); + Debug.Assert(_sampleCount is 160 or 240); if (_sampleCount == 160) { @@ -32,7 +32,7 @@ namespace Ryujinx.Audio.Renderer.Server public uint Estimate(ClearMixBufferCommand command) { - Debug.Assert(_sampleCount == 160 || _sampleCount == 240); + Debug.Assert(_sampleCount is 160 or 240); float costPerBuffer = 668.8f; float baseCost = 193.2f; @@ -48,7 +48,7 @@ namespace Ryujinx.Audio.Renderer.Server public uint Estimate(BiquadFilterCommand command) { - Debug.Assert(_sampleCount == 160 || _sampleCount == 240); + Debug.Assert(_sampleCount is 160 or 240); if (_sampleCount == 160) { @@ -62,7 +62,7 @@ namespace Ryujinx.Audio.Renderer.Server { const float CostPerSample = 7.245f; - Debug.Assert(_sampleCount == 160 || _sampleCount == 240); + Debug.Assert(_sampleCount is 160 or 240); int volumeCount = 0; @@ -79,7 +79,7 @@ namespace Ryujinx.Audio.Renderer.Server public uint Estimate(MixRampCommand command) { - Debug.Assert(_sampleCount == 160 || _sampleCount == 240); + Debug.Assert(_sampleCount is 160 or 240); if (_sampleCount == 160) { @@ -91,7 +91,7 @@ namespace Ryujinx.Audio.Renderer.Server public uint Estimate(DepopPrepareCommand command) { - Debug.Assert(_sampleCount == 160 || _sampleCount == 240); + Debug.Assert(_sampleCount is 160 or 240); if (_sampleCount == 160) { @@ -103,7 +103,7 @@ namespace Ryujinx.Audio.Renderer.Server public uint Estimate(VolumeRampCommand command) { - Debug.Assert(_sampleCount == 160 || _sampleCount == 240); + Debug.Assert(_sampleCount is 160 or 240); if (_sampleCount == 160) { @@ -115,7 +115,7 @@ namespace Ryujinx.Audio.Renderer.Server public uint Estimate(PcmInt16DataSourceCommandVersion1 command) { - Debug.Assert(_sampleCount == 160 || _sampleCount == 240); + Debug.Assert(_sampleCount is 160 or 240); float costPerSample = 1195.5f; float baseCost = 7797.0f; @@ -131,7 +131,7 @@ namespace Ryujinx.Audio.Renderer.Server public uint Estimate(AdpcmDataSourceCommandVersion1 command) { - Debug.Assert(_sampleCount == 160 || _sampleCount == 240); + Debug.Assert(_sampleCount is 160 or 240); float costPerSample = 3564.1f; float baseCost = 6225.5f; @@ -147,7 +147,7 @@ namespace Ryujinx.Audio.Renderer.Server public uint Estimate(DepopForMixBuffersCommand command) { - Debug.Assert(_sampleCount == 160 || _sampleCount == 240); + Debug.Assert(_sampleCount is 160 or 240); if (_sampleCount == 160) { @@ -159,7 +159,7 @@ namespace Ryujinx.Audio.Renderer.Server public uint Estimate(CopyMixBufferCommand command) { - Debug.Assert(_sampleCount == 160 || _sampleCount == 240); + Debug.Assert(_sampleCount is 160 or 240); if (_sampleCount == 160) { @@ -171,7 +171,7 @@ namespace Ryujinx.Audio.Renderer.Server public uint Estimate(MixCommand command) { - Debug.Assert(_sampleCount == 160 || _sampleCount == 240); + Debug.Assert(_sampleCount is 160 or 240); if (_sampleCount == 160) { @@ -183,7 +183,7 @@ namespace Ryujinx.Audio.Renderer.Server public uint Estimate(DelayCommand command) { - Debug.Assert(_sampleCount == 160 || _sampleCount == 240); + Debug.Assert(_sampleCount is 160 or 240); if (_sampleCount == 160) { @@ -234,7 +234,7 @@ namespace Ryujinx.Audio.Renderer.Server public uint Estimate(ReverbCommand command) { - Debug.Assert(_sampleCount == 160 || _sampleCount == 240); + Debug.Assert(_sampleCount is 160 or 240); if (_sampleCount == 160) { @@ -285,7 +285,7 @@ namespace Ryujinx.Audio.Renderer.Server public uint Estimate(Reverb3dCommand command) { - Debug.Assert(_sampleCount == 160 || _sampleCount == 240); + Debug.Assert(_sampleCount is 160 or 240); if (_sampleCount == 160) { @@ -335,7 +335,7 @@ namespace Ryujinx.Audio.Renderer.Server public uint Estimate(AuxiliaryBufferCommand command) { - Debug.Assert(_sampleCount == 160 || _sampleCount == 240); + Debug.Assert(_sampleCount is 160 or 240); if (_sampleCount == 160) { @@ -357,7 +357,7 @@ namespace Ryujinx.Audio.Renderer.Server public uint Estimate(VolumeCommand command) { - Debug.Assert(_sampleCount == 160 || _sampleCount == 240); + Debug.Assert(_sampleCount is 160 or 240); if (_sampleCount == 160) { @@ -369,7 +369,7 @@ namespace Ryujinx.Audio.Renderer.Server public uint Estimate(CircularBufferSinkCommand command) { - Debug.Assert(_sampleCount == 160 || _sampleCount == 240); + Debug.Assert(_sampleCount is 160 or 240); float costPerBuffer = 1726.0f; float baseCost = 1369.7f; @@ -385,7 +385,7 @@ namespace Ryujinx.Audio.Renderer.Server public uint Estimate(DownMixSurroundToStereoCommand command) { - Debug.Assert(_sampleCount == 160 || _sampleCount == 240); + Debug.Assert(_sampleCount is 160 or 240); if (_sampleCount == 160) { @@ -397,7 +397,7 @@ namespace Ryujinx.Audio.Renderer.Server public uint Estimate(UpsampleCommand command) { - Debug.Assert(_sampleCount == 160 || _sampleCount == 240); + Debug.Assert(_sampleCount is 160 or 240); if (_sampleCount == 160) { @@ -409,8 +409,8 @@ namespace Ryujinx.Audio.Renderer.Server public uint Estimate(DeviceSinkCommand command) { - Debug.Assert(_sampleCount == 160 || _sampleCount == 240); - Debug.Assert(command.InputCount == 2 || command.InputCount == 6); + Debug.Assert(_sampleCount is 160 or 240); + Debug.Assert(command.InputCount is 2 or 6); if (command.InputCount == 2) { @@ -433,7 +433,7 @@ namespace Ryujinx.Audio.Renderer.Server public uint Estimate(PcmFloatDataSourceCommandVersion1 command) { // NOTE: This was added between REV7 and REV8 and for some reasons the estimator v2 was changed... - Debug.Assert(_sampleCount == 160 || _sampleCount == 240); + Debug.Assert(_sampleCount is 160 or 240); float costPerSample = 3490.9f; float baseCost = 10091.0f; diff --git a/src/Ryujinx.Audio/Renderer/Server/CommandProcessingTimeEstimatorVersion3.cs b/src/Ryujinx.Audio/Renderer/Server/CommandProcessingTimeEstimatorVersion3.cs index 0e0433b46..0dbdcb9c9 100644 --- a/src/Ryujinx.Audio/Renderer/Server/CommandProcessingTimeEstimatorVersion3.cs +++ b/src/Ryujinx.Audio/Renderer/Server/CommandProcessingTimeEstimatorVersion3.cs @@ -23,7 +23,7 @@ namespace Ryujinx.Audio.Renderer.Server public uint Estimate(PerformanceCommand command) { - Debug.Assert(SampleCount == 160 || SampleCount == 240); + Debug.Assert(SampleCount is 160 or 240); if (SampleCount == 160) { @@ -35,7 +35,7 @@ namespace Ryujinx.Audio.Renderer.Server public uint Estimate(ClearMixBufferCommand command) { - Debug.Assert(SampleCount == 160 || SampleCount == 240); + Debug.Assert(SampleCount is 160 or 240); float costPerBuffer = 440.68f; float baseCost = 0; @@ -50,7 +50,7 @@ namespace Ryujinx.Audio.Renderer.Server public uint Estimate(BiquadFilterCommand command) { - Debug.Assert(SampleCount == 160 || SampleCount == 240); + Debug.Assert(SampleCount is 160 or 240); if (SampleCount == 160) { @@ -64,7 +64,7 @@ namespace Ryujinx.Audio.Renderer.Server { float costPerSample = 6.4434f; - Debug.Assert(SampleCount == 160 || SampleCount == 240); + Debug.Assert(SampleCount is 160 or 240); if (SampleCount == 160) { @@ -86,7 +86,7 @@ namespace Ryujinx.Audio.Renderer.Server public uint Estimate(MixRampCommand command) { - Debug.Assert(SampleCount == 160 || SampleCount == 240); + Debug.Assert(SampleCount is 160 or 240); if (SampleCount == 160) { @@ -103,7 +103,7 @@ namespace Ryujinx.Audio.Renderer.Server public uint Estimate(VolumeRampCommand command) { - Debug.Assert(SampleCount == 160 || SampleCount == 240); + Debug.Assert(SampleCount is 160 or 240); if (SampleCount == 160) { @@ -115,7 +115,7 @@ namespace Ryujinx.Audio.Renderer.Server public uint Estimate(PcmInt16DataSourceCommandVersion1 command) { - Debug.Assert(SampleCount == 160 || SampleCount == 240); + Debug.Assert(SampleCount is 160 or 240); float costPerSample = 710.143f; float baseCost = 7853.286f; @@ -131,7 +131,7 @@ namespace Ryujinx.Audio.Renderer.Server public uint Estimate(AdpcmDataSourceCommandVersion1 command) { - Debug.Assert(SampleCount == 160 || SampleCount == 240); + Debug.Assert(SampleCount is 160 or 240); float costPerSample = 3564.1f; float baseCost = 9736.702f; @@ -147,7 +147,7 @@ namespace Ryujinx.Audio.Renderer.Server public uint Estimate(DepopForMixBuffersCommand command) { - Debug.Assert(SampleCount == 160 || SampleCount == 240); + Debug.Assert(SampleCount is 160 or 240); if (SampleCount == 160) { @@ -159,7 +159,7 @@ namespace Ryujinx.Audio.Renderer.Server public uint Estimate(CopyMixBufferCommand command) { - Debug.Assert(SampleCount == 160 || SampleCount == 240); + Debug.Assert(SampleCount is 160 or 240); if (SampleCount == 160) { @@ -171,7 +171,7 @@ namespace Ryujinx.Audio.Renderer.Server public uint Estimate(MixCommand command) { - Debug.Assert(SampleCount == 160 || SampleCount == 240); + Debug.Assert(SampleCount is 160 or 240); if (SampleCount == 160) { @@ -183,7 +183,7 @@ namespace Ryujinx.Audio.Renderer.Server public virtual uint Estimate(DelayCommand command) { - Debug.Assert(SampleCount == 160 || SampleCount == 240); + Debug.Assert(SampleCount is 160 or 240); if (SampleCount == 160) { @@ -233,7 +233,7 @@ namespace Ryujinx.Audio.Renderer.Server public virtual uint Estimate(ReverbCommand command) { - Debug.Assert(SampleCount == 160 || SampleCount == 240); + Debug.Assert(SampleCount is 160 or 240); if (SampleCount == 160) { @@ -283,7 +283,7 @@ namespace Ryujinx.Audio.Renderer.Server public virtual uint Estimate(Reverb3dCommand command) { - Debug.Assert(SampleCount == 160 || SampleCount == 240); + Debug.Assert(SampleCount is 160 or 240); if (SampleCount == 160) { @@ -333,7 +333,7 @@ namespace Ryujinx.Audio.Renderer.Server public uint Estimate(AuxiliaryBufferCommand command) { - Debug.Assert(SampleCount == 160 || SampleCount == 240); + Debug.Assert(SampleCount is 160 or 240); if (SampleCount == 160) { @@ -355,7 +355,7 @@ namespace Ryujinx.Audio.Renderer.Server public uint Estimate(VolumeCommand command) { - Debug.Assert(SampleCount == 160 || SampleCount == 240); + Debug.Assert(SampleCount is 160 or 240); if (SampleCount == 160) { @@ -367,7 +367,7 @@ namespace Ryujinx.Audio.Renderer.Server public uint Estimate(CircularBufferSinkCommand command) { - Debug.Assert(SampleCount == 160 || SampleCount == 240); + Debug.Assert(SampleCount is 160 or 240); float costPerBuffer = 770.26f; float baseCost = 0f; @@ -382,7 +382,7 @@ namespace Ryujinx.Audio.Renderer.Server public uint Estimate(DownMixSurroundToStereoCommand command) { - Debug.Assert(SampleCount == 160 || SampleCount == 240); + Debug.Assert(SampleCount is 160 or 240); if (SampleCount == 160) { @@ -394,7 +394,7 @@ namespace Ryujinx.Audio.Renderer.Server public uint Estimate(UpsampleCommand command) { - Debug.Assert(SampleCount == 160 || SampleCount == 240); + Debug.Assert(SampleCount is 160 or 240); if (SampleCount == 160) { @@ -406,8 +406,8 @@ namespace Ryujinx.Audio.Renderer.Server public uint Estimate(DeviceSinkCommand command) { - Debug.Assert(SampleCount == 160 || SampleCount == 240); - Debug.Assert(command.InputCount == 2 || command.InputCount == 6); + Debug.Assert(SampleCount is 160 or 240); + Debug.Assert(command.InputCount is 2 or 6); if (command.InputCount == 2) { @@ -429,7 +429,7 @@ namespace Ryujinx.Audio.Renderer.Server public uint Estimate(PcmFloatDataSourceCommandVersion1 command) { - Debug.Assert(SampleCount == 160 || SampleCount == 240); + Debug.Assert(SampleCount is 160 or 240); float costPerSample = 3490.9f; float baseCost = 10090.9f; @@ -445,7 +445,7 @@ namespace Ryujinx.Audio.Renderer.Server public uint Estimate(DataSourceVersion2Command command) { - Debug.Assert(SampleCount == 160 || SampleCount == 240); + Debug.Assert(SampleCount is 160 or 240); (float baseCost, float costPerSample) = GetCostByFormat(SampleCount, command.SampleFormat, command.SrcQuality); @@ -454,7 +454,7 @@ namespace Ryujinx.Audio.Renderer.Server private static (float, float) GetCostByFormat(uint sampleCount, SampleFormat format, SampleRateConversionQuality quality) { - Debug.Assert(sampleCount == 160 || sampleCount == 240); + Debug.Assert(sampleCount is 160 or 240); switch (format) { @@ -540,7 +540,7 @@ namespace Ryujinx.Audio.Renderer.Server private uint EstimateLimiterCommandCommon(LimiterParameter parameter, bool enabled) { - Debug.Assert(SampleCount == 160 || SampleCount == 240); + Debug.Assert(SampleCount is 160 or 240); if (SampleCount == 160) { @@ -590,14 +590,14 @@ namespace Ryujinx.Audio.Renderer.Server public uint Estimate(LimiterCommandVersion1 command) { - Debug.Assert(SampleCount == 160 || SampleCount == 240); + Debug.Assert(SampleCount is 160 or 240); return EstimateLimiterCommandCommon(command.Parameter, command.IsEffectEnabled); } public uint Estimate(LimiterCommandVersion2 command) { - Debug.Assert(SampleCount == 160 || SampleCount == 240); + Debug.Assert(SampleCount is 160 or 240); if (!command.Parameter.StatisticsEnabled || !command.IsEffectEnabled) { diff --git a/src/Ryujinx.Audio/Renderer/Server/CommandProcessingTimeEstimatorVersion4.cs b/src/Ryujinx.Audio/Renderer/Server/CommandProcessingTimeEstimatorVersion4.cs index fb357120d..3cb04e385 100644 --- a/src/Ryujinx.Audio/Renderer/Server/CommandProcessingTimeEstimatorVersion4.cs +++ b/src/Ryujinx.Audio/Renderer/Server/CommandProcessingTimeEstimatorVersion4.cs @@ -12,7 +12,7 @@ namespace Ryujinx.Audio.Renderer.Server public override uint Estimate(MultiTapBiquadFilterCommand command) { - Debug.Assert(SampleCount == 160 || SampleCount == 240); + Debug.Assert(SampleCount is 160 or 240); if (SampleCount == 160) { @@ -24,7 +24,7 @@ namespace Ryujinx.Audio.Renderer.Server public override uint Estimate(CaptureBufferCommand command) { - Debug.Assert(SampleCount == 160 || SampleCount == 240); + Debug.Assert(SampleCount is 160 or 240); if (SampleCount == 160) { diff --git a/src/Ryujinx.Audio/Renderer/Server/CommandProcessingTimeEstimatorVersion5.cs b/src/Ryujinx.Audio/Renderer/Server/CommandProcessingTimeEstimatorVersion5.cs index bc9ba073d..fe6103f2b 100644 --- a/src/Ryujinx.Audio/Renderer/Server/CommandProcessingTimeEstimatorVersion5.cs +++ b/src/Ryujinx.Audio/Renderer/Server/CommandProcessingTimeEstimatorVersion5.cs @@ -13,7 +13,7 @@ namespace Ryujinx.Audio.Renderer.Server public override uint Estimate(DelayCommand command) { - Debug.Assert(SampleCount == 160 || SampleCount == 240); + Debug.Assert(SampleCount is 160 or 240); if (SampleCount == 160) { @@ -63,7 +63,7 @@ namespace Ryujinx.Audio.Renderer.Server public override uint Estimate(ReverbCommand command) { - Debug.Assert(SampleCount == 160 || SampleCount == 240); + Debug.Assert(SampleCount is 160 or 240); if (SampleCount == 160) { @@ -113,7 +113,7 @@ namespace Ryujinx.Audio.Renderer.Server public override uint Estimate(Reverb3dCommand command) { - Debug.Assert(SampleCount == 160 || SampleCount == 240); + Debug.Assert(SampleCount is 160 or 240); if (SampleCount == 160) { @@ -163,7 +163,7 @@ namespace Ryujinx.Audio.Renderer.Server public override uint Estimate(CompressorCommand command) { - Debug.Assert(SampleCount == 160 || SampleCount == 240); + Debug.Assert(SampleCount is 160 or 240); if (SampleCount == 160) { @@ -241,7 +241,7 @@ namespace Ryujinx.Audio.Renderer.Server public override uint Estimate(BiquadFilterAndMixCommand command) { - Debug.Assert(SampleCount == 160 || SampleCount == 240); + Debug.Assert(SampleCount is 160 or 240); if (command.HasVolumeRamp) { @@ -265,7 +265,7 @@ namespace Ryujinx.Audio.Renderer.Server public override uint Estimate(MultiTapBiquadFilterAndMixCommand command) { - Debug.Assert(SampleCount == 160 || SampleCount == 240); + Debug.Assert(SampleCount is 160 or 240); if (command.HasVolumeRamp) { diff --git a/src/Ryujinx.Common/SystemInterop/ForceDpiAware.cs b/src/Ryujinx.Common/SystemInterop/ForceDpiAware.cs index b8e1df7d2..0da48dff9 100644 --- a/src/Ryujinx.Common/SystemInterop/ForceDpiAware.cs +++ b/src/Ryujinx.Common/SystemInterop/ForceDpiAware.cs @@ -57,7 +57,7 @@ namespace Ryujinx.Common.SystemInterop { string xdgSessionType = Environment.GetEnvironmentVariable("XDG_SESSION_TYPE")?.ToLower(); - if (xdgSessionType == null || xdgSessionType == "x11") + if (xdgSessionType is null or "x11") { IntPtr display = XOpenDisplay(null); string dpiString = Marshal.PtrToStringAnsi(XGetDefault(display, "Xft", "dpi")); diff --git a/src/Ryujinx.Cpu/AppleHv/HvExecutionContext.cs b/src/Ryujinx.Cpu/AppleHv/HvExecutionContext.cs index 4d5368882..f13662e44 100644 --- a/src/Ryujinx.Cpu/AppleHv/HvExecutionContext.cs +++ b/src/Ryujinx.Cpu/AppleHv/HvExecutionContext.cs @@ -219,7 +219,7 @@ namespace Ryujinx.Cpu.AppleHv address = SynchronousException(memoryManager, ref vcpu); HvApi.hv_vcpu_set_reg(vcpu.Handle, HvReg.PC, address).ThrowOnError(); } - else if (reason == HvExitReason.Canceled || reason == HvExitReason.VTimerActivated) + else if (reason is HvExitReason.Canceled or HvExitReason.VTimerActivated) { if (GetAndClearInterruptRequested()) { diff --git a/src/Ryujinx.Cpu/LightningJit/Arm32/InstName.cs b/src/Ryujinx.Cpu/LightningJit/Arm32/InstName.cs index 2ee67aa0a..809fbf25e 100644 --- a/src/Ryujinx.Cpu/LightningJit/Arm32/InstName.cs +++ b/src/Ryujinx.Cpu/LightningJit/Arm32/InstName.cs @@ -531,7 +531,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm32 { public static bool IsCall(this InstName name) { - return name == InstName.BlI || name == InstName.BlxR; + return name is InstName.BlI or InstName.BlxR; } public static bool IsSystem(this InstName name) diff --git a/src/Ryujinx.Cpu/LightningJit/Arm32/Target/Arm64/Compiler.cs b/src/Ryujinx.Cpu/LightningJit/Arm32/Target/Arm64/Compiler.cs index a668b5777..eb7ce89d9 100644 --- a/src/Ryujinx.Cpu/LightningJit/Arm32/Target/Arm64/Compiler.cs +++ b/src/Ryujinx.Cpu/LightningJit/Arm32/Target/Arm64/Compiler.cs @@ -560,7 +560,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm32.Target.Arm64 } } - Debug.Assert(name == InstName.B || name == InstName.Cbnz, $"Unknown branch instruction \"{name}\"."); + Debug.Assert(name is InstName.B or InstName.Cbnz, $"Unknown branch instruction \"{name}\"."); } private static void RewriteCallInstructionWithTarget(in Context context, uint targetAddress, uint nextAddress, int branchIndex) diff --git a/src/Ryujinx.Cpu/LightningJit/Arm32/Target/Arm64/InstEmitNeonCommon.cs b/src/Ryujinx.Cpu/LightningJit/Arm32/Target/Arm64/InstEmitNeonCommon.cs index dce6556e4..eb5b56364 100644 --- a/src/Ryujinx.Cpu/LightningJit/Arm32/Target/Arm64/InstEmitNeonCommon.cs +++ b/src/Ryujinx.Cpu/LightningJit/Arm32/Target/Arm64/InstEmitNeonCommon.cs @@ -118,7 +118,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm32.Target.Arm64 public static void EmitScalarUnaryF(CodeGenContext context, uint rd, uint rm, uint size, Action action) { - Debug.Assert(size == 1 || size == 2 || size == 3); + Debug.Assert(size is 1 or 2 or 3); bool singleRegs = size != 3; @@ -133,7 +133,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm32.Target.Arm64 public static void EmitScalarUnaryF(CodeGenContext context, uint rd, uint rm, uint size, Action action, Action actionHalf) { - Debug.Assert(size == 1 || size == 2 || size == 3); + Debug.Assert(size is 1 or 2 or 3); bool singleRegs = size != 3; @@ -161,7 +161,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm32.Target.Arm64 uint sf, Action action) { - Debug.Assert(size == 1 || size == 2 || size == 3); + Debug.Assert(size is 1 or 2 or 3); bool singleRegs = size != 3; @@ -182,7 +182,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm32.Target.Arm64 uint sf, Action action) { - Debug.Assert(size == 1 || size == 2 || size == 3); + Debug.Assert(size is 1 or 2 or 3); bool singleRegs = size != 3; @@ -197,7 +197,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm32.Target.Arm64 public static void EmitScalarUnaryFixedF(CodeGenContext context, uint rd, uint rm, uint fbits, uint size, bool is16Bit, Action action) { - Debug.Assert(size == 1 || size == 2 || size == 3); + Debug.Assert(size is 1 or 2 or 3); bool singleRegs = size != 3; @@ -214,7 +214,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm32.Target.Arm64 public static void EmitScalarBinaryF(CodeGenContext context, uint rd, uint rn, uint rm, uint size, Action action) { - Debug.Assert(size == 1 || size == 2 || size == 3); + Debug.Assert(size is 1 or 2 or 3); bool singleRegs = size != 3; @@ -252,7 +252,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm32.Target.Arm64 public static void EmitScalarTernaryRdF(CodeGenContext context, uint rd, uint rn, uint rm, uint size, Action action) { - Debug.Assert(size == 1 || size == 2 || size == 3); + Debug.Assert(size is 1 or 2 or 3); bool singleRegs = size != 3; @@ -276,7 +276,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm32.Target.Arm64 uint size, Action action) { - Debug.Assert(size == 1 || size == 2 || size == 3); + Debug.Assert(size is 1 or 2 or 3); bool singleRegs = size != 3; @@ -300,7 +300,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm32.Target.Arm64 bool negD, bool negProduct) { - Debug.Assert(size == 1 || size == 2 || size == 3); + Debug.Assert(size is 1 or 2 or 3); bool singleRegs = size != 3; @@ -918,7 +918,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm32.Target.Arm64 Action action, Action actionHalf) { - Debug.Assert(sz == 0 || sz == 1); + Debug.Assert(sz is 0 or 1); if (q == 0) { @@ -962,7 +962,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm32.Target.Arm64 Action action, Action actionHalf) { - Debug.Assert(size == 1 || size == 2 || size == 3); + Debug.Assert(size is 1 or 2 or 3); Debug.Assert(size != 3 || q == 1); if (q == 0) @@ -1007,7 +1007,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm32.Target.Arm64 uint q, Action action) { - Debug.Assert(size == 1 || size == 2 || size == 3); + Debug.Assert(size is 1 or 2 or 3); Debug.Assert(size != 3 || q == 1); (uint immb, uint immh) = GetImmbImmh(fbits, size); @@ -1040,7 +1040,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm32.Target.Arm64 Action action, Action actionHalf) { - Debug.Assert(sz == 0 || sz == 1); + Debug.Assert(sz is 0 or 1); if (q == 0) { @@ -1100,7 +1100,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm32.Target.Arm64 Action action, Action actionHalf) { - Debug.Assert(sz == 0 || sz == 1); + Debug.Assert(sz is 0 or 1); if (q == 0) { @@ -1148,7 +1148,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm32.Target.Arm64 uint q, bool negProduct) { - Debug.Assert(sz == 0 || sz == 1); + Debug.Assert(sz is 0 or 1); if (q == 0) { diff --git a/src/Ryujinx.Cpu/LightningJit/Arm32/Target/Arm64/InstEmitNeonMove.cs b/src/Ryujinx.Cpu/LightningJit/Arm32/Target/Arm64/InstEmitNeonMove.cs index 08a0673aa..f22cb5839 100644 --- a/src/Ryujinx.Cpu/LightningJit/Arm32/Target/Arm64/InstEmitNeonMove.cs +++ b/src/Ryujinx.Cpu/LightningJit/Arm32/Target/Arm64/InstEmitNeonMove.cs @@ -252,7 +252,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm32.Target.Arm64 } else { - Debug.Assert(opc1 == 0 || opc1 == 1); + Debug.Assert(opc1 is 0 or 1); Debug.Assert(opc2 == 0); index = opc1 & 1u; @@ -307,7 +307,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm32.Target.Arm64 } else { - Debug.Assert(opc1 == 0 || opc1 == 1); + Debug.Assert(opc1 is 0 or 1); Debug.Assert(opc2 == 0); Debug.Assert(!u); diff --git a/src/Ryujinx.Cpu/LightningJit/Arm32/Target/Arm64/InstEmitVfpCompare.cs b/src/Ryujinx.Cpu/LightningJit/Arm32/Target/Arm64/InstEmitVfpCompare.cs index c1b51750f..66873818e 100644 --- a/src/Ryujinx.Cpu/LightningJit/Arm32/Target/Arm64/InstEmitVfpCompare.cs +++ b/src/Ryujinx.Cpu/LightningJit/Arm32/Target/Arm64/InstEmitVfpCompare.cs @@ -27,7 +27,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm32.Target.Arm64 private static void EmitVcmpVcmpe(CodeGenContext context, uint cond, uint rd, uint rm, uint size, bool zero, bool e) { - Debug.Assert(size == 1 || size == 2 || size == 3); + Debug.Assert(size is 1 or 2 or 3); bool singleRegs = size != 3; uint ftype = size ^ 2u; diff --git a/src/Ryujinx.Cpu/LightningJit/Arm32/Target/Arm64/InstEmitVfpConvert.cs b/src/Ryujinx.Cpu/LightningJit/Arm32/Target/Arm64/InstEmitVfpConvert.cs index 8e4886950..aef833256 100644 --- a/src/Ryujinx.Cpu/LightningJit/Arm32/Target/Arm64/InstEmitVfpConvert.cs +++ b/src/Ryujinx.Cpu/LightningJit/Arm32/Target/Arm64/InstEmitVfpConvert.cs @@ -231,7 +231,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm32.Target.Arm64 { bool unsigned = (op & 1) == 0; - Debug.Assert(size == 1 || size == 2 || size == 3); + Debug.Assert(size is 1 or 2 or 3); bool singleRegs = size != 3; diff --git a/src/Ryujinx.Cpu/LightningJit/Arm64/InstName.cs b/src/Ryujinx.Cpu/LightningJit/Arm64/InstName.cs index 3391a2c14..af3b872a5 100644 --- a/src/Ryujinx.Cpu/LightningJit/Arm64/InstName.cs +++ b/src/Ryujinx.Cpu/LightningJit/Arm64/InstName.cs @@ -1044,7 +1044,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm64 { public static bool IsCall(this InstName name) { - return name == InstName.Bl || name == InstName.Blr; + return name is InstName.Bl or InstName.Blr; } public static bool IsControlFlowOrException(this InstName name) diff --git a/src/Ryujinx.Cpu/LightningJit/Arm64/Target/Arm64/Compiler.cs b/src/Ryujinx.Cpu/LightningJit/Arm64/Target/Arm64/Compiler.cs index 415859ce0..148297e39 100644 --- a/src/Ryujinx.Cpu/LightningJit/Arm64/Target/Arm64/Compiler.cs +++ b/src/Ryujinx.Cpu/LightningJit/Arm64/Target/Arm64/Compiler.cs @@ -575,7 +575,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm64.Target.Arm64 case InstName.Tbz: uint branchMask; - if (name == InstName.Tbnz || name == InstName.Tbz) + if (name is InstName.Tbnz or InstName.Tbz) { originalOffset = ImmUtils.ExtractSImm14Times4(encoding); branchMask = 0x3fff; @@ -653,7 +653,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm64.Target.Arm64 case InstName.Tbz: uint branchMask; - if (name == InstName.Tbnz || name == InstName.Tbz) + if (name is InstName.Tbnz or InstName.Tbz) { originalOffset = ImmUtils.ExtractSImm14Times4(encoding); branchMask = 0x3fff; diff --git a/src/Ryujinx.Cpu/LightningJit/Arm64/Target/Arm64/Decoder.cs b/src/Ryujinx.Cpu/LightningJit/Arm64/Target/Arm64/Decoder.cs index 33d319668..ad221c7aa 100644 --- a/src/Ryujinx.Cpu/LightningJit/Arm64/Target/Arm64/Decoder.cs +++ b/src/Ryujinx.Cpu/LightningJit/Arm64/Target/Arm64/Decoder.cs @@ -72,7 +72,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm64.Target.Arm64 case InstName.Cbz: case InstName.Tbnz: case InstName.Tbz: - if (name == InstName.Tbnz || name == InstName.Tbz) + if (name is InstName.Tbnz or InstName.Tbz) { originalOffset = ImmUtils.ExtractSImm14Times4(encoding); } @@ -369,7 +369,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm64.Target.Arm64 case InstName.Cbz: case InstName.Tbnz: case InstName.Tbz: - int imm = name == InstName.Tbnz || name == InstName.Tbz + int imm = name is InstName.Tbnz or InstName.Tbz ? ImmUtils.ExtractSImm14Times4(encoding) : ImmUtils.ExtractSImm19Times4(encoding); diff --git a/src/Ryujinx.Cpu/LightningJit/Arm64/Target/Arm64/InstEmitSystem.cs b/src/Ryujinx.Cpu/LightningJit/Arm64/Target/Arm64/InstEmitSystem.cs index 577e35e76..57751b4ef 100644 --- a/src/Ryujinx.Cpu/LightningJit/Arm64/Target/Arm64/InstEmitSystem.cs +++ b/src/Ryujinx.Cpu/LightningJit/Arm64/Target/Arm64/InstEmitSystem.cs @@ -230,7 +230,7 @@ namespace Ryujinx.Cpu.LightningJit.Arm64.Target.Arm64 case InstName.Bl: case InstName.Blr: case InstName.Br: - if (name == InstName.BUncond || name == InstName.Bl) + if (name is InstName.BUncond or InstName.Bl) { int imm = ImmUtils.ExtractSImm26Times4(encoding); diff --git a/src/Ryujinx.Cpu/LightningJit/CodeGen/Arm64/CodeGenCommon.cs b/src/Ryujinx.Cpu/LightningJit/CodeGen/Arm64/CodeGenCommon.cs index db6a71593..f1aca983f 100644 --- a/src/Ryujinx.Cpu/LightningJit/CodeGen/Arm64/CodeGenCommon.cs +++ b/src/Ryujinx.Cpu/LightningJit/CodeGen/Arm64/CodeGenCommon.cs @@ -28,7 +28,7 @@ namespace Ryujinx.Cpu.LightningJit.CodeGen.Arm64 // Any value AND all ones will be equal itself, so it's effectively a no-op. // Any value OR all ones will be equal all ones, so one can just use MOV. // Any value XOR all ones will be equal its inverse, so one can just use MVN. - if (value == 0 || value == ulong.MaxValue) + if (value is 0 or ulong.MaxValue) { immN = 0; immS = 0; diff --git a/src/Ryujinx.Cpu/LightningJit/CodeGen/OperandType.cs b/src/Ryujinx.Cpu/LightningJit/CodeGen/OperandType.cs index 6191f791b..cd36c6781 100644 --- a/src/Ryujinx.Cpu/LightningJit/CodeGen/OperandType.cs +++ b/src/Ryujinx.Cpu/LightningJit/CodeGen/OperandType.cs @@ -16,7 +16,7 @@ namespace Ryujinx.Cpu.LightningJit.CodeGen { public static bool IsInteger(this OperandType type) { - return type == OperandType.I32 || type == OperandType.I64; + return type is OperandType.I32 or OperandType.I64; } public static int GetSizeInBytes(this OperandType type) diff --git a/src/Ryujinx.Graphics.GAL/Target.cs b/src/Ryujinx.Graphics.GAL/Target.cs index 73497546e..09a188e45 100644 --- a/src/Ryujinx.Graphics.GAL/Target.cs +++ b/src/Ryujinx.Graphics.GAL/Target.cs @@ -18,17 +18,17 @@ namespace Ryujinx.Graphics.GAL { public static bool IsMultisample(this Target target) { - return target == Target.Texture2DMultisample || target == Target.Texture2DMultisampleArray; + return target is Target.Texture2DMultisample or Target.Texture2DMultisampleArray; } public static bool HasDepthOrLayers(this Target target) { - return target == Target.Texture3D || - target == Target.Texture1DArray || - target == Target.Texture2DArray || - target == Target.Texture2DMultisampleArray || - target == Target.Cubemap || - target == Target.CubemapArray; + return target is Target.Texture3D + or Target.Texture1DArray + or Target.Texture2DArray + or Target.Texture2DMultisampleArray + or Target.Cubemap + or Target.CubemapArray; } } } diff --git a/src/Ryujinx.Graphics.GAL/TextureCreateInfo.cs b/src/Ryujinx.Graphics.GAL/TextureCreateInfo.cs index 79c84db01..5b2a1f011 100644 --- a/src/Ryujinx.Graphics.GAL/TextureCreateInfo.cs +++ b/src/Ryujinx.Graphics.GAL/TextureCreateInfo.cs @@ -98,9 +98,7 @@ namespace Ryujinx.Graphics.GAL public int GetLayers() { - if (Target == Target.Texture2DArray || - Target == Target.Texture2DMultisampleArray || - Target == Target.CubemapArray) + if (Target is Target.Texture2DArray or Target.Texture2DMultisampleArray or Target.CubemapArray) { return Depth; } diff --git a/src/Ryujinx.Graphics.Gpu/Engine/DeviceStateWithShadow.cs b/src/Ryujinx.Graphics.Gpu/Engine/DeviceStateWithShadow.cs index a2e5b1164..1bce5ce2d 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/DeviceStateWithShadow.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/DeviceStateWithShadow.cs @@ -85,8 +85,7 @@ namespace Ryujinx.Graphics.Gpu.Engine { _state.WriteWithRedundancyCheck(offset, value, out changed); } - else if (shadowRamControl == SetMmeShadowRamControlMode.MethodTrack || - shadowRamControl == SetMmeShadowRamControlMode.MethodTrackWithFilter) + else if (shadowRamControl is SetMmeShadowRamControlMode.MethodTrack or SetMmeShadowRamControlMode.MethodTrackWithFilter) { _shadowState.Write(offset, value); _state.WriteWithRedundancyCheck(offset, value, out changed); diff --git a/src/Ryujinx.Graphics.Gpu/Engine/SetMmeShadowRamControlMode.cs b/src/Ryujinx.Graphics.Gpu/Engine/SetMmeShadowRamControlMode.cs index b9a5c74a3..c07cb1044 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/SetMmeShadowRamControlMode.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/SetMmeShadowRamControlMode.cs @@ -15,7 +15,7 @@ namespace Ryujinx.Graphics.Gpu.Engine { public static bool IsTrack(this SetMmeShadowRamControlMode mode) { - return mode == SetMmeShadowRamControlMode.MethodTrack || mode == SetMmeShadowRamControlMode.MethodTrackWithFilter; + return mode is SetMmeShadowRamControlMode.MethodTrack or SetMmeShadowRamControlMode.MethodTrackWithFilter; } public static bool IsPassthrough(this SetMmeShadowRamControlMode mode) diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/ComputeDraw/VtgAsComputeState.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/ComputeDraw/VtgAsComputeState.cs index 487128cef..e0ecb45f8 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/ComputeDraw/VtgAsComputeState.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/ComputeDraw/VtgAsComputeState.cs @@ -482,7 +482,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.ComputeDraw private readonly ulong GetVertexBufferSize(ulong vbAddress, ulong vbEndAddress, int vbStride, bool indexed, bool instanced, int firstVertex, int vertexCount) { IndexType indexType = _state.State.IndexBufferState.Type; - bool indexTypeSmall = indexType == IndexType.UByte || indexType == IndexType.UShort; + bool indexTypeSmall = indexType is IndexType.UByte or IndexType.UShort; ulong vbSize = vbEndAddress - vbAddress + 1; ulong size; diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/SpecializationStateUpdater.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/SpecializationStateUpdater.cs index d041ecea1..3f5af214e 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/SpecializationStateUpdater.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/SpecializationStateUpdater.cs @@ -250,13 +250,11 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed }; } - if (mayConvertVtgToCompute && (size == VertexAttribSize.Rgb10A2 || size == VertexAttribSize.Rg11B10)) + if (mayConvertVtgToCompute && size is VertexAttribSize.Rgb10A2 or VertexAttribSize.Rg11B10) { value |= AttributeType.Packed; - if (type == VertexAttribType.Snorm || - type == VertexAttribType.Sint || - type == VertexAttribType.Sscaled) + if (type is VertexAttribType.Snorm or VertexAttribType.Sint or VertexAttribType.Sscaled) { value |= AttributeType.PackedRgb10A2Signed; } diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs index 3ecece63e..3b06cd7ec 100644 --- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs +++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs @@ -1111,7 +1111,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed private void UpdateVertexBufferState() { IndexType indexType = _state.State.IndexBufferState.Type; - bool indexTypeSmall = indexType == IndexType.UByte || indexType == IndexType.UShort; + bool indexTypeSmall = indexType is IndexType.UByte or IndexType.UShort; _drawState.IsAnyVbInstanced = false; diff --git a/src/Ryujinx.Graphics.Gpu/Image/Sampler.cs b/src/Ryujinx.Graphics.Gpu/Image/Sampler.cs index b007c1591..b1b1f3968 100644 --- a/src/Ryujinx.Graphics.Gpu/Image/Sampler.cs +++ b/src/Ryujinx.Graphics.Gpu/Image/Sampler.cs @@ -77,7 +77,7 @@ namespace Ryujinx.Graphics.Gpu.Image mipLodBias, Math.Min(maxRequestedAnisotropy, maxSupportedAnisotropy))); - if (GraphicsConfig.MaxAnisotropy >= 0 && GraphicsConfig.MaxAnisotropy <= 16 && (minFilter == MinFilter.LinearMipmapNearest || minFilter == MinFilter.LinearMipmapLinear)) + if (GraphicsConfig.MaxAnisotropy >= 0 && GraphicsConfig.MaxAnisotropy <= 16 && minFilter is MinFilter.LinearMipmapNearest or MinFilter.LinearMipmapLinear) { maxRequestedAnisotropy = GraphicsConfig.MaxAnisotropy; diff --git a/src/Ryujinx.Graphics.Gpu/Image/Texture.cs b/src/Ryujinx.Graphics.Gpu/Image/Texture.cs index 62a49fd8d..188697e0a 100644 --- a/src/Ryujinx.Graphics.Gpu/Image/Texture.cs +++ b/src/Ryujinx.Graphics.Gpu/Image/Texture.cs @@ -1343,7 +1343,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// True if anisotropic filtering can be forced, false otherwise private bool CanTextureForceAnisotropy() { - if (!(Target == Target.Texture2D || Target == Target.Texture2DArray)) + if (!(Target is Target.Texture2D or Target.Texture2DArray)) { return false; } @@ -1367,16 +1367,16 @@ namespace Ryujinx.Graphics.Gpu.Image { case Target.Texture1D: case Target.Texture1DArray: - return target == Target.Texture1D || target == Target.Texture1DArray; + return target is Target.Texture1D or Target.Texture1DArray; case Target.Texture2D: case Target.Texture2DArray: - return target == Target.Texture2D || target == Target.Texture2DArray; + return target is Target.Texture2D or Target.Texture2DArray; case Target.Cubemap: case Target.CubemapArray: - return target == Target.Cubemap || target == Target.CubemapArray; + return target is Target.Cubemap or Target.CubemapArray; case Target.Texture2DMultisample: case Target.Texture2DMultisampleArray: - return target == Target.Texture2DMultisample || target == Target.Texture2DMultisampleArray; + return target is Target.Texture2DMultisample or Target.Texture2DMultisampleArray; case Target.Texture3D: return target == Target.Texture3D; default: diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs index f18ffce97..22a980a79 100644 --- a/src/Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs +++ b/src/Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs @@ -784,8 +784,7 @@ namespace Ryujinx.Graphics.Gpu.Image samplerHandle = samplerWordOffset; } - if (handleType == TextureHandleType.SeparateSamplerId || - handleType == TextureHandleType.SeparateConstantSamplerHandle) + if (handleType is TextureHandleType.SeparateSamplerId or TextureHandleType.SeparateConstantSamplerHandle) { samplerHandle <<= 20; } diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureCache.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureCache.cs index b032d24cc..a34392d5d 100644 --- a/src/Ryujinx.Graphics.Gpu/Image/TextureCache.cs +++ b/src/Ryujinx.Graphics.Gpu/Image/TextureCache.cs @@ -146,7 +146,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// True if eligible private static TextureScaleMode IsUpscaleCompatible(TextureInfo info, bool withUpscale) { - if ((info.Target == Target.Texture2D || info.Target == Target.Texture2DArray || info.Target == Target.Texture2DMultisample) && !info.FormatInfo.IsCompressed) + if (info.Target is Target.Texture2D or Target.Texture2DArray or Target.Texture2DMultisample && !info.FormatInfo.IsCompressed) { return UpscaleSafeMode(info) ? (withUpscale ? TextureScaleMode.Scaled : TextureScaleMode.Eligible) : TextureScaleMode.Undesired; } @@ -675,10 +675,11 @@ namespace Ryujinx.Graphics.Gpu.Image return null; } - if ((info.Target == Target.Texture3D || - info.Target == Target.Texture2DArray || - info.Target == Target.Texture2DMultisampleArray || - info.Target == Target.CubemapArray) && info.DepthOrLayers < 1) + if (info.Target is Target.Texture3D + or Target.Texture2DArray + or Target.Texture2DMultisampleArray + or Target.CubemapArray && + info.DepthOrLayers < 1) { return null; } diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureCompatibility.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureCompatibility.cs index 260a112b2..35e1f80bd 100644 --- a/src/Ryujinx.Graphics.Gpu/Image/TextureCompatibility.cs +++ b/src/Ryujinx.Graphics.Gpu/Image/TextureCompatibility.cs @@ -207,8 +207,7 @@ namespace Ryujinx.Graphics.Gpu.Image return false; // Flushing this format is not supported, as it may have been converted to another host format. } - if (info.Target == Target.Texture2DMultisample || - info.Target == Target.Texture2DMultisampleArray) + if (info.Target is Target.Texture2DMultisample or Target.Texture2DMultisampleArray) { return false; // Flushing multisample textures is not supported, the host does not allow getting their data. } @@ -241,9 +240,10 @@ namespace Ryujinx.Graphics.Gpu.Image { return TextureMatchQuality.FormatAlias; } - else if ((lhs.FormatInfo.Format == Format.D24UnormS8Uint || - lhs.FormatInfo.Format == Format.S8UintD24Unorm || - lhs.FormatInfo.Format == Format.X8UintD24Unorm) && rhs.FormatInfo.Format == Format.B8G8R8A8Unorm || + else if (lhs.FormatInfo.Format is Format.D24UnormS8Uint + or Format.S8UintD24Unorm + or Format.X8UintD24Unorm && + rhs.FormatInfo.Format == Format.B8G8R8A8Unorm || lhs.FormatInfo.Format == Format.D32FloatS8Uint && rhs.FormatInfo.Format == Format.R32G32Float) { return TextureMatchQuality.FormatAlias; @@ -755,43 +755,38 @@ namespace Ryujinx.Graphics.Gpu.Image { case Target.Texture1D: case Target.Texture1DArray: - result = rhs.Target == Target.Texture1D || - rhs.Target == Target.Texture1DArray; + result = rhs.Target is Target.Texture1D or Target.Texture1DArray; break; case Target.Texture2D: - result = rhs.Target == Target.Texture2D || - rhs.Target == Target.Texture2DArray; + result = rhs.Target is Target.Texture2D or Target.Texture2DArray; break; case Target.Texture2DArray: - result = rhs.Target == Target.Texture2D || - rhs.Target == Target.Texture2DArray; + result = rhs.Target is Target.Texture2D or Target.Texture2DArray; - if (rhs.Target == Target.Cubemap || rhs.Target == Target.CubemapArray) + if (rhs.Target is Target.Cubemap or Target.CubemapArray) { return caps.SupportsCubemapView ? TextureViewCompatibility.Full : TextureViewCompatibility.CopyOnly; } break; case Target.Cubemap: case Target.CubemapArray: - result = rhs.Target == Target.Cubemap || - rhs.Target == Target.CubemapArray; + result = rhs.Target is Target.Cubemap or Target.CubemapArray; - if (rhs.Target == Target.Texture2D || rhs.Target == Target.Texture2DArray) + if (rhs.Target is Target.Texture2D or Target.Texture2DArray) { return caps.SupportsCubemapView ? TextureViewCompatibility.Full : TextureViewCompatibility.CopyOnly; } break; case Target.Texture2DMultisample: case Target.Texture2DMultisampleArray: - if (rhs.Target == Target.Texture2D || rhs.Target == Target.Texture2DArray) + if (rhs.Target is Target.Texture2D or Target.Texture2DArray) { return TextureViewCompatibility.CopyOnly; } - result = rhs.Target == Target.Texture2DMultisample || - rhs.Target == Target.Texture2DMultisampleArray; + result = rhs.Target is Target.Texture2DMultisample or Target.Texture2DMultisampleArray; break; case Target.Texture3D: diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureInfo.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureInfo.cs index 94d2e0bfc..cb2ccf54d 100644 --- a/src/Ryujinx.Graphics.Gpu/Image/TextureInfo.cs +++ b/src/Ryujinx.Graphics.Gpu/Image/TextureInfo.cs @@ -216,7 +216,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// The number of texture layers public static int GetLayers(Target target, int depthOrLayers) { - if (target == Target.Texture2DArray || target == Target.Texture2DMultisampleArray) + if (target is Target.Texture2DArray or Target.Texture2DMultisampleArray) { return depthOrLayers; } @@ -241,7 +241,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// The number of texture slices public int GetSlices() { - if (Target == Target.Texture3D || Target == Target.Texture2DArray || Target == Target.Texture2DMultisampleArray) + if (Target is Target.Texture3D or Target.Texture2DArray or Target.Texture2DMultisampleArray) { return DepthOrLayers; } diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureManager.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureManager.cs index db2921468..6476abddc 100644 --- a/src/Ryujinx.Graphics.Gpu/Image/TextureManager.cs +++ b/src/Ryujinx.Graphics.Gpu/Image/TextureManager.cs @@ -143,7 +143,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// True if the scale needs updating, false if the scale is up to date private static bool ScaleNeedsUpdated(Texture texture) { - return texture != null && !(texture.ScaleMode == TextureScaleMode.Blacklisted || texture.ScaleMode == TextureScaleMode.Undesired) && texture.ScaleFactor != GraphicsConfig.ResScale; + return texture != null && !(texture.ScaleMode is TextureScaleMode.Blacklisted or TextureScaleMode.Undesired) && texture.ScaleFactor != GraphicsConfig.ResScale; } /// diff --git a/src/Ryujinx.Graphics.Gpu/Image/TexturePool.cs b/src/Ryujinx.Graphics.Gpu/Image/TexturePool.cs index 86f6fe2d1..da0a3a1d8 100644 --- a/src/Ryujinx.Graphics.Gpu/Image/TexturePool.cs +++ b/src/Ryujinx.Graphics.Gpu/Image/TexturePool.cs @@ -554,7 +554,7 @@ namespace Ryujinx.Graphics.Gpu.Image int width = target == Target.TextureBuffer ? descriptor.UnpackBufferTextureWidth() : descriptor.UnpackWidth(); int height = descriptor.UnpackHeight(); - if (target == Target.Texture2DMultisample || target == Target.Texture2DMultisampleArray) + if (target is Target.Texture2DMultisample or Target.Texture2DMultisampleArray) { // This is divided back before the backend texture is created. width *= samplesInX; @@ -771,8 +771,7 @@ namespace Ryujinx.Graphics.Gpu.Image /// True if the swizzle component is equal to the red or green, false otherwise private static bool IsRG(SwizzleComponent component) { - return component == SwizzleComponent.Red || - component == SwizzleComponent.Green; + return component is SwizzleComponent.Red or SwizzleComponent.Green; } /// diff --git a/src/Ryujinx.Graphics.Gpu/Memory/PteKind.cs b/src/Ryujinx.Graphics.Gpu/Memory/PteKind.cs index 1585328f0..bdaddc1ee 100644 --- a/src/Ryujinx.Graphics.Gpu/Memory/PteKind.cs +++ b/src/Ryujinx.Graphics.Gpu/Memory/PteKind.cs @@ -262,7 +262,7 @@ namespace Ryujinx.Graphics.Gpu.Memory /// True if pitch, false otherwise public static bool IsPitch(this PteKind kind) { - return kind == PteKind.Pitch || kind == PteKind.PitchNoSwizzle; + return kind is PteKind.Pitch or PteKind.PitchNoSwizzle; } } } diff --git a/src/Ryujinx.Graphics.Gpu/Shader/GpuChannelGraphicsState.cs b/src/Ryujinx.Graphics.Gpu/Shader/GpuChannelGraphicsState.cs index 765bef7d4..694b67ab9 100644 --- a/src/Ryujinx.Graphics.Gpu/Shader/GpuChannelGraphicsState.cs +++ b/src/Ryujinx.Graphics.Gpu/Shader/GpuChannelGraphicsState.cs @@ -133,7 +133,7 @@ namespace Ryujinx.Graphics.Gpu.Shader }; } - bool isQuad = Topology == PrimitiveTopology.Quads || Topology == PrimitiveTopology.QuadStrip; + bool isQuad = Topology is PrimitiveTopology.Quads or PrimitiveTopology.QuadStrip; bool halvePrimitiveId = !hostSupportsQuads && !hasGeometryShader && isQuad; return new GpuGraphicsState( diff --git a/src/Ryujinx.Graphics.Gpu/Shader/ShaderSpecializationState.cs b/src/Ryujinx.Graphics.Gpu/Shader/ShaderSpecializationState.cs index 36793cd4a..6f5f1628a 100644 --- a/src/Ryujinx.Graphics.Gpu/Shader/ShaderSpecializationState.cs +++ b/src/Ryujinx.Graphics.Gpu/Shader/ShaderSpecializationState.cs @@ -639,7 +639,7 @@ namespace Ryujinx.Graphics.Gpu.Shader type &= ~(AttributeType.Packed | AttributeType.PackedRgb10A2Signed); if (channel.Capabilities.SupportsScaledVertexFormats && - (type == AttributeType.Sscaled || type == AttributeType.Uscaled)) + type is AttributeType.Sscaled or AttributeType.Uscaled) { type = AttributeType.Float; } diff --git a/src/Ryujinx.Graphics.Nvdec.Vp9/DecodeMv.cs b/src/Ryujinx.Graphics.Nvdec.Vp9/DecodeMv.cs index c6c75f74d..5b37f7327 100644 --- a/src/Ryujinx.Graphics.Nvdec.Vp9/DecodeMv.cs +++ b/src/Ryujinx.Graphics.Nvdec.Vp9/DecodeMv.cs @@ -961,7 +961,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9 int j = (idy * 2) + idx; bMode = ReadInterMode(ref cm, ref xd, ref r, interModeCtx); - if (bMode == PredictionMode.NearestMv || bMode == PredictionMode.NearMv) + if (bMode is PredictionMode.NearestMv or PredictionMode.NearMv) { for (refr = 0; refr < 1 + isCompound; ++refr) { @@ -1028,7 +1028,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9 private static PredictionMode LeftBlockMode(Ptr curMi, Ptr leftMi, int b) { - if (b == 0 || b == 2) + if (b is 0 or 2) { if (leftMi.IsNull || leftMi.Value.IsInterBlock()) { @@ -1038,13 +1038,13 @@ namespace Ryujinx.Graphics.Nvdec.Vp9 return leftMi.Value.GetYMode(b + 1); } - Debug.Assert(b == 1 || b == 3); + Debug.Assert(b is 1 or 3); return curMi.Value.Bmi[b - 1].Mode; } private static PredictionMode AboveBlockMode(Ptr curMi, Ptr aboveMi, int b) { - if (b == 0 || b == 1) + if (b is 0 or 1) { if (aboveMi.IsNull || aboveMi.Value.IsInterBlock()) { @@ -1054,7 +1054,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9 return aboveMi.Value.GetYMode(b + 2); } - Debug.Assert(b == 2 || b == 3); + Debug.Assert(b is 2 or 3); return curMi.Value.Bmi[b - 2].Mode; } diff --git a/src/Ryujinx.Graphics.Nvdec.Vp9/EntropyMv.cs b/src/Ryujinx.Graphics.Nvdec.Vp9/EntropyMv.cs index 493cd24bd..149616f73 100644 --- a/src/Ryujinx.Graphics.Nvdec.Vp9/EntropyMv.cs +++ b/src/Ryujinx.Graphics.Nvdec.Vp9/EntropyMv.cs @@ -33,12 +33,12 @@ namespace Ryujinx.Graphics.Nvdec.Vp9 private static bool JointVertical(MvJointType type) { - return type == MvJointType.Hzvnz || type == MvJointType.Hnzvnz; + return type is MvJointType.Hzvnz or MvJointType.Hnzvnz; } private static bool JointHorizontal(MvJointType type) { - return type == MvJointType.Hnzvz || type == MvJointType.Hnzvnz; + return type is MvJointType.Hnzvz or MvJointType.Hnzvnz; } private static readonly byte[] LogInBase2 = diff --git a/src/Ryujinx.Graphics.Nvdec.Vp9/Types/Mv.cs b/src/Ryujinx.Graphics.Nvdec.Vp9/Types/Mv.cs index 0a89b73a7..890602851 100644 --- a/src/Ryujinx.Graphics.Nvdec.Vp9/Types/Mv.cs +++ b/src/Ryujinx.Graphics.Nvdec.Vp9/Types/Mv.cs @@ -52,12 +52,12 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Types public static bool JointVertical(MvJointType type) { - return type == MvJointType.Hzvnz || type == MvJointType.Hnzvnz; + return type is MvJointType.Hzvnz or MvJointType.Hnzvnz; } public static bool JointHorizontal(MvJointType type) { - return type == MvJointType.Hnzvz || type == MvJointType.Hnzvnz; + return type is MvJointType.Hnzvz or MvJointType.Hnzvnz; } private static int ClassBase(MvClassType c) diff --git a/src/Ryujinx.Graphics.Nvdec.Vp9/Types/Vp9Common.cs b/src/Ryujinx.Graphics.Nvdec.Vp9/Types/Vp9Common.cs index 48f216d24..9904c6dfa 100644 --- a/src/Ryujinx.Graphics.Nvdec.Vp9/Types/Vp9Common.cs +++ b/src/Ryujinx.Graphics.Nvdec.Vp9/Types/Vp9Common.cs @@ -811,7 +811,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Types if (ColorSpace != VpxColorSpace.Srgb) { ColorRange = (VpxColorRange)rb.ReadBit(); - if (Profile == BitstreamProfile.Profile1 || Profile == BitstreamProfile.Profile3) + if (Profile is BitstreamProfile.Profile1 or BitstreamProfile.Profile3) { SubsamplingX = rb.ReadBit(); SubsamplingY = rb.ReadBit(); @@ -834,7 +834,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Types else { ColorRange = VpxColorRange.Full; - if (Profile == BitstreamProfile.Profile1 || Profile == BitstreamProfile.Profile3) + if (Profile is BitstreamProfile.Profile1 or BitstreamProfile.Profile3) { // Note if colorspace is SRGB then 4:4:4 chroma sampling is assumed. // 4:2:2 or 4:4:0 chroma sampling is not allowed. diff --git a/src/Ryujinx.Graphics.OpenGL/FormatTable.cs b/src/Ryujinx.Graphics.OpenGL/FormatTable.cs index 4cf4dc760..3b9b2cc32 100644 --- a/src/Ryujinx.Graphics.OpenGL/FormatTable.cs +++ b/src/Ryujinx.Graphics.OpenGL/FormatTable.cs @@ -228,14 +228,12 @@ namespace Ryujinx.Graphics.OpenGL public static bool IsPackedDepthStencil(Format format) { - return format == Format.D24UnormS8Uint || - format == Format.D32FloatS8Uint || - format == Format.S8UintD24Unorm; + return format is Format.D24UnormS8Uint or Format.D32FloatS8Uint or Format.S8UintD24Unorm; } public static bool IsDepthOnly(Format format) { - return format == Format.D16Unorm || format == Format.D32Float || format == Format.X8UintD24Unorm; + return format is Format.D16Unorm or Format.D32Float or Format.X8UintD24Unorm; } } } diff --git a/src/Ryujinx.Graphics.OpenGL/HwCapabilities.cs b/src/Ryujinx.Graphics.OpenGL/HwCapabilities.cs index cf0b0645c..048d6fa81 100644 --- a/src/Ryujinx.Graphics.OpenGL/HwCapabilities.cs +++ b/src/Ryujinx.Graphics.OpenGL/HwCapabilities.cs @@ -43,13 +43,13 @@ namespace Ryujinx.Graphics.OpenGL private static readonly Lazy _gpuVendor = new(GetGpuVendor); - private static bool IsIntel => _gpuVendor.Value == GpuVendor.IntelWindows || _gpuVendor.Value == GpuVendor.IntelUnix; + private static bool IsIntel => _gpuVendor.Value is GpuVendor.IntelWindows or GpuVendor.IntelUnix; public static GpuVendor Vendor => _gpuVendor.Value; private static readonly Lazy _maxSupportedAnisotropy = new(GL.GetFloat((GetPName)All.MaxTextureMaxAnisotropy)); - public static bool UsePersistentBufferForFlush => _gpuVendor.Value == GpuVendor.AmdWindows || _gpuVendor.Value == GpuVendor.Nvidia; + public static bool UsePersistentBufferForFlush => _gpuVendor.Value is GpuVendor.AmdWindows or GpuVendor.Nvidia; public static bool SupportsAlphaToCoverageDitherControl => _supportsAlphaToCoverageDitherControl.Value; public static bool SupportsAstcCompression => _supportsAstcCompression.Value; @@ -117,11 +117,11 @@ namespace Ryujinx.Graphics.OpenGL return renderer.Contains("mesa") ? GpuVendor.IntelUnix : GpuVendor.IntelWindows; } - else if (vendor == "ati technologies inc." || vendor == "advanced micro devices, inc.") + else if (vendor is "ati technologies inc." or "advanced micro devices, inc.") { return GpuVendor.AmdWindows; } - else if (vendor == "amd" || vendor == "x.org") + else if (vendor is "amd" or "x.org") { return GpuVendor.AmdUnix; } diff --git a/src/Ryujinx.Graphics.OpenGL/Image/TextureCopy.cs b/src/Ryujinx.Graphics.OpenGL/Image/TextureCopy.cs index 89bd5e4ff..bcec0909b 100644 --- a/src/Ryujinx.Graphics.OpenGL/Image/TextureCopy.cs +++ b/src/Ryujinx.Graphics.OpenGL/Image/TextureCopy.cs @@ -290,7 +290,7 @@ namespace Ryujinx.Graphics.OpenGL.Image private static FramebufferAttachment AttachmentForFormat(Format format) { - if (format == Format.D24UnormS8Uint || format == Format.D32FloatS8Uint) + if (format is Format.D24UnormS8Uint or Format.D32FloatS8Uint) { return FramebufferAttachment.DepthStencilAttachment; } diff --git a/src/Ryujinx.Graphics.OpenGL/Image/TextureView.cs b/src/Ryujinx.Graphics.OpenGL/Image/TextureView.cs index 8c12ddcae..b3a68eeeb 100644 --- a/src/Ryujinx.Graphics.OpenGL/Image/TextureView.cs +++ b/src/Ryujinx.Graphics.OpenGL/Image/TextureView.cs @@ -358,7 +358,7 @@ namespace Ryujinx.Graphics.OpenGL.Image PixelFormat pixelFormat = format.PixelFormat; PixelType pixelType = format.PixelType; - if (target == TextureTarget.TextureCubeMap || target == TextureTarget.TextureCubeMapArray) + if (target is TextureTarget.TextureCubeMap or TextureTarget.TextureCubeMapArray) { target = TextureTarget.TextureCubeMapPositiveX + (layer % 6); } diff --git a/src/Ryujinx.Graphics.OpenGL/VertexArray.cs b/src/Ryujinx.Graphics.OpenGL/VertexArray.cs index 32211e783..8186475cf 100644 --- a/src/Ryujinx.Graphics.OpenGL/VertexArray.cs +++ b/src/Ryujinx.Graphics.OpenGL/VertexArray.cs @@ -104,8 +104,7 @@ namespace Ryujinx.Graphics.OpenGL int offset = attrib.Offset; int size = fmtInfo.Components; - bool isFloat = fmtInfo.PixelType == PixelType.Float || - fmtInfo.PixelType == PixelType.HalfFloat; + bool isFloat = fmtInfo.PixelType is PixelType.Float or PixelType.HalfFloat; if (isFloat || fmtInfo.Normalized || fmtInfo.Scaled) { diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs index 8d1ae1fdf..16c9826f3 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Declarations.cs @@ -629,9 +629,9 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl } else { - return stage == ShaderStage.TessellationControl || - stage == ShaderStage.TessellationEvaluation || - stage == ShaderStage.Geometry; + return stage is ShaderStage.TessellationControl + or ShaderStage.TessellationEvaluation + or ShaderStage.Geometry; } } diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGen.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGen.cs index 9e7f64b0e..3bd9a4c17 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGen.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGen.cs @@ -70,11 +70,11 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions StringBuilder builder = new(); - if (atomic && (operation.StorageKind == StorageKind.StorageBuffer || operation.StorageKind == StorageKind.SharedMemory)) + if (atomic && operation.StorageKind is StorageKind.StorageBuffer or StorageKind.SharedMemory) { builder.Append(GenerateLoadOrStore(context, operation, isStore: false)); - AggregateType dstType = operation.Inst == Instruction.AtomicMaxS32 || operation.Inst == Instruction.AtomicMinS32 + AggregateType dstType = operation.Inst is Instruction.AtomicMaxS32 or Instruction.AtomicMinS32 ? AggregateType.S32 : AggregateType.U32; diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/IoMap.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/IoMap.cs index caa6ef642..66943a7d0 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/IoMap.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/IoMap.cs @@ -79,9 +79,9 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions } else { - return stage == ShaderStage.TessellationControl || - stage == ShaderStage.TessellationEvaluation || - stage == ShaderStage.Geometry; + return stage is ShaderStage.TessellationControl + or ShaderStage.TessellationEvaluation + or ShaderStage.Geometry; } } diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/OperandManager.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/OperandManager.cs index a350b089c..6c20cb0c8 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/OperandManager.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/OperandManager.cs @@ -97,8 +97,8 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl } IoVariable ioVariable = (IoVariable)varId.Value; - bool isOutput = operation.StorageKind == StorageKind.Output || operation.StorageKind == StorageKind.OutputPerPatch; - bool isPerPatch = operation.StorageKind == StorageKind.InputPerPatch || operation.StorageKind == StorageKind.OutputPerPatch; + bool isOutput = operation.StorageKind is StorageKind.Output or StorageKind.OutputPerPatch; + bool isPerPatch = operation.StorageKind is StorageKind.InputPerPatch or StorageKind.OutputPerPatch; int location = 0; int component = 0; diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/IoMap.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/IoMap.cs index 7b4e14ff0..ac75e73ef 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/IoMap.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/IoMap.cs @@ -104,9 +104,9 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv } else { - return stage == ShaderStage.TessellationControl || - stage == ShaderStage.TessellationEvaluation || - stage == ShaderStage.Geometry; + return stage is ShaderStage.TessellationControl + or ShaderStage.TessellationEvaluation + or ShaderStage.Geometry; } } diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/SpirvGenerator.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/SpirvGenerator.cs index 8082d736d..9236384f3 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/SpirvGenerator.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Spirv/SpirvGenerator.cs @@ -89,8 +89,8 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv context.AddCapability(Capability.GeometryShaderPassthroughNV); } } - else if (parameters.Definitions.Stage == ShaderStage.TessellationControl || - parameters.Definitions.Stage == ShaderStage.TessellationEvaluation) + else if (parameters.Definitions.Stage is ShaderStage.TessellationControl + or ShaderStage.TessellationEvaluation) { context.AddCapability(Capability.Tessellation); } @@ -371,10 +371,10 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv // We only need a branch if the last instruction didn't // already cause the program to exit or jump elsewhere. bool lastIsCf = e.Block.Last is AstOperation lastOp && - (lastOp.Inst == Instruction.Discard || - lastOp.Inst == Instruction.LoopBreak || - lastOp.Inst == Instruction.LoopContinue || - lastOp.Inst == Instruction.Return); + lastOp.Inst is Instruction.Discard + or Instruction.LoopBreak + or Instruction.LoopContinue + or Instruction.Return; if (!lastIsCf) { @@ -383,8 +383,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv } bool hasElse = AstHelper.Next(e.Block) is AstBlock nextBlock && - (nextBlock.Type == AstBlockType.Else || - nextBlock.Type == AstBlockType.ElseIf); + nextBlock.Type is AstBlockType.Else or AstBlockType.ElseIf; // Re-enter the parent block. if (e.Block.Parent != null && !hasElse) diff --git a/src/Ryujinx.Graphics.Shader/Decoders/Decoder.cs b/src/Ryujinx.Graphics.Shader/Decoders/Decoder.cs index d676fc9e1..2718677e2 100644 --- a/src/Ryujinx.Graphics.Shader/Decoders/Decoder.cs +++ b/src/Ryujinx.Graphics.Shader/Decoders/Decoder.cs @@ -501,7 +501,7 @@ namespace Ryujinx.Graphics.Shader.Decoders { InstConditional condOp = new(op.RawOpCode); - if ((op.Name == InstName.Bra || op.Name == InstName.Exit) && condOp.Ccc != Ccc.T) + if (op.Name is InstName.Bra or InstName.Exit && condOp.Ccc != Ccc.T) { return false; } @@ -879,7 +879,7 @@ namespace Ryujinx.Graphics.Shader.Decoders public static bool IsPopBranch(InstName name) { - return name == InstName.Brk || name == InstName.Cont || name == InstName.Sync; + return name is InstName.Brk or InstName.Cont or InstName.Sync; } private static MergeType GetMergeTypeFromPush(InstName name) diff --git a/src/Ryujinx.Graphics.Shader/Instructions/AttributeMap.cs b/src/Ryujinx.Graphics.Shader/Instructions/AttributeMap.cs index 1e7582e50..a61c3f300 100644 --- a/src/Ryujinx.Graphics.Shader/Instructions/AttributeMap.cs +++ b/src/Ryujinx.Graphics.Shader/Instructions/AttributeMap.cs @@ -322,9 +322,9 @@ namespace Ryujinx.Graphics.Shader.Instructions return false; } - return stage == ShaderStage.TessellationControl || - stage == ShaderStage.TessellationEvaluation || - stage == ShaderStage.Geometry; + return stage is ShaderStage.TessellationControl + or ShaderStage.TessellationEvaluation + or ShaderStage.Geometry; } public static bool HasInvocationId(ShaderStage stage, bool isOutput) diff --git a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitAttribute.cs b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitAttribute.cs index c704156bc..6606803cd 100644 --- a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitAttribute.cs +++ b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitAttribute.cs @@ -173,7 +173,7 @@ namespace Ryujinx.Graphics.Shader.Instructions res = context.FPMultiply(res, context.Load(StorageKind.Input, IoVariable.FragmentCoord, null, Const(3))); } } - else if (op.Imm10 == AttributeConsts.PositionX || op.Imm10 == AttributeConsts.PositionY) + else if (op.Imm10 is AttributeConsts.PositionX or AttributeConsts.PositionY) { // FragCoord X/Y must be divided by the render target scale, if resolution scaling is active, // because the shader code is not expecting scaled values. diff --git a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitConversion.cs b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitConversion.cs index e7e0fba92..5a34cc755 100644 --- a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitConversion.cs +++ b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitConversion.cs @@ -179,8 +179,8 @@ namespace Ryujinx.Graphics.Shader.Instructions Instruction fpType = srcType.ToInstFPType(); - bool isSignedInt = dstType == IDstFmt.S16 || dstType == IDstFmt.S32 || dstType == IDstFmt.S64; - bool isSmallInt = dstType == IDstFmt.U16 || dstType == IDstFmt.S16; + bool isSignedInt = dstType is IDstFmt.S16 or IDstFmt.S32 or IDstFmt.S64; + bool isSmallInt = dstType is IDstFmt.U16 or IDstFmt.S16; Operand srcB = context.FPAbsNeg(src, absolute, negate, fpType); @@ -242,15 +242,9 @@ namespace Ryujinx.Graphics.Shader.Instructions bool negate) { bool isSignedInt = - srcType == ISrcFmt.S8 || - srcType == ISrcFmt.S16 || - srcType == ISrcFmt.S32 || - srcType == ISrcFmt.S64; + srcType is ISrcFmt.S8 or ISrcFmt.S16 or ISrcFmt.S32 or ISrcFmt.S64; bool isSmallInt = - srcType == ISrcFmt.U16 || - srcType == ISrcFmt.S16 || - srcType == ISrcFmt.U8 || - srcType == ISrcFmt.S8; + srcType is ISrcFmt.U16 or ISrcFmt.S16 or ISrcFmt.U8 or ISrcFmt.S8; // TODO: Handle S/U64. @@ -258,7 +252,7 @@ namespace Ryujinx.Graphics.Shader.Instructions if (isSmallInt) { - int size = srcType == ISrcFmt.U16 || srcType == ISrcFmt.S16 ? 16 : 8; + int size = srcType is ISrcFmt.U16 or ISrcFmt.S16 ? 16 : 8; srcB = isSignedInt ? context.BitfieldExtractS32(srcB, Const((int)byteSelection * 8), Const(size)) @@ -302,22 +296,15 @@ namespace Ryujinx.Graphics.Shader.Instructions } bool srcIsSignedInt = - srcType == ISrcDstFmt.S8 || - srcType == ISrcDstFmt.S16 || - srcType == ISrcDstFmt.S32; + srcType is ISrcDstFmt.S8 or ISrcDstFmt.S16 or ISrcDstFmt.S32; bool dstIsSignedInt = - dstType == ISrcDstFmt.S8 || - dstType == ISrcDstFmt.S16 || - dstType == ISrcDstFmt.S32; + dstType is ISrcDstFmt.S8 or ISrcDstFmt.S16 or ISrcDstFmt.S32; bool srcIsSmallInt = - srcType == ISrcDstFmt.U16 || - srcType == ISrcDstFmt.S16 || - srcType == ISrcDstFmt.U8 || - srcType == ISrcDstFmt.S8; + srcType is ISrcDstFmt.U16 or ISrcDstFmt.S16 or ISrcDstFmt.U8 or ISrcDstFmt.S8; if (srcIsSmallInt) { - int size = srcType == ISrcDstFmt.U16 || srcType == ISrcDstFmt.S16 ? 16 : 8; + int size = srcType is ISrcDstFmt.U16 or ISrcDstFmt.S16 ? 16 : 8; src = srcIsSignedInt ? context.BitfieldExtractS32(src, Const((int)byteSelection * 8), Const(size)) diff --git a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitFloatComparison.cs b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitFloatComparison.cs index 59ad7a5de..46ac84c96 100644 --- a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitFloatComparison.cs +++ b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitFloatComparison.cs @@ -534,7 +534,7 @@ namespace Ryujinx.Graphics.Shader.Instructions { res = Const(IrConsts.False); } - else if (cond == FComp.Nan || cond == FComp.Num) + else if (cond is FComp.Nan or FComp.Num) { res = context.BitwiseOr(context.IsNan(srcA, fpType), context.IsNan(srcB, fpType)); diff --git a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitMemory.cs b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitMemory.cs index 3fcb821d3..4a647b588 100644 --- a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitMemory.cs +++ b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitMemory.cs @@ -73,7 +73,7 @@ namespace Ryujinx.Graphics.Shader.Instructions Operand slot = Const(op.CbufSlot); Operand srcA = GetSrcReg(context, op.SrcA); - if (op.AddressMode == AddressMode.Is || op.AddressMode == AddressMode.Isl) + if (op.AddressMode is AddressMode.Is or AddressMode.Isl) { slot = context.IAdd(slot, context.BitfieldExtractU32(srcA, Const(16), Const(16))); srcA = context.BitwiseAnd(srcA, Const(0xffff)); @@ -213,7 +213,7 @@ namespace Ryujinx.Graphics.Shader.Instructions switch (op) { case AtomOp.Add: - if (type == AtomSize.S32 || type == AtomSize.U32) + if (type is AtomSize.S32 or AtomSize.U32) { res = context.AtomicAdd(storageKind, e0, e1, value); } @@ -251,7 +251,7 @@ namespace Ryujinx.Graphics.Shader.Instructions } break; case AtomOp.And: - if (type == AtomSize.S32 || type == AtomSize.U32) + if (type is AtomSize.S32 or AtomSize.U32) { res = context.AtomicAnd(storageKind, e0, e1, value); } @@ -261,7 +261,7 @@ namespace Ryujinx.Graphics.Shader.Instructions } break; case AtomOp.Or: - if (type == AtomSize.S32 || type == AtomSize.U32) + if (type is AtomSize.S32 or AtomSize.U32) { res = context.AtomicOr(storageKind, e0, e1, value); } @@ -271,7 +271,7 @@ namespace Ryujinx.Graphics.Shader.Instructions } break; case AtomOp.Xor: - if (type == AtomSize.S32 || type == AtomSize.U32) + if (type is AtomSize.S32 or AtomSize.U32) { res = context.AtomicXor(storageKind, e0, e1, value); } @@ -281,7 +281,7 @@ namespace Ryujinx.Graphics.Shader.Instructions } break; case AtomOp.Exch: - if (type == AtomSize.S32 || type == AtomSize.U32) + if (type is AtomSize.S32 or AtomSize.U32) { res = context.AtomicSwap(storageKind, e0, e1, value); } diff --git a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitMove.cs b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitMove.cs index 944039d65..35757c5cb 100644 --- a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitMove.cs +++ b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitMove.cs @@ -98,8 +98,8 @@ namespace Ryujinx.Graphics.Shader.Instructions // but it seems to be NVIDIA implementation specific as it's only used // to calculate ISBE offsets, so we can just keep it as zero. - if (context.TranslatorContext.Definitions.Stage == ShaderStage.TessellationControl || - context.TranslatorContext.Definitions.Stage == ShaderStage.TessellationEvaluation) + if (context.TranslatorContext.Definitions.Stage is ShaderStage.TessellationControl + or ShaderStage.TessellationEvaluation) { src = context.ShiftLeft(context.Load(StorageKind.Input, IoVariable.PatchVertices), Const(16)); } diff --git a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitShift.cs b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitShift.cs index ee0dac155..efa99dc3e 100644 --- a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitShift.cs +++ b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitShift.cs @@ -115,7 +115,7 @@ namespace Ryujinx.Graphics.Shader.Instructions bool left, bool writeCC) { - bool isLongShift = maxShift == MaxShift.U64 || maxShift == MaxShift.S64; + bool isLongShift = maxShift is MaxShift.U64 or MaxShift.S64; bool signedShift = maxShift == MaxShift.S64; int maxShiftConst = isLongShift ? 64 : 32; diff --git a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitSurface.cs b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitSurface.cs index 946dcc02e..e9f930179 100644 --- a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitSurface.cs +++ b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitSurface.cs @@ -258,7 +258,7 @@ namespace Ryujinx.Graphics.Shader.Instructions } // TODO: FP and 64-bit formats. - TextureFormat format = size == SuatomSize.Sd32 || size == SuatomSize.Sd64 + TextureFormat format = size is SuatomSize.Sd32 or SuatomSize.Sd64 ? (isBindless ? TextureFormat.Unknown : ShaderProperties.GetTextureFormatAtomic(context.TranslatorContext.GpuAccessor, imm)) : GetTextureFormat(size); @@ -537,7 +537,7 @@ namespace Ryujinx.Graphics.Shader.Instructions } // TODO: FP and 64-bit formats. - TextureFormat format = size == SuatomSize.Sd32 || size == SuatomSize.Sd64 + TextureFormat format = size is SuatomSize.Sd32 or SuatomSize.Sd64 ? (isBindless ? TextureFormat.Unknown : ShaderProperties.GetTextureFormatAtomic(context.TranslatorContext.GpuAccessor, imm)) : GetTextureFormat(size); diff --git a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitTexture.cs b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitTexture.cs index d110b66c9..abf11046f 100644 --- a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitTexture.cs +++ b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitTexture.cs @@ -260,9 +260,7 @@ namespace Ryujinx.Graphics.Shader.Instructions type |= SamplerType.Shadow; } - if ((lodMode == Lod.Lz || - lodMode == Lod.Ll || - lodMode == Lod.Lla) && !isMultisample && type != SamplerType.TextureBuffer) + if (lodMode is Lod.Lz or Lod.Ll or Lod.Lla && !isMultisample && type != SamplerType.TextureBuffer) { sourcesList.Add(lodValue); @@ -284,7 +282,7 @@ namespace Ryujinx.Graphics.Shader.Instructions flags |= TextureFlags.Offset; } - if (lodMode == Lod.Lb || lodMode == Lod.Lba) + if (lodMode is Lod.Lb or Lod.Lba) { sourcesList.Add(lodValue); @@ -694,10 +692,7 @@ namespace Ryujinx.Graphics.Shader.Instructions } bool isArray = - dimensions == TexDim.Array1d || - dimensions == TexDim.Array2d || - dimensions == TexDim.Array3d || - dimensions == TexDim.ArrayCube; + dimensions is TexDim.Array1d or TexDim.Array2d or TexDim.Array3d or TexDim.ArrayCube; Operand arrayIndex = isArray ? Ra() : null; @@ -736,7 +731,7 @@ namespace Ryujinx.Graphics.Shader.Instructions Operand[] packedOffs = new Operand[2]; - bool hasAnyOffset = offset == TexOffset.Aoffi || offset == TexOffset.Ptp; + bool hasAnyOffset = offset is TexOffset.Aoffi or TexOffset.Ptp; packedOffs[0] = hasAnyOffset ? Rb() : null; packedOffs[1] = offset == TexOffset.Ptp ? Rb() : null; @@ -849,10 +844,7 @@ namespace Ryujinx.Graphics.Shader.Instructions int coordsCount = type.GetDimensions(); bool isArray = - dimensions == TexDim.Array1d || - dimensions == TexDim.Array2d || - dimensions == TexDim.Array3d || - dimensions == TexDim.ArrayCube; + dimensions is TexDim.Array1d or TexDim.Array2d or TexDim.Array3d or TexDim.ArrayCube; Operand arrayIndex = isArray ? Ra() : null; @@ -993,10 +985,7 @@ namespace Ryujinx.Graphics.Shader.Instructions Operand packedParams = Ra(); bool isArray = - dimensions == TexDim.Array1d || - dimensions == TexDim.Array2d || - dimensions == TexDim.Array3d || - dimensions == TexDim.ArrayCube; + dimensions is TexDim.Array1d or TexDim.Array2d or TexDim.Array3d or TexDim.ArrayCube; if (isArray) { diff --git a/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/Instruction.cs b/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/Instruction.cs index 273a38a5b..f63a8c4be 100644 --- a/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/Instruction.cs +++ b/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/Instruction.cs @@ -179,19 +179,19 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation public static bool IsTextureQuery(this Instruction inst) { inst &= Instruction.Mask; - return inst == Instruction.Lod || inst == Instruction.TextureQuerySamples || inst == Instruction.TextureQuerySize; + return inst is Instruction.Lod or Instruction.TextureQuerySamples or Instruction.TextureQuerySize; } public static bool IsImage(this Instruction inst) { inst &= Instruction.Mask; - return inst == Instruction.ImageAtomic || inst == Instruction.ImageLoad || inst == Instruction.ImageStore; + return inst is Instruction.ImageAtomic or Instruction.ImageLoad or Instruction.ImageStore; } public static bool IsImageStore(this Instruction inst) { inst &= Instruction.Mask; - return inst == Instruction.ImageAtomic || inst == Instruction.ImageStore; + return inst is Instruction.ImageAtomic or Instruction.ImageStore; } } } diff --git a/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/StorageKind.cs b/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/StorageKind.cs index 669c12816..d95abd64a 100644 --- a/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/StorageKind.cs +++ b/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/StorageKind.cs @@ -24,22 +24,20 @@ namespace Ryujinx.Graphics.Shader.IntermediateRepresentation { public static bool IsInputOrOutput(this StorageKind storageKind) { - return storageKind == StorageKind.Input || - storageKind == StorageKind.InputPerPatch || - storageKind == StorageKind.Output || - storageKind == StorageKind.OutputPerPatch; + return storageKind is StorageKind.Input + or StorageKind.InputPerPatch + or StorageKind.Output + or StorageKind.OutputPerPatch; } public static bool IsOutput(this StorageKind storageKind) { - return storageKind == StorageKind.Output || - storageKind == StorageKind.OutputPerPatch; + return storageKind is StorageKind.Output or StorageKind.OutputPerPatch; } public static bool IsPerPatch(this StorageKind storageKind) { - return storageKind == StorageKind.InputPerPatch || - storageKind == StorageKind.OutputPerPatch; + return storageKind is StorageKind.InputPerPatch or StorageKind.OutputPerPatch; } } } diff --git a/src/Ryujinx.Graphics.Shader/ShaderStage.cs b/src/Ryujinx.Graphics.Shader/ShaderStage.cs index 2522b4fc1..0732449f8 100644 --- a/src/Ryujinx.Graphics.Shader/ShaderStage.cs +++ b/src/Ryujinx.Graphics.Shader/ShaderStage.cs @@ -21,7 +21,7 @@ namespace Ryujinx.Graphics.Shader /// True if the shader stage supports render scale, false otherwise public static bool SupportsRenderScale(this ShaderStage stage) { - return stage == ShaderStage.Vertex || stage == ShaderStage.Fragment || stage == ShaderStage.Compute; + return stage is ShaderStage.Vertex or ShaderStage.Fragment or ShaderStage.Compute; } /// @@ -31,10 +31,10 @@ namespace Ryujinx.Graphics.Shader /// True if the shader stage is vertex, tessellation or geometry, false otherwise public static bool IsVtg(this ShaderStage stage) { - return stage == ShaderStage.Vertex || - stage == ShaderStage.TessellationControl || - stage == ShaderStage.TessellationEvaluation || - stage == ShaderStage.Geometry; + return stage is ShaderStage.Vertex + or ShaderStage.TessellationControl + or ShaderStage.TessellationEvaluation + or ShaderStage.Geometry; } } } diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/InstructionInfo.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/InstructionInfo.cs index 72d0e9896..1fede9fe6 100644 --- a/src/Ryujinx.Graphics.Shader/StructuredIr/InstructionInfo.cs +++ b/src/Ryujinx.Graphics.Shader/StructuredIr/InstructionInfo.cs @@ -150,11 +150,11 @@ namespace Ryujinx.Graphics.Shader.StructuredIr { // TODO: Return correct type depending on source index, // that can improve the decompiler output. - if (inst == Instruction.ImageLoad || - inst == Instruction.ImageStore || - inst == Instruction.ImageAtomic || - inst == Instruction.Lod || - inst == Instruction.TextureSample) + if (inst is Instruction.ImageLoad + or Instruction.ImageStore + or Instruction.ImageAtomic + or Instruction.Lod + or Instruction.TextureSample) { return AggregateType.FP32; } diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/ShaderProperties.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/ShaderProperties.cs index 53ed6bfcc..165fce939 100644 --- a/src/Ryujinx.Graphics.Shader/StructuredIr/ShaderProperties.cs +++ b/src/Ryujinx.Graphics.Shader/StructuredIr/ShaderProperties.cs @@ -87,7 +87,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr private static bool FormatSupportsAtomic(TextureFormat format) { - return format == TextureFormat.R32Sint || format == TextureFormat.R32Uint; + return format is TextureFormat.R32Sint or TextureFormat.R32Uint; } public static TextureFormat GetTextureFormatAtomic(IGpuAccessor gpuAccessor, int handle, int cbufSlot = -1) diff --git a/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgram.cs b/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgram.cs index dc25f63c4..3da723aec 100644 --- a/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgram.cs +++ b/src/Ryujinx.Graphics.Shader/StructuredIr/StructuredProgram.cs @@ -83,7 +83,7 @@ namespace Ryujinx.Graphics.Shader.StructuredIr Instruction inst = operation.Inst; StorageKind storageKind = operation.StorageKind; - if (inst == Instruction.Load || inst == Instruction.Store) + if (inst is Instruction.Load or Instruction.Store) { if (storageKind.IsInputOrOutput()) { diff --git a/src/Ryujinx.Graphics.Shader/TextureHandle.cs b/src/Ryujinx.Graphics.Shader/TextureHandle.cs index 3aaceac48..7902a6012 100644 --- a/src/Ryujinx.Graphics.Shader/TextureHandle.cs +++ b/src/Ryujinx.Graphics.Shader/TextureHandle.cs @@ -110,8 +110,7 @@ namespace Ryujinx.Graphics.Shader samplerHandle = samplerWordOffset; } - if (handleType == TextureHandleType.SeparateSamplerId || - handleType == TextureHandleType.SeparateConstantSamplerHandle) + if (handleType is TextureHandleType.SeparateSamplerId or TextureHandleType.SeparateConstantSamplerHandle) { samplerHandle <<= 20; } diff --git a/src/Ryujinx.Graphics.Shader/Translation/ControlFlowGraph.cs b/src/Ryujinx.Graphics.Shader/Translation/ControlFlowGraph.cs index e14044256..07116a85a 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/ControlFlowGraph.cs +++ b/src/Ryujinx.Graphics.Shader/Translation/ControlFlowGraph.cs @@ -110,9 +110,8 @@ namespace Ryujinx.Graphics.Shader.Translation currentBlock.Operations.AddLast(operation); } - needsNewBlock = operation.Inst == Instruction.Branch || - operation.Inst == Instruction.BranchIfTrue || - operation.Inst == Instruction.BranchIfFalse; + needsNewBlock = + operation.Inst is Instruction.Branch or Instruction.BranchIfTrue or Instruction.BranchIfFalse; if (needsNewBlock) { diff --git a/src/Ryujinx.Graphics.Shader/Translation/EmitterContext.cs b/src/Ryujinx.Graphics.Shader/Translation/EmitterContext.cs index 3fbbb6d9e..9271f1cd7 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/EmitterContext.cs +++ b/src/Ryujinx.Graphics.Shader/Translation/EmitterContext.cs @@ -349,7 +349,7 @@ namespace Ryujinx.Graphics.Shader.Translation } if (TranslatorContext.Definitions.LastInVertexPipeline && - (TranslatorContext.Definitions.Stage == ShaderStage.Vertex || TranslatorContext.Definitions.Stage == ShaderStage.TessellationEvaluation) && + TranslatorContext.Definitions.Stage is ShaderStage.Vertex or ShaderStage.TessellationEvaluation && (TranslatorContext.Options.Flags & TranslationFlags.VertexA) == 0) { PrepareForVertexReturn(); @@ -493,7 +493,7 @@ namespace Ryujinx.Graphics.Shader.Translation Operand src = Register(regIndexBase + component, RegisterType.Gpr); // Perform B <-> R swap if needed, for BGRA formats (not supported on OpenGL). - if (!supportsBgra && (component == 0 || component == 2)) + if (!supportsBgra && component is 0 or 2) { Operand isBgra = this.Load(StorageKind.ConstantBuffer, SupportBuffer.Binding, Const((int)SupportBufferField.FragmentIsBgra), Const(rtIndex)); diff --git a/src/Ryujinx.Graphics.Shader/Translation/Optimizations/GlobalToStorage.cs b/src/Ryujinx.Graphics.Shader/Translation/Optimizations/GlobalToStorage.cs index d30672f3f..811b22f50 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/Optimizations/GlobalToStorage.cs +++ b/src/Ryujinx.Graphics.Shader/Translation/Optimizations/GlobalToStorage.cs @@ -256,8 +256,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations } } else if (operation.Inst == Instruction.Store && - (operation.StorageKind == StorageKind.SharedMemory || - operation.StorageKind == StorageKind.LocalMemory)) + operation.StorageKind is StorageKind.SharedMemory or StorageKind.LocalMemory) { // The NVIDIA compiler can sometimes use shared or local memory as temporary // storage to place the base address and size on, so we need @@ -281,19 +280,19 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations private static bool IsGlobalMemory(StorageKind storageKind) { - return storageKind == StorageKind.GlobalMemory || - storageKind == StorageKind.GlobalMemoryS8 || - storageKind == StorageKind.GlobalMemoryS16 || - storageKind == StorageKind.GlobalMemoryU8 || - storageKind == StorageKind.GlobalMemoryU16; + return storageKind is StorageKind.GlobalMemory + or StorageKind.GlobalMemoryS8 + or StorageKind.GlobalMemoryS16 + or StorageKind.GlobalMemoryU8 + or StorageKind.GlobalMemoryU16; } private static bool IsSmallInt(StorageKind storageKind) { - return storageKind == StorageKind.GlobalMemoryS8 || - storageKind == StorageKind.GlobalMemoryS16 || - storageKind == StorageKind.GlobalMemoryU8 || - storageKind == StorageKind.GlobalMemoryU16; + return storageKind is StorageKind.GlobalMemoryS8 + or StorageKind.GlobalMemoryS16 + or StorageKind.GlobalMemoryU8 + or StorageKind.GlobalMemoryU16; } private static LinkedListNode ReplaceGlobalMemoryWithStorage( @@ -1100,7 +1099,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations { baseOffset = null; - if (operation.Inst == Instruction.Load || operation.Inst == Instruction.Store) + if (operation.Inst is Instruction.Load or Instruction.Store) { if (operation.StorageKind == StorageKind.SharedMemory) { diff --git a/src/Ryujinx.Graphics.Shader/Translation/Optimizations/Utils.cs b/src/Ryujinx.Graphics.Shader/Translation/Optimizations/Utils.cs index bc02d57ac..589199e7a 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/Optimizations/Utils.cs +++ b/src/Ryujinx.Graphics.Shader/Translation/Optimizations/Utils.cs @@ -96,7 +96,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations private static bool IsConditionalBranch(Instruction inst) { - return inst == Instruction.BranchIfFalse || inst == Instruction.BranchIfTrue; + return inst is Instruction.BranchIfFalse or Instruction.BranchIfTrue; } private static bool IsSameCondition(Operand currentCondition, Operand queryCondition) diff --git a/src/Ryujinx.Graphics.Texture/Encoders/BC7Encoder.cs b/src/Ryujinx.Graphics.Texture/Encoders/BC7Encoder.cs index 6e1285a44..946b7c995 100644 --- a/src/Ryujinx.Graphics.Texture/Encoders/BC7Encoder.cs +++ b/src/Ryujinx.Graphics.Texture/Encoders/BC7Encoder.cs @@ -153,7 +153,7 @@ namespace Ryujinx.Graphics.Texture.Encoders int selectedPartition = 0; - if (selectedMode == 1 || selectedMode == 7) + if (selectedMode is 1 or 7) { int partitionSelectionLowestError = int.MaxValue; @@ -180,7 +180,7 @@ namespace Ryujinx.Graphics.Texture.Encoders for (int m = 0; m < 8; m++) { - for (int r = 0; r < (m == 4 || m == 5 ? 4 : 1); r++) + for (int r = 0; r < (m is 4 or 5 ? 4 : 1); r++) { for (int im = 0; im < (m == 4 ? 2 : 1); im++) { diff --git a/src/Ryujinx.Graphics.Vic/Types/FrameFormat.cs b/src/Ryujinx.Graphics.Vic/Types/FrameFormat.cs index b8f821631..ea65d3a35 100644 --- a/src/Ryujinx.Graphics.Vic/Types/FrameFormat.cs +++ b/src/Ryujinx.Graphics.Vic/Types/FrameFormat.cs @@ -54,8 +54,7 @@ namespace Ryujinx.Graphics.Vic.Types public static bool IsInterlacedBottomFirst(this FrameFormat frameFormat) { - return frameFormat == FrameFormat.InterlacedBottomFieldFirst || - frameFormat == FrameFormat.SubPicInterlacedBottomFieldFirst; + return frameFormat is FrameFormat.InterlacedBottomFieldFirst or FrameFormat.SubPicInterlacedBottomFieldFirst; } public static bool IsTopField(this FrameFormat frameFormat, bool isLuma) diff --git a/src/Ryujinx.Graphics.Vulkan/DescriptorSetTemplate.cs b/src/Ryujinx.Graphics.Vulkan/DescriptorSetTemplate.cs index 117f79bb4..27a4a2fdd 100644 --- a/src/Ryujinx.Graphics.Vulkan/DescriptorSetTemplate.cs +++ b/src/Ryujinx.Graphics.Vulkan/DescriptorSetTemplate.cs @@ -194,12 +194,12 @@ namespace Ryujinx.Graphics.Vulkan private static bool IsBufferType(ResourceType type) { - return type == ResourceType.UniformBuffer || type == ResourceType.StorageBuffer; + return type is ResourceType.UniformBuffer or ResourceType.StorageBuffer; } private static bool IsBufferTextureType(ResourceType type) { - return type == ResourceType.BufferTexture || type == ResourceType.BufferImage; + return type is ResourceType.BufferTexture or ResourceType.BufferImage; } public unsafe void Dispose() diff --git a/src/Ryujinx.Graphics.Vulkan/DescriptorSetUpdater.cs b/src/Ryujinx.Graphics.Vulkan/DescriptorSetUpdater.cs index 0e673df0b..be63b802c 100644 --- a/src/Ryujinx.Graphics.Vulkan/DescriptorSetUpdater.cs +++ b/src/Ryujinx.Graphics.Vulkan/DescriptorSetUpdater.cs @@ -347,16 +347,16 @@ namespace Ryujinx.Graphics.Vulkan if (segment.IsArray) { - if (segment.Type == ResourceType.Texture || - segment.Type == ResourceType.Sampler || - segment.Type == ResourceType.TextureAndSampler || - segment.Type == ResourceType.BufferTexture) + if (segment.Type is ResourceType.Texture + or ResourceType.Sampler + or ResourceType.TextureAndSampler + or ResourceType.BufferTexture) { ref var arrayRef = ref _textureArrayExtraRefs[setIndex - PipelineBase.DescriptorSetLayouts]; PipelineStageFlags stageFlags = arrayRef.Stage.ConvertToPipelineStageFlags(); arrayRef.Array?.QueueWriteToReadBarriers(cbs, stageFlags); } - else if (segment.Type == ResourceType.Image || segment.Type == ResourceType.BufferImage) + else if (segment.Type is ResourceType.Image or ResourceType.BufferImage) { ref var arrayRef = ref _imageArrayExtraRefs[setIndex - PipelineBase.DescriptorSetLayouts]; PipelineStageFlags stageFlags = arrayRef.Stage.ConvertToPipelineStageFlags(); @@ -1101,10 +1101,10 @@ namespace Ryujinx.Graphics.Vulkan { DescriptorSet[] sets = null; - if (segment.Type == ResourceType.Texture || - segment.Type == ResourceType.Sampler || - segment.Type == ResourceType.TextureAndSampler || - segment.Type == ResourceType.BufferTexture) + if (segment.Type is ResourceType.Texture + or ResourceType.Sampler + or ResourceType.TextureAndSampler + or ResourceType.BufferTexture) { sets = _textureArrayExtraRefs[setIndex - PipelineBase.DescriptorSetLayouts].Array.GetDescriptorSets( _device, @@ -1115,7 +1115,7 @@ namespace Ryujinx.Graphics.Vulkan _dummyTexture, _dummySampler); } - else if (segment.Type == ResourceType.Image || segment.Type == ResourceType.BufferImage) + else if (segment.Type is ResourceType.Image or ResourceType.BufferImage) { sets = _imageArrayExtraRefs[setIndex - PipelineBase.DescriptorSetLayouts].Array.GetDescriptorSets( _device, diff --git a/src/Ryujinx.Graphics.Vulkan/FormatCapabilities.cs b/src/Ryujinx.Graphics.Vulkan/FormatCapabilities.cs index d4f3def3b..d09a10c17 100644 --- a/src/Ryujinx.Graphics.Vulkan/FormatCapabilities.cs +++ b/src/Ryujinx.Graphics.Vulkan/FormatCapabilities.cs @@ -222,14 +222,12 @@ namespace Ryujinx.Graphics.Vulkan public static bool IsD24S8(Format format) { - return format == Format.D24UnormS8Uint || format == Format.S8UintD24Unorm || format == Format.X8UintD24Unorm; + return format is Format.D24UnormS8Uint or Format.S8UintD24Unorm or Format.X8UintD24Unorm; } private static bool IsRGB16IntFloat(Format format) { - return format == Format.R16G16B16Float || - format == Format.R16G16B16Sint || - format == Format.R16G16B16Uint; + return format is Format.R16G16B16Float or Format.R16G16B16Sint or Format.R16G16B16Uint; } } } diff --git a/src/Ryujinx.Graphics.Vulkan/PipelineState.cs b/src/Ryujinx.Graphics.Vulkan/PipelineState.cs index f3ae37f5d..eed783930 100644 --- a/src/Ryujinx.Graphics.Vulkan/PipelineState.cs +++ b/src/Ryujinx.Graphics.Vulkan/PipelineState.cs @@ -432,11 +432,11 @@ namespace Ryujinx.Graphics.Vulkan } else { - topologySupportsRestart = Topology == PrimitiveTopology.LineStrip || - Topology == PrimitiveTopology.TriangleStrip || - Topology == PrimitiveTopology.TriangleFan || - Topology == PrimitiveTopology.LineStripWithAdjacency || - Topology == PrimitiveTopology.TriangleStripWithAdjacency; + topologySupportsRestart = Topology is PrimitiveTopology.LineStrip + or PrimitiveTopology.TriangleStrip + or PrimitiveTopology.TriangleFan + or PrimitiveTopology.LineStripWithAdjacency + or PrimitiveTopology.TriangleStripWithAdjacency; } primitiveRestartEnable &= topologySupportsRestart; diff --git a/src/Ryujinx.Graphics.Vulkan/SamplerHolder.cs b/src/Ryujinx.Graphics.Vulkan/SamplerHolder.cs index 7f37ab139..97fe17c4a 100644 --- a/src/Ryujinx.Graphics.Vulkan/SamplerHolder.cs +++ b/src/Ryujinx.Graphics.Vulkan/SamplerHolder.cs @@ -20,7 +20,7 @@ namespace Ryujinx.Graphics.Vulkan float minLod = info.MinLod; float maxLod = info.MaxLod; - if (info.MinFilter == MinFilter.Nearest || info.MinFilter == MinFilter.Linear) + if (info.MinFilter is MinFilter.Nearest or MinFilter.Linear) { minLod = 0; maxLod = 0.25f; diff --git a/src/Ryujinx.Graphics.Vulkan/TextureStorage.cs b/src/Ryujinx.Graphics.Vulkan/TextureStorage.cs index aa3f284b5..aa30399d6 100644 --- a/src/Ryujinx.Graphics.Vulkan/TextureStorage.cs +++ b/src/Ryujinx.Graphics.Vulkan/TextureStorage.cs @@ -98,7 +98,7 @@ namespace Ryujinx.Graphics.Vulkan var flags = ImageCreateFlags.CreateMutableFormatBit | ImageCreateFlags.CreateExtendedUsageBit; // This flag causes mipmapped texture arrays to break on AMD GCN, so for that copy dependencies are forced for aliasing as cube. - bool isCube = info.Target == Target.Cubemap || info.Target == Target.CubemapArray; + bool isCube = info.Target is Target.Cubemap or Target.CubemapArray; bool cubeCompatible = gd.IsAmdGcn ? isCube : (info.Width == info.Height && layers >= 6); if (type == ImageType.Type2D && cubeCompatible) @@ -338,7 +338,7 @@ namespace Ryujinx.Graphics.Vulkan public static SampleCountFlags ConvertToSampleCountFlags(SampleCountFlags supportedSampleCounts, uint samples) { - if (samples == 0 || samples > (uint)SampleCountFlags.Count64Bit) + if (samples is 0 or > (uint)SampleCountFlags.Count64Bit) { return SampleCountFlags.Count1Bit; } diff --git a/src/Ryujinx.Graphics.Vulkan/TextureView.cs b/src/Ryujinx.Graphics.Vulkan/TextureView.cs index ffbb98f34..924b3babf 100644 --- a/src/Ryujinx.Graphics.Vulkan/TextureView.cs +++ b/src/Ryujinx.Graphics.Vulkan/TextureView.cs @@ -77,9 +77,7 @@ namespace Ryujinx.Graphics.Vulkan var swizzleB = info.SwizzleB.Convert(); var swizzleA = info.SwizzleA.Convert(); - if (info.Format == Format.R5G5B5A1Unorm || - info.Format == Format.R5G5B5X1Unorm || - info.Format == Format.R5G6B5Unorm) + if (info.Format is Format.R5G5B5A1Unorm or Format.R5G5B5X1Unorm or Format.R5G6B5Unorm) { (swizzleB, swizzleR) = (swizzleR, swizzleB); } diff --git a/src/Ryujinx.Graphics.Vulkan/VulkanRenderer.cs b/src/Ryujinx.Graphics.Vulkan/VulkanRenderer.cs index c40a66839..410096366 100644 --- a/src/Ryujinx.Graphics.Vulkan/VulkanRenderer.cs +++ b/src/Ryujinx.Graphics.Vulkan/VulkanRenderer.cs @@ -355,11 +355,7 @@ namespace Ryujinx.Graphics.Vulkan IsAmdWindows = Vendor == Vendor.Amd && OperatingSystem.IsWindows(); IsIntelWindows = Vendor == Vendor.Intel && OperatingSystem.IsWindows(); IsTBDR = - Vendor == Vendor.Apple || - Vendor == Vendor.Qualcomm || - Vendor == Vendor.ARM || - Vendor == Vendor.Broadcom || - Vendor == Vendor.ImgTec; + Vendor is Vendor.Apple or Vendor.Qualcomm or Vendor.ARM or Vendor.Broadcom or Vendor.ImgTec; GpuVendor = VendorUtils.GetNameFromId(properties.VendorID); GpuDriver = hasDriverProperties && !OperatingSystem.IsMacOS() ? diff --git a/src/Ryujinx.HLE/Debugger/Debugger.cs b/src/Ryujinx.HLE/Debugger/Debugger.cs index 625c7dff3..1b5b87e8b 100644 --- a/src/Ryujinx.HLE/Debugger/Debugger.cs +++ b/src/Ryujinx.HLE/Debugger/Debugger.cs @@ -648,7 +648,7 @@ namespace Ryujinx.HLE.Debugger // Note: We don't support signals yet. ushort? signal = null; - if (cmd == 'C' || cmd == 'S') + if (cmd is 'C' or 'S') { signal = (ushort)stream.ReadLengthAsHex(2); } @@ -857,7 +857,7 @@ namespace Ryujinx.HLE.Debugger void CommandSetThread(char op, ulong? threadId) { - if (threadId == 0 || threadId == null) + if (threadId is 0 or null) { threadId = GetThreads().First().ThreadUid; } diff --git a/src/Ryujinx.HLE/FileSystem/EncryptedFileSystemCreator.cs b/src/Ryujinx.HLE/FileSystem/EncryptedFileSystemCreator.cs index d9f7d5dcf..e6d76cec9 100644 --- a/src/Ryujinx.HLE/FileSystem/EncryptedFileSystemCreator.cs +++ b/src/Ryujinx.HLE/FileSystem/EncryptedFileSystemCreator.cs @@ -12,7 +12,7 @@ namespace Ryujinx.HLE.FileSystem ref readonly SharedRef baseFileSystem, IEncryptedFileSystemCreator.KeyId idIndex, in EncryptionSeed encryptionSeed) { - if (idIndex < IEncryptedFileSystemCreator.KeyId.Save || idIndex > IEncryptedFileSystemCreator.KeyId.CustomStorage) + if (idIndex is < IEncryptedFileSystemCreator.KeyId.Save or > IEncryptedFileSystemCreator.KeyId.CustomStorage) { return ResultFs.InvalidArgument.Log(); } diff --git a/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardApplet.cs b/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardApplet.cs index 3545c71aa..bbb5380ac 100644 --- a/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardApplet.cs +++ b/src/Ryujinx.HLE/HOS/Applets/SoftwareKeyboard/SoftwareKeyboardApplet.cs @@ -152,14 +152,12 @@ namespace Ryujinx.HLE.HOS.Applets private bool InputModeControllerEnabled() { - return _inputMode == KeyboardInputMode.ControllerAndKeyboard || - _inputMode == KeyboardInputMode.ControllerOnly; + return _inputMode is KeyboardInputMode.ControllerAndKeyboard or KeyboardInputMode.ControllerOnly; } private bool InputModeTypingEnabled() { - return _inputMode == KeyboardInputMode.ControllerAndKeyboard || - _inputMode == KeyboardInputMode.KeyboardOnly; + return _inputMode is KeyboardInputMode.ControllerAndKeyboard or KeyboardInputMode.KeyboardOnly; } private void AdvanceInputMode() diff --git a/src/Ryujinx.HLE/HOS/ArmProcessContextFactory.cs b/src/Ryujinx.HLE/HOS/ArmProcessContextFactory.cs index f8eda5105..27574a893 100644 --- a/src/Ryujinx.HLE/HOS/ArmProcessContextFactory.cs +++ b/src/Ryujinx.HLE/HOS/ArmProcessContextFactory.cs @@ -69,14 +69,17 @@ namespace Ryujinx.HLE.HOS mode = MemoryManagerMode.SoftwarePageTable; } - ICpuEngine cpuEngine = isArm64Host && (mode == MemoryManagerMode.HostMapped || mode == MemoryManagerMode.HostMappedUnsafe) && !context.Device.Configuration.EnableGdbStub + ICpuEngine cpuEngine = isArm64Host && + mode is MemoryManagerMode.HostMapped or MemoryManagerMode.HostMappedUnsafe && + !context.Device.Configuration.EnableGdbStub ? new LightningJitEngine(_tickSource) : new JitEngine(_tickSource); AddressSpace addressSpace = null; // We want to use host tracked mode if the host page size is > 4KB. - if ((mode == MemoryManagerMode.HostMapped || mode == MemoryManagerMode.HostMappedUnsafe) && MemoryBlock.GetPageSize() <= 0x1000) + if (mode is MemoryManagerMode.HostMapped or MemoryManagerMode.HostMappedUnsafe && + MemoryBlock.GetPageSize() <= 0x1000) { if (!AddressSpace.TryCreate(context.Memory, addressSpaceSize, out addressSpace)) { diff --git a/src/Ryujinx.HLE/HOS/Diagnostics/Demangler/Demangler.cs b/src/Ryujinx.HLE/HOS/Diagnostics/Demangler/Demangler.cs index 5967fdd96..649e36790 100644 --- a/src/Ryujinx.HLE/HOS/Diagnostics/Demangler/Demangler.cs +++ b/src/Ryujinx.HLE/HOS/Diagnostics/Demangler/Demangler.cs @@ -1430,10 +1430,10 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler } char foldKind = Peek(); - bool hasInitializer = foldKind == 'L' || foldKind == 'R'; - bool isLeftFold = foldKind == 'l' || foldKind == 'L'; + bool hasInitializer = foldKind is 'L' or 'R'; + bool isLeftFold = foldKind is 'l' or 'L'; - if (!isLeftFold && !(foldKind == 'r' || foldKind == 'R')) + if (!isLeftFold && !(foldKind is 'r' or 'R')) { return null; } diff --git a/src/Ryujinx.HLE/HOS/Kernel/Ipc/KServerSession.cs b/src/Ryujinx.HLE/HOS/Kernel/Ipc/KServerSession.cs index 06cfcb47d..65b5daf19 100644 --- a/src/Ryujinx.HLE/HOS/Kernel/Ipc/KServerSession.cs +++ b/src/Ryujinx.HLE/HOS/Kernel/Ipc/KServerSession.cs @@ -943,7 +943,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Ipc { return KernelResult.OutOfResource; } - else if (recvListType == 1 || recvListType == 2) + else if (recvListType is 1 or 2) { ulong recvListBaseAddr; ulong recvListEndAddr; diff --git a/src/Ryujinx.HLE/HOS/Kernel/Memory/KCodeMemory.cs b/src/Ryujinx.HLE/HOS/Kernel/Memory/KCodeMemory.cs index e6d96d803..967aa6c0f 100644 --- a/src/Ryujinx.HLE/HOS/Kernel/Memory/KCodeMemory.cs +++ b/src/Ryujinx.HLE/HOS/Kernel/Memory/KCodeMemory.cs @@ -86,7 +86,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory return KernelResult.InvalidState; } - Debug.Assert(permission == KMemoryPermission.Read || permission == KMemoryPermission.ReadAndExecute); + Debug.Assert(permission is KMemoryPermission.Read or KMemoryPermission.ReadAndExecute); Result result = Owner.MemoryManager.MapPages(address, _pageList, MemoryState.CodeReadOnly, permission); diff --git a/src/Ryujinx.HLE/HOS/Kernel/Process/KProcess.cs b/src/Ryujinx.HLE/HOS/Kernel/Process/KProcess.cs index 73aa763a7..ba80522e7 100644 --- a/src/Ryujinx.HLE/HOS/Kernel/Process/KProcess.cs +++ b/src/Ryujinx.HLE/HOS/Kernel/Process/KProcess.cs @@ -134,7 +134,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process Pid = KernelContext.NewKipId(); - if (Pid == 0 || Pid >= KernelConstants.InitialProcessId) + if (Pid is 0 or >= KernelConstants.InitialProcessId) { throw new InvalidOperationException($"Invalid KIP Id {Pid}."); } @@ -237,7 +237,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process Pid = KernelContext.NewProcessId(); - if (Pid == ulong.MaxValue || Pid < KernelConstants.InitialProcessId) + if (Pid is ulong.MaxValue or < KernelConstants.InitialProcessId) { throw new InvalidOperationException($"Invalid Process Id {Pid}."); } @@ -897,10 +897,10 @@ namespace Ryujinx.HLE.HOS.Kernel.Process { if (State >= ProcessState.Started) { - if (State == ProcessState.Started || - State == ProcessState.Crashed || - State == ProcessState.Attached || - State == ProcessState.DebugSuspended) + if (State is ProcessState.Started + or ProcessState.Crashed + or ProcessState.Attached + or ProcessState.DebugSuspended) { SetState(ProcessState.Exiting); @@ -938,16 +938,12 @@ namespace Ryujinx.HLE.HOS.Kernel.Process lock (_processLock) { - if (State >= ProcessState.Started) + if (State is >= ProcessState.Started + and (ProcessState.Started or ProcessState.Attached or ProcessState.DebugSuspended)) { - if (State == ProcessState.Started || - State == ProcessState.Attached || - State == ProcessState.DebugSuspended) - { - SetState(ProcessState.Exiting); + SetState(ProcessState.Exiting); - shallTerminate = true; - } + shallTerminate = true; } } diff --git a/src/Ryujinx.HLE/HOS/Kernel/SupervisorCall/Syscall.cs b/src/Ryujinx.HLE/HOS/Kernel/SupervisorCall/Syscall.cs index c3492ea49..d27e4f3d2 100644 --- a/src/Ryujinx.HLE/HOS/Kernel/SupervisorCall/Syscall.cs +++ b/src/Ryujinx.HLE/HOS/Kernel/SupervisorCall/Syscall.cs @@ -1191,7 +1191,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall return KernelResult.InvalidMemState; } - if (permission > KMemoryPermission.ReadAndWrite || permission == KMemoryPermission.Write) + if (permission is > KMemoryPermission.ReadAndWrite or KMemoryPermission.Write) { return KernelResult.InvalidPermission; } @@ -1253,7 +1253,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall return KernelResult.InvalidMemState; } - if (permission > KMemoryPermission.ReadAndWrite || permission == KMemoryPermission.Write) + if (permission is > KMemoryPermission.ReadAndWrite or KMemoryPermission.Write) { return KernelResult.InvalidPermission; } @@ -2126,7 +2126,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall case InfoType.ThreadTickCount: { - if (subId < -1 || subId > 3) + if (subId is < -1 or > 3) { return KernelResult.InvalidCombination; } diff --git a/src/Ryujinx.HLE/HOS/Services/Caps/IAlbumApplicationService.cs b/src/Ryujinx.HLE/HOS/Services/Caps/IAlbumApplicationService.cs index 5fbba310f..754a44025 100644 --- a/src/Ryujinx.HLE/HOS/Services/Caps/IAlbumApplicationService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Caps/IAlbumApplicationService.cs @@ -50,7 +50,7 @@ namespace Ryujinx.HLE.HOS.Services.Caps MemoryHelper.FillWithZeros(context.Memory, applicationAlbumFileEntryPosition, (int)applicationAlbumFileEntrySize); - if (contentType > ContentType.Unknown || contentType == ContentType.ExtraMovie) + if (contentType is > ContentType.Unknown or ContentType.ExtraMovie) { resultCode = ResultCode.InvalidContentType; } diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/IHidServer.cs b/src/Ryujinx.HLE/HOS/Services/Hid/IHidServer.cs index bd6508545..38e35f87d 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/IHidServer.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/IHidServer.cs @@ -1141,7 +1141,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid NpadStyleIndex deviceType = (NpadStyleIndex)deviceHandle.DeviceType; NpadIdType npadIdType = (NpadIdType)deviceHandle.PlayerId; - if (deviceType < NpadStyleIndex.System || deviceType >= NpadStyleIndex.FullKey) + if (deviceType is < NpadStyleIndex.System or >= NpadStyleIndex.FullKey) { if (!HidUtils.IsValidNpadIdType(npadIdType)) { diff --git a/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/IUserLocalCommunicationService.cs b/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/IUserLocalCommunicationService.cs index c1c1ff5eb..138d802a5 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/IUserLocalCommunicationService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/IUserLocalCommunicationService.cs @@ -178,7 +178,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator // NOTE: Return ResultCode.InvalidArgument if ip_address and subnet_mask are null, doesn't occur in our case. - if (_state == NetworkState.AccessPointCreated || _state == NetworkState.StationConnected) + if (_state is NetworkState.AccessPointCreated or NetworkState.StationConnected) { ProxyConfig config = _state switch { @@ -525,7 +525,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator return _nifmResultCode; } - if (_state == NetworkState.AccessPoint || _state == NetworkState.AccessPointCreated) + if (_state is NetworkState.AccessPoint or NetworkState.AccessPointCreated) { DestroyNetworkImpl(DisconnectReason.DestroyedByUser); } @@ -701,12 +701,12 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator return _nifmResultCode; } - if (bufferSize == 0 || bufferSize > LdnConst.AdvertiseDataSizeMax) + if (bufferSize is 0 or > LdnConst.AdvertiseDataSizeMax) { return ResultCode.InvalidArgument; } - if (_state == NetworkState.AccessPoint || _state == NetworkState.AccessPointCreated) + if (_state is NetworkState.AccessPoint or NetworkState.AccessPointCreated) { byte[] advertiseData = new byte[bufferSize]; @@ -736,7 +736,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator return ResultCode.InvalidArgument; } - if (_state == NetworkState.AccessPoint || _state == NetworkState.AccessPointCreated) + if (_state is NetworkState.AccessPoint or NetworkState.AccessPointCreated) { return _accessPoint.SetStationAcceptPolicy(acceptPolicy); } @@ -810,7 +810,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator return _nifmResultCode; } - if (_state == NetworkState.Station || _state == NetworkState.StationConnected) + if (_state is NetworkState.Station or NetworkState.StationConnected) { DisconnectImpl(DisconnectReason.DisconnectedByUser); } diff --git a/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnRyu/Proxy/LdnProxy.cs b/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnRyu/Proxy/LdnProxy.cs index fa9cbda67..c4941451f 100644 --- a/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnRyu/Proxy/LdnProxy.cs +++ b/src/Ryujinx.HLE/HOS/Services/Ldn/UserServiceCreator/LdnRyu/Proxy/LdnProxy.cs @@ -47,7 +47,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy { Logger.Error?.PrintMsg(LogClass.ServiceLdn, "Tcp proxy networking is untested. Please report this game so that it can be tested."); } - return domain == AddressFamily.InterNetwork && (protocol == ProtocolType.Tcp || protocol == ProtocolType.Udp); + return domain == AddressFamily.InterNetwork && protocol is ProtocolType.Tcp or ProtocolType.Udp; } private void RegisterHandlers(RyuLdnProtocol protocol) diff --git a/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/INfp.cs b/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/INfp.cs index 73c7a96fc..6c03b759a 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/INfp.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/INfp.cs @@ -967,7 +967,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp { // TODO: Find the differencies between IUser and ISystem/IDebug. - if (_permissionLevel == NfpPermissionLevel.Debug || _permissionLevel == NfpPermissionLevel.System) + if (_permissionLevel is NfpPermissionLevel.Debug or NfpPermissionLevel.System) { return GetRegisterInfo(context); } diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/NvHostChannelDeviceFile.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/NvHostChannelDeviceFile.cs index bc70b05cf..71d884276 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/NvHostChannelDeviceFile.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostChannel/NvHostChannelDeviceFile.cs @@ -400,7 +400,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel private NvInternalResult SetTimeslice(ref uint timeslice) { - if (timeslice < 1000 || timeslice > 50000) + if (timeslice is < 1000 or > 50000) { return NvInternalResult.InvalidInput; } diff --git a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/NvHostCtrlDeviceFile.cs b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/NvHostCtrlDeviceFile.cs index 471bca73c..3cf5f4dd9 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/NvHostCtrlDeviceFile.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nv/NvDrvServices/NvHostCtrl/NvHostCtrlDeviceFile.cs @@ -243,9 +243,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrl return NvInternalResult.Success; } - if (hostEvent.State == NvHostEventState.Available || - hostEvent.State == NvHostEventState.Cancelled || - hostEvent.State == NvHostEventState.Signaled) + if (hostEvent.State is NvHostEventState.Available + or NvHostEventState.Cancelled + or NvHostEventState.Signaled) { _events[userEventId].CloseEvent(Context); _events[userEventId] = null; @@ -392,9 +392,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrl { lock (hostEvent.Lock) { - if (hostEvent.State == NvHostEventState.Available || - hostEvent.State == NvHostEventState.Signaled || - hostEvent.State == NvHostEventState.Cancelled) + if (hostEvent.State is NvHostEventState.Available + or NvHostEventState.Signaled + or NvHostEventState.Cancelled) { bool timedOut = hostEvent.Wait(_device.Gpu, fence); @@ -456,9 +456,9 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrl if (Event != null) { - if (Event.State == NvHostEventState.Available || - Event.State == NvHostEventState.Signaled || - Event.State == NvHostEventState.Cancelled) + if (Event.State is NvHostEventState.Available + or NvHostEventState.Signaled + or NvHostEventState.Cancelled) { eventIndex = index; diff --git a/src/Ryujinx.HLE/HOS/Services/ServerBase.cs b/src/Ryujinx.HLE/HOS/Services/ServerBase.cs index 40329aa36..9cb882bf0 100644 --- a/src/Ryujinx.HLE/HOS/Services/ServerBase.cs +++ b/src/Ryujinx.HLE/HOS/Services/ServerBase.cs @@ -352,8 +352,7 @@ namespace Ryujinx.HLE.HOS.Services _requestDataStream.Write(request.RawData); _requestDataStream.Position = 0; - if (request.Type == IpcMessageType.CmifRequest || - request.Type == IpcMessageType.CmifRequestWithContext) + if (request.Type is IpcMessageType.CmifRequest or IpcMessageType.CmifRequestWithContext) { response.Type = IpcMessageType.CmifResponse; @@ -373,8 +372,7 @@ namespace Ryujinx.HLE.HOS.Services response.RawData = _responseDataStream.ToArray(); } - else if (request.Type == IpcMessageType.CmifControl || - request.Type == IpcMessageType.CmifControlWithContext) + else if (request.Type is IpcMessageType.CmifControl or IpcMessageType.CmifControlWithContext) { #pragma warning disable IDE0059 // Remove unnecessary value assignment uint magic = (uint)_requestDataReader.ReadUInt64(); @@ -424,7 +422,7 @@ namespace Ryujinx.HLE.HOS.Services throw new NotImplementedException(cmdId.ToString()); } } - else if (request.Type == IpcMessageType.CmifCloseSession || request.Type == IpcMessageType.TipcCloseSession) + else if (request.Type is IpcMessageType.CmifCloseSession or IpcMessageType.TipcCloseSession) { DestroySession(serverSessionHandle); shouldReply = false; diff --git a/src/Ryujinx.HLE/HOS/Services/Settings/ISettingsServer.cs b/src/Ryujinx.HLE/HOS/Services/Settings/ISettingsServer.cs index abb9b6d8e..fef994bf8 100644 --- a/src/Ryujinx.HLE/HOS/Services/Settings/ISettingsServer.cs +++ b/src/Ryujinx.HLE/HOS/Services/Settings/ISettingsServer.cs @@ -63,7 +63,7 @@ namespace Ryujinx.HLE.HOS.Services.Settings RegionCode regionCode = (RegionCode)context.Device.System.State.DesiredRegionCode; - if (regionCode < RegionCode.Min || regionCode > RegionCode.Max) + if (regionCode is < RegionCode.Min or > RegionCode.Max) { regionCode = RegionCode.USA; } diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs index 14bf3c1d1..c9b4a5de2 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Bsd/IClient.cs @@ -79,7 +79,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd { return WriteBsdResult(context, -1, LinuxError.EPROTONOSUPPORT); } - else if ((type == BsdSocketType.Seqpacket || type == BsdSocketType.Raw) && !_isPrivileged) + else if (type is BsdSocketType.Seqpacket or BsdSocketType.Raw && !_isPrivileged) { if (domain != BsdAddressFamily.InterNetwork || type != BsdSocketType.Raw || protocol != ProtocolType.Icmp) { diff --git a/src/Ryujinx.HLE/HOS/Services/Sockets/Nsd/Manager/FqdnResolver.cs b/src/Ryujinx.HLE/HOS/Services/Sockets/Nsd/Manager/FqdnResolver.cs index 2ec0f744e..3d06eb2d8 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sockets/Nsd/Manager/FqdnResolver.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sockets/Nsd/Manager/FqdnResolver.cs @@ -24,10 +24,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Nsd.Manager public static ResultCode Resolve(string address, out string resolvedAddress) { - if (address == "api.sect.srv.nintendo.net" || - address == "ctest.cdn.nintendo.net" || - address == "ctest.cdn.n.nintendoswitch.cn" || - address == "unknown.dummy.nintendo.net") + if (address is "api.sect.srv.nintendo.net" + or "ctest.cdn.nintendo.net" + or "ctest.cdn.n.nintendoswitch.cn" + or "unknown.dummy.nintendo.net") { resolvedAddress = address; } diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferQueueConsumer.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferQueueConsumer.cs index 74afa989d..68560240b 100644 --- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferQueueConsumer.cs +++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferQueueConsumer.cs @@ -336,7 +336,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger public Status SetMaxAcquiredBufferCount(int maxAcquiredBufferCount) { - if (maxAcquiredBufferCount < 0 || maxAcquiredBufferCount > BufferSlotArray.MaxAcquiredBuffers) + if (maxAcquiredBufferCount is < 0 or > BufferSlotArray.MaxAcquiredBuffers) { return Status.BadValue; } diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferQueueCore.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferQueueCore.cs index 770149489..8399c6d67 100644 --- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferQueueCore.cs +++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/BufferQueueCore.cs @@ -126,7 +126,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger { BufferState state = Slots[slot].BufferState; - if (state == BufferState.Queued || state == BufferState.Dequeued) + if (state is BufferState.Queued or BufferState.Dequeued) { maxBufferCount = slot + 1; } diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/SurfaceFlinger.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/SurfaceFlinger.cs index ecbf0f3f3..b8b568dcf 100644 --- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/SurfaceFlinger.cs +++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/SurfaceFlinger.cs @@ -421,8 +421,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger Format format = ConvertColorFormat(item.GraphicBuffer.Object.Buffer.Surfaces[0].ColorFormat); byte bytesPerPixel = - format == Format.B5G6R5Unorm || - format == Format.R4G4B4A4Unorm ? (byte)2 : (byte)4; + format is Format.B5G6R5Unorm or Format.R4G4B4A4Unorm ? (byte)2 : (byte)4; int gobBlocksInY = 1 << item.GraphicBuffer.Object.Buffer.Surfaces[0].BlockHeightLog2; diff --git a/src/Ryujinx.HLE/HOS/TamperMachine.cs b/src/Ryujinx.HLE/HOS/TamperMachine.cs index 609221535..a22e87cb1 100644 --- a/src/Ryujinx.HLE/HOS/TamperMachine.cs +++ b/src/Ryujinx.HLE/HOS/TamperMachine.cs @@ -173,7 +173,7 @@ namespace Ryujinx.HLE.HOS // Look for the input of the player one or the handheld. foreach (GamepadInput input in gamepadInputs) { - if (input.PlayerId == PlayerIndex.Player1 || input.PlayerId == PlayerIndex.Handheld) + if (input.PlayerId is PlayerIndex.Player1 or PlayerIndex.Handheld) { Volatile.Write(ref _pressedKeys, (long)input.Buttons); diff --git a/src/Ryujinx.HLE/Loaders/Elf/ElfSymbol.cs b/src/Ryujinx.HLE/Loaders/Elf/ElfSymbol.cs index 1ed61b2cb..e3ade80ba 100644 --- a/src/Ryujinx.HLE/Loaders/Elf/ElfSymbol.cs +++ b/src/Ryujinx.HLE/Loaders/Elf/ElfSymbol.cs @@ -8,8 +8,8 @@ namespace Ryujinx.HLE.Loaders.Elf public ElfSymbolBinding Binding { get; private set; } public ElfSymbolVisibility Visibility { get; private set; } - public readonly bool IsFuncOrObject => Type == ElfSymbolType.SttFunc || Type == ElfSymbolType.SttObject; - public readonly bool IsGlobalOrWeak => Binding == ElfSymbolBinding.StbGlobal || Binding == ElfSymbolBinding.StbWeak; + public readonly bool IsFuncOrObject => Type is ElfSymbolType.SttFunc or ElfSymbolType.SttObject; + public readonly bool IsGlobalOrWeak => Binding is ElfSymbolBinding.StbGlobal or ElfSymbolBinding.StbWeak; public int ShIdx { get; private set; } public ulong Value { get; private set; } diff --git a/src/Ryujinx.Horizon.Generators/Hipc/HipcGenerator.cs b/src/Ryujinx.Horizon.Generators/Hipc/HipcGenerator.cs index 98c84b634..555a51d47 100644 --- a/src/Ryujinx.Horizon.Generators/Hipc/HipcGenerator.cs +++ b/src/Ryujinx.Horizon.Generators/Hipc/HipcGenerator.cs @@ -165,7 +165,7 @@ namespace Ryujinx.Horizon.Generators.Hipc arg = $"new CommandArg({bufferFlags})"; } } - else if (argType == CommandArgType.InArgument || argType == CommandArgType.OutArgument) + else if (argType is CommandArgType.InArgument or CommandArgType.OutArgument) { string alignment = GetTypeAlignmentExpression(compilation, parameter.Type); diff --git a/src/Ryujinx.Horizon.Kernel.Generators/SyscallGenerator.cs b/src/Ryujinx.Horizon.Kernel.Generators/SyscallGenerator.cs index c3d088a72..32cd263a3 100644 --- a/src/Ryujinx.Horizon.Kernel.Generators/SyscallGenerator.cs +++ b/src/Ryujinx.Horizon.Kernel.Generators/SyscallGenerator.cs @@ -498,12 +498,12 @@ namespace Ryujinx.Horizon.Kernel.Generators private static bool Is32BitInteger(string canonicalTypeName) { - return canonicalTypeName == TypeSystemInt32 || canonicalTypeName == TypeSystemUInt32; + return canonicalTypeName is TypeSystemInt32 or TypeSystemUInt32; } private static bool Is64BitInteger(string canonicalTypeName) { - return canonicalTypeName == TypeSystemInt64 || canonicalTypeName == TypeSystemUInt64; + return canonicalTypeName is TypeSystemInt64 or TypeSystemUInt64; } private static string GenerateCastFromUInt64(string value, string canonicalTargetTypeName, string targetTypeName) diff --git a/src/Ryujinx.Horizon/Prepo/Ipc/PrepoService.cs b/src/Ryujinx.Horizon/Prepo/Ipc/PrepoService.cs index 4ed7dd48e..ca7a87a63 100644 --- a/src/Ryujinx.Horizon/Prepo/Ipc/PrepoService.cs +++ b/src/Ryujinx.Horizon/Prepo/Ipc/PrepoService.cs @@ -137,7 +137,7 @@ namespace Ryujinx.Horizon.Prepo.Ipc { enabled = false; - if (_permissionLevel == PrepoServicePermissionLevel.User || _permissionLevel == PrepoServicePermissionLevel.System) + if (_permissionLevel is PrepoServicePermissionLevel.User or PrepoServicePermissionLevel.System) { enabled = _userAgreementCheckEnabled; @@ -154,7 +154,7 @@ namespace Ryujinx.Horizon.Prepo.Ipc [CmifCommand(40101)] // 2.0.0+ public Result SetUserAgreementCheckEnabled(bool enabled) { - if (_permissionLevel == PrepoServicePermissionLevel.User || _permissionLevel == PrepoServicePermissionLevel.System) + if (_permissionLevel is PrepoServicePermissionLevel.User or PrepoServicePermissionLevel.System) { _userAgreementCheckEnabled = enabled; diff --git a/src/Ryujinx.Horizon/Sdk/Codec/Detail/HardwareOpusDecoderManager.cs b/src/Ryujinx.Horizon/Sdk/Codec/Detail/HardwareOpusDecoderManager.cs index f59a235d3..043b76f5e 100644 --- a/src/Ryujinx.Horizon/Sdk/Codec/Detail/HardwareOpusDecoderManager.cs +++ b/src/Ryujinx.Horizon/Sdk/Codec/Detail/HardwareOpusDecoderManager.cs @@ -297,7 +297,7 @@ namespace Ryujinx.Horizon.Sdk.Codec.Detail { const int SilkDecoderSize = 0x2160; - if (channelsCount < 1 || channelsCount > 2) + if (channelsCount is < 1 or > 2) { return 0; } diff --git a/src/Ryujinx.Horizon/Sdk/Ngc/Detail/ProfanityFilterBase.cs b/src/Ryujinx.Horizon/Sdk/Ngc/Detail/ProfanityFilterBase.cs index 9f3c6b449..3a7595464 100644 --- a/src/Ryujinx.Horizon/Sdk/Ngc/Detail/ProfanityFilterBase.cs +++ b/src/Ryujinx.Horizon/Sdk/Ngc/Detail/ProfanityFilterBase.cs @@ -232,7 +232,7 @@ namespace Ryujinx.Horizon.Sdk.Ngc.Detail text[startOffset] = 0xc1; text[startOffset + 1] = 0xc1; } - else if (maskMode == MaskMode.Overwrite || maskMode == MaskMode.ReplaceByOneCharacter) + else if (maskMode is MaskMode.Overwrite or MaskMode.ReplaceByOneCharacter) { text[startOffset] = 0xc0; text[startOffset + 1] = 0xc0; diff --git a/src/Ryujinx.Horizon/Sdk/Sf/Cmif/ServiceDispatchTableBase.cs b/src/Ryujinx.Horizon/Sdk/Sf/Cmif/ServiceDispatchTableBase.cs index 2625a4c3e..70a0db58d 100644 --- a/src/Ryujinx.Horizon/Sdk/Sf/Cmif/ServiceDispatchTableBase.cs +++ b/src/Ryujinx.Horizon/Sdk/Sf/Cmif/ServiceDispatchTableBase.cs @@ -62,8 +62,7 @@ namespace Ryujinx.Horizon.Sdk.Sf.Cmif Result commandResult = commandHandler.Invoke(ref outHeader, ref context, inMessageRawData); - if (commandResult.Module == SfResult.ModuleId || - commandResult.Module == HipcResult.ModuleId) + if (commandResult.Module is SfResult.ModuleId or HipcResult.ModuleId) { Logger.Warning?.Print(LogClass.KernelIpc, $"{commandHandler.MethodName} returned error {commandResult}"); } diff --git a/src/Ryujinx.SDL2.Common/SDL2Driver.cs b/src/Ryujinx.SDL2.Common/SDL2Driver.cs index 2da1d4954..14b47f557 100644 --- a/src/Ryujinx.SDL2.Common/SDL2Driver.cs +++ b/src/Ryujinx.SDL2.Common/SDL2Driver.cs @@ -151,7 +151,9 @@ namespace Ryujinx.SDL2.Common { OnJoyBatteryUpdated?.Invoke(evnt.cbutton.which, (SDL_JoystickPowerLevel)evnt.user.code); } - else if (evnt.type == SDL_EventType.SDL_WINDOWEVENT || evnt.type == SDL_EventType.SDL_MOUSEBUTTONDOWN || evnt.type == SDL_EventType.SDL_MOUSEBUTTONUP) + else if (evnt.type is SDL_EventType.SDL_WINDOWEVENT + or SDL_EventType.SDL_MOUSEBUTTONDOWN + or SDL_EventType.SDL_MOUSEBUTTONUP) { if (_registeredWindowHandlers.TryGetValue(evnt.window.windowID, out Action handler)) { diff --git a/src/Ryujinx.UI.Common/App/ApplicationLibrary.cs b/src/Ryujinx.UI.Common/App/ApplicationLibrary.cs index 1ba49d9d1..115335657 100644 --- a/src/Ryujinx.UI.Common/App/ApplicationLibrary.cs +++ b/src/Ryujinx.UI.Common/App/ApplicationLibrary.cs @@ -1184,7 +1184,7 @@ namespace Ryujinx.UI.App.Common using FileStream file = new(applicationPath ?? string.Empty, FileMode.Open, FileAccess.Read); - if (extension == ".nsp" || extension == ".pfs0" || extension == ".xci") + if (extension is ".nsp" or ".pfs0" or ".xci") { try { diff --git a/src/Ryujinx.UI.Common/Configuration/ConfigurationState.cs b/src/Ryujinx.UI.Common/Configuration/ConfigurationState.cs index 25320e387..238a529f0 100644 --- a/src/Ryujinx.UI.Common/Configuration/ConfigurationState.cs +++ b/src/Ryujinx.UI.Common/Configuration/ConfigurationState.cs @@ -1077,7 +1077,7 @@ namespace Ryujinx.UI.Common.Configuration { bool configurationFileUpdated = false; - if (configurationFileFormat.Version < 0 || configurationFileFormat.Version > ConfigurationFileFormat.CurrentVersion) + if (configurationFileFormat.Version is < 0 or > ConfigurationFileFormat.CurrentVersion) { Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Unsupported configuration version {configurationFileFormat.Version}, loading default."); diff --git a/src/Ryujinx.UI.Common/Helper/SetupValidator.cs b/src/Ryujinx.UI.Common/Helper/SetupValidator.cs index a954be26f..f108d4c37 100644 --- a/src/Ryujinx.UI.Common/Helper/SetupValidator.cs +++ b/src/Ryujinx.UI.Common/Helper/SetupValidator.cs @@ -96,7 +96,7 @@ namespace Ryujinx.UI.Common.Helper string baseApplicationExtension = Path.GetExtension(baseApplicationPath).ToLowerInvariant(); // NOTE: We don't force homebrew developers to install a system firmware. - if (baseApplicationExtension == ".nro" || baseApplicationExtension == ".nso") + if (baseApplicationExtension is ".nro" or ".nso") { error = UserError.Success; diff --git a/src/Ryujinx/Headless/HeadlessRyujinx.Init.cs b/src/Ryujinx/Headless/HeadlessRyujinx.Init.cs index 5f6df78b4..f4f0bfa3d 100644 --- a/src/Ryujinx/Headless/HeadlessRyujinx.Init.cs +++ b/src/Ryujinx/Headless/HeadlessRyujinx.Init.cs @@ -97,7 +97,7 @@ namespace Ryujinx.Headless InputConfig config; - if (inputProfileName == null || inputProfileName.Equals("default")) + if (inputProfileName is null or "default") { if (isKeyboard) { diff --git a/src/Ryujinx/Input/AvaloniaKeyboardDriver.cs b/src/Ryujinx/Input/AvaloniaKeyboardDriver.cs index ca0144103..141d1659b 100644 --- a/src/Ryujinx/Input/AvaloniaKeyboardDriver.cs +++ b/src/Ryujinx/Input/AvaloniaKeyboardDriver.cs @@ -84,7 +84,7 @@ namespace Ryujinx.Ava.Input internal bool IsPressed(Key key) { - if (key == Key.Unbound || key == Key.Unknown) + if (key is Key.Unbound or Key.Unknown) { return false; } diff --git a/src/Ryujinx/UI/Applet/AvaloniaHostUITheme.cs b/src/Ryujinx/UI/Applet/AvaloniaHostUITheme.cs index 3ab2fdc70..ea7a08bf7 100644 --- a/src/Ryujinx/UI/Applet/AvaloniaHostUITheme.cs +++ b/src/Ryujinx/UI/Applet/AvaloniaHostUITheme.cs @@ -55,7 +55,7 @@ namespace Ryujinx.Ava.UI.Applet return culture.TwoLetterISOLanguageName switch { - "zh" => langCode == "zh-CN" || langCode == "zh-Hans" || langCode == "zh-SG" + "zh" => langCode is "zh-CN" or "zh-Hans" or "zh-SG" ? "Microsoft YaHei UI" // Simplified Chinese : "Microsoft JhengHei UI", // Traditional Chinese diff --git a/src/Ryujinx/UI/ViewModels/SettingsViewModel.cs b/src/Ryujinx/UI/ViewModels/SettingsViewModel.cs index 164e8281b..fecbbad9a 100644 --- a/src/Ryujinx/UI/ViewModels/SettingsViewModel.cs +++ b/src/Ryujinx/UI/ViewModels/SettingsViewModel.cs @@ -168,9 +168,7 @@ namespace Ryujinx.Ava.UI.ViewModels get => _vSyncMode; set { - if (value == VSyncMode.Custom || - value == VSyncMode.Switch || - value == VSyncMode.Unbounded) + if (value is VSyncMode.Custom or VSyncMode.Switch or VSyncMode.Unbounded) { _vSyncMode = value; OnPropertyChanged(); diff --git a/src/Spv.Generator/Module.cs b/src/Spv.Generator/Module.cs index ce11f13de..bdd650854 100644 --- a/src/Spv.Generator/Module.cs +++ b/src/Spv.Generator/Module.cs @@ -208,11 +208,11 @@ namespace Spv.Generator private void AddConstant(Instruction constant) { - Debug.Assert(constant.Opcode == Op.OpConstant || - constant.Opcode == Op.OpConstantFalse || - constant.Opcode == Op.OpConstantTrue || - constant.Opcode == Op.OpConstantNull || - constant.Opcode == Op.OpConstantComposite); + Debug.Assert(constant.Opcode is Op.OpConstant + or Op.OpConstantFalse + or Op.OpConstantTrue + or Op.OpConstantNull + or Op.OpConstantComposite); var key = new ConstantKey(constant);