From 268c9aecf8e9181bb7114cf1dd826f00b2237714 Mon Sep 17 00:00:00 2001 From: jhorv <38920027+jhorv@users.noreply.github.com> Date: Sun, 14 Apr 2024 16:06:14 -0400 Subject: Texture loading: reduce memory allocations (#6623) * rebase * add methods Ryyjinx.Common EmbeddedResources and SteamUtils * GAL changes - change SetData() methods and ThreadedTexture commands to use IMemoryOwner instead of SpanOrArray * Ryujinx.Graphics.Texture: change texture conversion methods to return IMemoryOwner and allocate from ByteMemoryPool * Ryujinx.Graphics.OpenGL: update ITexture and Texture-like types with SetData() methods to take IMemoryOwner instead of SpanOrArray * Ryujinx.Graphics.Vulkan: update ITexture and Texture-like types with SetData() methods to take IMemoryOwner instead of SpanOrArray * Ryujinx.Graphics.Gpu: update ITexture and Texture-like types with SetData() methods to take IMemoryOwner instead of SpanOrArray * Remove now-unused SpanOrArray * post-rebase cleanup * PixelConverter: remove unsafe modifier on safe methods, and remove one unnecessary cast * use ByteMemoryPool.Rent() in GetWritableRegion() impls * fix formatting, rename `ReadRentedMemory()` to `ReadFileToRentedMemory()`` * Texture.ConvertToHostCompatibleFormat(): dispose of `result` in Astc decode branch --- src/Ryujinx.Graphics.GAL/ITexture.cs | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) (limited to 'src/Ryujinx.Graphics.GAL/ITexture.cs') diff --git a/src/Ryujinx.Graphics.GAL/ITexture.cs b/src/Ryujinx.Graphics.GAL/ITexture.cs index 5a4623a6..2d9c6b79 100644 --- a/src/Ryujinx.Graphics.GAL/ITexture.cs +++ b/src/Ryujinx.Graphics.GAL/ITexture.cs @@ -1,4 +1,4 @@ -using Ryujinx.Common.Memory; +using System.Buffers; namespace Ryujinx.Graphics.GAL { @@ -17,10 +17,34 @@ namespace Ryujinx.Graphics.GAL PinnedSpan GetData(); PinnedSpan GetData(int layer, int level); - void SetData(SpanOrArray data); - void SetData(SpanOrArray data, int layer, int level); - void SetData(SpanOrArray data, int layer, int level, Rectangle region); + /// + /// Sets the texture data. The data passed as a will be disposed when + /// the operation completes. + /// + /// Texture data bytes + void SetData(IMemoryOwner data); + + /// + /// Sets the texture data. The data passed as a will be disposed when + /// the operation completes. + /// + /// Texture data bytes + /// Target layer + /// Target level + void SetData(IMemoryOwner data, int layer, int level); + + /// + /// Sets the texture data. The data passed as a will be disposed when + /// the operation completes. + /// + /// Texture data bytes + /// Target layer + /// Target level + /// Target sub-region of the texture to update + void SetData(IMemoryOwner data, int layer, int level, Rectangle region); + void SetStorage(BufferRange buffer); + void Release(); } } -- cgit v1.2.3