Add a sampler pool cache and improve texture pool cache (#3487)
* 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
This commit is contained in:
parent
a00c59a46c
commit
3c3bcd82fe
8 changed files with 321 additions and 136 deletions
|
@ -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();
|
||||
|
@ -501,6 +511,15 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||
_context.Renderer.Pipeline.SetRenderTargets(_rtHostColors, _rtHostDs);
|
||||
}
|
||||
|
||||
/// <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.
|
||||
|
@ -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++)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue