Compare commits
16 Commits
Author | SHA1 | Date | |
---|---|---|---|
ed0b10c81f | |||
f92650fcff | |||
712361f6e1 | |||
2232e4ae87 | |||
14ce9e1567 | |||
952d013c67 | |||
46c8129bf5 | |||
8cfec5de4b | |||
37b6e081da | |||
3c3bcd82fe | |||
a00c59a46c | |||
1825bd87b4 | |||
62f8ceb60b | |||
1a888ae087 | |||
84d0ca5645 | |||
31b8d413d5 |
@ -197,12 +197,29 @@ namespace ARMeilleure.Signal
|
||||
// Only call tracking if in range.
|
||||
context.BranchIfFalse(nextLabel, inRange, BasicBlockFrequency.Cold);
|
||||
|
||||
context.Copy(inRegionLocal, Const(1));
|
||||
Operand offset = context.BitwiseAnd(context.Subtract(faultAddress, rangeAddress), Const(~PageMask));
|
||||
|
||||
// Call the tracking action, with the pointer's relative offset to the base address.
|
||||
Operand trackingActionPtr = context.Load(OperandType.I64, Const((ulong)signalStructPtr + rangeBaseOffset + 20));
|
||||
context.Call(trackingActionPtr, OperandType.I32, offset, Const(PageSize), isWrite, Const(0));
|
||||
|
||||
context.Copy(inRegionLocal, Const(0));
|
||||
|
||||
Operand skipActionLabel = Label();
|
||||
|
||||
// Tracking action should be non-null to call it, otherwise assume false return.
|
||||
context.BranchIfFalse(skipActionLabel, trackingActionPtr);
|
||||
Operand result = context.Call(trackingActionPtr, OperandType.I32, offset, Const(PageSize), isWrite, Const(0));
|
||||
context.Copy(inRegionLocal, result);
|
||||
|
||||
context.MarkLabel(skipActionLabel);
|
||||
|
||||
// If the tracking action returns false or does not exist, it might be an invalid access due to a partial overlap on Windows.
|
||||
if (OperatingSystem.IsWindows())
|
||||
{
|
||||
context.BranchIfTrue(endLabel, inRegionLocal);
|
||||
|
||||
context.Copy(inRegionLocal, WindowsPartialUnmapHandler.EmitRetryFromAccessViolation(context));
|
||||
}
|
||||
|
||||
context.Branch(endLabel);
|
||||
|
||||
|
84
ARMeilleure/Signal/TestMethods.cs
Normal file
84
ARMeilleure/Signal/TestMethods.cs
Normal file
@ -0,0 +1,84 @@
|
||||
using ARMeilleure.IntermediateRepresentation;
|
||||
using ARMeilleure.Translation;
|
||||
using System;
|
||||
|
||||
using static ARMeilleure.IntermediateRepresentation.Operand.Factory;
|
||||
|
||||
namespace ARMeilleure.Signal
|
||||
{
|
||||
public struct NativeWriteLoopState
|
||||
{
|
||||
public int Running;
|
||||
public int Error;
|
||||
}
|
||||
|
||||
public static class TestMethods
|
||||
{
|
||||
public delegate bool DebugPartialUnmap();
|
||||
public delegate int DebugThreadLocalMapGetOrReserve(int threadId, int initialState);
|
||||
public delegate void DebugNativeWriteLoop(IntPtr nativeWriteLoopPtr, IntPtr writePtr);
|
||||
|
||||
public static DebugPartialUnmap GenerateDebugPartialUnmap()
|
||||
{
|
||||
EmitterContext context = new EmitterContext();
|
||||
|
||||
var result = WindowsPartialUnmapHandler.EmitRetryFromAccessViolation(context);
|
||||
|
||||
context.Return(result);
|
||||
|
||||
// Compile and return the function.
|
||||
|
||||
ControlFlowGraph cfg = context.GetControlFlowGraph();
|
||||
|
||||
OperandType[] argTypes = new OperandType[] { OperandType.I64 };
|
||||
|
||||
return Compiler.Compile(cfg, argTypes, OperandType.I32, CompilerOptions.HighCq).Map<DebugPartialUnmap>();
|
||||
}
|
||||
|
||||
public static DebugThreadLocalMapGetOrReserve GenerateDebugThreadLocalMapGetOrReserve(IntPtr structPtr)
|
||||
{
|
||||
EmitterContext context = new EmitterContext();
|
||||
|
||||
var result = WindowsPartialUnmapHandler.EmitThreadLocalMapIntGetOrReserve(context, structPtr, context.LoadArgument(OperandType.I32, 0), context.LoadArgument(OperandType.I32, 1));
|
||||
|
||||
context.Return(result);
|
||||
|
||||
// Compile and return the function.
|
||||
|
||||
ControlFlowGraph cfg = context.GetControlFlowGraph();
|
||||
|
||||
OperandType[] argTypes = new OperandType[] { OperandType.I64 };
|
||||
|
||||
return Compiler.Compile(cfg, argTypes, OperandType.I32, CompilerOptions.HighCq).Map<DebugThreadLocalMapGetOrReserve>();
|
||||
}
|
||||
|
||||
public static DebugNativeWriteLoop GenerateDebugNativeWriteLoop()
|
||||
{
|
||||
EmitterContext context = new EmitterContext();
|
||||
|
||||
// Loop a write to the target address until "running" is false.
|
||||
|
||||
Operand structPtr = context.Copy(context.LoadArgument(OperandType.I64, 0));
|
||||
Operand writePtr = context.Copy(context.LoadArgument(OperandType.I64, 1));
|
||||
|
||||
Operand loopLabel = Label();
|
||||
context.MarkLabel(loopLabel);
|
||||
|
||||
context.Store(writePtr, Const(12345));
|
||||
|
||||
Operand running = context.Load(OperandType.I32, structPtr);
|
||||
|
||||
context.BranchIfTrue(loopLabel, running);
|
||||
|
||||
context.Return();
|
||||
|
||||
// Compile and return the function.
|
||||
|
||||
ControlFlowGraph cfg = context.GetControlFlowGraph();
|
||||
|
||||
OperandType[] argTypes = new OperandType[] { OperandType.I64 };
|
||||
|
||||
return Compiler.Compile(cfg, argTypes, OperandType.None, CompilerOptions.HighCq).Map<DebugNativeWriteLoop>();
|
||||
}
|
||||
}
|
||||
}
|
186
ARMeilleure/Signal/WindowsPartialUnmapHandler.cs
Normal file
186
ARMeilleure/Signal/WindowsPartialUnmapHandler.cs
Normal file
@ -0,0 +1,186 @@
|
||||
using ARMeilleure.IntermediateRepresentation;
|
||||
using ARMeilleure.Translation;
|
||||
using Ryujinx.Common.Memory.PartialUnmaps;
|
||||
using System;
|
||||
|
||||
using static ARMeilleure.IntermediateRepresentation.Operand.Factory;
|
||||
|
||||
namespace ARMeilleure.Signal
|
||||
{
|
||||
/// <summary>
|
||||
/// Methods to handle signals caused by partial unmaps. See the structs for C# implementations of the methods.
|
||||
/// </summary>
|
||||
internal static class WindowsPartialUnmapHandler
|
||||
{
|
||||
public static Operand EmitRetryFromAccessViolation(EmitterContext context)
|
||||
{
|
||||
IntPtr partialRemapStatePtr = PartialUnmapState.GlobalState;
|
||||
IntPtr localCountsPtr = IntPtr.Add(partialRemapStatePtr, PartialUnmapState.LocalCountsOffset);
|
||||
|
||||
// Get the lock first.
|
||||
EmitNativeReaderLockAcquire(context, IntPtr.Add(partialRemapStatePtr, PartialUnmapState.PartialUnmapLockOffset));
|
||||
|
||||
IntPtr getCurrentThreadId = WindowsSignalHandlerRegistration.GetCurrentThreadIdFunc();
|
||||
Operand threadId = context.Call(Const((ulong)getCurrentThreadId), OperandType.I32);
|
||||
Operand threadIndex = EmitThreadLocalMapIntGetOrReserve(context, localCountsPtr, threadId, Const(0));
|
||||
|
||||
Operand endLabel = Label();
|
||||
Operand retry = context.AllocateLocal(OperandType.I32);
|
||||
Operand threadIndexValidLabel = Label();
|
||||
|
||||
context.BranchIfFalse(threadIndexValidLabel, context.ICompareEqual(threadIndex, Const(-1)));
|
||||
|
||||
context.Copy(retry, Const(1)); // Always retry when thread local cannot be allocated.
|
||||
|
||||
context.Branch(endLabel);
|
||||
|
||||
context.MarkLabel(threadIndexValidLabel);
|
||||
|
||||
Operand threadLocalPartialUnmapsPtr = EmitThreadLocalMapIntGetValuePtr(context, localCountsPtr, threadIndex);
|
||||
Operand threadLocalPartialUnmaps = context.Load(OperandType.I32, threadLocalPartialUnmapsPtr);
|
||||
Operand partialUnmapsCount = context.Load(OperandType.I32, Const((ulong)IntPtr.Add(partialRemapStatePtr, PartialUnmapState.PartialUnmapsCountOffset)));
|
||||
|
||||
context.Copy(retry, context.ICompareNotEqual(threadLocalPartialUnmaps, partialUnmapsCount));
|
||||
|
||||
Operand noRetryLabel = Label();
|
||||
|
||||
context.BranchIfFalse(noRetryLabel, retry);
|
||||
|
||||
// if (retry) {
|
||||
|
||||
context.Store(threadLocalPartialUnmapsPtr, partialUnmapsCount);
|
||||
|
||||
context.Branch(endLabel);
|
||||
|
||||
context.MarkLabel(noRetryLabel);
|
||||
|
||||
// }
|
||||
|
||||
context.MarkLabel(endLabel);
|
||||
|
||||
// Finally, release the lock and return the retry value.
|
||||
EmitNativeReaderLockRelease(context, IntPtr.Add(partialRemapStatePtr, PartialUnmapState.PartialUnmapLockOffset));
|
||||
|
||||
return retry;
|
||||
}
|
||||
|
||||
public static Operand EmitThreadLocalMapIntGetOrReserve(EmitterContext context, IntPtr threadLocalMapPtr, Operand threadId, Operand initialState)
|
||||
{
|
||||
Operand idsPtr = Const((ulong)IntPtr.Add(threadLocalMapPtr, ThreadLocalMap<int>.ThreadIdsOffset));
|
||||
|
||||
Operand i = context.AllocateLocal(OperandType.I32);
|
||||
|
||||
context.Copy(i, Const(0));
|
||||
|
||||
// (Loop 1) Check all slots for a matching Thread ID (while also trying to allocate)
|
||||
|
||||
Operand endLabel = Label();
|
||||
|
||||
Operand loopLabel = Label();
|
||||
context.MarkLabel(loopLabel);
|
||||
|
||||
Operand offset = context.Multiply(i, Const(sizeof(int)));
|
||||
Operand idPtr = context.Add(idsPtr, context.SignExtend32(OperandType.I64, offset));
|
||||
|
||||
// Check that this slot has the thread ID.
|
||||
Operand existingId = context.CompareAndSwap(idPtr, threadId, threadId);
|
||||
|
||||
// If it was already the thread ID, then we just need to return i.
|
||||
context.BranchIfTrue(endLabel, context.ICompareEqual(existingId, threadId));
|
||||
|
||||
context.Copy(i, context.Add(i, Const(1)));
|
||||
|
||||
context.BranchIfTrue(loopLabel, context.ICompareLess(i, Const(ThreadLocalMap<int>.MapSize)));
|
||||
|
||||
// (Loop 2) Try take a slot that is 0 with our Thread ID.
|
||||
|
||||
context.Copy(i, Const(0)); // Reset i.
|
||||
|
||||
Operand loop2Label = Label();
|
||||
context.MarkLabel(loop2Label);
|
||||
|
||||
Operand offset2 = context.Multiply(i, Const(sizeof(int)));
|
||||
Operand idPtr2 = context.Add(idsPtr, context.SignExtend32(OperandType.I64, offset2));
|
||||
|
||||
// Try and swap in the thread id on top of 0.
|
||||
Operand existingId2 = context.CompareAndSwap(idPtr2, Const(0), threadId);
|
||||
|
||||
Operand idNot0Label = Label();
|
||||
|
||||
// If it was 0, then we need to initialize the struct entry and return i.
|
||||
context.BranchIfFalse(idNot0Label, context.ICompareEqual(existingId2, Const(0)));
|
||||
|
||||
Operand structsPtr = Const((ulong)IntPtr.Add(threadLocalMapPtr, ThreadLocalMap<int>.StructsOffset));
|
||||
Operand structPtr = context.Add(structsPtr, context.SignExtend32(OperandType.I64, offset2));
|
||||
context.Store(structPtr, initialState);
|
||||
|
||||
context.Branch(endLabel);
|
||||
|
||||
context.MarkLabel(idNot0Label);
|
||||
|
||||
context.Copy(i, context.Add(i, Const(1)));
|
||||
|
||||
context.BranchIfTrue(loop2Label, context.ICompareLess(i, Const(ThreadLocalMap<int>.MapSize)));
|
||||
|
||||
context.Copy(i, Const(-1)); // Could not place the thread in the list.
|
||||
|
||||
context.MarkLabel(endLabel);
|
||||
|
||||
return context.Copy(i);
|
||||
}
|
||||
|
||||
private static Operand EmitThreadLocalMapIntGetValuePtr(EmitterContext context, IntPtr threadLocalMapPtr, Operand index)
|
||||
{
|
||||
Operand offset = context.Multiply(index, Const(sizeof(int)));
|
||||
Operand structsPtr = Const((ulong)IntPtr.Add(threadLocalMapPtr, ThreadLocalMap<int>.StructsOffset));
|
||||
|
||||
return context.Add(structsPtr, context.SignExtend32(OperandType.I64, offset));
|
||||
}
|
||||
|
||||
private static void EmitThreadLocalMapIntRelease(EmitterContext context, IntPtr threadLocalMapPtr, Operand threadId, Operand index)
|
||||
{
|
||||
Operand offset = context.Multiply(index, Const(sizeof(int)));
|
||||
Operand idsPtr = Const((ulong)IntPtr.Add(threadLocalMapPtr, ThreadLocalMap<int>.ThreadIdsOffset));
|
||||
Operand idPtr = context.Add(idsPtr, context.SignExtend32(OperandType.I64, offset));
|
||||
|
||||
context.CompareAndSwap(idPtr, threadId, Const(0));
|
||||
}
|
||||
|
||||
private static void EmitAtomicAddI32(EmitterContext context, Operand ptr, Operand additive)
|
||||
{
|
||||
Operand loop = Label();
|
||||
context.MarkLabel(loop);
|
||||
|
||||
Operand initial = context.Load(OperandType.I32, ptr);
|
||||
Operand newValue = context.Add(initial, additive);
|
||||
|
||||
Operand replaced = context.CompareAndSwap(ptr, initial, newValue);
|
||||
|
||||
context.BranchIfFalse(loop, context.ICompareEqual(initial, replaced));
|
||||
}
|
||||
|
||||
private static void EmitNativeReaderLockAcquire(EmitterContext context, IntPtr nativeReaderLockPtr)
|
||||
{
|
||||
Operand writeLockPtr = Const((ulong)IntPtr.Add(nativeReaderLockPtr, NativeReaderWriterLock.WriteLockOffset));
|
||||
|
||||
// Spin until we can acquire the write lock.
|
||||
Operand spinLabel = Label();
|
||||
context.MarkLabel(spinLabel);
|
||||
|
||||
// Old value must be 0 to continue (we gained the write lock)
|
||||
context.BranchIfTrue(spinLabel, context.CompareAndSwap(writeLockPtr, Const(0), Const(1)));
|
||||
|
||||
// Increment reader count.
|
||||
EmitAtomicAddI32(context, Const((ulong)IntPtr.Add(nativeReaderLockPtr, NativeReaderWriterLock.ReaderCountOffset)), Const(1));
|
||||
|
||||
// Release write lock.
|
||||
context.CompareAndSwap(writeLockPtr, Const(1), Const(0));
|
||||
}
|
||||
|
||||
private static void EmitNativeReaderLockRelease(EmitterContext context, IntPtr nativeReaderLockPtr)
|
||||
{
|
||||
// Decrement reader count.
|
||||
EmitAtomicAddI32(context, Const((ulong)IntPtr.Add(nativeReaderLockPtr, NativeReaderWriterLock.ReaderCountOffset)), Const(-1));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,9 +1,10 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace ARMeilleure.Signal
|
||||
{
|
||||
class WindowsSignalHandlerRegistration
|
||||
unsafe class WindowsSignalHandlerRegistration
|
||||
{
|
||||
[DllImport("kernel32.dll")]
|
||||
private static extern IntPtr AddVectoredExceptionHandler(uint first, IntPtr handler);
|
||||
@ -11,6 +12,14 @@ namespace ARMeilleure.Signal
|
||||
[DllImport("kernel32.dll")]
|
||||
private static extern ulong RemoveVectoredExceptionHandler(IntPtr handle);
|
||||
|
||||
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Ansi)]
|
||||
static extern IntPtr LoadLibrary([MarshalAs(UnmanagedType.LPStr)] string lpFileName);
|
||||
|
||||
[DllImport("kernel32.dll", CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
|
||||
private static extern IntPtr GetProcAddress(IntPtr hModule, string procName);
|
||||
|
||||
private static IntPtr _getCurrentThreadIdPtr;
|
||||
|
||||
public static IntPtr RegisterExceptionHandler(IntPtr action)
|
||||
{
|
||||
return AddVectoredExceptionHandler(1, action);
|
||||
@ -20,5 +29,17 @@ namespace ARMeilleure.Signal
|
||||
{
|
||||
return RemoveVectoredExceptionHandler(handle) != 0;
|
||||
}
|
||||
|
||||
public static IntPtr GetCurrentThreadIdFunc()
|
||||
{
|
||||
if (_getCurrentThreadIdPtr == IntPtr.Zero)
|
||||
{
|
||||
IntPtr handle = LoadLibrary("kernel32.dll");
|
||||
|
||||
_getCurrentThreadIdPtr = GetProcAddress(handle, "GetCurrentThreadId");
|
||||
}
|
||||
|
||||
return _getCurrentThreadIdPtr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ namespace Ryujinx.Audio.Renderer.Common
|
||||
return Memory<byte>.Empty;
|
||||
}
|
||||
|
||||
public Memory<T> Allocate<T>(ulong count, int align) where T: unmanaged
|
||||
public Memory<T> Allocate<T>(ulong count, int align) where T : unmanaged
|
||||
{
|
||||
Memory<byte> allocatedMemory = Allocate((ulong)Unsafe.SizeOf<T>() * count, align);
|
||||
|
||||
@ -53,7 +53,7 @@ namespace Ryujinx.Audio.Renderer.Common
|
||||
return SpanMemoryManager<T>.Cast(allocatedMemory);
|
||||
}
|
||||
|
||||
public static ulong GetTargetSize<T>(ulong currentSize, ulong count, int align) where T: unmanaged
|
||||
public static ulong GetTargetSize<T>(ulong currentSize, ulong count, int align) where T : unmanaged
|
||||
{
|
||||
return BitUtils.AlignUp(currentSize, align) + (ulong)Unsafe.SizeOf<T>() * count;
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
float dryGain = FixedPointHelper.ToFloat(Parameter.DryGain, FixedPointPrecision);
|
||||
float outGain = FixedPointHelper.ToFloat(Parameter.OutGain, FixedPointPrecision);
|
||||
|
||||
Matrix2x2 delayFeedback = new Matrix2x2(delayFeedbackBaseGain , delayFeedbackCrossGain,
|
||||
Matrix2x2 delayFeedback = new Matrix2x2(delayFeedbackBaseGain, delayFeedbackCrossGain,
|
||||
delayFeedbackCrossGain, delayFeedbackBaseGain);
|
||||
|
||||
for (int i = 0; i < sampleCount; i++)
|
||||
@ -124,10 +124,10 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
float dryGain = FixedPointHelper.ToFloat(Parameter.DryGain, FixedPointPrecision);
|
||||
float outGain = FixedPointHelper.ToFloat(Parameter.OutGain, FixedPointPrecision);
|
||||
|
||||
Matrix4x4 delayFeedback = new Matrix4x4(delayFeedbackBaseGain , delayFeedbackCrossGain, delayFeedbackCrossGain, 0.0f,
|
||||
delayFeedbackCrossGain, delayFeedbackBaseGain , 0.0f , delayFeedbackCrossGain,
|
||||
delayFeedbackCrossGain, 0.0f , delayFeedbackBaseGain , delayFeedbackCrossGain,
|
||||
0.0f , delayFeedbackCrossGain, delayFeedbackCrossGain, delayFeedbackBaseGain);
|
||||
Matrix4x4 delayFeedback = new Matrix4x4(delayFeedbackBaseGain, delayFeedbackCrossGain, delayFeedbackCrossGain, 0.0f,
|
||||
delayFeedbackCrossGain, delayFeedbackBaseGain, 0.0f, delayFeedbackCrossGain,
|
||||
delayFeedbackCrossGain, 0.0f, delayFeedbackBaseGain, delayFeedbackCrossGain,
|
||||
0.0f, delayFeedbackCrossGain, delayFeedbackCrossGain, delayFeedbackBaseGain);
|
||||
|
||||
|
||||
for (int i = 0; i < sampleCount; i++)
|
||||
@ -171,12 +171,12 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
float dryGain = FixedPointHelper.ToFloat(Parameter.DryGain, FixedPointPrecision);
|
||||
float outGain = FixedPointHelper.ToFloat(Parameter.OutGain, FixedPointPrecision);
|
||||
|
||||
Matrix6x6 delayFeedback = new Matrix6x6(delayFeedbackBaseGain , 0.0f , 0.0f , 0.0f , delayFeedbackCrossGain, delayFeedbackCrossGain,
|
||||
0.0f , delayFeedbackBaseGain , 0.0f , delayFeedbackCrossGain, delayFeedbackCrossGain, 0.0f ,
|
||||
delayFeedbackCrossGain, 0.0f , delayFeedbackBaseGain , delayFeedbackCrossGain, 0.0f , 0.0f ,
|
||||
0.0f , delayFeedbackCrossGain, delayFeedbackCrossGain, delayFeedbackBaseGain , 0.0f , 0.0f ,
|
||||
delayFeedbackCrossGain, delayFeedbackCrossGain, 0.0f , 0.0f , delayFeedbackBaseGain , 0.0f ,
|
||||
0.0f , 0.0f , 0.0f , 0.0f , 0.0f , feedbackGain);
|
||||
Matrix6x6 delayFeedback = new Matrix6x6(delayFeedbackBaseGain, 0.0f, 0.0f, 0.0f, delayFeedbackCrossGain, delayFeedbackCrossGain,
|
||||
0.0f, delayFeedbackBaseGain, 0.0f, delayFeedbackCrossGain, delayFeedbackCrossGain, 0.0f,
|
||||
delayFeedbackCrossGain, 0.0f, delayFeedbackBaseGain, delayFeedbackCrossGain, 0.0f, 0.0f,
|
||||
0.0f, delayFeedbackCrossGain, delayFeedbackCrossGain, delayFeedbackBaseGain, 0.0f, 0.0f,
|
||||
delayFeedbackCrossGain, delayFeedbackCrossGain, 0.0f, 0.0f, delayFeedbackBaseGain, 0.0f,
|
||||
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, feedbackGain);
|
||||
|
||||
for (int i = 0; i < sampleCount; i++)
|
||||
{
|
||||
|
@ -25,6 +25,6 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
|
||||
UpdateParameter(ref parameter);
|
||||
}
|
||||
|
||||
public void UpdateParameter(ref LimiterParameter parameter) {}
|
||||
public void UpdateParameter(ref LimiterParameter parameter) { }
|
||||
}
|
||||
}
|
@ -81,7 +81,7 @@ namespace Ryujinx.Audio.Renderer.Server.Effect
|
||||
/// </summary>
|
||||
/// <param name="parameter">The user parameter.</param>
|
||||
/// <returns>Returns true if the <see cref="EffectType"/> sent by the user matches the internal <see cref="EffectType"/>.</returns>
|
||||
public bool IsTypeValid<T>(ref T parameter) where T: unmanaged, IEffectInParameter
|
||||
public bool IsTypeValid<T>(ref T parameter) where T : unmanaged, IEffectInParameter
|
||||
{
|
||||
return parameter.Type == TargetEffectType;
|
||||
}
|
||||
@ -140,14 +140,14 @@ namespace Ryujinx.Audio.Renderer.Server.Effect
|
||||
/// Initialize the given <paramref name="state"/> result state.
|
||||
/// </summary>
|
||||
/// <param name="state">The state to initalize</param>
|
||||
public virtual void InitializeResultState(ref EffectResultState state) {}
|
||||
public virtual void InitializeResultState(ref EffectResultState state) { }
|
||||
|
||||
/// <summary>
|
||||
/// Update the <paramref name="destState"/> result state with <paramref name="srcState"/>.
|
||||
/// </summary>
|
||||
/// <param name="destState">The destination result state</param>
|
||||
/// <param name="srcState">The source result state</param>
|
||||
public virtual void UpdateResultState(ref EffectResultState destState, ref EffectResultState srcState) {}
|
||||
public virtual void UpdateResultState(ref EffectResultState destState, ref EffectResultState srcState) { }
|
||||
|
||||
/// <summary>
|
||||
/// Update the internal state from a user version 1 parameter.
|
||||
@ -215,7 +215,7 @@ namespace Ryujinx.Audio.Renderer.Server.Effect
|
||||
/// </summary>
|
||||
/// <param name="outStatus">The given user output.</param>
|
||||
/// <param name="isAudioRendererActive">If set to true, the <see cref="AudioRenderSystem"/> is active.</param>
|
||||
public void StoreStatus<T>(ref T outStatus, bool isAudioRendererActive) where T: unmanaged, IEffectOutStatus
|
||||
public void StoreStatus<T>(ref T outStatus, bool isAudioRendererActive) where T : unmanaged, IEffectOutStatus
|
||||
{
|
||||
if (isAudioRendererActive)
|
||||
{
|
||||
|
@ -46,7 +46,7 @@ namespace Ryujinx.Audio.Renderer.Server.Effect
|
||||
Update(out updateErrorInfo, ref parameter, mapper);
|
||||
}
|
||||
|
||||
public void Update<T>(out BehaviourParameter.ErrorInfo updateErrorInfo, ref T parameter, PoolMapper mapper) where T: unmanaged, IEffectInParameter
|
||||
public void Update<T>(out BehaviourParameter.ErrorInfo updateErrorInfo, ref T parameter, PoolMapper mapper) where T : unmanaged, IEffectInParameter
|
||||
{
|
||||
Debug.Assert(IsTypeValid(ref parameter));
|
||||
|
||||
|
@ -1,8 +1,7 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using DspAddress = System.UInt64;
|
||||
using CpuAddress = System.UInt64;
|
||||
using DspAddress = System.UInt64;
|
||||
|
||||
namespace Ryujinx.Audio.Renderer.Server.MemoryPool
|
||||
{
|
||||
|
@ -1,8 +1,7 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using DspAddress = System.UInt64;
|
||||
using CpuAddress = System.UInt64;
|
||||
using DspAddress = System.UInt64;
|
||||
|
||||
namespace Ryujinx.Audio.Renderer.Server.MemoryPool
|
||||
{
|
||||
|
@ -13,7 +13,7 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
|
||||
/// <typeparam name="THeader">The header implementation of the performance frame.</typeparam>
|
||||
/// <typeparam name="TEntry">The entry implementation of the performance frame.</typeparam>
|
||||
/// <typeparam name="TEntryDetail">A detailed implementation of the performance frame.</typeparam>
|
||||
public class PerformanceManagerGeneric<THeader, TEntry, TEntryDetail> : PerformanceManager where THeader: unmanaged, IPerformanceHeader where TEntry : unmanaged, IPerformanceEntry where TEntryDetail: unmanaged, IPerformanceDetailEntry
|
||||
public class PerformanceManagerGeneric<THeader, TEntry, TEntryDetail> : PerformanceManager where THeader : unmanaged, IPerformanceHeader where TEntry : unmanaged, IPerformanceEntry where TEntryDetail : unmanaged, IPerformanceDetailEntry
|
||||
{
|
||||
/// <summary>
|
||||
/// The magic used for the <see cref="THeader"/>.
|
||||
|
@ -172,7 +172,7 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
fixed (SplitterDestination *nextPtr = &next)
|
||||
fixed (SplitterDestination* nextPtr = &next)
|
||||
{
|
||||
_next = nextPtr;
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
public class StateUpdater
|
||||
{
|
||||
private readonly ReadOnlyMemory<byte> _inputOrigin;
|
||||
private ReadOnlyMemory <byte> _outputOrigin;
|
||||
private ReadOnlyMemory<byte> _outputOrigin;
|
||||
private ReadOnlyMemory<byte> _input;
|
||||
|
||||
private Memory<byte> _output;
|
||||
@ -207,7 +207,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
private static void ResetEffect<T>(ref BaseEffect effect, ref T parameter, PoolMapper mapper) where T: unmanaged, IEffectInParameter
|
||||
private static void ResetEffect<T>(ref BaseEffect effect, ref T parameter, PoolMapper mapper) where T : unmanaged, IEffectInParameter
|
||||
{
|
||||
effect.ForceUnmapBuffers(mapper);
|
||||
|
||||
|
@ -200,7 +200,7 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
|
||||
SampleFormat = SampleFormat.Invalid;
|
||||
ChannelsCount = 0;
|
||||
Pitch = 0.0f;
|
||||
Volume= 0.0f;
|
||||
Volume = 0.0f;
|
||||
PreviousVolume = 0.0f;
|
||||
BiquadFilters.ToSpan().Fill(new BiquadFilterParameter());
|
||||
WaveBuffersCount = 0;
|
||||
|
@ -1,7 +1,6 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
using DspAddress = System.UInt64;
|
||||
using CpuAddress = System.UInt64;
|
||||
using DspAddress = System.UInt64;
|
||||
|
||||
namespace Ryujinx.Audio.Renderer.Utils
|
||||
{
|
||||
|
@ -1,5 +1,6 @@
|
||||
using ARMeilleure.Translation;
|
||||
using ARMeilleure.Translation.PTC;
|
||||
using Avalonia;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Threading;
|
||||
using LibHac.Tools.FsSystem;
|
||||
@ -13,6 +14,7 @@ using Ryujinx.Ava.Common.Locale;
|
||||
using Ryujinx.Ava.Input;
|
||||
using Ryujinx.Ava.Ui.Controls;
|
||||
using Ryujinx.Ava.Ui.Models;
|
||||
using Ryujinx.Ava.Ui.Vulkan;
|
||||
using Ryujinx.Ava.Ui.Windows;
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Common.Configuration;
|
||||
@ -22,6 +24,7 @@ using Ryujinx.Graphics.GAL;
|
||||
using Ryujinx.Graphics.GAL.Multithreading;
|
||||
using Ryujinx.Graphics.Gpu;
|
||||
using Ryujinx.Graphics.OpenGL;
|
||||
using Ryujinx.Graphics.Vulkan;
|
||||
using Ryujinx.HLE.FileSystem;
|
||||
using Ryujinx.HLE.HOS;
|
||||
using Ryujinx.HLE.HOS.Services.Account.Acc;
|
||||
@ -53,6 +56,7 @@ namespace Ryujinx.Ava
|
||||
internal class AppHost
|
||||
{
|
||||
private const int CursorHideIdleTime = 8; // Hide Cursor seconds
|
||||
private const float MaxResolutionScale = 4.0f; // Max resolution hotkeys can scale to before wrapping.
|
||||
|
||||
private static readonly Cursor InvisibleCursor = new Cursor(StandardCursorType.None);
|
||||
|
||||
@ -365,6 +369,7 @@ namespace Ryujinx.Ava
|
||||
ConfigurationState.Instance.System.IgnoreMissingServices.Event -= UpdateIgnoreMissingServicesState;
|
||||
ConfigurationState.Instance.Graphics.AspectRatio.Event -= UpdateAspectRatioState;
|
||||
ConfigurationState.Instance.System.EnableDockedMode.Event -= UpdateDockedModeState;
|
||||
ConfigurationState.Instance.System.AudioVolume.Event -= UpdateAudioVolumeState;
|
||||
|
||||
_gpuCancellationTokenSource.Cancel();
|
||||
_gpuCancellationTokenSource.Dispose();
|
||||
@ -586,7 +591,23 @@ namespace Ryujinx.Ava
|
||||
{
|
||||
VirtualFileSystem.ReloadKeySet();
|
||||
|
||||
IRenderer renderer = new Renderer();
|
||||
IRenderer renderer;
|
||||
|
||||
if (Program.UseVulkan)
|
||||
{
|
||||
var vulkan = AvaloniaLocator.Current.GetService<VulkanPlatformInterface>();
|
||||
renderer = new VulkanRenderer(vulkan.Instance.InternalHandle,
|
||||
vulkan.Device.InternalHandle,
|
||||
vulkan.PhysicalDevice.InternalHandle,
|
||||
vulkan.Device.Queue.InternalHandle,
|
||||
vulkan.PhysicalDevice.QueueFamilyIndex,
|
||||
vulkan.Device.Lock);
|
||||
}
|
||||
else
|
||||
{
|
||||
renderer = new OpenGLRenderer();
|
||||
}
|
||||
|
||||
IHardwareDeviceDriver deviceDriver = new DummyHardwareDeviceDriver();
|
||||
|
||||
BackendThreading threadingMode = ConfigurationState.Instance.Graphics.BackendThreading;
|
||||
@ -794,9 +815,12 @@ namespace Ryujinx.Ava
|
||||
|
||||
_renderer.ScreenCaptured += Renderer_ScreenCaptured;
|
||||
|
||||
(_renderer as Renderer).InitializeBackgroundContext(SPBOpenGLContext.CreateBackgroundContext(Renderer.GameContext));
|
||||
if (!Program.UseVulkan)
|
||||
{
|
||||
(_renderer as OpenGLRenderer).InitializeBackgroundContext(SPBOpenGLContext.CreateBackgroundContext((Renderer as OpenGLRendererControl).GameContext));
|
||||
|
||||
Renderer.MakeCurrent();
|
||||
}
|
||||
|
||||
Device.Gpu.Renderer.Initialize(_glLogLevel);
|
||||
|
||||
@ -855,16 +879,15 @@ namespace Ryujinx.Ava
|
||||
dockedMode += $" ({scale}x)";
|
||||
}
|
||||
|
||||
string vendor = _renderer is Renderer renderer ? renderer.GpuVendor : "";
|
||||
|
||||
StatusUpdatedEvent?.Invoke(this, new StatusUpdatedEventArgs(
|
||||
Device.EnableDeviceVsync,
|
||||
Device.GetVolume(),
|
||||
Program.UseVulkan ? "Vulkan" : "OpenGL",
|
||||
dockedMode,
|
||||
ConfigurationState.Instance.Graphics.AspectRatio.Value.ToText(),
|
||||
LocaleManager.Instance["Game"] + $": {Device.Statistics.GetGameFrameRate():00.00} FPS ({Device.Statistics.GetGameFrameTime():00.00} ms)",
|
||||
$"FIFO: {Device.Statistics.GetFifoPercent():00.00} %",
|
||||
$"GPU: {vendor}"));
|
||||
$"GPU: {_renderer.GetHardwareInfo().GpuVendor}"));
|
||||
|
||||
Renderer.Present(image);
|
||||
}
|
||||
@ -976,6 +999,13 @@ namespace Ryujinx.Ava
|
||||
|
||||
_parent.ViewModel.Volume = Device.GetVolume();
|
||||
break;
|
||||
case KeyboardHotkeyState.ResScaleUp:
|
||||
GraphicsConfig.ResScale = GraphicsConfig.ResScale % MaxResolutionScale + 1;
|
||||
break;
|
||||
case KeyboardHotkeyState.ResScaleDown:
|
||||
GraphicsConfig.ResScale =
|
||||
(MaxResolutionScale + GraphicsConfig.ResScale - 2) % MaxResolutionScale + 1;
|
||||
break;
|
||||
case KeyboardHotkeyState.None:
|
||||
(_keyboardInterface as AvaloniaKeyboard).Clear();
|
||||
break;
|
||||
@ -1033,6 +1063,14 @@ namespace Ryujinx.Ava
|
||||
{
|
||||
state = KeyboardHotkeyState.ToggleMute;
|
||||
}
|
||||
else if (_keyboardInterface.IsPressed((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.ResScaleUp))
|
||||
{
|
||||
state = KeyboardHotkeyState.ResScaleUp;
|
||||
}
|
||||
else if (_keyboardInterface.IsPressed((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.ResScaleDown))
|
||||
{
|
||||
state = KeyboardHotkeyState.ResScaleDown;
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
@ -118,11 +118,11 @@
|
||||
"SettingsTabSystemAudioBackendSoundIO": "SoundIO",
|
||||
"SettingsTabSystemAudioBackendSDL2": "SDL2",
|
||||
"SettingsTabSystemHacks": "Hacks",
|
||||
"SettingsTabSystemHacksNote": " - Können Fehler verursachen",
|
||||
"SettingsTabSystemHacksNote": " (Können Fehler verursachen)",
|
||||
"SettingsTabSystemExpandDramSize": "Erweitere DRAM Größe auf 6GB",
|
||||
"SettingsTabSystemIgnoreMissingServices": "Ignoriere fehlende Dienste",
|
||||
"SettingsTabGraphics": "Grafik",
|
||||
"SettingsTabGraphicsEnhancements": "Verbesserungen",
|
||||
"SettingsTabGraphicsAPI": "Grafik-API",
|
||||
"SettingsTabGraphicsEnableShaderCache": "Aktiviere den Shader Cache",
|
||||
"SettingsTabGraphicsAnisotropicFiltering": "Anisotrope Filterung:",
|
||||
"SettingsTabGraphicsAnisotropicFilteringAuto": "Auto",
|
||||
@ -416,7 +416,7 @@
|
||||
"CommonFavorite": "Favoriten",
|
||||
"OrderAscending": "Aufsteigend",
|
||||
"OrderDescending": "Absteigend",
|
||||
"SettingsTabGraphicsFeatures": "Erweiterungen",
|
||||
"SettingsTabGraphicsFeatures": "Erweiterungen & Verbesserungen",
|
||||
"ErrorWindowTitle": "Fehler-Fenster",
|
||||
"ToggleDiscordTooltip": "Aktiviert/Deaktiviert Discord Rich Presence",
|
||||
"AddGameDirBoxTooltip": "Gibt das Spielverzeichnis an, das der Liste hinzuzufügt wird",
|
||||
@ -556,5 +556,7 @@
|
||||
"SettingsSelectThemeFileDialogTitle" : "Wähle ein benutzerdefiniertes Thema",
|
||||
"SettingsXamlThemeFile" : "Xaml Thema-Datei",
|
||||
"SettingsTabGraphicsBackend" : "Grafik-Backend",
|
||||
"GraphicsBackendTooltip" : "Ändert das Grafik-Backend"
|
||||
"GraphicsBackendTooltip" : "Ändert das Grafik-Backend",
|
||||
"SettingsTabHotkeysResScaleUpHotkey": "Auflösung erhöhen:",
|
||||
"SettingsTabHotkeysResScaleDownHotkey": "Auflösung vermindern:"
|
||||
}
|
||||
|
@ -118,11 +118,11 @@
|
||||
"SettingsTabSystemAudioBackendSoundIO": "SoundIO",
|
||||
"SettingsTabSystemAudioBackendSDL2": "SDL2",
|
||||
"SettingsTabSystemHacks": "Μικροδιορθώσεις",
|
||||
"SettingsTabSystemHacksNote": " - Μπορεί να προκαλέσουν αστάθεια",
|
||||
"SettingsTabSystemHacksNote": " (Μπορεί να προκαλέσουν αστάθεια)",
|
||||
"SettingsTabSystemExpandDramSize": "Επέκταση μεγέθους DRAM στα 6GB",
|
||||
"SettingsTabSystemIgnoreMissingServices": "Αγνόηση υπηρεσιών που λείπουν",
|
||||
"SettingsTabGraphics": "Γραφικά",
|
||||
"SettingsTabGraphicsEnhancements": "Βελτιώσεις",
|
||||
"SettingsTabGraphicsAPI": "API Γραφικά",
|
||||
"SettingsTabGraphicsEnableShaderCache": "Ενεργοποίηση Προσωρινής Μνήμης Shader",
|
||||
"SettingsTabGraphicsAnisotropicFiltering": "Ανισότροπο Φιλτράρισμα:",
|
||||
"SettingsTabGraphicsAnisotropicFilteringAuto": "Αυτόματο",
|
||||
@ -416,7 +416,7 @@
|
||||
"CommonFavorite": "Αγαπημένα",
|
||||
"OrderAscending": "Αύξουσα",
|
||||
"OrderDescending": "Φθίνουσα",
|
||||
"SettingsTabGraphicsFeatures": "Χαρακτηριστικά",
|
||||
"SettingsTabGraphicsFeatures": "Χαρακτηριστικά & Βελτιώσεις",
|
||||
"ErrorWindowTitle": "Παράθυρο σφάλματος",
|
||||
"ToggleDiscordTooltip": "Ενεργοποιεί ή απενεργοποιεί την Εμπλουτισμένη Παρουσία σας στο Discord",
|
||||
"AddGameDirBoxTooltip": "Εισαγάγετε μία τοποθεσία παιχνιδιών για προσθήκη στη λίστα",
|
||||
|
@ -122,8 +122,8 @@
|
||||
"SettingsTabSystemExpandDramSize": "Expand DRAM Size to 6GB",
|
||||
"SettingsTabSystemIgnoreMissingServices": "Ignore Missing Services",
|
||||
"SettingsTabGraphics": "Graphics",
|
||||
"SettingsTabGraphicsEnhancements": "Enhancements",
|
||||
"SettingsTabGraphicsEnableShaderCache": "Shader Cache",
|
||||
"SettingsTabGraphicsAPI": "Graphics API",
|
||||
"SettingsTabGraphicsEnableShaderCache": "Enable Shader Cache",
|
||||
"SettingsTabGraphicsAnisotropicFiltering": "Anisotropic Filtering:",
|
||||
"SettingsTabGraphicsAnisotropicFilteringAuto": "Auto",
|
||||
"SettingsTabGraphicsAnisotropicFiltering2x": "2x",
|
||||
@ -416,7 +416,7 @@
|
||||
"CommonFavorite": "Favorite",
|
||||
"OrderAscending": "Ascending",
|
||||
"OrderDescending": "Descending",
|
||||
"SettingsTabGraphicsFeatures": "Features",
|
||||
"SettingsTabGraphicsFeatures": "Features & Enhancements",
|
||||
"ErrorWindowTitle": "Error Window",
|
||||
"ToggleDiscordTooltip": "Choose whether or not to display Ryujinx on your \"currently playing\" Discord activity",
|
||||
"AddGameDirBoxTooltip": "Enter a game directory to add to the list",
|
||||
@ -575,5 +575,18 @@
|
||||
"UserProfilesSetProfileImage": "Set Profile Image",
|
||||
"UserProfileEmptyNameError": "Name is required",
|
||||
"UserProfileNoImageError": "Profile image must be set",
|
||||
"GameUpdateWindowHeading": "Updates Available for {0} [{1}]"
|
||||
"GameUpdateWindowHeading": "Updates Available for {0} [{1}]",
|
||||
"SettingsTabHotkeysResScaleUpHotkey": "Increase resolution:",
|
||||
"SettingsTabHotkeysResScaleDownHotkey": "Decrease resolution:",
|
||||
"UserProfilesName": "Name:",
|
||||
"UserProfilesUserId" : "User Id:",
|
||||
"SettingsTabGraphicsBackend": "Graphics Backend",
|
||||
"SettingsTabGraphicsBackendTooltip": "Graphics Backend to use",
|
||||
"SettingsEnableTextureRecompression": "Enable Texture Recompression",
|
||||
"SettingsEnableTextureRecompressionTooltip": "Compresses certain textures in order to reduce VRAM usage.\n\nRecommended for use with GPUs that have less than 4GB VRAM.\n\nLeave OFF if unsure.",
|
||||
"SettingsTabGraphicsPreferredGpu": "Preferred GPU",
|
||||
"SettingsTabGraphicsPreferredGpuTooltip": "Select the graphics card that will be used with the Vulkan graphics backend.\n\nDoes not affect the GPU that OpenGL will use.\n\nSet to the GPU flagged as \"dGPU\" if unsure. If there isn't one, leave untouched.",
|
||||
"SettingsAppRequiredRestartMessage": "Ryujinx Restart Required",
|
||||
"SettingsGpuBackendRestartMessage": "Graphics Backend or Gpu settings have been modified. This will require a restart to be applied",
|
||||
"SettingsGpuBackendRestartSubMessage": "Do you want to restart now?"
|
||||
}
|
||||
|
@ -118,12 +118,12 @@
|
||||
"SettingsTabSystemAudioBackendSoundIO": "SoundIO",
|
||||
"SettingsTabSystemAudioBackendSDL2": "SDL2",
|
||||
"SettingsTabSystemHacks": "Hacks",
|
||||
"SettingsTabSystemHacksNote": " - Pueden causar inestabilidad",
|
||||
"SettingsTabSystemHacksNote": " (Pueden causar inestabilidad)",
|
||||
"SettingsTabSystemExpandDramSize": "Expandir DRAM a 6GB",
|
||||
"SettingsTabSystemIgnoreMissingServices": "Ignorar servicios no implementados",
|
||||
"SettingsTabGraphics": "Gráficos",
|
||||
"SettingsTabGraphicsEnhancements": "Mejoras",
|
||||
"SettingsTabGraphicsEnableShaderCache": "Caché de sombreadores",
|
||||
"SettingsTabGraphicsAPI": "API de gráficos",
|
||||
"SettingsTabGraphicsEnableShaderCache": "Habilitar caché de sombreadores",
|
||||
"SettingsTabGraphicsAnisotropicFiltering": "Filtro anisotrópico:",
|
||||
"SettingsTabGraphicsAnisotropicFilteringAuto": "Auto",
|
||||
"SettingsTabGraphicsAnisotropicFiltering2x": "x2",
|
||||
@ -416,7 +416,7 @@
|
||||
"CommonFavorite": "Favorito",
|
||||
"OrderAscending": "Ascendente",
|
||||
"OrderDescending": "Descendente",
|
||||
"SettingsTabGraphicsFeatures": "Funcionalidades",
|
||||
"SettingsTabGraphicsFeatures": "Funcionalidades & Mejoras",
|
||||
"ErrorWindowTitle": "Ventana de error",
|
||||
"ToggleDiscordTooltip": "Elige si muestras Ryujinx o no en tu actividad de Discord cuando lo estés usando",
|
||||
"AddGameDirBoxTooltip": "Elige un directorio de juegos para mostrar en la ventana principal",
|
||||
@ -568,5 +568,7 @@
|
||||
"UpdateWindowTitle": "Administrar actualizaciones",
|
||||
"CheatWindowHeading": "Cheats disponibles para {0} [{1}]",
|
||||
"DlcWindowHeading": "Contenido descargable disponible para {0} [{1}]",
|
||||
"GameUpdateWindowHeading": "Actualizaciones disponibles para {0} [{1}]"
|
||||
"GameUpdateWindowHeading": "Actualizaciones disponibles para {0} [{1}]",
|
||||
"SettingsTabHotkeysResScaleUpHotkey": "Aumentar la resolución:",
|
||||
"SettingsTabHotkeysResScaleDownHotkey": "Disminuir la resolución:"
|
||||
}
|
||||
|
@ -111,11 +111,11 @@
|
||||
"SettingsTabSystemAudioBackendSoundIO": "SoundIO",
|
||||
"SettingsTabSystemAudioBackendSDL2": "SDL2",
|
||||
"SettingsTabSystemHacks": "Hacks",
|
||||
"SettingsTabSystemHacksNote": " - Cela peut causer des instabilitées",
|
||||
"SettingsTabSystemHacksNote": " (Cela peut causer des instabilitées)",
|
||||
"SettingsTabSystemExpandDramSize": "Augmenter la taille de la DRAM à 6GB",
|
||||
"SettingsTabSystemIgnoreMissingServices": "Ignorer les services manquant",
|
||||
"SettingsTabGraphics": "Graphique",
|
||||
"SettingsTabGraphicsEnhancements": "Améliorations",
|
||||
"SettingsTabGraphicsAPI": "API Graphique",
|
||||
"SettingsTabGraphicsEnableShaderCache": "Activer le cache des shaders",
|
||||
"SettingsTabGraphicsAnisotropicFiltering": "Filtrage anisotrope:",
|
||||
"SettingsTabGraphicsAnisotropicFilteringAuto": "Auto",
|
||||
@ -138,6 +138,7 @@
|
||||
"SettingsTabGraphicsAspectRatioStretch": "Écran étiré",
|
||||
"SettingsTabGraphicsDeveloperOptions": "Options développeur",
|
||||
"SettingsTabGraphicsShaderDumpPath": "Chemin du dossier de dump des shaders:",
|
||||
"SettingsTabGraphicsFeatures": "Fonctionnalités & Améliorations",
|
||||
"SettingsTabLogging": "Journaux",
|
||||
"SettingsTabLoggingLogging": "Journaux",
|
||||
"SettingsTabLoggingEnableLoggingToFile": "Activer la sauvegarde des journaux vers un fichier",
|
||||
|
@ -118,11 +118,11 @@
|
||||
"SettingsTabSystemAudioBackendSoundIO": "SoundIO",
|
||||
"SettingsTabSystemAudioBackendSDL2": "SDL2",
|
||||
"SettingsTabSystemHacks": "Hacks",
|
||||
"SettingsTabSystemHacksNote": " - Possono causare instabilità",
|
||||
"SettingsTabSystemHacksNote": " (Possono causare instabilità)",
|
||||
"SettingsTabSystemExpandDramSize": "Espandi dimensione DRAM a 6GB",
|
||||
"SettingsTabSystemIgnoreMissingServices": "Ignora servizi mancanti",
|
||||
"SettingsTabGraphics": "Grafica",
|
||||
"SettingsTabGraphicsEnhancements": "Miglioramenti",
|
||||
"SettingsTabGraphicsAPI": "API Grafiche",
|
||||
"SettingsTabGraphicsEnableShaderCache": "Attiva Shader Cache",
|
||||
"SettingsTabGraphicsAnisotropicFiltering": "Filtro anisotropico:",
|
||||
"SettingsTabGraphicsAnisotropicFilteringAuto": "Auto",
|
||||
@ -416,7 +416,7 @@
|
||||
"CommonFavorite": "Preferito",
|
||||
"OrderAscending": "Crescente",
|
||||
"OrderDescending": "Decrescente",
|
||||
"SettingsTabGraphicsFeatures": "Funzionalità",
|
||||
"SettingsTabGraphicsFeatures": "Funzionalità & Miglioramenti",
|
||||
"ErrorWindowTitle": "Finestra errore",
|
||||
"ToggleDiscordTooltip": "Attiva o disattiva Discord Rich Presence",
|
||||
"AddGameDirBoxTooltip": "Inserisci la directory di un gioco per aggiungerlo alla lista",
|
||||
@ -554,5 +554,7 @@
|
||||
"ControllerMotionTitle": "Impostazioni dei sensori di movimento",
|
||||
"ControllerRumbleTitle": "Impostazioni di vibrazione",
|
||||
"SettingsSelectThemeFileDialogTitle" : "Seleziona file del tema",
|
||||
"SettingsXamlThemeFile" : "File del tema xaml"
|
||||
"SettingsXamlThemeFile" : "File del tema xaml",
|
||||
"SettingsTabHotkeysResScaleUpHotkey": "Aumentare la risoluzione:",
|
||||
"SettingsTabHotkeysResScaleDownHotkey": "Diminuire la risoluzione:"
|
||||
}
|
||||
|
@ -118,11 +118,11 @@
|
||||
"SettingsTabSystemAudioBackendSoundIO": "SoundIO",
|
||||
"SettingsTabSystemAudioBackendSDL2": "SDL2",
|
||||
"SettingsTabSystemHacks": "해킹",
|
||||
"SettingsTabSystemHacksNote": " - 불안정을 일으킬 수 있음",
|
||||
"SettingsTabSystemHacksNote": " (불안정을 일으킬 수 있음)",
|
||||
"SettingsTabSystemExpandDramSize": "DRAM 크기를 6GB로 확장",
|
||||
"SettingsTabSystemIgnoreMissingServices": "누락된 서비스 무시",
|
||||
"SettingsTabGraphics": "제도법",
|
||||
"SettingsTabGraphicsEnhancements": "개선 사항",
|
||||
"SettingsTabGraphicsAPI": "그래픽 API",
|
||||
"SettingsTabGraphicsEnableShaderCache": "셰이더 캐시 활성화",
|
||||
"SettingsTabGraphicsAnisotropicFiltering": "이방성 필터링 :",
|
||||
"SettingsTabGraphicsAnisotropicFilteringAuto": "자동적 인",
|
||||
@ -415,7 +415,7 @@
|
||||
"CommonFavorite": "가장 좋아하는",
|
||||
"OrderAscending": "오름차순",
|
||||
"OrderDescending": "내림차순",
|
||||
"SettingsTabGraphicsFeatures": "특징",
|
||||
"SettingsTabGraphicsFeatures": "특징ㆍ개선 사항",
|
||||
"ErrorWindowTitle": "오류 창",
|
||||
"ToggleDiscordTooltip": "Discord Rich Presence 활성화 또는 비활성화",
|
||||
"AddGameDirBoxTooltip": "게임 디렉토리를 입력하여 목록에 추가하세요",
|
||||
|
@ -118,11 +118,11 @@
|
||||
"SettingsTabSystemAudioBackendSoundIO": "SoundIO",
|
||||
"SettingsTabSystemAudioBackendSDL2": "SDL2",
|
||||
"SettingsTabSystemHacks": "Hacks",
|
||||
"SettingsTabSystemHacksNote": " - Pode causar instabilidade",
|
||||
"SettingsTabSystemHacksNote": " (Pode causar instabilidade)",
|
||||
"SettingsTabSystemExpandDramSize": "Expandir memória para 6GB",
|
||||
"SettingsTabSystemIgnoreMissingServices": "Ignorar serviços não implementados",
|
||||
"SettingsTabGraphics": "Gráficos",
|
||||
"SettingsTabGraphicsEnhancements": "Melhorias",
|
||||
"SettingsTabGraphicsAPI": "API gráfica",
|
||||
"SettingsTabGraphicsEnableShaderCache": "Habilitar cache de shader",
|
||||
"SettingsTabGraphicsAnisotropicFiltering": "Filtragem anisotrópica:",
|
||||
"SettingsTabGraphicsAnisotropicFilteringAuto": "Auto",
|
||||
@ -416,7 +416,7 @@
|
||||
"CommonFavorite": "Favorito",
|
||||
"OrderAscending": "Ascendente",
|
||||
"OrderDescending": "Descendente",
|
||||
"SettingsTabGraphicsFeatures": "Recursos",
|
||||
"SettingsTabGraphicsFeatures": "Recursos & Melhorias",
|
||||
"ErrorWindowTitle": "Janela de erro",
|
||||
"ToggleDiscordTooltip": "Habilita ou desabilita Discord Rich Presence",
|
||||
"AddGameDirBoxTooltip": "Escreva um diretório de jogo para adicionar à lista",
|
||||
@ -554,5 +554,7 @@
|
||||
"ControllerMotionTitle": "Configurações do controle de movimento",
|
||||
"ControllerRumbleTitle": "Configurações de vibração",
|
||||
"SettingsSelectThemeFileDialogTitle" : "Selecionar arquivo do tema",
|
||||
"SettingsXamlThemeFile" : "Arquivo de tema Xaml"
|
||||
"SettingsXamlThemeFile" : "Arquivo de tema Xaml",
|
||||
"SettingsTabHotkeysResScaleUpHotkey": "Aumentar a resolução:",
|
||||
"SettingsTabHotkeysResScaleDownHotkey": "Diminuir a resolução:"
|
||||
}
|
||||
|
@ -118,11 +118,11 @@
|
||||
"SettingsTabSystemAudioBackendSoundIO": "SoundIO",
|
||||
"SettingsTabSystemAudioBackendSDL2": "SDL2",
|
||||
"SettingsTabSystemHacks": "Хаки",
|
||||
"SettingsTabSystemHacksNote": " - Эти многие настройки вызывают нестабильность",
|
||||
"SettingsTabSystemHacksNote": " (Эти многие настройки вызывают нестабильность)",
|
||||
"SettingsTabSystemExpandDramSize": "Увеличение размера DRAM до 6GB",
|
||||
"SettingsTabSystemIgnoreMissingServices": "Игнорировать отсутствующие службы",
|
||||
"SettingsTabGraphics": "Графика",
|
||||
"SettingsTabGraphicsEnhancements": "Улучшения",
|
||||
"SettingsTabGraphicsAPI": "Графические API",
|
||||
"SettingsTabGraphicsEnableShaderCache": "Включить кэш шейдеров",
|
||||
"SettingsTabGraphicsAnisotropicFiltering": "Анизотропная фильтрация:",
|
||||
"SettingsTabGraphicsAnisotropicFilteringAuto": "Автоматически",
|
||||
@ -377,7 +377,7 @@
|
||||
"DialogUpdateAddUpdateErrorMessage": "Указанный файл не содержит обновления для выбранного заголовка!",
|
||||
"DialogSettingsBackendThreadingWarningTitle": "Предупреждение: многопоточность в бэкенде",
|
||||
"DialogSettingsBackendThreadingWarningMessage": "Ryujinx необходимо перезапустить после изменения этой опции, чтобы она полностью применилась. В зависимости от вашей платформы вам может потребоваться вручную отключить собственную многопоточность вашего драйвера при использовании Ryujinx.",
|
||||
"SettingsTabGraphicsFeaturesOptions": "Функции",
|
||||
"SettingsTabGraphicsFeaturesOptions": "Функции & Улучшения",
|
||||
"SettingsTabGraphicsBackendMultithreading": "Многопоточность графического бэкенда:",
|
||||
"CommonAuto": "Автоматически",
|
||||
"CommonOff": "Выключен",
|
||||
|
@ -118,11 +118,11 @@
|
||||
"SettingsTabSystemAudioBackendSoundIO": "SoundIO",
|
||||
"SettingsTabSystemAudioBackendSDL2": "SDL2",
|
||||
"SettingsTabSystemHacks": "Hacklar",
|
||||
"SettingsTabSystemHacksNote": " - Bunlar birçok dengesizlik oluşturabilir",
|
||||
"SettingsTabSystemHacksNote": " (Bunlar birçok dengesizlik oluşturabilir)",
|
||||
"SettingsTabSystemExpandDramSize": "DRAM boyutunu 6GB'a genişlet",
|
||||
"SettingsTabSystemIgnoreMissingServices": "Eksik Servisleri Görmezden Gel",
|
||||
"SettingsTabGraphics": "Grafikler",
|
||||
"SettingsTabGraphicsEnhancements": "İyileştirmeler",
|
||||
"SettingsTabGraphicsAPI": "Grafikler API",
|
||||
"SettingsTabGraphicsEnableShaderCache": "Shader Cache'i Etkinleştir",
|
||||
"SettingsTabGraphicsAnisotropicFiltering": "Anisotropic Filtering:",
|
||||
"SettingsTabGraphicsAnisotropicFilteringAuto": "Otomatik",
|
||||
@ -416,7 +416,7 @@
|
||||
"CommonFavorite": "Favori",
|
||||
"OrderAscending": "Artan",
|
||||
"OrderDescending": "Azalan",
|
||||
"SettingsTabGraphicsFeatures": "Özellikler",
|
||||
"SettingsTabGraphicsFeatures": "Özellikler & İyileştirmeler",
|
||||
"ErrorWindowTitle": "Hata Penceresi",
|
||||
"ToggleDiscordTooltip": "Discord Rich Presence'i Aç/Kapat",
|
||||
"AddGameDirBoxTooltip": "Listeye eklemek için bir oyun dizini ekleyin",
|
||||
@ -554,5 +554,7 @@
|
||||
"ControllerMotionTitle": "Hareket Kontrol Seçenekleri",
|
||||
"ControllerRumbleTitle": "Titreşim Seçenekleri",
|
||||
"SettingsSelectThemeFileDialogTitle" : "Tema Dosyası Seçin",
|
||||
"SettingsXamlThemeFile" : "Xaml Tema Dosyası"
|
||||
"SettingsXamlThemeFile" : "Xaml Tema Dosyası",
|
||||
"SettingsTabHotkeysResScaleUpHotkey": "Çözünürlüğü artırın:",
|
||||
"SettingsTabHotkeysResScaleDownHotkey": "Çözünürlüğü azaltın:"
|
||||
}
|
||||
|
@ -118,11 +118,11 @@
|
||||
"SettingsTabSystemAudioBackendSoundIO": "SoundIO",
|
||||
"SettingsTabSystemAudioBackendSDL2": "SDL2",
|
||||
"SettingsTabSystemHacks": "修正",
|
||||
"SettingsTabSystemHacksNote": " - 会引起模拟器不稳定",
|
||||
"SettingsTabSystemHacksNote": " (会引起模拟器不稳定)",
|
||||
"SettingsTabSystemExpandDramSize": "将模拟RAM大小扩展到 6GB",
|
||||
"SettingsTabSystemIgnoreMissingServices": "忽略缺少的服务",
|
||||
"SettingsTabGraphics": "图像",
|
||||
"SettingsTabGraphicsEnhancements": "增强",
|
||||
"SettingsTabGraphicsAPI": "的图形 API",
|
||||
"SettingsTabGraphicsEnableShaderCache": "启用着色器缓存",
|
||||
"SettingsTabGraphicsAnisotropicFiltering": "各向异性过滤:",
|
||||
"SettingsTabGraphicsAnisotropicFilteringAuto": "自动",
|
||||
@ -416,7 +416,7 @@
|
||||
"CommonFavorite": "收藏",
|
||||
"OrderAscending": "从小到大",
|
||||
"OrderDescending": "从大到小",
|
||||
"SettingsTabGraphicsFeatures": "额外功能",
|
||||
"SettingsTabGraphicsFeatures": "额外功能和增强",
|
||||
"ErrorWindowTitle": "错误窗口",
|
||||
"ToggleDiscordTooltip": "启用或关闭 Discord 详细在线状态展示",
|
||||
"AddGameDirBoxTooltip": "输入要添加的游戏目录",
|
||||
@ -568,5 +568,7 @@
|
||||
"UpdateWindowTitle": "管理游戏更新",
|
||||
"CheatWindowHeading": "适用于 {0} [{1}] 的金手指",
|
||||
"DlcWindowHeading": "适用于 {0} [{1}] 的 DLC",
|
||||
"GameUpdateWindowHeading": "适用于 {0} [{1}] 的更新"
|
||||
"GameUpdateWindowHeading": "适用于 {0} [{1}] 的更新",
|
||||
"SettingsTabHotkeysResScaleUpHotkey": "分辨率提高",
|
||||
"SettingsTabHotkeysResScaleDownHotkey": "降低分辨率"
|
||||
}
|
||||
|
572
Ryujinx.Ava/Assets/Locales/zh_TW.json
Normal file
572
Ryujinx.Ava/Assets/Locales/zh_TW.json
Normal file
@ -0,0 +1,572 @@
|
||||
{
|
||||
"MenuBarFileOpenApplet": "打開小程式",
|
||||
"MenuBarFileOpenAppletOpenMiiAppletToolTip": "打開獨立的 Mii 小程式",
|
||||
"SettingsTabInputDirectMouseAccess": "直通滑鼠操作",
|
||||
"SettingsTabSystemMemoryManagerMode": "記憶體管理模式:",
|
||||
"SettingsTabSystemMemoryManagerModeSoftware": "軟體",
|
||||
"SettingsTabSystemMemoryManagerModeHost": "Host (快速)",
|
||||
"SettingsTabSystemMemoryManagerModeHostUnchecked": "Host 略過檢查 (最快,但較不安全)",
|
||||
"MenuBarFile": "_檔案",
|
||||
"MenuBarFileOpenFromFile": "_載入檔案",
|
||||
"MenuBarFileOpenUnpacked": "載入_解包後的遊戲",
|
||||
"MenuBarFileOpenEmuFolder": "開啟 Ryujinx 資料夾",
|
||||
"MenuBarFileOpenLogsFolder": "開啟日誌資料夾",
|
||||
"MenuBarFileExit": "_退出",
|
||||
"MenuBarOptions": "選項",
|
||||
"MenuBarOptionsToggleFullscreen": "切換全螢幕模式",
|
||||
"MenuBarOptionsStartGamesInFullscreen": "使用全螢幕模式啟動遊戲",
|
||||
"MenuBarOptionsStopEmulation": "停止模擬",
|
||||
"MenuBarOptionsSettings": "_設定",
|
||||
"MenuBarOptionsManageUserProfiles": "_管理使用者帳號",
|
||||
"MenuBarActions": "_動作",
|
||||
"MenuBarOptionsSimulateWakeUpMessage": "模擬喚醒訊息",
|
||||
"MenuBarActionsScanAmiibo": "掃描 Amiibo",
|
||||
"MenuBarTools": "_工具",
|
||||
"MenuBarToolsInstallFirmware": "安裝韌體",
|
||||
"MenuBarFileToolsInstallFirmwareFromFile": "從 XCI 或 ZIP 安裝韌體",
|
||||
"MenuBarFileToolsInstallFirmwareFromDirectory": "從資料夾安裝韌體",
|
||||
"MenuBarHelp": "幫助",
|
||||
"MenuBarHelpCheckForUpdates": "檢查更新",
|
||||
"MenuBarHelpAbout": "關於",
|
||||
"MenuSearch": "搜尋...",
|
||||
"GameListHeaderFavorite": "收藏",
|
||||
"GameListHeaderIcon": "圖示",
|
||||
"GameListHeaderApplication": "名稱",
|
||||
"GameListHeaderDeveloper": "開發商",
|
||||
"GameListHeaderVersion": "版本",
|
||||
"GameListHeaderTimePlayed": "遊玩時間",
|
||||
"GameListHeaderLastPlayed": "上次遊玩",
|
||||
"GameListHeaderFileExtension": "副檔名",
|
||||
"GameListHeaderFileSize": "大小",
|
||||
"GameListHeaderPath": "路徑",
|
||||
"GameListContextMenuOpenUserSaveDirectory": "開啟使用者存檔資料夾",
|
||||
"GameListContextMenuOpenUserSaveDirectoryToolTip": "開啟儲存遊戲存檔的資料夾",
|
||||
"GameListContextMenuOpenUserDeviceDirectory": "開啟系統資料夾",
|
||||
"GameListContextMenuOpenUserDeviceDirectoryToolTip": "開啟包含遊戲系統設定的資料夾",
|
||||
"GameListContextMenuOpenUserBcatDirectory": "開啟 BCAT 資料夾",
|
||||
"GameListContextMenuOpenUserBcatDirectoryToolTip": "開啟包含遊戲 BCAT 資料的資料夾",
|
||||
"GameListContextMenuManageTitleUpdates": "管理遊戲更新",
|
||||
"GameListContextMenuManageTitleUpdatesToolTip": "開啟更新管理視窗",
|
||||
"GameListContextMenuManageDlc": "管理 DLC",
|
||||
"GameListContextMenuManageDlcToolTip": "開啟 DLC 管理視窗",
|
||||
"GameListContextMenuOpenModsDirectory": "開啟模組資料夾",
|
||||
"GameListContextMenuOpenModsDirectoryToolTip": "開啟存放遊戲模組的資料夾",
|
||||
"GameListContextMenuCacheManagement": "快取管理",
|
||||
"GameListContextMenuCacheManagementPurgePptc": "清除 PPTC 快取",
|
||||
"GameListContextMenuCacheManagementPurgePptcToolTip": "刪除遊戲的 PPTC 快取",
|
||||
"GameListContextMenuCacheManagementPurgeShaderCache": "清除渲染器快取",
|
||||
"GameListContextMenuCacheManagementPurgeShaderCacheToolTip": "刪除遊戲的渲染器快取",
|
||||
"GameListContextMenuCacheManagementOpenPptcDirectory": "開啟 PPTC 資料夾",
|
||||
"GameListContextMenuCacheManagementOpenPptcDirectoryToolTip": "開啟包含遊戲 PPTC 快取的資料夾",
|
||||
"GameListContextMenuCacheManagementOpenShaderCacheDirectory": "開啟渲染器快取資料夾",
|
||||
"GameListContextMenuCacheManagementOpenShaderCacheDirectoryToolTip": "開啟包含應用程式渲染器快取的資料夾",
|
||||
"GameListContextMenuExtractData": "提取資料",
|
||||
"GameListContextMenuExtractDataExeFS": "ExeFS",
|
||||
"GameListContextMenuExtractDataExeFSToolTip": "從遊戲的目前狀態中提取 ExeFS 分區(包含更新)",
|
||||
"GameListContextMenuExtractDataRomFS": "RomFS",
|
||||
"GameListContextMenuExtractDataRomFSToolTip": "從遊戲的目前狀態中提取 RomFS 分區(包含更新)",
|
||||
"GameListContextMenuExtractDataLogo": "圖示",
|
||||
"GameListContextMenuExtractDataLogoToolTip": "從遊戲的目前狀態中提取圖示(包含更新)",
|
||||
"StatusBarGamesLoaded": "{0}/{1} 遊戲載入完成",
|
||||
"StatusBarSystemVersion": "系統版本: {0}",
|
||||
"Settings": "設定",
|
||||
"SettingsTabGeneral": "使用者介面",
|
||||
"SettingsTabGeneralGeneral": "一般",
|
||||
"SettingsTabGeneralEnableDiscordRichPresence": "啟用 Discord 動態狀態展示",
|
||||
"SettingsTabGeneralCheckUpdatesOnLaunch": "自動檢查更新",
|
||||
"SettingsTabGeneralShowConfirmExitDialog": "顯示 \"確認離開\" 對話框",
|
||||
"SettingsTabGeneralHideCursorOnIdle": "自動隱藏滑鼠",
|
||||
"SettingsTabGeneralGameDirectories": "遊戲資料夾",
|
||||
"SettingsTabGeneralAdd": "新增",
|
||||
"SettingsTabGeneralRemove": "刪除",
|
||||
"SettingsTabSystem": "系統",
|
||||
"SettingsTabSystemCore": "核心",
|
||||
"SettingsTabSystemSystemRegion": "系統區域:",
|
||||
"SettingsTabSystemSystemRegionJapan": "日本",
|
||||
"SettingsTabSystemSystemRegionUSA": "美國",
|
||||
"SettingsTabSystemSystemRegionEurope": "歐洲",
|
||||
"SettingsTabSystemSystemRegionAustralia": "澳洲",
|
||||
"SettingsTabSystemSystemRegionChina": "中國",
|
||||
"SettingsTabSystemSystemRegionKorea": "韓國",
|
||||
"SettingsTabSystemSystemRegionTaiwan": "台灣",
|
||||
"SettingsTabSystemSystemLanguage": "系統語言:",
|
||||
"SettingsTabSystemSystemLanguageJapanese": "日語",
|
||||
"SettingsTabSystemSystemLanguageAmericanEnglish": "美式英語",
|
||||
"SettingsTabSystemSystemLanguageFrench": "法語",
|
||||
"SettingsTabSystemSystemLanguageGerman": "德語",
|
||||
"SettingsTabSystemSystemLanguageItalian": "義大利語",
|
||||
"SettingsTabSystemSystemLanguageSpanish": "西班牙語",
|
||||
"SettingsTabSystemSystemLanguageChinese": "中文 (中國)",
|
||||
"SettingsTabSystemSystemLanguageKorean": "韓語",
|
||||
"SettingsTabSystemSystemLanguageDutch": "荷蘭語",
|
||||
"SettingsTabSystemSystemLanguagePortuguese": "葡萄牙語",
|
||||
"SettingsTabSystemSystemLanguageRussian": "俄語",
|
||||
"SettingsTabSystemSystemLanguageTaiwanese": "中文 (台灣)",
|
||||
"SettingsTabSystemSystemLanguageBritishEnglish": "英式英語",
|
||||
"SettingsTabSystemSystemLanguageCanadianFrench": "加拿大法語",
|
||||
"SettingsTabSystemSystemLanguageLatinAmericanSpanish": "拉美西班牙語",
|
||||
"SettingsTabSystemSystemLanguageSimplifiedChinese": "簡體中文 (推薦)",
|
||||
"SettingsTabSystemSystemLanguageTraditionalChinese": "繁體中文 (推薦)",
|
||||
"SettingsTabSystemSystemTimeZone": "系統時區:",
|
||||
"SettingsTabSystemSystemTime": "系統時鐘:",
|
||||
"SettingsTabSystemEnableVsync": "開啟 VSync",
|
||||
"SettingsTabSystemEnablePptc": "開啟 PPTC 快取",
|
||||
"SettingsTabSystemEnableFsIntegrityChecks": "開啟檔案系統完整性檢查",
|
||||
"SettingsTabSystemAudioBackend": "音訊後端:",
|
||||
"SettingsTabSystemAudioBackendDummy": "無",
|
||||
"SettingsTabSystemAudioBackendOpenAL": "OpenAL",
|
||||
"SettingsTabSystemAudioBackendSoundIO": "SoundIO",
|
||||
"SettingsTabSystemAudioBackendSDL2": "SDL2",
|
||||
"SettingsTabSystemHacks": "修正",
|
||||
"SettingsTabSystemHacksNote": " (會引起模擬器不穩定)",
|
||||
"SettingsTabSystemExpandDramSize": "將模擬記憶體大小擴充至 6GB",
|
||||
"SettingsTabSystemIgnoreMissingServices": "忽略缺少的服務",
|
||||
"SettingsTabGraphics": "圖形",
|
||||
"SettingsTabGraphicsEnhancements": "增強",
|
||||
"SettingsTabGraphicsEnableShaderCache": "啟用渲染器快取",
|
||||
"SettingsTabGraphicsAnisotropicFiltering": "各向異性過濾:",
|
||||
"SettingsTabGraphicsAnisotropicFilteringAuto": "自動",
|
||||
"SettingsTabGraphicsAnisotropicFiltering2x": "2x",
|
||||
"SettingsTabGraphicsAnisotropicFiltering4x": "4x",
|
||||
"SettingsTabGraphicsAnisotropicFiltering8x": "8x",
|
||||
"SettingsTabGraphicsAnisotropicFiltering16x": "16x",
|
||||
"SettingsTabGraphicsResolutionScale": "解析度縮放:",
|
||||
"SettingsTabGraphicsResolutionScaleCustom": "自訂 (不推薦)",
|
||||
"SettingsTabGraphicsResolutionScaleNative": "原生 (720p/1080p)",
|
||||
"SettingsTabGraphicsResolutionScale2x": "2x (1440p/2160p)",
|
||||
"SettingsTabGraphicsResolutionScale3x": "3x (2160p/3240p)",
|
||||
"SettingsTabGraphicsResolutionScale4x": "4x (2880p/4320p)",
|
||||
"SettingsTabGraphicsAspectRatio": "寬高比:",
|
||||
"SettingsTabGraphicsAspectRatio4x3": "4:3",
|
||||
"SettingsTabGraphicsAspectRatio16x9": "16:9",
|
||||
"SettingsTabGraphicsAspectRatio16x10": "16:10",
|
||||
"SettingsTabGraphicsAspectRatio21x9": "21:9",
|
||||
"SettingsTabGraphicsAspectRatio32x9": "32:9",
|
||||
"SettingsTabGraphicsAspectRatioStretch": "拉伸至螢幕大小",
|
||||
"SettingsTabGraphicsDeveloperOptions": "開發者選項",
|
||||
"SettingsTabGraphicsShaderDumpPath": "圖形渲染器轉儲路徑:",
|
||||
"SettingsTabLogging": "日誌",
|
||||
"SettingsTabLoggingLogging": "日誌",
|
||||
"SettingsTabLoggingEnableLoggingToFile": "儲存日誌為檔案",
|
||||
"SettingsTabLoggingEnableStubLogs": "記錄 Stub",
|
||||
"SettingsTabLoggingEnableInfoLogs": "記錄資訊",
|
||||
"SettingsTabLoggingEnableWarningLogs": "記錄警告",
|
||||
"SettingsTabLoggingEnableErrorLogs": "記錄錯誤",
|
||||
"SettingsTabLoggingEnableTraceLogs": "記錄 Trace",
|
||||
"SettingsTabLoggingEnableGuestLogs": "記錄 Guest",
|
||||
"SettingsTabLoggingEnableFsAccessLogs": "記錄檔案存取",
|
||||
"SettingsTabLoggingFsGlobalAccessLogMode": "記錄全域檔案存取模式:",
|
||||
"SettingsTabLoggingDeveloperOptions": "開發者選項 (警告: 會降低效能)",
|
||||
"SettingsTabLoggingOpenglLogLevel": "OpenGL 日誌級別:",
|
||||
"SettingsTabLoggingOpenglLogLevelNone": "無",
|
||||
"SettingsTabLoggingOpenglLogLevelError": "錯誤",
|
||||
"SettingsTabLoggingOpenglLogLevelPerformance": "減速",
|
||||
"SettingsTabLoggingOpenglLogLevelAll": "全部",
|
||||
"SettingsTabLoggingEnableDebugLogs": "啟用除錯日誌",
|
||||
"SettingsTabInput": "輸入",
|
||||
"SettingsTabInputEnableDockedMode": "Docked 模式",
|
||||
"SettingsTabInputDirectKeyboardAccess": "直通鍵盤控制",
|
||||
"SettingsButtonSave": "儲存",
|
||||
"SettingsButtonClose": "關閉",
|
||||
"SettingsButtonApply": "套用",
|
||||
"ControllerSettingsPlayer": "玩家",
|
||||
"ControllerSettingsPlayer1": "玩家 1",
|
||||
"ControllerSettingsPlayer2": "玩家 2",
|
||||
"ControllerSettingsPlayer3": "玩家 3",
|
||||
"ControllerSettingsPlayer4": "玩家 4",
|
||||
"ControllerSettingsPlayer5": "玩家 5",
|
||||
"ControllerSettingsPlayer6": "玩家 6",
|
||||
"ControllerSettingsPlayer7": "玩家 7",
|
||||
"ControllerSettingsPlayer8": "玩家 8",
|
||||
"ControllerSettingsHandheld": "掌機模式",
|
||||
"ControllerSettingsInputDevice": "輸入設備",
|
||||
"ControllerSettingsRefresh": "更新",
|
||||
"ControllerSettingsDeviceDisabled": "關閉",
|
||||
"ControllerSettingsControllerType": "手把類型",
|
||||
"ControllerSettingsControllerTypeHandheld": "掌機",
|
||||
"ControllerSettingsControllerTypeProController": "Pro 手把",
|
||||
"ControllerSettingsControllerTypeJoyConPair": "JoyCon",
|
||||
"ControllerSettingsControllerTypeJoyConLeft": "左 JoyCon",
|
||||
"ControllerSettingsControllerTypeJoyConRight": "右 JoyCon",
|
||||
"ControllerSettingsProfile": "預設",
|
||||
"ControllerSettingsProfileDefault": "預設",
|
||||
"ControllerSettingsLoad": "載入",
|
||||
"ControllerSettingsAdd": "建立",
|
||||
"ControllerSettingsRemove": "刪除",
|
||||
"ControllerSettingsButtons": "按鈕",
|
||||
"ControllerSettingsButtonA": "A",
|
||||
"ControllerSettingsButtonB": "B",
|
||||
"ControllerSettingsButtonX": "X",
|
||||
"ControllerSettingsButtonY": "Y",
|
||||
"ControllerSettingsButtonPlus": "+",
|
||||
"ControllerSettingsButtonMinus": "-",
|
||||
"ControllerSettingsDPad": "方向鍵",
|
||||
"ControllerSettingsDPadUp": "上",
|
||||
"ControllerSettingsDPadDown": "下",
|
||||
"ControllerSettingsDPadLeft": "左",
|
||||
"ControllerSettingsDPadRight": "右",
|
||||
"ControllerSettingsLStick": "左搖桿",
|
||||
"ControllerSettingsLStickButton": "按下",
|
||||
"ControllerSettingsLStickUp": "上",
|
||||
"ControllerSettingsLStickDown": "下",
|
||||
"ControllerSettingsLStickLeft": "左",
|
||||
"ControllerSettingsLStickRight": "右",
|
||||
"ControllerSettingsLStickStick": "桿",
|
||||
"ControllerSettingsLStickInvertXAxis": "反轉 X 方向",
|
||||
"ControllerSettingsLStickInvertYAxis": "反轉 Y 方向",
|
||||
"ControllerSettingsLStickDeadzone": "死區:",
|
||||
"ControllerSettingsRStick": "右搖桿",
|
||||
"ControllerSettingsRStickButton": "按下",
|
||||
"ControllerSettingsRStickUp": "上",
|
||||
"ControllerSettingsRStickDown": "下",
|
||||
"ControllerSettingsRStickLeft": "左",
|
||||
"ControllerSettingsRStickRight": "右",
|
||||
"ControllerSettingsRStickStick": "桿",
|
||||
"ControllerSettingsRStickInvertXAxis": "反轉 X 方向",
|
||||
"ControllerSettingsRStickInvertYAxis": "反轉 Y 方向",
|
||||
"ControllerSettingsRStickDeadzone": "死區:",
|
||||
"ControllerSettingsTriggersLeft": "左 Triggers",
|
||||
"ControllerSettingsTriggersRight": "右 Triggers",
|
||||
"ControllerSettingsTriggersButtonsLeft": "左 Triggers 鍵",
|
||||
"ControllerSettingsTriggersButtonsRight": "右 Triggers 鍵",
|
||||
"ControllerSettingsTriggers": "Triggers",
|
||||
"ControllerSettingsTriggerL": "L",
|
||||
"ControllerSettingsTriggerR": "R",
|
||||
"ControllerSettingsTriggerZL": "ZL",
|
||||
"ControllerSettingsTriggerZR": "ZR",
|
||||
"ControllerSettingsLeftSL": "SL",
|
||||
"ControllerSettingsLeftSR": "SR",
|
||||
"ControllerSettingsRightSL": "SL",
|
||||
"ControllerSettingsRightSR": "SR",
|
||||
"ControllerSettingsExtraButtonsLeft": "左按鍵",
|
||||
"ControllerSettingsExtraButtonsRight": "右按鍵",
|
||||
"ControllerSettingsMisc": "其他",
|
||||
"ControllerSettingsTriggerThreshold": "Triggers 閾值:",
|
||||
"ControllerSettingsMotion": "體感",
|
||||
"ControllerSettingsMotionUseCemuhookCompatibleMotion": "使用 CemuHook 體感協議",
|
||||
"ControllerSettingsMotionControllerSlot": "手把:",
|
||||
"ControllerSettingsMotionMirrorInput": "鏡像操作",
|
||||
"ControllerSettingsMotionRightJoyConSlot": "右 JoyCon:",
|
||||
"ControllerSettingsMotionServerHost": "伺服器 Host:",
|
||||
"ControllerSettingsMotionGyroSensitivity": "陀螺儀敏感度:",
|
||||
"ControllerSettingsMotionGyroDeadzone": "陀螺儀死區:",
|
||||
"ControllerSettingsSave": "儲存",
|
||||
"ControllerSettingsClose": "關閉",
|
||||
"UserProfilesSelectedUserProfile": "選擇使用者帳號:",
|
||||
"UserProfilesSaveProfileName": "儲存帳號名稱",
|
||||
"UserProfilesChangeProfileImage": "更換頭像",
|
||||
"UserProfilesAvailableUserProfiles": "現有的帳號:",
|
||||
"UserProfilesAddNewProfile": "建立帳號",
|
||||
"UserProfilesDeleteSelectedProfile": "刪除選擇的帳號",
|
||||
"UserProfilesClose": "關閉",
|
||||
"ProfileImageSelectionTitle": "頭像選擇",
|
||||
"ProfileImageSelectionHeader": "選擇合適的頭像圖片",
|
||||
"ProfileImageSelectionNote": "您可以導入自訂頭像,或從系統中選擇頭像",
|
||||
"ProfileImageSelectionImportImage": "導入圖片檔案",
|
||||
"ProfileImageSelectionSelectAvatar": "選擇系統頭像",
|
||||
"InputDialogTitle": "輸入對話框",
|
||||
"InputDialogOk": "完成",
|
||||
"InputDialogCancel": "取消",
|
||||
"InputDialogAddNewProfileTitle": "選擇使用者名稱",
|
||||
"InputDialogAddNewProfileHeader": "請輸入帳號名稱",
|
||||
"InputDialogAddNewProfileSubtext": "(最大長度: {0})",
|
||||
"AvatarChoose": "選擇",
|
||||
"AvatarSetBackgroundColor": "設定背景顏色",
|
||||
"AvatarClose": "關閉",
|
||||
"ControllerSettingsLoadProfileToolTip": "載入預設",
|
||||
"ControllerSettingsAddProfileToolTip": "新增預設",
|
||||
"ControllerSettingsRemoveProfileToolTip": "刪除預設",
|
||||
"ControllerSettingsSaveProfileToolTip": "儲存預設",
|
||||
"MenuBarFileToolsTakeScreenshot": "儲存截圖",
|
||||
"MenuBarFileToolsHideUi": "隱藏 UI",
|
||||
"GameListContextMenuToggleFavorite": "標記為收藏",
|
||||
"GameListContextMenuToggleFavoriteToolTip": "啟用或取消收藏標記",
|
||||
"SettingsTabGeneralTheme": "主題",
|
||||
"SettingsTabGeneralThemeCustomTheme": "自定主題路徑",
|
||||
"SettingsTabGeneralThemeBaseStyle": "主題樣式",
|
||||
"SettingsTabGeneralThemeBaseStyleDark": "深色模式",
|
||||
"SettingsTabGeneralThemeBaseStyleLight": "淺色模式",
|
||||
"SettingsTabGeneralThemeEnableCustomTheme": "使用自訂主題介面",
|
||||
"ButtonBrowse": "瀏覽",
|
||||
"ControllerSettingsConfigureGeneral": "配置",
|
||||
"ControllerSettingsRumble": "震動",
|
||||
"ControllerSettingsRumbleStrongMultiplier": "強震動調節",
|
||||
"ControllerSettingsRumbleWeakMultiplier": "弱震動調節",
|
||||
"DialogMessageSaveNotAvailableMessage": "沒有{0} [{1:x16}]的遊戲存檔",
|
||||
"DialogMessageSaveNotAvailableCreateSaveMessage": "是否建立該遊戲的存檔資料夾?",
|
||||
"DialogConfirmationTitle": "Ryujinx - 設定",
|
||||
"DialogUpdaterTitle": "Ryujinx - 更新",
|
||||
"DialogErrorTitle": "Ryujinx - 錯誤",
|
||||
"DialogWarningTitle": "Ryujinx - 警告",
|
||||
"DialogExitTitle": "Ryujinx - 關閉",
|
||||
"DialogErrorMessage": "Ryujinx 遇到了錯誤",
|
||||
"DialogExitMessage": "是否關閉 Ryujinx?",
|
||||
"DialogExitSubMessage": "所有未儲存的進度會遺失!",
|
||||
"DialogMessageCreateSaveErrorMessage": "建立特定的存檔時出錯: {0}",
|
||||
"DialogMessageFindSaveErrorMessage": "查找特定的存檔時出錯: {0}",
|
||||
"FolderDialogExtractTitle": "選擇要解壓到的資料夾",
|
||||
"DialogNcaExtractionMessage": "提取{1}的{0}分區...",
|
||||
"DialogNcaExtractionTitle": "Ryujinx - NCA分區提取",
|
||||
"DialogNcaExtractionMainNcaNotFoundErrorMessage": "提取失敗。所選檔案中不含主NCA檔案",
|
||||
"DialogNcaExtractionCheckLogErrorMessage": "提取失敗。請查看日誌檔案取得詳情。",
|
||||
"DialogNcaExtractionSuccessMessage": "提取成功。",
|
||||
"DialogUpdaterConvertFailedMessage": "無法轉換目前 Ryujinx 版本。",
|
||||
"DialogUpdaterCancelUpdateMessage": "更新取消!",
|
||||
"DialogUpdaterAlreadyOnLatestVersionMessage": "您使用的 Ryujinx 是最新版本。",
|
||||
"DialogUpdaterFailedToGetVersionMessage": "嘗試從 Github 取得版本訊息時無效。可能是因為 GitHub Actions 正在編譯新版本。請過幾分鐘重試。",
|
||||
"DialogUpdaterConvertFailedGithubMessage": "無法轉換從 Github 接收到的 Ryujinx 版本。",
|
||||
"DialogUpdaterDownloadingMessage": "下載新版本中...",
|
||||
"DialogUpdaterExtractionMessage": "正在提取更新...",
|
||||
"DialogUpdaterRenamingMessage": "正在刪除舊檔案...",
|
||||
"DialogUpdaterAddingFilesMessage": "安裝更新中...",
|
||||
"DialogUpdaterCompleteMessage": "更新成功!",
|
||||
"DialogUpdaterRestartMessage": "立即重啟 Ryujinx 完成更新?",
|
||||
"DialogUpdaterArchNotSupportedMessage": "您執行的系統架構不受支援!",
|
||||
"DialogUpdaterArchNotSupportedSubMessage": "(僅支援 x64 系統)",
|
||||
"DialogUpdaterNoInternetMessage": "沒有連接到網路",
|
||||
"DialogUpdaterNoInternetSubMessage": "請確保網路連接正常。",
|
||||
"DialogUpdaterDirtyBuildMessage": "不能更新非官方版本的 Ryujinx!",
|
||||
"DialogUpdaterDirtyBuildSubMessage": "如果希望使用受支援的版本,請您在 https://ryujinx.org/ 下載。",
|
||||
"DialogRestartRequiredMessage": "需要重啟模擬器",
|
||||
"DialogThemeRestartMessage": "主題設定已儲存。需要重新啟動才能生效。",
|
||||
"DialogThemeRestartSubMessage": "您是否要重啟?",
|
||||
"DialogFirmwareInstallEmbeddedMessage": "要安裝遊戲內建的韌體嗎?(韌體 {0})",
|
||||
"DialogFirmwareInstallEmbeddedSuccessMessage": "未找到已安裝的韌體,但 Ryujinx 可以從現有的遊戲安裝韌體{0}.\\n模擬器現在可以執行。",
|
||||
"DialogFirmwareNoFirmwareInstalledMessage": "未安裝韌體",
|
||||
"DialogFirmwareInstalledMessage": "已安裝韌體{0}",
|
||||
"DialogOpenSettingsWindowLabel": "打開設定視窗",
|
||||
"DialogControllerAppletTitle": "控制器小視窗",
|
||||
"DialogMessageDialogErrorExceptionMessage": "顯示訊息對話框時出錯: {0}",
|
||||
"DialogSoftwareKeyboardErrorExceptionMessage": "顯示軟體鍵盤時出錯: {0}",
|
||||
"DialogErrorAppletErrorExceptionMessage": "顯示錯誤對話框時出錯: {0}",
|
||||
"DialogUserErrorDialogMessage": "{0}: {1}",
|
||||
"DialogUserErrorDialogInfoMessage": "\n有關修復此錯誤的更多訊息,可以遵循我們的設定指南。",
|
||||
"DialogUserErrorDialogTitle": "Ryujinx 錯誤 ({0})",
|
||||
"DialogAmiiboApiTitle": "Amiibo API",
|
||||
"DialogAmiiboApiFailFetchMessage": "從 API 取得訊息時出錯。",
|
||||
"DialogAmiiboApiConnectErrorMessage": "無法連接到 Amiibo API 伺服器。伺服器可能已關閉,或者您沒有網路連接。",
|
||||
"DialogProfileInvalidProfileErrorMessage": "預設{0} 與目前輸入配置系統不相容。",
|
||||
"DialogProfileDefaultProfileOverwriteErrorMessage": "默認預設無法被覆蓋",
|
||||
"DialogProfileDeleteProfileTitle": "刪除預設",
|
||||
"DialogProfileDeleteProfileMessage": "刪除後不可恢復,確定嗎?",
|
||||
"DialogWarning": "警告",
|
||||
"DialogPPTCDeletionMessage": "您即將刪除:\n\n{0}的 PPTC 快取\n\n確定嗎?",
|
||||
"DialogPPTCDeletionErrorMessage": "清除位於{0}的 PPTC 快取時出錯: {1}",
|
||||
"DialogShaderDeletionMessage": "您即將刪除:\n\n{0}的渲染器快取\n\n確定嗎?",
|
||||
"DialogShaderDeletionErrorMessage": "清除位於{0}的渲染器快取時出錯: {1}",
|
||||
"DialogRyujinxErrorMessage": "Ryujinx 遇到錯誤",
|
||||
"DialogInvalidTitleIdErrorMessage": "UI 錯誤:所選遊戲沒有有效的標題ID",
|
||||
"DialogFirmwareInstallerFirmwareNotFoundErrorMessage": "路徑{0}找不到有效的系統韌體。",
|
||||
"DialogFirmwareInstallerFirmwareInstallTitle": "安裝韌體{0}",
|
||||
"DialogFirmwareInstallerFirmwareInstallMessage": "將安裝{0}版本的系統。",
|
||||
"DialogFirmwareInstallerFirmwareInstallSubMessage": "\n\n這將替換目前系統版本{0}。",
|
||||
"DialogFirmwareInstallerFirmwareInstallConfirmMessage": "\n\n確認進行?",
|
||||
"DialogFirmwareInstallerFirmwareInstallWaitMessage": "安裝韌體中...",
|
||||
"DialogFirmwareInstallerFirmwareInstallSuccessMessage": "成功安裝系統版本{0}。",
|
||||
"DialogUserProfileDeletionWarningMessage": "刪除後將沒有可選擇的使用者帳號",
|
||||
"DialogUserProfileDeletionConfirmMessage": "是否刪除選擇的帳號",
|
||||
"DialogControllerSettingsModifiedConfirmMessage": "目前的輸入預設已更新",
|
||||
"DialogControllerSettingsModifiedConfirmSubMessage": "要儲存嗎?",
|
||||
"DialogDlcLoadNcaErrorMessage": "{0}. 錯誤的檔案: {1}",
|
||||
"DialogDlcNoDlcErrorMessage": "選擇的檔案不包含所選遊戲的 DLC!",
|
||||
"DialogPerformanceCheckLoggingEnabledMessage": "您啟用了跟蹤日誌,僅供開發人員使用。",
|
||||
"DialogPerformanceCheckLoggingEnabledConfirmMessage": "為了獲得最佳效能,建議停用跟蹤日誌記錄。您是否要立即停用?",
|
||||
"DialogPerformanceCheckShaderDumpEnabledMessage": "您啟用了渲染器轉儲,僅供開發人員使用。",
|
||||
"DialogPerformanceCheckShaderDumpEnabledConfirmMessage": "為了獲得最佳效能,建議停用渲染器轉儲。您是否要立即停用?",
|
||||
"DialogLoadAppGameAlreadyLoadedMessage": "目前已載入有遊戲",
|
||||
"DialogLoadAppGameAlreadyLoadedSubMessage": "請停止模擬或關閉程式,再啟動另一個遊戲。",
|
||||
"DialogUpdateAddUpdateErrorMessage": "選擇的檔案不包含所選遊戲的更新!",
|
||||
"DialogSettingsBackendThreadingWarningTitle": "警告 - 後端多執行緒",
|
||||
"DialogSettingsBackendThreadingWarningMessage": "改變此選項後必須重啟 Ryujinx 才能生效。根據您的硬體,您開啟該選項時,可能需要手動停用驅動程式本身的GL多執行緒。",
|
||||
"SettingsTabGraphicsFeaturesOptions": "功能",
|
||||
"SettingsTabGraphicsBackendMultithreading": "後端多執行緒:",
|
||||
"CommonAuto": "自動(推薦)",
|
||||
"CommonOff": "關閉",
|
||||
"CommonOn": "打開",
|
||||
"InputDialogYes": "是",
|
||||
"InputDialogNo": "否",
|
||||
"DialogProfileInvalidProfileNameErrorMessage": "檔案名包含無效字元,請重試。",
|
||||
"MenuBarOptionsPauseEmulation": "暫停",
|
||||
"MenuBarOptionsResumeEmulation": "繼續",
|
||||
"AboutUrlTooltipMessage": "在瀏覽器中打開 Ryujinx 的官網。",
|
||||
"AboutDisclaimerMessage": "Ryujinx 以任何方式與 Nintendo™ 及其合作伙伴都沒有任何關聯。",
|
||||
"AboutAmiiboDisclaimerMessage": "我們的 Amiibo 模擬使用了\nAmiiboAPI (www.amiiboapi.com) ",
|
||||
"AboutPatreonUrlTooltipMessage": "在瀏覽器中打開 Ryujinx 的 Patreon 贊助頁。",
|
||||
"AboutGithubUrlTooltipMessage": "在瀏覽器中打開 Ryujinx 的 GitHub 儲存庫。",
|
||||
"AboutDiscordUrlTooltipMessage": "在瀏覽器中打開 Ryujinx 的 Discord 伺服器邀請連結。",
|
||||
"AboutTwitterUrlTooltipMessage": "在瀏覽器中打開 Ryujinx 的 Twitter 首頁。",
|
||||
"AboutRyujinxAboutTitle": "關於:",
|
||||
"AboutRyujinxAboutContent": "Ryujinx 是一款 Nintendo Switch™ 模擬器。\n您可以在 Patreon 上贊助 Ryujinx。\n關注 Twitter 或 Discord 可以取得模擬器最新動態。\n如果您對開發本軟體感興趣,歡迎來 GitHub 和 Discord 加入我們!",
|
||||
"AboutRyujinxMaintainersTitle": "由以下作者維護:",
|
||||
"AboutRyujinxMaintainersContentTooltipMessage": "在瀏覽器中打開貢獻者的網頁",
|
||||
"AboutRyujinxSupprtersTitle": "感謝 Patreon 的贊助者:",
|
||||
"AmiiboSeriesLabel": "Amiibo 系列",
|
||||
"AmiiboCharacterLabel": "角色",
|
||||
"AmiiboScanButtonLabel": "掃描",
|
||||
"AmiiboOptionsShowAllLabel": "顯示所有 Amiibo",
|
||||
"AmiiboOptionsUsRandomTagLabel": "修正: 使用隨機標記的 Uuid",
|
||||
"DlcManagerTableHeadingEnabledLabel": "啟用",
|
||||
"DlcManagerTableHeadingTitleIdLabel": "遊戲ID",
|
||||
"DlcManagerTableHeadingContainerPathLabel": "資料夾路徑",
|
||||
"DlcManagerTableHeadingFullPathLabel": "完整路徑",
|
||||
"DlcManagerRemoveAllButton": "全部刪除",
|
||||
"MenuBarOptionsChangeLanguage": "變更語言",
|
||||
"CommonSort": "排序",
|
||||
"CommonShowNames": "顯示名稱",
|
||||
"CommonFavorite": "收藏",
|
||||
"OrderAscending": "從小到大",
|
||||
"OrderDescending": "從大到小",
|
||||
"SettingsTabGraphicsFeatures": "額外功能",
|
||||
"ErrorWindowTitle": "錯誤視窗",
|
||||
"ToggleDiscordTooltip": "啟用或關閉 Discord 動態狀態展示",
|
||||
"AddGameDirBoxTooltip": "輸入要添加的遊戲資料夾",
|
||||
"AddGameDirTooltip": "添加遊戲資料夾到列表中",
|
||||
"RemoveGameDirTooltip": "移除選中的資料夾",
|
||||
"CustomThemeCheckTooltip": "啟用或關閉自訂主題",
|
||||
"CustomThemePathTooltip": "自訂主題的資料夾",
|
||||
"CustomThemeBrowseTooltip": "查找自訂主題",
|
||||
"DockModeToggleTooltip": "是否開啟 Switch 的 Docked 模式",
|
||||
"DirectKeyboardTooltip": "是否開啟\"直連鍵盤存取(HID) 支援\"\n(部分遊戲可以使用您的鍵盤輸入文字)",
|
||||
"DirectMouseTooltip": "是否開啟\"直連滑鼠存取(HID) 支援\"\n(部分遊戲可以使用您的滑鼠導航)",
|
||||
"RegionTooltip": "變更系統區域",
|
||||
"LanguageTooltip": "變更系統語言",
|
||||
"TimezoneTooltip": "變更系統時區",
|
||||
"TimeTooltip": "變更系統時鐘",
|
||||
"VSyncToggleTooltip": "關閉後,部分使用動態幀率的遊戲可以超過 60Hz 更新率",
|
||||
"PptcToggleTooltip": "開啟以後減少遊戲啟動時間和卡頓",
|
||||
"FsIntegrityToggleTooltip": "是否檢查遊戲檔案內容的完整性",
|
||||
"AudioBackendTooltip": "默認推薦SDL,但每種音訊後端對各類遊戲相容性不同,遇到音訊問題可以切換後端",
|
||||
"MemoryManagerTooltip": "改變 Switch 記憶體映射到電腦記憶體的方式,會影響CPU效能消耗",
|
||||
"MemoryManagerSoftwareTooltip": "使用軟體記憶體頁管理,最精確但是速度最慢",
|
||||
"MemoryManagerHostTooltip": "直接映射記憶體頁到電腦記憶體,JIT效率高",
|
||||
"MemoryManagerUnsafeTooltip": "直接映射記憶體頁,但是不檢查記憶體溢出,JIT效率最高。\nRyujinx可以存取任何位置的記憶體,因而相對不安全。此模式下只應執行您信任的遊戲或軟體(即官方遊戲)",
|
||||
"DRamTooltip": "擴展模擬的 Switch 記憶體為6GB,某些高畫質材質模組或 4K 模組需要此選項",
|
||||
"IgnoreMissingServicesTooltip": "忽略某些未實現的系統服務,少部分遊戲需要此選項才能啟動",
|
||||
"GraphicsBackendThreadingTooltip": "啟用後端多執行緒",
|
||||
"GalThreadingTooltip": "使用模擬器自帶的多執行緒調度,減少渲染器編譯的卡頓,並提高驅動程式的效能(尤其是缺失多執行緒的AMD)。\nNVIDIA使用者需要重啟模擬器才能停用驅動本身的多執行緒,否則您需手動執行停用獲得最佳效能",
|
||||
"ShaderCacheToggleTooltip": "開啟後快取渲染器到硬碟,減少遊戲卡頓",
|
||||
"ResolutionScaleTooltip": "縮放渲染的解析度",
|
||||
"ResolutionScaleEntryTooltip": "盡量使用如1.5的浮點倍數。非整數的倍率易引起錯誤",
|
||||
"AnisotropyTooltip": "各向異性過濾等級。提高傾斜視角材質的清晰度\n('自動'使用遊戲默認指定的等級)",
|
||||
"AspectRatioTooltip": "模擬器渲染視窗的寬高比",
|
||||
"ShaderDumpPathTooltip": "轉儲圖形渲染器的路徑",
|
||||
"FileLogTooltip": "是否儲存日誌檔案到硬碟",
|
||||
"StubLogTooltip": "記錄 Stub 訊息",
|
||||
"InfoLogTooltip": "記錄資訊訊息",
|
||||
"WarnLogTooltip": "記錄警告訊息",
|
||||
"ErrorLogTooltip": "記錄錯誤訊息",
|
||||
"TraceLogTooltip": "記錄 Trace 訊息",
|
||||
"GuestLogTooltip": "記錄 Guest 訊息",
|
||||
"FileAccessLogTooltip": "記錄檔案存取訊息",
|
||||
"FSAccessLogModeTooltip": "記錄 FS 存取訊息,輸出到控制台。可選的模式是0-3",
|
||||
"DeveloperOptionTooltip": "使用請謹慎",
|
||||
"OpenGlLogLevel": "需要打開適當的日誌等級",
|
||||
"DebugLogTooltip": "記錄Debug訊息",
|
||||
"LoadApplicationFileTooltip": "選擇 Switch 支援的遊戲格式並載入",
|
||||
"LoadApplicationFolderTooltip": "選擇解包後的 Switch 遊戲並載入",
|
||||
"OpenRyujinxFolderTooltip": "打開 Ryujinx 系統資料夾",
|
||||
"OpenRyujinxLogsTooltip": "打開日誌存放的資料夾",
|
||||
"ExitTooltip": "關閉 Ryujinx",
|
||||
"OpenSettingsTooltip": "打開設定視窗",
|
||||
"OpenProfileManagerTooltip": "打開使用者帳號管理器",
|
||||
"StopEmulationTooltip": "停止執行目前遊戲並回到選擇界面",
|
||||
"CheckUpdatesTooltip": "檢查 Ryujinx 新版本",
|
||||
"OpenAboutTooltip": "開啟關於視窗",
|
||||
"GridSize": "網格尺寸",
|
||||
"GridSizeTooltip": "調整網格模式的大小",
|
||||
"SettingsTabSystemSystemLanguageBrazilianPortuguese": "巴西葡萄牙語",
|
||||
"AboutRyujinxContributorsButtonHeader": "查看所有參與者",
|
||||
"SettingsTabSystemAudioVolume": "音量: ",
|
||||
"AudioVolumeTooltip": "調節音量",
|
||||
"SettingsTabSystemEnableInternetAccess": "啟用網路連接",
|
||||
"EnableInternetAccessTooltip": "開啟網路存取。此選項打開後,效果類似於 Switch 連接到網路的狀態。注意即使此選項關閉,應用程式偶爾也有可能連接到網路",
|
||||
"GameListContextMenuManageCheatToolTip": "管理金手指",
|
||||
"GameListContextMenuManageCheat": "管理金手指",
|
||||
"ControllerSettingsStickRange": "範圍",
|
||||
"DialogStopEmulationTitle": "Ryujinx - 停止模擬",
|
||||
"DialogStopEmulationMessage": "是否確定停止模擬?",
|
||||
"SettingsTabCpu": "CPU",
|
||||
"SettingsTabAudio": "音訊",
|
||||
"SettingsTabNetwork": "網路",
|
||||
"SettingsTabNetworkConnection": "網路連接",
|
||||
"SettingsTabCpuCache": "CPU 快取",
|
||||
"SettingsTabCpuMemory": "CPU 記憶體",
|
||||
"DialogUpdaterFlatpakNotSupportedMessage": "請透過 Flathub 更新 Ryujinx。",
|
||||
"UpdaterDisabledWarningTitle": "更新已停用!",
|
||||
"GameListContextMenuOpenSdModsDirectory": "打開 Atmosphere 模組資料夾",
|
||||
"GameListContextMenuOpenSdModsDirectoryToolTip": "打開包含應用程式模組的額外 Atmosphere SD卡資料夾",
|
||||
"ControllerSettingsRotate90": "順時針旋轉 90°",
|
||||
"IconSize": "圖示尺寸",
|
||||
"IconSizeTooltip": "變更遊戲圖示大小",
|
||||
"MenuBarOptionsShowConsole": "顯示控制台",
|
||||
"ShaderCachePurgeError": "清除渲染器快取時出錯: {0}: {1}",
|
||||
"UserErrorNoKeys": "找不到金鑰",
|
||||
"UserErrorNoFirmware": "找不到韌體",
|
||||
"UserErrorFirmwareParsingFailed": "韌體解析錯誤",
|
||||
"UserErrorApplicationNotFound": "找不到應用程式",
|
||||
"UserErrorUnknown": "未知錯誤",
|
||||
"UserErrorUndefined": "未定義錯誤",
|
||||
"UserErrorNoKeysDescription": "Ryujinx 找不到 『prod.keys』 檔案",
|
||||
"UserErrorNoFirmwareDescription": "Ryujinx 找不到任何已安裝的韌體",
|
||||
"UserErrorFirmwareParsingFailedDescription": "Ryujinx 無法解密選擇的韌體。這通常是由於金鑰過舊。",
|
||||
"UserErrorApplicationNotFoundDescription": "Ryujinx 在選中路徑找不到有效的應用程式。",
|
||||
"UserErrorUnknownDescription": "發生未知錯誤!",
|
||||
"UserErrorUndefinedDescription": "發生了未定義錯誤!此類錯誤不應出現,請聯絡開發人員!",
|
||||
"OpenSetupGuideMessage": "打開設定教學",
|
||||
"NoUpdate": "沒有新版本",
|
||||
"TitleUpdateVersionLabel": "版本 {0} - {1}",
|
||||
"RyujinxInfo": "Ryujinx - 訊息",
|
||||
"RyujinxConfirm": "Ryujinx - 確認",
|
||||
"FileDialogAllTypes": "全部類型",
|
||||
"Never": "從不",
|
||||
"SwkbdMinCharacters": "至少應為 {0} 個字長",
|
||||
"SwkbdMinRangeCharacters": "必須為 {0}-{1} 個字長",
|
||||
"SoftwareKeyboard": "軟體鍵盤",
|
||||
"DialogControllerAppletMessagePlayerRange": "遊戲需要 {0} 個玩家()持有:\n\nTYPES: {1}\n\nPLAYERS: {2}\n\n{3}請打開設定界面,配置手把;或者關閉視窗。",
|
||||
"DialogControllerAppletMessage": "遊戲需要剛好 {0} 個玩家()持有 with:\n\nTYPES: {1}\n\nPLAYERS: {2}\n\n{3}請打開設定界面,配置手把;或者關閉視窗。",
|
||||
"DialogControllerAppletDockModeSet": "現在處於主機模式,無法使用掌機操作方式\n\n",
|
||||
"UpdaterRenaming": "正在刪除舊檔案...",
|
||||
"UpdaterRenameFailed": "更新過程中無法重命名檔案: {0}",
|
||||
"UpdaterAddingFiles": "安裝更新中...",
|
||||
"UpdaterExtracting": "正在提取更新...",
|
||||
"UpdaterDownloading": "下載新版本中...",
|
||||
"Game": "遊戲",
|
||||
"Docked": "主機模式",
|
||||
"Handheld": "掌機模式",
|
||||
"ConnectionError": "連接錯誤。",
|
||||
"AboutPageDeveloperListMore": "{0} 等開發者...",
|
||||
"ApiError": "API 錯誤",
|
||||
"LoadingHeading": "正在啟動 {0}",
|
||||
"CompilingPPTC": "編譯 PPTC 快取中",
|
||||
"CompilingShaders": "編譯渲染器中",
|
||||
"AllKeyboards": "所有鍵盤",
|
||||
"OpenFileDialogTitle": "選擇支援的檔案格式",
|
||||
"OpenFolderDialogTitle": "選擇一個包含解包遊戲的資料夾",
|
||||
"AllSupportedFormats": "全部支援的格式",
|
||||
"RyujinxUpdater": "Ryujinx 更新程式",
|
||||
"SettingsTabHotkeys": "快捷鍵",
|
||||
"SettingsTabHotkeysHotkeys": "鍵盤快捷鍵",
|
||||
"SettingsTabHotkeysToggleVsyncHotkey": "切換垂直同步",
|
||||
"SettingsTabHotkeysScreenshotHotkey": "截圖",
|
||||
"SettingsTabHotkeysShowUiHotkey": "隱藏 UI",
|
||||
"SettingsTabHotkeysPauseHotkey": "暫停",
|
||||
"SettingsTabHotkeysToggleMuteHotkey": "靜音",
|
||||
"ControllerMotionTitle": "體感操作設定",
|
||||
"ControllerRumbleTitle": "震動設定",
|
||||
"SettingsSelectThemeFileDialogTitle": "選擇主題檔案",
|
||||
"SettingsXamlThemeFile": "Xaml 主題檔案",
|
||||
"AvatarWindowTitle": "管理帳號 - 頭像",
|
||||
"Amiibo": "Amiibo",
|
||||
"Unknown": "未知",
|
||||
"Usage": "用途",
|
||||
"Writable": "可寫入",
|
||||
"SelectDlcDialogTitle": "選擇 DLC 檔案",
|
||||
"SelectUpdateDialogTitle": "選擇更新檔",
|
||||
"UserProfileWindowTitle": "管理使用者設定檔",
|
||||
"CheatWindowTitle": "管理遊戲金手指",
|
||||
"DlcWindowTitle": "管理遊戲 DLC",
|
||||
"UpdateWindowTitle": "管理遊戲更新",
|
||||
"CheatWindowHeading": "金手指可用於 {0} [{1}]",
|
||||
"DlcWindowHeading": "DLC 可用於 {0} [{1}]",
|
||||
"GameUpdateWindowHeading": "更新可用於 {0} [{1}]"
|
||||
}
|
@ -7,6 +7,8 @@
|
||||
Screenshot,
|
||||
ShowUi,
|
||||
Pause,
|
||||
ToggleMute
|
||||
ToggleMute,
|
||||
ResScaleUp,
|
||||
ResScaleDown
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@ using Avalonia;
|
||||
using Avalonia.OpenGL;
|
||||
using Avalonia.Rendering;
|
||||
using Avalonia.Threading;
|
||||
using Ryujinx.Ava.Ui.Backend;
|
||||
using Ryujinx.Ava.Ui.Controls;
|
||||
using Ryujinx.Ava.Ui.Windows;
|
||||
using Ryujinx.Common;
|
||||
@ -11,9 +12,12 @@ using Ryujinx.Common.GraphicsDriver;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Common.System;
|
||||
using Ryujinx.Common.SystemInfo;
|
||||
using Ryujinx.Graphics.Vulkan;
|
||||
using Ryujinx.Modules;
|
||||
using Ryujinx.Ui.Common;
|
||||
using Ryujinx.Ui.Common.Configuration;
|
||||
using Silk.NET.Vulkan.Extensions.EXT;
|
||||
using Silk.NET.Vulkan.Extensions.KHR;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@ -25,17 +29,20 @@ namespace Ryujinx.Ava
|
||||
internal class Program
|
||||
{
|
||||
public static double WindowScaleFactor { get; set; }
|
||||
public static double ActualScaleFactor { get; set; }
|
||||
public static string Version { get; private set; }
|
||||
public static string ConfigurationPath { get; private set; }
|
||||
public static string CommandLineProfile { get; set; }
|
||||
public static bool PreviewerDetached { get; private set; }
|
||||
|
||||
public static RenderTimer RenderTimer { get; private set; }
|
||||
public static bool UseVulkan { get; private set; }
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
public static extern int MessageBoxA(IntPtr hWnd, string text, string caption, uint type);
|
||||
|
||||
private const uint MB_ICONWARNING = 0x30;
|
||||
private const int BaseDpi = 96;
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
@ -66,7 +73,7 @@ namespace Ryujinx.Ava
|
||||
EnableMultiTouch = true,
|
||||
EnableIme = true,
|
||||
UseEGL = false,
|
||||
UseGpu = true,
|
||||
UseGpu = !UseVulkan,
|
||||
GlProfiles = new List<GlVersion>()
|
||||
{
|
||||
new GlVersion(GlProfileType.OpenGL, 4, 3)
|
||||
@ -75,7 +82,7 @@ namespace Ryujinx.Ava
|
||||
.With(new Win32PlatformOptions
|
||||
{
|
||||
EnableMultitouch = true,
|
||||
UseWgl = true,
|
||||
UseWgl = !UseVulkan,
|
||||
WglProfiles = new List<GlVersion>()
|
||||
{
|
||||
new GlVersion(GlProfileType.OpenGL, 4, 3)
|
||||
@ -84,6 +91,19 @@ namespace Ryujinx.Ava
|
||||
CompositionBackdropCornerRadius = 8f,
|
||||
})
|
||||
.UseSkia()
|
||||
.With(new Ui.Vulkan.VulkanOptions()
|
||||
{
|
||||
ApplicationName = "Ryujinx.Graphics.Vulkan",
|
||||
VulkanVersion = new Version(1, 2),
|
||||
MaxQueueCount = 2,
|
||||
PreferDiscreteGpu = true,
|
||||
PreferredDevice = !PreviewerDetached ? "" : ConfigurationState.Instance.Graphics.PreferredGpu.Value,
|
||||
UseDebug = !PreviewerDetached ? false : ConfigurationState.Instance.Logger.GraphicsDebugLevel.Value != GraphicsDebugLevel.None,
|
||||
})
|
||||
.With(new SkiaOptions()
|
||||
{
|
||||
CustomGpuFactory = UseVulkan ? SkiaGpuFactory.CreateVulkanGpu : null
|
||||
})
|
||||
.AfterSetup(_ =>
|
||||
{
|
||||
AvaloniaLocator.CurrentMutable
|
||||
@ -136,9 +156,6 @@ namespace Ryujinx.Ava
|
||||
}
|
||||
}
|
||||
|
||||
// Make process DPI aware for proper window sizing on high-res screens.
|
||||
WindowScaleFactor = ForceDpiAware.GetWindowScaleFactor();
|
||||
|
||||
// Delete backup files after updating.
|
||||
Task.Run(Updater.CleanupUpdate);
|
||||
|
||||
@ -162,6 +179,18 @@ namespace Ryujinx.Ava
|
||||
|
||||
ReloadConfig();
|
||||
|
||||
UseVulkan = PreviewerDetached ? ConfigurationState.Instance.Graphics.GraphicsBackend.Value == GraphicsBackend.Vulkan : false;
|
||||
|
||||
if (UseVulkan)
|
||||
{
|
||||
// With a custom gpu backend, avalonia doesn't enable dpi awareness, so the backend must handle it. This isn't so for the opengl backed,
|
||||
// as that uses avalonia's gpu backend and it's enabled there.
|
||||
ForceDpiAware.Windows();
|
||||
}
|
||||
|
||||
WindowScaleFactor = ForceDpiAware.GetWindowScaleFactor();
|
||||
ActualScaleFactor = ForceDpiAware.GetActualScaleFactor() / BaseDpi;
|
||||
|
||||
// Logging system information.
|
||||
PrintSystemInfo();
|
||||
|
||||
|
@ -28,16 +28,20 @@
|
||||
<PackageReference Include="FluentAvaloniaUI" Version="1.4.1" />
|
||||
<PackageReference Include="XamlNameReferenceGenerator" Version="1.3.4" />
|
||||
|
||||
<PackageReference Include="OpenTK.Core" Version="4.7.2" />
|
||||
<PackageReference Include="Ryujinx.Audio.OpenAL.Dependencies" Version="1.21.0.1" Condition="'$(RuntimeIdentifier)' != 'linux-x64' AND '$(RuntimeIdentifier)' != 'osx-x64'" />
|
||||
<PackageReference Include="Ryujinx.Graphics.Nvdec.Dependencies" Version="5.0.1-build10" Condition="'$(RuntimeIdentifier)' != 'linux-x64' AND '$(RuntimeIdentifier)' != 'osx-x64'" />
|
||||
<PackageReference Include="OpenTK.Graphics" Version="4.7.2" />
|
||||
<PackageReference Include="SPB" Version="0.0.4-build17" />
|
||||
<PackageReference Include="Silk.NET.Vulkan" Version="2.10.1" />
|
||||
<PackageReference Include="Silk.NET.Vulkan.Extensions.EXT" Version="2.10.1" />
|
||||
<PackageReference Include="Silk.NET.Vulkan.Extensions.KHR" Version="2.10.1" />
|
||||
<PackageReference Include="SPB" Version="0.0.4-build24" />
|
||||
<PackageReference Include="SharpZipLib" Version="1.3.3" />
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.4" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Ryujinx.Audio.Backends.SDL2\Ryujinx.Audio.Backends.SDL2.csproj" />
|
||||
<ProjectReference Include="..\Ryujinx.Graphics.Vulkan\Ryujinx.Graphics.Vulkan.csproj" />
|
||||
<ProjectReference Include="..\Ryujinx.Input\Ryujinx.Input.csproj" />
|
||||
<ProjectReference Include="..\Ryujinx.Input.SDL2\Ryujinx.Input.SDL2.csproj" />
|
||||
<ProjectReference Include="..\Ryujinx.Audio.Backends.OpenAL\Ryujinx.Audio.Backends.OpenAL.csproj" />
|
||||
@ -119,6 +123,7 @@
|
||||
<None Remove="Assets\Locales\ru_RU.json" />
|
||||
<None Remove="Assets\Locales\tr_TR.json" />
|
||||
<None Remove="Assets\Locales\zh_CN.json" />
|
||||
<None Remove="Assets\Locales\zh_TW.json" />
|
||||
<None Remove="Assets\Styles\Styles.xaml" />
|
||||
<None Remove="Assets\Styles\BaseDark.xaml" />
|
||||
<None Remove="Assets\Styles\BaseLight.xaml" />
|
||||
@ -136,6 +141,7 @@
|
||||
<EmbeddedResource Include="Assets\Locales\ru_RU.json" />
|
||||
<EmbeddedResource Include="Assets\Locales\tr_TR.json" />
|
||||
<EmbeddedResource Include="Assets\Locales\zh_CN.json" />
|
||||
<EmbeddedResource Include="Assets\Locales\zh_TW.json" />
|
||||
<EmbeddedResource Include="Assets\Styles\Styles.xaml" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
@ -135,7 +135,7 @@ namespace Ryujinx.Ava.Ui.Applet
|
||||
Dispatcher.UIThread.Post(() =>
|
||||
{
|
||||
_hiddenTextBox.Clear();
|
||||
_parent.GlRenderer.Focus();
|
||||
_parent.RendererControl.Focus();
|
||||
|
||||
_parent = null;
|
||||
});
|
||||
|
76
Ryujinx.Ava/Ui/Backend/BackendSurface.cs
Normal file
76
Ryujinx.Ava/Ui/Backend/BackendSurface.cs
Normal file
@ -0,0 +1,76 @@
|
||||
using Avalonia;
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using static Ryujinx.Ava.Ui.Backend.Interop;
|
||||
|
||||
namespace Ryujinx.Ava.Ui.Backend
|
||||
{
|
||||
public abstract class BackendSurface : IDisposable
|
||||
{
|
||||
protected IntPtr Display => _display;
|
||||
|
||||
private IntPtr _display = IntPtr.Zero;
|
||||
|
||||
[DllImport("libX11.so.6")]
|
||||
public static extern IntPtr XOpenDisplay(IntPtr display);
|
||||
|
||||
[DllImport("libX11.so.6")]
|
||||
public static extern int XCloseDisplay(IntPtr display);
|
||||
|
||||
private PixelSize _currentSize;
|
||||
public IntPtr Handle { get; protected set; }
|
||||
|
||||
public bool IsDisposed { get; private set; }
|
||||
|
||||
public BackendSurface(IntPtr handle)
|
||||
{
|
||||
Handle = handle;
|
||||
|
||||
if (OperatingSystem.IsLinux())
|
||||
{
|
||||
_display = XOpenDisplay(IntPtr.Zero);
|
||||
}
|
||||
}
|
||||
|
||||
public PixelSize Size
|
||||
{
|
||||
get
|
||||
{
|
||||
PixelSize size = new PixelSize();
|
||||
if (OperatingSystem.IsWindows())
|
||||
{
|
||||
GetClientRect(Handle, out var rect);
|
||||
size = new PixelSize(rect.right, rect.bottom);
|
||||
}
|
||||
else if (OperatingSystem.IsLinux())
|
||||
{
|
||||
XWindowAttributes attributes = new XWindowAttributes();
|
||||
XGetWindowAttributes(Display, Handle, ref attributes);
|
||||
|
||||
size = new PixelSize(attributes.width, attributes.height);
|
||||
}
|
||||
|
||||
_currentSize = size;
|
||||
|
||||
return size;
|
||||
}
|
||||
}
|
||||
|
||||
public PixelSize CurrentSize => _currentSize;
|
||||
|
||||
public virtual void Dispose()
|
||||
{
|
||||
if (IsDisposed)
|
||||
{
|
||||
throw new ObjectDisposedException(nameof(BackendSurface));
|
||||
}
|
||||
|
||||
IsDisposed = true;
|
||||
|
||||
if (_display != IntPtr.Zero)
|
||||
{
|
||||
XCloseDisplay(_display);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
49
Ryujinx.Ava/Ui/Backend/Interop.cs
Normal file
49
Ryujinx.Ava/Ui/Backend/Interop.cs
Normal file
@ -0,0 +1,49 @@
|
||||
using FluentAvalonia.Interop;
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ryujinx.Ava.Ui.Backend
|
||||
{
|
||||
public static class Interop
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct XWindowAttributes
|
||||
{
|
||||
public int x;
|
||||
public int y;
|
||||
public int width;
|
||||
public int height;
|
||||
public int border_width;
|
||||
public int depth;
|
||||
public IntPtr visual;
|
||||
public IntPtr root;
|
||||
public int c_class;
|
||||
public int bit_gravity;
|
||||
public int win_gravity;
|
||||
public int backing_store;
|
||||
public IntPtr backing_planes;
|
||||
public IntPtr backing_pixel;
|
||||
public int save_under;
|
||||
public IntPtr colormap;
|
||||
public int map_installed;
|
||||
public int map_state;
|
||||
public IntPtr all_event_masks;
|
||||
public IntPtr your_event_mask;
|
||||
public IntPtr do_not_propagate_mask;
|
||||
public int override_direct;
|
||||
public IntPtr screen;
|
||||
}
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern bool GetClientRect(IntPtr hwnd, out RECT lpRect);
|
||||
|
||||
[DllImport("libX11.so.6")]
|
||||
public static extern int XCloseDisplay(IntPtr display);
|
||||
|
||||
[DllImport("libX11.so.6")]
|
||||
public static extern int XGetWindowAttributes(IntPtr display, IntPtr window, ref XWindowAttributes attributes);
|
||||
|
||||
[DllImport("libX11.so.6")]
|
||||
public static extern IntPtr XOpenDisplay(IntPtr display);
|
||||
}
|
||||
}
|
26
Ryujinx.Ava/Ui/Backend/SkiaGpuFactory.cs
Normal file
26
Ryujinx.Ava/Ui/Backend/SkiaGpuFactory.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Skia;
|
||||
using Ryujinx.Ava.Ui.Vulkan;
|
||||
using Ryujinx.Ava.Ui.Backend.Vulkan;
|
||||
|
||||
namespace Ryujinx.Ava.Ui.Backend
|
||||
{
|
||||
public static class SkiaGpuFactory
|
||||
{
|
||||
public static ISkiaGpu CreateVulkanGpu()
|
||||
{
|
||||
var skiaOptions = AvaloniaLocator.Current.GetService<SkiaOptions>() ?? new SkiaOptions();
|
||||
var platformInterface = AvaloniaLocator.Current.GetService<VulkanPlatformInterface>();
|
||||
|
||||
if (platformInterface == null)
|
||||
{
|
||||
VulkanPlatformInterface.TryInitialize();
|
||||
}
|
||||
|
||||
var gpu = new VulkanSkiaGpu(skiaOptions.MaxGpuResourceSizeBytes);
|
||||
AvaloniaLocator.CurrentMutable.Bind<VulkanSkiaGpu>().ToConstant(gpu);
|
||||
|
||||
return gpu;
|
||||
}
|
||||
}
|
||||
}
|
16
Ryujinx.Ava/Ui/Backend/Vulkan/ResultExtensions.cs
Normal file
16
Ryujinx.Ava/Ui/Backend/Vulkan/ResultExtensions.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using Silk.NET.Vulkan;
|
||||
|
||||
namespace Ryujinx.Ava.Ui.Vulkan
|
||||
{
|
||||
public static class ResultExtensions
|
||||
{
|
||||
public static void ThrowOnError(this Result result)
|
||||
{
|
||||
if (result != Result.Success)
|
||||
{
|
||||
throw new Exception($"Unexpected API error \"{result}\".");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
135
Ryujinx.Ava/Ui/Backend/Vulkan/Skia/VulkanRenderTarget.cs
Normal file
135
Ryujinx.Ava/Ui/Backend/Vulkan/Skia/VulkanRenderTarget.cs
Normal file
@ -0,0 +1,135 @@
|
||||
using System;
|
||||
using Avalonia.Skia;
|
||||
using Ryujinx.Ava.Ui.Vulkan;
|
||||
using Ryujinx.Ava.Ui.Vulkan.Surfaces;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Ryujinx.Ava.Ui.Backend.Vulkan
|
||||
{
|
||||
internal class VulkanRenderTarget : ISkiaGpuRenderTarget
|
||||
{
|
||||
public GRContext GrContext { get; set; }
|
||||
|
||||
private readonly VulkanSurfaceRenderTarget _surface;
|
||||
private readonly IVulkanPlatformSurface _vulkanPlatformSurface;
|
||||
|
||||
public VulkanRenderTarget(VulkanPlatformInterface vulkanPlatformInterface, IVulkanPlatformSurface vulkanPlatformSurface)
|
||||
{
|
||||
_surface = vulkanPlatformInterface.CreateRenderTarget(vulkanPlatformSurface);
|
||||
_vulkanPlatformSurface = vulkanPlatformSurface;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_surface.Dispose();
|
||||
}
|
||||
|
||||
public ISkiaGpuRenderSession BeginRenderingSession()
|
||||
{
|
||||
var session = _surface.BeginDraw(_vulkanPlatformSurface.Scaling);
|
||||
bool success = false;
|
||||
try
|
||||
{
|
||||
var disp = session.Display;
|
||||
var api = session.Api;
|
||||
|
||||
var size = session.Size;
|
||||
var scaling = session.Scaling;
|
||||
if (size.Width <= 0 || size.Height <= 0 || scaling < 0)
|
||||
{
|
||||
size = new Avalonia.PixelSize(1, 1);
|
||||
scaling = 1;
|
||||
}
|
||||
|
||||
lock (GrContext)
|
||||
{
|
||||
GrContext.ResetContext();
|
||||
|
||||
var imageInfo = new GRVkImageInfo()
|
||||
{
|
||||
CurrentQueueFamily = disp.QueueFamilyIndex,
|
||||
Format = _surface.ImageFormat,
|
||||
Image = _surface.Image.Handle,
|
||||
ImageLayout = (uint)_surface.Image.CurrentLayout,
|
||||
ImageTiling = (uint)_surface.Image.Tiling,
|
||||
ImageUsageFlags = _surface.UsageFlags,
|
||||
LevelCount = _surface.MipLevels,
|
||||
SampleCount = 1,
|
||||
Protected = false,
|
||||
Alloc = new GRVkAlloc()
|
||||
{
|
||||
Memory = _surface.Image.MemoryHandle,
|
||||
Flags = 0,
|
||||
Offset = 0,
|
||||
Size = _surface.MemorySize
|
||||
}
|
||||
};
|
||||
|
||||
var renderTarget =
|
||||
new GRBackendRenderTarget((int)size.Width, (int)size.Height, 1,
|
||||
imageInfo);
|
||||
var surface = SKSurface.Create(GrContext, renderTarget,
|
||||
GRSurfaceOrigin.TopLeft,
|
||||
_surface.IsRgba ? SKColorType.Rgba8888 : SKColorType.Bgra8888, SKColorSpace.CreateSrgb());
|
||||
|
||||
if (surface == null)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Surface can't be created with the provided render target");
|
||||
}
|
||||
|
||||
success = true;
|
||||
|
||||
return new VulkanGpuSession(GrContext, renderTarget, surface, session);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!success)
|
||||
{
|
||||
session.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsCorrupted { get; }
|
||||
|
||||
internal class VulkanGpuSession : ISkiaGpuRenderSession
|
||||
{
|
||||
private readonly GRBackendRenderTarget _backendRenderTarget;
|
||||
private readonly VulkanSurfaceRenderingSession _vulkanSession;
|
||||
|
||||
public VulkanGpuSession(GRContext grContext,
|
||||
GRBackendRenderTarget backendRenderTarget,
|
||||
SKSurface surface,
|
||||
VulkanSurfaceRenderingSession vulkanSession)
|
||||
{
|
||||
GrContext = grContext;
|
||||
_backendRenderTarget = backendRenderTarget;
|
||||
SkSurface = surface;
|
||||
_vulkanSession = vulkanSession;
|
||||
|
||||
SurfaceOrigin = GRSurfaceOrigin.TopLeft;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
lock (_vulkanSession.Display.Lock)
|
||||
{
|
||||
SkSurface.Canvas.Flush();
|
||||
|
||||
SkSurface.Dispose();
|
||||
_backendRenderTarget.Dispose();
|
||||
GrContext.Flush();
|
||||
|
||||
_vulkanSession.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public GRContext GrContext { get; }
|
||||
public SKSurface SkSurface { get; }
|
||||
public double ScaleFactor => _vulkanSession.Scaling;
|
||||
public GRSurfaceOrigin SurfaceOrigin { get; }
|
||||
}
|
||||
}
|
||||
}
|
124
Ryujinx.Ava/Ui/Backend/Vulkan/Skia/VulkanSkiaGpu.cs
Normal file
124
Ryujinx.Ava/Ui/Backend/Vulkan/Skia/VulkanSkiaGpu.cs
Normal file
@ -0,0 +1,124 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Avalonia;
|
||||
using Avalonia.Platform;
|
||||
using Avalonia.Skia;
|
||||
using Avalonia.X11;
|
||||
using Ryujinx.Ava.Ui.Vulkan;
|
||||
using Silk.NET.Vulkan;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Ryujinx.Ava.Ui.Backend.Vulkan
|
||||
{
|
||||
public class VulkanSkiaGpu : ISkiaGpu
|
||||
{
|
||||
private readonly VulkanPlatformInterface _vulkan;
|
||||
private readonly long? _maxResourceBytes;
|
||||
private GRVkBackendContext _grVkBackend;
|
||||
private bool _initialized;
|
||||
|
||||
public GRContext GrContext { get; private set; }
|
||||
|
||||
public VulkanSkiaGpu(long? maxResourceBytes)
|
||||
{
|
||||
_vulkan = AvaloniaLocator.Current.GetService<VulkanPlatformInterface>();
|
||||
_maxResourceBytes = maxResourceBytes;
|
||||
}
|
||||
|
||||
private void Initialize()
|
||||
{
|
||||
if (_initialized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_initialized = true;
|
||||
GRVkGetProcedureAddressDelegate getProc = (string name, IntPtr instanceHandle, IntPtr deviceHandle) =>
|
||||
{
|
||||
IntPtr addr = IntPtr.Zero;
|
||||
|
||||
if (deviceHandle != IntPtr.Zero)
|
||||
{
|
||||
addr = _vulkan.Device.Api.GetDeviceProcAddr(new Device(deviceHandle), name);
|
||||
|
||||
if (addr != IntPtr.Zero)
|
||||
{
|
||||
return addr;
|
||||
}
|
||||
|
||||
addr = _vulkan.Device.Api.GetDeviceProcAddr(new Device(_vulkan.Device.Handle), name);
|
||||
|
||||
if (addr != IntPtr.Zero)
|
||||
{
|
||||
return addr;
|
||||
}
|
||||
}
|
||||
|
||||
addr = _vulkan.Device.Api.GetInstanceProcAddr(new Instance(_vulkan.Instance.Handle), name);
|
||||
|
||||
if (addr == IntPtr.Zero)
|
||||
{
|
||||
addr = _vulkan.Device.Api.GetInstanceProcAddr(new Instance(instanceHandle), name);
|
||||
}
|
||||
|
||||
return addr;
|
||||
};
|
||||
|
||||
_grVkBackend = new GRVkBackendContext()
|
||||
{
|
||||
VkInstance = _vulkan.Device.Handle,
|
||||
VkPhysicalDevice = _vulkan.PhysicalDevice.Handle,
|
||||
VkDevice = _vulkan.Device.Handle,
|
||||
VkQueue = _vulkan.Device.Queue.Handle,
|
||||
GraphicsQueueIndex = _vulkan.PhysicalDevice.QueueFamilyIndex,
|
||||
GetProcedureAddress = getProc
|
||||
};
|
||||
GrContext = GRContext.CreateVulkan(_grVkBackend);
|
||||
if (_maxResourceBytes.HasValue)
|
||||
{
|
||||
GrContext.SetResourceCacheLimit(_maxResourceBytes.Value);
|
||||
}
|
||||
}
|
||||
|
||||
public ISkiaGpuRenderTarget TryCreateRenderTarget(IEnumerable<object> surfaces)
|
||||
{
|
||||
foreach (var surface in surfaces)
|
||||
{
|
||||
VulkanWindowSurface window;
|
||||
|
||||
if (surface is IPlatformHandle handle)
|
||||
{
|
||||
window = new VulkanWindowSurface(handle.Handle);
|
||||
}
|
||||
else if (surface is X11FramebufferSurface x11FramebufferSurface)
|
||||
{
|
||||
// As of Avalonia 0.10.13, an IPlatformHandle isn't passed for linux, so use reflection to otherwise get the window id
|
||||
var xId = (IntPtr)x11FramebufferSurface.GetType().GetField(
|
||||
"_xid",
|
||||
System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(x11FramebufferSurface);
|
||||
|
||||
window = new VulkanWindowSurface(xId);
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
VulkanRenderTarget vulkanRenderTarget = new VulkanRenderTarget(_vulkan, window);
|
||||
|
||||
Initialize();
|
||||
|
||||
vulkanRenderTarget.GrContext = GrContext;
|
||||
|
||||
return vulkanRenderTarget;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public ISkiaSurface TryCreateSurface(PixelSize size, ISkiaGpuRenderSession session)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
53
Ryujinx.Ava/Ui/Backend/Vulkan/Skia/VulkanSurface.cs
Normal file
53
Ryujinx.Ava/Ui/Backend/Vulkan/Skia/VulkanSurface.cs
Normal file
@ -0,0 +1,53 @@
|
||||
using Avalonia;
|
||||
using Ryujinx.Ava.Ui.Vulkan;
|
||||
using Ryujinx.Ava.Ui.Vulkan.Surfaces;
|
||||
using Silk.NET.Vulkan;
|
||||
using Silk.NET.Vulkan.Extensions.KHR;
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.Ava.Ui.Backend.Vulkan
|
||||
{
|
||||
internal class VulkanWindowSurface : BackendSurface, IVulkanPlatformSurface
|
||||
{
|
||||
public float Scaling => (float)Program.ActualScaleFactor;
|
||||
|
||||
public PixelSize SurfaceSize => Size;
|
||||
|
||||
public VulkanWindowSurface(IntPtr handle) : base(handle)
|
||||
{
|
||||
}
|
||||
|
||||
public unsafe SurfaceKHR CreateSurface(VulkanInstance instance)
|
||||
{
|
||||
if (OperatingSystem.IsWindows())
|
||||
{
|
||||
if (instance.Api.TryGetInstanceExtension(new Instance(instance.Handle), out KhrWin32Surface surfaceExtension))
|
||||
{
|
||||
var createInfo = new Win32SurfaceCreateInfoKHR() { Hinstance = 0, Hwnd = Handle, SType = StructureType.Win32SurfaceCreateInfoKhr };
|
||||
|
||||
surfaceExtension.CreateWin32Surface(new Instance(instance.Handle), createInfo, null, out var surface).ThrowOnError();
|
||||
|
||||
return surface;
|
||||
}
|
||||
}
|
||||
else if (OperatingSystem.IsLinux())
|
||||
{
|
||||
if (instance.Api.TryGetInstanceExtension(new Instance(instance.Handle), out KhrXlibSurface surfaceExtension))
|
||||
{
|
||||
var createInfo = new XlibSurfaceCreateInfoKHR()
|
||||
{
|
||||
SType = StructureType.XlibSurfaceCreateInfoKhr,
|
||||
Dpy = (nint*)Display,
|
||||
Window = Handle
|
||||
};
|
||||
|
||||
surfaceExtension.CreateXlibSurface(new Instance(instance.Handle), createInfo, null, out var surface).ThrowOnError();
|
||||
|
||||
return surface;
|
||||
}
|
||||
}
|
||||
|
||||
throw new PlatformNotSupportedException("The current platform does not support surface creation.");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using Avalonia;
|
||||
using Silk.NET.Vulkan;
|
||||
|
||||
namespace Ryujinx.Ava.Ui.Vulkan.Surfaces
|
||||
{
|
||||
public interface IVulkanPlatformSurface : IDisposable
|
||||
{
|
||||
float Scaling { get; }
|
||||
PixelSize SurfaceSize { get; }
|
||||
SurfaceKHR CreateSurface(VulkanInstance instance);
|
||||
}
|
||||
}
|
@ -0,0 +1,92 @@
|
||||
using System;
|
||||
using Avalonia;
|
||||
using Silk.NET.Vulkan;
|
||||
|
||||
namespace Ryujinx.Ava.Ui.Vulkan.Surfaces
|
||||
{
|
||||
internal class VulkanSurfaceRenderTarget : IDisposable
|
||||
{
|
||||
private readonly VulkanPlatformInterface _platformInterface;
|
||||
|
||||
private readonly Format _format;
|
||||
|
||||
public VulkanImage Image { get; private set; }
|
||||
public bool IsCorrupted { get; private set; } = true;
|
||||
|
||||
public uint MipLevels => Image.MipLevels;
|
||||
|
||||
public VulkanSurfaceRenderTarget(VulkanPlatformInterface platformInterface, VulkanSurface surface)
|
||||
{
|
||||
_platformInterface = platformInterface;
|
||||
|
||||
Display = VulkanDisplay.CreateDisplay(platformInterface.Instance, platformInterface.Device,
|
||||
platformInterface.PhysicalDevice, surface);
|
||||
Surface = surface;
|
||||
|
||||
// Skia seems to only create surfaces from images with unorm format
|
||||
|
||||
IsRgba = Display.SurfaceFormat.Format >= Format.R8G8B8A8Unorm &&
|
||||
Display.SurfaceFormat.Format <= Format.R8G8B8A8Srgb;
|
||||
|
||||
_format = IsRgba ? Format.R8G8B8A8Unorm : Format.B8G8R8A8Unorm;
|
||||
}
|
||||
|
||||
public bool IsRgba { get; }
|
||||
|
||||
public uint ImageFormat => (uint) _format;
|
||||
|
||||
public ulong MemorySize => Image.MemorySize;
|
||||
|
||||
public VulkanDisplay Display { get; }
|
||||
|
||||
public VulkanSurface Surface { get; }
|
||||
|
||||
public uint UsageFlags => Image.UsageFlags;
|
||||
|
||||
public PixelSize Size { get; private set; }
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_platformInterface.Device.WaitIdle();
|
||||
DestroyImage();
|
||||
Display?.Dispose();
|
||||
Surface?.Dispose();
|
||||
}
|
||||
|
||||
public VulkanSurfaceRenderingSession BeginDraw(float scaling)
|
||||
{
|
||||
var session = new VulkanSurfaceRenderingSession(Display, _platformInterface.Device, this, scaling);
|
||||
|
||||
if (IsCorrupted)
|
||||
{
|
||||
IsCorrupted = false;
|
||||
DestroyImage();
|
||||
CreateImage();
|
||||
}
|
||||
else
|
||||
{
|
||||
Image.TransitionLayout(ImageLayout.ColorAttachmentOptimal, AccessFlags.AccessNoneKhr);
|
||||
}
|
||||
|
||||
return session;
|
||||
}
|
||||
|
||||
public void Invalidate()
|
||||
{
|
||||
IsCorrupted = true;
|
||||
}
|
||||
|
||||
private void CreateImage()
|
||||
{
|
||||
Size = Display.Size;
|
||||
|
||||
Image = new VulkanImage(_platformInterface.Device, _platformInterface.PhysicalDevice, _platformInterface.Device.CommandBufferPool, ImageFormat, Size);
|
||||
}
|
||||
|
||||
private void DestroyImage()
|
||||
{
|
||||
_platformInterface.Device.WaitIdle();
|
||||
Image?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
182
Ryujinx.Ava/Ui/Backend/Vulkan/VulkanCommandBufferPool.cs
Normal file
182
Ryujinx.Ava/Ui/Backend/Vulkan/VulkanCommandBufferPool.cs
Normal file
@ -0,0 +1,182 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Silk.NET.Vulkan;
|
||||
|
||||
namespace Ryujinx.Ava.Ui.Vulkan
|
||||
{
|
||||
internal class VulkanCommandBufferPool : IDisposable
|
||||
{
|
||||
private readonly VulkanDevice _device;
|
||||
private readonly CommandPool _commandPool;
|
||||
|
||||
private readonly List<VulkanCommandBuffer> _usedCommandBuffers = new();
|
||||
|
||||
public unsafe VulkanCommandBufferPool(VulkanDevice device, VulkanPhysicalDevice physicalDevice)
|
||||
{
|
||||
_device = device;
|
||||
|
||||
var commandPoolCreateInfo = new CommandPoolCreateInfo
|
||||
{
|
||||
SType = StructureType.CommandPoolCreateInfo,
|
||||
Flags = CommandPoolCreateFlags.CommandPoolCreateResetCommandBufferBit,
|
||||
QueueFamilyIndex = physicalDevice.QueueFamilyIndex
|
||||
};
|
||||
|
||||
device.Api.CreateCommandPool(_device.InternalHandle, commandPoolCreateInfo, null, out _commandPool)
|
||||
.ThrowOnError();
|
||||
}
|
||||
|
||||
private CommandBuffer AllocateCommandBuffer()
|
||||
{
|
||||
var commandBufferAllocateInfo = new CommandBufferAllocateInfo
|
||||
{
|
||||
SType = StructureType.CommandBufferAllocateInfo,
|
||||
CommandPool = _commandPool,
|
||||
CommandBufferCount = 1,
|
||||
Level = CommandBufferLevel.Primary
|
||||
};
|
||||
|
||||
_device.Api.AllocateCommandBuffers(_device.InternalHandle, commandBufferAllocateInfo, out var commandBuffer);
|
||||
|
||||
return commandBuffer;
|
||||
}
|
||||
|
||||
public VulkanCommandBuffer CreateCommandBuffer()
|
||||
{
|
||||
return new(_device, this);
|
||||
}
|
||||
|
||||
public void FreeUsedCommandBuffers()
|
||||
{
|
||||
lock (_usedCommandBuffers)
|
||||
{
|
||||
foreach (var usedCommandBuffer in _usedCommandBuffers)
|
||||
{
|
||||
usedCommandBuffer.Dispose();
|
||||
}
|
||||
|
||||
_usedCommandBuffers.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
private void DisposeCommandBuffer(VulkanCommandBuffer commandBuffer)
|
||||
{
|
||||
lock (_usedCommandBuffers)
|
||||
{
|
||||
_usedCommandBuffers.Add(commandBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
FreeUsedCommandBuffers();
|
||||
_device.Api.DestroyCommandPool(_device.InternalHandle, _commandPool, Span<AllocationCallbacks>.Empty);
|
||||
}
|
||||
|
||||
public class VulkanCommandBuffer : IDisposable
|
||||
{
|
||||
private readonly VulkanCommandBufferPool _commandBufferPool;
|
||||
private readonly VulkanDevice _device;
|
||||
private readonly Fence _fence;
|
||||
private bool _hasEnded;
|
||||
private bool _hasStarted;
|
||||
|
||||
public IntPtr Handle => InternalHandle.Handle;
|
||||
|
||||
internal CommandBuffer InternalHandle { get; }
|
||||
|
||||
internal unsafe VulkanCommandBuffer(VulkanDevice device, VulkanCommandBufferPool commandBufferPool)
|
||||
{
|
||||
_device = device;
|
||||
_commandBufferPool = commandBufferPool;
|
||||
|
||||
InternalHandle = _commandBufferPool.AllocateCommandBuffer();
|
||||
|
||||
var fenceCreateInfo = new FenceCreateInfo()
|
||||
{
|
||||
SType = StructureType.FenceCreateInfo,
|
||||
Flags = FenceCreateFlags.FenceCreateSignaledBit
|
||||
};
|
||||
|
||||
device.Api.CreateFence(device.InternalHandle, fenceCreateInfo, null, out _fence);
|
||||
}
|
||||
|
||||
public void BeginRecording()
|
||||
{
|
||||
if (!_hasStarted)
|
||||
{
|
||||
_hasStarted = true;
|
||||
|
||||
var beginInfo = new CommandBufferBeginInfo
|
||||
{
|
||||
SType = StructureType.CommandBufferBeginInfo,
|
||||
Flags = CommandBufferUsageFlags.CommandBufferUsageOneTimeSubmitBit
|
||||
};
|
||||
|
||||
_device.Api.BeginCommandBuffer(InternalHandle, beginInfo);
|
||||
}
|
||||
}
|
||||
|
||||
public void EndRecording()
|
||||
{
|
||||
if (_hasStarted && !_hasEnded)
|
||||
{
|
||||
_hasEnded = true;
|
||||
|
||||
_device.Api.EndCommandBuffer(InternalHandle);
|
||||
}
|
||||
}
|
||||
|
||||
public void Submit()
|
||||
{
|
||||
Submit(null, null, null, _fence);
|
||||
}
|
||||
|
||||
public unsafe void Submit(
|
||||
ReadOnlySpan<Semaphore> waitSemaphores,
|
||||
ReadOnlySpan<PipelineStageFlags> waitDstStageMask,
|
||||
ReadOnlySpan<Semaphore> signalSemaphores,
|
||||
Fence? fence = null)
|
||||
{
|
||||
EndRecording();
|
||||
|
||||
if (!fence.HasValue)
|
||||
{
|
||||
fence = _fence;
|
||||
}
|
||||
|
||||
fixed (Semaphore* pWaitSemaphores = waitSemaphores, pSignalSemaphores = signalSemaphores)
|
||||
{
|
||||
fixed (PipelineStageFlags* pWaitDstStageMask = waitDstStageMask)
|
||||
{
|
||||
var commandBuffer = InternalHandle;
|
||||
var submitInfo = new SubmitInfo
|
||||
{
|
||||
SType = StructureType.SubmitInfo,
|
||||
WaitSemaphoreCount = waitSemaphores != null ? (uint)waitSemaphores.Length : 0,
|
||||
PWaitSemaphores = pWaitSemaphores,
|
||||
PWaitDstStageMask = pWaitDstStageMask,
|
||||
CommandBufferCount = 1,
|
||||
PCommandBuffers = &commandBuffer,
|
||||
SignalSemaphoreCount = signalSemaphores != null ? (uint)signalSemaphores.Length : 0,
|
||||
PSignalSemaphores = pSignalSemaphores,
|
||||
};
|
||||
|
||||
_device.Api.ResetFences(_device.InternalHandle, 1, fence.Value);
|
||||
|
||||
_device.Submit(submitInfo, fence.Value);
|
||||
}
|
||||
}
|
||||
|
||||
_commandBufferPool.DisposeCommandBuffer(this);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_device.Api.WaitForFences(_device.InternalHandle, 1, _fence, true, ulong.MaxValue);
|
||||
_device.Api.FreeCommandBuffers(_device.InternalHandle, _commandBufferPool._commandPool, 1, InternalHandle);
|
||||
_device.Api.DestroyFence(_device.InternalHandle, _fence, Span<AllocationCallbacks>.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
67
Ryujinx.Ava/Ui/Backend/Vulkan/VulkanDevice.cs
Normal file
67
Ryujinx.Ava/Ui/Backend/Vulkan/VulkanDevice.cs
Normal file
@ -0,0 +1,67 @@
|
||||
using System;
|
||||
using Silk.NET.Vulkan;
|
||||
|
||||
namespace Ryujinx.Ava.Ui.Vulkan
|
||||
{
|
||||
internal class VulkanDevice : IDisposable
|
||||
{
|
||||
private static object _lock = new object();
|
||||
|
||||
public VulkanDevice(Device apiHandle, VulkanPhysicalDevice physicalDevice, Vk api)
|
||||
{
|
||||
InternalHandle = apiHandle;
|
||||
Api = api;
|
||||
|
||||
api.GetDeviceQueue(apiHandle, physicalDevice.QueueFamilyIndex, 0, out var queue);
|
||||
|
||||
var vulkanQueue = new VulkanQueue(this, queue);
|
||||
Queue = vulkanQueue;
|
||||
|
||||
PresentQueue = vulkanQueue;
|
||||
|
||||
CommandBufferPool = new VulkanCommandBufferPool(this, physicalDevice);
|
||||
}
|
||||
|
||||
public IntPtr Handle => InternalHandle.Handle;
|
||||
|
||||
internal Device InternalHandle { get; }
|
||||
public Vk Api { get; }
|
||||
|
||||
public VulkanQueue Queue { get; private set; }
|
||||
public VulkanQueue PresentQueue { get; }
|
||||
public VulkanCommandBufferPool CommandBufferPool { get; }
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
WaitIdle();
|
||||
CommandBufferPool?.Dispose();
|
||||
Queue = null;
|
||||
}
|
||||
|
||||
internal void Submit(SubmitInfo submitInfo, Fence fence = default)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
Api.QueueSubmit(Queue.InternalHandle, 1, submitInfo, fence).ThrowOnError();
|
||||
}
|
||||
}
|
||||
|
||||
public void WaitIdle()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
Api.DeviceWaitIdle(InternalHandle);
|
||||
}
|
||||
}
|
||||
|
||||
public void QueueWaitIdle()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
Api.QueueWaitIdle(Queue.InternalHandle);
|
||||
}
|
||||
}
|
||||
|
||||
public object Lock => _lock;
|
||||
}
|
||||
}
|
439
Ryujinx.Ava/Ui/Backend/Vulkan/VulkanDisplay.cs
Normal file
439
Ryujinx.Ava/Ui/Backend/Vulkan/VulkanDisplay.cs
Normal file
@ -0,0 +1,439 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using Avalonia;
|
||||
using Ryujinx.Ava.Ui.Vulkan.Surfaces;
|
||||
using Ryujinx.Ui.Common.Configuration;
|
||||
using Silk.NET.Vulkan;
|
||||
using Silk.NET.Vulkan.Extensions.KHR;
|
||||
|
||||
namespace Ryujinx.Ava.Ui.Vulkan
|
||||
{
|
||||
internal class VulkanDisplay : IDisposable
|
||||
{
|
||||
private static KhrSwapchain _swapchainExtension;
|
||||
private readonly VulkanInstance _instance;
|
||||
private readonly VulkanPhysicalDevice _physicalDevice;
|
||||
private readonly VulkanSemaphorePair _semaphorePair;
|
||||
private uint _nextImage;
|
||||
private readonly VulkanSurface _surface;
|
||||
private SurfaceFormatKHR _surfaceFormat;
|
||||
private SwapchainKHR _swapchain;
|
||||
private Extent2D _swapchainExtent;
|
||||
private Image[] _swapchainImages;
|
||||
private VulkanDevice _device { get; }
|
||||
private ImageView[] _swapchainImageViews = new ImageView[0];
|
||||
private bool _vsyncStateChanged;
|
||||
private bool _vsyncEnabled;
|
||||
|
||||
public VulkanCommandBufferPool CommandBufferPool { get; set; }
|
||||
|
||||
public object Lock => _device.Lock;
|
||||
|
||||
private VulkanDisplay(VulkanInstance instance, VulkanDevice device,
|
||||
VulkanPhysicalDevice physicalDevice, VulkanSurface surface, SwapchainKHR swapchain,
|
||||
Extent2D swapchainExtent)
|
||||
{
|
||||
_instance = instance;
|
||||
_device = device;
|
||||
_physicalDevice = physicalDevice;
|
||||
_swapchain = swapchain;
|
||||
_swapchainExtent = swapchainExtent;
|
||||
_surface = surface;
|
||||
|
||||
CreateSwapchainImages();
|
||||
|
||||
_semaphorePair = new VulkanSemaphorePair(_device);
|
||||
|
||||
CommandBufferPool = new VulkanCommandBufferPool(device, physicalDevice);
|
||||
}
|
||||
|
||||
public PixelSize Size { get; private set; }
|
||||
public uint QueueFamilyIndex => _physicalDevice.QueueFamilyIndex;
|
||||
|
||||
internal SurfaceFormatKHR SurfaceFormat
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_surfaceFormat.Format == Format.Undefined)
|
||||
{
|
||||
_surfaceFormat = _surface.GetSurfaceFormat(_physicalDevice);
|
||||
}
|
||||
|
||||
return _surfaceFormat;
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_device.WaitIdle();
|
||||
_semaphorePair?.Dispose();
|
||||
DestroyCurrentImageViews();
|
||||
_swapchainExtension.DestroySwapchain(_device.InternalHandle, _swapchain, Span<AllocationCallbacks>.Empty);
|
||||
CommandBufferPool.Dispose();
|
||||
}
|
||||
|
||||
private static unsafe SwapchainKHR CreateSwapchain(VulkanInstance instance, VulkanDevice device,
|
||||
VulkanPhysicalDevice physicalDevice, VulkanSurface surface, out Extent2D swapchainExtent,
|
||||
SwapchainKHR? oldswapchain = null, bool vsyncEnabled = true)
|
||||
{
|
||||
if (_swapchainExtension == null)
|
||||
{
|
||||
instance.Api.TryGetDeviceExtension(instance.InternalHandle, device.InternalHandle, out _swapchainExtension);
|
||||
}
|
||||
|
||||
while (!surface.CanSurfacePresent(physicalDevice))
|
||||
{
|
||||
Thread.Sleep(16);
|
||||
}
|
||||
|
||||
VulkanSurface.SurfaceExtension.GetPhysicalDeviceSurfaceCapabilities(physicalDevice.InternalHandle,
|
||||
surface.ApiHandle, out var capabilities);
|
||||
|
||||
var imageCount = capabilities.MinImageCount + 1;
|
||||
if (capabilities.MaxImageCount > 0 && imageCount > capabilities.MaxImageCount)
|
||||
{
|
||||
imageCount = capabilities.MaxImageCount;
|
||||
}
|
||||
|
||||
var surfaceFormat = surface.GetSurfaceFormat(physicalDevice);
|
||||
|
||||
bool supportsIdentityTransform = capabilities.SupportedTransforms.HasFlag(SurfaceTransformFlagsKHR.SurfaceTransformIdentityBitKhr);
|
||||
bool isRotated = capabilities.CurrentTransform.HasFlag(SurfaceTransformFlagsKHR.SurfaceTransformRotate90BitKhr) ||
|
||||
capabilities.CurrentTransform.HasFlag(SurfaceTransformFlagsKHR.SurfaceTransformRotate270BitKhr);
|
||||
|
||||
swapchainExtent = GetSwapchainExtent(surface, capabilities);
|
||||
|
||||
CompositeAlphaFlagsKHR compositeAlphaFlags = GetSuitableCompositeAlphaFlags(capabilities);
|
||||
|
||||
PresentModeKHR presentMode = GetSuitablePresentMode(physicalDevice, surface, vsyncEnabled);
|
||||
|
||||
var swapchainCreateInfo = new SwapchainCreateInfoKHR
|
||||
{
|
||||
SType = StructureType.SwapchainCreateInfoKhr,
|
||||
Surface = surface.ApiHandle,
|
||||
MinImageCount = imageCount,
|
||||
ImageFormat = surfaceFormat.Format,
|
||||
ImageColorSpace = surfaceFormat.ColorSpace,
|
||||
ImageExtent = swapchainExtent,
|
||||
ImageUsage =
|
||||
ImageUsageFlags.ImageUsageColorAttachmentBit | ImageUsageFlags.ImageUsageTransferDstBit,
|
||||
ImageSharingMode = SharingMode.Exclusive,
|
||||
ImageArrayLayers = 1,
|
||||
PreTransform = supportsIdentityTransform && isRotated ?
|
||||
SurfaceTransformFlagsKHR.SurfaceTransformIdentityBitKhr :
|
||||
capabilities.CurrentTransform,
|
||||
CompositeAlpha = compositeAlphaFlags,
|
||||
PresentMode = presentMode,
|
||||
Clipped = true,
|
||||
OldSwapchain = oldswapchain ?? new SwapchainKHR()
|
||||
};
|
||||
|
||||
_swapchainExtension.CreateSwapchain(device.InternalHandle, swapchainCreateInfo, null, out var swapchain)
|
||||
.ThrowOnError();
|
||||
|
||||
if (oldswapchain != null)
|
||||
{
|
||||
_swapchainExtension.DestroySwapchain(device.InternalHandle, oldswapchain.Value, null);
|
||||
}
|
||||
|
||||
return swapchain;
|
||||
}
|
||||
|
||||
private static unsafe Extent2D GetSwapchainExtent(VulkanSurface surface, SurfaceCapabilitiesKHR capabilities)
|
||||
{
|
||||
Extent2D swapchainExtent;
|
||||
if (capabilities.CurrentExtent.Width != uint.MaxValue)
|
||||
{
|
||||
swapchainExtent = capabilities.CurrentExtent;
|
||||
}
|
||||
else
|
||||
{
|
||||
var surfaceSize = surface.SurfaceSize;
|
||||
|
||||
var width = Math.Clamp((uint)surfaceSize.Width, capabilities.MinImageExtent.Width, capabilities.MaxImageExtent.Width);
|
||||
var height = Math.Clamp((uint)surfaceSize.Height, capabilities.MinImageExtent.Height, capabilities.MaxImageExtent.Height);
|
||||
|
||||
swapchainExtent = new Extent2D(width, height);
|
||||
}
|
||||
|
||||
return swapchainExtent;
|
||||
}
|
||||
|
||||
private static unsafe CompositeAlphaFlagsKHR GetSuitableCompositeAlphaFlags(SurfaceCapabilitiesKHR capabilities)
|
||||
{
|
||||
var compositeAlphaFlags = CompositeAlphaFlagsKHR.CompositeAlphaOpaqueBitKhr;
|
||||
|
||||
if (capabilities.SupportedCompositeAlpha.HasFlag(CompositeAlphaFlagsKHR.CompositeAlphaPostMultipliedBitKhr))
|
||||
{
|
||||
compositeAlphaFlags = CompositeAlphaFlagsKHR.CompositeAlphaPostMultipliedBitKhr;
|
||||
}
|
||||
else if (capabilities.SupportedCompositeAlpha.HasFlag(CompositeAlphaFlagsKHR.CompositeAlphaPreMultipliedBitKhr))
|
||||
{
|
||||
compositeAlphaFlags = CompositeAlphaFlagsKHR.CompositeAlphaPreMultipliedBitKhr;
|
||||
}
|
||||
|
||||
return compositeAlphaFlags;
|
||||
}
|
||||
|
||||
private static unsafe PresentModeKHR GetSuitablePresentMode(VulkanPhysicalDevice physicalDevice, VulkanSurface surface, bool vsyncEnabled)
|
||||
{
|
||||
uint presentModesCount;
|
||||
|
||||
VulkanSurface.SurfaceExtension.GetPhysicalDeviceSurfacePresentModes(physicalDevice.InternalHandle,
|
||||
surface.ApiHandle,
|
||||
&presentModesCount, null);
|
||||
|
||||
var presentModes = new PresentModeKHR[presentModesCount];
|
||||
|
||||
fixed (PresentModeKHR* pPresentModes = presentModes)
|
||||
{
|
||||
VulkanSurface.SurfaceExtension.GetPhysicalDeviceSurfacePresentModes(physicalDevice.InternalHandle,
|
||||
surface.ApiHandle, &presentModesCount, pPresentModes);
|
||||
}
|
||||
|
||||
var modes = presentModes.ToList();
|
||||
var presentMode = PresentModeKHR.PresentModeFifoKhr;
|
||||
|
||||
if (!vsyncEnabled && modes.Contains(PresentModeKHR.PresentModeImmediateKhr))
|
||||
{
|
||||
presentMode = PresentModeKHR.PresentModeImmediateKhr;
|
||||
}
|
||||
else if (modes.Contains(PresentModeKHR.PresentModeMailboxKhr))
|
||||
{
|
||||
presentMode = PresentModeKHR.PresentModeMailboxKhr;
|
||||
}
|
||||
else if (modes.Contains(PresentModeKHR.PresentModeImmediateKhr))
|
||||
{
|
||||
presentMode = PresentModeKHR.PresentModeImmediateKhr;
|
||||
}
|
||||
|
||||
return presentMode;
|
||||
}
|
||||
|
||||
internal static VulkanDisplay CreateDisplay(VulkanInstance instance, VulkanDevice device,
|
||||
VulkanPhysicalDevice physicalDevice, VulkanSurface surface)
|
||||
{
|
||||
var swapchain = CreateSwapchain(instance, device, physicalDevice, surface, out var extent, null, true);
|
||||
|
||||
return new VulkanDisplay(instance, device, physicalDevice, surface, swapchain, extent);
|
||||
}
|
||||
|
||||
private unsafe void CreateSwapchainImages()
|
||||
{
|
||||
DestroyCurrentImageViews();
|
||||
|
||||
Size = new PixelSize((int)_swapchainExtent.Width, (int)_swapchainExtent.Height);
|
||||
|
||||
uint imageCount = 0;
|
||||
|
||||
_swapchainExtension.GetSwapchainImages(_device.InternalHandle, _swapchain, &imageCount, null);
|
||||
|
||||
_swapchainImages = new Image[imageCount];
|
||||
|
||||
fixed (Image* pSwapchainImages = _swapchainImages)
|
||||
{
|
||||
_swapchainExtension.GetSwapchainImages(_device.InternalHandle, _swapchain, &imageCount, pSwapchainImages);
|
||||
}
|
||||
|
||||
_swapchainImageViews = new ImageView[imageCount];
|
||||
|
||||
var surfaceFormat = SurfaceFormat;
|
||||
|
||||
for (var i = 0; i < imageCount; i++)
|
||||
{
|
||||
_swapchainImageViews[i] = CreateSwapchainImageView(_swapchainImages[i], surfaceFormat.Format);
|
||||
}
|
||||
}
|
||||
|
||||
private void DestroyCurrentImageViews()
|
||||
{
|
||||
for (var i = 0; i < _swapchainImageViews.Length; i++)
|
||||
{
|
||||
_instance.Api.DestroyImageView(_device.InternalHandle, _swapchainImageViews[i], Span<AllocationCallbacks>.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
internal void ChangeVSyncMode(bool vsyncEnabled)
|
||||
{
|
||||
_vsyncStateChanged = true;
|
||||
_vsyncEnabled = vsyncEnabled;
|
||||
}
|
||||
|
||||
private void Recreate()
|
||||
{
|
||||
_device.WaitIdle();
|
||||
_swapchain = CreateSwapchain(_instance, _device, _physicalDevice, _surface, out _swapchainExtent, _swapchain, _vsyncEnabled);
|
||||
|
||||
CreateSwapchainImages();
|
||||
}
|
||||
|
||||
private unsafe ImageView CreateSwapchainImageView(Image swapchainImage, Format format)
|
||||
{
|
||||
var componentMapping = new ComponentMapping(
|
||||
ComponentSwizzle.Identity,
|
||||
ComponentSwizzle.Identity,
|
||||
ComponentSwizzle.Identity,
|
||||
ComponentSwizzle.Identity);
|
||||
|
||||
var subresourceRange = new ImageSubresourceRange(ImageAspectFlags.ImageAspectColorBit, 0, 1, 0, 1);
|
||||
|
||||
var imageCreateInfo = new ImageViewCreateInfo
|
||||
{
|
||||
SType = StructureType.ImageViewCreateInfo,
|
||||
Image = swapchainImage,
|
||||
ViewType = ImageViewType.ImageViewType2D,
|
||||
Format = format,
|
||||
Components = componentMapping,
|
||||
SubresourceRange = subresourceRange
|
||||
};
|
||||
|
||||
_instance.Api.CreateImageView(_device.InternalHandle, imageCreateInfo, null, out var imageView).ThrowOnError();
|
||||
return imageView;
|
||||
}
|
||||
|
||||
public bool EnsureSwapchainAvailable()
|
||||
{
|
||||
if (Size != _surface.SurfaceSize || _vsyncStateChanged)
|
||||
{
|
||||
_vsyncStateChanged = false;
|
||||
|
||||
Recreate();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
internal VulkanCommandBufferPool.VulkanCommandBuffer StartPresentation(VulkanSurfaceRenderTarget renderTarget)
|
||||
{
|
||||
_nextImage = 0;
|
||||
while (true)
|
||||
{
|
||||
var acquireResult = _swapchainExtension.AcquireNextImage(
|
||||
_device.InternalHandle,
|
||||
_swapchain,
|
||||
ulong.MaxValue,
|
||||
_semaphorePair.ImageAvailableSemaphore,
|
||||
new Fence(),
|
||||
ref _nextImage);
|
||||
|
||||
if (acquireResult == Result.ErrorOutOfDateKhr ||
|
||||
acquireResult == Result.SuboptimalKhr)
|
||||
{
|
||||
Recreate();
|
||||
}
|
||||
else
|
||||
{
|
||||
acquireResult.ThrowOnError();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var commandBuffer = CommandBufferPool.CreateCommandBuffer();
|
||||
commandBuffer.BeginRecording();
|
||||
|
||||
VulkanMemoryHelper.TransitionLayout(_device, commandBuffer.InternalHandle,
|
||||
_swapchainImages[_nextImage], ImageLayout.Undefined,
|
||||
AccessFlags.AccessNoneKhr,
|
||||
ImageLayout.TransferDstOptimal,
|
||||
AccessFlags.AccessTransferWriteBit,
|
||||
1);
|
||||
|
||||
return commandBuffer;
|
||||
}
|
||||
|
||||
internal void BlitImageToCurrentImage(VulkanSurfaceRenderTarget renderTarget, CommandBuffer commandBuffer)
|
||||
{
|
||||
VulkanMemoryHelper.TransitionLayout(_device, commandBuffer,
|
||||
renderTarget.Image.InternalHandle.Value, (ImageLayout)renderTarget.Image.CurrentLayout,
|
||||
AccessFlags.AccessNoneKhr,
|
||||
ImageLayout.TransferSrcOptimal,
|
||||
AccessFlags.AccessTransferReadBit,
|
||||
renderTarget.MipLevels);
|
||||
|
||||
var srcBlitRegion = new ImageBlit
|
||||
{
|
||||
SrcOffsets = new ImageBlit.SrcOffsetsBuffer
|
||||
{
|
||||
Element0 = new Offset3D(0, 0, 0),
|
||||
Element1 = new Offset3D(renderTarget.Size.Width, renderTarget.Size.Height, 1),
|
||||
},
|
||||
DstOffsets = new ImageBlit.DstOffsetsBuffer
|
||||
{
|
||||
Element0 = new Offset3D(0, 0, 0),
|
||||
Element1 = new Offset3D(Size.Width, Size.Height, 1),
|
||||
},
|
||||
SrcSubresource = new ImageSubresourceLayers
|
||||
{
|
||||
AspectMask = ImageAspectFlags.ImageAspectColorBit,
|
||||
BaseArrayLayer = 0,
|
||||
LayerCount = 1,
|
||||
MipLevel = 0
|
||||
},
|
||||
DstSubresource = new ImageSubresourceLayers
|
||||
{
|
||||
AspectMask = ImageAspectFlags.ImageAspectColorBit,
|
||||
BaseArrayLayer = 0,
|
||||
LayerCount = 1,
|
||||
MipLevel = 0
|
||||
}
|
||||
};
|
||||
|
||||
_device.Api.CmdBlitImage(commandBuffer, renderTarget.Image.InternalHandle.Value,
|
||||
ImageLayout.TransferSrcOptimal,
|
||||
_swapchainImages[_nextImage],
|
||||
ImageLayout.TransferDstOptimal,
|
||||
1,
|
||||
srcBlitRegion,
|
||||
Filter.Linear);
|
||||
|
||||
VulkanMemoryHelper.TransitionLayout(_device, commandBuffer,
|
||||
renderTarget.Image.InternalHandle.Value, ImageLayout.TransferSrcOptimal,
|
||||
AccessFlags.AccessTransferReadBit,
|
||||
(ImageLayout)renderTarget.Image.CurrentLayout,
|
||||
AccessFlags.AccessNoneKhr,
|
||||
renderTarget.MipLevels);
|
||||
}
|
||||
|
||||
internal unsafe void EndPresentation(VulkanCommandBufferPool.VulkanCommandBuffer commandBuffer)
|
||||
{
|
||||
VulkanMemoryHelper.TransitionLayout(_device, commandBuffer.InternalHandle,
|
||||
_swapchainImages[_nextImage], ImageLayout.TransferDstOptimal,
|
||||
AccessFlags.AccessNoneKhr,
|
||||
ImageLayout.PresentSrcKhr,
|
||||
AccessFlags.AccessNoneKhr,
|
||||
1);
|
||||
|
||||
commandBuffer.Submit(
|
||||
stackalloc[] { _semaphorePair.ImageAvailableSemaphore },
|
||||
stackalloc[] { PipelineStageFlags.PipelineStageColorAttachmentOutputBit },
|
||||
stackalloc[] { _semaphorePair.RenderFinishedSemaphore });
|
||||
|
||||
var semaphore = _semaphorePair.RenderFinishedSemaphore;
|
||||
var swapchain = _swapchain;
|
||||
var nextImage = _nextImage;
|
||||
|
||||
Result result;
|
||||
|
||||
var presentInfo = new PresentInfoKHR
|
||||
{
|
||||
SType = StructureType.PresentInfoKhr,
|
||||
WaitSemaphoreCount = 1,
|
||||
PWaitSemaphores = &semaphore,
|
||||
SwapchainCount = 1,
|
||||
PSwapchains = &swapchain,
|
||||
PImageIndices = &nextImage,
|
||||
PResults = &result
|
||||
};
|
||||
|
||||
lock (_device.Lock)
|
||||
{
|
||||
_swapchainExtension.QueuePresent(_device.PresentQueue.InternalHandle, presentInfo);
|
||||
}
|
||||
|
||||
CommandBufferPool.FreeUsedCommandBuffers();
|
||||
}
|
||||
}
|
||||
}
|
167
Ryujinx.Ava/Ui/Backend/Vulkan/VulkanImage.cs
Normal file
167
Ryujinx.Ava/Ui/Backend/Vulkan/VulkanImage.cs
Normal file
@ -0,0 +1,167 @@
|
||||
using System;
|
||||
using Avalonia;
|
||||
using Silk.NET.Vulkan;
|
||||
|
||||
namespace Ryujinx.Ava.Ui.Vulkan
|
||||
{
|
||||
internal class VulkanImage : IDisposable
|
||||
{
|
||||
private readonly VulkanDevice _device;
|
||||
private readonly VulkanPhysicalDevice _physicalDevice;
|
||||
private readonly VulkanCommandBufferPool _commandBufferPool;
|
||||
private ImageLayout _currentLayout;
|
||||
private AccessFlags _currentAccessFlags;
|
||||
private ImageUsageFlags _imageUsageFlags { get; }
|
||||
private ImageView? _imageView { get; set; }
|
||||
private DeviceMemory _imageMemory { get; set; }
|
||||
|
||||
internal Image? InternalHandle { get; private set; }
|
||||
internal Format Format { get; }
|
||||
internal ImageAspectFlags AspectFlags { get; private set; }
|
||||
|
||||
public ulong Handle => InternalHandle?.Handle ?? 0;
|
||||
public ulong ViewHandle => _imageView?.Handle ?? 0;
|
||||
public uint UsageFlags => (uint)_imageUsageFlags;
|
||||
public ulong MemoryHandle => _imageMemory.Handle;
|
||||
public uint MipLevels { get; private set; }
|
||||
public PixelSize Size { get; }
|
||||
public ulong MemorySize { get; private set; }
|
||||
public uint CurrentLayout => (uint)_currentLayout;
|
||||
|
||||
public VulkanImage(
|
||||
VulkanDevice device,
|
||||
VulkanPhysicalDevice physicalDevice,
|
||||
VulkanCommandBufferPool commandBufferPool,
|
||||
uint format,
|
||||
PixelSize size,
|
||||
uint mipLevels = 0)
|
||||
{
|
||||
_device = device;
|
||||
_physicalDevice = physicalDevice;
|
||||
_commandBufferPool = commandBufferPool;
|
||||
Format = (Format)format;
|
||||
Size = size;
|
||||
MipLevels = mipLevels;
|
||||
_imageUsageFlags =
|
||||
ImageUsageFlags.ImageUsageColorAttachmentBit | ImageUsageFlags.ImageUsageTransferDstBit |
|
||||
ImageUsageFlags.ImageUsageTransferSrcBit | ImageUsageFlags.ImageUsageSampledBit;
|
||||
|
||||
Initialize();
|
||||
}
|
||||
|
||||
public unsafe void Initialize()
|
||||
{
|
||||
if (!InternalHandle.HasValue)
|
||||
{
|
||||
MipLevels = MipLevels != 0 ? MipLevels : (uint)Math.Floor(Math.Log(Math.Max(Size.Width, Size.Height), 2));
|
||||
|
||||
var imageCreateInfo = new ImageCreateInfo
|
||||
{
|
||||
SType = StructureType.ImageCreateInfo,
|
||||
ImageType = ImageType.ImageType2D,
|
||||
Format = Format,
|
||||
Extent = new Extent3D((uint?)Size.Width, (uint?)Size.Height, 1),
|
||||
MipLevels = MipLevels,
|
||||
ArrayLayers = 1,
|
||||
Samples = SampleCountFlags.SampleCount1Bit,
|
||||
Tiling = Tiling,
|
||||
Usage = _imageUsageFlags,
|
||||
SharingMode = SharingMode.Exclusive,
|
||||
InitialLayout = ImageLayout.Undefined,
|
||||
Flags = ImageCreateFlags.ImageCreateMutableFormatBit
|
||||
};
|
||||
|
||||
_device.Api.CreateImage(_device.InternalHandle, imageCreateInfo, null, out var image).ThrowOnError();
|
||||
InternalHandle = image;
|
||||
|
||||
_device.Api.GetImageMemoryRequirements(_device.InternalHandle, InternalHandle.Value,
|
||||
out var memoryRequirements);
|
||||
|
||||
var memoryAllocateInfo = new MemoryAllocateInfo
|
||||
{
|
||||
SType = StructureType.MemoryAllocateInfo,
|
||||
AllocationSize = memoryRequirements.Size,
|
||||
MemoryTypeIndex = (uint)VulkanMemoryHelper.FindSuitableMemoryTypeIndex(
|
||||
_physicalDevice,
|
||||
memoryRequirements.MemoryTypeBits, MemoryPropertyFlags.MemoryPropertyDeviceLocalBit)
|
||||
};
|
||||
|
||||
_device.Api.AllocateMemory(_device.InternalHandle, memoryAllocateInfo, null,
|
||||
out var imageMemory);
|
||||
|
||||
_imageMemory = imageMemory;
|
||||
|
||||
_device.Api.BindImageMemory(_device.InternalHandle, InternalHandle.Value, _imageMemory, 0);
|
||||
|
||||
MemorySize = memoryRequirements.Size;
|
||||
|
||||
var componentMapping = new ComponentMapping(
|
||||
ComponentSwizzle.Identity,
|
||||
ComponentSwizzle.Identity,
|
||||
ComponentSwizzle.Identity,
|
||||
ComponentSwizzle.Identity);
|
||||
|
||||
AspectFlags = ImageAspectFlags.ImageAspectColorBit;
|
||||
|
||||
var subresourceRange = new ImageSubresourceRange(AspectFlags, 0, MipLevels, 0, 1);
|
||||
|
||||
var imageViewCreateInfo = new ImageViewCreateInfo
|
||||
{
|
||||
SType = StructureType.ImageViewCreateInfo,
|
||||
Image = InternalHandle.Value,
|
||||
ViewType = ImageViewType.ImageViewType2D,
|
||||
Format = Format,
|
||||
Components = componentMapping,
|
||||
SubresourceRange = subresourceRange
|
||||
};
|
||||
|
||||
_device.Api
|
||||
.CreateImageView(_device.InternalHandle, imageViewCreateInfo, null, out var imageView)
|
||||
.ThrowOnError();
|
||||
|
||||
_imageView = imageView;
|
||||
|
||||
_currentLayout = ImageLayout.Undefined;
|
||||
|
||||
TransitionLayout(ImageLayout.ColorAttachmentOptimal, AccessFlags.AccessNoneKhr);
|
||||
}
|
||||
}
|
||||
|
||||
public ImageTiling Tiling => ImageTiling.Optimal;
|
||||
|
||||
internal void TransitionLayout(ImageLayout destinationLayout, AccessFlags destinationAccessFlags)
|
||||
{
|
||||
var commandBuffer = _commandBufferPool.CreateCommandBuffer();
|
||||
commandBuffer.BeginRecording();
|
||||
|
||||
VulkanMemoryHelper.TransitionLayout(_device, commandBuffer.InternalHandle, InternalHandle.Value,
|
||||
_currentLayout,
|
||||
_currentAccessFlags,
|
||||
destinationLayout, destinationAccessFlags,
|
||||
MipLevels);
|
||||
|
||||
commandBuffer.EndRecording();
|
||||
|
||||
commandBuffer.Submit();
|
||||
|
||||
_currentLayout = destinationLayout;
|
||||
_currentAccessFlags = destinationAccessFlags;
|
||||
}
|
||||
|
||||
public void TransitionLayout(uint destinationLayout, uint destinationAccessFlags)
|
||||
{
|
||||
TransitionLayout((ImageLayout)destinationLayout, (AccessFlags)destinationAccessFlags);
|
||||
}
|
||||
|
||||
public unsafe void Dispose()
|
||||
{
|
||||
_device.Api.DestroyImageView(_device.InternalHandle, _imageView.Value, null);
|
||||
_device.Api.DestroyImage(_device.InternalHandle, InternalHandle.Value, null);
|
||||
_device.Api.FreeMemory(_device.InternalHandle, _imageMemory, null);
|
||||
|
||||
_imageView = default;
|
||||
InternalHandle = default;
|
||||
_imageMemory = default;
|
||||
}
|
||||
}
|
||||
}
|
136
Ryujinx.Ava/Ui/Backend/Vulkan/VulkanInstance.cs
Normal file
136
Ryujinx.Ava/Ui/Backend/Vulkan/VulkanInstance.cs
Normal file
@ -0,0 +1,136 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using Silk.NET.Core;
|
||||
using Silk.NET.Vulkan;
|
||||
using Silk.NET.Vulkan.Extensions.EXT;
|
||||
|
||||
namespace Ryujinx.Ava.Ui.Vulkan
|
||||
{
|
||||
public class VulkanInstance : IDisposable
|
||||
{
|
||||
private const string EngineName = "Avalonia Vulkan";
|
||||
|
||||
private VulkanInstance(Instance apiHandle, Vk api)
|
||||
{
|
||||
InternalHandle = apiHandle;
|
||||
Api = api;
|
||||
}
|
||||
|
||||
public IntPtr Handle => InternalHandle.Handle;
|
||||
|
||||
internal Instance InternalHandle { get; }
|
||||
public Vk Api { get; }
|
||||
|
||||
internal static IEnumerable<string> RequiredInstanceExtensions
|
||||
{
|
||||
get
|
||||
{
|
||||
yield return "VK_KHR_surface";
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||
{
|
||||
yield return "VK_KHR_xlib_surface";
|
||||
}
|
||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
yield return "VK_KHR_win32_surface";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Api?.DestroyInstance(InternalHandle, Span<AllocationCallbacks>.Empty);
|
||||
Api?.Dispose();
|
||||
}
|
||||
|
||||
internal static unsafe VulkanInstance Create(VulkanOptions options)
|
||||
{
|
||||
var api = Vk.GetApi();
|
||||
var applicationName = Marshal.StringToHGlobalAnsi(options.ApplicationName);
|
||||
var engineName = Marshal.StringToHGlobalAnsi(EngineName);
|
||||
var enabledExtensions = new List<string>(options.InstanceExtensions);
|
||||
|
||||
enabledExtensions.AddRange(RequiredInstanceExtensions);
|
||||
|
||||
var applicationInfo = new ApplicationInfo
|
||||
{
|
||||
PApplicationName = (byte*)applicationName,
|
||||
ApiVersion = new Version32((uint)options.VulkanVersion.Major, (uint)options.VulkanVersion.Minor,
|
||||
(uint)options.VulkanVersion.Build),
|
||||
PEngineName = (byte*)engineName,
|
||||
EngineVersion = new Version32(1, 0, 0),
|
||||
ApplicationVersion = new Version32(1, 0, 0)
|
||||
};
|
||||
|
||||
var enabledLayers = new HashSet<string>();
|
||||
|
||||
if (options.UseDebug)
|
||||
{
|
||||
enabledExtensions.Add(ExtDebugUtils.ExtensionName);
|
||||
enabledExtensions.Add(ExtDebugReport.ExtensionName);
|
||||
if (IsLayerAvailable(api, "VK_LAYER_KHRONOS_validation"))
|
||||
enabledLayers.Add("VK_LAYER_KHRONOS_validation");
|
||||
}
|
||||
|
||||
foreach (var layer in options.EnabledLayers)
|
||||
enabledLayers.Add(layer);
|
||||
|
||||
var ppEnabledExtensions = stackalloc IntPtr[enabledExtensions.Count];
|
||||
var ppEnabledLayers = stackalloc IntPtr[enabledLayers.Count];
|
||||
|
||||
for (var i = 0; i < enabledExtensions.Count; i++)
|
||||
ppEnabledExtensions[i] = Marshal.StringToHGlobalAnsi(enabledExtensions[i]);
|
||||
|
||||
var layers = enabledLayers.ToList();
|
||||
|
||||
for (var i = 0; i < enabledLayers.Count; i++)
|
||||
ppEnabledLayers[i] = Marshal.StringToHGlobalAnsi(layers[i]);
|
||||
|
||||
var instanceCreateInfo = new InstanceCreateInfo
|
||||
{
|
||||
SType = StructureType.InstanceCreateInfo,
|
||||
PApplicationInfo = &applicationInfo,
|
||||
PpEnabledExtensionNames = (byte**)ppEnabledExtensions,
|
||||
PpEnabledLayerNames = (byte**)ppEnabledLayers,
|
||||
EnabledExtensionCount = (uint)enabledExtensions.Count,
|
||||
EnabledLayerCount = (uint)enabledLayers.Count
|
||||
};
|
||||
|
||||
api.CreateInstance(in instanceCreateInfo, null, out var instance).ThrowOnError();
|
||||
|
||||
Marshal.FreeHGlobal(applicationName);
|
||||
Marshal.FreeHGlobal(engineName);
|
||||
|
||||
for (var i = 0; i < enabledExtensions.Count; i++) Marshal.FreeHGlobal(ppEnabledExtensions[i]);
|
||||
|
||||
for (var i = 0; i < enabledLayers.Count; i++) Marshal.FreeHGlobal(ppEnabledLayers[i]);
|
||||
|
||||
return new VulkanInstance(instance, api);
|
||||
}
|
||||
|
||||
private static unsafe bool IsLayerAvailable(Vk api, string layerName)
|
||||
{
|
||||
uint layerPropertiesCount;
|
||||
|
||||
api.EnumerateInstanceLayerProperties(&layerPropertiesCount, null).ThrowOnError();
|
||||
|
||||
var layerProperties = new LayerProperties[layerPropertiesCount];
|
||||
|
||||
fixed (LayerProperties* pLayerProperties = layerProperties)
|
||||
{
|
||||
api.EnumerateInstanceLayerProperties(&layerPropertiesCount, layerProperties).ThrowOnError();
|
||||
|
||||
for (var i = 0; i < layerPropertiesCount; i++)
|
||||
{
|
||||
var currentLayerName = Marshal.PtrToStringAnsi((IntPtr)pLayerProperties[i].LayerName);
|
||||
|
||||
if (currentLayerName == layerName) return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
59
Ryujinx.Ava/Ui/Backend/Vulkan/VulkanMemoryHelper.cs
Normal file
59
Ryujinx.Ava/Ui/Backend/Vulkan/VulkanMemoryHelper.cs
Normal file
@ -0,0 +1,59 @@
|
||||
using Silk.NET.Vulkan;
|
||||
|
||||
namespace Ryujinx.Ava.Ui.Vulkan
|
||||
{
|
||||
internal static class VulkanMemoryHelper
|
||||
{
|
||||
internal static int FindSuitableMemoryTypeIndex(VulkanPhysicalDevice physicalDevice, uint memoryTypeBits,
|
||||
MemoryPropertyFlags flags)
|
||||
{
|
||||
physicalDevice.Api.GetPhysicalDeviceMemoryProperties(physicalDevice.InternalHandle, out var properties);
|
||||
|
||||
for (var i = 0; i < properties.MemoryTypeCount; i++)
|
||||
{
|
||||
var type = properties.MemoryTypes[i];
|
||||
|
||||
if ((memoryTypeBits & (1 << i)) != 0 && type.PropertyFlags.HasFlag(flags)) return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
internal static unsafe void TransitionLayout(VulkanDevice device,
|
||||
CommandBuffer commandBuffer,
|
||||
Image image,
|
||||
ImageLayout sourceLayout,
|
||||
AccessFlags sourceAccessMask,
|
||||
ImageLayout destinationLayout,
|
||||
AccessFlags destinationAccessMask,
|
||||
uint mipLevels)
|
||||
{
|
||||
var subresourceRange = new ImageSubresourceRange(ImageAspectFlags.ImageAspectColorBit, 0, mipLevels, 0, 1);
|
||||
|
||||
var barrier = new ImageMemoryBarrier
|
||||
{
|
||||
SType = StructureType.ImageMemoryBarrier,
|
||||
SrcAccessMask = sourceAccessMask,
|
||||
DstAccessMask = destinationAccessMask,
|
||||
OldLayout = sourceLayout,
|
||||
NewLayout = destinationLayout,
|
||||
SrcQueueFamilyIndex = Vk.QueueFamilyIgnored,
|
||||
DstQueueFamilyIndex = Vk.QueueFamilyIgnored,
|
||||
Image = image,
|
||||
SubresourceRange = subresourceRange
|
||||
};
|
||||
|
||||
device.Api.CmdPipelineBarrier(
|
||||
commandBuffer,
|
||||
PipelineStageFlags.PipelineStageAllCommandsBit,
|
||||
PipelineStageFlags.PipelineStageAllCommandsBit,
|
||||
0,
|
||||
0,
|
||||
null,
|
||||
0,
|
||||
null,
|
||||
1,
|
||||
barrier);
|
||||
}
|
||||
}
|
||||
}
|
49
Ryujinx.Ava/Ui/Backend/Vulkan/VulkanOptions.cs
Normal file
49
Ryujinx.Ava/Ui/Backend/Vulkan/VulkanOptions.cs
Normal file
@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Ryujinx.Ava.Ui.Vulkan
|
||||
{
|
||||
public class VulkanOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Sets the application name of the Vulkan instance
|
||||
/// </summary>
|
||||
public string ApplicationName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the Vulkan API version to use
|
||||
/// </summary>
|
||||
public Version VulkanVersion { get; set; } = new Version(1, 1, 0);
|
||||
|
||||
/// <summary>
|
||||
/// Specifies additional extensions to enable if available on the instance
|
||||
/// </summary>
|
||||
public IEnumerable<string> InstanceExtensions { get; set; } = Enumerable.Empty<string>();
|
||||
|
||||
/// <summary>
|
||||
/// Specifies layers to enable if available on the instance
|
||||
/// </summary>
|
||||
public IEnumerable<string> EnabledLayers { get; set; } = Enumerable.Empty<string>();
|
||||
|
||||
/// <summary>
|
||||
/// Enables the debug layer
|
||||
/// </summary>
|
||||
public bool UseDebug { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Selects the first suitable discrete GPU available
|
||||
/// </summary>
|
||||
public bool PreferDiscreteGpu { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Sets the device to use if available and suitable.
|
||||
/// </summary>
|
||||
public string PreferredDevice { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Max number of device queues to request
|
||||
/// </summary>
|
||||
public uint MaxQueueCount { get; set; }
|
||||
}
|
||||
}
|
219
Ryujinx.Ava/Ui/Backend/Vulkan/VulkanPhysicalDevice.cs
Normal file
219
Ryujinx.Ava/Ui/Backend/Vulkan/VulkanPhysicalDevice.cs
Normal file
@ -0,0 +1,219 @@
|
||||
using Ryujinx.Graphics.Vulkan;
|
||||
using Silk.NET.Core;
|
||||
using Silk.NET.Vulkan;
|
||||
using Silk.NET.Vulkan.Extensions.KHR;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ryujinx.Ava.Ui.Vulkan
|
||||
{
|
||||
public unsafe class VulkanPhysicalDevice
|
||||
{
|
||||
private VulkanPhysicalDevice(PhysicalDevice apiHandle, Vk api, uint queueCount, uint queueFamilyIndex)
|
||||
{
|
||||
InternalHandle = apiHandle;
|
||||
Api = api;
|
||||
QueueCount = queueCount;
|
||||
QueueFamilyIndex = queueFamilyIndex;
|
||||
|
||||
api.GetPhysicalDeviceProperties(apiHandle, out var properties);
|
||||
|
||||
DeviceName = Marshal.PtrToStringAnsi((IntPtr)properties.DeviceName);
|
||||
DeviceId = VulkanInitialization.StringFromIdPair(properties.VendorID, properties.DeviceID);
|
||||
|
||||
var version = (Version32)properties.ApiVersion;
|
||||
ApiVersion = new Version((int)version.Major, (int)version.Minor, 0, (int)version.Patch);
|
||||
}
|
||||
|
||||
internal PhysicalDevice InternalHandle { get; }
|
||||
internal Vk Api { get; }
|
||||
public uint QueueCount { get; }
|
||||
public uint QueueFamilyIndex { get; }
|
||||
public IntPtr Handle => InternalHandle.Handle;
|
||||
|
||||
public string DeviceName { get; }
|
||||
public string DeviceId { get; }
|
||||
public Version ApiVersion { get; }
|
||||
public static Dictionary<PhysicalDevice, PhysicalDeviceProperties> PhysicalDevices { get; private set; }
|
||||
public static IEnumerable<KeyValuePair<PhysicalDevice, PhysicalDeviceProperties>> SuitableDevices { get; private set; }
|
||||
|
||||
internal static void SelectAvailableDevices(VulkanInstance instance,
|
||||
VulkanSurface surface, bool preferDiscreteGpu, string preferredDevice)
|
||||
{
|
||||
uint physicalDeviceCount;
|
||||
|
||||
instance.Api.EnumeratePhysicalDevices(instance.InternalHandle, &physicalDeviceCount, null).ThrowOnError();
|
||||
|
||||
var physicalDevices = new PhysicalDevice[physicalDeviceCount];
|
||||
|
||||
fixed (PhysicalDevice* pPhysicalDevices = physicalDevices)
|
||||
{
|
||||
instance.Api.EnumeratePhysicalDevices(instance.InternalHandle, &physicalDeviceCount, pPhysicalDevices)
|
||||
.ThrowOnError();
|
||||
}
|
||||
|
||||
PhysicalDevices = new Dictionary<PhysicalDevice, PhysicalDeviceProperties>();
|
||||
|
||||
foreach (var physicalDevice in physicalDevices)
|
||||
{
|
||||
instance.Api.GetPhysicalDeviceProperties(physicalDevice, out var properties);
|
||||
PhysicalDevices.Add(physicalDevice, properties);
|
||||
}
|
||||
|
||||
SuitableDevices = PhysicalDevices.Where(x => IsSuitableDevice(
|
||||
instance.Api,
|
||||
x.Key,
|
||||
x.Value,
|
||||
surface.ApiHandle,
|
||||
out _,
|
||||
out _));
|
||||
}
|
||||
|
||||
internal static VulkanPhysicalDevice FindSuitablePhysicalDevice(VulkanInstance instance,
|
||||
VulkanSurface surface, bool preferDiscreteGpu, string preferredDevice)
|
||||
{
|
||||
SelectAvailableDevices(instance, surface, preferDiscreteGpu, preferredDevice);
|
||||
|
||||
uint queueFamilyIndex = 0;
|
||||
uint queueCount = 0;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(preferredDevice))
|
||||
{
|
||||
var physicalDevice = SuitableDevices.FirstOrDefault(x => VulkanInitialization.StringFromIdPair(x.Value.VendorID, x.Value.DeviceID) == preferredDevice);
|
||||
|
||||
queueFamilyIndex = FindSuitableQueueFamily(instance.Api, physicalDevice.Key,
|
||||
surface.ApiHandle, out queueCount);
|
||||
if (queueFamilyIndex != int.MaxValue)
|
||||
{
|
||||
return new VulkanPhysicalDevice(physicalDevice.Key, instance.Api, queueCount, queueFamilyIndex);
|
||||
}
|
||||
}
|
||||
|
||||
if (preferDiscreteGpu)
|
||||
{
|
||||
var discreteGpus = SuitableDevices.Where(p => p.Value.DeviceType == PhysicalDeviceType.DiscreteGpu);
|
||||
|
||||
foreach (var gpu in discreteGpus)
|
||||
{
|
||||
queueFamilyIndex = FindSuitableQueueFamily(instance.Api, gpu.Key,
|
||||
surface.ApiHandle, out queueCount);
|
||||
if (queueFamilyIndex != int.MaxValue)
|
||||
{
|
||||
return new VulkanPhysicalDevice(gpu.Key, instance.Api, queueCount, queueFamilyIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var physicalDevice in SuitableDevices)
|
||||
{
|
||||
queueFamilyIndex = FindSuitableQueueFamily(instance.Api, physicalDevice.Key,
|
||||
surface.ApiHandle, out queueCount);
|
||||
if (queueFamilyIndex != int.MaxValue)
|
||||
{
|
||||
return new VulkanPhysicalDevice(physicalDevice.Key, instance.Api, queueCount, queueFamilyIndex);
|
||||
}
|
||||
}
|
||||
|
||||
throw new Exception("No suitable physical device found");
|
||||
}
|
||||
|
||||
private static unsafe bool IsSuitableDevice(Vk api, PhysicalDevice physicalDevice, PhysicalDeviceProperties properties, SurfaceKHR surface,
|
||||
out uint queueCount, out uint familyIndex)
|
||||
{
|
||||
queueCount = 0;
|
||||
familyIndex = 0;
|
||||
|
||||
if (properties.DeviceType == PhysicalDeviceType.Cpu) return false;
|
||||
|
||||
var extensionMatches = 0;
|
||||
uint propertiesCount;
|
||||
|
||||
api.EnumerateDeviceExtensionProperties(physicalDevice, (byte*)null, &propertiesCount, null).ThrowOnError();
|
||||
|
||||
var extensionProperties = new ExtensionProperties[propertiesCount];
|
||||
|
||||
fixed (ExtensionProperties* pExtensionProperties = extensionProperties)
|
||||
{
|
||||
api.EnumerateDeviceExtensionProperties(
|
||||
physicalDevice,
|
||||
(byte*)null,
|
||||
&propertiesCount,
|
||||
pExtensionProperties).ThrowOnError();
|
||||
|
||||
for (var i = 0; i < propertiesCount; i++)
|
||||
{
|
||||
var extensionName = Marshal.PtrToStringAnsi((IntPtr)pExtensionProperties[i].ExtensionName);
|
||||
|
||||
if (VulkanInitialization.RequiredExtensions.Contains(extensionName))
|
||||
{
|
||||
extensionMatches++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (extensionMatches == VulkanInitialization.RequiredExtensions.Length)
|
||||
{
|
||||
familyIndex = FindSuitableQueueFamily(api, physicalDevice, surface, out queueCount);
|
||||
|
||||
return familyIndex != uint.MaxValue;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
internal unsafe string[] GetSupportedExtensions()
|
||||
{
|
||||
uint propertiesCount;
|
||||
|
||||
Api.EnumerateDeviceExtensionProperties(InternalHandle, (byte*)null, &propertiesCount, null).ThrowOnError();
|
||||
|
||||
var extensionProperties = new ExtensionProperties[propertiesCount];
|
||||
|
||||
fixed (ExtensionProperties* pExtensionProperties = extensionProperties)
|
||||
{
|
||||
Api.EnumerateDeviceExtensionProperties(InternalHandle, (byte*)null, &propertiesCount, pExtensionProperties)
|
||||
.ThrowOnError();
|
||||
}
|
||||
|
||||
return extensionProperties.Select(x => Marshal.PtrToStringAnsi((IntPtr)x.ExtensionName)).ToArray();
|
||||
}
|
||||
|
||||
private static uint FindSuitableQueueFamily(Vk api, PhysicalDevice physicalDevice, SurfaceKHR surface,
|
||||
out uint queueCount)
|
||||
{
|
||||
const QueueFlags RequiredFlags = QueueFlags.QueueGraphicsBit | QueueFlags.QueueComputeBit;
|
||||
|
||||
var khrSurface = new KhrSurface(api.Context);
|
||||
|
||||
uint propertiesCount;
|
||||
|
||||
api.GetPhysicalDeviceQueueFamilyProperties(physicalDevice, &propertiesCount, null);
|
||||
|
||||
var properties = new QueueFamilyProperties[propertiesCount];
|
||||
|
||||
fixed (QueueFamilyProperties* pProperties = properties)
|
||||
{
|
||||
api.GetPhysicalDeviceQueueFamilyProperties(physicalDevice, &propertiesCount, pProperties);
|
||||
}
|
||||
|
||||
for (uint index = 0; index < propertiesCount; index++)
|
||||
{
|
||||
var queueFlags = properties[index].QueueFlags;
|
||||
|
||||
khrSurface.GetPhysicalDeviceSurfaceSupport(physicalDevice, index, surface, out var surfaceSupported)
|
||||
.ThrowOnError();
|
||||
|
||||
if (queueFlags.HasFlag(RequiredFlags) && surfaceSupported)
|
||||
{
|
||||
queueCount = properties[index].QueueCount;
|
||||
return index;
|
||||
}
|
||||
}
|
||||
|
||||
queueCount = 0;
|
||||
return uint.MaxValue;
|
||||
}
|
||||
}
|
||||
}
|
80
Ryujinx.Ava/Ui/Backend/Vulkan/VulkanPlatformInterface.cs
Normal file
80
Ryujinx.Ava/Ui/Backend/Vulkan/VulkanPlatformInterface.cs
Normal file
@ -0,0 +1,80 @@
|
||||
using Avalonia;
|
||||
using Ryujinx.Ava.Ui.Vulkan.Surfaces;
|
||||
using Ryujinx.Graphics.Vulkan;
|
||||
using Silk.NET.Vulkan;
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.Ava.Ui.Vulkan
|
||||
{
|
||||
internal class VulkanPlatformInterface : IDisposable
|
||||
{
|
||||
private static VulkanOptions _options;
|
||||
|
||||
private VulkanPlatformInterface(VulkanInstance instance)
|
||||
{
|
||||
Instance = instance;
|
||||
Api = instance.Api;
|
||||
}
|
||||
|
||||
public VulkanPhysicalDevice PhysicalDevice { get; private set; }
|
||||
public VulkanInstance Instance { get; }
|
||||
public VulkanDevice Device { get; set; }
|
||||
public Vk Api { get; private set; }
|
||||
public VulkanSurfaceRenderTarget MainSurface { get; set; }
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Device?.Dispose();
|
||||
Instance?.Dispose();
|
||||
Api?.Dispose();
|
||||
}
|
||||
|
||||
private static VulkanPlatformInterface TryCreate()
|
||||
{
|
||||
_options = AvaloniaLocator.Current.GetService<VulkanOptions>() ?? new VulkanOptions();
|
||||
|
||||
var instance = VulkanInstance.Create(_options);
|
||||
|
||||
return new VulkanPlatformInterface(instance);
|
||||
}
|
||||
|
||||
public static bool TryInitialize()
|
||||
{
|
||||
var feature = TryCreate();
|
||||
if (feature != null)
|
||||
{
|
||||
AvaloniaLocator.CurrentMutable.Bind<VulkanPlatformInterface>().ToConstant(feature);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public VulkanSurfaceRenderTarget CreateRenderTarget(IVulkanPlatformSurface platformSurface)
|
||||
{
|
||||
var surface = VulkanSurface.CreateSurface(Instance, platformSurface);
|
||||
|
||||
if (Device == null)
|
||||
{
|
||||
PhysicalDevice = VulkanPhysicalDevice.FindSuitablePhysicalDevice(Instance, surface, _options.PreferDiscreteGpu, _options.PreferredDevice);
|
||||
var device = VulkanInitialization.CreateDevice(Instance.Api,
|
||||
PhysicalDevice.InternalHandle,
|
||||
PhysicalDevice.QueueFamilyIndex,
|
||||
VulkanInitialization.GetSupportedExtensions(Instance.Api, PhysicalDevice.InternalHandle),
|
||||
PhysicalDevice.QueueCount);
|
||||
|
||||
Device = new VulkanDevice(device, PhysicalDevice, Instance.Api);
|
||||
}
|
||||
|
||||
var renderTarget = new VulkanSurfaceRenderTarget(this, surface);
|
||||
|
||||
if (MainSurface == null && surface != null)
|
||||
{
|
||||
MainSurface = renderTarget;
|
||||
MainSurface.Display.ChangeVSyncMode(false);
|
||||
}
|
||||
|
||||
return renderTarget;
|
||||
}
|
||||
}
|
||||
}
|
18
Ryujinx.Ava/Ui/Backend/Vulkan/VulkanQueue.cs
Normal file
18
Ryujinx.Ava/Ui/Backend/Vulkan/VulkanQueue.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using Silk.NET.Vulkan;
|
||||
|
||||
namespace Ryujinx.Ava.Ui.Vulkan
|
||||
{
|
||||
internal class VulkanQueue
|
||||
{
|
||||
public VulkanQueue(VulkanDevice device, Queue apiHandle)
|
||||
{
|
||||
Device = device;
|
||||
InternalHandle = apiHandle;
|
||||
}
|
||||
|
||||
public VulkanDevice Device { get; }
|
||||
public IntPtr Handle => InternalHandle.Handle;
|
||||
internal Queue InternalHandle { get; }
|
||||
}
|
||||
}
|
32
Ryujinx.Ava/Ui/Backend/Vulkan/VulkanSemaphorePair.cs
Normal file
32
Ryujinx.Ava/Ui/Backend/Vulkan/VulkanSemaphorePair.cs
Normal file
@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using Silk.NET.Vulkan;
|
||||
|
||||
namespace Ryujinx.Ava.Ui.Vulkan
|
||||
{
|
||||
internal class VulkanSemaphorePair : IDisposable
|
||||
{
|
||||
private readonly VulkanDevice _device;
|
||||
|
||||
public unsafe VulkanSemaphorePair(VulkanDevice device)
|
||||
{
|
||||
_device = device;
|
||||
|
||||
var semaphoreCreateInfo = new SemaphoreCreateInfo { SType = StructureType.SemaphoreCreateInfo };
|
||||
|
||||
_device.Api.CreateSemaphore(_device.InternalHandle, semaphoreCreateInfo, null, out var semaphore).ThrowOnError();
|
||||
ImageAvailableSemaphore = semaphore;
|
||||
|
||||
_device.Api.CreateSemaphore(_device.InternalHandle, semaphoreCreateInfo, null, out semaphore).ThrowOnError();
|
||||
RenderFinishedSemaphore = semaphore;
|
||||
}
|
||||
|
||||
internal Semaphore ImageAvailableSemaphore { get; }
|
||||
internal Semaphore RenderFinishedSemaphore { get; }
|
||||
|
||||
public unsafe void Dispose()
|
||||
{
|
||||
_device.Api.DestroySemaphore(_device.InternalHandle, ImageAvailableSemaphore, null);
|
||||
_device.Api.DestroySemaphore(_device.InternalHandle, RenderFinishedSemaphore, null);
|
||||
}
|
||||
}
|
||||
}
|
75
Ryujinx.Ava/Ui/Backend/Vulkan/VulkanSurface.cs
Normal file
75
Ryujinx.Ava/Ui/Backend/Vulkan/VulkanSurface.cs
Normal file
@ -0,0 +1,75 @@
|
||||
using System;
|
||||
using Avalonia;
|
||||
using Ryujinx.Ava.Ui.Vulkan.Surfaces;
|
||||
using Silk.NET.Vulkan;
|
||||
using Silk.NET.Vulkan.Extensions.KHR;
|
||||
|
||||
namespace Ryujinx.Ava.Ui.Vulkan
|
||||
{
|
||||
public class VulkanSurface : IDisposable
|
||||
{
|
||||
private readonly VulkanInstance _instance;
|
||||
private readonly IVulkanPlatformSurface _vulkanPlatformSurface;
|
||||
|
||||
private VulkanSurface(IVulkanPlatformSurface vulkanPlatformSurface, VulkanInstance instance)
|
||||
{
|
||||
_vulkanPlatformSurface = vulkanPlatformSurface;
|
||||
_instance = instance;
|
||||
ApiHandle = vulkanPlatformSurface.CreateSurface(instance);
|
||||
}
|
||||
|
||||
internal SurfaceKHR ApiHandle { get; }
|
||||
|
||||
internal static KhrSurface SurfaceExtension { get; private set; }
|
||||
|
||||
internal PixelSize SurfaceSize => _vulkanPlatformSurface.SurfaceSize;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
SurfaceExtension.DestroySurface(_instance.InternalHandle, ApiHandle, Span<AllocationCallbacks>.Empty);
|
||||
_vulkanPlatformSurface.Dispose();
|
||||
}
|
||||
|
||||
internal static VulkanSurface CreateSurface(VulkanInstance instance, IVulkanPlatformSurface vulkanPlatformSurface)
|
||||
{
|
||||
if (SurfaceExtension == null)
|
||||
{
|
||||
instance.Api.TryGetInstanceExtension(instance.InternalHandle, out KhrSurface extension);
|
||||
|
||||
SurfaceExtension = extension;
|
||||
}
|
||||
|
||||
return new VulkanSurface(vulkanPlatformSurface, instance);
|
||||
}
|
||||
|
||||
internal bool CanSurfacePresent(VulkanPhysicalDevice physicalDevice)
|
||||
{
|
||||
SurfaceExtension.GetPhysicalDeviceSurfaceSupport(physicalDevice.InternalHandle, physicalDevice.QueueFamilyIndex, ApiHandle, out var isSupported);
|
||||
|
||||
return isSupported;
|
||||
}
|
||||
|
||||
internal SurfaceFormatKHR GetSurfaceFormat(VulkanPhysicalDevice physicalDevice)
|
||||
{
|
||||
Span<uint> surfaceFormatsCount = stackalloc uint[1];
|
||||
SurfaceExtension.GetPhysicalDeviceSurfaceFormats(physicalDevice.InternalHandle, ApiHandle, surfaceFormatsCount, Span<SurfaceFormatKHR>.Empty);
|
||||
Span<SurfaceFormatKHR> surfaceFormats = stackalloc SurfaceFormatKHR[(int)surfaceFormatsCount[0]];
|
||||
SurfaceExtension.GetPhysicalDeviceSurfaceFormats(physicalDevice.InternalHandle, ApiHandle, surfaceFormatsCount, surfaceFormats);
|
||||
|
||||
if (surfaceFormats.Length == 1 && surfaceFormats[0].Format == Format.Undefined)
|
||||
{
|
||||
return new SurfaceFormatKHR(Format.B8G8R8A8Unorm, ColorSpaceKHR.ColorspaceSrgbNonlinearKhr);
|
||||
}
|
||||
|
||||
foreach (var format in surfaceFormats)
|
||||
{
|
||||
if (format.Format == Format.B8G8R8A8Unorm && format.ColorSpace == ColorSpaceKHR.ColorspaceSrgbNonlinearKhr)
|
||||
{
|
||||
return format;
|
||||
}
|
||||
}
|
||||
|
||||
return surfaceFormats[0];
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using Avalonia;
|
||||
using Ryujinx.Ava.Ui.Vulkan.Surfaces;
|
||||
using Silk.NET.Vulkan;
|
||||
|
||||
namespace Ryujinx.Ava.Ui.Vulkan
|
||||
{
|
||||
internal class VulkanSurfaceRenderingSession : IDisposable
|
||||
{
|
||||
private readonly VulkanDevice _device;
|
||||
private readonly VulkanSurfaceRenderTarget _renderTarget;
|
||||
private VulkanCommandBufferPool.VulkanCommandBuffer _commandBuffer;
|
||||
|
||||
public VulkanSurfaceRenderingSession(VulkanDisplay display, VulkanDevice device,
|
||||
VulkanSurfaceRenderTarget renderTarget, float scaling)
|
||||
{
|
||||
Display = display;
|
||||
_device = device;
|
||||
_renderTarget = renderTarget;
|
||||
Scaling = scaling;
|
||||
Begin();
|
||||
}
|
||||
|
||||
public VulkanDisplay Display { get; }
|
||||
|
||||
public PixelSize Size => _renderTarget.Size;
|
||||
public Vk Api => _device.Api;
|
||||
|
||||
public float Scaling { get; }
|
||||
|
||||
private void Begin()
|
||||
{
|
||||
if (!Display.EnsureSwapchainAvailable())
|
||||
{
|
||||
_renderTarget.Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_commandBuffer = Display.StartPresentation(_renderTarget);
|
||||
|
||||
Display.BlitImageToCurrentImage(_renderTarget, _commandBuffer.InternalHandle);
|
||||
|
||||
Display.EndPresentation(_commandBuffer);
|
||||
}
|
||||
}
|
||||
}
|
@ -37,7 +37,7 @@
|
||||
Header="{locale:Locale GameListContextMenuManageTitleUpdates}"
|
||||
ToolTip.Tip="{locale:Locale GameListContextMenuManageTitleUpdatesToolTip}" />
|
||||
<MenuItem
|
||||
Command="{Binding OpenDlcManager}"
|
||||
Command="{Binding OpenDownloadableContentManager}"
|
||||
Header="{locale:Locale GameListContextMenuManageDlc}"
|
||||
ToolTip.Tip="{locale:Locale GameListContextMenuManageDlcToolTip}" />
|
||||
<MenuItem
|
||||
|
@ -37,7 +37,7 @@
|
||||
Header="{locale:Locale GameListContextMenuManageTitleUpdates}"
|
||||
ToolTip.Tip="{locale:Locale GameListContextMenuManageTitleUpdatesToolTip}" />
|
||||
<MenuItem
|
||||
Command="{Binding OpenDlcManager}"
|
||||
Command="{Binding OpenDownloadableContentManager}"
|
||||
Header="{locale:Locale GameListContextMenuManageDlc}"
|
||||
ToolTip.Tip="{locale:Locale GameListContextMenuManageDlcToolTip}" />
|
||||
<MenuItem
|
||||
|
190
Ryujinx.Ava/Ui/Controls/OpenGLRendererControl.cs
Normal file
190
Ryujinx.Ava/Ui/Controls/OpenGLRendererControl.cs
Normal file
@ -0,0 +1,190 @@
|
||||
using Avalonia;
|
||||
using Avalonia.OpenGL;
|
||||
using Avalonia.Platform;
|
||||
using Avalonia.Rendering.SceneGraph;
|
||||
using Avalonia.Skia;
|
||||
using Avalonia.Threading;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
using Ryujinx.Common.Configuration;
|
||||
using SkiaSharp;
|
||||
using SPB.Graphics;
|
||||
using SPB.Graphics.OpenGL;
|
||||
using SPB.Platform;
|
||||
using SPB.Windowing;
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.Ava.Ui.Controls
|
||||
{
|
||||
internal class OpenGLRendererControl : RendererControl
|
||||
{
|
||||
public int Major { get; }
|
||||
public int Minor { get; }
|
||||
public OpenGLContextBase GameContext { get; set; }
|
||||
|
||||
public static OpenGLContextBase PrimaryContext =>
|
||||
AvaloniaLocator.Current.GetService<IPlatformOpenGlInterface>()
|
||||
.PrimaryContext.AsOpenGLContextBase();
|
||||
|
||||
private SwappableNativeWindowBase _gameBackgroundWindow;
|
||||
|
||||
private IntPtr _fence;
|
||||
|
||||
public OpenGLRendererControl(int major, int minor, GraphicsDebugLevel graphicsDebugLevel) : base(graphicsDebugLevel)
|
||||
{
|
||||
Major = major;
|
||||
Minor = minor;
|
||||
}
|
||||
|
||||
public override void DestroyBackgroundContext()
|
||||
{
|
||||
_image = null;
|
||||
|
||||
if (_fence != IntPtr.Zero)
|
||||
{
|
||||
DrawOperation.Dispose();
|
||||
GL.DeleteSync(_fence);
|
||||
}
|
||||
|
||||
GlDrawOperation.DeleteFramebuffer();
|
||||
|
||||
GameContext?.Dispose();
|
||||
|
||||
_gameBackgroundWindow?.Dispose();
|
||||
}
|
||||
|
||||
internal override void Present(object image)
|
||||
{
|
||||
Dispatcher.UIThread.InvokeAsync(() =>
|
||||
{
|
||||
Image = (int)image;
|
||||
}).Wait();
|
||||
|
||||
if (_fence != IntPtr.Zero)
|
||||
{
|
||||
GL.DeleteSync(_fence);
|
||||
}
|
||||
|
||||
_fence = GL.FenceSync(SyncCondition.SyncGpuCommandsComplete, WaitSyncFlags.None);
|
||||
|
||||
QueueRender();
|
||||
|
||||
_gameBackgroundWindow.SwapBuffers();
|
||||
}
|
||||
|
||||
internal override void MakeCurrent()
|
||||
{
|
||||
GameContext.MakeCurrent(_gameBackgroundWindow);
|
||||
}
|
||||
|
||||
internal override void MakeCurrent(SwappableNativeWindowBase window)
|
||||
{
|
||||
GameContext.MakeCurrent(window);
|
||||
}
|
||||
|
||||
protected override void CreateWindow()
|
||||
{
|
||||
var flags = OpenGLContextFlags.Compat;
|
||||
if (DebugLevel != GraphicsDebugLevel.None)
|
||||
{
|
||||
flags |= OpenGLContextFlags.Debug;
|
||||
}
|
||||
_gameBackgroundWindow = PlatformHelper.CreateOpenGLWindow(FramebufferFormat.Default, 0, 0, 100, 100);
|
||||
_gameBackgroundWindow.Hide();
|
||||
|
||||
GameContext = PlatformHelper.CreateOpenGLContext(FramebufferFormat.Default, Major, Minor, flags, shareContext: PrimaryContext);
|
||||
GameContext.Initialize(_gameBackgroundWindow);
|
||||
}
|
||||
|
||||
protected override ICustomDrawOperation CreateDrawOperation()
|
||||
{
|
||||
return new GlDrawOperation(this);
|
||||
}
|
||||
|
||||
private class GlDrawOperation : ICustomDrawOperation
|
||||
{
|
||||
private static int _framebuffer;
|
||||
|
||||
public Rect Bounds { get; }
|
||||
|
||||
private readonly OpenGLRendererControl _control;
|
||||
|
||||
public GlDrawOperation(OpenGLRendererControl control)
|
||||
{
|
||||
_control = control;
|
||||
Bounds = _control.Bounds;
|
||||
}
|
||||
|
||||
public void Dispose() { }
|
||||
|
||||
public static void DeleteFramebuffer()
|
||||
{
|
||||
if (_framebuffer == 0)
|
||||
{
|
||||
GL.DeleteFramebuffer(_framebuffer);
|
||||
}
|
||||
|
||||
_framebuffer = 0;
|
||||
}
|
||||
|
||||
public bool Equals(ICustomDrawOperation other)
|
||||
{
|
||||
return other is GlDrawOperation operation && Equals(this, operation) && operation.Bounds == Bounds;
|
||||
}
|
||||
|
||||
public bool HitTest(Point p)
|
||||
{
|
||||
return Bounds.Contains(p);
|
||||
}
|
||||
|
||||
private void CreateRenderTarget()
|
||||
{
|
||||
_framebuffer = GL.GenFramebuffer();
|
||||
}
|
||||
|
||||
public void Render(IDrawingContextImpl context)
|
||||
{
|
||||
if (_control.Image == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_framebuffer == 0)
|
||||
{
|
||||
CreateRenderTarget();
|
||||
}
|
||||
|
||||
int currentFramebuffer = GL.GetInteger(GetPName.FramebufferBinding);
|
||||
|
||||
var image = _control.Image;
|
||||
var fence = _control._fence;
|
||||
|
||||
GL.BindFramebuffer(FramebufferTarget.Framebuffer, _framebuffer);
|
||||
GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment0, TextureTarget.Texture2D, (int)image, 0);
|
||||
GL.BindFramebuffer(FramebufferTarget.Framebuffer, currentFramebuffer);
|
||||
|
||||
if (context is not ISkiaDrawingContextImpl skiaDrawingContextImpl)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var imageInfo = new SKImageInfo((int)_control.RenderSize.Width, (int)_control.RenderSize.Height, SKColorType.Rgba8888);
|
||||
var glInfo = new GRGlFramebufferInfo((uint)_framebuffer, SKColorType.Rgba8888.ToGlSizedFormat());
|
||||
|
||||
GL.WaitSync(fence, WaitSyncFlags.None, ulong.MaxValue);
|
||||
|
||||
using var backendTexture = new GRBackendRenderTarget(imageInfo.Width, imageInfo.Height, 1, 0, glInfo);
|
||||
using var surface = SKSurface.Create(skiaDrawingContextImpl.GrContext, backendTexture, GRSurfaceOrigin.BottomLeft, SKColorType.Rgba8888);
|
||||
|
||||
if (surface == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var rect = new Rect(new Point(), _control.RenderSize);
|
||||
|
||||
using var snapshot = surface.Snapshot();
|
||||
skiaDrawingContextImpl.SkCanvas.DrawImage(snapshot, rect.ToSKRect(), _control.Bounds.ToSKRect(), new SKPaint());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -2,65 +2,49 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Data;
|
||||
using Avalonia.Media;
|
||||
using Avalonia.OpenGL;
|
||||
using Avalonia.Platform;
|
||||
using Avalonia.Rendering.SceneGraph;
|
||||
using Avalonia.Skia;
|
||||
using Avalonia.Threading;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
using Ryujinx.Common.Configuration;
|
||||
using SkiaSharp;
|
||||
using SPB.Graphics;
|
||||
using SPB.Graphics.OpenGL;
|
||||
using SPB.Platform;
|
||||
using SPB.Windowing;
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.Ava.Ui.Controls
|
||||
{
|
||||
internal class RendererControl : Control
|
||||
internal abstract class RendererControl : Control
|
||||
{
|
||||
private int _image;
|
||||
protected object _image;
|
||||
|
||||
static RendererControl()
|
||||
{
|
||||
AffectsRender<RendererControl>(ImageProperty);
|
||||
}
|
||||
|
||||
public readonly static StyledProperty<int> ImageProperty =
|
||||
AvaloniaProperty.Register<RendererControl, int>(nameof(Image), 0, inherits: true, defaultBindingMode: BindingMode.TwoWay);
|
||||
public readonly static StyledProperty<object> ImageProperty =
|
||||
AvaloniaProperty.Register<RendererControl, object>(
|
||||
nameof(Image),
|
||||
0,
|
||||
inherits: true,
|
||||
defaultBindingMode: BindingMode.TwoWay);
|
||||
|
||||
protected int Image
|
||||
protected object Image
|
||||
{
|
||||
get => _image;
|
||||
set => SetAndRaise(ImageProperty, ref _image, value);
|
||||
}
|
||||
|
||||
public event EventHandler<EventArgs> GlInitialized;
|
||||
public event EventHandler<EventArgs> RendererInitialized;
|
||||
public event EventHandler<Size> SizeChanged;
|
||||
|
||||
protected Size RenderSize { get; private set; }
|
||||
public bool IsStarted { get; private set; }
|
||||
|
||||
public int Major { get; }
|
||||
public int Minor { get; }
|
||||
public GraphicsDebugLevel DebugLevel { get; }
|
||||
public OpenGLContextBase GameContext { get; set; }
|
||||
|
||||
public static OpenGLContextBase PrimaryContext => AvaloniaLocator.Current.GetService<IPlatformOpenGlInterface>().PrimaryContext.AsOpenGLContextBase();
|
||||
|
||||
private SwappableNativeWindowBase _gameBackgroundWindow;
|
||||
|
||||
private bool _isInitialized;
|
||||
|
||||
private IntPtr _fence;
|
||||
protected ICustomDrawOperation DrawOperation { get; private set; }
|
||||
|
||||
private GlDrawOperation _glDrawOperation;
|
||||
|
||||
public RendererControl(int major, int minor, GraphicsDebugLevel graphicsDebugLevel)
|
||||
public RendererControl(GraphicsDebugLevel graphicsDebugLevel)
|
||||
{
|
||||
Major = major;
|
||||
Minor = minor;
|
||||
DebugLevel = graphicsDebugLevel;
|
||||
IObservable<Rect> resizeObservable = this.GetObservable(BoundsProperty);
|
||||
|
||||
@ -69,7 +53,7 @@ namespace Ryujinx.Ava.Ui.Controls
|
||||
Focusable = true;
|
||||
}
|
||||
|
||||
private void Resized(Rect rect)
|
||||
protected void Resized(Rect rect)
|
||||
{
|
||||
SizeChanged?.Invoke(this, rect.Size);
|
||||
|
||||
@ -77,37 +61,40 @@ namespace Ryujinx.Ava.Ui.Controls
|
||||
{
|
||||
RenderSize = rect.Size * VisualRoot.RenderScaling;
|
||||
|
||||
_glDrawOperation?.Dispose();
|
||||
_glDrawOperation = new GlDrawOperation(this);
|
||||
DrawOperation?.Dispose();
|
||||
DrawOperation = CreateDrawOperation();
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract ICustomDrawOperation CreateDrawOperation();
|
||||
protected abstract void CreateWindow();
|
||||
|
||||
public override void Render(DrawingContext context)
|
||||
{
|
||||
if (!_isInitialized)
|
||||
{
|
||||
CreateWindow();
|
||||
|
||||
OnGlInitialized();
|
||||
OnRendererInitialized();
|
||||
_isInitialized = true;
|
||||
}
|
||||
|
||||
if (GameContext == null || !IsStarted || Image == 0)
|
||||
if (!IsStarted || Image == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_glDrawOperation != null)
|
||||
if (DrawOperation != null)
|
||||
{
|
||||
context.Custom(_glDrawOperation);
|
||||
context.Custom(DrawOperation);
|
||||
}
|
||||
|
||||
base.Render(context);
|
||||
}
|
||||
|
||||
protected void OnGlInitialized()
|
||||
protected void OnRendererInitialized()
|
||||
{
|
||||
GlInitialized?.Invoke(this, EventArgs.Empty);
|
||||
RendererInitialized?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
public void QueueRender()
|
||||
@ -115,24 +102,7 @@ namespace Ryujinx.Ava.Ui.Controls
|
||||
Program.RenderTimer.TickNow();
|
||||
}
|
||||
|
||||
internal void Present(object image)
|
||||
{
|
||||
Dispatcher.UIThread.InvokeAsync(() =>
|
||||
{
|
||||
Image = (int)image;
|
||||
}).Wait();
|
||||
|
||||
if (_fence != IntPtr.Zero)
|
||||
{
|
||||
GL.DeleteSync(_fence);
|
||||
}
|
||||
|
||||
_fence = GL.FenceSync(SyncCondition.SyncGpuCommandsComplete, WaitSyncFlags.None);
|
||||
|
||||
QueueRender();
|
||||
|
||||
_gameBackgroundWindow.SwapBuffers();
|
||||
}
|
||||
internal abstract void Present(object image);
|
||||
|
||||
internal void Start()
|
||||
{
|
||||
@ -145,132 +115,8 @@ namespace Ryujinx.Ava.Ui.Controls
|
||||
IsStarted = false;
|
||||
}
|
||||
|
||||
public void DestroyBackgroundContext()
|
||||
{
|
||||
_image = 0;
|
||||
|
||||
if (_fence != IntPtr.Zero)
|
||||
{
|
||||
_glDrawOperation.Dispose();
|
||||
GL.DeleteSync(_fence);
|
||||
}
|
||||
|
||||
GlDrawOperation.DeleteFramebuffer();
|
||||
|
||||
GameContext?.Dispose();
|
||||
|
||||
_gameBackgroundWindow?.Dispose();
|
||||
}
|
||||
|
||||
internal void MakeCurrent()
|
||||
{
|
||||
GameContext.MakeCurrent(_gameBackgroundWindow);
|
||||
}
|
||||
|
||||
internal void MakeCurrent(SwappableNativeWindowBase window)
|
||||
{
|
||||
GameContext.MakeCurrent(window);
|
||||
}
|
||||
|
||||
protected void CreateWindow()
|
||||
{
|
||||
var flags = OpenGLContextFlags.Compat;
|
||||
if (DebugLevel != GraphicsDebugLevel.None)
|
||||
{
|
||||
flags |= OpenGLContextFlags.Debug;
|
||||
}
|
||||
_gameBackgroundWindow = PlatformHelper.CreateOpenGLWindow(FramebufferFormat.Default, 0, 0, 100, 100);
|
||||
_gameBackgroundWindow.Hide();
|
||||
|
||||
GameContext = PlatformHelper.CreateOpenGLContext(FramebufferFormat.Default, Major, Minor, flags, shareContext: PrimaryContext);
|
||||
GameContext.Initialize(_gameBackgroundWindow);
|
||||
}
|
||||
|
||||
private class GlDrawOperation : ICustomDrawOperation
|
||||
{
|
||||
private static int _framebuffer;
|
||||
|
||||
public Rect Bounds { get; }
|
||||
|
||||
private readonly RendererControl _control;
|
||||
|
||||
public GlDrawOperation(RendererControl control)
|
||||
{
|
||||
_control = control;
|
||||
Bounds = _control.Bounds;
|
||||
}
|
||||
|
||||
public void Dispose() { }
|
||||
|
||||
public static void DeleteFramebuffer()
|
||||
{
|
||||
if (_framebuffer == 0)
|
||||
{
|
||||
GL.DeleteFramebuffer(_framebuffer);
|
||||
}
|
||||
|
||||
_framebuffer = 0;
|
||||
}
|
||||
|
||||
public bool Equals(ICustomDrawOperation other)
|
||||
{
|
||||
return other is GlDrawOperation operation && Equals(this, operation) && operation.Bounds == Bounds;
|
||||
}
|
||||
|
||||
public bool HitTest(Point p)
|
||||
{
|
||||
return Bounds.Contains(p);
|
||||
}
|
||||
|
||||
private void CreateRenderTarget()
|
||||
{
|
||||
_framebuffer = GL.GenFramebuffer();
|
||||
}
|
||||
|
||||
public void Render(IDrawingContextImpl context)
|
||||
{
|
||||
if (_control.Image == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_framebuffer == 0)
|
||||
{
|
||||
CreateRenderTarget();
|
||||
}
|
||||
|
||||
int currentFramebuffer = GL.GetInteger(GetPName.FramebufferBinding);
|
||||
|
||||
var image = _control.Image;
|
||||
var fence = _control._fence;
|
||||
|
||||
GL.BindFramebuffer(FramebufferTarget.Framebuffer, _framebuffer);
|
||||
GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment0, TextureTarget.Texture2D, image, 0);
|
||||
GL.BindFramebuffer(FramebufferTarget.Framebuffer, currentFramebuffer);
|
||||
|
||||
if (context is not ISkiaDrawingContextImpl skiaDrawingContextImpl)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var imageInfo = new SKImageInfo((int)_control.RenderSize.Width, (int)_control.RenderSize.Height, SKColorType.Rgba8888);
|
||||
var glInfo = new GRGlFramebufferInfo((uint)_framebuffer, SKColorType.Rgba8888.ToGlSizedFormat());
|
||||
|
||||
GL.WaitSync(fence, WaitSyncFlags.None, ulong.MaxValue);
|
||||
|
||||
using var backendTexture = new GRBackendRenderTarget(imageInfo.Width, imageInfo.Height, 1, 0, glInfo);
|
||||
using var surface = SKSurface.Create(skiaDrawingContextImpl.GrContext, backendTexture, GRSurfaceOrigin.BottomLeft, SKColorType.Rgba8888);
|
||||
|
||||
if (surface == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var rect = new Rect(new Point(), _control.RenderSize);
|
||||
|
||||
using var snapshot = surface.Snapshot();
|
||||
skiaDrawingContextImpl.SkCanvas.DrawImage(snapshot, rect.ToSKRect(), _control.Bounds.ToSKRect(), new SKPaint());
|
||||
}
|
||||
}
|
||||
public abstract void DestroyBackgroundContext();
|
||||
internal abstract void MakeCurrent();
|
||||
internal abstract void MakeCurrent(SwappableNativeWindowBase window);
|
||||
}
|
||||
}
|
@ -17,9 +17,6 @@ namespace Ryujinx.Ava.Ui.Controls
|
||||
public UpdateWaitWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
#if DEBUG
|
||||
this.AttachDevTools();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
@ -1,55 +1,87 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
<UserControl
|
||||
x:Class="Ryujinx.Ava.Ui.Controls.UserEditor"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:Locale="clr-namespace:Ryujinx.Ava.Common.Locale"
|
||||
xmlns:controls="clr-namespace:Ryujinx.Ava.Ui.Controls"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d"
|
||||
Padding="0"
|
||||
Margin="0"
|
||||
xmlns:Locale="clr-namespace:Ryujinx.Ava.Common.Locale"
|
||||
xmlns:viewModels="clr-namespace:Ryujinx.Ava.Ui.ViewModels"
|
||||
xmlns:models="clr-namespace:Ryujinx.Ava.Ui.Models"
|
||||
xmlns:controls="clr-namespace:Ryujinx.Ava.Ui.Controls"
|
||||
xmlns:ui="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
|
||||
x:Class="Ryujinx.Ava.Ui.Controls.UserEditor">
|
||||
xmlns:viewModels="clr-namespace:Ryujinx.Ava.Ui.ViewModels"
|
||||
Margin="0"
|
||||
Padding="0"
|
||||
mc:Ignorable="d">
|
||||
<UserControl.Resources>
|
||||
<controls:BitmapArrayValueConverter x:Key="ByteImage" />
|
||||
</UserControl.Resources>
|
||||
<Grid Margin="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel Orientation="Vertical" VerticalAlignment="Stretch" HorizontalAlignment="Left">
|
||||
<StackPanel
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Stretch"
|
||||
Orientation="Vertical">
|
||||
<Image
|
||||
Name="ProfileImage"
|
||||
Width="96"
|
||||
Height="96"
|
||||
Margin="0"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Top"
|
||||
Height="96" Width="96"
|
||||
Name="ProfileImage"
|
||||
Source="{Binding Image, Converter={StaticResource ByteImage}}" />
|
||||
<Button Margin="5" Content="{Locale:Locale UserProfilesChangeProfileImage}"
|
||||
<Button
|
||||
Name="ChangePictureButton"
|
||||
Margin="5"
|
||||
HorizontalAlignment="Stretch"
|
||||
Click="ChangePictureButton_Click"
|
||||
HorizontalAlignment="Stretch"/>
|
||||
<Button Margin="5" Content="{Locale:Locale UserProfilesSetProfileImage}"
|
||||
Content="{Locale:Locale UserProfilesChangeProfileImage}" />
|
||||
<Button
|
||||
Name="AddPictureButton"
|
||||
Margin="5"
|
||||
HorizontalAlignment="Stretch"
|
||||
Click="ChangePictureButton_Click"
|
||||
HorizontalAlignment="Stretch"/>
|
||||
Content="{Locale:Locale UserProfilesSetProfileImage}" />
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="0" Orientation="Vertical" HorizontalAlignment="Stretch" Grid.Column="1" Spacing="10"
|
||||
Margin="5, 10">
|
||||
<TextBox Name="NameBox" Width="300" Text="{Binding Name}" MaxLength="{Binding MaxProfileNameLength}"
|
||||
HorizontalAlignment="Stretch" />
|
||||
<TextBlock Text="{Binding UserId}" Name="IdLabel" />
|
||||
<StackPanel
|
||||
Grid.Row="0"
|
||||
Grid.Column="1"
|
||||
Margin="5,10"
|
||||
HorizontalAlignment="Stretch"
|
||||
Orientation="Vertical"
|
||||
Spacing="10">
|
||||
<TextBlock Text="{Locale:Locale UserProfilesName}" />
|
||||
<TextBox
|
||||
Name="NameBox"
|
||||
Width="300"
|
||||
HorizontalAlignment="Stretch"
|
||||
MaxLength="{Binding MaxProfileNameLength}"
|
||||
Text="{Binding Name}" />
|
||||
<TextBlock Text="{Locale:Locale UserProfilesUserId}" />
|
||||
<TextBlock Name="IdLabel" Text="{Binding UserId}" />
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1" Orientation="Horizontal" Spacing="10" HorizontalAlignment="Right">
|
||||
<Button Content="{Locale:Locale Save}" Name="SaveButton" Click="SaveButton_Click"/>
|
||||
<Button HorizontalAlignment="Right" Content="{Locale:Locale Discard}"
|
||||
Name="CloseButton" Click="CloseButton_Click"/>
|
||||
<StackPanel
|
||||
Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
HorizontalAlignment="Right"
|
||||
Orientation="Horizontal"
|
||||
Spacing="10">
|
||||
<Button
|
||||
Name="SaveButton"
|
||||
Click="SaveButton_Click"
|
||||
Content="{Locale:Locale Save}" />
|
||||
<Button
|
||||
Name="CloseButton"
|
||||
HorizontalAlignment="Right"
|
||||
Click="CloseButton_Click"
|
||||
Content="{Locale:Locale Discard}" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
@ -63,7 +63,7 @@ namespace Ryujinx.Ava.Ui.Controls
|
||||
_parent?.GoBack();
|
||||
}
|
||||
|
||||
private void SaveButton_Click(object sender, RoutedEventArgs e)
|
||||
private async void SaveButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
DataValidationErrors.ClearErrors(NameBox);
|
||||
bool isInvalid = false;
|
||||
@ -77,7 +77,7 @@ namespace Ryujinx.Ava.Ui.Controls
|
||||
|
||||
if (TempProfile.Image == null)
|
||||
{
|
||||
ContentDialogHelper.CreateWarningDialog(LocaleManager.Instance["UserProfileNoImageError"], "");
|
||||
await ContentDialogHelper.CreateWarningDialog(LocaleManager.Instance["UserProfileNoImageError"], "");
|
||||
|
||||
isInvalid = true;
|
||||
}
|
||||
|
@ -1,28 +1,34 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
<UserControl
|
||||
x:Class="Ryujinx.Ava.Ui.Controls.UserSelector"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:flex="clr-namespace:Avalonia.Flexbox;assembly=Avalonia.Flexbox"
|
||||
xmlns:Locale="clr-namespace:Ryujinx.Ava.Common.Locale"
|
||||
xmlns:viewModels="clr-namespace:Ryujinx.Ava.Ui.ViewModels"
|
||||
xmlns:controls="clr-namespace:Ryujinx.Ava.Ui.Controls"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:flex="clr-namespace:Avalonia.Flexbox;assembly=Avalonia.Flexbox"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:ui="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="Ryujinx.Ava.Ui.Controls.UserSelector">
|
||||
xmlns:viewModels="clr-namespace:Ryujinx.Ava.Ui.ViewModels"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
mc:Ignorable="d">
|
||||
<UserControl.Resources>
|
||||
<controls:BitmapArrayValueConverter x:Key="ByteImage" />
|
||||
</UserControl.Resources>
|
||||
<Design.DataContext>
|
||||
<viewModels:UserProfileViewModel />
|
||||
</Design.DataContext>
|
||||
<Grid HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch">
|
||||
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<ListBox HorizontalAlignment="Stretch" VerticalAlignment="Center" Margin="5" Items="{Binding Profiles}"
|
||||
<ListBox
|
||||
Margin="5"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Center"
|
||||
DoubleTapped="ProfilesList_DoubleTapped"
|
||||
Items="{Binding Profiles}"
|
||||
SelectionChanged="SelectingItemsControl_SelectionChanged">
|
||||
<ListBox.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
@ -49,10 +55,11 @@
|
||||
</Grid.RowDefinitions>
|
||||
<Image
|
||||
Grid.Row="0"
|
||||
Width="96"
|
||||
Height="96"
|
||||
Margin="0"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Top"
|
||||
Height="96" Width="96"
|
||||
Source="{Binding Image, Converter={StaticResource ByteImage}}" />
|
||||
<StackPanel
|
||||
Grid.Row="1"
|
||||
@ -68,23 +75,34 @@
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
<Border HorizontalAlignment="Left" VerticalAlignment="Top"
|
||||
IsVisible="{Binding IsOpened}"
|
||||
Background="LimeGreen"
|
||||
<Border
|
||||
Width="10"
|
||||
Height="10"
|
||||
Margin="5"
|
||||
CornerRadius="5" />
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Top"
|
||||
Background="LimeGreen"
|
||||
CornerRadius="5"
|
||||
IsVisible="{Binding IsOpened}" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
<StackPanel Grid.Row="1" Orientation="Horizontal" Margin="10,0" Spacing="10" HorizontalAlignment="Center">
|
||||
<Button Content="{Locale:Locale UserProfilesAddNewProfile}" Command="{Binding AddUser}" />
|
||||
<Button IsEnabled="{Binding IsSelectedProfiledEditable}"
|
||||
Content="{Locale:Locale UserProfilesEditProfile}" Command="{Binding EditUser}" />
|
||||
<Button IsEnabled="{Binding IsSelectedProfileDeletable}"
|
||||
Content="{Locale:Locale UserProfilesDeleteSelectedProfile}" Command="{Binding DeleteUser}" />
|
||||
<StackPanel
|
||||
Grid.Row="1"
|
||||
Margin="10,0"
|
||||
HorizontalAlignment="Center"
|
||||
Orientation="Horizontal"
|
||||
Spacing="10">
|
||||
<Button Command="{Binding AddUser}" Content="{Locale:Locale UserProfilesAddNewProfile}" />
|
||||
<Button
|
||||
Command="{Binding EditUser}"
|
||||
Content="{Locale:Locale UserProfilesEditProfile}"
|
||||
IsEnabled="{Binding IsSelectedProfiledEditable}" />
|
||||
<Button
|
||||
Command="{Binding DeleteUser}"
|
||||
Content="{Locale:Locale UserProfilesDeleteSelectedProfile}"
|
||||
IsEnabled="{Binding IsSelectedProfileDeletable}" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
@ -21,7 +21,7 @@ namespace Ryujinx.Ava.Ui.Controls
|
||||
AddHandler(Frame.NavigatedToEvent, (s, e) =>
|
||||
{
|
||||
NavigatedTo(e);
|
||||
}, Avalonia.Interactivity.RoutingStrategies.Direct);
|
||||
}, RoutingStrategies.Direct);
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,12 +29,10 @@ namespace Ryujinx.Ava.Ui.Controls
|
||||
{
|
||||
if (Program.PreviewerDetached)
|
||||
{
|
||||
switch (arg.NavigationMode)
|
||||
if (arg.NavigationMode == NavigationMode.New)
|
||||
{
|
||||
case NavigationMode.New:
|
||||
_parent = (NavigationDialogHost)arg.Parameter;
|
||||
ViewModel = _parent.ViewModel;
|
||||
break;
|
||||
}
|
||||
|
||||
DataContext = ViewModel;
|
||||
|
153
Ryujinx.Ava/Ui/Controls/VulkanRendererControl.cs
Normal file
153
Ryujinx.Ava/Ui/Controls/VulkanRendererControl.cs
Normal file
@ -0,0 +1,153 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Platform;
|
||||
using Avalonia.Rendering.SceneGraph;
|
||||
using Avalonia.Skia;
|
||||
using Avalonia.Threading;
|
||||
using Ryujinx.Ava.Ui.Backend.Vulkan;
|
||||
using Ryujinx.Ava.Ui.Vulkan;
|
||||
using Ryujinx.Common.Configuration;
|
||||
using Ryujinx.Graphics.Vulkan;
|
||||
using Silk.NET.Vulkan;
|
||||
using SkiaSharp;
|
||||
using SPB.Windowing;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Ryujinx.Ava.Ui.Controls
|
||||
{
|
||||
internal class VulkanRendererControl : RendererControl
|
||||
{
|
||||
private VulkanPlatformInterface _platformInterface;
|
||||
|
||||
public VulkanRendererControl(GraphicsDebugLevel graphicsDebugLevel) : base(graphicsDebugLevel)
|
||||
{
|
||||
_platformInterface = AvaloniaLocator.Current.GetService<VulkanPlatformInterface>();
|
||||
}
|
||||
|
||||
public override void DestroyBackgroundContext()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override ICustomDrawOperation CreateDrawOperation()
|
||||
{
|
||||
return new VulkanDrawOperation(this);
|
||||
}
|
||||
|
||||
protected override void CreateWindow()
|
||||
{
|
||||
}
|
||||
|
||||
internal override void MakeCurrent()
|
||||
{
|
||||
}
|
||||
|
||||
internal override void MakeCurrent(SwappableNativeWindowBase window)
|
||||
{
|
||||
}
|
||||
|
||||
internal override void Present(object image)
|
||||
{
|
||||
Dispatcher.UIThread.InvokeAsync(() =>
|
||||
{
|
||||
Image = image;
|
||||
}).Wait();
|
||||
|
||||
QueueRender();
|
||||
}
|
||||
|
||||
private class VulkanDrawOperation : ICustomDrawOperation
|
||||
{
|
||||
public Rect Bounds { get; }
|
||||
|
||||
private readonly VulkanRendererControl _control;
|
||||
|
||||
public VulkanDrawOperation(VulkanRendererControl control)
|
||||
{
|
||||
_control = control;
|
||||
Bounds = _control.Bounds;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public bool Equals(ICustomDrawOperation other)
|
||||
{
|
||||
return other is VulkanDrawOperation operation && Equals(this, operation) && operation.Bounds == Bounds;
|
||||
}
|
||||
|
||||
public bool HitTest(Point p)
|
||||
{
|
||||
return Bounds.Contains(p);
|
||||
}
|
||||
|
||||
public void Render(IDrawingContextImpl context)
|
||||
{
|
||||
if (_control.Image == null || _control.RenderSize.Width == 0 || _control.RenderSize.Height == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var image = (PresentImageInfo)_control.Image;
|
||||
|
||||
if (context is not ISkiaDrawingContextImpl skiaDrawingContextImpl)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_control._platformInterface.Device.QueueWaitIdle();
|
||||
|
||||
var gpu = AvaloniaLocator.Current.GetService<VulkanSkiaGpu>();
|
||||
|
||||
var imageInfo = new GRVkImageInfo()
|
||||
{
|
||||
CurrentQueueFamily = _control._platformInterface.PhysicalDevice.QueueFamilyIndex,
|
||||
Format = (uint)Format.R8G8B8A8Unorm,
|
||||
Image = image.Image.Handle,
|
||||
ImageLayout = (uint)ImageLayout.ColorAttachmentOptimal,
|
||||
ImageTiling = (uint)ImageTiling.Optimal,
|
||||
ImageUsageFlags = (uint)(ImageUsageFlags.ImageUsageColorAttachmentBit
|
||||
| ImageUsageFlags.ImageUsageTransferSrcBit
|
||||
| ImageUsageFlags.ImageUsageTransferDstBit),
|
||||
LevelCount = 1,
|
||||
SampleCount = 1,
|
||||
Protected = false,
|
||||
Alloc = new GRVkAlloc()
|
||||
{
|
||||
Memory = image.Memory.Handle,
|
||||
Flags = 0,
|
||||
Offset = image.MemoryOffset,
|
||||
Size = image.MemorySize
|
||||
}
|
||||
};
|
||||
|
||||
using var backendTexture = new GRBackendRenderTarget(
|
||||
(int)_control.RenderSize.Width,
|
||||
(int)_control.RenderSize.Height,
|
||||
1,
|
||||
imageInfo);
|
||||
|
||||
using var surface = SKSurface.Create(
|
||||
gpu.GrContext,
|
||||
backendTexture,
|
||||
GRSurfaceOrigin.TopLeft,
|
||||
SKColorType.Rgba8888);
|
||||
|
||||
if (surface == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var rect = new Rect(new Point(), _control.RenderSize);
|
||||
|
||||
using var snapshot = surface.Snapshot();
|
||||
skiaDrawingContextImpl.SkCanvas.DrawImage(snapshot, rect.ToSKRect(), _control.Bounds.ToSKRect(), new SKPaint());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -22,7 +22,9 @@ namespace Ryujinx.Ava.Ui.Models
|
||||
set
|
||||
{
|
||||
_isEnabled = value;
|
||||
|
||||
EnableToggled?.Invoke(this, _isEnabled);
|
||||
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
@ -30,6 +32,7 @@ namespace Ryujinx.Ava.Ui.Models
|
||||
public string BuildId { get; }
|
||||
|
||||
public string BuildIdKey => $"{BuildId}-{Name}";
|
||||
|
||||
public string Name { get; }
|
||||
|
||||
public string CleanName => Name.Substring(1, Name.Length - 8);
|
||||
|
@ -11,23 +11,10 @@ namespace Ryujinx.Ava.Ui.Models
|
||||
{
|
||||
BuildId = buildId;
|
||||
Path = path;
|
||||
|
||||
CollectionChanged += CheatsList_CollectionChanged;
|
||||
}
|
||||
|
||||
private void CheatsList_CollectionChanged(object sender,
|
||||
NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
if (e.Action == NotifyCollectionChangedAction.Add)
|
||||
{
|
||||
(e.NewItems[0] as CheatModel).EnableToggled += Item_EnableToggled;
|
||||
}
|
||||
}
|
||||
|
||||
private void Item_EnableToggled(object sender, bool e)
|
||||
{
|
||||
OnPropertyChanged(new PropertyChangedEventArgs(nameof(IsEnabled)));
|
||||
}
|
||||
|
||||
public string BuildId { get; }
|
||||
public string Path { get; }
|
||||
|
||||
@ -47,5 +34,18 @@ namespace Ryujinx.Ava.Ui.Models
|
||||
OnPropertyChanged(new PropertyChangedEventArgs(nameof(IsEnabled)));
|
||||
}
|
||||
}
|
||||
|
||||
private void CheatsList_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
if (e.Action == NotifyCollectionChangedAction.Add)
|
||||
{
|
||||
(e.NewItems[0] as CheatModel).EnableToggled += Item_EnableToggled;
|
||||
}
|
||||
}
|
||||
|
||||
private void Item_EnableToggled(object sender, bool e)
|
||||
{
|
||||
OnPropertyChanged(new PropertyChangedEventArgs(nameof(IsEnabled)));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
namespace Ryujinx.Ava.Ui.Models
|
||||
{
|
||||
public class DlcModel
|
||||
{
|
||||
public bool IsEnabled { get; set; }
|
||||
public string TitleId { get; }
|
||||
public string ContainerPath { get; }
|
||||
public string FullPath { get; }
|
||||
|
||||
public DlcModel(string titleId, string containerPath, string fullPath, bool isEnabled)
|
||||
{
|
||||
TitleId = titleId;
|
||||
ContainerPath = containerPath;
|
||||
FullPath = fullPath;
|
||||
IsEnabled = isEnabled;
|
||||
}
|
||||
}
|
||||
}
|
18
Ryujinx.Ava/Ui/Models/DownloadableContentModel.cs
Normal file
18
Ryujinx.Ava/Ui/Models/DownloadableContentModel.cs
Normal file
@ -0,0 +1,18 @@
|
||||
namespace Ryujinx.Ava.Ui.Models
|
||||
{
|
||||
public class DownloadableContentModel
|
||||
{
|
||||
public bool Enabled { get; set; }
|
||||
public string TitleId { get; }
|
||||
public string ContainerPath { get; }
|
||||
public string FullPath { get; }
|
||||
|
||||
public DownloadableContentModel(string titleId, string containerPath, string fullPath, bool enabled)
|
||||
{
|
||||
TitleId = titleId;
|
||||
ContainerPath = containerPath;
|
||||
FullPath = fullPath;
|
||||
Enabled = enabled;
|
||||
}
|
||||
}
|
||||
}
|
@ -6,16 +6,18 @@ namespace Ryujinx.Ava.Ui.Models
|
||||
{
|
||||
public bool VSyncEnabled { get; }
|
||||
public float Volume { get; }
|
||||
public string GpuBackend { get; }
|
||||
public string AspectRatio { get; }
|
||||
public string DockedMode { get; }
|
||||
public string FifoStatus { get; }
|
||||
public string GameStatus { get; }
|
||||
public string GpuName { get; }
|
||||
|
||||
public StatusUpdatedEventArgs(bool vSyncEnabled, float volume, string dockedMode, string aspectRatio, string gameStatus, string fifoStatus, string gpuName)
|
||||
public StatusUpdatedEventArgs(bool vSyncEnabled, float volume, string gpuBackend, string dockedMode, string aspectRatio, string gameStatus, string fifoStatus, string gpuName)
|
||||
{
|
||||
VSyncEnabled = vSyncEnabled;
|
||||
Volume = volume;
|
||||
GpuBackend = gpuBackend;
|
||||
DockedMode = dockedMode;
|
||||
AspectRatio = aspectRatio;
|
||||
GameStatus = gameStatus;
|
||||
|
@ -382,9 +382,9 @@ namespace Ryujinx.Ava.Ui.ViewModels
|
||||
{
|
||||
string amiiboJsonString = await response.Content.ReadAsStringAsync();
|
||||
|
||||
using (FileStream dlcJsonStream = File.Create(_amiiboJsonPath, 4096, FileOptions.WriteThrough))
|
||||
using (FileStream amiiboJsonStream = File.Create(_amiiboJsonPath, 4096, FileOptions.WriteThrough))
|
||||
{
|
||||
dlcJsonStream.Write(Encoding.UTF8.GetBytes(amiiboJsonString));
|
||||
amiiboJsonStream.Write(Encoding.UTF8.GetBytes(amiiboJsonString));
|
||||
}
|
||||
|
||||
return amiiboJsonString;
|
||||
|
@ -197,6 +197,7 @@ namespace Ryujinx.Ava.Ui.ViewModels
|
||||
private string _pauseKey = "F5";
|
||||
private string _screenshotkey = "F8";
|
||||
private float _volume;
|
||||
private string _backendText;
|
||||
|
||||
public ApplicationData SelectedApplication
|
||||
{
|
||||
@ -335,7 +336,7 @@ namespace Ryujinx.Ava.Ui.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public string GpuStatusText
|
||||
public string GpuNameText
|
||||
{
|
||||
get => _gpuStatusText;
|
||||
set
|
||||
@ -346,6 +347,17 @@ namespace Ryujinx.Ava.Ui.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public string BackendText
|
||||
{
|
||||
get => _backendText;
|
||||
set
|
||||
{
|
||||
_backendText = value;
|
||||
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public string DockedStatusText
|
||||
{
|
||||
get => _dockedStatusText;
|
||||
@ -1261,15 +1273,15 @@ namespace Ryujinx.Ava.Ui.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public async void OpenDlcManager()
|
||||
public async void OpenDownloadableContentManager()
|
||||
{
|
||||
var selection = SelectedApplication;
|
||||
|
||||
if (selection != null)
|
||||
{
|
||||
DlcManagerWindow dlcManager = new(_owner.VirtualFileSystem, ulong.Parse(selection.TitleId, NumberStyles.HexNumber), selection.TitleName);
|
||||
DownloadableContentManagerWindow downloadableContentManager = new(_owner.VirtualFileSystem, ulong.Parse(selection.TitleId, NumberStyles.HexNumber), selection.TitleName);
|
||||
|
||||
await dlcManager.ShowDialog(_owner);
|
||||
await downloadableContentManager.ShowDialog(_owner);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Collections;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Threading;
|
||||
using DynamicData;
|
||||
using LibHac.Tools.FsSystem;
|
||||
using Ryujinx.Audio.Backends.OpenAL;
|
||||
using Ryujinx.Audio.Backends.SDL2;
|
||||
@ -8,18 +10,26 @@ using Ryujinx.Audio.Backends.SoundIo;
|
||||
using Ryujinx.Ava.Common.Locale;
|
||||
using Ryujinx.Ava.Input;
|
||||
using Ryujinx.Ava.Ui.Controls;
|
||||
using Ryujinx.Ava.Ui.Vulkan;
|
||||
using Ryujinx.Ava.Ui.Windows;
|
||||
using Ryujinx.Common.Configuration;
|
||||
using Ryujinx.Common.Configuration.Hid;
|
||||
using Ryujinx.Common.GraphicsDriver;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Graphics.Vulkan;
|
||||
using Ryujinx.HLE.FileSystem;
|
||||
using Ryujinx.HLE.HOS.Services.Time.TimeZone;
|
||||
using Ryujinx.Input;
|
||||
using Ryujinx.Ui.Common.Configuration;
|
||||
using Ryujinx.Ui.Common.Configuration.System;
|
||||
using Silk.NET.Vulkan;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading.Tasks;
|
||||
using TimeZone = Ryujinx.Ava.Ui.Models.TimeZone;
|
||||
|
||||
namespace Ryujinx.Ava.Ui.ViewModels
|
||||
@ -101,6 +111,7 @@ namespace Ryujinx.Ava.Ui.ViewModels
|
||||
public bool IgnoreMissingServices { get; set; }
|
||||
public bool ExpandDramSize { get; set; }
|
||||
public bool EnableShaderCache { get; set; }
|
||||
public bool EnableTextureRecompression { get; set; }
|
||||
public bool EnableFileLog { get; set; }
|
||||
public bool EnableStub { get; set; }
|
||||
public bool EnableInfo { get; set; }
|
||||
@ -115,6 +126,7 @@ namespace Ryujinx.Ava.Ui.ViewModels
|
||||
public bool IsSDL2Enabled { get; set; }
|
||||
public bool EnableCustomTheme { get; set; }
|
||||
public bool IsCustomResolutionScaleActive => _resolutionScale == 0;
|
||||
public bool IsVulkanSelected => GraphicsBackendIndex == 0;
|
||||
|
||||
public string TimeZone { get; set; }
|
||||
public string ShaderDumpPath { get; set; }
|
||||
@ -129,6 +141,18 @@ namespace Ryujinx.Ava.Ui.ViewModels
|
||||
public int OpenglDebugLevel { get; set; }
|
||||
public int MemoryMode { get; set; }
|
||||
public int BaseStyleIndex { get; set; }
|
||||
public int GraphicsBackendIndex
|
||||
{
|
||||
get => graphicsBackendIndex;
|
||||
set
|
||||
{
|
||||
graphicsBackendIndex = value;
|
||||
OnPropertyChanged();
|
||||
OnPropertyChanged(nameof(IsVulkanSelected));
|
||||
}
|
||||
}
|
||||
|
||||
public int PreferredGpuIndex { get; set; }
|
||||
|
||||
public float Volume
|
||||
{
|
||||
@ -148,8 +172,11 @@ namespace Ryujinx.Ava.Ui.ViewModels
|
||||
public AvaloniaList<TimeZone> TimeZones { get; set; }
|
||||
|
||||
public AvaloniaList<string> GameDirectories { get; set; }
|
||||
public ObservableCollection<ComboBoxItem> AvailableGpus { get; set; }
|
||||
|
||||
private KeyboardHotkeys _keyboardHotkeys;
|
||||
private int graphicsBackendIndex;
|
||||
private List<string> _gpuIds = new List<string>();
|
||||
|
||||
public KeyboardHotkeys KeyboardHotkeys
|
||||
{
|
||||
@ -180,12 +207,14 @@ namespace Ryujinx.Ava.Ui.ViewModels
|
||||
{
|
||||
GameDirectories = new AvaloniaList<string>();
|
||||
TimeZones = new AvaloniaList<TimeZone>();
|
||||
AvailableGpus = new ObservableCollection<ComboBoxItem>();
|
||||
_validTzRegions = new List<string>();
|
||||
|
||||
CheckSoundBackends();
|
||||
|
||||
if (Program.PreviewerDetached)
|
||||
{
|
||||
LoadAvailableGpus();
|
||||
LoadCurrentConfiguration();
|
||||
}
|
||||
}
|
||||
@ -197,6 +226,34 @@ namespace Ryujinx.Ava.Ui.ViewModels
|
||||
IsSDL2Enabled = SDL2HardwareDeviceDriver.IsSupported;
|
||||
}
|
||||
|
||||
private unsafe void LoadAvailableGpus()
|
||||
{
|
||||
_gpuIds = new List<string>();
|
||||
List<string> names = new List<string>();
|
||||
if (!Program.UseVulkan)
|
||||
{
|
||||
var devices = VulkanRenderer.GetPhysicalDevices();
|
||||
foreach (var device in devices)
|
||||
{
|
||||
_gpuIds.Add(device.Id);
|
||||
names.Add($"{device.Name} {(device.IsDiscrete ? "(dGpu)" : "")}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var device in VulkanPhysicalDevice.SuitableDevices)
|
||||
{
|
||||
_gpuIds.Add(VulkanInitialization.StringFromIdPair(device.Value.VendorID, device.Value.DeviceID));
|
||||
var value = device.Value;
|
||||
var name = value.DeviceName;
|
||||
names.Add($"{Marshal.PtrToStringAnsi((IntPtr)name)} {(device.Value.DeviceType == PhysicalDeviceType.DiscreteGpu ? "(dGpu)" : "")}");
|
||||
}
|
||||
}
|
||||
|
||||
AvailableGpus.Clear();
|
||||
AvailableGpus.AddRange(names.Select(x => new ComboBoxItem() { Content = x }));
|
||||
}
|
||||
|
||||
public void LoadTimeZones()
|
||||
{
|
||||
_timeZoneContentManager = new TimeZoneContentManager();
|
||||
@ -266,6 +323,7 @@ namespace Ryujinx.Ava.Ui.ViewModels
|
||||
IgnoreMissingServices = config.System.IgnoreMissingServices;
|
||||
ExpandDramSize = config.System.ExpandRam;
|
||||
EnableShaderCache = config.Graphics.EnableShaderCache;
|
||||
EnableTextureRecompression = config.Graphics.EnableTextureRecompression;
|
||||
EnableFileLog = config.Logger.EnableFileLog;
|
||||
EnableStub = config.Logger.EnableStub;
|
||||
EnableInfo = config.Logger.EnableInfo;
|
||||
@ -286,6 +344,9 @@ namespace Ryujinx.Ava.Ui.ViewModels
|
||||
ShaderDumpPath = config.Graphics.ShadersDumpPath;
|
||||
CustomThemePath = config.Ui.CustomThemePath;
|
||||
BaseStyleIndex = config.Ui.BaseStyle == "Light" ? 0 : 1;
|
||||
GraphicsBackendIndex = (int)config.Graphics.GraphicsBackend.Value;
|
||||
|
||||
PreferredGpuIndex = _gpuIds.Contains(config.Graphics.PreferredGpu) ? _gpuIds.IndexOf(config.Graphics.PreferredGpu) : 0;
|
||||
|
||||
Language = (int)config.System.Language.Value;
|
||||
Region = (int)config.System.Region.Value;
|
||||
@ -313,7 +374,7 @@ namespace Ryujinx.Ava.Ui.ViewModels
|
||||
_previousVolumeLevel = Volume;
|
||||
}
|
||||
|
||||
public void SaveSettings()
|
||||
public async Task SaveSettings()
|
||||
{
|
||||
List<string> gameDirs = new List<string>(GameDirectories);
|
||||
|
||||
@ -324,6 +385,8 @@ namespace Ryujinx.Ava.Ui.ViewModels
|
||||
config.System.TimeZone.Value = TimeZone;
|
||||
}
|
||||
|
||||
bool requiresRestart = config.Graphics.GraphicsBackend.Value != (GraphicsBackend)GraphicsBackendIndex;
|
||||
|
||||
config.Logger.EnableError.Value = EnableError;
|
||||
config.Logger.EnableTrace.Value = EnableTrace;
|
||||
config.Logger.EnableWarn.Value = EnableWarn;
|
||||
@ -341,6 +404,8 @@ namespace Ryujinx.Ava.Ui.ViewModels
|
||||
config.HideCursorOnIdle.Value = HideCursorOnIdle;
|
||||
config.Graphics.EnableVsync.Value = EnableVsync;
|
||||
config.Graphics.EnableShaderCache.Value = EnableShaderCache;
|
||||
config.Graphics.EnableTextureRecompression.Value = EnableTextureRecompression;
|
||||
config.Graphics.GraphicsBackend.Value = (GraphicsBackend)GraphicsBackendIndex;
|
||||
config.System.EnablePtc.Value = EnablePptc;
|
||||
config.System.EnableInternetAccess.Value = EnableInternetAccess;
|
||||
config.System.EnableFsIntegrityChecks.Value = EnableFsIntegrityChecks;
|
||||
@ -354,6 +419,20 @@ namespace Ryujinx.Ava.Ui.ViewModels
|
||||
config.System.Language.Value = (Language)Language;
|
||||
config.System.Region.Value = (Region)Region;
|
||||
|
||||
var selectedGpu = _gpuIds.ElementAtOrDefault(PreferredGpuIndex);
|
||||
if (!requiresRestart)
|
||||
{
|
||||
var platform = AvaloniaLocator.Current.GetService<VulkanPlatformInterface>();
|
||||
if (platform != null)
|
||||
{
|
||||
var physicalDevice = platform.PhysicalDevice;
|
||||
|
||||
requiresRestart = physicalDevice.DeviceId != selectedGpu;
|
||||
}
|
||||
}
|
||||
|
||||
config.Graphics.PreferredGpu.Value = selectedGpu;
|
||||
|
||||
if (ConfigurationState.Instance.Graphics.BackendThreading != (BackendThreading)GraphicsBackendMultithreadingIndex)
|
||||
{
|
||||
DriverUtilities.ToggleOGLThreading(GraphicsBackendMultithreadingIndex == (int)BackendThreading.Off);
|
||||
@ -392,6 +471,20 @@ namespace Ryujinx.Ava.Ui.ViewModels
|
||||
MainWindow.UpdateGraphicsConfig();
|
||||
|
||||
_previousVolumeLevel = Volume;
|
||||
|
||||
if (requiresRestart)
|
||||
{
|
||||
var choice = await ContentDialogHelper.CreateChoiceDialog(
|
||||
LocaleManager.Instance["SettingsAppRequiredRestartMessage"],
|
||||
LocaleManager.Instance["SettingsGpuBackendRestartMessage"],
|
||||
LocaleManager.Instance["SettingsGpuBackendRestartSubMessage"]);
|
||||
|
||||
if (choice)
|
||||
{
|
||||
Process.Start(Environment.ProcessPath);
|
||||
Environment.Exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void RevertIfNotSaved()
|
||||
|
@ -43,11 +43,9 @@ namespace Ryujinx.Ava.Ui.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsHighlightedProfileEditable =>
|
||||
_highlightedProfile != null;
|
||||
public bool IsHighlightedProfileEditable => _highlightedProfile != null;
|
||||
|
||||
public bool IsHighlightedProfileDeletable =>
|
||||
_highlightedProfile != null && _highlightedProfile.UserId != AccountManager.DefaultUserId;
|
||||
public bool IsHighlightedProfileDeletable => _highlightedProfile != null && _highlightedProfile.UserId != AccountManager.DefaultUserId;
|
||||
|
||||
public UserProfile HighlightedProfile
|
||||
{
|
||||
@ -62,16 +60,13 @@ namespace Ryujinx.Ava.Ui.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
public void Dispose() { }
|
||||
|
||||
public void LoadProfiles()
|
||||
{
|
||||
Profiles.Clear();
|
||||
|
||||
var profiles = _owner.AccountManager.GetAllUsers()
|
||||
.OrderByDescending(x => x.AccountState == AccountState.Open);
|
||||
var profiles = _owner.AccountManager.GetAllUsers().OrderByDescending(x => x.AccountState == AccountState.Open);
|
||||
|
||||
foreach (var profile in profiles)
|
||||
{
|
||||
@ -94,6 +89,7 @@ namespace Ryujinx.Ava.Ui.ViewModels
|
||||
public void AddUser()
|
||||
{
|
||||
UserProfile userProfile = null;
|
||||
|
||||
_owner.Navigate(typeof(UserEditor), (this._owner, userProfile, true));
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.Threading;
|
||||
using Ryujinx.Ava.Common.Locale;
|
||||
using Ryujinx.Common.Utilities;
|
||||
@ -27,9 +26,6 @@ namespace Ryujinx.Ava.Ui.Windows
|
||||
DataContext = this;
|
||||
|
||||
InitializeComponent();
|
||||
#if DEBUG
|
||||
this.AttachDevTools();
|
||||
#endif
|
||||
|
||||
_ = DownloadPatronsJson();
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Ryujinx.Ava.Common.Locale;
|
||||
using Ryujinx.Ava.Ui.Models;
|
||||
using Ryujinx.Ava.Ui.ViewModels;
|
||||
@ -18,9 +17,7 @@ namespace Ryujinx.Ava.Ui.Windows
|
||||
DataContext = ViewModel;
|
||||
|
||||
InitializeComponent();
|
||||
#if DEBUG
|
||||
this.AttachDevTools();
|
||||
#endif
|
||||
|
||||
Title = $"Ryujinx {Program.Version} - " + LocaleManager.Instance["Amiibo"];
|
||||
}
|
||||
|
||||
@ -31,9 +28,7 @@ namespace Ryujinx.Ava.Ui.Windows
|
||||
DataContext = ViewModel;
|
||||
|
||||
InitializeComponent();
|
||||
#if DEBUG
|
||||
this.AttachDevTools();
|
||||
#endif
|
||||
|
||||
if (Program.PreviewerDetached)
|
||||
{
|
||||
Title = $"Ryujinx {Program.Version} - " + LocaleManager.Instance["Amiibo"];
|
||||
|
@ -1,21 +1,24 @@
|
||||
<window:StyleableWindow x:Class="Ryujinx.Ava.Ui.Windows.CheatWindow"
|
||||
<window:StyleableWindow
|
||||
x:Class="Ryujinx.Ava.Ui.Windows.CheatWindow"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:locale="clr-namespace:Ryujinx.Ava.Common.Locale"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:model="clr-namespace:Ryujinx.Ava.Ui.Models"
|
||||
xmlns:window="clr-namespace:Ryujinx.Ava.Ui.Windows"
|
||||
mc:Ignorable="d"
|
||||
Width="500" MinHeight="500" Height="500"
|
||||
Width="500"
|
||||
Height="500"
|
||||
MinWidth="500"
|
||||
MinHeight="500"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
MinWidth="500">
|
||||
mc:Ignorable="d">
|
||||
<Window.Styles>
|
||||
<Style Selector="TreeViewItem">
|
||||
<Setter Property="IsExpanded" Value="True" />
|
||||
</Style>
|
||||
</Window.Styles>
|
||||
<Grid Name="DlcGrid" Margin="15">
|
||||
<Grid Name="CheatGrid" Margin="15">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
@ -24,14 +27,14 @@
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock
|
||||
Grid.Row="1"
|
||||
MaxWidth="500"
|
||||
Margin="20,15,20,20"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
MaxWidth="500"
|
||||
LineHeight="18"
|
||||
TextWrapping="Wrap"
|
||||
Text="{Binding Heading}"
|
||||
TextAlignment="Center" />
|
||||
TextAlignment="Center"
|
||||
TextWrapping="Wrap" />
|
||||
<Border
|
||||
Grid.Row="2"
|
||||
Margin="5"
|
||||
@ -39,32 +42,38 @@
|
||||
VerticalAlignment="Stretch"
|
||||
BorderBrush="Gray"
|
||||
BorderThickness="1">
|
||||
<TreeView Items="{Binding LoadedCheats}"
|
||||
<TreeView
|
||||
Name="CheatsView"
|
||||
MinHeight="300"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
Name="CheatsView"
|
||||
MinHeight="300">
|
||||
Items="{Binding LoadedCheats}">
|
||||
<TreeView.Styles>
|
||||
<Styles>
|
||||
<Style Selector="TreeViewItem:empty /template/ ItemsPresenter">
|
||||
<Setter Property="IsVisible" Value="False"/>
|
||||
<Setter Property="IsVisible" Value="False" />
|
||||
</Style>
|
||||
</Styles>
|
||||
</TreeView.Styles>
|
||||
<TreeView.DataTemplates>
|
||||
<TreeDataTemplate DataType="model:CheatsList" ItemsSource="{Binding}">
|
||||
<StackPanel HorizontalAlignment="Left" Orientation="Horizontal">
|
||||
<CheckBox IsChecked="{Binding IsEnabled}" MinWidth="20" />
|
||||
<TextBlock Width="150"
|
||||
Text="{Binding BuildId}" />
|
||||
<TextBlock
|
||||
Text="{Binding Path}" />
|
||||
<CheckBox MinWidth="20" IsChecked="{Binding IsEnabled}" />
|
||||
<TextBlock Width="150" Text="{Binding BuildId}" />
|
||||
<TextBlock Text="{Binding Path}" />
|
||||
</StackPanel>
|
||||
</TreeDataTemplate>
|
||||
<DataTemplate x:DataType="model:CheatModel">
|
||||
<StackPanel Orientation="Horizontal" Margin="0" HorizontalAlignment="Left">
|
||||
<CheckBox IsChecked="{Binding IsEnabled}" Padding="0" Margin="5,0" MinWidth="20" />
|
||||
<TextBlock Text="{Binding CleanName}" VerticalAlignment="Center" />
|
||||
<StackPanel
|
||||
Margin="0"
|
||||
HorizontalAlignment="Left"
|
||||
Orientation="Horizontal">
|
||||
<CheckBox
|
||||
MinWidth="20"
|
||||
Margin="5,0"
|
||||
Padding="0"
|
||||
IsChecked="{Binding IsEnabled}" />
|
||||
<TextBlock VerticalAlignment="Center" Text="{Binding CleanName}" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</TreeView.DataTemplates>
|
||||
@ -79,8 +88,8 @@
|
||||
Name="SaveButton"
|
||||
MinWidth="90"
|
||||
Margin="5"
|
||||
IsVisible="{Binding !NoCheatsFound}"
|
||||
Command="{Binding Save}">
|
||||
Command="{Binding Save}"
|
||||
IsVisible="{Binding !NoCheatsFound}">
|
||||
<TextBlock Text="{locale:Locale SettingsButtonSave}" />
|
||||
</Button>
|
||||
<Button
|
||||
|
@ -1,6 +1,5 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Collections;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Ryujinx.Ava.Common.Locale;
|
||||
using Ryujinx.Ava.Ui.Models;
|
||||
using Ryujinx.HLE.FileSystem;
|
||||
@ -26,7 +25,6 @@ namespace Ryujinx.Ava.Ui.Windows
|
||||
DataContext = this;
|
||||
|
||||
InitializeComponent();
|
||||
AttachDebugDevTools();
|
||||
|
||||
Title = $"Ryujinx {Program.Version} - " + LocaleManager.Instance["CheatWindowTitle"];
|
||||
}
|
||||
@ -38,9 +36,6 @@ namespace Ryujinx.Ava.Ui.Windows
|
||||
Heading = string.Format(LocaleManager.Instance["CheatWindowHeading"], titleName, titleId.ToUpper());
|
||||
|
||||
InitializeComponent();
|
||||
#if DEBUG
|
||||
this.AttachDevTools();
|
||||
#endif
|
||||
|
||||
string modsBasePath = virtualFileSystem.ModLoader.GetModsBasePath();
|
||||
string titleModsPath = virtualFileSystem.ModLoader.GetTitleDir(modsBasePath, titleId);
|
||||
@ -96,12 +91,6 @@ namespace Ryujinx.Ava.Ui.Windows
|
||||
Title = $"Ryujinx {Program.Version} - " + LocaleManager.Instance["CheatWindowTitle"];
|
||||
}
|
||||
|
||||
[Conditional("DEBUG")]
|
||||
private void AttachDebugDevTools()
|
||||
{
|
||||
this.AttachDevTools();
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
if (NoCheatsFound)
|
||||
|
@ -3,24 +3,14 @@ using Avalonia.Controls.Primitives;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.LogicalTree;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.Threading;
|
||||
using Avalonia.VisualTree;
|
||||
using Ryujinx.Ava.Common.Locale;
|
||||
using Ryujinx.Ava.Ui.Controls;
|
||||
using Ryujinx.Ava.Ui.Models;
|
||||
using Ryujinx.Ava.Ui.ViewModels;
|
||||
using Ryujinx.Common.Configuration.Hid;
|
||||
using Ryujinx.Common.Configuration.Hid.Controller;
|
||||
using Ryujinx.Input;
|
||||
using Ryujinx.Input.Assigner;
|
||||
using Ryujinx.Ui.Common.Configuration;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Key = Ryujinx.Input.Key;
|
||||
|
||||
namespace Ryujinx.Ava.Ui.Windows
|
||||
{
|
||||
|
@ -1,254 +0,0 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Collections;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Threading;
|
||||
using LibHac.Common;
|
||||
using LibHac.Fs;
|
||||
using LibHac.Fs.Fsa;
|
||||
using LibHac.FsSystem;
|
||||
using LibHac.Tools.Fs;
|
||||
using LibHac.Tools.FsSystem;
|
||||
using LibHac.Tools.FsSystem.NcaUtils;
|
||||
using Ryujinx.Ava.Common.Locale;
|
||||
using Ryujinx.Ava.Ui.Controls;
|
||||
using Ryujinx.Ava.Ui.Models;
|
||||
using Ryujinx.Common.Configuration;
|
||||
using Ryujinx.Common.Utilities;
|
||||
using Ryujinx.HLE.FileSystem;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Path = System.IO.Path;
|
||||
|
||||
namespace Ryujinx.Ava.Ui.Windows
|
||||
{
|
||||
public partial class DlcManagerWindow : StyleableWindow
|
||||
{
|
||||
private readonly List<DlcContainer> _dlcContainerList;
|
||||
private readonly string _dlcJsonPath;
|
||||
|
||||
public VirtualFileSystem VirtualFileSystem { get; }
|
||||
|
||||
public AvaloniaList<DlcModel> Dlcs { get; set; }
|
||||
public ulong TitleId { get; }
|
||||
public string TitleName { get; }
|
||||
|
||||
public string Heading => string.Format(LocaleManager.Instance["DlcWindowHeading"], TitleName, TitleId.ToString("X16"));
|
||||
|
||||
public DlcManagerWindow()
|
||||
{
|
||||
DataContext = this;
|
||||
|
||||
InitializeComponent();
|
||||
AttachDebugDevTools();
|
||||
|
||||
Title = $"Ryujinx {Program.Version} - " + LocaleManager.Instance["DlcWindowTitle"];
|
||||
}
|
||||
|
||||
public DlcManagerWindow(VirtualFileSystem virtualFileSystem, ulong titleId, string titleName)
|
||||
{
|
||||
VirtualFileSystem = virtualFileSystem;
|
||||
TitleId = titleId;
|
||||
TitleName = titleName;
|
||||
|
||||
_dlcJsonPath = Path.Combine(AppDataManager.GamesDirPath, titleId.ToString("x16"), "dlc.json");
|
||||
|
||||
try
|
||||
{
|
||||
_dlcContainerList = JsonHelper.DeserializeFromFile<List<DlcContainer>>(_dlcJsonPath);
|
||||
}
|
||||
catch
|
||||
{
|
||||
_dlcContainerList = new List<DlcContainer>();
|
||||
}
|
||||
|
||||
DataContext = this;
|
||||
|
||||
InitializeComponent();
|
||||
AttachDebugDevTools();
|
||||
|
||||
Title = $"Ryujinx {Program.Version} - " + LocaleManager.Instance["DlcWindowTitle"];
|
||||
|
||||
LoadDlcs();
|
||||
}
|
||||
|
||||
[Conditional("DEBUG")]
|
||||
private void AttachDebugDevTools()
|
||||
{
|
||||
this.AttachDevTools();
|
||||
}
|
||||
|
||||
private void LoadDlcs()
|
||||
{
|
||||
foreach (DlcContainer dlcContainer in _dlcContainerList)
|
||||
{
|
||||
using FileStream containerFile = File.OpenRead(dlcContainer.Path);
|
||||
|
||||
PartitionFileSystem pfs = new PartitionFileSystem(containerFile.AsStorage());
|
||||
|
||||
VirtualFileSystem.ImportTickets(pfs);
|
||||
|
||||
foreach (DlcNca dlcNca in dlcContainer.DlcNcaList)
|
||||
{
|
||||
using var ncaFile = new UniqueRef<IFile>();
|
||||
pfs.OpenFile(ref ncaFile.Ref(), dlcNca.Path.ToU8Span(), OpenMode.Read).ThrowIfFailure();
|
||||
|
||||
Nca nca = TryCreateNca(ncaFile.Get.AsStorage(), dlcContainer.Path);
|
||||
|
||||
if (nca != null)
|
||||
{
|
||||
Dlcs.Add(new DlcModel(nca.Header.TitleId.ToString("X16"), dlcContainer.Path, dlcNca.Path,
|
||||
dlcNca.Enabled));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Nca TryCreateNca(IStorage ncaStorage, string containerPath)
|
||||
{
|
||||
try
|
||||
{
|
||||
return new Nca(VirtualFileSystem.KeySet, ncaStorage);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Dispatcher.UIThread.InvokeAsync(async () =>
|
||||
{
|
||||
await ContentDialogHelper.CreateErrorDialog(string.Format(LocaleManager.Instance[
|
||||
"DialogDlcLoadNcaErrorMessage"], ex.Message, containerPath));
|
||||
});
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private async Task AddDlc(string path)
|
||||
{
|
||||
if (!File.Exists(path) || Dlcs.FirstOrDefault(x => x.ContainerPath == path) != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
using (FileStream containerFile = File.OpenRead(path))
|
||||
{
|
||||
PartitionFileSystem pfs = new PartitionFileSystem(containerFile.AsStorage());
|
||||
bool containsDlc = false;
|
||||
|
||||
VirtualFileSystem.ImportTickets(pfs);
|
||||
|
||||
foreach (DirectoryEntryEx fileEntry in pfs.EnumerateEntries("/", "*.nca"))
|
||||
{
|
||||
using var ncaFile = new UniqueRef<IFile>();
|
||||
|
||||
pfs.OpenFile(ref ncaFile.Ref(), fileEntry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
|
||||
|
||||
Nca nca = TryCreateNca(ncaFile.Get.AsStorage(), path);
|
||||
|
||||
if (nca == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (nca.Header.ContentType == NcaContentType.PublicData)
|
||||
{
|
||||
if ((nca.Header.TitleId & 0xFFFFFFFFFFFFE000) != TitleId)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
Dlcs.Add(new DlcModel(nca.Header.TitleId.ToString("X16"), path, fileEntry.FullPath, true));
|
||||
|
||||
containsDlc = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!containsDlc)
|
||||
{
|
||||
await ContentDialogHelper.CreateErrorDialog(LocaleManager.Instance["DialogDlcNoDlcErrorMessage"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void RemoveDlcs(bool removeSelectedOnly = false)
|
||||
{
|
||||
if (removeSelectedOnly)
|
||||
{
|
||||
Dlcs.RemoveAll(Dlcs.Where(x => x.IsEnabled).ToList());
|
||||
}
|
||||
else
|
||||
{
|
||||
Dlcs.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveSelected()
|
||||
{
|
||||
RemoveDlcs(true);
|
||||
}
|
||||
|
||||
public void RemoveAll()
|
||||
{
|
||||
RemoveDlcs();
|
||||
}
|
||||
|
||||
public async void Add()
|
||||
{
|
||||
OpenFileDialog dialog = new OpenFileDialog() { Title = LocaleManager.Instance["SelectDlcDialogTitle"], AllowMultiple = true };
|
||||
|
||||
dialog.Filters.Add(new FileDialogFilter { Name = "NSP", Extensions = { "nsp" } });
|
||||
|
||||
string[] files = await dialog.ShowAsync(this);
|
||||
|
||||
if (files != null)
|
||||
{
|
||||
foreach (string file in files)
|
||||
{
|
||||
await AddDlc(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
_dlcContainerList.Clear();
|
||||
|
||||
DlcContainer container = default;
|
||||
|
||||
foreach (DlcModel dlc in Dlcs)
|
||||
{
|
||||
if (container.Path != dlc.ContainerPath)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(container.Path))
|
||||
{
|
||||
_dlcContainerList.Add(container);
|
||||
}
|
||||
|
||||
container = new DlcContainer { Path = dlc.ContainerPath, DlcNcaList = new List<DlcNca>() };
|
||||
}
|
||||
|
||||
container.DlcNcaList.Add(new DlcNca
|
||||
{
|
||||
Enabled = dlc.IsEnabled,
|
||||
TitleId = Convert.ToUInt64(dlc.TitleId, 16),
|
||||
Path = dlc.FullPath
|
||||
});
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(container.Path))
|
||||
{
|
||||
_dlcContainerList.Add(container);
|
||||
}
|
||||
|
||||
using (FileStream dlcJsonStream = File.Create(_dlcJsonPath, 4096, FileOptions.WriteThrough))
|
||||
{
|
||||
dlcJsonStream.Write(Encoding.UTF8.GetBytes(JsonHelper.Serialize(_dlcContainerList, true)));
|
||||
}
|
||||
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
<window:StyleableWindow
|
||||
x:Class="Ryujinx.Ava.Ui.Windows.DlcManagerWindow"
|
||||
x:Class="Ryujinx.Ava.Ui.Windows.DownloadableContentManagerWindow"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
@ -11,7 +11,7 @@
|
||||
WindowStartupLocation="CenterOwner"
|
||||
MinWidth="600"
|
||||
mc:Ignorable="d">
|
||||
<Grid Name="DlcGrid" Margin="15">
|
||||
<Grid Name="DownloadableContentGrid" Margin="15">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
@ -40,7 +40,7 @@
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
HorizontalScrollBarVisibility="Auto"
|
||||
Items="{Binding Dlcs}"
|
||||
Items="{Binding DownloadableContents}"
|
||||
VerticalScrollBarVisibility="Auto">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTemplateColumn Width="90">
|
||||
@ -50,7 +50,7 @@
|
||||
Width="50"
|
||||
MinWidth="40"
|
||||
HorizontalAlignment="Right"
|
||||
IsChecked="{Binding IsEnabled}" />
|
||||
IsChecked="{Binding Enabled}" />
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
<DataGridTemplateColumn.Header>
|
||||
@ -116,7 +116,7 @@
|
||||
Name="SaveButton"
|
||||
MinWidth="90"
|
||||
Margin="5"
|
||||
Command="{Binding Save}">
|
||||
Command="{Binding SaveAndClose}">
|
||||
<TextBlock Text="{locale:Locale SettingsButtonSave}" />
|
||||
</Button>
|
||||
<Button
|
266
Ryujinx.Ava/Ui/Windows/DownloadableContentManagerWindow.axaml.cs
Normal file
266
Ryujinx.Ava/Ui/Windows/DownloadableContentManagerWindow.axaml.cs
Normal file
@ -0,0 +1,266 @@
|
||||
using Avalonia.Collections;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Threading;
|
||||
using LibHac.Common;
|
||||
using LibHac.Fs;
|
||||
using LibHac.Fs.Fsa;
|
||||
using LibHac.FsSystem;
|
||||
using LibHac.Tools.Fs;
|
||||
using LibHac.Tools.FsSystem;
|
||||
using LibHac.Tools.FsSystem.NcaUtils;
|
||||
using Ryujinx.Ava.Common.Locale;
|
||||
using Ryujinx.Ava.Ui.Controls;
|
||||
using Ryujinx.Ava.Ui.Models;
|
||||
using Ryujinx.Common.Configuration;
|
||||
using Ryujinx.Common.Utilities;
|
||||
using Ryujinx.HLE.FileSystem;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Path = System.IO.Path;
|
||||
|
||||
namespace Ryujinx.Ava.Ui.Windows
|
||||
{
|
||||
public partial class DownloadableContentManagerWindow : StyleableWindow
|
||||
{
|
||||
private readonly List<DownloadableContentContainer> _downloadableContentContainerList;
|
||||
private readonly string _downloadableContentJsonPath;
|
||||
|
||||
public VirtualFileSystem VirtualFileSystem { get; }
|
||||
public AvaloniaList<DownloadableContentModel> DownloadableContents { get; set; } = new AvaloniaList<DownloadableContentModel>();
|
||||
public ulong TitleId { get; }
|
||||
public string TitleName { get; }
|
||||
|
||||
public string Heading => string.Format(LocaleManager.Instance["DlcWindowHeading"], TitleName, TitleId.ToString("X16"));
|
||||
|
||||
public DownloadableContentManagerWindow()
|
||||
{
|
||||
DataContext = this;
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
Title = $"Ryujinx {Program.Version} - " + LocaleManager.Instance["DlcWindowTitle"];
|
||||
}
|
||||
|
||||
public DownloadableContentManagerWindow(VirtualFileSystem virtualFileSystem, ulong titleId, string titleName)
|
||||
{
|
||||
VirtualFileSystem = virtualFileSystem;
|
||||
TitleId = titleId;
|
||||
TitleName = titleName;
|
||||
|
||||
_downloadableContentJsonPath = Path.Combine(AppDataManager.GamesDirPath, titleId.ToString("x16"), "dlc.json");
|
||||
|
||||
try
|
||||
{
|
||||
_downloadableContentContainerList = JsonHelper.DeserializeFromFile<List<DownloadableContentContainer>>(_downloadableContentJsonPath);
|
||||
}
|
||||
catch
|
||||
{
|
||||
_downloadableContentContainerList = new List<DownloadableContentContainer>();
|
||||
}
|
||||
|
||||
DataContext = this;
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
Title = $"Ryujinx {Program.Version} - " + LocaleManager.Instance["DlcWindowTitle"];
|
||||
|
||||
LoadDownloadableContents();
|
||||
}
|
||||
|
||||
private void LoadDownloadableContents()
|
||||
{
|
||||
foreach (DownloadableContentContainer downloadableContentContainer in _downloadableContentContainerList)
|
||||
{
|
||||
if (File.Exists(downloadableContentContainer.ContainerPath))
|
||||
{
|
||||
using FileStream containerFile = File.OpenRead(downloadableContentContainer.ContainerPath);
|
||||
|
||||
PartitionFileSystem pfs = new PartitionFileSystem(containerFile.AsStorage());
|
||||
|
||||
VirtualFileSystem.ImportTickets(pfs);
|
||||
|
||||
foreach (DownloadableContentNca downloadableContentNca in downloadableContentContainer.DownloadableContentNcaList)
|
||||
{
|
||||
using var ncaFile = new UniqueRef<IFile>();
|
||||
|
||||
pfs.OpenFile(ref ncaFile.Ref(), downloadableContentNca.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
|
||||
|
||||
Nca nca = TryCreateNca(ncaFile.Get.AsStorage(), downloadableContentContainer.ContainerPath);
|
||||
if (nca != null)
|
||||
{
|
||||
DownloadableContents.Add(new DownloadableContentModel(nca.Header.TitleId.ToString("X16"),
|
||||
downloadableContentContainer.ContainerPath,
|
||||
downloadableContentNca.FullPath,
|
||||
downloadableContentNca.Enabled));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: Save the list again to remove leftovers.
|
||||
Save();
|
||||
}
|
||||
|
||||
private Nca TryCreateNca(IStorage ncaStorage, string containerPath)
|
||||
{
|
||||
try
|
||||
{
|
||||
return new Nca(VirtualFileSystem.KeySet, ncaStorage);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Dispatcher.UIThread.InvokeAsync(async () =>
|
||||
{
|
||||
await ContentDialogHelper.CreateErrorDialog(string.Format(LocaleManager.Instance["DialogDlcLoadNcaErrorMessage"], ex.Message, containerPath));
|
||||
});
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private async Task AddDownloadableContent(string path)
|
||||
{
|
||||
if (!File.Exists(path) || DownloadableContents.FirstOrDefault(x => x.ContainerPath == path) != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
using (FileStream containerFile = File.OpenRead(path))
|
||||
{
|
||||
PartitionFileSystem pfs = new PartitionFileSystem(containerFile.AsStorage());
|
||||
bool containsDownloadableContent = false;
|
||||
|
||||
VirtualFileSystem.ImportTickets(pfs);
|
||||
|
||||
foreach (DirectoryEntryEx fileEntry in pfs.EnumerateEntries("/", "*.nca"))
|
||||
{
|
||||
using var ncaFile = new UniqueRef<IFile>();
|
||||
|
||||
pfs.OpenFile(ref ncaFile.Ref(), fileEntry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
|
||||
|
||||
Nca nca = TryCreateNca(ncaFile.Get.AsStorage(), path);
|
||||
|
||||
if (nca == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (nca.Header.ContentType == NcaContentType.PublicData)
|
||||
{
|
||||
if ((nca.Header.TitleId & 0xFFFFFFFFFFFFE000) != TitleId)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
DownloadableContents.Add(new DownloadableContentModel(nca.Header.TitleId.ToString("X16"), path, fileEntry.FullPath, true));
|
||||
|
||||
containsDownloadableContent = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!containsDownloadableContent)
|
||||
{
|
||||
await ContentDialogHelper.CreateErrorDialog(LocaleManager.Instance["DialogDlcNoDlcErrorMessage"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void RemoveDownloadableContents(bool removeSelectedOnly = false)
|
||||
{
|
||||
if (removeSelectedOnly)
|
||||
{
|
||||
DownloadableContents.RemoveAll(DownloadableContents.Where(x => x.Enabled).ToList());
|
||||
}
|
||||
else
|
||||
{
|
||||
DownloadableContents.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveSelected()
|
||||
{
|
||||
RemoveDownloadableContents(true);
|
||||
}
|
||||
|
||||
public void RemoveAll()
|
||||
{
|
||||
RemoveDownloadableContents();
|
||||
}
|
||||
|
||||
public async void Add()
|
||||
{
|
||||
OpenFileDialog dialog = new OpenFileDialog()
|
||||
{
|
||||
Title = LocaleManager.Instance["SelectDlcDialogTitle"],
|
||||
AllowMultiple = true
|
||||
};
|
||||
|
||||
dialog.Filters.Add(new FileDialogFilter
|
||||
{
|
||||
Name = "NSP",
|
||||
Extensions = { "nsp" }
|
||||
});
|
||||
|
||||
string[] files = await dialog.ShowAsync(this);
|
||||
|
||||
if (files != null)
|
||||
{
|
||||
foreach (string file in files)
|
||||
{
|
||||
await AddDownloadableContent(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
_downloadableContentContainerList.Clear();
|
||||
|
||||
DownloadableContentContainer container = default;
|
||||
|
||||
foreach (DownloadableContentModel downloadableContent in DownloadableContents)
|
||||
{
|
||||
if (container.ContainerPath != downloadableContent.ContainerPath)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(container.ContainerPath))
|
||||
{
|
||||
_downloadableContentContainerList.Add(container);
|
||||
}
|
||||
|
||||
container = new DownloadableContentContainer
|
||||
{
|
||||
ContainerPath = downloadableContent.ContainerPath,
|
||||
DownloadableContentNcaList = new List<DownloadableContentNca>()
|
||||
};
|
||||
}
|
||||
|
||||
container.DownloadableContentNcaList.Add(new DownloadableContentNca
|
||||
{
|
||||
Enabled = downloadableContent.Enabled,
|
||||
TitleId = Convert.ToUInt64(downloadableContent.TitleId, 16),
|
||||
FullPath = downloadableContent.FullPath
|
||||
});
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(container.ContainerPath))
|
||||
{
|
||||
_downloadableContentContainerList.Add(container);
|
||||
}
|
||||
|
||||
using (FileStream downloadableContentJsonStream = File.Create(_downloadableContentJsonPath, 4096, FileOptions.WriteThrough))
|
||||
{
|
||||
downloadableContentJsonStream.Write(Encoding.UTF8.GetBytes(JsonHelper.Serialize(_downloadableContentContainerList, true)));
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveAndClose()
|
||||
{
|
||||
Save();
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
@ -111,14 +111,20 @@
|
||||
Command="{ReflectionBinding ToggleFullscreen}"
|
||||
Header="{locale:Locale MenuBarOptionsToggleFullscreen}"
|
||||
InputGesture="F11" />
|
||||
<MenuItem Header="{locale:Locale MenuBarOptionsStartGamesInFullscreen}">
|
||||
<MenuItem>
|
||||
<MenuItem.Icon>
|
||||
<CheckBox IsChecked="{Binding StartGamesInFullscreen, Mode=TwoWay}" />
|
||||
<CheckBox IsChecked="{Binding StartGamesInFullscreen, Mode=TwoWay}"
|
||||
MinWidth="250">
|
||||
<TextBlock Text="{locale:Locale MenuBarOptionsStartGamesInFullscreen}"/>
|
||||
</CheckBox>
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="{locale:Locale MenuBarOptionsShowConsole}" IsVisible="{Binding ShowConsoleVisible}">
|
||||
<MenuItem IsVisible="{Binding ShowConsoleVisible}">
|
||||
<MenuItem.Icon>
|
||||
<CheckBox IsChecked="{Binding ShowConsole, Mode=TwoWay}" />
|
||||
<CheckBox IsChecked="{Binding ShowConsole, Mode=TwoWay}"
|
||||
MinWidth="250">
|
||||
<TextBlock Text="{locale:Locale MenuBarOptionsShowConsole}"/>
|
||||
</CheckBox>
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<Separator />
|
||||
@ -167,6 +173,10 @@
|
||||
Command="{ReflectionBinding ChangeLanguage}"
|
||||
CommandParameter="zh_CN"
|
||||
Header="Simplified Chinese" />
|
||||
<MenuItem
|
||||
Command="{ReflectionBinding ChangeLanguage}"
|
||||
CommandParameter="zh_TW"
|
||||
Header="Traditional Chinese (Taiwan)" />
|
||||
</MenuItem>
|
||||
<Separator />
|
||||
<MenuItem
|
||||
@ -247,7 +257,7 @@
|
||||
</DockPanel>
|
||||
</StackPanel>
|
||||
<ContentControl
|
||||
Name="Content"
|
||||
Name="MainContent"
|
||||
Grid.Row="1"
|
||||
Padding="0"
|
||||
HorizontalAlignment="Stretch"
|
||||
@ -711,7 +721,21 @@
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
IsVisible="{Binding !ShowLoadProgress}"
|
||||
Text="{Binding GpuStatusText}"
|
||||
Text="{Binding BackendText}"
|
||||
TextAlignment="Left" />
|
||||
<Border
|
||||
Width="2"
|
||||
Height="12"
|
||||
Margin="2,0"
|
||||
BorderBrush="Gray"
|
||||
BorderThickness="1"
|
||||
IsVisible="{Binding !ShowLoadProgress}" />
|
||||
<TextBlock
|
||||
Margin="5,0,5,0"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
IsVisible="{Binding !ShowLoadProgress}"
|
||||
Text="{Binding GpuNameText}"
|
||||
TextAlignment="Left" />
|
||||
</StackPanel>
|
||||
<StackPanel
|
||||
|
@ -2,10 +2,8 @@ using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.Media;
|
||||
using Avalonia.Threading;
|
||||
using Avalonia.Win32;
|
||||
using FluentAvalonia.UI.Controls;
|
||||
using Ryujinx.Ava.Common;
|
||||
using Ryujinx.Ava.Common.Locale;
|
||||
@ -14,6 +12,7 @@ using Ryujinx.Ava.Ui.Applet;
|
||||
using Ryujinx.Ava.Ui.Controls;
|
||||
using Ryujinx.Ava.Ui.Models;
|
||||
using Ryujinx.Ava.Ui.ViewModels;
|
||||
using Ryujinx.Ava.Ui.Vulkan;
|
||||
using Ryujinx.Common.Configuration;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Graphics.Gpu;
|
||||
@ -33,7 +32,7 @@ using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using InputManager = Ryujinx.Input.HLE.InputManager;
|
||||
using ProgressBar = Avalonia.Controls.ProgressBar;
|
||||
|
||||
namespace Ryujinx.Ava.Ui.Windows
|
||||
{
|
||||
public partial class MainWindow : StyleableWindow
|
||||
@ -61,7 +60,7 @@ namespace Ryujinx.Ava.Ui.Windows
|
||||
internal AppHost AppHost { get; private set; }
|
||||
public InputManager InputManager { get; private set; }
|
||||
|
||||
internal RendererControl GlRenderer { get; private set; }
|
||||
internal RendererControl RendererControl { get; private set; }
|
||||
internal MainWindowViewModel ViewModel { get; private set; }
|
||||
public SettingsWindow SettingsWindow { get; set; }
|
||||
|
||||
@ -87,7 +86,6 @@ namespace Ryujinx.Ava.Ui.Windows
|
||||
|
||||
InitializeComponent();
|
||||
Load();
|
||||
AttachDebugDevTools();
|
||||
|
||||
UiHandler = new AvaHostUiHandler(this);
|
||||
|
||||
@ -110,12 +108,6 @@ namespace Ryujinx.Ava.Ui.Windows
|
||||
_rendererWaitEvent = new AutoResetEvent(false);
|
||||
}
|
||||
|
||||
[Conditional("DEBUG")]
|
||||
private void AttachDebugDevTools()
|
||||
{
|
||||
this.AttachDevTools();
|
||||
}
|
||||
|
||||
public void LoadGameList()
|
||||
{
|
||||
if (_isLoading)
|
||||
@ -149,7 +141,8 @@ namespace Ryujinx.Ava.Ui.Windows
|
||||
ViewModel.AspectRatioStatusText = args.AspectRatio;
|
||||
ViewModel.GameStatusText = args.GameStatus;
|
||||
ViewModel.FifoStatusText = args.FifoStatus;
|
||||
ViewModel.GpuStatusText = args.GpuName;
|
||||
ViewModel.GpuNameText = args.GpuName;
|
||||
ViewModel.BackendText = args.GpuBackend;
|
||||
|
||||
ViewModel.ShowStatusSeparator = true;
|
||||
});
|
||||
@ -244,10 +237,10 @@ namespace Ryujinx.Ava.Ui.Windows
|
||||
|
||||
PrepareLoadScreen();
|
||||
|
||||
_mainViewContent = Content.Content as Control;
|
||||
_mainViewContent = MainContent.Content as Control;
|
||||
|
||||
GlRenderer = new RendererControl(3, 3, ConfigurationState.Instance.Logger.GraphicsDebugLevel);
|
||||
AppHost = new AppHost(GlRenderer, InputManager, path, VirtualFileSystem, ContentManager, AccountManager, _userChannelPersistence, this);
|
||||
RendererControl = Program.UseVulkan ? new VulkanRendererControl(ConfigurationState.Instance.Logger.GraphicsDebugLevel) : new OpenGLRendererControl(3, 3, ConfigurationState.Instance.Logger.GraphicsDebugLevel);
|
||||
AppHost = new AppHost(RendererControl, InputManager, path, VirtualFileSystem, ContentManager, AccountManager, _userChannelPersistence, this);
|
||||
|
||||
if (!AppHost.LoadGuestApplication().Result)
|
||||
{
|
||||
@ -271,7 +264,7 @@ namespace Ryujinx.Ava.Ui.Windows
|
||||
|
||||
private void InitializeGame()
|
||||
{
|
||||
GlRenderer.GlInitialized += GlRenderer_Created;
|
||||
RendererControl.RendererInitialized += GlRenderer_Created;
|
||||
|
||||
AppHost.StatusUpdatedEvent += Update_StatusBar;
|
||||
AppHost.AppExit += AppHost_AppExit;
|
||||
@ -311,14 +304,14 @@ namespace Ryujinx.Ava.Ui.Windows
|
||||
|
||||
Dispatcher.UIThread.InvokeAsync(() =>
|
||||
{
|
||||
Content.Content = GlRenderer;
|
||||
MainContent.Content = RendererControl;
|
||||
|
||||
if (startFullscreen && WindowState != WindowState.FullScreen)
|
||||
{
|
||||
ViewModel.ToggleFullscreen();
|
||||
}
|
||||
|
||||
GlRenderer.Focus();
|
||||
RendererControl.Focus();
|
||||
});
|
||||
}
|
||||
|
||||
@ -355,9 +348,9 @@ namespace Ryujinx.Ava.Ui.Windows
|
||||
|
||||
Dispatcher.UIThread.InvokeAsync(() =>
|
||||
{
|
||||
if (Content.Content != _mainViewContent)
|
||||
if (MainContent.Content != _mainViewContent)
|
||||
{
|
||||
Content.Content = _mainViewContent;
|
||||
MainContent.Content = _mainViewContent;
|
||||
}
|
||||
|
||||
ViewModel.ShowMenuAndStatusBar = true;
|
||||
@ -370,8 +363,9 @@ namespace Ryujinx.Ava.Ui.Windows
|
||||
|
||||
HandleRelaunch();
|
||||
});
|
||||
GlRenderer.GlInitialized -= GlRenderer_Created;
|
||||
GlRenderer = null;
|
||||
|
||||
RendererControl.RendererInitialized -= GlRenderer_Created;
|
||||
RendererControl = null;
|
||||
|
||||
ViewModel.SelectedIcon = null;
|
||||
|
||||
@ -522,6 +516,7 @@ namespace Ryujinx.Ava.Ui.Windows
|
||||
GraphicsConfig.MaxAnisotropy = ConfigurationState.Instance.Graphics.MaxAnisotropy;
|
||||
GraphicsConfig.ShadersDumpPath = ConfigurationState.Instance.Graphics.ShadersDumpPath;
|
||||
GraphicsConfig.EnableShaderCache = ConfigurationState.Instance.Graphics.EnableShaderCache;
|
||||
GraphicsConfig.EnableTextureRecompression = ConfigurationState.Instance.Graphics.EnableTextureRecompression;
|
||||
}
|
||||
|
||||
public void LoadHotKeys()
|
||||
|
@ -1,5 +1,4 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using FluentAvalonia.UI.Controls;
|
||||
using Ryujinx.Ava.Common.Locale;
|
||||
using Ryujinx.Ava.Ui.Models;
|
||||
|
@ -1,5 +1,4 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using FluentAvalonia.UI.Controls;
|
||||
using Ryujinx.Ava.Common.Locale;
|
||||
using Ryujinx.Ava.Ui.Models;
|
||||
|
@ -241,6 +241,22 @@
|
||||
TextAlignment="Center" />
|
||||
</ToggleButton>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="10,0,0,0" Orientation="Horizontal">
|
||||
<TextBlock VerticalAlignment="Center" Text="{locale:Locale SettingsTabHotkeysResScaleUpHotkey}" Width="230" />
|
||||
<ToggleButton Width="90" Height="27" Checked="Button_Checked" Unchecked="Button_Unchecked">
|
||||
<TextBlock
|
||||
Text="{Binding KeyboardHotkeys.ResScaleUp, Mode=TwoWay, Converter={StaticResource Key}}"
|
||||
TextAlignment="Center" />
|
||||
</ToggleButton>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="10,0,0,0" Orientation="Horizontal">
|
||||
<TextBlock VerticalAlignment="Center" Text="{locale:Locale SettingsTabHotkeysResScaleDownHotkey}" Width="230" />
|
||||
<ToggleButton Width="90" Height="27" Checked="Button_Checked" Unchecked="Button_Unchecked">
|
||||
<TextBlock
|
||||
Text="{Binding KeyboardHotkeys.ResScaleDown, Mode=TwoWay, Converter={StaticResource Key}}"
|
||||
TextAlignment="Center" />
|
||||
</ToggleButton>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</ScrollViewer>
|
||||
@ -488,43 +504,51 @@
|
||||
VerticalScrollBarVisibility="Auto">
|
||||
<Border>
|
||||
<StackPanel
|
||||
Margin="10, 5"
|
||||
Margin="10,5"
|
||||
HorizontalAlignment="Stretch"
|
||||
Orientation="Vertical"
|
||||
Spacing="10">
|
||||
<TextBlock FontWeight="Bold" Text="{locale:Locale SettingsTabGraphicsEnhancements}" />
|
||||
<TextBlock FontWeight="Bold" Text="{locale:Locale SettingsTabGraphicsAPI}" />
|
||||
<StackPanel Margin="10,0,0,0" Orientation="Vertical" Spacing="10">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock VerticalAlignment="Center"
|
||||
ToolTip.Tip="{locale:Locale SettingsTabGraphicsBackendTooltip}"
|
||||
Text="{locale:Locale SettingsTabGraphicsBackend}"
|
||||
Width="250" />
|
||||
<ComboBox Width="350"
|
||||
HorizontalContentAlignment="Left"
|
||||
ToolTip.Tip="{locale:Locale SettingsTabGraphicsBackendTooltip}"
|
||||
SelectedIndex="{Binding GraphicsBackendIndex}">
|
||||
<ComboBoxItem>
|
||||
<TextBlock Text="Vulkan" />
|
||||
</ComboBoxItem>
|
||||
<ComboBoxItem>
|
||||
<TextBlock Text="OpenGL" />
|
||||
</ComboBoxItem>
|
||||
</ComboBox>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" IsVisible="{Binding IsVulkanSelected}">
|
||||
<TextBlock VerticalAlignment="Center"
|
||||
ToolTip.Tip="{locale:Locale SettingsTabGraphicsPreferredGpuTooltip}"
|
||||
Text="{locale:Locale SettingsTabGraphicsPreferredGpu}"
|
||||
Width="250" />
|
||||
<ComboBox Width="350"
|
||||
HorizontalContentAlignment="Left"
|
||||
ToolTip.Tip="{locale:Locale SettingsTabGraphicsPreferredGpuTooltip}"
|
||||
SelectedIndex="{Binding PreferredGpuIndex}"
|
||||
Items="{Binding AvailableGpus}"/>
|
||||
</StackPanel>
|
||||
<Separator Height="1" />
|
||||
<TextBlock FontWeight="Bold" Text="{locale:Locale SettingsTabGraphicsFeatures}" />
|
||||
<StackPanel Orientation="Vertical">
|
||||
<CheckBox IsChecked="{Binding EnableShaderCache}"
|
||||
ToolTip.Tip="{locale:Locale ShaderCacheToggleTooltip}">
|
||||
<TextBlock Text="{locale:Locale SettingsTabGraphicsEnableShaderCache}" />
|
||||
</CheckBox>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock VerticalAlignment="Center"
|
||||
ToolTip.Tip="{locale:Locale AnisotropyTooltip}"
|
||||
Text="{locale:Locale SettingsTabGraphicsAnisotropicFiltering}"
|
||||
Width="250" />
|
||||
<ComboBox SelectedIndex="{Binding MaxAnisotropy}"
|
||||
Width="350"
|
||||
HorizontalContentAlignment="Left"
|
||||
ToolTip.Tip="{locale:Locale AnisotropyTooltip}">
|
||||
<ComboBoxItem>
|
||||
<TextBlock
|
||||
Text="{locale:Locale SettingsTabGraphicsAnisotropicFilteringAuto}" />
|
||||
</ComboBoxItem>
|
||||
<ComboBoxItem>
|
||||
<TextBlock Text="{locale:Locale SettingsTabGraphicsAnisotropicFiltering2x}" />
|
||||
</ComboBoxItem>
|
||||
<ComboBoxItem>
|
||||
<TextBlock Text="{locale:Locale SettingsTabGraphicsAnisotropicFiltering4x}" />
|
||||
</ComboBoxItem>
|
||||
<ComboBoxItem>
|
||||
<TextBlock Text="{locale:Locale SettingsTabGraphicsAnisotropicFiltering8x}" />
|
||||
</ComboBoxItem>
|
||||
<ComboBoxItem>
|
||||
<TextBlock
|
||||
Text="{locale:Locale SettingsTabGraphicsAnisotropicFiltering16x}" />
|
||||
</ComboBoxItem>
|
||||
</ComboBox>
|
||||
<CheckBox IsChecked="{Binding EnableTextureRecompression}"
|
||||
ToolTip.Tip="{locale:Locale SettingsEnableTextureRecompressionTooltip}">
|
||||
<TextBlock Text="{locale:Locale SettingsEnableTextureRecompression}" />
|
||||
</CheckBox>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock VerticalAlignment="Center"
|
||||
@ -564,6 +588,34 @@
|
||||
Minimum="0.1"
|
||||
Value="{Binding CustomResolutionScale}" />
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock VerticalAlignment="Center"
|
||||
ToolTip.Tip="{locale:Locale AnisotropyTooltip}"
|
||||
Text="{locale:Locale SettingsTabGraphicsAnisotropicFiltering}"
|
||||
Width="250" />
|
||||
<ComboBox SelectedIndex="{Binding MaxAnisotropy}"
|
||||
Width="350"
|
||||
HorizontalContentAlignment="Left"
|
||||
ToolTip.Tip="{locale:Locale AnisotropyTooltip}">
|
||||
<ComboBoxItem>
|
||||
<TextBlock
|
||||
Text="{locale:Locale SettingsTabGraphicsAnisotropicFilteringAuto}" />
|
||||
</ComboBoxItem>
|
||||
<ComboBoxItem>
|
||||
<TextBlock Text="{locale:Locale SettingsTabGraphicsAnisotropicFiltering2x}" />
|
||||
</ComboBoxItem>
|
||||
<ComboBoxItem>
|
||||
<TextBlock Text="{locale:Locale SettingsTabGraphicsAnisotropicFiltering4x}" />
|
||||
</ComboBoxItem>
|
||||
<ComboBoxItem>
|
||||
<TextBlock Text="{locale:Locale SettingsTabGraphicsAnisotropicFiltering8x}" />
|
||||
</ComboBoxItem>
|
||||
<ComboBoxItem>
|
||||
<TextBlock
|
||||
Text="{locale:Locale SettingsTabGraphicsAnisotropicFiltering16x}" />
|
||||
</ComboBoxItem>
|
||||
</ComboBox>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock VerticalAlignment="Center"
|
||||
ToolTip.Tip="{locale:Locale AspectRatioTooltip}"
|
||||
@ -594,8 +646,6 @@
|
||||
</ComboBox>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
<Separator Height="1" />
|
||||
<TextBlock FontWeight="Bold" Text="{locale:Locale SettingsTabGraphicsFeatures}" />
|
||||
<StackPanel
|
||||
Margin="10,0,0,0"
|
||||
HorizontalAlignment="Stretch"
|
||||
|
@ -1,29 +1,21 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Presenters;
|
||||
using Avalonia.Controls.Primitives;
|
||||
using Avalonia.Data;
|
||||
using Avalonia.Data.Converters;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.LogicalTree;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.Threading;
|
||||
using FluentAvalonia.Core;
|
||||
using FluentAvalonia.UI.Controls;
|
||||
using Ryujinx.Ava.Common.Locale;
|
||||
using Ryujinx.Ava.Ui.Controls;
|
||||
using Ryujinx.Ava.Ui.Models;
|
||||
using Ryujinx.Ava.Ui.ViewModels;
|
||||
using Ryujinx.HLE.FileSystem;
|
||||
using Ryujinx.Input;
|
||||
using Ryujinx.Input.Assigner;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using TimeZone = Ryujinx.Ava.Ui.Models.TimeZone;
|
||||
|
||||
@ -44,7 +36,6 @@ namespace Ryujinx.Ava.Ui.Windows
|
||||
|
||||
InitializeComponent();
|
||||
Load();
|
||||
AttachDebugDevTools();
|
||||
|
||||
FuncMultiValueConverter<string, string> converter = new(parts => string.Format("{0} {1} {2}", parts.ToArray()));
|
||||
MultiBinding tzMultiBinding = new() { Converter = converter };
|
||||
@ -62,13 +53,6 @@ namespace Ryujinx.Ava.Ui.Windows
|
||||
|
||||
InitializeComponent();
|
||||
Load();
|
||||
AttachDebugDevTools();
|
||||
}
|
||||
|
||||
[Conditional("DEBUG")]
|
||||
private void AttachDebugDevTools()
|
||||
{
|
||||
this.AttachDevTools();
|
||||
}
|
||||
|
||||
private void Load()
|
||||
@ -224,9 +208,9 @@ namespace Ryujinx.Ava.Ui.Windows
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveButton_Clicked(object sender, RoutedEventArgs e)
|
||||
private async void SaveButton_Clicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
SaveSettings();
|
||||
await SaveSettings();
|
||||
|
||||
Close();
|
||||
}
|
||||
@ -237,14 +221,14 @@ namespace Ryujinx.Ava.Ui.Windows
|
||||
Close();
|
||||
}
|
||||
|
||||
private void ApplyButton_Clicked(object sender, RoutedEventArgs e)
|
||||
private async void ApplyButton_Clicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
SaveSettings();
|
||||
await SaveSettings();
|
||||
}
|
||||
|
||||
private void SaveSettings()
|
||||
private async Task SaveSettings()
|
||||
{
|
||||
ViewModel.SaveSettings();
|
||||
await ViewModel.SaveSettings();
|
||||
|
||||
ControllerSettings?.SaveCurrentProfile();
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
using Avalonia.Controls.Primitives;
|
||||
using Avalonia.Media.Imaging;
|
||||
using Avalonia.Platform;
|
||||
using FluentAvalonia.UI.Controls;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
@ -1,13 +1,14 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Collections;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.Threading;
|
||||
using LibHac.Common;
|
||||
using LibHac.Fs;
|
||||
using LibHac.Fs.Fsa;
|
||||
using LibHac.FsSystem;
|
||||
using LibHac.Tools.FsSystem.NcaUtils;
|
||||
using LibHac.Ns;
|
||||
using LibHac.Tools.FsSystem;
|
||||
using LibHac.Tools.FsSystem.NcaUtils;
|
||||
using Ryujinx.Ava.Common.Locale;
|
||||
using Ryujinx.Ava.Ui.Controls;
|
||||
using Ryujinx.Ava.Ui.Models;
|
||||
@ -23,14 +24,12 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using Path = System.IO.Path;
|
||||
using SpanHelpers = LibHac.Common.SpanHelpers;
|
||||
using LibHac.Tools.FsSystem;
|
||||
using Avalonia.Threading;
|
||||
|
||||
namespace Ryujinx.Ava.Ui.Windows
|
||||
{
|
||||
public partial class TitleUpdateWindow : StyleableWindow
|
||||
{
|
||||
private readonly string _updateJsonPath;
|
||||
private readonly string _titleUpdateJsonPath;
|
||||
private TitleUpdateMetadata _titleUpdateWindowData;
|
||||
|
||||
public VirtualFileSystem VirtualFileSystem { get; }
|
||||
@ -46,7 +45,6 @@ namespace Ryujinx.Ava.Ui.Windows
|
||||
DataContext = this;
|
||||
|
||||
InitializeComponent();
|
||||
AttachDebugDevTools();
|
||||
|
||||
Title = $"Ryujinx {Program.Version} - " + LocaleManager.Instance["UpdateWindowTitle"];
|
||||
}
|
||||
@ -57,33 +55,30 @@ namespace Ryujinx.Ava.Ui.Windows
|
||||
TitleId = titleId;
|
||||
TitleName = titleName;
|
||||
|
||||
_updateJsonPath = Path.Combine(AppDataManager.GamesDirPath, titleId, "updates.json");
|
||||
_titleUpdateJsonPath = Path.Combine(AppDataManager.GamesDirPath, titleId, "updates.json");
|
||||
|
||||
try
|
||||
{
|
||||
_titleUpdateWindowData = JsonHelper.DeserializeFromFile<TitleUpdateMetadata>(_updateJsonPath);
|
||||
_titleUpdateWindowData = JsonHelper.DeserializeFromFile<TitleUpdateMetadata>(_titleUpdateJsonPath);
|
||||
}
|
||||
catch
|
||||
{
|
||||
_titleUpdateWindowData = new TitleUpdateMetadata {Selected = "", Paths = new List<string>()};
|
||||
_titleUpdateWindowData = new TitleUpdateMetadata
|
||||
{
|
||||
Selected = "",
|
||||
Paths = new List<string>()
|
||||
};
|
||||
}
|
||||
|
||||
DataContext = this;
|
||||
|
||||
InitializeComponent();
|
||||
AttachDebugDevTools();
|
||||
|
||||
Title = $"Ryujinx {Program.Version} - " + LocaleManager.Instance["UpdateWindowTitle"];
|
||||
|
||||
LoadUpdates();
|
||||
}
|
||||
|
||||
[Conditional("DEBUG")]
|
||||
private void AttachDebugDevTools()
|
||||
{
|
||||
this.AttachDevTools();
|
||||
}
|
||||
|
||||
private void LoadUpdates()
|
||||
{
|
||||
TitleUpdates.Add(new TitleUpdateModel(default, string.Empty, true));
|
||||
@ -126,8 +121,7 @@ namespace Ryujinx.Ava.Ui.Windows
|
||||
|
||||
try
|
||||
{
|
||||
(Nca patchNca, Nca controlNca) =
|
||||
ApplicationLoader.GetGameUpdateDataFromPartition(VirtualFileSystem, nsp, TitleId, 0);
|
||||
(Nca patchNca, Nca controlNca) = ApplicationLoader.GetGameUpdateDataFromPartition(VirtualFileSystem, nsp, TitleId, 0);
|
||||
|
||||
if (controlNca != null && patchNca != null)
|
||||
{
|
||||
@ -135,11 +129,8 @@ namespace Ryujinx.Ava.Ui.Windows
|
||||
|
||||
using var nacpFile = new UniqueRef<IFile>();
|
||||
|
||||
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();
|
||||
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();
|
||||
|
||||
TitleUpdates.Add(new TitleUpdateModel(controlData, path));
|
||||
}
|
||||
@ -190,9 +181,17 @@ namespace Ryujinx.Ava.Ui.Windows
|
||||
|
||||
public async void Add()
|
||||
{
|
||||
OpenFileDialog dialog = new OpenFileDialog() { Title = LocaleManager.Instance["SelectUpdateDialogTitle"], AllowMultiple = true };
|
||||
OpenFileDialog dialog = new OpenFileDialog()
|
||||
{
|
||||
Title = LocaleManager.Instance["SelectUpdateDialogTitle"],
|
||||
AllowMultiple = true
|
||||
};
|
||||
|
||||
dialog.Filters.Add(new FileDialogFilter { Name = "NSP", Extensions = { "nsp" } });
|
||||
dialog.Filters.Add(new FileDialogFilter
|
||||
{
|
||||
Name = "NSP",
|
||||
Extensions = { "nsp" }
|
||||
});
|
||||
|
||||
string[] files = await dialog.ShowAsync(this);
|
||||
|
||||
@ -222,12 +221,10 @@ namespace Ryujinx.Ava.Ui.Windows
|
||||
return 1;
|
||||
}
|
||||
|
||||
return Version.Parse(first.Control.DisplayVersionString.ToString())
|
||||
.CompareTo(Version.Parse(second.Control.DisplayVersionString.ToString())) * -1;
|
||||
return Version.Parse(first.Control.DisplayVersionString.ToString()).CompareTo(Version.Parse(second.Control.DisplayVersionString.ToString())) * -1;
|
||||
});
|
||||
|
||||
TitleUpdates.Clear();
|
||||
|
||||
TitleUpdates.AddRange(list);
|
||||
}
|
||||
|
||||
@ -247,9 +244,9 @@ namespace Ryujinx.Ava.Ui.Windows
|
||||
}
|
||||
}
|
||||
|
||||
using (FileStream dlcJsonStream = File.Create(_updateJsonPath, 4096, FileOptions.WriteThrough))
|
||||
using (FileStream titleUpdateJsonStream = File.Create(_titleUpdateJsonPath, 4096, FileOptions.WriteThrough))
|
||||
{
|
||||
dlcJsonStream.Write(Encoding.UTF8.GetBytes(JsonHelper.Serialize(_titleUpdateWindowData, true)));
|
||||
titleUpdateJsonStream.Write(Encoding.UTF8.GetBytes(JsonHelper.Serialize(_titleUpdateWindowData, true)));
|
||||
}
|
||||
|
||||
if (Owner is MainWindow window)
|
||||
|
@ -1,6 +1,5 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Ryujinx.Ava.Common.Locale;
|
||||
using Ryujinx.Modules;
|
||||
using System;
|
||||
@ -23,9 +22,7 @@ namespace Ryujinx.Ava.Ui.Windows
|
||||
DataContext = this;
|
||||
|
||||
InitializeComponent();
|
||||
#if DEBUG
|
||||
this.AttachDevTools();
|
||||
#endif
|
||||
|
||||
Title = LocaleManager.Instance["RyujinxUpdater"];
|
||||
}
|
||||
|
||||
|
@ -1,10 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Ryujinx.Common.Configuration
|
||||
{
|
||||
public struct DlcContainer
|
||||
{
|
||||
public string Path { get; set; }
|
||||
public List<DlcNca> DlcNcaList { get; set; }
|
||||
}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
namespace Ryujinx.Common.Configuration
|
||||
{
|
||||
public struct DlcNca
|
||||
{
|
||||
public string Path { get; set; }
|
||||
public ulong TitleId { get; set; }
|
||||
public bool Enabled { get; set; }
|
||||
}
|
||||
}
|
13
Ryujinx.Common/Configuration/DownloadableContentContainer.cs
Normal file
13
Ryujinx.Common/Configuration/DownloadableContentContainer.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Ryujinx.Common.Configuration
|
||||
{
|
||||
public struct DownloadableContentContainer
|
||||
{
|
||||
[JsonPropertyName("path")]
|
||||
public string ContainerPath { get; set; }
|
||||
[JsonPropertyName("dlc_nca_list")]
|
||||
public List<DownloadableContentNca> DownloadableContentNcaList { get; set; }
|
||||
}
|
||||
}
|
14
Ryujinx.Common/Configuration/DownloadableContentNca.cs
Normal file
14
Ryujinx.Common/Configuration/DownloadableContentNca.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Ryujinx.Common.Configuration
|
||||
{
|
||||
public struct DownloadableContentNca
|
||||
{
|
||||
[JsonPropertyName("path")]
|
||||
public string FullPath { get; set; }
|
||||
[JsonPropertyName("title_id")]
|
||||
public ulong TitleId { get; set; }
|
||||
[JsonPropertyName("is_enabled")]
|
||||
public bool Enabled { get; set; }
|
||||
}
|
||||
}
|
8
Ryujinx.Common/Configuration/GraphicsBackend.cs
Normal file
8
Ryujinx.Common/Configuration/GraphicsBackend.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace Ryujinx.Common.Configuration
|
||||
{
|
||||
public enum GraphicsBackend
|
||||
{
|
||||
Vulkan,
|
||||
OpenGl
|
||||
}
|
||||
}
|
@ -7,5 +7,7 @@
|
||||
public Key ShowUi { get; set; }
|
||||
public Key Pause { get; set; }
|
||||
public Key ToggleMute { get; set; }
|
||||
public Key ResScaleUp { get; set; }
|
||||
public Key ResScaleDown { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,80 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
|
||||
using static Ryujinx.Common.Memory.PartialUnmaps.PartialUnmapHelpers;
|
||||
|
||||
namespace Ryujinx.Common.Memory.PartialUnmaps
|
||||
{
|
||||
/// <summary>
|
||||
/// A simple implementation of a ReaderWriterLock which can be used from native code.
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct NativeReaderWriterLock
|
||||
{
|
||||
public int WriteLock;
|
||||
public int ReaderCount;
|
||||
|
||||
public static int WriteLockOffset;
|
||||
public static int ReaderCountOffset;
|
||||
|
||||
/// <summary>
|
||||
/// Populates the field offsets for use when emitting native code.
|
||||
/// </summary>
|
||||
static NativeReaderWriterLock()
|
||||
{
|
||||
NativeReaderWriterLock instance = new NativeReaderWriterLock();
|
||||
|
||||
WriteLockOffset = OffsetOf(ref instance, ref instance.WriteLock);
|
||||
ReaderCountOffset = OffsetOf(ref instance, ref instance.ReaderCount);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Acquires the reader lock.
|
||||
/// </summary>
|
||||
public void AcquireReaderLock()
|
||||
{
|
||||
// Must take write lock for a very short time to become a reader.
|
||||
|
||||
while (Interlocked.CompareExchange(ref WriteLock, 1, 0) != 0) { }
|
||||
|
||||
Interlocked.Increment(ref ReaderCount);
|
||||
|
||||
Interlocked.Exchange(ref WriteLock, 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Releases the reader lock.
|
||||
/// </summary>
|
||||
public void ReleaseReaderLock()
|
||||
{
|
||||
Interlocked.Decrement(ref ReaderCount);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Upgrades to a writer lock. The reader lock is temporarily released while obtaining the writer lock.
|
||||
/// </summary>
|
||||
public void UpgradeToWriterLock()
|
||||
{
|
||||
// Prevent any more threads from entering reader.
|
||||
// If the write lock is already taken, wait for it to not be taken.
|
||||
|
||||
Interlocked.Decrement(ref ReaderCount);
|
||||
|
||||
while (Interlocked.CompareExchange(ref WriteLock, 1, 0) != 0) { }
|
||||
|
||||
// Wait for reader count to drop to 0, then take the lock again as the only reader.
|
||||
|
||||
while (Interlocked.CompareExchange(ref ReaderCount, 1, 0) != 0) { }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Downgrades from a writer lock, back to a reader one.
|
||||
/// </summary>
|
||||
public void DowngradeFromWriterLock()
|
||||
{
|
||||
// Release the WriteLock.
|
||||
|
||||
Interlocked.Exchange(ref WriteLock, 0);
|
||||
}
|
||||
}
|
||||
}
|
20
Ryujinx.Common/Memory/PartialUnmaps/PartialUnmapHelpers.cs
Normal file
20
Ryujinx.Common/Memory/PartialUnmaps/PartialUnmapHelpers.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Ryujinx.Common.Memory.PartialUnmaps
|
||||
{
|
||||
static class PartialUnmapHelpers
|
||||
{
|
||||
/// <summary>
|
||||
/// Calculates a byte offset of a given field within a struct.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Struct type</typeparam>
|
||||
/// <typeparam name="T2">Field type</typeparam>
|
||||
/// <param name="storage">Parent struct</param>
|
||||
/// <param name="target">Field</param>
|
||||
/// <returns>The byte offset of the given field in the given struct</returns>
|
||||
public static int OffsetOf<T, T2>(ref T2 storage, ref T target)
|
||||
{
|
||||
return (int)Unsafe.ByteOffset(ref Unsafe.As<T2, T>(ref storage), ref target);
|
||||
}
|
||||
}
|
||||
}
|
160
Ryujinx.Common/Memory/PartialUnmaps/PartialUnmapState.cs
Normal file
160
Ryujinx.Common/Memory/PartialUnmaps/PartialUnmapState.cs
Normal file
@ -0,0 +1,160 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Versioning;
|
||||
using System.Threading;
|
||||
|
||||
using static Ryujinx.Common.Memory.PartialUnmaps.PartialUnmapHelpers;
|
||||
|
||||
namespace Ryujinx.Common.Memory.PartialUnmaps
|
||||
{
|
||||
/// <summary>
|
||||
/// State for partial unmaps. Intended to be used on Windows.
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct PartialUnmapState
|
||||
{
|
||||
public NativeReaderWriterLock PartialUnmapLock;
|
||||
public int PartialUnmapsCount;
|
||||
public ThreadLocalMap<int> LocalCounts;
|
||||
|
||||
public readonly static int PartialUnmapLockOffset;
|
||||
public readonly static int PartialUnmapsCountOffset;
|
||||
public readonly static int LocalCountsOffset;
|
||||
|
||||
public readonly static IntPtr GlobalState;
|
||||
|
||||
[SupportedOSPlatform("windows")]
|
||||
[DllImport("kernel32.dll")]
|
||||
public static extern int GetCurrentThreadId();
|
||||
|
||||
[SupportedOSPlatform("windows")]
|
||||
[DllImport("kernel32.dll", SetLastError = true)]
|
||||
static extern IntPtr OpenThread(int dwDesiredAccess, bool bInheritHandle, uint dwThreadId);
|
||||
|
||||
[SupportedOSPlatform("windows")]
|
||||
[DllImport("kernel32.dll", SetLastError = true)]
|
||||
public static extern bool CloseHandle(IntPtr hObject);
|
||||
|
||||
[SupportedOSPlatform("windows")]
|
||||
[DllImport("kernel32.dll", SetLastError = true)]
|
||||
static extern bool GetExitCodeThread(IntPtr hThread, out uint lpExitCode);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a global static PartialUnmapState and populates the field offsets.
|
||||
/// </summary>
|
||||
static unsafe PartialUnmapState()
|
||||
{
|
||||
PartialUnmapState instance = new PartialUnmapState();
|
||||
|
||||
PartialUnmapLockOffset = OffsetOf(ref instance, ref instance.PartialUnmapLock);
|
||||
PartialUnmapsCountOffset = OffsetOf(ref instance, ref instance.PartialUnmapsCount);
|
||||
LocalCountsOffset = OffsetOf(ref instance, ref instance.LocalCounts);
|
||||
|
||||
int size = Unsafe.SizeOf<PartialUnmapState>();
|
||||
GlobalState = Marshal.AllocHGlobal(size);
|
||||
Unsafe.InitBlockUnaligned((void*)GlobalState, 0, (uint)size);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets the global state.
|
||||
/// </summary>
|
||||
public static unsafe void Reset()
|
||||
{
|
||||
int size = Unsafe.SizeOf<PartialUnmapState>();
|
||||
Unsafe.InitBlockUnaligned((void*)GlobalState, 0, (uint)size);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the global state.
|
||||
/// </summary>
|
||||
/// <returns>A reference to the global state</returns>
|
||||
public static unsafe ref PartialUnmapState GetRef()
|
||||
{
|
||||
return ref Unsafe.AsRef<PartialUnmapState>((void*)GlobalState);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if an access violation handler should retry execution due to a fault caused by partial unmap.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Due to Windows limitations, <see cref="UnmapView"/> might need to unmap more memory than requested.
|
||||
/// The additional memory that was unmapped is later remapped, however this leaves a time gap where the
|
||||
/// memory might be accessed but is unmapped. Users of the API must compensate for that by catching the
|
||||
/// access violation and retrying if it happened between the unmap and remap operation.
|
||||
/// This method can be used to decide if retrying in such cases is necessary or not.
|
||||
///
|
||||
/// This version of the function is not used, but serves as a reference for the native
|
||||
/// implementation in ARMeilleure.
|
||||
/// </remarks>
|
||||
/// <returns>True if execution should be retried, false otherwise</returns>
|
||||
[SupportedOSPlatform("windows")]
|
||||
public bool RetryFromAccessViolation()
|
||||
{
|
||||
PartialUnmapLock.AcquireReaderLock();
|
||||
|
||||
int threadID = GetCurrentThreadId();
|
||||
int threadIndex = LocalCounts.GetOrReserve(threadID, 0);
|
||||
|
||||
if (threadIndex == -1)
|
||||
{
|
||||
// Out of thread local space... try again later.
|
||||
|
||||
PartialUnmapLock.ReleaseReaderLock();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ref int threadLocalPartialUnmapsCount = ref LocalCounts.GetValue(threadIndex);
|
||||
|
||||
bool retry = threadLocalPartialUnmapsCount != PartialUnmapsCount;
|
||||
if (retry)
|
||||
{
|
||||
threadLocalPartialUnmapsCount = PartialUnmapsCount;
|
||||
}
|
||||
|
||||
PartialUnmapLock.ReleaseReaderLock();
|
||||
|
||||
return retry;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Iterates and trims threads in the thread -> count map that
|
||||
/// are no longer active.
|
||||
/// </summary>
|
||||
[SupportedOSPlatform("windows")]
|
||||
public void TrimThreads()
|
||||
{
|
||||
const uint ExitCodeStillActive = 259;
|
||||
const int ThreadQueryInformation = 0x40;
|
||||
|
||||
Span<int> ids = LocalCounts.ThreadIds.ToSpan();
|
||||
|
||||
for (int i = 0; i < ids.Length; i++)
|
||||
{
|
||||
int id = ids[i];
|
||||
|
||||
if (id != 0)
|
||||
{
|
||||
IntPtr handle = OpenThread(ThreadQueryInformation, false, (uint)id);
|
||||
|
||||
if (handle == IntPtr.Zero)
|
||||
{
|
||||
Interlocked.CompareExchange(ref ids[i], 0, id);
|
||||
}
|
||||
else
|
||||
{
|
||||
GetExitCodeThread(handle, out uint exitCode);
|
||||
|
||||
if (exitCode != ExitCodeStillActive)
|
||||
{
|
||||
Interlocked.CompareExchange(ref ids[i], 0, id);
|
||||
}
|
||||
|
||||
CloseHandle(handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user