Revert "misc: chore: Remove redundant code"

This reverts commit 05a88ccc94.
This commit is contained in:
KeatonTheBot 2025-03-15 20:00:22 -05:00
parent 7960ea643f
commit efd5a104b6
109 changed files with 412 additions and 271 deletions

View file

@ -146,9 +146,9 @@ namespace ARMeilleure.CodeGen.RegisterAllocators
} }
} }
private Queue<Operation> _fillQueue; private Queue<Operation> _fillQueue = null;
private Queue<Operation> _spillQueue; private Queue<Operation> _spillQueue = null;
private ParallelCopy _parallelCopy; private ParallelCopy _parallelCopy = null;
public bool HasCopy { get; private set; } public bool HasCopy { get; private set; }

View file

@ -1,5 +1,9 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace ARMeilleure.Instructions namespace ARMeilleure.Instructions
{ {

View file

@ -1,7 +1,7 @@
namespace ARMeilleure namespace ARMeilleure
{ {
using Arm64HardwareCapabilities = CodeGen.Arm64.HardwareCapabilities; using Arm64HardwareCapabilities = ARMeilleure.CodeGen.Arm64.HardwareCapabilities;
using X86HardwareCapabilities = CodeGen.X86.HardwareCapabilities; using X86HardwareCapabilities = ARMeilleure.CodeGen.X86.HardwareCapabilities;
public static class Optimizations public static class Optimizations
{ {

View file

@ -24,7 +24,7 @@ namespace ARMeilleure.State
public long Tpidr2El0; public long Tpidr2El0;
} }
private static NativeCtxStorage _dummyStorage; private static NativeCtxStorage _dummyStorage = new();
private readonly IJitMemoryBlock _block; private readonly IJitMemoryBlock _block;

View file

@ -54,7 +54,7 @@ namespace ARMeilleure.Translation
public bool HasPtc { get; } public bool HasPtc { get; }
public Aarch32Mode Mode { get; } public Aarch32Mode Mode { get; }
private int _ifThenBlockStateIndex; private int _ifThenBlockStateIndex = 0;
private Condition[] _ifThenBlockState = []; private Condition[] _ifThenBlockState = [];
public bool IsInIfThenBlock => _ifThenBlockStateIndex < _ifThenBlockState.Length; public bool IsInIfThenBlock => _ifThenBlockStateIndex < _ifThenBlockState.Length;
public Condition CurrentIfThenBlockCond => _ifThenBlockState[_ifThenBlockStateIndex]; public Condition CurrentIfThenBlockCond => _ifThenBlockState[_ifThenBlockStateIndex];

View file

@ -18,7 +18,7 @@ namespace ARMeilleure.Translation.Cache
UnwindInfo = unwindInfo; UnwindInfo = unwindInfo;
} }
public int CompareTo(CacheEntry other) public int CompareTo([AllowNull] CacheEntry other)
{ {
return Offset.CompareTo(other.Offset); return Offset.CompareTo(other.Offset);
} }

View file

@ -17,7 +17,7 @@ namespace ARMeilleure.Translation.Cache
Size = size; Size = size;
} }
public int CompareTo(MemoryBlock other) public int CompareTo([AllowNull] MemoryBlock other)
{ {
return Offset.CompareTo(other.Offset); return Offset.CompareTo(other.Offset);
} }

View file

@ -32,7 +32,7 @@ namespace ARMeilleure.Translation.Cache
private static bool _initialized; private static bool _initialized;
private static readonly List<ReservedRegion> _jitRegions = []; private static readonly List<ReservedRegion> _jitRegions = [];
private static int _activeRegionIndex; private static int _activeRegionIndex = 0;
[SupportedOSPlatform("windows")] [SupportedOSPlatform("windows")]
[LibraryImport("kernel32.dll", SetLastError = true)] [LibraryImport("kernel32.dll", SetLastError = true)]

View file

