aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Graphics.Vulkan/TextureArray.cs
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2024-06-02 22:40:28 -0300
committerGitHub <noreply@github.com>2024-06-02 22:40:28 -0300
commitc0f2491eaee7eb1088605f5bda8055b941a14f99 (patch)
tree4f52becd1f06d3f2dc2209be8e802f505b1d1eca /src/Ryujinx.Graphics.Vulkan/TextureArray.cs
parentd7c6474729ee36875cf387629afe1389655311f8 (diff)
Vulkan separate descriptor set fixes (#6895)
* Ensure descriptor sets are only re-used when all command buffers using it have completed * Fix some SPIR-V capabilities * Set update after bind flag if we exceed limits * Simpler fix for Intel * Format whitespace * Make struct readonly * Add barriers for extra set arrays too
Diffstat (limited to 'src/Ryujinx.Graphics.Vulkan/TextureArray.cs')
-rw-r--r--src/Ryujinx.Graphics.Vulkan/TextureArray.cs40
1 files changed, 4 insertions, 36 deletions
diff --git a/src/Ryujinx.Graphics.Vulkan/TextureArray.cs b/src/Ryujinx.Graphics.Vulkan/TextureArray.cs
index fe834225..31c408d6 100644
--- a/src/Ryujinx.Graphics.Vulkan/TextureArray.cs
+++ b/src/Ryujinx.Graphics.Vulkan/TextureArray.cs
@@ -2,11 +2,10 @@ using Ryujinx.Graphics.GAL;
using Silk.NET.Vulkan;
using System;
using System.Collections.Generic;
-using System.Diagnostics;
namespace Ryujinx.Graphics.Vulkan
{
- class TextureArray : ITextureArray
+ class TextureArray : ResourceArray, ITextureArray
{
private readonly VulkanRenderer _gd;
@@ -25,19 +24,11 @@ namespace Ryujinx.Graphics.Vulkan
private HashSet<TextureStorage> _storages;
- private DescriptorSet[] _cachedDescriptorSets;
-
private int _cachedCommandBufferIndex;
private int _cachedSubmissionCount;
- private ShaderCollection _cachedDscProgram;
- private int _cachedDscSetIndex;
- private int _cachedDscIndex;
-
private readonly bool _isBuffer;
- private int _bindCount;
-
public TextureArray(VulkanRenderer gd, int size, bool isBuffer)
{
_gd = gd;
@@ -113,12 +104,7 @@ namespace Ryujinx.Graphics.Vulkan
{
_cachedCommandBufferIndex = -1;
_storages = null;
- _cachedDescriptorSets = null;
-
- if (_bindCount != 0)
- {
- _gd.PipelineInternal.ForceTextureDirty();
- }
+ SetDirty(_gd);
}
public void QueueWriteToReadBarriers(CommandBufferScoped cbs, PipelineStageFlags stageFlags)
@@ -211,7 +197,7 @@ namespace Ryujinx.Graphics.Vulkan
TextureView dummyTexture,
SamplerHolder dummySampler)
{
- if (_cachedDescriptorSets != null)
+ if (TryGetCachedDescriptorSets(cbs, program, setIndex, out DescriptorSet[] sets))
{
// We still need to ensure the current command buffer holds a reference to all used textures.
@@ -224,12 +210,9 @@ namespace Ryujinx.Graphics.Vulkan
GetBufferViews(cbs);
}
- return _cachedDescriptorSets;
+ return sets;
}
- _cachedDscProgram?.ReleaseManualDescriptorSetCollection(_cachedDscSetIndex, _cachedDscIndex);
- var dsc = program.GetNewManualDescriptorSetCollection(cbs.CommandBufferIndex, setIndex, out _cachedDscIndex).Get(cbs);
-
DescriptorSetTemplate template = program.Templates[setIndex];
DescriptorSetTemplateWriter tu = templateUpdater.Begin(template);
@@ -243,24 +226,9 @@ namespace Ryujinx.Graphics.Vulkan
tu.Push(GetBufferViews(cbs));
}
- var sets = dsc.GetSets();
templateUpdater.Commit(_gd, device, sets[0]);
- _cachedDescriptorSets = sets;
- _cachedDscProgram = program;
- _cachedDscSetIndex = setIndex;
return sets;
}
-
- public void IncrementBindCount()
- {
- _bindCount++;
- }
-
- public void DecrementBindCount()
- {
- int newBindCount = --_bindCount;
- Debug.Assert(newBindCount >= 0);
- }
}
}