diff options
author | riperiperi <rhy3756547@hotmail.com> | 2022-05-14 15:58:33 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-14 11:58:33 -0300 |
commit | 9ba73ffbe5f78c0403cf102b95768f388da05122 (patch) | |
tree | d4568160e1dd7b285f2cb0e407a7e99091cceb9d | |
parent | 43b4b34376cdea486906f8bb4058dda3be7e1bd8 (diff) |
Prefetch capabilities before spawning translation threads. (#3338)1.1.121
* 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
-rw-r--r-- | Ryujinx.Graphics.Gpu/GpuContext.cs | 18 | ||||
-rw-r--r-- | Ryujinx.Headless.SDL2/WindowBase.cs | 1 |
2 files changed, 4 insertions, 15 deletions
diff --git a/Ryujinx.Graphics.Gpu/GpuContext.cs b/Ryujinx.Graphics.Gpu/GpuContext.cs index 66077c3b..67edd842 100644 --- a/Ryujinx.Graphics.Gpu/GpuContext.cs +++ b/Ryujinx.Graphics.Gpu/GpuContext.cs @@ -82,27 +82,13 @@ namespace Ryujinx.Graphics.Gpu /// <summary> /// Host hardware capabilities. /// </summary> - internal ref Capabilities Capabilities - { - get - { - if (!_capsLoaded) - { - _caps = Renderer.GetCapabilities(); - _capsLoaded = true; - } - - return ref _caps; - } - } + internal Capabilities Capabilities { get; private set; } /// <summary> /// Event for signalling shader cache loading progress. /// </summary> public event Action<ShaderCacheState, int, int> ShaderCacheStateChanged; - private bool _capsLoaded; - private Capabilities _caps; private Thread _gpuThread; /// <summary> @@ -254,6 +240,8 @@ namespace Ryujinx.Graphics.Gpu public void SetGpuThread() { _gpuThread = Thread.CurrentThread; + + Capabilities = Renderer.GetCapabilities(); } /// <summary> diff --git a/Ryujinx.Headless.SDL2/WindowBase.cs b/Ryujinx.Headless.SDL2/WindowBase.cs index 74eb0d31..c7c45596 100644 --- a/Ryujinx.Headless.SDL2/WindowBase.cs +++ b/Ryujinx.Headless.SDL2/WindowBase.cs @@ -164,6 +164,7 @@ namespace Ryujinx.Headless.SDL2 Device.Gpu.Renderer.RunLoop(() => { + Device.Gpu.SetGpuThread(); Device.Gpu.InitializeShaderCache(_gpuCancellationTokenSource.Token); Translator.IsReadyForTranslation.Set(); |