From 59fdaa744b20f91928ee3fcaf5fabfcb7b409451 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Tue, 31 Dec 2019 19:09:49 -0300 Subject: GPU resource disposal --- Ryujinx.Graphics.Gpu/Memory/BufferManager.cs | 12 ++++++++++++ Ryujinx.Graphics.Gpu/Memory/RangeList.cs | 15 +++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) (limited to 'Ryujinx.Graphics.Gpu/Memory') diff --git a/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs b/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs index 1d27bc7e..44542349 100644 --- a/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs +++ b/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs @@ -683,5 +683,17 @@ namespace Ryujinx.Graphics.Gpu.Memory buffer.SynchronizeMemory(address, size); } } + + /// + /// Disposes all buffers in the cache. + /// It's an error to use the buffer manager after disposal. + /// + public void Dispose() + { + foreach (Buffer buffer in _buffers) + { + buffer.Dispose(); + } + } } } \ No newline at end of file diff --git a/Ryujinx.Graphics.Gpu/Memory/RangeList.cs b/Ryujinx.Graphics.Gpu/Memory/RangeList.cs index 1d185e21..75be1cf2 100644 --- a/Ryujinx.Graphics.Gpu/Memory/RangeList.cs +++ b/Ryujinx.Graphics.Gpu/Memory/RangeList.cs @@ -1,4 +1,5 @@ using System; +using System.Collections; using System.Collections.Generic; namespace Ryujinx.Graphics.Gpu.Memory @@ -7,11 +8,11 @@ namespace Ryujinx.Graphics.Gpu.Memory /// List of GPU resources with data on guest memory. /// /// Type of the GPU resource - class RangeList where T : IRange + class RangeList : IEnumerable where T : IRange { private const int ArrayGrowthSize = 32; - private List _items; + private readonly List _items; /// /// Creates a new GPU resources list. @@ -320,5 +321,15 @@ namespace Ryujinx.Graphics.Gpu.Memory return ~left; } + + public IEnumerator GetEnumerator() + { + return _items.GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return _items.GetEnumerator(); + } } } \ No newline at end of file -- cgit v1.2.3