aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjhorv <38920027+jhorv@users.noreply.github.com>2024-09-18 22:00:54 -0400
committerGitHub <noreply@github.com>2024-09-18 23:00:54 -0300
commit73f985d27ca0c85f053e8b9494ba83a6c4d3afbf (patch)
tree4577f46b5da7fee66e780419d2c8f406bbae45ad
parentef81658fbd5b2aa23bf7e71b22a636da9a16c67b (diff)
Replace passing by IMemoryOwner<byte> with passing by concrete MemoryOwner<byte> (#7171)1.1.1395
* refactor(perf): pass MemoryOwner<byte> around as itself rather than IMemoryOwner<byte> * fix(perf): get span via MemoryOwner<byte>.Span property instead of through Memory property * fix: incorrect comment change
-rw-r--r--src/Ryujinx.Graphics.GAL/ITexture.cs14
-rw-r--r--src/Ryujinx.Graphics.GAL/Multithreading/Commands/Texture/TextureSetDataCommand.cs6
-rw-r--r--src/Ryujinx.Graphics.GAL/Multithreading/Commands/Texture/TextureSetDataSliceCommand.cs6
-rw-r--r--src/Ryujinx.Graphics.GAL/Multithreading/Commands/Texture/TextureSetDataSliceRegionCommand.cs6
-rw-r--r--src/Ryujinx.Graphics.GAL/Multithreading/Resources/ThreadedTexture.cs8
-rw-r--r--src/Ryujinx.Graphics.Gpu/Engine/Dma/DmaClass.cs4
-rw-r--r--src/Ryujinx.Graphics.Gpu/Image/Texture.cs49
-rw-r--r--src/Ryujinx.Graphics.Gpu/Image/TextureGroup.cs4
-rw-r--r--src/Ryujinx.Graphics.OpenGL/Image/TextureBuffer.cs10
-rw-r--r--src/Ryujinx.Graphics.OpenGL/Image/TextureView.cs18
-rw-r--r--src/Ryujinx.Graphics.Vulkan/TextureBuffer.cs10
-rw-r--r--src/Ryujinx.Graphics.Vulkan/TextureView.cs14
-rw-r--r--src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Parcel.cs2
-rw-r--r--src/Ryujinx.Memory/WritableRegion.cs6
14 files changed, 78 insertions, 79 deletions
diff --git a/src/Ryujinx.Graphics.GAL/ITexture.cs b/src/Ryujinx.Graphics.GAL/ITexture.cs
index 2d9c6b799..2aa4053ff 100644
--- a/src/Ryujinx.Graphics.GAL/ITexture.cs
+++ b/src/Ryujinx.Graphics.GAL/ITexture.cs
@@ -1,4 +1,4 @@
1using System.Buffers; 1using Ryujinx.Common.Memory;
2 2
3namespace Ryujinx.Graphics.GAL 3namespace Ryujinx.Graphics.GAL
4{ 4{
@@ -18,30 +18,30 @@ namespace Ryujinx.Graphics.GAL
18 PinnedSpan<byte> GetData(int layer, int level); 18 PinnedSpan<byte> GetData(int layer, int level);
19 19
20 /// <summary> 20 /// <summary>
21 /// Sets the texture data. The data passed as a <see cref="IMemoryOwner{Byte}" /> will be disposed when 21 /// Sets the texture data. The data passed as a <see cref="MemoryOwner{Byte}" /> will be disposed when
22 /// the operation completes. 22 /// the operation completes.
23 /// </summary> 23 /// </summary>
24 /// <param name="data">Texture data bytes</param> 24 /// <param name="data">Texture data bytes</param>
25 void SetData(IMemoryOwner<byte> data); 25 void SetData(MemoryOwner<byte> data);
26 26
27 /// <summary> 27 /// <summary>
28 /// Sets the texture data. The data passed as a <see cref="IMemoryOwner{Byte}" /> will be disposed when 28 /// Sets the texture data. The data passed as a <see cref="MemoryOwner{Byte}" /> will be disposed when
29 /// the operation completes. 29 /// the operation completes.
30 /// </summary> 30 /// </summary>
31 /// <param name="data">Texture data bytes</param> 31 /// <param name="data">Texture data bytes</param>
32 /// <param name="layer">Target layer</param> 32 /// <param name="layer">Target layer</param>
33 /// <param name="level">Target level</param> 33 /// <param name="level">Target level</param>
34 void SetData(IMemoryOwner<byte> data, int layer, int level); 34 void SetData(MemoryOwner<byte> data, int layer, int level);
35 35
36 /// <summary> 36 /// <summary>
37 /// Sets the texture data. The data passed as a <see cref="IMemoryOwner{Byte}" /> will be disposed when 37 /// Sets the texture data. The data passed as a <see cref="MemoryOwner{Byte}" /> will be disposed when
38 /// the operation completes. 38 /// the operation completes.
39 /// </summary> 39 /// </summary>
40 /// <param name="data">Texture data bytes</param> 40 /// <param name="data">Texture data bytes</param>
41 /// <param name="layer">Target layer</param> 41 /// <param name="layer">Target layer</param>
42 /// <param name="level">Target level</param> 42 /// <param name="level">Target level</param>
43 /// <param name="region">Target sub-region of the texture to update</param> 43 /// <param name="region">Target sub-region of the texture to update</param>
44 void SetData(IMemoryOwner<byte> data, int layer, int level, Rectangle<int> region); 44 void SetData(MemoryOwner<byte> data, int layer, int level, Rectangle<int> region);
45 45
46 void SetStorage(BufferRange buffer); 46 void SetStorage(BufferRange buffer);
47 47
diff --git a/src/Ryujinx.Graphics.GAL/Multithreading/Commands/Texture/TextureSetDataCommand.cs b/src/Ryujinx.Graphics.GAL/Multithreading/Commands/Texture/TextureSetDataCommand.cs
index 3aba004df..4449566a7 100644
--- a/src/Ryujinx.Graphics.GAL/Multithreading/Commands/Texture/TextureSetDataCommand.cs
+++ b/src/Ryujinx.Graphics.GAL/Multithreading/Commands/Texture/TextureSetDataCommand.cs
@@ -1,6 +1,6 @@
1using Ryujinx.Common.Memory;
1using Ryujinx.Graphics.GAL.Multithreading.Model; 2using Ryujinx.Graphics.GAL.Multithreading.Model;
2using Ryujinx.Graphics.GAL.Multithreading.Resources; 3using Ryujinx.Graphics.GAL.Multithreading.Resources;
3using System.Buffers;
4 4
5namespace Ryujinx.Graphics.GAL.Multithreading.Commands.Texture 5namespace Ryujinx.Graphics.GAL.Multithreading.Commands.Texture
6{ 6{
@@ -8,9 +8,9 @@ namespace Ryujinx.Graphics.GAL.Multithreading.Commands.Texture
8 { 8 {
9 public readonly CommandType CommandType => CommandType.TextureSetData; 9 public readonly CommandType CommandType => CommandType.TextureSetData;
10 private TableRef<ThreadedTexture> _texture; 10 private TableRef<ThreadedTexture> _texture;
11 private TableRef<IMemoryOwner<byte>> _data; 11 private TableRef<MemoryOwner<byte>> _data;
12 12
13 public void Set(TableRef<ThreadedTexture> texture, TableRef<IMemoryOwner<byte>> data) 13 public void Set(TableRef<ThreadedTexture> texture, TableRef<MemoryOwner<byte>> data)
14 { 14 {
15 _texture = texture; 15 _texture = texture;
16 _data = data; 16 _data = data;
diff --git a/src/Ryujinx.Graphics.GAL/Multithreading/Commands/Texture/TextureSetDataSliceCommand.cs b/src/Ryujinx.Graphics.GAL/Multithreading/Commands/Texture/TextureSetDataSliceCommand.cs
index 7ad709a75..3619149e9 100644
--- a/src/Ryujinx.Graphics.GAL/Multithreading/Commands/Texture/TextureSetDataSliceCommand.cs
+++ b/src/Ryujinx.Graphics.GAL/Multithreading/Commands/Texture/TextureSetDataSliceCommand.cs
@@ -1,6 +1,6 @@
1using Ryujinx.Common.Memory;
1using Ryujinx.Graphics.GAL.Multithreading.Model; 2using Ryujinx.Graphics.GAL.Multithreading.Model;
2using Ryujinx.Graphics.GAL.Multithreading.Resources; 3using Ryujinx.Graphics.GAL.Multithreading.Resources;
3using System.Buffers;
4 4
5namespace Ryujinx.Graphics.GAL.Multithreading.Commands.Texture 5namespace Ryujinx.Graphics.GAL.Multithreading.Commands.Texture
6{ 6{
@@ -8,11 +8,11 @@ namespace Ryujinx.Graphics.GAL.Multithreading.Commands.Texture
8 { 8 {
9 public readonly CommandType CommandType => CommandType.TextureSetDataSlice; 9 public readonly CommandType CommandType => CommandType.TextureSetDataSlice;
10 private TableRef<ThreadedTexture> _texture; 10 private TableRef<ThreadedTexture> _texture;
11 private TableRef<IMemoryOwner<byte>> _data; 11 private TableRef<MemoryOwner<byte>> _data;
12 private int _layer; 12 private int _layer;
13 private int _level; 13 private int _level;
14 14
15 public void Set(TableRef<ThreadedTexture> texture, TableRef<IMemoryOwner<byte>> data, int layer, int level) 15 public void Set(TableRef<ThreadedTexture> texture, TableRef<MemoryOwner<byte>> data, int layer, int level)
16 { 16 {
17 _texture = texture; 17 _texture = texture;
18 _data = data; 18 _data = data;
diff --git a/src/Ryujinx.Graphics.GAL/Multithreading/Commands/Texture/TextureSetDataSliceRegionCommand.cs b/src/Ryujinx.Graphics.GAL/Multithreading/Commands/Texture/TextureSetDataSliceRegionCommand.cs
index c211931bc..6c6a53636 100644
--- a/src/Ryujinx.Graphics.GAL/Multithreading/Commands/Texture/TextureSetDataSliceRegionCommand.cs
+++ b/src/Ryujinx.Graphics.GAL/Multithreading/Commands/Texture/TextureSetDataSliceRegionCommand.cs
@@ -1,6 +1,6 @@
1using Ryujinx.Common.Memory;
1using Ryujinx.Graphics.GAL.Multithreading.Model; 2using Ryujinx.Graphics.GAL.Multithreading.Model;
2using Ryujinx.Graphics.GAL.Multithreading.Resources; 3using Ryujinx.Graphics.GAL.Multithreading.Resources;
3using System.Buffers;
4 4
5namespace Ryujinx.Graphics.GAL.Multithreading.Commands.Texture 5namespace Ryujinx.Graphics.GAL.Multithreading.Commands.Texture
6{ 6{
@@ -8,12 +8,12 @@ namespace Ryujinx.Graphics.GAL.Multithreading.Commands.Texture
8 { 8 {
9 public readonly CommandType CommandType => CommandType.TextureSetDataSliceRegion; 9 public readonly CommandType CommandType => CommandType.TextureSetDataSliceRegion;
10 private TableRef<ThreadedTexture> _texture; 10 private TableRef<ThreadedTexture> _texture;
11 private TableRef<IMemoryOwner<byte>> _data; 11 private TableRef<MemoryOwner<byte>> _data;
12 private int _layer; 12 private int _layer;
13 private int _level; 13 private int _level;
14 private Rectangle<int> _region; 14 private Rectangle<int> _region;
15 15
16 public void Set(TableRef<ThreadedTexture> texture, TableRef<IMemoryOwner<byte>> data, int layer, int level, Rectangle<int> region) 16 public void Set(TableRef<ThreadedTexture> texture, TableRef<MemoryOwner<byte>> data, int layer, int level, Rectangle<int> region)
17 { 17 {
18 _texture = texture; 18 _texture = texture;
19 _data = data; 19 _data = data;
diff --git a/src/Ryujinx.Graphics.GAL/Multithreading/Resources/ThreadedTexture.cs b/src/Ryujinx.Graphics.GAL/Multithreading/Resources/ThreadedTexture.cs
index 80003b844..fa71d20b3 100644
--- a/src/Ryujinx.Graphics.GAL/Multithreading/Resources/ThreadedTexture.cs
+++ b/src/Ryujinx.Graphics.GAL/Multithreading/Resources/ThreadedTexture.cs
@@ -1,6 +1,6 @@
1using Ryujinx.Common.Memory;
1using Ryujinx.Graphics.GAL.Multithreading.Commands.Texture; 2using Ryujinx.Graphics.GAL.Multithreading.Commands.Texture;
2using Ryujinx.Graphics.GAL.Multithreading.Model; 3using Ryujinx.Graphics.GAL.Multithreading.Model;
3using System.Buffers;
4 4
5namespace Ryujinx.Graphics.GAL.Multithreading.Resources 5namespace Ryujinx.Graphics.GAL.Multithreading.Resources
6{ 6{
@@ -111,21 +111,21 @@ namespace Ryujinx.Graphics.GAL.Multithreading.Resources
111 } 111 }
112 112
113 /// <inheritdoc/> 113 /// <inheritdoc/>
114 public void SetData(IMemoryOwner<byte> data) 114 public void SetData(MemoryOwner<byte> data)
115 { 115 {
116 _renderer.New<TextureSetDataCommand>().Set(Ref(this), Ref(data)); 116 _renderer.New<TextureSetDataCommand>().Set(Ref(this), Ref(data));
117 _renderer.QueueCommand(); 117 _renderer.QueueCommand();
118 } 118 }
119 119
120 /// <inheritdoc/> 120 /// <inheritdoc/>
121 public void SetData(IMemoryOwner<byte> data, int layer, int level) 121 public void SetData(MemoryOwner<byte> data, int layer, int level)
122 { 122 {
123 _renderer.New<TextureSetDataSliceCommand>().Set(Ref(this), Ref(data), layer, level); 123 _renderer.New<TextureSetDataSliceCommand>().Set(Ref(this), Ref(data), layer, level);
124 _renderer.QueueCommand(); 124 _renderer.QueueCommand();
125 } 125 }
126 126
127 /// <inheritdoc/> 127 /// <inheritdoc/>
128 public void SetData(IMemoryOwner<byte> data, int layer, int level, Rectangle<int> region) 128 public void SetData(MemoryOwner<byte> data, int layer, int level, Rectangle<int> region)
129 { 129 {
130 _renderer.New<TextureSetDataSliceRegionCommand>().Set(Ref(this), Ref(data), layer, level, region); 130 _renderer.New<TextureSetDataSliceRegionCommand>().Set(Ref(this), Ref(data), layer, level, region);
131 _renderer.QueueCommand(); 131 _renderer.QueueCommand();
diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Dma/DmaClass.cs b/src/Ryujinx.Graphics.Gpu/Engine/Dma/DmaClass.cs
index f2bfd8eaa..cdeae0040 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Dma/DmaClass.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Dma/DmaClass.cs
@@ -1,10 +1,10 @@
1using Ryujinx.Common; 1using Ryujinx.Common;
2using Ryujinx.Common.Memory;
2using Ryujinx.Graphics.Device; 3using Ryujinx.Graphics.Device;
3using Ryujinx.Graphics.Gpu.Engine.Threed; 4using Ryujinx.Graphics.Gpu.Engine.Threed;
4using Ryujinx.Graphics.Gpu.Memory; 5using Ryujinx.Graphics.Gpu.Memory;
5using Ryujinx.Graphics.Texture; 6using Ryujinx.Graphics.Texture;
6using System; 7using System;
7using System.Buffers;
8using System.Collections.Generic; 8using System.Collections.Generic;
9using System.Runtime.CompilerServices; 9using System.Runtime.CompilerServices;
10using System.Runtime.InteropServices; 10using System.Runtime.InteropServices;
@@ -353,7 +353,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma
353 353
354 if (target != null) 354 if (target != null)
355 { 355 {
356 IMemoryOwner<byte> data; 356 MemoryOwner<byte> data;
357 if (srcLinear) 357 if (srcLinear)
358 { 358 {
359 data = LayoutConverter.ConvertLinearStridedToLinear( 359 data = LayoutConverter.ConvertLinearStridedToLinear(
diff --git a/src/Ryujinx.Graphics.Gpu/Image/Texture.cs b/src/Ryujinx.Graphics.Gpu/Image/Texture.cs
index 3b6c407cc..7ee2e5cf0 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/Texture.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/Texture.cs
@@ -7,7 +7,6 @@ using Ryujinx.Graphics.Texture.Astc;
7using Ryujinx.Memory; 7using Ryujinx.Memory;
8using Ryujinx.Memory.Range; 8using Ryujinx.Memory.Range;
9using System; 9using System;
10using System.Buffers;
11using System.Collections.Generic; 10using System.Collections.Generic;
12using System.Diagnostics; 11using System.Diagnostics;
13using System.Linq; 12using System.Linq;
@@ -662,7 +661,7 @@ namespace Ryujinx.Graphics.Gpu.Image
662 } 661 }
663 } 662 }
664 663
665 IMemoryOwner<byte> result = ConvertToHostCompatibleFormat(data); 664 MemoryOwner<byte> result = ConvertToHostCompatibleFormat(data);
666 665
667 if (ScaleFactor != 1f && AllowScaledSetData()) 666 if (ScaleFactor != 1f && AllowScaledSetData())
668 { 667 {
@@ -685,7 +684,7 @@ namespace Ryujinx.Graphics.Gpu.Image
685 /// Uploads new texture data to the host GPU. 684 /// Uploads new texture data to the host GPU.
686 /// </summary> 685 /// </summary>
687 /// <param name="data">New data</param> 686 /// <param name="data">New data</param>
688 public void SetData(IMemoryOwner<byte> data) 687 public void SetData(MemoryOwner<byte> data)
689 { 688 {
690 BlacklistScale(); 689 BlacklistScale();
691 690
@@ -704,7 +703,7 @@ namespace Ryujinx.Graphics.Gpu.Image
704 /// <param name="data">New data</param> 703 /// <param name="data">New data</param>
705 /// <param name="layer">Target layer</param> 704 /// <param name="layer">Target layer</param>
706 /// <param name="level">Target level</param> 705 /// <param name="level">Target level</param>
707 public void SetData(IMemoryOwner<byte> data, int layer, int level) 706 public void SetData(MemoryOwner<byte> data, int layer, int level)
708 { 707 {
709 BlacklistScale(); 708 BlacklistScale();
710 709
@@ -722,7 +721,7 @@ namespace Ryujinx.Graphics.Gpu.Image
722 /// <param name="layer">Target layer</param> 721 /// <param name="layer">Target layer</param>
723 /// <param name="level">Target level</param> 722 /// <param name="level">Target level</param>
724 /// <param name="region">Target sub-region of the texture to update</param> 723 /// <param name="region">Target sub-region of the texture to update</param>
725 public void SetData(IMemoryOwner<byte> data, int layer, int level, Rectangle<int> region) 724 public void SetData(MemoryOwner<byte> data, int layer, int level, Rectangle<int> region)
726 { 725 {
727 BlacklistScale(); 726 BlacklistScale();
728 727
@@ -740,7 +739,7 @@ namespace Ryujinx.Graphics.Gpu.Image
740 /// <param name="level">Mip level to convert</param> 739 /// <param name="level">Mip level to convert</param>
741 /// <param name="single">True to convert a single slice</param> 740 /// <param name="single">True to convert a single slice</param>
742 /// <returns>Converted data</returns> 741 /// <returns>Converted data</returns>
743 public IMemoryOwner<byte> ConvertToHostCompatibleFormat(ReadOnlySpan<byte> data, int level = 0, bool single = false) 742 public MemoryOwner<byte> ConvertToHostCompatibleFormat(ReadOnlySpan<byte> data, int level = 0, bool single = false)
744 { 743 {
745 int width = Info.Width; 744 int width = Info.Width;
746 int height = Info.Height; 745 int height = Info.Height;
@@ -755,7 +754,7 @@ namespace Ryujinx.Graphics.Gpu.Image
755 754
756 int sliceDepth = single ? 1 : depth; 755 int sliceDepth = single ? 1 : depth;
757 756
758 IMemoryOwner<byte> linear; 757 MemoryOwner<byte> linear;
759 758
760 if (Info.IsLinear) 759 if (Info.IsLinear)
761 { 760 {
@@ -788,7 +787,7 @@ namespace Ryujinx.Graphics.Gpu.Image
788 data); 787 data);
789 } 788 }
790 789
791 IMemoryOwner<byte> result = linear; 790 MemoryOwner<byte> result = linear;
792 791
793 // Handle compressed cases not supported by the host: 792 // Handle compressed cases not supported by the host:
794 // - ASTC is usually not supported on desktop cards. 793 // - ASTC is usually not supported on desktop cards.
@@ -832,19 +831,19 @@ namespace Ryujinx.Graphics.Gpu.Image
832 case Format.Etc2RgbaUnorm: 831 case Format.Etc2RgbaUnorm:
833 using (result) 832 using (result)
834 { 833 {
835 return ETC2Decoder.DecodeRgba(result.Memory.Span, width, height, sliceDepth, levels, layers); 834 return ETC2Decoder.DecodeRgba(result.Span, width, height, sliceDepth, levels, layers);
836 } 835 }
837 case Format.Etc2RgbPtaSrgb: 836 case Format.Etc2RgbPtaSrgb:
838 case Format.Etc2RgbPtaUnorm: 837 case Format.Etc2RgbPtaUnorm:
839 using (result) 838 using (result)
840 { 839 {
841 return ETC2Decoder.DecodePta(result.Memory.Span, width, height, sliceDepth, levels, layers); 840 return ETC2Decoder.DecodePta(result.Span, width, height, sliceDepth, levels, layers);
842 } 841 }
843 case Format.Etc2RgbSrgb: 842 case Format.Etc2RgbSrgb:
844 case Format.Etc2RgbUnorm: 843 case Format.Etc2RgbUnorm:
845 using (result) 844 using (result)
846 { 845 {
847 return ETC2Decoder.DecodeRgb(result.Memory.Span, width, height, sliceDepth, levels, layers); 846 return ETC2Decoder.DecodeRgb(result.Span, width, height, sliceDepth, levels, layers);
848 } 847 }
849 } 848 }
850 } 849 }
@@ -856,43 +855,43 @@ namespace Ryujinx.Graphics.Gpu.Image
856 case Format.Bc1RgbaUnorm: 855 case Format.Bc1RgbaUnorm:
857 using (result) 856 using (result)
858 { 857 {
859 return BCnDecoder.DecodeBC1(result.Memory.Span, width, height, sliceDepth, levels, layers); 858 return BCnDecoder.DecodeBC1(result.Span, width, height, sliceDepth, levels, layers);
860 } 859 }
861 case Format.Bc2Srgb: 860 case Format.Bc2Srgb:
862 case Format.Bc2Unorm: 861 case Format.Bc2Unorm:
863 using (result) 862 using (result)
864 { 863 {
865 return BCnDecoder.DecodeBC2(result.Memory.Span, width, height, sliceDepth, levels, layers); 864 return BCnDecoder.DecodeBC2(result.Span, width, height, sliceDepth, levels, layers);
866 } 865 }
867 case Format.Bc3Srgb: 866 case Format.Bc3Srgb:
868 case Format.Bc3Unorm: 867 case Format.Bc3Unorm:
869 using (result) 868 using (result)
870 { 869 {
871 return BCnDecoder.DecodeBC3(result.Memory.Span, width, height, sliceDepth, levels, layers); 870 return BCnDecoder.DecodeBC3(result.Span, width, height, sliceDepth, levels, layers);
872 } 871 }
873 case Format.Bc4Snorm: 872 case Format.Bc4Snorm:
874 case Format.Bc4Unorm: 873 case Format.Bc4Unorm:
875 using (result) 874 using (result)
876 { 875 {
877 return BCnDecoder.DecodeBC4(result.Memory.Span, width, height, sliceDepth, levels, layers, Format == Format.Bc4Snorm); 876 return BCnDecoder.DecodeBC4(result.Span, width, height, sliceDepth, levels, layers, Format == Format.Bc4Snorm);
878 } 877 }
879 case Format.Bc5Snorm: 878 case Format.Bc5Snorm:
880 case Format.Bc5Unorm: 879 case Format.Bc5Unorm:
881 using (result) 880 using (result)
882 { 881 {
883 return BCnDecoder.DecodeBC5(result.Memory.Span, width, height, sliceDepth, levels, layers, Format == Format.Bc5Snorm); 882 return BCnDecoder.DecodeBC5(result.Span, width, height, sliceDepth, levels, layers, Format == Format.Bc5Snorm);
884 } 883 }
885 case Format.Bc6HSfloat: 884 case Format.Bc6HSfloat:
886 case Format.Bc6HUfloat: 885 case Format.Bc6HUfloat:
887 using (result) 886 using (result)
888 { 887 {
889 return BCnDecoder.DecodeBC6(result.Memory.Span, width, height, sliceDepth, levels, layers, Format == Format.Bc6HSfloat); 888 return BCnDecoder.DecodeBC6(result.Span, width, height, sliceDepth, levels, layers, Format == Format.Bc6HSfloat);
890 } 889 }
891 case Format.Bc7Srgb: 890 case Format.Bc7Srgb:
892 case Format.Bc7Unorm: 891 case Format.Bc7Unorm:
893 using (result) 892 using (result)
894 { 893 {
895 return BCnDecoder.DecodeBC7(result.Memory.Span, width, height, sliceDepth, levels, layers); 894 return BCnDecoder.DecodeBC7(result.Span, width, height, sliceDepth, levels, layers);
896 } 895 }
897 } 896 }
898 } 897 }
@@ -900,7 +899,7 @@ namespace Ryujinx.Graphics.Gpu.Image
900 { 899 {
901 using (result) 900 using (result)
902 { 901 {
903 var converted = PixelConverter.ConvertR4G4ToR4G4B4A4(result.Memory.Span, width); 902 var converted = PixelConverter.ConvertR4G4ToR4G4B4A4(result.Span, width);
904 903
905 if (_context.Capabilities.SupportsR4G4B4A4Format) 904 if (_context.Capabilities.SupportsR4G4B4A4Format)
906 { 905 {
@@ -910,7 +909,7 @@ namespace Ryujinx.Graphics.Gpu.Image
910 { 909 {
911 using (converted) 910 using (converted)
912 { 911 {
913 return PixelConverter.ConvertR4G4B4A4ToR8G8B8A8(converted.Memory.Span, width); 912 return PixelConverter.ConvertR4G4B4A4ToR8G8B8A8(converted.Span, width);
914 } 913 }
915 } 914 }
916 } 915 }
@@ -921,7 +920,7 @@ namespace Ryujinx.Graphics.Gpu.Image
921 { 920 {
922 using (result) 921 using (result)
923 { 922 {
924 return PixelConverter.ConvertR4G4B4A4ToR8G8B8A8(result.Memory.Span, width); 923 return PixelConverter.ConvertR4G4B4A4ToR8G8B8A8(result.Span, width);
925 } 924 }
926 } 925 }
927 } 926 }
@@ -933,24 +932,24 @@ namespace Ryujinx.Graphics.Gpu.Image
933 case Format.R5G6B5Unorm: 932 case Format.R5G6B5Unorm:
934 using (result) 933 using (result)
935 { 934 {
936 return PixelConverter.ConvertR5G6B5ToR8G8B8A8(result.Memory.Span, width); 935 return PixelConverter.ConvertR5G6B5ToR8G8B8A8(result.Span, width);
937 } 936 }
938 case Format.B5G5R5A1Unorm: 937 case Format.B5G5R5A1Unorm:
939 case Format.R5G5B5X1Unorm: 938 case Format.R5G5B5X1Unorm:
940 case Format.R5G5B5A1Unorm: 939 case Format.R5G5B5A1Unorm:
941 using (result) 940 using (result)
942 { 941 {
943 return PixelConverter.ConvertR5G5B5ToR8G8B8A8(result.Memory.Span, width, Format == Format.R5G5B5X1Unorm); 942 return PixelConverter.ConvertR5G5B5ToR8G8B8A8(result.Span, width, Format == Format.R5G5B5X1Unorm);
944 } 943 }
945 case Format.A1B5G5R5Unorm: 944 case Format.A1B5G5R5Unorm:
946 using (result) 945 using (result)
947 { 946 {
948 return PixelConverter.ConvertA1B5G5R5ToR8G8B8A8(result.Memory.Span, width); 947 return PixelConverter.ConvertA1B5G5R5ToR8G8B8A8(result.Span, width);
949 } 948 }
950 case Format.R4G4B4A4Unorm: 949 case Format.R4G4B4A4Unorm:
951 using (result) 950 using (result)
952 { 951 {
953 return PixelConverter.ConvertR4G4B4A4ToR8G8B8A8(result.Memory.Span, width); 952 return PixelConverter.ConvertR4G4B4A4ToR8G8B8A8(result.Span, width);
954 } 953 }
955 } 954 }
956 } 955 }
diff --git a/src/Ryujinx.Graphics.Gpu/Image/TextureGroup.cs b/src/Ryujinx.Graphics.Gpu/Image/TextureGroup.cs
index 06ca2c599..526fc0c24 100644
--- a/src/Ryujinx.Graphics.Gpu/Image/TextureGroup.cs
+++ b/src/Ryujinx.Graphics.Gpu/Image/TextureGroup.cs
@@ -1,3 +1,4 @@
1using Ryujinx.Common.Memory;
1using Ryujinx.Graphics.GAL; 2using Ryujinx.Graphics.GAL;
2using Ryujinx.Graphics.Gpu.Memory; 3using Ryujinx.Graphics.Gpu.Memory;
3using Ryujinx.Graphics.Texture; 4using Ryujinx.Graphics.Texture;
@@ -5,7 +6,6 @@ using Ryujinx.Memory;
5using Ryujinx.Memory.Range; 6using Ryujinx.Memory.Range;
6using Ryujinx.Memory.Tracking; 7using Ryujinx.Memory.Tracking;
7using System; 8using System;
8using System.Buffers;
9using System.Collections.Generic; 9using System.Collections.Generic;
10using System.Runtime.CompilerServices; 10using System.Runtime.CompilerServices;
11 11
@@ -445,7 +445,7 @@ namespace Ryujinx.Graphics.Gpu.Image
445 445
446 ReadOnlySpan<byte> data = dataSpan[(offset - spanBase)..]; 446 ReadOnlySpan<byte> data = dataSpan[(offset - spanBase)..];
447 447
448 IMemoryOwner<byte> result = Storage.ConvertToHostCompatibleFormat(data, info.BaseLevel + level, true); 448 MemoryOwner<byte> result = Storage.ConvertToHostCompatibleFormat(data, info.BaseLevel + level, true);
449 449
450 Storage.SetData(result, info.BaseLayer + layer, info.BaseLevel + level); 450 Storage.SetData(result, info.BaseLayer + layer, info.BaseLevel + level);
451 } 451 }
diff --git a/src/Ryujinx.Graphics.OpenGL/Image/TextureBuffer.cs b/src/Ryujinx.Graphics.OpenGL/Image/TextureBuffer.cs
index a8196541a..22f4c04cd 100644
--- a/src/Ryujinx.Graphics.OpenGL/Image/TextureBuffer.cs
+++ b/src/Ryujinx.Graphics.OpenGL/Image/TextureBuffer.cs
@@ -1,7 +1,7 @@
1using OpenTK.Graphics.OpenGL; 1using OpenTK.Graphics.OpenGL;
2using Ryujinx.Common.Memory;
2using Ryujinx.Graphics.GAL; 3using Ryujinx.Graphics.GAL;
3using System; 4using System;
4using System.Buffers;
5 5
6namespace Ryujinx.Graphics.OpenGL.Image 6namespace Ryujinx.Graphics.OpenGL.Image
7{ 7{
@@ -55,9 +55,9 @@ namespace Ryujinx.Graphics.OpenGL.Image
55 } 55 }
56 56
57 /// <inheritdoc/> 57 /// <inheritdoc/>
58 public void SetData(IMemoryOwner<byte> data) 58 public void SetData(MemoryOwner<byte> data)
59 { 59 {
60 var dataSpan = data.Memory.Span; 60 var dataSpan = data.Span;
61 61
62 Buffer.SetData(_buffer, _bufferOffset, dataSpan[..Math.Min(dataSpan.Length, _bufferSize)]); 62 Buffer.SetData(_buffer, _bufferOffset, dataSpan[..Math.Min(dataSpan.Length, _bufferSize)]);
63 63
@@ -65,13 +65,13 @@ namespace Ryujinx.Graphics.OpenGL.Image
65 } 65 }
66 66
67 /// <inheritdoc/> 67 /// <inheritdoc/>
68 public void SetData(IMemoryOwner<byte> data, int layer, int level) 68 public void SetData(MemoryOwner<byte> data, int layer, int level)
69 { 69 {
70 throw new NotSupportedException(); 70 throw new NotSupportedException();
71 } 71 }
72 72
73 /// <inheritdoc/> 73 /// <inheritdoc/>
74 public void SetData(IMemoryOwner<byte> data, int layer, int level, Rectangle<int> region) 74 public void SetData(MemoryOwner<byte> data, int layer, int level, Rectangle<int> region)
75 { 75 {
76 throw new NotSupportedException(); 76 throw new NotSupportedException();
77 } 77 }
diff --git a/src/Ryujinx.Graphics.OpenGL/Image/TextureView.cs b/src/Ryujinx.Graphics.OpenGL/Image/TextureView.cs
index 946eb755c..b0859c49e 100644
--- a/src/Ryujinx.Graphics.OpenGL/Image/TextureView.cs
+++ b/src/Ryujinx.Graphics.OpenGL/Image/TextureView.cs
@@ -1,8 +1,8 @@
1using OpenTK.Graphics.OpenGL; 1using OpenTK.Graphics.OpenGL;
2using Ryujinx.Common; 2using Ryujinx.Common;
3using Ryujinx.Common.Memory;
3using Ryujinx.Graphics.GAL; 4using Ryujinx.Graphics.GAL;
4using System; 5using System;
5using System.Buffers;
6using System.Diagnostics; 6using System.Diagnostics;
7 7
8namespace Ryujinx.Graphics.OpenGL.Image 8namespace Ryujinx.Graphics.OpenGL.Image
@@ -448,13 +448,13 @@ namespace Ryujinx.Graphics.OpenGL.Image
448 } 448 }
449 } 449 }
450 450
451 public void SetData(IMemoryOwner<byte> data) 451 public void SetData(MemoryOwner<byte> data)
452 { 452 {
453 using (data = EnsureDataFormat(data)) 453 using (data = EnsureDataFormat(data))
454 { 454 {
455 unsafe 455 unsafe
456 { 456 {
457 var dataSpan = data.Memory.Span; 457 var dataSpan = data.Span;
458 fixed (byte* ptr = dataSpan) 458 fixed (byte* ptr = dataSpan)
459 { 459 {
460 ReadFrom((IntPtr)ptr, dataSpan.Length); 460 ReadFrom((IntPtr)ptr, dataSpan.Length);
@@ -463,13 +463,13 @@ namespace Ryujinx.Graphics.OpenGL.Image
463 } 463 }
464 } 464 }
465 465
466 public void SetData(IMemoryOwner<byte> data, int layer, int level) 466 public void SetData(MemoryOwner<byte> data, int layer, int level)
467 { 467 {
468 using (data = EnsureDataFormat(data)) 468 using (data = EnsureDataFormat(data))
469 { 469 {
470 unsafe 470 unsafe
471 { 471 {
472 fixed (byte* ptr = data.Memory.Span) 472 fixed (byte* ptr = data.Span)
473 { 473 {
474 int width = Math.Max(Info.Width >> level, 1); 474 int width = Math.Max(Info.Width >> level, 1);
475 int height = Math.Max(Info.Height >> level, 1); 475 int height = Math.Max(Info.Height >> level, 1);
@@ -480,7 +480,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
480 } 480 }
481 } 481 }
482 482
483 public void SetData(IMemoryOwner<byte> data, int layer, int level, Rectangle<int> region) 483 public void SetData(MemoryOwner<byte> data, int layer, int level, Rectangle<int> region)
484 { 484 {
485 using (data = EnsureDataFormat(data)) 485 using (data = EnsureDataFormat(data))
486 { 486 {
@@ -489,7 +489,7 @@ namespace Ryujinx.Graphics.OpenGL.Image
489 489
490 unsafe 490 unsafe
491 { 491 {
492 fixed (byte* ptr = data.Memory.Span) 492 fixed (byte* ptr = data.Span)
493 { 493 {
494 ReadFrom2D( 494 ReadFrom2D(
495 (IntPtr)ptr, 495 (IntPtr)ptr,
@@ -522,13 +522,13 @@ namespace Ryujinx.Graphics.OpenGL.Image
522 ReadFrom2D(data, layer, level, x, y, width, height, mipSize); 522 ReadFrom2D(data, layer, level, x, y, width, height, mipSize);
523 } 523 }
524 524
525 private IMemoryOwner<byte> EnsureDataFormat(IMemoryOwner<byte> data) 525 private MemoryOwner<byte> EnsureDataFormat(MemoryOwner<byte> data)
526 { 526 {
527 if (Format == Format.S8UintD24Unorm) 527 if (Format == Format.S8UintD24Unorm)
528 { 528 {
529 using (data) 529 using (data)
530 { 530 {
531 return FormatConverter.ConvertS8D24ToD24S8(data.Memory.Span); 531 return FormatConverter.ConvertS8D24ToD24S8(data.Span);
532 } 532 }
533 } 533 }
534 534
diff --git a/src/Ryujinx.Graphics.Vulkan/TextureBuffer.cs b/src/Ryujinx.Graphics.Vulkan/TextureBuffer.cs
index bc1a50961..073eee2ca 100644
--- a/src/Ryujinx.Graphics.Vulkan/TextureBuffer.cs
+++ b/src/Ryujinx.Graphics.Vulkan/TextureBuffer.cs
@@ -1,7 +1,7 @@
1using Ryujinx.Common.Memory;
1using Ryujinx.Graphics.GAL; 2using Ryujinx.Graphics.GAL;
2using Silk.NET.Vulkan; 3using Silk.NET.Vulkan;
3using System; 4using System;
4using System.Buffers;
5using System.Collections.Generic; 5using System.Collections.Generic;
6using Format = Ryujinx.Graphics.GAL.Format; 6using Format = Ryujinx.Graphics.GAL.Format;
7using VkFormat = Silk.NET.Vulkan.Format; 7using VkFormat = Silk.NET.Vulkan.Format;
@@ -84,20 +84,20 @@ namespace Ryujinx.Graphics.Vulkan
84 } 84 }
85 85
86 /// <inheritdoc/> 86 /// <inheritdoc/>
87 public void SetData(IMemoryOwner<byte> data) 87 public void SetData(MemoryOwner<byte> data)
88 { 88 {
89 _gd.SetBufferData(_bufferHandle, _offset, data.Memory.Span); 89 _gd.SetBufferData(_bufferHandle, _offset, data.Span);
90 data.Dispose(); 90 data.Dispose();
91 } 91 }
92 92
93 /// <inheritdoc/> 93 /// <inheritdoc/>
94 public void SetData(IMemoryOwner<byte> data, int layer, int level) 94 public void SetData(MemoryOwner<byte> data, int layer, int level)
95 { 95 {
96 throw new NotSupportedException(); 96 throw new NotSupportedException();
97 } 97 }
98 98
99 /// <inheritdoc/> 99 /// <inheritdoc/>
100 public void SetData(IMemoryOwner<byte> data, int layer, int level, Rectangle<int> region) 100 public void SetData(MemoryOwner<byte> data, int layer, int level, Rectangle<int> region)
101 { 101 {
102 throw new NotSupportedException(); 102 throw new NotSupportedException();
103 } 103 }
diff --git a/src/Ryujinx.Graphics.Vulkan/TextureView.cs b/src/Ryujinx.Graphics.Vulkan/TextureView.cs
index 9b3f46662..b7b936809 100644
--- a/src/Ryujinx.Graphics.Vulkan/TextureView.cs
+++ b/src/Ryujinx.Graphics.Vulkan/TextureView.cs
@@ -1,7 +1,7 @@
1using Ryujinx.Common.Memory;
1using Ryujinx.Graphics.GAL; 2using Ryujinx.Graphics.GAL;
2using Silk.NET.Vulkan; 3using Silk.NET.Vulkan;
3using System; 4using System;
4using System.Buffers;
5using System.Collections.Generic; 5using System.Collections.Generic;
6using System.Linq; 6using System.Linq;
7using System.Threading; 7using System.Threading;
@@ -746,23 +746,23 @@ namespace Ryujinx.Graphics.Vulkan
746 } 746 }
747 747
748 /// <inheritdoc/> 748 /// <inheritdoc/>
749 public void SetData(IMemoryOwner<byte> data) 749 public void SetData(MemoryOwner<byte> data)
750 { 750 {
751 SetData(data.Memory.Span, 0, 0, Info.GetLayers(), Info.Levels, singleSlice: false); 751 SetData(data.Span, 0, 0, Info.GetLayers(), Info.Levels, singleSlice: false);
752 data.Dispose(); 752 data.Dispose();
753 } 753 }
754 754
755 /// <inheritdoc/> 755 /// <inheritdoc/>
756 public void SetData(IMemoryOwner<byte> data, int layer, int level) 756 public void SetData(MemoryOwner<byte> data, int layer, int level)
757 { 757 {
758 SetData(data.Memory.Span, layer, level, 1, 1, singleSlice: true); 758 SetData(data.Span, layer, level, 1, 1, singleSlice: true);
759 data.Dispose(); 759 data.Dispose();
760 } 760 }
761 761
762 /// <inheritdoc/> 762 /// <inheritdoc/>
763 public void SetData(IMemoryOwner<byte> data, int layer, int level, Rectangle<int> region) 763 public void SetData(MemoryOwner<byte> data, int layer, int level, Rectangle<int> region)
764 { 764 {
765 SetData(data.Memory.Span, layer, level, 1, 1, singleSlice: true, region); 765 SetData(data.Span, layer, level, 1, 1, singleSlice: true, region);
766 data.Dispose(); 766 data.Dispose();
767 } 767 }
768 768
diff --git a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Parcel.cs b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Parcel.cs
index 2ca0e1aac..1df280dce 100644
--- a/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Parcel.cs
+++ b/src/Ryujinx.HLE/HOS/Services/SurfaceFlinger/Parcel.cs
@@ -14,7 +14,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
14 { 14 {
15 private readonly MemoryOwner<byte> _rawDataOwner; 15 private readonly MemoryOwner<byte> _rawDataOwner;
16 16
17 private Span<byte> Raw => _rawDataOwner.Memory.Span; 17 private Span<byte> Raw => _rawDataOwner.Span;
18 18
19 private ref ParcelHeader Header => ref MemoryMarshal.Cast<byte, ParcelHeader>(Raw)[0]; 19 private ref ParcelHeader Header => ref MemoryMarshal.Cast<byte, ParcelHeader>(Raw)[0];
20 20
diff --git a/src/Ryujinx.Memory/WritableRegion.cs b/src/Ryujinx.Memory/WritableRegion.cs
index 2c21ef4e8..54facb508 100644
--- a/src/Ryujinx.Memory/WritableRegion.cs
+++ b/src/Ryujinx.Memory/WritableRegion.cs
@@ -1,5 +1,5 @@
1using Ryujinx.Common.Memory;
1using System; 2using System;
2using System.Buffers;
3 3
4namespace Ryujinx.Memory 4namespace Ryujinx.Memory
5{ 5{
@@ -7,7 +7,7 @@ namespace Ryujinx.Memory
7 { 7 {
8 private readonly IWritableBlock _block; 8 private readonly IWritableBlock _block;
9 private readonly ulong _va; 9 private readonly ulong _va;
10 private readonly IMemoryOwner<byte> _memoryOwner; 10 private readonly MemoryOwner<byte> _memoryOwner;
11 private readonly bool _tracked; 11 private readonly bool _tracked;
12 12
13 private bool NeedsWriteback => _block != null; 13 private bool NeedsWriteback => _block != null;
@@ -22,7 +22,7 @@ namespace Ryujinx.Memory
22 Memory = memory; 22 Memory = memory;
23 } 23 }
24 24
25 public WritableRegion(IWritableBlock block, ulong va, IMemoryOwner<byte> memoryOwner, bool tracked = false) 25 public WritableRegion(IWritableBlock block, ulong va, MemoryOwner<byte> memoryOwner, bool tracked = false)
26 : this(block, va, memoryOwner.Memory, tracked) 26 : this(block, va, memoryOwner.Memory, tracked)
27 { 27 {
28 _memoryOwner = memoryOwner; 28 _memoryOwner = memoryOwner;