mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2026-03-04 13:41:07 +00:00
Compare commits
48 Commits
1.3.3
...
Canary-1.3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fd07453887 | ||
|
|
c6bc77e4bf | ||
|
|
49cbe4b328 | ||
|
|
6fd67cdcb7 | ||
|
|
5ced2bf764 | ||
|
|
67e97d1a1a | ||
|
|
09d8a411c8 | ||
|
|
93516df7e6 | ||
|
|
0c165c3f62 | ||
|
|
91da244c02 | ||
|
|
904d4a7eb0 | ||
|
|
1248a054de | ||
|
|
1bb2af84ce | ||
|
|
886981004d | ||
|
|
e551dda17e | ||
|
|
ed67535227 | ||
|
|
7d65611b96 | ||
|
|
71eb844dd8 | ||
|
|
a0e5edf8ba | ||
|
|
6541ad0726 | ||
|
|
1c084373c9 | ||
|
|
5b3b907fd2 | ||
|
|
f46577af58 | ||
|
|
0e218754f5 | ||
|
|
0c6d4a07b9 | ||
|
|
8714b010f6 | ||
|
|
d1d4a735a6 | ||
|
|
247e2e03d6 | ||
|
|
6058af5119 | ||
|
|
e11eff0f41 | ||
|
|
2a2ab523cb | ||
|
|
8e941e4a8f | ||
|
|
9aacf9b37b | ||
|
|
2b159dbca8 | ||
|
|
c33a97f01c | ||
|
|
fdbdb05cb5 | ||
|
|
7268acbfb4 | ||
|
|
d4107ac05f | ||
|
|
1d409f7127 | ||
|
|
2434c55266 | ||
|
|
99126603ba | ||
|
|
a62716002e | ||
|
|
47559cd311 | ||
|
|
51584a083b | ||
|
|
ceec9617ef | ||
|
|
1865be47cf | ||
|
|
ef9810582a | ||
|
|
13878acdb2 |
@@ -10,7 +10,7 @@ Make sure your SDK version is higher or equal to the required version specified
|
||||
|
||||
### Step 2
|
||||
|
||||
Either use `git clone https://github.com/Ryubing/Ryujinx` on the command line to clone the repository or use Code --> Download zip button to get the files.
|
||||
Either use `git clone https://git.ryujinx.app/ryubing/ryujinx.git` on the command line to clone the repository or use Code --> Download zip button to get the files.
|
||||
|
||||
### Step 3
|
||||
|
||||
|
||||
@@ -3,25 +3,25 @@
|
||||
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageVersion Include="Avalonia" Version="11.0.13" />
|
||||
<PackageVersion Include="Avalonia.Controls.DataGrid" Version="11.0.13" />
|
||||
<PackageVersion Include="Avalonia.Desktop" Version="11.0.13" />
|
||||
<PackageVersion Include="Avalonia.Diagnostics" Version="11.0.13" />
|
||||
<PackageVersion Include="Avalonia.Markup.Xaml.Loader" Version="11.0.13" />
|
||||
<PackageVersion Include="Avalonia.Svg" Version="11.0.0.19" />
|
||||
<PackageVersion Include="Avalonia.Svg.Skia" Version="11.0.0.19" />
|
||||
<PackageVersion Include="Avalonia" Version="11.3.6" />
|
||||
<PackageVersion Include="Avalonia.Controls.DataGrid" Version="11.3.6" />
|
||||
<PackageVersion Include="Avalonia.Desktop" Version="11.3.6" />
|
||||
<PackageVersion Include="Avalonia.Diagnostics" Version="11.3.6" />
|
||||
<PackageVersion Include="Avalonia.Markup.Xaml.Loader" Version="11.3.6" />
|
||||
<PackageVersion Include="Svg.Controls.Avalonia" Version="11.3.6.2" />
|
||||
<PackageVersion Include="Svg.Controls.Skia.Avalonia" Version="11.3.6.2" />
|
||||
<PackageVersion Include="Microsoft.Build.Framework" Version="17.11.4" />
|
||||
<PackageVersion Include="Microsoft.Build.Utilities.Core" Version="17.12.6" />
|
||||
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageVersion Include="Projektanker.Icons.Avalonia" Version="9.4.0" />
|
||||
<PackageVersion Include="Projektanker.Icons.Avalonia.FontAwesome" Version="9.4.0"/>
|
||||
<PackageVersion Include="Projektanker.Icons.Avalonia.MaterialDesign" Version="9.4.0"/>
|
||||
<PackageVersion Include="Projektanker.Icons.Avalonia" Version="9.6.2" />
|
||||
<PackageVersion Include="Projektanker.Icons.Avalonia.FontAwesome" Version="9.6.2"/>
|
||||
<PackageVersion Include="Projektanker.Icons.Avalonia.MaterialDesign" Version="9.6.2"/>
|
||||
<PackageVersion Include="CommandLineParser" Version="2.9.1" />
|
||||
<PackageVersion Include="CommunityToolkit.Mvvm" Version="8.4.0"/>
|
||||
<PackageVersion Include="Concentus" Version="2.2.2" />
|
||||
<PackageVersion Include="DiscordRichPresence" Version="1.6.1.70" />
|
||||
<PackageVersion Include="DynamicData" Version="9.4.1" />
|
||||
<PackageVersion Include="FluentAvaloniaUI" Version="2.0.5" />
|
||||
<PackageVersion Include="FluentAvaloniaUI.NoAnim" Version="2.4.0-build3" />
|
||||
<PackageVersion Include="Humanizer" Version="2.14.1" />
|
||||
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" />
|
||||
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.9.2" />
|
||||
@@ -40,7 +40,7 @@
|
||||
<PackageVersion Include="Ryujinx.Audio.OpenAL.Dependencies" Version="1.21.0.1" />
|
||||
<PackageVersion Include="Ryujinx.Graphics.Nvdec.Dependencies.AllArch" Version="6.1.2-build3" />
|
||||
<PackageVersion Include="Ryujinx.Graphics.Vulkan.Dependencies.MoltenVK" Version="1.2.0" />
|
||||
<PackageVersion Include="Ryujinx.LibHac" Version="0.21.0-alpha.116" />
|
||||
<PackageVersion Include="Ryujinx.LibHac" Version="0.21.0-alpha.117" />
|
||||
<PackageVersion Include="Ryujinx.SDL2-CS" Version="2.30.0-build32" />
|
||||
<PackageVersion Include="Ryujinx.UpdateClient" Version="1.0.44" />
|
||||
<PackageVersion Include="Ryujinx.Systems.Update.Common" Version="1.0.44" />
|
||||
|
||||
@@ -3629,7 +3629,7 @@
|
||||
"he_IL": "ממשק קלאסי (הפעלה מחדש דרושה)",
|
||||
"it_IT": "Interfaccia classica (Riavvio necessario)",
|
||||
"ja_JP": "クラシックインターフェース(再起動必要)",
|
||||
"ko_KR": "클래식 인터페이스 (재시작 필요)",
|
||||
"ko_KR": "클래식 인터페이스(다시 시작 필요)",
|
||||
"no_NO": "Klassisk grensesnitt (Krever omstart)",
|
||||
"pl_PL": "Klasyczny interfejs (Wymaga restartu)",
|
||||
"pt_BR": "Interface Clássica (Reinício necessário)",
|
||||
@@ -6445,26 +6445,27 @@
|
||||
{
|
||||
"ID": "SettingsButtonResetConfirm",
|
||||
"Translations": {
|
||||
"ar_SA": "أريد إعادة تعيين إعداداتي",
|
||||
"de_DE": "Ich möchte meine Einstellungen zurücksetzen",
|
||||
"el_GR": "Θέλω να επαναφέρω τις ρυθμίσεις μου",
|
||||
"en_US": "I Want To Reset My Settings",
|
||||
"es_ES": "Quiero Restablecer Mi Configuración",
|
||||
"fr_FR": "Je Veux Réinitialiser Mes Paramètres",
|
||||
"he_IL": "אני רוצה לאפס את ההגדרות שלי",
|
||||
"it_IT": "Voglio reimpostare le mie impostazioni",
|
||||
"ja_JP": "設定をリセットしたいです",
|
||||
"ko_KR": "설정을 초기화하고 싶습니다",
|
||||
"no_NO": "Jeg vil tilbakestille innstillingene mine",
|
||||
"pl_PL": "Chcę zresetować moje ustawienia",
|
||||
"pt_BR": "Quero redefinir minhas configurações",
|
||||
"ru_RU": "Я хочу сбросить свои настройки",
|
||||
"sv_SE": "Jag vill nollställa mina inställningar",
|
||||
"th_TH": "ฉันต้องการรีเซ็ตการตั้งค่าของฉัน",
|
||||
"tr_TR": "Ayarlarımı sıfırlamak istiyorum",
|
||||
"uk_UA": "Я хочу скинути налаштування",
|
||||
"zh_CN": "我要重置我的设置",
|
||||
"zh_TW": "我想重設我的設定"
|
||||
"ar_SA": "",
|
||||
"de_DE": "",
|
||||
"el_GR": "",
|
||||
"en_US": "I want to reset my settings.",
|
||||
"es_ES": "Quiero restablecer mi Configuración.",
|
||||
"fr_FR": "Je veux réinitialiser mes paramètres.",
|
||||
"he_IL": "",
|
||||
"it_IT": "Voglio ripristinare le mie impostazioni.",
|
||||
"ja_JP": "",
|
||||
"ko_KR": "설정을 초기화하고자 합니다.",
|
||||
"no_NO": "Jeg vil tilbakestille innstillingene mine.",
|
||||
"pl_PL": "",
|
||||
"pt_BR": "Quero redefinir minhas configurações.",
|
||||
"ru_RU": "Я хочу сбросить свои настройки.",
|
||||
"sv_SE": "Jag vill nollställa mina inställningar.",
|
||||
"th_TH": "",
|
||||
"tr_TR": "",
|
||||
"uk_UA": "Я хочу скинути налаштування.",
|
||||
"zh_CN": "我要重置我的设置。",
|
||||
"zh_TW": "我想重設我的設定。"
|
||||
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -2280,6 +2280,7 @@
|
||||
01008F6008C5E000,"Pokémon™ Violet",gpu;nvdec;ldn-works;amd-vendor-bug;mac-bug,ingame,2024-07-30 02:51:48
|
||||
0100187003A36000,"Pokémon™: Let’s Go, Eevee!",crash;nvdec;online-broken;ldn-broken,ingame,2024-06-01 15:03:04
|
||||
010003F003A34000,"Pokémon™: Let’s Go, Pikachu!",crash;nvdec;online-broken;ldn-broken,ingame,2024-03-15 07:55:41
|
||||
0100F43008C44000,"Pokémon Legends: Z-A",gpu;crash;ldn-broken,ingame,2025-10-16 19:13:00
|
||||
0100B3F000BE2000,"Pokkén Tournament™ DX",nvdec;ldn-works;opengl-backend-bug;LAN;amd-vendor-bug;intel-vendor-bug,playable,2024-07-18 23:11:08
|
||||
010030D005AE6000,"Pokkén Tournament™ DX Demo",demo;opengl-backend-bug,playable,2022-08-10 12:03:19
|
||||
0100A3500B4EC000,"Polandball: Can Into Space",,playable,2020-06-25 15:13:26
|
||||
|
||||
|
@@ -201,11 +201,7 @@ namespace ARMeilleure.Instructions
|
||||
|
||||
ExecutionContext context = GetContext();
|
||||
|
||||
// If debugging, we'll handle interrupts outside
|
||||
if (!Optimizations.EnableDebugging)
|
||||
{
|
||||
context.CheckInterrupt();
|
||||
}
|
||||
context.CheckInterrupt();
|
||||
|
||||
Statistics.ResumeTimer();
|
||||
|
||||
|
||||
@@ -11,27 +11,32 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
{
|
||||
public bool Enabled { get; set; }
|
||||
|
||||
public int NodeId { get; }
|
||||
public int NodeId { get; private set; }
|
||||
|
||||
public CommandType CommandType => CommandType.AdpcmDataSourceVersion1;
|
||||
|
||||
public uint EstimatedProcessingTime { get; set; }
|
||||
|
||||
public ushort OutputBufferIndex { get; }
|
||||
public uint SampleRate { get; }
|
||||
public ushort OutputBufferIndex { get; private set; }
|
||||
public uint SampleRate { get; private set; }
|
||||
|
||||
public float Pitch { get; }
|
||||
public float Pitch { get; private set; }
|
||||
|
||||
public WaveBuffer[] WaveBuffers { get; }
|
||||
|
||||
public Memory<VoiceState> State { get; }
|
||||
public Memory<VoiceState> State { get; private set; }
|
||||
|
||||
public ulong AdpcmParameter { get; }
|
||||
public ulong AdpcmParameterSize { get; }
|
||||
public ulong AdpcmParameter { get; private set; }
|
||||
public ulong AdpcmParameterSize { get; private set; }
|
||||
|
||||
public DecodingBehaviour DecodingBehaviour { get; }
|
||||
public DecodingBehaviour DecodingBehaviour { get; private set; }
|
||||
|
||||
public AdpcmDataSourceCommandVersion1(ref VoiceInfo serverInfo, Memory<VoiceState> state, ushort outputBufferIndex, int nodeId)
|
||||
public AdpcmDataSourceCommandVersion1()
|
||||
{
|
||||
WaveBuffers = new WaveBuffer[Constants.VoiceWaveBufferCount];
|
||||
}
|
||||
|
||||
public AdpcmDataSourceCommandVersion1 Initialize(ref VoiceInfo serverInfo, Memory<VoiceState> state, ushort outputBufferIndex, int nodeId)
|
||||
{
|
||||
Enabled = true;
|
||||
NodeId = nodeId;
|
||||
@@ -42,8 +47,6 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
|
||||
Span<Server.Voice.WaveBuffer> waveBufferSpan = serverInfo.WaveBuffers.AsSpan();
|
||||
|
||||
WaveBuffers = new WaveBuffer[Constants.VoiceWaveBufferCount];
|
||||
|
||||
for (int i = 0; i < WaveBuffers.Length; i++)
|
||||
{
|
||||
ref Server.Voice.WaveBuffer voiceWaveBuffer = ref waveBufferSpan[i];
|
||||
@@ -55,6 +58,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
AdpcmParameterSize = serverInfo.DataSourceStateAddressInfo.Size;
|
||||
State = state;
|
||||
DecodingBehaviour = serverInfo.DecodingBehaviour;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public void Process(CommandList context)
|
||||
|
||||
@@ -12,26 +12,31 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
{
|
||||
public bool Enabled { get; set; }
|
||||
|
||||
public int NodeId { get; }
|
||||
public int NodeId { get; private set; }
|
||||
|
||||
public CommandType CommandType => CommandType.AuxiliaryBuffer;
|
||||
|
||||
public uint EstimatedProcessingTime { get; set; }
|
||||
|
||||
public uint InputBufferIndex { get; }
|
||||
public uint OutputBufferIndex { get; }
|
||||
public uint InputBufferIndex { get; private set; }
|
||||
public uint OutputBufferIndex { get; private set; }
|
||||
|
||||
public AuxiliaryBufferAddresses BufferInfo { get; }
|
||||
public AuxiliaryBufferAddresses BufferInfo { get; private set; }
|
||||
|
||||
public CpuAddress InputBuffer { get; }
|
||||
public CpuAddress OutputBuffer { get; }
|
||||
public uint CountMax { get; }
|
||||
public uint UpdateCount { get; }
|
||||
public uint WriteOffset { get; }
|
||||
public CpuAddress InputBuffer { get; private set; }
|
||||
public CpuAddress OutputBuffer { get; private set; }
|
||||
public uint CountMax { get; private set; }
|
||||
public uint UpdateCount { get; private set; }
|
||||
public uint WriteOffset { get; private set; }
|
||||
|
||||
public bool IsEffectEnabled { get; }
|
||||
public bool IsEffectEnabled { get; private set; }
|
||||
|
||||
public AuxiliaryBufferCommand(
|
||||
public AuxiliaryBufferCommand()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public AuxiliaryBufferCommand Initialize(
|
||||
uint bufferOffset,
|
||||
byte inputBufferOffset,
|
||||
byte outputBufferOffset,
|
||||
@@ -55,6 +60,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
UpdateCount = updateCount;
|
||||
WriteOffset = writeOffset;
|
||||
IsEffectEnabled = isEnabled;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
|
||||
@@ -9,32 +9,37 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
{
|
||||
public bool Enabled { get; set; }
|
||||
|
||||
public int NodeId { get; }
|
||||
public int NodeId { get; private set; }
|
||||
|
||||
public CommandType CommandType => CommandType.BiquadFilterAndMix;
|
||||
|
||||
public uint EstimatedProcessingTime { get; set; }
|
||||
|
||||
public ushort InputBufferIndex { get; }
|
||||
public ushort OutputBufferIndex { get; }
|
||||
public ushort InputBufferIndex { get; private set; }
|
||||
public ushort OutputBufferIndex { get; private set; }
|
||||
|
||||
private BiquadFilterParameter2 _parameter;
|
||||
|
||||
public Memory<BiquadFilterState> BiquadFilterState { get; }
|
||||
public Memory<BiquadFilterState> PreviousBiquadFilterState { get; }
|
||||
public Memory<BiquadFilterState> BiquadFilterState { get; private set; }
|
||||
public Memory<BiquadFilterState> PreviousBiquadFilterState { get; private set; }
|
||||
|
||||
public Memory<VoiceState> State { get; }
|
||||
public Memory<VoiceState> State { get; private set; }
|
||||
|
||||
public int LastSampleIndex { get; }
|
||||
public int LastSampleIndex { get; private set; }
|
||||
|
||||
public float Volume0 { get; }
|
||||
public float Volume1 { get; }
|
||||
public float Volume0 { get; private set; }
|
||||
public float Volume1 { get; private set; }
|
||||
|
||||
public bool NeedInitialization { get; }
|
||||
public bool HasVolumeRamp { get; }
|
||||
public bool IsFirstMixBuffer { get; }
|
||||
public bool NeedInitialization { get; private set; }
|
||||
public bool HasVolumeRamp { get; private set; }
|
||||
public bool IsFirstMixBuffer { get; private set; }
|
||||
|
||||
public BiquadFilterAndMixCommand(
|
||||
public BiquadFilterAndMixCommand()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public BiquadFilterAndMixCommand Initialize(
|
||||
float volume0,
|
||||
float volume1,
|
||||
uint inputBufferIndex,
|
||||
@@ -68,6 +73,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
NeedInitialization = needInitialization;
|
||||
HasVolumeRamp = hasVolumeRamp;
|
||||
IsFirstMixBuffer = isFirstMixBuffer;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public void Process(CommandList context)
|
||||
|
||||
@@ -8,20 +8,25 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
{
|
||||
public bool Enabled { get; set; }
|
||||
|
||||
public int NodeId { get; }
|
||||
public int NodeId { get; private set; }
|
||||
|
||||
public CommandType CommandType => CommandType.BiquadFilter;
|
||||
|
||||
public uint EstimatedProcessingTime { get; set; }
|
||||
|
||||
public Memory<BiquadFilterState> BiquadFilterState { get; }
|
||||
public int InputBufferIndex { get; }
|
||||
public int OutputBufferIndex { get; }
|
||||
public bool NeedInitialization { get; }
|
||||
public Memory<BiquadFilterState> BiquadFilterState { get; private set; }
|
||||
public int InputBufferIndex { get; private set; }
|
||||
public int OutputBufferIndex { get; private set; }
|
||||
public bool NeedInitialization { get; private set; }
|
||||
|
||||
private BiquadFilterParameter2 _parameter;
|
||||
|
||||
public BiquadFilterCommand(
|
||||
public BiquadFilterCommand()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public BiquadFilterCommand Initialize(
|
||||
int baseIndex,
|
||||
ref BiquadFilterParameter2 filter,
|
||||
Memory<BiquadFilterState> biquadFilterStateMemory,
|
||||
@@ -38,6 +43,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
|
||||
Enabled = true;
|
||||
NodeId = nodeId;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public void Process(CommandList context)
|
||||
|
||||
@@ -12,25 +12,30 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
{
|
||||
public bool Enabled { get; set; }
|
||||
|
||||
public int NodeId { get; }
|
||||
public int NodeId { get; private set; }
|
||||
|
||||
public CommandType CommandType => CommandType.CaptureBuffer;
|
||||
|
||||
public uint EstimatedProcessingTime { get; set; }
|
||||
|
||||
public uint InputBufferIndex { get; }
|
||||
public uint InputBufferIndex { get; private set; }
|
||||
|
||||
public ulong CpuBufferInfoAddress { get; }
|
||||
public ulong DspBufferInfoAddress { get; }
|
||||
public ulong CpuBufferInfoAddress { get; private set; }
|
||||
public ulong DspBufferInfoAddress { get; private set; }
|
||||
|
||||
public CpuAddress OutputBuffer { get; }
|
||||
public uint CountMax { get; }
|
||||
public uint UpdateCount { get; }
|
||||
public uint WriteOffset { get; }
|
||||
public CpuAddress OutputBuffer { get; private set; }
|
||||
public uint CountMax { get; private set; }
|
||||
public uint UpdateCount { get; private set; }
|
||||
public uint WriteOffset { get; private set; }
|
||||
|
||||
public bool IsEffectEnabled { get; }
|
||||
public bool IsEffectEnabled { get; private set; }
|
||||
|
||||
public CaptureBufferCommand(uint bufferOffset, byte inputBufferOffset, ulong sendBufferInfo, bool isEnabled,
|
||||
public CaptureBufferCommand()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public CaptureBufferCommand Initialize(uint bufferOffset, byte inputBufferOffset, ulong sendBufferInfo, bool isEnabled,
|
||||
uint countMax, CpuAddress outputBuffer, uint updateCount, uint writeOffset, int nodeId)
|
||||
{
|
||||
Enabled = true;
|
||||
@@ -43,6 +48,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
UpdateCount = updateCount;
|
||||
WriteOffset = writeOffset;
|
||||
IsEffectEnabled = isEnabled;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
|
||||
@@ -9,25 +9,29 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
{
|
||||
public bool Enabled { get; set; }
|
||||
|
||||
public int NodeId { get; }
|
||||
public int NodeId { get; private set; }
|
||||
|
||||
public CommandType CommandType => CommandType.CircularBufferSink;
|
||||
|
||||
public uint EstimatedProcessingTime { get; set; }
|
||||
|
||||
public ushort[] Input { get; }
|
||||
public uint InputCount { get; }
|
||||
public uint InputCount { get; private set; }
|
||||
|
||||
public ulong CircularBuffer { get; }
|
||||
public ulong CircularBufferSize { get; }
|
||||
public ulong CurrentOffset { get; }
|
||||
public ulong CircularBuffer { get; private set; }
|
||||
public ulong CircularBufferSize { get; private set; }
|
||||
public ulong CurrentOffset { get; private set; }
|
||||
|
||||
public CircularBufferSinkCommand(uint bufferOffset, ref CircularBufferParameter parameter, ref AddressInfo circularBufferAddressInfo, uint currentOffset, int nodeId)
|
||||
public CircularBufferSinkCommand()
|
||||
{
|
||||
Input = new ushort[Constants.ChannelCountMax];
|
||||
}
|
||||
|
||||
public CircularBufferSinkCommand Initialize(uint bufferOffset, ref CircularBufferParameter parameter, ref AddressInfo circularBufferAddressInfo, uint currentOffset, int nodeId)
|
||||
{
|
||||
Enabled = true;
|
||||
NodeId = nodeId;
|
||||
|
||||
Input = new ushort[Constants.ChannelCountMax];
|
||||
InputCount = parameter.InputCount;
|
||||
|
||||
Span<byte> inputSpan = parameter.Input.AsSpan();
|
||||
@@ -42,6 +46,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
CurrentOffset = currentOffset;
|
||||
|
||||
Debug.Assert(CircularBuffer != 0);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public void Process(CommandList context)
|
||||
|
||||
@@ -4,16 +4,23 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
{
|
||||
public bool Enabled { get; set; }
|
||||
|
||||
public int NodeId { get; }
|
||||
public int NodeId { get; private set; }
|
||||
|
||||
public CommandType CommandType => CommandType.ClearMixBuffer;
|
||||
|
||||
public uint EstimatedProcessingTime { get; set; }
|
||||
|
||||
public ClearMixBufferCommand(int nodeId)
|
||||
public ClearMixBufferCommand()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ClearMixBufferCommand Initialize(int nodeId)
|
||||
{
|
||||
Enabled = true;
|
||||
NodeId = nodeId;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public void Process(CommandList context)
|
||||
|
||||
@@ -20,6 +20,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
public Memory<float> Buffers { get; }
|
||||
public uint BufferCount { get; }
|
||||
|
||||
private readonly static ObjectPool<List<ICommand>> CommandsListPool = new(() => new List<ICommand>(256));
|
||||
public List<ICommand> Commands { get; }
|
||||
|
||||
public IVirtualMemoryManager MemoryManager { get; }
|
||||
@@ -46,7 +47,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
SampleRate = sampleRate;
|
||||
BufferCount = mixBufferCount + voiceChannelCountMax;
|
||||
Buffers = mixBuffer;
|
||||
Commands = [];
|
||||
Commands = CommandsListPool.Allocate();
|
||||
MemoryManager = memoryManager;
|
||||
|
||||
_buffersEntryCount = Buffers.Length;
|
||||
@@ -142,6 +143,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CommandBuffer.ReleaseCommand(command);
|
||||
}
|
||||
|
||||
EndTime = (ulong)PerformanceCounter.ElapsedNanoseconds;
|
||||
@@ -149,6 +152,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Commands.Clear();
|
||||
CommandsListPool.Release(Commands);
|
||||
GC.SuppressFinalize(this);
|
||||
_buffersMemoryHandle.Dispose();
|
||||
}
|
||||
|
||||
@@ -15,22 +15,28 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
|
||||
public bool Enabled { get; set; }
|
||||
|
||||
public int NodeId { get; }
|
||||
public int NodeId { get; private set; }
|
||||
|
||||
public CommandType CommandType => CommandType.Compressor;
|
||||
|
||||
public uint EstimatedProcessingTime { get; set; }
|
||||
|
||||
public CompressorParameter Parameter => _parameter;
|
||||
public Memory<CompressorState> State { get; }
|
||||
public Memory<EffectResultState> ResultState { get; }
|
||||
public Memory<CompressorState> State { get; private set; }
|
||||
public Memory<EffectResultState> ResultState { get; private set; }
|
||||
public ushort[] OutputBufferIndices { get; }
|
||||
public ushort[] InputBufferIndices { get; }
|
||||
public bool IsEffectEnabled { get; }
|
||||
public bool IsEffectEnabled { get; private set; }
|
||||
|
||||
private CompressorParameter _parameter;
|
||||
|
||||
public CompressorCommand(uint bufferOffset, CompressorParameter parameter, Memory<CompressorState> state, Memory<EffectResultState> resultState, bool isEnabled, int nodeId)
|
||||
public CompressorCommand()
|
||||
{
|
||||
InputBufferIndices = new ushort[Constants.VoiceChannelCountMax];
|
||||
OutputBufferIndices = new ushort[Constants.VoiceChannelCountMax];
|
||||
}
|
||||
|
||||
public CompressorCommand Initialize(uint bufferOffset, CompressorParameter parameter, Memory<CompressorState> state, Memory<EffectResultState> resultState, bool isEnabled, int nodeId)
|
||||
{
|
||||
Enabled = true;
|
||||
NodeId = nodeId;
|
||||
@@ -39,9 +45,6 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
ResultState = resultState;
|
||||
|
||||
IsEffectEnabled = isEnabled;
|
||||
|
||||
InputBufferIndices = new ushort[Constants.VoiceChannelCountMax];
|
||||
OutputBufferIndices = new ushort[Constants.VoiceChannelCountMax];
|
||||
|
||||
Span<byte> inputSpan = _parameter.Input.AsSpan();
|
||||
Span<byte> outputSpan = _parameter.Output.AsSpan();
|
||||
@@ -51,6 +54,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
InputBufferIndices[i] = (ushort)(bufferOffset + inputSpan[i]);
|
||||
OutputBufferIndices[i] = (ushort)(bufferOffset + outputSpan[i]);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public void Process(CommandList context)
|
||||
|
||||
@@ -4,22 +4,29 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
{
|
||||
public bool Enabled { get; set; }
|
||||
|
||||
public int NodeId { get; }
|
||||
public int NodeId { get; private set; }
|
||||
|
||||
public CommandType CommandType => CommandType.CopyMixBuffer;
|
||||
|
||||
public uint EstimatedProcessingTime { get; set; }
|
||||
|
||||
public ushort InputBufferIndex { get; }
|
||||
public ushort OutputBufferIndex { get; }
|
||||
public ushort InputBufferIndex { get; private set; }
|
||||
public ushort OutputBufferIndex { get; private set; }
|
||||
|
||||
public CopyMixBufferCommand(uint inputBufferIndex, uint outputBufferIndex, int nodeId)
|
||||
public CopyMixBufferCommand()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public CopyMixBufferCommand Initialize(uint inputBufferIndex, uint outputBufferIndex, int nodeId)
|
||||
{
|
||||
Enabled = true;
|
||||
NodeId = nodeId;
|
||||
|
||||
InputBufferIndex = (ushort)inputBufferIndex;
|
||||
OutputBufferIndex = (ushort)outputBufferIndex;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public void Process(CommandList context)
|
||||
|
||||
@@ -3,6 +3,7 @@ using Ryujinx.Audio.Renderer.Common;
|
||||
using Ryujinx.Audio.Renderer.Server.Voice;
|
||||
using System;
|
||||
using Ryujinx.Audio.Renderer.Parameter;
|
||||
using Ryujinx.Memory;
|
||||
using WaveBuffer = Ryujinx.Audio.Renderer.Common.WaveBuffer;
|
||||
|
||||
namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
@@ -11,35 +12,40 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
{
|
||||
public bool Enabled { get; set; }
|
||||
|
||||
public int NodeId { get; }
|
||||
public int NodeId { get; private set; }
|
||||
|
||||
public CommandType CommandType { get; }
|
||||
public CommandType CommandType { get; private set; }
|
||||
|
||||
public uint EstimatedProcessingTime { get; set; }
|
||||
|
||||
public ushort OutputBufferIndex { get; }
|
||||
public uint SampleRate { get; }
|
||||
public ushort OutputBufferIndex { get; private set; }
|
||||
public uint SampleRate { get; private set; }
|
||||
|
||||
public float Pitch { get; }
|
||||
public float Pitch { get; private set; }
|
||||
|
||||
public WaveBuffer[] WaveBuffers { get; }
|
||||
|
||||
public Memory<VoiceState> State { get; }
|
||||
public Memory<VoiceState> State { get; private set; }
|
||||
|
||||
public ulong ExtraParameter { get; }
|
||||
public ulong ExtraParameterSize { get; }
|
||||
public ulong ExtraParameter { get; private set; }
|
||||
public ulong ExtraParameterSize { get; private set; }
|
||||
|
||||
public uint ChannelIndex { get; }
|
||||
public uint ChannelIndex { get; private set; }
|
||||
|
||||
public uint ChannelCount { get; }
|
||||
public uint ChannelCount { get; private set; }
|
||||
|
||||
public DecodingBehaviour DecodingBehaviour { get; }
|
||||
public DecodingBehaviour DecodingBehaviour { get; private set; }
|
||||
|
||||
public SampleFormat SampleFormat { get; }
|
||||
public SampleFormat SampleFormat { get; private set; }
|
||||
|
||||
public SampleRateConversionQuality SrcQuality { get; }
|
||||
public SampleRateConversionQuality SrcQuality { get; private set; }
|
||||
|
||||
public DataSourceVersion2Command(ref VoiceInfo serverInfo, Memory<VoiceState> state, ushort outputBufferIndex, ushort channelIndex, int nodeId)
|
||||
public DataSourceVersion2Command()
|
||||
{
|
||||
WaveBuffers = new WaveBuffer[Constants.VoiceWaveBufferCount];
|
||||
}
|
||||
|
||||
public DataSourceVersion2Command Initialize(ref VoiceInfo serverInfo, Memory<VoiceState> state, ushort outputBufferIndex, ushort channelIndex, int nodeId)
|
||||
{
|
||||
Enabled = true;
|
||||
NodeId = nodeId;
|
||||
@@ -55,8 +61,6 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
|
||||
Span<Server.Voice.WaveBuffer> waveBufferSpan = serverInfo.WaveBuffers.AsSpan();
|
||||
|
||||
WaveBuffers = new WaveBuffer[Constants.VoiceWaveBufferCount];
|
||||
|
||||
for (int i = 0; i < WaveBuffers.Length; i++)
|
||||
{
|
||||
ref Server.Voice.WaveBuffer voiceWaveBuffer = ref waveBufferSpan[i];
|
||||
@@ -72,6 +76,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
|
||||
State = state;
|
||||
DecodingBehaviour = serverInfo.DecodingBehaviour;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
private static CommandType GetCommandTypeBySampleFormat(SampleFormat sampleFormat)
|
||||
|
||||
@@ -13,24 +13,30 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
{
|
||||
public bool Enabled { get; set; }
|
||||
|
||||
public int NodeId { get; }
|
||||
public int NodeId { get; private set; }
|
||||
|
||||
public CommandType CommandType => CommandType.Delay;
|
||||
|
||||
public uint EstimatedProcessingTime { get; set; }
|
||||
|
||||
public DelayParameter Parameter => _parameter;
|
||||
public Memory<DelayState> State { get; }
|
||||
public ulong WorkBuffer { get; }
|
||||
public Memory<DelayState> State { get; private set; }
|
||||
public ulong WorkBuffer { get; private set; }
|
||||
public ushort[] OutputBufferIndices { get; }
|
||||
public ushort[] InputBufferIndices { get; }
|
||||
public bool IsEffectEnabled { get; }
|
||||
public bool IsEffectEnabled { get; private set; }
|
||||
|
||||
private DelayParameter _parameter;
|
||||
|
||||
private const int FixedPointPrecision = 14;
|
||||
|
||||
public DelayCommand(uint bufferOffset, DelayParameter parameter, Memory<DelayState> state, bool isEnabled, ulong workBuffer, int nodeId, bool newEffectChannelMappingSupported)
|
||||
public DelayCommand()
|
||||
{
|
||||
InputBufferIndices = new ushort[Constants.VoiceChannelCountMax];
|
||||
OutputBufferIndices = new ushort[Constants.VoiceChannelCountMax];
|
||||
}
|
||||
|
||||
public DelayCommand Initialize(uint bufferOffset, DelayParameter parameter, Memory<DelayState> state, bool isEnabled, ulong workBuffer, int nodeId, bool newEffectChannelMappingSupported)
|
||||
{
|
||||
Enabled = true;
|
||||
NodeId = nodeId;
|
||||
@@ -39,9 +45,6 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
WorkBuffer = workBuffer;
|
||||
|
||||
IsEffectEnabled = isEnabled;
|
||||
|
||||
InputBufferIndices = new ushort[Constants.VoiceChannelCountMax];
|
||||
OutputBufferIndices = new ushort[Constants.VoiceChannelCountMax];
|
||||
|
||||
Span<byte> inputSpan = Parameter.Input.AsSpan();
|
||||
Span<byte> outputSpan = Parameter.Output.AsSpan();
|
||||
@@ -54,6 +57,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
|
||||
DataSourceHelper.RemapLegacyChannelEffectMappingToChannelResourceMapping(newEffectChannelMappingSupported, InputBufferIndices, Parameter.ChannelCount);
|
||||
DataSourceHelper.RemapLegacyChannelEffectMappingToChannelResourceMapping(newEffectChannelMappingSupported, OutputBufferIndices, Parameter.ChannelCount);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
|
||||
@@ -7,21 +7,26 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
{
|
||||
public bool Enabled { get; set; }
|
||||
|
||||
public int NodeId { get; }
|
||||
public int NodeId { get; private set; }
|
||||
|
||||
public CommandType CommandType => CommandType.DepopForMixBuffers;
|
||||
|
||||
public uint EstimatedProcessingTime { get; set; }
|
||||
|
||||
public uint MixBufferOffset { get; }
|
||||
public uint MixBufferOffset { get; private set; }
|
||||
|
||||
public uint MixBufferCount { get; }
|
||||
public uint MixBufferCount { get; private set; }
|
||||
|
||||
public float Decay { get; }
|
||||
public float Decay { get; private set; }
|
||||
|
||||
public Memory<float> DepopBuffer { get; }
|
||||
public Memory<float> DepopBuffer { get; private set; }
|
||||
|
||||
public DepopForMixBuffersCommand(Memory<float> depopBuffer, uint bufferOffset, uint mixBufferCount, int nodeId, uint sampleRate)
|
||||
public DepopForMixBuffersCommand()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public DepopForMixBuffersCommand Initialize(Memory<float> depopBuffer, uint bufferOffset, uint mixBufferCount, int nodeId, uint sampleRate)
|
||||
{
|
||||
Enabled = true;
|
||||
NodeId = nodeId;
|
||||
@@ -37,6 +42,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
{
|
||||
Decay = 0.943695f;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
|
||||
@@ -7,27 +7,30 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
{
|
||||
public bool Enabled { get; set; }
|
||||
|
||||
public int NodeId { get; }
|
||||
public int NodeId { get; private set; }
|
||||
|
||||
public CommandType CommandType => CommandType.DepopPrepare;
|
||||
|
||||
public uint EstimatedProcessingTime { get; set; }
|
||||
|
||||
public uint MixBufferCount { get; }
|
||||
public uint MixBufferCount { get; private set; }
|
||||
|
||||
public ushort[] OutputBufferIndices { get; }
|
||||
|
||||
public Memory<VoiceState> State { get; }
|
||||
public Memory<float> DepopBuffer { get; }
|
||||
public Memory<VoiceState> State { get; private set; }
|
||||
public Memory<float> DepopBuffer { get; private set; }
|
||||
|
||||
public DepopPrepareCommand(Memory<VoiceState> state, Memory<float> depopBuffer, uint mixBufferCount, uint bufferOffset, int nodeId, bool enabled)
|
||||
public DepopPrepareCommand()
|
||||
{
|
||||
OutputBufferIndices = new ushort[Constants.MixBufferCountMax];
|
||||
}
|
||||
|
||||
public DepopPrepareCommand Initialize(Memory<VoiceState> state, Memory<float> depopBuffer, uint mixBufferCount, uint bufferOffset, int nodeId, bool enabled)
|
||||
{
|
||||
Enabled = enabled;
|
||||
NodeId = nodeId;
|
||||
MixBufferCount = mixBufferCount;
|
||||
|
||||
OutputBufferIndices = new ushort[Constants.MixBufferCountMax];
|
||||
|
||||
for (int i = 0; i < Constants.MixBufferCountMax; i++)
|
||||
{
|
||||
OutputBufferIndices[i] = (ushort)(bufferOffset + i);
|
||||
@@ -35,6 +38,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
|
||||
State = state;
|
||||
DepopBuffer = depopBuffer;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public void Process(CommandList context)
|
||||
|
||||
@@ -10,22 +10,27 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
{
|
||||
public bool Enabled { get; set; }
|
||||
|
||||
public int NodeId { get; }
|
||||
public int NodeId { get; private set; }
|
||||
|
||||
public CommandType CommandType => CommandType.DeviceSink;
|
||||
|
||||
public uint EstimatedProcessingTime { get; set; }
|
||||
|
||||
public string DeviceName { get; }
|
||||
public string DeviceName { get; private set; }
|
||||
|
||||
public int SessionId { get; }
|
||||
public int SessionId { get; private set; }
|
||||
|
||||
public uint InputCount { get; }
|
||||
public ushort[] InputBufferIndices { get; }
|
||||
public uint InputCount { get; private set; }
|
||||
public ushort[] InputBufferIndices { get; private set; }
|
||||
|
||||
public Memory<float> Buffers { get; }
|
||||
public Memory<float> Buffers { get; private set; }
|
||||
|
||||
public DeviceSinkCommand(uint bufferOffset, DeviceSink sink, int sessionId, Memory<float> buffers, int nodeId)
|
||||
public DeviceSinkCommand()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public DeviceSinkCommand Initialize(uint bufferOffset, DeviceSink sink, int sessionId, Memory<float> buffers, int nodeId)
|
||||
{
|
||||
Enabled = true;
|
||||
NodeId = nodeId;
|
||||
@@ -50,6 +55,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
{
|
||||
Buffers = buffers;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
{
|
||||
public bool Enabled { get; set; }
|
||||
|
||||
public int NodeId { get; }
|
||||
public int NodeId { get; private set; }
|
||||
|
||||
public CommandType CommandType => CommandType.DownMixSurroundToStereo;
|
||||
|
||||
@@ -16,16 +16,19 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
public ushort[] InputBufferIndices { get; }
|
||||
public ushort[] OutputBufferIndices { get; }
|
||||
|
||||
public float[] Coefficients { get; }
|
||||
public float[] Coefficients { get; private set; }
|
||||
|
||||
public DownMixSurroundToStereoCommand(uint bufferOffset, Span<byte> inputBufferOffset, Span<byte> outputBufferOffset, float[] downMixParameter, int nodeId)
|
||||
public DownMixSurroundToStereoCommand()
|
||||
{
|
||||
InputBufferIndices = new ushort[Constants.VoiceChannelCountMax];
|
||||
OutputBufferIndices = new ushort[Constants.VoiceChannelCountMax];
|
||||
}
|
||||
|
||||
public DownMixSurroundToStereoCommand Initialize(uint bufferOffset, Span<byte> inputBufferOffset, Span<byte> outputBufferOffset, float[] downMixParameter, int nodeId)
|
||||
{
|
||||
Enabled = true;
|
||||
NodeId = nodeId;
|
||||
|
||||
InputBufferIndices = new ushort[Constants.VoiceChannelCountMax];
|
||||
OutputBufferIndices = new ushort[Constants.VoiceChannelCountMax];
|
||||
|
||||
for (int i = 0; i < Constants.VoiceChannelCountMax; i++)
|
||||
{
|
||||
InputBufferIndices[i] = (ushort)(bufferOffset + inputBufferOffset[i]);
|
||||
@@ -33,6 +36,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
}
|
||||
|
||||
Coefficients = downMixParameter;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
|
||||
@@ -8,38 +8,43 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
{
|
||||
public bool Enabled { get; set; }
|
||||
|
||||
public int NodeId { get; }
|
||||
public int NodeId { get; private set; }
|
||||
|
||||
public CommandType CommandType => CommandType.FillBuffer;
|
||||
|
||||
public uint EstimatedProcessingTime { get; set; }
|
||||
|
||||
public SplitterDestinationVersion1 Destination1 { get; }
|
||||
public SplitterDestinationVersion2 Destination2 { get; }
|
||||
public bool IsV2 { get; }
|
||||
public int Length { get; }
|
||||
public float Value { get; }
|
||||
public SplitterDestinationVersion1 Destination1 { get; private set; }
|
||||
public SplitterDestinationVersion2 Destination2 { get; private set; }
|
||||
public bool IsV2 { get; private set; }
|
||||
public int Length { get; private set; }
|
||||
public float Value { get; private set; }
|
||||
|
||||
public FillBufferCommand(SplitterDestinationVersion1 destination, int length, float value, int nodeId)
|
||||
public FillBufferCommand()
|
||||
{
|
||||
Enabled = true;
|
||||
NodeId = nodeId;
|
||||
|
||||
Destination1 = destination;
|
||||
IsV2 = false;
|
||||
Length = length;
|
||||
Value = value;
|
||||
|
||||
}
|
||||
|
||||
public FillBufferCommand(SplitterDestinationVersion2 destination, int length, float value, int nodeId)
|
||||
public FillBufferCommand Initialize(SplitterDestination destination, int length, float value, int nodeId)
|
||||
{
|
||||
Enabled = true;
|
||||
NodeId = nodeId;
|
||||
|
||||
if (Unsafe.IsNullRef(ref destination.GetV2RefOrNull()))
|
||||
{
|
||||
Destination1 = destination.GetV1RefOrNull();
|
||||
IsV2 = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Destination2 = destination.GetV2RefOrNull();
|
||||
IsV2 = true;
|
||||
}
|
||||
|
||||
Destination2 = destination;
|
||||
IsV2 = true;
|
||||
Length = length;
|
||||
Value = value;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
|
||||
@@ -10,22 +10,28 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
{
|
||||
public bool Enabled { get; set; }
|
||||
|
||||
public int NodeId { get; }
|
||||
public int NodeId { get; private set; }
|
||||
|
||||
public CommandType CommandType => CommandType.LimiterVersion1;
|
||||
|
||||
public uint EstimatedProcessingTime { get; set; }
|
||||
|
||||
public LimiterParameter Parameter => _parameter;
|
||||
public Memory<LimiterState> State { get; }
|
||||
public ulong WorkBuffer { get; }
|
||||
public Memory<LimiterState> State { get; private set; }
|
||||
public ulong WorkBuffer { get; private set; }
|
||||
public ushort[] OutputBufferIndices { get; }
|
||||
public ushort[] InputBufferIndices { get; }
|
||||
public bool IsEffectEnabled { get; }
|
||||
public bool IsEffectEnabled { get; private set; }
|
||||
|
||||
private LimiterParameter _parameter;
|
||||
|
||||
public LimiterCommandVersion1(uint bufferOffset, LimiterParameter parameter, Memory<LimiterState> state, bool isEnabled, ulong workBuffer, int nodeId)
|
||||
public LimiterCommandVersion1()
|
||||
{
|
||||
InputBufferIndices = new ushort[Constants.VoiceChannelCountMax];
|
||||
OutputBufferIndices = new ushort[Constants.VoiceChannelCountMax];
|
||||
}
|
||||
|
||||
public LimiterCommandVersion1 Initialize(uint bufferOffset, LimiterParameter parameter, Memory<LimiterState> state, bool isEnabled, ulong workBuffer, int nodeId)
|
||||
{
|
||||
Enabled = true;
|
||||
NodeId = nodeId;
|
||||
@@ -35,9 +41,6 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
|
||||
IsEffectEnabled = isEnabled;
|
||||
|
||||
InputBufferIndices = new ushort[Constants.VoiceChannelCountMax];
|
||||
OutputBufferIndices = new ushort[Constants.VoiceChannelCountMax];
|
||||
|
||||
Span<byte> inputSpan = _parameter.Input.AsSpan();
|
||||
Span<byte> outputSpan = _parameter.Output.AsSpan();
|
||||
|
||||
@@ -46,6 +49,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
InputBufferIndices[i] = (ushort)(bufferOffset + inputSpan[i]);
|
||||
OutputBufferIndices[i] = (ushort)(bufferOffset + outputSpan[i]);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public void Process(CommandList context)
|
||||
|
||||
@@ -12,23 +12,29 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
{
|
||||
public bool Enabled { get; set; }
|
||||
|
||||
public int NodeId { get; }
|
||||
public int NodeId { get; private set; }
|
||||
|
||||
public CommandType CommandType => CommandType.LimiterVersion2;
|
||||
|
||||
public uint EstimatedProcessingTime { get; set; }
|
||||
|
||||
public LimiterParameter Parameter => _parameter;
|
||||
public Memory<LimiterState> State { get; }
|
||||
public Memory<EffectResultState> ResultState { get; }
|
||||
public ulong WorkBuffer { get; }
|
||||
public Memory<LimiterState> State { get; private set; }
|
||||
public Memory<EffectResultState> ResultState { get; private set; }
|
||||
public ulong WorkBuffer { get; private set; }
|
||||
public ushort[] OutputBufferIndices { get; }
|
||||
public ushort[] InputBufferIndices { get; }
|
||||
public bool IsEffectEnabled { get; }
|
||||
public bool IsEffectEnabled { get; private set; }
|
||||
|
||||
private LimiterParameter _parameter;
|
||||
|
||||
public LimiterCommandVersion2(
|
||||
public LimiterCommandVersion2()
|
||||
{
|
||||
InputBufferIndices = new ushort[Constants.VoiceChannelCountMax];
|
||||
OutputBufferIndices = new ushort[Constants.VoiceChannelCountMax];
|
||||
}
|
||||
|
||||
public LimiterCommandVersion2 Initialize(
|
||||
uint bufferOffset,
|
||||
LimiterParameter parameter,
|
||||
Memory<LimiterState> state,
|
||||
@@ -45,9 +51,6 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
WorkBuffer = workBuffer;
|
||||
|
||||
IsEffectEnabled = isEnabled;
|
||||
|
||||
InputBufferIndices = new ushort[Constants.VoiceChannelCountMax];
|
||||
OutputBufferIndices = new ushort[Constants.VoiceChannelCountMax];
|
||||
|
||||
Span<byte> inputSpan = _parameter.Input.AsSpan();
|
||||
Span<byte> outputSpan = _parameter.Output.AsSpan();
|
||||
@@ -57,6 +60,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
InputBufferIndices[i] = (ushort)(bufferOffset + inputSpan[i]);
|
||||
OutputBufferIndices[i] = (ushort)(bufferOffset + outputSpan[i]);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public void Process(CommandList context)
|
||||
|
||||
@@ -11,18 +11,23 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
{
|
||||
public bool Enabled { get; set; }
|
||||
|
||||
public int NodeId { get; }
|
||||
public int NodeId { get; private set; }
|
||||
|
||||
public CommandType CommandType => CommandType.Mix;
|
||||
|
||||
public uint EstimatedProcessingTime { get; set; }
|
||||
|
||||
public ushort InputBufferIndex { get; }
|
||||
public ushort OutputBufferIndex { get; }
|
||||
public ushort InputBufferIndex { get; private set; }
|
||||
public ushort OutputBufferIndex { get; private set; }
|
||||
|
||||
public float Volume { get; }
|
||||
public float Volume { get; private set; }
|
||||
|
||||
public MixCommand(uint inputBufferIndex, uint outputBufferIndex, int nodeId, float volume)
|
||||
public MixCommand()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public MixCommand Initialize(uint inputBufferIndex, uint outputBufferIndex, int nodeId, float volume)
|
||||
{
|
||||
Enabled = true;
|
||||
NodeId = nodeId;
|
||||
@@ -31,6 +36,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
OutputBufferIndex = (ushort)outputBufferIndex;
|
||||
|
||||
Volume = volume;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
|
||||
@@ -8,23 +8,28 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
{
|
||||
public bool Enabled { get; set; }
|
||||
|
||||
public int NodeId { get; }
|
||||
public int NodeId { get; private set; }
|
||||
|
||||
public CommandType CommandType => CommandType.MixRamp;
|
||||
|
||||
public uint EstimatedProcessingTime { get; set; }
|
||||
|
||||
public ushort InputBufferIndex { get; }
|
||||
public ushort OutputBufferIndex { get; }
|
||||
public ushort InputBufferIndex { get; private set; }
|
||||
public ushort OutputBufferIndex { get; private set; }
|
||||
|
||||
public float Volume0 { get; }
|
||||
public float Volume1 { get; }
|
||||
public float Volume0 { get; private set; }
|
||||
public float Volume1 { get; private set; }
|
||||
|
||||
public Memory<VoiceState> State { get; }
|
||||
public Memory<VoiceState> State { get; private set; }
|
||||
|
||||
public int LastSampleIndex { get; }
|
||||
public int LastSampleIndex { get; private set; }
|
||||
|
||||
public MixRampCommand(float volume0, float volume1, uint inputBufferIndex, uint outputBufferIndex, int lastSampleIndex, Memory<VoiceState> state, int nodeId)
|
||||
public MixRampCommand()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public MixRampCommand Initialize(float volume0, float volume1, uint inputBufferIndex, uint outputBufferIndex, int lastSampleIndex, Memory<VoiceState> state, int nodeId)
|
||||
{
|
||||
Enabled = true;
|
||||
NodeId = nodeId;
|
||||
@@ -37,6 +42,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
|
||||
State = state;
|
||||
LastSampleIndex = lastSampleIndex;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
|
||||
@@ -8,23 +8,28 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
{
|
||||
public bool Enabled { get; set; }
|
||||
|
||||
public int NodeId { get; }
|
||||
public int NodeId { get; private set; }
|
||||
|
||||
public CommandType CommandType => CommandType.MixRampGrouped;
|
||||
|
||||
public uint EstimatedProcessingTime { get; set; }
|
||||
|
||||
public uint MixBufferCount { get; }
|
||||
public uint MixBufferCount { get; private set; }
|
||||
|
||||
public ushort[] InputBufferIndices { get; }
|
||||
public ushort[] OutputBufferIndices { get; }
|
||||
public ushort[] InputBufferIndices { get; private set; }
|
||||
public ushort[] OutputBufferIndices { get; private set; }
|
||||
|
||||
public float[] Volume0 { get; }
|
||||
public float[] Volume1 { get; }
|
||||
public float[] Volume0 { get; private set; }
|
||||
public float[] Volume1 { get; private set; }
|
||||
|
||||
public Memory<VoiceState> State { get; }
|
||||
public Memory<VoiceState> State { get; private set; }
|
||||
|
||||
public MixRampGroupedCommand(
|
||||
public MixRampGroupedCommand()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public MixRampGroupedCommand Initialize(
|
||||
uint mixBufferCount,
|
||||
uint inputBufferIndex,
|
||||
uint outputBufferIndex,
|
||||
@@ -52,6 +57,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
}
|
||||
|
||||
State = state;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
|
||||
@@ -9,36 +9,41 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
{
|
||||
public bool Enabled { get; set; }
|
||||
|
||||
public int NodeId { get; }
|
||||
public int NodeId { get; private set; }
|
||||
|
||||
public CommandType CommandType => CommandType.MultiTapBiquadFilterAndMix;
|
||||
|
||||
public uint EstimatedProcessingTime { get; set; }
|
||||
|
||||
public ushort InputBufferIndex { get; }
|
||||
public ushort OutputBufferIndex { get; }
|
||||
public ushort InputBufferIndex { get; private set; }
|
||||
public ushort OutputBufferIndex { get; private set; }
|
||||
|
||||
private BiquadFilterParameter2 _parameter0;
|
||||
private BiquadFilterParameter2 _parameter1;
|
||||
|
||||
public Memory<BiquadFilterState> BiquadFilterState0 { get; }
|
||||
public Memory<BiquadFilterState> BiquadFilterState1 { get; }
|
||||
public Memory<BiquadFilterState> PreviousBiquadFilterState0 { get; }
|
||||
public Memory<BiquadFilterState> PreviousBiquadFilterState1 { get; }
|
||||
public Memory<BiquadFilterState> BiquadFilterState0 { get; private set; }
|
||||
public Memory<BiquadFilterState> BiquadFilterState1 { get; private set; }
|
||||
public Memory<BiquadFilterState> PreviousBiquadFilterState0 { get; private set; }
|
||||
public Memory<BiquadFilterState> PreviousBiquadFilterState1 { get; private set; }
|
||||
|
||||
public Memory<VoiceState> State { get; }
|
||||
public Memory<VoiceState> State { get; private set; }
|
||||
|
||||
public int LastSampleIndex { get; }
|
||||
public int LastSampleIndex { get; private set; }
|
||||
|
||||
public float Volume0 { get; }
|
||||
public float Volume1 { get; }
|
||||
public float Volume0 { get; private set; }
|
||||
public float Volume1 { get; private set; }
|
||||
|
||||
public bool NeedInitialization0 { get; }
|
||||
public bool NeedInitialization1 { get; }
|
||||
public bool HasVolumeRamp { get; }
|
||||
public bool IsFirstMixBuffer { get; }
|
||||
public bool NeedInitialization0 { get; private set; }
|
||||
public bool NeedInitialization1 { get; private set; }
|
||||
public bool HasVolumeRamp { get; private set; }
|
||||
public bool IsFirstMixBuffer { get; private set; }
|
||||
|
||||
public MultiTapBiquadFilterAndMixCommand(
|
||||
public MultiTapBiquadFilterAndMixCommand()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public MultiTapBiquadFilterAndMixCommand Initialize(
|
||||
float volume0,
|
||||
float volume1,
|
||||
uint inputBufferIndex,
|
||||
@@ -80,6 +85,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
NeedInitialization1 = needInitialization1;
|
||||
HasVolumeRamp = hasVolumeRamp;
|
||||
IsFirstMixBuffer = isFirstMixBuffer;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
private void UpdateState(Memory<BiquadFilterState> state, Memory<BiquadFilterState> previousState, bool needInitialization)
|
||||
|
||||
@@ -8,40 +8,47 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
{
|
||||
public bool Enabled { get; set; }
|
||||
|
||||
public int NodeId { get; }
|
||||
public int NodeId { get; private set; }
|
||||
|
||||
public CommandType CommandType => CommandType.MultiTapBiquadFilter;
|
||||
|
||||
public uint EstimatedProcessingTime { get; set; }
|
||||
|
||||
private readonly BiquadFilterParameter2[] _parameters;
|
||||
private readonly Memory<BiquadFilterState> _biquadFilterStates;
|
||||
private readonly int _inputBufferIndex;
|
||||
private readonly int _outputBufferIndex;
|
||||
private readonly bool[] _isInitialized;
|
||||
public BiquadFilterParameter2[] Parameters { get; private set; }
|
||||
public Memory<BiquadFilterState> BiquadFilterStates { get; private set; }
|
||||
public int InputBufferIndex { get; private set; }
|
||||
public int OutputBufferIndex { get; private set; }
|
||||
public bool[] IsInitialized { get; private set; }
|
||||
|
||||
public MultiTapBiquadFilterCommand(int baseIndex, ReadOnlySpan<BiquadFilterParameter2> filters, Memory<BiquadFilterState> biquadFilterStateMemory, int inputBufferOffset, int outputBufferOffset, ReadOnlySpan<bool> isInitialized, int nodeId)
|
||||
public MultiTapBiquadFilterCommand()
|
||||
{
|
||||
_parameters = filters.ToArray();
|
||||
_biquadFilterStates = biquadFilterStateMemory;
|
||||
_inputBufferIndex = baseIndex + inputBufferOffset;
|
||||
_outputBufferIndex = baseIndex + outputBufferOffset;
|
||||
_isInitialized = isInitialized.ToArray();
|
||||
|
||||
}
|
||||
|
||||
public MultiTapBiquadFilterCommand Initialize(int baseIndex, ReadOnlySpan<BiquadFilterParameter2> filters, Memory<BiquadFilterState> biquadFilterStateMemory, int inputBufferOffset, int outputBufferOffset, ReadOnlySpan<bool> isInitialized, int nodeId)
|
||||
{
|
||||
Parameters = filters.ToArray();
|
||||
BiquadFilterStates = biquadFilterStateMemory;
|
||||
InputBufferIndex = baseIndex + inputBufferOffset;
|
||||
OutputBufferIndex = baseIndex + outputBufferOffset;
|
||||
IsInitialized = isInitialized.ToArray();
|
||||
|
||||
Enabled = true;
|
||||
NodeId = nodeId;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public void Process(CommandList context)
|
||||
{
|
||||
Span<BiquadFilterState> states = _biquadFilterStates.Span;
|
||||
Span<BiquadFilterState> states = BiquadFilterStates.Span;
|
||||
|
||||
ReadOnlySpan<float> inputBuffer = context.GetBuffer(_inputBufferIndex);
|
||||
Span<float> outputBuffer = context.GetBuffer(_outputBufferIndex);
|
||||
ReadOnlySpan<float> inputBuffer = context.GetBuffer(InputBufferIndex);
|
||||
Span<float> outputBuffer = context.GetBuffer(OutputBufferIndex);
|
||||
|
||||
for (int i = 0; i < _parameters.Length; i++)
|
||||
for (int i = 0; i < Parameters.Length; i++)
|
||||
{
|
||||
if (!_isInitialized[i])
|
||||
if (!IsInitialized[i])
|
||||
{
|
||||
states[i] = new BiquadFilterState();
|
||||
}
|
||||
@@ -49,13 +56,13 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
|
||||
// NOTE: Nintendo only implement single and double biquad filters but no generic path when the command definition suggests it could be done.
|
||||
// As such we currently only implement a generic path for simplicity for double biquad.
|
||||
if (_parameters.Length == 1)
|
||||
if (Parameters.Length == 1)
|
||||
{
|
||||
BiquadFilterHelper.ProcessBiquadFilter(ref _parameters[0], ref states[0], outputBuffer, inputBuffer, context.SampleCount);
|
||||
BiquadFilterHelper.ProcessBiquadFilter(ref Parameters[0], ref states[0], outputBuffer, inputBuffer, context.SampleCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
BiquadFilterHelper.ProcessBiquadFilter(_parameters, states, outputBuffer, inputBuffer, context.SampleCount);
|
||||
BiquadFilterHelper.ProcessBiquadFilter(Parameters, states, outputBuffer, inputBuffer, context.SampleCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,26 +11,31 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
{
|
||||
public bool Enabled { get; set; }
|
||||
|
||||
public int NodeId { get; }
|
||||
public int NodeId { get; private set; }
|
||||
|
||||
public CommandType CommandType => CommandType.PcmFloatDataSourceVersion1;
|
||||
|
||||
public uint EstimatedProcessingTime { get; set; }
|
||||
|
||||
public ushort OutputBufferIndex { get; }
|
||||
public uint SampleRate { get; }
|
||||
public uint ChannelIndex { get; }
|
||||
public ushort OutputBufferIndex { get; private set; }
|
||||
public uint SampleRate { get; private set; }
|
||||
public uint ChannelIndex { get; private set; }
|
||||
|
||||
public uint ChannelCount { get; }
|
||||
public uint ChannelCount { get; private set; }
|
||||
|
||||
public float Pitch { get; }
|
||||
public float Pitch { get; private set; }
|
||||
|
||||
public WaveBuffer[] WaveBuffers { get; }
|
||||
|
||||
public Memory<VoiceState> State { get; }
|
||||
public DecodingBehaviour DecodingBehaviour { get; }
|
||||
public Memory<VoiceState> State { get; private set; }
|
||||
public DecodingBehaviour DecodingBehaviour { get; private set; }
|
||||
|
||||
public PcmFloatDataSourceCommandVersion1(ref VoiceInfo serverInfo, Memory<VoiceState> state, ushort outputBufferIndex, ushort channelIndex, int nodeId)
|
||||
public PcmFloatDataSourceCommandVersion1()
|
||||
{
|
||||
WaveBuffers = new WaveBuffer[Constants.VoiceWaveBufferCount];
|
||||
}
|
||||
|
||||
public PcmFloatDataSourceCommandVersion1 Initialize(ref VoiceInfo serverInfo, Memory<VoiceState> state, ushort outputBufferIndex, ushort channelIndex, int nodeId)
|
||||
{
|
||||
Enabled = true;
|
||||
NodeId = nodeId;
|
||||
@@ -40,8 +45,6 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
ChannelIndex = channelIndex;
|
||||
ChannelCount = serverInfo.ChannelsCount;
|
||||
Pitch = serverInfo.Pitch;
|
||||
|
||||
WaveBuffers = new WaveBuffer[Constants.VoiceWaveBufferCount];
|
||||
|
||||
Span<Server.Voice.WaveBuffer> waveBufferSpan = serverInfo.WaveBuffers.AsSpan();
|
||||
|
||||
@@ -54,6 +57,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
|
||||
State = state;
|
||||
DecodingBehaviour = serverInfo.DecodingBehaviour;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public void Process(CommandList context)
|
||||
|
||||
@@ -11,26 +11,31 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
{
|
||||
public bool Enabled { get; set; }
|
||||
|
||||
public int NodeId { get; }
|
||||
public int NodeId { get; private set; }
|
||||
|
||||
public CommandType CommandType => CommandType.PcmInt16DataSourceVersion1;
|
||||
|
||||
public uint EstimatedProcessingTime { get; set; }
|
||||
|
||||
public ushort OutputBufferIndex { get; }
|
||||
public uint SampleRate { get; }
|
||||
public uint ChannelIndex { get; }
|
||||
public ushort OutputBufferIndex { get; private set; }
|
||||
public uint SampleRate { get; private set; }
|
||||
public uint ChannelIndex { get; private set; }
|
||||
|
||||
public uint ChannelCount { get; }
|
||||
public uint ChannelCount { get; private set; }
|
||||
|
||||
public float Pitch { get; }
|
||||
public float Pitch { get; private set; }
|
||||
|
||||
public WaveBuffer[] WaveBuffers { get; }
|
||||
|
||||
public Memory<VoiceState> State { get; }
|
||||
public DecodingBehaviour DecodingBehaviour { get; }
|
||||
public Memory<VoiceState> State { get; private set; }
|
||||
public DecodingBehaviour DecodingBehaviour { get; private set; }
|
||||
|
||||
public PcmInt16DataSourceCommandVersion1(ref VoiceInfo serverInfo, Memory<VoiceState> state, ushort outputBufferIndex, ushort channelIndex, int nodeId)
|
||||
public PcmInt16DataSourceCommandVersion1()
|
||||
{
|
||||
WaveBuffers = new WaveBuffer[Constants.VoiceWaveBufferCount];
|
||||
}
|
||||
|
||||
public PcmInt16DataSourceCommandVersion1 Initialize(ref VoiceInfo serverInfo, Memory<VoiceState> state, ushort outputBufferIndex, ushort channelIndex, int nodeId)
|
||||
{
|
||||
Enabled = true;
|
||||
NodeId = nodeId;
|
||||
@@ -40,8 +45,6 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
ChannelIndex = channelIndex;
|
||||
ChannelCount = serverInfo.ChannelsCount;
|
||||
Pitch = serverInfo.Pitch;
|
||||
|
||||
WaveBuffers = new WaveBuffer[Constants.VoiceWaveBufferCount];
|
||||
|
||||
Span<Server.Voice.WaveBuffer> waveBufferSpan = serverInfo.WaveBuffers.AsSpan();
|
||||
|
||||
@@ -54,6 +57,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
|
||||
State = state;
|
||||
DecodingBehaviour = serverInfo.DecodingBehaviour;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public void Process(CommandList context)
|
||||
|
||||
@@ -13,22 +13,34 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
|
||||
public bool Enabled { get; set; }
|
||||
|
||||
public int NodeId { get; }
|
||||
public int NodeId { get; private set; }
|
||||
|
||||
public CommandType CommandType => CommandType.Performance;
|
||||
|
||||
public uint EstimatedProcessingTime { get; set; }
|
||||
|
||||
public PerformanceEntryAddresses PerformanceEntryAddresses { get; }
|
||||
public PerformanceEntryAddresses PerformanceEntryAddresses { get; private set; }
|
||||
|
||||
public Type PerformanceType { get; set; }
|
||||
|
||||
public PerformanceCommand(ref PerformanceEntryAddresses performanceEntryAddresses, Type performanceType, int nodeId)
|
||||
public PerformanceCommand()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public PerformanceCommand Initialize(ref PerformanceEntryAddresses performanceEntryAddresses, Type performanceType, int nodeId)
|
||||
{
|
||||
if (PerformanceEntryAddresses is not null)
|
||||
{
|
||||
PerformanceEntryAddresses.PerformanceEntryAddressesPool.Release(PerformanceEntryAddresses);
|
||||
}
|
||||
|
||||
Enabled = true;
|
||||
PerformanceEntryAddresses = performanceEntryAddresses;
|
||||
PerformanceType = performanceType;
|
||||
NodeId = nodeId;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public void Process(CommandList context)
|
||||
|
||||
@@ -35,26 +35,32 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
|
||||
public bool Enabled { get; set; }
|
||||
|
||||
public int NodeId { get; }
|
||||
public int NodeId { get; private set; }
|
||||
|
||||
public CommandType CommandType => CommandType.Reverb3d;
|
||||
|
||||
public uint EstimatedProcessingTime { get; set; }
|
||||
|
||||
public ushort InputBufferIndex { get; }
|
||||
public ushort OutputBufferIndex { get; }
|
||||
public ushort InputBufferIndex { get; private set; }
|
||||
public ushort OutputBufferIndex { get; private set; }
|
||||
|
||||
public Reverb3dParameter Parameter => _parameter;
|
||||
public Memory<Reverb3dState> State { get; }
|
||||
public ulong WorkBuffer { get; }
|
||||
public Memory<Reverb3dState> State { get; private set; }
|
||||
public ulong WorkBuffer { get; private set; }
|
||||
public ushort[] OutputBufferIndices { get; }
|
||||
public ushort[] InputBufferIndices { get; }
|
||||
|
||||
public bool IsEffectEnabled { get; }
|
||||
public bool IsEffectEnabled { get; private set; }
|
||||
|
||||
private Reverb3dParameter _parameter;
|
||||
|
||||
public Reverb3dCommand(uint bufferOffset, Reverb3dParameter parameter, Memory<Reverb3dState> state, bool isEnabled, ulong workBuffer, int nodeId, bool newEffectChannelMappingSupported)
|
||||
public Reverb3dCommand()
|
||||
{
|
||||
InputBufferIndices = new ushort[Constants.VoiceChannelCountMax];
|
||||
OutputBufferIndices = new ushort[Constants.VoiceChannelCountMax];
|
||||
}
|
||||
|
||||
public Reverb3dCommand Initialize(uint bufferOffset, Reverb3dParameter parameter, Memory<Reverb3dState> state, bool isEnabled, ulong workBuffer, int nodeId, bool newEffectChannelMappingSupported)
|
||||
{
|
||||
Enabled = true;
|
||||
IsEffectEnabled = isEnabled;
|
||||
@@ -62,9 +68,6 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
_parameter = parameter;
|
||||
State = state;
|
||||
WorkBuffer = workBuffer;
|
||||
|
||||
InputBufferIndices = new ushort[Constants.VoiceChannelCountMax];
|
||||
OutputBufferIndices = new ushort[Constants.VoiceChannelCountMax];
|
||||
|
||||
Span<byte> inputSpan = Parameter.Input.AsSpan();
|
||||
Span<byte> outputSpan = Parameter.Output.AsSpan();
|
||||
@@ -79,6 +82,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
// TODO: Update reverb 3d processing and remove this to use RemapLegacyChannelEffectMappingToChannelResourceMapping.
|
||||
DataSourceHelper.RemapChannelResourceMappingToLegacy(newEffectChannelMappingSupported, InputBufferIndices, Parameter.ChannelCount);
|
||||
DataSourceHelper.RemapChannelResourceMappingToLegacy(newEffectChannelMappingSupported, OutputBufferIndices, Parameter.ChannelCount);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
|
||||
@@ -33,26 +33,32 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
|
||||
public bool Enabled { get; set; }
|
||||
|
||||
public int NodeId { get; }
|
||||
public int NodeId { get; private set; }
|
||||
|
||||
public CommandType CommandType => CommandType.Reverb;
|
||||
|
||||
public uint EstimatedProcessingTime { get; set; }
|
||||
|
||||
public ReverbParameter Parameter => _parameter;
|
||||
public Memory<ReverbState> State { get; }
|
||||
public ulong WorkBuffer { get; }
|
||||
public Memory<ReverbState> State { get; private set; }
|
||||
public ulong WorkBuffer { get; private set; }
|
||||
public ushort[] OutputBufferIndices { get; }
|
||||
public ushort[] InputBufferIndices { get; }
|
||||
public bool IsLongSizePreDelaySupported { get; }
|
||||
public bool IsLongSizePreDelaySupported { get; private set; }
|
||||
|
||||
public bool IsEffectEnabled { get; }
|
||||
public bool IsEffectEnabled { get; private set; }
|
||||
|
||||
private ReverbParameter _parameter;
|
||||
|
||||
private const int FixedPointPrecision = 14;
|
||||
|
||||
public ReverbCommand(uint bufferOffset, ReverbParameter parameter, Memory<ReverbState> state, bool isEnabled, ulong workBuffer, int nodeId, bool isLongSizePreDelaySupported, bool newEffectChannelMappingSupported)
|
||||
public ReverbCommand()
|
||||
{
|
||||
InputBufferIndices = new ushort[Constants.VoiceChannelCountMax];
|
||||
OutputBufferIndices = new ushort[Constants.VoiceChannelCountMax];
|
||||
}
|
||||
|
||||
public ReverbCommand Initialize(uint bufferOffset, ReverbParameter parameter, Memory<ReverbState> state, bool isEnabled, ulong workBuffer, int nodeId, bool isLongSizePreDelaySupported, bool newEffectChannelMappingSupported)
|
||||
{
|
||||
Enabled = true;
|
||||
IsEffectEnabled = isEnabled;
|
||||
@@ -60,9 +66,6 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
_parameter = parameter;
|
||||
State = state;
|
||||
WorkBuffer = workBuffer;
|
||||
|
||||
InputBufferIndices = new ushort[Constants.VoiceChannelCountMax];
|
||||
OutputBufferIndices = new ushort[Constants.VoiceChannelCountMax];
|
||||
|
||||
Span<byte> inputSpan = Parameter.Input.AsSpan();
|
||||
Span<byte> outputSpan = Parameter.Output.AsSpan();
|
||||
@@ -79,6 +82,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
// TODO: Update reverb processing and remove this to use RemapLegacyChannelEffectMappingToChannelResourceMapping.
|
||||
DataSourceHelper.RemapChannelResourceMappingToLegacy(newEffectChannelMappingSupported, InputBufferIndices, Parameter.ChannelCount);
|
||||
DataSourceHelper.RemapChannelResourceMappingToLegacy(newEffectChannelMappingSupported, OutputBufferIndices, Parameter.ChannelCount);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
|
||||
@@ -7,22 +7,27 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
{
|
||||
public bool Enabled { get; set; }
|
||||
|
||||
public int NodeId { get; }
|
||||
public int NodeId { get; private set; }
|
||||
|
||||
public CommandType CommandType => CommandType.Upsample;
|
||||
|
||||
public uint EstimatedProcessingTime { get; set; }
|
||||
|
||||
public uint BufferCount { get; }
|
||||
public uint InputBufferIndex { get; }
|
||||
public uint InputSampleCount { get; }
|
||||
public uint InputSampleRate { get; }
|
||||
public uint BufferCount { get; private set; }
|
||||
public uint InputBufferIndex { get; private set; }
|
||||
public uint InputSampleCount { get; private set; }
|
||||
public uint InputSampleRate { get; private set; }
|
||||
|
||||
public UpsamplerInfo UpsamplerInfo { get; }
|
||||
public UpsamplerInfo UpsamplerInfo { get; private set; }
|
||||
|
||||
public Memory<float> OutBuffer { get; }
|
||||
public Memory<float> OutBuffer { get; private set; }
|
||||
|
||||
public UpsampleCommand(uint bufferOffset, UpsamplerInfo info, uint inputCount, Span<byte> inputBufferOffset, uint bufferCount, uint sampleCount, uint sampleRate, int nodeId)
|
||||
public UpsampleCommand()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public UpsampleCommand Initialize(uint bufferOffset, UpsamplerInfo info, uint inputCount, Span<byte> inputBufferOffset, uint bufferCount, uint sampleCount, uint sampleRate, int nodeId)
|
||||
{
|
||||
Enabled = true;
|
||||
NodeId = nodeId;
|
||||
@@ -47,6 +52,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
}
|
||||
|
||||
UpsamplerInfo = info;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
private Span<float> GetBuffer(int index, int sampleCount)
|
||||
|
||||
@@ -11,18 +11,23 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
{
|
||||
public bool Enabled { get; set; }
|
||||
|
||||
public int NodeId { get; }
|
||||
public int NodeId { get; private set; }
|
||||
|
||||
public CommandType CommandType => CommandType.Volume;
|
||||
|
||||
public uint EstimatedProcessingTime { get; set; }
|
||||
|
||||
public ushort InputBufferIndex { get; }
|
||||
public ushort OutputBufferIndex { get; }
|
||||
public ushort InputBufferIndex { get; private set; }
|
||||
public ushort OutputBufferIndex { get; private set; }
|
||||
|
||||
public float Volume { get; }
|
||||
public float Volume { get; private set; }
|
||||
|
||||
public VolumeCommand(float volume, uint bufferIndex, int nodeId)
|
||||
public VolumeCommand()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public VolumeCommand Initialize(float volume, uint bufferIndex, int nodeId)
|
||||
{
|
||||
Enabled = true;
|
||||
NodeId = nodeId;
|
||||
@@ -31,6 +36,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
OutputBufferIndex = (ushort)bufferIndex;
|
||||
|
||||
Volume = volume;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
|
||||
@@ -7,19 +7,24 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
{
|
||||
public bool Enabled { get; set; }
|
||||
|
||||
public int NodeId { get; }
|
||||
public int NodeId { get; private set; }
|
||||
|
||||
public CommandType CommandType => CommandType.VolumeRamp;
|
||||
|
||||
public uint EstimatedProcessingTime { get; set; }
|
||||
|
||||
public ushort InputBufferIndex { get; }
|
||||
public ushort OutputBufferIndex { get; }
|
||||
public ushort InputBufferIndex { get; private set; }
|
||||
public ushort OutputBufferIndex { get; private set; }
|
||||
|
||||
public float Volume0 { get; }
|
||||
public float Volume1 { get; }
|
||||
public float Volume0 { get; private set; }
|
||||
public float Volume1 { get; private set; }
|
||||
|
||||
public VolumeRampCommand(float volume0, float volume1, uint bufferIndex, int nodeId)
|
||||
public VolumeRampCommand()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public VolumeRampCommand Initialize(float volume0, float volume1, uint bufferIndex, int nodeId)
|
||||
{
|
||||
Enabled = true;
|
||||
NodeId = nodeId;
|
||||
@@ -29,6 +34,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
|
||||
|
||||
Volume0 = volume0;
|
||||
Volume1 = volume1;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
|
||||
@@ -1,97 +0,0 @@
|
||||
using Ryujinx.Audio.Renderer.Common;
|
||||
using Ryujinx.Common.Utilities;
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ryujinx.Audio.Renderer.Parameter
|
||||
{
|
||||
/// <summary>
|
||||
/// Input information for an effect version 2. (added with REV9)
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct EffectInParameterVersion3 : IEffectInParameter
|
||||
{
|
||||
/// <summary>
|
||||
/// Type of the effect.
|
||||
/// </summary>
|
||||
public EffectType Type;
|
||||
|
||||
/// <summary>
|
||||
/// Set to true if the effect is new.
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.I1)]
|
||||
public bool IsNew;
|
||||
|
||||
/// <summary>
|
||||
/// Set to true if the effect must be active.
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.I1)]
|
||||
public bool IsEnabled;
|
||||
|
||||
/// <summary>
|
||||
/// Reserved/padding.
|
||||
/// </summary>
|
||||
private readonly byte _reserved1;
|
||||
|
||||
/// <summary>
|
||||
/// The target mix id of the effect.
|
||||
/// </summary>
|
||||
public int MixId;
|
||||
|
||||
/// <summary>
|
||||
/// Address of the processing workbuffer.
|
||||
/// </summary>
|
||||
/// <remarks>This is additional data that could be required by the effect processing.</remarks>
|
||||
public ulong BufferBase;
|
||||
|
||||
/// <summary>
|
||||
/// Size of the processing workbuffer.
|
||||
/// </summary>
|
||||
/// <remarks>This is additional data that could be required by the effect processing.</remarks>
|
||||
public ulong BufferSize;
|
||||
|
||||
/// <summary>
|
||||
/// Position of the effect while processing effects.
|
||||
/// </summary>
|
||||
public uint ProcessingOrder;
|
||||
|
||||
/// <summary>
|
||||
/// Reserved/padding.
|
||||
/// </summary>
|
||||
private readonly uint _reserved2;
|
||||
|
||||
/// <summary>
|
||||
/// Specific data storage.
|
||||
/// </summary>
|
||||
private SpecificDataStruct _specificDataStart;
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0xA0, Pack = 1)]
|
||||
private struct SpecificDataStruct { }
|
||||
|
||||
public Span<byte> SpecificData => SpanHelpers.AsSpan<SpecificDataStruct, byte>(ref _specificDataStart);
|
||||
|
||||
readonly EffectType IEffectInParameter.Type => Type;
|
||||
|
||||
readonly bool IEffectInParameter.IsNew => IsNew;
|
||||
|
||||
readonly bool IEffectInParameter.IsEnabled => IsEnabled;
|
||||
|
||||
readonly int IEffectInParameter.MixId => MixId;
|
||||
|
||||
readonly ulong IEffectInParameter.BufferBase => BufferBase;
|
||||
|
||||
readonly ulong IEffectInParameter.BufferSize => BufferSize;
|
||||
|
||||
readonly uint IEffectInParameter.ProcessingOrder => ProcessingOrder;
|
||||
|
||||
/// <summary>
|
||||
/// Check if the given channel count is valid.
|
||||
/// </summary>
|
||||
/// <param name="channelCount">The channel count to check</param>
|
||||
/// <returns>Returns true if the channel count is valid.</returns>
|
||||
public static bool IsChannelCountValid(int channelCount)
|
||||
{
|
||||
return channelCount is 1 or 2 or 4 or 6;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ using Ryujinx.Audio.Renderer.Server.Sink;
|
||||
using Ryujinx.Audio.Renderer.Server.Splitter;
|
||||
using Ryujinx.Audio.Renderer.Server.Upsampler;
|
||||
using Ryujinx.Audio.Renderer.Server.Voice;
|
||||
using Ryujinx.Common;
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using CpuAddress = System.UInt64;
|
||||
@@ -34,6 +35,170 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
/// </summary>
|
||||
public CommandList CommandList { get; }
|
||||
|
||||
private readonly static ObjectPool<PcmInt16DataSourceCommandVersion1> _pcmInt16DataSourceCommandVersion1Pool = new(() => new PcmInt16DataSourceCommandVersion1());
|
||||
private readonly static ObjectPool<PcmFloatDataSourceCommandVersion1> _pcmFloatDataSourceCommandVersion1Pool = new(() => new PcmFloatDataSourceCommandVersion1());
|
||||
private readonly static ObjectPool<AdpcmDataSourceCommandVersion1> _adpcmDataSourceCommandVersion1Pool = new(() => new AdpcmDataSourceCommandVersion1());
|
||||
private readonly static ObjectPool<DataSourceVersion2Command> _dataSourceVersion2CommandPool = new(() => new DataSourceVersion2Command());
|
||||
private readonly static ObjectPool<VolumeCommand> _volumeCommandPool = new(() => new VolumeCommand());
|
||||
private readonly static ObjectPool<VolumeRampCommand> _volumeRampCommandPool = new(() => new VolumeRampCommand());
|
||||
private readonly static ObjectPool<BiquadFilterCommand> _biquadFilterCommandPool = new(() => new BiquadFilterCommand());
|
||||
private readonly static ObjectPool<MixCommand> _mixCommandPool = new(() => new MixCommand());
|
||||
private readonly static ObjectPool<MixRampCommand> _mixRampCommandPool = new(() => new MixRampCommand());
|
||||
private readonly static ObjectPool<MixRampGroupedCommand> _mixRampGroupedCommandPool = new(() => new MixRampGroupedCommand());
|
||||
private readonly static ObjectPool<DepopPrepareCommand> _depopPrepareCommandPool = new(() => new DepopPrepareCommand());
|
||||
private readonly static ObjectPool<DepopForMixBuffersCommand> _depopForMixBuffersCommandPool = new(() => new DepopForMixBuffersCommand());
|
||||
private readonly static ObjectPool<DelayCommand> _delayCommandPool = new(() => new DelayCommand());
|
||||
private readonly static ObjectPool<UpsampleCommand> _upsampleCommandPool = new(() => new UpsampleCommand());
|
||||
private readonly static ObjectPool<DownMixSurroundToStereoCommand> _downMixSurroundToStereoCommandPool = new(() => new DownMixSurroundToStereoCommand());
|
||||
private readonly static ObjectPool<AuxiliaryBufferCommand> _auxiliaryBufferCommandPool = new(() => new AuxiliaryBufferCommand());
|
||||
private readonly static ObjectPool<DeviceSinkCommand> _deviceSinkCommandPool = new(() => new DeviceSinkCommand());
|
||||
private readonly static ObjectPool<CircularBufferSinkCommand> _circularBufferSinkCommandPool = new(() => new CircularBufferSinkCommand());
|
||||
private readonly static ObjectPool<ReverbCommand> _reverbCommandPool = new(() => new ReverbCommand());
|
||||
private readonly static ObjectPool<Reverb3dCommand> _reverb3dCommandPool = new(() => new Reverb3dCommand());
|
||||
private readonly static ObjectPool<PerformanceCommand> _performanceCommandPool = new(() => new PerformanceCommand());
|
||||
private readonly static ObjectPool<ClearMixBufferCommand> _clearMixBufferCommandPool = new(() => new ClearMixBufferCommand());
|
||||
private readonly static ObjectPool<CopyMixBufferCommand> _copyMixBufferCommandPool = new(() => new CopyMixBufferCommand());
|
||||
private readonly static ObjectPool<LimiterCommandVersion1> _limiterCommandVersion1Pool = new(() => new LimiterCommandVersion1());
|
||||
private readonly static ObjectPool<LimiterCommandVersion2> _limiterCommandVersion2Pool = new(() => new LimiterCommandVersion2());
|
||||
private readonly static ObjectPool<MultiTapBiquadFilterCommand> _multiTapBiquadFilterCommandPool = new(() => new MultiTapBiquadFilterCommand());
|
||||
private readonly static ObjectPool<CaptureBufferCommand> _captureBufferCommandPool = new(() => new CaptureBufferCommand());
|
||||
private readonly static ObjectPool<CompressorCommand> _compressorCommandPool = new(() => new CompressorCommand());
|
||||
private readonly static ObjectPool<BiquadFilterAndMixCommand> _biquadFilterAndMixCommandPool = new(() => new BiquadFilterAndMixCommand());
|
||||
private readonly static ObjectPool<MultiTapBiquadFilterAndMixCommand> _multiTapBiquadFilterAndMixCommandPool = new(() => new MultiTapBiquadFilterAndMixCommand());
|
||||
private readonly static ObjectPool<FillBufferCommand> _fillBufferCommandPool = new(() => new FillBufferCommand());
|
||||
|
||||
public static void ReleaseCommand(ICommand command)
|
||||
{
|
||||
switch (command.CommandType)
|
||||
{
|
||||
case CommandType.PcmInt16DataSourceVersion1:
|
||||
_pcmInt16DataSourceCommandVersion1Pool.Release((PcmInt16DataSourceCommandVersion1)command);
|
||||
break;
|
||||
case CommandType.PcmInt16DataSourceVersion2:
|
||||
_dataSourceVersion2CommandPool.Release((DataSourceVersion2Command)command);
|
||||
break;
|
||||
case CommandType.PcmFloatDataSourceVersion1:
|
||||
_pcmFloatDataSourceCommandVersion1Pool.Release((PcmFloatDataSourceCommandVersion1)command);
|
||||
break;
|
||||
case CommandType.PcmFloatDataSourceVersion2:
|
||||
_dataSourceVersion2CommandPool.Release((DataSourceVersion2Command)command);
|
||||
break;
|
||||
case CommandType.AdpcmDataSourceVersion1:
|
||||
_adpcmDataSourceCommandVersion1Pool.Release((AdpcmDataSourceCommandVersion1)command);
|
||||
break;
|
||||
case CommandType.AdpcmDataSourceVersion2:
|
||||
_dataSourceVersion2CommandPool.Release((DataSourceVersion2Command)command);
|
||||
break;
|
||||
case CommandType.Volume:
|
||||
_volumeCommandPool.Release((VolumeCommand)command);
|
||||
break;
|
||||
case CommandType.VolumeRamp:
|
||||
_volumeRampCommandPool.Release((VolumeRampCommand)command);
|
||||
break;
|
||||
case CommandType.BiquadFilter:
|
||||
_biquadFilterCommandPool.Release((BiquadFilterCommand)command);
|
||||
break;
|
||||
case CommandType.BiquadFilterFloatCoeff:
|
||||
throw new NotImplementedException();
|
||||
break;
|
||||
case CommandType.Mix:
|
||||
_mixCommandPool.Release((MixCommand)command);
|
||||
break;
|
||||
case CommandType.MixRamp:
|
||||
_mixRampCommandPool.Release((MixRampCommand)command);
|
||||
break;
|
||||
case CommandType.MixRampGrouped:
|
||||
_mixRampGroupedCommandPool.Release((MixRampGroupedCommand)command);
|
||||
break;
|
||||
case CommandType.DepopPrepare:
|
||||
_depopPrepareCommandPool.Release((DepopPrepareCommand)command);
|
||||
break;
|
||||
case CommandType.DepopForMixBuffers:
|
||||
_depopForMixBuffersCommandPool.Release((DepopForMixBuffersCommand)command);
|
||||
break;
|
||||
case CommandType.Delay:
|
||||
_delayCommandPool.Release((DelayCommand)command);
|
||||
break;
|
||||
case CommandType.Upsample:
|
||||
_upsampleCommandPool.Release((UpsampleCommand)command);
|
||||
break;
|
||||
case CommandType.DownMixSurroundToStereo:
|
||||
_downMixSurroundToStereoCommandPool.Release((DownMixSurroundToStereoCommand)command);
|
||||
break;
|
||||
case CommandType.AuxiliaryBuffer:
|
||||
_auxiliaryBufferCommandPool.Release((AuxiliaryBufferCommand)command);
|
||||
break;
|
||||
case CommandType.DeviceSink:
|
||||
_deviceSinkCommandPool.Release((DeviceSinkCommand)command);
|
||||
break;
|
||||
case CommandType.CircularBufferSink:
|
||||
_circularBufferSinkCommandPool.Release((CircularBufferSinkCommand)command);
|
||||
break;
|
||||
case CommandType.Reverb:
|
||||
_reverbCommandPool.Release((ReverbCommand)command);
|
||||
break;
|
||||
case CommandType.Reverb3d:
|
||||
_reverb3dCommandPool.Release((Reverb3dCommand)command);
|
||||
break;
|
||||
case CommandType.Performance:
|
||||
_performanceCommandPool.Release((PerformanceCommand)command);
|
||||
break;
|
||||
case CommandType.ClearMixBuffer:
|
||||
_clearMixBufferCommandPool.Release((ClearMixBufferCommand)command);
|
||||
break;
|
||||
case CommandType.CopyMixBuffer:
|
||||
_copyMixBufferCommandPool.Release((CopyMixBufferCommand)command);
|
||||
break;
|
||||
case CommandType.LimiterVersion1:
|
||||
_limiterCommandVersion1Pool.Release((LimiterCommandVersion1)command);
|
||||
break;
|
||||
case CommandType.LimiterVersion2:
|
||||
_limiterCommandVersion2Pool.Release((LimiterCommandVersion2)command);
|
||||
break;
|
||||
case CommandType.MultiTapBiquadFilter:
|
||||
_multiTapBiquadFilterCommandPool.Release((MultiTapBiquadFilterCommand)command);
|
||||
break;
|
||||
case CommandType.MultiTapBiquadFilterFloatCoeff:
|
||||
throw new NotImplementedException();
|
||||
break;
|
||||
case CommandType.CaptureBuffer:
|
||||
_captureBufferCommandPool.Release((CaptureBufferCommand)command);
|
||||
break;
|
||||
case CommandType.Compressor:
|
||||
_compressorCommandPool.Release((CompressorCommand)command);
|
||||
break;
|
||||
case CommandType.BiquadFilterAndMix:
|
||||
_biquadFilterAndMixCommandPool.Release((BiquadFilterAndMixCommand)command);
|
||||
break;
|
||||
case CommandType.BiquadFilterAndMixFloatCoeff:
|
||||
throw new NotImplementedException();
|
||||
break;
|
||||
case CommandType.MultiTapBiquadFilterAndMix:
|
||||
_multiTapBiquadFilterAndMixCommandPool.Release((MultiTapBiquadFilterAndMixCommand)command);
|
||||
break;
|
||||
case CommandType.MultiTapBiquadFilterAndMixFloatCoef:
|
||||
throw new NotImplementedException();
|
||||
break;
|
||||
case CommandType.AuxiliaryBufferGrouped:
|
||||
throw new NotImplementedException();
|
||||
break;
|
||||
case CommandType.FillMixBuffer:
|
||||
throw new NotImplementedException();
|
||||
break;
|
||||
case CommandType.BiquadFilterCrossFade:
|
||||
throw new NotImplementedException();
|
||||
break;
|
||||
case CommandType.MultiTapBiquadFilterCrossFade:
|
||||
throw new NotImplementedException();
|
||||
break;
|
||||
case CommandType.FillBuffer:
|
||||
_fillBufferCommandPool.Release((FillBufferCommand)command);
|
||||
break;
|
||||
default:
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="CommandBuffer"/>.
|
||||
/// </summary>
|
||||
@@ -63,7 +228,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
/// <param name="nodeId">The node id associated to this command.</param>
|
||||
public void GenerateClearMixBuffer(int nodeId)
|
||||
{
|
||||
ClearMixBufferCommand command = new(nodeId);
|
||||
ClearMixBufferCommand command = _clearMixBufferCommandPool.Allocate().Initialize(nodeId);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -81,7 +246,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
/// <param name="wasPlaying">Set to true if the voice was playing previously.</param>
|
||||
public void GenerateDepopPrepare(Memory<VoiceState> state, Memory<float> depopBuffer, uint bufferCount, uint bufferOffset, int nodeId, bool wasPlaying)
|
||||
{
|
||||
DepopPrepareCommand command = new(state, depopBuffer, bufferCount, bufferOffset, nodeId, wasPlaying);
|
||||
DepopPrepareCommand command = _depopPrepareCommandPool.Allocate().Initialize(state, depopBuffer, bufferCount, bufferOffset, nodeId, wasPlaying);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -96,7 +261,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
/// <param name="nodeId">The node id associated to this command.</param>
|
||||
public void GeneratePerformance(ref PerformanceEntryAddresses performanceEntryAddresses, PerformanceCommand.Type type, int nodeId)
|
||||
{
|
||||
PerformanceCommand command = new(ref performanceEntryAddresses, type, nodeId);
|
||||
PerformanceCommand command = _performanceCommandPool.Allocate().Initialize(ref performanceEntryAddresses, type, nodeId);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -112,7 +277,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
/// <param name="nodeId">The node id associated to this command.</param>
|
||||
public void GenerateVolumeRamp(float previousVolume, float volume, uint bufferIndex, int nodeId)
|
||||
{
|
||||
VolumeRampCommand command = new(previousVolume, volume, bufferIndex, nodeId);
|
||||
VolumeRampCommand command = _volumeRampCommandPool.Allocate().Initialize(previousVolume, volume, bufferIndex, nodeId);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -129,7 +294,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
/// <param name="nodeId">The node id associated to this command.</param>
|
||||
public void GenerateDataSourceVersion2(ref VoiceInfo voiceInfo, Memory<VoiceState> state, ushort outputBufferIndex, ushort channelIndex, int nodeId)
|
||||
{
|
||||
DataSourceVersion2Command command = new(ref voiceInfo, state, outputBufferIndex, channelIndex, nodeId);
|
||||
DataSourceVersion2Command command = _dataSourceVersion2CommandPool.Allocate().Initialize(ref voiceInfo, state, outputBufferIndex, channelIndex, nodeId);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -146,7 +311,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
/// <param name="nodeId">The node id associated to this command.</param>
|
||||
public void GeneratePcmInt16DataSourceVersion1(ref VoiceInfo voiceInfo, Memory<VoiceState> state, ushort outputBufferIndex, ushort channelIndex, int nodeId)
|
||||
{
|
||||
PcmInt16DataSourceCommandVersion1 command = new(ref voiceInfo, state, outputBufferIndex, channelIndex, nodeId);
|
||||
PcmInt16DataSourceCommandVersion1 command = _pcmInt16DataSourceCommandVersion1Pool.Allocate().Initialize(ref voiceInfo, state, outputBufferIndex, channelIndex, nodeId);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -163,7 +328,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
/// <param name="nodeId">The node id associated to this command.</param>
|
||||
public void GeneratePcmFloatDataSourceVersion1(ref VoiceInfo voiceInfo, Memory<VoiceState> state, ushort outputBufferIndex, ushort channelIndex, int nodeId)
|
||||
{
|
||||
PcmFloatDataSourceCommandVersion1 command = new(ref voiceInfo, state, outputBufferIndex, channelIndex, nodeId);
|
||||
PcmFloatDataSourceCommandVersion1 command = _pcmFloatDataSourceCommandVersion1Pool.Allocate().Initialize(ref voiceInfo, state, outputBufferIndex, channelIndex, nodeId);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -179,7 +344,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
/// <param name="nodeId">The node id associated to this command.</param>
|
||||
public void GenerateAdpcmDataSourceVersion1(ref VoiceInfo voiceInfo, Memory<VoiceState> state, ushort outputBufferIndex, int nodeId)
|
||||
{
|
||||
AdpcmDataSourceCommandVersion1 command = new(ref voiceInfo, state, outputBufferIndex, nodeId);
|
||||
AdpcmDataSourceCommandVersion1 command = _adpcmDataSourceCommandVersion1Pool.Allocate().Initialize(ref voiceInfo, state, outputBufferIndex, nodeId);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -198,7 +363,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
/// <param name="nodeId">The node id associated to this command.</param>
|
||||
public void GenerateBiquadFilter(int baseIndex, ref BiquadFilterParameter2 filter, Memory<BiquadFilterState> biquadFilterStateMemory, int inputBufferOffset, int outputBufferOffset, bool needInitialization, int nodeId)
|
||||
{
|
||||
BiquadFilterCommand command = new(baseIndex, ref filter, biquadFilterStateMemory, inputBufferOffset, outputBufferOffset, needInitialization, nodeId);
|
||||
BiquadFilterCommand command = _biquadFilterCommandPool.Allocate().Initialize(baseIndex, ref filter, biquadFilterStateMemory, inputBufferOffset, outputBufferOffset, needInitialization, nodeId);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -217,7 +382,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
/// <param name="nodeId">The node id associated to this command.</param>
|
||||
public void GenerateMultiTapBiquadFilter(int baseIndex, ReadOnlySpan<BiquadFilterParameter2> filters, Memory<BiquadFilterState> biquadFilterStatesMemory, int inputBufferOffset, int outputBufferOffset, ReadOnlySpan<bool> isInitialized, int nodeId)
|
||||
{
|
||||
MultiTapBiquadFilterCommand command = new(baseIndex, filters, biquadFilterStatesMemory, inputBufferOffset, outputBufferOffset, isInitialized, nodeId);
|
||||
MultiTapBiquadFilterCommand command = _multiTapBiquadFilterCommandPool.Allocate().Initialize(baseIndex, filters, biquadFilterStatesMemory, inputBufferOffset, outputBufferOffset, isInitialized, nodeId);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -236,7 +401,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
/// <param name="nodeId">The node id associated to this command.</param>
|
||||
public void GenerateMixRampGrouped(uint mixBufferCount, uint inputBufferIndex, uint outputBufferIndex, ReadOnlySpan<float> previousVolume, ReadOnlySpan<float> volume, Memory<VoiceState> state, int nodeId)
|
||||
{
|
||||
MixRampGroupedCommand command = new(mixBufferCount, inputBufferIndex, outputBufferIndex, previousVolume, volume, state, nodeId);
|
||||
MixRampGroupedCommand command = _mixRampGroupedCommandPool.Allocate().Initialize(mixBufferCount, inputBufferIndex, outputBufferIndex, previousVolume, volume, state, nodeId);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -255,7 +420,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
/// <param name="nodeId">The node id associated to this command.</param>
|
||||
public void GenerateMixRamp(float previousVolume, float volume, uint inputBufferIndex, uint outputBufferIndex, int lastSampleIndex, Memory<VoiceState> state, int nodeId)
|
||||
{
|
||||
MixRampCommand command = new(previousVolume, volume, inputBufferIndex, outputBufferIndex, lastSampleIndex, state, nodeId);
|
||||
MixRampCommand command = _mixRampCommandPool.Allocate().Initialize(previousVolume, volume, inputBufferIndex, outputBufferIndex, lastSampleIndex, state, nodeId);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -293,7 +458,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
bool isFirstMixBuffer,
|
||||
int nodeId)
|
||||
{
|
||||
BiquadFilterAndMixCommand command = new(
|
||||
BiquadFilterAndMixCommand command = _biquadFilterAndMixCommandPool.Allocate().Initialize(
|
||||
previousVolume,
|
||||
volume,
|
||||
inputBufferIndex,
|
||||
@@ -352,7 +517,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
bool isFirstMixBuffer,
|
||||
int nodeId)
|
||||
{
|
||||
MultiTapBiquadFilterAndMixCommand command = new(
|
||||
MultiTapBiquadFilterAndMixCommand command = _multiTapBiquadFilterAndMixCommandPool.Allocate().Initialize(
|
||||
previousVolume,
|
||||
volume,
|
||||
inputBufferIndex,
|
||||
@@ -386,7 +551,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
/// <param name="sampleRate">The target sample rate in use.</param>
|
||||
public void GenerateDepopForMixBuffers(Memory<float> depopBuffer, uint bufferOffset, uint bufferCount, int nodeId, uint sampleRate)
|
||||
{
|
||||
DepopForMixBuffersCommand command = new(depopBuffer, bufferOffset, bufferCount, nodeId, sampleRate);
|
||||
DepopForMixBuffersCommand command = _depopForMixBuffersCommandPool.Allocate().Initialize(depopBuffer, bufferOffset, bufferCount, nodeId, sampleRate);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -401,7 +566,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
/// <param name="nodeId">The node id associated to this command.</param>
|
||||
public void GenerateCopyMixBuffer(uint inputBufferIndex, uint outputBufferIndex, int nodeId)
|
||||
{
|
||||
CopyMixBufferCommand command = new(inputBufferIndex, outputBufferIndex, nodeId);
|
||||
CopyMixBufferCommand command = _copyMixBufferCommandPool.Allocate().Initialize(inputBufferIndex, outputBufferIndex, nodeId);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -417,7 +582,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
/// <param name="volume">The mix volume.</param>
|
||||
public void GenerateMix(uint inputBufferIndex, uint outputBufferIndex, int nodeId, float volume)
|
||||
{
|
||||
MixCommand command = new(inputBufferIndex, outputBufferIndex, nodeId, volume);
|
||||
MixCommand command = _mixCommandPool.Allocate().Initialize(inputBufferIndex, outputBufferIndex, nodeId, volume);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -439,7 +604,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
{
|
||||
if (parameter.IsChannelCountValid())
|
||||
{
|
||||
ReverbCommand command = new(bufferOffset, parameter, state, isEnabled, workBuffer, nodeId, isLongSizePreDelaySupported, newEffectChannelMappingSupported);
|
||||
ReverbCommand command = _reverbCommandPool.Allocate().Initialize(bufferOffset, parameter, state, isEnabled, workBuffer, nodeId, isLongSizePreDelaySupported, newEffectChannelMappingSupported);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -461,7 +626,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
{
|
||||
if (parameter.IsChannelCountValid())
|
||||
{
|
||||
Reverb3dCommand command = new(bufferOffset, parameter, state, isEnabled, workBuffer, nodeId, newEffectChannelMappingSupported);
|
||||
Reverb3dCommand command = _reverb3dCommandPool.Allocate().Initialize(bufferOffset, parameter, state, isEnabled, workBuffer, nodeId, newEffectChannelMappingSupported);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -483,7 +648,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
{
|
||||
if (parameter.IsChannelCountValid())
|
||||
{
|
||||
DelayCommand command = new(bufferOffset, parameter, state, isEnabled, workBuffer, nodeId, newEffectChannelMappingSupported);
|
||||
DelayCommand command = _delayCommandPool.Allocate().Initialize(bufferOffset, parameter, state, isEnabled, workBuffer, nodeId, newEffectChannelMappingSupported);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -504,7 +669,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
{
|
||||
if (parameter.IsChannelCountValid())
|
||||
{
|
||||
LimiterCommandVersion1 command = new(bufferOffset, parameter, state, isEnabled, workBuffer, nodeId);
|
||||
LimiterCommandVersion1 command = _limiterCommandVersion1Pool.Allocate().Initialize(bufferOffset, parameter, state, isEnabled, workBuffer, nodeId);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -526,7 +691,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
{
|
||||
if (parameter.IsChannelCountValid())
|
||||
{
|
||||
LimiterCommandVersion2 command = new(bufferOffset, parameter, state, effectResultState, isEnabled, workBuffer, nodeId);
|
||||
LimiterCommandVersion2 command = _limiterCommandVersion2Pool.Allocate().Initialize(bufferOffset, parameter, state, effectResultState, isEnabled, workBuffer, nodeId);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -552,7 +717,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
{
|
||||
if (state.SendBufferInfoBase != 0 && state.ReturnBufferInfoBase != 0)
|
||||
{
|
||||
AuxiliaryBufferCommand command = new(bufferOffset, inputBufferOffset, outputBufferOffset, ref state, isEnabled, countMax, outputBuffer, inputBuffer, updateCount, writeOffset, nodeId);
|
||||
AuxiliaryBufferCommand command = _auxiliaryBufferCommandPool.Allocate().Initialize(bufferOffset, inputBufferOffset, outputBufferOffset, ref state, isEnabled, countMax, outputBuffer, inputBuffer, updateCount, writeOffset, nodeId);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -576,7 +741,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
{
|
||||
if (sendBufferInfo != 0)
|
||||
{
|
||||
CaptureBufferCommand command = new(bufferOffset, inputBufferOffset, sendBufferInfo, isEnabled, countMax, outputBuffer, updateCount, writeOffset, nodeId);
|
||||
CaptureBufferCommand command = _captureBufferCommandPool.Allocate().Initialize(bufferOffset, inputBufferOffset, sendBufferInfo, isEnabled, countMax, outputBuffer, updateCount, writeOffset, nodeId);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -597,7 +762,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
{
|
||||
if (parameter.IsChannelCountValid())
|
||||
{
|
||||
CompressorCommand command = new(bufferOffset, parameter, state, effectResultState, isEnabled, nodeId);
|
||||
CompressorCommand command = _compressorCommandPool.Allocate().Initialize(bufferOffset, parameter, state, effectResultState, isEnabled, nodeId);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -613,7 +778,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
/// <param name="nodeId">The node id associated to this command.</param>
|
||||
public void GenerateVolume(float volume, uint bufferOffset, int nodeId)
|
||||
{
|
||||
VolumeCommand command = new(volume, bufferOffset, nodeId);
|
||||
VolumeCommand command = _volumeCommandPool.Allocate().Initialize(volume, bufferOffset, nodeId);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -628,7 +793,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
/// <param name="nodeId">The node id associated to this command.</param>
|
||||
public void GenerateCircularBuffer(uint bufferOffset, CircularBufferSink sink, int nodeId)
|
||||
{
|
||||
CircularBufferSinkCommand command = new(bufferOffset, ref sink.Parameter, ref sink.CircularBufferAddressInfo, sink.CurrentWriteOffset, nodeId);
|
||||
CircularBufferSinkCommand command = _circularBufferSinkCommandPool.Allocate().Initialize(bufferOffset, ref sink.Parameter, ref sink.CircularBufferAddressInfo, sink.CurrentWriteOffset, nodeId);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -645,7 +810,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
/// <param name="nodeId">The node id associated to this command.</param>
|
||||
public void GenerateDownMixSurroundToStereo(uint bufferOffset, Span<byte> inputBufferOffset, Span<byte> outputBufferOffset, float[] downMixParameter, int nodeId)
|
||||
{
|
||||
DownMixSurroundToStereoCommand command = new(bufferOffset, inputBufferOffset, outputBufferOffset, downMixParameter, nodeId);
|
||||
DownMixSurroundToStereoCommand command = _downMixSurroundToStereoCommandPool.Allocate().Initialize(bufferOffset, inputBufferOffset, outputBufferOffset, downMixParameter, nodeId);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -665,7 +830,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
/// <param name="nodeId">The node id associated to this command.</param>
|
||||
public void GenerateUpsample(uint bufferOffset, UpsamplerInfo upsampler, uint inputCount, Span<byte> inputBufferOffset, uint bufferCountPerSample, uint sampleCount, uint sampleRate, int nodeId)
|
||||
{
|
||||
UpsampleCommand command = new(bufferOffset, upsampler, inputCount, inputBufferOffset, bufferCountPerSample, sampleCount, sampleRate, nodeId);
|
||||
UpsampleCommand command = _upsampleCommandPool.Allocate().Initialize(bufferOffset, upsampler, inputCount, inputBufferOffset, bufferCountPerSample, sampleCount, sampleRate, nodeId);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -682,7 +847,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
/// <param name="nodeId">The node id associated to this command.</param>
|
||||
public void GenerateDeviceSink(uint bufferOffset, DeviceSink sink, int sessionId, Memory<float> buffer, int nodeId)
|
||||
{
|
||||
DeviceSinkCommand command = new(bufferOffset, sink, sessionId, buffer, nodeId);
|
||||
DeviceSinkCommand command = _deviceSinkCommandPool.Allocate().Initialize(bufferOffset, sink, sessionId, buffer, nodeId);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
@@ -691,16 +856,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
|
||||
public void GenerateFillBuffer(SplitterDestination destination, float value, int length, int nodeId)
|
||||
{
|
||||
FillBufferCommand command;
|
||||
|
||||
if (Unsafe.IsNullRef(ref destination.GetV2RefOrNull()))
|
||||
{
|
||||
command = new(destination.GetV1RefOrNull(), length, value, nodeId);
|
||||
}
|
||||
else
|
||||
{
|
||||
command = new(destination.GetV2RefOrNull(), length, value, nodeId);
|
||||
}
|
||||
FillBufferCommand command = _fillBufferCommandPool.Allocate().Initialize(destination, length, value, nodeId);
|
||||
|
||||
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
|
||||
|
||||
|
||||
@@ -339,7 +339,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
|
||||
bool performanceInitialized = false;
|
||||
|
||||
PerformanceEntryAddresses performanceEntry = new();
|
||||
PerformanceEntryAddresses performanceEntry = null;
|
||||
|
||||
if (_performanceManager != null && _performanceManager.IsTargetNodeId(nodeId) && _performanceManager.GetNextEntry(out performanceEntry, dataSourceDetailType, PerformanceEntryType.Voice, nodeId))
|
||||
{
|
||||
@@ -500,7 +500,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
{
|
||||
int nodeId = sortedInfo.NodeId;
|
||||
|
||||
PerformanceEntryAddresses performanceEntry = new();
|
||||
PerformanceEntryAddresses performanceEntry = null;
|
||||
|
||||
bool performanceInitialized = false;
|
||||
|
||||
@@ -786,7 +786,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
|
||||
bool isFinalMix = mix.MixId == Constants.FinalMixId;
|
||||
|
||||
PerformanceEntryAddresses performanceEntry = new();
|
||||
PerformanceEntryAddresses performanceEntry = null;
|
||||
|
||||
bool performanceInitialized = false;
|
||||
|
||||
@@ -1050,7 +1050,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
|
||||
GenerateEffects(ref subMix);
|
||||
|
||||
PerformanceEntryAddresses performanceEntry = new();
|
||||
PerformanceEntryAddresses performanceEntry = null;
|
||||
|
||||
int nodeId = subMix.NodeId;
|
||||
|
||||
@@ -1081,7 +1081,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
{
|
||||
int nodeId = sortedInfo.NodeId;
|
||||
|
||||
PerformanceEntryAddresses performanceEntry = new();
|
||||
PerformanceEntryAddresses performanceEntry = null;
|
||||
|
||||
bool performanceInitialized = false;
|
||||
|
||||
@@ -1115,7 +1115,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
|
||||
GenerateEffects(ref finalMix);
|
||||
|
||||
PerformanceEntryAddresses performanceEntry = new();
|
||||
PerformanceEntryAddresses performanceEntry = null;
|
||||
|
||||
int nodeId = finalMix.NodeId;
|
||||
|
||||
@@ -1164,7 +1164,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
{
|
||||
int nodeId = _mixContext.GetFinalState().NodeId;
|
||||
|
||||
PerformanceEntryAddresses performanceEntry = new();
|
||||
PerformanceEntryAddresses performanceEntry = null;
|
||||
|
||||
bool performanceInitialized = false;
|
||||
|
||||
@@ -1244,7 +1244,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
{
|
||||
bool performanceInitialized = false;
|
||||
|
||||
PerformanceEntryAddresses performanceEntry = new();
|
||||
PerformanceEntryAddresses performanceEntry = null;
|
||||
|
||||
if (_performanceManager != null && _performanceManager.GetNextEntry(out performanceEntry, PerformanceEntryType.Sink, sink.NodeId))
|
||||
{
|
||||
|
||||
@@ -174,19 +174,6 @@ namespace Ryujinx.Audio.Renderer.Server.Effect
|
||||
|
||||
updateErrorInfo = new ErrorInfo();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update the internal state from a user version 3 parameter.
|
||||
/// </summary>
|
||||
/// <param name="updateErrorInfo">The possible <see cref="ErrorInfo"/> that was generated.</param>
|
||||
/// <param name="parameter">The user parameter.</param>
|
||||
/// <param name="mapper">The mapper to use.</param>
|
||||
public virtual void Update(out ErrorInfo updateErrorInfo, in EffectInParameterVersion3 parameter, PoolMapper mapper)
|
||||
{
|
||||
Debug.Assert(IsTypeValid(in parameter));
|
||||
|
||||
updateErrorInfo = new ErrorInfo();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the work buffer DSP address at the given index.
|
||||
|
||||
@@ -25,13 +25,19 @@ namespace Ryujinx.Audio.Renderer.Server.Effect
|
||||
/// </summary>
|
||||
public Memory<BiquadFilterState> State { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The biquad filter effect version.
|
||||
/// </summary>
|
||||
public int BiquadFilterEffectVersion;
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="BiquadFilterEffect"/>.
|
||||
/// </summary>
|
||||
public BiquadFilterEffect()
|
||||
public BiquadFilterEffect(int version)
|
||||
{
|
||||
Parameter = new BiquadFilterEffectParameter2();
|
||||
State = new BiquadFilterState[Constants.ChannelCountMax];
|
||||
BiquadFilterEffectVersion = version;
|
||||
}
|
||||
|
||||
public override EffectType TargetEffectType => EffectType.BiquadFilter;
|
||||
@@ -45,11 +51,6 @@ namespace Ryujinx.Audio.Renderer.Server.Effect
|
||||
{
|
||||
Update(out updateErrorInfo, in parameter, mapper);
|
||||
}
|
||||
|
||||
public override void Update(out BehaviourParameter.ErrorInfo updateErrorInfo, in EffectInParameterVersion3 parameter, PoolMapper mapper)
|
||||
{
|
||||
Update(out updateErrorInfo, in parameter, mapper);
|
||||
}
|
||||
|
||||
public void Update<T>(out BehaviourParameter.ErrorInfo updateErrorInfo, in T parameter, PoolMapper mapper) where T : unmanaged, IEffectInParameter
|
||||
{
|
||||
@@ -57,7 +58,7 @@ namespace Ryujinx.Audio.Renderer.Server.Effect
|
||||
|
||||
UpdateParameterBase(in parameter);
|
||||
|
||||
if (typeof(T) == typeof(EffectInParameterVersion3))
|
||||
if (BiquadFilterEffectVersion == 2)
|
||||
{
|
||||
Parameter = MemoryMarshal.Cast<byte, BiquadFilterEffectParameter2>(parameter.SpecificData)[0];
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Ryujinx.Common;
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.Audio.Renderer.Server.Performance
|
||||
@@ -7,6 +8,8 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
|
||||
/// </summary>
|
||||
public class PerformanceEntryAddresses
|
||||
{
|
||||
public static readonly ObjectPool<PerformanceEntryAddresses> PerformanceEntryAddressesPool = new(() => new PerformanceEntryAddresses());
|
||||
|
||||
/// <summary>
|
||||
/// The memory storing the performance entry.
|
||||
/// </summary>
|
||||
@@ -52,5 +55,10 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
|
||||
{
|
||||
BaseMemory.Span[(int)ProcessingTimeOffset / 4] = (int)(endTimeNano / 1000) - BaseMemory.Span[(int)StartTimeOffset / 4];
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,11 +208,9 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
|
||||
|
||||
public override bool GetNextEntry(out PerformanceEntryAddresses performanceEntry, PerformanceEntryType entryType, int nodeId)
|
||||
{
|
||||
performanceEntry = new PerformanceEntryAddresses
|
||||
{
|
||||
BaseMemory = SpanMemoryManager<int>.Cast(CurrentBuffer),
|
||||
EntryCountOffset = (uint)CurrentHeader.GetEntryCountOffset(),
|
||||
};
|
||||
performanceEntry = PerformanceEntryAddresses.PerformanceEntryAddressesPool.Allocate();
|
||||
performanceEntry.BaseMemory = SpanMemoryManager<int>.Cast(CurrentBuffer);
|
||||
performanceEntry.EntryCountOffset = (uint)CurrentHeader.GetEntryCountOffset();
|
||||
|
||||
uint baseEntryOffset = (uint)(Unsafe.SizeOf<THeader>() + Unsafe.SizeOf<TEntry>() * _entryIndex);
|
||||
|
||||
@@ -238,12 +236,10 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
performanceEntry = new PerformanceEntryAddresses
|
||||
{
|
||||
BaseMemory = SpanMemoryManager<int>.Cast(CurrentBuffer),
|
||||
EntryCountOffset = (uint)CurrentHeader.GetEntryCountOffset(),
|
||||
};
|
||||
|
||||
performanceEntry = PerformanceEntryAddresses.PerformanceEntryAddressesPool.Allocate();
|
||||
performanceEntry.BaseMemory = SpanMemoryManager<int>.Cast(CurrentBuffer);
|
||||
performanceEntry.EntryCountOffset = (uint)CurrentHeader.GetEntryCountOffset();
|
||||
|
||||
uint baseEntryOffset = (uint)(Unsafe.SizeOf<THeader>() + GetEntriesSize() + Unsafe.SizeOf<TEntryDetail>() * _entryDetailIndex);
|
||||
|
||||
|
||||
@@ -300,7 +300,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
private static void ResetEffect<T>(ref BaseEffect effect, in T parameter, PoolMapper mapper) where T : unmanaged, IEffectInParameter
|
||||
private void ResetEffect<T>(ref BaseEffect effect, in T parameter, PoolMapper mapper) where T : unmanaged, IEffectInParameter
|
||||
{
|
||||
effect.ForceUnmapBuffers(mapper);
|
||||
|
||||
@@ -312,7 +312,8 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
EffectType.Delay => new DelayEffect(),
|
||||
EffectType.Reverb => new ReverbEffect(),
|
||||
EffectType.Reverb3d => new Reverb3dEffect(),
|
||||
EffectType.BiquadFilter => new BiquadFilterEffect(),
|
||||
EffectType.BiquadFilter when _behaviourInfo.IsBiquadFilterParameterFloatSupported() => new BiquadFilterEffect(2),
|
||||
EffectType.BiquadFilter => new BiquadFilterEffect(1),
|
||||
EffectType.Limiter => new LimiterEffect(),
|
||||
EffectType.CaptureBuffer => new CaptureBufferEffect(),
|
||||
EffectType.Compressor => new CompressorEffect(),
|
||||
@@ -322,11 +323,6 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
|
||||
public ResultCode UpdateEffects(EffectContext context, bool isAudioRendererActive, PoolMapper mapper)
|
||||
{
|
||||
if (_behaviourInfo.IsBiquadFilterParameterFloatSupported())
|
||||
{
|
||||
return UpdateEffectsVersion3(context, isAudioRendererActive, mapper);
|
||||
}
|
||||
|
||||
if (_behaviourInfo.IsEffectInfoVersion2Supported())
|
||||
{
|
||||
return UpdateEffectsVersion2(context, isAudioRendererActive, mapper);
|
||||
@@ -334,60 +330,6 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
|
||||
return UpdateEffectsVersion1(context, isAudioRendererActive, mapper);
|
||||
}
|
||||
|
||||
public ResultCode UpdateEffectsVersion3(EffectContext context, bool isAudioRendererActive, PoolMapper mapper)
|
||||
{
|
||||
if (context.GetCount() * Unsafe.SizeOf<EffectInParameterVersion2>() != _inputHeader.EffectsSize)
|
||||
{
|
||||
return ResultCode.InvalidUpdateInfo;
|
||||
}
|
||||
|
||||
int initialOutputSize = _output.Length;
|
||||
|
||||
long initialInputConsumed = _inputReader.Consumed;
|
||||
|
||||
for (int i = 0; i < context.GetCount(); i++)
|
||||
{
|
||||
ref readonly EffectInParameterVersion3 parameter = ref _inputReader.GetRefOrRefToCopy<EffectInParameterVersion3>(out _);
|
||||
|
||||
ref EffectOutStatusVersion2 outStatus = ref SpanIOHelper.GetWriteRef<EffectOutStatusVersion2>(ref _output)[0];
|
||||
|
||||
ref BaseEffect effect = ref context.GetEffect(i);
|
||||
|
||||
if (!effect.IsTypeValid(in parameter))
|
||||
{
|
||||
ResetEffect(ref effect, in parameter, mapper);
|
||||
}
|
||||
|
||||
effect.Update(out ErrorInfo updateErrorInfo, in parameter, mapper);
|
||||
|
||||
if (updateErrorInfo.ErrorCode != ResultCode.Success)
|
||||
{
|
||||
_behaviourInfo.AppendError(ref updateErrorInfo);
|
||||
}
|
||||
|
||||
effect.StoreStatus(ref outStatus, isAudioRendererActive);
|
||||
|
||||
if (parameter.IsNew)
|
||||
{
|
||||
effect.InitializeResultState(ref context.GetDspState(i));
|
||||
effect.InitializeResultState(ref context.GetState(i));
|
||||
}
|
||||
|
||||
effect.UpdateResultState(ref outStatus.ResultState, ref context.GetState(i));
|
||||
}
|
||||
|
||||
int currentOutputSize = _output.Length;
|
||||
|
||||
OutputHeader.EffectsSize = (uint)(Unsafe.SizeOf<EffectOutStatusVersion2>() * context.GetCount());
|
||||
OutputHeader.TotalSize += OutputHeader.EffectsSize;
|
||||
|
||||
Debug.Assert((initialOutputSize - currentOutputSize) == OutputHeader.EffectsSize);
|
||||
|
||||
_inputReader.SetConsumed(initialInputConsumed + _inputHeader.EffectsSize);
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
public ResultCode UpdateEffectsVersion2(EffectContext context, bool isAudioRendererActive, PoolMapper mapper)
|
||||
{
|
||||
|
||||
@@ -4,9 +4,11 @@ using Ryujinx.Audio.Renderer.Dsp;
|
||||
using Ryujinx.Audio.Renderer.Dsp.State;
|
||||
using Ryujinx.Audio.Renderer.Parameter;
|
||||
using Ryujinx.Audio.Renderer.Server.MemoryPool;
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Common.Memory;
|
||||
using Ryujinx.Common.Utilities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using static Ryujinx.Audio.Renderer.Common.BehaviourParameter;
|
||||
@@ -20,6 +22,8 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
|
||||
{
|
||||
public const int Alignment = 0x10;
|
||||
|
||||
private static readonly ObjectPool<Memory<VoiceState>[]> voiceStatesPool = new(() => new Memory<VoiceState>[Constants.VoiceChannelCountMax]);
|
||||
|
||||
/// <summary>
|
||||
/// Set to true if the voice is used.
|
||||
/// </summary>
|
||||
@@ -568,7 +572,7 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
|
||||
PoolMapper mapper,
|
||||
ref BehaviourInfo behaviourInfo)
|
||||
{
|
||||
errorInfos = new ErrorInfo[Constants.VoiceWaveBufferCount * 2];
|
||||
|
||||
|
||||
if (parameter.IsNew)
|
||||
{
|
||||
@@ -584,11 +588,14 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
|
||||
|
||||
Span<WaveBuffer> waveBuffersSpan = WaveBuffers.AsSpan();
|
||||
Span<WaveBufferInternal> pWaveBuffersSpan = parameter.WaveBuffers.AsSpan();
|
||||
List<ErrorInfo> errorInfosList = [];
|
||||
|
||||
for (int i = 0; i < Constants.VoiceWaveBufferCount; i++)
|
||||
{
|
||||
UpdateWaveBuffer(errorInfos.AsSpan(i * 2, 2), ref waveBuffersSpan[i], ref pWaveBuffersSpan[i], parameter.SampleFormat, voiceState.IsWaveBufferValid[i], mapper, ref behaviourInfo);
|
||||
UpdateWaveBuffer(errorInfosList, ref waveBuffersSpan[i], ref pWaveBuffersSpan[i], parameter.SampleFormat, voiceState.IsWaveBufferValid[i], mapper, ref behaviourInfo);
|
||||
}
|
||||
|
||||
errorInfos = errorInfosList.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -606,7 +613,7 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
|
||||
PoolMapper mapper,
|
||||
ref BehaviourInfo behaviourInfo)
|
||||
{
|
||||
errorInfos = new ErrorInfo[Constants.VoiceWaveBufferCount * 2];
|
||||
|
||||
|
||||
if (parameter.IsNew)
|
||||
{
|
||||
@@ -622,11 +629,14 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
|
||||
|
||||
Span<WaveBuffer> waveBuffersSpan = WaveBuffers.AsSpan();
|
||||
Span<WaveBufferInternal> pWaveBuffersSpan = parameter.WaveBuffers.AsSpan();
|
||||
List<ErrorInfo> errorInfosList = [];
|
||||
|
||||
for (int i = 0; i < Constants.VoiceWaveBufferCount; i++)
|
||||
{
|
||||
UpdateWaveBuffer(errorInfos.AsSpan(i * 2, 2), ref waveBuffersSpan[i], ref pWaveBuffersSpan[i], parameter.SampleFormat, voiceState.IsWaveBufferValid[i], mapper, ref behaviourInfo);
|
||||
UpdateWaveBuffer(errorInfosList, ref waveBuffersSpan[i], ref pWaveBuffersSpan[i], parameter.SampleFormat, voiceState.IsWaveBufferValid[i], mapper, ref behaviourInfo);
|
||||
}
|
||||
|
||||
errorInfos = errorInfosList.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -640,7 +650,7 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
|
||||
/// <param name="mapper">The mapper to use.</param>
|
||||
/// <param name="behaviourInfo">The behaviour context.</param>
|
||||
private void UpdateWaveBuffer(
|
||||
Span<ErrorInfo> errorInfos,
|
||||
List<ErrorInfo> errorInfos,
|
||||
ref WaveBuffer waveBuffer,
|
||||
ref WaveBufferInternal inputWaveBuffer,
|
||||
SampleFormat sampleFormat,
|
||||
@@ -671,7 +681,10 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
|
||||
|
||||
BufferInfoUnmapped = !mapper.TryAttachBuffer(out ErrorInfo bufferInfoError, ref waveBuffer.BufferAddressInfo, inputWaveBuffer.Address, inputWaveBuffer.Size);
|
||||
|
||||
errorInfos[0] = bufferInfoError;
|
||||
if (bufferInfoError.ErrorCode != ResultCode.Success)
|
||||
{
|
||||
errorInfos.Add(bufferInfoError);
|
||||
}
|
||||
|
||||
if (sampleFormat == SampleFormat.Adpcm && behaviourInfo.IsAdpcmLoopContextBugFixed() && inputWaveBuffer.ContextAddress != 0)
|
||||
{
|
||||
@@ -680,7 +693,10 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
|
||||
inputWaveBuffer.ContextAddress,
|
||||
inputWaveBuffer.ContextSize);
|
||||
|
||||
errorInfos[1] = adpcmLoopContextInfoError;
|
||||
if (adpcmLoopContextInfoError.ErrorCode != ResultCode.Success)
|
||||
{
|
||||
errorInfos.Add(adpcmLoopContextInfoError);
|
||||
}
|
||||
|
||||
if (!adpcmLoopContextMapped || BufferInfoUnmapped)
|
||||
{
|
||||
@@ -698,8 +714,11 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
|
||||
}
|
||||
else
|
||||
{
|
||||
errorInfos[0].ErrorCode = ResultCode.InvalidAddressInfo;
|
||||
errorInfos[0].ExtraErrorInfo = inputWaveBuffer.Address;
|
||||
errorInfos.Add(new ErrorInfo
|
||||
{
|
||||
ErrorCode = ResultCode.InvalidAddressInfo,
|
||||
ExtraErrorInfo = inputWaveBuffer.Address
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -891,7 +910,7 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
|
||||
IsNew = false;
|
||||
}
|
||||
|
||||
Memory<VoiceState>[] voiceStates = new Memory<VoiceState>[Constants.VoiceChannelCountMax];
|
||||
Memory<VoiceState>[] voiceStates = voiceStatesPool.Allocate();
|
||||
|
||||
Span<int> channelResourceIdsSpan = ChannelResourceIds.AsSpan();
|
||||
|
||||
@@ -900,7 +919,12 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
|
||||
voiceStates[i] = context.GetUpdateStateForDsp(channelResourceIdsSpan[i]);
|
||||
}
|
||||
|
||||
return UpdateParametersForCommandGeneration(voiceStates);
|
||||
bool result = UpdateParametersForCommandGeneration(voiceStates);
|
||||
|
||||
voiceStatesPool.Release(voiceStates);
|
||||
//might contain garbage data, but said data will never be accessed
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
226
src/Ryujinx.Common/Collections/BitMap.cs
Normal file
226
src/Ryujinx.Common/Collections/BitMap.cs
Normal file
@@ -0,0 +1,226 @@
|
||||
namespace Ryujinx.Common.Collections
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a collection that can store 1 bit values.
|
||||
/// </summary>
|
||||
public struct BitMap
|
||||
{
|
||||
/// <summary>
|
||||
/// Size in bits of the integer used internally for the groups of bits.
|
||||
/// </summary>
|
||||
public const int IntSize = 64;
|
||||
|
||||
private const int IntShift = 6;
|
||||
private const int IntMask = IntSize - 1;
|
||||
|
||||
private readonly long[] _masks;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value of a bit.
|
||||
/// </summary>
|
||||
/// <param name="bit">Bit to access</param>
|
||||
/// <returns>Bit value</returns>
|
||||
public bool this[int bit]
|
||||
{
|
||||
get => IsSet(bit);
|
||||
set
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
Set(bit);
|
||||
}
|
||||
else
|
||||
{
|
||||
Clear(bit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new bitmap.
|
||||
/// </summary>
|
||||
/// <param name="count">Total number of bits</param>
|
||||
public BitMap(int count)
|
||||
{
|
||||
_masks = new long[(count + IntMask) / IntSize];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if any bit is set.
|
||||
/// </summary>
|
||||
/// <returns>True if any bit is set, false otherwise</returns>
|
||||
public bool AnySet()
|
||||
{
|
||||
for (int i = 0; i < _masks.Length; i++)
|
||||
{
|
||||
if (_masks[i] != 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if a specific bit is set.
|
||||
/// </summary>
|
||||
/// <param name="bit">Bit to be checked</param>
|
||||
/// <returns>True if set, false otherwise</returns>
|
||||
public bool IsSet(int bit)
|
||||
{
|
||||
int wordIndex = bit >> IntShift;
|
||||
int wordBit = bit & IntMask;
|
||||
|
||||
long wordMask = 1L << wordBit;
|
||||
|
||||
return (_masks[wordIndex] & wordMask) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if any bit inside a given range of bits is set.
|
||||
/// </summary>
|
||||
/// <param name="start">Start bit of the range</param>
|
||||
/// <param name="end">End bit of the range (inclusive)</param>
|
||||
/// <returns>True if any bit is set, false otherwise</returns>
|
||||
public bool IsSet(int start, int end)
|
||||
{
|
||||
if (start == end)
|
||||
{
|
||||
return IsSet(start);
|
||||
}
|
||||
|
||||
int startIndex = start >> IntShift;
|
||||
int startBit = start & IntMask;
|
||||
long startMask = -1L << startBit;
|
||||
|
||||
int endIndex = end >> IntShift;
|
||||
int endBit = end & IntMask;
|
||||
long endMask = (long)(ulong.MaxValue >> (IntMask - endBit));
|
||||
|
||||
if (startIndex == endIndex)
|
||||
{
|
||||
return (_masks[startIndex] & startMask & endMask) != 0;
|
||||
}
|
||||
|
||||
if ((_masks[startIndex] & startMask) != 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
for (int i = startIndex + 1; i < endIndex; i++)
|
||||
{
|
||||
if (_masks[i] != 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if ((_masks[endIndex] & endMask) != 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the value of a bit to 1.
|
||||
/// </summary>
|
||||
/// <param name="bit">Bit to be set</param>
|
||||
/// <returns>True if the bit was 0 and then changed to 1, false if it was already 1</returns>
|
||||
public bool Set(int bit)
|
||||
{
|
||||
int wordIndex = bit >> IntShift;
|
||||
int wordBit = bit & IntMask;
|
||||
|
||||
long wordMask = 1L << wordBit;
|
||||
|
||||
if ((_masks[wordIndex] & wordMask) != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
_masks[wordIndex] |= wordMask;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a given range of bits to 1.
|
||||
/// </summary>
|
||||
/// <param name="start">Start bit of the range</param>
|
||||
/// <param name="end">End bit of the range (inclusive)</param>
|
||||
public void SetRange(int start, int end)
|
||||
{
|
||||
if (start == end)
|
||||
{
|
||||
Set(start);
|
||||
return;
|
||||
}
|
||||
|
||||
int startIndex = start >> IntShift;
|
||||
int startBit = start & IntMask;
|
||||
long startMask = -1L << startBit;
|
||||
|
||||
int endIndex = end >> IntShift;
|
||||
int endBit = end & IntMask;
|
||||
long endMask = (long)(ulong.MaxValue >> (IntMask - endBit));
|
||||
|
||||
if (startIndex == endIndex)
|
||||
{
|
||||
_masks[startIndex] |= startMask & endMask;
|
||||
}
|
||||
else
|
||||
{
|
||||
_masks[startIndex] |= startMask;
|
||||
|
||||
for (int i = startIndex + 1; i < endIndex; i++)
|
||||
{
|
||||
_masks[i] |= -1;
|
||||
}
|
||||
|
||||
_masks[endIndex] |= endMask;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a given bit to 0.
|
||||
/// </summary>
|
||||
/// <param name="bit">Bit to be cleared</param>
|
||||
public void Clear(int bit)
|
||||
{
|
||||
int wordIndex = bit >> IntShift;
|
||||
int wordBit = bit & IntMask;
|
||||
|
||||
long wordMask = 1L << wordBit;
|
||||
|
||||
_masks[wordIndex] &= ~wordMask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets all bits to 0.
|
||||
/// </summary>
|
||||
public void Clear()
|
||||
{
|
||||
for (int i = 0; i < _masks.Length; i++)
|
||||
{
|
||||
_masks[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets one or more groups of bits to 0.
|
||||
/// See <see cref="IntSize"/> for how many bits are inside each group.
|
||||
/// </summary>
|
||||
/// <param name="start">Start index of the group</param>
|
||||
/// <param name="end">End index of the group (inclusive)</param>
|
||||
public void ClearInt(int start, int end)
|
||||
{
|
||||
for (int i = start; i <= end; i++)
|
||||
{
|
||||
_masks[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -187,6 +187,17 @@ namespace Ryujinx.Common.Logging
|
||||
}
|
||||
}
|
||||
|
||||
public static void Flush()
|
||||
{
|
||||
foreach (ILogTarget target in _logTargets)
|
||||
{
|
||||
if (target is AsyncLogTargetWrapper asyncTarget)
|
||||
{
|
||||
asyncTarget.Flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void Shutdown()
|
||||
{
|
||||
Updated = null;
|
||||
|
||||
@@ -27,6 +27,17 @@ namespace Ryujinx.Common.Logging.Targets
|
||||
|
||||
private readonly int _overflowTimeout;
|
||||
|
||||
private sealed class FlushEventArgs : LogEventArgs
|
||||
{
|
||||
public readonly ManualResetEventSlim SignalEvent;
|
||||
|
||||
public FlushEventArgs(ManualResetEventSlim signalEvent)
|
||||
: base(LogLevel.Notice, TimeSpan.Zero, string.Empty, string.Empty)
|
||||
{
|
||||
SignalEvent = signalEvent;
|
||||
}
|
||||
}
|
||||
|
||||
string ILogTarget.Name => _target.Name;
|
||||
|
||||
public AsyncLogTargetWrapper(ILogTarget target, int queueLimit = -1, AsyncLogTargetOverflowAction overflowAction = AsyncLogTargetOverflowAction.Block)
|
||||
@@ -41,7 +52,15 @@ namespace Ryujinx.Common.Logging.Targets
|
||||
{
|
||||
try
|
||||
{
|
||||
_target.Log(this, _messageQueue.Take());
|
||||
LogEventArgs item = _messageQueue.Take();
|
||||
|
||||
if (item is FlushEventArgs flush)
|
||||
{
|
||||
flush.SignalEvent.Set();
|
||||
continue;
|
||||
}
|
||||
|
||||
_target.Log(this, item);
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
@@ -68,6 +87,26 @@ namespace Ryujinx.Common.Logging.Targets
|
||||
}
|
||||
}
|
||||
|
||||
public void Flush()
|
||||
{
|
||||
if (_messageQueue.Count == 0 || _messageQueue.IsAddingCompleted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
using ManualResetEventSlim signal = new ManualResetEventSlim(false);
|
||||
try
|
||||
{
|
||||
_messageQueue.Add(new FlushEventArgs(signal));
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
signal.Wait();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
GC.SuppressFinalize(this);
|
||||
|
||||
@@ -1,67 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Threading;
|
||||
|
||||
namespace Ryujinx.Common
|
||||
{
|
||||
public class ObjectPool<T>(Func<T> factory, int size)
|
||||
public class ObjectPool<T>(Func<T> factory, int size = -1)
|
||||
where T : class
|
||||
{
|
||||
private T _firstItem;
|
||||
private readonly T[] _items = new T[size - 1];
|
||||
private int _size = size;
|
||||
private readonly ConcurrentStack<T> _items = new();
|
||||
|
||||
public T Allocate()
|
||||
{
|
||||
T instance = _firstItem;
|
||||
bool success = _items.TryPop(out T instance);
|
||||
|
||||
if (instance == null || instance != Interlocked.CompareExchange(ref _firstItem, null, instance))
|
||||
if (!success)
|
||||
{
|
||||
instance = AllocateInternal();
|
||||
instance = factory();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
private T AllocateInternal()
|
||||
{
|
||||
T[] items = _items;
|
||||
|
||||
for (int i = 0; i < items.Length; i++)
|
||||
{
|
||||
T instance = items[i];
|
||||
|
||||
if (instance != null && instance == Interlocked.CompareExchange(ref items[i], null, instance))
|
||||
{
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
return factory();
|
||||
}
|
||||
|
||||
public void Release(T obj)
|
||||
{
|
||||
if (_firstItem == null)
|
||||
if (_size < 0 || _items.Count < _size)
|
||||
{
|
||||
_firstItem = obj;
|
||||
}
|
||||
else
|
||||
{
|
||||
ReleaseInternal(obj);
|
||||
}
|
||||
}
|
||||
|
||||
private void ReleaseInternal(T obj)
|
||||
{
|
||||
T[] items = _items;
|
||||
|
||||
for (int i = 0; i < items.Length; i++)
|
||||
{
|
||||
if (items[i] == null)
|
||||
{
|
||||
items[i] = obj;
|
||||
break;
|
||||
}
|
||||
_items.Push(obj);
|
||||
}
|
||||
}
|
||||
|
||||
public void Clear() => _items.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,6 +106,7 @@ namespace Ryujinx.Common
|
||||
"0100b3f000be2000", // Pokkén Tournament DX
|
||||
"0100187003a36000", // Pokémon: Let's Go Eevee!
|
||||
"010003f003a34000", // Pokémon: Let's Go Pikachu!
|
||||
"0100f43008c44000", // Pokémon Legends: Z-A
|
||||
|
||||
//Splatoon Franchise
|
||||
"0100f8f0000a2000", // Splatoon 2 (EU)
|
||||
|
||||
@@ -42,6 +42,11 @@ namespace Ryujinx.Cpu
|
||||
/// </summary>
|
||||
uint Fpsr { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Floating-point Status and Control Register.
|
||||
/// </summary>
|
||||
uint Fpscr => Fpsr | Fpcr;
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whenever the CPU is running 64-bit (AArch64 mode) or 32-bit (AArch32 mode) code.
|
||||
/// </summary>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Ryujinx.Common.Collections;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Graphics.GAL;
|
||||
using Ryujinx.Graphics.Gpu.Memory;
|
||||
@@ -72,6 +73,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||
}
|
||||
|
||||
private readonly GpuChannel _channel;
|
||||
private readonly BitMap _invalidMap;
|
||||
private readonly ConcurrentQueue<DereferenceRequest> _dereferenceQueue = new();
|
||||
private TextureDescriptor _defaultDescriptor;
|
||||
|
||||
@@ -166,6 +168,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||
{
|
||||
_channel = channel;
|
||||
_aliasLists = new Dictionary<Texture, TextureAliasList>();
|
||||
_invalidMap = new BitMap(maximumId + 1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -182,6 +185,11 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||
|
||||
if (texture == null)
|
||||
{
|
||||
if (_invalidMap.IsSet(id))
|
||||
{
|
||||
return ref descriptor;
|
||||
}
|
||||
|
||||
texture = PhysicalMemory.TextureCache.FindShortCache(descriptor);
|
||||
|
||||
if (texture == null)
|
||||
@@ -198,6 +206,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||
// If this happens, then the texture address is invalid, we can't add it to the cache.
|
||||
if (texture == null)
|
||||
{
|
||||
_invalidMap.Set(id);
|
||||
return ref descriptor;
|
||||
}
|
||||
}
|
||||
@@ -515,6 +524,8 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||
RemoveAliasList(texture);
|
||||
}
|
||||
}
|
||||
|
||||
_invalidMap.Clear(id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -205,7 +205,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
||||
GpuChannelComputeState computeState,
|
||||
ulong gpuVa)
|
||||
{
|
||||
if (_cpPrograms.TryGetValue(gpuVa, out var cpShader) && IsShaderEqual(channel, poolState, computeState, cpShader, gpuVa))
|
||||
if (_cpPrograms.TryGetValue(gpuVa, out CachedShaderProgram cpShader) && IsShaderEqual(channel, poolState, computeState, cpShader, gpuVa))
|
||||
{
|
||||
return cpShader;
|
||||
}
|
||||
@@ -252,8 +252,8 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
||||
{
|
||||
channel.TextureManager.UpdateRenderTargets();
|
||||
|
||||
var rtControl = state.RtControl;
|
||||
var msaaMode = state.RtMsaaMode;
|
||||
RtControl rtControl = state.RtControl;
|
||||
TextureMsaaMode msaaMode = state.RtMsaaMode;
|
||||
|
||||
pipeline.SamplesCount = msaaMode.SamplesInX() * msaaMode.SamplesInY();
|
||||
|
||||
@@ -267,7 +267,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
||||
{
|
||||
int rtIndex = rtControl.UnpackPermutationIndex(index);
|
||||
|
||||
var colorState = rtColorStateSpan[rtIndex];
|
||||
RtColorState colorState = rtColorStateSpan[rtIndex];
|
||||
|
||||
if (index >= count || colorState.Format == 0 || colorState.WidthOrStride == 0)
|
||||
{
|
||||
@@ -312,12 +312,12 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
||||
ref GpuChannelGraphicsState graphicsState,
|
||||
ShaderAddresses addresses)
|
||||
{
|
||||
if (_gpPrograms.TryGetValue(addresses, out var gpShaders) && IsShaderEqual(channel, ref poolState, ref graphicsState, gpShaders, addresses))
|
||||
if (_gpPrograms.TryGetValue(addresses, out CachedShaderProgram gpShaders) && IsShaderEqual(channel, ref poolState, ref graphicsState, gpShaders, addresses))
|
||||
{
|
||||
return gpShaders;
|
||||
}
|
||||
|
||||
if (_graphicsShaderCache.TryFind(channel, ref poolState, ref graphicsState, addresses, out gpShaders, out var cachedGuestCode))
|
||||
if (_graphicsShaderCache.TryFind(channel, ref poolState, ref graphicsState, addresses, out gpShaders, out CachedGraphicsGuestCode cachedGuestCode))
|
||||
{
|
||||
_gpPrograms[addresses] = gpShaders;
|
||||
return gpShaders;
|
||||
@@ -590,7 +590,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
||||
|
||||
for (int i = 0; i < Constants.TotalTransformFeedbackBuffers; i++)
|
||||
{
|
||||
var tf = tfStateSpan[i];
|
||||
TfState tf = tfStateSpan[i];
|
||||
|
||||
descs[i] = new TransformFeedbackDescriptor(
|
||||
tf.BufferIndex,
|
||||
@@ -696,7 +696,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
||||
/// <returns>The generated translator context</returns>
|
||||
public static TranslatorContext DecodeComputeShader(IGpuAccessor gpuAccessor, TargetApi api, ulong gpuVa)
|
||||
{
|
||||
var options = CreateTranslationOptions(api, DefaultFlags | TranslationFlags.Compute);
|
||||
TranslationOptions options = CreateTranslationOptions(api, DefaultFlags | TranslationFlags.Compute);
|
||||
return Translator.CreateContext(gpuVa, gpuAccessor, options);
|
||||
}
|
||||
|
||||
@@ -713,7 +713,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
||||
/// <returns>The generated translator context</returns>
|
||||
public static TranslatorContext DecodeGraphicsShader(IGpuAccessor gpuAccessor, TargetApi api, TranslationFlags flags, ulong gpuVa)
|
||||
{
|
||||
var options = CreateTranslationOptions(api, flags);
|
||||
TranslationOptions options = CreateTranslationOptions(api, flags);
|
||||
return Translator.CreateContext(gpuVa, gpuAccessor, options);
|
||||
}
|
||||
|
||||
@@ -739,7 +739,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
||||
{
|
||||
ulong cb1DataAddress = channel.BufferManager.GetGraphicsUniformBufferAddress(0, 1);
|
||||
|
||||
var memoryManager = channel.MemoryManager;
|
||||
MemoryManager memoryManager = channel.MemoryManager;
|
||||
|
||||
codeA ??= memoryManager.GetSpan(vertexA.Address, vertexA.Size).ToArray();
|
||||
codeB ??= memoryManager.GetSpan(currentStage.Address, currentStage.Size).ToArray();
|
||||
@@ -777,7 +777,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
||||
/// <returns>Compiled graphics shader code</returns>
|
||||
private static TranslatedShader TranslateShader(ShaderDumper dumper, GpuChannel channel, TranslatorContext context, byte[] code, bool asCompute)
|
||||
{
|
||||
var memoryManager = channel.MemoryManager;
|
||||
MemoryManager memoryManager = channel.MemoryManager;
|
||||
|
||||
ulong cb1DataAddress = context.Stage == ShaderStage.Compute
|
||||
? channel.BufferManager.GetComputeUniformBufferAddress(1)
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
using SharpMetal;
|
||||
using SharpMetal.Foundation;
|
||||
using SharpMetal.ObjectiveCCore;
|
||||
using SharpMetal.QuartzCore;
|
||||
using System.Runtime.Versioning;
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
namespace Ryujinx.Graphics.Metal.SharpMetalExtensions
|
||||
{
|
||||
[SupportedOSPlatform("macOS")]
|
||||
public static class CAMetalLayerExtensions
|
||||
{
|
||||
private static readonly Selector sel_developerHUDProperties = "developerHUDProperties";
|
||||
private static readonly Selector sel_setDeveloperHUDProperties = "setDeveloperHUDProperties:";
|
||||
|
||||
public static NSDictionary GetDeveloperHudProperties(this CAMetalLayer metalLayer)
|
||||
=> new(ObjectiveCRuntime.IntPtr_objc_msgSend(metalLayer.NativePtr, sel_developerHUDProperties));
|
||||
|
||||
public static void SetDeveloperHudProperties(this CAMetalLayer metalLayer, NSDictionary dictionary)
|
||||
=> ObjectiveCRuntime.objc_msgSend(metalLayer.NativePtr, sel_setDeveloperHUDProperties, dictionary);
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
using SharpMetal.Foundation;
|
||||
using SharpMetal.ObjectiveCCore;
|
||||
using System.Runtime.Versioning;
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
namespace Ryujinx.Graphics.Metal.SharpMetalExtensions
|
||||
{
|
||||
[SupportedOSPlatform("macOS")]
|
||||
public static class NSHelper
|
||||
{
|
||||
private static readonly Selector sel_getCStringMaxLengthEncoding = "getCString:maxLength:encoding:";
|
||||
private static readonly Selector sel_stringWithUTF8String = "stringWithUTF8String:";
|
||||
|
||||
public static unsafe string ToDotNetString(this NSString source)
|
||||
{
|
||||
char[] sourceBuffer = new char[source.Length];
|
||||
fixed (char* pSourceBuffer = sourceBuffer)
|
||||
{
|
||||
ObjectiveC.bool_objc_msgSend(source,
|
||||
sel_getCStringMaxLengthEncoding,
|
||||
pSourceBuffer,
|
||||
source.MaximumLengthOfBytes(NSStringEncoding.UTF16) + 1,
|
||||
(ulong)NSStringEncoding.UTF16);
|
||||
}
|
||||
|
||||
return new string(sourceBuffer);
|
||||
}
|
||||
|
||||
public static NSString ToNSString(this string source)
|
||||
=> new(ObjectiveC.IntPtr_objc_msgSend(new ObjectiveCClass(nameof(NSString)), sel_stringWithUTF8String, source));
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SharpMetal" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -93,7 +93,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||
size = DefaultLocalMemorySize;
|
||||
}
|
||||
|
||||
var lmem = new MemoryDefinition("local_memory", AggregateType.Array | AggregateType.U32, BitUtils.DivRoundUp(size, sizeof(uint)));
|
||||
MemoryDefinition lmem = new MemoryDefinition("local_memory", AggregateType.Array | AggregateType.U32, BitUtils.DivRoundUp(size, sizeof(uint)));
|
||||
|
||||
LocalMemoryId = Properties.AddLocalMemory(lmem);
|
||||
}
|
||||
@@ -112,7 +112,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||
size = DefaultSharedMemorySize;
|
||||
}
|
||||
|
||||
var smem = new MemoryDefinition("shared_memory", AggregateType.Array | AggregateType.U32, BitUtils.DivRoundUp(size, sizeof(uint)));
|
||||
MemoryDefinition smem = new MemoryDefinition("shared_memory", AggregateType.Array | AggregateType.U32, BitUtils.DivRoundUp(size, sizeof(uint)));
|
||||
|
||||
SharedMemoryId = Properties.AddSharedMemory(smem);
|
||||
}
|
||||
@@ -273,16 +273,16 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||
bool coherent,
|
||||
bool separate)
|
||||
{
|
||||
var dimensions = type == SamplerType.None ? 0 : type.GetDimensions();
|
||||
var dict = isImage ? _usedImages : _usedTextures;
|
||||
int dimensions = type == SamplerType.None ? 0 : type.GetDimensions();
|
||||
Dictionary<TextureInfo, TextureMeta> dict = isImage ? _usedImages : _usedTextures;
|
||||
|
||||
var usageFlags = TextureUsageFlags.None;
|
||||
TextureUsageFlags usageFlags = TextureUsageFlags.None;
|
||||
|
||||
if (intCoords)
|
||||
{
|
||||
usageFlags |= TextureUsageFlags.NeedsScaleValue;
|
||||
|
||||
var canScale = _stage.SupportsRenderScale() && arrayLength == 1 && !write && dimensions == 2;
|
||||
bool canScale = _stage.SupportsRenderScale() && arrayLength == 1 && !write && dimensions == 2;
|
||||
|
||||
if (!canScale)
|
||||
{
|
||||
@@ -304,9 +304,9 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||
|
||||
// For array textures, we also want to use type as key,
|
||||
// since we may have texture handles stores in the same buffer, but for textures with different types.
|
||||
var keyType = arrayLength > 1 ? type : SamplerType.None;
|
||||
var info = new TextureInfo(cbufSlot, handle, arrayLength, separate, keyType, format);
|
||||
var meta = new TextureMeta()
|
||||
SamplerType keyType = arrayLength > 1 ? type : SamplerType.None;
|
||||
TextureInfo info = new TextureInfo(cbufSlot, handle, arrayLength, separate, keyType, format);
|
||||
TextureMeta meta = new TextureMeta()
|
||||
{
|
||||
AccurateType = accurateType,
|
||||
Type = type,
|
||||
@@ -316,7 +316,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||
int setIndex;
|
||||
int binding;
|
||||
|
||||
if (dict.TryGetValue(info, out var existingMeta))
|
||||
if (dict.TryGetValue(info, out TextureMeta existingMeta))
|
||||
{
|
||||
dict[info] = MergeTextureMeta(meta, existingMeta);
|
||||
setIndex = existingMeta.Set;
|
||||
@@ -373,7 +373,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||
nameSuffix = cbufSlot < 0 ? $"{prefix}_tcb_{handle:X}" : $"{prefix}_cb{cbufSlot}_{handle:X}";
|
||||
}
|
||||
|
||||
var definition = new TextureDefinition(
|
||||
TextureDefinition definition = new TextureDefinition(
|
||||
setIndex,
|
||||
binding,
|
||||
arrayLength,
|
||||
@@ -433,8 +433,8 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||
{
|
||||
selectedMeta.UsageFlags |= TextureUsageFlags.NeedsScaleValue;
|
||||
|
||||
var dimensions = type.GetDimensions();
|
||||
var canScale = _stage.SupportsRenderScale() && selectedInfo.ArrayLength == 1 && dimensions == 2;
|
||||
int dimensions = type.GetDimensions();
|
||||
bool canScale = _stage.SupportsRenderScale() && selectedInfo.ArrayLength == 1 && dimensions == 2;
|
||||
|
||||
if (!canScale)
|
||||
{
|
||||
@@ -454,7 +454,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||
|
||||
public BufferDescriptor[] GetConstantBufferDescriptors()
|
||||
{
|
||||
var descriptors = new BufferDescriptor[_usedConstantBufferBindings.Count];
|
||||
BufferDescriptor[] descriptors = new BufferDescriptor[_usedConstantBufferBindings.Count];
|
||||
|
||||
int descriptorIndex = 0;
|
||||
|
||||
@@ -478,7 +478,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||
|
||||
public BufferDescriptor[] GetStorageBufferDescriptors()
|
||||
{
|
||||
var descriptors = new BufferDescriptor[_sbSlots.Count];
|
||||
BufferDescriptor[] descriptors = new BufferDescriptor[_sbSlots.Count];
|
||||
|
||||
int descriptorIndex = 0;
|
||||
|
||||
|
||||
@@ -242,8 +242,8 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||
usedFeatures |= FeatureFlags.VtgAsCompute;
|
||||
}
|
||||
|
||||
var cfgs = new ControlFlowGraph[functions.Length];
|
||||
var frus = new RegisterUsage.FunctionRegisterUsage[functions.Length];
|
||||
ControlFlowGraph[] cfgs = new ControlFlowGraph[functions.Length];
|
||||
RegisterUsage.FunctionRegisterUsage[] frus = new RegisterUsage.FunctionRegisterUsage[functions.Length];
|
||||
|
||||
for (int i = 0; i < functions.Length; i++)
|
||||
{
|
||||
@@ -266,14 +266,14 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||
|
||||
for (int i = 0; i < functions.Length; i++)
|
||||
{
|
||||
var cfg = cfgs[i];
|
||||
ControlFlowGraph cfg = cfgs[i];
|
||||
|
||||
int inArgumentsCount = 0;
|
||||
int outArgumentsCount = 0;
|
||||
|
||||
if (i != 0)
|
||||
{
|
||||
var fru = frus[i];
|
||||
RegisterUsage.FunctionRegisterUsage fru = frus[i];
|
||||
|
||||
inArgumentsCount = fru.InArguments.Length;
|
||||
outArgumentsCount = fru.OutArguments.Length;
|
||||
@@ -325,7 +325,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||
FeatureFlags usedFeatures,
|
||||
byte clipDistancesWritten)
|
||||
{
|
||||
var sInfo = StructuredProgram.MakeStructuredProgram(
|
||||
StructuredProgramInfo sInfo = StructuredProgram.MakeStructuredProgram(
|
||||
funcs,
|
||||
attributeUsage,
|
||||
definitions,
|
||||
@@ -340,7 +340,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||
_ => 1
|
||||
};
|
||||
|
||||
var info = new ShaderProgramInfo(
|
||||
ShaderProgramInfo info = new ShaderProgramInfo(
|
||||
resourceManager.GetConstantBufferDescriptors(),
|
||||
resourceManager.GetStorageBufferDescriptors(),
|
||||
resourceManager.GetTextureDescriptors(),
|
||||
@@ -356,7 +356,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||
clipDistancesWritten,
|
||||
originalDefinitions.OmapTargets);
|
||||
|
||||
var hostCapabilities = new HostCapabilities(
|
||||
HostCapabilities hostCapabilities = new HostCapabilities(
|
||||
GpuAccessor.QueryHostReducedPrecision(),
|
||||
GpuAccessor.QueryHostSupportsFragmentShaderInterlock(),
|
||||
GpuAccessor.QueryHostSupportsFragmentShaderOrderingIntel(),
|
||||
@@ -367,7 +367,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||
GpuAccessor.QueryHostSupportsTextureShadowLod(),
|
||||
GpuAccessor.QueryHostSupportsViewportMask());
|
||||
|
||||
var parameters = new CodeGenParameters(attributeUsage, definitions, resourceManager.Properties, hostCapabilities, GpuAccessor, Options.TargetApi);
|
||||
CodeGenParameters parameters = new CodeGenParameters(attributeUsage, definitions, resourceManager.Properties, hostCapabilities, GpuAccessor, Options.TargetApi);
|
||||
|
||||
return Options.TargetLanguage switch
|
||||
{
|
||||
@@ -486,10 +486,10 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||
|
||||
public ShaderProgram GenerateVertexPassthroughForCompute()
|
||||
{
|
||||
var attributeUsage = new AttributeUsage(GpuAccessor);
|
||||
var resourceManager = new ResourceManager(ShaderStage.Vertex, GpuAccessor);
|
||||
AttributeUsage attributeUsage = new AttributeUsage(GpuAccessor);
|
||||
ResourceManager resourceManager = new ResourceManager(ShaderStage.Vertex, GpuAccessor);
|
||||
|
||||
var reservations = GetResourceReservations();
|
||||
ResourceReservations reservations = GetResourceReservations();
|
||||
|
||||
int vertexInfoCbBinding = reservations.VertexInfoConstantBufferBinding;
|
||||
|
||||
@@ -508,7 +508,7 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||
BufferDefinition vertexOutputBuffer = new(BufferLayout.Std430, 1, vertexDataSbBinding, "vb_input", vertexInputStruct);
|
||||
resourceManager.Properties.AddOrUpdateStorageBuffer(vertexOutputBuffer);
|
||||
|
||||
var context = new EmitterContext();
|
||||
EmitterContext context = new EmitterContext();
|
||||
|
||||
Operand vertexIndex = Options.TargetApi == TargetApi.OpenGL
|
||||
? context.Load(StorageKind.Input, IoVariable.VertexId)
|
||||
@@ -553,13 +553,13 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||
}
|
||||
}
|
||||
|
||||
var operations = context.GetOperations();
|
||||
var cfg = ControlFlowGraph.Create(operations);
|
||||
var function = new Function(cfg.Blocks, "main", false, 0, 0);
|
||||
Operation[] operations = context.GetOperations();
|
||||
ControlFlowGraph cfg = ControlFlowGraph.Create(operations);
|
||||
Function function = new Function(cfg.Blocks, "main", false, 0, 0);
|
||||
|
||||
var transformFeedbackOutputs = GetTransformFeedbackOutputs(GpuAccessor, out ulong transformFeedbackVecMap);
|
||||
TransformFeedbackOutput[] transformFeedbackOutputs = GetTransformFeedbackOutputs(GpuAccessor, out ulong transformFeedbackVecMap);
|
||||
|
||||
var definitions = new ShaderDefinitions(ShaderStage.Vertex, transformFeedbackVecMap, transformFeedbackOutputs)
|
||||
ShaderDefinitions definitions = new ShaderDefinitions(ShaderStage.Vertex, transformFeedbackVecMap, transformFeedbackOutputs)
|
||||
{
|
||||
LastInVertexPipeline = true
|
||||
};
|
||||
@@ -604,10 +604,10 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||
break;
|
||||
}
|
||||
|
||||
var attributeUsage = new AttributeUsage(GpuAccessor);
|
||||
var resourceManager = new ResourceManager(ShaderStage.Geometry, GpuAccessor);
|
||||
AttributeUsage attributeUsage = new AttributeUsage(GpuAccessor);
|
||||
ResourceManager resourceManager = new ResourceManager(ShaderStage.Geometry, GpuAccessor);
|
||||
|
||||
var context = new EmitterContext();
|
||||
EmitterContext context = new EmitterContext();
|
||||
|
||||
for (int v = 0; v < maxOutputVertices; v++)
|
||||
{
|
||||
@@ -648,11 +648,11 @@ namespace Ryujinx.Graphics.Shader.Translation
|
||||
|
||||
context.EndPrimitive();
|
||||
|
||||
var operations = context.GetOperations();
|
||||
var cfg = ControlFlowGraph.Create(operations);
|
||||
var function = new Function(cfg.Blocks, "main", false, 0, 0);
|
||||
Operation[] operations = context.GetOperations();
|
||||
ControlFlowGraph cfg = ControlFlowGraph.Create(operations);
|
||||
Function function = new Function(cfg.Blocks, "main", false, 0, 0);
|
||||
|
||||
var definitions = new ShaderDefinitions(
|
||||
ShaderDefinitions definitions = new ShaderDefinitions(
|
||||
ShaderStage.Geometry,
|
||||
GpuAccessor.QueryGraphicsState(),
|
||||
false,
|
||||
|
||||
@@ -904,8 +904,8 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
pattern.OffsetIndex.CopyTo(shaderParams[..pattern.OffsetIndex.Length]);
|
||||
|
||||
using var patternScoped = gd.BufferManager.ReserveOrCreate(gd, cbs, ParamsBufferSize);
|
||||
var patternBuffer = patternScoped.Holder;
|
||||
using ScopedTemporaryBuffer patternScoped = gd.BufferManager.ReserveOrCreate(gd, cbs, ParamsBufferSize);
|
||||
BufferHolder patternBuffer = patternScoped.Holder;
|
||||
|
||||
patternBuffer.SetDataUnchecked<int>(patternScoped.Offset, shaderParams);
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.HLE.HOS.Kernel.Threading;
|
||||
using Ryujinx.Memory;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Ryujinx.HLE.Debugger
|
||||
{
|
||||
@@ -11,12 +9,9 @@ namespace Ryujinx.HLE.Debugger
|
||||
{
|
||||
public byte[] OriginalData { get; }
|
||||
|
||||
public bool IsStep { get; }
|
||||
|
||||
public Breakpoint(byte[] originalData, bool isStep)
|
||||
public Breakpoint(byte[] originalData)
|
||||
{
|
||||
OriginalData = originalData;
|
||||
IsStep = isStep;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,9 +23,9 @@ namespace Ryujinx.HLE.Debugger
|
||||
private readonly Debugger _debugger;
|
||||
private readonly ConcurrentDictionary<ulong, Breakpoint> _breakpoints = new();
|
||||
|
||||
private static readonly byte[] _aarch64BreakInstruction = { 0x00, 0x00, 0x20, 0xD4 }; // BRK #0
|
||||
private static readonly byte[] _aarch32BreakInstruction = { 0xFE, 0xDE, 0xFF, 0xE7 }; // TRAP
|
||||
private static readonly byte[] _aarch32ThumbBreakInstruction = { 0x80, 0xB6 };
|
||||
private static readonly byte[] _aarch64BreakInstruction = [0x00, 0x00, 0x20, 0xD4]; // BRK #0
|
||||
private static readonly byte[] _aarch32BreakInstruction = [0xFE, 0xDE, 0xFF, 0xE7]; // TRAP
|
||||
private static readonly byte[] _aarch32ThumbBreakInstruction = [0x80, 0xB6];
|
||||
|
||||
public BreakpointManager(Debugger debugger)
|
||||
{
|
||||
@@ -44,7 +39,7 @@ namespace Ryujinx.HLE.Debugger
|
||||
/// <param name="length">The length of the instruction to replace.</param>
|
||||
/// <param name="isStep">Indicates if this is a single-step breakpoint.</param>
|
||||
/// <returns>True if the breakpoint was set successfully; otherwise, false.</returns>
|
||||
public bool SetBreakPoint(ulong address, ulong length, bool isStep = false)
|
||||
public bool SetBreakPoint(ulong address, ulong length)
|
||||
{
|
||||
if (_breakpoints.ContainsKey(address))
|
||||
{
|
||||
@@ -58,7 +53,7 @@ namespace Ryujinx.HLE.Debugger
|
||||
return false;
|
||||
}
|
||||
|
||||
var originalInstruction = new byte[length];
|
||||
byte[] originalInstruction = new byte[length];
|
||||
if (!ReadMemory(address, originalInstruction))
|
||||
{
|
||||
Logger.Error?.Print(LogClass.GdbStub, $"Failed to read memory at 0x{address:X16} to set breakpoint.");
|
||||
@@ -71,7 +66,7 @@ namespace Ryujinx.HLE.Debugger
|
||||
return false;
|
||||
}
|
||||
|
||||
var breakpoint = new Breakpoint(originalInstruction, isStep);
|
||||
Breakpoint breakpoint = new(originalInstruction);
|
||||
if (_breakpoints.TryAdd(address, breakpoint))
|
||||
{
|
||||
Logger.Debug?.Print(LogClass.GdbStub, $"Breakpoint set at 0x{address:X16}");
|
||||
@@ -112,7 +107,7 @@ namespace Ryujinx.HLE.Debugger
|
||||
/// </summary>
|
||||
public void ClearAll()
|
||||
{
|
||||
foreach (var bp in _breakpoints)
|
||||
foreach (KeyValuePair<ulong, Breakpoint> bp in _breakpoints)
|
||||
{
|
||||
if (!WriteMemory(bp.Key, bp.Value.OriginalData))
|
||||
{
|
||||
@@ -124,33 +119,9 @@ namespace Ryujinx.HLE.Debugger
|
||||
Logger.Debug?.Print(LogClass.GdbStub, "All breakpoints cleared.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears all currently set single-step software breakpoints.
|
||||
/// </summary>
|
||||
public void ClearAllStepBreakpoints()
|
||||
{
|
||||
var stepBreakpoints = _breakpoints.Where(p => p.Value.IsStep).ToList();
|
||||
|
||||
if (stepBreakpoints.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var bp in stepBreakpoints)
|
||||
{
|
||||
if (_breakpoints.TryRemove(bp.Key, out Breakpoint removedBreakpoint))
|
||||
{
|
||||
WriteMemory(bp.Key, removedBreakpoint.OriginalData);
|
||||
}
|
||||
}
|
||||
|
||||
Logger.Debug?.Print(LogClass.GdbStub, "All step breakpoints cleared.");
|
||||
}
|
||||
|
||||
|
||||
private byte[] GetBreakInstruction(ulong length)
|
||||
{
|
||||
if (_debugger.IsProcessAarch32)
|
||||
if (_debugger.IsProcess32Bit)
|
||||
{
|
||||
if (length == 2)
|
||||
{
|
||||
|
||||
127
src/Ryujinx.HLE/Debugger/Debugger.MainThread.cs
Normal file
127
src/Ryujinx.HLE/Debugger/Debugger.MainThread.cs
Normal file
@@ -0,0 +1,127 @@
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.HLE.Debugger.Gdb;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading;
|
||||
|
||||
namespace Ryujinx.HLE.Debugger
|
||||
{
|
||||
public partial class Debugger
|
||||
{
|
||||
private void MainLoop()
|
||||
{
|
||||
IPEndPoint endpoint = new(IPAddress.Any, GdbStubPort);
|
||||
_listenerSocket = new TcpListener(endpoint);
|
||||
|
||||
try
|
||||
{
|
||||
_listenerSocket.Start();
|
||||
}
|
||||
catch (SocketException se)
|
||||
{
|
||||
Logger.Error?.Print(LogClass.GdbStub,
|
||||
$"Failed to create TCP server on {endpoint} for GDB client: {Enum.GetName(se.SocketErrorCode)}");
|
||||
throw;
|
||||
}
|
||||
|
||||
Logger.Notice.Print(LogClass.GdbStub, $"Currently waiting on {endpoint} for GDB client");
|
||||
|
||||
while (!_shuttingDown)
|
||||
{
|
||||
try
|
||||
{
|
||||
_clientSocket = _listenerSocket.AcceptSocket();
|
||||
}
|
||||
catch (SocketException se)
|
||||
{
|
||||
Logger.Error?.Print(LogClass.GdbStub,
|
||||
$"Failed to accept incoming GDB client connection: {Enum.GetName(se.SocketErrorCode)}");
|
||||
return;
|
||||
}
|
||||
|
||||
// If the user connects before the application is running, wait for the application to start.
|
||||
int retries = 10;
|
||||
while ((DebugProcess == null || GetThreads().Length == 0) && retries-- > 0)
|
||||
{
|
||||
Thread.Sleep(500);
|
||||
}
|
||||
|
||||
if (DebugProcess == null || GetThreads().Length == 0)
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.GdbStub,
|
||||
"Application is not running, cannot accept GDB client connection");
|
||||
_clientSocket.Close();
|
||||
continue;
|
||||
}
|
||||
|
||||
_clientSocket.NoDelay = true;
|
||||
_readStream = new NetworkStream(_clientSocket, System.IO.FileAccess.Read);
|
||||
_writeStream = new NetworkStream(_clientSocket, System.IO.FileAccess.Write);
|
||||
_commands = new GdbCommands(_listenerSocket, _clientSocket, _readStream, _writeStream, this);
|
||||
|
||||
Logger.Notice.Print(LogClass.GdbStub, "GDB client connected");
|
||||
|
||||
while (true)
|
||||
{
|
||||
try
|
||||
{
|
||||
switch (_readStream.ReadByte())
|
||||
{
|
||||
case -1:
|
||||
goto EndOfLoop;
|
||||
case '+':
|
||||
continue;
|
||||
case '-':
|
||||
Logger.Notice.Print(LogClass.GdbStub, "NACK received!");
|
||||
continue;
|
||||
case '\x03':
|
||||
_messages.Add(Message.BreakIn);
|
||||
break;
|
||||
case '$':
|
||||
string cmd = string.Empty;
|
||||
while (true)
|
||||
{
|
||||
int x = _readStream.ReadByte();
|
||||
if (x == -1)
|
||||
goto EndOfLoop;
|
||||
if (x == '#')
|
||||
break;
|
||||
cmd += (char)x;
|
||||
}
|
||||
|
||||
string checksum = $"{(char)_readStream.ReadByte()}{(char)_readStream.ReadByte()}";
|
||||
if (checksum == $"{Helpers.CalculateChecksum(cmd):x2}")
|
||||
{
|
||||
_messages.Add(new CommandMessage(cmd));
|
||||
}
|
||||
else
|
||||
{
|
||||
_messages.Add(Message.SendNack);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
goto EndOfLoop;
|
||||
}
|
||||
}
|
||||
|
||||
EndOfLoop:
|
||||
Logger.Notice.Print(LogClass.GdbStub, "GDB client lost connection");
|
||||
_readStream.Close();
|
||||
_readStream = null;
|
||||
_writeStream.Close();
|
||||
_writeStream = null;
|
||||
_clientSocket.Close();
|
||||
_clientSocket = null;
|
||||
_commands = null;
|
||||
|
||||
BreakpointManager.ClearAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
58
src/Ryujinx.HLE/Debugger/Debugger.MessageHandler.cs
Normal file
58
src/Ryujinx.HLE/Debugger/Debugger.MessageHandler.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using Ryujinx.Common.Logging;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.Debugger
|
||||
{
|
||||
public partial class Debugger
|
||||
{
|
||||
private void MessageHandlerMain()
|
||||
{
|
||||
while (!_shuttingDown)
|
||||
{
|
||||
try
|
||||
{
|
||||
switch (_messages.Take())
|
||||
{
|
||||
case Message { Type: MessageType.BreakIn }:
|
||||
Logger.Notice.Print(LogClass.GdbStub, "Break-in requested");
|
||||
_commands.Interrupt();
|
||||
break;
|
||||
|
||||
case Message { Type: MessageType.SendNack }:
|
||||
_writeStream.WriteByte((byte)'-');
|
||||
break;
|
||||
|
||||
case Message { Type: MessageType.Kill }:
|
||||
return;
|
||||
|
||||
case CommandMessage { Command: { } cmd }:
|
||||
Logger.Debug?.Print(LogClass.GdbStub, $"Received Command: {cmd}");
|
||||
_writeStream.WriteByte((byte)'+');
|
||||
_commands.Processor.Process(cmd);
|
||||
break;
|
||||
|
||||
case ThreadBreakMessage { Context: { } ctx }:
|
||||
DebugProcess.DebugStop();
|
||||
GThreadId = CThreadId = ctx.ThreadUid;
|
||||
_breakHandlerEvent.Set();
|
||||
_commands.Processor.Reply($"T05thread:{ctx.ThreadUid:x};");
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
Logger.Error?.Print(LogClass.GdbStub, "Error while processing GDB messages", e);
|
||||
}
|
||||
catch (NullReferenceException e)
|
||||
{
|
||||
Logger.Error?.Print(LogClass.GdbStub, "Error while processing GDB messages", e);
|
||||
}
|
||||
catch (ObjectDisposedException e)
|
||||
{
|
||||
Logger.Error?.Print(LogClass.GdbStub, "Error while processing GDB messages", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
94
src/Ryujinx.HLE/Debugger/Debugger.Rcmd.cs
Normal file
94
src/Ryujinx.HLE/Debugger/Debugger.Rcmd.cs
Normal file
@@ -0,0 +1,94 @@
|
||||
using Gommon;
|
||||
using JetBrains.Annotations;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.HLE.HOS.Kernel.Process;
|
||||
using Ryujinx.HLE.HOS.Kernel.Threading;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Ryujinx.HLE.Debugger
|
||||
{
|
||||
public partial class Debugger
|
||||
{
|
||||
static Debugger()
|
||||
{
|
||||
_rcmdDelegates.Add(["help"],
|
||||
_ => _rcmdDelegates.Keys
|
||||
.Where(x => !x[0].Equals("help"))
|
||||
.Select(x => x.JoinToString('\n'))
|
||||
.JoinToString('\n') + '\n'
|
||||
);
|
||||
_rcmdDelegates.Add(["get info"], dbgr => dbgr.GetProcessInfo());
|
||||
_rcmdDelegates.Add(["backtrace", "bt"], dbgr => dbgr.GetStackTrace());
|
||||
_rcmdDelegates.Add(["registers", "reg"], dbgr => dbgr.GetRegisters());
|
||||
_rcmdDelegates.Add(["minidump"], dbgr => dbgr.GetMinidump());
|
||||
}
|
||||
|
||||
private static readonly Dictionary<string[], Func<Debugger, string>> _rcmdDelegates = new();
|
||||
|
||||
public static Func<Debugger, string> FindRcmdDelegate(string command)
|
||||
{
|
||||
Func<Debugger, string> searchResult = _ => $"Unknown command: {command}\n";
|
||||
|
||||
foreach ((string[] names, Func<Debugger, string> dlg) in _rcmdDelegates)
|
||||
{
|
||||
if (names.ContainsIgnoreCase(command.Trim()))
|
||||
{
|
||||
searchResult = dlg;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return searchResult;
|
||||
}
|
||||
|
||||
public string GetStackTrace()
|
||||
{
|
||||
if (GThreadId == null)
|
||||
return "No thread selected\n";
|
||||
|
||||
return Process?.Debugger?.GetGuestStackTrace(DebugProcess.GetThread(GThreadId.Value)) ?? "No application process found\n";
|
||||
}
|
||||
|
||||
public string GetRegisters()
|
||||
{
|
||||
if (GThreadId == null)
|
||||
return "No thread selected\n";
|
||||
|
||||
return Process?.Debugger?.GetCpuRegisterPrintout(DebugProcess.GetThread(GThreadId.Value)) ?? "No application process found\n";
|
||||
}
|
||||
|
||||
public string GetMinidump()
|
||||
{
|
||||
if (Process is not { } kProcess)
|
||||
return "No application process found\n";
|
||||
|
||||
if (kProcess.Debugger is not { } debugger)
|
||||
return "Error getting minidump: debugger is null\n";
|
||||
|
||||
string response = debugger.GetMinidump();
|
||||
|
||||
Logger.Info?.Print(LogClass.GdbStub, response);
|
||||
return response;
|
||||
}
|
||||
|
||||
public string GetProcessInfo()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Process is not { } kProcess)
|
||||
return "No application process found\n";
|
||||
|
||||
return kProcess.Debugger?.GetProcessInfoPrintout()
|
||||
?? "Error getting process info: debugger is null\n";
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Error?.Print(LogClass.GdbStub, $"Error getting process info: {e.Message}");
|
||||
return $"Error getting process info: {e.Message}\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
415
src/Ryujinx.HLE/Debugger/Gdb/CommandProcessor.cs
Normal file
415
src/Ryujinx.HLE/Debugger/Gdb/CommandProcessor.cs
Normal file
@@ -0,0 +1,415 @@
|
||||
using Gommon;
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.HLE.HOS.Kernel.Threading;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Ryujinx.HLE.Debugger.Gdb
|
||||
{
|
||||
class GdbCommandProcessor
|
||||
{
|
||||
public readonly GdbCommands Commands;
|
||||
|
||||
private Debugger Debugger => Commands.Debugger;
|
||||
private BreakpointManager BreakpointManager => Commands.Debugger.BreakpointManager;
|
||||
private IDebuggableProcess DebugProcess => Commands.Debugger.DebugProcess;
|
||||
|
||||
public GdbCommandProcessor(GdbCommands commands)
|
||||
{
|
||||
Commands = commands;
|
||||
}
|
||||
|
||||
public void ReplyHex(string data) => Reply(Helpers.ToHex(data));
|
||||
public void ReplyHex(byte[] data) => Reply(Helpers.ToHex(data));
|
||||
|
||||
public void Reply(string cmd)
|
||||
{
|
||||
Logger.Debug?.Print(LogClass.GdbStub, $"Reply: {cmd}");
|
||||
Commands.WriteStream.Write(Encoding.ASCII.GetBytes($"${cmd}#{Helpers.CalculateChecksum(cmd):x2}"));
|
||||
}
|
||||
|
||||
public void ReplyOK() => Reply("OK");
|
||||
|
||||
public void ReplyError() => Reply("E01");
|
||||
|
||||
public void Reply(bool success)
|
||||
{
|
||||
if (success)
|
||||
ReplyOK();
|
||||
else ReplyError();
|
||||
}
|
||||
|
||||
public void Reply(bool success, string cmd)
|
||||
{
|
||||
if (success)
|
||||
Reply(cmd);
|
||||
else ReplyError();
|
||||
}
|
||||
|
||||
private string _previousThreadListXml = string.Empty;
|
||||
|
||||
public void Process(string cmd)
|
||||
{
|
||||
StringStream ss = new(cmd);
|
||||
|
||||
switch (ss.ReadChar())
|
||||
{
|
||||
case '!':
|
||||
if (!ss.IsEmpty)
|
||||
{
|
||||
goto unknownCommand;
|
||||
}
|
||||
|
||||
// Enable extended mode
|
||||
ReplyOK();
|
||||
break;
|
||||
case '?':
|
||||
if (!ss.IsEmpty)
|
||||
{
|
||||
goto unknownCommand;
|
||||
}
|
||||
|
||||
Commands.Query();
|
||||
break;
|
||||
case 'c':
|
||||
Commands.Continue(ss.IsEmpty ? null : ss.ReadRemainingAsHex());
|
||||
break;
|
||||
case 'D':
|
||||
if (!ss.IsEmpty)
|
||||
{
|
||||
goto unknownCommand;
|
||||
}
|
||||
|
||||
Commands.Detach();
|
||||
break;
|
||||
case 'g':
|
||||
if (!ss.IsEmpty)
|
||||
{
|
||||
goto unknownCommand;
|
||||
}
|
||||
|
||||
Commands.ReadRegisters();
|
||||
break;
|
||||
case 'G':
|
||||
Commands.WriteRegisters(ss);
|
||||
break;
|
||||
case 'H':
|
||||
{
|
||||
char op = ss.ReadChar();
|
||||
ulong? threadId = ss.ReadRemainingAsThreadUid();
|
||||
Commands.SetThread(op, threadId);
|
||||
break;
|
||||
}
|
||||
case 'k':
|
||||
Logger.Notice.Print(LogClass.GdbStub, "Kill request received, detach instead");
|
||||
Reply(string.Empty);
|
||||
Commands.Detach();
|
||||
break;
|
||||
case 'm':
|
||||
{
|
||||
ulong addr = ss.ReadUntilAsHex(',');
|
||||
ulong len = ss.ReadRemainingAsHex();
|
||||
Commands.ReadMemory(addr, len);
|
||||
break;
|
||||
}
|
||||
case 'M':
|
||||
{
|
||||
ulong addr = ss.ReadUntilAsHex(',');
|
||||
ulong len = ss.ReadUntilAsHex(':');
|
||||
Commands.WriteMemory(addr, len, ss);
|
||||
break;
|
||||
}
|
||||
case 'p':
|
||||
{
|
||||
ulong gdbRegId = ss.ReadRemainingAsHex();
|
||||
Commands.ReadRegister((int)gdbRegId);
|
||||
break;
|
||||
}
|
||||
case 'P':
|
||||
{
|
||||
ulong gdbRegId = ss.ReadUntilAsHex('=');
|
||||
Commands.WriteRegister((int)gdbRegId, ss);
|
||||
break;
|
||||
}
|
||||
case 'q':
|
||||
if (ss.ConsumeRemaining("GDBServerVersion"))
|
||||
{
|
||||
Reply($"name:Ryujinx;version:{ReleaseInformation.Version};");
|
||||
break;
|
||||
}
|
||||
|
||||
if (ss.ConsumeRemaining("HostInfo"))
|
||||
{
|
||||
Reply(
|
||||
Debugger.IsProcess32Bit
|
||||
? $"triple:{Helpers.ToHex("arm-unknown-linux-android")};endian:little;ptrsize:4;hostname:{Helpers.ToHex("Ryujinx")};"
|
||||
: $"triple:{Helpers.ToHex("aarch64-unknown-linux-android")};endian:little;ptrsize:8;hostname:{Helpers.ToHex("Ryujinx")};");
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (ss.ConsumeRemaining("Attached"))
|
||||
{
|
||||
Reply("1");
|
||||
break;
|
||||
}
|
||||
|
||||
if (ss.ConsumeRemaining("ProcessInfo"))
|
||||
{
|
||||
Reply(
|
||||
Debugger.IsProcess32Bit
|
||||
? $"pid:1;cputype:12;cpusubtype:0;triple:{Helpers.ToHex("arm-unknown-linux-android")};ostype:unknown;vendor:none;endian:little;ptrsize:4;"
|
||||
: $"pid:1;cputype:100000c;cpusubtype:0;triple:{Helpers.ToHex("aarch64-unknown-linux-android")};ostype:unknown;vendor:none;endian:little;ptrsize:8;");
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (ss.ConsumePrefix("Supported:") || ss.ConsumeRemaining("Supported"))
|
||||
{
|
||||
Reply("PacketSize=10000;qXfer:features:read+;qXfer:threads:read+;vContSupported+");
|
||||
break;
|
||||
}
|
||||
|
||||
if (ss.ConsumePrefix("Rcmd,"))
|
||||
{
|
||||
string hexCommand = ss.ReadRemaining();
|
||||
Commands.Q_Rcmd(hexCommand);
|
||||
break;
|
||||
}
|
||||
|
||||
if (ss.ConsumeRemaining("fThreadInfo"))
|
||||
{
|
||||
Reply(
|
||||
$"m{DebugProcess.ThreadUids.Select(x => $"{x:x}").JoinToString(",")}");
|
||||
break;
|
||||
}
|
||||
|
||||
if (ss.ConsumeRemaining("sThreadInfo"))
|
||||
{
|
||||
Reply("l");
|
||||
break;
|
||||
}
|
||||
|
||||
if (ss.ConsumePrefix("ThreadExtraInfo,"))
|
||||
{
|
||||
ulong? threadId = ss.ReadRemainingAsThreadUid();
|
||||
if (threadId == null)
|
||||
{
|
||||
ReplyError();
|
||||
break;
|
||||
}
|
||||
|
||||
ReplyHex(
|
||||
DebugProcess.IsThreadPaused(DebugProcess.GetThread(threadId.Value))
|
||||
? "Paused"
|
||||
: "Running"
|
||||
);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (ss.ConsumePrefix("Xfer:threads:read:"))
|
||||
{
|
||||
ss.ReadUntil(':');
|
||||
ulong offset = ss.ReadUntilAsHex(',');
|
||||
ulong len = ss.ReadRemainingAsHex();
|
||||
|
||||
string data;
|
||||
if (offset > 0)
|
||||
{
|
||||
data = _previousThreadListXml;
|
||||
}
|
||||
else
|
||||
{
|
||||
_previousThreadListXml = data = GetThreadListXml();
|
||||
}
|
||||
|
||||
if (offset >= (ulong)data.Length)
|
||||
{
|
||||
Reply("l");
|
||||
break;
|
||||
}
|
||||
|
||||
if (len >= (ulong)data.Length - offset)
|
||||
{
|
||||
Reply("l" + Helpers.ToBinaryFormat(data[(int)offset..]));
|
||||
}
|
||||
else
|
||||
{
|
||||
Reply("m" + Helpers.ToBinaryFormat(data.Substring((int)offset, (int)len)));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (ss.ConsumePrefix("Xfer:features:read:"))
|
||||
{
|
||||
string feature = ss.ReadUntil(':');
|
||||
ulong offset = ss.ReadUntilAsHex(',');
|
||||
ulong len = ss.ReadRemainingAsHex();
|
||||
|
||||
if (feature == "target.xml")
|
||||
{
|
||||
feature = Debugger.IsProcess32Bit ? "target32.xml" : "target64.xml";
|
||||
}
|
||||
|
||||
if (!RegisterInformation.Features.TryGetValue(feature, out string data))
|
||||
{
|
||||
Reply("E00"); // Invalid annex
|
||||
break;
|
||||
}
|
||||
|
||||
if (offset >= (ulong)data.Length)
|
||||
{
|
||||
Reply("l");
|
||||
break;
|
||||
}
|
||||
|
||||
if (len >= (ulong)data.Length - offset)
|
||||
{
|
||||
Reply("l" + Helpers.ToBinaryFormat(data[(int)offset..]));
|
||||
}
|
||||
else
|
||||
{
|
||||
Reply("m" + Helpers.ToBinaryFormat(data.Substring((int)offset, (int)len)));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
goto unknownCommand;
|
||||
case 'Q':
|
||||
goto unknownCommand;
|
||||
case 's':
|
||||
Commands.Step(ss.IsEmpty ? null : ss.ReadRemainingAsHex());
|
||||
break;
|
||||
case 'T':
|
||||
{
|
||||
ulong? threadId = ss.ReadRemainingAsThreadUid();
|
||||
Commands.IsAlive(threadId);
|
||||
break;
|
||||
}
|
||||
case 'v':
|
||||
if (ss.ConsumePrefix("Cont"))
|
||||
{
|
||||
if (ss.ConsumeRemaining("?"))
|
||||
{
|
||||
Reply("vCont;c;C;s;S");
|
||||
break;
|
||||
}
|
||||
|
||||
if (ss.ConsumePrefix(";"))
|
||||
{
|
||||
Commands.VCont(ss);
|
||||
break;
|
||||
}
|
||||
|
||||
goto unknownCommand;
|
||||
}
|
||||
|
||||
if (ss.ConsumeRemaining("MustReplyEmpty"))
|
||||
{
|
||||
Reply(string.Empty);
|
||||
break;
|
||||
}
|
||||
|
||||
goto unknownCommand;
|
||||
case 'Z':
|
||||
{
|
||||
string type = ss.ReadUntil(',');
|
||||
ulong addr = ss.ReadUntilAsHex(',');
|
||||
ulong len = ss.ReadLengthAsHex(1);
|
||||
string extra = ss.ReadRemaining();
|
||||
|
||||
if (extra.Length > 0)
|
||||
{
|
||||
Logger.Notice.Print(LogClass.GdbStub, $"Unsupported Z command extra data: {extra}");
|
||||
ReplyError();
|
||||
return;
|
||||
}
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case "0": // Software breakpoint
|
||||
if (!BreakpointManager.SetBreakPoint(addr, len))
|
||||
{
|
||||
ReplyError();
|
||||
return;
|
||||
}
|
||||
|
||||
ReplyOK();
|
||||
return;
|
||||
// ReSharper disable RedundantCaseLabel
|
||||
case "1": // Hardware breakpoint
|
||||
case "2": // Write watchpoint
|
||||
case "3": // Read watchpoint
|
||||
case "4": // Access watchpoint
|
||||
// ReSharper restore RedundantCaseLabel
|
||||
default:
|
||||
ReplyError();
|
||||
return;
|
||||
}
|
||||
}
|
||||
case 'z':
|
||||
{
|
||||
string type = ss.ReadUntil(',');
|
||||
ss.ConsumePrefix(",");
|
||||
ulong addr = ss.ReadUntilAsHex(',');
|
||||
ulong len = ss.ReadLengthAsHex(1);
|
||||
string extra = ss.ReadRemaining();
|
||||
|
||||
if (extra.Length > 0)
|
||||
{
|
||||
Logger.Notice.Print(LogClass.GdbStub, $"Unsupported z command extra data: {extra}");
|
||||
ReplyError();
|
||||
return;
|
||||
}
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case "0": // Software breakpoint
|
||||
if (!BreakpointManager.ClearBreakPoint(addr, len))
|
||||
{
|
||||
ReplyError();
|
||||
return;
|
||||
}
|
||||
|
||||
ReplyOK();
|
||||
return;
|
||||
// ReSharper disable RedundantCaseLabel
|
||||
case "1": // Hardware breakpoint
|
||||
case "2": // Write watchpoint
|
||||
case "3": // Read watchpoint
|
||||
case "4": // Access watchpoint
|
||||
// ReSharper restore RedundantCaseLabel
|
||||
default:
|
||||
ReplyError();
|
||||
return;
|
||||
}
|
||||
}
|
||||
default:
|
||||
unknownCommand:
|
||||
Logger.Notice.Print(LogClass.GdbStub, $"Unknown command: {cmd}");
|
||||
Reply(string.Empty);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private string GetThreadListXml()
|
||||
{
|
||||
StringBuilder sb = new();
|
||||
sb.Append("<?xml version=\"1.0\"?><threads>\n");
|
||||
|
||||
foreach (KThread thread in Debugger.GetThreads())
|
||||
{
|
||||
string threadName = System.Security.SecurityElement.Escape(thread.GetThreadName());
|
||||
sb.Append(
|
||||
$"<thread id=\"{thread.ThreadUid:x}\" name=\"{threadName}\">{(DebugProcess.IsThreadPaused(thread) ? "Paused" : "Running")}</thread>\n");
|
||||
}
|
||||
|
||||
sb.Append("</threads>");
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
418
src/Ryujinx.HLE/Debugger/Gdb/Commands.cs
Normal file
418
src/Ryujinx.HLE/Debugger/Gdb/Commands.cs
Normal file
@@ -0,0 +1,418 @@
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Cpu;
|
||||
using Ryujinx.HLE.HOS.Kernel.Threading;
|
||||
using Ryujinx.Memory;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Sockets;
|
||||
|
||||
namespace Ryujinx.HLE.Debugger.Gdb
|
||||
{
|
||||
class GdbCommands
|
||||
{
|
||||
public readonly Debugger Debugger;
|
||||
|
||||
private GdbCommandProcessor _processor;
|
||||
|
||||
public GdbCommandProcessor Processor
|
||||
=> _processor ??= new GdbCommandProcessor(this);
|
||||
|
||||
internal readonly TcpListener ListenerSocket;
|
||||
internal readonly Socket ClientSocket;
|
||||
internal readonly NetworkStream ReadStream;
|
||||
internal readonly NetworkStream WriteStream;
|
||||
|
||||
public GdbCommands(TcpListener listenerSocket, Socket clientSocket, NetworkStream readStream,
|
||||
NetworkStream writeStream, Debugger debugger)
|
||||
{
|
||||
ListenerSocket = listenerSocket;
|
||||
ClientSocket = clientSocket;
|
||||
ReadStream = readStream;
|
||||
WriteStream = writeStream;
|
||||
Debugger = debugger;
|
||||
}
|
||||
|
||||
internal void Query()
|
||||
{
|
||||
// GDB is performing initial contact. Stop everything.
|
||||
Debugger.DebugProcess.DebugStop();
|
||||
Debugger.GThreadId = Debugger.CThreadId = Debugger.DebugProcess.ThreadUids.First();
|
||||
Processor.Reply($"T05thread:{Debugger.CThreadId:x};");
|
||||
}
|
||||
|
||||
internal void Interrupt()
|
||||
{
|
||||
// GDB is requesting an interrupt. Stop everything.
|
||||
Debugger.DebugProcess.DebugStop();
|
||||
if (Debugger.GThreadId == null || Debugger.GetThreads().All(x => x.ThreadUid != Debugger.GThreadId.Value))
|
||||
{
|
||||
Debugger.GThreadId = Debugger.CThreadId = Debugger.DebugProcess.ThreadUids.First();
|
||||
}
|
||||
|
||||
Processor.Reply($"T02thread:{Debugger.GThreadId:x};");
|
||||
}
|
||||
|
||||
internal void Continue(ulong? newPc)
|
||||
{
|
||||
if (newPc.HasValue)
|
||||
{
|
||||
if (Debugger.CThreadId == null)
|
||||
{
|
||||
Processor.ReplyError();
|
||||
return;
|
||||
}
|
||||
|
||||
Debugger.CThread.Context.DebugPc = newPc.Value;
|
||||
}
|
||||
|
||||
Debugger.DebugProcess.DebugContinue();
|
||||
Processor.ReplyOK();
|
||||
}
|
||||
|
||||
internal void Detach()
|
||||
{
|
||||
Debugger.BreakpointManager.ClearAll();
|
||||
Continue(null); // Continue() will call ReplyError/ReplyOK for us.
|
||||
}
|
||||
|
||||
internal void ReadRegisters()
|
||||
{
|
||||
if (Debugger.GThreadId == null)
|
||||
{
|
||||
Processor.ReplyError();
|
||||
return;
|
||||
}
|
||||
|
||||
IExecutionContext ctx = Debugger.GThread.Context;
|
||||
string registers = string.Empty;
|
||||
if (Debugger.IsProcess32Bit)
|
||||
{
|
||||
for (int i = 0; i < GdbRegisters.Count32; i++)
|
||||
{
|
||||
registers += ctx.ReadRegister32(i);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < GdbRegisters.Count64; i++)
|
||||
{
|
||||
registers += ctx.ReadRegister64(i);
|
||||
}
|
||||
}
|
||||
|
||||
Processor.Reply(registers);
|
||||
}
|
||||
|
||||
internal void WriteRegisters(StringStream ss)
|
||||
{
|
||||
if (Debugger.GThreadId == null)
|
||||
{
|
||||
Processor.ReplyError();
|
||||
return;
|
||||
}
|
||||
|
||||
IExecutionContext ctx = Debugger.GThread.Context;
|
||||
if (Debugger.IsProcess32Bit)
|
||||
{
|
||||
for (int i = 0; i < GdbRegisters.Count32; i++)
|
||||
{
|
||||
if (!ctx.WriteRegister32(i, ss))
|
||||
{
|
||||
Processor.ReplyError();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < GdbRegisters.Count64; i++)
|
||||
{
|
||||
if (!ctx.WriteRegister64(i, ss))
|
||||
{
|
||||
Processor.ReplyError();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Processor.Reply(ss.IsEmpty);
|
||||
}
|
||||
|
||||
internal void SetThread(char op, ulong? threadId)
|
||||
{
|
||||
if (threadId is 0 or null)
|
||||
{
|
||||
KThread[] threads = Debugger.GetThreads();
|
||||
if (threads.Length == 0)
|
||||
{
|
||||
Processor.ReplyError();
|
||||
return;
|
||||
}
|
||||
|
||||
threadId = threads.First().ThreadUid;
|
||||
}
|
||||
|
||||
if (Debugger.DebugProcess.GetThread(threadId.Value) == null)
|
||||
{
|
||||
Processor.ReplyError();
|
||||
return;
|
||||
}
|
||||
|
||||
switch (op)
|
||||
{
|
||||
case 'c':
|
||||
Debugger.CThreadId = threadId;
|
||||
Processor.ReplyOK();
|
||||
return;
|
||||
case 'g':
|
||||
Debugger.GThreadId = threadId;
|
||||
Processor.ReplyOK();
|
||||
return;
|
||||
default:
|
||||
Processor.ReplyError();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
internal void ReadMemory(ulong addr, ulong len)
|
||||
{
|
||||
try
|
||||
{
|
||||
byte[] data = new byte[len];
|
||||
Debugger.DebugProcess.CpuMemory.Read(addr, data);
|
||||
Processor.ReplyHex(data);
|
||||
}
|
||||
catch (InvalidMemoryRegionException)
|
||||
{
|
||||
// InvalidAccessHandler will show an error message, we log it again to tell user the error is from GDB (which can be ignored)
|
||||
// TODO: Do not let InvalidAccessHandler show the error message
|
||||
Logger.Notice.Print(LogClass.GdbStub, $"GDB failed to read memory at 0x{addr:X16}");
|
||||
Processor.ReplyError();
|
||||
}
|
||||
}
|
||||
|
||||
internal void WriteMemory(ulong addr, ulong len, StringStream ss)
|
||||
{
|
||||
try
|
||||
{
|
||||
byte[] data = new byte[len];
|
||||
for (ulong i = 0; i < len; i++)
|
||||
{
|
||||
data[i] = (byte)ss.ReadLengthAsHex(2);
|
||||
}
|
||||
|
||||
Debugger.DebugProcess.CpuMemory.Write(addr, data);
|
||||
Debugger.DebugProcess.InvalidateCacheRegion(addr, len);
|
||||
Processor.ReplyOK();
|
||||
}
|
||||
catch (InvalidMemoryRegionException)
|
||||
{
|
||||
Processor.ReplyError();
|
||||
}
|
||||
}
|
||||
|
||||
internal void ReadRegister(int gdbRegId)
|
||||
{
|
||||
if (Debugger.GThreadId == null)
|
||||
{
|
||||
Processor.ReplyError();
|
||||
return;
|
||||
}
|
||||
|
||||
IExecutionContext ctx = Debugger.GThread.Context;
|
||||
string result = Debugger.ReadRegister(ctx, gdbRegId);
|
||||
|
||||
Processor.Reply(result != null, result);
|
||||
}
|
||||
|
||||
internal void WriteRegister(int gdbRegId, StringStream ss)
|
||||
{
|
||||
if (Debugger.GThreadId == null)
|
||||
{
|
||||
Processor.ReplyError();
|
||||
return;
|
||||
}
|
||||
|
||||
Processor.Reply(
|
||||
success: Debugger.WriteRegister(Debugger.GThread.Context, gdbRegId, ss) && ss.IsEmpty
|
||||
);
|
||||
}
|
||||
|
||||
internal void Step(ulong? newPc)
|
||||
{
|
||||
if (Debugger.CThreadId == null)
|
||||
{
|
||||
Processor.ReplyError();
|
||||
return;
|
||||
}
|
||||
|
||||
KThread thread = Debugger.CThread;
|
||||
|
||||
if (newPc.HasValue)
|
||||
{
|
||||
thread.Context.DebugPc = newPc.Value;
|
||||
}
|
||||
|
||||
if (!Debugger.DebugProcess.DebugStep(thread))
|
||||
{
|
||||
Processor.ReplyError();
|
||||
}
|
||||
else
|
||||
{
|
||||
Debugger.GThreadId = Debugger.CThreadId = thread.ThreadUid;
|
||||
Processor.Reply($"T05thread:{thread.ThreadUid:x};");
|
||||
}
|
||||
}
|
||||
|
||||
internal void IsAlive(ulong? threadId)
|
||||
{
|
||||
if (Debugger.GetThreads().Any(x => x.ThreadUid == threadId))
|
||||
{
|
||||
Processor.ReplyOK();
|
||||
}
|
||||
else
|
||||
{
|
||||
Processor.Reply("E00");
|
||||
}
|
||||
}
|
||||
|
||||
enum VContAction
|
||||
{
|
||||
None,
|
||||
Continue,
|
||||
Stop,
|
||||
Step
|
||||
}
|
||||
|
||||
record VContPendingAction(VContAction Action/*, ushort? Signal = null*/);
|
||||
|
||||
internal void VCont(StringStream ss)
|
||||
{
|
||||
string[] rawActions = ss.ReadRemaining().Split(';', StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
Dictionary<ulong, VContPendingAction> threadActionMap = new();
|
||||
foreach (KThread thread in Debugger.GetThreads())
|
||||
{
|
||||
threadActionMap[thread.ThreadUid] = new VContPendingAction(VContAction.None);
|
||||
}
|
||||
|
||||
VContAction defaultAction = VContAction.None;
|
||||
|
||||
// For each inferior thread, the *leftmost* action with a matching thread-id is applied.
|
||||
for (int i = rawActions.Length - 1; i >= 0; i--)
|
||||
{
|
||||
string rawAction = rawActions[i];
|
||||
StringStream stream = new(rawAction);
|
||||
|
||||
char cmd = stream.ReadChar();
|
||||
VContAction action = cmd switch
|
||||
{
|
||||
'c' or 'C' => VContAction.Continue,
|
||||
's' or 'S' => VContAction.Step,
|
||||
't' => VContAction.Stop,
|
||||
_ => VContAction.None
|
||||
};
|
||||
|
||||
// TODO: Note: We don't support signals yet.
|
||||
//ushort? signal = null;
|
||||
if (cmd is 'C' or 'S')
|
||||
{
|
||||
/*signal = (ushort)*/stream.ReadLengthAsHex(2);
|
||||
// we still call the read length method even if we have signals commented
|
||||
// since that method advances the underlying string position
|
||||
}
|
||||
|
||||
ulong? threadId = stream.ConsumePrefix(":")
|
||||
? stream.ReadRemainingAsThreadUid()
|
||||
: null;
|
||||
|
||||
if (threadId.HasValue)
|
||||
{
|
||||
if (threadActionMap.ContainsKey(threadId.Value))
|
||||
{
|
||||
threadActionMap[threadId.Value] = new VContPendingAction(action /*, signal*/);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (ulong thread in threadActionMap.Keys)
|
||||
{
|
||||
threadActionMap[thread] = new VContPendingAction(action /*, signal*/);
|
||||
}
|
||||
|
||||
if (action == VContAction.Continue)
|
||||
{
|
||||
defaultAction = action;
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.GdbStub,
|
||||
$"Received vCont command with unsupported default action: {rawAction}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool hasError = false;
|
||||
|
||||
foreach ((ulong threadUid, VContPendingAction action) in threadActionMap)
|
||||
{
|
||||
if (action.Action == VContAction.Step)
|
||||
{
|
||||
KThread thread = Debugger.DebugProcess.GetThread(threadUid);
|
||||
if (!Debugger.DebugProcess.DebugStep(thread))
|
||||
{
|
||||
hasError = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If we receive "vCont;c", just continue the process.
|
||||
// If we receive something like "vCont;c:2e;c:2f" (IDA Pro will send commands like this), continue these threads.
|
||||
// For "vCont;s:2f;c", `DebugProcess.DebugStep()` will continue and suspend other threads if needed, so we don't do anything here.
|
||||
if (threadActionMap.Values.All(a => a.Action == VContAction.Continue))
|
||||
{
|
||||
Debugger.DebugProcess.DebugContinue();
|
||||
}
|
||||
else if (defaultAction == VContAction.None)
|
||||
{
|
||||
foreach ((ulong threadUid, VContPendingAction action) in threadActionMap)
|
||||
{
|
||||
if (action.Action == VContAction.Continue)
|
||||
{
|
||||
Debugger.DebugProcess.DebugContinue(Debugger.DebugProcess.GetThread(threadUid));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Processor.Reply(!hasError);
|
||||
|
||||
foreach ((ulong threadUid, VContPendingAction action) in threadActionMap)
|
||||
{
|
||||
if (action.Action == VContAction.Step)
|
||||
{
|
||||
Debugger.GThreadId = Debugger.CThreadId = threadUid;
|
||||
Processor.Reply($"T05thread:{threadUid:x};");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal void Q_Rcmd(string hexCommand)
|
||||
{
|
||||
try
|
||||
{
|
||||
string command = Helpers.FromHex(hexCommand);
|
||||
Logger.Debug?.Print(LogClass.GdbStub, $"Received Rcmd: {command}");
|
||||
|
||||
Func<Debugger, string> rcmd = Debugger.FindRcmdDelegate(command);
|
||||
|
||||
Processor.ReplyHex(rcmd(Debugger));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Error?.Print(LogClass.GdbStub, $"Error processing Rcmd: {e.Message}");
|
||||
Processor.ReplyError();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
161
src/Ryujinx.HLE/Debugger/Gdb/Registers.cs
Normal file
161
src/Ryujinx.HLE/Debugger/Gdb/Registers.cs
Normal file
@@ -0,0 +1,161 @@
|
||||
using ARMeilleure.State;
|
||||
using Ryujinx.Cpu;
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.HLE.Debugger.Gdb
|
||||
{
|
||||
static class GdbRegisters
|
||||
{
|
||||
public const int Count64 = 68;
|
||||
public const int Count32 = 66;
|
||||
|
||||
/*
|
||||
FPCR = FPSR & ~FpcrMask
|
||||
All of FPCR's bits are reserved in FPCR and vice versa,
|
||||
see ARM's documentation.
|
||||
*/
|
||||
private const uint FpcrMask = 0xfc1fffff;
|
||||
|
||||
#region 64-bit
|
||||
|
||||
public static string ReadRegister64(this IExecutionContext state, int registerId) =>
|
||||
registerId switch
|
||||
{
|
||||
>= 0 and <= 31 => Helpers.ToHex(BitConverter.GetBytes(state.GetX(registerId))),
|
||||
32 => Helpers.ToHex(BitConverter.GetBytes(state.DebugPc)),
|
||||
33 => Helpers.ToHex(BitConverter.GetBytes(state.Pstate)),
|
||||
>= 34 and <= 65 => Helpers.ToHex(state.GetV(registerId - 34).ToArray()),
|
||||
66 => Helpers.ToHex(BitConverter.GetBytes(state.Fpsr)),
|
||||
67 => Helpers.ToHex(BitConverter.GetBytes(state.Fpcr)),
|
||||
_ => null
|
||||
};
|
||||
|
||||
public static bool WriteRegister64(this IExecutionContext state, int registerId, StringStream ss)
|
||||
{
|
||||
switch (registerId)
|
||||
{
|
||||
case >= 0 and <= 31:
|
||||
{
|
||||
ulong value = ss.ReadLengthAsLittleEndianHex(16);
|
||||
state.SetX(registerId, value);
|
||||
return true;
|
||||
}
|
||||
case 32:
|
||||
{
|
||||
ulong value = ss.ReadLengthAsLittleEndianHex(16);
|
||||
state.DebugPc = value;
|
||||
return true;
|
||||
}
|
||||
case 33:
|
||||
{
|
||||
ulong value = ss.ReadLengthAsLittleEndianHex(8);
|
||||
state.Pstate = (uint)value;
|
||||
return true;
|
||||
}
|
||||
case >= 34 and <= 65:
|
||||
{
|
||||
ulong value0 = ss.ReadLengthAsLittleEndianHex(16);
|
||||
ulong value1 = ss.ReadLengthAsLittleEndianHex(16);
|
||||
state.SetV(registerId - 34, new V128(value0, value1));
|
||||
return true;
|
||||
}
|
||||
case 66:
|
||||
{
|
||||
ulong value = ss.ReadLengthAsLittleEndianHex(8);
|
||||
state.Fpsr = (uint)value;
|
||||
return true;
|
||||
}
|
||||
case 67:
|
||||
{
|
||||
ulong value = ss.ReadLengthAsLittleEndianHex(8);
|
||||
state.Fpcr = (uint)value;
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 32-bit
|
||||
|
||||
public static string ReadRegister32(this IExecutionContext state, int registerId)
|
||||
{
|
||||
switch (registerId)
|
||||
{
|
||||
case >= 0 and <= 14:
|
||||
return Helpers.ToHex(BitConverter.GetBytes((uint)state.GetX(registerId)));
|
||||
case 15:
|
||||
return Helpers.ToHex(BitConverter.GetBytes((uint)state.DebugPc));
|
||||
case 16:
|
||||
return Helpers.ToHex(BitConverter.GetBytes(state.Pstate));
|
||||
case >= 17 and <= 32:
|
||||
return Helpers.ToHex(state.GetV(registerId - 17).ToArray());
|
||||
case >= 33 and <= 64:
|
||||
int reg = (registerId - 33);
|
||||
int n = reg / 2;
|
||||
int shift = reg % 2;
|
||||
ulong value = state.GetV(n).Extract<ulong>(shift);
|
||||
return Helpers.ToHex(BitConverter.GetBytes(value));
|
||||
case 65:
|
||||
return Helpers.ToHex(BitConverter.GetBytes(state.Fpscr));
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool WriteRegister32(this IExecutionContext state, int registerId, StringStream ss)
|
||||
{
|
||||
switch (registerId)
|
||||
{
|
||||
case >= 0 and <= 14:
|
||||
{
|
||||
ulong value = ss.ReadLengthAsLittleEndianHex(8);
|
||||
state.SetX(registerId, value);
|
||||
return true;
|
||||
}
|
||||
case 15:
|
||||
{
|
||||
ulong value = ss.ReadLengthAsLittleEndianHex(8);
|
||||
state.DebugPc = value;
|
||||
return true;
|
||||
}
|
||||
case 16:
|
||||
{
|
||||
ulong value = ss.ReadLengthAsLittleEndianHex(8);
|
||||
state.Pstate = (uint)value;
|
||||
return true;
|
||||
}
|
||||
case >= 17 and <= 32:
|
||||
{
|
||||
ulong value0 = ss.ReadLengthAsLittleEndianHex(16);
|
||||
ulong value1 = ss.ReadLengthAsLittleEndianHex(16);
|
||||
state.SetV(registerId - 17, new V128(value0, value1));
|
||||
return true;
|
||||
}
|
||||
case >= 33 and <= 64:
|
||||
{
|
||||
ulong value = ss.ReadLengthAsLittleEndianHex(16);
|
||||
int regId = (registerId - 33);
|
||||
int regNum = regId / 2;
|
||||
int shift = regId % 2;
|
||||
V128 reg = state.GetV(regNum);
|
||||
reg.Insert(shift, value);
|
||||
return true;
|
||||
}
|
||||
case 65:
|
||||
{
|
||||
ulong value = ss.ReadLengthAsLittleEndianHex(8);
|
||||
state.Fpsr = (uint)value & FpcrMask;
|
||||
state.Fpcr = (uint)value & ~FpcrMask;
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
50
src/Ryujinx.HLE/Debugger/Helpers.cs
Normal file
50
src/Ryujinx.HLE/Debugger/Helpers.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using Gommon;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Ryujinx.HLE.Debugger
|
||||
{
|
||||
public static class Helpers
|
||||
{
|
||||
public static byte CalculateChecksum(string cmd)
|
||||
{
|
||||
byte checksum = 0;
|
||||
foreach (char x in cmd)
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
checksum += (byte)x;
|
||||
}
|
||||
}
|
||||
|
||||
return checksum;
|
||||
}
|
||||
|
||||
public static string FromHex(string hexString)
|
||||
{
|
||||
if (string.IsNullOrEmpty(hexString))
|
||||
return string.Empty;
|
||||
|
||||
byte[] bytes = Convert.FromHexString(hexString);
|
||||
return Encoding.ASCII.GetString(bytes);
|
||||
}
|
||||
|
||||
public static string ToHex(byte[] bytes) => string.Join("", bytes.Select(x => $"{x:x2}"));
|
||||
|
||||
public static string ToHex(string str) => ToHex(Encoding.ASCII.GetBytes(str));
|
||||
|
||||
public static string ToBinaryFormat(string str) => ToBinaryFormat(Encoding.ASCII.GetBytes(str));
|
||||
public static string ToBinaryFormat(byte[] bytes) =>
|
||||
bytes.Select(x =>
|
||||
x switch
|
||||
{
|
||||
(byte)'#' => "}\x03",
|
||||
(byte)'$' => "}\x04",
|
||||
(byte)'*' => "}\x0a",
|
||||
(byte)'}' => "}\x5d",
|
||||
_ => Convert.ToChar(x).ToString()
|
||||
}
|
||||
).JoinToString(string.Empty);
|
||||
}
|
||||
}
|
||||
@@ -6,16 +6,17 @@ namespace Ryujinx.HLE.Debugger
|
||||
{
|
||||
internal interface IDebuggableProcess
|
||||
{
|
||||
IVirtualMemoryManager CpuMemory { get; }
|
||||
ulong[] ThreadUids { get; }
|
||||
DebugState DebugState { get; }
|
||||
|
||||
void DebugStop();
|
||||
void DebugContinue();
|
||||
void DebugContinue(KThread thread);
|
||||
bool DebugStep(KThread thread);
|
||||
KThread GetThread(ulong threadUid);
|
||||
DebugState GetDebugState();
|
||||
bool IsThreadPaused(KThread thread);
|
||||
ulong[] GetThreadUids();
|
||||
public void DebugInterruptHandler(IExecutionContext ctx);
|
||||
IVirtualMemoryManager CpuMemory { get; }
|
||||
void InvalidateCacheRegion(ulong address, ulong size);
|
||||
}
|
||||
}
|
||||
|
||||
45
src/Ryujinx.HLE/Debugger/Message.cs
Normal file
45
src/Ryujinx.HLE/Debugger/Message.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using Ryujinx.Cpu;
|
||||
|
||||
namespace Ryujinx.HLE.Debugger
|
||||
{
|
||||
public enum MessageType
|
||||
{
|
||||
Kill,
|
||||
BreakIn,
|
||||
SendNack
|
||||
}
|
||||
|
||||
record struct Message(MessageType Type) : Message.IMarker
|
||||
{
|
||||
/// <summary>
|
||||
/// Marker interface for debugger messages.
|
||||
/// </summary>
|
||||
internal interface IMarker;
|
||||
|
||||
public static Message Kill => new(MessageType.Kill);
|
||||
public static Message BreakIn => new(MessageType.BreakIn);
|
||||
public static Message SendNack => new(MessageType.SendNack);
|
||||
}
|
||||
|
||||
struct CommandMessage : Message.IMarker
|
||||
{
|
||||
public readonly string Command;
|
||||
|
||||
public CommandMessage(string cmd)
|
||||
=> Command = cmd;
|
||||
}
|
||||
|
||||
public class ThreadBreakMessage : Message.IMarker
|
||||
{
|
||||
public IExecutionContext Context { get; }
|
||||
public ulong Address { get; }
|
||||
public int Opcode { get; }
|
||||
|
||||
public ThreadBreakMessage(IExecutionContext context, ulong address, int opcode)
|
||||
{
|
||||
Context = context;
|
||||
Address = address;
|
||||
Opcode = opcode;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
namespace Ryujinx.HLE.Debugger
|
||||
{
|
||||
struct BreakInMessage : IMessage
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
namespace Ryujinx.HLE.Debugger
|
||||
{
|
||||
struct CommandMessage : IMessage
|
||||
{
|
||||
public string Command;
|
||||
|
||||
public CommandMessage(string cmd)
|
||||
{
|
||||
Command = cmd;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
namespace Ryujinx.HLE.Debugger
|
||||
{
|
||||
interface IMessage
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
namespace Ryujinx.HLE.Debugger
|
||||
{
|
||||
struct KillMessage : IMessage
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
namespace Ryujinx.HLE.Debugger
|
||||
{
|
||||
struct SendNackMessage : IMessage
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
using IExecutionContext = Ryujinx.Cpu.IExecutionContext;
|
||||
|
||||
namespace Ryujinx.HLE.Debugger
|
||||
{
|
||||
public class ThreadBreakMessage : IMessage
|
||||
{
|
||||
public IExecutionContext Context { get; }
|
||||
public ulong Address { get; }
|
||||
public int Opcode { get; }
|
||||
|
||||
public ThreadBreakMessage(IExecutionContext context, ulong address, int opcode)
|
||||
{
|
||||
Context = context;
|
||||
Address = address;
|
||||
Opcode = opcode;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.Debugger
|
||||
{
|
||||
class RegisterInformation
|
||||
static class RegisterInformation
|
||||
{
|
||||
public static readonly Dictionary<string, string> Features = new()
|
||||
{
|
||||
@@ -17,12 +17,9 @@ namespace Ryujinx.HLE.Debugger
|
||||
|
||||
private static string GetEmbeddedResourceContent(string resourceName)
|
||||
{
|
||||
Stream stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("Ryujinx.HLE.Debugger.GdbXml." + resourceName);
|
||||
StreamReader reader = new StreamReader(stream);
|
||||
string result = reader.ReadToEnd();
|
||||
reader.Dispose();
|
||||
stream.Dispose();
|
||||
return result;
|
||||
using Stream stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("Ryujinx.HLE.Debugger.Gdb.Xml." + resourceName);
|
||||
using StreamReader reader = new(stream);
|
||||
return reader.ReadToEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,65 +3,58 @@ using System.Globalization;
|
||||
|
||||
namespace Ryujinx.HLE.Debugger
|
||||
{
|
||||
class StringStream
|
||||
internal class StringStream
|
||||
{
|
||||
private readonly string Data;
|
||||
private int Position;
|
||||
private readonly string _data;
|
||||
private int _position;
|
||||
|
||||
public StringStream(string s)
|
||||
{
|
||||
Data = s;
|
||||
_data = s;
|
||||
}
|
||||
|
||||
public bool IsEmpty => _position >= _data.Length;
|
||||
|
||||
public char ReadChar()
|
||||
{
|
||||
return Data[Position++];
|
||||
}
|
||||
public char ReadChar() => _data[_position++];
|
||||
|
||||
public string ReadUntil(char needle)
|
||||
{
|
||||
int needlePos = Data.IndexOf(needle, Position);
|
||||
int needlePos = _data.IndexOf(needle, _position);
|
||||
|
||||
if (needlePos == -1)
|
||||
{
|
||||
needlePos = Data.Length;
|
||||
needlePos = _data.Length;
|
||||
}
|
||||
|
||||
string result = Data.Substring(Position, needlePos - Position);
|
||||
Position = needlePos + 1;
|
||||
string result = _data.Substring(_position, needlePos - _position);
|
||||
_position = needlePos + 1;
|
||||
return result;
|
||||
}
|
||||
|
||||
public string ReadLength(int len)
|
||||
{
|
||||
string result = Data.Substring(Position, len);
|
||||
Position += len;
|
||||
string result = _data.Substring(_position, len);
|
||||
_position += len;
|
||||
return result;
|
||||
}
|
||||
|
||||
public string ReadRemaining()
|
||||
{
|
||||
string result = Data.Substring(Position);
|
||||
Position = Data.Length;
|
||||
string result = _data[_position..];
|
||||
_position = _data.Length;
|
||||
return result;
|
||||
}
|
||||
|
||||
public ulong ReadRemainingAsHex()
|
||||
{
|
||||
return ulong.Parse(ReadRemaining(), NumberStyles.HexNumber);
|
||||
}
|
||||
public ulong ReadRemainingAsHex()
|
||||
=> ulong.Parse(ReadRemaining(), NumberStyles.HexNumber);
|
||||
|
||||
public ulong ReadUntilAsHex(char needle)
|
||||
{
|
||||
return ulong.Parse(ReadUntil(needle), NumberStyles.HexNumber);
|
||||
}
|
||||
public ulong ReadUntilAsHex(char needle)
|
||||
=> ulong.Parse(ReadUntil(needle), NumberStyles.HexNumber);
|
||||
|
||||
public ulong ReadLengthAsHex(int len)
|
||||
{
|
||||
return ulong.Parse(ReadLength(len), NumberStyles.HexNumber);
|
||||
}
|
||||
public ulong ReadLengthAsHex(int len)
|
||||
=> ulong.Parse(ReadLength(len), NumberStyles.HexNumber);
|
||||
|
||||
public ulong ReadLengthAsLEHex(int len)
|
||||
public ulong ReadLengthAsLittleEndianHex(int len)
|
||||
{
|
||||
Debug.Assert(len % 2 == 0);
|
||||
|
||||
@@ -83,9 +76,9 @@ namespace Ryujinx.HLE.Debugger
|
||||
|
||||
public bool ConsumePrefix(string prefix)
|
||||
{
|
||||
if (Data.Substring(Position).StartsWith(prefix))
|
||||
if (_data[_position..].StartsWith(prefix))
|
||||
{
|
||||
Position += prefix.Length;
|
||||
_position += prefix.Length;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -93,17 +86,12 @@ namespace Ryujinx.HLE.Debugger
|
||||
|
||||
public bool ConsumeRemaining(string match)
|
||||
{
|
||||
if (Data.Substring(Position) == match)
|
||||
if (_data[_position..] == match)
|
||||
{
|
||||
Position += match.Length;
|
||||
_position += match.Length;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool IsEmpty()
|
||||
{
|
||||
return Position >= Data.Length;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ namespace Ryujinx.HLE.HOS.Kernel
|
||||
capabilities,
|
||||
context.ResourceLimit,
|
||||
MemoryRegion.Service,
|
||||
context.Device.Configuration.MemoryConfiguration,
|
||||
null,
|
||||
customThreadStart);
|
||||
|
||||
|
||||
@@ -102,6 +102,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
ProcessCreationFlags flags,
|
||||
bool fromBack,
|
||||
MemoryRegion memRegion,
|
||||
MemoryConfiguration memConfig,
|
||||
ulong address,
|
||||
ulong size,
|
||||
KMemoryBlockSlabManager slabManager)
|
||||
@@ -117,6 +118,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
addrSpaceBase,
|
||||
addrSpaceSize,
|
||||
memRegion,
|
||||
memConfig,
|
||||
address,
|
||||
size,
|
||||
slabManager);
|
||||
@@ -159,6 +161,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
ulong addrSpaceStart,
|
||||
ulong addrSpaceEnd,
|
||||
MemoryRegion memRegion,
|
||||
MemoryConfiguration memConfig,
|
||||
ulong address,
|
||||
ulong size,
|
||||
KMemoryBlockSlabManager slabManager)
|
||||
@@ -193,7 +196,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
|
||||
case ProcessCreationFlags.AddressSpace64BitDeprecated:
|
||||
aliasRegion.Size = 0x180000000;
|
||||
heapRegion.Size = 0x180000000;
|
||||
heapRegion.Size = memConfig == MemoryConfiguration.MemoryConfiguration12GiB ? 0x300000000u : 0x180000000u;
|
||||
stackRegion.Size = 0;
|
||||
tlsIoRegion.Size = 0;
|
||||
CodeRegionStart = 0x8000000;
|
||||
@@ -223,7 +226,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
int addressSpaceWidth = (int)ulong.Log2(_reservedAddressSpaceSize);
|
||||
|
||||
aliasRegion.Size = 1UL << (addressSpaceWidth - 3);
|
||||
heapRegion.Size = 0x180000000;
|
||||
heapRegion.Size = memConfig == MemoryConfiguration.MemoryConfiguration12GiB ? 0x300000000u : 0x180000000u;
|
||||
stackRegion.Size = 1UL << (addressSpaceWidth - 8);
|
||||
tlsIoRegion.Size = 1UL << (addressSpaceWidth - 3);
|
||||
CodeRegionStart = BitUtils.AlignDown(address, RegionAlignment);
|
||||
@@ -237,7 +240,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
|
||||
else
|
||||
{
|
||||
aliasRegion.Size = 0x1000000000;
|
||||
heapRegion.Size = 0x180000000;
|
||||
heapRegion.Size = memConfig == MemoryConfiguration.MemoryConfiguration12GiB ? 0x300000000u : 0x180000000u;
|
||||
stackRegion.Size = 0x80000000;
|
||||
tlsIoRegion.Size = 0x1000000000;
|
||||
CodeRegionStart = BitUtils.AlignDown(address, RegionAlignment);
|
||||
|
||||
@@ -161,6 +161,116 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public string GetProcessInfoPrintout()
|
||||
{
|
||||
StringBuilder sb = new();
|
||||
|
||||
sb.AppendLine($"Process: {_owner.Name}, PID: {_owner.Pid}");
|
||||
sb.AppendLine($"Program Id: 0x{_owner.TitleId:x16}");
|
||||
sb.AppendLine($"Application: {(_owner.IsApplication ? 1 : 0)}");
|
||||
|
||||
sb.AppendLine("Layout:");
|
||||
sb.AppendLine(
|
||||
$" Alias: 0x{_owner.MemoryManager.AliasRegionStart:x10} - 0x{_owner.MemoryManager.AliasRegionEnd - 1:x10}");
|
||||
sb.AppendLine(
|
||||
$" Heap: 0x{_owner.MemoryManager.HeapRegionStart:x10} - 0x{_owner.MemoryManager.HeapRegionEnd - 1:x10}");
|
||||
sb.AppendLine(
|
||||
$" Aslr: 0x{_owner.MemoryManager.AslrRegionStart:x10} - 0x{_owner.MemoryManager.AslrRegionEnd - 1:x10}");
|
||||
sb.AppendLine(
|
||||
$" Stack: 0x{_owner.MemoryManager.StackRegionStart:x10} - 0x{_owner.MemoryManager.StackRegionEnd - 1:x10}");
|
||||
|
||||
sb.AppendLine("Modules:");
|
||||
|
||||
foreach (Image image in GetLoadedImages())
|
||||
{
|
||||
ulong endAddress = image.BaseAddress + image.Size - 1;
|
||||
sb.AppendLine($" 0x{image.BaseAddress:x10} - 0x{endAddress:x10} {image.Name}");
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public string GetMinidump()
|
||||
{
|
||||
var result = new StringBuilder();
|
||||
|
||||
result.AppendLine("=== Begin Minidump ===\n");
|
||||
try
|
||||
{
|
||||
result.AppendLine(GetProcessInfoPrintout());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
result.AppendLine($"[Error getting process info: {e.Message}]");
|
||||
}
|
||||
|
||||
var debugInterface = _owner?.DebugInterface;
|
||||
|
||||
if (debugInterface != null)
|
||||
{
|
||||
ulong[] threadUids;
|
||||
|
||||
try
|
||||
{
|
||||
threadUids = debugInterface.ThreadUids ?? [];
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
result.AppendLine($"[Error getting thread uids: {e.Message}]");
|
||||
threadUids = [];
|
||||
}
|
||||
|
||||
foreach (ulong threadUid in threadUids)
|
||||
{
|
||||
result.AppendLine($"=== Thread {threadUid} ===");
|
||||
|
||||
KThread thread;
|
||||
|
||||
try
|
||||
{
|
||||
thread = debugInterface.GetThread(threadUid);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
result.AppendLine($"[Error getting thread: {e.Message}]");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (thread == null)
|
||||
{
|
||||
result.AppendLine("[Thread not found]");
|
||||
continue;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
result.AppendLine(GetGuestStackTrace(thread));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
result.AppendLine($"[Error getting stack trace: {e.Message}]");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
result.AppendLine(GetCpuRegisterPrintout(thread));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
result.AppendLine($"[Error getting registers: {e.Message}]");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result.AppendLine("[Error generating minidump: debugInterface is null]");
|
||||
}
|
||||
|
||||
result.AppendLine("=== End Minidump ===");
|
||||
|
||||
return result.ToString();
|
||||
}
|
||||
|
||||
private static bool TryGetSubName(Image image, ulong address, out ElfSymbol symbol)
|
||||
{
|
||||
address -= image.BaseAddress;
|
||||
@@ -267,7 +377,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
{
|
||||
moduleName = string.Empty;
|
||||
|
||||
var rodataStart = image.BaseAddress + image.Size;
|
||||
ulong rodataStart = image.BaseAddress + image.Size;
|
||||
|
||||
KMemoryInfo roInfo = _owner.MemoryManager.QueryMemory(rodataStart);
|
||||
if (roInfo.Permission != KMemoryPermission.Read)
|
||||
@@ -275,7 +385,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
return false;
|
||||
}
|
||||
|
||||
var rwdataStart = roInfo.Address + roInfo.Size;
|
||||
ulong rwdataStart = roInfo.Address + roInfo.Size;
|
||||
|
||||
try
|
||||
{
|
||||
@@ -305,7 +415,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
}
|
||||
|
||||
pathLength = Math.Min(pathLength, rodataBuf.Length - 8);
|
||||
var pathBuf = rodataBuf.Slice(8, pathLength);
|
||||
Span<byte> pathBuf = rodataBuf.Slice(8, pathLength);
|
||||
int lastSlash = pathBuf.LastIndexOfAny(new byte[] { (byte)'\\', (byte)'/' });
|
||||
|
||||
moduleName = Encoding.ASCII.GetString(pathBuf.Slice(lastSlash + 1).TrimEnd((byte)0));
|
||||
@@ -483,12 +593,11 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
|
||||
lock (_images)
|
||||
{
|
||||
var image = new Image(textOffset, textSize, symbols.OrderBy(x => x.Value).ToArray());
|
||||
Image image = new(textOffset, textSize, symbols.OrderBy(x => x.Value).ToArray());
|
||||
|
||||
string moduleName;
|
||||
if (!GetModuleName(out moduleName, image))
|
||||
if (!GetModuleName(out string moduleName, image))
|
||||
{
|
||||
var newIndex = _images.Count;
|
||||
int newIndex = _images.Count;
|
||||
moduleName = $"(unknown{newIndex})";
|
||||
}
|
||||
image.Name = moduleName;
|
||||
|
||||
@@ -124,6 +124,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
KPageList pageList,
|
||||
KResourceLimit resourceLimit,
|
||||
MemoryRegion memRegion,
|
||||
MemoryConfiguration memConfig,
|
||||
IProcessContextFactory contextFactory,
|
||||
ThreadStart customThreadStart = null)
|
||||
{
|
||||
@@ -153,6 +154,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
creationInfo.Flags,
|
||||
!creationInfo.Flags.HasFlag(ProcessCreationFlags.EnableAslr),
|
||||
memRegion,
|
||||
memConfig,
|
||||
codeAddress,
|
||||
codeSize,
|
||||
slabManager);
|
||||
@@ -189,6 +191,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
ReadOnlySpan<uint> capabilities,
|
||||
KResourceLimit resourceLimit,
|
||||
MemoryRegion memRegion,
|
||||
MemoryConfiguration memConfig,
|
||||
IProcessContextFactory contextFactory,
|
||||
ThreadStart customThreadStart = null)
|
||||
{
|
||||
@@ -252,6 +255,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
creationInfo.Flags,
|
||||
!creationInfo.Flags.HasFlag(ProcessCreationFlags.EnableAslr),
|
||||
memRegion,
|
||||
memConfig,
|
||||
codeAddress,
|
||||
codeSize,
|
||||
slabManager);
|
||||
@@ -1088,21 +1092,25 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
MemoryManager = new KPageTable(KernelContext, CpuMemory, Context.AddressSpaceSize);
|
||||
}
|
||||
|
||||
private bool InvalidAccessHandler(ulong va)
|
||||
private static bool InvalidAccessHandler(ulong va)
|
||||
{
|
||||
KernelStatic.GetCurrentThread()?.PrintGuestStackTrace();
|
||||
KernelStatic.GetCurrentThread()?.PrintGuestRegisterPrintout();
|
||||
|
||||
Logger.Error?.Print(LogClass.Cpu, $"Invalid memory access at virtual address 0x{va:X16}.");
|
||||
|
||||
Logger.Flush();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void UndefinedInstructionHandler(IExecutionContext context, ulong address, int opCode)
|
||||
private static void UndefinedInstructionHandler(IExecutionContext context, ulong address, int opCode)
|
||||
{
|
||||
KernelStatic.GetCurrentThread().PrintGuestStackTrace();
|
||||
KernelStatic.GetCurrentThread()?.PrintGuestRegisterPrintout();
|
||||
|
||||
Logger.Flush();
|
||||
|
||||
throw new UndefinedInstructionException(address, opCode);
|
||||
}
|
||||
|
||||
@@ -1200,16 +1208,16 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
|
||||
private class DebuggerInterface : IDebuggableProcess
|
||||
{
|
||||
private Barrier StepBarrier;
|
||||
private readonly Barrier _stepBarrier;
|
||||
private readonly KProcess _parent;
|
||||
private readonly KernelContext _kernelContext;
|
||||
private KThread steppingThread;
|
||||
private KThread _steppingThread;
|
||||
|
||||
public DebuggerInterface(KProcess p)
|
||||
{
|
||||
_parent = p;
|
||||
_kernelContext = p.KernelContext;
|
||||
StepBarrier = new(2);
|
||||
_stepBarrier = new(2);
|
||||
}
|
||||
|
||||
public void DebugStop()
|
||||
@@ -1277,7 +1285,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
}
|
||||
|
||||
_kernelContext.CriticalSection.Enter();
|
||||
steppingThread = target;
|
||||
_steppingThread = target;
|
||||
bool waiting = target.MutexOwner != null || target.WaitingSync || target.WaitingInArbitration;
|
||||
target.Context.RequestDebugStep();
|
||||
if (waiting)
|
||||
@@ -1297,14 +1305,14 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
_kernelContext.CriticalSection.Leave();
|
||||
|
||||
bool stepTimedOut = false;
|
||||
if (!StepBarrier.SignalAndWait(TimeSpan.FromMilliseconds(2000)))
|
||||
if (!_stepBarrier.SignalAndWait(TimeSpan.FromMilliseconds(2000)))
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.Kernel, $"Failed to step thread {target.ThreadUid} in time.");
|
||||
stepTimedOut = true;
|
||||
}
|
||||
|
||||
_kernelContext.CriticalSection.Enter();
|
||||
steppingThread = null;
|
||||
_steppingThread = null;
|
||||
if (waiting)
|
||||
{
|
||||
lock (_parent._threadingLock)
|
||||
@@ -1326,26 +1334,28 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
return false;
|
||||
}
|
||||
|
||||
StepBarrier.SignalAndWait();
|
||||
_stepBarrier.SignalAndWait();
|
||||
return true;
|
||||
}
|
||||
|
||||
public DebugState GetDebugState()
|
||||
{
|
||||
return (DebugState)_parent.debugState;
|
||||
}
|
||||
public DebugState DebugState => (DebugState)_parent.debugState;
|
||||
|
||||
public bool IsThreadPaused(KThread target)
|
||||
{
|
||||
return (target.SchedFlags & ThreadSchedState.ThreadPauseFlag) != 0;
|
||||
}
|
||||
|
||||
public ulong[] GetThreadUids()
|
||||
public ulong[] ThreadUids
|
||||
{
|
||||
lock (_parent._threadingLock)
|
||||
get
|
||||
{
|
||||
var threads = _parent._threads.Where(x => !x.TerminationRequested).ToArray();
|
||||
return threads.Select(x => x.ThreadUid).ToArray();
|
||||
lock (_parent._threadingLock)
|
||||
{
|
||||
return _parent._threads
|
||||
.Where(x => !x.TerminationRequested)
|
||||
.Select(x => x.ThreadUid)
|
||||
.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1353,25 +1363,25 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
{
|
||||
lock (_parent._threadingLock)
|
||||
{
|
||||
var threads = _parent._threads.Where(x => !x.TerminationRequested).ToArray();
|
||||
return threads.FirstOrDefault(x => x.ThreadUid == threadUid);
|
||||
return _parent._threads.Where(x => !x.TerminationRequested)
|
||||
.FirstOrDefault(x => x.ThreadUid == threadUid);
|
||||
}
|
||||
}
|
||||
|
||||
public void DebugInterruptHandler(IExecutionContext ctx)
|
||||
{
|
||||
_kernelContext.CriticalSection.Enter();
|
||||
bool stepping = steppingThread != null;
|
||||
bool stepping = _steppingThread != null;
|
||||
_kernelContext.CriticalSection.Leave();
|
||||
if (stepping)
|
||||
{
|
||||
StepBarrier.SignalAndWait();
|
||||
StepBarrier.SignalAndWait();
|
||||
_stepBarrier.SignalAndWait();
|
||||
_stepBarrier.SignalAndWait();
|
||||
}
|
||||
_parent.InterruptHandler(ctx);
|
||||
}
|
||||
|
||||
public IVirtualMemoryManager CpuMemory { get { return _parent.CpuMemory; } }
|
||||
public IVirtualMemoryManager CpuMemory => _parent.CpuMemory;
|
||||
|
||||
public void InvalidateCacheRegion(ulong address, ulong size)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
{
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using ARMeilleure.State;
|
||||
using Ryujinx.Cpu;
|
||||
using System.Threading;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Kernel.Process
|
||||
{
|
||||
|
||||
@@ -137,6 +137,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
capabilities,
|
||||
resourceLimit,
|
||||
memRegion,
|
||||
_context.Device.Configuration.MemoryConfiguration,
|
||||
contextFactory,
|
||||
customThreadStart);
|
||||
|
||||
@@ -888,7 +889,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
[Svc(1)]
|
||||
public Result SetHeapSize([PointerSized] out ulong address, [PointerSized] ulong size)
|
||||
{
|
||||
if ((size & 0xfffffffe001fffff) != 0)
|
||||
if ((size & 0xfffffffc001fffff) != 0)
|
||||
{
|
||||
address = 0;
|
||||
|
||||
@@ -1893,6 +1894,9 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
|
||||
return;
|
||||
}
|
||||
|
||||
Logger.Error?.Print(LogClass.KernelSvc, "The guest program broke execution!");
|
||||
Logger.Flush();
|
||||
|
||||
// TODO: Debug events.
|
||||
currentThread.Owner.TerminateCurrentProcess();
|
||||
|
||||
|
||||
@@ -293,6 +293,12 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
|
||||
KThread currentThread = KernelStatic.GetCurrentThread();
|
||||
KThread selectedThread = _state.SelectedThread;
|
||||
|
||||
if (!currentThread.IsThreadNamed && !string.IsNullOrEmpty(currentThread.GetThreadName()))
|
||||
{
|
||||
currentThread.HostThread.Name = $"<{currentThread.GetThreadName()}>";
|
||||
currentThread.IsThreadNamed = true;
|
||||
}
|
||||
|
||||
// If the thread is already scheduled and running on the core, we have nothing to do.
|
||||
if (currentThread == selectedThread)
|
||||
{
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using ARMeilleure.State;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Cpu;
|
||||
using Ryujinx.HLE.Debugger;
|
||||
using Ryujinx.HLE.HOS.Kernel.Common;
|
||||
using Ryujinx.HLE.HOS.Kernel.Process;
|
||||
using Ryujinx.HLE.HOS.Kernel.SupervisorCall;
|
||||
@@ -53,6 +52,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
|
||||
public ulong AffinityMask { get; set; }
|
||||
|
||||
public ulong ThreadUid { get; private set; }
|
||||
|
||||
public bool IsThreadNamed { get; set; }
|
||||
|
||||
private long _totalTimeRunning;
|
||||
|
||||
|
||||
@@ -38,6 +38,13 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc.AccountService
|
||||
}
|
||||
|
||||
[CommandCmif(3)]
|
||||
// LoadIdTokenCacheDeprecated() -> (u32 id_token_cache_size, buffer<bytes, 6>)
|
||||
public ResultCode LoadIdTokenCacheDeprecated(ServiceCtx context)
|
||||
{
|
||||
return _managerServer.LoadIdTokenCache(context);
|
||||
}
|
||||
|
||||
[CommandCmif(4)] // 19.0.0+
|
||||
// LoadIdTokenCache() -> (u32 id_token_cache_size, buffer<bytes, 6>)
|
||||
public ResultCode LoadIdTokenCache(ServiceCtx context)
|
||||
{
|
||||
|
||||
@@ -38,6 +38,13 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc.AccountService
|
||||
}
|
||||
|
||||
[CommandCmif(3)]
|
||||
// LoadIdTokenCacheDeprecated() -> (u32 id_token_cache_size, buffer<bytes, 6>)
|
||||
public ResultCode LoadIdTokenCacheDeprecated(ServiceCtx context)
|
||||
{
|
||||
return _managerServer.LoadIdTokenCache(context);
|
||||
}
|
||||
|
||||
[CommandCmif(4)] // 19.0.0+
|
||||
// LoadIdTokenCache() -> (u32 id_token_cache_size, buffer<bytes, 6>)
|
||||
public ResultCode LoadIdTokenCache(ServiceCtx context)
|
||||
{
|
||||
|
||||
@@ -7,7 +7,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Claims;
|
||||
using System.Security.Cryptography;
|
||||
using System.Security.Principal;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -83,23 +83,23 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.Common
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public ReadOnlySpan<AtomicStorage<T>> ReadEntries(uint maxCount)
|
||||
{
|
||||
ulong countAvailaible = Math.Min(Math.Max(0, ReadCurrentCount()), maxCount);
|
||||
ulong countAvailable = Math.Min(Math.Max(0, ReadCurrentCount()), maxCount);
|
||||
|
||||
if (countAvailaible == 0)
|
||||
if (countAvailable == 0)
|
||||
{
|
||||
return ReadOnlySpan<AtomicStorage<T>>.Empty;
|
||||
}
|
||||
|
||||
ulong index = ReadCurrentIndex();
|
||||
|
||||
AtomicStorage<T>[] result = new AtomicStorage<T>[countAvailaible];
|
||||
AtomicStorage<T>[] result = new AtomicStorage<T>[countAvailable];
|
||||
|
||||
Span<AtomicStorage<T>> storageSpan = _storage.AsSpan();
|
||||
|
||||
for (ulong i = 0; i < countAvailaible; i++)
|
||||
for (ulong i = 0; i < countAvailable; i++)
|
||||
{
|
||||
int inputEntryIndex = (int)((index + MaxEntries + 1 - countAvailaible + i) % MaxEntries);
|
||||
int outputEntryIndex = (int)(countAvailaible - i - 1);
|
||||
int inputEntryIndex = (int)((index + MaxEntries + 1 - countAvailable + i) % MaxEntries);
|
||||
int outputEntryIndex = (int)(countAvailable - i - 1);
|
||||
|
||||
ulong samplingNumber0 = storageSpan[inputEntryIndex].ReadSamplingNumberAtomic();
|
||||
result[outputEntryIndex] = storageSpan[inputEntryIndex];
|
||||
@@ -107,9 +107,9 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.Common
|
||||
|
||||
if (samplingNumber0 != samplingNumber1 && (i > 0 && (result[outputEntryIndex].SamplingNumber - result[outputEntryIndex].SamplingNumber) != 1))
|
||||
{
|
||||
ulong tempCount = Math.Min(ReadCurrentCount(), countAvailaible);
|
||||
ulong tempCount = Math.Min(ReadCurrentCount(), countAvailable);
|
||||
|
||||
countAvailaible = Math.Min(tempCount, maxCount);
|
||||
countAvailable = Math.Min(tempCount, maxCount);
|
||||
index = ReadCurrentIndex();
|
||||
|
||||
i -= 1;
|
||||
|
||||
@@ -15,5 +15,14 @@ namespace Ryujinx.HLE.HOS.Services.Ldn
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[CommandCmif(1)] // 18.0.0+
|
||||
// CreateClientProcessMonitor() -> object<nn::ldn::detail::IClientProcessMonitor>
|
||||
public ResultCode CreateClientProcessMonitor(ServiceCtx context)
|
||||
{
|
||||
MakeObject(context, new IClientProcessMonitor(context));
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
using Ryujinx.Common.Logging;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator
|
||||
{
|
||||
class IClientProcessMonitor : DisposableIpcService
|
||||
{
|
||||
public IClientProcessMonitor(ServiceCtx context) { }
|
||||
|
||||
[CommandCmif(0)] // 18.0.0+
|
||||
// RegisterClient(u64 pid_placeholder, pid)
|
||||
public ResultCode RegisterClient(ServiceCtx context)
|
||||
{
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceLdn);
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing) { }
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user