diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureBindingsArrayCache.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureBindingsArrayCache.cs index 85a5d686b..d2274e761 100644 --- a/src/Ryujinx.Graphics.Gpu/Image/TextureBindingsArrayCache.cs +++ b/src/Ryujinx.Graphics.Gpu/Image/TextureBindingsArrayCache.cs @@ -175,7 +175,6 @@ namespace Ryujinx.Graphics.Gpu.Image private int[] _cachedTextureBuffer; private int[] _cachedSamplerBuffer; - private int _lastBinding; private int _lastSequenceNumber; /// @@ -194,7 +193,6 @@ namespace Ryujinx.Graphics.Gpu.Image _texturePool = texturePool; _samplerPool = samplerPool; - _lastBinding = -1; _lastSequenceNumber = -1; } @@ -249,18 +247,6 @@ namespace Ryujinx.Graphics.Gpu.Image SamplerIds.Clear(); } - /// - /// Invalidates the cached binding number if it equals to . - /// - /// Binding number to match - public void ClearBindingIfEqual(int binding) - { - if (_lastBinding == binding) - { - _lastBinding = -1; - } - } - /// /// Updates the cached constant buffer data. /// @@ -290,35 +276,6 @@ namespace Ryujinx.Graphics.Gpu.Image return true; } - /// - /// Updates the cached binding number. - /// - /// Cache instance - /// New binding number - public void SetNewBinding(TextureBindingsArrayCache parent, int newBinding) - { - parent.ClearBindingsIfEqual(newBinding); - _lastBinding = newBinding; - } - - /// - /// Checks if the binding number changed since the last call to this method. - /// - /// Cache instance - /// New binding number - /// True if the binding changed, false otherwise - public bool BindingChanged(TextureBindingsArrayCache parent, int newBinding) - { - if (_lastBinding != newBinding) - { - SetNewBinding(parent, newBinding); - - return true; - } - - return false; - } - /// /// Checks if the cached texture or sampler pool has been modified since the last call to this method. /// @@ -520,7 +477,11 @@ namespace Ryujinx.Graphics.Gpu.Image { entry.SynchronizeMemory(isStore); - if (entry.BindingChanged(this, bindingInfo.Binding)) + if (isImage) + { + _context.Renderer.Pipeline.SetImageArray(stage, bindingInfo.Binding, entry.ImageArray); + } + else { _context.Renderer.Pipeline.SetTextureArray(stage, bindingInfo.Binding, entry.TextureArray); } @@ -545,7 +506,11 @@ namespace Ryujinx.Graphics.Gpu.Image { entry.SynchronizeMemory(isStore); - if (entry.BindingChanged(this, bindingInfo.Binding)) + if (isImage) + { + _context.Renderer.Pipeline.SetImageArray(stage, bindingInfo.Binding, entry.ImageArray); + } + else { _context.Renderer.Pipeline.SetTextureArray(stage, bindingInfo.Binding, entry.TextureArray); } @@ -652,8 +617,6 @@ namespace Ryujinx.Graphics.Gpu.Image } } - entry.SetNewBinding(this, bindingInfo.Binding); - if (isImage) { entry.ImageArray.SetFormats(0, formats); @@ -743,17 +706,5 @@ namespace Ryujinx.Graphics.Gpu.Image _lruCache.Remove(toRemove); } } - - /// - /// Clears all cached bindings that are equal to . - /// - /// Binding number to clear - private void ClearBindingsIfEqual(int binding) - { - foreach (CacheEntry entry in _cache.Values) - { - entry.ClearBindingIfEqual(binding); - } - } } } diff --git a/src/Ryujinx.Graphics.Vulkan/DescriptorSetUpdater.cs b/src/Ryujinx.Graphics.Vulkan/DescriptorSetUpdater.cs index 8ea479715..0933aec3d 100644 --- a/src/Ryujinx.Graphics.Vulkan/DescriptorSetUpdater.cs +++ b/src/Ryujinx.Graphics.Vulkan/DescriptorSetUpdater.cs @@ -499,10 +499,13 @@ namespace Ryujinx.Graphics.Vulkan Array.Resize(ref _textureArrayRefs, binding + ArrayGrowthSize); } - _textureArrayRefs[binding] = new ArrayRef(stage, array as TextureArray); - _textureArrayRefs[binding].Array?.QueueWriteToReadBarriers(cbs, stage.ConvertToPipelineStageFlags()); + if (_textureArrayRefs[binding].Stage != stage || _textureArrayRefs[binding].Array != array) + { + _textureArrayRefs[binding] = new ArrayRef(stage, array as TextureArray); + _textureArrayRefs[binding].Array?.QueueWriteToReadBarriers(cbs, stage.ConvertToPipelineStageFlags()); - SignalDirty(DirtyFlags.Texture); + SignalDirty(DirtyFlags.Texture); + } } public void SetImageArray(CommandBufferScoped cbs, ShaderStage stage, int binding, IImageArray array) @@ -512,10 +515,13 @@ namespace Ryujinx.Graphics.Vulkan Array.Resize(ref _imageArrayRefs, binding + ArrayGrowthSize); } - _imageArrayRefs[binding] = new ArrayRef(stage, array as ImageArray); - _imageArrayRefs[binding].Array?.QueueWriteToReadBarriers(cbs, stage.ConvertToPipelineStageFlags()); + if (_imageArrayRefs[binding].Stage != stage || _imageArrayRefs[binding].Array != array) + { + _imageArrayRefs[binding] = new ArrayRef(stage, array as ImageArray); + _imageArrayRefs[binding].Array?.QueueWriteToReadBarriers(cbs, stage.ConvertToPipelineStageFlags()); - SignalDirty(DirtyFlags.Image); + SignalDirty(DirtyFlags.Image); + } } public void SetUniformBuffers(CommandBuffer commandBuffer, ReadOnlySpan buffers)