瀏覽代碼

GAL: Fix sampler leaks on exit (#2353)

Before this, all samplers instance were leaking on exit because the
dispose method was never getting called.

This fix this issue by making TextureBindingsManager disposable and
calling the dispose method in the TextureManager.
Mary 5 年之前
父節點
當前提交
afd68d4c6c
共有 2 個文件被更改,包括 14 次插入2 次删除
  1. 10 1
      Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs
  2. 4 1
      Ryujinx.Graphics.Gpu/Image/TextureManager.cs

+ 10 - 1
Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs

@@ -1,13 +1,14 @@
 using Ryujinx.Graphics.GAL;
 using Ryujinx.Graphics.Gpu.State;
 using Ryujinx.Graphics.Shader;
+using System;
 
 namespace Ryujinx.Graphics.Gpu.Image
 {
     /// <summary>
     /// Texture bindings manager.
     /// </summary>
-    class TextureBindingsManager
+    class TextureBindingsManager : IDisposable
     {
         private const int HandleHigh = 16;
         private const int HandleMask = (1 << HandleHigh) - 1;
@@ -505,5 +506,13 @@ namespace Ryujinx.Graphics.Gpu.Image
         {
             _rebind = true;
         }
+
+        /// <summary>
+        /// Disposes all textures and samplers in the cache.
+        /// </summary>
+        public void Dispose()
+        {
+            _samplerPool?.Dispose();
+        }
     }
 }

+ 4 - 1
Ryujinx.Graphics.Gpu/Image/TextureManager.cs

@@ -1286,7 +1286,7 @@ namespace Ryujinx.Graphics.Gpu.Image
         }
 
         /// <summary>
-        /// Disposes all textures in the cache.
+        /// Disposes all textures and samplers in the cache.
         /// It's an error to use the texture manager after disposal.
         /// </summary>
         public void Dispose()
@@ -1297,6 +1297,9 @@ namespace Ryujinx.Graphics.Gpu.Image
                 {
                     texture.Dispose();
                 }
+
+                _cpBindingsManager.Dispose();
+                _gpBindingsManager.Dispose();
             }
         }
     }