New NVDEC and VIC implementation (#1384)

* Initial NVDEC and VIC implementation

* Update FFmpeg.AutoGen to 4.3.0

* Add nvdec dependencies for Windows

* Unify some VP9 structures

* Rename VP9 structure fields

* Improvements to Video API

* XML docs for Common.Memory

* Remove now unused or redundant overloads from MemoryAccessor

* NVDEC UV surface read/write scalar paths

* Add FIXME comments about hacky things/stuff that will need to be fixed in the future

* Cleaned up VP9 memory allocation

* Remove some debug logs

* Rename some VP9 structs

* Remove unused struct

* No need to compile Ryujinx.Graphics.Host1x with unsafe anymore

* Name AsyncWorkQueue threads to make debugging easier

* Make Vp9PictureInfo a ref struct

* LayoutConverter no longer needs the depth argument (broken by rebase)

* Pooling of VP9 buffers, plus fix a memory leak on VP9

* Really wish VS could rename projects properly...

* Address feedback

* Remove using

* Catch OperationCanceledException

* Add licensing informations

* Add THIRDPARTY.md to release too

Co-authored-by: Thog <me@thog.eu>
This commit is contained in:
gdkchan 2020-07-12 00:07:01 -03:00 committed by GitHub
parent 38b26cf424
commit 4d02a2d2c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
202 changed files with 20563 additions and 2567 deletions

View file

@ -0,0 +1,39 @@
using System.Runtime.CompilerServices;
namespace Ryujinx.Graphics.Vic.Types
{
static class BitfieldExtensions
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool Extract(this int value, int lsb)
{
return ((value >> (lsb & 0x1f)) & 1) != 0;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int Extract(this int value, int lsb, int length)
{
return (value >> (lsb & 0x1f)) & (int)(uint.MaxValue >> (32 - length));
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool Extract(this long value, int lsb)
{
return ((int)(value >> (lsb & 0x3f)) & 1) != 0;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int Extract(this long value, int lsb, int length)
{
return (int)(value >> (lsb & 0x3f)) & (int)(uint.MaxValue >> (32 - length));
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int ExtractSx(this long value, int lsb, int length)
{
int shift = lsb & 0x3f;
return (int)((value << (64 - (shift + length))) >> (64 - length));
}
}
}

View file

@ -0,0 +1,27 @@
namespace Ryujinx.Graphics.Vic.Types
{
struct BlendingSlotStruct
{
private long _word0;
private long _word1;
public int AlphaK1 => _word0.Extract(0, 10);
public int AlphaK2 => _word0.Extract(16, 10);
public int SrcFactCMatchSelect => _word0.Extract(32, 3);
public int DstFactCMatchSelect => _word0.Extract(36, 3);
public int SrcFactAMatchSelect => _word0.Extract(40, 3);
public int DstFactAMatchSelect => _word0.Extract(44, 3);
public int OverrideR => _word1.Extract(66, 10);
public int OverrideG => _word1.Extract(76, 10);
public int OverrideB => _word1.Extract(86, 10);
public int OverrideA => _word1.Extract(96, 10);
public bool UseOverrideR => _word1.Extract(108);
public bool UseOverrideG => _word1.Extract(109);
public bool UseOverrideB => _word1.Extract(110);
public bool UseOverrideA => _word1.Extract(111);
public bool MaskR => _word1.Extract(112);
public bool MaskG => _word1.Extract(113);
public bool MaskB => _word1.Extract(114);
public bool MaskA => _word1.Extract(115);
}
}

View file

@ -0,0 +1,17 @@
namespace Ryujinx.Graphics.Vic.Types
{
struct ClearRectStruct
{
private long _word0;
private long _word1;
public int ClearRect0Left => _word0.Extract(0, 14);
public int ClearRect0Right => _word0.Extract(16, 14);
public int ClearRect0Top => _word0.Extract(32, 14);
public int ClearRect0Bottom => _word0.Extract(48, 14);
public int ClearRect1Left => _word1.Extract(64, 14);
public int ClearRect1Right => _word1.Extract(80, 14);
public int ClearRect1Top => _word1.Extract(96, 14);
public int ClearRect1Bottom => _word1.Extract(112, 14);
}
}

View file

@ -0,0 +1,14 @@
using Ryujinx.Common.Memory;
namespace Ryujinx.Graphics.Vic.Types
{
struct ConfigStruct
{
public PipeConfig PipeConfig;
public OutputConfig OutputConfig;
public OutputSurfaceConfig OutputSurfaceConfig;
public MatrixStruct OutColorMatrix;
public Array4<ClearRectStruct> ClearRectStruct;
public Array8<SlotStruct> SlotStruct;
}
}

View file

@ -0,0 +1,17 @@
namespace Ryujinx.Graphics.Vic.Types
{
struct LumaKeyStruct
{
private long _word0;
private long _word1;
public int LumaCoeff0 => _word0.Extract(0, 20);
public int LumaCoeff1 => _word0.Extract(20, 20);
public int LumaCoeff2 => _word0.Extract(40, 20);
public int LumaRShift => _word0.Extract(60, 4);
public int LumaCoeff3 => _word1.Extract(64, 20);
public int LumaKeyLower => _word1.Extract(84, 10);
public int LumaKeyUpper => _word1.Extract(94, 10);
public bool LumaKeyEnabled => _word1.Extract(104);
}
}

View file

@ -0,0 +1,25 @@
namespace Ryujinx.Graphics.Vic.Types
{
struct MatrixStruct
{
private long _word0;
private long _word1;
private long _word2;
private long _word3;
public int MatrixCoeff00 => _word0.ExtractSx(0, 20);
public int MatrixCoeff10 => _word0.ExtractSx(20, 20);
public int MatrixCoeff20 => _word0.ExtractSx(40, 20);
public int MatrixRShift => _word0.Extract(60, 4);
public int MatrixCoeff01 => _word1.ExtractSx(64, 20);
public int MatrixCoeff11 => _word1.ExtractSx(84, 20);
public int MatrixCoeff21 => _word1.ExtractSx(104, 20);
public bool MatrixEnable => _word1.Extract(127);
public int MatrixCoeff02 => _word2.ExtractSx(128, 20);
public int MatrixCoeff12 => _word2.ExtractSx(148, 20);
public int MatrixCoeff22 => _word2.ExtractSx(168, 20);
public int MatrixCoeff03 => _word3.ExtractSx(192, 20);
public int MatrixCoeff13 => _word3.ExtractSx(212, 20);
public int MatrixCoeff23 => _word3.ExtractSx(232, 20);
}
}

View file

@ -0,0 +1,23 @@
namespace Ryujinx.Graphics.Vic.Types
{
struct OutputConfig
{
private long _word0;
private long _word1;
public int AlphaFillMode => _word0.Extract(0, 3);
public int AlphaFillSlot => _word0.Extract(3, 3);
public int BackgroundAlpha => _word0.Extract(6, 10);
public int BackgroundR => _word0.Extract(16, 10);
public int BackgroundG => _word0.Extract(26, 10);
public int BackgroundB => _word0.Extract(36, 10);
public int RegammaMode => _word0.Extract(46, 2);
public bool OutputFlipX => _word0.Extract(48);
public bool OutputFlipY => _word0.Extract(49);
public bool OutputTranspose => _word0.Extract(50);
public int TargetRectLeft => _word1.Extract(64, 14);
public int TargetRectRight => _word1.Extract(80, 14);
public int TargetRectTop => _word1.Extract(96, 14);
public int TargetRectBottom => _word1.Extract(112, 14);
}
}

View file

@ -0,0 +1,20 @@
namespace Ryujinx.Graphics.Vic.Types
{
struct OutputSurfaceConfig
{
private long _word0;
private long _word1;
public PixelFormat OutPixelFormat => (PixelFormat)_word0.Extract(0, 7);
public int OutChromaLocHoriz => _word0.Extract(7, 2);
public int OutChromaLocVert => _word0.Extract(9, 2);
public int OutBlkKind => _word0.Extract(11, 4);
public int OutBlkHeight => _word0.Extract(15, 4);
public int OutSurfaceWidth => _word0.Extract(32, 14);
public int OutSurfaceHeight => _word0.Extract(46, 14);
public int OutLumaWidth => _word1.Extract(64, 14);
public int OutLumaHeight => _word1.Extract(78, 14);
public int OutChromaWidth => _word1.Extract(96, 14);
public int OutChromaHeight => _word1.Extract(110, 14);
}
}

View file

@ -0,0 +1,11 @@
namespace Ryujinx.Graphics.Vic.Types
{
struct PipeConfig
{
private long _word0;
private long _word1;
public int DownsampleHoriz => _word0.Extract(0, 11);
public int DownsampleVert => _word0.Extract(16, 11);
}
}

View file

@ -0,0 +1,81 @@
namespace Ryujinx.Graphics.Vic.Types
{
enum PixelFormat
{
A8,
L8,
A4L4,
L4A4,
R8,
A8L8,
L8A8,
R8G8,
G8R8,
B5G6R5,
R5G6B5,
B6G5R5,
R5G5B6,
A1B5G5R5,
A1R5G5B5,
B5G5R5A1,
R5G5B5A1,
A5B5G5R1,
A5R1G5B5,
B5G5R1A5,
R1G5B5A5,
X1B5G5R5,
X1R5G5B5,
B5G5R5X1,
R5G5B5X1,
A4B4G4R4,
A4R4G4B4,
B4G4R4A4,
R4G4B4A4,
B8_G8_R8,
R8_G8_B8,
A8B8G8R8,
A8R8G8B8,
B8G8R8A8,
R8G8B8A8,
X8B8G8R8,
X8R8G8B8,
B8G8R8X8,
R8G8B8X8,
A2B10G10R10,
A2R10G10B10,
B10G10R10A2,
R10G10B10A2,
A4P4,
P4A4,
P8A845,
A8P8,
P8,
P1,
U8V8,
V8U8,
A8Y8U8V8,
V8U8Y8A8,
Y8_U8_V8,
Y8_V8_U8,
U8_V8_Y8,
V8_U8_Y8,
Y8_U8__Y8_V8,
Y8_V8__Y8_U8,
U8_Y8__V8_Y8,
V8_Y8__U8_Y8,
Y8___U8V8_N444,
Y8___V8U8_N444,
Y8___U8V8_N422,
Y8___V8U8_N422,
Y8___U8V8_N422R,
Y8___V8U8_N422R,
Y8___U8V8_N420,
Y8___V8U8_N420,
Y8___U8___V8_N444,
Y8___U8___V8_N422,
Y8___U8___V8_N422R,
Y8___U8___V8_N420,
U8,
V8
}
}

View file

@ -0,0 +1,63 @@
namespace Ryujinx.Graphics.Vic.Types
{
struct SlotConfig
{
private long _word0;
private long _word1;
private long _word2;
private long _word3;
private long _word4;
private long _word5;
private long _word6;
private long _word7;
public bool SlotEnable => _word0.Extract(0);
public bool DeNoise => _word0.Extract(1);
public bool AdvancedDenoise => _word0.Extract(2);
public bool CadenceDetect => _word0.Extract(3);
public bool MotionMap => _word0.Extract(4);
public bool MMapCombine => _word0.Extract(5);
public bool IsEven => _word0.Extract(6);
public bool ChromaEven => _word0.Extract(7);
public bool CurrentFieldEnable => _word0.Extract(8);
public bool PrevFieldEnable => _word0.Extract(9);
public bool NextFieldEnable => _word0.Extract(10);
public bool NextNrFieldEnable => _word0.Extract(11);
public bool CurMotionFieldEnable => _word0.Extract(12);
public bool PrevMotionFieldEnable => _word0.Extract(13);
public bool PpMotionFieldEnable => _word0.Extract(14);
public bool CombMotionFieldEnable => _word0.Extract(15);
public int FrameFormat => _word0.Extract(16, 4);
public int FilterLengthY => _word0.Extract(20, 2);
public int FilterLengthX => _word0.Extract(22, 2);
public int Panoramic => _word0.Extract(24, 12);
public int DetailFltClamp => _word0.Extract(58, 6);
public int FilterNoise => _word1.Extract(64, 10);
public int FilterDetail => _word1.Extract(74, 10);
public int ChromaNoise => _word1.Extract(84, 10);
public int ChromaDetail => _word1.Extract(94, 10);
public int DeinterlaceMode => _word1.Extract(104, 4);
public int MotionAccumWeight => _word1.Extract(108, 3);
public int NoiseIir => _word1.Extract(111, 11);
public int LightLevel => _word1.Extract(122, 4);
public int SoftClampLow => _word2.Extract(128, 10);
public int SoftClampHigh => _word2.Extract(138, 10);
public int PlanarAlpha => _word2.Extract(160, 10);
public bool ConstantAlpha => _word2.Extract(170);
public int StereoInterleave => _word2.Extract(171, 3);
public bool ClipEnabled => _word2.Extract(174);
public int ClearRectMask => _word2.Extract(175, 8);
public int DegammaMode => _word2.Extract(183, 2);
public bool DecompressEnable => _word2.Extract(186);
public int DecompressCtbCount => _word3.Extract(192, 8);
public int DecompressZbcColor => _word3.Extract(200, 32);
public int SourceRectLeft => _word4.Extract(256, 30);
public int SourceRectRight => _word4.Extract(288, 30);
public int SourceRectTop => _word5.Extract(320, 30);
public int SourceRectBottom => _word5.Extract(352, 30);
public int DstRectLeft => _word6.Extract(384, 14);
public int DstRectRight => _word6.Extract(400, 14);
public int DstRectTop => _word6.Extract(416, 14);
public int DstRectBottom => _word6.Extract(432, 14);
}
}

View file

@ -0,0 +1,12 @@
namespace Ryujinx.Graphics.Vic.Types
{
struct SlotStruct
{
public SlotConfig SlotConfig;
public SlotSurfaceConfig SlotSurfaceConfig;
public LumaKeyStruct LumaKeyStruct;
public MatrixStruct ColorMatrixStruct;
public MatrixStruct GamutMatrixStruct;
public BlendingSlotStruct BlendingSlotStruct;
}
}

View file

@ -0,0 +1,21 @@
namespace Ryujinx.Graphics.Vic.Types
{
struct SlotSurfaceConfig
{
private long _word0;
private long _word1;
public PixelFormat SlotPixelFormat => (PixelFormat)_word0.Extract(0, 7);
public int SlotChromaLocHoriz => _word0.Extract(7, 2);
public int SlotChromaLocVert => _word0.Extract(9, 2);
public int SlotBlkKind => _word0.Extract(11, 4);
public int SlotBlkHeight => _word0.Extract(15, 4);
public int SlotCacheWidth => _word0.Extract(19, 3);
public int SlotSurfaceWidth => _word0.Extract(32, 14);
public int SlotSurfaceHeight => _word0.Extract(46, 14);
public int SlotLumaWidth => _word1.Extract(64, 14);
public int SlotLumaHeight => _word1.Extract(78, 14);
public int SlotChromaWidth => _word1.Extract(96, 14);
public int SlotChromaHeight => _word1.Extract(110, 14);
}
}