aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Ryujinx.Graphics.Gpu/ClassId.cs4
-rw-r--r--src/Ryujinx.Graphics.Gpu/Constants.cs2
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/Compute/ComputeClass.cs10
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/Compute/ComputeClassState.cs204
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/Compute/ComputeQmd.cs270
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/ConditionalRenderEnabled.cs2
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/Dma/DmaClass.cs70
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/Dma/DmaClassState.cs84
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/Dma/DmaTexture.cs4
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/GPFifo/CompressedMethod.cs24
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPEntry.cs22
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoClass.cs3
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoClassState.cs92
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoDevice.cs12
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoProcessor.cs2
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/InlineToMemory/InlineToMemoryClass.cs8
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/InlineToMemory/InlineToMemoryClassState.cs48
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/MME/AluOperation.cs2
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/MME/AluRegOperation.cs2
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/MME/AssignmentOperation.cs2
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/MME/Macro.cs6
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLE.cs3
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLEFunctionName.cs2
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLETable.cs14
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/MME/MacroInterpreter.cs21
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/MME/MacroJit.cs4
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/MME/MacroJitCompiler.cs2
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/MME/MacroJitContext.cs2
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/MmeShadowScratch.cs2
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/SetMmeShadowRamControlMode.cs2
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/ShaderTexture.cs4
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendFunctions.cs6
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendManager.cs6
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendPreGenTable.cs4
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendUcode.cs10
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/UcodeAssembler.cs52
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/Threed/ConstantBufferUpdater.cs2
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/Threed/DrawManager.cs10
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/Threed/DrawState.cs2
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/Threed/IbStreamer.cs22
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/Threed/IndirectDrawType.cs7
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/Threed/RenderTargetUpdateFlags.cs2
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/Threed/SemaphoreUpdater.cs19
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/Threed/SpecializationStateUpdater.cs2
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs30
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/Threed/ThreedClass.cs2
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/Threed/ThreedClassState.cs170
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/Twod/TwodClass.cs12
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/Twod/TwodClassState.cs206
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/Twod/TwodTexture.cs2
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/Types/Boolean32.cs6
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/Types/ColorFormat.cs104
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/Types/GpuVa.cs4
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/Types/MemoryLayout.cs12
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/Types/PrimitiveType.cs14
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/Types/SamplerIndex.cs6
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/Types/SbDescriptor.cs4
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/Types/ZetaFormat.cs14
-rw-r--r--src/Ryujinx.Graphics.Gpu/GpuChannel.cs1
-rw-r--r--src/Ryujinx.Graphics.Gpu/GpuContext.cs6
-rw-r--r--src/Ryujinx.Graphics.Gpu/GraphicsConfig.cs4
-rw-r--r--src/Ryujinx.Graphics.Gpu/Image/AutoDeleteCache.cs4
-rw-r--r--src/Ryujinx.Graphics.Gpu/Image/FormatInfo.cs20
-rw-r--r--src/Ryujinx.Graphics.Gpu/Image/FormatTable.cs15
-rw-r--r--src/Ryujinx.Graphics.Gpu/Image/Pool.cs4
-rw-r--r--src/Ryujinx.Graphics.Gpu/Image/PoolCache.cs2
-rw-r--r--src/Ryujinx.Graphics.Gpu/Image/ReductionFilter.cs2
-rw-r--r--src/Ryujinx.Graphics.Gpu/Image/Sampler.cs10
-rw-r--r--src/Ryujinx.Graphics.Gpu/Image/SamplerDescriptor.cs52
-rw-r--r--src/Ryujinx.Graphics.Gpu/Image/SamplerMinFilter.cs2
-rw-r--r--src/Ryujinx.Graphics.Gpu/Image/SamplerMipFilter.cs2
-rw-r--r--src/Ryujinx.Graphics.Gpu/Image/SamplerPool.cs2
-rw-r--r--src/Ryujinx.Graphics.Gpu/Image/SamplerPoolCache.cs2
-rw-r--r--src/Ryujinx.Graphics.Gpu/Image/Texture.cs36
-rw-r--r--src/Ryujinx.Graphics.Gpu/Image/TextureBindingInfo.cs12
-rw-r--r--src/Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs12
-rw-r--r--src/Ryujinx.Graphics.Gpu/Image/TextureCache.cs18
-rw-r--r--src/Ryujinx.Graphics.Gpu/Image/TextureCompatibility.cs107
-rw-r--r--src/Ryujinx.Graphics.Gpu/Image/TextureComponent.cs31
-rw-r--r--src/Ryujinx.Graphics.Gpu/Image/TextureDescriptor.cs61
-rw-r--r--src/Ryujinx.Graphics.Gpu/Image/TextureDescriptorType.cs4
-rw-r--r--src/Ryujinx.Graphics.Gpu/Image/TextureGroup.cs16
-rw-r--r--src/Ryujinx.Graphics.Gpu/Image/TextureGroupHandle.cs10
-rw-r--r--src/Ryujinx.Graphics.Gpu/Image/TextureInfo.cs78
-rw-r--r--src/Ryujinx.Graphics.Gpu/Image/TextureManager.cs14
-rw-r--r--src/Ryujinx.Graphics.Gpu/Image/TextureMatchQuality.cs2
-rw-r--r--src/Ryujinx.Graphics.Gpu/Image/TextureMsaaMode.cs10
-rw-r--r--src/Ryujinx.Graphics.Gpu/Image/TexturePool.cs16
-rw-r--r--src/Ryujinx.Graphics.Gpu/Image/TexturePoolCache.cs2
-rw-r--r--src/Ryujinx.Graphics.Gpu/Image/TextureScaleMode.cs2
-rw-r--r--src/Ryujinx.Graphics.Gpu/Image/TextureSearchFlags.cs12
-rw-r--r--src/Ryujinx.Graphics.Gpu/Image/TextureTarget.cs53
-rw-r--r--src/Ryujinx.Graphics.Gpu/Image/TextureViewCompatibility.cs2
-rw-r--r--src/Ryujinx.Graphics.Gpu/Memory/Buffer.cs19
-rw-r--r--src/Ryujinx.Graphics.Gpu/Memory/BufferBounds.cs2
-rw-r--r--src/Ryujinx.Graphics.Gpu/Memory/BufferCache.cs12
-rw-r--r--src/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs6
-rw-r--r--src/Ryujinx.Graphics.Gpu/Memory/BufferModifiedRangeList.cs9
-rw-r--r--src/Ryujinx.Graphics.Gpu/Memory/CounterCache.cs7
-rw-r--r--src/Ryujinx.Graphics.Gpu/Memory/IndexBuffer.cs2
-rw-r--r--src/Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs16
-rw-r--r--src/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs4
-rw-r--r--src/Ryujinx.Graphics.Gpu/Memory/PteKind.cs4
-rw-r--r--src/Ryujinx.Graphics.Gpu/Memory/ResourceKind.cs2
-rw-r--r--src/Ryujinx.Graphics.Gpu/Memory/VertexBuffer.cs6
-rw-r--r--src/Ryujinx.Graphics.Gpu/Shader/CachedShaderStage.cs2
-rw-r--r--src/Ryujinx.Graphics.Gpu/Shader/ComputeShaderCacheHashTable.cs5
-rw-r--r--src/Ryujinx.Graphics.Gpu/Shader/DiskCache/BackgroundDiskCacheWriter.cs2
-rw-r--r--src/Ryujinx.Graphics.Gpu/Shader/DiskCache/BinarySerializer.cs20
-rw-r--r--src/Ryujinx.Graphics.Gpu/Shader/DiskCache/CompressionAlgorithm.cs4
-rw-r--r--src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheCommon.cs2
-rw-r--r--src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheGpuAccessor.cs8
-rw-r--r--src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheGuestStorage.cs22
-rw-r--r--src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheHostStorage.cs84
-rw-r--r--src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheLoadException.cs2
-rw-r--r--src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheLoadResult.cs6
-rw-r--r--src/Ryujinx.Graphics.Gpu/Shader/DiskCache/GuestCodeAndCbData.cs2
-rw-r--r--src/Ryujinx.Graphics.Gpu/Shader/DiskCache/ParallelDiskCacheLoader.cs39
-rw-r--r--src/Ryujinx.Graphics.Gpu/Shader/DiskCache/ShaderBinarySerializer.cs9
-rw-r--r--src/Ryujinx.Graphics.Gpu/Shader/GpuAccessor.cs2
-rw-r--r--src/Ryujinx.Graphics.Gpu/Shader/GpuAccessorBase.cs9
-rw-r--r--src/Ryujinx.Graphics.Gpu/Shader/GpuAccessorState.cs2
-rw-r--r--src/Ryujinx.Graphics.Gpu/Shader/GpuChannelComputeState.cs2
-rw-r--r--src/Ryujinx.Graphics.Gpu/Shader/GpuChannelGraphicsState.cs2
-rw-r--r--src/Ryujinx.Graphics.Gpu/Shader/GpuChannelPoolState.cs9
-rw-r--r--src/Ryujinx.Graphics.Gpu/Shader/HashTable/HashState.cs6
-rw-r--r--src/Ryujinx.Graphics.Gpu/Shader/HashTable/PartitionHashTable.cs20
-rw-r--r--src/Ryujinx.Graphics.Gpu/Shader/HashTable/PartitionedHashTable.cs6
-rw-r--r--src/Ryujinx.Graphics.Gpu/Shader/HashTable/SmartDataAccessor.cs4
-rw-r--r--src/Ryujinx.Graphics.Gpu/Shader/ResourceCounts.cs2
-rw-r--r--src/Ryujinx.Graphics.Gpu/Shader/ShaderAddresses.cs20
-rw-r--r--src/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs34
-rw-r--r--src/Ryujinx.Graphics.Gpu/Shader/ShaderCacheHashTable.cs20
-rw-r--r--src/Ryujinx.Graphics.Gpu/Shader/ShaderCacheState.cs4
-rw-r--r--src/Ryujinx.Graphics.Gpu/Shader/ShaderCodeAccessor.cs2
-rw-r--r--src/Ryujinx.Graphics.Gpu/Shader/ShaderDumpPaths.cs2
-rw-r--r--src/Ryujinx.Graphics.Gpu/Shader/ShaderDumper.cs10
-rw-r--r--src/Ryujinx.Graphics.Gpu/Shader/ShaderInfoBuilder.cs12
-rw-r--r--src/Ryujinx.Graphics.Gpu/Shader/ShaderSpecializationList.cs4
-rw-r--r--src/Ryujinx.Graphics.Gpu/Shader/ShaderSpecializationState.cs16
-rw-r--r--src/Ryujinx.Graphics.Gpu/Shader/TransformFeedbackDescriptor.cs2
-rw-r--r--src/Ryujinx.Graphics.Gpu/Synchronization/HostSyncFlags.cs2
-rw-r--r--src/Ryujinx.Graphics.Gpu/Synchronization/SynchronizationManager.cs30
-rw-r--r--src/Ryujinx.Graphics.Gpu/Synchronization/Syncpoint.cs11
-rw-r--r--src/Ryujinx.Graphics.Gpu/Window.cs54
145 files changed, 1443 insertions, 1425 deletions
diff --git a/src/Ryujinx.Graphics.Gpu/ClassId.cs b/src/Ryujinx.Graphics.Gpu/ClassId.cs
index 4e475a24..7c1d1e46 100644
--- a/src/Ryujinx.Graphics.Gpu/ClassId.cs
+++ b/src/Ryujinx.Graphics.Gpu/ClassId.cs
@@ -10,6 +10,6 @@ namespace Ryujinx.Graphics.Gpu
Compute = 0xb1c0,
InlineToMemory = 0xa140,
Dma = 0xb0b5,
- GPFifo = 0xb06f
+ GPFifo = 0xb06f,
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Constants.cs b/src/Ryujinx.Graphics.Gpu/Constants.cs
index ff90e61b..c553d988 100644
--- a/src/Ryujinx.Graphics.Gpu/Constants.cs
+++ b/src/Ryujinx.Graphics.Gpu/Constants.cs
@@ -90,4 +90,4 @@ namespace Ryujinx.Graphics.Gpu
/// </summary>
public const ulong MaxUnknownStorageSize = 0x100000;
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Compute/ComputeClass.cs b/src/Ryujinx.Graphics.Gpu/Engine/Compute/ComputeClass.cs
index d8103ac7..67743de3 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Compute/ComputeClass.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Compute/ComputeClass.cs
@@ -1,9 +1,7 @@
using Ryujinx.Graphics.Device;
-using Ryujinx.Graphics.GAL;
using Ryujinx.Graphics.Gpu.Engine.InlineToMemory;
using Ryujinx.Graphics.Gpu.Engine.Threed;
using Ryujinx.Graphics.Gpu.Engine.Types;
-using Ryujinx.Graphics.Gpu.Image;
using Ryujinx.Graphics.Gpu.Shader;
using Ryujinx.Graphics.Shader;
using System;
@@ -39,7 +37,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
{
{ nameof(ComputeClassState.LaunchDma), new RwCallback(LaunchDma, null) },
{ nameof(ComputeClassState.LoadInlineData), new RwCallback(LoadInlineData, null) },
- { nameof(ComputeClassState.SendSignalingPcasB), new RwCallback(SendSignalingPcasB, null) }
+ { nameof(ComputeClassState.SendSignalingPcasB), new RwCallback(SendSignalingPcasB, null) },
});
_i2mClass = new InlineToMemoryClass(context, channel, initializeState: false);
@@ -128,12 +126,12 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
ulong samplerPoolGpuVa = ((ulong)_state.State.SetTexSamplerPoolAOffsetUpper << 32) | _state.State.SetTexSamplerPoolB;
ulong texturePoolGpuVa = ((ulong)_state.State.SetTexHeaderPoolAOffsetUpper << 32) | _state.State.SetTexHeaderPoolB;
- GpuChannelPoolState poolState = new GpuChannelPoolState(
+ GpuChannelPoolState poolState = new(
texturePoolGpuVa,
_state.State.SetTexHeaderPoolCMaximumIndex,
_state.State.SetBindlessTextureConstantBufferSlotSelect);
- GpuChannelComputeState computeState = new GpuChannelComputeState(
+ GpuChannelComputeState computeState = new(
qmd.CtaThreadDimension0,
qmd.CtaThreadDimension1,
qmd.CtaThreadDimension2,
@@ -189,8 +187,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
cs = memoryManager.Physical.ShaderCache.GetComputeShader(_channel, poolState, computeState, shaderGpuVa);
_context.Renderer.Pipeline.SetProgram(cs.HostProgram);
-
- info = cs.Shaders[0].Info;
}
_channel.BufferManager.SetComputeBufferBindings(cs.Bindings);
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Compute/ComputeClassState.cs b/src/Ryujinx.Graphics.Gpu/Engine/Compute/ComputeClassState.cs
index 73dd31b2..0b192ef6 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Compute/ComputeClassState.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Compute/ComputeClassState.cs
@@ -98,24 +98,24 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
/// </summary>
unsafe struct ComputeClassState
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public uint SetObject;
- public int SetObjectClassId => (int)(SetObject & 0xFFFF);
- public int SetObjectEngineId => (int)((SetObject >> 16) & 0x1F);
+ public readonly int SetObjectClassId => (int)(SetObject & 0xFFFF);
+ public readonly int SetObjectEngineId => (int)((SetObject >> 16) & 0x1F);
public fixed uint Reserved04[63];
public uint NoOperation;
public uint SetNotifyA;
- public int SetNotifyAAddressUpper => (int)(SetNotifyA & 0xFF);
+ public readonly int SetNotifyAAddressUpper => (int)(SetNotifyA & 0xFF);
public uint SetNotifyB;
public uint Notify;
- public NotifyType NotifyType => (NotifyType)(Notify);
+ public readonly NotifyType NotifyType => (NotifyType)(Notify);
public uint WaitForIdle;
public fixed uint Reserved114[7];
public uint SetGlobalRenderEnableA;
- public int SetGlobalRenderEnableAOffsetUpper => (int)(SetGlobalRenderEnableA & 0xFF);
+ public readonly int SetGlobalRenderEnableAOffsetUpper => (int)(SetGlobalRenderEnableA & 0xFF);
public uint SetGlobalRenderEnableB;
public uint SetGlobalRenderEnableC;
- public int SetGlobalRenderEnableCMode => (int)(SetGlobalRenderEnableC & 0x7);
+ public readonly int SetGlobalRenderEnableCMode => (int)(SetGlobalRenderEnableC & 0x7);
public uint SendGoIdle;
public uint PmTrigger;
public uint PmTriggerWfi;
@@ -126,34 +126,34 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
public uint LineLengthIn;
public uint LineCount;
public uint OffsetOutUpper;
- public int OffsetOutUpperValue => (int)(OffsetOutUpper & 0xFF);
+ public readonly int OffsetOutUpperValue => (int)(OffsetOutUpper & 0xFF);
public uint OffsetOut;
public uint PitchOut;
public uint SetDstBlockSize;
- public SetDstBlockSizeWidth SetDstBlockSizeWidth => (SetDstBlockSizeWidth)(SetDstBlockSize & 0xF);
- public SetDstBlockSizeHeight SetDstBlockSizeHeight => (SetDstBlockSizeHeight)((SetDstBlockSize >> 4) & 0xF);
- public SetDstBlockSizeDepth SetDstBlockSizeDepth => (SetDstBlockSizeDepth)((SetDstBlockSize >> 8) & 0xF);
+ public readonly SetDstBlockSizeWidth SetDstBlockSizeWidth => (SetDstBlockSizeWidth)(SetDstBlockSize & 0xF);
+ public readonly SetDstBlockSizeHeight SetDstBlockSizeHeight => (SetDstBlockSizeHeight)((SetDstBlockSize >> 4) & 0xF);
+ public readonly SetDstBlockSizeDepth SetDstBlockSizeDepth => (SetDstBlockSizeDepth)((SetDstBlockSize >> 8) & 0xF);
public uint SetDstWidth;
public uint SetDstHeight;
public uint SetDstDepth;
public uint SetDstLayer;
public uint SetDstOriginBytesX;
- public int SetDstOriginBytesXV => (int)(SetDstOriginBytesX & 0xFFFFF);
+ public readonly int SetDstOriginBytesXV => (int)(SetDstOriginBytesX & 0xFFFFF);
public uint SetDstOriginSamplesY;
- public int SetDstOriginSamplesYV => (int)(SetDstOriginSamplesY & 0xFFFF);
+ public readonly int SetDstOriginSamplesYV => (int)(SetDstOriginSamplesY & 0xFFFF);
public uint LaunchDma;
- public LaunchDmaDstMemoryLayout LaunchDmaDstMemoryLayout => (LaunchDmaDstMemoryLayout)(LaunchDma & 0x1);
- public LaunchDmaCompletionType LaunchDmaCompletionType => (LaunchDmaCompletionType)((LaunchDma >> 4) & 0x3);
- public LaunchDmaInterruptType LaunchDmaInterruptType => (LaunchDmaInterruptType)((LaunchDma >> 8) & 0x3);
- public LaunchDmaSemaphoreStructSize LaunchDmaSemaphoreStructSize => (LaunchDmaSemaphoreStructSize)((LaunchDma >> 12) & 0x1);
- public bool LaunchDmaReductionEnable => (LaunchDma & 0x2) != 0;
- public LaunchDmaReductionOp LaunchDmaReductionOp => (LaunchDmaReductionOp)((LaunchDma >> 13) & 0x7);
- public LaunchDmaReductionFormat LaunchDmaReductionFormat => (LaunchDmaReductionFormat)((LaunchDma >> 2) & 0x3);
- public bool LaunchDmaSysmembarDisable => (LaunchDma & 0x40) != 0;
+ public readonly LaunchDmaDstMemoryLayout LaunchDmaDstMemoryLayout => (LaunchDmaDstMemoryLayout)(LaunchDma & 0x1);
+ public readonly LaunchDmaCompletionType LaunchDmaCompletionType => (LaunchDmaCompletionType)((LaunchDma >> 4) & 0x3);
+ public readonly LaunchDmaInterruptType LaunchDmaInterruptType => (LaunchDmaInterruptType)((LaunchDma >> 8) & 0x3);
+ public readonly LaunchDmaSemaphoreStructSize LaunchDmaSemaphoreStructSize => (LaunchDmaSemaphoreStructSize)((LaunchDma >> 12) & 0x1);
+ public readonly bool LaunchDmaReductionEnable => (LaunchDma & 0x2) != 0;
+ public readonly LaunchDmaReductionOp LaunchDmaReductionOp => (LaunchDmaReductionOp)((LaunchDma >> 13) & 0x7);
+ public readonly LaunchDmaReductionFormat LaunchDmaReductionFormat => (LaunchDmaReductionFormat)((LaunchDma >> 2) & 0x3);
+ public readonly bool LaunchDmaSysmembarDisable => (LaunchDma & 0x40) != 0;
public uint LoadInlineData;
public fixed uint Reserved1B8[9];
public uint SetI2mSemaphoreA;
- public int SetI2mSemaphoreAOffsetUpper => (int)(SetI2mSemaphoreA & 0xFF);
+ public readonly int SetI2mSemaphoreAOffsetUpper => (int)(SetI2mSemaphoreA & 0xFF);
public uint SetI2mSemaphoreB;
public uint SetI2mSemaphoreC;
public fixed uint Reserved1E8[2];
@@ -162,20 +162,20 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
public uint SetI2mSpareNoop02;
public uint SetI2mSpareNoop03;
public uint SetValidSpanOverflowAreaA;
- public int SetValidSpanOverflowAreaAAddressUpper => (int)(SetValidSpanOverflowAreaA & 0xFF);
+ public readonly int SetValidSpanOverflowAreaAAddressUpper => (int)(SetValidSpanOverflowAreaA & 0xFF);
public uint SetValidSpanOverflowAreaB;
public uint SetValidSpanOverflowAreaC;
public uint SetCoalesceWaitingPeriodUnit;
public uint PerfmonTransfer;
public uint SetShaderSharedMemoryWindow;
public uint SetSelectMaxwellTextureHeaders;
- public bool SetSelectMaxwellTextureHeadersV => (SetSelectMaxwellTextureHeaders & 0x1) != 0;
+ public readonly bool SetSelectMaxwellTextureHeadersV => (SetSelectMaxwellTextureHeaders & 0x1) != 0;
public uint InvalidateShaderCaches;
- public bool InvalidateShaderCachesInstruction => (InvalidateShaderCaches & 0x1) != 0;
- public bool InvalidateShaderCachesData => (InvalidateShaderCaches & 0x10) != 0;
- public bool InvalidateShaderCachesConstant => (InvalidateShaderCaches & 0x1000) != 0;
- public bool InvalidateShaderCachesLocks => (InvalidateShaderCaches & 0x2) != 0;
- public bool InvalidateShaderCachesFlushData => (InvalidateShaderCaches & 0x4) != 0;
+ public readonly bool InvalidateShaderCachesInstruction => (InvalidateShaderCaches & 0x1) != 0;
+ public readonly bool InvalidateShaderCachesData => (InvalidateShaderCaches & 0x10) != 0;
+ public readonly bool InvalidateShaderCachesConstant => (InvalidateShaderCaches & 0x1000) != 0;
+ public readonly bool InvalidateShaderCachesLocks => (InvalidateShaderCaches & 0x2) != 0;
+ public readonly bool InvalidateShaderCachesFlushData => (InvalidateShaderCaches & 0x4) != 0;
public uint SetReservedSwMethod00;
public uint SetReservedSwMethod01;
public uint SetReservedSwMethod02;
@@ -185,13 +185,13 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
public uint SetReservedSwMethod06;
public uint SetReservedSwMethod07;
public uint SetCwdControl;
- public SetCwdControlSmSelection SetCwdControlSmSelection => (SetCwdControlSmSelection)(SetCwdControl & 0x1);
+ public readonly SetCwdControlSmSelection SetCwdControlSmSelection => (SetCwdControlSmSelection)(SetCwdControl & 0x1);
public uint InvalidateTextureHeaderCacheNoWfi;
- public InvalidateCacheLines InvalidateTextureHeaderCacheNoWfiLines => (InvalidateCacheLines)(InvalidateTextureHeaderCacheNoWfi & 0x1);
- public int InvalidateTextureHeaderCacheNoWfiTag => (int)((InvalidateTextureHeaderCacheNoWfi >> 4) & 0x3FFFFF);
+ public readonly InvalidateCacheLines InvalidateTextureHeaderCacheNoWfiLines => (InvalidateCacheLines)(InvalidateTextureHeaderCacheNoWfi & 0x1);
+ public readonly int InvalidateTextureHeaderCacheNoWfiTag => (int)((InvalidateTextureHeaderCacheNoWfi >> 4) & 0x3FFFFF);
public uint SetCwdRefCounter;
- public int SetCwdRefCounterSelect => (int)(SetCwdRefCounter & 0x3F);
- public int SetCwdRefCounterValue => (int)((SetCwdRefCounter >> 8) & 0xFFFF);
+ public readonly int SetCwdRefCounterSelect => (int)(SetCwdRefCounter & 0x3F);
+ public readonly int SetCwdRefCounterValue => (int)((SetCwdRefCounter >> 8) & 0xFFFF);
public uint SetReservedSwMethod08;
public uint SetReservedSwMethod09;
public uint SetReservedSwMethod10;
@@ -201,59 +201,59 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
public uint SetReservedSwMethod14;
public uint SetReservedSwMethod15;
public uint SetGwcScgType;
- public SetGwcScgTypeScgType SetGwcScgTypeScgType => (SetGwcScgTypeScgType)(SetGwcScgType & 0x1);
+ public readonly SetGwcScgTypeScgType SetGwcScgTypeScgType => (SetGwcScgTypeScgType)(SetGwcScgType & 0x1);
public uint SetScgControl;
- public int SetScgControlCompute1MaxSmCount => (int)(SetScgControl & 0x1FF);
+ public readonly int SetScgControlCompute1MaxSmCount => (int)(SetScgControl & 0x1FF);
public uint InvalidateConstantBufferCacheA;
- public int InvalidateConstantBufferCacheAAddressUpper => (int)(InvalidateConstantBufferCacheA & 0xFF);
+ public readonly int InvalidateConstantBufferCacheAAddressUpper => (int)(InvalidateConstantBufferCacheA & 0xFF);
public uint InvalidateConstantBufferCacheB;
public uint InvalidateConstantBufferCacheC;
- public int InvalidateConstantBufferCacheCByteCount => (int)(InvalidateConstantBufferCacheC & 0x1FFFF);
- public bool InvalidateConstantBufferCacheCThruL2 => (InvalidateConstantBufferCacheC & 0x80000000) != 0;
+ public readonly int InvalidateConstantBufferCacheCByteCount => (int)(InvalidateConstantBufferCacheC & 0x1FFFF);
+ public readonly bool InvalidateConstantBufferCacheCThruL2 => (InvalidateConstantBufferCacheC & 0x80000000) != 0;
public uint SetComputeClassVersion;
- public int SetComputeClassVersionCurrent => (int)(SetComputeClassVersion & 0xFFFF);
- public int SetComputeClassVersionOldestSupported => (int)((SetComputeClassVersion >> 16) & 0xFFFF);
+ public readonly int SetComputeClassVersionCurrent => (int)(SetComputeClassVersion & 0xFFFF);
+ public readonly int SetComputeClassVersionOldestSupported => (int)((SetComputeClassVersion >> 16) & 0xFFFF);
public uint CheckComputeClassVersion;
- public int CheckComputeClassVersionCurrent => (int)(CheckComputeClassVersion & 0xFFFF);
- public int CheckComputeClassVersionOldestSupported => (int)((CheckComputeClassVersion >> 16) & 0xFFFF);
+ public readonly int CheckComputeClassVersionCurrent => (int)(CheckComputeClassVersion & 0xFFFF);
+ public readonly int CheckComputeClassVersionOldestSupported => (int)((CheckComputeClassVersion >> 16) & 0xFFFF);
public uint SetQmdVersion;
- public int SetQmdVersionCurrent => (int)(SetQmdVersion & 0xFFFF);
- public int SetQmdVersionOldestSupported => (int)((SetQmdVersion >> 16) & 0xFFFF);
+ public readonly int SetQmdVersionCurrent => (int)(SetQmdVersion & 0xFFFF);
+ public readonly int SetQmdVersionOldestSupported => (int)((SetQmdVersion >> 16) & 0xFFFF);
public uint SetWfiConfig;
- public bool SetWfiConfigEnableScgTypeWfi => (SetWfiConfig & 0x1) != 0;
+ public readonly bool SetWfiConfigEnableScgTypeWfi => (SetWfiConfig & 0x1) != 0;
public uint CheckQmdVersion;
- public int CheckQmdVersionCurrent => (int)(CheckQmdVersion & 0xFFFF);
- public int CheckQmdVersionOldestSupported => (int)((CheckQmdVersion >> 16) & 0xFFFF);
+ public readonly int CheckQmdVersionCurrent => (int)(CheckQmdVersion & 0xFFFF);
+ public readonly int CheckQmdVersionOldestSupported => (int)((CheckQmdVersion >> 16) & 0xFFFF);
public uint WaitForIdleScgType;
public uint InvalidateSkedCaches;
- public bool InvalidateSkedCachesV => (InvalidateSkedCaches & 0x1) != 0;
+ public readonly bool InvalidateSkedCachesV => (InvalidateSkedCaches & 0x1) != 0;
public uint SetScgRenderEnableControl;
- public bool SetScgRenderEnableControlCompute1UsesRenderEnable => (SetScgRenderEnableControl & 0x1) != 0;
+ public readonly bool SetScgRenderEnableControlCompute1UsesRenderEnable => (SetScgRenderEnableControl & 0x1) != 0;
public fixed uint Reserved2A0[4];
public uint SetCwdSlotCount;
- public int SetCwdSlotCountV => (int)(SetCwdSlotCount & 0xFF);
+ public readonly int SetCwdSlotCountV => (int)(SetCwdSlotCount & 0xFF);
public uint SendPcasA;
public uint SendPcasB;
- public int SendPcasBFrom => (int)(SendPcasB & 0xFFFFFF);
- public int SendPcasBDelta => (int)((SendPcasB >> 24) & 0xFF);
+ public readonly int SendPcasBFrom => (int)(SendPcasB & 0xFFFFFF);
+ public readonly int SendPcasBDelta => (int)((SendPcasB >> 24) & 0xFF);
public uint SendSignalingPcasB;
- public bool SendSignalingPcasBInvalidate => (SendSignalingPcasB & 0x1) != 0;
- public bool SendSignalingPcasBSchedule => (SendSignalingPcasB & 0x2) != 0;
+ public readonly bool SendSignalingPcasBInvalidate => (SendSignalingPcasB & 0x1) != 0;
+ public readonly bool SendSignalingPcasBSchedule => (SendSignalingPcasB & 0x2) != 0;
public fixed uint Reserved2C0[9];
public uint SetShaderLocalMemoryNonThrottledA;
- public int SetShaderLocalMemoryNonThrottledASizeUpper => (int)(SetShaderLocalMemoryNonThrottledA & 0xFF);
+ public readonly int SetShaderLocalMemoryNonThrottledASizeUpper => (int)(SetShaderLocalMemoryNonThrottledA & 0xFF);
public uint SetShaderLocalMemoryNonThrottledB;
public uint SetShaderLocalMemoryNonThrottledC;
- public int SetShaderLocalMemoryNonThrottledCMaxSmCount => (int)(SetShaderLocalMemoryNonThrottledC & 0x1FF);
+ public readonly int SetShaderLocalMemoryNonThrottledCMaxSmCount => (int)(SetShaderLocalMemoryNonThrottledC & 0x1FF);
public uint SetShaderLocalMemoryThrottledA;
- public int SetShaderLocalMemoryThrottledASizeUpper => (int)(SetShaderLocalMemoryThrottledA & 0xFF);
+ public readonly int SetShaderLocalMemoryThrottledASizeUpper => (int)(SetShaderLocalMemoryThrottledA & 0xFF);
public uint SetShaderLocalMemoryThrottledB;
public uint SetShaderLocalMemoryThrottledC;
- public int SetShaderLocalMemoryThrottledCMaxSmCount => (int)(SetShaderLocalMemoryThrottledC & 0x1FF);
+ public readonly int SetShaderLocalMemoryThrottledCMaxSmCount => (int)(SetShaderLocalMemoryThrottledC & 0x1FF);
public fixed uint Reserved2FC[5];
public uint SetSpaVersion;
- public int SetSpaVersionMinor => (int)(SetSpaVersion & 0xFF);
- public int SetSpaVersionMajor => (int)((SetSpaVersion >> 8) & 0xFF);
+ public readonly int SetSpaVersionMinor => (int)(SetSpaVersion & 0xFF);
+ public readonly int SetSpaVersionMajor => (int)((SetSpaVersion >> 8) & 0xFF);
public fixed uint Reserved314[123];
public uint SetFalcon00;
public uint SetFalcon01;
@@ -291,14 +291,14 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
public uint SetShaderLocalMemoryWindow;
public fixed uint Reserved780[4];
public uint SetShaderLocalMemoryA;
- public int SetShaderLocalMemoryAAddressUpper => (int)(SetShaderLocalMemoryA & 0xFF);
+ public readonly int SetShaderLocalMemoryAAddressUpper => (int)(SetShaderLocalMemoryA & 0xFF);
public uint SetShaderLocalMemoryB;
public fixed uint Reserved798[383];
public uint SetShaderCacheControl;
- public bool SetShaderCacheControlIcachePrefetchEnable => (SetShaderCacheControl & 0x1) != 0;
+ public readonly bool SetShaderCacheControlIcachePrefetchEnable => (SetShaderCacheControl & 0x1) != 0;
public fixed uint ReservedD98[19];
public uint SetSmTimeoutInterval;
- public int SetSmTimeoutIntervalCounterBit => (int)(SetSmTimeoutInterval & 0x3F);
+ public readonly int SetSmTimeoutIntervalCounterBit => (int)(SetSmTimeoutInterval & 0x3F);
public fixed uint ReservedDE8[87];
public uint SetSpareNoop12;
public uint SetSpareNoop13;
@@ -319,62 +319,62 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
public uint SetSpareNoop11;
public fixed uint Reserved1070[103];
public uint InvalidateSamplerCacheAll;
- public bool InvalidateSamplerCacheAllV => (InvalidateSamplerCacheAll & 0x1) != 0;
+ public readonly bool InvalidateSamplerCacheAllV => (InvalidateSamplerCacheAll & 0x1) != 0;
public uint InvalidateTextureHeaderCacheAll;
- public bool InvalidateTextureHeaderCacheAllV => (InvalidateTextureHeaderCacheAll & 0x1) != 0;
+ public readonly bool InvalidateTextureHeaderCacheAllV => (InvalidateTextureHeaderCacheAll & 0x1) != 0;
public fixed uint Reserved1214[29];
public uint InvalidateTextureDataCacheNoWfi;
- public InvalidateCacheLines InvalidateTextureDataCacheNoWfiLines => (InvalidateCacheLines)(InvalidateTextureDataCacheNoWfi & 0x1);
- public int InvalidateTextureDataCacheNoWfiTag => (int)((InvalidateTextureDataCacheNoWfi >> 4) & 0x3FFFFF);
+ public readonly InvalidateCacheLines InvalidateTextureDataCacheNoWfiLines => (InvalidateCacheLines)(InvalidateTextureDataCacheNoWfi & 0x1);
+ public readonly int InvalidateTextureDataCacheNoWfiTag => (int)((InvalidateTextureDataCacheNoWfi >> 4) & 0x3FFFFF);
public fixed uint Reserved128C[7];
public uint ActivatePerfSettingsForComputeContext;
- public bool ActivatePerfSettingsForComputeContextAll => (ActivatePerfSettingsForComputeContext & 0x1) != 0;
+ public readonly bool ActivatePerfSettingsForComputeContextAll => (ActivatePerfSettingsForComputeContext & 0x1) != 0;
public fixed uint Reserved12AC[33];
public uint InvalidateSamplerCache;
- public InvalidateCacheLines InvalidateSamplerCacheLines => (InvalidateCacheLines)(InvalidateSamplerCache & 0x1);
- public int InvalidateSamplerCacheTag => (int)((InvalidateSamplerCache >> 4) & 0x3FFFFF);
+ public readonly InvalidateCacheLines InvalidateSamplerCacheLines => (InvalidateCacheLines)(InvalidateSamplerCache & 0x1);
+ public readonly int InvalidateSamplerCacheTag => (int)((InvalidateSamplerCache >> 4) & 0x3FFFFF);
public uint InvalidateTextureHeaderCache;
- public InvalidateCacheLines InvalidateTextureHeaderCacheLines => (InvalidateCacheLines)(InvalidateTextureHeaderCache & 0x1);
- public int InvalidateTextureHeaderCacheTag => (int)((InvalidateTextureHeaderCache >> 4) & 0x3FFFFF);
+ public readonly InvalidateCacheLines InvalidateTextureHeaderCacheLines => (InvalidateCacheLines)(InvalidateTextureHeaderCache & 0x1);
+ public readonly int InvalidateTextureHeaderCacheTag => (int)((InvalidateTextureHeaderCache >> 4) & 0x3FFFFF);
public uint InvalidateTextureDataCache;
- public InvalidateCacheLines InvalidateTextureDataCacheLines => (InvalidateCacheLines)(InvalidateTextureDataCache & 0x1);
- public int InvalidateTextureDataCacheTag => (int)((InvalidateTextureDataCache >> 4) & 0x3FFFFF);
+ public readonly InvalidateCacheLines InvalidateTextureDataCacheLines => (InvalidateCacheLines)(InvalidateTextureDataCache & 0x1);
+ public readonly int InvalidateTextureDataCacheTag => (int)((InvalidateTextureDataCache >> 4) & 0x3FFFFF);
public fixed uint Reserved133C[58];
public uint InvalidateSamplerCacheNoWfi;
- public InvalidateCacheLines InvalidateSamplerCacheNoWfiLines => (InvalidateCacheLines)(InvalidateSamplerCacheNoWfi & 0x1);
- public int InvalidateSamplerCacheNoWfiTag => (int)((InvalidateSamplerCacheNoWfi >> 4) & 0x3FFFFF);
+ public readonly InvalidateCacheLines InvalidateSamplerCacheNoWfiLines => (InvalidateCacheLines)(InvalidateSamplerCacheNoWfi & 0x1);
+ public readonly int InvalidateSamplerCacheNoWfiTag => (int)((InvalidateSamplerCacheNoWfi >> 4) & 0x3FFFFF);
public fixed uint Reserved1428[64];
public uint SetShaderExceptions;
- public bool SetShaderExceptionsEnable => (SetShaderExceptions & 0x1) != 0;
+ public readonly bool SetShaderExceptionsEnable => (SetShaderExceptions & 0x1) != 0;
public fixed uint Reserved152C[9];
public uint SetRenderEnableA;
- public int SetRenderEnableAOffsetUpper => (int)(SetRenderEnableA & 0xFF);
+ public readonly int SetRenderEnableAOffsetUpper => (int)(SetRenderEnableA & 0xFF);
public uint SetRenderEnableB;
public uint SetRenderEnableC;
- public int SetRenderEnableCMode => (int)(SetRenderEnableC & 0x7);
+ public readonly int SetRenderEnableCMode => (int)(SetRenderEnableC & 0x7);
public uint SetTexSamplerPoolA;
- public int SetTexSamplerPoolAOffsetUpper => (int)(SetTexSamplerPoolA & 0xFF);
+ public readonly int SetTexSamplerPoolAOffsetUpper => (int)(SetTexSamplerPoolA & 0xFF);
public uint SetTexSamplerPoolB;
public uint SetTexSamplerPoolC;
- public int SetTexSamplerPoolCMaximumIndex => (int)(SetTexSamplerPoolC & 0xFFFFF);
+ public readonly int SetTexSamplerPoolCMaximumIndex => (int)(SetTexSamplerPoolC & 0xFFFFF);
public fixed uint Reserved1568[3];
public uint SetTexHeaderPoolA;
- public int SetTexHeaderPoolAOffsetUpper => (int)(SetTexHeaderPoolA & 0xFF);
+ public readonly int SetTexHeaderPoolAOffsetUpper => (int)(SetTexHeaderPoolA & 0xFF);
public uint SetTexHeaderPoolB;
public uint SetTexHeaderPoolC;
- public int SetTexHeaderPoolCMaximumIndex => (int)(SetTexHeaderPoolC & 0x3FFFFF);
+ public readonly int SetTexHeaderPoolCMaximumIndex => (int)(SetTexHeaderPoolC & 0x3FFFFF);
public fixed uint Reserved1580[34];
public uint SetProgramRegionA;
- public int SetProgramRegionAAddressUpper => (int)(SetProgramRegionA & 0xFF);
+ public readonly int SetProgramRegionAAddressUpper => (int)(SetProgramRegionA & 0xFF);
public uint SetProgramRegionB;
public fixed uint Reserved1610[34];
public uint InvalidateShaderCachesNoWfi;
- public bool InvalidateShaderCachesNoWfiInstruction => (InvalidateShaderCachesNoWfi & 0x1) != 0;
- public bool InvalidateShaderCachesNoWfiGlobalData => (InvalidateShaderCachesNoWfi & 0x10) != 0;
- public bool InvalidateShaderCachesNoWfiConstant => (InvalidateShaderCachesNoWfi & 0x1000) != 0;
+ public readonly bool InvalidateShaderCachesNoWfiInstruction => (InvalidateShaderCachesNoWfi & 0x1) != 0;
+ public readonly bool InvalidateShaderCachesNoWfiGlobalData => (InvalidateShaderCachesNoWfi & 0x10) != 0;
+ public readonly bool InvalidateShaderCachesNoWfiConstant => (InvalidateShaderCachesNoWfi & 0x1000) != 0;
public fixed uint Reserved169C[170];
public uint SetRenderEnableOverride;
- public SetRenderEnableOverrideMode SetRenderEnableOverrideMode => (SetRenderEnableOverrideMode)(SetRenderEnableOverride & 0x3);
+ public readonly SetRenderEnableOverrideMode SetRenderEnableOverrideMode => (SetRenderEnableOverrideMode)(SetRenderEnableOverride & 0x3);
public fixed uint Reserved1948[57];
public uint PipeNop;
public uint SetSpare00;
@@ -383,20 +383,20 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
public uint SetSpare03;
public fixed uint Reserved1A40[48];
public uint SetReportSemaphoreA;
- public int SetReportSemaphoreAOffsetUpper => (int)(SetReportSemaphoreA & 0xFF);
+ public readonly int SetReportSemaphoreAOffsetUpper => (int)(SetReportSemaphoreA & 0xFF);
public uint SetReportSemaphoreB;
public uint SetReportSemaphoreC;
public uint SetReportSemaphoreD;
- public SetReportSemaphoreDOperation SetReportSemaphoreDOperation => (SetReportSemaphoreDOperation)(SetReportSemaphoreD & 0x3);
- public bool SetReportSemaphoreDAwakenEnable => (SetReportSemaphoreD & 0x100000) != 0;
- public SetReportSemaphoreDStructureSize SetReportSemaphoreDStructureSize => (SetReportSemaphoreDStructureSize)((SetReportSemaphoreD >> 28) & 0x1);
- public bool SetReportSemaphoreDFlushDisable => (SetReportSemaphoreD & 0x4) != 0;
- public bool SetReportSemaphoreDReductionEnable => (SetReportSemaphoreD & 0x8) != 0;
- public SetReportSemaphoreDReductionOp SetReportSemaphoreDReductionOp => (SetReportSemaphoreDReductionOp)((SetReportSemaphoreD >> 9) & 0x7);
- public SetReportSemaphoreDReductionFormat SetReportSemaphoreDReductionFormat => (SetReportSemaphoreDReductionFormat)((SetReportSemaphoreD >> 17) & 0x3);
+ public readonly SetReportSemaphoreDOperation SetReportSemaphoreDOperation => (SetReportSemaphoreDOperation)(SetReportSemaphoreD & 0x3);
+ public readonly bool SetReportSemaphoreDAwakenEnable => (SetReportSemaphoreD & 0x100000) != 0;
+ public readonly SetReportSemaphoreDStructureSize SetReportSemaphoreDStructureSize => (SetReportSemaphoreDStructureSize)((SetReportSemaphoreD >> 28) & 0x1);
+ public readonly bool SetReportSemaphoreDFlushDisable => (SetReportSemaphoreD & 0x4) != 0;
+ public readonly bool SetReportSemaphoreDReductionEnable => (SetReportSemaphoreD & 0x8) != 0;
+ public readonly SetReportSemaphoreDReductionOp SetReportSemaphoreDReductionOp => (SetReportSemaphoreDReductionOp)((SetReportSemaphoreD >> 9) & 0x7);
+ public readonly SetReportSemaphoreDReductionFormat SetReportSemaphoreDReductionFormat => (SetReportSemaphoreDReductionFormat)((SetReportSemaphoreD >> 17) & 0x3);
public fixed uint Reserved1B10[702];
public uint SetBindlessTexture;
- public int SetBindlessTextureConstantBufferSlotSelect => (int)(SetBindlessTexture & 0x7);
+ public readonly int SetBindlessTextureConstantBufferSlotSelect => (int)(SetBindlessTexture & 0x7);
public uint SetTrapHandler;
public fixed uint Reserved2610[843];
public Array8<uint> SetShaderPerformanceCounterValueUpper;
@@ -423,13 +423,13 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
public bool SetShaderPerformanceCounterControlBWindowed(int i) => (SetShaderPerformanceCounterControlB[i] & 0x8) != 0;
public int SetShaderPerformanceCounterControlBFunc(int i) => (int)((SetShaderPerformanceCounterControlB[i] >> 4) & 0xFFFF);
public uint SetShaderPerformanceCounterTrapControl;
- public int SetShaderPerformanceCounterTrapControlMask => (int)(SetShaderPerformanceCounterTrapControl & 0xFF);
+ public readonly int SetShaderPerformanceCounterTrapControlMask => (int)(SetShaderPerformanceCounterTrapControl & 0xFF);
public uint StartShaderPerformanceCounter;
- public int StartShaderPerformanceCounterCounterMask => (int)(StartShaderPerformanceCounter & 0xFF);
+ public readonly int StartShaderPerformanceCounterCounterMask => (int)(StartShaderPerformanceCounter & 0xFF);
public uint StopShaderPerformanceCounter;
- public int StopShaderPerformanceCounterCounterMask => (int)(StopShaderPerformanceCounter & 0xFF);
+ public readonly int StopShaderPerformanceCounterCounterMask => (int)(StopShaderPerformanceCounter & 0xFF);
public fixed uint Reserved33E8[6];
- public MmeShadowScratch SetMmeShadowScratch;
+ public Array256<uint> SetMmeShadowScratch;
#pragma warning restore CS0649
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Compute/ComputeQmd.cs b/src/Ryujinx.Graphics.Gpu/Engine/Compute/ComputeQmd.cs
index 1b20e41c..4e750ff5 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Compute/ComputeQmd.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Compute/ComputeQmd.cs
@@ -10,7 +10,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
enum DependentQmdType
{
Queue,
- Grid
+ Grid,
}
/// <summary>
@@ -19,7 +19,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
enum ReleaseMembarType
{
FeNone,
- FeSysmembar
+ FeSysmembar,
}
/// <summary>
@@ -29,7 +29,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
{
L1None,
L1Sysmembar,
- L1Membar
+ L1Membar,
}
/// <summary>
@@ -38,7 +38,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
enum Fp32NanBehavior
{
Legacy,
- Fp64Compatible
+ Fp64Compatible,
}
/// <summary>
@@ -47,7 +47,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
enum Fp32F2iNanBehavior
{
PassZero,
- PassIndefinite
+ PassIndefinite,
}
/// <summary>
@@ -56,7 +56,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
enum ApiVisibleCallLimit
{
_32,
- NoCheck
+ NoCheck,
}
/// <summary>
@@ -65,7 +65,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
enum SharedMemoryBankMapping
{
FourBytesPerBank,
- EightBytesPerBank
+ EightBytesPerBank,
}
/// <summary>
@@ -74,7 +74,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
enum Fp32NarrowInstruction
{
KeepDenorms,
- FlushDenorms
+ FlushDenorms,
}
/// <summary>
@@ -84,7 +84,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
{
DirectlyAddressableMemorySize16kb,
DirectlyAddressableMemorySize32kb,
- DirectlyAddressableMemorySize48kb
+ DirectlyAddressableMemorySize48kb,
}
/// <summary>
@@ -99,7 +99,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
RedDec,
RedAnd,
RedOr,
- RedXor
+ RedXor,
}
/// <summary>
@@ -108,7 +108,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
enum ReductionFormat
{
Unsigned32,
- Signed32
+ Signed32,
}
/// <summary>
@@ -117,7 +117,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
enum StructureSize
{
FourWords,
- OneWord
+ OneWord,
}
/// <summary>
@@ -127,129 +127,129 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
{
private fixed int _words[64];
- public int OuterPut => BitRange(30, 0);
- public bool OuterOverflow => Bit(31);
- public int OuterGet => BitRange(62, 32);
- public bool OuterStickyOverflow => Bit(63);
- public int InnerGet => BitRange(94, 64);
- public bool InnerOverflow => Bit(95);
- public int InnerPut => BitRange(126, 96);
- public bool InnerStickyOverflow => Bit(127);
- public int QmdReservedAA => BitRange(159, 128);
- public int DependentQmdPointer => BitRange(191, 160);
- public int QmdGroupId => BitRange(197, 192);
- public bool SmGlobalCachingEnable => Bit(198);
- public bool RunCtaInOneSmPartition => Bit(199);
- public bool IsQueue => Bit(200);
- public bool AddToHeadOfQmdGroupLinkedList => Bit(201);
- public bool SemaphoreReleaseEnable0 => Bit(202);
- public bool SemaphoreReleaseEnable1 => Bit(203);
- public bool RequireSchedulingPcas => Bit(204);
- public bool DependentQmdScheduleEnable => Bit(205);
- public DependentQmdType DependentQmdType => (DependentQmdType)BitRange(206, 206);
- public bool DependentQmdFieldCopy => Bit(207);
- public int QmdReservedB => BitRange(223, 208);
- public int CircularQueueSize => BitRange(248, 224);
- public bool QmdReservedC => Bit(249);
- public bool InvalidateTextureHeaderCache => Bit(250);
- public bool InvalidateTextureSamplerCache => Bit(251);
- public bool InvalidateTextureDataCache => Bit(252);
- public bool InvalidateShaderDataCache => Bit(253);
- public bool InvalidateInstructionCache => Bit(254);
- public bool InvalidateShaderConstantCache => Bit(255);
- public int ProgramOffset => BitRange(287, 256);
- public int CircularQueueAddrLower => BitRange(319, 288);
- public int CircularQueueAddrUpper => BitRange(327, 320);
- public int QmdReservedD => BitRange(335, 328);
- public int CircularQueueEntrySize => BitRange(351, 336);
- public int CwdReferenceCountId => BitRange(357, 352);
- public int CwdReferenceCountDeltaMinusOne => BitRange(365, 358);
- public ReleaseMembarType ReleaseMembarType => (ReleaseMembarType)BitRange(366, 366);
- public bool CwdReferenceCountIncrEnable => Bit(367);
- public CwdMembarType CwdMembarType => (CwdMembarType)BitRange(369, 368);
- public bool SequentiallyRunCtas => Bit(370);
- public bool CwdReferenceCountDecrEnable => Bit(371);
- public bool Throttled => Bit(372);
- public Fp32NanBehavior Fp32NanBehavior => (Fp32NanBehavior)BitRange(376, 376);
- public Fp32F2iNanBehavior Fp32F2iNanBehavior => (Fp32F2iNanBehavior)BitRange(377, 377);
- public ApiVisibleCallLimit ApiVisibleCallLimit => (ApiVisibleCallLimit)BitRange(378, 378);
- public SharedMemoryBankMapping SharedMemoryBankMapping => (SharedMemoryBankMapping)BitRange(379, 379);
- public SamplerIndex SamplerIndex => (SamplerIndex)BitRange(382, 382);
- public Fp32NarrowInstruction Fp32NarrowInstruction => (Fp32NarrowInstruction)BitRange(383, 383);
- public int CtaRasterWidth => BitRange(415, 384);
- public int CtaRasterHeight => BitRange(431, 416);
- public int CtaRasterDepth => BitRange(447, 432);
- public int CtaRasterWidthResume => BitRange(479, 448);
- public int CtaRasterHeightResume => BitRange(495, 480);
- public int CtaRasterDepthResume => BitRange(511, 496);
- public int QueueEntriesPerCtaMinusOne => BitRange(518, 512);
- public int CoalesceWaitingPeriod => BitRange(529, 522);
- public int SharedMemorySize => BitRange(561, 544);
- public int QmdReservedG => BitRange(575, 562);
- public int QmdVersion => BitRange(579, 576);
- public int QmdMajorVersion => BitRange(583, 580);
- public int QmdReservedH => BitRange(591, 584);
- public int CtaThreadDimension0 => BitRange(607, 592);
- public int CtaThreadDimension1 => BitRange(623, 608);
- public int CtaThreadDimension2 => BitRange(639, 624);
- public bool ConstantBufferValid(int i) => Bit(640 + i * 1);
- public int QmdReservedI => BitRange(668, 648);
- public L1Configuration L1Configuration => (L1Configuration)BitRange(671, 669);
- public int SmDisableMaskLower => BitRange(703, 672);
- public int SmDisableMaskUpper => BitRange(735, 704);
- public int Release0AddressLower => BitRange(767, 736);
- public int Release0AddressUpper => BitRange(775, 768);
- public int QmdReservedJ => BitRange(783, 776);
- public ReductionOp Release0ReductionOp => (ReductionOp)BitRange(790, 788);
- public bool QmdReservedK => Bit(791);
- public ReductionFormat Release0ReductionFormat => (ReductionFormat)BitRange(793, 792);
- public bool Release0ReductionEnable => Bit(794);
- public StructureSize Release0StructureSize => (StructureSize)BitRange(799, 799);
- public int Release0Payload => BitRange(831, 800);
- public int Release1AddressLower => BitRange(863, 832);
- public int Release1AddressUpper => BitRange(871, 864);
- public int QmdReservedL => BitRange(879, 872);
- public ReductionOp Release1ReductionOp => (ReductionOp)BitRange(886, 884);
- public bool QmdReservedM => Bit(887);
- public ReductionFormat Release1ReductionFormat => (ReductionFormat)BitRange(889, 888);
- public bool Release1ReductionEnable => Bit(890);
- public StructureSize Release1StructureSize => (StructureSize)BitRange(895, 895);
- public int Release1Payload => BitRange(927, 896);
- public int ConstantBufferAddrLower(int i) => BitRange(959 + i * 64, 928 + i * 64);
- public int ConstantBufferAddrUpper(int i) => BitRange(967 + i * 64, 960 + i * 64);
- public int ConstantBufferReservedAddr(int i) => BitRange(973 + i * 64, 968 + i * 64);
- public bool ConstantBufferInvalidate(int i) => Bit(974 + i * 64);
- public int ConstantBufferSize(int i) => BitRange(991 + i * 64, 975 + i * 64);
- public int ShaderLocalMemoryLowSize => BitRange(1463, 1440);
- public int QmdReservedN => BitRange(1466, 1464);
- public int BarrierCount => BitRange(1471, 1467);
- public int ShaderLocalMemoryHighSize => BitRange(1495, 1472);
- public int RegisterCount => BitRange(1503, 1496);
- public int ShaderLocalMemoryCrsSize => BitRange(1527, 1504);
- public int SassVersion => BitRange(1535, 1528);
- public int HwOnlyInnerGet => BitRange(1566, 1536);
- public bool HwOnlyRequireSchedulingPcas => Bit(1567);
- public int HwOnlyInnerPut => BitRange(1598, 1568);
- public bool HwOnlyScgType => Bit(1599);
- public int HwOnlySpanListHeadIndex => BitRange(1629, 1600);
- public bool QmdReservedQ => Bit(1630);
- public bool HwOnlySpanListHeadIndexValid => Bit(1631);
- public int HwOnlySkedNextQmdPointer => BitRange(1663, 1632);
- public int QmdSpareE => BitRange(1695, 1664);
- public int QmdSpareF => BitRange(1727, 1696);
- public int QmdSpareG => BitRange(1759, 1728);
- public int QmdSpareH => BitRange(1791, 1760);
- public int QmdSpareI => BitRange(1823, 1792);
- public int QmdSpareJ => BitRange(1855, 1824);
- public int QmdSpareK => BitRange(1887, 1856);
- public int QmdSpareL => BitRange(1919, 1888);
- public int QmdSpareM => BitRange(1951, 1920);
- public int QmdSpareN => BitRange(1983, 1952);
- public int DebugIdUpper => BitRange(2015, 1984);
- public int DebugIdLower => BitRange(2047, 2016);
+ public readonly int OuterPut => BitRange(30, 0);
+ public readonly bool OuterOverflow => Bit(31);
+ public readonly int OuterGet => BitRange(62, 32);
+ public readonly bool OuterStickyOverflow => Bit(63);
+ public readonly int InnerGet => BitRange(94, 64);
+ public readonly bool InnerOverflow => Bit(95);
+ public readonly int InnerPut => BitRange(126, 96);
+ public readonly bool InnerStickyOverflow => Bit(127);
+ public readonly int QmdReservedAA => BitRange(159, 128);
+ public readonly int DependentQmdPointer => BitRange(191, 160);
+ public readonly int QmdGroupId => BitRange(197, 192);
+ public readonly bool SmGlobalCachingEnable => Bit(198);
+ public readonly bool RunCtaInOneSmPartition => Bit(199);
+ public readonly bool IsQueue => Bit(200);
+ public readonly bool AddToHeadOfQmdGroupLinkedList => Bit(201);
+ public readonly bool SemaphoreReleaseEnable0 => Bit(202);
+ public readonly bool SemaphoreReleaseEnable1 => Bit(203);
+ public readonly bool RequireSchedulingPcas => Bit(204);
+ public readonly bool DependentQmdScheduleEnable => Bit(205);
+ public readonly DependentQmdType DependentQmdType => (DependentQmdType)BitRange(206, 206);
+ public readonly bool DependentQmdFieldCopy => Bit(207);
+ public readonly int QmdReservedB => BitRange(223, 208);
+ public readonly int CircularQueueSize => BitRange(248, 224);
+ public readonly bool QmdReservedC => Bit(249);
+ public readonly bool InvalidateTextureHeaderCache => Bit(250);
+ public readonly bool InvalidateTextureSamplerCache => Bit(251);
+ public readonly bool InvalidateTextureDataCache => Bit(252);
+ public readonly bool InvalidateShaderDataCache => Bit(253);
+ public readonly bool InvalidateInstructionCache => Bit(254);
+ public readonly bool InvalidateShaderConstantCache => Bit(255);
+ public readonly int ProgramOffset => BitRange(287, 256);
+ public readonly int CircularQueueAddrLower => BitRange(319, 288);
+ public readonly int CircularQueueAddrUpper => BitRange(327, 320);
+ public readonly int QmdReservedD => BitRange(335, 328);
+ public readonly int CircularQueueEntrySize => BitRange(351, 336);
+ public readonly int CwdReferenceCountId => BitRange(357, 352);
+ public readonly int CwdReferenceCountDeltaMinusOne => BitRange(365, 358);
+ public readonly ReleaseMembarType ReleaseMembarType => (ReleaseMembarType)BitRange(366, 366);
+ public readonly bool CwdReferenceCountIncrEnable => Bit(367);
+ public readonly CwdMembarType CwdMembarType => (CwdMembarType)BitRange(369, 368);
+ public readonly bool SequentiallyRunCtas => Bit(370);
+ public readonly bool CwdReferenceCountDecrEnable => Bit(371);
+ public readonly bool Throttled => Bit(372);
+ public readonly Fp32NanBehavior Fp32NanBehavior => (Fp32NanBehavior)BitRange(376, 376);
+ public readonly Fp32F2iNanBehavior Fp32F2iNanBehavior => (Fp32F2iNanBehavior)BitRange(377, 377);
+ public readonly ApiVisibleCallLimit ApiVisibleCallLimit => (ApiVisibleCallLimit)BitRange(378, 378);
+ public readonly SharedMemoryBankMapping SharedMemoryBankMapping => (SharedMemoryBankMapping)BitRange(379, 379);
+ public readonly SamplerIndex SamplerIndex => (SamplerIndex)BitRange(382, 382);
+ public readonly Fp32NarrowInstruction Fp32NarrowInstruction => (Fp32NarrowInstruction)BitRange(383, 383);
+ public readonly int CtaRasterWidth => BitRange(415, 384);
+ public readonly int CtaRasterHeight => BitRange(431, 416);
+ public readonly int CtaRasterDepth => BitRange(447, 432);
+ public readonly int CtaRasterWidthResume => BitRange(479, 448);
+ public readonly int CtaRasterHeightResume => BitRange(495, 480);
+ public readonly int CtaRasterDepthResume => BitRange(511, 496);
+ public readonly int QueueEntriesPerCtaMinusOne => BitRange(518, 512);
+ public readonly int CoalesceWaitingPeriod => BitRange(529, 522);
+ public readonly int SharedMemorySize => BitRange(561, 544);
+ public readonly int QmdReservedG => BitRange(575, 562);
+ public readonly int QmdVersion => BitRange(579, 576);
+ public readonly int QmdMajorVersion => BitRange(583, 580);
+ public readonly int QmdReservedH => BitRange(591, 584);
+ public readonly int CtaThreadDimension0 => BitRange(607, 592);
+ public readonly int CtaThreadDimension1 => BitRange(623, 608);
+ public readonly int CtaThreadDimension2 => BitRange(639, 624);
+ public readonly bool ConstantBufferValid(int i) => Bit(640 + i * 1);
+ public readonly int QmdReservedI => BitRange(668, 648);
+ public readonly L1Configuration L1Configuration => (L1Configuration)BitRange(671, 669);
+ public readonly int SmDisableMaskLower => BitRange(703, 672);
+ public readonly int SmDisableMaskUpper => BitRange(735, 704);
+ public readonly int Release0AddressLower => BitRange(767, 736);
+ public readonly int Release0AddressUpper => BitRange(775, 768);
+ public readonly int QmdReservedJ => BitRange(783, 776);
+ public readonly ReductionOp Release0ReductionOp => (ReductionOp)BitRange(790, 788);
+ public readonly bool QmdReservedK => Bit(791);
+ public readonly ReductionFormat Release0ReductionFormat => (ReductionFormat)BitRange(793, 792);
+ public readonly bool Release0ReductionEnable => Bit(794);
+ public readonly StructureSize Release0StructureSize => (StructureSize)BitRange(799, 799);
+ public readonly int Release0Payload => BitRange(831, 800);
+ public readonly int Release1AddressLower => BitRange(863, 832);
+ public readonly int Release1AddressUpper => BitRange(871, 864);
+ public readonly int QmdReservedL => BitRange(879, 872);
+ public readonly ReductionOp Release1ReductionOp => (ReductionOp)BitRange(886, 884);
+ public readonly bool QmdReservedM => Bit(887);
+ public readonly ReductionFormat Release1ReductionFormat => (ReductionFormat)BitRange(889, 888);
+ public readonly bool Release1ReductionEnable => Bit(890);
+ public readonly StructureSize Release1StructureSize => (StructureSize)BitRange(895, 895);
+ public readonly int Release1Payload => BitRange(927, 896);
+ public readonly int ConstantBufferAddrLower(int i) => BitRange(959 + i * 64, 928 + i * 64);
+ public readonly int ConstantBufferAddrUpper(int i) => BitRange(967 + i * 64, 960 + i * 64);
+ public readonly int ConstantBufferReservedAddr(int i) => BitRange(973 + i * 64, 968 + i * 64);
+ public readonly bool ConstantBufferInvalidate(int i) => Bit(974 + i * 64);
+ public readonly int ConstantBufferSize(int i) => BitRange(991 + i * 64, 975 + i * 64);
+ public readonly int ShaderLocalMemoryLowSize => BitRange(1463, 1440);
+ public readonly int QmdReservedN => BitRange(1466, 1464);
+ public readonly int BarrierCount => BitRange(1471, 1467);
+ public readonly int ShaderLocalMemoryHighSize => BitRange(1495, 1472);
+ public readonly int RegisterCount => BitRange(1503, 1496);
+ public readonly int ShaderLocalMemoryCrsSize => BitRange(1527, 1504);
+ public readonly int SassVersion => BitRange(1535, 1528);
+ public readonly int HwOnlyInnerGet => BitRange(1566, 1536);
+ public readonly bool HwOnlyRequireSchedulingPcas => Bit(1567);
+ public readonly int HwOnlyInnerPut => BitRange(1598, 1568);
+ public readonly bool HwOnlyScgType => Bit(1599);
+ public readonly int HwOnlySpanListHeadIndex => BitRange(1629, 1600);
+ public readonly bool QmdReservedQ => Bit(1630);
+ public readonly bool HwOnlySpanListHeadIndexValid => Bit(1631);
+ public readonly int HwOnlySkedNextQmdPointer => BitRange(1663, 1632);
+ public readonly int QmdSpareE => BitRange(1695, 1664);
+ public readonly int QmdSpareF => BitRange(1727, 1696);
+ public readonly int QmdSpareG => BitRange(1759, 1728);
+ public readonly int QmdSpareH => BitRange(1791, 1760);
+ public readonly int QmdSpareI => BitRange(1823, 1792);
+ public readonly int QmdSpareJ => BitRange(1855, 1824);
+ public readonly int QmdSpareK => BitRange(1887, 1856);
+ public readonly int QmdSpareL => BitRange(1919, 1888);
+ public readonly int QmdSpareM => BitRange(1951, 1920);
+ public readonly int QmdSpareN => BitRange(1983, 1952);
+ public readonly int DebugIdUpper => BitRange(2015, 1984);
+ public readonly int DebugIdLower => BitRange(2047, 2016);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- private bool Bit(int bit)
+ private readonly bool Bit(int bit)
{
if ((uint)bit >= 64 * 32)
{
@@ -260,7 +260,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- private int BitRange(int upper, int lower)
+ private readonly int BitRange(int upper, int lower)
{
if ((uint)lower >= 64 * 32)
{
@@ -272,4 +272,4 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
return (_words[lower >> 5] >> (lower & 31)) & mask;
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/ConditionalRenderEnabled.cs b/src/Ryujinx.Graphics.Gpu/Engine/ConditionalRenderEnabled.cs
index 5581b5cc..52d7f69f 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/ConditionalRenderEnabled.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/ConditionalRenderEnabled.cs
@@ -7,6 +7,6 @@
{
False,
True,
- Host
+ Host,
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Dma/DmaClass.cs b/src/Ryujinx.Graphics.Gpu/Engine/Dma/DmaClass.cs
index fd93cd8b..e6557780 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Dma/DmaClass.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Dma/DmaClass.cs
@@ -30,13 +30,13 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma
SrcLinear = 1 << 7,
DstLinear = 1 << 8,
MultiLineEnable = 1 << 9,
- RemapEnable = 1 << 10
+ RemapEnable = 1 << 10,
}
/// <summary>
/// Texture parameters for copy.
/// </summary>
- private struct TextureParams
+ private readonly struct TextureParams
{
/// <summary>
/// Copy region X coordinate.
@@ -109,7 +109,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma
_3dEngine = threedEngine;
_state = new DeviceState<DmaClassState>(new Dictionary<string, RwCallback>
{
- { nameof(DmaClassState.LaunchDma), new RwCallback(LaunchDma, null) }
+ { nameof(DmaClassState.LaunchDma), new RwCallback(LaunchDma, null) },
});
}
@@ -345,8 +345,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma
// all be rewritten to use pooled arrays, but that gets complicated with packed data and strides
Span<byte> dstSpan = memoryManager.GetSpan(dstGpuVa + (ulong)dstBaseOffset, dstSize).ToArray();
- TextureParams srcParams = new TextureParams(srcRegionX, srcRegionY, srcBaseOffset, srcBpp, srcLinear, srcCalculator);
- TextureParams dstParams = new TextureParams(dstRegionX, dstRegionY, dstBaseOffset, dstBpp, dstLinear, dstCalculator);
+ TextureParams srcParams = new(srcRegionX, srcRegionY, srcBaseOffset, srcBpp, srcLinear, srcCalculator);
+ TextureParams dstParams = new(dstRegionX, dstRegionY, dstBaseOffset, dstBpp, dstLinear, dstCalculator);
// If remapping is enabled, we always copy the components directly, in order.
// If it's enabled, but the mapping is just XYZW, we also copy them in order.
@@ -363,13 +363,26 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma
switch (srcBpp)
{
- case 1: Copy<byte>(dstSpan, srcSpan, dstParams, srcParams); break;
- case 2: Copy<ushort>(dstSpan, srcSpan, dstParams, srcParams); break;
- case 4: Copy<uint>(dstSpan, srcSpan, dstParams, srcParams); break;
- case 8: Copy<ulong>(dstSpan, srcSpan, dstParams, srcParams); break;
- case 12: Copy<Bpp12Pixel>(dstSpan, srcSpan, dstParams, srcParams); break;
- case 16: Copy<Vector128<byte>>(dstSpan, srcSpan, dstParams, srcParams); break;
- default: throw new NotSupportedException($"Unable to copy ${srcBpp} bpp pixel format.");
+ case 1:
+ Copy<byte>(dstSpan, srcSpan, dstParams, srcParams);
+ break;
+ case 2:
+ Copy<ushort>(dstSpan, srcSpan, dstParams, srcParams);
+ break;
+ case 4:
+ Copy<uint>(dstSpan, srcSpan, dstParams, srcParams);
+ break;
+ case 8:
+ Copy<ulong>(dstSpan, srcSpan, dstParams, srcParams);
+ break;
+ case 12:
+ Copy<Bpp12Pixel>(dstSpan, srcSpan, dstParams, srcParams);
+ break;
+ case 16:
+ Copy<Vector128<byte>>(dstSpan, srcSpan, dstParams, srcParams);
+ break;
+ default:
+ throw new NotSupportedException($"Unable to copy ${srcBpp} bpp pixel format.");
}
}
else
@@ -378,11 +391,20 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma
switch (componentSize)
{
- case 1: CopyShuffle<byte>(dstSpan, srcSpan, dstParams, srcParams); break;
- case 2: CopyShuffle<ushort>(dstSpan, srcSpan, dstParams, srcParams); break;
- case 3: CopyShuffle<UInt24>(dstSpan, srcSpan, dstParams, srcParams); break;
- case 4: CopyShuffle<uint>(dstSpan, srcSpan, dstParams, srcParams); break;
- default: throw new NotSupportedException($"Unable to copy ${componentSize} component size.");
+ case 1:
+ CopyShuffle<byte>(dstSpan, srcSpan, dstParams, srcParams);
+ break;
+ case 2:
+ CopyShuffle<ushort>(dstSpan, srcSpan, dstParams, srcParams);
+ break;
+ case 3:
+ CopyShuffle<UInt24>(dstSpan, srcSpan, dstParams, srcParams);
+ break;
+ case 4:
+ CopyShuffle<uint>(dstSpan, srcSpan, dstParams, srcParams);
+ break;
+ default:
+ throw new NotSupportedException($"Unable to copy ${componentSize} component size.");
}
}
@@ -526,28 +548,28 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma
0 => _state.State.SetRemapComponentsDstX,
1 => _state.State.SetRemapComponentsDstY,
2 => _state.State.SetRemapComponentsDstZ,
- _ => _state.State.SetRemapComponentsDstW
+ _ => _state.State.SetRemapComponentsDstW,
};
switch (componentsDst)
{
case SetRemapComponentsDst.SrcX:
- Copy<T>(dstSpan.Slice(Unsafe.SizeOf<T>() * i), srcSpan, dst, src);
+ Copy<T>(dstSpan[(Unsafe.SizeOf<T>() * i)..], srcSpan, dst, src);
break;
case SetRemapComponentsDst.SrcY:
- Copy<T>(dstSpan.Slice(Unsafe.SizeOf<T>() * i), srcSpan.Slice(Unsafe.SizeOf<T>()), dst, src);
+ Copy<T>(dstSpan[(Unsafe.SizeOf<T>() * i)..], srcSpan[Unsafe.SizeOf<T>()..], dst, src);
break;
case SetRemapComponentsDst.SrcZ:
- Copy<T>(dstSpan.Slice(Unsafe.SizeOf<T>() * i), srcSpan.Slice(Unsafe.SizeOf<T>() * 2), dst, src);
+ Copy<T>(dstSpan[(Unsafe.SizeOf<T>() * i)..], srcSpan[(Unsafe.SizeOf<T>() * 2)..], dst, src);
break;
case SetRemapComponentsDst.SrcW:
- Copy<T>(dstSpan.Slice(Unsafe.SizeOf<T>() * i), srcSpan.Slice(Unsafe.SizeOf<T>() * 3), dst, src);
+ Copy<T>(dstSpan[(Unsafe.SizeOf<T>() * i)..], srcSpan[(Unsafe.SizeOf<T>() * 3)..], dst, src);
break;
case SetRemapComponentsDst.ConstA:
- Fill<T>(dstSpan.Slice(Unsafe.SizeOf<T>() * i), dst, Unsafe.As<uint, T>(ref _state.State.SetRemapConstA));
+ Fill<T>(dstSpan[(Unsafe.SizeOf<T>() * i)..], dst, Unsafe.As<uint, T>(ref _state.State.SetRemapConstA));
break;
case SetRemapComponentsDst.ConstB:
- Fill<T>(dstSpan.Slice(Unsafe.SizeOf<T>() * i), dst, Unsafe.As<uint, T>(ref _state.State.SetRemapConstB));
+ Fill<T>(dstSpan[(Unsafe.SizeOf<T>() * i)..], dst, Unsafe.As<uint, T>(ref _state.State.SetRemapConstB));
break;
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Dma/DmaClassState.cs b/src/Ryujinx.Graphics.Gpu/Engine/Dma/DmaClassState.cs
index 6f3b91f2..d8588736 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Dma/DmaClassState.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Dma/DmaClassState.cs
@@ -179,49 +179,49 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma
/// </summary>
unsafe struct DmaClassState
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public fixed uint Reserved00[64];
public uint Nop;
public fixed uint Reserved104[15];
public uint PmTrigger;
public fixed uint Reserved144[63];
public uint SetSemaphoreA;
- public int SetSemaphoreAUpper => (int)(SetSemaphoreA & 0xFF);
+ public readonly int SetSemaphoreAUpper => (int)(SetSemaphoreA & 0xFF);
public uint SetSemaphoreB;
public uint SetSemaphorePayload;
public fixed uint Reserved24C[2];
public uint SetRenderEnableA;
- public int SetRenderEnableAUpper => (int)(SetRenderEnableA & 0xFF);
+ public readonly int SetRenderEnableAUpper => (int)(SetRenderEnableA & 0xFF);
public uint SetRenderEnableB;
public uint SetRenderEnableC;
- public int SetRenderEnableCMode => (int)(SetRenderEnableC & 0x7);
+ public readonly int SetRenderEnableCMode => (int)(SetRenderEnableC & 0x7);
public uint SetSrcPhysMode;
- public SetPhysModeTarget SetSrcPhysModeTarget => (SetPhysModeTarget)(SetSrcPhysMode & 0x3);
+ public readonly SetPhysModeTarget SetSrcPhysModeTarget => (SetPhysModeTarget)(SetSrcPhysMode & 0x3);
public uint SetDstPhysMode;
- public SetPhysModeTarget SetDstPhysModeTarget => (SetPhysModeTarget)(SetDstPhysMode & 0x3);
+ public readonly SetPhysModeTarget SetDstPhysModeTarget => (SetPhysModeTarget)(SetDstPhysMode & 0x3);
public fixed uint Reserved268[38];
public uint LaunchDma;
- public LaunchDmaDataTransferType LaunchDmaDataTransferType => (LaunchDmaDataTransferType)(LaunchDma & 0x3);
- public bool LaunchDmaFlushEnable => (LaunchDma & 0x4) != 0;
- public LaunchDmaSemaphoreType LaunchDmaSemaphoreType => (LaunchDmaSemaphoreType)((LaunchDma >> 3) & 0x3);
- public LaunchDmaInterruptType LaunchDmaInterruptType => (LaunchDmaInterruptType)((LaunchDma >> 5) & 0x3);
- public LaunchDmaMemoryLayout LaunchDmaSrcMemoryLayout => (LaunchDmaMemoryLayout)((LaunchDma >> 7) & 0x1);
- public LaunchDmaMemoryLayout LaunchDmaDstMemoryLayout => (LaunchDmaMemoryLayout)((LaunchDma >> 8) & 0x1);
- public bool LaunchDmaMultiLineEnable => (LaunchDma & 0x200) != 0;
- public bool LaunchDmaRemapEnable => (LaunchDma & 0x400) != 0;
- public bool LaunchDmaForceRmwdisable => (LaunchDma & 0x800) != 0;
- public LaunchDmaType LaunchDmaSrcType => (LaunchDmaType)((LaunchDma >> 12) & 0x1);
- public LaunchDmaType LaunchDmaDstType => (LaunchDmaType)((LaunchDma >> 13) & 0x1);
- public LaunchDmaSemaphoreReduction LaunchDmaSemaphoreReduction => (LaunchDmaSemaphoreReduction)((LaunchDma >> 14) & 0xF);
- public LaunchDmaSemaphoreReductionSign LaunchDmaSemaphoreReductionSign => (LaunchDmaSemaphoreReductionSign)((LaunchDma >> 18) & 0x1);
- public bool LaunchDmaSemaphoreReductionEnable => (LaunchDma & 0x80000) != 0;
- public LaunchDmaBypassL2 LaunchDmaBypassL2 => (LaunchDmaBypassL2)((LaunchDma >> 20) & 0x1);
+ public readonly LaunchDmaDataTransferType LaunchDmaDataTransferType => (LaunchDmaDataTransferType)(LaunchDma & 0x3);
+ public readonly bool LaunchDmaFlushEnable => (LaunchDma & 0x4) != 0;
+ public readonly LaunchDmaSemaphoreType LaunchDmaSemaphoreType => (LaunchDmaSemaphoreType)((LaunchDma >> 3) & 0x3);
+ public readonly LaunchDmaInterruptType LaunchDmaInterruptType => (LaunchDmaInterruptType)((LaunchDma >> 5) & 0x3);
+ public readonly LaunchDmaMemoryLayout LaunchDmaSrcMemoryLayout => (LaunchDmaMemoryLayout)((LaunchDma >> 7) & 0x1);
+ public readonly LaunchDmaMemoryLayout LaunchDmaDstMemoryLayout => (LaunchDmaMemoryLayout)((LaunchDma >> 8) & 0x1);
+ public readonly bool LaunchDmaMultiLineEnable => (LaunchDma & 0x200) != 0;
+ public readonly bool LaunchDmaRemapEnable => (LaunchDma & 0x400) != 0;
+ public readonly bool LaunchDmaForceRmwdisable => (LaunchDma & 0x800) != 0;
+ public readonly LaunchDmaType LaunchDmaSrcType => (LaunchDmaType)((LaunchDma >> 12) & 0x1);
+ public readonly LaunchDmaType LaunchDmaDstType => (LaunchDmaType)((LaunchDma >> 13) & 0x1);
+ public readonly LaunchDmaSemaphoreReduction LaunchDmaSemaphoreReduction => (LaunchDmaSemaphoreReduction)((LaunchDma >> 14) & 0xF);
+ public readonly LaunchDmaSemaphoreReductionSign LaunchDmaSemaphoreReductionSign => (LaunchDmaSemaphoreReductionSign)((LaunchDma >> 18) & 0x1);
+ public readonly bool LaunchDmaSemaphoreReductionEnable => (LaunchDma & 0x80000) != 0;
+ public readonly LaunchDmaBypassL2 LaunchDmaBypassL2 => (LaunchDmaBypassL2)((LaunchDma >> 20) & 0x1);
public fixed uint Reserved304[63];
public uint OffsetInUpper;
- public int OffsetInUpperUpper => (int)(OffsetInUpper & 0xFF);
+ public readonly int OffsetInUpperUpper => (int)(OffsetInUpper & 0xFF);
public uint OffsetInLower;
public uint OffsetOutUpper;
- public int OffsetOutUpperUpper => (int)(OffsetOutUpper & 0xFF);
+ public readonly int OffsetOutUpperUpper => (int)(OffsetOutUpper & 0xFF);
public uint OffsetOutLower;
public uint PitchIn;
public uint PitchOut;
@@ -231,38 +231,38 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma
public uint SetRemapConstA;
public uint SetRemapConstB;
public uint SetRemapComponents;
- public SetRemapComponentsDst SetRemapComponentsDstX => (SetRemapComponentsDst)(SetRemapComponents & 0x7);
- public SetRemapComponentsDst SetRemapComponentsDstY => (SetRemapComponentsDst)((SetRemapComponents >> 4) & 0x7);
- public SetRemapComponentsDst SetRemapComponentsDstZ => (SetRemapComponentsDst)((SetRemapComponents >> 8) & 0x7);
- public SetRemapComponentsDst SetRemapComponentsDstW => (SetRemapComponentsDst)((SetRemapComponents >> 12) & 0x7);
- public SetRemapComponentsComponentSize SetRemapComponentsComponentSize => (SetRemapComponentsComponentSize)((SetRemapComponents >> 16) & 0x3);
- public SetRemapComponentsNumComponents SetRemapComponentsNumSrcComponents => (SetRemapComponentsNumComponents)((SetRemapComponents >> 20) & 0x3);
- public SetRemapComponentsNumComponents SetRemapComponentsNumDstComponents => (SetRemapComponentsNumComponents)((SetRemapComponents >> 24) & 0x3);
+ public readonly SetRemapComponentsDst SetRemapComponentsDstX => (SetRemapComponentsDst)(SetRemapComponents & 0x7);
+ public readonly SetRemapComponentsDst SetRemapComponentsDstY => (SetRemapComponentsDst)((SetRemapComponents >> 4) & 0x7);
+ public readonly SetRemapComponentsDst SetRemapComponentsDstZ => (SetRemapComponentsDst)((SetRemapComponents >> 8) & 0x7);
+ public readonly SetRemapComponentsDst SetRemapComponentsDstW => (SetRemapComponentsDst)((SetRemapComponents >> 12) & 0x7);
+ public readonly SetRemapComponentsComponentSize SetRemapComponentsComponentSize => (SetRemapComponentsComponentSize)((SetRemapComponents >> 16) & 0x3);
+ public readonly SetRemapComponentsNumComponents SetRemapComponentsNumSrcComponents => (SetRemapComponentsNumComponents)((SetRemapComponents >> 20) & 0x3);
+ public readonly SetRemapComponentsNumComponents SetRemapComponentsNumDstComponents => (SetRemapComponentsNumComponents)((SetRemapComponents >> 24) & 0x3);
public uint SetDstBlockSize;
- public SetBlockSizeWidth SetDstBlockSizeWidth => (SetBlockSizeWidth)(SetDstBlockSize & 0xF);
- public SetBlockSizeHeight SetDstBlockSizeHeight => (SetBlockSizeHeight)((SetDstBlockSize >> 4) & 0xF);
- public SetBlockSizeDepth SetDstBlockSizeDepth => (SetBlockSizeDepth)((SetDstBlockSize >> 8) & 0xF);
- public SetBlockSizeGobHeight SetDstBlockSizeGobHeight => (SetBlockSizeGobHeight)((SetDstBlockSize >> 12) & 0xF);
+ public readonly SetBlockSizeWidth SetDstBlockSizeWidth => (SetBlockSizeWidth)(SetDstBlockSize & 0xF);
+ public readonly SetBlockSizeHeight SetDstBlockSizeHeight => (SetBlockSizeHeight)((SetDstBlockSize >> 4) & 0xF);
+ public readonly SetBlockSizeDepth SetDstBlockSizeDepth => (SetBlockSizeDepth)((SetDstBlockSize >> 8) & 0xF);
+ public readonly SetBlockSizeGobHeight SetDstBlockSizeGobHeight => (SetBlockSizeGobHeight)((SetDstBlockSize >> 12) & 0xF);
public uint SetDstWidth;
public uint SetDstHeight;
public uint SetDstDepth;
public uint SetDstLayer;
public uint SetDstOrigin;
- public int SetDstOriginX => (int)(SetDstOrigin & 0xFFFF);
- public int SetDstOriginY => (int)((SetDstOrigin >> 16) & 0xFFFF);
+ public readonly int SetDstOriginX => (int)(SetDstOrigin & 0xFFFF);
+ public readonly int SetDstOriginY => (int)((SetDstOrigin >> 16) & 0xFFFF);
public uint Reserved724;
public uint SetSrcBlockSize;
- public SetBlockSizeWidth SetSrcBlockSizeWidth => (SetBlockSizeWidth)(SetSrcBlockSize & 0xF);
- public SetBlockSizeHeight SetSrcBlockSizeHeight => (SetBlockSizeHeight)((SetSrcBlockSize >> 4) & 0xF);
- public SetBlockSizeDepth SetSrcBlockSizeDepth => (SetBlockSizeDepth)((SetSrcBlockSize >> 8) & 0xF);
- public SetBlockSizeGobHeight SetSrcBlockSizeGobHeight => (SetBlockSizeGobHeight)((SetSrcBlockSize >> 12) & 0xF);
+ public readonly SetBlockSizeWidth SetSrcBlockSizeWidth => (SetBlockSizeWidth)(SetSrcBlockSize & 0xF);
+ public readonly SetBlockSizeHeight SetSrcBlockSizeHeight => (SetBlockSizeHeight)((SetSrcBlockSize >> 4) & 0xF);
+ public readonly SetBlockSizeDepth SetSrcBlockSizeDepth => (SetBlockSizeDepth)((SetSrcBlockSize >> 8) & 0xF);
+ public readonly SetBlockSizeGobHeight SetSrcBlockSizeGobHeight => (SetBlockSizeGobHeight)((SetSrcBlockSize >> 12) & 0xF);
public uint SetSrcWidth;
public uint SetSrcHeight;
public uint SetSrcDepth;
public uint SetSrcLayer;
public uint SetSrcOrigin;
- public int SetSrcOriginX => (int)(SetSrcOrigin & 0xFFFF);
- public int SetSrcOriginY => (int)((SetSrcOrigin >> 16) & 0xFFFF);
+ public readonly int SetSrcOriginX => (int)(SetSrcOrigin & 0xFFFF);
+ public readonly int SetSrcOriginY => (int)((SetSrcOrigin >> 16) & 0xFFFF);
public fixed uint Reserved740[629];
public uint PmTriggerEnd;
public fixed uint Reserved1118[2490];
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Dma/DmaTexture.cs b/src/Ryujinx.Graphics.Gpu/Engine/Dma/DmaTexture.cs
index 6873ff40..8193c4a2 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Dma/DmaTexture.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Dma/DmaTexture.cs
@@ -7,7 +7,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma
/// </summary>
struct DmaTexture
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public MemoryLayout MemoryLayout;
public int Width;
public int Height;
@@ -17,4 +17,4 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma
public ushort RegionY;
#pragma warning restore CS0649
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/CompressedMethod.cs b/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/CompressedMethod.cs
index d082ee9d..afa4db5e 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/CompressedMethod.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/CompressedMethod.cs
@@ -8,7 +8,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
Grp0SetSubDevMask = 1,
Grp0StoreSubDevMask = 2,
Grp0UseSubDevMask = 3,
- Grp2NonIncMethod = 0
+ Grp2NonIncMethod = Grp0IncMethod,
}
enum SecOp
@@ -20,22 +20,22 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
ImmdDataMethod = 4,
OneInc = 5,
Reserved6 = 6,
- EndPbSegment = 7
+ EndPbSegment = 7,
}
struct CompressedMethod
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public uint Method;
#pragma warning restore CS0649
- public int MethodAddressOld => (int)((Method >> 2) & 0x7FF);
- public int MethodAddress => (int)(Method & 0xFFF);
- public int SubdeviceMask => (int)((Method >> 4) & 0xFFF);
- public int MethodSubchannel => (int)((Method >> 13) & 0x7);
- public TertOp TertOp => (TertOp)((Method >> 16) & 0x3);
- public int MethodCountOld => (int)((Method >> 18) & 0x7FF);
- public int MethodCount => (int)((Method >> 16) & 0x1FFF);
- public int ImmdData => (int)((Method >> 16) & 0x1FFF);
- public SecOp SecOp => (SecOp)((Method >> 29) & 0x7);
+ public readonly int MethodAddressOld => (int)((Method >> 2) & 0x7FF);
+ public readonly int MethodAddress => (int)(Method & 0xFFF);
+ public readonly int SubdeviceMask => (int)((Method >> 4) & 0xFFF);
+ public readonly int MethodSubchannel => (int)((Method >> 13) & 0x7);
+ public readonly TertOp TertOp => (TertOp)((Method >> 16) & 0x3);
+ public readonly int MethodCountOld => (int)((Method >> 18) & 0x7FF);
+ public readonly int MethodCount => (int)((Method >> 16) & 0x1FFF);
+ public readonly int ImmdData => (int)((Method >> 16) & 0x1FFF);
+ public readonly SecOp SecOp => (SecOp)((Method >> 29) & 0x7);
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPEntry.cs b/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPEntry.cs
index 31ba3217..81e28acf 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPEntry.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPEntry.cs
@@ -36,20 +36,20 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
struct GPEntry
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public uint Entry0;
#pragma warning restore CS0649
- public Entry0Fetch Entry0Fetch => (Entry0Fetch)(Entry0 & 0x1);
- public int Entry0Get => (int)((Entry0 >> 2) & 0x3FFFFFFF);
- public int Entry0Operand => (int)(Entry0);
-#pragma warning disable CS0649
+ public readonly Entry0Fetch Entry0Fetch => (Entry0Fetch)(Entry0 & 0x1);
+ public readonly int Entry0Get => (int)((Entry0 >> 2) & 0x3FFFFFFF);
+ public readonly int Entry0Operand => (int)(Entry0);
+#pragma warning disable CS0649 // Field is never assigned to
public uint Entry1;
#pragma warning restore CS0649
- public int Entry1GetHi => (int)(Entry1 & 0xFF);
- public Entry1Priv Entry1Priv => (Entry1Priv)((Entry1 >> 8) & 0x1);
- public Entry1Level Entry1Level => (Entry1Level)((Entry1 >> 9) & 0x1);
- public int Entry1Length => (int)((Entry1 >> 10) & 0x1FFFFF);
- public Entry1Sync Entry1Sync => (Entry1Sync)((Entry1 >> 31) & 0x1);
- public Entry1Opcode Entry1Opcode => (Entry1Opcode)(Entry1 & 0xFF);
+ public readonly int Entry1GetHi => (int)(Entry1 & 0xFF);
+ public readonly Entry1Priv Entry1Priv => (Entry1Priv)((Entry1 >> 8) & 0x1);
+ public readonly Entry1Level Entry1Level => (Entry1Level)((Entry1 >> 9) & 0x1);
+ public readonly int Entry1Length => (int)((Entry1 >> 10) & 0x1FFFFF);
+ public readonly Entry1Sync Entry1Sync => (Entry1Sync)((Entry1 >> 31) & 0x1);
+ public readonly Entry1Opcode Entry1Opcode => (Entry1Opcode)(Entry1 & 0xFF);
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoClass.cs b/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoClass.cs
index 7a11c649..4bdbd1a0 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoClass.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoClass.cs
@@ -16,7 +16,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
private readonly GPFifoProcessor _parent;
private readonly DeviceState<GPFifoClassState> _state;
- private int _previousSubChannel;
private bool _createSyncPending;
private const int MacrosCount = 0x80;
@@ -45,7 +44,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
{ nameof(GPFifoClassState.SetReference), new RwCallback(SetReference, null) },
{ nameof(GPFifoClassState.LoadMmeInstructionRam), new RwCallback(LoadMmeInstructionRam, null) },
{ nameof(GPFifoClassState.LoadMmeStartAddressRam), new RwCallback(LoadMmeStartAddressRam, null) },
- { nameof(GPFifoClassState.SetMmeShadowRamControl), new RwCallback(SetMmeShadowRamControl, null) }
+ { nameof(GPFifoClassState.SetMmeShadowRamControl), new RwCallback(SetMmeShadowRamControl, null) },
});
_macros = new Macro[MacrosCount];
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoClassState.cs b/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoClassState.cs
index ebfe1566..dd6ae1b4 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoClassState.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoClassState.cs
@@ -13,7 +13,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
Release = 2,
AcqGeq = 4,
AcqAnd = 8,
- Reduction = 16
+ Reduction = 16,
}
/// <summary>
@@ -22,7 +22,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
enum SemaphoredAcquireSwitch
{
Disabled = 0,
- Enabled = 1
+ Enabled = 1,
}
/// <summary>
@@ -31,7 +31,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
enum SemaphoredReleaseWfi
{
En = 0,
- Dis = 1
+ Dis = 1,
}
/// <summary>
@@ -40,7 +40,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
enum SemaphoredReleaseSize
{
SixteenBytes = 0,
- FourBytes = 1
+ FourBytes = 1,
}
/// <summary>
@@ -55,7 +55,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
Or = 4,
Add = 5,
Inc = 6,
- Dec = 7
+ Dec = 7,
}
/// <summary>
@@ -64,7 +64,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
enum SemaphoredFormat
{
Signed = 0,
- Unsigned = 1
+ Unsigned = 1,
}
/// <summary>
@@ -73,7 +73,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
enum MemOpCTlbInvalidatePdb
{
One = 0,
- All = 1
+ All = 1,
}
/// <summary>
@@ -82,7 +82,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
enum MemOpCTlbInvalidateGpc
{
Enable = 0,
- Disable = 1
+ Disable = 1,
}
/// <summary>
@@ -92,7 +92,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
{
VidMem = 0,
SysMemCoherent = 2,
- SysMemNoncoherent = 3
+ SysMemNoncoherent = 3,
}
/// <summary>
@@ -105,7 +105,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
L2PeermemInvalidate = 13,
L2SysmemInvalidate = 14,
L2CleanComptags = 15,
- L2FlushDirty = 16
+ L2FlushDirty = 16,
}
/// <summary>
@@ -114,7 +114,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
enum SyncpointbOperation
{
Wait = 0,
- Incr = 1
+ Incr = 1,
}
/// <summary>
@@ -123,7 +123,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
enum SyncpointbWaitSwitch
{
Dis = 0,
- En = 1
+ En = 1,
}
/// <summary>
@@ -132,7 +132,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
enum WfiScope
{
CurrentScgType = 0,
- All = 1
+ All = 1,
}
/// <summary>
@@ -143,7 +143,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
Nop = 0,
PbdmaTimeslice = 1,
RunlistTimeslice = 2,
- Tsg = 3
+ Tsg = 3,
}
/// <summary>
@@ -151,44 +151,44 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
/// </summary>
struct GPFifoClassState
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public uint SetObject;
- public int SetObjectNvclass => (int)(SetObject & 0xFFFF);
- public int SetObjectEngine => (int)((SetObject >> 16) & 0x1F);
+ public readonly int SetObjectNvclass => (int)(SetObject & 0xFFFF);
+ public readonly int SetObjectEngine => (int)((SetObject >> 16) & 0x1F);
public uint Illegal;
- public int IllegalHandle => (int)(Illegal);
+ public readonly int IllegalHandle => (int)(Illegal);
public uint Nop;
- public int NopHandle => (int)(Nop);
+ public readonly int NopHandle => (int)(Nop);
public uint Reserved0C;
public uint Semaphorea;
- public int SemaphoreaOffsetUpper => (int)(Semaphorea & 0xFF);
+ public readonly int SemaphoreaOffsetUpper => (int)(Semaphorea & 0xFF);
public uint Semaphoreb;
- public int SemaphorebOffsetLower => (int)((Semaphoreb >> 2) & 0x3FFFFFFF);
+ public readonly int SemaphorebOffsetLower => (int)((Semaphoreb >> 2) & 0x3FFFFFFF);
public uint Semaphorec;
- public int SemaphorecPayload => (int)(Semaphorec);
+ public readonly int SemaphorecPayload => (int)(Semaphorec);
public uint Semaphored;
- public SemaphoredOperation SemaphoredOperation => (SemaphoredOperation)(Semaphored & 0x1F);
- public SemaphoredAcquireSwitch SemaphoredAcquireSwitch => (SemaphoredAcquireSwitch)((Semaphored >> 12) & 0x1);
- public SemaphoredReleaseWfi SemaphoredReleaseWfi => (SemaphoredReleaseWfi)((Semaphored >> 20) & 0x1);
- public SemaphoredReleaseSize SemaphoredReleaseSize => (SemaphoredReleaseSize)((Semaphored >> 24) & 0x1);
- public SemaphoredReduction SemaphoredReduction => (SemaphoredReduction)((Semaphored >> 27) & 0xF);
- public SemaphoredFormat SemaphoredFormat => (SemaphoredFormat)((Semaphored >> 31) & 0x1);
+ public readonly SemaphoredOperation SemaphoredOperation => (SemaphoredOperation)(Semaphored & 0x1F);
+ public readonly SemaphoredAcquireSwitch SemaphoredAcquireSwitch => (SemaphoredAcquireSwitch)((Semaphored >> 12) & 0x1);
+ public readonly SemaphoredReleaseWfi SemaphoredReleaseWfi => (SemaphoredReleaseWfi)((Semaphored >> 20) & 0x1);
+ public readonly SemaphoredReleaseSize SemaphoredReleaseSize => (SemaphoredReleaseSize)((Semaphored >> 24) & 0x1);
+ public readonly SemaphoredReduction SemaphoredReduction => (SemaphoredReduction)((Semaphored >> 27) & 0xF);
+ public readonly SemaphoredFormat SemaphoredFormat => (SemaphoredFormat)((Semaphored >> 31) & 0x1);
public uint NonStallInterrupt;
- public int NonStallInterruptHandle => (int)(NonStallInterrupt);
+ public readonly int NonStallInterruptHandle => (int)(NonStallInterrupt);
public uint FbFlush;
- public int FbFlushHandle => (int)(FbFlush);
+ public readonly int FbFlushHandle => (int)(FbFlush);
public uint Reserved28;
public uint Reserved2C;
public uint MemOpC;
- public int MemOpCOperandLow => (int)((MemOpC >> 2) & 0x3FFFFFFF);
- public MemOpCTlbInvalidatePdb MemOpCTlbInvalidatePdb => (MemOpCTlbInvalidatePdb)(MemOpC & 0x1);
- public MemOpCTlbInvalidateGpc MemOpCTlbInvalidateGpc => (MemOpCTlbInvalidateGpc)((MemOpC >> 1) & 0x1);
- public MemOpCTlbInvalidateTarget MemOpCTlbInvalidateTarget => (MemOpCTlbInvalidateTarget)((MemOpC >> 10) & 0x3);
- public int MemOpCTlbInvalidateAddrLo => (int)((MemOpC >> 12) & 0xFFFFF);
+ public readonly int MemOpCOperandLow => (int)((MemOpC >> 2) & 0x3FFFFFFF);
+ public readonly MemOpCTlbInvalidatePdb MemOpCTlbInvalidatePdb => (MemOpCTlbInvalidatePdb)(MemOpC & 0x1);
+ public readonly MemOpCTlbInvalidateGpc MemOpCTlbInvalidateGpc => (MemOpCTlbInvalidateGpc)((MemOpC >> 1) & 0x1);
+ public readonly MemOpCTlbInvalidateTarget MemOpCTlbInvalidateTarget => (MemOpCTlbInvalidateTarget)((MemOpC >> 10) & 0x3);
+ public readonly int MemOpCTlbInvalidateAddrLo => (int)((MemOpC >> 12) & 0xFFFFF);
public uint MemOpD;
- public int MemOpDOperandHigh => (int)(MemOpD & 0xFF);
- public MemOpDOperation MemOpDOperation => (MemOpDOperation)((MemOpD >> 27) & 0x1F);
- public int MemOpDTlbInvalidateAddrHi => (int)(MemOpD & 0xFF);
+ public readonly int MemOpDOperandHigh => (int)(MemOpD & 0xFF);
+ public readonly MemOpDOperation MemOpDOperation => (MemOpDOperation)((MemOpD >> 27) & 0x1F);
+ public readonly int MemOpDTlbInvalidateAddrHi => (int)(MemOpD & 0xFF);
public uint Reserved38;
public uint Reserved3C;
public uint Reserved40;
@@ -196,7 +196,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
public uint Reserved48;
public uint Reserved4C;
public uint SetReference;
- public int SetReferenceCount => (int)(SetReference);
+ public readonly int SetReferenceCount => (int)(SetReference);
public uint Reserved54;
public uint Reserved58;
public uint Reserved5C;
@@ -205,17 +205,17 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
public uint Reserved68;
public uint Reserved6C;
public uint Syncpointa;
- public int SyncpointaPayload => (int)(Syncpointa);
+ public readonly int SyncpointaPayload => (int)(Syncpointa);
public uint Syncpointb;
- public SyncpointbOperation SyncpointbOperation => (SyncpointbOperation)(Syncpointb & 0x1);
- public SyncpointbWaitSwitch SyncpointbWaitSwitch => (SyncpointbWaitSwitch)((Syncpointb >> 4) & 0x1);
- public int SyncpointbSyncptIndex => (int)((Syncpointb >> 8) & 0xFFF);
+ public readonly SyncpointbOperation SyncpointbOperation => (SyncpointbOperation)(Syncpointb & 0x1);
+ public readonly SyncpointbWaitSwitch SyncpointbWaitSwitch => (SyncpointbWaitSwitch)((Syncpointb >> 4) & 0x1);
+ public readonly int SyncpointbSyncptIndex => (int)((Syncpointb >> 8) & 0xFFF);
public uint Wfi;
- public WfiScope WfiScope => (WfiScope)(Wfi & 0x1);
+ public readonly WfiScope WfiScope => (WfiScope)(Wfi & 0x1);
public uint CrcCheck;
- public int CrcCheckValue => (int)(CrcCheck);
+ public readonly int CrcCheckValue => (int)(CrcCheck);
public uint Yield;
- public YieldOp YieldOp => (YieldOp)(Yield & 0x3);
+ public readonly YieldOp YieldOp => (YieldOp)(Yield & 0x3);
// TODO: Eventually move this to per-engine state.
public Array31<uint> Reserved84;
public uint NoOperation;
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoDevice.cs b/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoDevice.cs
index 09bcdec1..bb5bc21c 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoDevice.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoDevice.cs
@@ -18,7 +18,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
private enum CommandBufferType
{
Prefetch,
- NoPrefetch
+ NoPrefetch,
}
/// <summary>
@@ -57,7 +57,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
/// <param name="memoryManager">The memory manager used to fetch the data</param>
/// <param name="flush">If true, flushes potential GPU written data before reading the command buffer</param>
/// <returns>The fetched data</returns>
- private ReadOnlySpan<int> GetWords(MemoryManager memoryManager, bool flush)
+ private readonly ReadOnlySpan<int> GetWords(MemoryManager memoryManager, bool flush)
{
return MemoryMarshal.Cast<byte, int>(memoryManager.GetSpan(EntryAddress, (int)EntryCount * 4, flush));
}
@@ -77,7 +77,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
/// <param name="memoryManager">The memory manager used to fetch the data</param>
/// <param name="flush">If true, flushes potential GPU written data before reading the command buffer</param>
/// <returns>The command buffer words</returns>
- public ReadOnlySpan<int> Fetch(MemoryManager memoryManager, bool flush)
+ public readonly ReadOnlySpan<int> Fetch(MemoryManager memoryManager, bool flush)
{
return Words ?? GetWords(memoryManager, flush);
}
@@ -85,7 +85,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
private readonly ConcurrentQueue<CommandBuffer> _commandBufferQueue;
- private CommandBuffer _currentCommandBuffer;
private GPFifoProcessor _prevChannelProcessor;
private readonly bool _ibEnable;
@@ -129,7 +128,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
Type = CommandBufferType.Prefetch,
Words = commandBuffer,
EntryAddress = ulong.MaxValue,
- EntryCount = (uint)commandBuffer.Length
+ EntryCount = (uint)commandBuffer.Length,
});
}
@@ -156,7 +155,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
Type = type,
Words = null,
EntryAddress = startAddress,
- EntryCount = (uint)entry.Entry1Length
+ EntryCount = (uint)entry.Entry1Length,
};
}
@@ -217,7 +216,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
flushCommandBuffer = false;
}
- _currentCommandBuffer = entry;
ReadOnlySpan<int> words = entry.Fetch(entry.Processor.MemoryManager, flushCommandBuffer);
// If we are changing the current channel,
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoProcessor.cs b/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoProcessor.cs
index 3fb3feee..6ba1bc22 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoProcessor.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/GPFifo/GPFifoProcessor.cs
@@ -243,7 +243,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
{
0 => _3dClass,
3 => _2dClass,
- _ => null
+ _ => null,
};
if (state != null)
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/InlineToMemory/InlineToMemoryClass.cs b/src/Ryujinx.Graphics.Gpu/Engine/InlineToMemory/InlineToMemoryClass.cs
index e1d7e940..e417b9a0 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/InlineToMemory/InlineToMemoryClass.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/InlineToMemory/InlineToMemoryClass.cs
@@ -53,7 +53,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.InlineToMemory
_state = new DeviceState<InlineToMemoryClassState>(new Dictionary<string, RwCallback>
{
{ nameof(InlineToMemoryClassState.LaunchDma), new RwCallback(LaunchDma, null) },
- { nameof(InlineToMemoryClassState.LoadInlineData), new RwCallback(LoadInlineData, null) }
+ { nameof(InlineToMemoryClassState.LoadInlineData), new RwCallback(LoadInlineData, null) },
});
}
}
@@ -134,7 +134,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.InlineToMemory
if (!_finished)
{
int copySize = Math.Min(data.Length, _buffer.Length - _offset);
- data.Slice(0, copySize).CopyTo(new Span<int>(_buffer).Slice(_offset, copySize));
+ data[..copySize].CopyTo(new Span<int>(_buffer).Slice(_offset, copySize));
_offset += copySize;
@@ -169,11 +169,11 @@ namespace Ryujinx.Graphics.Gpu.Engine.InlineToMemory
{
var memoryManager = _channel.MemoryManager;
- var data = MemoryMarshal.Cast<int, byte>(_buffer).Slice(0, _size);
+ var data = MemoryMarshal.Cast<int, byte>(_buffer)[.._size];
if (_isLinear && _lineCount == 1)
{
- memoryManager.WriteTrackedResource(_dstGpuVa, data.Slice(0, _lineLengthIn));
+ memoryManager.WriteTrackedResource(_dstGpuVa, data[.._lineLengthIn]);
_context.AdvanceSequence();
}
else
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/InlineToMemory/InlineToMemoryClassState.cs b/src/Ryujinx.Graphics.Gpu/Engine/InlineToMemory/InlineToMemoryClassState.cs
index f6d9602a..ec5042fd 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/InlineToMemory/InlineToMemoryClassState.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/InlineToMemory/InlineToMemoryClassState.cs
@@ -1,5 +1,7 @@
// This file was auto-generated from NVIDIA official Maxwell definitions.
+using Ryujinx.Common.Memory;
+
namespace Ryujinx.Graphics.Gpu.Engine.InlineToMemory
{
/// <summary>
@@ -111,24 +113,24 @@ namespace Ryujinx.Graphics.Gpu.Engine.InlineToMemory
/// </summary>
unsafe struct InlineToMemoryClassState
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public uint SetObject;
- public int SetObjectClassId => (int)(SetObject & 0xFFFF);
- public int SetObjectEngineId => (int)((SetObject >> 16) & 0x1F);
+ public readonly int SetObjectClassId => (int)(SetObject & 0xFFFF);
+ public readonly int SetObjectEngineId => (int)((SetObject >> 16) & 0x1F);
public fixed uint Reserved04[63];
public uint NoOperation;
public uint SetNotifyA;
- public int SetNotifyAAddressUpper => (int)(SetNotifyA & 0xFF);
+ public readonly int SetNotifyAAddressUpper => (int)(SetNotifyA & 0xFF);
public uint SetNotifyB;
public uint Notify;
- public NotifyType NotifyType => (NotifyType)(Notify);
+ public readonly NotifyType NotifyType => (NotifyType)(Notify);
public uint WaitForIdle;
public fixed uint Reserved114[7];
public uint SetGlobalRenderEnableA;
- public int SetGlobalRenderEnableAOffsetUpper => (int)(SetGlobalRenderEnableA & 0xFF);
+ public readonly int SetGlobalRenderEnableAOffsetUpper => (int)(SetGlobalRenderEnableA & 0xFF);
public uint SetGlobalRenderEnableB;
public uint SetGlobalRenderEnableC;
- public int SetGlobalRenderEnableCMode => (int)(SetGlobalRenderEnableC & 0x7);
+ public readonly int SetGlobalRenderEnableCMode => (int)(SetGlobalRenderEnableC & 0x7);
public uint SendGoIdle;
public uint PmTrigger;
public uint PmTriggerWfi;
@@ -139,34 +141,34 @@ namespace Ryujinx.Graphics.Gpu.Engine.InlineToMemory
public uint LineLengthIn;
public uint LineCount;
public uint OffsetOutUpper;
- public int OffsetOutUpperValue => (int)(OffsetOutUpper & 0xFF);
+ public readonly int OffsetOutUpperValue => (int)(OffsetOutUpper & 0xFF);
public uint OffsetOut;
public uint PitchOut;
public uint SetDstBlockSize;
- public SetDstBlockSizeWidth SetDstBlockSizeWidth => (SetDstBlockSizeWidth)(SetDstBlockSize & 0xF);
- public SetDstBlockSizeHeight SetDstBlockSizeHeight => (SetDstBlockSizeHeight)((SetDstBlockSize >> 4) & 0xF);
- public SetDstBlockSizeDepth SetDstBlockSizeDepth => (SetDstBlockSizeDepth)((SetDstBlockSize >> 8) & 0xF);
+ public readonly SetDstBlockSizeWidth SetDstBlockSizeWidth => (SetDstBlockSizeWidth)(SetDstBlockSize & 0xF);
+ public readonly SetDstBlockSizeHeight SetDstBlockSizeHeight => (SetDstBlockSizeHeight)((SetDstBlockSize >> 4) & 0xF);
+ public readonly SetDstBlockSizeDepth SetDstBlockSizeDepth => (SetDstBlockSizeDepth)((SetDstBlockSize >> 8) & 0xF);
public uint SetDstWidth;
public uint SetDstHeight;
public uint SetDstDepth;
public uint SetDstLayer;
public uint SetDstOriginBytesX;
- public int SetDstOriginBytesXV => (int)(SetDstOriginBytesX & 0xFFFFF);
+ public readonly int SetDstOriginBytesXV => (int)(SetDstOriginBytesX & 0xFFFFF);
public uint SetDstOriginSamplesY;
- public int SetDstOriginSamplesYV => (int)(SetDstOriginSamplesY & 0xFFFF);
+ public readonly int SetDstOriginSamplesYV => (int)(SetDstOriginSamplesY & 0xFFFF);
public uint LaunchDma;
- public LaunchDmaDstMemoryLayout LaunchDmaDstMemoryLayout => (LaunchDmaDstMemoryLayout)(LaunchDma & 0x1);
- public LaunchDmaCompletionType LaunchDmaCompletionType => (LaunchDmaCompletionType)((LaunchDma >> 4) & 0x3);
- public LaunchDmaInterruptType LaunchDmaInterruptType => (LaunchDmaInterruptType)((LaunchDma >> 8) & 0x3);
- public LaunchDmaSemaphoreStructSize LaunchDmaSemaphoreStructSize => (LaunchDmaSemaphoreStructSize)((LaunchDma >> 12) & 0x1);
- public bool LaunchDmaReductionEnable => (LaunchDma & 0x2) != 0;
- public LaunchDmaReductionOp LaunchDmaReductionOp => (LaunchDmaReductionOp)((LaunchDma >> 13) & 0x7);
- public LaunchDmaReductionFormat LaunchDmaReductionFormat => (LaunchDmaReductionFormat)((LaunchDma >> 2) & 0x3);
- public bool LaunchDmaSysmembarDisable => (LaunchDma & 0x40) != 0;
+ public readonly LaunchDmaDstMemoryLayout LaunchDmaDstMemoryLayout => (LaunchDmaDstMemoryLayout)(LaunchDma & 0x1);
+ public readonly LaunchDmaCompletionType LaunchDmaCompletionType => (LaunchDmaCompletionType)((LaunchDma >> 4) & 0x3);
+ public readonly LaunchDmaInterruptType LaunchDmaInterruptType => (LaunchDmaInterruptType)((LaunchDma >> 8) & 0x3);
+ public readonly LaunchDmaSemaphoreStructSize LaunchDmaSemaphoreStructSize => (LaunchDmaSemaphoreStructSize)((LaunchDma >> 12) & 0x1);
+ public readonly bool LaunchDmaReductionEnable => (LaunchDma & 0x2) != 0;
+ public readonly LaunchDmaReductionOp LaunchDmaReductionOp => (LaunchDmaReductionOp)((LaunchDma >> 13) & 0x7);
+ public readonly LaunchDmaReductionFormat LaunchDmaReductionFormat => (LaunchDmaReductionFormat)((LaunchDma >> 2) & 0x3);
+ public readonly bool LaunchDmaSysmembarDisable => (LaunchDma & 0x40) != 0;
public uint LoadInlineData;
public fixed uint Reserved1B8[9];
public uint SetI2mSemaphoreA;
- public int SetI2mSemaphoreAOffsetUpper => (int)(SetI2mSemaphoreA & 0xFF);
+ public readonly int SetI2mSemaphoreAOffsetUpper => (int)(SetI2mSemaphoreA & 0xFF);
public uint SetI2mSemaphoreB;
public uint SetI2mSemaphoreC;
public fixed uint Reserved1E8[2];
@@ -175,7 +177,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.InlineToMemory
public uint SetI2mSpareNoop02;
public uint SetI2mSpareNoop03;
public fixed uint Reserved200[3200];
- public MmeShadowScratch SetMmeShadowScratch;
+ public Array256<uint> SetMmeShadowScratch;
#pragma warning restore CS0649
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/MME/AluOperation.cs b/src/Ryujinx.Graphics.Gpu/Engine/MME/AluOperation.cs
index eeef9c67..43faa788 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/MME/AluOperation.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/MME/AluOperation.cs
@@ -10,6 +10,6 @@
BitfieldReplace = 2,
BitfieldExtractLslImm = 3,
BitfieldExtractLslReg = 4,
- ReadImmediate = 5
+ ReadImmediate = 5,
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/MME/AluRegOperation.cs b/src/Ryujinx.Graphics.Gpu/Engine/MME/AluRegOperation.cs
index f3e05d38..c878bd41 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/MME/AluRegOperation.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/MME/AluRegOperation.cs
@@ -13,6 +13,6 @@
BitwiseOr = 9,
BitwiseAnd = 10,
BitwiseAndNot = 11,
- BitwiseNotAnd = 12
+ BitwiseNotAnd = 12,
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/MME/AssignmentOperation.cs b/src/Ryujinx.Graphics.Gpu/Engine/MME/AssignmentOperation.cs
index dc336026..592aa5a6 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/MME/AssignmentOperation.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/MME/AssignmentOperation.cs
@@ -12,6 +12,6 @@
MoveAndSend = 4,
FetchAndSetMaddr = 5,
MoveAndSetMaddrThenFetchAndSend = 6,
- MoveAndSetMaddrThenSendHigh = 7
+ MoveAndSetMaddrThenSendHigh = 7,
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/MME/Macro.cs b/src/Ryujinx.Graphics.Gpu/Engine/MME/Macro.cs
index 12a3ac02..65c6aab4 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/MME/Macro.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/MME/Macro.cs
@@ -48,7 +48,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
if (_executionEngine == null)
{
- if (GraphicsConfig.EnableMacroHLE && MacroHLETable.TryGetMacroHLEFunction(code.Slice(Position), context.Capabilities, out _hleFunction))
+ if (GraphicsConfig.EnableMacroHLE && MacroHLETable.TryGetMacroHLEFunction(code[Position..], context.Capabilities, out _hleFunction))
{
_executionEngine = new MacroHLE(processor, _hleFunction);
}
@@ -84,7 +84,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
if (_executionPending)
{
_executionPending = false;
- _executionEngine?.Execute(code.Slice(Position), state, _argument);
+ _executionEngine?.Execute(code[Position..], state, _argument);
}
}
@@ -93,7 +93,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
/// </summary>
/// <param name="gpuVa">GPU virtual address where the command word is located</param>
/// <param name="argument">Argument to be pushed</param>
- public void PushArgument(ulong gpuVa, int argument)
+ public readonly void PushArgument(ulong gpuVa, int argument)
{
_executionEngine?.Fifo.Enqueue(new FifoWord(gpuVa, argument));
}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLE.cs b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLE.cs
index 8630bbc4..a4c4dd10 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLE.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLE.cs
@@ -16,7 +16,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
private const int ColorStructSize = 0x40;
private const int ZetaLayerCountOffset = 0x1230;
- private const int IndirectDataEntrySize = 0x10;
private const int IndirectIndexedDataEntrySize = 0x14;
private readonly GPFifoProcessor _processor;
@@ -262,10 +261,12 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
for (int i = 0; i < maxDrawCount; i++)
{
var count = FetchParam();
+#pragma warning disable IDE0059 // Remove unnecessary value assignment
var instanceCount = FetchParam();
var firstIndex = FetchParam();
var firstVertex = FetchParam();
var firstInstance = FetchParam();
+#pragma warning restore IDE0059
if (i == 0)
{
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLEFunctionName.cs b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLEFunctionName.cs
index 751867fc..9e71761b 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLEFunctionName.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLEFunctionName.cs
@@ -11,6 +11,6 @@
DrawArraysInstanced,
DrawElementsInstanced,
DrawElementsIndirect,
- MultiDrawElementsIndirectCount
+ MultiDrawElementsIndirectCount,
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLETable.cs b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLETable.cs
index 719e170f..5630756c 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLETable.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroHLETable.cs
@@ -46,12 +46,12 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
private static readonly TableEntry[] _table = new TableEntry[]
{
- new TableEntry(MacroHLEFunctionName.ClearColor, new Hash128(0xA9FB28D1DC43645A, 0xB177E5D2EAE67FB0), 0x28),
- new TableEntry(MacroHLEFunctionName.ClearDepthStencil, new Hash128(0x1B96CB77D4879F4F, 0x8557032FE0C965FB), 0x24),
- new TableEntry(MacroHLEFunctionName.DrawArraysInstanced, new Hash128(0x197FB416269DBC26, 0x34288C01DDA82202), 0x48),
- new TableEntry(MacroHLEFunctionName.DrawElementsInstanced, new Hash128(0x1A501FD3D54EC8E0, 0x6CF570CF79DA74D6), 0x5c),
- new TableEntry(MacroHLEFunctionName.DrawElementsIndirect, new Hash128(0x86A3E8E903AF8F45, 0xD35BBA07C23860A4), 0x7c),
- new TableEntry(MacroHLEFunctionName.MultiDrawElementsIndirectCount, new Hash128(0x890AF57ED3FB1C37, 0x35D0C95C61F5386F), 0x19C)
+ new(MacroHLEFunctionName.ClearColor, new Hash128(0xA9FB28D1DC43645A, 0xB177E5D2EAE67FB0), 0x28),
+ new(MacroHLEFunctionName.ClearDepthStencil, new Hash128(0x1B96CB77D4879F4F, 0x8557032FE0C965FB), 0x24),
+ new(MacroHLEFunctionName.DrawArraysInstanced, new Hash128(0x197FB416269DBC26, 0x34288C01DDA82202), 0x48),
+ new(MacroHLEFunctionName.DrawElementsInstanced, new Hash128(0x1A501FD3D54EC8E0, 0x6CF570CF79DA74D6), 0x5c),
+ new(MacroHLEFunctionName.DrawElementsIndirect, new Hash128(0x86A3E8E903AF8F45, 0xD35BBA07C23860A4), 0x7c),
+ new(MacroHLEFunctionName.MultiDrawElementsIndirectCount, new Hash128(0x890AF57ED3FB1C37, 0x35D0C95C61F5386F), 0x19C),
};
/// <summary>
@@ -93,7 +93,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
{
ref var entry = ref _table[i];
- var hash = XXHash128.ComputeHash(mc.Slice(0, entry.Length));
+ var hash = XXHash128.ComputeHash(mc[..entry.Length]);
if (hash == entry.Hash)
{
if (IsMacroHLESupported(caps, entry.Name))
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroInterpreter.cs b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroInterpreter.cs
index df6ee040..dd60688d 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroInterpreter.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroInterpreter.cs
@@ -15,7 +15,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
/// </summary>
public Queue<FifoWord> Fifo { get; }
- private int[] _gprs;
+ private readonly int[] _gprs;
private int _methAddr;
private int _methIncr;
@@ -291,11 +291,16 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
return (int)result;
- case AluRegOperation.BitwiseExclusiveOr: return a ^ b;
- case AluRegOperation.BitwiseOr: return a | b;
- case AluRegOperation.BitwiseAnd: return a & b;
- case AluRegOperation.BitwiseAndNot: return a & ~b;
- case AluRegOperation.BitwiseNotAnd: return ~(a & b);
+ case AluRegOperation.BitwiseExclusiveOr:
+ return a ^ b;
+ case AluRegOperation.BitwiseOr:
+ return a | b;
+ case AluRegOperation.BitwiseAnd:
+ return a & b;
+ case AluRegOperation.BitwiseAndNot:
+ return a & ~b;
+ case AluRegOperation.BitwiseNotAnd:
+ return ~(a & b);
}
throw new InvalidOperationException($"Invalid operation \"{aluOp}\" on instruction 0x{_opCode:X8}.");
@@ -380,7 +385,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
/// <param name="state">Current GPU state</param>
/// <param name="reg">Register offset to read</param>
/// <returns>GPU register value</returns>
- private int Read(IDeviceState state, int reg)
+ private static int Read(IDeviceState state, int reg)
{
return state.Read(reg * 4);
}
@@ -397,4 +402,4 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
_methAddr += _methIncr;
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroJit.cs b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroJit.cs
index 4077f74e..a23bfef1 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroJit.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroJit.cs
@@ -9,7 +9,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
/// </summary>
class MacroJit : IMacroEE
{
- private readonly MacroJitContext _context = new MacroJitContext();
+ private readonly MacroJitContext _context = new();
/// <summary>
/// Arguments FIFO.
@@ -28,7 +28,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
{
if (_execute == null)
{
- MacroJitCompiler compiler = new MacroJitCompiler();
+ MacroJitCompiler compiler = new();
_execute = compiler.Compile(code);
}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroJitCompiler.cs b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroJitCompiler.cs
index f8d839fa..d9c26c58 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroJitCompiler.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroJitCompiler.cs
@@ -48,7 +48,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
/// <returns>Delegate of the host compiled code</returns>
public MacroExecute Compile(ReadOnlySpan<int> code)
{
- Dictionary<int, Label> labels = new Dictionary<int, Label>();
+ Dictionary<int, Label> labels = new();
int lastTarget = 0;
int i;
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroJitContext.cs b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroJitContext.cs
index 52c2a11b..5a71e3f4 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroJitContext.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/MME/MacroJitContext.cs
@@ -12,7 +12,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
/// <summary>
/// Arguments FIFO.
/// </summary>
- public Queue<FifoWord> Fifo { get; } = new Queue<FifoWord>();
+ public Queue<FifoWord> Fifo { get; } = new();
/// <summary>
/// Fetches a arguments from the arguments FIFO.
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/MmeShadowScratch.cs b/src/Ryujinx.Graphics.Gpu/Engine/MmeShadowScratch.cs
index 44cd8213..0aa6b82a 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/MmeShadowScratch.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/MmeShadowScratch.cs
@@ -9,7 +9,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
[StructLayout(LayoutKind.Sequential, Size = 1024)]
struct MmeShadowScratch
{
-#pragma warning disable CS0169
+#pragma warning disable CS0169 // The private field is never used
private uint _e0;
#pragma warning restore CS0169
public ref uint this[int index] => ref AsSpan()[index];
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/SetMmeShadowRamControlMode.cs b/src/Ryujinx.Graphics.Gpu/Engine/SetMmeShadowRamControlMode.cs
index 060d35ca..ebb0ff33 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/SetMmeShadowRamControlMode.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/SetMmeShadowRamControlMode.cs
@@ -10,4 +10,4 @@ namespace Ryujinx.Graphics.Gpu.Engine
MethodPassthrough = 2,
MethodReplay = 3,
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/ShaderTexture.cs b/src/Ryujinx.Graphics.Gpu/Engine/ShaderTexture.cs
index e1e3085b..40d9a97d 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/ShaderTexture.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/ShaderTexture.cs
@@ -65,6 +65,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
{
return format switch
{
+#pragma warning disable IDE0055 // Disable formatting
TextureFormat.R8Unorm => Format.R8Unorm,
TextureFormat.R8Snorm => Format.R8Snorm,
TextureFormat.R8Uint => Format.R8Uint,
@@ -104,7 +105,8 @@ namespace Ryujinx.Graphics.Gpu.Engine
TextureFormat.R10G10B10A2Unorm => Format.R10G10B10A2Unorm,
TextureFormat.R10G10B10A2Uint => Format.R10G10B10A2Uint,
TextureFormat.R11G11B10Float => Format.R11G11B10Float,
- _ => 0
+ _ => 0,
+#pragma warning restore IDE0055
};
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendFunctions.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendFunctions.cs
index a40b9cc4..0aca3907 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendFunctions.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendFunctions.cs
@@ -209,14 +209,14 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
new AdvancedBlendUcode(AdvancedBlendOp.HslHue, AdvancedBlendOverlap.Conjoint, false, GenConjointHslHue),
new AdvancedBlendUcode(AdvancedBlendOp.HslSaturation, AdvancedBlendOverlap.Conjoint, false, GenConjointHslSaturation),
new AdvancedBlendUcode(AdvancedBlendOp.HslColor, AdvancedBlendOverlap.Conjoint, false, GenConjointHslColor),
- new AdvancedBlendUcode(AdvancedBlendOp.HslLuminosity, AdvancedBlendOverlap.Conjoint, false, GenConjointHslLuminosity)
+ new AdvancedBlendUcode(AdvancedBlendOp.HslLuminosity, AdvancedBlendOverlap.Conjoint, false, GenConjointHslLuminosity),
};
public static string GenTable()
{
// This can be used to generate the table on AdvancedBlendPreGenTable.
- StringBuilder sb = new StringBuilder();
+ StringBuilder sb = new();
sb.AppendLine($"private static Dictionary<Hash128, AdvancedBlendEntry> _entries = new()");
sb.AppendLine("{");
@@ -4223,4 +4223,4 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
return new FixedFunctionAlpha(BlendOp.MaximumGl, BlendFactor.OneGl, BlendFactor.OneGl);
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendManager.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendManager.cs
index 8072c6af..b336382d 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendManager.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendManager.cs
@@ -54,12 +54,12 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
/// <returns>True if the function was found, false otherwise</returns>
public bool TryGetAdvancedBlend(out AdvancedBlendDescriptor descriptor)
{
- Span<uint> currentCode = new Span<uint>(_code);
+ Span<uint> currentCode = new(_code);
byte codeLength = (byte)_state.State.BlendUcodeSize;
if (currentCode.Length > codeLength)
{
- currentCode = currentCode.Slice(0, codeLength);
+ currentCode = currentCode[..codeLength];
}
Hash128 hash = XXHash128.ComputeHash(MemoryMarshal.Cast<uint, byte>(currentCode));
@@ -112,4 +112,4 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
return true;
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendPreGenTable.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendPreGenTable.cs
index d35d8abf..b6cd9def 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendPreGenTable.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendPreGenTable.cs
@@ -8,7 +8,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
/// <summary>
/// Advanced blend function entry.
/// </summary>
- struct AdvancedBlendEntry
+ readonly struct AdvancedBlendEntry
{
/// <summary>
/// Advanced blend operation.
@@ -270,4 +270,4 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
{ new Hash128(0x8652300E32D93050, 0x9460E7B449132371), new AdvancedBlendEntry(AdvancedBlendOp.HslLuminosity, AdvancedBlendOverlap.Conjoint, false, new[] { new RgbFloat(0.3f, 0.59f, 0.11f) }, new FixedFunctionAlpha(BlendUcodeEnable.EnableRGB, BlendOp.MaximumGl, BlendFactor.OneGl, BlendFactor.OneGl)) },
};
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendUcode.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendUcode.cs
index f06b4bf7..d3e3abbc 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendUcode.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/AdvancedBlendUcode.cs
@@ -5,12 +5,12 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
/// <summary>
/// Fixed function alpha state used for a advanced blend function.
/// </summary>
- struct FixedFunctionAlpha
+ readonly struct FixedFunctionAlpha
{
/// <summary>
/// Fixed function alpha state with alpha blending disabled.
/// </summary>
- public static FixedFunctionAlpha Disabled => new FixedFunctionAlpha(BlendUcodeEnable.EnableRGBA, default, default, default);
+ public static FixedFunctionAlpha Disabled => new(BlendUcodeEnable.EnableRGBA, default, default, default);
/// <summary>
/// Individual enable bits for the RGB and alpha components.
@@ -68,7 +68,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
/// <summary>
/// Advanced blend microcode state.
/// </summary>
- struct AdvancedBlendUcode
+ readonly struct AdvancedBlendUcode
{
/// <summary>
/// Advanced blend operation.
@@ -117,10 +117,10 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
Overlap = overlap;
SrcPreMultiplied = srcPreMultiplied;
- UcodeAssembler asm = new UcodeAssembler();
+ UcodeAssembler asm = new();
Alpha = genFunc(ref asm);
Code = asm.GetCode();
Constants = asm.GetConstants();
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/UcodeAssembler.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/UcodeAssembler.cs
index f854787e..8e020906 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/UcodeAssembler.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/Blender/UcodeAssembler.cs
@@ -14,7 +14,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
Max = 3,
Rcp = 4,
Add = 5,
- Sub = 6
+ Sub = 6,
}
/// <summary>
@@ -29,7 +29,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
LT = 4,
LE = 5,
GT = 6,
- GE = 7
+ GE = 7,
}
/// <summary>
@@ -49,7 +49,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
Temp1 = 0xa,
Temp2 = 0xb,
PBR = 0xc,
- ConstantRGB = 0xd
+ ConstantRGB = 0xd,
}
/// <summary>
@@ -64,7 +64,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
Temp0 = 4,
Temp1 = 5,
Temp2 = 6,
- PBR = 7
+ PBR = 7,
}
/// <summary>
@@ -75,7 +75,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
Temp0 = 0,
Temp1 = 1,
Temp2 = 2,
- PBR = 3
+ PBR = 3,
}
/// <summary>
@@ -88,7 +88,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
RRR = 2,
GGG = 3,
BBB = 4,
- RToA = 5
+ RToA = 5,
}
/// <summary>
@@ -99,13 +99,13 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
RGB = 0,
R = 1,
G = 2,
- B = 3
+ B = 3,
}
/// <summary>
/// Floating-point RGB color values.
/// </summary>
- struct RgbFloat
+ readonly struct RgbFloat
{
/// <summary>
/// Red component value.
@@ -139,24 +139,24 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
/// <summary>
/// Blend microcode destination operand, including swizzle, write mask and condition code update flag.
/// </summary>
- struct Dest
+ readonly struct Dest
{
- public static Dest Temp0 => new Dest(OpDst.Temp0, Swizzle.RGB, WriteMask.RGB, false);
- public static Dest Temp1 => new Dest(OpDst.Temp1, Swizzle.RGB, WriteMask.RGB, false);
- public static Dest Temp2 => new Dest(OpDst.Temp2, Swizzle.RGB, WriteMask.RGB, false);
- public static Dest PBR => new Dest(OpDst.PBR, Swizzle.RGB, WriteMask.RGB, false);
+ public static Dest Temp0 => new(OpDst.Temp0, Swizzle.RGB, WriteMask.RGB, false);
+ public static Dest Temp1 => new(OpDst.Temp1, Swizzle.RGB, WriteMask.RGB, false);
+ public static Dest Temp2 => new(OpDst.Temp2, Swizzle.RGB, WriteMask.RGB, false);
+ public static Dest PBR => new(OpDst.PBR, Swizzle.RGB, WriteMask.RGB, false);
- public Dest GBR => new Dest(Dst, Swizzle.GBR, WriteMask, WriteCC);
- public Dest RRR => new Dest(Dst, Swizzle.RRR, WriteMask, WriteCC);
- public Dest GGG => new Dest(Dst, Swizzle.GGG, WriteMask, WriteCC);
- public Dest BBB => new Dest(Dst, Swizzle.BBB, WriteMask, WriteCC);
- public Dest RToA => new Dest(Dst, Swizzle.RToA, WriteMask, WriteCC);
+ public Dest GBR => new(Dst, Swizzle.GBR, WriteMask, WriteCC);
+ public Dest RRR => new(Dst, Swizzle.RRR, WriteMask, WriteCC);
+ public Dest GGG => new(Dst, Swizzle.GGG, WriteMask, WriteCC);
+ public Dest BBB => new(Dst, Swizzle.BBB, WriteMask, WriteCC);
+ public Dest RToA => new(Dst, Swizzle.RToA, WriteMask, WriteCC);
- public Dest R => new Dest(Dst, Swizzle, WriteMask.R, WriteCC);
- public Dest G => new Dest(Dst, Swizzle, WriteMask.G, WriteCC);
- public Dest B => new Dest(Dst, Swizzle, WriteMask.B, WriteCC);
+ public Dest R => new(Dst, Swizzle, WriteMask.R, WriteCC);
+ public Dest G => new(Dst, Swizzle, WriteMask.G, WriteCC);
+ public Dest B => new(Dst, Swizzle, WriteMask.B, WriteCC);
- public Dest CC => new Dest(Dst, Swizzle, WriteMask, true);
+ public Dest CC => new(Dst, Swizzle, WriteMask, true);
public OpDst Dst { get; }
public Swizzle Swizzle { get; }
@@ -182,7 +182,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
/// <summary>
/// Blend microcode operaiton.
/// </summary>
- struct UcodeOp
+ readonly struct UcodeOp
{
public readonly uint Word;
@@ -292,14 +292,14 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
_constantIndex = index;
}
- public uint[] GetCode()
+ public readonly uint[] GetCode()
{
return _code?.ToArray();
}
- public RgbFloat[] GetConstants()
+ public readonly RgbFloat[] GetConstants()
{
return _constants;
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/ConstantBufferUpdater.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/ConstantBufferUpdater.cs
index 5c936616..e30092ce 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/ConstantBufferUpdater.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/ConstantBufferUpdater.cs
@@ -19,7 +19,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
private ulong _ubFollowUpAddress = 0;
private ulong _ubByteCount = 0;
private int _ubIndex = 0;
- private int[] _ubData = new int[UniformDataCacheSize];
+ private readonly int[] _ubData = new int[UniformDataCacheSize];
/// <summary>
/// Creates a new instance of the constant buffer updater.
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/DrawManager.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/DrawManager.cs
index 9c4921c8..d7ee24b1 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/DrawManager.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/DrawManager.cs
@@ -186,7 +186,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
{
int firstVertex = (int)_state.State.FirstVertex;
- BufferRange br = new BufferRange(_drawState.IbStreamer.GetInlineIndexBuffer(), 0, inlineIndexCount * 4);
+ BufferRange br = new(_drawState.IbStreamer.GetInlineIndexBuffer(), 0, inlineIndexCount * 4);
_channel.BufferManager.SetIndexBuffer(br, IndexType.UInt);
@@ -200,7 +200,9 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
}
else
{
+#pragma warning disable IDE0059 // Remove unnecessary value assignment
var drawState = _state.State.VertexBufferDrawState;
+#pragma warning restore IDE0059
_context.Renderer.Pipeline.Draw(drawVertexCount, 1, drawFirstVertex, firstInstance);
}
@@ -679,7 +681,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
if (indexedInline)
{
int inlineIndexCount = _drawState.IbStreamer.GetAndResetInlineIndexCount(_context.Renderer);
- BufferRange br = new BufferRange(_drawState.IbStreamer.GetInlineIndexBuffer(), 0, inlineIndexCount * 4);
+ BufferRange br = new(_drawState.IbStreamer.GetInlineIndexBuffer(), 0, inlineIndexCount * 4);
_channel.BufferManager.SetIndexBuffer(br, IndexType.UInt);
}
@@ -809,7 +811,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
Span<Rectangle<int>> scissors = stackalloc Rectangle<int>[]
{
- new Rectangle<int>(scissorX, scissorY, scissorW, scissorH)
+ new Rectangle<int>(scissorX, scissorY, scissorW, scissorH),
};
_context.Renderer.Pipeline.SetScissors(scissors);
@@ -821,7 +823,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
{
var clearColor = _state.State.ClearColors;
- ColorF color = new ColorF(clearColor.Red, clearColor.Green, clearColor.Blue, clearColor.Alpha);
+ ColorF color = new(clearColor.Red, clearColor.Green, clearColor.Blue, clearColor.Alpha);
_context.Renderer.Pipeline.ClearRenderTargetColor(index, layer, layerCount, componentMask, color);
}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/DrawState.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/DrawState.cs
index 42ec2442..12099aef 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/DrawState.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/DrawState.cs
@@ -60,6 +60,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// <summary>
/// Index buffer data streamer for inline index buffer updates, such as those used in legacy OpenGL.
/// </summary>
- public IbStreamer IbStreamer = new IbStreamer();
+ public IbStreamer IbStreamer = new();
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/IbStreamer.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/IbStreamer.cs
index 80d8c00b..022e12f5 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/IbStreamer.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/IbStreamer.cs
@@ -1,6 +1,5 @@
using Ryujinx.Common;
using Ryujinx.Graphics.GAL;
-using System;
using System.Runtime.InteropServices;
namespace Ryujinx.Graphics.Gpu.Engine.Threed
@@ -17,33 +16,35 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
private int _inlineIndexBufferSize;
private int _inlineIndexCount;
private uint[] _buffer;
- private int _bufferOffset;
+#pragma warning disable IDE0051 // Remove unused private member
+ private readonly int _bufferOffset;
+#pragma warning restore IDE0051
/// <summary>
/// Indicates if any index buffer data has been pushed.
/// </summary>
- public bool HasInlineIndexData => _inlineIndexCount != 0;
+ public readonly bool HasInlineIndexData => _inlineIndexCount != 0;
/// <summary>
/// Total numbers of indices that have been pushed.
/// </summary>
- public int InlineIndexCount => _inlineIndexCount;
+ public readonly int InlineIndexCount => _inlineIndexCount;
/// <summary>
/// Gets the handle for the host buffer currently holding the inline index buffer data.
/// </summary>
/// <returns>Host buffer handle</returns>
- public BufferHandle GetInlineIndexBuffer()
+ public readonly BufferHandle GetInlineIndexBuffer()
{
return _inlineIndexBuffer;
}
/// <summary>
/// Gets the number of elements on the current inline index buffer,
- /// while also reseting it to zero for the next draw.
+ /// while also resetting it to zero for the next draw.
/// </summary>
/// <param name="renderer">Host renderer</param>
- /// <returns>Inline index bufffer count</returns>
+ /// <returns>Inline index buffer count</returns>
public int GetAndResetInlineIndexCount(IRenderer renderer)
{
UpdateRemaining(renderer);
@@ -114,10 +115,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// <param name="value">Index value to be written</param>
private void PushData(IRenderer renderer, int offset, uint value)
{
- if (_buffer == null)
- {
- _buffer = new uint[BufferCapacity];
- }
+ _buffer ??= new uint[BufferCapacity];
// We upload data in chunks.
// If we are at the start of a chunk, then the buffer might be full,
@@ -155,7 +153,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
int baseOffset = (offset - count) * sizeof(uint);
int length = count * sizeof(uint);
BufferHandle buffer = GetInlineIndexBuffer(renderer, baseOffset, length);
- renderer.SetBufferData(buffer, baseOffset, MemoryMarshal.Cast<uint, byte>(_buffer).Slice(0, length));
+ renderer.SetBufferData(buffer, baseOffset, MemoryMarshal.Cast<uint, byte>(_buffer)[..length]);
}
/// <summary>
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/IndirectDrawType.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/IndirectDrawType.cs
index d78aa498..331b1976 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/IndirectDrawType.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/IndirectDrawType.cs
@@ -1,8 +1,11 @@
+using System.Diagnostics.CodeAnalysis;
+
namespace Ryujinx.Graphics.Gpu.Engine.Threed
{
/// <summary>
/// Indirect draw type, which can be indexed or non-indexed, with or without a draw count.
/// </summary>
+ [SuppressMessage("Design", "CA1069: Enums values should not be duplicated")]
enum IndirectDrawType
{
/// <summary>
@@ -33,6 +36,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// <summary>
/// Draw count flag.
/// </summary>
- Count = 1 << 1
+ Count = 1 << 1,
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/RenderTargetUpdateFlags.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/RenderTargetUpdateFlags.cs
index cf2e818c..e575923d 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/RenderTargetUpdateFlags.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/RenderTargetUpdateFlags.cs
@@ -36,6 +36,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// <summary>
/// Default update flags for draw.
/// </summary>
- UpdateAll = UseControl | UpdateDepthStencil
+ UpdateAll = UseControl | UpdateDepthStencil,
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/SemaphoreUpdater.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/SemaphoreUpdater.cs
index 63a2c841..0a813ee5 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/SemaphoreUpdater.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/SemaphoreUpdater.cs
@@ -1,5 +1,4 @@
using Ryujinx.Graphics.GAL;
-using System;
namespace Ryujinx.Graphics.Gpu.Engine.Threed
{
@@ -15,7 +14,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
{
Release = 0,
Acquire = 1,
- Counter = 2
+ Counter = 2,
}
/// <summary>
@@ -37,7 +36,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
ClipperInputPrimitives = 0x1c,
ClipperOutputPrimitives = 0x1d,
FragmentShaderInvocations = 0x1e,
- PrimitivesGenerated = 0x1f
+ PrimitivesGenerated = 0x1f,
}
/// <summary>
@@ -64,7 +63,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
TransformFeedbackOffset = 0x1a,
TessControlShaderInvocations = 0x1b,
TessEvaluationShaderInvocations = 0x1d,
- TessEvaluationShaderPrimitives = 0x1f
+ TessEvaluationShaderPrimitives = 0x1f,
}
private readonly GpuContext _context;
@@ -117,8 +116,12 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
switch (op)
{
- case SemaphoreOperation.Release: ReleaseSemaphore(); break;
- case SemaphoreOperation.Counter: ReportCounter(type); break;
+ case SemaphoreOperation.Release:
+ ReleaseSemaphore();
+ break;
+ case SemaphoreOperation.Counter:
+ ReportCounter(type);
+ break;
}
}
@@ -156,10 +159,10 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
void resultHandler(object evt, ulong result)
{
- CounterData counterData = new CounterData
+ CounterData counterData = new()
{
Counter = result,
- Timestamp = ticks
+ Timestamp = ticks,
};
if (counter?.Invalid != true)
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/SpecializationStateUpdater.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/SpecializationStateUpdater.cs
index a8af5497..cbf1573c 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/SpecializationStateUpdater.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/SpecializationStateUpdater.cs
@@ -227,7 +227,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
{
VertexAttribType.Sint => AttributeType.Sint,
VertexAttribType.Uint => AttributeType.Uint,
- _ => AttributeType.Float
+ _ => AttributeType.Float,
};
if (attributeTypes[location] != value)
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs
index 92e980ce..34439657 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/StateUpdater.cs
@@ -33,7 +33,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
private readonly ShaderProgramInfo[] _currentProgramInfo;
private ShaderSpecializationState _shaderSpecState;
- private SpecializationStateUpdater _currentSpecState;
+ private readonly SpecializationStateUpdater _currentSpecState;
private ProgramPipelineState _pipeline;
@@ -43,7 +43,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
private uint _vbEnableMask;
private bool _prevDrawIndexed;
- private bool _prevDrawIndirect;
+ private readonly bool _prevDrawIndirect;
private IndexType _prevIndexType;
private uint _prevFirstVertex;
private bool _prevTfEnable;
@@ -448,7 +448,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
int samplesInY = msaaMode.SamplesInY();
var scissor = _state.State.ScreenScissorState;
- Size sizeHint = new Size((scissor.X + scissor.Width) * samplesInX, (scissor.Y + scissor.Height) * samplesInY, 1);
+ Size sizeHint = new((scissor.X + scissor.Width) * samplesInX, (scissor.Y + scissor.Height) * samplesInY, 1);
int clipRegionWidth = int.MaxValue;
int clipRegionHeight = int.MaxValue;
@@ -669,7 +669,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
private void UpdateDepthTestState()
{
- DepthTestDescriptor descriptor = new DepthTestDescriptor(
+ DepthTestDescriptor descriptor = new(
_state.State.DepthTestEnable,
_state.State.DepthWriteEnable,
_state.State.DepthTestFunc);
@@ -739,7 +739,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
height *= scale;
}
- Rectangle<float> region = new Rectangle<float>(x, y, width, height);
+ Rectangle<float> region = new(x, y, width, height);
ViewportSwizzle swizzleX = transform.UnpackSwizzleX();
ViewportSwizzle swizzleY = transform.UnpackSwizzleY();
@@ -751,9 +751,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
if (transform.ScaleZ < 0)
{
- float temp = depthNear;
- depthNear = depthFar;
- depthFar = temp;
+ (depthFar, depthNear) = (depthNear, depthFar);
}
viewports[index] = new Viewport(region, swizzleX, swizzleY, swizzleZ, swizzleW, depthNear, depthFar);
@@ -845,7 +843,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
backMask = test.FrontMask;
}
- StencilTestDescriptor descriptor = new StencilTestDescriptor(
+ StencilTestDescriptor descriptor = new(
test.Enable,
test.FrontFunc,
test.FrontSFail,
@@ -939,7 +937,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
{
VertexAttribType.Sint => Format.R32G32B32A32Sint,
VertexAttribType.Uint => Format.R32G32B32A32Uint,
- _ => Format.R32G32B32A32Float
+ _ => Format.R32G32B32A32Float,
};
}
@@ -1017,8 +1015,12 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
switch (indexBuffer.Type)
{
- case IndexType.UShort: size *= 2; break;
- case IndexType.UInt: size *= 4; break;
+ case IndexType.UShort:
+ size *= 2;
+ break;
+ case IndexType.UInt:
+ size *= 4;
+ break;
}
_channel.BufferManager.SetIndexBuffer(gpuVa, size, indexBuffer.Type);
@@ -1338,7 +1340,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
_vtgWritesRtLayer = false;
- ShaderAddresses addresses = new ShaderAddresses();
+ ShaderAddresses addresses = new();
Span<ulong> addressesSpan = addresses.AsSpan();
ulong baseAddress = _state.State.ShaderBaseAddress.Pack();
@@ -1453,7 +1455,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
// ScaleZ = (Far - Near) / 2
// DepthNear/Far are sorted such as that Near is always less than Far.
depthMode = extents.DepthNear != transform.TranslateZ &&
- extents.DepthFar != transform.TranslateZ
+ extents.DepthFar != transform.TranslateZ
? DepthMode.MinusOneToOne
: DepthMode.ZeroToOne;
}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/ThreedClass.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/ThreedClass.cs
index 1386071c..1f662890 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/ThreedClass.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/ThreedClass.cs
@@ -71,7 +71,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
{ nameof(ThreedClassState.UniformBufferBindTessControl), new RwCallback(ConstantBufferBindTessControl, null) },
{ nameof(ThreedClassState.UniformBufferBindTessEvaluation), new RwCallback(ConstantBufferBindTessEvaluation, null) },
{ nameof(ThreedClassState.UniformBufferBindGeometry), new RwCallback(ConstantBufferBindGeometry, null) },
- { nameof(ThreedClassState.UniformBufferBindFragment), new RwCallback(ConstantBufferBindFragment, null) }
+ { nameof(ThreedClassState.UniformBufferBindFragment), new RwCallback(ConstantBufferBindFragment, null) },
});
_i2mClass = new InlineToMemoryClass(context, channel, initializeState: false);
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Threed/ThreedClassState.cs b/src/Ryujinx.Graphics.Gpu/Engine/Threed/ThreedClassState.cs
index beda2dbf..f2997678 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Threed/ThreedClassState.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Threed/ThreedClassState.cs
@@ -18,7 +18,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
TessellationControl,
TessellationEvaluation,
Geometry,
- Fragment
+ Fragment,
}
/// <summary>
@@ -26,7 +26,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct TessMode
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public uint Packed;
#pragma warning restore CS0649
@@ -34,7 +34,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks the tessellation abstract patch type.
/// </summary>
/// <returns>Abtract patch type</returns>
- public TessPatchType UnpackPatchType()
+ public readonly TessPatchType UnpackPatchType()
{
return (TessPatchType)(Packed & 3);
}
@@ -43,7 +43,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks the spacing between tessellated vertices of the patch.
/// </summary>
/// <returns>Spacing between tessellated vertices</returns>
- public TessSpacing UnpackSpacing()
+ public readonly TessSpacing UnpackSpacing()
{
return (TessSpacing)((Packed >> 4) & 3);
}
@@ -52,7 +52,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks the primitive winding order.
/// </summary>
/// <returns>True if clockwise, false if counter-clockwise</returns>
- public bool UnpackCw()
+ public readonly bool UnpackCw()
{
return (Packed & (1 << 8)) != 0;
}
@@ -63,7 +63,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct TfBufferState
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public Boolean32 Enable;
public GpuVa Address;
public int Size;
@@ -79,7 +79,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct TfState
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public int BufferIndex;
public int VaryingsCount;
public int Stride;
@@ -92,7 +92,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct RtColorState
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public GpuVa Address;
public int WidthOrStride;
public int Height;
@@ -116,7 +116,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct ViewportTransform
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public float ScaleX;
public float ScaleY;
public float ScaleZ;
@@ -131,7 +131,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks viewport swizzle of the position X component.
/// </summary>
/// <returns>Swizzle enum value</returns>
- public ViewportSwizzle UnpackSwizzleX()
+ public readonly ViewportSwizzle UnpackSwizzleX()
{
return (ViewportSwizzle)(Swizzle & 7);
}
@@ -140,7 +140,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks viewport swizzle of the position Y component.
/// </summary>
/// <returns>Swizzle enum value</returns>
- public ViewportSwizzle UnpackSwizzleY()
+ public readonly ViewportSwizzle UnpackSwizzleY()
{
return (ViewportSwizzle)((Swizzle >> 4) & 7);
}
@@ -149,7 +149,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks viewport swizzle of the position Z component.
/// </summary>
/// <returns>Swizzle enum value</returns>
- public ViewportSwizzle UnpackSwizzleZ()
+ public readonly ViewportSwizzle UnpackSwizzleZ()
{
return (ViewportSwizzle)((Swizzle >> 8) & 7);
}
@@ -158,7 +158,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks viewport swizzle of the position W component.
/// </summary>
/// <returns>Swizzle enum value</returns>
- public ViewportSwizzle UnpackSwizzleW()
+ public readonly ViewportSwizzle UnpackSwizzleW()
{
return (ViewportSwizzle)((Swizzle >> 12) & 7);
}
@@ -169,7 +169,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct ViewportExtents
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public ushort X;
public ushort Width;
public ushort Y;
@@ -184,7 +184,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct VertexBufferDrawState
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public int First;
public int Count;
#pragma warning restore CS0649
@@ -195,7 +195,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct ClearColors
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public float Red;
public float Green;
public float Blue;
@@ -208,7 +208,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct DepthBiasState
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public Boolean32 PointEnable;
public Boolean32 LineEnable;
public Boolean32 FillEnable;
@@ -223,7 +223,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
Disabled = 0,
EnableRGB = 1,
EnableAlpha = 2,
- EnableRGBA = 3
+ EnableRGBA = 3,
}
/// <summary>
@@ -231,7 +231,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct ScissorState
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public Boolean32 Enable;
public ushort X1;
public ushort X2;
@@ -246,7 +246,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct StencilBackMasks
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public int FuncRef;
public int Mask;
public int FuncMask;
@@ -258,7 +258,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct RtDepthStencilState
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public GpuVa Address;
public ZetaFormat Format;
public MemoryLayout MemoryLayout;
@@ -271,7 +271,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct ScreenScissorState
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public ushort X;
public ushort Width;
public ushort Y;
@@ -297,7 +297,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
Size16 = 0x1b,
Size8 = 0x1d,
Rgb10A2 = 0x30,
- Rg11B10 = 0x31
+ Rg11B10 = 0x31,
}
/// <summary>
@@ -311,7 +311,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
Uint = 4,
Uscaled = 5,
Sscaled = 6,
- Float = 7
+ Float = 7,
}
/// <summary>
@@ -319,7 +319,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct VertexAttribState
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public uint Attribute;
#pragma warning restore CS0649
@@ -327,7 +327,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks the index of the vertex buffer this attribute belongs to.
/// </summary>
/// <returns>Vertex buffer index</returns>
- public int UnpackBufferIndex()
+ public readonly int UnpackBufferIndex()
{
return (int)(Attribute & 0x1f);
}
@@ -336,7 +336,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks the attribute constant flag.
/// </summary>
/// <returns>True if the attribute is constant, false otherwise</returns>
- public bool UnpackIsConstant()
+ public readonly bool UnpackIsConstant()
{
return (Attribute & 0x40) != 0;
}
@@ -345,7 +345,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks the offset, in bytes, of the attribute on the vertex buffer.
/// </summary>
/// <returns>Attribute offset in bytes</returns>
- public int UnpackOffset()
+ public readonly int UnpackOffset()
{
return (int)((Attribute >> 7) & 0x3fff);
}
@@ -354,7 +354,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks the Maxwell attribute format integer.
/// </summary>
/// <returns>Attribute format integer</returns>
- public uint UnpackFormat()
+ public readonly uint UnpackFormat()
{
return Attribute & 0x3fe00000;
}
@@ -363,7 +363,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks the Maxwell attribute size.
/// </summary>
/// <returns>Attribute size</returns>
- public VertexAttribSize UnpackSize()
+ public readonly VertexAttribSize UnpackSize()
{
return (VertexAttribSize)((Attribute >> 21) & 0x3f);
}
@@ -372,7 +372,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks the Maxwell attribute component type.
/// </summary>
/// <returns>Attribute component type</returns>
- public VertexAttribType UnpackType()
+ public readonly VertexAttribType UnpackType()
{
return (VertexAttribType)((Attribute >> 27) & 7);
}
@@ -383,7 +383,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct RtControl
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public uint Packed;
#pragma warning restore CS0649
@@ -391,7 +391,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks the number of active draw buffers.
/// </summary>
/// <returns>Number of active draw buffers</returns>
- public int UnpackCount()
+ public readonly int UnpackCount()
{
return (int)(Packed & 0xf);
}
@@ -401,7 +401,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
/// <param name="index">Index of the draw buffer</param>
/// <returns>Attachment index</returns>
- public int UnpackPermutationIndex(int index)
+ public readonly int UnpackPermutationIndex(int index)
{
return (int)((Packed >> (4 + index * 3)) & 7);
}
@@ -412,7 +412,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct Size3D
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public int Width;
public int Height;
public int Depth;
@@ -424,7 +424,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct StencilTestState
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public Boolean32 Enable;
public StencilOp FrontSFail;
public StencilOp FrontDpFail;
@@ -443,7 +443,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
enum YControl
{
NegateY = 1 << 0,
- TriangleRastFlip = 1 << 4
+ TriangleRastFlip = 1 << 4,
}
/// <summary>
@@ -451,7 +451,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct RgbHalf
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public uint R;
public uint G;
public uint B;
@@ -462,7 +462,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks the red color component as a 16-bit float value.
/// </summary>
/// <returns>The component value</returns>
- public Half UnpackR()
+ public readonly Half UnpackR()
{
ushort value = (ushort)R;
return Unsafe.As<ushort, Half>(ref value);
@@ -472,7 +472,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks the green color component as a 16-bit float value.
/// </summary>
/// <returns>The component value</returns>
- public Half UnpackG()
+ public readonly Half UnpackG()
{
ushort value = (ushort)G;
return Unsafe.As<ushort, Half>(ref value);
@@ -482,7 +482,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks the blue color component as a 16-bit float value.
/// </summary>
/// <returns>The component value</returns>
- public Half UnpackB()
+ public readonly Half UnpackB()
{
ushort value = (ushort)B;
return Unsafe.As<ushort, Half>(ref value);
@@ -498,7 +498,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
Always,
ResultNonZero,
Equal,
- NotEqual
+ NotEqual,
}
/// <summary>
@@ -506,7 +506,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct PoolState
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public GpuVa Address;
public int MaximumId;
#pragma warning restore CS0649
@@ -517,7 +517,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct StencilBackTestState
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public Boolean32 TwoSided;
public StencilOp BackSFail;
public StencilOp BackDpFail;
@@ -531,7 +531,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct PrimitiveRestartState
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public Boolean32 Enable;
public int Index;
#pragma warning restore CS0649
@@ -543,7 +543,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct IndexBufferState
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public GpuVa Address;
public GpuVa EndAddress;
public IndexType Type;
@@ -556,7 +556,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct FaceState
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public Boolean32 CullEnable;
public FrontFace FrontFace;
public Face CullFace;
@@ -570,7 +570,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
enum ViewVolumeClipControl
{
ForceDepthRangeZeroToOne = 1 << 0,
- DepthClampDisabled = 1 << 11
+ DepthClampDisabled = 1 << 11,
}
/// <summary>
@@ -578,7 +578,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct LogicalOpState
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public Boolean32 Enable;
public LogicalOp LogicalOp;
#pragma warning restore CS0649
@@ -590,7 +590,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct RtColorMask
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public uint Packed;
#pragma warning restore CS0649
@@ -598,7 +598,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks red channel enable.
/// </summary>
/// <returns>True to write the new red channel color, false to keep the old value</returns>
- public bool UnpackRed()
+ public readonly bool UnpackRed()
{
return (Packed & 0x1) != 0;
}
@@ -607,7 +607,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks green channel enable.
/// </summary>
/// <returns>True to write the new green channel color, false to keep the old value</returns>
- public bool UnpackGreen()
+ public readonly bool UnpackGreen()
{
return (Packed & 0x10) != 0;
}
@@ -616,7 +616,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks blue channel enable.
/// </summary>
/// <returns>True to write the new blue channel color, false to keep the old value</returns>
- public bool UnpackBlue()
+ public readonly bool UnpackBlue()
{
return (Packed & 0x100) != 0;
}
@@ -625,7 +625,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks alpha channel enable.
/// </summary>
/// <returns>True to write the new alpha channel color, false to keep the old value</returns>
- public bool UnpackAlpha()
+ public readonly bool UnpackAlpha()
{
return (Packed & 0x1000) != 0;
}
@@ -636,7 +636,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct VertexBufferState
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public uint Control;
public GpuVa Address;
public int Divisor;
@@ -646,7 +646,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Vertex buffer stride, defined as the number of bytes occupied by each vertex in memory.
/// </summary>
/// <returns>Vertex buffer stride</returns>
- public int UnpackStride()
+ public readonly int UnpackStride()
{
return (int)(Control & 0xfff);
}
@@ -655,7 +655,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Vertex buffer enable.
/// </summary>
/// <returns>True if the vertex buffer is enabled, false otherwise</returns>
- public bool UnpackEnable()
+ public readonly bool UnpackEnable()
{
return (Control & (1 << 12)) != 0;
}
@@ -666,7 +666,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct BlendStateCommon
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public Boolean32 SeparateAlpha;
public BlendOp ColorOp;
public BlendFactor ColorSrcFactor;
@@ -683,7 +683,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct BlendState
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public Boolean32 SeparateAlpha;
public BlendOp ColorOp;
public BlendFactor ColorSrcFactor;
@@ -700,7 +700,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct ShaderState
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public uint Control;
public uint Offset;
public uint Unknown0x8;
@@ -724,7 +724,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Must be ignored for vertex shaders, those are always enabled.
/// </summary>
/// <returns>True if the stage is enabled, false otherwise</returns>
- public bool UnpackEnable()
+ public readonly bool UnpackEnable()
{
return (Control & 1) != 0;
}
@@ -735,7 +735,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary>
struct UniformBufferState
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public int Size;
public GpuVa Address;
public int Offset;
@@ -744,30 +744,30 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
unsafe struct ThreedClassState : IShadowState
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public uint SetObject;
- public int SetObjectClassId => (int)(SetObject & 0xFFFF);
- public int SetObjectEngineId => (int)((SetObject >> 16) & 0x1F);
+ public readonly int SetObjectClassId => (int)(SetObject & 0xFFFF);
+ public readonly int SetObjectEngineId => (int)((SetObject >> 16) & 0x1F);
public fixed uint Reserved04[63];
public uint NoOperation;
public uint SetNotifyA;
- public int SetNotifyAAddressUpper => (int)(SetNotifyA & 0xFF);
+ public readonly int SetNotifyAAddressUpper => (int)(SetNotifyA & 0xFF);
public uint SetNotifyB;
public uint Notify;
- public NotifyType NotifyType => (NotifyType)(Notify);
+ public readonly NotifyType NotifyType => (NotifyType)(Notify);
public uint WaitForIdle;
public uint LoadMmeInstructionRamPointer;
public uint LoadMmeInstructionRam;
public uint LoadMmeStartAddressRamPointer;
public uint LoadMmeStartAddressRam;
public uint SetMmeShadowRamControl;
- public SetMmeShadowRamControlMode SetMmeShadowRamControlMode => (SetMmeShadowRamControlMode)(SetMmeShadowRamControl & 0x3);
+ public readonly SetMmeShadowRamControlMode SetMmeShadowRamControlMode => (SetMmeShadowRamControlMode)(SetMmeShadowRamControl & 0x3);
public fixed uint Reserved128[2];
public uint SetGlobalRenderEnableA;
- public int SetGlobalRenderEnableAOffsetUpper => (int)(SetGlobalRenderEnableA & 0xFF);
+ public readonly int SetGlobalRenderEnableAOffsetUpper => (int)(SetGlobalRenderEnableA & 0xFF);
public uint SetGlobalRenderEnableB;
public uint SetGlobalRenderEnableC;
- public int SetGlobalRenderEnableCMode => (int)(SetGlobalRenderEnableC & 0x7);
+ public readonly int SetGlobalRenderEnableCMode => (int)(SetGlobalRenderEnableC & 0x7);
public uint SendGoIdle;
public uint PmTrigger;
public uint PmTriggerWfi;
@@ -778,30 +778,30 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
public uint LineLengthIn;
public uint LineCount;
public uint OffsetOutUpper;
- public int OffsetOutUpperValue => (int)(OffsetOutUpper & 0xFF);
+ public readonly int OffsetOutUpperValue => (int)(OffsetOutUpper & 0xFF);
public uint OffsetOut;
public uint PitchOut;
public uint SetDstBlockSize;
- public SetDstBlockSizeWidth SetDstBlockSizeWidth => (SetDstBlockSizeWidth)(SetDstBlockSize & 0xF);
- public SetDstBlockSizeHeight SetDstBlockSizeHeight => (SetDstBlockSizeHeight)((SetDstBlockSize >> 4) & 0xF);
- public SetDstBlockSizeDepth SetDstBlockSizeDepth => (SetDstBlockSizeDepth)((SetDstBlockSize >> 8) & 0xF);
+ public readonly SetDstBlockSizeWidth SetDstBlockSizeWidth => (SetDstBlockSizeWidth)(SetDstBlockSize & 0xF);
+ public readonly SetDstBlockSizeHeight SetDstBlockSizeHeight => (SetDstBlockSizeHeight)((SetDstBlockSize >> 4) & 0xF);
+ public readonly SetDstBlockSizeDepth SetDstBlockSizeDepth => (SetDstBlockSizeDepth)((SetDstBlockSize >> 8) & 0xF);
public uint SetDstWidth;
public uint SetDstHeight;
public uint SetDstDepth;
public uint SetDstLayer;
public uint SetDstOriginBytesX;
- public int SetDstOriginBytesXV => (int)(SetDstOriginBytesX & 0xFFFFF);
+ public readonly int SetDstOriginBytesXV => (int)(SetDstOriginBytesX & 0xFFFFF);
public uint SetDstOriginSamplesY;
- public int SetDstOriginSamplesYV => (int)(SetDstOriginSamplesY & 0xFFFF);
+ public readonly int SetDstOriginSamplesYV => (int)(SetDstOriginSamplesY & 0xFFFF);
public uint LaunchDma;
- public LaunchDmaDstMemoryLayout LaunchDmaDstMemoryLayout => (LaunchDmaDstMemoryLayout)(LaunchDma & 0x1);
- public LaunchDmaCompletionType LaunchDmaCompletionType => (LaunchDmaCompletionType)((LaunchDma >> 4) & 0x3);
- public LaunchDmaInterruptType LaunchDmaInterruptType => (LaunchDmaInterruptType)((LaunchDma >> 8) & 0x3);
- public LaunchDmaSemaphoreStructSize LaunchDmaSemaphoreStructSize => (LaunchDmaSemaphoreStructSize)((LaunchDma >> 12) & 0x1);
- public bool LaunchDmaReductionEnable => (LaunchDma & 0x2) != 0;
- public LaunchDmaReductionOp LaunchDmaReductionOp => (LaunchDmaReductionOp)((LaunchDma >> 13) & 0x7);
- public LaunchDmaReductionFormat LaunchDmaReductionFormat => (LaunchDmaReductionFormat)((LaunchDma >> 2) & 0x3);
- public bool LaunchDmaSysmembarDisable => (LaunchDma & 0x40) != 0;
+ public readonly LaunchDmaDstMemoryLayout LaunchDmaDstMemoryLayout => (LaunchDmaDstMemoryLayout)(LaunchDma & 0x1);
+ public readonly LaunchDmaCompletionType LaunchDmaCompletionType => (LaunchDmaCompletionType)((LaunchDma >> 4) & 0x3);
+ public readonly LaunchDmaInterruptType LaunchDmaInterruptType => (LaunchDmaInterruptType)((LaunchDma >> 8) & 0x3);
+ public readonly LaunchDmaSemaphoreStructSize LaunchDmaSemaphoreStructSize => (LaunchDmaSemaphoreStructSize)((LaunchDma >> 12) & 0x1);
+ public readonly bool LaunchDmaReductionEnable => (LaunchDma & 0x2) != 0;
+ public readonly LaunchDmaReductionOp LaunchDmaReductionOp => (LaunchDmaReductionOp)((LaunchDma >> 13) & 0x7);
+ public readonly LaunchDmaReductionFormat LaunchDmaReductionFormat => (LaunchDmaReductionFormat)((LaunchDma >> 2) & 0x3);
+ public readonly bool LaunchDmaSysmembarDisable => (LaunchDma & 0x40) != 0;
public uint LoadInlineData;
public fixed uint Reserved1B8[22];
public Boolean32 EarlyZForce;
@@ -1042,7 +1042,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
public fixed uint Reserved260C[125];
public Array4<Array32<uint>> TfVaryingLocations;
public fixed uint Reserved2A00[640];
- public MmeShadowScratch SetMmeShadowScratch;
+ public Array256<uint> SetMmeShadowScratch;
#pragma warning restore CS0649
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Twod/TwodClass.cs b/src/Ryujinx.Graphics.Gpu/Engine/Twod/TwodClass.cs
index 2ac84ab5..b33fb7f7 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Twod/TwodClass.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Twod/TwodClass.cs
@@ -30,7 +30,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
_channel = channel;
_state = new DeviceState<TwodClassState>(new Dictionary<string, RwCallback>
{
- { nameof(TwodClassState.PixelsFromMemorySrcY0Int), new RwCallback(PixelsFromMemorySrcY0Int, null) }
+ { nameof(TwodClassState.PixelsFromMemorySrcY0Int), new RwCallback(PixelsFromMemorySrcY0Int, null) },
});
}
@@ -57,7 +57,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
/// <param name="lhsFormat">Format of the first texture</param>
/// <param name="rhsFormat">Format of the second texture</param>
/// <returns>True if the data is compatible, false otherwise</returns>
- private bool IsDataCompatible(TwodTexture lhs, TwodTexture rhs, FormatInfo lhsFormat, FormatInfo rhsFormat)
+ private static bool IsDataCompatible(TwodTexture lhs, TwodTexture rhs, FormatInfo lhsFormat, FormatInfo rhsFormat)
{
if (lhsFormat.BytesPerPixel != rhsFormat.BytesPerPixel ||
lhs.Height != rhs.Height ||
@@ -88,7 +88,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
/// <param name="x2">Region end x</param>
/// <param name="y2">Region end y</param>
/// <returns>True if the region covers the full texture, false otherwise</returns>
- private bool IsCopyRegionComplete(TwodTexture texture, FormatInfo formatInfo, int x1, int y1, int x2, int y2)
+ private static bool IsCopyRegionComplete(TwodTexture texture, FormatInfo formatInfo, int x1, int y1, int x2, int y2)
{
if (x1 != 0 || y1 != 0 || y2 != texture.Height)
{
@@ -172,7 +172,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
for (int y = 0; y < height; y++)
{
- srcSpan.Slice(offset, lineSize).CopyTo(dstSpan.Slice(offset));
+ srcSpan.Slice(offset, lineSize).CopyTo(dstSpan[offset..]);
offset += stride;
}
@@ -364,13 +364,13 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
float scale = srcTexture.ScaleFactor;
float dstScale = dstTexture.ScaleFactor;
- Extents2D srcRegion = new Extents2D(
+ Extents2D srcRegion = new(
(int)Math.Ceiling(scale * (srcX1 / srcTexture.Info.SamplesInX)),
(int)Math.Ceiling(scale * (srcY1 / srcTexture.Info.SamplesInY)),
(int)Math.Ceiling(scale * (srcX2 / srcTexture.Info.SamplesInX)),
(int)Math.Ceiling(scale * (srcY2 / srcTexture.Info.SamplesInY)));
- Extents2D dstRegion = new Extents2D(
+ Extents2D dstRegion = new(
(int)Math.Ceiling(dstScale * (dstX1 / dstTexture.Info.SamplesInX)),
(int)Math.Ceiling(dstScale * (dstY1 / dstTexture.Info.SamplesInY)),
(int)Math.Ceiling(dstScale * (dstX2 / dstTexture.Info.SamplesInX)),
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Twod/TwodClassState.cs b/src/Ryujinx.Graphics.Gpu/Engine/Twod/TwodClassState.cs
index 55e5019f..edea7327 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Twod/TwodClassState.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Twod/TwodClassState.cs
@@ -486,7 +486,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
/// </summary>
struct RenderSolidPrimPoint
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public uint SetX;
public uint Y;
#pragma warning restore CS0649
@@ -497,30 +497,30 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
/// </summary>
unsafe struct TwodClassState : IShadowState
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public uint SetObject;
- public int SetObjectClassId => (int)(SetObject & 0xFFFF);
- public int SetObjectEngineId => (int)((SetObject >> 16) & 0x1F);
+ public readonly int SetObjectClassId => (int)(SetObject & 0xFFFF);
+ public readonly int SetObjectEngineId => (int)((SetObject >> 16) & 0x1F);
public fixed uint Reserved04[63];
public uint NoOperation;
public uint SetNotifyA;
- public int SetNotifyAAddressUpper => (int)(SetNotifyA & 0x1FFFFFF);
+ public readonly int SetNotifyAAddressUpper => (int)(SetNotifyA & 0x1FFFFFF);
public uint SetNotifyB;
public uint Notify;
- public NotifyType NotifyType => (NotifyType)(Notify);
+ public readonly NotifyType NotifyType => (NotifyType)(Notify);
public uint WaitForIdle;
public uint LoadMmeInstructionRamPointer;
public uint LoadMmeInstructionRam;
public uint LoadMmeStartAddressRamPointer;
public uint LoadMmeStartAddressRam;
public uint SetMmeShadowRamControl;
- public SetMmeShadowRamControlMode SetMmeShadowRamControlMode => (SetMmeShadowRamControlMode)(SetMmeShadowRamControl & 0x3);
+ public readonly SetMmeShadowRamControlMode SetMmeShadowRamControlMode => (SetMmeShadowRamControlMode)(SetMmeShadowRamControl & 0x3);
public fixed uint Reserved128[2];
public uint SetGlobalRenderEnableA;
- public int SetGlobalRenderEnableAOffsetUpper => (int)(SetGlobalRenderEnableA & 0xFF);
+ public readonly int SetGlobalRenderEnableAOffsetUpper => (int)(SetGlobalRenderEnableA & 0xFF);
public uint SetGlobalRenderEnableB;
public uint SetGlobalRenderEnableC;
- public int SetGlobalRenderEnableCMode => (int)(SetGlobalRenderEnableC & 0x7);
+ public readonly int SetGlobalRenderEnableCMode => (int)(SetGlobalRenderEnableC & 0x7);
public uint SendGoIdle;
public uint PmTrigger;
public fixed uint Reserved144[3];
@@ -528,54 +528,54 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
public uint SetInstrumentationMethodData;
public fixed uint Reserved158[37];
public uint SetMmeSwitchState;
- public bool SetMmeSwitchStateValid => (SetMmeSwitchState & 0x1) != 0;
- public int SetMmeSwitchStateSaveMacro => (int)((SetMmeSwitchState >> 4) & 0xFF);
- public int SetMmeSwitchStateRestoreMacro => (int)((SetMmeSwitchState >> 12) & 0xFF);
+ public readonly bool SetMmeSwitchStateValid => (SetMmeSwitchState & 0x1) != 0;
+ public readonly int SetMmeSwitchStateSaveMacro => (int)((SetMmeSwitchState >> 4) & 0xFF);
+ public readonly int SetMmeSwitchStateRestoreMacro => (int)((SetMmeSwitchState >> 12) & 0xFF);
public fixed uint Reserved1F0[4];
public uint SetDstFormat;
- public SetDstFormatV SetDstFormatV => (SetDstFormatV)(SetDstFormat & 0xFF);
+ public readonly SetDstFormatV SetDstFormatV => (SetDstFormatV)(SetDstFormat & 0xFF);
public uint SetDstMemoryLayout;
- public SetDstMemoryLayoutV SetDstMemoryLayoutV => (SetDstMemoryLayoutV)(SetDstMemoryLayout & 0x1);
+ public readonly SetDstMemoryLayoutV SetDstMemoryLayoutV => (SetDstMemoryLayoutV)(SetDstMemoryLayout & 0x1);
public uint SetDstBlockSize;
- public SetDstBlockSizeHeight SetDstBlockSizeHeight => (SetDstBlockSizeHeight)((SetDstBlockSize >> 4) & 0x7);
- public SetDstBlockSizeDepth SetDstBlockSizeDepth => (SetDstBlockSizeDepth)((SetDstBlockSize >> 8) & 0x7);
+ public readonly SetDstBlockSizeHeight SetDstBlockSizeHeight => (SetDstBlockSizeHeight)((SetDstBlockSize >> 4) & 0x7);
+ public readonly SetDstBlockSizeDepth SetDstBlockSizeDepth => (SetDstBlockSizeDepth)((SetDstBlockSize >> 8) & 0x7);
public uint SetDstDepth;
public uint SetDstLayer;
public uint SetDstPitch;
public uint SetDstWidth;
public uint SetDstHeight;
public uint SetDstOffsetUpper;
- public int SetDstOffsetUpperV => (int)(SetDstOffsetUpper & 0xFF);
+ public readonly int SetDstOffsetUpperV => (int)(SetDstOffsetUpper & 0xFF);
public uint SetDstOffsetLower;
public uint FlushAndInvalidateRopMiniCache;
- public bool FlushAndInvalidateRopMiniCacheV => (FlushAndInvalidateRopMiniCache & 0x1) != 0;
+ public readonly bool FlushAndInvalidateRopMiniCacheV => (FlushAndInvalidateRopMiniCache & 0x1) != 0;
public uint SetSpareNoop06;
public uint SetSrcFormat;
- public SetSrcFormatV SetSrcFormatV => (SetSrcFormatV)(SetSrcFormat & 0xFF);
+ public readonly SetSrcFormatV SetSrcFormatV => (SetSrcFormatV)(SetSrcFormat & 0xFF);
public uint SetSrcMemoryLayout;
- public SetSrcMemoryLayoutV SetSrcMemoryLayoutV => (SetSrcMemoryLayoutV)(SetSrcMemoryLayout & 0x1);
+ public readonly SetSrcMemoryLayoutV SetSrcMemoryLayoutV => (SetSrcMemoryLayoutV)(SetSrcMemoryLayout & 0x1);
public uint SetSrcBlockSize;
- public SetSrcBlockSizeHeight SetSrcBlockSizeHeight => (SetSrcBlockSizeHeight)((SetSrcBlockSize >> 4) & 0x7);
- public SetSrcBlockSizeDepth SetSrcBlockSizeDepth => (SetSrcBlockSizeDepth)((SetSrcBlockSize >> 8) & 0x7);
+ public readonly SetSrcBlockSizeHeight SetSrcBlockSizeHeight => (SetSrcBlockSizeHeight)((SetSrcBlockSize >> 4) & 0x7);
+ public readonly SetSrcBlockSizeDepth SetSrcBlockSizeDepth => (SetSrcBlockSizeDepth)((SetSrcBlockSize >> 8) & 0x7);
public uint SetSrcDepth;
public uint TwodInvalidateTextureDataCache;
- public TwodInvalidateTextureDataCacheV TwodInvalidateTextureDataCacheV => (TwodInvalidateTextureDataCacheV)(TwodInvalidateTextureDataCache & 0x3);
+ public readonly TwodInvalidateTextureDataCacheV TwodInvalidateTextureDataCacheV => (TwodInvalidateTextureDataCacheV)(TwodInvalidateTextureDataCache & 0x3);
public uint SetSrcPitch;
public uint SetSrcWidth;
public uint SetSrcHeight;
public uint SetSrcOffsetUpper;
- public int SetSrcOffsetUpperV => (int)(SetSrcOffsetUpper & 0xFF);
+ public readonly int SetSrcOffsetUpperV => (int)(SetSrcOffsetUpper & 0xFF);
public uint SetSrcOffsetLower;
public uint SetPixelsFromMemorySectorPromotion;
- public SetPixelsFromMemorySectorPromotionV SetPixelsFromMemorySectorPromotionV => (SetPixelsFromMemorySectorPromotionV)(SetPixelsFromMemorySectorPromotion & 0x3);
+ public readonly SetPixelsFromMemorySectorPromotionV SetPixelsFromMemorySectorPromotionV => (SetPixelsFromMemorySectorPromotionV)(SetPixelsFromMemorySectorPromotion & 0x3);
public uint SetSpareNoop12;
public uint SetNumProcessingClusters;
- public SetNumProcessingClustersV SetNumProcessingClustersV => (SetNumProcessingClustersV)(SetNumProcessingClusters & 0x1);
+ public readonly SetNumProcessingClustersV SetNumProcessingClustersV => (SetNumProcessingClustersV)(SetNumProcessingClusters & 0x1);
public uint SetRenderEnableA;
- public int SetRenderEnableAOffsetUpper => (int)(SetRenderEnableA & 0xFF);
+ public readonly int SetRenderEnableAOffsetUpper => (int)(SetRenderEnableA & 0xFF);
public uint SetRenderEnableB;
public uint SetRenderEnableC;
- public int SetRenderEnableCMode => (int)(SetRenderEnableC & 0x7);
+ public readonly int SetRenderEnableCMode => (int)(SetRenderEnableC & 0x7);
public uint SetSpareNoop08;
public uint SetSpareNoop01;
public uint SetSpareNoop11;
@@ -585,29 +585,29 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
public uint SetClipWidth;
public uint SetClipHeight;
public uint SetClipEnable;
- public bool SetClipEnableV => (SetClipEnable & 0x1) != 0;
+ public readonly bool SetClipEnableV => (SetClipEnable & 0x1) != 0;
public uint SetColorKeyFormat;
- public SetColorKeyFormatV SetColorKeyFormatV => (SetColorKeyFormatV)(SetColorKeyFormat & 0x7);
+ public readonly SetColorKeyFormatV SetColorKeyFormatV => (SetColorKeyFormatV)(SetColorKeyFormat & 0x7);
public uint SetColorKey;
public uint SetColorKeyEnable;
- public bool SetColorKeyEnableV => (SetColorKeyEnable & 0x1) != 0;
+ public readonly bool SetColorKeyEnableV => (SetColorKeyEnable & 0x1) != 0;
public uint SetRop;
- public int SetRopV => (int)(SetRop & 0xFF);
+ public readonly int SetRopV => (int)(SetRop & 0xFF);
public uint SetBeta1;
public uint SetBeta4;
- public int SetBeta4B => (int)(SetBeta4 & 0xFF);
- public int SetBeta4G => (int)((SetBeta4 >> 8) & 0xFF);
- public int SetBeta4R => (int)((SetBeta4 >> 16) & 0xFF);
- public int SetBeta4A => (int)((SetBeta4 >> 24) & 0xFF);
+ public readonly int SetBeta4B => (int)(SetBeta4 & 0xFF);
+ public readonly int SetBeta4G => (int)((SetBeta4 >> 8) & 0xFF);
+ public readonly int SetBeta4R => (int)((SetBeta4 >> 16) & 0xFF);
+ public readonly int SetBeta4A => (int)((SetBeta4 >> 24) & 0xFF);
public uint SetOperation;
- public SetOperationV SetOperationV => (SetOperationV)(SetOperation & 0x7);
+ public readonly SetOperationV SetOperationV => (SetOperationV)(SetOperation & 0x7);
public uint SetPatternOffset;
- public int SetPatternOffsetX => (int)(SetPatternOffset & 0x3F);
- public int SetPatternOffsetY => (int)((SetPatternOffset >> 8) & 0x3F);
+ public readonly int SetPatternOffsetX => (int)(SetPatternOffset & 0x3F);
+ public readonly int SetPatternOffsetY => (int)((SetPatternOffset >> 8) & 0x3F);
public uint SetPatternSelect;
- public SetPatternSelectV SetPatternSelectV => (SetPatternSelectV)(SetPatternSelect & 0x3);
+ public readonly SetPatternSelectV SetPatternSelectV => (SetPatternSelectV)(SetPatternSelect & 0x3);
public uint SetDstColorRenderToZetaSurface;
- public bool SetDstColorRenderToZetaSurfaceV => (SetDstColorRenderToZetaSurface & 0x1) != 0;
+ public readonly bool SetDstColorRenderToZetaSurfaceV => (SetDstColorRenderToZetaSurface & 0x1) != 0;
public uint SetSpareNoop04;
public uint SetSpareNoop15;
public uint SetSpareNoop13;
@@ -615,18 +615,18 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
public uint SetSpareNoop14;
public uint SetSpareNoop02;
public uint SetCompression;
- public bool SetCompressionEnable => (SetCompression & 0x1) != 0;
+ public readonly bool SetCompressionEnable => (SetCompression & 0x1) != 0;
public uint SetSpareNoop09;
public uint SetRenderEnableOverride;
- public SetRenderEnableOverrideMode SetRenderEnableOverrideMode => (SetRenderEnableOverrideMode)(SetRenderEnableOverride & 0x3);
+ public readonly SetRenderEnableOverrideMode SetRenderEnableOverrideMode => (SetRenderEnableOverrideMode)(SetRenderEnableOverride & 0x3);
public uint SetPixelsFromMemoryDirection;
- public SetPixelsFromMemoryDirectionHorizontal SetPixelsFromMemoryDirectionHorizontal => (SetPixelsFromMemoryDirectionHorizontal)(SetPixelsFromMemoryDirection & 0x3);
- public SetPixelsFromMemoryDirectionVertical SetPixelsFromMemoryDirectionVertical => (SetPixelsFromMemoryDirectionVertical)((SetPixelsFromMemoryDirection >> 4) & 0x3);
+ public readonly SetPixelsFromMemoryDirectionHorizontal SetPixelsFromMemoryDirectionHorizontal => (SetPixelsFromMemoryDirectionHorizontal)(SetPixelsFromMemoryDirection & 0x3);
+ public readonly SetPixelsFromMemoryDirectionVertical SetPixelsFromMemoryDirectionVertical => (SetPixelsFromMemoryDirectionVertical)((SetPixelsFromMemoryDirection >> 4) & 0x3);
public uint SetSpareNoop10;
public uint SetMonochromePatternColorFormat;
- public SetMonochromePatternColorFormatV SetMonochromePatternColorFormatV => (SetMonochromePatternColorFormatV)(SetMonochromePatternColorFormat & 0x7);
+ public readonly SetMonochromePatternColorFormatV SetMonochromePatternColorFormatV => (SetMonochromePatternColorFormatV)(SetMonochromePatternColorFormat & 0x7);
public uint SetMonochromePatternFormat;
- public SetMonochromePatternFormatV SetMonochromePatternFormatV => (SetMonochromePatternFormatV)(SetMonochromePatternFormat & 0x1);
+ public readonly SetMonochromePatternFormatV SetMonochromePatternFormatV => (SetMonochromePatternFormatV)(SetMonochromePatternFormat & 0x1);
public uint SetMonochromePatternColor0;
public uint SetMonochromePatternColor1;
public uint SetMonochromePattern0;
@@ -662,52 +662,52 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
public uint SetRenderSolidPrimColor2;
public uint SetRenderSolidPrimColor3;
public uint SetMmeMemAddressA;
- public int SetMmeMemAddressAUpper => (int)(SetMmeMemAddressA & 0x1FFFFFF);
+ public readonly int SetMmeMemAddressAUpper => (int)(SetMmeMemAddressA & 0x1FFFFFF);
public uint SetMmeMemAddressB;
public uint SetMmeDataRamAddress;
public uint MmeDmaRead;
public uint MmeDmaReadFifoed;
public uint MmeDmaWrite;
public uint MmeDmaReduction;
- public MmeDmaReductionReductionOp MmeDmaReductionReductionOp => (MmeDmaReductionReductionOp)(MmeDmaReduction & 0x7);
- public MmeDmaReductionReductionFormat MmeDmaReductionReductionFormat => (MmeDmaReductionReductionFormat)((MmeDmaReduction >> 4) & 0x3);
- public MmeDmaReductionReductionSize MmeDmaReductionReductionSize => (MmeDmaReductionReductionSize)((MmeDmaReduction >> 8) & 0x1);
+ public readonly MmeDmaReductionReductionOp MmeDmaReductionReductionOp => (MmeDmaReductionReductionOp)(MmeDmaReduction & 0x7);
+ public readonly MmeDmaReductionReductionFormat MmeDmaReductionReductionFormat => (MmeDmaReductionReductionFormat)((MmeDmaReduction >> 4) & 0x3);
+ public readonly MmeDmaReductionReductionSize MmeDmaReductionReductionSize => (MmeDmaReductionReductionSize)((MmeDmaReduction >> 8) & 0x1);
public uint MmeDmaSysmembar;
- public bool MmeDmaSysmembarV => (MmeDmaSysmembar & 0x1) != 0;
+ public readonly bool MmeDmaSysmembarV => (MmeDmaSysmembar & 0x1) != 0;
public uint MmeDmaSync;
public uint SetMmeDataFifoConfig;
- public SetMmeDataFifoConfigFifoSize SetMmeDataFifoConfigFifoSize => (SetMmeDataFifoConfigFifoSize)(SetMmeDataFifoConfig & 0x7);
+ public readonly SetMmeDataFifoConfigFifoSize SetMmeDataFifoConfigFifoSize => (SetMmeDataFifoConfigFifoSize)(SetMmeDataFifoConfig & 0x7);
public fixed uint Reserved578[2];
public uint RenderSolidPrimMode;
- public RenderSolidPrimModeV RenderSolidPrimModeV => (RenderSolidPrimModeV)(RenderSolidPrimMode & 0x7);
+ public readonly RenderSolidPrimModeV RenderSolidPrimModeV => (RenderSolidPrimModeV)(RenderSolidPrimMode & 0x7);
public uint SetRenderSolidPrimColorFormat;
- public SetRenderSolidPrimColorFormatV SetRenderSolidPrimColorFormatV => (SetRenderSolidPrimColorFormatV)(SetRenderSolidPrimColorFormat & 0xFF);
+ public readonly SetRenderSolidPrimColorFormatV SetRenderSolidPrimColorFormatV => (SetRenderSolidPrimColorFormatV)(SetRenderSolidPrimColorFormat & 0xFF);
public uint SetRenderSolidPrimColor;
public uint SetRenderSolidLineTieBreakBits;
- public bool SetRenderSolidLineTieBreakBitsXmajXincYinc => (SetRenderSolidLineTieBreakBits & 0x1) != 0;
- public bool SetRenderSolidLineTieBreakBitsXmajXdecYinc => (SetRenderSolidLineTieBreakBits & 0x10) != 0;
- public bool SetRenderSolidLineTieBreakBitsYmajXincYinc => (SetRenderSolidLineTieBreakBits & 0x100) != 0;
- public bool SetRenderSolidLineTieBreakBitsYmajXdecYinc => (SetRenderSolidLineTieBreakBits & 0x1000) != 0;
+ public readonly bool SetRenderSolidLineTieBreakBitsXmajXincYinc => (SetRenderSolidLineTieBreakBits & 0x1) != 0;
+ public readonly bool SetRenderSolidLineTieBreakBitsXmajXdecYinc => (SetRenderSolidLineTieBreakBits & 0x10) != 0;
+ public readonly bool SetRenderSolidLineTieBreakBitsYmajXincYinc => (SetRenderSolidLineTieBreakBits & 0x100) != 0;
+ public readonly bool SetRenderSolidLineTieBreakBitsYmajXdecYinc => (SetRenderSolidLineTieBreakBits & 0x1000) != 0;
public fixed uint Reserved590[20];
public uint RenderSolidPrimPointXY;
- public int RenderSolidPrimPointXYX => (int)(RenderSolidPrimPointXY & 0xFFFF);
- public int RenderSolidPrimPointXYY => (int)((RenderSolidPrimPointXY >> 16) & 0xFFFF);
+ public readonly int RenderSolidPrimPointXYX => (int)(RenderSolidPrimPointXY & 0xFFFF);
+ public readonly int RenderSolidPrimPointXYY => (int)((RenderSolidPrimPointXY >> 16) & 0xFFFF);
public fixed uint Reserved5E4[7];
public Array64<RenderSolidPrimPoint> RenderSolidPrimPoint;
public uint SetPixelsFromCpuDataType;
- public SetPixelsFromCpuDataTypeV SetPixelsFromCpuDataTypeV => (SetPixelsFromCpuDataTypeV)(SetPixelsFromCpuDataType & 0x1);
+ public readonly SetPixelsFromCpuDataTypeV SetPixelsFromCpuDataTypeV => (SetPixelsFromCpuDataTypeV)(SetPixelsFromCpuDataType & 0x1);
public uint SetPixelsFromCpuColorFormat;
- public SetPixelsFromCpuColorFormatV SetPixelsFromCpuColorFormatV => (SetPixelsFromCpuColorFormatV)(SetPixelsFromCpuColorFormat & 0xFF);
+ public readonly SetPixelsFromCpuColorFormatV SetPixelsFromCpuColorFormatV => (SetPixelsFromCpuColorFormatV)(SetPixelsFromCpuColorFormat & 0xFF);
public uint SetPixelsFromCpuIndexFormat;
- public SetPixelsFromCpuIndexFormatV SetPixelsFromCpuIndexFormatV => (SetPixelsFromCpuIndexFormatV)(SetPixelsFromCpuIndexFormat & 0x3);
+ public readonly SetPixelsFromCpuIndexFormatV SetPixelsFromCpuIndexFormatV => (SetPixelsFromCpuIndexFormatV)(SetPixelsFromCpuIndexFormat & 0x3);
public uint SetPixelsFromCpuMonoFormat;
- public SetPixelsFromCpuMonoFormatV SetPixelsFromCpuMonoFormatV => (SetPixelsFromCpuMonoFormatV)(SetPixelsFromCpuMonoFormat & 0x1);
+ public readonly SetPixelsFromCpuMonoFormatV SetPixelsFromCpuMonoFormatV => (SetPixelsFromCpuMonoFormatV)(SetPixelsFromCpuMonoFormat & 0x1);
public uint SetPixelsFromCpuWrap;
- public SetPixelsFromCpuWrapV SetPixelsFromCpuWrapV => (SetPixelsFromCpuWrapV)(SetPixelsFromCpuWrap & 0x3);
+ public readonly SetPixelsFromCpuWrapV SetPixelsFromCpuWrapV => (SetPixelsFromCpuWrapV)(SetPixelsFromCpuWrap & 0x3);
public uint SetPixelsFromCpuColor0;
public uint SetPixelsFromCpuColor1;
public uint SetPixelsFromCpuMonoOpacity;
- public SetPixelsFromCpuMonoOpacityV SetPixelsFromCpuMonoOpacityV => (SetPixelsFromCpuMonoOpacityV)(SetPixelsFromCpuMonoOpacity & 0x1);
+ public readonly SetPixelsFromCpuMonoOpacityV SetPixelsFromCpuMonoOpacityV => (SetPixelsFromCpuMonoOpacityV)(SetPixelsFromCpuMonoOpacity & 0x1);
public fixed uint Reserved820[6];
public uint SetPixelsFromCpuSrcWidth;
public uint SetPixelsFromCpuSrcHeight;
@@ -722,45 +722,45 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
public uint PixelsFromCpuData;
public fixed uint Reserved864[3];
public uint SetBigEndianControl;
- public bool SetBigEndianControlX32Swap1 => (SetBigEndianControl & 0x1) != 0;
- public bool SetBigEndianControlX32Swap4 => (SetBigEndianControl & 0x2) != 0;
- public bool SetBigEndianControlX32Swap8 => (SetBigEndianControl & 0x4) != 0;
- public bool SetBigEndianControlX32Swap16 => (SetBigEndianControl & 0x8) != 0;
- public bool SetBigEndianControlX16Swap1 => (SetBigEndianControl & 0x10) != 0;
- public bool SetBigEndianControlX16Swap4 => (SetBigEndianControl & 0x20) != 0;
- public bool SetBigEndianControlX16Swap8 => (SetBigEndianControl & 0x40) != 0;
- public bool SetBigEndianControlX16Swap16 => (SetBigEndianControl & 0x80) != 0;
- public bool SetBigEndianControlX8Swap1 => (SetBigEndianControl & 0x100) != 0;
- public bool SetBigEndianControlX8Swap4 => (SetBigEndianControl & 0x200) != 0;
- public bool SetBigEndianControlX8Swap8 => (SetBigEndianControl & 0x400) != 0;
- public bool SetBigEndianControlX8Swap16 => (SetBigEndianControl & 0x800) != 0;
- public bool SetBigEndianControlI1X8Cga6Swap1 => (SetBigEndianControl & 0x1000) != 0;
- public bool SetBigEndianControlI1X8Cga6Swap4 => (SetBigEndianControl & 0x2000) != 0;
- public bool SetBigEndianControlI1X8Cga6Swap8 => (SetBigEndianControl & 0x4000) != 0;
- public bool SetBigEndianControlI1X8Cga6Swap16 => (SetBigEndianControl & 0x8000) != 0;
- public bool SetBigEndianControlI1X8LeSwap1 => (SetBigEndianControl & 0x10000) != 0;
- public bool SetBigEndianControlI1X8LeSwap4 => (SetBigEndianControl & 0x20000) != 0;
- public bool SetBigEndianControlI1X8LeSwap8 => (SetBigEndianControl & 0x40000) != 0;
- public bool SetBigEndianControlI1X8LeSwap16 => (SetBigEndianControl & 0x80000) != 0;
- public bool SetBigEndianControlI4Swap1 => (SetBigEndianControl & 0x100000) != 0;
- public bool SetBigEndianControlI4Swap4 => (SetBigEndianControl & 0x200000) != 0;
- public bool SetBigEndianControlI4Swap8 => (SetBigEndianControl & 0x400000) != 0;
- public bool SetBigEndianControlI4Swap16 => (SetBigEndianControl & 0x800000) != 0;
- public bool SetBigEndianControlI8Swap1 => (SetBigEndianControl & 0x1000000) != 0;
- public bool SetBigEndianControlI8Swap4 => (SetBigEndianControl & 0x2000000) != 0;
- public bool SetBigEndianControlI8Swap8 => (SetBigEndianControl & 0x4000000) != 0;
- public bool SetBigEndianControlI8Swap16 => (SetBigEndianControl & 0x8000000) != 0;
- public bool SetBigEndianControlOverride => (SetBigEndianControl & 0x10000000) != 0;
+ public readonly bool SetBigEndianControlX32Swap1 => (SetBigEndianControl & 0x1) != 0;
+ public readonly bool SetBigEndianControlX32Swap4 => (SetBigEndianControl & 0x2) != 0;
+ public readonly bool SetBigEndianControlX32Swap8 => (SetBigEndianControl & 0x4) != 0;
+ public readonly bool SetBigEndianControlX32Swap16 => (SetBigEndianControl & 0x8) != 0;
+ public readonly bool SetBigEndianControlX16Swap1 => (SetBigEndianControl & 0x10) != 0;
+ public readonly bool SetBigEndianControlX16Swap4 => (SetBigEndianControl & 0x20) != 0;
+ public readonly bool SetBigEndianControlX16Swap8 => (SetBigEndianControl & 0x40) != 0;
+ public readonly bool SetBigEndianControlX16Swap16 => (SetBigEndianControl & 0x80) != 0;
+ public readonly bool SetBigEndianControlX8Swap1 => (SetBigEndianControl & 0x100) != 0;
+ public readonly bool SetBigEndianControlX8Swap4 => (SetBigEndianControl & 0x200) != 0;
+ public readonly bool SetBigEndianControlX8Swap8 => (SetBigEndianControl & 0x400) != 0;
+ public readonly bool SetBigEndianControlX8Swap16 => (SetBigEndianControl & 0x800) != 0;
+ public readonly bool SetBigEndianControlI1X8Cga6Swap1 => (SetBigEndianControl & 0x1000) != 0;
+ public readonly bool SetBigEndianControlI1X8Cga6Swap4 => (SetBigEndianControl & 0x2000) != 0;
+ public readonly bool SetBigEndianControlI1X8Cga6Swap8 => (SetBigEndianControl & 0x4000) != 0;
+ public readonly bool SetBigEndianControlI1X8Cga6Swap16 => (SetBigEndianControl & 0x8000) != 0;
+ public readonly bool SetBigEndianControlI1X8LeSwap1 => (SetBigEndianControl & 0x10000) != 0;
+ public readonly bool SetBigEndianControlI1X8LeSwap4 => (SetBigEndianControl & 0x20000) != 0;
+ public readonly bool SetBigEndianControlI1X8LeSwap8 => (SetBigEndianControl & 0x40000) != 0;
+ public readonly bool SetBigEndianControlI1X8LeSwap16 => (SetBigEndianControl & 0x80000) != 0;
+ public readonly bool SetBigEndianControlI4Swap1 => (SetBigEndianControl & 0x100000) != 0;
+ public readonly bool SetBigEndianControlI4Swap4 => (SetBigEndianControl & 0x200000) != 0;
+ public readonly bool SetBigEndianControlI4Swap8 => (SetBigEndianControl & 0x400000) != 0;
+ public readonly bool SetBigEndianControlI4Swap16 => (SetBigEndianControl & 0x800000) != 0;
+ public readonly bool SetBigEndianControlI8Swap1 => (SetBigEndianControl & 0x1000000) != 0;
+ public readonly bool SetBigEndianControlI8Swap4 => (SetBigEndianControl & 0x2000000) != 0;
+ public readonly bool SetBigEndianControlI8Swap8 => (SetBigEndianControl & 0x4000000) != 0;
+ public readonly bool SetBigEndianControlI8Swap16 => (SetBigEndianControl & 0x8000000) != 0;
+ public readonly bool SetBigEndianControlOverride => (SetBigEndianControl & 0x10000000) != 0;
public fixed uint Reserved874[3];
public uint SetPixelsFromMemoryBlockShape;
- public SetPixelsFromMemoryBlockShapeV SetPixelsFromMemoryBlockShapeV => (SetPixelsFromMemoryBlockShapeV)(SetPixelsFromMemoryBlockShape & 0x7);
+ public readonly SetPixelsFromMemoryBlockShapeV SetPixelsFromMemoryBlockShapeV => (SetPixelsFromMemoryBlockShapeV)(SetPixelsFromMemoryBlockShape & 0x7);
public uint SetPixelsFromMemoryCorralSize;
- public int SetPixelsFromMemoryCorralSizeV => (int)(SetPixelsFromMemoryCorralSize & 0x3FF);
+ public readonly int SetPixelsFromMemoryCorralSizeV => (int)(SetPixelsFromMemoryCorralSize & 0x3FF);
public uint SetPixelsFromMemorySafeOverlap;
- public bool SetPixelsFromMemorySafeOverlapV => (SetPixelsFromMemorySafeOverlap & 0x1) != 0;
+ public readonly bool SetPixelsFromMemorySafeOverlapV => (SetPixelsFromMemorySafeOverlap & 0x1) != 0;
public uint SetPixelsFromMemorySampleMode;
- public SetPixelsFromMemorySampleModeOrigin SetPixelsFromMemorySampleModeOrigin => (SetPixelsFromMemorySampleModeOrigin)(SetPixelsFromMemorySampleMode & 0x1);
- public SetPixelsFromMemorySampleModeFilter SetPixelsFromMemorySampleModeFilter => (SetPixelsFromMemorySampleModeFilter)((SetPixelsFromMemorySampleMode >> 4) & 0x1);
+ public readonly SetPixelsFromMemorySampleModeOrigin SetPixelsFromMemorySampleModeOrigin => (SetPixelsFromMemorySampleModeOrigin)(SetPixelsFromMemorySampleMode & 0x1);
+ public readonly SetPixelsFromMemorySampleModeFilter SetPixelsFromMemorySampleModeFilter => (SetPixelsFromMemorySampleModeFilter)((SetPixelsFromMemorySampleMode >> 4) & 0x1);
public fixed uint Reserved890[8];
public uint SetPixelsFromMemoryDstX0;
public uint SetPixelsFromMemoryDstY0;
@@ -808,9 +808,9 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
public uint SetFalcon31;
public fixed uint Reserved960[291];
public uint MmeDmaWriteMethodBarrier;
- public bool MmeDmaWriteMethodBarrierV => (MmeDmaWriteMethodBarrier & 0x1) != 0;
+ public readonly bool MmeDmaWriteMethodBarrierV => (MmeDmaWriteMethodBarrier & 0x1) != 0;
public fixed uint ReservedDF0[2436];
- public MmeShadowScratch SetMmeShadowScratch;
+ public Array256<uint> SetMmeShadowScratch;
#pragma warning restore CS0649
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Twod/TwodTexture.cs b/src/Ryujinx.Graphics.Gpu/Engine/Twod/TwodTexture.cs
index c28da094..dd6b6900 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Twod/TwodTexture.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Twod/TwodTexture.cs
@@ -7,7 +7,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
/// </summary>
struct TwodTexture
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public ColorFormat Format;
public Boolean32 LinearLayout;
public MemoryLayout MemoryLayout;
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Types/Boolean32.cs b/src/Ryujinx.Graphics.Gpu/Engine/Types/Boolean32.cs
index c982347a..911ad53b 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Types/Boolean32.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Types/Boolean32.cs
@@ -3,10 +3,10 @@
/// <summary>
/// Boolean value, stored as a 32-bits integer in memory.
/// </summary>
- struct Boolean32
+ readonly struct Boolean32
{
-#pragma warning disable CS0649
- private uint _value;
+#pragma warning disable CS0649 // Field is never assigned to
+ private readonly uint _value;
#pragma warning restore CS0649
public static implicit operator bool(Boolean32 value)
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Types/ColorFormat.cs b/src/Ryujinx.Graphics.Gpu/Engine/Types/ColorFormat.cs
index 889b5c8b..c798384f 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Types/ColorFormat.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Types/ColorFormat.cs
@@ -9,58 +9,58 @@ namespace Ryujinx.Graphics.Gpu.Engine.Types
enum ColorFormat
{
R32G32B32A32Float = 0xc0,
- R32G32B32A32Sint = 0xc1,
- R32G32B32A32Uint = 0xc2,
+ R32G32B32A32Sint = 0xc1,
+ R32G32B32A32Uint = 0xc2,
R32G32B32X32Float = 0xc3,
- R32G32B32X32Sint = 0xc4,
- R32G32B32X32Uint = 0xc5,
+ R32G32B32X32Sint = 0xc4,
+ R32G32B32X32Uint = 0xc5,
R16G16B16X16Unorm = 0xc6,
R16G16B16X16Snorm = 0xc7,
- R16G16B16X16Sint = 0xc8,
- R16G16B16X16Uint = 0xc9,
+ R16G16B16X16Sint = 0xc8,
+ R16G16B16X16Uint = 0xc9,
R16G16B16A16Float = 0xca,
- R32G32Float = 0xcb,
- R32G32Sint = 0xcc,
- R32G32Uint = 0xcd,
+ R32G32Float = 0xcb,
+ R32G32Sint = 0xcc,
+ R32G32Uint = 0xcd,
R16G16B16X16Float = 0xce,
- B8G8R8A8Unorm = 0xcf,
- B8G8R8A8Srgb = 0xd0,
- R10G10B10A2Unorm = 0xd1,
- R10G10B10A2Uint = 0xd2,
- R8G8B8A8Unorm = 0xd5,
- R8G8B8A8Srgb = 0xd6,
- R8G8B8X8Snorm = 0xd7,
- R8G8B8X8Sint = 0xd8,
- R8G8B8X8Uint = 0xd9,
- R16G16Unorm = 0xda,
- R16G16Snorm = 0xdb,
- R16G16Sint = 0xdc,
- R16G16Uint = 0xdd,
- R16G16Float = 0xde,
- R11G11B10Float = 0xe0,
- R32Sint = 0xe3,
- R32Uint = 0xe4,
- R32Float = 0xe5,
- B8G8R8X8Unorm = 0xe6,
- B8G8R8X8Srgb = 0xe7,
- B5G6R5Unorm = 0xe8,
- B5G5R5A1Unorm = 0xe9,
- R8G8Unorm = 0xea,
- R8G8Snorm = 0xeb,
- R8G8Sint = 0xec,
- R8G8Uint = 0xed,
- R16Unorm = 0xee,
- R16Snorm = 0xef,
- R16Sint = 0xf0,
- R16Uint = 0xf1,
- R16Float = 0xf2,
- R8Unorm = 0xf3,
- R8Snorm = 0xf4,
- R8Sint = 0xf5,
- R8Uint = 0xf6,
- B5G5R5X1Unorm = 0xf8,
- R8G8B8X8Unorm = 0xf9,
- R8G8B8X8Srgb = 0xfa
+ B8G8R8A8Unorm = 0xcf,
+ B8G8R8A8Srgb = 0xd0,
+ R10G10B10A2Unorm = 0xd1,
+ R10G10B10A2Uint = 0xd2,
+ R8G8B8A8Unorm = 0xd5,
+ R8G8B8A8Srgb = 0xd6,
+ R8G8B8X8Snorm = 0xd7,
+ R8G8B8X8Sint = 0xd8,
+ R8G8B8X8Uint = 0xd9,
+ R16G16Unorm = 0xda,
+ R16G16Snorm = 0xdb,
+ R16G16Sint = 0xdc,
+ R16G16Uint = 0xdd,
+ R16G16Float = 0xde,
+ R11G11B10Float = 0xe0,
+ R32Sint = 0xe3,
+ R32Uint = 0xe4,
+ R32Float = 0xe5,
+ B8G8R8X8Unorm = 0xe6,
+ B8G8R8X8Srgb = 0xe7,
+ B5G6R5Unorm = 0xe8,
+ B5G5R5A1Unorm = 0xe9,
+ R8G8Unorm = 0xea,
+ R8G8Snorm = 0xeb,
+ R8G8Sint = 0xec,
+ R8G8Uint = 0xed,
+ R16Unorm = 0xee,
+ R16Snorm = 0xef,
+ R16Sint = 0xf0,
+ R16Uint = 0xf1,
+ R16Float = 0xf2,
+ R8Unorm = 0xf3,
+ R8Snorm = 0xf4,
+ R8Sint = 0xf5,
+ R8Uint = 0xf6,
+ B5G5R5X1Unorm = 0xf8,
+ R8G8B8X8Unorm = 0xf9,
+ R8G8B8X8Srgb = 0xfa,
}
static class ColorFormatConverter
@@ -74,6 +74,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Types
{
return format switch
{
+#pragma warning disable IDE0055 // Disable formatting
ColorFormat.R32G32B32A32Float => new FormatInfo(Format.R32G32B32A32Float, 1, 1, 16, 4),
ColorFormat.R32G32B32A32Sint => new FormatInfo(Format.R32G32B32A32Sint, 1, 1, 16, 4),
ColorFormat.R32G32B32A32Uint => new FormatInfo(Format.R32G32B32A32Uint, 1, 1, 16, 4),
@@ -127,7 +128,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.Types
ColorFormat.B5G5R5X1Unorm => new FormatInfo(Format.B5G5R5A1Unorm, 1, 1, 2, 4),
ColorFormat.R8G8B8X8Unorm => new FormatInfo(Format.R8G8B8A8Unorm, 1, 1, 4, 4),
ColorFormat.R8G8B8X8Srgb => new FormatInfo(Format.R8G8B8A8Srgb, 1, 1, 4, 4),
- _ => FormatInfo.Default
+ _ => FormatInfo.Default,
+#pragma warning restore IDE0055
};
}
@@ -157,9 +159,9 @@ namespace Ryujinx.Graphics.Gpu.Engine.Types
case ColorFormat.R8G8B8X8Unorm:
case ColorFormat.R8G8B8X8Srgb:
return true;
+ default:
+ return false;
}
-
- return false;
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Types/GpuVa.cs b/src/Ryujinx.Graphics.Gpu/Engine/Types/GpuVa.cs
index 839faac9..b3b0c41a 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Types/GpuVa.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Types/GpuVa.cs
@@ -5,7 +5,7 @@
/// </summary>
struct GpuVa
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public uint High;
public uint Low;
#pragma warning restore CS0649
@@ -14,7 +14,7 @@
/// Packs the split address into a 64-bits address value.
/// </summary>
/// <returns>The 64-bits address value</returns>
- public ulong Pack()
+ public readonly ulong Pack()
{
return Low | ((ulong)High << 32);
}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Types/MemoryLayout.cs b/src/Ryujinx.Graphics.Gpu/Engine/Types/MemoryLayout.cs
index 6da96bd4..5a425373 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Types/MemoryLayout.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Types/MemoryLayout.cs
@@ -5,31 +5,31 @@
/// </summary>
struct MemoryLayout
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public uint Packed;
#pragma warning restore CS0649
- public int UnpackGobBlocksInX()
+ public readonly int UnpackGobBlocksInX()
{
return 1 << (int)(Packed & 0xf);
}
- public int UnpackGobBlocksInY()
+ public readonly int UnpackGobBlocksInY()
{
return 1 << (int)((Packed >> 4) & 0xf);
}
- public int UnpackGobBlocksInZ()
+ public readonly int UnpackGobBlocksInZ()
{
return 1 << (int)((Packed >> 8) & 0xf);
}
- public bool UnpackIsLinear()
+ public readonly bool UnpackIsLinear()
{
return (Packed & 0x1000) != 0;
}
- public bool UnpackIsTarget3D()
+ public readonly bool UnpackIsTarget3D()
{
return (Packed & 0x10000) != 0;
}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Types/PrimitiveType.cs b/src/Ryujinx.Graphics.Gpu/Engine/Types/PrimitiveType.cs
index dae63124..5abbc923 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Types/PrimitiveType.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Types/PrimitiveType.cs
@@ -21,7 +21,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Types
LineStripAdjacency,
TrianglesAdjacency,
TriangleStripAdjacency,
- Patches
+ Patches,
}
/// <summary>
@@ -39,7 +39,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Types
LineStripAdjacency = 11,
TrianglesAdjacency = 12,
TriangleStripAdjacency = 13,
- Patches = 14
+ Patches = 14,
}
static class PrimitiveTypeConverter
@@ -53,6 +53,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Types
{
return type switch
{
+#pragma warning disable IDE0055 // Disable formatting
PrimitiveType.Points => PrimitiveTopology.Points,
PrimitiveType.Lines => PrimitiveTopology.Lines,
PrimitiveType.LineLoop => PrimitiveTopology.LineLoop,
@@ -68,7 +69,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.Types
PrimitiveType.TrianglesAdjacency => PrimitiveTopology.TrianglesAdjacency,
PrimitiveType.TriangleStripAdjacency => PrimitiveTopology.TriangleStripAdjacency,
PrimitiveType.Patches => PrimitiveTopology.Patches,
- _ => PrimitiveTopology.Triangles
+ _ => PrimitiveTopology.Triangles,
+#pragma warning restore IDE0055
};
}
@@ -81,6 +83,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Types
{
return type switch
{
+#pragma warning disable IDE0055 // Disable formatting
PrimitiveTypeOverride.Points => PrimitiveTopology.Points,
PrimitiveTypeOverride.Lines => PrimitiveTopology.Lines,
PrimitiveTypeOverride.LineStrip => PrimitiveTopology.LineStrip,
@@ -92,8 +95,9 @@ namespace Ryujinx.Graphics.Gpu.Engine.Types
PrimitiveTypeOverride.TrianglesAdjacency => PrimitiveTopology.TrianglesAdjacency,
PrimitiveTypeOverride.TriangleStripAdjacency => PrimitiveTopology.TriangleStripAdjacency,
PrimitiveTypeOverride.Patches => PrimitiveTopology.Patches,
- _ => PrimitiveTopology.Triangles
+ _ => PrimitiveTopology.Triangles,
+#pragma warning restore IDE0055
};
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Types/SamplerIndex.cs b/src/Ryujinx.Graphics.Gpu/Engine/Types/SamplerIndex.cs
index 839a4d0a..22fe4a92 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Types/SamplerIndex.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Types/SamplerIndex.cs
@@ -5,7 +5,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Types
/// </summary>
enum SamplerIndex
{
- Independently = 0,
- ViaHeaderIndex = 1
+ Independently = 0,
+ ViaHeaderIndex = 1,
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Types/SbDescriptor.cs b/src/Ryujinx.Graphics.Gpu/Engine/Types/SbDescriptor.cs
index c457dbf9..e92263df 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Types/SbDescriptor.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Types/SbDescriptor.cs
@@ -5,14 +5,14 @@
/// </summary>
struct SbDescriptor
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public uint AddressLow;
public uint AddressHigh;
public int Size;
public int Padding;
#pragma warning restore CS0649
- public ulong PackAddress()
+ public readonly ulong PackAddress()
{
return AddressLow | ((ulong)AddressHigh << 32);
}
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Types/ZetaFormat.cs b/src/Ryujinx.Graphics.Gpu/Engine/Types/ZetaFormat.cs
index 1de1621f..0fa073d7 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Types/ZetaFormat.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Types/ZetaFormat.cs
@@ -8,13 +8,13 @@ namespace Ryujinx.Graphics.Gpu.Engine.Types
/// </summary>
enum ZetaFormat
{
- D32Float = 0xa,
- D16Unorm = 0x13,
+ D32Float = 0xa,
+ D16Unorm = 0x13,
D24UnormS8Uint = 0x14,
- D24Unorm = 0x15,
+ D24Unorm = 0x15,
S8UintD24Unorm = 0x16,
- S8Uint = 0x17,
- D32FloatS8Uint = 0x19
+ S8Uint = 0x17,
+ D32FloatS8Uint = 0x19,
}
static class ZetaFormatConverter
@@ -28,6 +28,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Types
{
return format switch
{
+#pragma warning disable IDE0055 // Disable formatting
ZetaFormat.D32Float => new FormatInfo(Format.D32Float, 1, 1, 4, 1),
ZetaFormat.D16Unorm => new FormatInfo(Format.D16Unorm, 1, 1, 2, 1),
ZetaFormat.D24UnormS8Uint => new FormatInfo(Format.D24UnormS8Uint, 1, 1, 4, 2),
@@ -35,7 +36,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.Types
ZetaFormat.S8UintD24Unorm => new FormatInfo(Format.S8UintD24Unorm, 1, 1, 4, 2),
ZetaFormat.S8Uint => new FormatInfo(Format.S8Uint, 1, 1, 1, 1),
ZetaFormat.D32FloatS8Uint => new FormatInfo(Format.D32FloatS8Uint, 1, 1, 8, 2),
- _ => FormatInfo.Default
+ _ => FormatInfo.Default,
+#pragma warning restore IDE0055
};
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/GpuChannel.cs b/src/Ryujinx.Graphics.Gpu/GpuChannel.cs
index 43fa8484..8fe64381 100644
--- a/src/Ryujinx.Graphics.Gpu/GpuChannel.cs
+++ b/src/Ryujinx.Graphics.Gpu/GpuChannel.cs
@@ -125,6 +125,7 @@ namespace Ryujinx.Graphics.Gpu
/// </summary>
public void Dispose()
{
+ GC.SuppressFinalize(this);
_context.DeferredActions.Enqueue(Destroy);
}
diff --git a/src/Ryujinx.Graphics.Gpu/GpuContext.cs b/src/Ryujinx.Graphics.Gpu/GpuContext.cs
index 233227b4..a5fe8f4c 100644
--- a/src/Ryujinx.Graphics.Gpu/GpuContext.cs
+++ b/src/Ryujinx.Graphics.Gpu/GpuContext.cs
@@ -99,7 +99,7 @@ namespace Ryujinx.Graphics.Gpu
private bool _pendingSync;
private long _modifiedSequence;
- private ulong _firstTimestamp;
+ private readonly ulong _firstTimestamp;
/// <summary>
/// Creates a new instance of the GPU emulation context.
@@ -220,7 +220,7 @@ namespace Ryujinx.Graphics.Gpu
/// <returns>The current GPU timestamp</returns>
public ulong GetTimestamp()
{
- // Guest timestamp will start at 0, instead of host value.
+ // Guest timestamp will start at 0, instead of host value.
ulong ticks = ConvertNanosecondsToTicks((ulong)PerformanceCounter.ElapsedNanoseconds) - _firstTimestamp;
if (GraphicsConfig.FastGpuTime)
@@ -406,4 +406,4 @@ namespace Ryujinx.Graphics.Gpu
Renderer.Dispose();
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/GraphicsConfig.cs b/src/Ryujinx.Graphics.Gpu/GraphicsConfig.cs
index d2f98c7f..4dfb9338 100644
--- a/src/Ryujinx.Graphics.Gpu/GraphicsConfig.cs
+++ b/src/Ryujinx.Graphics.Gpu/GraphicsConfig.cs
@@ -1,5 +1,6 @@
namespace Ryujinx.Graphics.Gpu
{
+#pragma warning disable CA2211 // Non-constant fields should not be visible
/// <summary>
/// General GPU and graphics configuration.
/// </summary>
@@ -67,4 +68,5 @@ namespace Ryujinx.Graphics.Gpu
/// </summary>
public static bool EnableTextureRecompression = false;
}
-} \ No newline at end of file
+#pragma warning restore CA2211
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/AutoDeleteCache.cs b/src/Ryujinx.Graphics.Gpu/Image/AutoDeleteCache.cs
index 2465efb0..05782605 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/AutoDeleteCache.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/AutoDeleteCache.cs
@@ -54,7 +54,7 @@ namespace Ryujinx.Graphics.Gpu.Image
private HashSet<ShortTextureCacheEntry> _shortCacheBuilder;
private HashSet<ShortTextureCacheEntry> _shortCache;
- private Dictionary<TextureDescriptor, ShortTextureCacheEntry> _shortCacheLookup;
+ private readonly Dictionary<TextureDescriptor, ShortTextureCacheEntry> _shortCacheLookup;
/// <summary>
/// Creates a new instance of the automatic deletion cache.
@@ -295,4 +295,4 @@ namespace Ryujinx.Graphics.Gpu.Image
return _textures.GetEnumerator();
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/FormatInfo.cs b/src/Ryujinx.Graphics.Gpu/Image/FormatInfo.cs
index 9ee649d2..8a9f37bb 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/FormatInfo.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/FormatInfo.cs
@@ -10,7 +10,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// <summary>
/// A default, generic RGBA8 texture format.
/// </summary>
- public static FormatInfo Default { get; } = new FormatInfo(Format.R8G8B8A8Unorm, 1, 1, 4, 4);
+ public static FormatInfo Default { get; } = new(Format.R8G8B8A8Unorm, 1, 1, 4, 4);
/// <summary>
/// The format of the texture data.
@@ -57,16 +57,16 @@ namespace Ryujinx.Graphics.Gpu.Image
/// <param name="bytesPerPixel">The number of bytes occupied by a single pixel in memory of the texture data</param>
public FormatInfo(
Format format,
- int blockWidth,
- int blockHeight,
- int bytesPerPixel,
- int components)
+ int blockWidth,
+ int blockHeight,
+ int bytesPerPixel,
+ int components)
{
- Format = format;
- BlockWidth = blockWidth;
- BlockHeight = blockHeight;
+ Format = format;
+ BlockWidth = blockWidth;
+ BlockHeight = blockHeight;
BytesPerPixel = bytesPerPixel;
- Components = components;
+ Components = components;
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/FormatTable.cs b/src/Ryujinx.Graphics.Gpu/Image/FormatTable.cs
index 72901610..ea5e9d00 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/FormatTable.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/FormatTable.cs
@@ -1,5 +1,6 @@
using Ryujinx.Graphics.GAL;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
namespace Ryujinx.Graphics.Gpu.Image
{
@@ -8,6 +9,8 @@ namespace Ryujinx.Graphics.Gpu.Image
/// </summary>
static class FormatTable
{
+#pragma warning disable IDE0055 // Disable formatting
+ [SuppressMessage("Design", "CA1069: Enums values should not be duplicated")]
private enum TextureFormat : uint
{
// Formats
@@ -244,6 +247,7 @@ namespace Ryujinx.Graphics.Gpu.Image
A5B5G5R1Unorm = A5B5G5R1 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24913
}
+ [SuppressMessage("Design", "CA1069: Enums values should not be duplicated")]
private enum VertexAttributeFormat : uint
{
// Width
@@ -357,7 +361,7 @@ namespace Ryujinx.Graphics.Gpu.Image
A2B10G10R10Sscaled = (A2B10G10R10 << 21) | (Sscaled << 27), // 0x36000000
}
- private static readonly Dictionary<TextureFormat, FormatInfo> _textureFormats = new Dictionary<TextureFormat, FormatInfo>()
+ private static readonly Dictionary<TextureFormat, FormatInfo> _textureFormats = new()
{
{ TextureFormat.R8Unorm, new FormatInfo(Format.R8Unorm, 1, 1, 1, 1) },
{ TextureFormat.R8Snorm, new FormatInfo(Format.R8Snorm, 1, 1, 1, 1) },
@@ -464,10 +468,10 @@ namespace Ryujinx.Graphics.Gpu.Image
{ TextureFormat.Astc2D10x10UnormSrgb, new FormatInfo(Format.Astc10x10Srgb, 10, 10, 16, 4) },
{ TextureFormat.Astc2D12x10UnormSrgb, new FormatInfo(Format.Astc12x10Srgb, 12, 10, 16, 4) },
{ TextureFormat.Astc2D12x12UnormSrgb, new FormatInfo(Format.Astc12x12Srgb, 12, 12, 16, 4) },
- { TextureFormat.A5B5G5R1Unorm, new FormatInfo(Format.A1B5G5R5Unorm, 1, 1, 2, 4) }
+ { TextureFormat.A5B5G5R1Unorm, new FormatInfo(Format.A1B5G5R5Unorm, 1, 1, 2, 4) },
};
- private static readonly Dictionary<VertexAttributeFormat, Format> _attribFormats = new Dictionary<VertexAttributeFormat, Format>()
+ private static readonly Dictionary<VertexAttributeFormat, Format> _attribFormats = new()
{
{ VertexAttributeFormat.R8Unorm, Format.R8Unorm },
{ VertexAttributeFormat.R8Snorm, Format.R8Snorm },
@@ -547,8 +551,9 @@ namespace Ryujinx.Graphics.Gpu.Image
{ VertexAttributeFormat.A2B10G10R10Snorm, Format.R10G10B10A2Snorm },
{ VertexAttributeFormat.A2B10G10R10Sint, Format.R10G10B10A2Sint },
{ VertexAttributeFormat.A2B10G10R10Uscaled, Format.R10G10B10A2Uscaled },
- { VertexAttributeFormat.A2B10G10R10Sscaled, Format.R10G10B10A2Sscaled }
+ { VertexAttributeFormat.A2B10G10R10Sscaled, Format.R10G10B10A2Sscaled },
};
+#pragma warning restore IDE0055
/// <summary>
/// Try getting the texture format from an encoded format integer from the Maxwell texture descriptor.
@@ -575,4 +580,4 @@ namespace Ryujinx.Graphics.Gpu.Image
return _attribFormats.TryGetValue((VertexAttributeFormat)encoded, out format);
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/Pool.cs b/src/Ryujinx.Graphics.Gpu/Image/Pool.cs
index 63be151f..0c3a219d 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/Pool.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/Pool.cs
@@ -67,7 +67,7 @@ namespace Ryujinx.Graphics.Gpu.Image
DescriptorCache = new T2[count];
Address = address;
- Size = size;
+ Size = size;
_memoryTracking = physicalMemory.BeginGranularTracking(address, size, ResourceKind.Pool);
_memoryTracking.RegisterPreciseAction(address, size, PreciseAction);
@@ -219,4 +219,4 @@ namespace Ryujinx.Graphics.Gpu.Image
_memoryTracking.Dispose();
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/PoolCache.cs b/src/Ryujinx.Graphics.Gpu/Image/PoolCache.cs
index e1493f38..d9881f89 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/PoolCache.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/PoolCache.cs
@@ -126,4 +126,4 @@ namespace Ryujinx.Graphics.Gpu.Image
_pools.Clear();
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/ReductionFilter.cs b/src/Ryujinx.Graphics.Gpu/Image/ReductionFilter.cs
index 1f7d9b07..01553e50 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/ReductionFilter.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/ReductionFilter.cs
@@ -10,6 +10,6 @@ namespace Ryujinx.Graphics.Gpu.Image
{
Average,
Minimum,
- Maximum
+ Maximum,
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/Sampler.cs b/src/Ryujinx.Graphics.Gpu/Image/Sampler.cs
index b70ac9eb..d6a3d975 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/Sampler.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/Sampler.cs
@@ -40,16 +40,16 @@ namespace Ryujinx.Graphics.Gpu.Image
AddressMode addressP = descriptor.UnpackAddressP();
CompareMode compareMode = descriptor.UnpackCompareMode();
- CompareOp compareOp = descriptor.UnpackCompareOp();
+ CompareOp compareOp = descriptor.UnpackCompareOp();
- ColorF color = new ColorF(
+ ColorF color = new(
descriptor.BorderColorR,
descriptor.BorderColorG,
descriptor.BorderColorB,
descriptor.BorderColorA);
- float minLod = descriptor.UnpackMinLod();
- float maxLod = descriptor.UnpackMaxLod();
+ float minLod = descriptor.UnpackMinLod();
+ float maxLod = descriptor.UnpackMaxLod();
float mipLodBias = descriptor.UnpackMipLodBias();
float maxRequestedAnisotropy = descriptor.UnpackMaxAnisotropy();
@@ -112,4 +112,4 @@ namespace Ryujinx.Graphics.Gpu.Image
_anisoSampler?.Dispose();
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/SamplerDescriptor.cs b/src/Ryujinx.Graphics.Gpu/Image/SamplerDescriptor.cs
index 64a146fb..e04c31df 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/SamplerDescriptor.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/SamplerDescriptor.cs
@@ -43,17 +43,17 @@ namespace Ryujinx.Graphics.Gpu.Image
0.45833334f,
0.46153846f,
0.4642857f,
- 0.46666667f
+ 0.46666667f,
};
private static readonly float[] _maxAnisotropyLut = new float[]
{
- 1, 2, 4, 6, 8, 10, 12, 16
+ 1, 2, 4, 6, 8, 10, 12, 16,
};
private const float Frac8ToF32 = 1.0f / 256.0f;
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public uint Word0;
public uint Word1;
public uint Word2;
@@ -68,7 +68,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Unpacks the texture wrap mode along the X axis.
/// </summary>
/// <returns>The texture wrap mode enum</returns>
- public AddressMode UnpackAddressU()
+ public readonly AddressMode UnpackAddressU()
{
return (AddressMode)(Word0 & 7);
}
@@ -77,7 +77,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Unpacks the texture wrap mode along the Y axis.
/// </summary>
/// <returns>The texture wrap mode enum</returns>
- public AddressMode UnpackAddressV()
+ public readonly AddressMode UnpackAddressV()
{
return (AddressMode)((Word0 >> 3) & 7);
}
@@ -86,7 +86,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Unpacks the texture wrap mode along the Z axis.
/// </summary>
/// <returns>The texture wrap mode enum</returns>
- public AddressMode UnpackAddressP()
+ public readonly AddressMode UnpackAddressP()
{
return (AddressMode)((Word0 >> 6) & 7);
}
@@ -97,7 +97,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// This is only relevant for shaders with shadow samplers.
/// </summary>
/// <returns>The depth comparison mode enum</returns>
- public CompareMode UnpackCompareMode()
+ public readonly CompareMode UnpackCompareMode()
{
return (CompareMode)((Word0 >> 9) & 1);
}
@@ -108,7 +108,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// This is only relevant for shaders with shadow samplers.
/// </summary>
/// <returns>The depth comparison operation enum</returns>
- public CompareOp UnpackCompareOp()
+ public readonly CompareOp UnpackCompareOp()
{
return (CompareOp)(((Word0 >> 10) & 7) + 1);
}
@@ -117,7 +117,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Unpacks and converts the maximum anisotropy value used for texture anisotropic filtering.
/// </summary>
/// <returns>The maximum anisotropy</returns>
- public float UnpackMaxAnisotropy()
+ public readonly float UnpackMaxAnisotropy()
{
return _maxAnisotropyLut[(Word0 >> 20) & 7];
}
@@ -128,7 +128,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// that is larger than the texture size.
/// </summary>
/// <returns>The magnification filter</returns>
- public MagFilter UnpackMagFilter()
+ public readonly MagFilter UnpackMagFilter()
{
return (MagFilter)(Word1 & 3);
}
@@ -139,7 +139,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// that is smaller than the texture size.
/// </summary>
/// <returns>The minification filter</returns>
- public MinFilter UnpackMinFilter()
+ public readonly MinFilter UnpackMinFilter()
{
SamplerMinFilter minFilter = (SamplerMinFilter)((Word1 >> 4) & 3);
SamplerMipFilter mipFilter = (SamplerMipFilter)((Word1 >> 6) & 3);
@@ -161,24 +161,30 @@ namespace Ryujinx.Graphics.Gpu.Image
case SamplerMipFilter.None:
switch (minFilter)
{
- case SamplerMinFilter.Nearest: return MinFilter.Nearest;
- case SamplerMinFilter.Linear: return MinFilter.Linear;
+ case SamplerMinFilter.Nearest:
+ return MinFilter.Nearest;
+ case SamplerMinFilter.Linear:
+ return MinFilter.Linear;
}
break;
case SamplerMipFilter.Nearest:
switch (minFilter)
{
- case SamplerMinFilter.Nearest: return MinFilter.NearestMipmapNearest;
- case SamplerMinFilter.Linear: return MinFilter.LinearMipmapNearest;
+ case SamplerMinFilter.Nearest:
+ return MinFilter.NearestMipmapNearest;
+ case SamplerMinFilter.Linear:
+ return MinFilter.LinearMipmapNearest;
}
break;
case SamplerMipFilter.Linear:
switch (minFilter)
{
- case SamplerMinFilter.Nearest: return MinFilter.NearestMipmapLinear;
- case SamplerMinFilter.Linear: return MinFilter.LinearMipmapLinear;
+ case SamplerMinFilter.Nearest:
+ return MinFilter.NearestMipmapLinear;
+ case SamplerMinFilter.Linear:
+ return MinFilter.LinearMipmapLinear;
}
break;
}
@@ -190,7 +196,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Unpacks the seamless cubemap flag.
/// </summary>
/// <returns>The seamless cubemap flag</returns>
- public bool UnpackSeamlessCubemap()
+ public readonly bool UnpackSeamlessCubemap()
{
return (Word1 & (1 << 9)) != 0;
}
@@ -200,7 +206,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// This describes how the final value will be computed from neighbouring pixels.
/// </summary>
/// <returns>The reduction filter</returns>
- public ReductionFilter UnpackReductionFilter()
+ public readonly ReductionFilter UnpackReductionFilter()
{
return (ReductionFilter)((Word1 >> 10) & 3);
}
@@ -211,7 +217,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// which mipmap level to use from a given texture.
/// </summary>
/// <returns>The level-of-detail bias value</returns>
- public float UnpackMipLodBias()
+ public readonly float UnpackMipLodBias()
{
int fixedValue = (int)(Word1 >> 12) & 0x1fff;
@@ -224,7 +230,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Unpacks the level-of-detail snap value.
/// </summary>
/// <returns>The level-of-detail snap value</returns>
- public float UnpackLodSnap()
+ public readonly float UnpackLodSnap()
{
return _f5ToF32ConversionLut[(Word1 >> 26) & 0x1f];
}
@@ -233,7 +239,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Unpacks the minimum level-of-detail value.
/// </summary>
/// <returns>The minimum level-of-detail value</returns>
- public float UnpackMinLod()
+ public readonly float UnpackMinLod()
{
return (Word2 & 0xfff) * Frac8ToF32;
}
@@ -242,7 +248,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Unpacks the maximum level-of-detail value.
/// </summary>
/// <returns>The maximum level-of-detail value</returns>
- public float UnpackMaxLod()
+ public readonly float UnpackMaxLod()
{
return ((Word2 >> 12) & 0xfff) * Frac8ToF32;
}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/SamplerMinFilter.cs b/src/Ryujinx.Graphics.Gpu/Image/SamplerMinFilter.cs
index 17beb129..d3009219 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/SamplerMinFilter.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/SamplerMinFilter.cs
@@ -6,6 +6,6 @@ namespace Ryujinx.Graphics.Gpu.Image
enum SamplerMinFilter
{
Nearest = 1,
- Linear
+ Linear,
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/SamplerMipFilter.cs b/src/Ryujinx.Graphics.Gpu/Image/SamplerMipFilter.cs
index 319d4196..b965f0c3 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/SamplerMipFilter.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/SamplerMipFilter.cs
@@ -7,6 +7,6 @@ namespace Ryujinx.Graphics.Gpu.Image
{
None = 1,
Nearest,
- Linear
+ Linear,
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/SamplerPool.cs b/src/Ryujinx.Graphics.Gpu/Image/SamplerPool.cs
index eb7222f9..3efcad76 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/SamplerPool.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/SamplerPool.cs
@@ -159,4 +159,4 @@ namespace Ryujinx.Graphics.Gpu.Image
item?.Dispose();
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/SamplerPoolCache.cs b/src/Ryujinx.Graphics.Gpu/Image/SamplerPoolCache.cs
index 3b3350fb..881c37af 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/SamplerPoolCache.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/SamplerPoolCache.cs
@@ -27,4 +27,4 @@ namespace Ryujinx.Graphics.Gpu.Image
return new SamplerPool(context, channel.MemoryManager.Physical, address, maximumId);
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/Texture.cs b/src/Ryujinx.Graphics.Gpu/Image/Texture.cs
index a7af1aad..c0d45cbd 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/Texture.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/Texture.cs
@@ -119,7 +119,7 @@ namespace Ryujinx.Graphics.Gpu.Image
private bool _modifiedStale = true;
private ITexture _arrayViewTexture;
- private Target _arrayViewTarget;
+ private Target _arrayViewTarget;
private ITexture _flushHostTexture;
private ITexture _setHostTexture;
@@ -334,7 +334,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// <returns>The child texture</returns>
public Texture CreateView(TextureInfo info, SizeInfo sizeInfo, MultiRange range, int firstLayer, int firstLevel)
{
- Texture texture = new Texture(
+ Texture texture = new(
_context,
_physicalMemory,
info,
@@ -523,7 +523,7 @@ namespace Ryujinx.Graphics.Gpu.Image
if (ScaleFactor != scale)
{
- Logger.Debug?.Print(LogClass.Gpu, $"Rescaling {Info.Width}x{Info.Height} {Info.FormatInfo.Format.ToString()} to ({ScaleFactor} to {scale}). ");
+ Logger.Debug?.Print(LogClass.Gpu, $"Rescaling {Info.Width}x{Info.Height} {Info.FormatInfo.Format} to ({ScaleFactor} to {scale}). ");
ScaleFactor = scale;
@@ -537,7 +537,7 @@ namespace Ryujinx.Graphics.Gpu.Image
foreach (var view in _views)
{
- Logger.Debug?.Print(LogClass.Gpu, $" Recreating view {Info.Width}x{Info.Height} {Info.FormatInfo.Format.ToString()}.");
+ Logger.Debug?.Print(LogClass.Gpu, $" Recreating view {Info.Width}x{Info.Height} {Info.FormatInfo.Format}.");
view.ScaleFactor = scale;
TextureCreateInfo viewCreateInfo = TextureCache.GetCreateInfo(view.Info, _context.Capabilities, scale);
@@ -1254,7 +1254,7 @@ namespace Ryujinx.Graphics.Gpu.Image
{
FormatInfo formatInfo = TextureCompatibility.ToHostCompatibleFormat(Info, _context.Capabilities);
- TextureCreateInfo createInfo = new TextureCreateInfo(
+ TextureCreateInfo createInfo = new(
Info.Width,
Info.Height,
target == Target.CubemapArray ? 6 : 1,
@@ -1274,7 +1274,7 @@ namespace Ryujinx.Graphics.Gpu.Image
ITexture viewTexture = HostTexture.CreateView(createInfo, 0, 0);
_arrayViewTexture = viewTexture;
- _arrayViewTarget = target;
+ _arrayViewTarget = target;
return viewTexture;
}
@@ -1317,29 +1317,21 @@ namespace Ryujinx.Graphics.Gpu.Image
{
case Target.Texture1D:
case Target.Texture1DArray:
- return target == Target.Texture1D ||
- target == Target.Texture1DArray;
-
+ return target == Target.Texture1D || target == Target.Texture1DArray;
case Target.Texture2D:
case Target.Texture2DArray:
- return target == Target.Texture2D ||
- target == Target.Texture2DArray;
-
+ return target == Target.Texture2D || target == Target.Texture2DArray;
case Target.Cubemap:
case Target.CubemapArray:
- return target == Target.Cubemap ||
- target == Target.CubemapArray;
-
+ return target == Target.Cubemap || target == Target.CubemapArray;
case Target.Texture2DMultisample:
case Target.Texture2DMultisampleArray:
- return target == Target.Texture2DMultisample ||
- target == Target.Texture2DMultisampleArray;
-
+ return target == Target.Texture2DMultisample || target == Target.Texture2DMultisampleArray;
case Target.Texture3D:
return target == Target.Texture3D;
+ default:
+ return false;
}
-
- return false;
}
/// <summary>
@@ -1398,7 +1390,7 @@ namespace Ryujinx.Graphics.Gpu.Image
Height = info.Height;
CanForceAnisotropy = CanTextureForceAnisotropy();
- _depth = info.GetDepth();
+ _depth = info.GetDepth();
_layers = info.GetLayers();
}
@@ -1714,4 +1706,4 @@ namespace Ryujinx.Graphics.Gpu.Image
}
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureBindingInfo.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureBindingInfo.cs
index febe508b..606842d6 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/TextureBindingInfo.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/TextureBindingInfo.cs
@@ -50,12 +50,12 @@ namespace Ryujinx.Graphics.Gpu.Image
/// <param name="flags">The texture's usage flags, indicating how it is used in the shader</param>
public TextureBindingInfo(Target target, Format format, int binding, int cbufSlot, int handle, TextureUsageFlags flags)
{
- Target = target;
- Format = format;
- Binding = binding;
+ Target = target;
+ Format = format;
+ Binding = binding;
CbufSlot = cbufSlot;
- Handle = handle;
- Flags = flags;
+ Handle = handle;
+ Flags = flags;
}
/// <summary>
@@ -70,4 +70,4 @@ namespace Ryujinx.Graphics.Gpu.Image
{
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs
index b08fb3eb..e5df1776 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs
@@ -93,10 +93,10 @@ namespace Ryujinx.Graphics.Gpu.Image
int stages = isCompute ? 1 : Constants.ShaderStages;
_textureBindings = new TextureBindingInfo[stages][];
- _imageBindings = new TextureBindingInfo[stages][];
+ _imageBindings = new TextureBindingInfo[stages][];
_textureState = new TextureState[InitialTextureStateSize];
- _imageState = new TextureState[InitialImageStateSize];
+ _imageState = new TextureState[InitialImageStateSize];
for (int stage = 0; stage < stages; stage++)
{
@@ -418,6 +418,7 @@ namespace Ryujinx.Graphics.Gpu.Image
}
}
+#pragma warning disable IDE0051 // Remove unused private member
/// <summary>
/// Counts the total number of texture bindings used by all shader stages.
/// </summary>
@@ -426,16 +427,17 @@ namespace Ryujinx.Graphics.Gpu.Image
{
int count = 0;
- for (int i = 0; i < _textureBindings.Length; i++)
+ foreach (TextureBindingInfo[] textureInfo in _textureBindings)
{
- if (_textureBindings[i] != null)
+ if (textureInfo != null)
{
- count += _textureBindings[i].Length;
+ count += textureInfo.Length;
}
}
return count;
}
+#pragma warning restore IDE0051
/// <summary>
/// Ensures that the texture bindings are visible to the host GPU.
diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureCache.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureCache.cs
index bccd3fd7..3f215a4a 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/TextureCache.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/TextureCache.cs
@@ -31,7 +31,7 @@ namespace Ryujinx.Graphics.Gpu.Image
}
private const int OverlapsBufferInitialCapacity = 10;
- private const int OverlapsBufferMaxCapacity = 10000;
+ private const int OverlapsBufferMaxCapacity = 10000;
private readonly GpuContext _context;
private readonly PhysicalMemory _physicalMemory;
@@ -224,7 +224,7 @@ namespace Ryujinx.Graphics.Gpu.Image
for (int i = 0; i < overlapCount; i++)
{
var other = _textureOverlaps[i];
-
+
if (texture != other &&
(texture.IsViewCompatible(other.Info, other.Range, true, other.LayerSize, _context.Capabilities, out _, out _) != TextureViewCompatibility.Incompatible ||
other.IsViewCompatible(texture.Info, texture.Range, true, texture.LayerSize, _context.Capabilities, out _, out _) != TextureViewCompatibility.Incompatible))
@@ -278,7 +278,7 @@ namespace Ryujinx.Graphics.Gpu.Image
width = copyTexture.Width;
}
- TextureInfo info = new TextureInfo(
+ TextureInfo info = new(
copyTexture.Address.Pack() + offset,
GetMinimumWidthInGob(width, sizeHint.Width, formatInfo.BytesPerPixel, copyTexture.LinearLayout),
copyTexture.Height,
@@ -371,16 +371,16 @@ namespace Ryujinx.Graphics.Gpu.Image
// so the width we get here is the aligned width.
if (isLinear)
{
- width = colorState.WidthOrStride / formatInfo.BytesPerPixel;
+ width = colorState.WidthOrStride / formatInfo.BytesPerPixel;
stride = colorState.WidthOrStride;
}
else
{
- width = colorState.WidthOrStride;
+ width = colorState.WidthOrStride;
stride = 0;
}
- TextureInfo info = new TextureInfo(
+ TextureInfo info = new(
colorState.Address.Pack(),
GetMinimumWidthInGob(width, sizeHint.Width, formatInfo.BytesPerPixel, isLinear),
colorState.Height,
@@ -449,7 +449,7 @@ namespace Ryujinx.Graphics.Gpu.Image
FormatInfo formatInfo = dsState.Format.Convert();
- TextureInfo info = new TextureInfo(
+ TextureInfo info = new(
dsState.Address.Pack(),
GetMinimumWidthInGob(size.Width, sizeHint.Width, formatInfo.BytesPerPixel, false),
size.Height,
@@ -1136,14 +1136,14 @@ namespace Ryujinx.Graphics.Gpu.Image
}
}
- int width = info.Width / info.SamplesInX;
+ int width = info.Width / info.SamplesInX;
int height = info.Height / info.SamplesInY;
int depth = info.GetDepth() * info.GetLayers();
if (scale != 1f)
{
- width = (int)MathF.Ceiling(width * scale);
+ width = (int)MathF.Ceiling(width * scale);
height = (int)MathF.Ceiling(height * scale);
}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureCompatibility.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureCompatibility.cs
index 9a8d048e..eafa50b2 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/TextureCompatibility.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/TextureCompatibility.cs
@@ -35,7 +35,7 @@ namespace Ryujinx.Graphics.Gpu.Image
Astc10x8,
Astc10x10,
Astc12x10,
- Astc12x12
+ Astc12x12,
}
/// <summary>
@@ -629,7 +629,7 @@ namespace Ryujinx.Graphics.Gpu.Image
{
TextureMatchQuality.Perfect => TextureViewCompatibility.Full,
TextureMatchQuality.FormatAlias => TextureViewCompatibility.FormatAlias,
- _ => TextureViewCompatibility.Incompatible
+ _ => TextureViewCompatibility.Incompatible,
};
}
@@ -783,80 +783,33 @@ namespace Ryujinx.Graphics.Gpu.Image
/// <returns>Format class</returns>
private static FormatClass GetFormatClass(Format format)
{
- switch (format)
- {
- case Format.Bc1RgbaSrgb:
- case Format.Bc1RgbaUnorm:
- return FormatClass.Bc1Rgba;
- case Format.Bc2Srgb:
- case Format.Bc2Unorm:
- return FormatClass.Bc2;
- case Format.Bc3Srgb:
- case Format.Bc3Unorm:
- return FormatClass.Bc3;
- case Format.Bc4Snorm:
- case Format.Bc4Unorm:
- return FormatClass.Bc4;
- case Format.Bc5Snorm:
- case Format.Bc5Unorm:
- return FormatClass.Bc5;
- case Format.Bc6HSfloat:
- case Format.Bc6HUfloat:
- return FormatClass.Bc6;
- case Format.Bc7Srgb:
- case Format.Bc7Unorm:
- return FormatClass.Bc7;
- case Format.Etc2RgbSrgb:
- case Format.Etc2RgbUnorm:
- return FormatClass.Etc2Rgb;
- case Format.Etc2RgbaSrgb:
- case Format.Etc2RgbaUnorm:
- return FormatClass.Etc2Rgba;
- case Format.Astc4x4Srgb:
- case Format.Astc4x4Unorm:
- return FormatClass.Astc4x4;
- case Format.Astc5x4Srgb:
- case Format.Astc5x4Unorm:
- return FormatClass.Astc5x4;
- case Format.Astc5x5Srgb:
- case Format.Astc5x5Unorm:
- return FormatClass.Astc5x5;
- case Format.Astc6x5Srgb:
- case Format.Astc6x5Unorm:
- return FormatClass.Astc6x5;
- case Format.Astc6x6Srgb:
- case Format.Astc6x6Unorm:
- return FormatClass.Astc6x6;
- case Format.Astc8x5Srgb:
- case Format.Astc8x5Unorm:
- return FormatClass.Astc8x5;
- case Format.Astc8x6Srgb:
- case Format.Astc8x6Unorm:
- return FormatClass.Astc8x6;
- case Format.Astc8x8Srgb:
- case Format.Astc8x8Unorm:
- return FormatClass.Astc8x8;
- case Format.Astc10x5Srgb:
- case Format.Astc10x5Unorm:
- return FormatClass.Astc10x5;
- case Format.Astc10x6Srgb:
- case Format.Astc10x6Unorm:
- return FormatClass.Astc10x6;
- case Format.Astc10x8Srgb:
- case Format.Astc10x8Unorm:
- return FormatClass.Astc10x8;
- case Format.Astc10x10Srgb:
- case Format.Astc10x10Unorm:
- return FormatClass.Astc10x10;
- case Format.Astc12x10Srgb:
- case Format.Astc12x10Unorm:
- return FormatClass.Astc12x10;
- case Format.Astc12x12Srgb:
- case Format.Astc12x12Unorm:
- return FormatClass.Astc12x12;
- }
-
- return FormatClass.Unclassified;
+ return format switch
+ {
+ Format.Bc1RgbaSrgb or Format.Bc1RgbaUnorm => FormatClass.Bc1Rgba,
+ Format.Bc2Srgb or Format.Bc2Unorm => FormatClass.Bc2,
+ Format.Bc3Srgb or Format.Bc3Unorm => FormatClass.Bc3,
+ Format.Bc4Snorm or Format.Bc4Unorm => FormatClass.Bc4,
+ Format.Bc5Snorm or Format.Bc5Unorm => FormatClass.Bc5,
+ Format.Bc6HSfloat or Format.Bc6HUfloat => FormatClass.Bc6,
+ Format.Bc7Srgb or Format.Bc7Unorm => FormatClass.Bc7,
+ Format.Etc2RgbSrgb or Format.Etc2RgbUnorm => FormatClass.Etc2Rgb,
+ Format.Etc2RgbaSrgb or Format.Etc2RgbaUnorm => FormatClass.Etc2Rgba,
+ Format.Astc4x4Srgb or Format.Astc4x4Unorm => FormatClass.Astc4x4,
+ Format.Astc5x4Srgb or Format.Astc5x4Unorm => FormatClass.Astc5x4,
+ Format.Astc5x5Srgb or Format.Astc5x5Unorm => FormatClass.Astc5x5,
+ Format.Astc6x5Srgb or Format.Astc6x5Unorm => FormatClass.Astc6x5,
+ Format.Astc6x6Srgb or Format.Astc6x6Unorm => FormatClass.Astc6x6,
+ Format.Astc8x5Srgb or Format.Astc8x5Unorm => FormatClass.Astc8x5,
+ Format.Astc8x6Srgb or Format.Astc8x6Unorm => FormatClass.Astc8x6,
+ Format.Astc8x8Srgb or Format.Astc8x8Unorm => FormatClass.Astc8x8,
+ Format.Astc10x5Srgb or Format.Astc10x5Unorm => FormatClass.Astc10x5,
+ Format.Astc10x6Srgb or Format.Astc10x6Unorm => FormatClass.Astc10x6,
+ Format.Astc10x8Srgb or Format.Astc10x8Unorm => FormatClass.Astc10x8,
+ Format.Astc10x10Srgb or Format.Astc10x10Unorm => FormatClass.Astc10x10,
+ Format.Astc12x10Srgb or Format.Astc12x10Unorm => FormatClass.Astc12x10,
+ Format.Astc12x12Srgb or Format.Astc12x12Unorm => FormatClass.Astc12x12,
+ _ => FormatClass.Unclassified,
+ };
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureComponent.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureComponent.cs
index 359069bc..172d11a8 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/TextureComponent.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/TextureComponent.cs
@@ -7,13 +7,13 @@ namespace Ryujinx.Graphics.Gpu.Image
/// </summary>
enum TextureComponent
{
- Zero = 0,
- Red = 2,
+ Zero = 0,
+ Red = 2,
Green = 3,
- Blue = 4,
+ Blue = 4,
Alpha = 5,
OneSI = 6,
- OneF = 7
+ OneF = 7,
}
static class TextureComponentConverter
@@ -25,19 +25,16 @@ namespace Ryujinx.Graphics.Gpu.Image
/// <returns>Converted enum</returns>
public static SwizzleComponent Convert(this TextureComponent component)
{
- switch (component)
+ return component switch
{
- case TextureComponent.Zero: return SwizzleComponent.Zero;
- case TextureComponent.Red: return SwizzleComponent.Red;
- case TextureComponent.Green: return SwizzleComponent.Green;
- case TextureComponent.Blue: return SwizzleComponent.Blue;
- case TextureComponent.Alpha: return SwizzleComponent.Alpha;
- case TextureComponent.OneSI:
- case TextureComponent.OneF:
- return SwizzleComponent.One;
- }
-
- return SwizzleComponent.Zero;
+ TextureComponent.Zero => SwizzleComponent.Zero,
+ TextureComponent.Red => SwizzleComponent.Red,
+ TextureComponent.Green => SwizzleComponent.Green,
+ TextureComponent.Blue => SwizzleComponent.Blue,
+ TextureComponent.Alpha => SwizzleComponent.Alpha,
+ TextureComponent.OneSI or TextureComponent.OneF => SwizzleComponent.One,
+ _ => SwizzleComponent.Zero,
+ };
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureDescriptor.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureDescriptor.cs
index 3e35f8d2..c82a555e 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/TextureDescriptor.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/TextureDescriptor.cs
@@ -9,7 +9,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// </summary>
struct TextureDescriptor : ITextureDescriptor, IEquatable<TextureDescriptor>
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public uint Word0;
public uint Word1;
public uint Word2;
@@ -24,7 +24,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Unpacks Maxwell texture format integer.
/// </summary>
/// <returns>The texture format integer</returns>
- public uint UnpackFormat()
+ public readonly uint UnpackFormat()
{
return Word0 & 0x8007ffff;
}
@@ -33,43 +33,43 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Unpacks the swizzle component for the texture red color channel.
/// </summary>
/// <returns>The swizzle component</returns>
- public TextureComponent UnpackSwizzleR()
+ public readonly TextureComponent UnpackSwizzleR()
{
- return(TextureComponent)((Word0 >> 19) & 7);
+ return (TextureComponent)((Word0 >> 19) & 7);
}
/// <summary>
/// Unpacks the swizzle component for the texture green color channel.
/// </summary>
/// <returns>The swizzle component</returns>
- public TextureComponent UnpackSwizzleG()
+ public readonly TextureComponent UnpackSwizzleG()
{
- return(TextureComponent)((Word0 >> 22) & 7);
+ return (TextureComponent)((Word0 >> 22) & 7);
}
/// <summary>
/// Unpacks the swizzle component for the texture blue color channel.
/// </summary>
/// <returns>The swizzle component</returns>
- public TextureComponent UnpackSwizzleB()
+ public readonly TextureComponent UnpackSwizzleB()
{
- return(TextureComponent)((Word0 >> 25) & 7);
+ return (TextureComponent)((Word0 >> 25) & 7);
}
/// <summary>
/// Unpacks the swizzle component for the texture alpha color channel.
/// </summary>
/// <returns>The swizzle component</returns>
- public TextureComponent UnpackSwizzleA()
+ public readonly TextureComponent UnpackSwizzleA()
{
- return(TextureComponent)((Word0 >> 28) & 7);
+ return (TextureComponent)((Word0 >> 28) & 7);
}
/// <summary>
/// Unpacks the 40-bits texture GPU virtual address.
/// </summary>
/// <returns>The GPU virtual address</returns>
- public ulong UnpackAddress()
+ public readonly ulong UnpackAddress()
{
return Word1 | ((ulong)(Word2 & 0xffff) << 32);
}
@@ -79,7 +79,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// This defines the texture layout, among other things.
/// </summary>
/// <returns>The texture descriptor type</returns>
- public TextureDescriptorType UnpackTextureDescriptorType()
+ public readonly TextureDescriptorType UnpackTextureDescriptorType()
{
return (TextureDescriptorType)((Word2 >> 21) & 7);
}
@@ -89,7 +89,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Always 32-bytes aligned.
/// </summary>
/// <returns>The linear texture stride</returns>
- public int UnpackStride()
+ public readonly int UnpackStride()
{
return (int)(Word3 & 0xffff) << 5;
}
@@ -99,7 +99,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Must be always 1, ignored by the GPU.
/// </summary>
/// <returns>THe GOB block X size</returns>
- public int UnpackGobBlocksInX()
+ public readonly int UnpackGobBlocksInX()
{
return 1 << (int)(Word3 & 7);
}
@@ -109,7 +109,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Must be always a power of 2, with a maximum value of 32.
/// </summary>
/// <returns>THe GOB block Y size</returns>
- public int UnpackGobBlocksInY()
+ public readonly int UnpackGobBlocksInY()
{
return 1 << (int)((Word3 >> 3) & 7);
}
@@ -120,7 +120,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Must be 1 for any texture target other than 3D textures.
/// </summary>
/// <returns>The GOB block Z size</returns>
- public int UnpackGobBlocksInZ()
+ public readonly int UnpackGobBlocksInZ()
{
return 1 << (int)((Word3 >> 6) & 7);
}
@@ -130,7 +130,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// This is only used for sparse textures, should be 1 otherwise.
/// </summary>
/// <returns>The number of GOB blocks per tile</returns>
- public int UnpackGobBlocksInTileX()
+ public readonly int UnpackGobBlocksInTileX()
{
return 1 << (int)((Word3 >> 10) & 7);
}
@@ -139,7 +139,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Unpacks the number of mipmap levels of the texture.
/// </summary>
/// <returns>The number of mipmap levels</returns>
- public int UnpackLevels()
+ public readonly int UnpackLevels()
{
return (int)(Word3 >> 28) + 1;
}
@@ -148,7 +148,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Unpack the base level texture width size.
/// </summary>
/// <returns>The texture width</returns>
- public int UnpackWidth()
+ public readonly int UnpackWidth()
{
return (int)(Word4 & 0xffff) + 1;
}
@@ -157,7 +157,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Unpack the width of a buffer texture.
/// </summary>
/// <returns>The texture width</returns>
- public int UnpackBufferTextureWidth()
+ public readonly int UnpackBufferTextureWidth()
{
return (int)((Word4 & 0xffff) | (Word3 << 16)) + 1;
}
@@ -166,7 +166,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Unpacks the texture sRGB format flag.
/// </summary>
/// <returns>True if the texture is sRGB, false otherwise</returns>
- public bool UnpackSrgb()
+ public readonly bool UnpackSrgb()
{
return (Word4 & (1 << 22)) != 0;
}
@@ -175,7 +175,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Unpacks the texture target.
/// </summary>
/// <returns>The texture target</returns>
- public TextureTarget UnpackTextureTarget()
+ public readonly TextureTarget UnpackTextureTarget()
{
return (TextureTarget)((Word4 >> 23) & 0xf);
}
@@ -185,7 +185,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Should be ignored for 1D or buffer textures.
/// </summary>
/// <returns>The texture height or layers count</returns>
- public int UnpackHeight()
+ public readonly int UnpackHeight()
{
return (int)(Word5 & 0xffff) + 1;
}
@@ -195,7 +195,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// The meaning of this value depends on the texture target.
/// </summary>
/// <returns>The texture depth, layer or faces count</returns>
- public int UnpackDepth()
+ public readonly int UnpackDepth()
{
return (int)((Word5 >> 16) & 0x3fff) + 1;
}
@@ -207,7 +207,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// It must be set to false (by the guest driver) for rectangle textures.
/// </summary>
/// <returns>The texture coordinates normalized flag</returns>
- public bool UnpackTextureCoordNormalized()
+ public readonly bool UnpackTextureCoordNormalized()
{
return (Word5 & (1 << 31)) != 0;
}
@@ -216,7 +216,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Unpacks the base mipmap level of the texture.
/// </summary>
/// <returns>The base mipmap level of the texture</returns>
- public int UnpackBaseLevel()
+ public readonly int UnpackBaseLevel()
{
return (int)(Word7 & 0xf);
}
@@ -226,7 +226,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Usually equal to Levels minus 1.
/// </summary>
/// <returns>The maximum mipmap level (inclusive) of the texture</returns>
- public int UnpackMaxLevelInclusive()
+ public readonly int UnpackMaxLevelInclusive()
{
return (int)((Word7 >> 4) & 0xf);
}
@@ -236,7 +236,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Must be ignored for non-multisample textures.
/// </summary>
/// <returns>The multisample counts enum</returns>
- public TextureMsaaMode UnpackTextureMsaaMode()
+ public readonly TextureMsaaMode UnpackTextureMsaaMode()
{
return (TextureMsaaMode)((Word7 >> 8) & 0xf);
}
@@ -269,5 +269,10 @@ namespace Ryujinx.Graphics.Gpu.Image
{
return Unsafe.As<TextureDescriptor, Vector256<byte>>(ref this).GetHashCode();
}
+
+ public override bool Equals(object obj)
+ {
+ return obj is TextureDescriptor descriptor && Equals(descriptor);
+ }
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureDescriptorType.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureDescriptorType.cs
index 8e7d40bb..ad0715c5 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/TextureDescriptorType.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/TextureDescriptorType.cs
@@ -11,6 +11,6 @@ namespace Ryujinx.Graphics.Gpu.Image
LinearColorKey,
Linear,
BlockLinear,
- BlockLinearColorKey
+ BlockLinearColorKey,
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureGroup.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureGroup.cs
index 2fa1e79e..1b947cd3 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/TextureGroup.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/TextureGroup.cs
@@ -78,11 +78,11 @@ namespace Ryujinx.Graphics.Gpu.Image
private int[] _allOffsets;
private int[] _sliceSizes;
- private bool _is3D;
+ private readonly bool _is3D;
private bool _hasMipViews;
private bool _hasLayerViews;
- private int _layers;
- private int _levels;
+ private readonly int _layers;
+ private readonly int _levels;
private MultiRange TextureRange => Storage.Range;
@@ -96,9 +96,9 @@ namespace Ryujinx.Graphics.Gpu.Image
/// <summary>
/// Other texture groups that have incompatible overlaps with this one.
/// </summary>
- private List<TextureIncompatibleOverlap> _incompatibleOverlaps;
+ private readonly List<TextureIncompatibleOverlap> _incompatibleOverlaps;
private bool _incompatibleOverlapsDirty = true;
- private bool _flushIncompatibleOverlaps;
+ private readonly bool _flushIncompatibleOverlaps;
private BufferHandle _flushBuffer;
private bool _flushBufferImported;
@@ -423,7 +423,7 @@ namespace Ryujinx.Graphics.Gpu.Image
int offsetIndex = GetOffsetIndex(info.BaseLayer + layer, info.BaseLevel + level);
int offset = _allOffsets[offsetIndex];
- ReadOnlySpan<byte> data = dataSpan.Slice(offset - spanBase);
+ ReadOnlySpan<byte> data = dataSpan[(offset - spanBase)..];
SpanOrArray<byte> result = Storage.ConvertToHostCompatibleFormat(data, info.BaseLevel + level, true);
@@ -1500,13 +1500,13 @@ namespace Ryujinx.Graphics.Gpu.Image
{
for (int i = 0; i < _allOffsets.Length; i++)
{
- (int layer, int level) = GetLayerLevelForView(i);
+ (_, int level) = GetLayerLevelForView(i);
MultiRange handleRange = Storage.Range.Slice((ulong)_allOffsets[i], 1);
ulong handleBase = handleRange.GetSubRange(0).Address;
for (int j = 0; j < other._handles.Length; j++)
{
- (int otherLayer, int otherLevel) = other.GetLayerLevelForView(j);
+ (_, int otherLevel) = other.GetLayerLevelForView(j);
MultiRange otherHandleRange = other.Storage.Range.Slice((ulong)other._allOffsets[j], 1);
ulong otherHandleBase = otherHandleRange.GetSubRange(0).Address;
diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureGroupHandle.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureGroupHandle.cs
index da8dd849..ef7198e8 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/TextureGroupHandle.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/TextureGroupHandle.cs
@@ -22,10 +22,10 @@ namespace Ryujinx.Graphics.Gpu.Image
private const int FlushBalanceMax = 60;
private const int FlushBalanceMin = -10;
- private TextureGroup _group;
+ private readonly TextureGroup _group;
private int _bindCount;
- private int _firstLevel;
- private int _firstLayer;
+ private readonly int _firstLevel;
+ private readonly int _firstLayer;
// Sync state for texture flush.
@@ -463,8 +463,8 @@ namespace Ryujinx.Graphics.Gpu.Image
_group.HasCopyDependencies = true;
other._group.HasCopyDependencies = true;
- TextureDependency dependency = new TextureDependency(this);
- TextureDependency otherDependency = new TextureDependency(other);
+ TextureDependency dependency = new(this);
+ TextureDependency otherDependency = new(other);
dependency.Other = otherDependency;
otherDependency.Other = dependency;
diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureInfo.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureInfo.cs
index 1994d226..94d2e0bf 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/TextureInfo.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/TextureInfo.cs
@@ -134,45 +134,45 @@ namespace Ryujinx.Graphics.Gpu.Image
/// <param name="swizzleB">Swizzle for the blue color channel</param>
/// <param name="swizzleA">Swizzle for the alpha color channel</param>
public TextureInfo(
- ulong gpuAddress,
- int width,
- int height,
- int depthOrLayers,
- int levels,
- int samplesInX,
- int samplesInY,
- int stride,
- bool isLinear,
- int gobBlocksInY,
- int gobBlocksInZ,
- int gobBlocksInTileX,
- Target target,
- FormatInfo formatInfo,
+ ulong gpuAddress,
+ int width,
+ int height,
+ int depthOrLayers,
+ int levels,
+ int samplesInX,
+ int samplesInY,
+ int stride,
+ bool isLinear,
+ int gobBlocksInY,
+ int gobBlocksInZ,
+ int gobBlocksInTileX,
+ Target target,
+ FormatInfo formatInfo,
DepthStencilMode depthStencilMode = DepthStencilMode.Depth,
- SwizzleComponent swizzleR = SwizzleComponent.Red,
- SwizzleComponent swizzleG = SwizzleComponent.Green,
- SwizzleComponent swizzleB = SwizzleComponent.Blue,
- SwizzleComponent swizzleA = SwizzleComponent.Alpha)
+ SwizzleComponent swizzleR = SwizzleComponent.Red,
+ SwizzleComponent swizzleG = SwizzleComponent.Green,
+ SwizzleComponent swizzleB = SwizzleComponent.Blue,
+ SwizzleComponent swizzleA = SwizzleComponent.Alpha)
{
- GpuAddress = gpuAddress;
- Width = width;
- Height = height;
- DepthOrLayers = depthOrLayers;
- Levels = levels;
- SamplesInX = samplesInX;
- SamplesInY = samplesInY;
- Stride = stride;
- IsLinear = isLinear;
- GobBlocksInY = gobBlocksInY;
- GobBlocksInZ = gobBlocksInZ;
+ GpuAddress = gpuAddress;
+ Width = width;
+ Height = height;
+ DepthOrLayers = depthOrLayers;
+ Levels = levels;
+ SamplesInX = samplesInX;
+ SamplesInY = samplesInY;
+ Stride = stride;
+ IsLinear = isLinear;
+ GobBlocksInY = gobBlocksInY;
+ GobBlocksInZ = gobBlocksInZ;
GobBlocksInTileX = gobBlocksInTileX;
- Target = target;
- FormatInfo = formatInfo;
+ Target = target;
+ FormatInfo = formatInfo;
DepthStencilMode = depthStencilMode;
- SwizzleR = swizzleR;
- SwizzleG = swizzleG;
- SwizzleB = swizzleB;
- SwizzleA = swizzleA;
+ SwizzleR = swizzleR;
+ SwizzleG = swizzleG;
+ SwizzleB = swizzleB;
+ SwizzleA = swizzleA;
}
/// <summary>
@@ -318,17 +318,17 @@ namespace Ryujinx.Graphics.Gpu.Image
// - If the parent format is not compressed, and the view is, the view
// size is calculated as described on the first point, but the width and height
// of the view must be also multiplied by the block width and height.
- int width = Math.Max(1, parent.Info.Width >> firstLevel);
+ int width = Math.Max(1, parent.Info.Width >> firstLevel);
int height = Math.Max(1, parent.Info.Height >> firstLevel);
if (parent.Info.FormatInfo.IsCompressed && !FormatInfo.IsCompressed)
{
- width = BitUtils.DivRoundUp(width, parent.Info.FormatInfo.BlockWidth);
+ width = BitUtils.DivRoundUp(width, parent.Info.FormatInfo.BlockWidth);
height = BitUtils.DivRoundUp(height, parent.Info.FormatInfo.BlockHeight);
}
else if (!parent.Info.FormatInfo.IsCompressed && FormatInfo.IsCompressed)
{
- width *= FormatInfo.BlockWidth;
+ width *= FormatInfo.BlockWidth;
height *= FormatInfo.BlockHeight;
}
@@ -408,4 +408,4 @@ namespace Ryujinx.Graphics.Gpu.Image
SwizzleA);
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureManager.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureManager.cs
index 266f6285..63b9b47c 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/TextureManager.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/TextureManager.cs
@@ -41,8 +41,8 @@ namespace Ryujinx.Graphics.Gpu.Image
_context = context;
_channel = channel;
- TexturePoolCache texturePoolCache = new TexturePoolCache(context);
- SamplerPoolCache samplerPoolCache = new SamplerPoolCache(context);
+ TexturePoolCache texturePoolCache = new(context);
+ SamplerPoolCache samplerPoolCache = new(context);
float[] scales = new float[64];
new Span<float>(scales).Fill(1f);
@@ -139,7 +139,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// </summary>
/// <param name="texture">The texture to check</param>
/// <returns>True if the scale needs updating, false if the scale is up to date</returns>
- private bool ScaleNeedsUpdated(Texture texture)
+ private static bool ScaleNeedsUpdated(Texture texture)
{
return texture != null && !(texture.ScaleMode == TextureScaleMode.Blacklisted || texture.ScaleMode == TextureScaleMode.Undesired) && texture.ScaleFactor != GraphicsConfig.ResScale;
}
@@ -234,7 +234,11 @@ namespace Ryujinx.Graphics.Gpu.Image
void ConsiderTarget(Texture target)
{
- if (target == null) return;
+ if (target == null)
+ {
+ return;
+ }
+
float scale = target.ScaleFactor;
switch (target.ScaleMode)
@@ -445,7 +449,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// </remarks>
public void UpdateRenderTargetDepthStencil()
{
- new Span<ITexture>(_rtHostColors).Fill(null);
+ new Span<ITexture>(_rtHostColors).Clear();
_rtHostDs = _rtDepthStencil?.HostTexture;
_context.Renderer.Pipeline.SetRenderTargets(_rtHostColors, _rtHostDs);
diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureMatchQuality.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureMatchQuality.cs
index 1351bf24..67835e95 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/TextureMatchQuality.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/TextureMatchQuality.cs
@@ -4,6 +4,6 @@
{
NoMatch,
FormatAlias,
- Perfect
+ Perfect,
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureMsaaMode.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureMsaaMode.cs
index 0461888f..43b83ae1 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/TextureMsaaMode.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/TextureMsaaMode.cs
@@ -9,7 +9,7 @@ namespace Ryujinx.Graphics.Gpu.Image
Ms2x2 = 2,
Ms4x2 = 4,
Ms2x1 = 5,
- Ms4x4 = 6
+ Ms4x4 = 6,
}
static class TextureMsaaModeConverter
@@ -27,7 +27,7 @@ namespace Ryujinx.Graphics.Gpu.Image
TextureMsaaMode.Ms2x2 => 4,
TextureMsaaMode.Ms4x2 => 8,
TextureMsaaMode.Ms4x4 => 16,
- _ => 1
+ _ => 1,
};
}
@@ -44,7 +44,7 @@ namespace Ryujinx.Graphics.Gpu.Image
TextureMsaaMode.Ms2x2 => 2,
TextureMsaaMode.Ms4x2 => 4,
TextureMsaaMode.Ms4x4 => 4,
- _ => 1
+ _ => 1,
};
}
@@ -61,8 +61,8 @@ namespace Ryujinx.Graphics.Gpu.Image
TextureMsaaMode.Ms2x2 => 2,
TextureMsaaMode.Ms4x2 => 2,
TextureMsaaMode.Ms4x4 => 4,
- _ => 1
+ _ => 1,
};
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/TexturePool.cs b/src/Ryujinx.Graphics.Gpu/Image/TexturePool.cs
index bade9bbb..0fdb6cd6 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/TexturePool.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/TexturePool.cs
@@ -18,7 +18,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// <summary>
/// A request to dereference a texture from a pool.
/// </summary>
- private struct DereferenceRequest
+ private readonly struct DereferenceRequest
{
/// <summary>
/// Whether the dereference is due to a mapping change or not.
@@ -71,7 +71,7 @@ namespace Ryujinx.Graphics.Gpu.Image
}
private readonly GpuChannel _channel;
- private readonly ConcurrentQueue<DereferenceRequest> _dereferenceQueue = new ConcurrentQueue<DereferenceRequest>();
+ private readonly ConcurrentQueue<DereferenceRequest> _dereferenceQueue = new();
private TextureDescriptor _defaultDescriptor;
/// <summary>
@@ -379,10 +379,10 @@ namespace Ryujinx.Graphics.Gpu.Image
/// <param name="descriptor">The texture descriptor</param>
/// <param name="layerSize">Layer size for textures using a sub-range of mipmap levels, otherwise 0</param>
/// <returns>The texture information</returns>
- private TextureInfo GetInfo(in TextureDescriptor descriptor, out int layerSize)
+ private static TextureInfo GetInfo(in TextureDescriptor descriptor, out int layerSize)
{
int depthOrLayers = descriptor.UnpackDepth();
- int levels = descriptor.UnpackLevels();
+ int levels = descriptor.UnpackLevels();
TextureMsaaMode msaaMode = descriptor.UnpackTextureMsaaMode();
@@ -424,7 +424,7 @@ namespace Ryujinx.Graphics.Gpu.Image
}
uint format = descriptor.UnpackFormat();
- bool srgb = descriptor.UnpackSrgb();
+ bool srgb = descriptor.UnpackSrgb();
ulong gpuVa = descriptor.UnpackAddress();
@@ -451,7 +451,7 @@ namespace Ryujinx.Graphics.Gpu.Image
// Linear textures don't support mipmaps, so we don't handle this case here.
if ((minLod != 0 || maxLod + 1 != levels) && target != Target.TextureBuffer && !isLinear)
{
- int depth = TextureInfo.GetDepth(target, depthOrLayers);
+ int depth = TextureInfo.GetDepth(target, depthOrLayers);
int layers = TextureInfo.GetLayers(target, depthOrLayers);
SizeInfo sizeInfo = SizeCalculator.GetBlockLinearTextureSize(
@@ -476,7 +476,7 @@ namespace Ryujinx.Graphics.Gpu.Image
// address if there is a overlapping texture on the cache that can contain the new texture.
gpuVa += (ulong)sizeInfo.GetMipOffset(minLod);
- width = Math.Max(1, width >> minLod);
+ width = Math.Max(1, width >> minLod);
height = Math.Max(1, height >> minLod);
if (target == Target.Texture3D)
@@ -608,4 +608,4 @@ namespace Ryujinx.Graphics.Gpu.Image
base.Dispose();
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/TexturePoolCache.cs b/src/Ryujinx.Graphics.Gpu/Image/TexturePoolCache.cs
index 0017f4cc..5da2c439 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/TexturePoolCache.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/TexturePoolCache.cs
@@ -27,4 +27,4 @@ namespace Ryujinx.Graphics.Gpu.Image
return new TexturePool(context, channel, address, maximumId);
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureScaleMode.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureScaleMode.cs
index b937f577..5d8e14db 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/TextureScaleMode.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/TextureScaleMode.cs
@@ -11,6 +11,6 @@
Eligible = 0,
Scaled = 1,
Blacklisted = 2,
- Undesired = 3
+ Undesired = 3,
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureSearchFlags.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureSearchFlags.cs
index d7b99a17..fb2a97b0 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/TextureSearchFlags.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/TextureSearchFlags.cs
@@ -8,11 +8,11 @@ namespace Ryujinx.Graphics.Gpu.Image
[Flags]
enum TextureSearchFlags
{
- None = 0,
- ForSampler = 1 << 1,
- ForCopy = 1 << 2,
- DepthAlias = 1 << 3,
+ None = 0,
+ ForSampler = 1 << 1,
+ ForCopy = 1 << 2,
+ DepthAlias = 1 << 3,
WithUpscale = 1 << 4,
- NoCreate = 1 << 5
+ NoCreate = 1 << 5,
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureTarget.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureTarget.cs
index 5e0a0721..b46b4204 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/TextureTarget.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/TextureTarget.cs
@@ -16,7 +16,7 @@ namespace Ryujinx.Graphics.Gpu.Image
Texture2DArray,
TextureBuffer,
Texture2DRect,
- CubemapArray
+ CubemapArray,
}
static class TextureTargetConverter
@@ -33,23 +33,34 @@ namespace Ryujinx.Graphics.Gpu.Image
{
switch (target)
{
- case TextureTarget.Texture2D: return Target.Texture2DMultisample;
- case TextureTarget.Texture2DArray: return Target.Texture2DMultisampleArray;
+ case TextureTarget.Texture2D:
+ return Target.Texture2DMultisample;
+ case TextureTarget.Texture2DArray:
+ return Target.Texture2DMultisampleArray;
}
}
else
{
switch (target)
{
- case TextureTarget.Texture1D: return Target.Texture1D;
- case TextureTarget.Texture2D: return Target.Texture2D;
- case TextureTarget.Texture2DRect: return Target.Texture2D;
- case TextureTarget.Texture3D: return Target.Texture3D;
- case TextureTarget.Texture1DArray: return Target.Texture1DArray;
- case TextureTarget.Texture2DArray: return Target.Texture2DArray;
- case TextureTarget.Cubemap: return Target.Cubemap;
- case TextureTarget.CubemapArray: return Target.CubemapArray;
- case TextureTarget.TextureBuffer: return Target.TextureBuffer;
+ case TextureTarget.Texture1D:
+ return Target.Texture1D;
+ case TextureTarget.Texture2D:
+ return Target.Texture2D;
+ case TextureTarget.Texture2DRect:
+ return Target.Texture2D;
+ case TextureTarget.Texture3D:
+ return Target.Texture3D;
+ case TextureTarget.Texture1DArray:
+ return Target.Texture1DArray;
+ case TextureTarget.Texture2DArray:
+ return Target.Texture2DArray;
+ case TextureTarget.Cubemap:
+ return Target.Cubemap;
+ case TextureTarget.CubemapArray:
+ return Target.CubemapArray;
+ case TextureTarget.TextureBuffer:
+ return Target.TextureBuffer;
}
}
@@ -65,17 +76,17 @@ namespace Ryujinx.Graphics.Gpu.Image
{
return target switch
{
- TextureTarget.Texture1D => SamplerType.Texture1D,
- TextureTarget.Texture2D => SamplerType.Texture2D,
- TextureTarget.Texture3D => SamplerType.Texture3D,
- TextureTarget.Cubemap => SamplerType.TextureCube,
+ TextureTarget.Texture1D => SamplerType.Texture1D,
+ TextureTarget.Texture2D => SamplerType.Texture2D,
+ TextureTarget.Texture3D => SamplerType.Texture3D,
+ TextureTarget.Cubemap => SamplerType.TextureCube,
TextureTarget.Texture1DArray => SamplerType.Texture1D | SamplerType.Array,
TextureTarget.Texture2DArray => SamplerType.Texture2D | SamplerType.Array,
- TextureTarget.TextureBuffer => SamplerType.TextureBuffer,
- TextureTarget.Texture2DRect => SamplerType.Texture2D,
- TextureTarget.CubemapArray => SamplerType.TextureCube | SamplerType.Array,
- _ => SamplerType.Texture2D
+ TextureTarget.TextureBuffer => SamplerType.TextureBuffer,
+ TextureTarget.Texture2DRect => SamplerType.Texture2D,
+ TextureTarget.CubemapArray => SamplerType.TextureCube | SamplerType.Array,
+ _ => SamplerType.Texture2D,
};
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureViewCompatibility.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureViewCompatibility.cs
index dfa688c4..3f3bfdfe 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/TextureViewCompatibility.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/TextureViewCompatibility.cs
@@ -10,6 +10,6 @@
LayoutIncompatible,
CopyOnly,
FormatAlias,
- Full
+ Full,
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Memory/Buffer.cs b/src/Ryujinx.Graphics.Gpu/Memory/Buffer.cs
index dc5037c5..e27c14a1 100644
--- a/src/Ryujinx.Graphics.Gpu/Memory/Buffer.cs
+++ b/src/Ryujinx.Graphics.Gpu/Memory/Buffer.cs
@@ -62,7 +62,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
private int _sequenceNumber;
- private bool _useGranular;
+ private readonly bool _useGranular;
private bool _syncActionRegistered;
private int _referenceCount = 1;
@@ -80,10 +80,10 @@ namespace Ryujinx.Graphics.Gpu.Memory
/// <param name="baseBuffers">Buffers which this buffer contains, and will inherit tracking handles from</param>
public Buffer(GpuContext context, PhysicalMemory physicalMemory, ulong address, ulong size, IEnumerable<Buffer> baseBuffers = null)
{
- _context = context;
+ _context = context;
_physicalMemory = physicalMemory;
- Address = address;
- Size = size;
+ Address = address;
+ Size = size;
Handle = context.Renderer.CreateBuffer((int)size, baseBuffers?.MaxBy(x => x.Size).Handle ?? BufferHandle.Null);
@@ -252,10 +252,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
/// </summary>
private void EnsureRangeList()
{
- if (_modifiedRanges == null)
- {
- _modifiedRanges = new BufferModifiedRangeList(_context, this, Flush);
- }
+ _modifiedRanges ??= new BufferModifiedRangeList(_context, this, Flush);
}
/// <summary>
@@ -326,7 +323,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
_syncActionRegistered = true;
}
- Action<ulong, ulong> registerRangeAction = (ulong address, ulong size) =>
+ void registerRangeAction(ulong address, ulong size)
{
if (_useGranular)
{
@@ -336,7 +333,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
{
_memoryTracking.RegisterAction(_externalFlushDelegate);
}
- };
+ }
EnsureRangeList();
@@ -643,4 +640,4 @@ namespace Ryujinx.Graphics.Gpu.Memory
DecrementReferenceCount();
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Memory/BufferBounds.cs b/src/Ryujinx.Graphics.Gpu/Memory/BufferBounds.cs
index d513b7ad..a9ea04ce 100644
--- a/src/Ryujinx.Graphics.Gpu/Memory/BufferBounds.cs
+++ b/src/Ryujinx.Graphics.Gpu/Memory/BufferBounds.cs
@@ -35,4 +35,4 @@ namespace Ryujinx.Graphics.Gpu.Memory
Flags = flags;
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Memory/BufferCache.cs b/src/Ryujinx.Graphics.Gpu/Memory/BufferCache.cs
index a5a9b75e..99c571ba 100644
--- a/src/Ryujinx.Graphics.Gpu/Memory/BufferCache.cs
+++ b/src/Ryujinx.Graphics.Gpu/Memory/BufferCache.cs
@@ -12,7 +12,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
class BufferCache : IDisposable
{
private const int OverlapsBufferInitialCapacity = 10;
- private const int OverlapsBufferMaxCapacity = 10000;
+ private const int OverlapsBufferMaxCapacity = 10000;
private const ulong BufferAlignmentSize = 0x1000;
private const ulong BufferAlignmentMask = BufferAlignmentSize - 1;
@@ -246,7 +246,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
{
Buffer buffer = _bufferOverlaps[index];
- address = Math.Min(address, buffer.Address);
+ address = Math.Min(address, buffer.Address);
endAddress = Math.Max(endAddress, buffer.EndAddress);
lock (_buffers)
@@ -257,7 +257,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
ulong newSize = endAddress - address;
- Buffer newBuffer = new Buffer(_context, _physicalMemory, address, newSize, _bufferOverlaps.Take(overlapsCount));
+ Buffer newBuffer = new(_context, _physicalMemory, address, newSize, _bufferOverlaps.Take(overlapsCount));
lock (_buffers)
{
@@ -285,7 +285,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
else
{
// No overlap, just create a new buffer.
- Buffer buffer = new Buffer(_context, _physicalMemory, address, size);
+ Buffer buffer = new(_context, _physicalMemory, address, size);
lock (_buffers)
{
@@ -446,7 +446,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
/// </summary>
/// <param name="dictionary">Dictionary to prune</param>
/// <param name="toDelete">List used to track entries to delete</param>
- private void Prune(Dictionary<ulong, BufferCacheEntry> dictionary, ref List<ulong> toDelete)
+ private static void Prune(Dictionary<ulong, BufferCacheEntry> dictionary, ref List<ulong> toDelete)
{
foreach (var entry in dictionary)
{
@@ -504,4 +504,4 @@ namespace Ryujinx.Graphics.Gpu.Memory
}
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs b/src/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs
index 07429cfe..4cd3710b 100644
--- a/src/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs
+++ b/src/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs
@@ -105,7 +105,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
private readonly BuffersPerStage[] _gpUniformBuffers;
private BufferHandle _tfInfoBuffer;
- private int[] _tfInfoData;
+ private readonly int[] _tfInfoData;
private bool _gpStorageBuffersDirty;
private bool _gpUniformBuffersDirty;
@@ -777,11 +777,11 @@ namespace Ryujinx.Graphics.Gpu.Memory
{
if (isStorage)
{
- _context.Renderer.Pipeline.SetStorageBuffers(ranges.Slice(0, count));
+ _context.Renderer.Pipeline.SetStorageBuffers(ranges[..count]);
}
else
{
- _context.Renderer.Pipeline.SetUniformBuffers(ranges.Slice(0, count));
+ _context.Renderer.Pipeline.SetUniformBuffers(ranges[..count]);
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Memory/BufferModifiedRangeList.cs b/src/Ryujinx.Graphics.Gpu/Memory/BufferModifiedRangeList.cs
index 03504b11..160a9aff 100644
--- a/src/Ryujinx.Graphics.Gpu/Memory/BufferModifiedRangeList.cs
+++ b/src/Ryujinx.Graphics.Gpu/Memory/BufferModifiedRangeList.cs
@@ -1,5 +1,4 @@
-using Ryujinx.Common.Logging;
-using Ryujinx.Common.Pools;
+using Ryujinx.Common.Pools;
using Ryujinx.Memory.Range;
using System;
using System.Collections.Generic;
@@ -71,9 +70,9 @@ namespace Ryujinx.Graphics.Gpu.Memory
{
private const int BackingInitialSize = 8;
- private GpuContext _context;
- private Buffer _parent;
- private Action<ulong, ulong> _flushAction;
+ private readonly GpuContext _context;
+ private readonly Buffer _parent;
+ private readonly Action<ulong, ulong> _flushAction;
private List<BufferMigration> _sources;
private BufferMigration _migrationTarget;
diff --git a/src/Ryujinx.Graphics.Gpu/Memory/CounterCache.cs b/src/Ryujinx.Graphics.Gpu/Memory/CounterCache.cs
index e763a899..6dcc52cb 100644
--- a/src/Ryujinx.Graphics.Gpu/Memory/CounterCache.cs
+++ b/src/Ryujinx.Graphics.Gpu/Memory/CounterCache.cs
@@ -34,11 +34,12 @@ namespace Ryujinx.Graphics.Gpu.Memory
/// Adds a new counter to the counter cache, or updates a existing one.
/// </summary>
/// <param name="gpuVa">GPU virtual address where the counter will be written in memory</param>
+ /// <param name="evt">The new counter</param>
public void AddOrUpdate(ulong gpuVa, ICounterEvent evt)
{
int index = BinarySearch(gpuVa);
- CounterEntry entry = new CounterEntry(gpuVa, evt);
+ CounterEntry entry = new(gpuVa, evt);
if (index < 0)
{
@@ -127,7 +128,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
_items[index].Event?.Flush();
return true;
- }
+ }
else
{
return false;
@@ -168,7 +169,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
int middle = left + (range >> 1);
- CounterEntry item = _items[middle];
+ CounterEntry item = _items[middle];
if (item.Address == address)
{
diff --git a/src/Ryujinx.Graphics.Gpu/Memory/IndexBuffer.cs b/src/Ryujinx.Graphics.Gpu/Memory/IndexBuffer.cs
index 7765e899..c72fa50e 100644
--- a/src/Ryujinx.Graphics.Gpu/Memory/IndexBuffer.cs
+++ b/src/Ryujinx.Graphics.Gpu/Memory/IndexBuffer.cs
@@ -12,4 +12,4 @@ namespace Ryujinx.Graphics.Gpu.Memory
public IndexType Type;
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs b/src/Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs
index c7a138c9..6af12de1 100644
--- a/src/Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs
+++ b/src/Ryujinx.Graphics.Gpu/Memory/MemoryManager.cs
@@ -14,15 +14,15 @@ namespace Ryujinx.Graphics.Gpu.Memory
{
private const int PtLvl0Bits = 14;
private const int PtLvl1Bits = 14;
- public const int PtPageBits = 12;
+ public const int PtPageBits = 12;
private const ulong PtLvl0Size = 1UL << PtLvl0Bits;
private const ulong PtLvl1Size = 1UL << PtLvl1Bits;
- public const ulong PageSize = 1UL << PtPageBits;
+ public const ulong PageSize = 1UL << PtPageBits;
private const ulong PtLvl0Mask = PtLvl0Size - 1;
private const ulong PtLvl1Mask = PtLvl1Size - 1;
- public const ulong PageMask = PageSize - 1;
+ public const ulong PageMask = PageSize - 1;
private const int PtLvl0Bit = PtPageBits + PtLvl1Bits;
private const int PtLvl1Bit = PtPageBits;
@@ -203,7 +203,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
size = Math.Min(data.Length, (int)PageSize - (int)(va & PageMask));
- Physical.GetSpan(pa, size, tracked).CopyTo(data.Slice(0, size));
+ Physical.GetSpan(pa, size, tracked).CopyTo(data[..size]);
offset += size;
}
@@ -306,7 +306,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
size = Math.Min(data.Length, (int)PageSize - (int)(va & PageMask));
- writeCallback(pa, data.Slice(0, size));
+ writeCallback(pa, data[..size]);
offset += size;
}
@@ -345,7 +345,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
if (pa != PteUnmapped && Physical.IsMapped(pa))
{
- Physical.Write(pa, data.Slice(0, size));
+ Physical.Write(pa, data[..size]);
}
offset += size;
@@ -370,7 +370,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
/// These must run after the mapping completes.
/// </summary>
/// <param name="e">Event with remap actions</param>
- private void RunRemapActions(UnmapEventArgs e)
+ private static void RunRemapActions(UnmapEventArgs e)
{
if (e.RemapActions != null)
{
@@ -759,4 +759,4 @@ namespace Ryujinx.Graphics.Gpu.Memory
return pte & 0xffffffffffffffUL;
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs b/src/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs
index cb95b04a..d0b4478e 100644
--- a/src/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs
+++ b/src/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs
@@ -19,7 +19,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
class PhysicalMemory : IDisposable
{
private readonly GpuContext _context;
- private IVirtualMemoryManagerTracked _cpuMemory;
+ private readonly IVirtualMemoryManagerTracked _cpuMemory;
private int _referenceCount;
/// <summary>
@@ -438,4 +438,4 @@ namespace Ryujinx.Graphics.Gpu.Memory
DecrementReferenceCount();
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Memory/PteKind.cs b/src/Ryujinx.Graphics.Gpu/Memory/PteKind.cs
index 4ceb6bcf..1585328f 100644
--- a/src/Ryujinx.Graphics.Gpu/Memory/PteKind.cs
+++ b/src/Ryujinx.Graphics.Gpu/Memory/PteKind.cs
@@ -250,7 +250,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
X8C24 = 0xfc,
PitchNoSwizzle = 0xfd,
SmSkedMessage = 0xca,
- SmHostMessage = 0xcb
+ SmHostMessage = 0xcb,
}
static class PteKindExtensions
@@ -265,4 +265,4 @@ namespace Ryujinx.Graphics.Gpu.Memory
return kind == PteKind.Pitch || kind == PteKind.PitchNoSwizzle;
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Memory/ResourceKind.cs b/src/Ryujinx.Graphics.Gpu/Memory/ResourceKind.cs
index 55d697b8..5d2ada56 100644
--- a/src/Ryujinx.Graphics.Gpu/Memory/ResourceKind.cs
+++ b/src/Ryujinx.Graphics.Gpu/Memory/ResourceKind.cs
@@ -8,6 +8,6 @@ namespace Ryujinx.Graphics.Gpu.Memory
None,
Buffer,
Texture,
- Pool
+ Pool,
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Memory/VertexBuffer.cs b/src/Ryujinx.Graphics.Gpu/Memory/VertexBuffer.cs
index 8f089125..ac334881 100644
--- a/src/Ryujinx.Graphics.Gpu/Memory/VertexBuffer.cs
+++ b/src/Ryujinx.Graphics.Gpu/Memory/VertexBuffer.cs
@@ -7,7 +7,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
{
public ulong Address;
public ulong Size;
- public int Stride;
- public int Divisor;
+ public int Stride;
+ public int Divisor;
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/CachedShaderStage.cs b/src/Ryujinx.Graphics.Gpu/Shader/CachedShaderStage.cs
index 22b08dd5..2381991d 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/CachedShaderStage.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/CachedShaderStage.cs
@@ -35,4 +35,4 @@ namespace Ryujinx.Graphics.Gpu.Shader
Cb1Data = cb1Data;
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/ComputeShaderCacheHashTable.cs b/src/Ryujinx.Graphics.Gpu/Shader/ComputeShaderCacheHashTable.cs
index a6718211..0119a6a3 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/ComputeShaderCacheHashTable.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/ComputeShaderCacheHashTable.cs
@@ -50,8 +50,9 @@ namespace Ryujinx.Graphics.Gpu.Shader
out byte[] cachedGuestCode)
{
program = null;
- ShaderCodeAccessor codeAccessor = new ShaderCodeAccessor(channel.MemoryManager, gpuVa);
+ ShaderCodeAccessor codeAccessor = new(channel.MemoryManager, gpuVa);
bool hasSpecList = _cache.TryFindItem(codeAccessor, out var specList, out cachedGuestCode);
+
return hasSpecList && specList.TryFindForCompute(channel, poolState, computeState, out program);
}
@@ -67,4 +68,4 @@ namespace Ryujinx.Graphics.Gpu.Shader
}
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/BackgroundDiskCacheWriter.cs b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/BackgroundDiskCacheWriter.cs
index 568fe968..e0f17ba9 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/BackgroundDiskCacheWriter.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/BackgroundDiskCacheWriter.cs
@@ -18,7 +18,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
/// <summary>
/// Operation to add a shader to the cache.
/// </summary>
- AddShader
+ AddShader,
}
/// <summary>
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/BinarySerializer.cs b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/BinarySerializer.cs
index 50e37033..b08c44d6 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/BinarySerializer.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/BinarySerializer.cs
@@ -29,12 +29,12 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
/// </summary>
/// <typeparam name="T">Type of the data</typeparam>
/// <param name="data">Data read</param>
- public void Read<T>(ref T data) where T : unmanaged
+ public readonly void Read<T>(ref T data) where T : unmanaged
{
Span<byte> buffer = MemoryMarshal.Cast<T, byte>(MemoryMarshal.CreateSpan(ref data, 1));
for (int offset = 0; offset < buffer.Length;)
{
- offset += _activeStream.Read(buffer.Slice(offset));
+ offset += _activeStream.Read(buffer[offset..]);
}
}
@@ -44,7 +44,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
/// <typeparam name="T">Type of the data</typeparam>
/// <param name="data">Data read</param>
/// <returns>True if the read was successful, false otherwise</returns>
- public bool TryRead<T>(ref T data) where T : unmanaged
+ public readonly bool TryRead<T>(ref T data) where T : unmanaged
{
// Length is unknown on compressed streams.
if (_activeStream == _stream)
@@ -66,7 +66,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
/// <typeparam name="T">Type of the data</typeparam>
/// <param name="data">Data read</param>
/// <param name="magic">Expected magic value, for validation</param>
- public void ReadWithMagicAndSize<T>(ref T data, uint magic) where T : unmanaged
+ public readonly void ReadWithMagicAndSize<T>(ref T data, uint magic) where T : unmanaged
{
uint actualMagic = 0;
int size = 0;
@@ -84,10 +84,10 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
throw new DiskCacheLoadException(DiskCacheLoadResult.FileCorruptedInvalidLength);
}
- Span<byte> buffer = MemoryMarshal.Cast<T, byte>(MemoryMarshal.CreateSpan(ref data, 1)).Slice(0, size);
+ Span<byte> buffer = MemoryMarshal.Cast<T, byte>(MemoryMarshal.CreateSpan(ref data, 1))[..size];
for (int offset = 0; offset < buffer.Length;)
{
- offset += _activeStream.Read(buffer.Slice(offset));
+ offset += _activeStream.Read(buffer[offset..]);
}
}
@@ -96,7 +96,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
/// </summary>
/// <typeparam name="T">Type of the data</typeparam>
/// <param name="data">Data to be written</param>
- public void Write<T>(ref T data) where T : unmanaged
+ public readonly void Write<T>(ref T data) where T : unmanaged
{
Span<byte> buffer = MemoryMarshal.Cast<T, byte>(MemoryMarshal.CreateSpan(ref data, 1));
_activeStream.Write(buffer);
@@ -108,7 +108,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
/// <typeparam name="T">Type of the data</typeparam>
/// <param name="data">Data to write</param>
/// <param name="magic">Magic value to write</param>
- public void WriteWithMagicAndSize<T>(ref T data, uint magic) where T : unmanaged
+ public readonly void WriteWithMagicAndSize<T>(ref T data, uint magic) where T : unmanaged
{
int size = Unsafe.SizeOf<T>();
Write(ref magic);
@@ -183,7 +183,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
stream = new DeflateStream(stream, CompressionMode.Decompress, true);
for (int offset = 0; offset < data.Length;)
{
- offset += stream.Read(data.Slice(offset));
+ offset += stream.Read(data[offset..]);
}
stream.Dispose();
break;
@@ -213,4 +213,4 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
}
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/CompressionAlgorithm.cs b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/CompressionAlgorithm.cs
index a46e1ef7..96ddbb51 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/CompressionAlgorithm.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/CompressionAlgorithm.cs
@@ -13,6 +13,6 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
/// <summary>
/// Deflate compression (RFC 1951).
/// </summary>
- Deflate
+ Deflate,
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheCommon.cs b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheCommon.cs
index c8a9f7ff..c4ce0b87 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheCommon.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheCommon.cs
@@ -54,4 +54,4 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
return CompressionAlgorithm.Deflate;
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheGpuAccessor.cs b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheGpuAccessor.cs
index 537cead0..7f01aca6 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheGpuAccessor.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheGpuAccessor.cs
@@ -19,7 +19,6 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
private readonly ShaderSpecializationState _newSpecState;
private readonly int _stageIndex;
private readonly bool _isVulkan;
- private readonly ResourceCounts _resourceCounts;
/// <summary>
/// Creates a new instance of the cached GPU state accessor for shader translation.
@@ -45,7 +44,6 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
_newSpecState = newSpecState;
_stageIndex = stageIndex;
_isVulkan = context.Capabilities.Api == TargetApi.Vulkan;
- _resourceCounts = counts;
}
/// <inheritdoc/>
@@ -56,7 +54,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
throw new DiskCacheLoadException(DiskCacheLoadResult.InvalidCb1DataLength);
}
- return MemoryMarshal.Cast<byte, uint>(_cb1Data.Span.Slice(offset))[0];
+ return MemoryMarshal.Cast<byte, uint>(_cb1Data.Span[offset..])[0];
}
/// <inheritdoc/>
@@ -68,7 +66,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
/// <inheritdoc/>
public ReadOnlySpan<ulong> GetCode(ulong address, int minimumSize)
{
- return MemoryMarshal.Cast<byte, ulong>(_data.Span.Slice((int)address));
+ return MemoryMarshal.Cast<byte, ulong>(_data.Span[(int)address..]);
}
/// <inheritdoc/>
@@ -94,7 +92,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
CompareOp.Greater or CompareOp.GreaterGl => AlphaTestOp.Greater,
CompareOp.NotEqual or CompareOp.NotEqualGl => AlphaTestOp.NotEqual,
CompareOp.GreaterOrEqual or CompareOp.GreaterOrEqualGl => AlphaTestOp.GreaterOrEqual,
- _ => AlphaTestOp.Always
+ _ => AlphaTestOp.Always,
};
}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheGuestStorage.cs b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheGuestStorage.cs
index 01034b49..59d2cfb3 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheGuestStorage.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheGuestStorage.cs
@@ -205,10 +205,10 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
if (guestCode == null || cb1Data == null)
{
- BinarySerializer tocReader = new BinarySerializer(tocFileStream);
+ BinarySerializer tocReader = new(tocFileStream);
tocFileStream.Seek(Unsafe.SizeOf<TocHeader>() + index * Unsafe.SizeOf<TocEntry>(), SeekOrigin.Begin);
- TocEntry entry = new TocEntry();
+ TocEntry entry = new();
tocReader.Read(ref entry);
guestCode = new byte[entry.CodeSize];
@@ -261,7 +261,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
using var tocFileStream = DiskCacheCommon.OpenFile(_basePath, TocFileName, writable: true);
using var dataFileStream = DiskCacheCommon.OpenFile(_basePath, DataFileName, writable: true);
- TocHeader header = new TocHeader();
+ TocHeader header = new();
LoadOrCreateToc(tocFileStream, ref header);
@@ -299,7 +299,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
/// <param name="header">Set to the TOC file header</param>
private void LoadOrCreateToc(Stream tocFileStream, ref TocHeader header)
{
- BinarySerializer reader = new BinarySerializer(tocFileStream);
+ BinarySerializer reader = new(tocFileStream);
if (!reader.TryRead(ref header) || header.Magic != TocMagic || header.Version != VersionPacked)
{
@@ -322,9 +322,9 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
/// </summary>
/// <param name="tocFileStream">Guest TOC file stream</param>
/// <param name="header">Set to the TOC header</param>
- private void CreateToc(Stream tocFileStream, ref TocHeader header)
+ private static void CreateToc(Stream tocFileStream, ref TocHeader header)
{
- BinarySerializer writer = new BinarySerializer(tocFileStream);
+ BinarySerializer writer = new(tocFileStream);
header.Magic = TocMagic;
header.Version = VersionPacked;
@@ -352,7 +352,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
{
_toc = new Dictionary<uint, List<TocMemoryEntry>>();
- TocEntry entry = new TocEntry();
+ TocEntry entry = new();
int index = 0;
while (tocFileStream.Position < tocFileStream.Length)
@@ -386,7 +386,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
ReadOnlySpan<byte> cb1Data,
uint hash)
{
- BinarySerializer tocWriter = new BinarySerializer(tocFileStream);
+ BinarySerializer tocWriter = new(tocFileStream);
dataFileStream.Seek(0, SeekOrigin.End);
uint dataOffset = checked((uint)dataFileStream.Position);
@@ -399,12 +399,12 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
tocFileStream.Seek(0, SeekOrigin.Begin);
tocWriter.Write(ref header);
- TocEntry entry = new TocEntry()
+ TocEntry entry = new()
{
Offset = dataOffset,
CodeSize = codeSize,
Cb1DataSize = cb1DataSize,
- Hash = hash
+ Hash = hash,
};
tocFileStream.Seek(0, SeekOrigin.End);
@@ -456,4 +456,4 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
return (uint)XXHash128.ComputeHash(data).Low;
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheHostStorage.cs b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheHostStorage.cs
index 26711286..95a0a6bd 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheHostStorage.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheHostStorage.cs
@@ -221,7 +221,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
int indexOfSpace = fileName.IndexOf(' ');
if (indexOfSpace >= 0)
{
- fileName = fileName.Substring(0, indexOfSpace);
+ fileName = fileName[..indexOfSpace];
}
return string.Concat(fileName.Split(Path.GetInvalidFileNameChars(), StringSplitOptions.RemoveEmptyEntries));
@@ -287,10 +287,10 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
using var guestTocFileStream = _guestStorage.OpenTocFileStream();
using var guestDataFileStream = _guestStorage.OpenDataFileStream();
- BinarySerializer tocReader = new BinarySerializer(tocFileStream);
- BinarySerializer dataReader = new BinarySerializer(dataFileStream);
+ BinarySerializer tocReader = new(tocFileStream);
+ BinarySerializer dataReader = new(dataFileStream);
- TocHeader header = new TocHeader();
+ TocHeader header = new();
if (!tocReader.TryRead(ref header) || header.Magic != TocsMagic)
{
@@ -306,7 +306,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
int programIndex = 0;
- DataEntry entry = new DataEntry();
+ DataEntry entry = new();
while (tocFileStream.Position < tocFileStream.Length && loader.Active)
{
@@ -337,7 +337,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
GuestCodeAndCbData?[] guestShaders = new GuestCodeAndCbData?[isCompute ? 1 : Constants.ShaderStages + 1];
- DataEntryPerStage stageEntry = new DataEntryPerStage();
+ DataEntryPerStage stageEntry = new();
while (stagesBitMask != 0)
{
@@ -389,7 +389,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
hostProgram = context.Renderer.LoadProgramBinary(hostCode, hasFragmentShader, shaderInfo);
}
- CachedShaderProgram program = new CachedShaderProgram(hostProgram, specState, shaders);
+ CachedShaderProgram program = new(hostProgram, specState, shaders);
loader.QueueHostProgram(program, hostCode, programIndex, isCompute);
}
@@ -448,9 +448,9 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
tocFileStream = DiskCacheCommon.OpenFile(_basePath, GetHostTocFileName(context), writable: false);
dataFileStream = DiskCacheCommon.OpenFile(_basePath, GetHostDataFileName(context), writable: false);
- BinarySerializer tempTocReader = new BinarySerializer(tocFileStream);
+ BinarySerializer tempTocReader = new(tocFileStream);
- TocHeader header = new TocHeader();
+ TocHeader header = new();
tempTocReader.Read(ref header);
@@ -473,9 +473,9 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
tocFileStream.Seek(offset, SeekOrigin.Begin);
- BinarySerializer tocReader = new BinarySerializer(tocFileStream);
+ BinarySerializer tocReader = new(tocFileStream);
- OffsetAndSize offsetAndSize = new OffsetAndSize();
+ OffsetAndSize offsetAndSize = new();
tocReader.Read(ref offsetAndSize);
if (offsetAndSize.Offset >= (ulong)dataFileStream.Length)
@@ -490,7 +490,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
BinarySerializer.ReadCompressed(dataFileStream, hostCode);
CachedShaderStage[] shaders = new CachedShaderStage[guestShaders.Length];
- BinarySerializer dataReader = new BinarySerializer(dataFileStream);
+ BinarySerializer dataReader = new(dataFileStream);
dataFileStream.Seek((long)(offsetAndSize.Offset + offsetAndSize.CompressedSize), SeekOrigin.Begin);
@@ -559,27 +559,28 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
if (tocFileStream.Length == 0)
{
- TocHeader header = new TocHeader();
+ TocHeader header = new();
CreateToc(tocFileStream, ref header, TocsMagic, CodeGenVersion, timestamp);
}
tocFileStream.Seek(0, SeekOrigin.End);
dataFileStream.Seek(0, SeekOrigin.End);
- BinarySerializer tocWriter = new BinarySerializer(tocFileStream);
- BinarySerializer dataWriter = new BinarySerializer(dataFileStream);
+ BinarySerializer tocWriter = new(tocFileStream);
+ BinarySerializer dataWriter = new(dataFileStream);
ulong dataOffset = (ulong)dataFileStream.Position;
tocWriter.Write(ref dataOffset);
- DataEntry entry = new DataEntry();
-
- entry.StagesBitMask = stagesBitMask;
+ DataEntry entry = new()
+ {
+ StagesBitMask = stagesBitMask,
+ };
dataWriter.BeginCompression(DiskCacheCommon.GetCompressionAlgorithm());
dataWriter.Write(ref entry);
- DataEntryPerStage stageEntry = new DataEntryPerStage();
+ DataEntryPerStage stageEntry = new();
for (int index = 0; index < program.Shaders.Length; index++)
{
@@ -665,19 +666,21 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
if (tocFileStream.Length == 0)
{
- TocHeader header = new TocHeader();
+ TocHeader header = new();
CreateToc(tocFileStream, ref header, TochMagic, 0, timestamp);
}
tocFileStream.Seek(0, SeekOrigin.End);
dataFileStream.Seek(0, SeekOrigin.End);
- BinarySerializer tocWriter = new BinarySerializer(tocFileStream);
- BinarySerializer dataWriter = new BinarySerializer(dataFileStream);
+ BinarySerializer tocWriter = new(tocFileStream);
+ BinarySerializer dataWriter = new(dataFileStream);
- OffsetAndSize offsetAndSize = new OffsetAndSize();
- offsetAndSize.Offset = (ulong)dataFileStream.Position;
- offsetAndSize.UncompressedSize = (uint)hostCode.Length;
+ OffsetAndSize offsetAndSize = new()
+ {
+ Offset = (ulong)dataFileStream.Position,
+ UncompressedSize = (uint)hostCode.Length,
+ };
long dataStartPosition = dataFileStream.Position;
@@ -714,9 +717,9 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
/// <param name="magic">Magic value to be written</param>
/// <param name="codegenVersion">Shader codegen version, only valid for the host file</param>
/// <param name="timestamp">File creation timestamp</param>
- private void CreateToc(Stream tocFileStream, ref TocHeader header, uint magic, uint codegenVersion, ulong timestamp)
+ private static void CreateToc(Stream tocFileStream, ref TocHeader header, uint magic, uint codegenVersion, ulong timestamp)
{
- BinarySerializer writer = new BinarySerializer(tocFileStream);
+ BinarySerializer writer = new(tocFileStream);
header.Magic = magic;
header.FormatVersion = FileFormatVersionPacked;
@@ -741,7 +744,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
/// <returns>Shader program info</returns>
private static ShaderProgramInfo ReadShaderProgramInfo(ref BinarySerializer dataReader)
{
- DataShaderInfo dataInfo = new DataShaderInfo();
+ DataShaderInfo dataInfo = new();
dataReader.ReadWithMagicAndSize(ref dataInfo, ShdiMagic);
@@ -797,18 +800,19 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
return;
}
- DataShaderInfo dataInfo = new DataShaderInfo();
-
- dataInfo.CBuffersCount = (ushort)info.CBuffers.Count;
- dataInfo.SBuffersCount = (ushort)info.SBuffers.Count;
- dataInfo.TexturesCount = (ushort)info.Textures.Count;
- dataInfo.ImagesCount = (ushort)info.Images.Count;
- dataInfo.Stage = info.Stage;
- dataInfo.UsesInstanceId = info.UsesInstanceId;
- dataInfo.UsesDrawParameters = info.UsesDrawParameters;
- dataInfo.UsesRtLayer = info.UsesRtLayer;
- dataInfo.ClipDistancesWritten = info.ClipDistancesWritten;
- dataInfo.FragmentOutputMap = info.FragmentOutputMap;
+ DataShaderInfo dataInfo = new()
+ {
+ CBuffersCount = (ushort)info.CBuffers.Count,
+ SBuffersCount = (ushort)info.SBuffers.Count,
+ TexturesCount = (ushort)info.Textures.Count,
+ ImagesCount = (ushort)info.Images.Count,
+ Stage = info.Stage,
+ UsesInstanceId = info.UsesInstanceId,
+ UsesDrawParameters = info.UsesDrawParameters,
+ UsesRtLayer = info.UsesRtLayer,
+ ClipDistancesWritten = info.ClipDistancesWritten,
+ FragmentOutputMap = info.FragmentOutputMap,
+ };
dataWriter.WriteWithMagicAndSize(ref dataInfo, ShdiMagic);
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheLoadException.cs b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheLoadException.cs
index d6e23302..9320638c 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheLoadException.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheLoadException.cs
@@ -45,4 +45,4 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
Result = result;
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheLoadResult.cs b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheLoadResult.cs
index b3ffa4a7..ba23f70e 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheLoadResult.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheLoadResult.cs
@@ -43,7 +43,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
/// <summary>
/// File might be valid, but is incompatible with the current emulator version.
/// </summary>
- IncompatibleVersion
+ IncompatibleVersion,
}
static class DiskCacheLoadResultExtensions
@@ -65,8 +65,8 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
DiskCacheLoadResult.FileCorruptedInvalidMagic => "Magic check failed, the cache file is corrupted.",
DiskCacheLoadResult.FileCorruptedInvalidLength => "Length check failed, the cache file is corrupted.",
DiskCacheLoadResult.IncompatibleVersion => "The version of the disk cache is not compatible with this version of the emulator.",
- _ => "Unknown error."
+ _ => "Unknown error.",
};
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/GuestCodeAndCbData.cs b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/GuestCodeAndCbData.cs
index 959d6e18..f412c62e 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/GuestCodeAndCbData.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/GuestCodeAndCbData.cs
@@ -26,4 +26,4 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
Cb1Data = cb1Data;
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/ParallelDiskCacheLoader.cs b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/ParallelDiskCacheLoader.cs
index 8df89824..8c2108bf 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/ParallelDiskCacheLoader.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/ParallelDiskCacheLoader.cs
@@ -190,7 +190,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
private readonly BlockingCollection<AsyncProgramTranslation> _asyncTranslationQueue;
private readonly SortedList<int, (CachedShaderProgram, byte[])> _programList;
- private int _backendParallelCompileThreads;
+ private readonly int _backendParallelCompileThreads;
private int _compiledCount;
private int _totalCount;
@@ -201,22 +201,21 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
/// <param name="graphicsCache">Graphics shader cache</param>
/// <param name="computeCache">Compute shader cache</param>
/// <param name="hostStorage">Disk cache host storage</param>
- /// <param name="cancellationToken">Cancellation token</param>
/// <param name="stateChangeCallback">Function to be called when there is a state change, reporting state, compiled and total shaders count</param>
- public ParallelDiskCacheLoader(
- GpuContext context,
+ /// <param name="cancellationToken">Cancellation token</param>
+ public ParallelDiskCacheLoader(GpuContext context,
ShaderCacheHashTable graphicsCache,
ComputeShaderCacheHashTable computeCache,
DiskCacheHostStorage hostStorage,
- CancellationToken cancellationToken,
- Action<ShaderCacheState, int, int> stateChangeCallback)
+ Action<ShaderCacheState, int, int> stateChangeCallback,
+ CancellationToken cancellationToken)
{
_context = context;
_graphicsCache = graphicsCache;
_computeCache = computeCache;
_hostStorage = hostStorage;
- _cancellationToken = cancellationToken;
_stateChangeCallback = stateChangeCallback;
+ _cancellationToken = cancellationToken;
_validationQueue = new Queue<ProgramEntry>();
_compilationQueue = new ConcurrentQueue<ProgramCompilation>();
_asyncTranslationQueue = new BlockingCollection<AsyncProgramTranslation>(ThreadCount);
@@ -235,7 +234,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
{
workThreads[index] = new Thread(ProcessAsyncQueue)
{
- Name = $"GPU.AsyncTranslationThread.{index}"
+ Name = $"GPU.AsyncTranslationThread.{index}",
};
}
@@ -367,7 +366,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
{
try
{
- AsyncProgramTranslation asyncTranslation = new AsyncProgramTranslation(guestShaders, specState, programIndex, isCompute);
+ AsyncProgramTranslation asyncTranslation = new(guestShaders, specState, programIndex, isCompute);
_asyncTranslationQueue.Add(asyncTranslation, _cancellationToken);
}
catch (OperationCanceledException)
@@ -491,7 +490,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
{
ShaderSource[] shaderSources = new ShaderSource[compilation.TranslatedStages.Length];
- ShaderInfoBuilder shaderInfoBuilder = new ShaderInfoBuilder(_context, compilation.SpecializationState.TransformFeedbackDescriptors != null);
+ ShaderInfoBuilder shaderInfoBuilder = new(_context, compilation.SpecializationState.TransformFeedbackDescriptors != null);
for (int index = 0; index < compilation.TranslatedStages.Length; index++)
{
@@ -502,7 +501,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
ShaderInfo shaderInfo = shaderInfoBuilder.Build(compilation.SpecializationState.PipelineState, fromCache: true);
IProgram hostProgram = _context.Renderer.CreateProgram(shaderSources, shaderInfo);
- CachedShaderProgram program = new CachedShaderProgram(hostProgram, compilation.SpecializationState, compilation.Shaders);
+ CachedShaderProgram program = new(hostProgram, compilation.SpecializationState, compilation.Shaders);
// Vulkan's binary code is the SPIR-V used for compilation, so it is ready immediately. Other APIs get this after compilation.
byte[] binaryCode = _context.Capabilities.Api == TargetApi.Vulkan ? ShaderBinarySerializer.Pack(shaderSources) : null;
@@ -589,12 +588,12 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
/// <param name="programIndex">Program index</param>
private void RecompileGraphicsFromGuestCode(GuestCodeAndCbData?[] guestShaders, ShaderSpecializationState specState, int programIndex)
{
- ShaderSpecializationState newSpecState = new ShaderSpecializationState(
+ ShaderSpecializationState newSpecState = new(
ref specState.GraphicsState,
specState.PipelineState,
specState.TransformFeedbackDescriptors);
- ResourceCounts counts = new ResourceCounts();
+ ResourceCounts counts = new();
TranslatorContext[] translatorContexts = new TranslatorContext[Constants.ShaderStages + 1];
TranslatorContext nextStage = null;
@@ -610,7 +609,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
byte[] guestCode = shader.Code;
byte[] cb1Data = shader.Cb1Data;
- DiskCacheGpuAccessor gpuAccessor = new DiskCacheGpuAccessor(_context, guestCode, cb1Data, specState, newSpecState, counts, stageIndex);
+ DiskCacheGpuAccessor gpuAccessor = new(_context, guestCode, cb1Data, specState, newSpecState, counts, stageIndex);
TranslatorContext currentStage = DecodeGraphicsShader(gpuAccessor, api, DefaultFlags, 0);
if (nextStage != null)
@@ -623,7 +622,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
byte[] guestCodeA = guestShaders[0].Value.Code;
byte[] cb1DataA = guestShaders[0].Value.Cb1Data;
- DiskCacheGpuAccessor gpuAccessorA = new DiskCacheGpuAccessor(_context, guestCodeA, cb1DataA, specState, newSpecState, counts, 0);
+ DiskCacheGpuAccessor gpuAccessorA = new(_context, guestCodeA, cb1DataA, specState, newSpecState, counts, 0);
translatorContexts[0] = DecodeGraphicsShader(gpuAccessorA, api, DefaultFlags | TranslationFlags.VertexA, 0);
}
@@ -638,7 +637,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
}
CachedShaderStage[] shaders = new CachedShaderStage[guestShaders.Length];
- List<ShaderProgram> translatedStages = new List<ShaderProgram>();
+ List<ShaderProgram> translatedStages = new();
TranslatorContext previousStage = null;
@@ -699,9 +698,9 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
private void RecompileComputeFromGuestCode(GuestCodeAndCbData?[] guestShaders, ShaderSpecializationState specState, int programIndex)
{
GuestCodeAndCbData shader = guestShaders[0].Value;
- ResourceCounts counts = new ResourceCounts();
- ShaderSpecializationState newSpecState = new ShaderSpecializationState(ref specState.ComputeState);
- DiskCacheGpuAccessor gpuAccessor = new DiskCacheGpuAccessor(_context, shader.Code, shader.Cb1Data, specState, newSpecState, counts, 0);
+ ResourceCounts counts = new();
+ ShaderSpecializationState newSpecState = new(ref specState.ComputeState);
+ DiskCacheGpuAccessor gpuAccessor = new(_context, shader.Code, shader.Cb1Data, specState, newSpecState, counts, 0);
TranslatorContext translatorContext = DecodeComputeShader(gpuAccessor, _context.Capabilities.Api, 0);
@@ -721,4 +720,4 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
_stateChangeCallback(ShaderCacheState.Loading, ++_compiledCount, _totalCount);
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/ShaderBinarySerializer.cs b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/ShaderBinarySerializer.cs
index 2dc5c971..a18b5780 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/ShaderBinarySerializer.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/ShaderBinarySerializer.cs
@@ -3,7 +3,6 @@ using Ryujinx.Common.Memory;
using Ryujinx.Graphics.GAL;
using Ryujinx.Graphics.Shader;
using Ryujinx.Graphics.Shader.Translation;
-using System;
using System.Collections.Generic;
using System.IO;
@@ -29,10 +28,10 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
public static ShaderSource[] Unpack(CachedShaderStage[] stages, byte[] code)
{
- using MemoryStream input = new MemoryStream(code);
- using BinaryReader reader = new BinaryReader(input);
+ using MemoryStream input = new(code);
+ using BinaryReader reader = new(input);
- List<ShaderSource> output = new List<ShaderSource>();
+ List<ShaderSource> output = new();
int count = reader.ReadInt32();
@@ -48,4 +47,4 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
return output.ToArray();
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/GpuAccessor.cs b/src/Ryujinx.Graphics.Gpu/Shader/GpuAccessor.cs
index 5e18e61f..ca9c883e 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/GpuAccessor.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/GpuAccessor.cs
@@ -97,7 +97,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
CompareOp.Greater or CompareOp.GreaterGl => AlphaTestOp.Greater,
CompareOp.NotEqual or CompareOp.NotEqualGl => AlphaTestOp.NotEqual,
CompareOp.GreaterOrEqual or CompareOp.GreaterOrEqualGl => AlphaTestOp.GreaterOrEqual,
- _ => AlphaTestOp.Always
+ _ => AlphaTestOp.Always,
};
}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/GpuAccessorBase.cs b/src/Ryujinx.Graphics.Gpu/Shader/GpuAccessorBase.cs
index 2dd7c631..07b7ddc2 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/GpuAccessorBase.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/GpuAccessorBase.cs
@@ -4,7 +4,6 @@ using Ryujinx.Graphics.Gpu.Engine.Threed;
using Ryujinx.Graphics.Gpu.Image;
using Ryujinx.Graphics.Shader;
using Ryujinx.Graphics.Shader.Translation;
-using System;
namespace Ryujinx.Graphics.Gpu.Shader
{
@@ -125,7 +124,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
3 => 2, // Geometry
1 => 3, // Tessellation control
2 => 4, // Tessellation evaluation
- _ => 0 // Vertex/Compute
+ _ => 0, // Vertex/Compute
};
}
@@ -188,6 +187,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
return formatInfo.Format switch
{
+#pragma warning disable IDE0055 // Disable formatting
Format.R8Unorm => TextureFormat.R8Unorm,
Format.R8Snorm => TextureFormat.R8Snorm,
Format.R8Uint => TextureFormat.R8Uint,
@@ -228,7 +228,8 @@ namespace Ryujinx.Graphics.Gpu.Shader
Format.R10G10B10A2Unorm => TextureFormat.R10G10B10A2Unorm,
Format.R10G10B10A2Uint => TextureFormat.R10G10B10A2Uint,
Format.R11G11B10Float => TextureFormat.R11G11B10Float,
- _ => TextureFormat.Unknown
+ _ => TextureFormat.Unknown,
+#pragma warning restore IDE0055
};
}
@@ -256,7 +257,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
PrimitiveTopology.Patches => tessellationMode.UnpackPatchType() == TessPatchType.Isolines
? InputTopology.Lines
: InputTopology.Triangles,
- _ => InputTopology.Points
+ _ => InputTopology.Points,
};
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/GpuAccessorState.cs b/src/Ryujinx.Graphics.Gpu/Shader/GpuAccessorState.cs
index 0e8e979c..cfc4a2cc 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/GpuAccessorState.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/GpuAccessorState.cs
@@ -58,4 +58,4 @@ namespace Ryujinx.Graphics.Gpu.Shader
ResourceCounts = new ResourceCounts();
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/GpuChannelComputeState.cs b/src/Ryujinx.Graphics.Gpu/Shader/GpuChannelComputeState.cs
index b65dd75e..d8cdbc34 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/GpuChannelComputeState.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/GpuChannelComputeState.cs
@@ -62,4 +62,4 @@ namespace Ryujinx.Graphics.Gpu.Shader
HasUnalignedStorageBuffer = hasUnalignedStorageBuffer;
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/GpuChannelGraphicsState.cs b/src/Ryujinx.Graphics.Gpu/Shader/GpuChannelGraphicsState.cs
index 5247a096..544e689a 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/GpuChannelGraphicsState.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/GpuChannelGraphicsState.cs
@@ -155,4 +155,4 @@ namespace Ryujinx.Graphics.Gpu.Shader
DualSourceBlendEnable = dualSourceBlendEnable;
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/GpuChannelPoolState.cs b/src/Ryujinx.Graphics.Gpu/Shader/GpuChannelPoolState.cs
index 1e34c5de..ddb45152 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/GpuChannelPoolState.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/GpuChannelPoolState.cs
@@ -2,6 +2,7 @@ using System;
namespace Ryujinx.Graphics.Gpu.Shader
{
+#pragma warning disable CS0659 // Class overrides Object.Equals(object o) but does not override Object.GetHashCode()
/// <summary>
/// State used by the <see cref="GpuAccessor"/>.
/// </summary>
@@ -46,5 +47,11 @@ namespace Ryujinx.Graphics.Gpu.Shader
TexturePoolMaximumId == other.TexturePoolMaximumId &&
TextureBufferIndex == other.TextureBufferIndex;
}
+
+ public override bool Equals(object obj)
+ {
+ return obj is GpuChannelPoolState state && Equals(state);
+ }
}
-} \ No newline at end of file
+#pragma warning restore CS0659
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/HashTable/HashState.cs b/src/Ryujinx.Graphics.Gpu/Shader/HashTable/HashState.cs
index 584eefdc..836b8663 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/HashTable/HashState.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/HashTable/HashState.cs
@@ -21,7 +21,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.HashTable
/// <returns>Hash of the given data</returns>
public static uint CalcHash(ReadOnlySpan<byte> data)
{
- HashState state = new HashState();
+ HashState state = new();
state.Initialize();
state.Continue(data);
@@ -50,7 +50,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.HashTable
{
ulong h = _hash;
- ReadOnlySpan<ulong> dataAsUlong = MemoryMarshal.Cast<byte, ulong>(data.Slice(_start));
+ ReadOnlySpan<ulong> dataAsUlong = MemoryMarshal.Cast<byte, ulong>(data[_start..]);
for (int i = 0; i < dataAsUlong.Length; i++)
{
@@ -75,7 +75,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.HashTable
/// </remarks>
/// <param name="data">Data to be hashed</param>
/// <returns>Hash of all the data hashed with this <see cref="HashState"/></returns>
- public uint Finalize(ReadOnlySpan<byte> data)
+ public readonly uint Finalize(ReadOnlySpan<byte> data)
{
ulong h = _hash;
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/HashTable/PartitionHashTable.cs b/src/Ryujinx.Graphics.Gpu/Shader/HashTable/PartitionHashTable.cs
index d7cb3d99..c8c8dfcb 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/HashTable/PartitionHashTable.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/HashTable/PartitionHashTable.cs
@@ -48,7 +48,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.HashTable
/// Partial entries have no items associated with them. They just indicates that the data might be present on
/// the table, and one must keep looking for the full entry on other tables of larger data size.
/// </remarks>
- public bool IsPartial => OwnSize != 0;
+ public readonly bool IsPartial => OwnSize != 0;
/// <summary>
/// Creates a new partial hash table entry.
@@ -82,11 +82,11 @@ namespace Ryujinx.Graphics.Gpu.Shader.HashTable
/// Gets the data for this entry, either full or partial.
/// </summary>
/// <returns>Data sub-region</returns>
- public ReadOnlySpan<byte> GetData()
+ public readonly ReadOnlySpan<byte> GetData()
{
if (OwnSize != 0)
{
- return new ReadOnlySpan<byte>(Data).Slice(0, OwnSize);
+ return new ReadOnlySpan<byte>(Data)[..OwnSize];
}
return Data;
@@ -139,7 +139,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.HashTable
return existingItem;
}
- Entry entry = new Entry(dataHash, data, item);
+ Entry entry = new(dataHash, data, item);
AddToBucket(dataHash, ref entry);
@@ -160,7 +160,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.HashTable
return false;
}
- Entry entry = new Entry(dataHash, data, item);
+ Entry entry = new(dataHash, data, item);
AddToBucket(dataHash, ref entry);
@@ -175,7 +175,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.HashTable
/// <returns>True if added, false otherwise</returns>
public bool AddPartial(byte[] ownerData, int ownSize)
{
- ReadOnlySpan<byte> data = new ReadOnlySpan<byte>(ownerData).Slice(0, ownSize);
+ ReadOnlySpan<byte> data = new ReadOnlySpan<byte>(ownerData)[..ownSize];
return AddPartial(ownerData, HashState.CalcHash(data), ownSize);
}
@@ -189,14 +189,14 @@ namespace Ryujinx.Graphics.Gpu.Shader.HashTable
/// <returns>True if added, false otherwise</returns>
public bool AddPartial(byte[] ownerData, uint dataHash, int ownSize)
{
- ReadOnlySpan<byte> data = new ReadOnlySpan<byte>(ownerData).Slice(0, ownSize);
+ ReadOnlySpan<byte> data = new ReadOnlySpan<byte>(ownerData)[..ownSize];
if (TryFindItem(dataHash, data, out _))
{
return false;
}
- Entry entry = new Entry(dataHash, ownerData, ownSize);
+ Entry entry = new(dataHash, ownerData, ownSize);
AddToBucket(dataHash, ref entry);
@@ -226,7 +226,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.HashTable
/// </summary>
/// <param name="bucket">Bucket to add the entry into</param>
/// <param name="entry">Entry to be added</param>
- private void AddToBucket(ref Bucket bucket, ref Entry entry)
+ private static void AddToBucket(ref Bucket bucket, ref Entry entry)
{
if (bucket.InlineEntry.Data == null)
{
@@ -339,7 +339,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.HashTable
/// <summary>
/// A full entry was found, the search was concluded and the item can be retrieved.
/// </summary>
- FoundFull
+ FoundFull,
}
/// <summary>
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/HashTable/PartitionedHashTable.cs b/src/Ryujinx.Graphics.Gpu/Shader/HashTable/PartitionedHashTable.cs
index e9a4f654..341d3114 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/HashTable/PartitionedHashTable.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/HashTable/PartitionedHashTable.cs
@@ -149,12 +149,12 @@ namespace Ryujinx.Graphics.Gpu.Shader.HashTable
}
}
- HashState hashState = new HashState();
+ HashState hashState = new();
hashState.Initialize();
for (int i = 0; i < index; i++)
{
- ReadOnlySpan<byte> dataSlice = new ReadOnlySpan<byte>(data).Slice(0, _sizeTable[i].Size);
+ ReadOnlySpan<byte> dataSlice = new ReadOnlySpan<byte>(data)[.._sizeTable[i].Size];
hashState.Continue(dataSlice);
_sizeTable[i].AddPartial(data, hashState.Finalize(dataSlice));
}
@@ -208,7 +208,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.HashTable
/// <returns>True if the item was found on the table, false otherwise</returns>
public bool TryFindItem(IDataAccessor dataAccessor, out T item, out byte[] data)
{
- SmartDataAccessor sda = new SmartDataAccessor(dataAccessor);
+ SmartDataAccessor sda = new(dataAccessor);
item = default;
data = null;
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/HashTable/SmartDataAccessor.cs b/src/Ryujinx.Graphics.Gpu/Shader/HashTable/SmartDataAccessor.cs
index 0632add6..17853e90 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/HashTable/SmartDataAccessor.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/HashTable/SmartDataAccessor.cs
@@ -40,7 +40,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.HashTable
}
else if (_data.Length > length)
{
- return _data.Slice(0, length);
+ return _data[..length];
}
return _data;
@@ -65,7 +65,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.HashTable
/// </summary>
/// <param name="data">Data to be hashed</param>
/// <returns>Hash of the data</returns>
- private uint CalcHashCached(ReadOnlySpan<byte> data)
+ private readonly uint CalcHashCached(ReadOnlySpan<byte> data)
{
HashState state = default;
bool found = false;
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/ResourceCounts.cs b/src/Ryujinx.Graphics.Gpu/Shader/ResourceCounts.cs
index f495229f..126e3249 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/ResourceCounts.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/ResourceCounts.cs
@@ -25,4 +25,4 @@ namespace Ryujinx.Graphics.Gpu.Shader
/// </summary>
public int ImagesCount;
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/ShaderAddresses.cs b/src/Ryujinx.Graphics.Gpu/Shader/ShaderAddresses.cs
index 651dfd26..32d92223 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/ShaderAddresses.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/ShaderAddresses.cs
@@ -9,7 +9,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
/// </summary>
struct ShaderAddresses : IEquatable<ShaderAddresses>
{
-#pragma warning disable CS0649
+#pragma warning disable CS0649 // Field is never assigned to
public ulong VertexA;
public ulong VertexB;
public ulong TessControl;
@@ -23,7 +23,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
/// </summary>
/// <param name="other">Shader addresses structure to compare with</param>
/// <returns>True if they are equal, false otherwise</returns>
- public override bool Equals(object other)
+ public readonly override bool Equals(object other)
{
return other is ShaderAddresses addresses && Equals(addresses);
}
@@ -33,21 +33,21 @@ namespace Ryujinx.Graphics.Gpu.Shader
/// </summary>
/// <param name="other">Shader addresses structure to compare with</param>
/// <returns>True if they are equal, false otherwise</returns>
- public bool Equals(ShaderAddresses other)
+ public readonly bool Equals(ShaderAddresses other)
{
- return VertexA == other.VertexA &&
- VertexB == other.VertexB &&
- TessControl == other.TessControl &&
+ return VertexA == other.VertexA &&
+ VertexB == other.VertexB &&
+ TessControl == other.TessControl &&
TessEvaluation == other.TessEvaluation &&
- Geometry == other.Geometry &&
- Fragment == other.Fragment;
+ Geometry == other.Geometry &&
+ Fragment == other.Fragment;
}
/// <summary>
/// Computes hash code from the addresses.
/// </summary>
/// <returns>Hash code</returns>
- public override int GetHashCode()
+ public readonly override int GetHashCode()
{
return HashCode.Combine(VertexA, VertexB, TessControl, TessEvaluation, Geometry, Fragment);
}
@@ -61,4 +61,4 @@ namespace Ryujinx.Graphics.Gpu.Shader
return MemoryMarshal.CreateSpan(ref VertexA, Unsafe.SizeOf<ShaderAddresses>() / sizeof(ulong));
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs b/src/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs
index 913f6e9e..97d7a720 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs
@@ -11,7 +11,6 @@ using Ryujinx.Graphics.Shader.Translation;
using System;
using System.Collections.Generic;
using System.IO;
-using System.Linq;
using System.Threading;
namespace Ryujinx.Graphics.Gpu.Shader
@@ -73,7 +72,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
}
}
- private Queue<ProgramToSave> _programsToSaveQueue;
+ private readonly Queue<ProgramToSave> _programsToSaveQueue;
private readonly ComputeShaderCacheHashTable _computeShaderCache;
private readonly ShaderCacheHashTable _graphicsShaderCache;
@@ -157,13 +156,12 @@ namespace Ryujinx.Graphics.Gpu.Shader
{
if (_diskCacheHostStorage.CacheEnabled)
{
- ParallelDiskCacheLoader loader = new ParallelDiskCacheLoader(
+ ParallelDiskCacheLoader loader = new(
_context,
_graphicsShaderCache,
_computeShaderCache,
_diskCacheHostStorage,
- cancellationToken,
- ShaderCacheStateUpdate);
+ ShaderCacheStateUpdate, cancellationToken);
loader.LoadShaders();
@@ -214,9 +212,9 @@ namespace Ryujinx.Graphics.Gpu.Shader
return cpShader;
}
- ShaderSpecializationState specState = new ShaderSpecializationState(ref computeState);
- GpuAccessorState gpuAccessorState = new GpuAccessorState(poolState, computeState, default, specState);
- GpuAccessor gpuAccessor = new GpuAccessor(_context, channel, gpuAccessorState);
+ ShaderSpecializationState specState = new(ref computeState);
+ GpuAccessorState gpuAccessorState = new(poolState, computeState, default, specState);
+ GpuAccessor gpuAccessor = new(_context, channel, gpuAccessorState);
TranslatorContext translatorContext = DecodeComputeShader(gpuAccessor, _context.Capabilities.Api, gpuVa);
TranslatedShader translatedShader = TranslateShader(_dumper, channel, translatorContext, cachedGuestCode);
@@ -241,7 +239,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
/// <param name="pipeline">Shader pipeline state to be updated</param>
/// <param name="graphicsState">Current graphics state</param>
/// <param name="channel">Current GPU channel</param>
- private void UpdatePipelineInfo(
+ private static void UpdatePipelineInfo(
ref ThreedClassState state,
ref ProgramPipelineState pipeline,
GpuChannelGraphicsState graphicsState,
@@ -318,8 +316,8 @@ namespace Ryujinx.Graphics.Gpu.Shader
UpdatePipelineInfo(ref state, ref pipeline, graphicsState, channel);
- ShaderSpecializationState specState = new ShaderSpecializationState(ref graphicsState, ref pipeline, transformFeedbackDescriptors);
- GpuAccessorState gpuAccessorState = new GpuAccessorState(poolState, default, graphicsState, specState, transformFeedbackDescriptors);
+ ShaderSpecializationState specState = new(ref graphicsState, ref pipeline, transformFeedbackDescriptors);
+ GpuAccessorState gpuAccessorState = new(poolState, default, graphicsState, specState, transformFeedbackDescriptors);
ReadOnlySpan<ulong> addressesSpan = addresses.AsSpan();
@@ -334,7 +332,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
if (gpuVa != 0)
{
- GpuAccessor gpuAccessor = new GpuAccessor(_context, channel, gpuAccessorState, stageIndex);
+ GpuAccessor gpuAccessor = new(_context, channel, gpuAccessorState, stageIndex);
TranslatorContext currentStage = DecodeGraphicsShader(gpuAccessor, api, DefaultFlags, gpuVa);
if (nextStage != null)
@@ -358,11 +356,11 @@ namespace Ryujinx.Graphics.Gpu.Shader
}
CachedShaderStage[] shaders = new CachedShaderStage[Constants.ShaderStages + 1];
- List<ShaderSource> shaderSources = new List<ShaderSource>();
+ List<ShaderSource> shaderSources = new();
TranslatorContext previousStage = null;
- ShaderInfoBuilder infoBuilder = new ShaderInfoBuilder(_context, transformFeedbackDescriptors != null);
+ ShaderInfoBuilder infoBuilder = new(_context, transformFeedbackDescriptors != null);
for (int stageIndex = 0; stageIndex < Constants.ShaderStages; stageIndex++)
{
@@ -486,7 +484,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
if (_diskCacheHostStorage.CacheEnabled)
{
byte[] binaryCode = _context.Capabilities.Api == TargetApi.Vulkan ? ShaderBinarySerializer.Pack(sources) : null;
- ProgramToSave programToSave = new ProgramToSave(program, hostProgram, binaryCode);
+ ProgramToSave programToSave = new(program, hostProgram, binaryCode);
_programsToSaveQueue.Enqueue(programToSave);
}
@@ -670,8 +668,8 @@ namespace Ryujinx.Graphics.Gpu.Shader
pathsB.Prepend(program);
pathsA.Prepend(program);
- CachedShaderStage vertexAStage = new CachedShaderStage(null, codeA, cb1DataA);
- CachedShaderStage vertexBStage = new CachedShaderStage(program.Info, codeB, cb1DataB);
+ CachedShaderStage vertexAStage = new(null, codeA, cb1DataA);
+ CachedShaderStage vertexBStage = new(program.Info, codeB, cb1DataB);
return new TranslatedShaderVertexPair(vertexAStage, vertexBStage, program);
}
@@ -716,7 +714,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
ShaderStage.TessellationEvaluation => 2,
ShaderStage.Geometry => 3,
ShaderStage.Fragment => 4,
- _ => 0
+ _ => 0,
};
}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/ShaderCacheHashTable.cs b/src/Ryujinx.Graphics.Gpu/Shader/ShaderCacheHashTable.cs
index e35c06b1..e65a1dec 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/ShaderCacheHashTable.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/ShaderCacheHashTable.cs
@@ -23,7 +23,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
/// </summary>
/// <param name="stageIndex">Index of the shader stage</param>
/// <returns>Guest code, or null if not present</returns>
- public byte[] GetByIndex(int stageIndex)
+ public readonly byte[] GetByIndex(int stageIndex)
{
return stageIndex switch
{
@@ -31,7 +31,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
2 => TessEvaluationCode,
3 => GeometryCode,
4 => FragmentCode,
- _ => VertexBCode
+ _ => VertexBCode,
};
}
}
@@ -85,7 +85,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
/// <param name="id">ID of the guest code, if found</param>
/// <param name="data">Cached guest code, if found</param>
/// <returns>True if found, false otherwise</returns>
- public bool TryFind(IDataAccessor dataAccessor, out int id, out byte[] data)
+ public readonly bool TryFind(IDataAccessor dataAccessor, out int id, out byte[] data)
{
return _cache.TryFindItem(dataAccessor, out id, out data);
}
@@ -103,12 +103,12 @@ namespace Ryujinx.Graphics.Gpu.Shader
public int GeometryId;
public int FragmentId;
- public override bool Equals(object obj)
+ public readonly override bool Equals(object obj)
{
return obj is IdTable other && Equals(other);
}
- public bool Equals(IdTable other)
+ public readonly bool Equals(IdTable other)
{
return other.VertexAId == VertexAId &&
other.VertexBId == VertexBId &&
@@ -118,7 +118,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
other.FragmentId == FragmentId;
}
- public override int GetHashCode()
+ public readonly override int GetHashCode()
{
return HashCode.Combine(VertexAId, VertexBId, TessControlId, TessEvaluationId, GeometryId, FragmentId);
}
@@ -154,7 +154,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
/// <param name="program">Program to be added</param>
public void Add(CachedShaderProgram program)
{
- IdTable idTable = new IdTable();
+ IdTable idTable = new();
foreach (var shader in program.Shaders)
{
@@ -222,7 +222,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
out CachedGraphicsGuestCode guestCode)
{
var memoryManager = channel.MemoryManager;
- IdTable idTable = new IdTable();
+ IdTable idTable = new();
guestCode = new CachedGraphicsGuestCode();
program = null;
@@ -260,7 +260,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
return true;
}
- ShaderCodeAccessor codeAccessor = new ShaderCodeAccessor(memoryManager, baseAddress);
+ ShaderCodeAccessor codeAccessor = new(memoryManager, baseAddress);
return idCache.TryFind(codeAccessor, out id, out data);
}
@@ -279,4 +279,4 @@ namespace Ryujinx.Graphics.Gpu.Shader
}
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/ShaderCacheState.cs b/src/Ryujinx.Graphics.Gpu/Shader/ShaderCacheState.cs
index b94a6c05..075e3a61 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/ShaderCacheState.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/ShaderCacheState.cs
@@ -10,6 +10,6 @@ namespace Ryujinx.Graphics.Gpu.Shader
/// <summary>Shader cache is written to disk</summary>
Packaging,
/// <summary>Shader cache finished loading</summary>
- Loaded
+ Loaded,
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/ShaderCodeAccessor.cs b/src/Ryujinx.Graphics.Gpu/Shader/ShaderCodeAccessor.cs
index e896493c..240a4ce9 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/ShaderCodeAccessor.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/ShaderCodeAccessor.cs
@@ -29,4 +29,4 @@ namespace Ryujinx.Graphics.Gpu.Shader
return _memoryManager.GetSpanMapped(_baseAddress + (ulong)offset, length);
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/ShaderDumpPaths.cs b/src/Ryujinx.Graphics.Gpu/Shader/ShaderDumpPaths.cs
index 6ca7daef..d0765963 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/ShaderDumpPaths.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/ShaderDumpPaths.cs
@@ -46,4 +46,4 @@ namespace Ryujinx.Graphics.Gpu.Shader
}
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/ShaderDumper.cs b/src/Ryujinx.Graphics.Gpu/Shader/ShaderDumper.cs
index 93eeb8d7..80d599e9 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/ShaderDumper.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/ShaderDumper.cs
@@ -46,13 +46,13 @@ namespace Ryujinx.Graphics.Gpu.Shader
CurrentDumpIndex++;
- using MemoryStream stream = new MemoryStream(code);
- BinaryReader codeReader = new BinaryReader(stream);
+ using MemoryStream stream = new(code);
+ BinaryReader codeReader = new(stream);
using FileStream fullFile = File.Create(fullPath);
using FileStream codeFile = File.Create(codePath);
- BinaryWriter fullWriter = new BinaryWriter(fullFile);
- BinaryWriter codeWriter = new BinaryWriter(codeFile);
+ BinaryWriter fullWriter = new(fullFile);
+ BinaryWriter codeWriter = new(codeFile);
int headerSize = compute ? 0 : 0x50;
@@ -126,4 +126,4 @@ namespace Ryujinx.Graphics.Gpu.Shader
return dir;
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/ShaderInfoBuilder.cs b/src/Ryujinx.Graphics.Gpu/Shader/ShaderInfoBuilder.cs
index 83d92edc..7356410c 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/ShaderInfoBuilder.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/ShaderInfoBuilder.cs
@@ -92,7 +92,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
ShaderStage.TessellationEvaluation => 2,
ShaderStage.Geometry => 3,
ShaderStage.Fragment => 4,
- _ => 0
+ _ => 0,
});
ResourceStages stages = info.Stage switch
@@ -103,7 +103,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
ShaderStage.TessellationEvaluation => ResourceStages.TessellationEvaluation,
ShaderStage.Geometry => ResourceStages.Geometry,
ShaderStage.Fragment => ResourceStages.Fragment,
- _ => ResourceStages.None
+ _ => ResourceStages.None,
};
int uniformsPerStage = (int)_context.Capabilities.MaximumUniformBuffersPerStage;
@@ -236,7 +236,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
usages[index] = new ResourceUsageCollection(_resourceUsages[index].ToArray().AsReadOnly());
}
- ResourceLayout resourceLayout = new ResourceLayout(descriptors.AsReadOnly(), usages.AsReadOnly());
+ ResourceLayout resourceLayout = new(descriptors.AsReadOnly(), usages.AsReadOnly());
if (pipeline.HasValue)
{
@@ -262,7 +262,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
ProgramPipelineState? pipeline,
bool tfEnabled)
{
- ShaderInfoBuilder builder = new ShaderInfoBuilder(context, tfEnabled);
+ ShaderInfoBuilder builder = new(context, tfEnabled);
foreach (CachedShaderStage program in programs)
{
@@ -284,11 +284,11 @@ namespace Ryujinx.Graphics.Gpu.Shader
/// <returns>Shader information</returns>
public static ShaderInfo BuildForCompute(GpuContext context, ShaderProgramInfo info, bool fromCache = false)
{
- ShaderInfoBuilder builder = new ShaderInfoBuilder(context, tfEnabled: false);
+ ShaderInfoBuilder builder = new(context, tfEnabled: false);
builder.AddStageInfo(info);
return builder.Build(null, fromCache);
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/ShaderSpecializationList.cs b/src/Ryujinx.Graphics.Gpu/Shader/ShaderSpecializationList.cs
index 7d61332e..e57e1df1 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/ShaderSpecializationList.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/ShaderSpecializationList.cs
@@ -8,7 +8,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
/// </summary>
class ShaderSpecializationList : IEnumerable<CachedShaderProgram>
{
- private readonly List<CachedShaderProgram> _entries = new List<CachedShaderProgram>();
+ private readonly List<CachedShaderProgram> _entries = new();
/// <summary>
/// Adds a program to the list.
@@ -81,4 +81,4 @@ namespace Ryujinx.Graphics.Gpu.Shader
return GetEnumerator();
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/ShaderSpecializationState.cs b/src/Ryujinx.Graphics.Gpu/Shader/ShaderSpecializationState.cs
index 9b0c8b9b..775bfb2a 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/ShaderSpecializationState.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/ShaderSpecializationState.cs
@@ -31,7 +31,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
EarlyZForce = 1 << 0,
PrimitiveTopology = 1 << 1,
TessellationMode = 1 << 2,
- TransformFeedback = 1 << 3
+ TransformFeedback = 1 << 3,
}
private QueriedStateFlags _queriedState;
@@ -71,7 +71,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
{
TextureFormat = 1 << 0,
SamplerType = 1 << 1,
- CoordNormalized = 1 << 2
+ CoordNormalized = 1 << 2,
}
/// <summary>
@@ -440,7 +440,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
/// <returns>Texture specialization state</returns>
private Box<TextureSpecializationState> GetOrCreateTextureSpecState(int stageIndex, int handle, int cbufSlot)
{
- TextureKey key = new TextureKey(stageIndex, handle, cbufSlot);
+ TextureKey key = new(stageIndex, handle, cbufSlot);
if (!_textureSpecialization.TryGetValue(key, out Box<TextureSpecializationState> state))
{
@@ -459,7 +459,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
/// <returns>Texture specialization state</returns>
private Box<TextureSpecializationState> GetTextureSpecState(int stageIndex, int handle, int cbufSlot)
{
- TextureKey key = new TextureKey(stageIndex, handle, cbufSlot);
+ TextureKey key = new(stageIndex, handle, cbufSlot);
if (_textureSpecialization.TryGetValue(key, out Box<TextureSpecializationState> state))
{
@@ -694,7 +694,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
/// <param name="descriptor">Texture descriptor</param>
/// <returns>True if the state matches, false otherwise</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- private bool MatchesTexture(Box<TextureSpecializationState> specializationState, in Image.TextureDescriptor descriptor)
+ private static bool MatchesTexture(Box<TextureSpecializationState> specializationState, in Image.TextureDescriptor descriptor)
{
if (specializationState != null)
{
@@ -756,7 +756,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
/// <returns>Shader specialization state</returns>
public static ShaderSpecializationState Read(ref BinarySerializer dataReader)
{
- ShaderSpecializationState specState = new ShaderSpecializationState();
+ ShaderSpecializationState specState = new();
dataReader.Read(ref specState._queriedState);
dataReader.Read(ref specState._compute);
@@ -812,7 +812,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
for (int index = 0; index < count; index++)
{
TextureKey textureKey = default;
- Box<TextureSpecializationState> textureState = new Box<TextureSpecializationState>();
+ Box<TextureSpecializationState> textureState = new();
dataReader.ReadWithMagicAndSize(ref textureKey, TexkMagic);
dataReader.ReadWithMagicAndSize(ref textureState.Value, TexsMagic);
@@ -886,4 +886,4 @@ namespace Ryujinx.Graphics.Gpu.Shader
}
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/TransformFeedbackDescriptor.cs b/src/Ryujinx.Graphics.Gpu/Shader/TransformFeedbackDescriptor.cs
index 5baf2a1a..1f245881 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/TransformFeedbackDescriptor.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/TransformFeedbackDescriptor.cs
@@ -52,7 +52,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
/// <returns>Span of varying locations</returns>
public ReadOnlySpan<byte> AsSpan()
{
- return MemoryMarshal.Cast<uint, byte>(VaryingLocations.AsSpan()).Slice(0, Math.Min(128, VaryingCount));
+ return MemoryMarshal.Cast<uint, byte>(VaryingLocations.AsSpan())[..Math.Min(128, VaryingCount)];
}
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Synchronization/HostSyncFlags.cs b/src/Ryujinx.Graphics.Gpu/Synchronization/HostSyncFlags.cs
index 42666991..1b4df37e 100644
--- a/src/Ryujinx.Graphics.Gpu/Synchronization/HostSyncFlags.cs
+++ b/src/Ryujinx.Graphics.Gpu/Synchronization/HostSyncFlags.cs
@@ -25,6 +25,6 @@ namespace Ryujinx.Graphics.Gpu.Synchronization
/// </summary>
Force = 1 << 2,
- StrictSyncpoint = Strict | Syncpoint
+ StrictSyncpoint = Strict | Syncpoint,
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Synchronization/SynchronizationManager.cs b/src/Ryujinx.Graphics.Gpu/Synchronization/SynchronizationManager.cs
index 968de930..ccec763e 100644
--- a/src/Ryujinx.Graphics.Gpu/Synchronization/SynchronizationManager.cs
+++ b/src/Ryujinx.Graphics.Gpu/Synchronization/SynchronizationManager.cs
@@ -17,7 +17,7 @@ namespace Ryujinx.Graphics.Gpu.Synchronization
/// <summary>
/// Array containing all hardware syncpoints.
/// </summary>
- private Syncpoint[] _syncpoints;
+ private readonly Syncpoint[] _syncpoints;
public SynchronizationManager()
{
@@ -118,26 +118,24 @@ namespace Ryujinx.Graphics.Gpu.Synchronization
timeout = TimeSpan.FromSeconds(1);
}
- using (ManualResetEvent waitEvent = new ManualResetEvent(false))
- {
- var info = _syncpoints[id].RegisterCallback(threshold, (x) => waitEvent.Set());
-
- if (info == null)
- {
- return false;
- }
+ using ManualResetEvent waitEvent = new(false);
+ var info = _syncpoints[id].RegisterCallback(threshold, (x) => waitEvent.Set());
- bool signaled = waitEvent.WaitOne(timeout);
+ if (info == null)
+ {
+ return false;
+ }
- if (!signaled && info != null)
- {
- Logger.Error?.Print(LogClass.Gpu, $"Wait on syncpoint {id} for threshold {threshold} took more than {timeout.TotalMilliseconds}ms, resuming execution...");
+ bool signaled = waitEvent.WaitOne(timeout);
- _syncpoints[id].UnregisterCallback(info);
- }
+ if (!signaled && info != null)
+ {
+ Logger.Error?.Print(LogClass.Gpu, $"Wait on syncpoint {id} for threshold {threshold} took more than {timeout.TotalMilliseconds}ms, resuming execution...");
- return !signaled;
+ _syncpoints[id].UnregisterCallback(info);
}
+
+ return !signaled;
}
}
}
diff --git a/src/Ryujinx.Graphics.Gpu/Synchronization/Syncpoint.cs b/src/Ryujinx.Graphics.Gpu/Synchronization/Syncpoint.cs
index 39fb83c0..16f4d971 100644
--- a/src/Ryujinx.Graphics.Gpu/Synchronization/Syncpoint.cs
+++ b/src/Ryujinx.Graphics.Gpu/Synchronization/Syncpoint.cs
@@ -23,7 +23,7 @@ namespace Ryujinx.Graphics.Gpu.Synchronization
public Syncpoint(uint id)
{
- Id = id;
+ Id = id;
_waiters = new List<SyncpointWaiterHandle>();
}
@@ -46,10 +46,10 @@ namespace Ryujinx.Graphics.Gpu.Synchronization
}
else
{
- SyncpointWaiterHandle waiterInformation = new SyncpointWaiterHandle
+ SyncpointWaiterHandle waiterInformation = new()
{
Threshold = threshold,
- Callback = callback
+ Callback = callback,
};
_waiters.Add(waiterInformation);
@@ -92,10 +92,7 @@ namespace Ryujinx.Graphics.Gpu.Synchronization
}
else
{
- if (expiredList == null)
- {
- expiredList = new List<SyncpointWaiterHandle>();
- }
+ expiredList ??= new List<SyncpointWaiterHandle>();
expiredList.Add(item);
}
diff --git a/src/Ryujinx.Graphics.Gpu/Window.cs b/src/Ryujinx.Graphics.Gpu/Window.cs
index 06d0fddf..5da472b3 100644
--- a/src/Ryujinx.Graphics.Gpu/Window.cs
+++ b/src/Ryujinx.Graphics.Gpu/Window.cs
@@ -68,21 +68,21 @@ namespace Ryujinx.Graphics.Gpu
/// <param name="releaseCallback">Texture release callback</param>
/// <param name="userObj">User defined object passed to the release callback, can be used to identify the texture</param>
public PresentationTexture(
- TextureCache cache,
- TextureInfo info,
- MultiRange range,
- ImageCrop crop,
+ TextureCache cache,
+ TextureInfo info,
+ MultiRange range,
+ ImageCrop crop,
Action<GpuContext, object> acquireCallback,
- Action<object> releaseCallback,
- object userObj)
+ Action<object> releaseCallback,
+ object userObj)
{
- Cache = cache;
- Info = info;
- Range = range;
- Crop = crop;
+ Cache = cache;
+ Info = info;
+ Range = range;
+ Crop = crop;
AcquireCallback = acquireCallback;
ReleaseCallback = releaseCallback;
- UserObj = userObj;
+ UserObj = userObj;
}
}
@@ -125,28 +125,28 @@ namespace Ryujinx.Graphics.Gpu
/// <exception cref="ArgumentException">Thrown when <paramref name="pid"/> is invalid</exception>
/// <returns>True if the frame was added to the queue, false otherwise</returns>
public bool EnqueueFrameThreadSafe(
- ulong pid,
- ulong address,
- int width,
- int height,
- int stride,
- bool isLinear,
- int gobBlocksInY,
- Format format,
- int bytesPerPixel,
- ImageCrop crop,
+ ulong pid,
+ ulong address,
+ int width,
+ int height,
+ int stride,
+ bool isLinear,
+ int gobBlocksInY,
+ Format format,
+ int bytesPerPixel,
+ ImageCrop crop,
Action<GpuContext, object> acquireCallback,
- Action<object> releaseCallback,
- object userObj)
+ Action<object> releaseCallback,
+ object userObj)
{
if (!_context.PhysicalMemoryRegistry.TryGetValue(pid, out var physicalMemory))
{
return false;
}
- FormatInfo formatInfo = new FormatInfo(format, 1, 1, bytesPerPixel, 4);
+ FormatInfo formatInfo = new(format, 1, 1, bytesPerPixel, 4);
- TextureInfo info = new TextureInfo(
+ TextureInfo info = new(
0UL,
width,
height,
@@ -175,7 +175,7 @@ namespace Ryujinx.Graphics.Gpu
1,
1).TotalSize;
- MultiRange range = new MultiRange(address, (ulong)size);
+ MultiRange range = new(address, (ulong)size);
_frameQueue.Enqueue(new PresentationTexture(
physicalMemory.TextureCache,
@@ -260,4 +260,4 @@ namespace Ryujinx.Graphics.Gpu
return false;
}
}
-} \ No newline at end of file
+}