Compare commits
14 Commits
Author | SHA1 | Date | |
---|---|---|---|
e85ee673b1 | |||
42f22fe5d7 | |||
263eb97f79 | |||
3004902257 | |||
59ddb26628 | |||
83fda10f6e | |||
d97e995e59 | |||
56b2f84702 | |||
698e36bbd2 | |||
6ce49a2dc7 | |||
ccd330ba0f | |||
95d252b7b8 | |||
add681144b | |||
c6dc00815a |
@ -13,14 +13,14 @@
|
||||
<PackageVersion Include="CommandLineParser" Version="2.9.1" />
|
||||
<PackageVersion Include="Concentus" Version="2.2.0" />
|
||||
<PackageVersion Include="DiscordRichPresence" Version="1.2.1.24" />
|
||||
<PackageVersion Include="DynamicData" Version="8.4.1" />
|
||||
<PackageVersion Include="DynamicData" Version="9.0.1" />
|
||||
<PackageVersion Include="FluentAvaloniaUI" Version="2.0.5" />
|
||||
<PackageVersion Include="GtkSharp.Dependencies" Version="1.1.1" />
|
||||
<PackageVersion Include="GtkSharp.Dependencies.osx" Version="0.0.5" />
|
||||
<PackageVersion Include="LibHac" Version="0.19.0" />
|
||||
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" />
|
||||
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.9.2" />
|
||||
<PackageVersion Include="Microsoft.IdentityModel.JsonWebTokens" Version="7.6.2" />
|
||||
<PackageVersion Include="Microsoft.IdentityModel.JsonWebTokens" Version="8.0.1" />
|
||||
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
|
||||
<PackageVersion Include="Microsoft.IO.RecyclableMemoryStream" Version="3.0.1" />
|
||||
<PackageVersion Include="MsgPack.Cli" Version="1.0.1" />
|
||||
|
@ -18,16 +18,12 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
|
||||
|
||||
if (version == 2)
|
||||
{
|
||||
return (ulong)PerformanceManagerGeneric<PerformanceFrameHeaderVersion2,
|
||||
PerformanceEntryVersion2,
|
||||
PerformanceDetailVersion2>.GetRequiredBufferSizeForPerformanceMetricsPerFrame(ref parameter);
|
||||
return (ulong)PerformanceManagerGeneric<PerformanceFrameHeaderVersion2, PerformanceEntryVersion2, PerformanceDetailVersion2>.GetRequiredBufferSizeForPerformanceMetricsPerFrame(ref parameter);
|
||||
}
|
||||
|
||||
if (version == 1)
|
||||
{
|
||||
return (ulong)PerformanceManagerGeneric<PerformanceFrameHeaderVersion1,
|
||||
PerformanceEntryVersion1,
|
||||
PerformanceDetailVersion1>.GetRequiredBufferSizeForPerformanceMetricsPerFrame(ref parameter);
|
||||
return (ulong)PerformanceManagerGeneric<PerformanceFrameHeaderVersion1, PerformanceEntryVersion1, PerformanceDetailVersion1>.GetRequiredBufferSizeForPerformanceMetricsPerFrame(ref parameter);
|
||||
}
|
||||
|
||||
throw new NotImplementedException($"Unknown Performance metrics data format version {version}");
|
||||
|
@ -234,7 +234,7 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
|
||||
{
|
||||
performanceEntry = null;
|
||||
|
||||
if (_entryDetailIndex > MaxFrameDetailCount)
|
||||
if (_entryDetailIndex >= MaxFrameDetailCount)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -245,7 +245,7 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
|
||||
EntryCountOffset = (uint)CurrentHeader.GetEntryCountOffset(),
|
||||
};
|
||||
|
||||
uint baseEntryOffset = (uint)(Unsafe.SizeOf<THeader>() + GetEntriesSize() + Unsafe.SizeOf<IPerformanceDetailEntry>() * _entryDetailIndex);
|
||||
uint baseEntryOffset = (uint)(Unsafe.SizeOf<THeader>() + GetEntriesSize() + Unsafe.SizeOf<TEntryDetail>() * _entryDetailIndex);
|
||||
|
||||
ref TEntryDetail entryDetail = ref EntriesDetail[_entryDetailIndex];
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
using Ryujinx.Common.Memory;
|
||||
using Ryujinx.Memory;
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
@ -145,9 +144,9 @@ namespace Ryujinx.Graphics.Device
|
||||
}
|
||||
else
|
||||
{
|
||||
IMemoryOwner<byte> memoryOwner = ByteMemoryPool.Rent(size);
|
||||
MemoryOwner<byte> memoryOwner = MemoryOwner<byte>.Rent(size);
|
||||
|
||||
GetSpan(va, size).CopyTo(memoryOwner.Memory.Span);
|
||||
ReadImpl(va, memoryOwner.Span);
|
||||
|
||||
return new WritableRegion(this, va, memoryOwner, tracked: true);
|
||||
}
|
||||
|
@ -199,7 +199,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.InlineToMemory
|
||||
if (target != null)
|
||||
{
|
||||
target.SynchronizeMemory();
|
||||
var dataCopy = ByteMemoryPool.RentCopy(data);
|
||||
var dataCopy = MemoryOwner<byte>.RentCopy(data);
|
||||
target.SetData(dataCopy, 0, 0, new GAL.Rectangle<int>(_dstX, _dstY, _lineLengthIn / target.Info.FormatInfo.BytesPerPixel, _lineCount));
|
||||
target.SignalModified();
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Common.Memory;
|
||||
using Ryujinx.Graphics.GAL;
|
||||
using Ryujinx.Graphics.Gpu.Memory;
|
||||
using Ryujinx.Graphics.Texture;
|
||||
@ -805,7 +806,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||
sliceDepth,
|
||||
levels,
|
||||
layers,
|
||||
out IMemoryOwner<byte> decoded))
|
||||
out MemoryOwner<byte> decoded))
|
||||
{
|
||||
string texInfo = $"{Info.Target} {Info.FormatInfo.Format} {Info.Width}x{Info.Height}x{Info.DepthOrLayers} levels {Info.Levels}";
|
||||
|
||||
|
@ -2,7 +2,6 @@ using Ryujinx.Common.Memory;
|
||||
using Ryujinx.Memory;
|
||||
using Ryujinx.Memory.Range;
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
@ -242,9 +241,9 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
||||
}
|
||||
else
|
||||
{
|
||||
IMemoryOwner<byte> memoryOwner = ByteMemoryPool.Rent(size);
|
||||
MemoryOwner<byte> memoryOwner = MemoryOwner<byte>.Rent(size);
|
||||
|
||||
GetSpan(va, size).CopyTo(memoryOwner.Memory.Span);
|
||||
ReadImpl(va, memoryOwner.Span, tracked);
|
||||
|
||||
return new WritableRegion(this, va, memoryOwner, tracked);
|
||||
}
|
||||
|
@ -192,9 +192,9 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
||||
}
|
||||
else
|
||||
{
|
||||
IMemoryOwner<byte> memoryOwner = ByteMemoryPool.Rent(range.GetSize());
|
||||
MemoryOwner<byte> memoryOwner = MemoryOwner<byte>.Rent(checked((int)range.GetSize()));
|
||||
|
||||
Memory<byte> memory = memoryOwner.Memory;
|
||||
Span<byte> memorySpan = memoryOwner.Span;
|
||||
|
||||
int offset = 0;
|
||||
for (int i = 0; i < range.Count; i++)
|
||||
@ -203,7 +203,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
||||
int size = (int)currentRange.Size;
|
||||
if (currentRange.Address != MemoryManager.PteUnmapped)
|
||||
{
|
||||
GetSpan(currentRange.Address, size).CopyTo(memory.Span.Slice(offset, size));
|
||||
GetSpan(currentRange.Address, size).CopyTo(memorySpan.Slice(offset, size));
|
||||
}
|
||||
offset += size;
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
|
||||
private const ushort FileFormatVersionMajor = 1;
|
||||
private const ushort FileFormatVersionMinor = 2;
|
||||
private const uint FileFormatVersionPacked = ((uint)FileFormatVersionMajor << 16) | FileFormatVersionMinor;
|
||||
private const uint CodeGenVersion = 6921;
|
||||
private const uint CodeGenVersion = 7131;
|
||||
|
||||
private const string SharedTocFileName = "shared.toc";
|
||||
private const string SharedDataFileName = "shared.data";
|
||||
|
@ -1,6 +1,5 @@
|
||||
using Ryujinx.Common.Memory;
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Numerics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Intrinsics;
|
||||
@ -10,11 +9,11 @@ namespace Ryujinx.Graphics.OpenGL.Image
|
||||
{
|
||||
static class FormatConverter
|
||||
{
|
||||
public unsafe static IMemoryOwner<byte> ConvertS8D24ToD24S8(ReadOnlySpan<byte> data)
|
||||
public unsafe static MemoryOwner<byte> ConvertS8D24ToD24S8(ReadOnlySpan<byte> data)
|
||||
{
|
||||
IMemoryOwner<byte> outputMemory = ByteMemoryPool.Rent(data.Length);
|
||||
MemoryOwner<byte> outputMemory = MemoryOwner<byte>.Rent(data.Length);
|
||||
|
||||
Span<byte> output = outputMemory.Memory.Span;
|
||||
Span<byte> output = outputMemory.Span;
|
||||
|
||||
int start = 0;
|
||||
|
||||
|
@ -155,9 +155,14 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||
localInputs[block.Index] |= GetMask(register) & ~localOutputs[block.Index];
|
||||
}
|
||||
|
||||
if (operation.Dest != null && operation.Dest.Type == OperandType.Register)
|
||||
for (int dstIndex = 0; dstIndex < operation.DestsCount; dstIndex++)
|
||||
{
|
||||
localOutputs[block.Index] |= GetMask(operation.Dest.GetRegister());
|
||||
Operand dest = operation.GetDest(dstIndex);
|
||||
|
||||
if (dest != null && dest.Type == OperandType.Register)
|
||||
{
|
||||
localOutputs[block.Index] |= GetMask(dest.GetRegister());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
using Ryujinx.Common.Memory;
|
||||
using Ryujinx.Common.Utilities;
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
@ -293,9 +292,9 @@ namespace Ryujinx.Graphics.Texture.Astc
|
||||
int depth,
|
||||
int levels,
|
||||
int layers,
|
||||
out IMemoryOwner<byte> decoded)
|
||||
out MemoryOwner<byte> decoded)
|
||||
{
|
||||
decoded = ByteMemoryPool.Rent(QueryDecompressedSize(width, height, depth, levels, layers));
|
||||
decoded = MemoryOwner<byte>.Rent(QueryDecompressedSize(width, height, depth, levels, layers));
|
||||
|
||||
AstcDecoder decoder = new(data, decoded.Memory, blockWidth, blockHeight, width, height, depth, levels, layers);
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Common.Memory;
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Buffers.Binary;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Intrinsics;
|
||||
@ -14,7 +13,7 @@ namespace Ryujinx.Graphics.Texture
|
||||
private const int BlockWidth = 4;
|
||||
private const int BlockHeight = 4;
|
||||
|
||||
public static IMemoryOwner<byte> DecodeBC1(ReadOnlySpan<byte> data, int width, int height, int depth, int levels, int layers)
|
||||
public static MemoryOwner<byte> DecodeBC1(ReadOnlySpan<byte> data, int width, int height, int depth, int levels, int layers)
|
||||
{
|
||||
int size = 0;
|
||||
|
||||
@ -23,12 +22,12 @@ namespace Ryujinx.Graphics.Texture
|
||||
size += Math.Max(1, width >> l) * Math.Max(1, height >> l) * Math.Max(1, depth >> l) * layers * 4;
|
||||
}
|
||||
|
||||
IMemoryOwner<byte> output = ByteMemoryPool.Rent(size);
|
||||
MemoryOwner<byte> output = MemoryOwner<byte>.Rent(size);
|
||||
|
||||
Span<byte> tile = stackalloc byte[BlockWidth * BlockHeight * 4];
|
||||
|
||||
Span<uint> tileAsUint = MemoryMarshal.Cast<byte, uint>(tile);
|
||||
Span<uint> outputAsUint = MemoryMarshal.Cast<byte, uint>(output.Memory.Span);
|
||||
Span<uint> outputAsUint = MemoryMarshal.Cast<byte, uint>(output.Span);
|
||||
|
||||
Span<Vector128<byte>> tileAsVector128 = MemoryMarshal.Cast<byte, Vector128<byte>>(tile);
|
||||
|
||||
@ -102,7 +101,7 @@ namespace Ryujinx.Graphics.Texture
|
||||
return output;
|
||||
}
|
||||
|
||||
public static IMemoryOwner<byte> DecodeBC2(ReadOnlySpan<byte> data, int width, int height, int depth, int levels, int layers)
|
||||
public static MemoryOwner<byte> DecodeBC2(ReadOnlySpan<byte> data, int width, int height, int depth, int levels, int layers)
|
||||
{
|
||||
int size = 0;
|
||||
|
||||
@ -111,12 +110,12 @@ namespace Ryujinx.Graphics.Texture
|
||||
size += Math.Max(1, width >> l) * Math.Max(1, height >> l) * Math.Max(1, depth >> l) * layers * 4;
|
||||
}
|
||||
|
||||
IMemoryOwner<byte> output = ByteMemoryPool.Rent(size);
|
||||
MemoryOwner<byte> output = MemoryOwner<byte>.Rent(size);
|
||||
|
||||
Span<byte> tile = stackalloc byte[BlockWidth * BlockHeight * 4];
|
||||
|
||||
Span<uint> tileAsUint = MemoryMarshal.Cast<byte, uint>(tile);
|
||||
Span<uint> outputAsUint = MemoryMarshal.Cast<byte, uint>(output.Memory.Span);
|
||||
Span<uint> outputAsUint = MemoryMarshal.Cast<byte, uint>(output.Span);
|
||||
|
||||
Span<Vector128<byte>> tileAsVector128 = MemoryMarshal.Cast<byte, Vector128<byte>>(tile);
|
||||
|
||||
@ -197,7 +196,7 @@ namespace Ryujinx.Graphics.Texture
|
||||
return output;
|
||||
}
|
||||
|
||||
public static IMemoryOwner<byte> DecodeBC3(ReadOnlySpan<byte> data, int width, int height, int depth, int levels, int layers)
|
||||
public static MemoryOwner<byte> DecodeBC3(ReadOnlySpan<byte> data, int width, int height, int depth, int levels, int layers)
|
||||
{
|
||||
int size = 0;
|
||||
|
||||
@ -206,13 +205,13 @@ namespace Ryujinx.Graphics.Texture
|
||||
size += Math.Max(1, width >> l) * Math.Max(1, height >> l) * Math.Max(1, depth >> l) * layers * 4;
|
||||
}
|
||||
|
||||
IMemoryOwner<byte> output = ByteMemoryPool.Rent(size);
|
||||
MemoryOwner<byte> output = MemoryOwner<byte>.Rent(size);
|
||||
|
||||
Span<byte> tile = stackalloc byte[BlockWidth * BlockHeight * 4];
|
||||
Span<byte> rPal = stackalloc byte[8];
|
||||
|
||||
Span<uint> tileAsUint = MemoryMarshal.Cast<byte, uint>(tile);
|
||||
Span<uint> outputAsUint = MemoryMarshal.Cast<byte, uint>(output.Memory.Span);
|
||||
Span<uint> outputAsUint = MemoryMarshal.Cast<byte, uint>(output.Span);
|
||||
|
||||
Span<Vector128<byte>> tileAsVector128 = MemoryMarshal.Cast<byte, Vector128<byte>>(tile);
|
||||
|
||||
@ -294,7 +293,7 @@ namespace Ryujinx.Graphics.Texture
|
||||
return output;
|
||||
}
|
||||
|
||||
public static IMemoryOwner<byte> DecodeBC4(ReadOnlySpan<byte> data, int width, int height, int depth, int levels, int layers, bool signed)
|
||||
public static MemoryOwner<byte> DecodeBC4(ReadOnlySpan<byte> data, int width, int height, int depth, int levels, int layers, bool signed)
|
||||
{
|
||||
int size = 0;
|
||||
|
||||
@ -306,8 +305,8 @@ namespace Ryujinx.Graphics.Texture
|
||||
// Backends currently expect a stride alignment of 4 bytes, so output width must be aligned.
|
||||
int alignedWidth = BitUtils.AlignUp(width, 4);
|
||||
|
||||
IMemoryOwner<byte> output = ByteMemoryPool.Rent(size);
|
||||
Span<byte> outputSpan = output.Memory.Span;
|
||||
MemoryOwner<byte> output = MemoryOwner<byte>.Rent(size);
|
||||
Span<byte> outputSpan = output.Span;
|
||||
|
||||
ReadOnlySpan<ulong> data64 = MemoryMarshal.Cast<byte, ulong>(data);
|
||||
|
||||
@ -402,7 +401,7 @@ namespace Ryujinx.Graphics.Texture
|
||||
return output;
|
||||
}
|
||||
|
||||
public static IMemoryOwner<byte> DecodeBC5(ReadOnlySpan<byte> data, int width, int height, int depth, int levels, int layers, bool signed)
|
||||
public static MemoryOwner<byte> DecodeBC5(ReadOnlySpan<byte> data, int width, int height, int depth, int levels, int layers, bool signed)
|
||||
{
|
||||
int size = 0;
|
||||
|
||||
@ -414,7 +413,7 @@ namespace Ryujinx.Graphics.Texture
|
||||
// Backends currently expect a stride alignment of 4 bytes, so output width must be aligned.
|
||||
int alignedWidth = BitUtils.AlignUp(width, 2);
|
||||
|
||||
IMemoryOwner<byte> output = ByteMemoryPool.Rent(size);
|
||||
MemoryOwner<byte> output = MemoryOwner<byte>.Rent(size);
|
||||
|
||||
ReadOnlySpan<ulong> data64 = MemoryMarshal.Cast<byte, ulong>(data);
|
||||
|
||||
@ -423,7 +422,7 @@ namespace Ryujinx.Graphics.Texture
|
||||
Span<byte> rPal = stackalloc byte[8];
|
||||
Span<byte> gPal = stackalloc byte[8];
|
||||
|
||||
Span<ushort> outputAsUshort = MemoryMarshal.Cast<byte, ushort>(output.Memory.Span);
|
||||
Span<ushort> outputAsUshort = MemoryMarshal.Cast<byte, ushort>(output.Span);
|
||||
|
||||
Span<uint> rTileAsUint = MemoryMarshal.Cast<byte, uint>(rTile);
|
||||
Span<uint> gTileAsUint = MemoryMarshal.Cast<byte, uint>(gTile);
|
||||
@ -527,7 +526,7 @@ namespace Ryujinx.Graphics.Texture
|
||||
return output;
|
||||
}
|
||||
|
||||
public static IMemoryOwner<byte> DecodeBC6(ReadOnlySpan<byte> data, int width, int height, int depth, int levels, int layers, bool signed)
|
||||
public static MemoryOwner<byte> DecodeBC6(ReadOnlySpan<byte> data, int width, int height, int depth, int levels, int layers, bool signed)
|
||||
{
|
||||
int size = 0;
|
||||
|
||||
@ -536,8 +535,8 @@ namespace Ryujinx.Graphics.Texture
|
||||
size += Math.Max(1, width >> l) * Math.Max(1, height >> l) * Math.Max(1, depth >> l) * layers * 8;
|
||||
}
|
||||
|
||||
IMemoryOwner<byte> output = ByteMemoryPool.Rent(size);
|
||||
Span<byte> outputSpan = output.Memory.Span;
|
||||
MemoryOwner<byte> output = MemoryOwner<byte>.Rent(size);
|
||||
Span<byte> outputSpan = output.Span;
|
||||
|
||||
int inputOffset = 0;
|
||||
int outputOffset = 0;
|
||||
@ -566,7 +565,7 @@ namespace Ryujinx.Graphics.Texture
|
||||
return output;
|
||||
}
|
||||
|
||||
public static IMemoryOwner<byte> DecodeBC7(ReadOnlySpan<byte> data, int width, int height, int depth, int levels, int layers)
|
||||
public static MemoryOwner<byte> DecodeBC7(ReadOnlySpan<byte> data, int width, int height, int depth, int levels, int layers)
|
||||
{
|
||||
int size = 0;
|
||||
|
||||
@ -575,8 +574,8 @@ namespace Ryujinx.Graphics.Texture
|
||||
size += Math.Max(1, width >> l) * Math.Max(1, height >> l) * Math.Max(1, depth >> l) * layers * 4;
|
||||
}
|
||||
|
||||
IMemoryOwner<byte> output = ByteMemoryPool.Rent(size);
|
||||
Span<byte> outputSpan = output.Memory.Span;
|
||||
MemoryOwner<byte> output = MemoryOwner<byte>.Rent(size);
|
||||
Span<byte> outputSpan = output.Span;
|
||||
|
||||
int inputOffset = 0;
|
||||
int outputOffset = 0;
|
||||
|
@ -2,7 +2,6 @@ using Ryujinx.Common;
|
||||
using Ryujinx.Common.Memory;
|
||||
using Ryujinx.Graphics.Texture.Encoders;
|
||||
using System;
|
||||
using System.Buffers;
|
||||
|
||||
namespace Ryujinx.Graphics.Texture
|
||||
{
|
||||
@ -11,7 +10,7 @@ namespace Ryujinx.Graphics.Texture
|
||||
private const int BlockWidth = 4;
|
||||
private const int BlockHeight = 4;
|
||||
|
||||
public static IMemoryOwner<byte> EncodeBC7(Memory<byte> data, int width, int height, int depth, int levels, int layers)
|
||||
public static MemoryOwner<byte> EncodeBC7(Memory<byte> data, int width, int height, int depth, int levels, int layers)
|
||||
{
|
||||
int size = 0;
|
||||
|
||||
@ -23,7 +22,7 @@ namespace Ryujinx.Graphics.Texture
|
||||
size += w * h * 16 * Math.Max(1, depth >> l) * layers;
|
||||
}
|
||||
|
||||
IMemoryOwner<byte> output = ByteMemoryPool.Rent(size);
|
||||
MemoryOwner<byte> output = MemoryOwner<byte>.Rent(size);
|
||||
Memory<byte> outputMemory = output.Memory;
|
||||
|
||||
int imageBaseIOffs = 0;
|
||||
|
@ -1,7 +1,6 @@
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Common.Memory;
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Buffers.Binary;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
@ -51,15 +50,15 @@ namespace Ryujinx.Graphics.Texture
|
||||
new int[] { -3, -5, -7, -9, 2, 4, 6, 8 },
|
||||
};
|
||||
|
||||
public static IMemoryOwner<byte> DecodeRgb(ReadOnlySpan<byte> data, int width, int height, int depth, int levels, int layers)
|
||||
public static MemoryOwner<byte> DecodeRgb(ReadOnlySpan<byte> data, int width, int height, int depth, int levels, int layers)
|
||||
{
|
||||
ReadOnlySpan<ulong> dataUlong = MemoryMarshal.Cast<byte, ulong>(data);
|
||||
|
||||
int inputOffset = 0;
|
||||
|
||||
IMemoryOwner<byte> output = ByteMemoryPool.Rent(CalculateOutputSize(width, height, depth, levels, layers));
|
||||
MemoryOwner<byte> output = MemoryOwner<byte>.Rent(CalculateOutputSize(width, height, depth, levels, layers));
|
||||
|
||||
Span<uint> outputUint = MemoryMarshal.Cast<byte, uint>(output.Memory.Span);
|
||||
Span<uint> outputUint = MemoryMarshal.Cast<byte, uint>(output.Span);
|
||||
Span<uint> tile = stackalloc uint[BlockWidth * BlockHeight];
|
||||
|
||||
int imageBaseOOffs = 0;
|
||||
@ -113,15 +112,15 @@ namespace Ryujinx.Graphics.Texture
|
||||
return output;
|
||||
}
|
||||
|
||||
public static IMemoryOwner<byte> DecodePta(ReadOnlySpan<byte> data, int width, int height, int depth, int levels, int layers)
|
||||
public static MemoryOwner<byte> DecodePta(ReadOnlySpan<byte> data, int width, int height, int depth, int levels, int layers)
|
||||
{
|
||||
ReadOnlySpan<ulong> dataUlong = MemoryMarshal.Cast<byte, ulong>(data);
|
||||
|
||||
int inputOffset = 0;
|
||||
|
||||
IMemoryOwner<byte> output = ByteMemoryPool.Rent(CalculateOutputSize(width, height, depth, levels, layers));
|
||||
MemoryOwner<byte> output = MemoryOwner<byte>.Rent(CalculateOutputSize(width, height, depth, levels, layers));
|
||||
|
||||
Span<uint> outputUint = MemoryMarshal.Cast<byte, uint>(output.Memory.Span);
|
||||
Span<uint> outputUint = MemoryMarshal.Cast<byte, uint>(output.Span);
|
||||
Span<uint> tile = stackalloc uint[BlockWidth * BlockHeight];
|
||||
|
||||
int imageBaseOOffs = 0;
|
||||
@ -170,15 +169,15 @@ namespace Ryujinx.Graphics.Texture
|
||||
return output;
|
||||
}
|
||||
|
||||
public static IMemoryOwner<byte> DecodeRgba(ReadOnlySpan<byte> data, int width, int height, int depth, int levels, int layers)
|
||||
public static MemoryOwner<byte> DecodeRgba(ReadOnlySpan<byte> data, int width, int height, int depth, int levels, int layers)
|
||||
{
|
||||
ReadOnlySpan<ulong> dataUlong = MemoryMarshal.Cast<byte, ulong>(data);
|
||||
|
||||
int inputOffset = 0;
|
||||
|
||||
IMemoryOwner<byte> output = ByteMemoryPool.Rent(CalculateOutputSize(width, height, depth, levels, layers));
|
||||
MemoryOwner<byte> output = MemoryOwner<byte>.Rent(CalculateOutputSize(width, height, depth, levels, layers));
|
||||
|
||||
Span<uint> outputUint = MemoryMarshal.Cast<byte, uint>(output.Memory.Span);
|
||||
Span<uint> outputUint = MemoryMarshal.Cast<byte, uint>(output.Span);
|
||||
Span<uint> tile = stackalloc uint[BlockWidth * BlockHeight];
|
||||
|
||||
int imageBaseOOffs = 0;
|
||||
|
@ -1,7 +1,6 @@
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Common.Memory;
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Runtime.Intrinsics;
|
||||
using static Ryujinx.Graphics.Texture.BlockLinearConstants;
|
||||
|
||||
@ -95,7 +94,7 @@ namespace Ryujinx.Graphics.Texture
|
||||
};
|
||||
}
|
||||
|
||||
public static IMemoryOwner<byte> ConvertBlockLinearToLinear(
|
||||
public static MemoryOwner<byte> ConvertBlockLinearToLinear(
|
||||
int width,
|
||||
int height,
|
||||
int depth,
|
||||
@ -121,8 +120,8 @@ namespace Ryujinx.Graphics.Texture
|
||||
blockHeight,
|
||||
bytesPerPixel);
|
||||
|
||||
IMemoryOwner<byte> outputOwner = ByteMemoryPool.Rent(outSize);
|
||||
Span<byte> output = outputOwner.Memory.Span;
|
||||
MemoryOwner<byte> outputOwner = MemoryOwner<byte>.Rent(outSize);
|
||||
Span<byte> output = outputOwner.Span;
|
||||
|
||||
int outOffs = 0;
|
||||
|
||||
@ -249,7 +248,7 @@ namespace Ryujinx.Graphics.Texture
|
||||
return outputOwner;
|
||||
}
|
||||
|
||||
public static IMemoryOwner<byte> ConvertLinearStridedToLinear(
|
||||
public static MemoryOwner<byte> ConvertLinearStridedToLinear(
|
||||
int width,
|
||||
int height,
|
||||
int blockWidth,
|
||||
@ -265,8 +264,8 @@ namespace Ryujinx.Graphics.Texture
|
||||
int outStride = BitUtils.AlignUp(w * bytesPerPixel, HostStrideAlignment);
|
||||
lineSize = Math.Min(lineSize, outStride);
|
||||
|
||||
IMemoryOwner<byte> output = ByteMemoryPool.Rent(h * outStride);
|
||||
Span<byte> outSpan = output.Memory.Span;
|
||||
MemoryOwner<byte> output = MemoryOwner<byte>.Rent(h * outStride);
|
||||
Span<byte> outSpan = output.Span;
|
||||
|
||||
int outOffs = 0;
|
||||
int inOffs = 0;
|
||||
|
@ -1,7 +1,6 @@
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Common.Memory;
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Intrinsics;
|
||||
using System.Runtime.Intrinsics.X86;
|
||||
@ -21,13 +20,14 @@ namespace Ryujinx.Graphics.Texture
|
||||
return (remainder, outRemainder, length / stride);
|
||||
}
|
||||
|
||||
public unsafe static IMemoryOwner<byte> ConvertR4G4ToR4G4B4A4(ReadOnlySpan<byte> data, int width)
|
||||
public unsafe static MemoryOwner<byte> ConvertR4G4ToR4G4B4A4(ReadOnlySpan<byte> data, int width)
|
||||
{
|
||||
IMemoryOwner<byte> output = ByteMemoryPool.Rent(data.Length * 2);
|
||||
MemoryOwner<byte> output = MemoryOwner<byte>.Rent(data.Length * 2);
|
||||
Span<byte> outputSpan = output.Span;
|
||||
|
||||
(int remainder, int outRemainder, int height) = GetLineRemainders(data.Length, width, 1, 2);
|
||||
|
||||
Span<ushort> outputSpan = MemoryMarshal.Cast<byte, ushort>(output.Memory.Span);
|
||||
Span<ushort> outputSpanUInt16 = MemoryMarshal.Cast<byte, ushort>(outputSpan);
|
||||
|
||||
if (remainder == 0)
|
||||
{
|
||||
@ -38,7 +38,7 @@ namespace Ryujinx.Graphics.Texture
|
||||
int sizeTrunc = data.Length & ~7;
|
||||
start = sizeTrunc;
|
||||
|
||||
fixed (byte* inputPtr = data, outputPtr = output.Memory.Span)
|
||||
fixed (byte* inputPtr = data, outputPtr = outputSpan)
|
||||
{
|
||||
for (ulong offset = 0; offset < (ulong)sizeTrunc; offset += 8)
|
||||
{
|
||||
@ -49,7 +49,7 @@ namespace Ryujinx.Graphics.Texture
|
||||
|
||||
for (int i = start; i < data.Length; i++)
|
||||
{
|
||||
outputSpan[i] = data[i];
|
||||
outputSpanUInt16[i] = data[i];
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -61,7 +61,7 @@ namespace Ryujinx.Graphics.Texture
|
||||
{
|
||||
for (int x = 0; x < width; x++)
|
||||
{
|
||||
outputSpan[outOffset++] = data[offset++];
|
||||
outputSpanUInt16[outOffset++] = data[offset++];
|
||||
}
|
||||
|
||||
offset += remainder;
|
||||
@ -72,16 +72,16 @@ namespace Ryujinx.Graphics.Texture
|
||||
return output;
|
||||
}
|
||||
|
||||
public static IMemoryOwner<byte> ConvertR5G6B5ToR8G8B8A8(ReadOnlySpan<byte> data, int width)
|
||||
public static MemoryOwner<byte> ConvertR5G6B5ToR8G8B8A8(ReadOnlySpan<byte> data, int width)
|
||||
{
|
||||
IMemoryOwner<byte> output = ByteMemoryPool.Rent(data.Length * 2);
|
||||
MemoryOwner<byte> output = MemoryOwner<byte>.Rent(data.Length * 2);
|
||||
int offset = 0;
|
||||
int outOffset = 0;
|
||||
|
||||
(int remainder, int outRemainder, int height) = GetLineRemainders(data.Length, width, 2, 4);
|
||||
|
||||
ReadOnlySpan<ushort> inputSpan = MemoryMarshal.Cast<byte, ushort>(data);
|
||||
Span<uint> outputSpan = MemoryMarshal.Cast<byte, uint>(output.Memory.Span);
|
||||
Span<uint> outputSpan = MemoryMarshal.Cast<byte, uint>(output.Span);
|
||||
|
||||
for (int y = 0; y < height; y++)
|
||||
{
|
||||
@ -109,16 +109,16 @@ namespace Ryujinx.Graphics.Texture
|
||||
return output;
|
||||
}
|
||||
|
||||
public static IMemoryOwner<byte> ConvertR5G5B5ToR8G8B8A8(ReadOnlySpan<byte> data, int width, bool forceAlpha)
|
||||
public static MemoryOwner<byte> ConvertR5G5B5ToR8G8B8A8(ReadOnlySpan<byte> data, int width, bool forceAlpha)
|
||||
{
|
||||
IMemoryOwner<byte> output = ByteMemoryPool.Rent(data.Length * 2);
|
||||
MemoryOwner<byte> output = MemoryOwner<byte>.Rent(data.Length * 2);
|
||||
int offset = 0;
|
||||
int outOffset = 0;
|
||||
|
||||
(int remainder, int outRemainder, int height) = GetLineRemainders(data.Length, width, 2, 4);
|
||||
|
||||
ReadOnlySpan<ushort> inputSpan = MemoryMarshal.Cast<byte, ushort>(data);
|
||||
Span<uint> outputSpan = MemoryMarshal.Cast<byte, uint>(output.Memory.Span);
|
||||
Span<uint> outputSpan = MemoryMarshal.Cast<byte, uint>(output.Span);
|
||||
|
||||
for (int y = 0; y < height; y++)
|
||||
{
|
||||
@ -146,16 +146,16 @@ namespace Ryujinx.Graphics.Texture
|
||||
return output;
|
||||
}
|
||||
|
||||
public static IMemoryOwner<byte> ConvertA1B5G5R5ToR8G8B8A8(ReadOnlySpan<byte> data, int width)
|
||||
public static MemoryOwner<byte> ConvertA1B5G5R5ToR8G8B8A8(ReadOnlySpan<byte> data, int width)
|
||||
{
|
||||
IMemoryOwner<byte> output = ByteMemoryPool.Rent(data.Length * 2);
|
||||
MemoryOwner<byte> output = MemoryOwner<byte>.Rent(data.Length * 2);
|
||||
int offset = 0;
|
||||
int outOffset = 0;
|
||||
|
||||
(int remainder, int outRemainder, int height) = GetLineRemainders(data.Length, width, 2, 4);
|
||||
|
||||
ReadOnlySpan<ushort> inputSpan = MemoryMarshal.Cast<byte, ushort>(data);
|
||||
Span<uint> outputSpan = MemoryMarshal.Cast<byte, uint>(output.Memory.Span);
|
||||
Span<uint> outputSpan = MemoryMarshal.Cast<byte, uint>(output.Span);
|
||||
|
||||
for (int y = 0; y < height; y++)
|
||||
{
|
||||
@ -183,16 +183,16 @@ namespace Ryujinx.Graphics.Texture
|
||||
return output;
|
||||
}
|
||||
|
||||
public static IMemoryOwner<byte> ConvertR4G4B4A4ToR8G8B8A8(ReadOnlySpan<byte> data, int width)
|
||||
public static MemoryOwner<byte> ConvertR4G4B4A4ToR8G8B8A8(ReadOnlySpan<byte> data, int width)
|
||||
{
|
||||
IMemoryOwner<byte> output = ByteMemoryPool.Rent(data.Length * 2);
|
||||
MemoryOwner<byte> output = MemoryOwner<byte>.Rent(data.Length * 2);
|
||||
int offset = 0;
|
||||
int outOffset = 0;
|
||||
|
||||
(int remainder, int outRemainder, int height) = GetLineRemainders(data.Length, width, 2, 4);
|
||||
|
||||
ReadOnlySpan<ushort> inputSpan = MemoryMarshal.Cast<byte, ushort>(data);
|
||||
Span<uint> outputSpan = MemoryMarshal.Cast<byte, uint>(output.Memory.Span);
|
||||
Span<uint> outputSpan = MemoryMarshal.Cast<byte, uint>(output.Span);
|
||||
|
||||
for (int y = 0; y < height; y++)
|
||||
{
|
||||
|
@ -211,7 +211,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
IMemoryOwner<byte> dummyTextureData = ByteMemoryPool.RentCleared(4);
|
||||
MemoryOwner<byte> dummyTextureData = MemoryOwner<byte>.RentCleared(4);
|
||||
_dummyTexture.SetData(dummyTextureData);
|
||||
}
|
||||
|
||||
|
@ -439,7 +439,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
{
|
||||
SType = StructureType.PipelineInputAssemblyStateCreateInfo,
|
||||
PrimitiveRestartEnable = primitiveRestartEnable,
|
||||
Topology = Topology,
|
||||
Topology = HasTessellationControlShader ? PrimitiveTopology.PatchList : Topology,
|
||||
};
|
||||
|
||||
var tessellationState = new PipelineTessellationStateCreateInfo
|
||||
|
@ -667,8 +667,36 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
if (PrepareOutputBuffer(cbs, hostSize, buffer, out VkBuffer copyToBuffer, out BufferHolder tempCopyHolder))
|
||||
{
|
||||
// No barrier necessary, as this is a temporary copy buffer.
|
||||
offset = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
BufferHolder.InsertBufferBarrier(
|
||||
_gd,
|
||||
cbs.CommandBuffer,
|
||||
copyToBuffer,
|
||||
BufferHolder.DefaultAccessFlags,
|
||||
AccessFlags.TransferWriteBit,
|
||||
PipelineStageFlags.AllCommandsBit,
|
||||
PipelineStageFlags.TransferBit,
|
||||
offset,
|
||||
outSize);
|
||||
}
|
||||
|
||||
InsertImageBarrier(
|
||||
_gd.Api,
|
||||
cbs.CommandBuffer,
|
||||
image,
|
||||
TextureStorage.DefaultAccessMask,
|
||||
AccessFlags.TransferReadBit,
|
||||
PipelineStageFlags.AllCommandsBit,
|
||||
PipelineStageFlags.TransferBit,
|
||||
Info.Format.ConvertAspectFlags(),
|
||||
FirstLayer + layer,
|
||||
FirstLevel + level,
|
||||
1,
|
||||
1);
|
||||
|
||||
CopyFromOrToBuffer(cbs.CommandBuffer, copyToBuffer, image, hostSize, true, layer, level, 1, 1, singleSlice: true, offset, stride);
|
||||
|
||||
@ -677,6 +705,19 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
CopyDataToOutputBuffer(cbs, tempCopyHolder, autoBuffer, hostSize, range.Offset);
|
||||
tempCopyHolder.Dispose();
|
||||
}
|
||||
else
|
||||
{
|
||||
BufferHolder.InsertBufferBarrier(
|
||||
_gd,
|
||||
cbs.CommandBuffer,
|
||||
copyToBuffer,
|
||||
AccessFlags.TransferWriteBit,
|
||||
BufferHolder.DefaultAccessFlags,
|
||||
PipelineStageFlags.TransferBit,
|
||||
PipelineStageFlags.AllCommandsBit,
|
||||
offset,
|
||||
outSize);
|
||||
}
|
||||
}
|
||||
|
||||
private ReadOnlySpan<byte> GetData(CommandBufferPool cbp, PersistentFlushBuffer flushBuffer)
|
||||
|
@ -256,6 +256,12 @@ namespace Ryujinx
|
||||
MainWindow mainWindow = new();
|
||||
mainWindow.Show();
|
||||
|
||||
// Load the game table if no application was requested by the command line
|
||||
if (CommandLineState.LaunchPathArg == null)
|
||||
{
|
||||
mainWindow.UpdateGameTable();
|
||||
}
|
||||
|
||||
if (OperatingSystem.IsLinux())
|
||||
{
|
||||
int currentVmMaxMapCount = LinuxHelper.VmMaxMapCount;
|
||||
|
@ -187,7 +187,10 @@ namespace Ryujinx.UI
|
||||
: IntegrityCheckLevel.None;
|
||||
|
||||
// Instantiate GUI objects.
|
||||
ApplicationLibrary = new ApplicationLibrary(_virtualFileSystem, checkLevel);
|
||||
ApplicationLibrary = new ApplicationLibrary(_virtualFileSystem, checkLevel)
|
||||
{
|
||||
DesiredLanguage = ConfigurationState.Instance.System.Language,
|
||||
};
|
||||
_uiHandler = new GtkHostUIHandler(this);
|
||||
_deviceExitStatus = new AutoResetEvent(false);
|
||||
|
||||
@ -325,7 +328,6 @@ namespace Ryujinx.UI
|
||||
_hideUI.Label = _hideUI.Label.Replace("SHOWUIKEY", ConfigurationState.Instance.Hid.Hotkeys.Value.ShowUI.ToString());
|
||||
|
||||
UpdateColumns();
|
||||
UpdateGameTable();
|
||||
|
||||
ConfigurationState.Instance.UI.GameDirs.Event += (sender, args) =>
|
||||
{
|
||||
@ -738,7 +740,8 @@ namespace Ryujinx.UI
|
||||
|
||||
Thread applicationLibraryThread = new(() =>
|
||||
{
|
||||
ApplicationLibrary.LoadApplications(ConfigurationState.Instance.UI.GameDirs, ConfigurationState.Instance.System.Language);
|
||||
ApplicationLibrary.DesiredLanguage = ConfigurationState.Instance.System.Language;
|
||||
ApplicationLibrary.LoadApplications(ConfigurationState.Instance.UI.GameDirs);
|
||||
|
||||
_updatingGameTable = false;
|
||||
})
|
||||
|
@ -473,7 +473,7 @@ namespace Ryujinx.UI.Widgets
|
||||
|
||||
private void ManageDlc_Clicked(object sender, EventArgs args)
|
||||
{
|
||||
new DlcWindow(_virtualFileSystem, _applicationData.IdString, _applicationData).Show();
|
||||
new DlcWindow(_virtualFileSystem, _applicationData.IdBaseString, _applicationData).Show();
|
||||
}
|
||||
|
||||
private void ManageCheats_Clicked(object sender, EventArgs args)
|
||||
|
@ -24,7 +24,7 @@ namespace Ryujinx.UI.Windows
|
||||
public class DlcWindow : Window
|
||||
{
|
||||
private readonly VirtualFileSystem _virtualFileSystem;
|
||||
private readonly string _applicationId;
|
||||
private readonly string _applicationIdBase;
|
||||
private readonly string _dlcJsonPath;
|
||||
private readonly List<DownloadableContentContainer> _dlcContainerList;
|
||||
|
||||
@ -36,16 +36,16 @@ namespace Ryujinx.UI.Windows
|
||||
[GUI] TreeSelection _dlcTreeSelection;
|
||||
#pragma warning restore CS0649, IDE0044
|
||||
|
||||
public DlcWindow(VirtualFileSystem virtualFileSystem, string titleId, ApplicationData applicationData) : this(new Builder("Ryujinx.Gtk3.UI.Windows.DlcWindow.glade"), virtualFileSystem, titleId, applicationData) { }
|
||||
public DlcWindow(VirtualFileSystem virtualFileSystem, string applicationIdBase, ApplicationData applicationData) : this(new Builder("Ryujinx.Gtk3.UI.Windows.DlcWindow.glade"), virtualFileSystem, applicationIdBase, applicationData) { }
|
||||
|
||||
private DlcWindow(Builder builder, VirtualFileSystem virtualFileSystem, string applicationId, ApplicationData applicationData) : base(builder.GetRawOwnedObject("_dlcWindow"))
|
||||
private DlcWindow(Builder builder, VirtualFileSystem virtualFileSystem, string applicationIdBase, ApplicationData applicationData) : base(builder.GetRawOwnedObject("_dlcWindow"))
|
||||
{
|
||||
builder.Autoconnect(this);
|
||||
|
||||
_applicationId = applicationId;
|
||||
_applicationIdBase = applicationIdBase;
|
||||
_virtualFileSystem = virtualFileSystem;
|
||||
_dlcJsonPath = System.IO.Path.Combine(AppDataManager.GamesDirPath, _applicationId, "dlc.json");
|
||||
_baseTitleInfoLabel.Text = $"DLC Available for {applicationData.Name} [{applicationId.ToUpper()}]";
|
||||
_dlcJsonPath = System.IO.Path.Combine(AppDataManager.GamesDirPath, _applicationIdBase, "dlc.json");
|
||||
_baseTitleInfoLabel.Text = $"DLC Available for {applicationData.Name} [{applicationIdBase.ToUpper()}]";
|
||||
|
||||
try
|
||||
{
|
||||
@ -163,7 +163,7 @@ namespace Ryujinx.UI.Windows
|
||||
|
||||
if (nca.Header.ContentType == NcaContentType.PublicData)
|
||||
{
|
||||
if (nca.GetProgramIdBase() != (ulong.Parse(_applicationId, NumberStyles.HexNumber) & ~0x1FFFUL))
|
||||
if (nca.GetProgramIdBase() != ulong.Parse(_applicationIdBase, NumberStyles.HexNumber))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ namespace Ryujinx.UI.Windows
|
||||
|
||||
_applicationData = applicationData;
|
||||
_virtualFileSystem = virtualFileSystem;
|
||||
_updateJsonPath = System.IO.Path.Combine(AppDataManager.GamesDirPath, applicationData.IdString, "updates.json");
|
||||
_updateJsonPath = System.IO.Path.Combine(AppDataManager.GamesDirPath, applicationData.IdBaseString, "updates.json");
|
||||
_radioButtonToPathDictionary = new Dictionary<RadioButton, string>();
|
||||
|
||||
try
|
||||
@ -67,7 +67,7 @@ namespace Ryujinx.UI.Windows
|
||||
};
|
||||
}
|
||||
|
||||
_baseTitleInfoLabel.Text = $"Updates Available for {applicationData.Name} [{applicationData.IdString}]";
|
||||
_baseTitleInfoLabel.Text = $"Updates Available for {applicationData.Name} [{applicationData.IdBaseString}]";
|
||||
|
||||
// Try to get updates from PFS first
|
||||
AddUpdate(_applicationData.Path, true);
|
||||
|
@ -1,10 +0,0 @@
|
||||
namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
{
|
||||
enum AddressSpaceType
|
||||
{
|
||||
Addr32Bits = 0,
|
||||
Addr36Bits = 1,
|
||||
Addr32BitsNoMap = 2,
|
||||
Addr39Bits = 3,
|
||||
}
|
||||
}
|
@ -58,11 +58,10 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
public ulong AslrRegionStart { get; private set; }
|
||||
public ulong AslrRegionEnd { get; private set; }
|
||||
|
||||
#pragma warning disable IDE0052 // Remove unread private member
|
||||
private ulong _heapCapacity;
|
||||
#pragma warning restore IDE0052
|
||||
|
||||
public ulong PhysicalMemoryUsage { get; private set; }
|
||||
public ulong AliasRegionExtraSize { get; private set; }
|
||||
|
||||
private readonly KMemoryBlockManager _blockManager;
|
||||
|
||||
@ -98,30 +97,21 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
_reservedAddressSpaceSize = reservedAddressSpaceSize;
|
||||
}
|
||||
|
||||
private static readonly int[] _addrSpaceSizes = { 32, 36, 32, 39 };
|
||||
|
||||
public Result InitializeForProcess(
|
||||
AddressSpaceType addrSpaceType,
|
||||
bool aslrEnabled,
|
||||
ProcessCreationFlags flags,
|
||||
bool fromBack,
|
||||
MemoryRegion memRegion,
|
||||
ulong address,
|
||||
ulong size,
|
||||
KMemoryBlockSlabManager slabManager)
|
||||
{
|
||||
if ((uint)addrSpaceType > (uint)AddressSpaceType.Addr39Bits)
|
||||
{
|
||||
throw new ArgumentException($"AddressSpaceType bigger than {(uint)AddressSpaceType.Addr39Bits}: {(uint)addrSpaceType}", nameof(addrSpaceType));
|
||||
}
|
||||
|
||||
_contextId = Context.ContextIdManager.GetId();
|
||||
|
||||
ulong addrSpaceBase = 0;
|
||||
ulong addrSpaceSize = 1UL << _addrSpaceSizes[(int)addrSpaceType];
|
||||
ulong addrSpaceSize = 1UL << GetAddressSpaceWidth(flags);
|
||||
|
||||
Result result = CreateUserAddressSpace(
|
||||
addrSpaceType,
|
||||
aslrEnabled,
|
||||
flags,
|
||||
fromBack,
|
||||
addrSpaceBase,
|
||||
addrSpaceSize,
|
||||
@ -138,6 +128,22 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
return result;
|
||||
}
|
||||
|
||||
private static int GetAddressSpaceWidth(ProcessCreationFlags flags)
|
||||
{
|
||||
switch (flags & ProcessCreationFlags.AddressSpaceMask)
|
||||
{
|
||||
case ProcessCreationFlags.AddressSpace32Bit:
|
||||
case ProcessCreationFlags.AddressSpace32BitWithoutAlias:
|
||||
return 32;
|
||||
case ProcessCreationFlags.AddressSpace64BitDeprecated:
|
||||
return 36;
|
||||
case ProcessCreationFlags.AddressSpace64Bit:
|
||||
return 39;
|
||||
}
|
||||
|
||||
throw new ArgumentException($"Invalid process flags {flags}", nameof(flags));
|
||||
}
|
||||
|
||||
private struct Region
|
||||
{
|
||||
public ulong Start;
|
||||
@ -147,8 +153,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
}
|
||||
|
||||
private Result CreateUserAddressSpace(
|
||||
AddressSpaceType addrSpaceType,
|
||||
bool aslrEnabled,
|
||||
ProcessCreationFlags flags,
|
||||
bool fromBack,
|
||||
ulong addrSpaceStart,
|
||||
ulong addrSpaceEnd,
|
||||
@ -168,9 +173,11 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
ulong stackAndTlsIoStart;
|
||||
ulong stackAndTlsIoEnd;
|
||||
|
||||
switch (addrSpaceType)
|
||||
AliasRegionExtraSize = 0;
|
||||
|
||||
switch (flags & ProcessCreationFlags.AddressSpaceMask)
|
||||
{
|
||||
case AddressSpaceType.Addr32Bits:
|
||||
case ProcessCreationFlags.AddressSpace32Bit:
|
||||
aliasRegion.Size = 0x40000000;
|
||||
heapRegion.Size = 0x40000000;
|
||||
stackRegion.Size = 0;
|
||||
@ -183,7 +190,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
stackAndTlsIoEnd = 0x40000000;
|
||||
break;
|
||||
|
||||
case AddressSpaceType.Addr36Bits:
|
||||
case ProcessCreationFlags.AddressSpace64BitDeprecated:
|
||||
aliasRegion.Size = 0x180000000;
|
||||
heapRegion.Size = 0x180000000;
|
||||
stackRegion.Size = 0;
|
||||
@ -196,7 +203,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
stackAndTlsIoEnd = 0x80000000;
|
||||
break;
|
||||
|
||||
case AddressSpaceType.Addr32BitsNoMap:
|
||||
case ProcessCreationFlags.AddressSpace32BitWithoutAlias:
|
||||
aliasRegion.Size = 0;
|
||||
heapRegion.Size = 0x80000000;
|
||||
stackRegion.Size = 0;
|
||||
@ -209,7 +216,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
stackAndTlsIoEnd = 0x40000000;
|
||||
break;
|
||||
|
||||
case AddressSpaceType.Addr39Bits:
|
||||
case ProcessCreationFlags.AddressSpace64Bit:
|
||||
if (_reservedAddressSpaceSize < addrSpaceEnd)
|
||||
{
|
||||
int addressSpaceWidth = (int)ulong.Log2(_reservedAddressSpaceSize);
|
||||
@ -218,8 +225,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
heapRegion.Size = 0x180000000;
|
||||
stackRegion.Size = 1UL << (addressSpaceWidth - 8);
|
||||
tlsIoRegion.Size = 1UL << (addressSpaceWidth - 3);
|
||||
CodeRegionStart = BitUtils.AlignDown<ulong>(address, RegionAlignment);
|
||||
codeRegionSize = BitUtils.AlignUp<ulong>(endAddr, RegionAlignment) - CodeRegionStart;
|
||||
CodeRegionStart = BitUtils.AlignDown(address, RegionAlignment);
|
||||
codeRegionSize = BitUtils.AlignUp(endAddr, RegionAlignment) - CodeRegionStart;
|
||||
stackAndTlsIoStart = 0;
|
||||
stackAndTlsIoEnd = 0;
|
||||
AslrRegionStart = 0x8000000;
|
||||
@ -239,9 +246,16 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
stackAndTlsIoStart = 0;
|
||||
stackAndTlsIoEnd = 0;
|
||||
}
|
||||
|
||||
if (flags.HasFlag(ProcessCreationFlags.EnableAliasRegionExtraSize))
|
||||
{
|
||||
AliasRegionExtraSize = addrSpaceEnd / 8;
|
||||
aliasRegion.Size += AliasRegionExtraSize;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new ArgumentException($"AddressSpaceType bigger than {(uint)AddressSpaceType.Addr39Bits}: {(uint)addrSpaceType}", nameof(addrSpaceType));
|
||||
throw new ArgumentException($"Invalid process flags {flags}", nameof(flags));
|
||||
}
|
||||
|
||||
CodeRegionEnd = CodeRegionStart + codeRegionSize;
|
||||
@ -266,6 +280,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
|
||||
ulong aslrMaxOffset = mapAvailableSize - mapTotalSize;
|
||||
|
||||
bool aslrEnabled = flags.HasFlag(ProcessCreationFlags.EnableAslr);
|
||||
|
||||
_aslrEnabled = aslrEnabled;
|
||||
|
||||
AddrSpaceStart = addrSpaceStart;
|
||||
@ -725,7 +741,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
{
|
||||
address = 0;
|
||||
|
||||
if (size > HeapRegionEnd - HeapRegionStart)
|
||||
if (size > HeapRegionEnd - HeapRegionStart || size > _heapCapacity)
|
||||
{
|
||||
return KernelResult.OutOfMemory;
|
||||
}
|
||||
|
@ -126,8 +126,6 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
_contextFactory = contextFactory ?? new ProcessContextFactory();
|
||||
_customThreadStart = customThreadStart;
|
||||
|
||||
AddressSpaceType addrSpaceType = (AddressSpaceType)((int)(creationInfo.Flags & ProcessCreationFlags.AddressSpaceMask) >> (int)ProcessCreationFlags.AddressSpaceShift);
|
||||
|
||||
Pid = KernelContext.NewKipId();
|
||||
|
||||
if (Pid == 0 || Pid >= KernelConstants.InitialProcessId)
|
||||
@ -137,8 +135,6 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
|
||||
InitializeMemoryManager(creationInfo.Flags);
|
||||
|
||||
bool aslrEnabled = creationInfo.Flags.HasFlag(ProcessCreationFlags.EnableAslr);
|
||||
|
||||
ulong codeAddress = creationInfo.CodeAddress;
|
||||
|
||||
ulong codeSize = (ulong)creationInfo.CodePagesCount * KPageTableBase.PageSize;
|
||||
@ -148,9 +144,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
: KernelContext.SmallMemoryBlockSlabManager;
|
||||
|
||||
Result result = MemoryManager.InitializeForProcess(
|
||||
addrSpaceType,
|
||||
aslrEnabled,
|
||||
!aslrEnabled,
|
||||
creationInfo.Flags,
|
||||
!creationInfo.Flags.HasFlag(ProcessCreationFlags.EnableAslr),
|
||||
memRegion,
|
||||
codeAddress,
|
||||
codeSize,
|
||||
@ -234,8 +229,6 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
: KernelContext.SmallMemoryBlockSlabManager;
|
||||
}
|
||||
|
||||
AddressSpaceType addrSpaceType = (AddressSpaceType)((int)(creationInfo.Flags & ProcessCreationFlags.AddressSpaceMask) >> (int)ProcessCreationFlags.AddressSpaceShift);
|
||||
|
||||
Pid = KernelContext.NewProcessId();
|
||||
|
||||
if (Pid == ulong.MaxValue || Pid < KernelConstants.InitialProcessId)
|
||||
@ -245,16 +238,13 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
|
||||
InitializeMemoryManager(creationInfo.Flags);
|
||||
|
||||
bool aslrEnabled = creationInfo.Flags.HasFlag(ProcessCreationFlags.EnableAslr);
|
||||
|
||||
ulong codeAddress = creationInfo.CodeAddress;
|
||||
|
||||
ulong codeSize = codePagesCount * KPageTableBase.PageSize;
|
||||
|
||||
Result result = MemoryManager.InitializeForProcess(
|
||||
addrSpaceType,
|
||||
aslrEnabled,
|
||||
!aslrEnabled,
|
||||
creationInfo.Flags,
|
||||
!creationInfo.Flags.HasFlag(ProcessCreationFlags.EnableAslr),
|
||||
memRegion,
|
||||
codeAddress,
|
||||
codeSize,
|
||||
@ -309,8 +299,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
private Result ParseProcessInfo(ProcessCreationInfo creationInfo)
|
||||
{
|
||||
// Ensure that the current kernel version is equal or above to the minimum required.
|
||||
uint requiredKernelVersionMajor = (uint)Capabilities.KernelReleaseVersion >> 19;
|
||||
uint requiredKernelVersionMinor = ((uint)Capabilities.KernelReleaseVersion >> 15) & 0xf;
|
||||
uint requiredKernelVersionMajor = Capabilities.KernelReleaseVersion >> 19;
|
||||
uint requiredKernelVersionMinor = (Capabilities.KernelReleaseVersion >> 15) & 0xf;
|
||||
|
||||
if (KernelContext.EnableVersionChecks)
|
||||
{
|
||||
@ -519,12 +509,10 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
return result;
|
||||
}
|
||||
|
||||
#pragma warning disable CA1822 // Mark member as static
|
||||
private void GenerateRandomEntropy()
|
||||
{
|
||||
// TODO.
|
||||
}
|
||||
#pragma warning restore CA1822
|
||||
|
||||
public Result Start(int mainThreadPriority, ulong stackSize)
|
||||
{
|
||||
@ -1182,5 +1170,10 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
// TODO
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool IsSvcPermitted(int svcId)
|
||||
{
|
||||
return Capabilities.IsSvcPermitted(svcId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
{
|
||||
class KProcessCapabilities
|
||||
{
|
||||
private const int SvcMaskElementBits = 8;
|
||||
|
||||
public byte[] SvcAccessMask { get; }
|
||||
public byte[] IrqAccessMask { get; }
|
||||
|
||||
@ -22,7 +24,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
public KProcessCapabilities()
|
||||
{
|
||||
// length / number of bits of the underlying type
|
||||
SvcAccessMask = new byte[KernelConstants.SupervisorCallCount / 8];
|
||||
SvcAccessMask = new byte[KernelConstants.SupervisorCallCount / SvcMaskElementBits];
|
||||
IrqAccessMask = new byte[0x80];
|
||||
}
|
||||
|
||||
@ -208,7 +210,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
return KernelResult.MaximumExceeded;
|
||||
}
|
||||
|
||||
SvcAccessMask[svcId / 8] |= (byte)(1 << (svcId & 7));
|
||||
SvcAccessMask[svcId / SvcMaskElementBits] |= (byte)(1 << (svcId % SvcMaskElementBits));
|
||||
}
|
||||
|
||||
break;
|
||||
@ -324,5 +326,13 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
|
||||
return mask << (int)min;
|
||||
}
|
||||
|
||||
public bool IsSvcPermitted(int svcId)
|
||||
{
|
||||
int index = svcId / SvcMaskElementBits;
|
||||
int mask = 1 << (svcId % SvcMaskElementBits);
|
||||
|
||||
return (uint)svcId < KernelConstants.SupervisorCallCount && (SvcAccessMask[index] & mask) != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
PoolPartitionMask = 0xf << PoolPartitionShift,
|
||||
|
||||
OptimizeMemoryAllocation = 1 << 11,
|
||||
DisableDeviceAddressSpaceMerge = 1 << 12,
|
||||
EnableAliasRegionExtraSize = 1 << 13,
|
||||
|
||||
All =
|
||||
Is64Bit |
|
||||
@ -38,6 +40,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
IsApplication |
|
||||
DeprecatedUseSecureMemory |
|
||||
PoolPartitionMask |
|
||||
OptimizeMemoryAllocation,
|
||||
OptimizeMemoryAllocation |
|
||||
DisableDeviceAddressSpaceMerge |
|
||||
EnableAliasRegionExtraSize,
|
||||
}
|
||||
}
|
||||
|
@ -21,14 +21,17 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
SystemResourceSizeTotal,
|
||||
SystemResourceSizeUsed,
|
||||
ProgramId,
|
||||
// NOTE: Added in 4.0.0, removed in 5.0.0.
|
||||
InitialProcessIdRange,
|
||||
InitialProcessIdRange, // NOTE: Added in 4.0.0, removed in 5.0.0.
|
||||
UserExceptionContextAddress,
|
||||
TotalNonSystemMemorySize,
|
||||
UsedNonSystemMemorySize,
|
||||
IsApplication,
|
||||
FreeThreadCount,
|
||||
ThreadTickCount,
|
||||
IsSvcPermitted,
|
||||
IoRegionHint,
|
||||
AliasRegionExtraSize,
|
||||
|
||||
MesosphereCurrentProcess = 65001,
|
||||
}
|
||||
}
|
||||
|
@ -84,6 +84,17 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
return KernelResult.InvalidSize;
|
||||
}
|
||||
|
||||
if (info.Flags.HasFlag(ProcessCreationFlags.EnableAliasRegionExtraSize))
|
||||
{
|
||||
if ((info.Flags & ProcessCreationFlags.AddressSpaceMask) != ProcessCreationFlags.AddressSpace64Bit ||
|
||||
info.SystemResourcePagesCount <= 0)
|
||||
{
|
||||
return KernelResult.InvalidState;
|
||||
}
|
||||
|
||||
// TODO: Check that we are in debug mode.
|
||||
}
|
||||
|
||||
if (info.Flags.HasFlag(ProcessCreationFlags.OptimizeMemoryAllocation) &&
|
||||
!info.Flags.HasFlag(ProcessCreationFlags.IsApplication))
|
||||
{
|
||||
@ -139,7 +150,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
return handleTable.GenerateHandle(process, out handle);
|
||||
}
|
||||
|
||||
#pragma warning disable CA1822 // Mark member as static
|
||||
public Result StartProcess(int handle, int priority, int cpuCore, ulong mainThreadStackSize)
|
||||
{
|
||||
KProcess process = KernelStatic.GetCurrentProcess().HandleTable.GetObject<KProcess>(handle);
|
||||
@ -172,17 +182,14 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
#pragma warning restore CA1822
|
||||
|
||||
[Svc(0x5f)]
|
||||
#pragma warning disable CA1822 // Mark member as static
|
||||
public Result FlushProcessDataCache(int processHandle, ulong address, ulong size)
|
||||
{
|
||||
// FIXME: This needs to be implemented as ARMv7 doesn't have any way to do cache maintenance operations on EL0.
|
||||
// As we don't support (and don't actually need) to flush the cache, this is stubbed.
|
||||
return Result.Success;
|
||||
}
|
||||
#pragma warning restore CA1822
|
||||
|
||||
// IPC
|
||||
|
||||
@ -256,7 +263,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
}
|
||||
|
||||
[Svc(0x22)]
|
||||
#pragma warning disable CA1822 // Mark member as static
|
||||
public Result SendSyncRequestWithUserBuffer(
|
||||
[PointerSized] ulong messagePtr,
|
||||
[PointerSized] ulong messageSize,
|
||||
@ -306,7 +312,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
|
||||
return result;
|
||||
}
|
||||
#pragma warning restore CA1822
|
||||
|
||||
[Svc(0x23)]
|
||||
public Result SendAsyncRequestWithUserBuffer(
|
||||
@ -896,7 +901,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
}
|
||||
|
||||
[Svc(2)]
|
||||
#pragma warning disable CA1822 // Mark member as static
|
||||
public Result SetMemoryPermission([PointerSized] ulong address, [PointerSized] ulong size, KMemoryPermission permission)
|
||||
{
|
||||
if (!PageAligned(address))
|
||||
@ -928,10 +932,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
|
||||
return currentProcess.MemoryManager.SetMemoryPermission(address, size, permission);
|
||||
}
|
||||
#pragma warning restore CA1822
|
||||
|
||||
[Svc(3)]
|
||||
#pragma warning disable CA1822 // Mark member as static
|
||||
public Result SetMemoryAttribute(
|
||||
[PointerSized] ulong address,
|
||||
[PointerSized] ulong size,
|
||||
@ -979,10 +981,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
|
||||
return result;
|
||||
}
|
||||
#pragma warning restore CA1822
|
||||
|
||||
[Svc(4)]
|
||||
#pragma warning disable CA1822 // Mark member as static
|
||||
public Result MapMemory([PointerSized] ulong dst, [PointerSized] ulong src, [PointerSized] ulong size)
|
||||
{
|
||||
if (!PageAligned(src | dst))
|
||||
@ -1018,10 +1018,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
|
||||
return process.MemoryManager.Map(dst, src, size);
|
||||
}
|
||||
#pragma warning restore CA1822
|
||||
|
||||
[Svc(5)]
|
||||
#pragma warning disable CA1822 // Mark member as static
|
||||
public Result UnmapMemory([PointerSized] ulong dst, [PointerSized] ulong src, [PointerSized] ulong size)
|
||||
{
|
||||
if (!PageAligned(src | dst))
|
||||
@ -1057,7 +1055,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
|
||||
return process.MemoryManager.Unmap(dst, src, size);
|
||||
}
|
||||
#pragma warning restore CA1822
|
||||
|
||||
[Svc(6)]
|
||||
public Result QueryMemory([PointerSized] ulong infoPtr, [PointerSized] out ulong pageInfo, [PointerSized] ulong address)
|
||||
@ -1074,7 +1071,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
return result;
|
||||
}
|
||||
|
||||
#pragma warning disable CA1822 // Mark member as static
|
||||
public Result QueryMemory(out MemoryInfo info, out ulong pageInfo, ulong address)
|
||||
{
|
||||
KProcess process = KernelStatic.GetCurrentProcess();
|
||||
@ -1094,10 +1090,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
#pragma warning restore CA1822
|
||||
|
||||
[Svc(0x13)]
|
||||
#pragma warning disable CA1822 // Mark member as static
|
||||
public Result MapSharedMemory(int handle, [PointerSized] ulong address, [PointerSized] ulong size, KMemoryPermission permission)
|
||||
{
|
||||
if (!PageAligned(address))
|
||||
@ -1143,10 +1137,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
currentProcess,
|
||||
permission);
|
||||
}
|
||||
#pragma warning restore CA1822
|
||||
|
||||
[Svc(0x14)]
|
||||
#pragma warning disable CA1822 // Mark member as static
|
||||
public Result UnmapSharedMemory(int handle, [PointerSized] ulong address, [PointerSized] ulong size)
|
||||
{
|
||||
if (!PageAligned(address))
|
||||
@ -1186,7 +1178,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
size,
|
||||
currentProcess);
|
||||
}
|
||||
#pragma warning restore CA1822
|
||||
|
||||
[Svc(0x15)]
|
||||
public Result CreateTransferMemory(out int handle, [PointerSized] ulong address, [PointerSized] ulong size, KMemoryPermission permission)
|
||||
@ -1253,7 +1244,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
}
|
||||
|
||||
[Svc(0x51)]
|
||||
#pragma warning disable CA1822 // Mark member as static
|
||||
public Result MapTransferMemory(int handle, [PointerSized] ulong address, [PointerSized] ulong size, KMemoryPermission permission)
|
||||
{
|
||||
if (!PageAligned(address))
|
||||
@ -1299,10 +1289,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
currentProcess,
|
||||
permission);
|
||||
}
|
||||
#pragma warning restore CA1822
|
||||
|
||||
[Svc(0x52)]
|
||||
#pragma warning disable CA1822 // Mark member as static
|
||||
public Result UnmapTransferMemory(int handle, [PointerSized] ulong address, [PointerSized] ulong size)
|
||||
{
|
||||
if (!PageAligned(address))
|
||||
@ -1342,10 +1330,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
size,
|
||||
currentProcess);
|
||||
}
|
||||
#pragma warning restore CA1822
|
||||
|
||||
[Svc(0x2c)]
|
||||
#pragma warning disable CA1822 // Mark member as static
|
||||
public Result MapPhysicalMemory([PointerSized] ulong address, [PointerSized] ulong size)
|
||||
{
|
||||
if (!PageAligned(address))
|
||||
@ -1380,10 +1366,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
|
||||
return process.MemoryManager.MapPhysicalMemory(address, size);
|
||||
}
|
||||
#pragma warning restore CA1822
|
||||
|
||||
[Svc(0x2d)]
|
||||
#pragma warning disable CA1822 // Mark member as static
|
||||
public Result UnmapPhysicalMemory([PointerSized] ulong address, [PointerSized] ulong size)
|
||||
{
|
||||
if (!PageAligned(address))
|
||||
@ -1418,7 +1402,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
|
||||
return process.MemoryManager.UnmapPhysicalMemory(address, size);
|
||||
}
|
||||
#pragma warning restore CA1822
|
||||
|
||||
[Svc(0x4b)]
|
||||
public Result CreateCodeMemory(out int handle, [PointerSized] ulong address, [PointerSized] ulong size)
|
||||
@ -1462,7 +1445,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
}
|
||||
|
||||
[Svc(0x4c)]
|
||||
#pragma warning disable CA1822 // Mark member as static
|
||||
public Result ControlCodeMemory(
|
||||
int handle,
|
||||
CodeMemoryOperation op,
|
||||
@ -1540,10 +1522,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
return KernelResult.InvalidEnumValue;
|
||||
}
|
||||
}
|
||||
#pragma warning restore CA1822
|
||||
|
||||
[Svc(0x73)]
|
||||
#pragma warning disable CA1822 // Mark member as static
|
||||
public Result SetProcessMemoryPermission(
|
||||
int handle,
|
||||
ulong src,
|
||||
@ -1584,10 +1564,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
|
||||
return targetProcess.MemoryManager.SetProcessMemoryPermission(src, size, permission);
|
||||
}
|
||||
#pragma warning restore CA1822
|
||||
|
||||
[Svc(0x74)]
|
||||
#pragma warning disable CA1822 // Mark member as static
|
||||
public Result MapProcessMemory(
|
||||
[PointerSized] ulong dst,
|
||||
int handle,
|
||||
@ -1643,10 +1621,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
|
||||
return dstProcess.MemoryManager.MapPages(dst, pageList, MemoryState.ProcessMemory, KMemoryPermission.ReadAndWrite);
|
||||
}
|
||||
#pragma warning restore CA1822
|
||||
|
||||
[Svc(0x75)]
|
||||
#pragma warning disable CA1822 // Mark member as static
|
||||
public Result UnmapProcessMemory(
|
||||
[PointerSized] ulong dst,
|
||||
int handle,
|
||||
@ -1691,10 +1667,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
#pragma warning restore CA1822
|
||||
|
||||
[Svc(0x77)]
|
||||
#pragma warning disable CA1822 // Mark member as static
|
||||
public Result MapProcessCodeMemory(int handle, ulong dst, ulong src, ulong size)
|
||||
{
|
||||
if (!PageAligned(dst) || !PageAligned(src))
|
||||
@ -1731,10 +1705,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
|
||||
return targetProcess.MemoryManager.MapProcessCodeMemory(dst, src, size);
|
||||
}
|
||||
#pragma warning restore CA1822
|
||||
|
||||
[Svc(0x78)]
|
||||
#pragma warning disable CA1822 // Mark member as static
|
||||
public Result UnmapProcessCodeMemory(int handle, ulong dst, ulong src, ulong size)
|
||||
{
|
||||
if (!PageAligned(dst) || !PageAligned(src))
|
||||
@ -1771,7 +1743,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
|
||||
return targetProcess.MemoryManager.UnmapProcessCodeMemory(dst, src, size);
|
||||
}
|
||||
#pragma warning restore CA1822
|
||||
|
||||
private static bool PageAligned(ulong address)
|
||||
{
|
||||
@ -1781,7 +1752,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
// System
|
||||
|
||||
[Svc(0x7b)]
|
||||
#pragma warning disable CA1822 // Mark member as static
|
||||
public Result TerminateProcess(int handle)
|
||||
{
|
||||
KProcess process = KernelStatic.GetCurrentProcess();
|
||||
@ -1810,15 +1780,12 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
|
||||
return result;
|
||||
}
|
||||
#pragma warning restore CA1822
|
||||
|
||||
[Svc(7)]
|
||||
#pragma warning disable CA1822 // Mark member as static
|
||||
public void ExitProcess()
|
||||
{
|
||||
KernelStatic.GetCurrentProcess().TerminateCurrentProcess();
|
||||
}
|
||||
#pragma warning restore CA1822
|
||||
|
||||
[Svc(0x11)]
|
||||
public Result SignalEvent(int handle)
|
||||
@ -1911,7 +1878,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
}
|
||||
|
||||
[Svc(0x26)]
|
||||
#pragma warning disable CA1822 // Mark member as static
|
||||
public void Break(ulong reason)
|
||||
{
|
||||
KThread currentThread = KernelStatic.GetCurrentThread();
|
||||
@ -1937,10 +1903,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
Logger.Debug?.Print(LogClass.KernelSvc, "Debugger triggered.");
|
||||
}
|
||||
}
|
||||
#pragma warning restore CA1822
|
||||
|
||||
[Svc(0x27)]
|
||||
#pragma warning disable CA1822 // Mark member as static
|
||||
public void OutputDebugString([PointerSized] ulong strPtr, [PointerSized] ulong size)
|
||||
{
|
||||
KProcess process = KernelStatic.GetCurrentProcess();
|
||||
@ -1949,7 +1913,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
|
||||
Logger.Warning?.Print(LogClass.KernelSvc, str);
|
||||
}
|
||||
#pragma warning restore CA1822
|
||||
|
||||
[Svc(0x29)]
|
||||
public Result GetInfo(out ulong value, InfoType id, int handle, long subId)
|
||||
@ -1978,6 +1941,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
case InfoType.UsedNonSystemMemorySize:
|
||||
case InfoType.IsApplication:
|
||||
case InfoType.FreeThreadCount:
|
||||
case InfoType.AliasRegionExtraSize:
|
||||
{
|
||||
if (subId != 0)
|
||||
{
|
||||
@ -2006,22 +1970,19 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
value = process.MemoryManager.AliasRegionStart;
|
||||
break;
|
||||
case InfoType.AliasRegionSize:
|
||||
value = (process.MemoryManager.AliasRegionEnd -
|
||||
process.MemoryManager.AliasRegionStart);
|
||||
value = process.MemoryManager.AliasRegionEnd - process.MemoryManager.AliasRegionStart;
|
||||
break;
|
||||
|
||||
case InfoType.HeapRegionAddress:
|
||||
value = process.MemoryManager.HeapRegionStart;
|
||||
break;
|
||||
case InfoType.HeapRegionSize:
|
||||
value = (process.MemoryManager.HeapRegionEnd -
|
||||
process.MemoryManager.HeapRegionStart);
|
||||
value = process.MemoryManager.HeapRegionEnd - process.MemoryManager.HeapRegionStart;
|
||||
break;
|
||||
|
||||
case InfoType.TotalMemorySize:
|
||||
value = process.GetMemoryCapacity();
|
||||
break;
|
||||
|
||||
case InfoType.UsedMemorySize:
|
||||
value = process.GetMemoryUsage();
|
||||
break;
|
||||
@ -2029,7 +1990,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
case InfoType.AslrRegionAddress:
|
||||
value = process.MemoryManager.GetAddrSpaceBaseAddr();
|
||||
break;
|
||||
|
||||
case InfoType.AslrRegionSize:
|
||||
value = process.MemoryManager.GetAddrSpaceSize();
|
||||
break;
|
||||
@ -2038,20 +1998,17 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
value = process.MemoryManager.StackRegionStart;
|
||||
break;
|
||||
case InfoType.StackRegionSize:
|
||||
value = (process.MemoryManager.StackRegionEnd -
|
||||
process.MemoryManager.StackRegionStart);
|
||||
value = process.MemoryManager.StackRegionEnd - process.MemoryManager.StackRegionStart;
|
||||
break;
|
||||
|
||||
case InfoType.SystemResourceSizeTotal:
|
||||
value = process.PersonalMmHeapPagesCount * KPageTableBase.PageSize;
|
||||
break;
|
||||
|
||||
case InfoType.SystemResourceSizeUsed:
|
||||
if (process.PersonalMmHeapPagesCount != 0)
|
||||
{
|
||||
value = process.MemoryManager.GetMmUsedPages() * KPageTableBase.PageSize;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case InfoType.ProgramId:
|
||||
@ -2065,7 +2022,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
case InfoType.TotalNonSystemMemorySize:
|
||||
value = process.GetMemoryCapacityWithoutPersonalMmHeap();
|
||||
break;
|
||||
|
||||
case InfoType.UsedNonSystemMemorySize:
|
||||
value = process.GetMemoryUsageWithoutPersonalMmHeap();
|
||||
break;
|
||||
@ -2084,10 +2040,12 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
{
|
||||
value = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case InfoType.AliasRegionExtraSize:
|
||||
value = process.MemoryManager.AliasRegionExtraSize;
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@ -2104,7 +2062,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
}
|
||||
|
||||
value = KernelStatic.GetCurrentProcess().Debug ? 1UL : 0UL;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@ -2136,7 +2093,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
|
||||
value = (uint)resLimHandle;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@ -2155,7 +2111,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
}
|
||||
|
||||
value = (ulong)KTimeManager.ConvertHostTicksToTicks(_context.Schedulers[currentCore].TotalIdleTimeTicks);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@ -2174,7 +2129,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
KProcess currentProcess = KernelStatic.GetCurrentProcess();
|
||||
|
||||
value = currentProcess.RandomEntropy[subId];
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@ -2220,7 +2174,22 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
|
||||
value = (ulong)KTimeManager.ConvertHostTicksToTicks(totalTimeRunning);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case InfoType.IsSvcPermitted:
|
||||
{
|
||||
if (handle != 0)
|
||||
{
|
||||
return KernelResult.InvalidHandle;
|
||||
}
|
||||
|
||||
if (subId != 0x36)
|
||||
{
|
||||
return KernelResult.InvalidCombination;
|
||||
}
|
||||
|
||||
value = KernelStatic.GetCurrentProcess().IsSvcPermitted((int)subId) ? 1UL : 0UL;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -2231,7 +2200,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
return KernelResult.InvalidHandle;
|
||||
}
|
||||
|
||||
if ((ulong)subId != 0)
|
||||
if (subId != 0)
|
||||
{
|
||||
return KernelResult.InvalidCombination;
|
||||
}
|
||||
@ -2246,8 +2215,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
return result;
|
||||
}
|
||||
|
||||
value = (ulong)outHandle;
|
||||
|
||||
value = (uint)outHandle;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -2398,7 +2366,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
}
|
||||
|
||||
[Svc(0x30)]
|
||||
#pragma warning disable CA1822 // Mark member as static
|
||||
public Result GetResourceLimitLimitValue(out long limitValue, int handle, LimitableResource resource)
|
||||
{
|
||||
limitValue = 0;
|
||||
@ -2419,10 +2386,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
#pragma warning restore CA1822
|
||||
|
||||
[Svc(0x31)]
|
||||
#pragma warning disable CA1822 // Mark member as static
|
||||
public Result GetResourceLimitCurrentValue(out long limitValue, int handle, LimitableResource resource)
|
||||
{
|
||||
limitValue = 0;
|
||||
@ -2443,10 +2408,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
#pragma warning restore CA1822
|
||||
|
||||
[Svc(0x37)]
|
||||
#pragma warning disable CA1822 // Mark member as static
|
||||
public Result GetResourceLimitPeakValue(out long peak, int handle, LimitableResource resource)
|
||||
{
|
||||
peak = 0;
|
||||
@ -2467,7 +2430,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
#pragma warning restore CA1822
|
||||
|
||||
[Svc(0x7d)]
|
||||
public Result CreateResourceLimit(out int handle)
|
||||
@ -2480,7 +2442,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
}
|
||||
|
||||
[Svc(0x7e)]
|
||||
#pragma warning disable CA1822 // Mark member as static
|
||||
public Result SetResourceLimitLimitValue(int handle, LimitableResource resource, long limitValue)
|
||||
{
|
||||
if (resource >= LimitableResource.Count)
|
||||
@ -2497,7 +2458,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
|
||||
return resourceLimit.SetLimitValue(resource, limitValue);
|
||||
}
|
||||
#pragma warning restore CA1822
|
||||
|
||||
// Thread
|
||||
|
||||
@ -2577,7 +2537,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
}
|
||||
|
||||
[Svc(9)]
|
||||
#pragma warning disable CA1822 // Mark member as static
|
||||
public Result StartThread(int handle)
|
||||
{
|
||||
KProcess process = KernelStatic.GetCurrentProcess();
|
||||
@ -2604,17 +2563,14 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
return KernelResult.InvalidHandle;
|
||||
}
|
||||
}
|
||||
#pragma warning restore CA1822
|
||||
|
||||
[Svc(0xa)]
|
||||
#pragma warning disable CA1822 // Mark member as static
|
||||
public void ExitThread()
|
||||
{
|
||||
KThread currentThread = KernelStatic.GetCurrentThread();
|
||||
|
||||
currentThread.Exit();
|
||||
}
|
||||
#pragma warning restore CA1822
|
||||
|
||||
[Svc(0xb)]
|
||||
public void SleepThread(long timeout)
|
||||
@ -2641,7 +2597,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
}
|
||||
|
||||
[Svc(0xc)]
|
||||
#pragma warning disable CA1822 // Mark member as static
|
||||
public Result GetThreadPriority(out int priority, int handle)
|
||||
{
|
||||
KProcess process = KernelStatic.GetCurrentProcess();
|
||||
@ -2661,10 +2616,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
return KernelResult.InvalidHandle;
|
||||
}
|
||||
}
|
||||
#pragma warning restore CA1822
|
||||
|
||||
[Svc(0xd)]
|
||||
#pragma warning disable CA1822 // Mark member as static
|
||||
public Result SetThreadPriority(int handle, int priority)
|
||||
{
|
||||
// TODO: NPDM check.
|
||||
@ -2682,10 +2635,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
#pragma warning restore CA1822
|
||||
|
||||
[Svc(0xe)]
|
||||
#pragma warning disable CA1822 // Mark member as static
|
||||
public Result GetThreadCoreMask(out int preferredCore, out ulong affinityMask, int handle)
|
||||
{
|
||||
KProcess process = KernelStatic.GetCurrentProcess();
|
||||
@ -2707,10 +2658,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
return KernelResult.InvalidHandle;
|
||||
}
|
||||
}
|
||||
#pragma warning restore CA1822
|
||||
|
||||
[Svc(0xf)]
|
||||
#pragma warning disable CA1822 // Mark member as static
|
||||
public Result SetThreadCoreMask(int handle, int preferredCore, ulong affinityMask)
|
||||
{
|
||||
KProcess currentProcess = KernelStatic.GetCurrentProcess();
|
||||
@ -2758,18 +2707,14 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
|
||||
return thread.SetCoreAndAffinityMask(preferredCore, affinityMask);
|
||||
}
|
||||
#pragma warning restore CA1822
|
||||
|
||||
[Svc(0x10)]
|
||||
#pragma warning disable CA1822 // Mark member as static
|
||||
public int GetCurrentProcessorNumber()
|
||||
{
|
||||
return KernelStatic.GetCurrentThread().CurrentCore;
|
||||
}
|
||||
#pragma warning restore CA1822
|
||||
|
||||
[Svc(0x25)]
|
||||
#pragma warning disable CA1822 // Mark member as static
|
||||
public Result GetThreadId(out ulong threadUid, int handle)
|
||||
{
|
||||
KProcess process = KernelStatic.GetCurrentProcess();
|
||||
@ -2789,10 +2734,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
return KernelResult.InvalidHandle;
|
||||
}
|
||||
}
|
||||
#pragma warning restore CA1822
|
||||
|
||||
[Svc(0x32)]
|
||||
#pragma warning disable CA1822 // Mark member as static
|
||||
public Result SetThreadActivity(int handle, bool pause)
|
||||
{
|
||||
KProcess process = KernelStatic.GetCurrentProcess();
|
||||
@ -2816,10 +2759,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
|
||||
return thread.SetActivity(pause);
|
||||
}
|
||||
#pragma warning restore CA1822
|
||||
|
||||
[Svc(0x33)]
|
||||
#pragma warning disable CA1822 // Mark member as static
|
||||
public Result GetThreadContext3([PointerSized] ulong address, int handle)
|
||||
{
|
||||
KProcess currentProcess = KernelStatic.GetCurrentProcess();
|
||||
@ -2853,7 +2794,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
|
||||
return result;
|
||||
}
|
||||
#pragma warning restore CA1822
|
||||
|
||||
// Thread synchronization
|
||||
|
||||
@ -2986,7 +2926,6 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
}
|
||||
|
||||
[Svc(0x1a)]
|
||||
#pragma warning disable CA1822 // Mark member as static
|
||||
public Result ArbitrateLock(int ownerHandle, [PointerSized] ulong mutexAddress, int requesterHandle)
|
||||
{
|
||||
if (IsPointingInsideKernel(mutexAddress))
|
||||
@ -3003,10 +2942,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
|
||||
return currentProcess.AddressArbiter.ArbitrateLock(ownerHandle, mutexAddress, requesterHandle);
|
||||
}
|
||||
#pragma warning restore CA1822
|
||||
|
||||
[Svc(0x1b)]
|
||||
#pragma warning disable CA1822 // Mark member as static
|
||||
public Result ArbitrateUnlock([PointerSized] ulong mutexAddress)
|
||||
{
|
||||
if (IsPointingInsideKernel(mutexAddress))
|
||||
@ -3023,10 +2960,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
|
||||
return currentProcess.AddressArbiter.ArbitrateUnlock(mutexAddress);
|
||||
}
|
||||
#pragma warning restore CA1822
|
||||
|
||||
[Svc(0x1c)]
|
||||
#pragma warning disable CA1822 // Mark member as static
|
||||
public Result WaitProcessWideKeyAtomic(
|
||||
[PointerSized] ulong mutexAddress,
|
||||
[PointerSized] ulong condVarAddress,
|
||||
@ -3056,10 +2991,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
handle,
|
||||
timeout);
|
||||
}
|
||||
#pragma warning restore CA1822
|
||||
|
||||
[Svc(0x1d)]
|
||||
#pragma warning disable CA1822 // Mark member as static
|
||||
public Result SignalProcessWideKey([PointerSized] ulong address, int count)
|
||||
{
|
||||
KProcess currentProcess = KernelStatic.GetCurrentProcess();
|
||||
@ -3068,10 +3001,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
#pragma warning restore CA1822
|
||||
|
||||
[Svc(0x34)]
|
||||
#pragma warning disable CA1822 // Mark member as static
|
||||
public Result WaitForAddress([PointerSized] ulong address, ArbitrationType type, int value, long timeout)
|
||||
{
|
||||
if (IsPointingInsideKernel(address))
|
||||
@ -3102,10 +3033,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
_ => KernelResult.InvalidEnumValue,
|
||||
};
|
||||
}
|
||||
#pragma warning restore CA1822
|
||||
|
||||
[Svc(0x35)]
|
||||
#pragma warning disable CA1822 // Mark member as static
|
||||
public Result SignalToAddress([PointerSized] ulong address, SignalType type, int value, int count)
|
||||
{
|
||||
if (IsPointingInsideKernel(address))
|
||||
@ -3131,17 +3060,14 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
_ => KernelResult.InvalidEnumValue,
|
||||
};
|
||||
}
|
||||
#pragma warning restore CA1822
|
||||
|
||||
[Svc(0x36)]
|
||||
#pragma warning disable CA1822 // Mark member as static
|
||||
public Result SynchronizePreemptionState()
|
||||
{
|
||||
KernelStatic.GetCurrentThread().SynchronizePreemptionState();
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
#pragma warning restore CA1822
|
||||
|
||||
// Not actual syscalls, used by HLE services and such.
|
||||
|
||||
|
@ -9,5 +9,6 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrlGpu.Types
|
||||
public byte Sm0TpcIndex;
|
||||
public byte Sm1GpcIndex;
|
||||
public byte Sm1TpcIndex;
|
||||
public uint Reserved;
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,12 @@ namespace Ryujinx.HLE.Loaders.Npdm
|
||||
public ServiceAccessControl ServiceAccessControl { get; private set; }
|
||||
public KernelAccessControl KernelAccessControl { get; private set; }
|
||||
|
||||
/// <exception cref="InvalidNpdmException">The stream doesn't contain valid ACI0 data.</exception>
|
||||
/// <exception cref="System.ArgumentException">The stream does not support reading, is <see langword="null"/>, or is already closed.</exception>
|
||||
/// <exception cref="EndOfStreamException">The end of the stream is reached.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
/// <exception cref="IOException">An I/O error occurred.</exception>
|
||||
/// <exception cref="System.NotImplementedException">The FsAccessHeader.ContentOwnerId section is not implemented.</exception>
|
||||
public Aci0(Stream stream, int offset)
|
||||
{
|
||||
stream.Seek(offset, SeekOrigin.Begin);
|
||||
|
@ -19,6 +19,11 @@ namespace Ryujinx.HLE.Loaders.Npdm
|
||||
public ServiceAccessControl ServiceAccessControl { get; private set; }
|
||||
public KernelAccessControl KernelAccessControl { get; private set; }
|
||||
|
||||
/// <exception cref="InvalidNpdmException">The stream doesn't contain valid ACID data.</exception>
|
||||
/// <exception cref="System.ArgumentException">The stream does not support reading, is <see langword="null"/>, or is already closed.</exception>
|
||||
/// <exception cref="EndOfStreamException">The end of the stream is reached.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
/// <exception cref="IOException">An I/O error occurred.</exception>
|
||||
public Acid(Stream stream, int offset)
|
||||
{
|
||||
stream.Seek(offset, SeekOrigin.Begin);
|
||||
|
@ -11,6 +11,10 @@ namespace Ryujinx.HLE.Loaders.Npdm
|
||||
public int Unknown3 { get; private set; }
|
||||
public int Unknown4 { get; private set; }
|
||||
|
||||
/// <exception cref="System.ArgumentException">The stream does not support reading, is <see langword="null"/>, or is already closed.</exception>
|
||||
/// <exception cref="EndOfStreamException">The end of the stream is reached.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
/// <exception cref="IOException">An I/O error occurred.</exception>
|
||||
public FsAccessControl(Stream stream, int offset, int size)
|
||||
{
|
||||
stream.Seek(offset, SeekOrigin.Begin);
|
||||
|
@ -9,6 +9,12 @@ namespace Ryujinx.HLE.Loaders.Npdm
|
||||
public int Version { get; private set; }
|
||||
public ulong PermissionsBitmask { get; private set; }
|
||||
|
||||
/// <exception cref="InvalidNpdmException">The stream contains invalid data.</exception>
|
||||
/// <exception cref="NotImplementedException">The ContentOwnerId section is not implemented.</exception>
|
||||
/// <exception cref="ArgumentException">The stream does not support reading, is <see langword="null"/>, or is already closed.</exception>
|
||||
/// <exception cref="EndOfStreamException">The end of the stream is reached.</exception>
|
||||
/// <exception cref="ObjectDisposedException">The stream is closed.</exception>
|
||||
/// <exception cref="IOException">An I/O error occurred.</exception>
|
||||
public FsAccessHeader(Stream stream, int offset, int size)
|
||||
{
|
||||
stream.Seek(offset, SeekOrigin.Begin);
|
||||
|
@ -6,6 +6,10 @@ namespace Ryujinx.HLE.Loaders.Npdm
|
||||
{
|
||||
public int[] Capabilities { get; private set; }
|
||||
|
||||
/// <exception cref="System.ArgumentException">The stream does not support reading, is <see langword="null"/>, or is already closed.</exception>
|
||||
/// <exception cref="EndOfStreamException">The end of the stream is reached.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
/// <exception cref="IOException">An I/O error occurred.</exception>
|
||||
public KernelAccessControl(Stream stream, int offset, int size)
|
||||
{
|
||||
stream.Seek(offset, SeekOrigin.Begin);
|
||||
|
@ -24,6 +24,13 @@ namespace Ryujinx.HLE.Loaders.Npdm
|
||||
public Aci0 Aci0 { get; private set; }
|
||||
public Acid Acid { get; private set; }
|
||||
|
||||
/// <exception cref="InvalidNpdmException">The stream doesn't contain valid NPDM data.</exception>
|
||||
/// <exception cref="System.NotImplementedException">The FsAccessHeader.ContentOwnerId section is not implemented.</exception>
|
||||
/// <exception cref="System.ArgumentException">The stream does not support reading, is <see langword="null"/>, or is already closed.</exception>
|
||||
/// <exception cref="System.ArgumentException">An error occured while reading bytes from the stream.</exception>
|
||||
/// <exception cref="EndOfStreamException">The end of the stream is reached.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
/// <exception cref="IOException">An I/O error occurred.</exception>
|
||||
public Npdm(Stream stream)
|
||||
{
|
||||
BinaryReader reader = new(stream);
|
||||
|
@ -9,6 +9,11 @@ namespace Ryujinx.HLE.Loaders.Npdm
|
||||
{
|
||||
public IReadOnlyDictionary<string, bool> Services { get; private set; }
|
||||
|
||||
/// <exception cref="System.ArgumentException">The stream does not support reading, is <see langword="null"/>, or is already closed.</exception>
|
||||
/// <exception cref="System.ArgumentException">An error occured while reading bytes from the stream.</exception>
|
||||
/// <exception cref="EndOfStreamException">The end of the stream is reached.</exception>
|
||||
/// <exception cref="System.ObjectDisposedException">The stream is closed.</exception>
|
||||
/// <exception cref="IOException">An I/O error occurred.</exception>
|
||||
public ServiceAccessControl(Stream stream, int offset, int size)
|
||||
{
|
||||
stream.Seek(offset, SeekOrigin.Begin);
|
||||
|
@ -139,7 +139,7 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions
|
||||
ulong titleIdBase = mainNca.GetProgramIdBase();
|
||||
|
||||
// Load update information if exists.
|
||||
string titleUpdateMetadataPath = Path.Combine(AppDataManager.GamesDirPath, mainNca.Header.TitleId.ToString("x16"), "updates.json");
|
||||
string titleUpdateMetadataPath = Path.Combine(AppDataManager.GamesDirPath, titleIdBase.ToString("x16"), "updates.json");
|
||||
if (File.Exists(titleUpdateMetadataPath))
|
||||
{
|
||||
updatePath = JsonHelper.DeserializeFromFile(titleUpdateMetadataPath, _applicationSerializerContext.TitleUpdateMetadata).Selected;
|
||||
|
@ -118,7 +118,7 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions
|
||||
device.Configuration.ContentManager.ClearAocData();
|
||||
|
||||
// Load DownloadableContents.
|
||||
string addOnContentMetadataPath = System.IO.Path.Combine(AppDataManager.GamesDirPath, mainNca.Header.TitleId.ToString("x16"), "dlc.json");
|
||||
string addOnContentMetadataPath = System.IO.Path.Combine(AppDataManager.GamesDirPath, mainNca.GetProgramIdBase().ToString("x16"), "dlc.json");
|
||||
if (File.Exists(addOnContentMetadataPath))
|
||||
{
|
||||
List<DownloadableContentContainer> dlcContainerList = JsonHelper.DeserializeFromFile(addOnContentMetadataPath, _contentSerializerContext.ListDownloadableContentContainer);
|
||||
|
@ -42,6 +42,8 @@ namespace Ryujinx.UI.App.Common
|
||||
|
||||
[JsonIgnore] public ulong IdBase => Id & ~0x1FFFUL;
|
||||
|
||||
[JsonIgnore] public string IdBaseString => IdBase.ToString("x16");
|
||||
|
||||
public static string GetBuildId(VirtualFileSystem virtualFileSystem, IntegrityCheckLevel checkLevel, string titleFilePath)
|
||||
{
|
||||
using FileStream file = new(titleFilePath, FileMode.Open, FileAccess.Read);
|
||||
|
@ -34,6 +34,7 @@ namespace Ryujinx.UI.App.Common
|
||||
{
|
||||
public class ApplicationLibrary
|
||||
{
|
||||
public Language DesiredLanguage { get; set; }
|
||||
public event EventHandler<ApplicationAddedEventArgs> ApplicationAdded;
|
||||
public event EventHandler<ApplicationCountUpdatedEventArgs> ApplicationCountUpdated;
|
||||
|
||||
@ -45,7 +46,6 @@ namespace Ryujinx.UI.App.Common
|
||||
|
||||
private readonly VirtualFileSystem _virtualFileSystem;
|
||||
private readonly IntegrityCheckLevel _checkLevel;
|
||||
private Language _desiredTitleLanguage;
|
||||
private CancellationTokenSource _cancellationToken;
|
||||
|
||||
private static readonly ApplicationJsonSerializerContext _serializerContext = new(JsonHelper.GetDefaultSerializerOptions());
|
||||
@ -72,37 +72,43 @@ namespace Ryujinx.UI.App.Common
|
||||
return resourceByteArray;
|
||||
}
|
||||
|
||||
/// <exception cref="Ryujinx.HLE.Exceptions.InvalidNpdmException">The npdm file doesn't contain valid data.</exception>
|
||||
/// <exception cref="NotImplementedException">The FsAccessHeader.ContentOwnerId section is not implemented.</exception>
|
||||
/// <exception cref="ArgumentException">An error occured while reading bytes from the stream.</exception>
|
||||
/// <exception cref="EndOfStreamException">The end of the stream is reached.</exception>
|
||||
/// <exception cref="IOException">An I/O error occurred.</exception>
|
||||
private ApplicationData GetApplicationFromExeFs(PartitionFileSystem pfs, string filePath)
|
||||
{
|
||||
ApplicationData data = new()
|
||||
{
|
||||
Icon = _nspIcon,
|
||||
Path = filePath,
|
||||
};
|
||||
|
||||
using UniqueRef<IFile> npdmFile = new();
|
||||
|
||||
try
|
||||
Result result = pfs.OpenFile(ref npdmFile.Ref, "/main.npdm".ToU8Span(), OpenMode.Read);
|
||||
|
||||
if (ResultFs.PathNotFound.Includes(result))
|
||||
{
|
||||
Result result = pfs.OpenFile(ref npdmFile.Ref, "/main.npdm".ToU8Span(), OpenMode.Read);
|
||||
Npdm npdm = new(npdmFile.Get.AsStream());
|
||||
|
||||
if (ResultFs.PathNotFound.Includes(result))
|
||||
{
|
||||
Npdm npdm = new(npdmFile.Get.AsStream());
|
||||
|
||||
data.Name = npdm.TitleName;
|
||||
data.Id = npdm.Aci0.TitleId;
|
||||
}
|
||||
|
||||
return data;
|
||||
data.Name = npdm.TitleName;
|
||||
data.Id = npdm.Aci0.TitleId;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.Application, $"The file encountered was not of a valid type. File: '{filePath}' Error: {exception.Message}");
|
||||
|
||||
return null;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
/// <exception cref="MissingKeyException">The configured key set is missing a key.</exception>
|
||||
/// <exception cref="InvalidDataException">The NCA header could not be decrypted.</exception>
|
||||
/// <exception cref="NotSupportedException">The NCA version is not supported.</exception>
|
||||
/// <exception cref="HorizonResultException">An error occured while reading PFS data.</exception>
|
||||
/// <exception cref="Ryujinx.HLE.Exceptions.InvalidNpdmException">The npdm file doesn't contain valid data.</exception>
|
||||
/// <exception cref="NotImplementedException">The FsAccessHeader.ContentOwnerId section is not implemented.</exception>
|
||||
/// <exception cref="ArgumentException">An error occured while reading bytes from the stream.</exception>
|
||||
/// <exception cref="EndOfStreamException">The end of the stream is reached.</exception>
|
||||
/// <exception cref="IOException">An I/O error occurred.</exception>
|
||||
private ApplicationData GetApplicationFromNsp(PartitionFileSystem pfs, string filePath)
|
||||
{
|
||||
bool isExeFs = false;
|
||||
@ -170,99 +176,88 @@ namespace Ryujinx.UI.App.Common
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <exception cref="MissingKeyException">The configured key set is missing a key.</exception>
|
||||
/// <exception cref="InvalidDataException">The NCA header could not be decrypted.</exception>
|
||||
/// <exception cref="NotSupportedException">The NCA version is not supported.</exception>
|
||||
/// <exception cref="HorizonResultException">An error occured while reading PFS data.</exception>
|
||||
private List<ApplicationData> GetApplicationsFromPfs(IFileSystem pfs, string filePath)
|
||||
{
|
||||
var applications = new List<ApplicationData>();
|
||||
string extension = Path.GetExtension(filePath).ToLower();
|
||||
|
||||
try
|
||||
foreach ((ulong titleId, ContentMetaData content) in pfs.GetContentData(ContentMetaType.Application, _virtualFileSystem, _checkLevel))
|
||||
{
|
||||
foreach ((ulong titleId, ContentMetaData content) in pfs.GetContentData(ContentMetaType.Application, _virtualFileSystem, _checkLevel))
|
||||
ApplicationData applicationData = new()
|
||||
{
|
||||
ApplicationData applicationData = new()
|
||||
Id = titleId,
|
||||
Path = filePath,
|
||||
};
|
||||
|
||||
Nca mainNca = content.GetNcaByType(_virtualFileSystem.KeySet, ContentType.Program);
|
||||
Nca controlNca = content.GetNcaByType(_virtualFileSystem.KeySet, ContentType.Control);
|
||||
|
||||
BlitStruct<ApplicationControlProperty> controlHolder = new(1);
|
||||
|
||||
IFileSystem controlFs = controlNca?.OpenFileSystem(NcaSectionType.Data, _checkLevel);
|
||||
|
||||
// Check if there is an update available.
|
||||
if (IsUpdateApplied(mainNca, out IFileSystem updatedControlFs))
|
||||
{
|
||||
// Replace the original ControlFs by the updated one.
|
||||
controlFs = updatedControlFs;
|
||||
}
|
||||
|
||||
if (controlFs == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ReadControlData(controlFs, controlHolder.ByteSpan);
|
||||
|
||||
GetApplicationInformation(ref controlHolder.Value, ref applicationData);
|
||||
|
||||
// Read the icon from the ControlFS and store it as a byte array
|
||||
try
|
||||
{
|
||||
using UniqueRef<IFile> icon = new();
|
||||
|
||||
controlFs.OpenFile(ref icon.Ref, $"/icon_{DesiredLanguage}.dat".ToU8Span(), OpenMode.Read).ThrowIfFailure();
|
||||
|
||||
using MemoryStream stream = new();
|
||||
|
||||
icon.Get.AsStream().CopyTo(stream);
|
||||
applicationData.Icon = stream.ToArray();
|
||||
}
|
||||
catch (HorizonResultException)
|
||||
{
|
||||
foreach (DirectoryEntryEx entry in controlFs.EnumerateEntries("/", "*"))
|
||||
{
|
||||
Id = titleId,
|
||||
Path = filePath,
|
||||
};
|
||||
if (entry.Name == "control.nacp")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Nca mainNca = content.GetNcaByType(_virtualFileSystem.KeySet, ContentType.Program);
|
||||
Nca controlNca = content.GetNcaByType(_virtualFileSystem.KeySet, ContentType.Control);
|
||||
using var icon = new UniqueRef<IFile>();
|
||||
|
||||
BlitStruct<ApplicationControlProperty> controlHolder = new(1);
|
||||
|
||||
IFileSystem controlFs = controlNca?.OpenFileSystem(NcaSectionType.Data, _checkLevel);
|
||||
|
||||
// Check if there is an update available.
|
||||
if (IsUpdateApplied(mainNca, out IFileSystem updatedControlFs))
|
||||
{
|
||||
// Replace the original ControlFs by the updated one.
|
||||
controlFs = updatedControlFs;
|
||||
}
|
||||
|
||||
if (controlFs == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ReadControlData(controlFs, controlHolder.ByteSpan);
|
||||
|
||||
GetApplicationInformation(ref controlHolder.Value, ref applicationData);
|
||||
|
||||
// Read the icon from the ControlFS and store it as a byte array
|
||||
try
|
||||
{
|
||||
using UniqueRef<IFile> icon = new();
|
||||
|
||||
controlFs.OpenFile(ref icon.Ref, $"/icon_{_desiredTitleLanguage}.dat".ToU8Span(), OpenMode.Read).ThrowIfFailure();
|
||||
controlFs.OpenFile(ref icon.Ref, entry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
|
||||
|
||||
using MemoryStream stream = new();
|
||||
|
||||
icon.Get.AsStream().CopyTo(stream);
|
||||
applicationData.Icon = stream.ToArray();
|
||||
}
|
||||
catch (HorizonResultException)
|
||||
{
|
||||
foreach (DirectoryEntryEx entry in controlFs.EnumerateEntries("/", "*"))
|
||||
|
||||
if (applicationData.Icon != null)
|
||||
{
|
||||
if (entry.Name == "control.nacp")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
using var icon = new UniqueRef<IFile>();
|
||||
|
||||
controlFs.OpenFile(ref icon.Ref, entry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
|
||||
|
||||
using MemoryStream stream = new();
|
||||
|
||||
icon.Get.AsStream().CopyTo(stream);
|
||||
applicationData.Icon = stream.ToArray();
|
||||
|
||||
if (applicationData.Icon != null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
applicationData.Icon ??= extension == ".xci" ? _xciIcon : _nspIcon;
|
||||
}
|
||||
|
||||
applicationData.ControlHolder = controlHolder;
|
||||
|
||||
applications.Add(applicationData);
|
||||
applicationData.Icon ??= extension == ".xci" ? _xciIcon : _nspIcon;
|
||||
}
|
||||
}
|
||||
catch (MissingKeyException exception)
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.Application, $"Your key set is missing a key with the name: {exception.Name}");
|
||||
}
|
||||
catch (InvalidDataException)
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.Application, $"The header key is incorrect or missing and therefore the NCA header content type check has failed. Errored File: {filePath}");
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.Application, $"The file encountered was not of a valid type. File: '{filePath}' Error: {exception}");
|
||||
|
||||
applicationData.ControlHolder = controlHolder;
|
||||
|
||||
applications.Add(applicationData);
|
||||
}
|
||||
|
||||
return applications;
|
||||
@ -271,8 +266,18 @@ namespace Ryujinx.UI.App.Common
|
||||
public bool TryGetApplicationsFromFile(string applicationPath, out List<ApplicationData> applications)
|
||||
{
|
||||
applications = [];
|
||||
long fileSize;
|
||||
|
||||
long fileSize = new FileInfo(applicationPath).Length;
|
||||
try
|
||||
{
|
||||
fileSize = new FileInfo(applicationPath).Length;
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.Application, $"The file was not found: '{applicationPath}'");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
BlitStruct<ApplicationControlProperty> controlHolder = new(1);
|
||||
|
||||
@ -319,52 +324,43 @@ namespace Ryujinx.UI.App.Common
|
||||
BinaryReader reader = new(file);
|
||||
ApplicationData application = new();
|
||||
|
||||
try
|
||||
file.Seek(24, SeekOrigin.Begin);
|
||||
|
||||
int assetOffset = reader.ReadInt32();
|
||||
|
||||
if (Encoding.ASCII.GetString(Read(assetOffset, 4)) == "ASET")
|
||||
{
|
||||
file.Seek(24, SeekOrigin.Begin);
|
||||
byte[] iconSectionInfo = Read(assetOffset + 8, 0x10);
|
||||
|
||||
int assetOffset = reader.ReadInt32();
|
||||
long iconOffset = BitConverter.ToInt64(iconSectionInfo, 0);
|
||||
long iconSize = BitConverter.ToInt64(iconSectionInfo, 8);
|
||||
|
||||
if (Encoding.ASCII.GetString(Read(assetOffset, 4)) == "ASET")
|
||||
ulong nacpOffset = reader.ReadUInt64();
|
||||
ulong nacpSize = reader.ReadUInt64();
|
||||
|
||||
// Reads and stores game icon as byte array
|
||||
if (iconSize > 0)
|
||||
{
|
||||
byte[] iconSectionInfo = Read(assetOffset + 8, 0x10);
|
||||
|
||||
long iconOffset = BitConverter.ToInt64(iconSectionInfo, 0);
|
||||
long iconSize = BitConverter.ToInt64(iconSectionInfo, 8);
|
||||
|
||||
ulong nacpOffset = reader.ReadUInt64();
|
||||
ulong nacpSize = reader.ReadUInt64();
|
||||
|
||||
// Reads and stores game icon as byte array
|
||||
if (iconSize > 0)
|
||||
{
|
||||
application.Icon = Read(assetOffset + iconOffset, (int)iconSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
application.Icon = _nroIcon;
|
||||
}
|
||||
|
||||
// Read the NACP data
|
||||
Read(assetOffset + (int)nacpOffset, (int)nacpSize).AsSpan().CopyTo(controlHolder.ByteSpan);
|
||||
|
||||
GetApplicationInformation(ref controlHolder.Value, ref application);
|
||||
application.Icon = Read(assetOffset + iconOffset, (int)iconSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
application.Icon = _nroIcon;
|
||||
application.Name = Path.GetFileNameWithoutExtension(applicationPath);
|
||||
}
|
||||
|
||||
application.ControlHolder = controlHolder;
|
||||
applications.Add(application);
|
||||
}
|
||||
catch
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.Application, $"The file encountered was not of a valid type. Errored File: {applicationPath}");
|
||||
// Read the NACP data
|
||||
Read(assetOffset + (int)nacpOffset, (int)nacpSize).AsSpan().CopyTo(controlHolder.ByteSpan);
|
||||
|
||||
return false;
|
||||
GetApplicationInformation(ref controlHolder.Value, ref application);
|
||||
}
|
||||
else
|
||||
{
|
||||
application.Icon = _nroIcon;
|
||||
application.Name = Path.GetFileNameWithoutExtension(applicationPath);
|
||||
}
|
||||
|
||||
application.ControlHolder = controlHolder;
|
||||
applications.Add(application);
|
||||
|
||||
break;
|
||||
|
||||
@ -377,34 +373,21 @@ namespace Ryujinx.UI.App.Common
|
||||
}
|
||||
case ".nca":
|
||||
{
|
||||
try
|
||||
ApplicationData application = new();
|
||||
|
||||
Nca nca = new(_virtualFileSystem.KeySet, new FileStream(applicationPath, FileMode.Open, FileAccess.Read).AsStorage());
|
||||
|
||||
if (!nca.IsProgram() || nca.IsPatch())
|
||||
{
|
||||
ApplicationData application = new();
|
||||
|
||||
Nca nca = new(_virtualFileSystem.KeySet, new FileStream(applicationPath, FileMode.Open, FileAccess.Read).AsStorage());
|
||||
|
||||
if (!nca.IsProgram() || nca.IsPatch())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
application.Icon = _ncaIcon;
|
||||
application.Name = Path.GetFileNameWithoutExtension(applicationPath);
|
||||
application.ControlHolder = controlHolder;
|
||||
|
||||
applications.Add(application);
|
||||
}
|
||||
catch (InvalidDataException)
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.Application, $"The NCA header content type check has failed. This is usually because the header key is incorrect or missing. Errored File: {applicationPath}");
|
||||
}
|
||||
catch
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.Application, $"The file encountered was not of a valid type. Errored File: {applicationPath}");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
application.Icon = _ncaIcon;
|
||||
application.Name = Path.GetFileNameWithoutExtension(applicationPath);
|
||||
application.ControlHolder = controlHolder;
|
||||
|
||||
applications.Add(application);
|
||||
|
||||
break;
|
||||
}
|
||||
// If its an NSO we just set defaults
|
||||
@ -417,48 +400,72 @@ namespace Ryujinx.UI.App.Common
|
||||
};
|
||||
|
||||
applications.Add(application);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (MissingKeyException exception)
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.Application, $"Your key set is missing a key with the name: {exception.Name}");
|
||||
|
||||
return false;
|
||||
}
|
||||
catch (InvalidDataException)
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.Application, $"The header key is incorrect or missing and therefore the NCA header content type check has failed. Errored File: {applicationPath}");
|
||||
|
||||
return false;
|
||||
}
|
||||
catch (IOException exception)
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.Application, exception.Message);
|
||||
|
||||
return false;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.Application, $"The file encountered was not of a valid type. File: '{applicationPath}' Error: {exception}");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach (var data in applications)
|
||||
{
|
||||
ApplicationMetadata appMetadata = LoadAndSaveMetaData(data.IdString, appMetadata =>
|
||||
// Only load metadata for applications with an ID
|
||||
if (data.Id != 0)
|
||||
{
|
||||
appMetadata.Title = data.Name;
|
||||
|
||||
// Only do the migration if time_played has a value and timespan_played hasn't been updated yet.
|
||||
if (appMetadata.TimePlayedOld != default && appMetadata.TimePlayed == TimeSpan.Zero)
|
||||
ApplicationMetadata appMetadata = LoadAndSaveMetaData(data.IdString, appMetadata =>
|
||||
{
|
||||
appMetadata.TimePlayed = TimeSpan.FromSeconds(appMetadata.TimePlayedOld);
|
||||
appMetadata.TimePlayedOld = default;
|
||||
}
|
||||
appMetadata.Title = data.Name;
|
||||
|
||||
// Only do the migration if last_played has a value and last_played_utc doesn't exist yet.
|
||||
if (appMetadata.LastPlayedOld != default && !appMetadata.LastPlayed.HasValue)
|
||||
{
|
||||
// Migrate from string-based last_played to DateTime-based last_played_utc.
|
||||
if (DateTime.TryParse(appMetadata.LastPlayedOld, out DateTime lastPlayedOldParsed))
|
||||
// Only do the migration if time_played has a value and timespan_played hasn't been updated yet.
|
||||
if (appMetadata.TimePlayedOld != default && appMetadata.TimePlayed == TimeSpan.Zero)
|
||||
{
|
||||
appMetadata.LastPlayed = lastPlayedOldParsed;
|
||||
|
||||
// Migration successful: deleting last_played from the metadata file.
|
||||
appMetadata.LastPlayedOld = default;
|
||||
appMetadata.TimePlayed = TimeSpan.FromSeconds(appMetadata.TimePlayedOld);
|
||||
appMetadata.TimePlayedOld = default;
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
// Only do the migration if last_played has a value and last_played_utc doesn't exist yet.
|
||||
if (appMetadata.LastPlayedOld != default && !appMetadata.LastPlayed.HasValue)
|
||||
{
|
||||
// Migrate from string-based last_played to DateTime-based last_played_utc.
|
||||
if (DateTime.TryParse(appMetadata.LastPlayedOld, out DateTime lastPlayedOldParsed))
|
||||
{
|
||||
appMetadata.LastPlayed = lastPlayedOldParsed;
|
||||
|
||||
// Migration successful: deleting last_played from the metadata file.
|
||||
appMetadata.LastPlayedOld = default;
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
data.Favorite = appMetadata.Favorite;
|
||||
data.TimePlayed = appMetadata.TimePlayed;
|
||||
data.LastPlayed = appMetadata.LastPlayed;
|
||||
}
|
||||
|
||||
data.Favorite = appMetadata.Favorite;
|
||||
data.TimePlayed = appMetadata.TimePlayed;
|
||||
data.LastPlayed = appMetadata.LastPlayed;
|
||||
data.FileExtension = Path.GetExtension(applicationPath).TrimStart('.').ToUpper();
|
||||
data.FileSize = fileSize;
|
||||
data.Path = applicationPath;
|
||||
@ -480,13 +487,11 @@ namespace Ryujinx.UI.App.Common
|
||||
controlFile.Get.Read(out _, 0, outProperty, ReadOption.None).ThrowIfFailure();
|
||||
}
|
||||
|
||||
public void LoadApplications(List<string> appDirs, Language desiredTitleLanguage)
|
||||
public void LoadApplications(List<string> appDirs)
|
||||
{
|
||||
int numApplicationsFound = 0;
|
||||
int numApplicationsLoaded = 0;
|
||||
|
||||
_desiredTitleLanguage = desiredTitleLanguage;
|
||||
|
||||
_cancellationToken = new CancellationTokenSource();
|
||||
|
||||
// Builds the applications list with paths to found applications
|
||||
@ -510,7 +515,13 @@ namespace Ryujinx.UI.App.Common
|
||||
|
||||
try
|
||||
{
|
||||
IEnumerable<string> files = Directory.EnumerateFiles(appDir, "*", SearchOption.AllDirectories).Where(file =>
|
||||
EnumerationOptions options = new()
|
||||
{
|
||||
RecurseSubdirectories = true,
|
||||
IgnoreInaccessible = false,
|
||||
};
|
||||
|
||||
IEnumerable<string> files = Directory.EnumerateFiles(appDir, "*", options).Where(file =>
|
||||
{
|
||||
return
|
||||
(Path.GetExtension(file).ToLower() is ".nsp" && ConfigurationState.Instance.UI.ShownFileTypes.NSP.Value) ||
|
||||
@ -529,14 +540,18 @@ namespace Ryujinx.UI.App.Common
|
||||
}
|
||||
|
||||
var fileInfo = new FileInfo(app);
|
||||
string extension = fileInfo.Extension.ToLower();
|
||||
|
||||
if (!fileInfo.Attributes.HasFlag(FileAttributes.Hidden) && extension is ".nsp" or ".pfs0" or ".xci" or ".nca" or ".nro" or ".nso")
|
||||
try
|
||||
{
|
||||
var fullPath = fileInfo.ResolveLinkTarget(true)?.FullName ?? fileInfo.FullName;
|
||||
|
||||
applicationPaths.Add(fullPath);
|
||||
numApplicationsFound++;
|
||||
}
|
||||
catch (IOException exception)
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.Application, $"Failed to resolve the full path to file: \"{app}\" Error: {exception}");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (UnauthorizedAccessException)
|
||||
@ -835,7 +850,7 @@ namespace Ryujinx.UI.App.Common
|
||||
|
||||
private void GetApplicationInformation(ref ApplicationControlProperty controlData, ref ApplicationData data)
|
||||
{
|
||||
_ = Enum.TryParse(_desiredTitleLanguage.ToString(), out TitleLanguage desiredTitleLanguage);
|
||||
_ = Enum.TryParse(DesiredLanguage.ToString(), out TitleLanguage desiredTitleLanguage);
|
||||
|
||||
if (controlData.Title.ItemsRo.Length > (int)desiredTitleLanguage)
|
||||
{
|
||||
|
@ -21,7 +21,7 @@ namespace Ryujinx.Ava.Common.Locale
|
||||
|
||||
var builder = new CompiledBindingPathBuilder();
|
||||
|
||||
builder.SetRawSource(LocaleManager.Instance)
|
||||
builder
|
||||
.Property(new ClrPropertyInfo("Item",
|
||||
obj => (LocaleManager.Instance[keyToUse]),
|
||||
null,
|
||||
@ -32,7 +32,10 @@ namespace Ryujinx.Ava.Common.Locale
|
||||
|
||||
var path = builder.Build();
|
||||
|
||||
var binding = new CompiledBindingExtension(path);
|
||||
var binding = new CompiledBindingExtension(path)
|
||||
{
|
||||
Source = LocaleManager.Instance
|
||||
};
|
||||
|
||||
return binding.ProvideValue(serviceProvider);
|
||||
}
|
||||
|
@ -139,9 +139,11 @@ namespace Ryujinx.Ava.Common.Locale
|
||||
|
||||
foreach (var item in locale)
|
||||
{
|
||||
this[item.Key] = item.Value;
|
||||
_localeStrings[item.Key] = item.Value;
|
||||
}
|
||||
|
||||
OnPropertyChanged("Item");
|
||||
|
||||
LocaleChanged?.Invoke();
|
||||
}
|
||||
|
||||
|
@ -1,21 +1,20 @@
|
||||
using LibHac.Ns;
|
||||
using Ryujinx.Ava.Common.Locale;
|
||||
|
||||
namespace Ryujinx.Ava.UI.Models
|
||||
{
|
||||
public class TitleUpdateModel
|
||||
{
|
||||
public ApplicationControlProperty Control { get; }
|
||||
public uint Version { get; }
|
||||
public string Path { get; }
|
||||
public string Label { get; }
|
||||
|
||||
public string Label => LocaleManager.Instance.UpdateAndGetDynamicValue(
|
||||
System.IO.Path.GetExtension(Path)?.ToLower() == ".xci" ? LocaleKeys.TitleBundledUpdateVersionLabel : LocaleKeys.TitleUpdateVersionLabel,
|
||||
Control.DisplayVersionString.ToString()
|
||||
);
|
||||
|
||||
public TitleUpdateModel(ApplicationControlProperty control, string path)
|
||||
public TitleUpdateModel(uint version, string displayVersion, string path)
|
||||
{
|
||||
Control = control;
|
||||
Version = version;
|
||||
Label = LocaleManager.Instance.UpdateAndGetDynamicValue(
|
||||
System.IO.Path.GetExtension(path)?.ToLower() == ".xci" ? LocaleKeys.TitleBundledUpdateVersionLabel : LocaleKeys.TitleUpdateVersionLabel,
|
||||
displayVersion
|
||||
);
|
||||
Path = path;
|
||||
}
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
_storageProvider = desktop.MainWindow.StorageProvider;
|
||||
}
|
||||
|
||||
_downloadableContentJsonPath = Path.Combine(AppDataManager.GamesDirPath, applicationData.IdString, "dlc.json");
|
||||
_downloadableContentJsonPath = Path.Combine(AppDataManager.GamesDirPath, applicationData.IdBaseString, "dlc.json");
|
||||
|
||||
if (!File.Exists(_downloadableContentJsonPath))
|
||||
{
|
||||
|
@ -88,7 +88,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
StorageProvider = desktop.MainWindow.StorageProvider;
|
||||
}
|
||||
|
||||
TitleUpdateJsonPath = Path.Combine(AppDataManager.GamesDirPath, ApplicationData.IdString, "updates.json");
|
||||
TitleUpdateJsonPath = Path.Combine(AppDataManager.GamesDirPath, ApplicationData.IdBaseString, "updates.json");
|
||||
|
||||
try
|
||||
{
|
||||
@ -96,7 +96,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
}
|
||||
catch
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.Application, $"Failed to deserialize title update data for {ApplicationData.IdString} at {TitleUpdateJsonPath}");
|
||||
Logger.Warning?.Print(LogClass.Application, $"Failed to deserialize title update data for {ApplicationData.IdBaseString} at {TitleUpdateJsonPath}");
|
||||
|
||||
TitleUpdateWindowData = new TitleUpdateMetadata
|
||||
{
|
||||
@ -131,26 +131,11 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
|
||||
public void SortUpdates()
|
||||
{
|
||||
var list = TitleUpdates.ToList();
|
||||
|
||||
list.Sort((first, second) =>
|
||||
{
|
||||
if (string.IsNullOrEmpty(first.Control.DisplayVersionString.ToString()))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(second.Control.DisplayVersionString.ToString()))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return Version.Parse(first.Control.DisplayVersionString.ToString()).CompareTo(Version.Parse(second.Control.DisplayVersionString.ToString())) * -1;
|
||||
});
|
||||
var sortedUpdates = TitleUpdates.OrderByDescending(update => update.Version);
|
||||
|
||||
Views.Clear();
|
||||
Views.Add(new BaseModel());
|
||||
Views.AddRange(list);
|
||||
Views.AddRange(sortedUpdates);
|
||||
|
||||
if (SelectedUpdate == null)
|
||||
{
|
||||
@ -204,7 +189,9 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
controlNca.OpenFileSystem(NcaSectionType.Data, IntegrityCheckLevel.None).OpenFile(ref nacpFile.Ref, "/control.nacp".ToU8Span(), OpenMode.Read).ThrowIfFailure();
|
||||
nacpFile.Get.Read(out _, 0, SpanHelpers.AsByteSpan(ref controlData), ReadOption.None).ThrowIfFailure();
|
||||
|
||||
var update = new TitleUpdateModel(controlData, path);
|
||||
var displayVersion = controlData.DisplayVersionString.ToString();
|
||||
var update = new TitleUpdateModel(content.Version.Version, displayVersion, path);
|
||||
|
||||
TitleUpdates.Add(update);
|
||||
|
||||
if (selected)
|
||||
|
@ -1,7 +1,7 @@
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using Ryujinx.Ava.UI.Models;
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
|
||||
namespace Ryujinx.Ava.UI.ViewModels
|
||||
{
|
||||
@ -11,7 +11,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
{
|
||||
Profiles = new ObservableCollection<BaseModel>();
|
||||
LostProfiles = new ObservableCollection<UserProfile>();
|
||||
IsEmpty = LostProfiles.IsNullOrEmpty();
|
||||
IsEmpty = !LostProfiles.Any();
|
||||
}
|
||||
|
||||
public ObservableCollection<BaseModel> Profiles { get; set; }
|
||||
|
@ -38,7 +38,7 @@ namespace Ryujinx.Ava.UI.Windows
|
||||
SecondaryButtonText = "",
|
||||
CloseButtonText = "",
|
||||
Content = new DownloadableContentManagerWindow(virtualFileSystem, applicationData),
|
||||
Title = string.Format(LocaleManager.Instance[LocaleKeys.DlcWindowTitle], applicationData.Name, applicationData.IdString),
|
||||
Title = string.Format(LocaleManager.Instance[LocaleKeys.DlcWindowTitle], applicationData.Name, applicationData.IdBaseString),
|
||||
};
|
||||
|
||||
Style bottomBorder = new(x => x.OfType<Grid>().Name("DialogSpace").Child().OfType<Border>());
|
||||
|
@ -37,6 +37,7 @@ namespace Ryujinx.Ava.UI.Windows
|
||||
internal static MainWindowViewModel MainWindowViewModel { get; private set; }
|
||||
|
||||
private bool _isLoading;
|
||||
private bool _applicationsLoadedOnce;
|
||||
|
||||
private UserChannelPersistence _userChannelPersistence;
|
||||
private static bool _deferLoad;
|
||||
@ -224,7 +225,10 @@ namespace Ryujinx.Ava.UI.Windows
|
||||
? IntegrityCheckLevel.ErrorOnInvalid
|
||||
: IntegrityCheckLevel.None;
|
||||
|
||||
ApplicationLibrary = new ApplicationLibrary(VirtualFileSystem, checkLevel);
|
||||
ApplicationLibrary = new ApplicationLibrary(VirtualFileSystem, checkLevel)
|
||||
{
|
||||
DesiredLanguage = ConfigurationState.Instance.System.Language,
|
||||
};
|
||||
|
||||
// Save data created before we supported extra data in directory save data will not work properly if
|
||||
// given empty extra data. Luckily some of that extra data can be created using the data from the
|
||||
@ -472,7 +476,11 @@ namespace Ryujinx.Ava.UI.Windows
|
||||
|
||||
ViewModel.RefreshFirmwareStatus();
|
||||
|
||||
LoadApplications();
|
||||
// Load applications if no application was requested by the command line
|
||||
if (!_deferLoad)
|
||||
{
|
||||
LoadApplications();
|
||||
}
|
||||
|
||||
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
||||
CheckLaunchState();
|
||||
@ -485,6 +493,12 @@ namespace Ryujinx.Ava.UI.Windows
|
||||
|
||||
if (MainContent.Content != content)
|
||||
{
|
||||
// Load applications while switching to the GameLibrary if we haven't done that yet
|
||||
if (!_applicationsLoadedOnce && content == GameLibrary)
|
||||
{
|
||||
LoadApplications();
|
||||
}
|
||||
|
||||
MainContent.Content = content;
|
||||
}
|
||||
}
|
||||
@ -581,6 +595,7 @@ namespace Ryujinx.Ava.UI.Windows
|
||||
|
||||
public void LoadApplications()
|
||||
{
|
||||
_applicationsLoadedOnce = true;
|
||||
ViewModel.Applications.Clear();
|
||||
|
||||
StatusBarView.LoadProgressBar.IsVisible = true;
|
||||
@ -622,7 +637,8 @@ namespace Ryujinx.Ava.UI.Windows
|
||||
|
||||
Thread applicationLibraryThread = new(() =>
|
||||
{
|
||||
ApplicationLibrary.LoadApplications(ConfigurationState.Instance.UI.GameDirs, ConfigurationState.Instance.System.Language);
|
||||
ApplicationLibrary.DesiredLanguage = ConfigurationState.Instance.System.Language;
|
||||
ApplicationLibrary.LoadApplications(ConfigurationState.Instance.UI.GameDirs);
|
||||
|
||||
_isLoading = false;
|
||||
})
|
||||
|
@ -40,7 +40,7 @@ namespace Ryujinx.Ava.UI.Windows
|
||||
SecondaryButtonText = "",
|
||||
CloseButtonText = "",
|
||||
Content = new TitleUpdateWindow(virtualFileSystem, applicationData),
|
||||
Title = LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.GameUpdateWindowHeading, applicationData.Name, applicationData.IdString),
|
||||
Title = LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.GameUpdateWindowHeading, applicationData.Name, applicationData.IdBaseString),
|
||||
};
|
||||
|
||||
Style bottomBorder = new(x => x.OfType<Grid>().Name("DialogSpace").Child().OfType<Border>());
|
||||
|
Reference in New Issue
Block a user