aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Nvdec.Vp9/Decoder.cs
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2021-02-10 21:54:42 -0300
committerGitHub <noreply@github.com>2021-02-11 01:54:42 +0100
commitc465d771dd099b0ffbb0792b3e74148e01259f19 (patch)
treebec6a92ed01427f2300c417ed26de0b9d2361920 /Ryujinx.Graphics.Nvdec.Vp9/Decoder.cs
parent172ec326e598971f2251e5acdcfa65faa7291396 (diff)
Enable multithreaded VP9 decoding (#2009)
* Enable multithreaded VP9 decoding * Limit the number of threads used for video decoding
Diffstat (limited to 'Ryujinx.Graphics.Nvdec.Vp9/Decoder.cs')
-rw-r--r--Ryujinx.Graphics.Nvdec.Vp9/Decoder.cs18
1 files changed, 16 insertions, 2 deletions
diff --git a/Ryujinx.Graphics.Nvdec.Vp9/Decoder.cs b/Ryujinx.Graphics.Nvdec.Vp9/Decoder.cs
index ff4221ac..f82ca761 100644
--- a/Ryujinx.Graphics.Nvdec.Vp9/Decoder.cs
+++ b/Ryujinx.Graphics.Nvdec.Vp9/Decoder.cs
@@ -92,7 +92,14 @@ namespace Ryujinx.Graphics.Nvdec.Vp9
cm.Mb.SetupBlockPlanes(1, 1);
- cm.AllocTileWorkerData(_allocator, 1 << pictureInfo.Log2TileCols, 1 << pictureInfo.Log2TileRows);
+ int tileCols = 1 << pictureInfo.Log2TileCols;
+ int tileRows = 1 << pictureInfo.Log2TileRows;
+
+ // Video usually have only 4 columns, so more threads won't make a difference for those.
+ // Try to not take all CPU cores for video decoding.
+ int maxThreads = Math.Min(4, Environment.ProcessorCount / 2);
+
+ cm.AllocTileWorkerData(_allocator, tileCols, tileRows, maxThreads);
cm.AllocContextBuffers(_allocator, output.Width, output.Height);
cm.InitContextBuffers();
cm.SetupSegmentationDequant();
@@ -104,7 +111,14 @@ namespace Ryujinx.Graphics.Nvdec.Vp9
{
try
{
- DecodeFrame.DecodeTiles(ref cm, new ArrayPtr<byte>(dataPtr, bitstream.Length));
+ if (maxThreads > 1 && tileRows == 1 && tileCols > 1)
+ {
+ DecodeFrame.DecodeTilesMt(ref cm, new ArrayPtr<byte>(dataPtr, bitstream.Length), maxThreads);
+ }
+ else
+ {
+ DecodeFrame.DecodeTiles(ref cm, new ArrayPtr<byte>(dataPtr, bitstream.Length));
+ }
}
catch (InternalErrorException)
{