mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-11-14 05:06:47 +00:00
Prefetch capabilities before spawning translation threads. (#3338)
* Prefetch capabilities before spawning translation threads. The Backend Multithreading only expects one thread to submit commands at a time. When compiling shaders, the translator may request the host GPU capabilities from the backend. It's possible for a bunch of translators to do this at the same time. There's a caching mechanism in place so that the capabilities are only fetched once. By triggering this before spawning the thread, the async translation threads no longer try to queue onto the backend queue all at the same time. The Capabilities do need to be checked from the GPU thread, due to OpenGL needing a context to check them, so it's not possible to call the underlying backend directly. * Initialize the capabilities when setting the GPU thread + missing call in headless * Remove private variables
This commit is contained in:
parent
43b4b34376
commit
9ba73ffbe5
2 changed files with 4 additions and 15 deletions
|
@ -82,27 +82,13 @@ namespace Ryujinx.Graphics.Gpu
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Host hardware capabilities.
|
/// Host hardware capabilities.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal ref Capabilities Capabilities
|
internal Capabilities Capabilities { get; private set; }
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (!_capsLoaded)
|
|
||||||
{
|
|
||||||
_caps = Renderer.GetCapabilities();
|
|
||||||
_capsLoaded = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ref _caps;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Event for signalling shader cache loading progress.
|
/// Event for signalling shader cache loading progress.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public event Action<ShaderCacheState, int, int> ShaderCacheStateChanged;
|
public event Action<ShaderCacheState, int, int> ShaderCacheStateChanged;
|
||||||
|
|
||||||
private bool _capsLoaded;
|
|
||||||
private Capabilities _caps;
|
|
||||||
private Thread _gpuThread;
|
private Thread _gpuThread;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -254,6 +240,8 @@ namespace Ryujinx.Graphics.Gpu
|
||||||
public void SetGpuThread()
|
public void SetGpuThread()
|
||||||
{
|
{
|
||||||
_gpuThread = Thread.CurrentThread;
|
_gpuThread = Thread.CurrentThread;
|
||||||
|
|
||||||
|
Capabilities = Renderer.GetCapabilities();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -164,6 +164,7 @@ namespace Ryujinx.Headless.SDL2
|
||||||
|
|
||||||
Device.Gpu.Renderer.RunLoop(() =>
|
Device.Gpu.Renderer.RunLoop(() =>
|
||||||
{
|
{
|
||||||
|
Device.Gpu.SetGpuThread();
|
||||||
Device.Gpu.InitializeShaderCache(_gpuCancellationTokenSource.Token);
|
Device.Gpu.InitializeShaderCache(_gpuCancellationTokenSource.Token);
|
||||||
Translator.IsReadyForTranslation.Set();
|
Translator.IsReadyForTranslation.Set();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue