forked from Mirror/Ryujinx
[Ryujinx.Graphics.Nvdec] Address dotnet-format issues (#5369)
* dotnet format style --severity info Some changes were manually reverted. * Restore a few unused methods and variables * 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 * Add previously silenced warnings back I have no clue how these disappeared * Add comments to disabled warnings * Simplify properties and array initialization, Use const when possible, Remove trailing commas * Address IDE0251 warnings * Revert "Simplify properties and array initialization, Use const when possible, Remove trailing commas" This reverts commit 9462e4136c0a2100dc28b20cf9542e06790aa67e. * dotnet format whitespace after rebase * First dotnet format pass
This commit is contained in:
parent
fd01259d2b
commit
07fc3ded68
18 changed files with 51 additions and 50 deletions
|
@ -17,12 +17,12 @@ namespace Ryujinx.Graphics.Nvdec
|
||||||
|
|
||||||
ReadOnlySpan<byte> bitstream = rm.Gmm.DeviceGetSpan(state.SetInBufBaseOffset, (int)pictureInfo.BitstreamSize);
|
ReadOnlySpan<byte> 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 height = (int)pictureInfo.PicHeightInMbs * MbSizeInPixels;
|
||||||
|
|
||||||
int surfaceIndex = (int)pictureInfo.OutputSurfaceIndex;
|
int surfaceIndex = (int)pictureInfo.OutputSurfaceIndex;
|
||||||
|
|
||||||
uint lumaOffset = state.SetPictureLumaOffset[surfaceIndex];
|
uint lumaOffset = state.SetPictureLumaOffset[surfaceIndex];
|
||||||
uint chromaOffset = state.SetPictureChromaOffset[surfaceIndex];
|
uint chromaOffset = state.SetPictureChromaOffset[surfaceIndex];
|
||||||
|
|
||||||
Decoder decoder = context.GetH264Decoder();
|
Decoder decoder = context.GetH264Decoder();
|
||||||
|
@ -36,7 +36,7 @@ namespace Ryujinx.Graphics.Nvdec
|
||||||
SurfaceWriter.Write(
|
SurfaceWriter.Write(
|
||||||
rm.Gmm,
|
rm.Gmm,
|
||||||
outputSurface,
|
outputSurface,
|
||||||
lumaOffset + pictureInfo.LumaFrameOffset,
|
lumaOffset + pictureInfo.LumaFrameOffset,
|
||||||
chromaOffset + pictureInfo.ChromaFrameOffset);
|
chromaOffset + pictureInfo.ChromaFrameOffset);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -44,9 +44,9 @@ namespace Ryujinx.Graphics.Nvdec
|
||||||
SurfaceWriter.WriteInterlaced(
|
SurfaceWriter.WriteInterlaced(
|
||||||
rm.Gmm,
|
rm.Gmm,
|
||||||
outputSurface,
|
outputSurface,
|
||||||
lumaOffset + pictureInfo.LumaTopFieldOffset,
|
lumaOffset + pictureInfo.LumaTopFieldOffset,
|
||||||
chromaOffset + pictureInfo.ChromaTopFieldOffset,
|
chromaOffset + pictureInfo.ChromaTopFieldOffset,
|
||||||
lumaOffset + pictureInfo.LumaBottomFieldOffset,
|
lumaOffset + pictureInfo.LumaBottomFieldOffset,
|
||||||
chromaOffset + pictureInfo.ChromaBottomFieldOffset);
|
chromaOffset + pictureInfo.ChromaBottomFieldOffset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ namespace Ryujinx.Graphics.Nvdec.Image
|
||||||
int width,
|
int width,
|
||||||
int height)
|
int height)
|
||||||
{
|
{
|
||||||
OffsetCalculator calc = new OffsetCalculator(width, height, 0, false, 2, 2);
|
OffsetCalculator calc = new(width, height, 0, false, 2, 2);
|
||||||
|
|
||||||
if (Sse2.IsSupported)
|
if (Sse2.IsSupported)
|
||||||
{
|
{
|
||||||
|
|
|
@ -60,7 +60,7 @@ namespace Ryujinx.Graphics.Nvdec.Image
|
||||||
|
|
||||||
WriteLuma(
|
WriteLuma(
|
||||||
lumaBottom.Memory.Span,
|
lumaBottom.Memory.Span,
|
||||||
surface.YPlane.AsSpan().Slice(surface.Stride),
|
surface.YPlane.AsSpan()[surface.Stride..],
|
||||||
surface.Stride * 2,
|
surface.Stride * 2,
|
||||||
surface.Width,
|
surface.Width,
|
||||||
surface.Height / 2);
|
surface.Height / 2);
|
||||||
|
@ -80,8 +80,8 @@ namespace Ryujinx.Graphics.Nvdec.Image
|
||||||
|
|
||||||
WriteChroma(
|
WriteChroma(
|
||||||
chromaBottom.Memory.Span,
|
chromaBottom.Memory.Span,
|
||||||
surface.UPlane.AsSpan().Slice(surface.UvStride),
|
surface.UPlane.AsSpan()[surface.UvStride..],
|
||||||
surface.VPlane.AsSpan().Slice(surface.UvStride),
|
surface.VPlane.AsSpan()[surface.UvStride..],
|
||||||
surface.UvStride * 2,
|
surface.UvStride * 2,
|
||||||
surface.UvWidth,
|
surface.UvWidth,
|
||||||
surface.UvHeight / 2);
|
surface.UvHeight / 2);
|
||||||
|
@ -100,7 +100,7 @@ namespace Ryujinx.Graphics.Nvdec.Image
|
||||||
int width,
|
int width,
|
||||||
int height)
|
int height)
|
||||||
{
|
{
|
||||||
OffsetCalculator calc = new OffsetCalculator(width, height, 0, false, 2, 2);
|
OffsetCalculator calc = new(width, height, 0, false, 2, 2);
|
||||||
|
|
||||||
if (Sse2.IsSupported)
|
if (Sse2.IsSupported)
|
||||||
{
|
{
|
||||||
|
|
|
@ -26,4 +26,4 @@ namespace Ryujinx.Graphics.Nvdec
|
||||||
_vp8Decoder = null;
|
_vp8Decoder = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace Ryujinx.Graphics.Nvdec
|
||||||
private readonly DeviceState<NvdecRegisters> _state;
|
private readonly DeviceState<NvdecRegisters> _state;
|
||||||
|
|
||||||
private long _currentId;
|
private long _currentId;
|
||||||
private ConcurrentDictionary<long, NvdecDecoderContext> _contexts;
|
private readonly ConcurrentDictionary<long, NvdecDecoderContext> _contexts;
|
||||||
private NvdecDecoderContext _currentContext;
|
private NvdecDecoderContext _currentContext;
|
||||||
|
|
||||||
public NvdecDevice(MemoryManager gmm)
|
public NvdecDevice(MemoryManager gmm)
|
||||||
|
|
|
@ -4,7 +4,7 @@ namespace Ryujinx.Graphics.Nvdec
|
||||||
{
|
{
|
||||||
struct NvdecRegisters
|
struct NvdecRegisters
|
||||||
{
|
{
|
||||||
#pragma warning disable CS0649
|
#pragma warning disable CS0649 // Field is never assigned to
|
||||||
public Array64<uint> Reserved0;
|
public Array64<uint> Reserved0;
|
||||||
public uint Nop;
|
public uint Nop;
|
||||||
public Array63<uint> Reserved104;
|
public Array63<uint> Reserved104;
|
||||||
|
|
|
@ -4,7 +4,7 @@ namespace Ryujinx.Graphics.Nvdec
|
||||||
{
|
{
|
||||||
struct NvdecStatus
|
struct NvdecStatus
|
||||||
{
|
{
|
||||||
#pragma warning disable CS0649
|
#pragma warning disable CS0649 // Field is never assigned to
|
||||||
public uint MbsCorrectlyDecoded;
|
public uint MbsCorrectlyDecoded;
|
||||||
public uint MbsInError;
|
public uint MbsInError;
|
||||||
public uint Reserved;
|
public uint Reserved;
|
||||||
|
@ -13,4 +13,4 @@ namespace Ryujinx.Graphics.Nvdec
|
||||||
public uint SliceHeaderErrorCode;
|
public uint SliceHeaderErrorCode;
|
||||||
#pragma warning restore CS0649
|
#pragma warning restore CS0649
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,9 @@ namespace Ryujinx.Graphics.Nvdec.Types.H264
|
||||||
{
|
{
|
||||||
struct PictureInfo
|
struct PictureInfo
|
||||||
{
|
{
|
||||||
#pragma warning disable CS0169, CS0649
|
#pragma warning disable IDE0051, CS0169, CS0649 // Remove unused private member
|
||||||
Array18<uint> Unknown0;
|
Array18<uint> Unknown0;
|
||||||
|
#pragma warning restore IDE0051
|
||||||
public uint BitstreamSize;
|
public uint BitstreamSize;
|
||||||
public uint NumSlices;
|
public uint NumSlices;
|
||||||
public uint Unknown50;
|
public uint Unknown50;
|
||||||
|
@ -50,24 +51,24 @@ namespace Ryujinx.Graphics.Nvdec.Types.H264
|
||||||
public Array10<uint> Unknown2D4;
|
public Array10<uint> Unknown2D4;
|
||||||
#pragma warning restore CS0169, CS0649
|
#pragma warning restore CS0169, CS0649
|
||||||
|
|
||||||
public bool MbAdaptiveFrameFieldFlag => (Flags & (1 << 0)) != 0;
|
public readonly bool MbAdaptiveFrameFieldFlag => (Flags & (1 << 0)) != 0;
|
||||||
public bool Direct8x8InferenceFlag => (Flags & (1 << 1)) != 0;
|
public readonly bool Direct8x8InferenceFlag => (Flags & (1 << 1)) != 0;
|
||||||
public bool WeightedPredFlag => (Flags & (1 << 2)) != 0;
|
public readonly bool WeightedPredFlag => (Flags & (1 << 2)) != 0;
|
||||||
public bool ConstrainedIntraPredFlag => (Flags & (1 << 3)) != 0;
|
public readonly bool ConstrainedIntraPredFlag => (Flags & (1 << 3)) != 0;
|
||||||
public bool IsReference => (Flags & (1 << 4)) != 0;
|
public readonly bool IsReference => (Flags & (1 << 4)) != 0;
|
||||||
public bool FieldPicFlag => (Flags & (1 << 5)) != 0;
|
public readonly bool FieldPicFlag => (Flags & (1 << 5)) != 0;
|
||||||
public bool BottomFieldFlag => (Flags & (1 << 6)) != 0;
|
public readonly bool BottomFieldFlag => (Flags & (1 << 6)) != 0;
|
||||||
public uint Log2MaxFrameNumMinus4 => (uint)(Flags >> 8) & 0xf;
|
public readonly uint Log2MaxFrameNumMinus4 => (uint)(Flags >> 8) & 0xf;
|
||||||
public ushort ChromaFormatIdc => (ushort)((Flags >> 12) & 3);
|
public readonly ushort ChromaFormatIdc => (ushort)((Flags >> 12) & 3);
|
||||||
public uint PicOrderCntType => (uint)(Flags >> 14) & 3;
|
public readonly uint PicOrderCntType => (uint)(Flags >> 14) & 3;
|
||||||
public int PicInitQpMinus26 => ExtractSx(Flags, 16, 6);
|
public readonly int PicInitQpMinus26 => ExtractSx(Flags, 16, 6);
|
||||||
public int ChromaQpIndexOffset => ExtractSx(Flags, 22, 5);
|
public readonly int ChromaQpIndexOffset => ExtractSx(Flags, 22, 5);
|
||||||
public int SecondChromaQpIndexOffset => ExtractSx(Flags, 27, 5);
|
public readonly int SecondChromaQpIndexOffset => ExtractSx(Flags, 27, 5);
|
||||||
public uint WeightedBipredIdc => (uint)(Flags >> 32) & 3;
|
public readonly uint WeightedBipredIdc => (uint)(Flags >> 32) & 3;
|
||||||
public uint OutputSurfaceIndex => (uint)(Flags >> 34) & 0x7f;
|
public readonly uint OutputSurfaceIndex => (uint)(Flags >> 34) & 0x7f;
|
||||||
public uint ColIndex => (uint)(Flags >> 41) & 0x1f;
|
public readonly uint ColIndex => (uint)(Flags >> 41) & 0x1f;
|
||||||
public ushort FrameNum => (ushort)(Flags >> 46);
|
public readonly ushort FrameNum => (ushort)(Flags >> 46);
|
||||||
public bool QpprimeYZeroTransformBypassFlag => (Flags2 & (1 << 1)) != 0;
|
public readonly bool QpprimeYZeroTransformBypassFlag => (Flags2 & (1 << 1)) != 0;
|
||||||
|
|
||||||
private static int ExtractSx(ulong packed, int lsb, int length)
|
private static int ExtractSx(ulong packed, int lsb, int length)
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,12 +4,12 @@ namespace Ryujinx.Graphics.Nvdec.Types.H264
|
||||||
{
|
{
|
||||||
struct ReferenceFrame
|
struct ReferenceFrame
|
||||||
{
|
{
|
||||||
#pragma warning disable CS0649
|
#pragma warning disable CS0649 // Field is never assigned to
|
||||||
public uint Flags;
|
public uint Flags;
|
||||||
public Array2<uint> FieldOrderCnt;
|
public Array2<uint> FieldOrderCnt;
|
||||||
public uint FrameNum;
|
public uint FrameNum;
|
||||||
#pragma warning restore CS0649
|
#pragma warning restore CS0649
|
||||||
|
|
||||||
public uint OutputSurfaceIndex => (uint)Flags & 0x7f;
|
public readonly uint OutputSurfaceIndex => (uint)Flags & 0x7f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ namespace Ryujinx.Graphics.Nvdec.Types.Vp8
|
||||||
{
|
{
|
||||||
struct PictureInfo
|
struct PictureInfo
|
||||||
{
|
{
|
||||||
#pragma warning disable CS0649
|
#pragma warning disable CS0649 // Field is never assigned to
|
||||||
public Array13<uint> Unknown0;
|
public Array13<uint> Unknown0;
|
||||||
public uint GpTimerTimeoutValue;
|
public uint GpTimerTimeoutValue;
|
||||||
public ushort FrameWidth;
|
public ushort FrameWidth;
|
||||||
|
|
|
@ -5,7 +5,7 @@ namespace Ryujinx.Graphics.Nvdec.Types.Vp9
|
||||||
{
|
{
|
||||||
struct EntropyProbs
|
struct EntropyProbs
|
||||||
{
|
{
|
||||||
#pragma warning disable CS0649
|
#pragma warning disable CS0649 // Field is never assigned to
|
||||||
public Array10<Array10<Array8<byte>>> KfYModeProbE0ToE7;
|
public Array10<Array10<Array8<byte>>> KfYModeProbE0ToE7;
|
||||||
public Array10<Array10<byte>> KfYModeProbE8;
|
public Array10<Array10<byte>> KfYModeProbE8;
|
||||||
public Array3<byte> Padding384;
|
public Array3<byte> Padding384;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
{
|
{
|
||||||
struct FrameSize
|
struct FrameSize
|
||||||
{
|
{
|
||||||
#pragma warning disable CS0649
|
#pragma warning disable CS0649 // Field is never assigned to
|
||||||
public ushort Width;
|
public ushort Width;
|
||||||
public ushort Height;
|
public ushort Height;
|
||||||
public ushort LumaPitch;
|
public ushort LumaPitch;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
{
|
{
|
||||||
struct FrameStats
|
struct FrameStats
|
||||||
{
|
{
|
||||||
#pragma warning disable CS0649
|
#pragma warning disable CS0649 // Field is never assigned to
|
||||||
public uint Unknown0;
|
public uint Unknown0;
|
||||||
public uint Unknown4;
|
public uint Unknown4;
|
||||||
public uint Pass2CycleCount;
|
public uint Pass2CycleCount;
|
||||||
|
|
|
@ -4,7 +4,7 @@ namespace Ryujinx.Graphics.Nvdec.Types.Vp9
|
||||||
{
|
{
|
||||||
struct LoopFilter
|
struct LoopFilter
|
||||||
{
|
{
|
||||||
#pragma warning disable CS0649
|
#pragma warning disable CS0649 // Field is never assigned to
|
||||||
public byte ModeRefDeltaEnabled;
|
public byte ModeRefDeltaEnabled;
|
||||||
public Array4<sbyte> RefDeltas;
|
public Array4<sbyte> RefDeltas;
|
||||||
public Array2<sbyte> ModeDeltas;
|
public Array2<sbyte> ModeDeltas;
|
||||||
|
|
|
@ -5,7 +5,7 @@ namespace Ryujinx.Graphics.Nvdec.Types.Vp9
|
||||||
{
|
{
|
||||||
struct PictureInfo
|
struct PictureInfo
|
||||||
{
|
{
|
||||||
#pragma warning disable CS0649
|
#pragma warning disable CS0649 // Field is never assigned to
|
||||||
public Array12<uint> Unknown0;
|
public Array12<uint> Unknown0;
|
||||||
public uint BitstreamSize;
|
public uint BitstreamSize;
|
||||||
public uint IsEncrypted;
|
public uint IsEncrypted;
|
||||||
|
@ -44,7 +44,7 @@ namespace Ryujinx.Graphics.Nvdec.Types.Vp9
|
||||||
public uint UnknownFC;
|
public uint UnknownFC;
|
||||||
#pragma warning restore CS0649
|
#pragma warning restore CS0649
|
||||||
|
|
||||||
public uint BitDepth => (SurfaceParams >> 1) & 0xf;
|
public readonly uint BitDepth => (SurfaceParams >> 1) & 0xf;
|
||||||
|
|
||||||
public Vp9PictureInfo Convert()
|
public Vp9PictureInfo Convert()
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,7 +4,7 @@ namespace Ryujinx.Graphics.Nvdec.Types.Vp9
|
||||||
{
|
{
|
||||||
struct Segmentation
|
struct Segmentation
|
||||||
{
|
{
|
||||||
#pragma warning disable CS0649
|
#pragma warning disable CS0649 // Field is never assigned to
|
||||||
public byte Enabled;
|
public byte Enabled;
|
||||||
public byte UpdateMap;
|
public byte UpdateMap;
|
||||||
public byte TemporalUpdate;
|
public byte TemporalUpdate;
|
||||||
|
|
|
@ -30,4 +30,4 @@ namespace Ryujinx.Graphics.Nvdec
|
||||||
rm.Cache.Put(outputSurface);
|
rm.Cache.Put(outputSurface);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace Ryujinx.Graphics.Nvdec
|
||||||
{
|
{
|
||||||
static class Vp9Decoder
|
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)
|
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);
|
return rm.Cache.Get(_decoder, lumaOffset, chromaOffset, size.Width, size.Height);
|
||||||
}
|
}
|
||||||
|
|
||||||
ISurface lastSurface = Rent(state.SetPictureLumaOffset[0], state.SetPictureChromaOffset[0], pictureInfo.LastFrameSize);
|
ISurface lastSurface = Rent(state.SetPictureLumaOffset[0], state.SetPictureChromaOffset[0], pictureInfo.LastFrameSize);
|
||||||
ISurface goldenSurface = Rent(state.SetPictureLumaOffset[1], state.SetPictureChromaOffset[1], pictureInfo.GoldenFrameSize);
|
ISurface goldenSurface = Rent(state.SetPictureLumaOffset[1], state.SetPictureChromaOffset[1], pictureInfo.GoldenFrameSize);
|
||||||
ISurface altSurface = Rent(state.SetPictureLumaOffset[2], state.SetPictureChromaOffset[2], pictureInfo.AltFrameSize);
|
ISurface altSurface = Rent(state.SetPictureLumaOffset[2], state.SetPictureChromaOffset[2], pictureInfo.AltFrameSize);
|
||||||
ISurface currentSurface = Rent(state.SetPictureLumaOffset[3], state.SetPictureChromaOffset[3], pictureInfo.CurrentFrameSize);
|
ISurface currentSurface = Rent(state.SetPictureLumaOffset[3], state.SetPictureChromaOffset[3], pictureInfo.CurrentFrameSize);
|
||||||
|
|
||||||
Vp9PictureInfo info = pictureInfo.Convert();
|
Vp9PictureInfo info = pictureInfo.Convert();
|
||||||
|
@ -54,7 +54,7 @@ namespace Ryujinx.Graphics.Nvdec
|
||||||
|
|
||||||
Span<Vp9MvRef> mvsOut = MemoryMarshal.Cast<byte, Vp9MvRef>(mvsRegion.Memory.Span);
|
Span<Vp9MvRef> mvsOut = MemoryMarshal.Cast<byte, Vp9MvRef>(mvsRegion.Memory.Span);
|
||||||
|
|
||||||
uint lumaOffset = state.SetPictureLumaOffset[3];
|
uint lumaOffset = state.SetPictureLumaOffset[3];
|
||||||
uint chromaOffset = state.SetPictureChromaOffset[3];
|
uint chromaOffset = state.SetPictureChromaOffset[3];
|
||||||
|
|
||||||
if (_decoder.Decode(ref info, currentSurface, bitstream, mvsIn, mvsOut))
|
if (_decoder.Decode(ref info, currentSurface, bitstream, mvsIn, mvsOut))
|
||||||
|
|
Loading…
Reference in a new issue