diff options
Diffstat (limited to 'Ryujinx.Graphics.Vulkan/PipelineLayoutCache.cs')
-rw-r--r-- | Ryujinx.Graphics.Vulkan/PipelineLayoutCache.cs | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/Ryujinx.Graphics.Vulkan/PipelineLayoutCache.cs b/Ryujinx.Graphics.Vulkan/PipelineLayoutCache.cs new file mode 100644 index 00000000..c834fa62 --- /dev/null +++ b/Ryujinx.Graphics.Vulkan/PipelineLayoutCache.cs @@ -0,0 +1,58 @@ +using Ryujinx.Graphics.GAL; +using Silk.NET.Vulkan; +using System.Collections.Generic; + +namespace Ryujinx.Graphics.Vulkan +{ + class PipelineLayoutCache + { + private readonly PipelineLayoutCacheEntry[] _plce; + private readonly List<PipelineLayoutCacheEntry> _plceMinimal; + + public PipelineLayoutCache() + { + _plce = new PipelineLayoutCacheEntry[1 << Constants.MaxShaderStages]; + _plceMinimal = new List<PipelineLayoutCacheEntry>(); + } + + public PipelineLayoutCacheEntry Create(VulkanRenderer gd, Device device, ShaderSource[] shaders) + { + var plce = new PipelineLayoutCacheEntry(gd, device, shaders); + _plceMinimal.Add(plce); + return plce; + } + + public PipelineLayoutCacheEntry GetOrCreate(VulkanRenderer gd, Device device, uint stages, bool usePd) + { + if (_plce[stages] == null) + { + _plce[stages] = new PipelineLayoutCacheEntry(gd, device, stages, usePd); + } + + return _plce[stages]; + } + + protected virtual unsafe void Dispose(bool disposing) + { + if (disposing) + { + for (int i = 0; i < _plce.Length; i++) + { + _plce[i]?.Dispose(); + } + + foreach (var plce in _plceMinimal) + { + plce.Dispose(); + } + + _plceMinimal.Clear(); + } + } + + public void Dispose() + { + Dispose(true); + } + } +} |