aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Vulkan/PipelineLayoutCacheEntry.cs
diff options
context:
space:
mode:
authorTSR Berry <20988865+TSRBerry@users.noreply.github.com>2023-04-08 01:22:00 +0200
committerMary <thog@protonmail.com>2023-04-27 23:51:14 +0200
commitcee712105850ac3385cd0091a923438167433f9f (patch)
tree4a5274b21d8b7f938c0d0ce18736d3f2993b11b1 /Ryujinx.Graphics.Vulkan/PipelineLayoutCacheEntry.cs
parentcd124bda587ef09668a971fa1cac1c3f0cfc9f21 (diff)
Move solution and projects to src
Diffstat (limited to 'Ryujinx.Graphics.Vulkan/PipelineLayoutCacheEntry.cs')
-rw-r--r--Ryujinx.Graphics.Vulkan/PipelineLayoutCacheEntry.cs112
1 files changed, 0 insertions, 112 deletions
diff --git a/Ryujinx.Graphics.Vulkan/PipelineLayoutCacheEntry.cs b/Ryujinx.Graphics.Vulkan/PipelineLayoutCacheEntry.cs
deleted file mode 100644
index 2c966115..00000000
--- a/Ryujinx.Graphics.Vulkan/PipelineLayoutCacheEntry.cs
+++ /dev/null
@@ -1,112 +0,0 @@
-using Ryujinx.Graphics.GAL;
-using Silk.NET.Vulkan;
-using System.Collections.Generic;
-
-namespace Ryujinx.Graphics.Vulkan
-{
- class PipelineLayoutCacheEntry
- {
- private readonly VulkanRenderer _gd;
- private readonly Device _device;
-
- public DescriptorSetLayout[] DescriptorSetLayouts { get; }
- public PipelineLayout PipelineLayout { get; }
-
- private readonly List<Auto<DescriptorSetCollection>>[][] _dsCache;
- private readonly int[] _dsCacheCursor;
- private int _dsLastCbIndex;
-
- private PipelineLayoutCacheEntry(VulkanRenderer gd, Device device)
- {
- _gd = gd;
- _device = device;
-
- _dsCache = new List<Auto<DescriptorSetCollection>>[CommandBufferPool.MaxCommandBuffers][];
-
- for (int i = 0; i < CommandBufferPool.MaxCommandBuffers; i++)
- {
- _dsCache[i] = new List<Auto<DescriptorSetCollection>>[PipelineBase.DescriptorSetLayouts];
-
- for (int j = 0; j < PipelineBase.DescriptorSetLayouts; j++)
- {
- _dsCache[i][j] = new List<Auto<DescriptorSetCollection>>();
- }
- }
-
- _dsCacheCursor = new int[PipelineBase.DescriptorSetLayouts];
- }
-
- public PipelineLayoutCacheEntry(VulkanRenderer gd, Device device, uint stages, bool usePd) : this(gd, device)
- {
- DescriptorSetLayouts = PipelineLayoutFactory.Create(gd, device, stages, usePd, out var pipelineLayout);
- PipelineLayout = pipelineLayout;
- }
-
- public PipelineLayoutCacheEntry(VulkanRenderer gd, Device device, ShaderSource[] shaders) : this(gd, device)
- {
- DescriptorSetLayouts = PipelineLayoutFactory.CreateMinimal(gd, device, shaders, out var pipelineLayout);
- PipelineLayout = pipelineLayout;
- }
-
- public Auto<DescriptorSetCollection> GetNewDescriptorSetCollection(
- VulkanRenderer gd,
- int commandBufferIndex,
- int setIndex,
- out bool isNew)
- {
- if (_dsLastCbIndex != commandBufferIndex)
- {
- _dsLastCbIndex = commandBufferIndex;
-
- for (int i = 0; i < PipelineBase.DescriptorSetLayouts; i++)
- {
- _dsCacheCursor[i] = 0;
- }
- }
-
- var list = _dsCache[commandBufferIndex][setIndex];
- int index = _dsCacheCursor[setIndex]++;
- if (index == list.Count)
- {
- var dsc = gd.DescriptorSetManager.AllocateDescriptorSet(gd.Api, DescriptorSetLayouts[setIndex]);
- list.Add(dsc);
- isNew = true;
- return dsc;
- }
-
- isNew = false;
- return list[index];
- }
-
- protected virtual unsafe void Dispose(bool disposing)
- {
- if (disposing)
- {
- for (int i = 0; i < _dsCache.Length; i++)
- {
- for (int j = 0; j < _dsCache[i].Length; j++)
- {
- for (int k = 0; k < _dsCache[i][j].Count; k++)
- {
- _dsCache[i][j][k].Dispose();
- }
-
- _dsCache[i][j].Clear();
- }
- }
-
- _gd.Api.DestroyPipelineLayout(_device, PipelineLayout, null);
-
- for (int i = 0; i < DescriptorSetLayouts.Length; i++)
- {
- _gd.Api.DestroyDescriptorSetLayout(_device, DescriptorSetLayouts[i], null);
- }
- }
- }
-
- public void Dispose()
- {
- Dispose(true);
- }
- }
-}