diff options
| author | jhorv <38920027+jhorv@users.noreply.github.com> | 2024-08-03 14:50:53 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-03 19:50:53 +0100 |
| commit | 59ddb26628fc2ab94f1c274a254c76b3e368f8b6 (patch) | |
| tree | 57a91040e67a4afb1aec5350704990592efe1acc /src/Ryujinx.Graphics.Texture/ETC2Decoder.cs | |
| parent | 83fda10f6ef68950de395b5f9f6ab0bf58adced4 (diff) | |
replace ByteMemoryPool usage in Ryujinx.Graphics (#7129)
* chore: replace `ByteMemoryPool` usage with `MemoryOwner<byte>`
* refactor: `PixelConverter.ConvertR4G4ToR4G4B4A4()` - rename old `outputSpan` to `outputSpanUInt16`, reuse same output `Span<byte>` as newly-freed name `outputSpan`
* eliminate temporary buffer allocations
* chore, perf: use MemoryOwner<byte> instead of IMemoryOwner<byte>
Diffstat (limited to 'src/Ryujinx.Graphics.Texture/ETC2Decoder.cs')
| -rw-r--r-- | src/Ryujinx.Graphics.Texture/ETC2Decoder.cs | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/Ryujinx.Graphics.Texture/ETC2Decoder.cs b/src/Ryujinx.Graphics.Texture/ETC2Decoder.cs index 52801ff4..49e7154c 100644 --- a/src/Ryujinx.Graphics.Texture/ETC2Decoder.cs +++ b/src/Ryujinx.Graphics.Texture/ETC2Decoder.cs @@ -1,7 +1,6 @@ using Ryujinx.Common; using Ryujinx.Common.Memory; using System; -using System.Buffers; using System.Buffers.Binary; using System.Runtime.InteropServices; @@ -51,15 +50,15 @@ namespace Ryujinx.Graphics.Texture new int[] { -3, -5, -7, -9, 2, 4, 6, 8 }, }; - public static IMemoryOwner<byte> DecodeRgb(ReadOnlySpan<byte> data, int width, int height, int depth, int levels, int layers) + public static MemoryOwner<byte> DecodeRgb(ReadOnlySpan<byte> data, int width, int height, int depth, int levels, int layers) { ReadOnlySpan<ulong> dataUlong = MemoryMarshal.Cast<byte, ulong>(data); int inputOffset = 0; - IMemoryOwner<byte> output = ByteMemoryPool.Rent(CalculateOutputSize(width, height, depth, levels, layers)); + MemoryOwner<byte> output = MemoryOwner<byte>.Rent(CalculateOutputSize(width, height, depth, levels, layers)); - Span<uint> outputUint = MemoryMarshal.Cast<byte, uint>(output.Memory.Span); + Span<uint> outputUint = MemoryMarshal.Cast<byte, uint>(output.Span); Span<uint> tile = stackalloc uint[BlockWidth * BlockHeight]; int imageBaseOOffs = 0; @@ -113,15 +112,15 @@ namespace Ryujinx.Graphics.Texture return output; } - public static IMemoryOwner<byte> DecodePta(ReadOnlySpan<byte> data, int width, int height, int depth, int levels, int layers) + public static MemoryOwner<byte> DecodePta(ReadOnlySpan<byte> data, int width, int height, int depth, int levels, int layers) { ReadOnlySpan<ulong> dataUlong = MemoryMarshal.Cast<byte, ulong>(data); int inputOffset = 0; - IMemoryOwner<byte> output = ByteMemoryPool.Rent(CalculateOutputSize(width, height, depth, levels, layers)); + MemoryOwner<byte> output = MemoryOwner<byte>.Rent(CalculateOutputSize(width, height, depth, levels, layers)); - Span<uint> outputUint = MemoryMarshal.Cast<byte, uint>(output.Memory.Span); + Span<uint> outputUint = MemoryMarshal.Cast<byte, uint>(output.Span); Span<uint> tile = stackalloc uint[BlockWidth * BlockHeight]; int imageBaseOOffs = 0; @@ -170,15 +169,15 @@ namespace Ryujinx.Graphics.Texture return output; } - public static IMemoryOwner<byte> DecodeRgba(ReadOnlySpan<byte> data, int width, int height, int depth, int levels, int layers) + public static MemoryOwner<byte> DecodeRgba(ReadOnlySpan<byte> data, int width, int height, int depth, int levels, int layers) { ReadOnlySpan<ulong> dataUlong = MemoryMarshal.Cast<byte, ulong>(data); int inputOffset = 0; - IMemoryOwner<byte> output = ByteMemoryPool.Rent(CalculateOutputSize(width, height, depth, levels, layers)); + MemoryOwner<byte> output = MemoryOwner<byte>.Rent(CalculateOutputSize(width, height, depth, levels, layers)); - Span<uint> outputUint = MemoryMarshal.Cast<byte, uint>(output.Memory.Span); + Span<uint> outputUint = MemoryMarshal.Cast<byte, uint>(output.Span); Span<uint> tile = stackalloc uint[BlockWidth * BlockHeight]; int imageBaseOOffs = 0; |
