mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2026-07-02 17:19:05 +00:00
Memory Changes part 2 (ryubing/ryujinx!123)
See merge request ryubing/ryujinx!123
This commit is contained in:
@@ -94,6 +94,8 @@ namespace Ryujinx.HLE.HOS.Services.Hid
|
||||
primaryIndex = PlayerIndex.Unknown;
|
||||
configuredCount = 0;
|
||||
|
||||
Span<NpadState> nPadsSpan = _device.Hid.SharedMemory.Npads.AsSpan();
|
||||
|
||||
for (int i = 0; i < MaxControllers; ++i)
|
||||
{
|
||||
ControllerType npad = _configuredTypes[i];
|
||||
@@ -103,7 +105,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid
|
||||
continue;
|
||||
}
|
||||
|
||||
ControllerType currentType = (ControllerType)_device.Hid.SharedMemory.Npads[i].InternalState.StyleSet;
|
||||
ControllerType currentType = (ControllerType)nPadsSpan[i].InternalState.StyleSet;
|
||||
|
||||
if (currentType != ControllerType.None && (npad & acceptedTypes) != 0 && _supportedPlayers[i])
|
||||
{
|
||||
|
||||
@@ -23,12 +23,14 @@ namespace Ryujinx.HLE.HOS.Services.Hid
|
||||
{
|
||||
newState.TouchesCount = points.Length;
|
||||
|
||||
int pointsLength = Math.Min(points.Length, newState.Touches.Length);
|
||||
Span<TouchState> touchesSpan = newState.Touches.AsSpan();
|
||||
|
||||
int pointsLength = Math.Min(points.Length, touchesSpan.Length);
|
||||
|
||||
for (int i = 0; i < pointsLength; ++i)
|
||||
{
|
||||
TouchPoint pi = points[i];
|
||||
newState.Touches[i] = new TouchState
|
||||
touchesSpan[i] = new TouchState
|
||||
{
|
||||
DeltaTime = newState.SamplingNumber,
|
||||
Attribute = pi.Attribute,
|
||||
|
||||
@@ -49,12 +49,14 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.Common
|
||||
}
|
||||
|
||||
ulong index = ReadCurrentIndex();
|
||||
|
||||
Span<AtomicStorage<T>> storageSpan = _storage.AsSpan();
|
||||
|
||||
while (true)
|
||||
{
|
||||
int inputEntryIndex = (int)((index + MaxEntries + 1 - countAvailaible) % MaxEntries);
|
||||
|
||||
ref AtomicStorage<T> result = ref _storage[inputEntryIndex];
|
||||
ref AtomicStorage<T> result = ref storageSpan[inputEntryIndex];
|
||||
|
||||
ulong samplingNumber0 = result.ReadSamplingNumberAtomic();
|
||||
ulong samplingNumber1 = result.ReadSamplingNumberAtomic();
|
||||
@@ -91,15 +93,17 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.Common
|
||||
ulong index = ReadCurrentIndex();
|
||||
|
||||
AtomicStorage<T>[] result = new AtomicStorage<T>[countAvailaible];
|
||||
|
||||
Span<AtomicStorage<T>> storageSpan = _storage.AsSpan();
|
||||
|
||||
for (ulong i = 0; i < countAvailaible; i++)
|
||||
{
|
||||
int inputEntryIndex = (int)((index + MaxEntries + 1 - countAvailaible + i) % MaxEntries);
|
||||
int outputEntryIndex = (int)(countAvailaible - i - 1);
|
||||
|
||||
ulong samplingNumber0 = _storage[inputEntryIndex].ReadSamplingNumberAtomic();
|
||||
result[outputEntryIndex] = _storage[inputEntryIndex];
|
||||
ulong samplingNumber1 = _storage[inputEntryIndex].ReadSamplingNumberAtomic();
|
||||
ulong samplingNumber0 = storageSpan[inputEntryIndex].ReadSamplingNumberAtomic();
|
||||
result[outputEntryIndex] = storageSpan[inputEntryIndex];
|
||||
ulong samplingNumber1 = storageSpan[inputEntryIndex].ReadSamplingNumberAtomic();
|
||||
|
||||
if (samplingNumber0 != samplingNumber1 && (i > 0 && (result[outputEntryIndex].SamplingNumber - result[outputEntryIndex].SamplingNumber) != 1))
|
||||
{
|
||||
|
||||
@@ -6,6 +6,7 @@ using Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.Keyboard;
|
||||
using Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.Mouse;
|
||||
using Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.Npad;
|
||||
using Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.TouchScreen;
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory
|
||||
@@ -61,10 +62,12 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory
|
||||
Mouse = RingLifo<MouseState>.Create(),
|
||||
Keyboard = RingLifo<KeyboardState>.Create(),
|
||||
};
|
||||
|
||||
Span<NpadState> npadsSpan = result.Npads.AsSpan();
|
||||
|
||||
for (int i = 0; i < result.Npads.Length; i++)
|
||||
for (int i = 0; i < npadsSpan.Length; i++)
|
||||
{
|
||||
result.Npads[i] = NpadState.Create();
|
||||
npadsSpan[i] = NpadState.Create();
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user