@ -79,7 +79,7 @@ namespace ARMeilleure.Translation.Cache
_unwindInfo = (UnwindInfo*)(workBufferPtr + _sizeOfRuntimeFunction); _unwindInfo = (UnwindInfo*)(workBufferPtr + _sizeOfRuntimeFunction);
_getRuntimeFunctionCallback = FunctionTableHandler; _getRuntimeFunctionCallback = new GetRuntimeFunctionCallback(FunctionTableHandler);
result = RtlInstallFunctionTableCallback( result = RtlInstallFunctionTableCallback(
codeCachePtr | 3, codeCachePtr | 3,
@ -102,7 +102,10 @@ namespace ARMeilleure.Translation.Cache
bool result; bool result;
result = RtlDeleteFunctionTable(codeCachePtr | 3); unsafe
{
result = RtlDeleteFunctionTable(codeCachePtr | 3);
}
if (!result) if (!result)
{ {

View file

@ -63,7 +63,7 @@ namespace ARMeilleure.Translation
private static readonly SortedList<string, DelegateInfo> _delegates; private static readonly SortedList<string, DelegateInfo> _delegates;
static Delegates() unsafe static Delegates()
{ {
_delegates = new SortedList<string, DelegateInfo>(); _delegates = new SortedList<string, DelegateInfo>();

View file

@ -14,8 +14,8 @@ namespace ARMeilleure.Translation
private const bool Black = true; private const bool Black = true;
private const bool Red = false; private const bool Red = false;
private IntervalTreeNode<TK, TV> _root; private IntervalTreeNode<TK, TV> _root = null;
private int _count; private int _count = 0;
public int Count => _count; public int Count => _count;
@ -709,9 +709,9 @@ namespace ARMeilleure.Translation
class IntervalTreeNode<TK, TV> class IntervalTreeNode<TK, TV>
{ {
public bool Color = true; public bool Color = true;
public IntervalTreeNode<TK, TV> Left; public IntervalTreeNode<TK, TV> Left = null;
public IntervalTreeNode<TK, TV> Right; public IntervalTreeNode<TK, TV> Right = null;
public IntervalTreeNode<TK, TV> Parent; public IntervalTreeNode<TK, TV> Parent = null;
/// <summary> /// <summary>
/// The start of the range. /// The start of the range.

View file

@ -8,7 +8,7 @@ namespace Ryujinx.Audio.Backends.SoundIo.Native
public class SoundIoOutStreamContext : IDisposable public class SoundIoOutStreamContext : IDisposable
{ {
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate void WriteCallbackDelegate(IntPtr ctx, int frameCountMin, int frameCountMax); private unsafe delegate void WriteCallbackDelegate(IntPtr ctx, int frameCountMin, int frameCountMax);
private IntPtr _context; private IntPtr _context;
private IntPtr _nameStored; private IntPtr _nameStored;

View file

@ -127,21 +127,24 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
{ {
get get
{ {
if (Unsafe.IsNullRef(ref _v2)) unsafe
{ {
if (Unsafe.IsNullRef(ref _v1)) if (Unsafe.IsNullRef(ref _v2))
{ {
return new SplitterDestination(); if (Unsafe.IsNullRef(ref _v1))
{
return new SplitterDestination();
}
else
{
return new SplitterDestination(ref _v1.Next);
}
} }
else else
{ {
return new SplitterDestination(ref _v1.Next); return new SplitterDestination(ref _v2.Next);
} }
} }
else
{
return new SplitterDestination(ref _v2.Next);
}
} }
} }

View file

@ -100,7 +100,7 @@ namespace Ryujinx.Common.Memory
return obj is ArrayPtr<T> other && Equals(other); return obj is ArrayPtr<T> other && Equals(other);
} }
public readonly bool Equals(ArrayPtr<T> other) public readonly bool Equals([AllowNull] ArrayPtr<T> other)
{ {
return _ptr == other._ptr && Length == other.Length; return _ptr == other._ptr && Length == other.Length;
} }

View file

@ -45,7 +45,7 @@ namespace Ryujinx.Common.Memory
return obj is Ptr<T> other && Equals(other); return obj is Ptr<T> other && Equals(other);
} }
public readonly bool Equals(Ptr<T> other) public readonly bool Equals([AllowNull] Ptr<T> other)
{ {
return _ptr == other._ptr; return _ptr == other._ptr;
} }

View file

@ -90,8 +90,8 @@ namespace Ryujinx.Common.Utilities
private BinaryReader _binaryReader; private BinaryReader _binaryReader;
private long _offsetB, _dataSizeB, _cartSizeB, _fileSizeB; private long _offsetB, _dataSizeB, _cartSizeB, _fileSizeB;
private bool _fileOK = true; private bool _fileOK = true;
private bool _freeSpaceChecked; private bool _freeSpaceChecked = false;
private bool _freeSpaceValid; private bool _freeSpaceValid = false;
public enum OperationOutcome public enum OperationOutcome
{ {
@ -191,7 +191,7 @@ namespace Ryujinx.Common.Utilities
if (timedSw.Elapsed.TotalSeconds > 0) if (timedSw.Elapsed.TotalSeconds > 0)
{ {
Log?.Write(LogType.Info, $"Checked at {readSizeB / (double)BytesInAMegabyte / timedSw.Elapsed.TotalSeconds:N} Mb/sec"); Log?.Write(LogType.Info, $"Checked at {readSizeB / (double)XCIFileTrimmer.BytesInAMegabyte / timedSw.Elapsed.TotalSeconds:N} Mb/sec");
} }
if (freeSpaceValid) if (freeSpaceValid)
@ -219,7 +219,7 @@ namespace Ryujinx.Common.Utilities
private bool CheckPadding(long readSizeB, CancellationToken? cancelToken = null) private bool CheckPadding(long readSizeB, CancellationToken? cancelToken = null)
{ {
long maxReads = readSizeB / BufferSize; long maxReads = readSizeB / XCIFileTrimmer.BufferSize;
long read = 0; long read = 0;
var buffer = new byte[BufferSize]; var buffer = new byte[BufferSize];
@ -230,12 +230,12 @@ namespace Ryujinx.Common.Utilities
return false; return false;
} }
int bytes = _fileStream.Read(buffer, 0, BufferSize); int bytes = _fileStream.Read(buffer, 0, XCIFileTrimmer.BufferSize);
if (bytes == 0) if (bytes == 0)
break; break;
Log?.Progress(read, maxReads, "Verifying file can be trimmed", false); Log?.Progress(read, maxReads, "Verifying file can be trimmed", false);
if (buffer.Take(bytes).AsParallel().Any(b => b != PaddingByte)) if (buffer.Take(bytes).AsParallel().Any(b => b != XCIFileTrimmer.PaddingByte))
{ {
Log?.Write(LogType.Warn, "Free space is NOT valid"); Log?.Write(LogType.Warn, "Free space is NOT valid");
return false; return false;
@ -380,7 +380,7 @@ namespace Ryujinx.Common.Utilities
if (timedSw.Elapsed.TotalSeconds > 0) if (timedSw.Elapsed.TotalSeconds > 0)
{ {
Log?.Write(LogType.Info, $"Wrote at {bytesToWriteB / (double)BytesInAMegabyte / timedSw.Elapsed.TotalSeconds:N} Mb/sec"); Log?.Write(LogType.Info, $"Wrote at {bytesToWriteB / (double)XCIFileTrimmer.BytesInAMegabyte / timedSw.Elapsed.TotalSeconds:N} Mb/sec");
} }
if (cancelToken.HasValue && cancelToken.Value.IsCancellationRequested) if (cancelToken.HasValue && cancelToken.Value.IsCancellationRequested)
@ -408,13 +408,13 @@ namespace Ryujinx.Common.Utilities
private void WritePadding(FileStream outfileStream, long bytesToWriteB, CancellationToken? cancelToken = null) private void WritePadding(FileStream outfileStream, long bytesToWriteB, CancellationToken? cancelToken = null)
{ {
long bytesLeftToWriteB = bytesToWriteB; long bytesLeftToWriteB = bytesToWriteB;
long writes = bytesLeftToWriteB / BufferSize; long writes = bytesLeftToWriteB / XCIFileTrimmer.BufferSize;
int write = 0; int write = 0;
try try
{ {
var buffer = new byte[BufferSize]; var buffer = new byte[BufferSize];
Array.Fill<byte>(buffer, PaddingByte); Array.Fill<byte>(buffer, XCIFileTrimmer.PaddingByte);
while (bytesLeftToWriteB > 0) while (bytesLeftToWriteB > 0)
{ {
@ -423,7 +423,7 @@ namespace Ryujinx.Common.Utilities
return; return;
} }
long bytesToWrite = Math.Min(BufferSize, bytesLeftToWriteB); long bytesToWrite = Math.Min(XCIFileTrimmer.BufferSize, bytesLeftToWriteB);
#if !XCI_TRIMMER_READ_ONLY_MODE #if !XCI_TRIMMER_READ_ONLY_MODE
outfileStream.Write(buffer, 0, (int)bytesToWrite); outfileStream.Write(buffer, 0, (int)bytesToWrite);
@ -504,12 +504,12 @@ namespace Ryujinx.Common.Utilities
} }
// Setup offset // Setup offset
_offsetB = (long)(assumeKeyArea ? CartKeyAreaSize : 0); _offsetB = (long)(assumeKeyArea ? XCIFileTrimmer.CartKeyAreaSize : 0);
// Check header // Check header
Pos = _offsetB + HeaderFilePos; Pos = _offsetB + XCIFileTrimmer.HeaderFilePos;
string head = System.Text.Encoding.ASCII.GetString(_binaryReader.ReadBytes(4)); string head = System.Text.Encoding.ASCII.GetString(_binaryReader.ReadBytes(4));
if (head != HeaderMagicValue) if (head != XCIFileTrimmer.HeaderMagicValue)
{ {
if (!assumeKeyArea) if (!assumeKeyArea)
{ {
@ -524,17 +524,17 @@ namespace Ryujinx.Common.Utilities
} }
// Read Cart Size // Read Cart Size
Pos = _offsetB + CartSizeFilePos; Pos = _offsetB + XCIFileTrimmer.CartSizeFilePos;
byte cartSizeId = _binaryReader.ReadByte(); byte cartSizeId = _binaryReader.ReadByte();
if (!_cartSizesGB.TryGetValue(cartSizeId, out long cartSizeNGB)) if (!_cartSizesGB.TryGetValue(cartSizeId, out long cartSizeNGB))
{ {
Log?.Write(LogType.Error, $"The source file doesn't look like an XCI file as the Cartridge Size is incorrect (0x{cartSizeId:X2})"); Log?.Write(LogType.Error, $"The source file doesn't look like an XCI file as the Cartridge Size is incorrect (0x{cartSizeId:X2})");
return false; return false;
} }
_cartSizeB = cartSizeNGB * CartSizeMBinFormattedGB * BytesInAMegabyte; _cartSizeB = cartSizeNGB * XCIFileTrimmer.CartSizeMBinFormattedGB * XCIFileTrimmer.BytesInAMegabyte;
// Read data size // Read data size
Pos = _offsetB + DataSizeFilePos; Pos = _offsetB + XCIFileTrimmer.DataSizeFilePos;
long records = (long)BitConverter.ToUInt32(_binaryReader.ReadBytes(4), 0); long records = (long)BitConverter.ToUInt32(_binaryReader.ReadBytes(4), 0);
_dataSizeB = RecordsToByte(records); _dataSizeB = RecordsToByte(records);

View file

@ -4,8 +4,7 @@ using System.Runtime.Versioning;
namespace Ryujinx.Cpu.AppleHv namespace Ryujinx.Cpu.AppleHv
{ {
[SupportedOSPlatform("macos")] [SupportedOSPlatform("macos")]
class HvMemoryBlockAllocator(HvIpaAllocator ipaAllocator, ulong blockAlignment) class HvMemoryBlockAllocator : PrivateMemoryAllocatorImpl<HvMemoryBlockAllocator.Block>
: PrivateMemoryAllocatorImpl<HvMemoryBlockAllocator.Block>(blockAlignment, MemoryAllocationFlags.None)
{ {
public class Block : PrivateMemoryAllocator.Block public class Block : PrivateMemoryAllocator.Block
{ {
@ -37,6 +36,13 @@ namespace Ryujinx.Cpu.AppleHv
} }
} }
private readonly HvIpaAllocator _ipaAllocator;
public HvMemoryBlockAllocator(HvIpaAllocator ipaAllocator, ulong blockAlignment) : base(blockAlignment, MemoryAllocationFlags.None)
{
_ipaAllocator = ipaAllocator;
}
public HvMemoryBlockAllocation Allocate(ulong size, ulong alignment) public HvMemoryBlockAllocation Allocate(ulong size, ulong alignment)
{ {
var allocation = Allocate(size, alignment, CreateBlock); var allocation = Allocate(size, alignment, CreateBlock);
@ -46,7 +52,7 @@ namespace Ryujinx.Cpu.AppleHv
private Block CreateBlock(MemoryBlock memory, ulong size) private Block CreateBlock(MemoryBlock memory, ulong size)
{ {
return new Block(ipaAllocator, memory, size); return new Block(_ipaAllocator, memory, size);
} }
} }
} }

View file

@ -5,6 +5,7 @@ using Ryujinx.Memory.Tracking;
using System; using System;
using System.Buffers; using System.Buffers;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.Versioning; using System.Runtime.Versioning;

View file

@ -8,7 +8,7 @@ namespace Ryujinx.Cpu.AppleHv
{ {
private const ulong InterruptIntervalNs = 16 * 1000000; // 16 ms private const ulong InterruptIntervalNs = 16 * 1000000; // 16 ms
private static ulong _interruptTimeDeltaTicks; private static ulong _interruptTimeDeltaTicks = 0;
public readonly ulong Handle; public readonly ulong Handle;
public readonly HvVcpuExit* ExitInfo; public readonly HvVcpuExit* ExitInfo;

View file

@ -5,6 +5,7 @@ using Ryujinx.Memory.Tracking;
using System; using System;
using System.Buffers; using System.Buffers;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Threading; using System.Threading;

View file

@ -8,6 +8,7 @@ using Ryujinx.Memory.Tracking;
using System; using System;
using System.Buffers; using System.Buffers;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
namespace Ryujinx.Cpu.Jit namespace Ryujinx.Cpu.Jit

View file

@ -14,7 +14,7 @@ namespace Ryujinx.Cpu.LightningJit.Cache
Size = size; Size = size;
} }
public int CompareTo(CacheEntry other) public int CompareTo([AllowNull] CacheEntry other)
{ {
return Offset.CompareTo(other.Offset); return Offset.CompareTo(other.Offset);
} }

View file

@ -18,7 +18,7 @@ namespace Ryujinx.Cpu.LightningJit.Cache
Size = size; Size = size;
} }
public int CompareTo(MemoryBlock other) public int CompareTo([AllowNull] MemoryBlock other)
{ {
return Offset.CompareTo(other.Offset); return Offset.CompareTo(other.Offset);
} }

View file

@ -28,7 +28,7 @@ namespace Ryujinx.Cpu.LightningJit.Cache
private static readonly Lock _lock = new(); private static readonly Lock _lock = new();
private static bool _initialized; private static bool _initialized;
private static readonly List<ReservedRegion> _jitRegions = []; private static readonly List<ReservedRegion> _jitRegions = [];
private static int _activeRegionIndex; private static int _activeRegionIndex = 0;
[SupportedOSPlatform("windows")] [SupportedOSPlatform("windows")]
[LibraryImport("kernel32.dll", SetLastError = true)] [LibraryImport("kernel32.dll", SetLastError = true)]
@ -75,9 +75,12 @@ namespace Ryujinx.Cpu.LightningJit.Cache
if (OperatingSystem.IsMacOS() && RuntimeInformation.ProcessArchitecture == Architecture.Arm64) if (OperatingSystem.IsMacOS() && RuntimeInformation.ProcessArchitecture == Architecture.Arm64)
{ {
fixed (byte* codePtr = code) unsafe
{ {
JitSupportDarwin.Copy(funcPtr, (IntPtr)codePtr, (ulong)code.Length); fixed (byte* codePtr = code)
{
JitSupportDarwin.Copy(funcPtr, (IntPtr)codePtr, (ulong)code.Length);
}
} }
} }
else else

View file

@ -20,7 +20,7 @@ namespace Ryujinx.Cpu.LightningJit.Cache
Size = size; Size = size;
} }
public int CompareTo(Range other) public int CompareTo([AllowNull] Range other)
{ {
return Offset.CompareTo(other.Offset); return Offset.CompareTo(other.Offset);
} }

View file

@ -21,7 +21,7 @@ namespace Ryujinx.Cpu.LightningJit.State
public int Running; public int Running;
} }
private static NativeCtxStorage _dummyStorage; private static NativeCtxStorage _dummyStorage = new();
private readonly IJitMemoryBlock _block; private readonly IJitMemoryBlock _block;
@ -79,22 +79,22 @@ namespace Ryujinx.Cpu.LightningJit.State
GetStorage().V[index * 2 + 1] = value.Extract<ulong>(1); GetStorage().V[index * 2 + 1] = value.Extract<ulong>(1);
} }
public uint GetPstate() public unsafe uint GetPstate()
{ {
return GetStorage().Flags; return GetStorage().Flags;
} }
public void SetPstate(uint value) public unsafe void SetPstate(uint value)
{ {
GetStorage().Flags = value; GetStorage().Flags = value;
} }
public uint GetFPState(uint mask = uint.MaxValue) public unsafe uint GetFPState(uint mask = uint.MaxValue)
{ {
return GetStorage().FpFlags & mask; return GetStorage().FpFlags & mask;
} }
public void SetFPState(uint value, uint mask = uint.MaxValue) public unsafe void SetFPState(uint value, uint mask = uint.MaxValue)
{ {
GetStorage().FpFlags = (value & mask) | (GetStorage().FpFlags & ~mask); GetStorage().FpFlags = (value & mask) | (GetStorage().FpFlags & ~mask);
} }

View file

@ -13,7 +13,7 @@ namespace Ryujinx.Graphics.GAL.Multithreading
/// </summary> /// </summary>
class BufferMap class BufferMap
{ {
private ulong _bufferHandle; private ulong _bufferHandle = 0;
private readonly Dictionary<BufferHandle, BufferHandle> _bufferMap = new(); private readonly Dictionary<BufferHandle, BufferHandle> _bufferMap = new();
private readonly HashSet<BufferHandle> _inFlight = []; private readonly HashSet<BufferHandle> _inFlight = [];

View file

@ -55,7 +55,7 @@ namespace Ryujinx.Graphics.GAL.Multithreading
private int _refProducerPtr; private int _refProducerPtr;
private int _refConsumerPtr; private int _refConsumerPtr;
public uint ProgramCount { get; set; } public uint ProgramCount { get; set; } = 0;
private Action _interruptAction; private Action _interruptAction;
private readonly Lock _interruptLock = new(); private readonly Lock _interruptLock = new();

View file

@ -506,7 +506,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
maxDrawCount, maxDrawCount,
stride, stride,
indexCount, indexCount,
IndirectDrawType.DrawIndexedIndirectCount); Threed.IndirectDrawType.DrawIndexedIndirectCount);
} }
/// <summary> /// <summary>

View file

@ -1,5 +1,6 @@
using Ryujinx.Common; using Ryujinx.Common;
using Ryujinx.Graphics.GAL; using Ryujinx.Graphics.GAL;
using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender

View file

@ -15,10 +15,10 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
// State associated with direct uniform buffer updates. // State associated with direct uniform buffer updates.
// This state is used to attempt to batch together consecutive updates. // This state is used to attempt to batch together consecutive updates.
private ulong _ubBeginCpuAddress; private ulong _ubBeginCpuAddress = 0;
private ulong _ubFollowUpAddress; private ulong _ubFollowUpAddress = 0;
private ulong _ubByteCount; private ulong _ubByteCount = 0;
private int _ubIndex; private int _ubIndex = 0;
private readonly int[] _ubData = new int[UniformDataCacheSize]; private readonly int[] _ubData = new int[UniformDataCacheSize];
/// <summary> /// <summary>

View file

@ -4,6 +4,7 @@ using Ryujinx.Graphics.Gpu.Memory;
using Ryujinx.Graphics.Shader; using Ryujinx.Graphics.Shader;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace Ryujinx.Graphics.Gpu.Image namespace Ryujinx.Graphics.Gpu.Image

View file

@ -60,13 +60,13 @@ namespace Ryujinx.Graphics.Gpu.Memory
/// <remarks> /// <remarks>
/// This is null until at least one modification occurs. /// This is null until at least one modification occurs.
/// </remarks> /// </remarks>
private BufferModifiedRangeList _modifiedRanges; private BufferModifiedRangeList _modifiedRanges = null;
/// <summary> /// <summary>
/// A structure that is used to flush buffer data back to a host mapped buffer for cached readback. /// A structure that is used to flush buffer data back to a host mapped buffer for cached readback.
/// Only used if the buffer data is explicitly owned by device local memory. /// Only used if the buffer data is explicitly owned by device local memory.
/// </summary> /// </summary>
private BufferPreFlush _preFlush; private BufferPreFlush _preFlush = null;
/// <summary> /// <summary>
/// Usage tracking state that determines what type of backing the buffer should use. /// Usage tracking state that determines what type of backing the buffer should use.
@ -171,9 +171,9 @@ namespace Ryujinx.Graphics.Gpu.Memory
_memoryTracking.RegisterPreciseAction(PreciseAction); _memoryTracking.RegisterPreciseAction(PreciseAction);
} }
_externalFlushDelegate = ExternalFlush; _externalFlushDelegate = new RegionSignal(ExternalFlush);
_loadDelegate = LoadRegion; _loadDelegate = new Action<ulong, ulong>(LoadRegion);
_modifiedDelegate = RegionModified; _modifiedDelegate = new Action<ulong, ulong>(RegionModified);
_virtualDependenciesLock = new ReaderWriterLockSlim(); _virtualDependenciesLock = new ReaderWriterLockSlim();
} }

