diff --git a/src/Ryujinx.Graphics.Nvdec/H264Decoder.cs b/src/Ryujinx.Graphics.Nvdec/H264Decoder.cs index ecc7dbc7..c99d4a17 100644 --- a/src/Ryujinx.Graphics.Nvdec/H264Decoder.cs +++ b/src/Ryujinx.Graphics.Nvdec/H264Decoder.cs @@ -17,12 +17,12 @@ namespace Ryujinx.Graphics.Nvdec ReadOnlySpan bitstream = rm.Gmm.DeviceGetSpan(state.SetInBufBaseOffset, (int)pictureInfo.BitstreamSize); - int width = (int)pictureInfo.PicWidthInMbs * MbSizeInPixels; + int width = (int)pictureInfo.PicWidthInMbs * MbSizeInPixels; int height = (int)pictureInfo.PicHeightInMbs * MbSizeInPixels; int surfaceIndex = (int)pictureInfo.OutputSurfaceIndex; - uint lumaOffset = state.SetPictureLumaOffset[surfaceIndex]; + uint lumaOffset = state.SetPictureLumaOffset[surfaceIndex]; uint chromaOffset = state.SetPictureChromaOffset[surfaceIndex]; Decoder decoder = context.GetH264Decoder(); @@ -36,7 +36,7 @@ namespace Ryujinx.Graphics.Nvdec SurfaceWriter.Write( rm.Gmm, outputSurface, - lumaOffset + pictureInfo.LumaFrameOffset, + lumaOffset + pictureInfo.LumaFrameOffset, chromaOffset + pictureInfo.ChromaFrameOffset); } else @@ -44,9 +44,9 @@ namespace Ryujinx.Graphics.Nvdec SurfaceWriter.WriteInterlaced( rm.Gmm, outputSurface, - lumaOffset + pictureInfo.LumaTopFieldOffset, + lumaOffset + pictureInfo.LumaTopFieldOffset, chromaOffset + pictureInfo.ChromaTopFieldOffset, - lumaOffset + pictureInfo.LumaBottomFieldOffset, + lumaOffset + pictureInfo.LumaBottomFieldOffset, chromaOffset + pictureInfo.ChromaBottomFieldOffset); } } diff --git a/src/Ryujinx.Graphics.Nvdec/Image/SurfaceReader.cs b/src/Ryujinx.Graphics.Nvdec/Image/SurfaceReader.cs index 039a2583..598b7199 100644 --- a/src/Ryujinx.Graphics.Nvdec/Image/SurfaceReader.cs +++ b/src/Ryujinx.Graphics.Nvdec/Image/SurfaceReader.cs @@ -43,7 +43,7 @@ namespace Ryujinx.Graphics.Nvdec.Image int width, int height) { - OffsetCalculator calc = new OffsetCalculator(width, height, 0, false, 2, 2); + OffsetCalculator calc = new(width, height, 0, false, 2, 2); if (Sse2.IsSupported) { diff --git a/src/Ryujinx.Graphics.Nvdec/Image/SurfaceWriter.cs b/src/Ryujinx.Graphics.Nvdec/Image/SurfaceWriter.cs index cc5c251b..dd67252a 100644 --- a/src/Ryujinx.Graphics.Nvdec/Image/SurfaceWriter.cs +++ b/src/Ryujinx.Graphics.Nvdec/Image/SurfaceWriter.cs @@ -60,7 +60,7 @@ namespace Ryujinx.Graphics.Nvdec.Image WriteLuma( lumaBottom.Memory.Span, - surface.YPlane.AsSpan().Slice(surface.Stride), + surface.YPlane.AsSpan()[surface.Stride..], surface.Stride * 2, surface.Width, surface.Height / 2); @@ -80,8 +80,8 @@ namespace Ryujinx.Graphics.Nvdec.Image WriteChroma( chromaBottom.Memory.Span, - surface.UPlane.AsSpan().Slice(surface.UvStride), - surface.VPlane.AsSpan().Slice(surface.UvStride), + surface.UPlane.AsSpan()[surface.UvStride..], + surface.VPlane.AsSpan()[surface.UvStride..], surface.UvStride * 2, surface.UvWidth, surface.UvHeight / 2); @@ -100,7 +100,7 @@ namespace Ryujinx.Graphics.Nvdec.Image int width, int height) { - OffsetCalculator calc = new OffsetCalculator(width, height, 0, false, 2, 2); + OffsetCalculator calc = new(width, height, 0, false, 2, 2); if (Sse2.IsSupported) { diff --git a/src/Ryujinx.Graphics.Nvdec/NvdecDecoderContext.cs b/src/Ryujinx.Graphics.Nvdec/NvdecDecoderContext.cs index 54934bc5..aaa734a8 100644 --- a/src/Ryujinx.Graphics.Nvdec/NvdecDecoderContext.cs +++ b/src/Ryujinx.Graphics.Nvdec/NvdecDecoderContext.cs @@ -26,4 +26,4 @@ namespace Ryujinx.Graphics.Nvdec _vp8Decoder = null; } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Nvdec/NvdecDevice.cs b/src/Ryujinx.Graphics.Nvdec/NvdecDevice.cs index ef8185f4..4ab7886d 100644 --- a/src/Ryujinx.Graphics.Nvdec/NvdecDevice.cs +++ b/src/Ryujinx.Graphics.Nvdec/NvdecDevice.cs @@ -14,7 +14,7 @@ namespace Ryujinx.Graphics.Nvdec private readonly DeviceState _state; private long _currentId; - private ConcurrentDictionary _contexts; + private readonly ConcurrentDictionary _contexts; private NvdecDecoderContext _currentContext; public NvdecDevice(MemoryManager gmm) diff --git a/src/Ryujinx.Graphics.Nvdec/NvdecRegisters.cs b/src/Ryujinx.Graphics.Nvdec/NvdecRegisters.cs index cf867783..5effcb49 100644 --- a/src/Ryujinx.Graphics.Nvdec/NvdecRegisters.cs +++ b/src/Ryujinx.Graphics.Nvdec/NvdecRegisters.cs @@ -4,7 +4,7 @@ namespace Ryujinx.Graphics.Nvdec { struct NvdecRegisters { -#pragma warning disable CS0649 +#pragma warning disable CS0649 // Field is never assigned to public Array64 Reserved0; public uint Nop; public Array63 Reserved104; diff --git a/src/Ryujinx.Graphics.Nvdec/NvdecStatus.cs b/src/Ryujinx.Graphics.Nvdec/NvdecStatus.cs index 0712af88..1d6b4a60 100644 --- a/src/Ryujinx.Graphics.Nvdec/NvdecStatus.cs +++ b/src/Ryujinx.Graphics.Nvdec/NvdecStatus.cs @@ -4,7 +4,7 @@ namespace Ryujinx.Graphics.Nvdec { struct NvdecStatus { -#pragma warning disable CS0649 +#pragma warning disable CS0649 // Field is never assigned to public uint MbsCorrectlyDecoded; public uint MbsInError; public uint Reserved; @@ -13,4 +13,4 @@ namespace Ryujinx.Graphics.Nvdec public uint SliceHeaderErrorCode; #pragma warning restore CS0649 } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Nvdec/Types/H264/PictureInfo.cs b/src/Ryujinx.Graphics.Nvdec/Types/H264/PictureInfo.cs index 7c779dff..c0e0a463 100644 --- a/src/Ryujinx.Graphics.Nvdec/Types/H264/PictureInfo.cs +++ b/src/Ryujinx.Graphics.Nvdec/Types/H264/PictureInfo.cs @@ -5,8 +5,9 @@ namespace Ryujinx.Graphics.Nvdec.Types.H264 { struct PictureInfo { -#pragma warning disable CS0169, CS0649 +#pragma warning disable IDE0051, CS0169, CS0649 // Remove unused private member Array18 Unknown0; +#pragma warning restore IDE0051 public uint BitstreamSize; public uint NumSlices; public uint Unknown50; @@ -50,24 +51,24 @@ namespace Ryujinx.Graphics.Nvdec.Types.H264 public Array10 Unknown2D4; #pragma warning restore CS0169, CS0649 - public bool MbAdaptiveFrameFieldFlag => (Flags & (1 << 0)) != 0; - public bool Direct8x8InferenceFlag => (Flags & (1 << 1)) != 0; - public bool WeightedPredFlag => (Flags & (1 << 2)) != 0; - public bool ConstrainedIntraPredFlag => (Flags & (1 << 3)) != 0; - public bool IsReference => (Flags & (1 << 4)) != 0; - public bool FieldPicFlag => (Flags & (1 << 5)) != 0; - public bool BottomFieldFlag => (Flags & (1 << 6)) != 0; - public uint Log2MaxFrameNumMinus4 => (uint)(Flags >> 8) & 0xf; - public ushort ChromaFormatIdc => (ushort)((Flags >> 12) & 3); - public uint PicOrderCntType => (uint)(Flags >> 14) & 3; - public int PicInitQpMinus26 => ExtractSx(Flags, 16, 6); - public int ChromaQpIndexOffset => ExtractSx(Flags, 22, 5); - public int SecondChromaQpIndexOffset => ExtractSx(Flags, 27, 5); - public uint WeightedBipredIdc => (uint)(Flags >> 32) & 3; - public uint OutputSurfaceIndex => (uint)(Flags >> 34) & 0x7f; - public uint ColIndex => (uint)(Flags >> 41) & 0x1f; - public ushort FrameNum => (ushort)(Flags >> 46); - public bool QpprimeYZeroTransformBypassFlag => (Flags2 & (1 << 1)) != 0; + public readonly bool MbAdaptiveFrameFieldFlag => (Flags & (1 << 0)) != 0; + public readonly bool Direct8x8InferenceFlag => (Flags & (1 << 1)) != 0; + public readonly bool WeightedPredFlag => (Flags & (1 << 2)) != 0; + public readonly bool ConstrainedIntraPredFlag => (Flags & (1 << 3)) != 0; + public readonly bool IsReference => (Flags & (1 << 4)) != 0; + public readonly bool FieldPicFlag => (Flags & (1 << 5)) != 0; + public readonly bool BottomFieldFlag => (Flags & (1 << 6)) != 0; + public readonly uint Log2MaxFrameNumMinus4 => (uint)(Flags >> 8) & 0xf; + public readonly ushort ChromaFormatIdc => (ushort)((Flags >> 12) & 3); + public readonly uint PicOrderCntType => (uint)(Flags >> 14) & 3; + public readonly int PicInitQpMinus26 => ExtractSx(Flags, 16, 6); + public readonly int ChromaQpIndexOffset => ExtractSx(Flags, 22, 5); + public readonly int SecondChromaQpIndexOffset => ExtractSx(Flags, 27, 5); + public readonly uint WeightedBipredIdc => (uint)(Flags >> 32) & 3; + public readonly uint OutputSurfaceIndex => (uint)(Flags >> 34) & 0x7f; + public readonly uint ColIndex => (uint)(Flags >> 41) & 0x1f; + public readonly ushort FrameNum => (ushort)(Flags >> 46); + public readonly bool QpprimeYZeroTransformBypassFlag => (Flags2 & (1 << 1)) != 0; private static int ExtractSx(ulong packed, int lsb, int length) { diff --git a/src/Ryujinx.Graphics.Nvdec/Types/H264/ReferenceFrame.cs b/src/Ryujinx.Graphics.Nvdec/Types/H264/ReferenceFrame.cs index d205a47a..9ab9d132 100644 --- a/src/Ryujinx.Graphics.Nvdec/Types/H264/ReferenceFrame.cs +++ b/src/Ryujinx.Graphics.Nvdec/Types/H264/ReferenceFrame.cs @@ -4,12 +4,12 @@ namespace Ryujinx.Graphics.Nvdec.Types.H264 { struct ReferenceFrame { -#pragma warning disable CS0649 +#pragma warning disable CS0649 // Field is never assigned to public uint Flags; public Array2 FieldOrderCnt; public uint FrameNum; #pragma warning restore CS0649 - public uint OutputSurfaceIndex => (uint)Flags & 0x7f; + public readonly uint OutputSurfaceIndex => (uint)Flags & 0x7f; } } diff --git a/src/Ryujinx.Graphics.Nvdec/Types/Vp8/PictureInfo.cs b/src/Ryujinx.Graphics.Nvdec/Types/Vp8/PictureInfo.cs index 844f2103..76e07a3f 100644 --- a/src/Ryujinx.Graphics.Nvdec/Types/Vp8/PictureInfo.cs +++ b/src/Ryujinx.Graphics.Nvdec/Types/Vp8/PictureInfo.cs @@ -5,7 +5,7 @@ namespace Ryujinx.Graphics.Nvdec.Types.Vp8 { struct PictureInfo { -#pragma warning disable CS0649 +#pragma warning disable CS0649 // Field is never assigned to public Array13 Unknown0; public uint GpTimerTimeoutValue; public ushort FrameWidth; diff --git a/src/Ryujinx.Graphics.Nvdec/Types/Vp9/EntropyProbs.cs b/src/Ryujinx.Graphics.Nvdec/Types/Vp9/EntropyProbs.cs index b2858d2d..dd5221b1 100644 --- a/src/Ryujinx.Graphics.Nvdec/Types/Vp9/EntropyProbs.cs +++ b/src/Ryujinx.Graphics.Nvdec/Types/Vp9/EntropyProbs.cs @@ -5,7 +5,7 @@ namespace Ryujinx.Graphics.Nvdec.Types.Vp9 { struct EntropyProbs { -#pragma warning disable CS0649 +#pragma warning disable CS0649 // Field is never assigned to public Array10>> KfYModeProbE0ToE7; public Array10> KfYModeProbE8; public Array3 Padding384; diff --git a/src/Ryujinx.Graphics.Nvdec/Types/Vp9/FrameSize.cs b/src/Ryujinx.Graphics.Nvdec/Types/Vp9/FrameSize.cs index d449ec4d..31c08a52 100644 --- a/src/Ryujinx.Graphics.Nvdec/Types/Vp9/FrameSize.cs +++ b/src/Ryujinx.Graphics.Nvdec/Types/Vp9/FrameSize.cs @@ -2,7 +2,7 @@ { struct FrameSize { -#pragma warning disable CS0649 +#pragma warning disable CS0649 // Field is never assigned to public ushort Width; public ushort Height; public ushort LumaPitch; diff --git a/src/Ryujinx.Graphics.Nvdec/Types/Vp9/FrameStats.cs b/src/Ryujinx.Graphics.Nvdec/Types/Vp9/FrameStats.cs index 26aab506..9b0325cf 100644 --- a/src/Ryujinx.Graphics.Nvdec/Types/Vp9/FrameStats.cs +++ b/src/Ryujinx.Graphics.Nvdec/Types/Vp9/FrameStats.cs @@ -2,7 +2,7 @@ { struct FrameStats { -#pragma warning disable CS0649 +#pragma warning disable CS0649 // Field is never assigned to public uint Unknown0; public uint Unknown4; public uint Pass2CycleCount; diff --git a/src/Ryujinx.Graphics.Nvdec/Types/Vp9/LoopFilter.cs b/src/Ryujinx.Graphics.Nvdec/Types/Vp9/LoopFilter.cs index 7cb0fd7a..ebef7f67 100644 --- a/src/Ryujinx.Graphics.Nvdec/Types/Vp9/LoopFilter.cs +++ b/src/Ryujinx.Graphics.Nvdec/Types/Vp9/LoopFilter.cs @@ -4,7 +4,7 @@ namespace Ryujinx.Graphics.Nvdec.Types.Vp9 { struct LoopFilter { -#pragma warning disable CS0649 +#pragma warning disable CS0649 // Field is never assigned to public byte ModeRefDeltaEnabled; public Array4 RefDeltas; public Array2 ModeDeltas; diff --git a/src/Ryujinx.Graphics.Nvdec/Types/Vp9/PictureInfo.cs b/src/Ryujinx.Graphics.Nvdec/Types/Vp9/PictureInfo.cs index 7d06f747..50569dbf 100644 --- a/src/Ryujinx.Graphics.Nvdec/Types/Vp9/PictureInfo.cs +++ b/src/Ryujinx.Graphics.Nvdec/Types/Vp9/PictureInfo.cs @@ -5,7 +5,7 @@ namespace Ryujinx.Graphics.Nvdec.Types.Vp9 { struct PictureInfo { -#pragma warning disable CS0649 +#pragma warning disable CS0649 // Field is never assigned to public Array12 Unknown0; public uint BitstreamSize; public uint IsEncrypted; @@ -44,7 +44,7 @@ namespace Ryujinx.Graphics.Nvdec.Types.Vp9 public uint UnknownFC; #pragma warning restore CS0649 - public uint BitDepth => (SurfaceParams >> 1) & 0xf; + public readonly uint BitDepth => (SurfaceParams >> 1) & 0xf; public Vp9PictureInfo Convert() { diff --git a/src/Ryujinx.Graphics.Nvdec/Types/Vp9/Segmentation.cs b/src/Ryujinx.Graphics.Nvdec/Types/Vp9/Segmentation.cs index f6c4f0b1..ab9954c6 100644 --- a/src/Ryujinx.Graphics.Nvdec/Types/Vp9/Segmentation.cs +++ b/src/Ryujinx.Graphics.Nvdec/Types/Vp9/Segmentation.cs @@ -4,7 +4,7 @@ namespace Ryujinx.Graphics.Nvdec.Types.Vp9 { struct Segmentation { -#pragma warning disable CS0649 +#pragma warning disable CS0649 // Field is never assigned to public byte Enabled; public byte UpdateMap; public byte TemporalUpdate; diff --git a/src/Ryujinx.Graphics.Nvdec/Vp8Decoder.cs b/src/Ryujinx.Graphics.Nvdec/Vp8Decoder.cs index cce9a574..e56b23d7 100644 --- a/src/Ryujinx.Graphics.Nvdec/Vp8Decoder.cs +++ b/src/Ryujinx.Graphics.Nvdec/Vp8Decoder.cs @@ -30,4 +30,4 @@ namespace Ryujinx.Graphics.Nvdec rm.Cache.Put(outputSurface); } } -} \ No newline at end of file +} diff --git a/src/Ryujinx.Graphics.Nvdec/Vp9Decoder.cs b/src/Ryujinx.Graphics.Nvdec/Vp9Decoder.cs index 9bb3529e..f78bb702 100644 --- a/src/Ryujinx.Graphics.Nvdec/Vp9Decoder.cs +++ b/src/Ryujinx.Graphics.Nvdec/Vp9Decoder.cs @@ -13,7 +13,7 @@ namespace Ryujinx.Graphics.Nvdec { static class Vp9Decoder { - private static Decoder _decoder = new Decoder(); + private static readonly Decoder _decoder = new(); public unsafe static void Decode(ResourceManager rm, ref NvdecRegisters state) { @@ -25,9 +25,9 @@ namespace Ryujinx.Graphics.Nvdec return rm.Cache.Get(_decoder, lumaOffset, chromaOffset, size.Width, size.Height); } - ISurface lastSurface = Rent(state.SetPictureLumaOffset[0], state.SetPictureChromaOffset[0], pictureInfo.LastFrameSize); - ISurface goldenSurface = Rent(state.SetPictureLumaOffset[1], state.SetPictureChromaOffset[1], pictureInfo.GoldenFrameSize); - ISurface altSurface = Rent(state.SetPictureLumaOffset[2], state.SetPictureChromaOffset[2], pictureInfo.AltFrameSize); + ISurface lastSurface = Rent(state.SetPictureLumaOffset[0], state.SetPictureChromaOffset[0], pictureInfo.LastFrameSize); + ISurface goldenSurface = Rent(state.SetPictureLumaOffset[1], state.SetPictureChromaOffset[1], pictureInfo.GoldenFrameSize); + ISurface altSurface = Rent(state.SetPictureLumaOffset[2], state.SetPictureChromaOffset[2], pictureInfo.AltFrameSize); ISurface currentSurface = Rent(state.SetPictureLumaOffset[3], state.SetPictureChromaOffset[3], pictureInfo.CurrentFrameSize); Vp9PictureInfo info = pictureInfo.Convert(); @@ -54,7 +54,7 @@ namespace Ryujinx.Graphics.Nvdec Span mvsOut = MemoryMarshal.Cast(mvsRegion.Memory.Span); - uint lumaOffset = state.SetPictureLumaOffset[3]; + uint lumaOffset = state.SetPictureLumaOffset[3]; uint chromaOffset = state.SetPictureChromaOffset[3]; if (_decoder.Decode(ref info, currentSurface, bitstream, mvsIn, mvsOut))