Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
42d31f646d | ||
|
07fc3ded68 | ||
|
fd01259d2b | ||
|
7ffe7f8442 |
@@ -19,12 +19,14 @@ namespace Ryujinx.Audio.Backends.SDL2
|
||||
private readonly ManualResetEvent _pauseEvent;
|
||||
private readonly ConcurrentDictionary<SDL2HardwareDeviceSession, byte> _sessions;
|
||||
|
||||
private bool _supportSurroundConfiguration;
|
||||
private readonly bool _supportSurroundConfiguration;
|
||||
|
||||
// TODO: Add this to SDL2-CS
|
||||
// NOTE: We use a DllImport here because of marshaling issue for spec.
|
||||
#pragma warning disable SYSLIB1054
|
||||
[DllImport("SDL2")]
|
||||
private static extern int SDL_GetDefaultAudioInfo(IntPtr name, out SDL_AudioSpec spec, int isCapture);
|
||||
#pragma warning restore SYSLIB1054
|
||||
|
||||
public SDL2HardwareDeviceDriver()
|
||||
{
|
||||
@@ -90,7 +92,7 @@ namespace Ryujinx.Audio.Backends.SDL2
|
||||
throw new NotImplementedException("Input direction is currently not implemented on SDL2 backend!");
|
||||
}
|
||||
|
||||
SDL2HardwareDeviceSession session = new SDL2HardwareDeviceSession(this, memoryManager, sampleFormat, sampleRate, channelCount, volume);
|
||||
SDL2HardwareDeviceSession session = new(this, memoryManager, sampleFormat, sampleRate, channelCount, volume);
|
||||
|
||||
_sessions.TryAdd(session, 0);
|
||||
|
||||
@@ -135,8 +137,7 @@ namespace Ryujinx.Audio.Backends.SDL2
|
||||
|
||||
if (device == 0)
|
||||
{
|
||||
Logger.Error?.Print(LogClass.Application,
|
||||
$"SDL2 open audio device initialization failed with error \"{SDL_GetError()}\"");
|
||||
Logger.Error?.Print(LogClass.Application, $"SDL2 open audio device initialization failed with error \"{SDL_GetError()}\"");
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -156,6 +157,7 @@ namespace Ryujinx.Audio.Backends.SDL2
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
GC.SuppressFinalize(this);
|
||||
Dispose(true);
|
||||
}
|
||||
|
||||
|
@@ -12,19 +12,19 @@ namespace Ryujinx.Audio.Backends.SDL2
|
||||
{
|
||||
class SDL2HardwareDeviceSession : HardwareDeviceSessionOutputBase
|
||||
{
|
||||
private SDL2HardwareDeviceDriver _driver;
|
||||
private ConcurrentQueue<SDL2AudioBuffer> _queuedBuffers;
|
||||
private DynamicRingBuffer _ringBuffer;
|
||||
private readonly SDL2HardwareDeviceDriver _driver;
|
||||
private readonly ConcurrentQueue<SDL2AudioBuffer> _queuedBuffers;
|
||||
private readonly DynamicRingBuffer _ringBuffer;
|
||||
private ulong _playedSampleCount;
|
||||
private ManualResetEvent _updateRequiredEvent;
|
||||
private readonly ManualResetEvent _updateRequiredEvent;
|
||||
private uint _outputStream;
|
||||
private bool _hasSetupError;
|
||||
private SDL_AudioCallback _callbackDelegate;
|
||||
private int _bytesPerFrame;
|
||||
private readonly SDL_AudioCallback _callbackDelegate;
|
||||
private readonly int _bytesPerFrame;
|
||||
private uint _sampleCount;
|
||||
private bool _started;
|
||||
private float _volume;
|
||||
private ushort _nativeSampleFormat;
|
||||
private readonly ushort _nativeSampleFormat;
|
||||
|
||||
public SDL2HardwareDeviceSession(SDL2HardwareDeviceDriver driver, IVirtualMemoryManager memoryManager, SampleFormat requestedSampleFormat, uint requestedSampleRate, uint requestedChannelCount, float requestedVolume) : base(memoryManager, requestedSampleFormat, requestedSampleRate, requestedChannelCount)
|
||||
{
|
||||
@@ -72,7 +72,7 @@ namespace Ryujinx.Audio.Backends.SDL2
|
||||
|
||||
private unsafe void Update(IntPtr userdata, IntPtr stream, int streamLength)
|
||||
{
|
||||
Span<byte> streamSpan = new Span<byte>((void*)stream, streamLength);
|
||||
Span<byte> streamSpan = new((void*)stream, streamLength);
|
||||
|
||||
int maxFrameCount = (int)GetSampleCount(streamLength);
|
||||
int bufferedFrames = _ringBuffer.Length / _bytesPerFrame;
|
||||
@@ -82,7 +82,7 @@ namespace Ryujinx.Audio.Backends.SDL2
|
||||
if (frameCount == 0)
|
||||
{
|
||||
// SDL2 left the responsibility to the user to clear the buffer.
|
||||
streamSpan.Fill(0);
|
||||
streamSpan.Clear();
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -96,7 +96,7 @@ namespace Ryujinx.Audio.Backends.SDL2
|
||||
IntPtr pStreamSrc = (IntPtr)p;
|
||||
|
||||
// Zero the dest buffer
|
||||
streamSpan.Fill(0);
|
||||
streamSpan.Clear();
|
||||
|
||||
// Apply volume to written data
|
||||
SDL_MixAudioFormat(stream, pStreamSrc, _nativeSampleFormat, (uint)samples.Length, (int)(_volume * SDL_MIX_MAXVOLUME));
|
||||
@@ -151,7 +151,7 @@ namespace Ryujinx.Audio.Backends.SDL2
|
||||
|
||||
if (_outputStream != 0)
|
||||
{
|
||||
SDL2AudioBuffer driverBuffer = new SDL2AudioBuffer(buffer.DataPointer, GetSampleCount(buffer));
|
||||
SDL2AudioBuffer driverBuffer = new(buffer.DataPointer, GetSampleCount(buffer));
|
||||
|
||||
_ringBuffer.Write(buffer.Data, 0, buffer.Data.Length);
|
||||
|
||||
|
@@ -12,8 +12,8 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg
|
||||
private readonly AVCodec_decode _decodeFrame;
|
||||
private static readonly FFmpegApi.av_log_set_callback_callback _logFunc;
|
||||
private readonly AVCodec* _codec;
|
||||
private AVPacket* _packet;
|
||||
private AVCodecContext* _context;
|
||||
private readonly AVPacket* _packet;
|
||||
private readonly AVCodecContext* _context;
|
||||
|
||||
public FFmpegContext(AVCodecID codecId)
|
||||
{
|
||||
@@ -164,7 +164,7 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg
|
||||
FFmpegApi.av_packet_free(ppPacket);
|
||||
}
|
||||
|
||||
FFmpegApi.avcodec_close(_context);
|
||||
_ = FFmpegApi.avcodec_close(_context);
|
||||
|
||||
fixed (AVCodecContext** ppContext = &_context)
|
||||
{
|
||||
|
@@ -12,7 +12,7 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg.H264
|
||||
|
||||
private readonly byte[] _workBuffer = new byte[WorkBufferSize];
|
||||
|
||||
private FFmpegContext _context = new FFmpegContext(AVCodecID.AV_CODEC_ID_H264);
|
||||
private FFmpegContext _context = new(AVCodecID.AV_CODEC_ID_H264);
|
||||
|
||||
private int _oldOutputWidth;
|
||||
private int _oldOutputHeight;
|
||||
@@ -46,7 +46,7 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg.H264
|
||||
byte[] output = new byte[data.Length + prep.Length];
|
||||
|
||||
prep.CopyTo(output);
|
||||
data.CopyTo(new Span<byte>(output).Slice(prep.Length));
|
||||
data.CopyTo(new Span<byte>(output)[prep.Length..]);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
@@ -84,9 +84,9 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg.H264
|
||||
Flush();
|
||||
}
|
||||
|
||||
public Span<byte> AsSpan()
|
||||
public readonly Span<byte> AsSpan()
|
||||
{
|
||||
return new Span<byte>(_workBuffer).Slice(0, _offset);
|
||||
return new Span<byte>(_workBuffer)[.._offset];
|
||||
}
|
||||
|
||||
public void WriteU(uint value, int valueSize) => WriteBits((int)value, valueSize);
|
||||
@@ -118,4 +118,4 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg.H264
|
||||
WriteBits((int)value, size - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg.H264
|
||||
{
|
||||
public static Span<byte> Reconstruct(ref H264PictureInfo pictureInfo, byte[] workBuffer)
|
||||
{
|
||||
H264BitStreamWriter writer = new H264BitStreamWriter(workBuffer);
|
||||
H264BitStreamWriter writer = new(workBuffer);
|
||||
|
||||
// Sequence Parameter Set.
|
||||
writer.WriteU(1, 24);
|
||||
|
@@ -4,7 +4,7 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg.Native
|
||||
{
|
||||
struct AVCodec
|
||||
{
|
||||
#pragma warning disable CS0649
|
||||
#pragma warning disable CS0649 // Field is never assigned to
|
||||
public unsafe byte* Name;
|
||||
public unsafe byte* LongName;
|
||||
public int Type;
|
||||
|
@@ -4,7 +4,7 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg.Native
|
||||
{
|
||||
struct AVCodec501
|
||||
{
|
||||
#pragma warning disable CS0649
|
||||
#pragma warning disable CS0649 // Field is never assigned to
|
||||
public unsafe byte* Name;
|
||||
public unsafe byte* LongName;
|
||||
public int Type;
|
||||
|
@@ -5,7 +5,7 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg.Native
|
||||
{
|
||||
struct AVCodecContext
|
||||
{
|
||||
#pragma warning disable CS0649
|
||||
#pragma warning disable CS0649 // Field is never assigned to
|
||||
public unsafe IntPtr AvClass;
|
||||
public int LogLevelOffset;
|
||||
public int CodecType;
|
||||
|
@@ -5,7 +5,7 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg.Native
|
||||
{
|
||||
struct AVFrame
|
||||
{
|
||||
#pragma warning disable CS0649
|
||||
#pragma warning disable CS0649 // Field is never assigned to
|
||||
public Array8<IntPtr> Data;
|
||||
public Array8<int> LineSize;
|
||||
public IntPtr ExtendedData;
|
||||
|
@@ -1,26 +1,24 @@
|
||||
using System;
|
||||
|
||||
using AVBufferRef = System.IntPtr;
|
||||
using AVBufferRef = System.IntPtr;
|
||||
|
||||
namespace Ryujinx.Graphics.Nvdec.FFmpeg.Native
|
||||
{
|
||||
struct AVPacket
|
||||
{
|
||||
#pragma warning disable CS0649
|
||||
public unsafe AVBufferRef *Buf;
|
||||
#pragma warning disable CS0649 // Field is never assigned to
|
||||
public unsafe AVBufferRef* Buf;
|
||||
public long Pts;
|
||||
public long Dts;
|
||||
public unsafe byte* Data;
|
||||
public int Size;
|
||||
public int StreamIndex;
|
||||
public int Flags;
|
||||
public IntPtr SizeData;
|
||||
public AVBufferRef SizeData;
|
||||
public int SizeDataElems;
|
||||
public long Duration;
|
||||
public long Position;
|
||||
public IntPtr Opaque;
|
||||
public unsafe AVBufferRef *OpaqueRef;
|
||||
public AVBufferRef Opaque;
|
||||
public unsafe AVBufferRef* OpaqueRef;
|
||||
public AVRational TimeBase;
|
||||
#pragma warning restore CS0649
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -2,9 +2,9 @@
|
||||
|
||||
namespace Ryujinx.Graphics.Nvdec.FFmpeg.Native
|
||||
{
|
||||
struct FFCodec<T> where T: struct
|
||||
struct FFCodec<T> where T : struct
|
||||
{
|
||||
#pragma warning disable CS0649
|
||||
#pragma warning disable CS0649 // Field is never assigned to
|
||||
public T Base;
|
||||
public int CapsInternalOrCbType;
|
||||
public int PrivDataSize;
|
||||
|
@@ -2,9 +2,9 @@
|
||||
|
||||
namespace Ryujinx.Graphics.Nvdec.FFmpeg.Native
|
||||
{
|
||||
struct FFCodecLegacy<T> where T: struct
|
||||
struct FFCodecLegacy<T> where T : struct
|
||||
{
|
||||
#pragma warning disable CS0649
|
||||
#pragma warning disable CS0649 // Field is never assigned to
|
||||
public T Base;
|
||||
public uint CapsInternalOrCbType;
|
||||
public int PrivDataSize;
|
||||
|
@@ -10,7 +10,7 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg.Native
|
||||
public const string AvCodecLibraryName = "avcodec";
|
||||
public const string AvUtilLibraryName = "avutil";
|
||||
|
||||
private static readonly Dictionary<string, (int, int)> _librariesWhitelist = new Dictionary<string, (int, int)>
|
||||
private static readonly Dictionary<string, (int, int)> _librariesWhitelist = new()
|
||||
{
|
||||
{ AvCodecLibraryName, (58, 59) },
|
||||
{ AvUtilLibraryName, (56, 57) }
|
||||
@@ -61,9 +61,8 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg.Native
|
||||
{
|
||||
NativeLibrary.SetDllImportResolver(typeof(FFmpegApi).Assembly, (name, assembly, path) =>
|
||||
{
|
||||
IntPtr handle;
|
||||
|
||||
if (name == AvUtilLibraryName && TryLoadWhitelistedLibrary(AvUtilLibraryName, assembly, path, out handle))
|
||||
if (name == AvUtilLibraryName && TryLoadWhitelistedLibrary(AvUtilLibraryName, assembly, path, out nint handle))
|
||||
{
|
||||
return handle;
|
||||
}
|
||||
@@ -106,7 +105,7 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg.Native
|
||||
internal static unsafe partial AVCodecContext* avcodec_alloc_context3(AVCodec* codec);
|
||||
|
||||
[LibraryImport(AvCodecLibraryName)]
|
||||
internal static unsafe partial int avcodec_open2(AVCodecContext* avctx, AVCodec* codec, void **options);
|
||||
internal static unsafe partial int avcodec_open2(AVCodecContext* avctx, AVCodec* codec, void** options);
|
||||
|
||||
[LibraryImport(AvCodecLibraryName)]
|
||||
internal static unsafe partial int avcodec_close(AVCodecContext* avctx);
|
||||
|
@@ -11,9 +11,9 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg
|
||||
public int RequestedWidth { get; }
|
||||
public int RequestedHeight { get; }
|
||||
|
||||
public Plane YPlane => new Plane((IntPtr)Frame->Data[0], Stride * Height);
|
||||
public Plane UPlane => new Plane((IntPtr)Frame->Data[1], UvStride * UvHeight);
|
||||
public Plane VPlane => new Plane((IntPtr)Frame->Data[2], UvStride * UvHeight);
|
||||
public Plane YPlane => new((IntPtr)Frame->Data[0], Stride * Height);
|
||||
public Plane UPlane => new((IntPtr)Frame->Data[1], UvStride * UvHeight);
|
||||
public Plane VPlane => new((IntPtr)Frame->Data[2], UvStride * UvHeight);
|
||||
|
||||
public FrameField Field => Frame->InterlacedFrame != 0 ? FrameField.Interlaced : FrameField.Progressive;
|
||||
|
||||
|
@@ -8,7 +8,7 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg.Vp8
|
||||
{
|
||||
public bool IsHardwareAccelerated => false;
|
||||
|
||||
private readonly FFmpegContext _context = new FFmpegContext(AVCodecID.AV_CODEC_ID_VP8);
|
||||
private readonly FFmpegContext _context = new(AVCodecID.AV_CODEC_ID_VP8);
|
||||
|
||||
public ISurface CreateSurface(int width, int height)
|
||||
{
|
||||
@@ -43,11 +43,11 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg.Vp8
|
||||
frame[9] = (byte)((pictureInfo.FrameHeight >> 8) & 0x3F);
|
||||
}
|
||||
|
||||
bitstream.CopyTo(new Span<byte>(frame).Slice(uncompHeaderSize));
|
||||
bitstream.CopyTo(new Span<byte>(frame)[uncompHeaderSize..]);
|
||||
|
||||
return _context.DecodeFrame(outSurf, frame) == 0;
|
||||
}
|
||||
|
||||
public void Dispose() => _context.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -17,12 +17,12 @@ namespace Ryujinx.Graphics.Nvdec
|
||||
|
||||
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 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);
|
||||
}
|
||||
}
|
||||
|
@@ -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)
|
||||
{
|
||||
|
@@ -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)
|
||||
{
|
||||
|
@@ -26,4 +26,4 @@ namespace Ryujinx.Graphics.Nvdec
|
||||
_vp8Decoder = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -14,7 +14,7 @@ namespace Ryujinx.Graphics.Nvdec
|
||||
private readonly DeviceState<NvdecRegisters> _state;
|
||||
|
||||
private long _currentId;
|
||||
private ConcurrentDictionary<long, NvdecDecoderContext> _contexts;
|
||||
private readonly ConcurrentDictionary<long, NvdecDecoderContext> _contexts;
|
||||
private NvdecDecoderContext _currentContext;
|
||||
|
||||
public NvdecDevice(MemoryManager gmm)
|
||||
|
@@ -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<uint> Reserved0;
|
||||
public uint Nop;
|
||||
public Array63<uint> Reserved104;
|
||||
|
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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<uint> 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<uint> 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)
|
||||
{
|
||||
|
@@ -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<uint> FieldOrderCnt;
|
||||
public uint FrameNum;
|
||||
#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
|
||||
{
|
||||
#pragma warning disable CS0649
|
||||
#pragma warning disable CS0649 // Field is never assigned to
|
||||
public Array13<uint> Unknown0;
|
||||
public uint GpTimerTimeoutValue;
|
||||
public ushort FrameWidth;
|
||||
|
@@ -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<Array10<Array8<byte>>> KfYModeProbE0ToE7;
|
||||
public Array10<Array10<byte>> KfYModeProbE8;
|
||||
public Array3<byte> Padding384;
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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<sbyte> RefDeltas;
|
||||
public Array2<sbyte> ModeDeltas;
|
||||
|
@@ -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<uint> 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()
|
||||
{
|
||||
|
@@ -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;
|
||||
|
@@ -30,4 +30,4 @@ namespace Ryujinx.Graphics.Nvdec
|
||||
rm.Cache.Put(outputSurface);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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<Vp9MvRef> mvsOut = MemoryMarshal.Cast<byte, Vp9MvRef>(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))
|
||||
|
@@ -20,7 +20,7 @@ namespace Ryujinx.ShaderTools
|
||||
|
||||
public ReadOnlySpan<ulong> GetCode(ulong address, int minimumSize)
|
||||
{
|
||||
return MemoryMarshal.Cast<byte, ulong>(new ReadOnlySpan<byte>(_data).Slice((int)address));
|
||||
return MemoryMarshal.Cast<byte, ulong>(new ReadOnlySpan<byte>(_data)[(int)address..]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace Ryujinx.ShaderTools
|
||||
|
||||
byte[] data = File.ReadAllBytes(options.InputPath);
|
||||
|
||||
TranslationOptions translationOptions = new TranslationOptions(options.TargetLanguage, options.TargetApi, flags);
|
||||
TranslationOptions translationOptions = new(options.TargetLanguage, options.TargetApi, flags);
|
||||
|
||||
ShaderProgram program = Translator.CreateContext(0, new GpuAccessor(data), translationOptions).Translate();
|
||||
|
||||
@@ -90,4 +90,4 @@ namespace Ryujinx.ShaderTools
|
||||
.WithNotParsed(errors => errors.Output());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user