mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2024-12-27 19:13:04 +00:00
c0f2491eae
* 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
74 lines
1.9 KiB
C#
74 lines
1.9 KiB
C#
using Silk.NET.Vulkan;
|
|
using System;
|
|
using System.Diagnostics;
|
|
|
|
namespace Ryujinx.Graphics.Vulkan
|
|
{
|
|
class ResourceArray : IDisposable
|
|
{
|
|
private DescriptorSet[] _cachedDescriptorSets;
|
|
|
|
private ShaderCollection _cachedDscProgram;
|
|
private int _cachedDscSetIndex;
|
|
private int _cachedDscIndex;
|
|
|
|
private int _bindCount;
|
|
|
|
protected void SetDirty(VulkanRenderer gd)
|
|
{
|
|
ReleaseDescriptorSet();
|
|
|
|
if (_bindCount != 0)
|
|
{
|
|
gd.PipelineInternal.ForceTextureDirty();
|
|
}
|
|
}
|
|
|
|
public bool TryGetCachedDescriptorSets(CommandBufferScoped cbs, ShaderCollection program, int setIndex, out DescriptorSet[] sets)
|
|
{
|
|
if (_cachedDescriptorSets != null)
|
|
{
|
|
_cachedDscProgram.UpdateManualDescriptorSetCollectionOwnership(cbs, _cachedDscSetIndex, _cachedDscIndex);
|
|
|
|
sets = _cachedDescriptorSets;
|
|
|
|
return true;
|
|
}
|
|
|
|
var dsc = program.GetNewManualDescriptorSetCollection(cbs, setIndex, out _cachedDscIndex).Get(cbs);
|
|
|
|
sets = dsc.GetSets();
|
|
|
|
_cachedDescriptorSets = sets;
|
|
_cachedDscProgram = program;
|
|
_cachedDscSetIndex = setIndex;
|
|
|
|
return false;
|
|
}
|
|
|
|
public void IncrementBindCount()
|
|
{
|
|
_bindCount++;
|
|
}
|
|
|
|
public void DecrementBindCount()
|
|
{
|
|
int newBindCount = --_bindCount;
|
|
Debug.Assert(newBindCount >= 0);
|
|
}
|
|
|
|
private void ReleaseDescriptorSet()
|
|
{
|
|
if (_cachedDescriptorSets != null)
|
|
{
|
|
_cachedDscProgram.ReleaseManualDescriptorSetCollection(_cachedDscSetIndex, _cachedDscIndex);
|
|
_cachedDescriptorSets = null;
|
|
}
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
ReleaseDescriptorSet();
|
|
}
|
|
}
|
|
}
|