mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-12-04 18:22:01 +00:00
NVIDIA Thread create/delete stutter workarounds (#1760)
* Thread create/delete stutter workarounds Pt 1 * As tiered compilation is disabled, disable quick jit too Should result in tier 1 compilation all the time * Fix rebase.
This commit is contained in:
parent
06aa8a7578
commit
c9b6be1ef8
2 changed files with 29 additions and 1 deletions
|
@ -1,4 +1,4 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net5.0</TargetFramework>
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
|
@ -6,6 +6,8 @@
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
<Version>1.0.0-dirty</Version>
|
<Version>1.0.0-dirty</Version>
|
||||||
|
<TieredCompilation>false</TieredCompilation>
|
||||||
|
<TieredCompilationQuickJit>false</TieredCompilationQuickJit>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -240,13 +240,39 @@ namespace Ryujinx.Ui
|
||||||
};
|
};
|
||||||
renderLoopThread.Start();
|
renderLoopThread.Start();
|
||||||
|
|
||||||
|
Thread nvStutterWorkaround = new Thread(NVStutterWorkaround)
|
||||||
|
{
|
||||||
|
Name = "GUI.NVStutterWorkaround"
|
||||||
|
};
|
||||||
|
nvStutterWorkaround.Start();
|
||||||
|
|
||||||
MainLoop();
|
MainLoop();
|
||||||
|
|
||||||
renderLoopThread.Join();
|
renderLoopThread.Join();
|
||||||
|
nvStutterWorkaround.Join();
|
||||||
|
|
||||||
Exit();
|
Exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void NVStutterWorkaround()
|
||||||
|
{
|
||||||
|
while (_isActive)
|
||||||
|
{
|
||||||
|
// When NVIDIA Threaded Optimization is on, the driver will snapshot all threads in the system whenever the application creates any new ones.
|
||||||
|
// The ThreadPool has something called a "GateThread" which terminates itself after some inactivity.
|
||||||
|
// However, it immediately starts up again, since the rules regarding when to terminate and when to start differ.
|
||||||
|
// This creates a new thread every second or so.
|
||||||
|
// The main problem with this is that the thread snapshot can take 70ms, is on the OpenGL thread and will delay rendering any graphics.
|
||||||
|
// This is a little over budget on a frame time of 16ms, so creates a large stutter.
|
||||||
|
// The solution is to keep the ThreadPool active so that it never has a reason to terminate the GateThread.
|
||||||
|
|
||||||
|
// TODO: This should be removed when the issue with the GateThread is resolved.
|
||||||
|
|
||||||
|
ThreadPool.QueueUserWorkItem((state) => { });
|
||||||
|
Thread.Sleep(300);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected override bool OnButtonPressEvent(EventButton evnt)
|
protected override bool OnButtonPressEvent(EventButton evnt)
|
||||||
{
|
{
|
||||||
_mouseX = evnt.X;
|
_mouseX = evnt.X;
|
||||||
|
|
Loading…
Reference in a new issue