Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
df5be5812f | ||
|
bc392e55df | ||
|
fffc3ed193 | ||
|
7d160e98fd | ||
|
bf96bc84a8 | ||
|
91e4caaa69 |
@@ -228,7 +228,6 @@ namespace ARMeilleure.Instructions
|
|||||||
|
|
||||||
switch (context.Fpcr.GetRoundingMode())
|
switch (context.Fpcr.GetRoundingMode())
|
||||||
{
|
{
|
||||||
default:
|
|
||||||
case FPRoundingMode.ToNearest:
|
case FPRoundingMode.ToNearest:
|
||||||
roundUp = (error > 0.5d || (error == 0.5d && (intMant & 1u) == 1u));
|
roundUp = (error > 0.5d || (error == 0.5d && (intMant & 1u) == 1u));
|
||||||
overflowToInf = true;
|
overflowToInf = true;
|
||||||
@@ -248,6 +247,9 @@ namespace ARMeilleure.Instructions
|
|||||||
roundUp = false;
|
roundUp = false;
|
||||||
overflowToInf = false;
|
overflowToInf = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new ArgumentException($"Invalid rounding mode \"{context.Fpcr.GetRoundingMode()}\".");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (roundUp)
|
if (roundUp)
|
||||||
@@ -412,7 +414,6 @@ namespace ARMeilleure.Instructions
|
|||||||
|
|
||||||
switch (context.Fpcr.GetRoundingMode())
|
switch (context.Fpcr.GetRoundingMode())
|
||||||
{
|
{
|
||||||
default:
|
|
||||||
case FPRoundingMode.ToNearest:
|
case FPRoundingMode.ToNearest:
|
||||||
roundUp = (error > 0.5d || (error == 0.5d && (intMant & 1u) == 1u));
|
roundUp = (error > 0.5d || (error == 0.5d && (intMant & 1u) == 1u));
|
||||||
overflowToInf = true;
|
overflowToInf = true;
|
||||||
@@ -432,6 +433,9 @@ namespace ARMeilleure.Instructions
|
|||||||
roundUp = false;
|
roundUp = false;
|
||||||
overflowToInf = false;
|
overflowToInf = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new ArgumentException($"Invalid rounding mode \"{context.Fpcr.GetRoundingMode()}\".");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (roundUp)
|
if (roundUp)
|
||||||
@@ -585,7 +589,6 @@ namespace ARMeilleure.Instructions
|
|||||||
|
|
||||||
switch (context.Fpcr.GetRoundingMode())
|
switch (context.Fpcr.GetRoundingMode())
|
||||||
{
|
{
|
||||||
default:
|
|
||||||
case FPRoundingMode.ToNearest:
|
case FPRoundingMode.ToNearest:
|
||||||
roundUp = (error > 0.5d || (error == 0.5d && (intMant & 1u) == 1u));
|
roundUp = (error > 0.5d || (error == 0.5d && (intMant & 1u) == 1u));
|
||||||
overflowToInf = true;
|
overflowToInf = true;
|
||||||
@@ -605,6 +608,9 @@ namespace ARMeilleure.Instructions
|
|||||||
roundUp = false;
|
roundUp = false;
|
||||||
overflowToInf = false;
|
overflowToInf = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new ArgumentException($"Invalid rounding mode \"{context.Fpcr.GetRoundingMode()}\".");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (roundUp)
|
if (roundUp)
|
||||||
@@ -1433,11 +1439,24 @@ namespace ARMeilleure.Instructions
|
|||||||
|
|
||||||
switch (fpcr.GetRoundingMode())
|
switch (fpcr.GetRoundingMode())
|
||||||
{
|
{
|
||||||
|
case FPRoundingMode.ToNearest:
|
||||||
|
overflowToInf = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FPRoundingMode.TowardsPlusInfinity:
|
||||||
|
overflowToInf = !sign;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FPRoundingMode.TowardsMinusInfinity:
|
||||||
|
overflowToInf = sign;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FPRoundingMode.TowardsZero:
|
||||||
|
overflowToInf = false;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
case FPRoundingMode.ToNearest: overflowToInf = true; break;
|
throw new ArgumentException($"Invalid rounding mode \"{fpcr.GetRoundingMode()}\".");
|
||||||
case FPRoundingMode.TowardsPlusInfinity: overflowToInf = !sign; break;
|
|
||||||
case FPRoundingMode.TowardsMinusInfinity: overflowToInf = sign; break;
|
|
||||||
case FPRoundingMode.TowardsZero: overflowToInf = false; break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result = overflowToInf ? FPInfinity(sign) : FPMaxNormal(sign);
|
result = overflowToInf ? FPInfinity(sign) : FPMaxNormal(sign);
|
||||||
@@ -2845,11 +2864,24 @@ namespace ARMeilleure.Instructions
|
|||||||
|
|
||||||
switch (fpcr.GetRoundingMode())
|
switch (fpcr.GetRoundingMode())
|
||||||
{
|
{
|
||||||
|
case FPRoundingMode.ToNearest:
|
||||||
|
overflowToInf = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FPRoundingMode.TowardsPlusInfinity:
|
||||||
|
overflowToInf = !sign;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FPRoundingMode.TowardsMinusInfinity:
|
||||||
|
overflowToInf = sign;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FPRoundingMode.TowardsZero:
|
||||||
|
overflowToInf = false;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
case FPRoundingMode.ToNearest: overflowToInf = true; break;
|
throw new ArgumentException($"Invalid rounding mode \"{fpcr.GetRoundingMode()}\".");
|
||||||
case FPRoundingMode.TowardsPlusInfinity: overflowToInf = !sign; break;
|
|
||||||
case FPRoundingMode.TowardsMinusInfinity: overflowToInf = sign; break;
|
|
||||||
case FPRoundingMode.TowardsZero: overflowToInf = false; break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result = overflowToInf ? FPInfinity(sign) : FPMaxNormal(sign);
|
result = overflowToInf ? FPInfinity(sign) : FPMaxNormal(sign);
|
||||||
|
@@ -6,7 +6,7 @@ namespace ARMeilleure.Memory
|
|||||||
{
|
{
|
||||||
IntPtr Pointer { get; }
|
IntPtr Pointer { get; }
|
||||||
|
|
||||||
bool Commit(ulong offset, ulong size);
|
void Commit(ulong offset, ulong size);
|
||||||
|
|
||||||
void MapAsRx(ulong offset, ulong size);
|
void MapAsRx(ulong offset, ulong size);
|
||||||
void MapAsRwx(ulong offset, ulong size);
|
void MapAsRwx(ulong offset, ulong size);
|
||||||
|
@@ -18,7 +18,7 @@ namespace Ryujinx.Audio.Backends.OpenAL
|
|||||||
private readonly ManualResetEvent _pauseEvent;
|
private readonly ManualResetEvent _pauseEvent;
|
||||||
private readonly ConcurrentDictionary<OpenALHardwareDeviceSession, byte> _sessions;
|
private readonly ConcurrentDictionary<OpenALHardwareDeviceSession, byte> _sessions;
|
||||||
private bool _stillRunning;
|
private bool _stillRunning;
|
||||||
private Thread _updaterThread;
|
private readonly Thread _updaterThread;
|
||||||
|
|
||||||
public OpenALHardwareDeviceDriver()
|
public OpenALHardwareDeviceDriver()
|
||||||
{
|
{
|
||||||
@@ -73,7 +73,7 @@ namespace Ryujinx.Audio.Backends.OpenAL
|
|||||||
throw new ArgumentException($"{channelCount}");
|
throw new ArgumentException($"{channelCount}");
|
||||||
}
|
}
|
||||||
|
|
||||||
OpenALHardwareDeviceSession session = new OpenALHardwareDeviceSession(this, memoryManager, sampleFormat, sampleRate, channelCount, volume);
|
OpenALHardwareDeviceSession session = new(this, memoryManager, sampleFormat, sampleRate, channelCount, volume);
|
||||||
|
|
||||||
_sessions.TryAdd(session, 0);
|
_sessions.TryAdd(session, 0);
|
||||||
|
|
||||||
@@ -123,6 +123,7 @@ namespace Ryujinx.Audio.Backends.OpenAL
|
|||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
Dispose(true);
|
Dispose(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -10,11 +10,11 @@ namespace Ryujinx.Audio.Backends.OpenAL
|
|||||||
{
|
{
|
||||||
class OpenALHardwareDeviceSession : HardwareDeviceSessionOutputBase
|
class OpenALHardwareDeviceSession : HardwareDeviceSessionOutputBase
|
||||||
{
|
{
|
||||||
private OpenALHardwareDeviceDriver _driver;
|
private readonly OpenALHardwareDeviceDriver _driver;
|
||||||
private int _sourceId;
|
private readonly int _sourceId;
|
||||||
private ALFormat _targetFormat;
|
private readonly ALFormat _targetFormat;
|
||||||
private bool _isActive;
|
private bool _isActive;
|
||||||
private Queue<OpenALAudioBuffer> _queuedBuffers;
|
private readonly Queue<OpenALAudioBuffer> _queuedBuffers;
|
||||||
private ulong _playedSampleCount;
|
private ulong _playedSampleCount;
|
||||||
|
|
||||||
private readonly object _lock = new();
|
private readonly object _lock = new();
|
||||||
@@ -32,23 +32,17 @@ namespace Ryujinx.Audio.Backends.OpenAL
|
|||||||
|
|
||||||
private ALFormat GetALFormat()
|
private ALFormat GetALFormat()
|
||||||
{
|
{
|
||||||
switch (RequestedSampleFormat)
|
return RequestedSampleFormat switch
|
||||||
{
|
{
|
||||||
case SampleFormat.PcmInt16:
|
SampleFormat.PcmInt16 => RequestedChannelCount switch
|
||||||
switch (RequestedChannelCount)
|
|
||||||
{
|
{
|
||||||
case 1:
|
1 => ALFormat.Mono16,
|
||||||
return ALFormat.Mono16;
|
2 => ALFormat.Stereo16,
|
||||||
case 2:
|
6 => ALFormat.Multi51Chn16Ext,
|
||||||
return ALFormat.Stereo16;
|
_ => throw new NotImplementedException($"Unsupported channel config {RequestedChannelCount}"),
|
||||||
case 6:
|
},
|
||||||
return ALFormat.Multi51Chn16Ext;
|
_ => throw new NotImplementedException($"Unsupported sample format {RequestedSampleFormat}"),
|
||||||
default:
|
};
|
||||||
throw new NotImplementedException($"Unsupported channel config {RequestedChannelCount}");
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
throw new NotImplementedException($"Unsupported sample format {RequestedSampleFormat}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void PrepareToClose() { }
|
public override void PrepareToClose() { }
|
||||||
@@ -69,7 +63,7 @@ namespace Ryujinx.Audio.Backends.OpenAL
|
|||||||
{
|
{
|
||||||
lock (_lock)
|
lock (_lock)
|
||||||
{
|
{
|
||||||
OpenALAudioBuffer driverBuffer = new OpenALAudioBuffer
|
OpenALAudioBuffer driverBuffer = new()
|
||||||
{
|
{
|
||||||
DriverIdentifier = buffer.DataPointer,
|
DriverIdentifier = buffer.DataPointer,
|
||||||
BufferId = AL.GenBuffer(),
|
BufferId = AL.GenBuffer(),
|
||||||
|
@@ -164,7 +164,7 @@ namespace Ryujinx.Audio
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The default coefficients used for standard 5.1 surround to stereo downmixing.
|
/// The default coefficients used for standard 5.1 surround to stereo downmixing.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static float[] DefaultSurroundToStereoCoefficients = new float[4]
|
public static readonly float[] DefaultSurroundToStereoCoefficients = new float[4]
|
||||||
{
|
{
|
||||||
1.0f,
|
1.0f,
|
||||||
0.707f,
|
0.707f,
|
||||||
|
@@ -15,7 +15,7 @@ namespace Ryujinx.Cpu.Jit
|
|||||||
_impl = new MemoryBlock(size, flags);
|
_impl = new MemoryBlock(size, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Commit(ulong offset, ulong size) => _impl.Commit(offset, size);
|
public void Commit(ulong offset, ulong size) => _impl.Commit(offset, size);
|
||||||
public void MapAsRx(ulong offset, ulong size) => _impl.Reprotect(offset, size, MemoryPermission.ReadAndExecute);
|
public void MapAsRx(ulong offset, ulong size) => _impl.Reprotect(offset, size, MemoryPermission.ReadAndExecute);
|
||||||
public void MapAsRwx(ulong offset, ulong size) => _impl.Reprotect(offset, size, MemoryPermission.ReadWriteExecute);
|
public void MapAsRwx(ulong offset, ulong size) => _impl.Reprotect(offset, size, MemoryPermission.ReadWriteExecute);
|
||||||
|
|
||||||
|
@@ -140,7 +140,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
|||||||
|
|
||||||
FunctionMatch.RunPass(program);
|
FunctionMatch.RunPass(program);
|
||||||
|
|
||||||
foreach (DecodedFunction function in program.OrderBy(x => x.Address).Where(x => !x.IsCompilerGenerated))
|
foreach (DecodedFunction function in program.Where(x => !x.IsCompilerGenerated).OrderBy(x => x.Address))
|
||||||
{
|
{
|
||||||
program.AddFunctionAndSetId(function);
|
program.AddFunctionAndSetId(function);
|
||||||
}
|
}
|
||||||
|
@@ -15,7 +15,7 @@ namespace Ryujinx.HLE.HOS.Diagnostics.Demangler.Ast
|
|||||||
|
|
||||||
writer.Write(Params);
|
writer.Write(Params);
|
||||||
|
|
||||||
if (Params.EndsWith(">"))
|
if (Params.EndsWith('>'))
|
||||||
{
|
{
|
||||||
writer.Write(" ");
|
writer.Write(" ");
|
||||||
}
|
}
|
||||||
|
@@ -39,7 +39,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Sfdnsres.Proxy
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ignore comments and empty lines
|
// Ignore comments and empty lines
|
||||||
if (line.StartsWith("#") || line.Trim().Length == 0)
|
if (line.StartsWith('#') || line.Trim().Length == 0)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|
||||||
namespace Ryujinx.Memory
|
namespace Ryujinx.Memory
|
||||||
@@ -101,12 +100,12 @@ namespace Ryujinx.Memory
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="offset">Starting offset of the range to be committed</param>
|
/// <param name="offset">Starting offset of the range to be committed</param>
|
||||||
/// <param name="size">Size of the range to be committed</param>
|
/// <param name="size">Size of the range to be committed</param>
|
||||||
/// <returns>True if the operation was successful, false otherwise</returns>
|
/// <exception cref="SystemException">Throw when the operation was not successful</exception>
|
||||||
/// <exception cref="ObjectDisposedException">Throw when the memory block has already been disposed</exception>
|
/// <exception cref="ObjectDisposedException">Throw when the memory block has already been disposed</exception>
|
||||||
/// <exception cref="InvalidMemoryRegionException">Throw when either <paramref name="offset"/> or <paramref name="size"/> are out of range</exception>
|
/// <exception cref="InvalidMemoryRegionException">Throw when either <paramref name="offset"/> or <paramref name="size"/> are out of range</exception>
|
||||||
public bool Commit(ulong offset, ulong size)
|
public void Commit(ulong offset, ulong size)
|
||||||
{
|
{
|
||||||
return MemoryManagement.Commit(GetPointerInternal(offset, size), size, _forJit);
|
MemoryManagement.Commit(GetPointerInternal(offset, size), size, _forJit);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -115,12 +114,12 @@ namespace Ryujinx.Memory
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="offset">Starting offset of the range to be decommitted</param>
|
/// <param name="offset">Starting offset of the range to be decommitted</param>
|
||||||
/// <param name="size">Size of the range to be decommitted</param>
|
/// <param name="size">Size of the range to be decommitted</param>
|
||||||
/// <returns>True if the operation was successful, false otherwise</returns>
|
/// <exception cref="SystemException">Throw when the operation was not successful</exception>
|
||||||
/// <exception cref="ObjectDisposedException">Throw when the memory block has already been disposed</exception>
|
/// <exception cref="ObjectDisposedException">Throw when the memory block has already been disposed</exception>
|
||||||
/// <exception cref="InvalidMemoryRegionException">Throw when either <paramref name="offset"/> or <paramref name="size"/> are out of range</exception>
|
/// <exception cref="InvalidMemoryRegionException">Throw when either <paramref name="offset"/> or <paramref name="size"/> are out of range</exception>
|
||||||
public bool Decommit(ulong offset, ulong size)
|
public void Decommit(ulong offset, ulong size)
|
||||||
{
|
{
|
||||||
return MemoryManagement.Decommit(GetPointerInternal(offset, size), size);
|
MemoryManagement.Decommit(GetPointerInternal(offset, size), size);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@@ -36,15 +36,15 @@ namespace Ryujinx.Memory
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool Commit(IntPtr address, ulong size, bool forJit)
|
public static void Commit(IntPtr address, ulong size, bool forJit)
|
||||||
{
|
{
|
||||||
if (OperatingSystem.IsWindows())
|
if (OperatingSystem.IsWindows())
|
||||||
{
|
{
|
||||||
return MemoryManagementWindows.Commit(address, (IntPtr)size);
|
MemoryManagementWindows.Commit(address, (IntPtr)size);
|
||||||
}
|
}
|
||||||
else if (OperatingSystem.IsLinux() || OperatingSystem.IsMacOS())
|
else if (OperatingSystem.IsLinux() || OperatingSystem.IsMacOS())
|
||||||
{
|
{
|
||||||
return MemoryManagementUnix.Commit(address, size, forJit);
|
MemoryManagementUnix.Commit(address, size, forJit);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -52,15 +52,15 @@ namespace Ryujinx.Memory
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool Decommit(IntPtr address, ulong size)
|
public static void Decommit(IntPtr address, ulong size)
|
||||||
{
|
{
|
||||||
if (OperatingSystem.IsWindows())
|
if (OperatingSystem.IsWindows())
|
||||||
{
|
{
|
||||||
return MemoryManagementWindows.Decommit(address, (IntPtr)size);
|
MemoryManagementWindows.Decommit(address, (IntPtr)size);
|
||||||
}
|
}
|
||||||
else if (OperatingSystem.IsLinux() || OperatingSystem.IsMacOS())
|
else if (OperatingSystem.IsLinux() || OperatingSystem.IsMacOS())
|
||||||
{
|
{
|
||||||
return MemoryManagementUnix.Decommit(address, size);
|
MemoryManagementUnix.Decommit(address, size);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@@ -2,8 +2,6 @@
|
|||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Runtime.Versioning;
|
using System.Runtime.Versioning;
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
using static Ryujinx.Memory.MemoryManagerUnixHelper;
|
using static Ryujinx.Memory.MemoryManagerUnixHelper;
|
||||||
|
|
||||||
namespace Ryujinx.Memory
|
namespace Ryujinx.Memory
|
||||||
@@ -12,7 +10,7 @@ namespace Ryujinx.Memory
|
|||||||
[SupportedOSPlatform("macos")]
|
[SupportedOSPlatform("macos")]
|
||||||
static class MemoryManagementUnix
|
static class MemoryManagementUnix
|
||||||
{
|
{
|
||||||
private static readonly ConcurrentDictionary<IntPtr, ulong> _allocations = new ConcurrentDictionary<IntPtr, ulong>();
|
private static readonly ConcurrentDictionary<IntPtr, ulong> _allocations = new();
|
||||||
|
|
||||||
public static IntPtr Allocate(ulong size, bool forJit)
|
public static IntPtr Allocate(ulong size, bool forJit)
|
||||||
{
|
{
|
||||||
@@ -68,7 +66,7 @@ namespace Ryujinx.Memory
|
|||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool Commit(IntPtr address, ulong size, bool forJit)
|
public static void Commit(IntPtr address, ulong size, bool forJit)
|
||||||
{
|
{
|
||||||
MmapProts prot = MmapProts.PROT_READ | MmapProts.PROT_WRITE;
|
MmapProts prot = MmapProts.PROT_READ | MmapProts.PROT_WRITE;
|
||||||
|
|
||||||
@@ -81,11 +79,9 @@ namespace Ryujinx.Memory
|
|||||||
{
|
{
|
||||||
throw new SystemException(Marshal.GetLastPInvokeErrorMessage());
|
throw new SystemException(Marshal.GetLastPInvokeErrorMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool Decommit(IntPtr address, ulong size)
|
public static void Decommit(IntPtr address, ulong size)
|
||||||
{
|
{
|
||||||
// Must be writable for madvise to work properly.
|
// Must be writable for madvise to work properly.
|
||||||
if (mprotect(address, size, MmapProts.PROT_READ | MmapProts.PROT_WRITE) != 0)
|
if (mprotect(address, size, MmapProts.PROT_READ | MmapProts.PROT_WRITE) != 0)
|
||||||
@@ -102,8 +98,6 @@ namespace Ryujinx.Memory
|
|||||||
{
|
{
|
||||||
throw new SystemException(Marshal.GetLastPInvokeErrorMessage());
|
throw new SystemException(Marshal.GetLastPInvokeErrorMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool Reprotect(IntPtr address, ulong size, MemoryPermission permission)
|
public static bool Reprotect(IntPtr address, ulong size, MemoryPermission permission)
|
||||||
@@ -146,7 +140,7 @@ namespace Ryujinx.Memory
|
|||||||
|
|
||||||
if (OperatingSystem.IsMacOS())
|
if (OperatingSystem.IsMacOS())
|
||||||
{
|
{
|
||||||
byte[] memName = Encoding.ASCII.GetBytes("Ryujinx-XXXXXX");
|
byte[] memName = "Ryujinx-XXXXXX"u8.ToArray();
|
||||||
|
|
||||||
fixed (byte* pMemName = memName)
|
fixed (byte* pMemName = memName)
|
||||||
{
|
{
|
||||||
@@ -164,7 +158,7 @@ namespace Ryujinx.Memory
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
byte[] fileName = Encoding.ASCII.GetBytes("/dev/shm/Ryujinx-XXXXXX");
|
byte[] fileName = "/dev/shm/Ryujinx-XXXXXX"u8.ToArray();
|
||||||
|
|
||||||
fixed (byte* pFileName = fileName)
|
fixed (byte* pFileName = fileName)
|
||||||
{
|
{
|
||||||
|
@@ -10,7 +10,7 @@ namespace Ryujinx.Memory
|
|||||||
{
|
{
|
||||||
public const int PageSize = 0x1000;
|
public const int PageSize = 0x1000;
|
||||||
|
|
||||||
private static readonly PlaceholderManager _placeholders = new PlaceholderManager();
|
private static readonly PlaceholderManager _placeholders = new();
|
||||||
|
|
||||||
public static IntPtr Allocate(IntPtr size)
|
public static IntPtr Allocate(IntPtr size)
|
||||||
{
|
{
|
||||||
@@ -55,14 +55,20 @@ namespace Ryujinx.Memory
|
|||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool Commit(IntPtr location, IntPtr size)
|
public static void Commit(IntPtr location, IntPtr size)
|
||||||
{
|
{
|
||||||
return WindowsApi.VirtualAlloc(location, size, AllocationType.Commit, MemoryProtection.ReadWrite) != IntPtr.Zero;
|
if (WindowsApi.VirtualAlloc(location, size, AllocationType.Commit, MemoryProtection.ReadWrite) == IntPtr.Zero)
|
||||||
|
{
|
||||||
|
throw new SystemException(Marshal.GetLastPInvokeErrorMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool Decommit(IntPtr location, IntPtr size)
|
public static void Decommit(IntPtr location, IntPtr size)
|
||||||
{
|
{
|
||||||
return WindowsApi.VirtualFree(location, size, AllocationType.Decommit);
|
if (!WindowsApi.VirtualFree(location, size, AllocationType.Decommit))
|
||||||
|
{
|
||||||
|
throw new SystemException(Marshal.GetLastPInvokeErrorMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void MapView(IntPtr sharedMemory, ulong srcOffset, IntPtr location, IntPtr size, MemoryBlock owner)
|
public static void MapView(IntPtr sharedMemory, ulong srcOffset, IntPtr location, IntPtr size, MemoryBlock owner)
|
||||||
|
Reference in New Issue
Block a user