View file

@ -69,7 +69,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
} }
private List<PhysicalDependency> _dependencies; private List<PhysicalDependency> _dependencies;
private BufferModifiedRangeList _modifiedRanges; private BufferModifiedRangeList _modifiedRanges = null;
/// <summary> /// <summary>
/// Creates a new instance of the buffer. /// Creates a new instance of the buffer.

View file

@ -2,6 +2,7 @@ using Ryujinx.Graphics.GAL;
using Ryujinx.Graphics.Gpu.Engine; using Ryujinx.Graphics.Gpu.Engine;
using Ryujinx.Graphics.Gpu.Image; using Ryujinx.Graphics.Gpu.Image;
using Ryujinx.Graphics.Shader; using Ryujinx.Graphics.Shader;
using System;
using System.Linq; using System.Linq;
namespace Ryujinx.Graphics.Gpu.Shader namespace Ryujinx.Graphics.Gpu.Shader

View file

@ -7,7 +7,7 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg
{ {
unsafe class FFmpegContext : IDisposable unsafe class FFmpegContext : IDisposable
{ {
private delegate int AVCodec_decode(AVCodecContext* avctx, void* outdata, int* got_frame_ptr, AVPacket* avpkt); private unsafe delegate int AVCodec_decode(AVCodecContext* avctx, void* outdata, int* got_frame_ptr, AVPacket* avpkt);
private readonly AVCodec_decode _decodeFrame; private readonly AVCodec_decode _decodeFrame;
private static readonly FFmpegApi.av_log_set_callback_callback _logFunc; private static readonly FFmpegApi.av_log_set_callback_callback _logFunc;

View file

@ -17,7 +17,7 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg.Native
public IntPtr SampleFmts; public IntPtr SampleFmts;
// Deprecated // Deprecated
public unsafe ulong* ChannelLayouts; public unsafe ulong* ChannelLayouts;
public IntPtr PrivClass; public unsafe IntPtr PrivClass;
public IntPtr Profiles; public IntPtr Profiles;
public unsafe byte* WrapperName; public unsafe byte* WrapperName;
public IntPtr ChLayouts; public IntPtr ChLayouts;

View file

@ -17,7 +17,7 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg.Native
public IntPtr SampleFmts; public IntPtr SampleFmts;
// Deprecated // Deprecated
public unsafe ulong* ChannelLayouts; public unsafe ulong* ChannelLayouts;
public IntPtr PrivClass; public unsafe IntPtr PrivClass;
public IntPtr Profiles; public IntPtr Profiles;
public unsafe byte* WrapperName; public unsafe byte* WrapperName;
#pragma warning restore CS0649 #pragma warning restore CS0649

View file

@ -6,7 +6,7 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg.Native
struct AVCodecContext struct AVCodecContext
{ {
#pragma warning disable CS0649 // Field is never assigned to #pragma warning disable CS0649 // Field is never assigned to
public IntPtr AvClass; public unsafe IntPtr AvClass;
public int LogLevelOffset; public int LogLevelOffset;
public int CodecType; public int CodecType;
public unsafe AVCodec* Codec; public unsafe AVCodec* Codec;

View file

@ -281,7 +281,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Types
Array8<uint> frameSizes = new(); Array8<uint> frameSizes = new();
int frameCount = 0; int frameCount = 0;
res = Decoder.ParseSuperframeIndex(data, (ulong)data.Length, ref frameSizes, out frameCount); res = Types.Decoder.ParseSuperframeIndex(data, (ulong)data.Length, ref frameSizes, out frameCount);
if (res != CodecErr.Ok) if (res != CodecErr.Ok)
{ {
return res; return res;
@ -322,7 +322,7 @@ namespace Ryujinx.Graphics.Nvdec.Vp9.Types
// Account for suboptimal termination by the encoder. // Account for suboptimal termination by the encoder.
while (dataStart.Length != 0) while (dataStart.Length != 0)
{ {
byte marker = Decoder.ReadMarker(dataStart); byte marker = Types.Decoder.ReadMarker(dataStart);
if (marker != 0) if (marker != 0)
{ {
break; break;

View file

@ -15,7 +15,7 @@ namespace Ryujinx.Graphics.Nvdec
{ {
private static readonly Decoder _decoder = new(); private static readonly Decoder _decoder = new();
public static void Decode(ResourceManager rm, ref NvdecRegisters state) public unsafe static void Decode(ResourceManager rm, ref NvdecRegisters state)
{ {
PictureInfo pictureInfo = rm.MemoryManager.DeviceRead<PictureInfo>(state.SetDrvPicSetupOffset); PictureInfo pictureInfo = rm.MemoryManager.DeviceRead<PictureInfo>(state.SetDrvPicSetupOffset);
EntropyProbs entropy = rm.MemoryManager.DeviceRead<EntropyProbs>(state.Vp9SetProbTabBufOffset); EntropyProbs entropy = rm.MemoryManager.DeviceRead<EntropyProbs>(state.Vp9SetProbTabBufOffset);

View file

@ -5,7 +5,7 @@ using System.Threading;
namespace Ryujinx.Graphics.OpenGL namespace Ryujinx.Graphics.OpenGL
{ {
class BackgroundContextWorker : IDisposable unsafe class BackgroundContextWorker : IDisposable
{ {
[ThreadStatic] [ThreadStatic]
public static bool InBackground; public static bool InBackground;

View file

@ -6,7 +6,7 @@ using System;
namespace Ryujinx.Graphics.OpenGL.Effects.Smaa namespace Ryujinx.Graphics.OpenGL.Effects.Smaa
{ {
internal class SmaaPostProcessingEffect : IPostProcessingEffect internal partial class SmaaPostProcessingEffect : IPostProcessingEffect
{ {
public const int AreaWidth = 160; public const int AreaWidth = 160;
public const int AreaHeight = 560; public const int AreaHeight = 560;
@ -75,7 +75,7 @@ namespace Ryujinx.Graphics.OpenGL.Effects.Smaa
} }
} }
private void RecreateShaders(int width, int height) private unsafe void RecreateShaders(int width, int height)
{ {
string baseShader = EmbeddedResources.ReadAllText("Ryujinx.Graphics.OpenGL/Effects/Shaders/smaa.hlsl"); string baseShader = EmbeddedResources.ReadAllText("Ryujinx.Graphics.OpenGL/Effects/Shaders/smaa.hlsl");
var pixelSizeDefine = $"#define SMAA_RT_METRICS float4(1.0 / {width}.0, 1.0 / {height}.0, {width}, {height}) \n"; var pixelSizeDefine = $"#define SMAA_RT_METRICS float4(1.0 / {width}.0, 1.0 / {height}.0, {width}, {height}) \n";

View file

@ -29,7 +29,7 @@ namespace Ryujinx.Graphics.OpenGL
private readonly Sync _sync; private readonly Sync _sync;
public uint ProgramCount { get; set; } public uint ProgramCount { get; set; } = 0;
public event EventHandler<ScreenCaptureImageInfo> ScreenCaptured; public event EventHandler<ScreenCaptureImageInfo> ScreenCaptured;

View file

@ -21,7 +21,7 @@ namespace Ryujinx.Graphics.OpenGL.Queries
private readonly CounterQueue _queue; private readonly CounterQueue _queue;
private readonly BufferedQuery _counter; private readonly BufferedQuery _counter;
private bool _hostAccessReserved; private bool _hostAccessReserved = false;
private int _refCount = 1; // Starts with a reference from the counter queue. private int _refCount = 1; // Starts with a reference from the counter queue.
private readonly Lock _lock = new(); private readonly Lock _lock = new();

View file

@ -14,7 +14,7 @@ namespace Ryujinx.Graphics.OpenGL
public IntPtr Handle; public IntPtr Handle;
} }
private ulong _firstHandle; private ulong _firstHandle = 0;
private static ClientWaitSyncFlags SyncFlags => HwCapabilities.RequiresSyncFlush ? ClientWaitSyncFlags.None : ClientWaitSyncFlags.SyncFlushCommandsBit; private static ClientWaitSyncFlags SyncFlags => HwCapabilities.RequiresSyncFlush ? ClientWaitSyncFlags.None : ClientWaitSyncFlags.SyncFlushCommandsBit;
private readonly List<SyncHandle> _handles = []; private readonly List<SyncHandle> _handles = [];

View file

@ -10,7 +10,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Spirv
{ {
using IrOperandType = IntermediateRepresentation.OperandType; using IrOperandType = IntermediateRepresentation.OperandType;
class CodeGenContext : Module partial class CodeGenContext : Module
{ {
private const uint SpirvVersionMajor = 1; private const uint SpirvVersionMajor = 1;
private const uint SpirvVersionMinor = 3; private const uint SpirvVersionMinor = 3;

View file

@ -4,10 +4,17 @@ namespace Ryujinx.Graphics.Shader.StructuredIr
{ {
class StructuredProgramInfo class StructuredProgramInfo
{ {
public List<StructuredFunction> Functions { get; } = []; public List<StructuredFunction> Functions { get; }
public HashSet<IoDefinition> IoDefinitions { get; } = []; public HashSet<IoDefinition> IoDefinitions { get; }
public HelperFunctionsMask HelperFunctionsMask { get; set; } public HelperFunctionsMask HelperFunctionsMask { get; set; }
public StructuredProgramInfo()
{
Functions = [];
IoDefinitions = [];
}
} }
} }

View file

@ -4,22 +4,31 @@ using System.Numerics;
namespace Ryujinx.Graphics.Shader.Translation namespace Ryujinx.Graphics.Shader.Translation
{ {
class AttributeUsage(IGpuAccessor gpuAccessor) class AttributeUsage
{ {
public bool NextUsesFixedFuncAttributes { get; private set; } public bool NextUsesFixedFuncAttributes { get; private set; }
public int UsedInputAttributes { get; private set; } public int UsedInputAttributes { get; private set; }
public int UsedOutputAttributes { get; private set; } public int UsedOutputAttributes { get; private set; }
public HashSet<int> UsedInputAttributesPerPatch { get; } = []; public HashSet<int> UsedInputAttributesPerPatch { get; }
public HashSet<int> UsedOutputAttributesPerPatch { get; } = []; public HashSet<int> UsedOutputAttributesPerPatch { get; }
public HashSet<int> NextUsedInputAttributesPerPatch { get; private set; } public HashSet<int> NextUsedInputAttributesPerPatch { get; private set; }
public int PassthroughAttributes { get; private set; } public int PassthroughAttributes { get; private set; }
private int _nextUsedInputAttributes; private int _nextUsedInputAttributes;
private int _thisUsedInputAttributes; private int _thisUsedInputAttributes;
private Dictionary<int, int> _perPatchAttributeLocations; private Dictionary<int, int> _perPatchAttributeLocations;
private readonly IGpuAccessor _gpuAccessor;
public UInt128 NextInputAttributesComponents { get; private set; } public UInt128 NextInputAttributesComponents { get; private set; }
public UInt128 ThisInputAttributesComponents { get; private set; } public UInt128 ThisInputAttributesComponents { get; private set; }
public AttributeUsage(IGpuAccessor gpuAccessor)
{
_gpuAccessor = gpuAccessor;
UsedInputAttributesPerPatch = [];
UsedOutputAttributesPerPatch = [];
}
public void SetInputUserAttribute(int index, int component) public void SetInputUserAttribute(int index, int component)
{ {
int mask = 1 << index; int mask = 1 << index;
@ -65,7 +74,7 @@ namespace Ryujinx.Graphics.Shader.Translation
int location = BitOperations.TrailingZeroCount(freeMask); int location = BitOperations.TrailingZeroCount(freeMask);
if (location == 32) if (location == 32)
{ {
gpuAccessor.Log($"No enough free locations for patch input/output 0x{attr:X}."); _gpuAccessor.Log($"No enough free locations for patch input/output 0x{attr:X}.");
break; break;
} }

View file

@ -61,12 +61,18 @@ namespace Ryujinx.Graphics.Shader.Translation
private readonly TransformFeedbackOutput[] _transformFeedbackOutputs; private readonly TransformFeedbackOutput[] _transformFeedbackOutputs;
readonly struct TransformFeedbackVariable(IoVariable ioVariable, int location = 0, int component = 0) readonly struct TransformFeedbackVariable : IEquatable<TransformFeedbackVariable>
: IEquatable<TransformFeedbackVariable>
{ {
public IoVariable IoVariable { get; } = ioVariable; public IoVariable IoVariable { get; }
public int Location { get; } = location; public int Location { get; }
public int Component { get; } = component; public int Component { get; }
public TransformFeedbackVariable(IoVariable ioVariable, int location = 0, int component = 0)
{
IoVariable = ioVariable;
Location = location;
Component = component;
}
public override bool Equals(object other) public override bool Equals(object other)
{ {

View file

@ -67,7 +67,7 @@ namespace Ryujinx.Graphics.Vulkan
return (access, stages); return (access, stages);
} }
private readonly record struct StageFlags private readonly record struct StageFlags : IEquatable<StageFlags>
{ {
public readonly PipelineStageFlags Source; public readonly PipelineStageFlags Source;
public readonly PipelineStageFlags Dest; public readonly PipelineStageFlags Dest;
@ -122,7 +122,7 @@ namespace Ryujinx.Graphics.Vulkan
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public void FlushMemoryBarrier(ShaderCollection program, bool inRenderPass) public unsafe void FlushMemoryBarrier(ShaderCollection program, bool inRenderPass)
{ {
if (_queuedIncoherentBarrier > IncoherentBarrierType.None) if (_queuedIncoherentBarrier > IncoherentBarrierType.None)
{ {
@ -182,7 +182,7 @@ namespace Ryujinx.Graphics.Vulkan
} }
} }
public void Flush(CommandBufferScoped cbs, bool inRenderPass, RenderPassHolder rpHolder, Action endRenderPass) public unsafe void Flush(CommandBufferScoped cbs, bool inRenderPass, RenderPassHolder rpHolder, Action endRenderPass)
{ {
Flush(cbs, null, inRenderPass, rpHolder, endRenderPass); Flush(cbs, null, inRenderPass, rpHolder, endRenderPass);
} }

View file

@ -640,7 +640,7 @@ namespace Ryujinx.Graphics.Vulkan
} }
} }
public void SetDataUnchecked<T>(int offset, ReadOnlySpan<T> data) where T : unmanaged public unsafe void SetDataUnchecked<T>(int offset, ReadOnlySpan<T> data) where T : unmanaged
{ {
SetDataUnchecked(offset, MemoryMarshal.AsBytes(data)); SetDataUnchecked(offset, MemoryMarshal.AsBytes(data));
} }

View file

@ -44,7 +44,7 @@ namespace Ryujinx.Graphics.Vulkan
} }
} }
public DescriptorSetCollection AllocateDescriptorSets(ReadOnlySpan<DescriptorSetLayout> layouts, int consumedDescriptors) public unsafe DescriptorSetCollection AllocateDescriptorSets(ReadOnlySpan<DescriptorSetLayout> layouts, int consumedDescriptors)
{ {
TryAllocateDescriptorSets(layouts, consumedDescriptors, isTry: false, out var dsc); TryAllocateDescriptorSets(layouts, consumedDescriptors, isTry: false, out var dsc);
return dsc; return dsc;

View file

@ -9,48 +9,48 @@ namespace Ryujinx.Graphics.Vulkan
{ {
class FormatCapabilities class FormatCapabilities
{ {
private static readonly Format[] _scaledFormats = private static readonly GAL.Format[] _scaledFormats =
[ [
Format.R8Uscaled, GAL.Format.R8Uscaled,
Format.R8Sscaled, GAL.Format.R8Sscaled,
Format.R16Uscaled, GAL.Format.R16Uscaled,
Format.R16Sscaled, GAL.Format.R16Sscaled,
Format.R8G8Uscaled, GAL.Format.R8G8Uscaled,
Format.R8G8Sscaled, GAL.Format.R8G8Sscaled,
Format.R16G16Uscaled, GAL.Format.R16G16Uscaled,
Format.R16G16Sscaled, GAL.Format.R16G16Sscaled,
Format.R8G8B8Uscaled, GAL.Format.R8G8B8Uscaled,
Format.R8G8B8Sscaled, GAL.Format.R8G8B8Sscaled,
Format.R16G16B16Uscaled, GAL.Format.R16G16B16Uscaled,
Format.R16G16B16Sscaled, GAL.Format.R16G16B16Sscaled,
Format.R8G8B8A8Uscaled, GAL.Format.R8G8B8A8Uscaled,
Format.R8G8B8A8Sscaled, GAL.Format.R8G8B8A8Sscaled,
Format.R16G16B16A16Uscaled, GAL.Format.R16G16B16A16Uscaled,
Format.R16G16B16A16Sscaled, GAL.Format.R16G16B16A16Sscaled,
Format.R10G10B10A2Uscaled, GAL.Format.R10G10B10A2Uscaled,
Format.R10G10B10A2Sscaled GAL.Format.R10G10B10A2Sscaled
]; ];
private static readonly Format[] _intFormats = private static readonly GAL.Format[] _intFormats =
[ [
Format.R8Uint, GAL.Format.R8Uint,
Format.R8Sint, GAL.Format.R8Sint,
Format.R16Uint, GAL.Format.R16Uint,
Format.R16Sint, GAL.Format.R16Sint,
Format.R8G8Uint, GAL.Format.R8G8Uint,
Format.R8G8Sint, GAL.Format.R8G8Sint,
Format.R16G16Uint, GAL.Format.R16G16Uint,
Format.R16G16Sint, GAL.Format.R16G16Sint,
Format.R8G8B8Uint, GAL.Format.R8G8B8Uint,
Format.R8G8B8Sint, GAL.Format.R8G8B8Sint,
Format.R16G16B16Uint, GAL.Format.R16G16B16Uint,
Format.R16G16B16Sint, GAL.Format.R16G16B16Sint,
Format.R8G8B8A8Uint, GAL.Format.R8G8B8A8Uint,
Format.R8G8B8A8Sint, GAL.Format.R8G8B8A8Sint,
Format.R16G16B16A16Uint, GAL.Format.R16G16B16A16Uint,
Format.R16G16B16A16Sint, GAL.Format.R16G16B16A16Sint,
Format.R10G10B10A2Uint, GAL.Format.R10G10B10A2Uint,
Format.R10G10B10A2Sint GAL.Format.R10G10B10A2Sint
]; ];
private readonly FormatFeatureFlags[] _bufferTable; private readonly FormatFeatureFlags[] _bufferTable;

View file

@ -131,7 +131,7 @@ namespace Ryujinx.Graphics.Vulkan
TriFanToTrisPattern = new IndexBufferPattern(Gd, 3, 3, 2, [int.MinValue, -1, 0], 1, true); TriFanToTrisPattern = new IndexBufferPattern(Gd, 3, 3, 2, [int.MinValue, -1, 0], 1, true);
} }
public void Barrier() public unsafe void Barrier()
{ {
Gd.Barriers.QueueMemoryBarrier(); Gd.Barriers.QueueMemoryBarrier();
} }
@ -255,7 +255,7 @@ namespace Ryujinx.Graphics.Vulkan
Gd.Api.CmdClearAttachments(CommandBuffer, 1, &attachment, 1, &clearRect); Gd.Api.CmdClearAttachments(CommandBuffer, 1, &attachment, 1, &clearRect);
} }
public void CommandBufferBarrier() public unsafe void CommandBufferBarrier()
{ {
Gd.Barriers.QueueCommandBufferBarrier(); Gd.Barriers.QueueCommandBufferBarrier();
} }
@ -1348,7 +1348,7 @@ namespace Ryujinx.Graphics.Vulkan
_descriptorSetUpdater.ForceImageDirty(); _descriptorSetUpdater.ForceImageDirty();
} }
public void TextureBarrier() public unsafe void TextureBarrier()
{ {
Gd.Barriers.QueueTextureBarrier(); Gd.Barriers.QueueTextureBarrier();
} }
@ -1446,7 +1446,7 @@ namespace Ryujinx.Graphics.Vulkan
_newState.SamplesCount = FramebufferParams.AttachmentSamples.Length != 0 ? FramebufferParams.AttachmentSamples[0] : 1; _newState.SamplesCount = FramebufferParams.AttachmentSamples.Length != 0 ? FramebufferParams.AttachmentSamples[0] : 1;
} }
protected void CreateRenderPass() protected unsafe void CreateRenderPass()
{ {
var hasFramebuffer = FramebufferParams != null; var hasFramebuffer = FramebufferParams != null;

View file

@ -205,7 +205,7 @@ namespace Ryujinx.Graphics.Vulkan
/// <param name="size">The minimum size the reserved data requires</param> /// <param name="size">The minimum size the reserved data requires</param>
/// <param name="alignment">The required alignment for the buffer offset</param> /// <param name="alignment">The required alignment for the buffer offset</param>
/// <returns>The reserved range of the staging buffer</returns> /// <returns>The reserved range of the staging buffer</returns>
public StagingBufferReserved? TryReserveData(CommandBufferScoped cbs, int size, int alignment) public unsafe StagingBufferReserved? TryReserveData(CommandBufferScoped cbs, int size, int alignment)
{ {
if (size > BufferSize) if (size > BufferSize)
{ {
@ -235,7 +235,7 @@ namespace Ryujinx.Graphics.Vulkan
/// <param name="cbs">Command buffer to reserve the data on</param> /// <param name="cbs">Command buffer to reserve the data on</param>
/// <param name="size">The minimum size the reserved data requires</param> /// <param name="size">The minimum size the reserved data requires</param>
/// <returns>The reserved range of the staging buffer</returns> /// <returns>The reserved range of the staging buffer</returns>
public StagingBufferReserved? TryReserveData(CommandBufferScoped cbs, int size) public unsafe StagingBufferReserved? TryReserveData(CommandBufferScoped cbs, int size)
{ {
return TryReserveData(cbs, size, _resourceAlignment); return TryReserveData(cbs, size, _resourceAlignment);
} }

View file

@ -6,7 +6,7 @@ using System.Linq;
namespace Ryujinx.Graphics.Vulkan namespace Ryujinx.Graphics.Vulkan
{ {
class SyncManager(VulkanRenderer gd, Device device) class SyncManager
{ {
private class SyncHandle private class SyncHandle
{ {
@ -23,10 +23,19 @@ namespace Ryujinx.Graphics.Vulkan
private ulong _firstHandle; private ulong _firstHandle;
private readonly List<SyncHandle> _handles = []; private readonly VulkanRenderer _gd;
private readonly Device _device;
private readonly List<SyncHandle> _handles;
private ulong _flushId; private ulong _flushId;
private long _waitTicks; private long _waitTicks;
public SyncManager(VulkanRenderer gd, Device device)
{
_gd = gd;
_device = device;
_handles = [];
}
public void RegisterFlush() public void RegisterFlush()
{ {
_flushId++; _flushId++;
@ -36,17 +45,17 @@ namespace Ryujinx.Graphics.Vulkan
{ {
ulong flushId = _flushId; ulong flushId = _flushId;
MultiFenceHolder waitable = new(); MultiFenceHolder waitable = new();
if (strict || gd.InterruptAction == null) if (strict || _gd.InterruptAction == null)
{ {
gd.FlushAllCommands(); _gd.FlushAllCommands();
gd.CommandBufferPool.AddWaitable(waitable); _gd.CommandBufferPool.AddWaitable(waitable);
} }
else else
{ {
// Don't flush commands, instead wait for the current command buffer to finish. // Don't flush commands, instead wait for the current command buffer to finish.
// If this sync is waited on before the command buffer is submitted, interrupt the gpu thread and flush it manually. // If this sync is waited on before the command buffer is submitted, interrupt the gpu thread and flush it manually.
gd.CommandBufferPool.AddInUseWaitable(waitable); _gd.CommandBufferPool.AddInUseWaitable(waitable);
} }
SyncHandle handle = new() SyncHandle handle = new()
@ -79,7 +88,7 @@ namespace Ryujinx.Graphics.Vulkan
if (handle.ID > lastHandle) if (handle.ID > lastHandle)
{ {
bool signaled = handle.Signalled || handle.Waitable.WaitForFences(gd.Api, device, 0); bool signaled = handle.Signalled || handle.Waitable.WaitForFences(_gd.Api, _device, 0);
if (signaled) if (signaled)
{ {
lastHandle = handle.ID; lastHandle = handle.ID;
@ -125,11 +134,11 @@ namespace Ryujinx.Graphics.Vulkan
if (result.NeedsFlush(_flushId)) if (result.NeedsFlush(_flushId))
{ {
gd.InterruptAction(() => _gd.InterruptAction(() =>
{ {
if (result.NeedsFlush(_flushId)) if (result.NeedsFlush(_flushId))
{ {
gd.FlushAllCommands(); _gd.FlushAllCommands();
} }
}); });
} }
@ -141,7 +150,7 @@ namespace Ryujinx.Graphics.Vulkan
return; return;
} }
bool signaled = result.Signalled || result.Waitable.WaitForFences(gd.Api, device, 1000000000); bool signaled = result.Signalled || result.Waitable.WaitForFences(_gd.Api, _device, 1000000000);
if (!signaled) if (!signaled)
{ {
@ -173,7 +182,7 @@ namespace Ryujinx.Graphics.Vulkan
break; break;
} }
bool signaled = first.Waitable.WaitForFences(gd.Api, device, 0); bool signaled = first.Waitable.WaitForFences(_gd.Api, _device, 0);
if (signaled) if (signaled)
{ {
// Delete the sync object. // Delete the sync object.

View file

@ -28,7 +28,7 @@ namespace Ryujinx.Graphics.Vulkan
private bool _initialized; private bool _initialized;
public uint ProgramCount { get; set; } public uint ProgramCount { get; set; } = 0;
internal FormatCapabilities FormatCapabilities { get; private set; } internal FormatCapabilities FormatCapabilities { get; private set; }
internal HardwareCapabilities Capabilities; internal HardwareCapabilities Capabilities;

View file

@ -42,7 +42,7 @@ namespace Ryujinx.Graphics.Vulkan
private ScalingFilter _currentScalingFilter; private ScalingFilter _currentScalingFilter;
private bool _colorSpacePassthroughEnabled; private bool _colorSpacePassthroughEnabled;
public Window(VulkanRenderer gd, SurfaceKHR surface, PhysicalDevice physicalDevice, Device device) public unsafe Window(VulkanRenderer gd, SurfaceKHR surface, PhysicalDevice physicalDevice, Device device)
{ {
_gd = gd; _gd = gd;
_physicalDevice = physicalDevice; _physicalDevice = physicalDevice;

View file

@ -698,6 +698,8 @@ namespace Ryujinx.HLE.FileSystem
{ {
throw new InvalidFirmwarePackageException("Update not found in xci file."); throw new InvalidFirmwarePackageException("Update not found in xci file.");
} }
default:
break;
} }
SystemVersion VerifyAndGetVersionDirectory(string firmwareDirectory) SystemVersion VerifyAndGetVersionDirectory(string firmwareDirectory)

View file

@ -38,7 +38,7 @@ namespace Ryujinx.HLE.FileSystem
private readonly ConcurrentDictionary<ulong, Stream> _romFsByPid; private readonly ConcurrentDictionary<ulong, Stream> _romFsByPid;
private static bool _isInitialized; private static bool _isInitialized = false;
public static VirtualFileSystem CreateInstance() public static VirtualFileSystem CreateInstance()
{ {

View file

@ -128,13 +128,13 @@ namespace Ryujinx.HLE.HOS.Applets.Cabinet
#region Structs #region Structs
[StructLayout(LayoutKind.Sequential, Pack = 1)] [StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct TagInfo public unsafe struct TagInfo
{ {
public fixed byte Data[0x58]; public fixed byte Data[0x58];
} }
[StructLayout(LayoutKind.Sequential, Pack = 1)] [StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct StartParamForAmiiboSettings public unsafe struct StartParamForAmiiboSettings
{ {
public byte ZeroValue; // Left at zero by sdknso public byte ZeroValue; // Left at zero by sdknso
public byte Type; public byte Type;
@ -151,7 +151,7 @@ namespace Ryujinx.HLE.HOS.Applets.Cabinet
} }
[StructLayout(LayoutKind.Sequential, Pack = 1)] [StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct ReturnValueForAmiiboSettings public unsafe struct ReturnValueForAmiiboSettings
{ {
public byte AmiiboSettingsReturnFlag; public byte AmiiboSettingsReturnFlag;
private byte Padding1; private byte Padding1;

View file

@ -34,7 +34,7 @@ namespace Ryujinx.HLE.HOS.Applets
private SoftwareKeyboardState _foregroundState = SoftwareKeyboardState.Uninitialized; private SoftwareKeyboardState _foregroundState = SoftwareKeyboardState.Uninitialized;
private volatile InlineKeyboardState _backgroundState = InlineKeyboardState.Uninitialized; private volatile InlineKeyboardState _backgroundState = InlineKeyboardState.Uninitialized;
private bool _isBackground; private bool _isBackground = false;
private AppletSession _normalSession; private AppletSession _normalSession;
private AppletSession _interactiveSession; private AppletSession _interactiveSession;
@ -53,14 +53,14 @@ namespace Ryujinx.HLE.HOS.Applets
private byte[] _transferMemory; private byte[] _transferMemory;
private string _textValue = ""; private string _textValue = "";
private int _cursorBegin; private int _cursorBegin = 0;
private Encoding _encoding = Encoding.Unicode; private Encoding _encoding = Encoding.Unicode;
private KeyboardResult _lastResult = KeyboardResult.NotSet; private KeyboardResult _lastResult = KeyboardResult.NotSet;
private IDynamicTextInputHandler _dynamicTextInputHandler; private IDynamicTextInputHandler _dynamicTextInputHandler = null;
private SoftwareKeyboardRenderer _keyboardRenderer; private SoftwareKeyboardRenderer _keyboardRenderer = null;
private NpadReader _npads; private NpadReader _npads = null;
private bool _canAcceptController; private bool _canAcceptController = false;
private KeyboardInputMode _inputMode = KeyboardInputMode.ControllerAndKeyboard; private KeyboardInputMode _inputMode = KeyboardInputMode.ControllerAndKeyboard;
private readonly Lock _lock = new(); private readonly Lock _lock = new();

View file

@ -23,15 +23,15 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
private readonly Lock _bufferLock = new(); private readonly Lock _bufferLock = new();
private RenderingSurfaceInfo _surfaceInfo; private RenderingSurfaceInfo _surfaceInfo = null;
private SKImageInfo _imageInfo; private SKImageInfo _imageInfo;
private SKSurface _surface; private SKSurface _surface = null;
private byte[] _bufferData; private byte[] _bufferData = null;
private readonly SKBitmap _ryujinxLogo; private readonly SKBitmap _ryujinxLogo = null;
private readonly SKBitmap _padAcceptIcon; private readonly SKBitmap _padAcceptIcon = null;
private readonly SKBitmap _padCancelIcon; private readonly SKBitmap _padCancelIcon = null;
private readonly SKBitmap _keyModeIcon; private readonly SKBitmap _keyModeIcon = null;
private readonly float _textBoxOutlineWidth; private readonly float _textBoxOutlineWidth;
private readonly float _padPressedPenWidth; private readonly float _padPressedPenWidth;

View file

@ -25,8 +25,8 @@ namespace Ryujinx.HLE.HOS.Applets.SoftwareKeyboard
} }
} }
private TRef<bool> _cancelled; private TRef<bool> _cancelled = null;
private Thread _thread; private Thread _thread = null;
private readonly Lock _lock = new(); private readonly Lock _lock = new();
public bool IsRunning public bool IsRunning

View file

@ -3,7 +3,7 @@ using Ryujinx.HLE.HOS.Kernel.Threading;
namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
{ {
class SyscallHandler partial class SyscallHandler
{ {
private readonly KernelContext _context; private readonly KernelContext _context;

View file

@ -6,7 +6,7 @@ using System.Threading;
namespace Ryujinx.HLE.HOS.Kernel.Threading namespace Ryujinx.HLE.HOS.Kernel.Threading
{ {
class KScheduler : IDisposable partial class KScheduler : IDisposable
{ {
public const int PrioritiesCount = 64; public const int PrioritiesCount = 64;
public static int CpuCoresCount; public static int CpuCoresCount;

View file

@ -4,6 +4,7 @@ using Ryujinx.Common.Utilities;
using Ryujinx.HLE.HOS.Services.Account.Acc.Types; using Ryujinx.HLE.HOS.Services.Account.Acc.Types;
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO; using System.IO;
namespace Ryujinx.HLE.HOS.Services.Account.Acc namespace Ryujinx.HLE.HOS.Services.Account.Acc

View file

@ -26,21 +26,21 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
// TODO: Determine where those fields are used. // TODO: Determine where those fields are used.
#pragma warning disable IDE0052 // Remove unread private member #pragma warning disable IDE0052 // Remove unread private member
private bool _screenShotPermission; private bool _screenShotPermission = false;
private bool _operationModeChangedNotification; private bool _operationModeChangedNotification = false;
private bool _performanceModeChangedNotification; private bool _performanceModeChangedNotification = false;
private bool _restartMessageEnabled; private bool _restartMessageEnabled = false;
private bool _outOfFocusSuspendingEnabled; private bool _outOfFocusSuspendingEnabled = false;
private bool _handlesRequestToDisplay; private bool _handlesRequestToDisplay = false;
#pragma warning restore IDE0052 #pragma warning restore IDE0052
private bool _autoSleepDisabled; private bool _autoSleepDisabled = false;
#pragma warning disable IDE0052 // Remove unread private member #pragma warning disable IDE0052 // Remove unread private member
private bool _albumImageTakenNotificationEnabled; private bool _albumImageTakenNotificationEnabled = false;
private bool _recordVolumeMuted; private bool _recordVolumeMuted = false;
private uint _screenShotImageOrientation; private uint _screenShotImageOrientation = 0;
#pragma warning restore IDE0052 #pragma warning restore IDE0052
private uint _idleTimeDetectionExtension; private uint _idleTimeDetectionExtension = 0;
public ISelfController(ServiceCtx context, ulong pid) public ISelfController(ServiceCtx context, ulong pid)
{ {

View file

@ -11,7 +11,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Irs
[Service("irs")] [Service("irs")]
class IIrSensorServer : IpcService class IIrSensorServer : IpcService
{ {
private int _irsensorSharedMemoryHandle; private int _irsensorSharedMemoryHandle = 0;
public IIrSensorServer(ServiceCtx context) { } public IIrSensorServer(ServiceCtx context) { }

View file

@ -10,8 +10,8 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.Lp2p
{ {
private readonly KEvent _stateChangeEvent; private readonly KEvent _stateChangeEvent;
private readonly KEvent _jointEvent; private readonly KEvent _jointEvent;
private int _stateChangeEventHandle; private int _stateChangeEventHandle = 0;
private int _jointEventHandle; private int _jointEventHandle = 0;
public ISfServiceMonitor(ServiceCtx context) public ISfServiceMonitor(ServiceCtx context)
{ {

View file

@ -22,7 +22,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu
{ {
public bool NeedsRealId => true; public bool NeedsRealId => true;
private static InitializeMessage InitializeMemory; private static InitializeMessage InitializeMemory = new InitializeMessage();
private const int InactiveTimeout = 6000; private const int InactiveTimeout = 6000;
private const int FailureTimeout = 4000; private const int FailureTimeout = 4000;

View file

@ -16,7 +16,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu
private readonly int _headerSize = Marshal.SizeOf<LdnHeader>(); private readonly int _headerSize = Marshal.SizeOf<LdnHeader>();
private readonly byte[] _buffer = new byte[MaxPacketSize]; private readonly byte[] _buffer = new byte[MaxPacketSize];
private int _bufferEnd; private int _bufferEnd = 0;
// Client Packets. // Client Packets.
public event Action<LdnHeader, InitializeMessage> Initialize; public event Action<LdnHeader, InitializeMessage> Initialize;
@ -312,6 +312,9 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu
break; break;
} }
default:
break;
} }
} }

View file

@ -12,7 +12,7 @@ namespace Ryujinx.HLE.HOS.Services.Mii
class MiiDatabaseManager class MiiDatabaseManager
{ {
private readonly bool _isTestModeEnabled = false; private readonly bool _isTestModeEnabled = false;
private uint _mountCounter; private uint _mountCounter = 0;
private const ulong DatabaseTestSaveDataId = 0x8000000000000031; private const ulong DatabaseTestSaveDataId = 0x8000000000000031;
private const ulong DatabaseSaveDataId = 0x8000000000000030; private const ulong DatabaseSaveDataId = 0x8000000000000030;

View file

@ -7,6 +7,7 @@ using Ryujinx.HLE.HOS.Services.Mii.Types;
using Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption; using Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption;
using Ryujinx.HLE.HOS.Services.Nfc.Nfp.NfpManager; using Ryujinx.HLE.HOS.Services.Nfc.Nfp.NfpManager;
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;

View file

@ -13,9 +13,9 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService
{ {
private readonly GeneralServiceDetail _generalServiceDetail; private readonly GeneralServiceDetail _generalServiceDetail;
private IPInterfaceProperties _targetPropertiesCache; private IPInterfaceProperties _targetPropertiesCache = null;
private UnicastIPAddressInformation _targetAddressInfoCache; private UnicastIPAddressInformation _targetAddressInfoCache = null;
private string _cacheChosenInterface; private string _cacheChosenInterface = null;
public IGeneralService() public IGeneralService()
{ {

View file

@ -52,7 +52,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv
private IVirtualMemoryManager _clientMemory; private IVirtualMemoryManager _clientMemory;
private ulong _owner; private ulong _owner;
private bool _transferMemInitialized; private bool _transferMemInitialized = false;
// TODO: This should call set:sys::GetDebugModeFlag // TODO: This should call set:sys::GetDebugModeFlag
private readonly bool _debugModeEnabled = false; private readonly bool _debugModeEnabled = false;

View file

@ -17,9 +17,9 @@ namespace Ryujinx.HLE.HOS.Services.Pctl.ParentalControlServiceFactory
// TODO: Find where they are set. // TODO: Find where they are set.
private readonly bool _restrictionEnabled = false; private readonly bool _restrictionEnabled = false;
private readonly bool _featuresRestriction = false; private readonly bool _featuresRestriction = false;
private bool _freeCommunicationEnabled; private bool _freeCommunicationEnabled = false;
private readonly bool _stereoVisionRestrictionConfigurable = true; private readonly bool _stereoVisionRestrictionConfigurable = true;
private bool _stereoVisionRestriction; private bool _stereoVisionRestriction = false;
#pragma warning restore IDE0052, CS0414 #pragma warning restore IDE0052, CS0414
public IParentalControlService(ServiceCtx context, ulong pid, bool withInitialize, int permissionFlag) public IParentalControlService(ServiceCtx context, ulong pid, bool withInitialize, int permissionFlag)

View file

@ -10,7 +10,7 @@ namespace Ryujinx.HLE.HOS.Services.Pcv.Clkrst
[Service("clkrst:i")] // 8.0.0+ [Service("clkrst:i")] // 8.0.0+
class IClkrstManager : IpcService class IClkrstManager : IpcService
{ {
private int _moduleStateTableEventHandle; private int _moduleStateTableEventHandle = 0;
public IClkrstManager(ServiceCtx context) { } public IClkrstManager(ServiceCtx context) { }

View file

@ -40,7 +40,7 @@ namespace Ryujinx.HLE.HOS.Services
private KProcess _selfProcess; private KProcess _selfProcess;
private KThread _selfThread; private KThread _selfThread;
private KEvent _wakeEvent; private KEvent _wakeEvent;
private int _wakeHandle; private int _wakeHandle = 0;
private readonly ReaderWriterLockSlim _handleLock = new(); private readonly ReaderWriterLockSlim _handleLock = new();
private readonly Dictionary<int, IpcService> _sessions = new(); private readonly Dictionary<int, IpcService> _sessions = new();
@ -52,7 +52,7 @@ namespace Ryujinx.HLE.HOS.Services
private readonly MemoryStream _responseDataStream; private readonly MemoryStream _responseDataStream;
private readonly BinaryWriter _responseDataWriter; private readonly BinaryWriter _responseDataWriter;
private int _isDisposed; private int _isDisposed = 0;
public ManualResetEvent InitDone { get; } public ManualResetEvent InitDone { get; }
public string Name { get; } public string Name { get; }

View file

@ -14,7 +14,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
{ {
[Service("bsd:s", true)] [Service("bsd:s", true)]
[Service("bsd:u", false)] [Service("bsd:u", false)]
class IClient(ServiceCtx context, bool isPrivileged) : IpcService(context.Device.System.BsdServer) class IClient : IpcService
{ {
private static readonly List<IPollManager> _pollManagers = private static readonly List<IPollManager> _pollManagers =
[ [
@ -23,6 +23,12 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
]; ];
private BsdContext _context; private BsdContext _context;
private readonly bool _isPrivileged;
public IClient(ServiceCtx context, bool isPrivileged) : base(context.Device.System.BsdServer)
{
_isPrivileged = isPrivileged;
}
private ResultCode WriteBsdResult(ServiceCtx context, int result, LinuxError errorCode = LinuxError.SUCCESS) private ResultCode WriteBsdResult(ServiceCtx context, int result, LinuxError errorCode = LinuxError.SUCCESS)
{ {
@ -73,7 +79,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
{ {
return WriteBsdResult(context, -1, LinuxError.EPROTONOSUPPORT); return WriteBsdResult(context, -1, LinuxError.EPROTONOSUPPORT);
} }
else if ((type == BsdSocketType.Seqpacket || type == BsdSocketType.Raw) && !isPrivileged) else if ((type == BsdSocketType.Seqpacket || type == BsdSocketType.Raw) && !_isPrivileged)
{ {
if (domain != BsdAddressFamily.InterNetwork || type != BsdSocketType.Raw || protocol != ProtocolType.Icmp) if (domain != BsdAddressFamily.InterNetwork || type != BsdSocketType.Raw || protocol != ProtocolType.Icmp)
{ {
@ -1034,7 +1040,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
LinuxError errno = LinuxError.ENOENT; LinuxError errno = LinuxError.ENOENT;
int newSockFd = -1; int newSockFd = -1;
if (isPrivileged) if (_isPrivileged)
{ {
errno = LinuxError.SUCCESS; errno = LinuxError.SUCCESS;

View file

@ -1,5 +1,6 @@
using Ryujinx.Common.Logging; using Ryujinx.Common.Logging;
using Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy; using Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy;
using Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;

View file

@ -18,7 +18,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Nsd
private readonly FqdnResolver _fqdnResolver; private readonly FqdnResolver _fqdnResolver;
#pragma warning restore IDE0052 #pragma warning restore IDE0052
private readonly bool _isInitialized; private readonly bool _isInitialized = false;
public IManager(ServiceCtx context) public IManager(ServiceCtx context)
{ {

View file

@ -44,6 +44,8 @@ namespace Ryujinx.HLE.HOS.Services.Spl
configValue = (ulong)HardwareState.Development; configValue = (ulong)HardwareState.Development;
result = SmcResult.Success; result = SmcResult.Success;
break; break;
default:
break;
} }
} }

View file

@ -792,6 +792,8 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
freeSlot = slot; freeSlot = slot;
} }
break; break;
default:
break;
} }
} }

View file

@ -10,7 +10,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
{ {
private static readonly Dictionary<int, IBinder> _registeredBinderObjects = new(); private static readonly Dictionary<int, IBinder> _registeredBinderObjects = new();
private static int _lastBinderId; private static int _lastBinderId = 0;
private static readonly Lock _lock = new(); private static readonly Lock _lock = new();

View file

@ -21,7 +21,7 @@ namespace Ryujinx.HLE.HOS.Services.Time
private readonly TimeManager _timeManager; private readonly TimeManager _timeManager;
private readonly TimePermissions _permissions; private readonly TimePermissions _permissions;
private int _timeSharedMemoryNativeHandle; private int _timeSharedMemoryNativeHandle = 0;
public IStaticServiceForPsc(ServiceCtx context, TimePermissions permissions) : this(TimeManager.Instance, permissions) { } public IStaticServiceForPsc(ServiceCtx context, TimePermissions permissions) : this(TimeManager.Instance, permissions) { }

View file

@ -5,7 +5,7 @@ namespace Ryujinx.HLE.HOS.Tamper
{ {
class Register : IOperand class Register : IOperand
{ {
private ulong _register; private ulong _register = 0;
private readonly string _alias; private readonly string _alias;
public Register(string alias) public Register(string alias)

View file

@ -11,7 +11,7 @@ namespace Ryujinx.HLE.HOS.Tamper
public ProcessState State => _process.State; public ProcessState State => _process.State;
public bool TamperedCodeMemory { get; set; } public bool TamperedCodeMemory { get; set; } = false;
public TamperedKProcess(KProcess process) public TamperedKProcess(KProcess process)
{ {

View file

@ -16,9 +16,9 @@ namespace Ryujinx.HLE.HOS
// cheat and the re-execution of the first one. // cheat and the re-execution of the first one.
private const int TamperMachineSleepMs = 1000 / 12; private const int TamperMachineSleepMs = 1000 / 12;
private Thread _tamperThread; private Thread _tamperThread = null;
private readonly ConcurrentQueue<ITamperProgram> _programs = new(); private readonly ConcurrentQueue<ITamperProgram> _programs = new();
private long _pressedKeys; private long _pressedKeys = 0;
private readonly Dictionary<string, ITamperProgram> _programDictionary = new(); private readonly Dictionary<string, ITamperProgram> _programDictionary = new();
private void Activate() private void Activate()

View file

@ -2,6 +2,7 @@ using Ryujinx.Common;
using Ryujinx.Horizon.Common; using Ryujinx.Horizon.Common;
using Ryujinx.Horizon.Sdk.Sf; using Ryujinx.Horizon.Sdk.Sf;
using Ryujinx.Horizon.Sdk.Sf.Hipc; using Ryujinx.Horizon.Sdk.Sf.Hipc;
using System;
namespace Ryujinx.Horizon.Sdk.Codec.Detail namespace Ryujinx.Horizon.Sdk.Codec.Detail
{ {

View file

@ -9,11 +9,20 @@ namespace Ryujinx.Horizon.Sdk.Ngc.Detail
private const int CompressedEntriesPerBlock = 64; private const int CompressedEntriesPerBlock = 64;
private const int BitsPerWord = Set.BitsPerWord; private const int BitsPerWord = Set.BitsPerWord;
private readonly struct BitfieldRange(uint range, int baseValue) private readonly struct BitfieldRange
{ {
public int BitfieldIndex => (int)(range & 0x7ffffff); private readonly uint _range;
public int BitfieldLength => (int)(range >> 27) + 1; private readonly int _baseValue;
public int BaseValue => baseValue;
public int BitfieldIndex => (int)(_range & 0x7ffffff);
public int BitfieldLength => (int)(_range >> 27) + 1;
public int BaseValue => _baseValue;
public BitfieldRange(uint range, int baseValue)
{
_range = range;
_baseValue = baseValue;
}
} }
private uint[] _bitfieldRanges; private uint[] _bitfieldRanges;

View file

@ -1,4 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.Threading; using System.Threading;
namespace Ryujinx.Horizon.Sdk.OsTypes namespace Ryujinx.Horizon.Sdk.OsTypes

View file

@ -1,6 +1,7 @@
using Ryujinx.Memory.Range; using Ryujinx.Memory.Range;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
namespace Ryujinx.Memory namespace Ryujinx.Memory

View file

@ -19,7 +19,7 @@ namespace Ryujinx.Memory
_length = length; _length = length;
} }
public T* Pointer => _pointer; public unsafe T* Pointer => _pointer;
public int Length => _length; public int Length => _length;

View file

@ -60,8 +60,8 @@ namespace Ryujinx.Memory.Tracking
private readonly MemoryTracking _tracking; private readonly MemoryTracking _tracking;
private bool _disposed; private bool _disposed;
private int _checkCount; private int _checkCount = 0;
private int _volatileCount; private int _volatileCount = 0;
private bool _volatile; private bool _volatile;
internal MemoryPermission RequiredPermission internal MemoryPermission RequiredPermission

View file

@ -1,4 +1,5 @@
using NUnit.Framework; using NUnit.Framework;
using System;
namespace Ryujinx.Tests.Cpu namespace Ryujinx.Tests.Cpu
{ {

View file

@ -795,10 +795,10 @@ namespace Ryujinx.UI.App.Common
{ {
ldnWebHost = DefaultLanPlayWebHost; ldnWebHost = DefaultLanPlayWebHost;
} }
IEnumerable<LdnGameData> ldnGameDataArray = Array.Empty<LdnGameData>();
using HttpClient httpClient = new HttpClient(); using HttpClient httpClient = new HttpClient();
string ldnGameDataArrayString = await httpClient.GetStringAsync($"https://{ldnWebHost}/api/public_games"); string ldnGameDataArrayString = await httpClient.GetStringAsync($"https://{ldnWebHost}/api/public_games");
IEnumerable<LdnGameData> ldnGameDataArray = JsonHelper.Deserialize(ldnGameDataArrayString, _ldnDataSerializerContext.IEnumerableLdnGameData); ldnGameDataArray = JsonHelper.Deserialize(ldnGameDataArrayString, _ldnDataSerializerContext.IEnumerableLdnGameData);
var evt = new LdnGameDataReceivedEventArgs var evt = new LdnGameDataReceivedEventArgs
{ {
LdnData = ldnGameDataArray LdnData = ldnGameDataArray

View file

@ -12,7 +12,7 @@ namespace Ryujinx.UI.App.Common
public TimeSpan TimePlayed { get; set; } = TimeSpan.Zero; public TimeSpan TimePlayed { get; set; } = TimeSpan.Zero;
[JsonPropertyName("last_played_utc")] [JsonPropertyName("last_played_utc")]
public DateTime? LastPlayed { get; set; } public DateTime? LastPlayed { get; set; } = null;
[JsonPropertyName("time_played")] [JsonPropertyName("time_played")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]

View file

@ -13,6 +13,7 @@ using Ryujinx.UI.Common.Helper;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Text.Json.Nodes;
namespace Ryujinx.UI.Common.Configuration namespace Ryujinx.UI.Common.Configuration
{ {
@ -25,23 +26,44 @@ namespace Ryujinx.UI.Common.Configuration
{ {
public class Columns public class Columns
{ {
public ReactiveObject<bool> FavColumn { get; private set; } = new(); public ReactiveObject<bool> FavColumn { get; private set; }
public ReactiveObject<bool> IconColumn { get; private set; } = new(); public ReactiveObject<bool> IconColumn { get; private set; }
public ReactiveObject<bool> AppColumn { get; private set; } = new(); public ReactiveObject<bool> AppColumn { get; private set; }
public ReactiveObject<bool> DevColumn { get; private set; } = new(); public ReactiveObject<bool> DevColumn { get; private set; }
public ReactiveObject<bool> VersionColumn { get; private set; } = new(); public ReactiveObject<bool> VersionColumn { get; private set; }
public ReactiveObject<bool> LdnInfoColumn { get; private set; } = new(); public ReactiveObject<bool> LdnInfoColumn { get; private set; }
public ReactiveObject<bool> TimePlayedColumn { get; private set; } = new(); public ReactiveObject<bool> TimePlayedColumn { get; private set; }
public ReactiveObject<bool> LastPlayedColumn { get; private set; } = new(); public ReactiveObject<bool> LastPlayedColumn { get; private set; }
public ReactiveObject<bool> FileExtColumn { get; private set; } = new(); public ReactiveObject<bool> FileExtColumn { get; private set; }
public ReactiveObject<bool> FileSizeColumn { get; private set; } = new(); public ReactiveObject<bool> FileSizeColumn { get; private set; }
public ReactiveObject<bool> PathColumn { get; private set; } = new(); public ReactiveObject<bool> PathColumn { get; private set; }
public Columns()
{
FavColumn = new ReactiveObject<bool>();
IconColumn = new ReactiveObject<bool>();
AppColumn = new ReactiveObject<bool>();
DevColumn = new ReactiveObject<bool>();
VersionColumn = new ReactiveObject<bool>();
LdnInfoColumn = new ReactiveObject<bool>();
TimePlayedColumn = new ReactiveObject<bool>();
LastPlayedColumn = new ReactiveObject<bool>();
FileExtColumn = new ReactiveObject<bool>();
FileSizeColumn = new ReactiveObject<bool>();
PathColumn = new ReactiveObject<bool>();
}
} }
public class ColumnSortSettings public class ColumnSortSettings
{ {
public ReactiveObject<int> SortColumnId { get; private set; } = new(); public ReactiveObject<int> SortColumnId { get; private set; }
public ReactiveObject<bool> SortAscending { get; private set; } = new(); public ReactiveObject<bool> SortAscending { get; private set; }
public ColumnSortSettings()
{
SortColumnId = new ReactiveObject<int>();
SortAscending = new ReactiveObject<bool>();
}
} }
/// <summary> /// <summary>
@ -49,12 +71,22 @@ namespace Ryujinx.UI.Common.Configuration
/// </summary> /// </summary>
public class ShownFileTypeSettings public class ShownFileTypeSettings
{ {
public ReactiveObject<bool> NSP { get; private set; } = new(); public ReactiveObject<bool> NSP { get; private set; }
public ReactiveObject<bool> PFS0 { get; private set; } = new(); public ReactiveObject<bool> PFS0 { get; private set; }
public ReactiveObject<bool> XCI { get; private set; } = new(); public ReactiveObject<bool> XCI { get; private set; }
public ReactiveObject<bool> NCA { get; private set; } = new(); public ReactiveObject<bool> NCA { get; private set; }
public ReactiveObject<bool> NRO { get; private set; } = new(); public ReactiveObject<bool> NRO { get; private set; }
public ReactiveObject<bool> NSO { get; private set; } = new(); public ReactiveObject<bool> NSO { get; private set; }
public ShownFileTypeSettings()
{
NSP = new ReactiveObject<bool>();
PFS0 = new ReactiveObject<bool>();
XCI = new ReactiveObject<bool>();
NCA = new ReactiveObject<bool>();
NRO = new ReactiveObject<bool>();
NSO = new ReactiveObject<bool>();
}
} }
// <summary> // <summary>
@ -62,11 +94,20 @@ namespace Ryujinx.UI.Common.Configuration
///<summary> ///<summary>
public class WindowStartupSettings public class WindowStartupSettings
{ {
public ReactiveObject<int> WindowSizeWidth { get; private set; } = new(); public ReactiveObject<int> WindowSizeWidth { get; private set; }
public ReactiveObject<int> WindowSizeHeight { get; private set; } = new(); public ReactiveObject<int> WindowSizeHeight { get; private set; }
public ReactiveObject<int> WindowPositionX { get; private set; } = new(); public ReactiveObject<int> WindowPositionX { get; private set; }
public ReactiveObject<int> WindowPositionY { get; private set; } = new(); public ReactiveObject<int> WindowPositionY { get; private set; }
public ReactiveObject<bool> WindowMaximized { get; private set; } = new(); public ReactiveObject<bool> WindowMaximized { get; private set; }
public WindowStartupSettings()
{
WindowSizeWidth = new ReactiveObject<int>();
WindowSizeHeight = new ReactiveObject<int>();
WindowPositionX = new ReactiveObject<int>();
WindowPositionY = new ReactiveObject<int>();
WindowMaximized = new ReactiveObject<bool>();
}
} }
/// <summary> /// <summary>
@ -380,24 +421,32 @@ namespace Ryujinx.UI.Common.Configuration
/// <summary> /// <summary>
/// Enable or disable keyboard support (Independent from controllers binding) /// Enable or disable keyboard support (Independent from controllers binding)
/// </summary> /// </summary>
public ReactiveObject<bool> EnableKeyboard { get; private set; } = new(); public ReactiveObject<bool> EnableKeyboard { get; private set; }
/// <summary> /// <summary>
/// Enable or disable mouse support (Independent from controllers binding) /// Enable or disable mouse support (Independent from controllers binding)
/// </summary> /// </summary>
public ReactiveObject<bool> EnableMouse { get; private set; } = new(); public ReactiveObject<bool> EnableMouse { get; private set; }
/// <summary> /// <summary>
/// Hotkey Keyboard Bindings /// Hotkey Keyboard Bindings
/// </summary> /// </summary>
public ReactiveObject<KeyboardHotkeys> Hotkeys { get; private set; } = new(); public ReactiveObject<KeyboardHotkeys> Hotkeys { get; private set; }
/// <summary> /// <summary>
/// Input device configuration. /// Input device configuration.
/// NOTE: This ReactiveObject won't issue an event when the List has elements added or removed. /// NOTE: This ReactiveObject won't issue an event when the List has elements added or removed.
/// TODO: Implement a ReactiveList class. /// TODO: Implement a ReactiveList class.
/// </summary> /// </summary>
public ReactiveObject<List<InputConfig>> InputConfig { get; private set; } = new(); public ReactiveObject<List<InputConfig>> InputConfig { get; private set; }
public HidSection()
{
EnableKeyboard = new ReactiveObject<bool>();
EnableMouse = new ReactiveObject<bool>();
Hotkeys = new ReactiveObject<KeyboardHotkeys>();
InputConfig = new ReactiveObject<List<InputConfig>>();
}
} }
/// <summary> /// <summary>

Some files were not shown because too many files have changed in this diff Show more