diff options
author | TSRBerry <20988865+TSRBerry@users.noreply.github.com> | 2023-07-02 02:47:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-02 02:47:54 +0200 |
commit | 3b46bb73f781a011705ecbc8a1d3207dfb145829 (patch) | |
tree | 1d5d2714c7001775b512bc14ce91a1ebbfc808df /src/Ryujinx.Graphics.Gpu/Engine/Dma | |
parent | 2457cfc9118a6ebb6008945c919edfd8b46af5e7 (diff) |
[Ryujinx.Graphics.Gpu] Address dotnet-format issues (#5367)1.1.951
* dotnet format style --severity info
Some changes were manually reverted.
* dotnet format analyzers --serverity info
Some changes have been minimally adapted.
* Restore a few unused methods and variables
* Silence dotnet format IDE0060 warnings
* Silence dotnet format IDE0052 warnings
* Address dotnet format CA1816 warnings
* Address or silence dotnet format CA1069 warnings
* Address or silence dotnet format CA2211 warnings
* Address remaining dotnet format analyzer warnings
* Address review comments
* Address most dotnet format whitespace warnings
* Apply dotnet format whitespace formatting
A few of them have been manually reverted and the corresponding warning was silenced
* Format if-blocks correctly
* Run dotnet format whitespace after rebase
* Run dotnet format style after rebase
* Another rebase, another dotnet format run
* Run dotnet format style after rebase
* Run dotnet format after rebase and remove unused usings
- analyzers
- style
- whitespace
* Disable 'prefer switch expression' rule
* Add comments to disabled warnings
* Remove a few unused parameters
* Replace MmeShadowScratch with Array256<uint>
* Simplify properties and array initialization, Use const when possible, Remove trailing commas
* Start working on disabled warnings
* Fix and silence a few dotnet-format warnings again
* Run dotnet format after rebase
* Address IDE0251 warnings
* Silence IDE0060 in .editorconfig
* Revert "Simplify properties and array initialization, Use const when possible, Remove trailing commas"
This reverts commit 9462e4136c0a2100dc28b20cf9542e06790aa67e.
* dotnet format whitespace after rebase
* First pass of dotnet format
* Add unsafe dotnet format changes
* Fix typos
* Add trailing commas
* Disable formatting for FormatTable
* Address review feedback
Diffstat (limited to 'src/Ryujinx.Graphics.Gpu/Engine/Dma')
-rw-r--r-- | src/Ryujinx.Graphics.Gpu/Engine/Dma/DmaClass.cs | 70 | ||||
-rw-r--r-- | src/Ryujinx.Graphics.Gpu/Engine/Dma/DmaClassState.cs | 84 | ||||
-rw-r--r-- | src/Ryujinx.Graphics.Gpu/Engine/Dma/DmaTexture.cs | 4 |
3 files changed, 90 insertions, 68 deletions
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 +} |