diff options
author | gdkchan <gab.dark.100@gmail.com> | 2022-07-27 21:07:48 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-27 21:07:48 -0300 |
commit | 3c3bcd82fe6dfa8bdc2c9a9f33724ebfacd7dd40 (patch) | |
tree | 1945094df81c8de1dd540508a6d59d82b5a18d39 /Ryujinx.Graphics.Gpu/Image/TextureManager.cs | |
parent | a00c59a46c372ad004cb5b6c9aca97e6f5e9e910 (diff) |
Add a sampler pool cache and improve texture pool cache (#3487)1.1.194
* Add a sampler pool cache and improve texture pool cache
* Increase disposal timestamp delta more to be on the safe side
* Nits
* Use abstract class for PoolCache, remove factory callback
Diffstat (limited to 'Ryujinx.Graphics.Gpu/Image/TextureManager.cs')
-rw-r--r-- | Ryujinx.Graphics.Gpu/Image/TextureManager.cs | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/Ryujinx.Graphics.Gpu/Image/TextureManager.cs b/Ryujinx.Graphics.Gpu/Image/TextureManager.cs index 628c3159..fe0175a6 100644 --- a/Ryujinx.Graphics.Gpu/Image/TextureManager.cs +++ b/Ryujinx.Graphics.Gpu/Image/TextureManager.cs @@ -16,6 +16,7 @@ namespace Ryujinx.Graphics.Gpu.Image private readonly TextureBindingsManager _cpBindingsManager; private readonly TextureBindingsManager _gpBindingsManager; private readonly TexturePoolCache _texturePoolCache; + private readonly SamplerPoolCache _samplerPoolCache; private readonly Texture[] _rtColors; private readonly ITexture[] _rtHostColors; @@ -41,13 +42,15 @@ namespace Ryujinx.Graphics.Gpu.Image _channel = channel; TexturePoolCache texturePoolCache = new TexturePoolCache(context); + SamplerPoolCache samplerPoolCache = new SamplerPoolCache(context); float[] scales = new float[64]; new Span<float>(scales).Fill(1f); - _cpBindingsManager = new TextureBindingsManager(context, channel, texturePoolCache, scales, isCompute: true); - _gpBindingsManager = new TextureBindingsManager(context, channel, texturePoolCache, scales, isCompute: false); + _cpBindingsManager = new TextureBindingsManager(context, channel, texturePoolCache, samplerPoolCache, scales, isCompute: true); + _gpBindingsManager = new TextureBindingsManager(context, channel, texturePoolCache, samplerPoolCache, scales, isCompute: false); _texturePoolCache = texturePoolCache; + _samplerPoolCache = samplerPoolCache; _rtColors = new Texture[Constants.TotalRenderTargets]; _rtHostColors = new ITexture[Constants.TotalRenderTargets]; @@ -368,6 +371,10 @@ namespace Ryujinx.Graphics.Gpu.Image // we must rebind everything. // Since compute work happens less often, we always do that // before and after the compute dispatch. + + _texturePoolCache.Tick(); + _samplerPoolCache.Tick(); + _cpBindingsManager.Rebind(); bool result = _cpBindingsManager.CommitBindings(specState); _gpBindingsManager.Rebind(); @@ -382,6 +389,9 @@ namespace Ryujinx.Graphics.Gpu.Image /// <returns>True if all bound textures match the current shader specialization state, false otherwise</returns> public bool CommitGraphicsBindings(ShaderSpecializationState specState) { + _texturePoolCache.Tick(); + _samplerPoolCache.Tick(); + bool result = _gpBindingsManager.CommitBindings(specState); UpdateRenderTargets(); @@ -502,6 +512,15 @@ namespace Ryujinx.Graphics.Gpu.Image } /// <summary> + /// Forces the texture and sampler pools to be re-loaded from the cache on next use. + /// </summary> + public void ReloadPools() + { + _cpBindingsManager.ReloadPools(); + _gpBindingsManager.ReloadPools(); + } + + /// <summary> /// Forces all textures, samplers, images and render targets to be rebound the next time /// CommitGraphicsBindings is called. /// </summary> @@ -523,8 +542,8 @@ namespace Ryujinx.Graphics.Gpu.Image /// </summary> public void Dispose() { - _cpBindingsManager.Dispose(); - _gpBindingsManager.Dispose(); + // Textures are owned by the texture cache, so we shouldn't dispose the texture pool cache. + _samplerPoolCache.Dispose(); for (int i = 0; i < _rtColors.Length; i++) { |