Archived
1
0
Fork 0
forked from Mirror/Ryujinx

replace ByteMemoryPool usage in Ryujinx.HLE (#6953)

This commit is contained in:
jhorv 2024-07-15 18:21:53 -04:00 committed by GitHub
parent 595e514f18
commit a6dbb2ad2b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 7 additions and 8 deletions

View file

@ -474,9 +474,9 @@ namespace Ryujinx.HLE.HOS.Services
{ {
const int MessageSize = 0x100; const int MessageSize = 0x100;
using IMemoryOwner<byte> reqDataOwner = ByteMemoryPool.Rent(MessageSize); using SpanOwner<byte> reqDataOwner = SpanOwner<byte>.Rent(MessageSize);
Span<byte> reqDataSpan = reqDataOwner.Memory.Span; Span<byte> reqDataSpan = reqDataOwner.Span;
_selfProcess.CpuMemory.Read(_selfThread.TlsAddress, reqDataSpan); _selfProcess.CpuMemory.Read(_selfThread.TlsAddress, reqDataSpan);

View file

@ -85,9 +85,9 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
ReadOnlySpan<byte> inputParcel = context.Memory.GetSpan(dataPos, (int)dataSize); ReadOnlySpan<byte> inputParcel = context.Memory.GetSpan(dataPos, (int)dataSize);
using IMemoryOwner<byte> outputParcelOwner = ByteMemoryPool.RentCleared(replySize); using SpanOwner<byte> outputParcelOwner = SpanOwner<byte>.RentCleared(checked((int)replySize));
Span<byte> outputParcel = outputParcelOwner.Memory.Span; Span<byte> outputParcel = outputParcelOwner.Span;
ResultCode result = OnTransact(binderId, code, flags, inputParcel, outputParcel); ResultCode result = OnTransact(binderId, code, flags, inputParcel, outputParcel);

View file

@ -3,7 +3,6 @@ using Ryujinx.Common.Memory;
using Ryujinx.Common.Utilities; using Ryujinx.Common.Utilities;
using Ryujinx.HLE.HOS.Services.SurfaceFlinger.Types; using Ryujinx.HLE.HOS.Services.SurfaceFlinger.Types;
using System; using System;
using System.Buffers;
using System.Diagnostics; using System.Diagnostics;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
@ -13,7 +12,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
{ {
sealed class Parcel : IDisposable sealed class Parcel : IDisposable
{ {
private readonly IMemoryOwner<byte> _rawDataOwner; private readonly MemoryOwner<byte> _rawDataOwner;
private Span<byte> Raw => _rawDataOwner.Memory.Span; private Span<byte> Raw => _rawDataOwner.Memory.Span;
@ -30,7 +29,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
public Parcel(ReadOnlySpan<byte> data) public Parcel(ReadOnlySpan<byte> data)
{ {
_rawDataOwner = ByteMemoryPool.RentCopy(data); _rawDataOwner = MemoryOwner<byte>.RentCopy(data);
_payloadPosition = 0; _payloadPosition = 0;
_objectPosition = 0; _objectPosition = 0;
@ -40,7 +39,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
{ {
uint headerSize = (uint)Unsafe.SizeOf<ParcelHeader>(); uint headerSize = (uint)Unsafe.SizeOf<ParcelHeader>();
_rawDataOwner = ByteMemoryPool.RentCleared(BitUtils.AlignUp<uint>(headerSize + payloadSize + objectsSize, 4)); _rawDataOwner = MemoryOwner<byte>.RentCleared(checked((int)BitUtils.AlignUp<uint>(headerSize + payloadSize + objectsSize, 4)));
Header.PayloadSize = payloadSize; Header.PayloadSize = payloadSize;
Header.ObjectsSize = objectsSize; Header.ObjectsSize = objectsSize;