From 99ffc061d30c92f224c6b839290e181b6179893d Mon Sep 17 00:00:00 2001 From: riperiperi Date: Fri, 17 Jun 2022 17:09:14 +0100 Subject: Optimize Texture Binding and Shader Specialization Checks (#3399) * Changes 1 * Changes 2 * Better ModifiedSequence handling This should handle PreciseEvents properly, and simplifies a few things. * Minor changes, remove debug log * Handle stage.Info being null Hopefully fixes Catherine crash * Fix shader specialization fast texture lookup * Fix some things. * Address Feedback Part 1 * Make method static. --- Ryujinx.Graphics.Gpu/Image/SamplerPool.cs | 35 +++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'Ryujinx.Graphics.Gpu/Image/SamplerPool.cs') diff --git a/Ryujinx.Graphics.Gpu/Image/SamplerPool.cs b/Ryujinx.Graphics.Gpu/Image/SamplerPool.cs index e205ec48..e95800ad 100644 --- a/Ryujinx.Graphics.Gpu/Image/SamplerPool.cs +++ b/Ryujinx.Graphics.Gpu/Image/SamplerPool.cs @@ -48,6 +48,8 @@ namespace Ryujinx.Graphics.Gpu.Image Items[i] = null; } } + + UpdateModifiedSequence(); } SequenceNumber = Context.SequenceNumber; @@ -71,6 +73,39 @@ namespace Ryujinx.Graphics.Gpu.Image return sampler; } + /// + /// Checks if the pool was modified, and returns the last sequence number where a modification was detected. + /// + /// A number that increments each time a modification is detected + public int CheckModified() + { + if (SequenceNumber != Context.SequenceNumber) + { + SequenceNumber = Context.SequenceNumber; + + if (_forcedAnisotropy != GraphicsConfig.MaxAnisotropy) + { + _forcedAnisotropy = GraphicsConfig.MaxAnisotropy; + + for (int i = 0; i < Items.Length; i++) + { + if (Items[i] != null) + { + Items[i].Dispose(); + + Items[i] = null; + } + } + + UpdateModifiedSequence(); + } + + SynchronizeMemory(); + } + + return ModifiedSequenceNumber; + } + /// /// Implementation of the sampler pool range invalidation. /// -- cgit v1.2.3