Compare commits

..

76 Commits

Author SHA1 Message Date
GreemDev
3140ec5f05 misc: Also show an error message box and quit if the process was launched with administrator rights. 2025-10-28 20:57:03 -05:00
GreemDev
40f709ff55 misc: Add a launch guard for program files (the emulator does not work properly when put here as it does not require admin) 2025-10-28 19:04:25 -05:00
GreemDev
53aae9b584 hle: Throw a ServiceNotImplementedException instead of ArgumentException if any number arguments provided to ILibraryAppletAccessor are nonzero 2025-10-28 15:37:59 -05:00
LotP
ff9a75f895 ILibraryAppletAccessor:90 tweak (ryubing/ryujinx!199)
See merge request ryubing/ryujinx!199
2025-10-28 13:37:20 -05:00
sh0inx
3394736b07 HLE: Stub ILibraryAppletAccessor Unknown90 (ryubing/ryujinx!197)
See merge request ryubing/ryujinx!197
2025-10-27 12:48:17 -05:00
yeager
b06846aa5e Updated Swedish translation (with updated branch) (ryubing/ryujinx!156)
See merge request ryubing/ryujinx!156
2025-10-27 02:47:59 -05:00
LotP
c94ffaa00a gpu allocation optimizations (ryubing/ryujinx!195)
See merge request ryubing/ryujinx!195
2025-10-26 14:14:51 -05:00
GreemDev
718652599d UI: Prevent null ldn game model arrays from entering the SetEntries method 2025-10-26 12:51:08 -05:00
GreemDev
c8959afa3d chore: Overall code cleanup
Update NuGet packages, fix version string in plist for macOS
2025-10-26 01:22:20 -05:00
Coxxs
7175da8621 UI: [ci skip] Show notifications for options that may cause side effects (ryubing/ryujinx!193)
See merge request ryubing/ryujinx!193
2025-10-26 00:29:38 -05:00
LotP
fd07453887 audio effects fix and audio object pooling (ryubing/ryujinx!192)
See merge request ryubing/ryujinx!192
2025-10-25 21:07:10 -05:00
KeatonTheBot
c6bc77e4bf UI: Update Avalonia to 11.3.6, FluentAvalonia to 2.4.0 (ryubing/ryujinx!118)
See merge request ryubing/ryujinx!118
2025-10-25 00:29:51 -05:00
GreemDev
49cbe4b328 UI: fix "Enable UI logs" not being persisted upon relaunch
Closes ryujinx#5

(it was saved, just not loaded back)
2025-10-24 18:25:29 -05:00
Coxxs
6fd67cdcb7 Fix application list loads slowly when RyuLDN is enabled (ryubing/ryujinx!191)
See merge request ryubing/ryujinx!191
2025-10-24 10:29:33 -05:00
LotP
5ced2bf764 fix wrong bit value (ryubing/ryujinx!190)
See merge request ryubing/ryujinx!190
2025-10-24 10:10:31 -05:00
GreemDev
67e97d1a1a gdb: YACC (yet another cleanup commit) 2025-10-23 19:11:58 -05:00
Coxxs
09d8a411c8 Do not RecurseSubdirectories when finding the icon fallback (ryubing/ryujinx!189)
See merge request ryubing/ryujinx!189
2025-10-23 15:17:29 -05:00
Coxxs
93516df7e6 Skip directories when finding the icon fallback (ryubing/ryujinx!188)
See merge request ryubing/ryujinx!188
2025-10-23 14:56:39 -05:00
Coxxs
0c165c3f62 Move ProcessInfo and Minidump to HleProcessDebugger (ryubing/ryujinx!187)
See merge request ryubing/ryujinx!187
2025-10-22 16:20:13 -05:00
GreemDev
91da244c02 gdb: some more cleanups 2025-10-22 15:04:03 -05:00
GreemDev
904d4a7eb0 gdb: Make waiting for a process to start more forgiving (200ms per poll 10x -> 500ms) 2025-10-22 01:07:19 -05:00
Coxxs
1248a054de gdb: Abort if unable to start GDB server (ryubing/ryujinx!186)
See merge request ryubing/ryujinx!186
2025-10-21 23:16:18 -05:00
GreemDev
1bb2af84ce gdb: Catch SocketException from TcpListener#Start 2025-10-21 22:15:14 -05:00
GreemDev
886981004d chore: I thought I removed these months ago lol 2025-10-21 20:33:35 -05:00
Coxxs
e551dda17e gdb: fix IsProcess32Bit throws exception if called too early (ryubing/ryujinx!185)
See merge request ryubing/ryujinx!185
2025-10-20 21:35:55 -05:00
GreemDev
ed67535227 chore: [si skip] fix in-code typos 2025-10-20 21:32:23 -05:00
GreemDev
7d65611b96 gdb: [ci skip] just had a brain wave 2025-10-20 21:20:41 -05:00
GreemDev
71eb844dd8 gdb: dynamic rcmd system & more cleanups 2025-10-20 21:18:16 -05:00
Coxxs
a0e5edf8ba gdb: Support qAttached; Add missing ReplyOK when detach (ryubing/ryujinx!184)
See merge request ryubing/ryujinx!184
2025-10-20 21:12:16 -05:00
Coxxs
6541ad0726 Implement IUserServiceCreator: 1 (CreateClientProcessMonitor) (ryubing/ryujinx!181)
See merge request ryubing/ryujinx!181
2025-10-20 19:14:42 -05:00
Coxxs
1c084373c9 Update LoadIdTokenCache for 19.0.0+ (ryubing/ryujinx!182)
See merge request ryubing/ryujinx!182
2025-10-20 17:37:16 -05:00
GreemDev
5b3b907fd2 [ci skip] chore: Fix usage of var 2025-10-20 02:42:57 -05:00
Hack茶ん
f46577af58 [ci skip] Update Korean translation (ryubing/ryujinx!174)
See merge request ryubing/ryujinx!174
2025-10-19 17:43:34 -05:00
Xam
0e218754f5 Fix duplicate volume and mode change events in AppHost (ryubing/ryujinx!176)
See merge request ryubing/ryujinx!176
2025-10-19 17:41:21 -05:00
Xam
0c6d4a07b9 Input: AvaloniaMouseDriver: fix native touch inputs (ryubing/ryujinx!178)
See merge request ryubing/ryujinx!178
2025-10-19 17:33:24 -05:00
Xam
8714b010f6 Horizon: Audio: HwopusIpcServer: fix random crashes regression in Pokemon Quest (ryubing/ryujinx!175)
See merge request ryubing/ryujinx!175
2025-10-19 17:17:46 -05:00
GreemDev
d1d4a735a6 docs: use the real repo in COMPILING.md 2025-10-19 14:48:41 -05:00
GreemDev
247e2e03d6 gdb: More cleanup changes
- Move the message handler into its debugger class part,
- Move all message types into one file and collapse 3 of the ones with no data into a generic, stateless message with a single property being its type,
- Add an Fpscr helper property on IExecutionContext along with a comment about what Fpscr is (similar to the other registers in there)
- Moved the Rcmd helpers (such as GetRegisters, GetMinidump, etc) into a dedicated Debugger class part,
- Fixed the double-collection (ToArray being called twice) in GetThreadUids & GetThread in KProcess
2025-10-19 04:26:12 -05:00
GreemDev
6058af5119 chore: cleanup unused usings in Ryujinx.HLE 2025-10-19 04:17:02 -05:00
GreemDev
e11eff0f41 gdb: more cleanups
- convert GdbRegisters utilities into extensions on IExecutionContext

- add a Write/Read Register helper on Debugger that handles 32/64 bit instead of doing that for every usage of register reading/writing
2025-10-18 03:01:21 -05:00
GreemDev
2a2ab523cb gdb: Code cleanup pass #2
Moved the reply functionality into the command processor, move the main debugger thread into a dedicated class part, and more
2025-10-17 00:09:51 -05:00
Coxxs
8e941e4a8f gdb: Cleanup (ryubing/ryujinx!171)
See merge request ryubing/ryujinx!171
2025-10-16 19:53:51 -05:00
Hack茶ん
9aacf9b37b Update Korean translation (ryubing/ryujinx!168)
See merge request ryubing/ryujinx!168
2025-10-16 19:45:14 -05:00
Bluey Enjoyer
2b159dbca8 AHHHHHHHHHHHHHH (ryubing/ryujinx!170)
See merge request ryubing/ryujinx!170
2025-10-16 19:43:56 -05:00
GreemDev
c33a97f01c gdb: Cleanup Debugger.cs
by moving the GDB command handlers and command processor out of the class and into their own
2025-10-16 17:32:04 -05:00
GreemDev
fdbdb05cb5 misc: Update Ryujinx.LibHac 2025-10-16 12:23:15 -05:00
Coxxs
7268acbfb4 gdb: Do not skip CheckInterrupt when gdb stub is enabled (ryubing/ryujinx!169)
See merge request ryubing/ryujinx!169
2025-10-16 07:49:41 -05:00
GreemDev
d4107ac05f UI: Add a startup flag to ignore new Amiibo file updates, useful for testing changes you intend on committing to Ryubing/Nfc.
Flag is `--local-only-amiibo`
2025-10-15 21:51:13 -05:00
LotP
1d409f7127 12 GiB heap support (ryubing/ryujinx!166)
See merge request ryubing/ryujinx!166
2025-10-15 15:37:13 -05:00
GreemDev
2434c55266 UI: Updater: Fix "No" opening the changelog and "Show Changelog" doing nothing (aka doing what "No" should be doing) 2025-10-14 18:38:56 -05:00
GreemDev
99126603ba UI: swap the UI reset checkbox text back to a sentence instead of title cased 2025-10-14 16:12:11 -05:00
GreemDev
a62716002e chore: move HasPtcCacheFiles & HasShaderCacheFiles into ApplicationData, instead of having the weird static dependency helpers 2025-10-14 16:09:51 -05:00
GreemDev
47559cd311 Revert game list rounding
The selected highlight was bugged

https://fs.ryujinx.app/40cl4Ih9RiOWLVi7e4lJsw.png
2025-10-14 15:59:02 -05:00
Coxxs
51584a083b Flush the error log before exit (ryubing/ryujinx!163)
See merge request ryubing/ryujinx!163
2025-10-13 17:40:15 -05:00
Coxxs
ceec9617ef gdb: Fix the crash that occurs when GDB is connected early (ryubing/ryujinx!159)
See merge request ryubing/ryujinx!159
2025-10-11 19:06:14 -05:00
Coxxs
1865be47cf gdb: Add monitor minidump command (ryubing/ryujinx!158)
See merge request ryubing/ryujinx!158
2025-10-11 10:01:30 -05:00
LotP
ef9810582a Sync thread name on Schedule (ryubing/ryujinx!157)
See merge request ryubing/ryujinx!157
2025-10-11 07:47:45 -05:00
KeatonTheBot
13878acdb2 Avoid lookup of invalid textures if pool did not change (ryubing/ryujinx!113)
See merge request ryubing/ryujinx!113
2025-10-11 02:56:13 -05:00
LotP
e2143d43bc SDK20 and REV15 support (ryubing/ryujinx!50)
See merge request ryubing/ryujinx!50
2025-10-11 02:11:39 -05:00
Astell
4444ecae41 fix super mario galaxy 0x25E00040 error (ryubing/ryujinx!155)
See merge request ryubing/ryujinx!155
2025-10-10 17:37:42 -05:00
Neo
4f5a236c21 UI: Settings → Interface Tab + General Settings (ryubing/ryujinx!154)
See merge request ryubing/ryujinx!154
2025-10-09 16:32:33 -05:00
Lorenzo
db31ff15c7 it_IT translation update (ryubing/ryujinx!148)
See merge request ryubing/ryujinx!148
2025-10-06 20:22:15 -05:00
Bluey Enjoyer
e70cd08c9a cleanup work for my last MR/PR (ryubing/ryujinx!153)
See merge request ryubing/ryujinx!153
2025-10-04 13:07:31 -05:00
Neo
60b9723df4 UI: Main Window + General (ryubing/ryujinx!150)
See merge request ryubing/ryujinx!150
2025-10-03 16:02:37 -05:00
KeatonTheBot
1900924a78 Fix push descriptors bugfix logic for Intel Arc on Linux 2025-10-01 21:58:22 -05:00
GreemDev
5fb0b5e7ec vulkan: Intel Arc on Linux also has the push descriptors bug. 2025-10-01 13:03:22 -05:00
Bluey Enjoyer
8d0e28ed9d New RPC images and compat updates (ryubing/ryujinx!151)
See merge request ryubing/ryujinx!151
2025-10-01 12:29:27 -05:00
Babib3l
a4eafd01f5 es_ES and fr_FR translation updates (ryubing/ryujinx!129)
See merge request ryubing/ryujinx!129
2025-09-28 14:58:32 -05:00
在中国的泰国青年_
f55aa87ab9 update thai language additional (ryubing/ryujinx!108)
See merge request ryubing/ryujinx!108
2025-09-27 23:27:56 -05:00
Mcost45
bb4f8d8749 Include SL/SR default bindings for single joycons (ryubing/ryujinx!149)
See merge request ryubing/ryujinx!149
2025-09-22 14:23:40 -05:00
Alula
a6cb681f10 feat: resolve real module names in HLE debugger (ryubing/ryujinx!147)
See merge request ryubing/ryujinx!147
2025-09-20 07:05:44 -05:00
GreemDev
00ff3e6b1b chore: CI: oops missed another zsync reference 2025-09-14 01:35:05 -05:00
GreemDev
12510a5396 chore: CI: actually remove zsync files this time
I'm blind, the previous commit failed CI since it still thought they were being generated
2025-09-14 00:37:30 -05:00
GreemDev
ea30a0ed24 chore: ci: Remove .zsync 2025-09-14 00:26:09 -05:00
Coxxs
df40a69872 Fix headless mode (ryubing/ryujinx!146)
See merge request ryubing/ryujinx!146
2025-09-10 11:43:50 -05:00
LotP
b000f91dad Memory changes 2.2.1 (ryubing/ryujinx!144)
See merge request ryubing/ryujinx!144
2025-09-06 13:51:08 -05:00
280 changed files with 7601 additions and 6223 deletions

View File

@@ -134,16 +134,13 @@ jobs:
exit 1
fi
export UFLAG="gh-releases-zsync|${{ secrets.RC_OWNER }}${{ secrets.RC_CANARY_NAME }}|latest|*-$ARCH_NAME.AppImage.zsync"
BUILDDIR=publish OUTDIR=publish_appimage distribution/linux/appimage/build-appimage.sh
pushd publish_appimage
mv Ryujinx.AppImage ../release_output/ryujinx-canary-$BUILD_VERSION-$ARCH_NAME.AppImage
mv Ryujinx.AppImage.zsync ../release_output/ryujinx-canary-$BUILD_VERSION-$ARCH_NAME.AppImage.zsync
popd
gli --access-token=${{ secrets.GITLAB_TOKEN }} --project=ryubing/canary --command=UploadGenericPackage "Ryubing-Canary|${{ steps.version_info.outputs.build_version }}|release_output/ryujinx-canary-$BUILD_VERSION-$ARCH_NAME.AppImage"
gli --access-token=${{ secrets.GITLAB_TOKEN }} --project=ryubing/canary --command=UploadGenericPackage "Ryubing-Canary|${{ steps.version_info.outputs.build_version }}|release_output/ryujinx-canary-$BUILD_VERSION-$ARCH_NAME.AppImage.zsync"
shell: bash
macos_release:

View File

@@ -125,16 +125,13 @@ jobs:
exit 1
fi
export UFLAG="gh-releases-zsync|${{ github.repository_owner }}|${{ github.event.repository.name }}|latest|*-$ARCH_NAME.AppImage.zsync"
BUILDDIR=publish OUTDIR=publish_appimage distribution/linux/appimage/build-appimage.sh
pushd publish_appimage
mv Ryujinx.AppImage ../release_output/ryujinx-$BUILD_VERSION-$ARCH_NAME.AppImage
mv Ryujinx.AppImage.zsync ../release_output/ryujinx-$BUILD_VERSION-$ARCH_NAME.AppImage.zsync
popd
gli --access-token=${{ secrets.GITLAB_TOKEN }} --project=ryubing/ryujinx --command=UploadGenericPackage "Ryubing|${{ steps.version_info.outputs.build_version }}|release_output/ryujinx-$BUILD_VERSION-$ARCH_NAME.AppImage"
gli --access-token=${{ secrets.GITLAB_TOKEN }} --project=ryubing/ryujinx --command=UploadGenericPackage "Ryubing|${{ steps.version_info.outputs.build_version }}|release_output/ryujinx-$BUILD_VERSION-$ARCH_NAME.AppImage.zsync"
shell: bash
macos_release:

View File

@@ -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

View File

@@ -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="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,11 +40,11 @@
<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.126" />
<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" />
<PackageVersion Include="Gommon" Version="2.7.2.1" />
<PackageVersion Include="Gommon" Version="2.8.0.1" />
<PackageVersion Include="securifybv.ShellLink" Version="0.1.0" />
<PackageVersion Include="Sep" Version="0.11.1" />
<PackageVersion Include="shaderc.net" Version="0.1.0" />
@@ -59,4 +59,4 @@
<PackageVersion Include="System.Management" Version="9.0.2" />
<PackageVersion Include="UnicornEngine.Unicorn" Version="2.0.2-rc1-fb78016" />
</ItemGroup>
</Project>
</Project>

File diff suppressed because it is too large Load Diff

View File

@@ -6,7 +6,6 @@ cd "$ROOTDIR"
BUILDDIR=${BUILDDIR:-publish}
OUTDIR=${OUTDIR:-publish_appimage}
UFLAG=${UFLAG:-"gh-releases-zsync|Ryubing|ryujinx|latest|*-x64.AppImage.zsync"}
rm -rf AppDir
mkdir -p AppDir/usr/bin
@@ -24,10 +23,4 @@ chmod +x AppDir/AppRun AppDir/usr/bin/Ryujinx*
mkdir -p "$OUTDIR"
appimagetool -n --comp zstd --mksquashfs-opt -Xcompression-level --mksquashfs-opt 21 \
-u "$UFLAG" \
AppDir "$OUTDIR"/Ryujinx.AppImage
# Move zsync file needed for delta updates
if [ "$RELEASE" = "1" ]; then
mv ./*.AppImage.zsync "$OUTDIR"
fi

View File

@@ -34,7 +34,7 @@
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleLongVersionString</key>
<string>%%RYUJINX_BUILD_VERSION%%-%%RYUJINX_BUILD_GIT_HASH%%"</string>
<string>%%RYUJINX_BUILD_VERSION%%-%%RYUJINX_BUILD_GIT_HASH%%</string>
<key>CFBundleName</key>
<string>Ryujinx</string>
<key>CFBundlePackageType</key>
@@ -44,13 +44,13 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.2.0</string>
<string>%%RYUJINX_BUILD_VERSION%%</string>
<key>NSHighResolutionCapable</key>
<true/>
<key>CSResourcesFileMapped</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2018 - 2023 Ryujinx Team and Contributors.</string>
<string>Copyright © 2018 - 2024 Ryujinx Team and Contributors. Copyright © 2024 - 2025 Ryubing and Contributors.</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.games</string>
<key>LSMinimumSystemVersion</key>

View File

@@ -1175,6 +1175,7 @@
0100EB100AB42000,"FINAL FANTASY XII THE ZODIAC AGE",opengl;vulkan-backend-bug,playable,2024-08-11 07:01:54
010068F00AA78000,"FINAL FANTASY XV POCKET EDITION HD",,playable,2021-01-05 17:52:08
0100CE4010AAC000,"FINAL FANTASY® CRYSTAL CHRONICLES™ Remastered Edition",,playable,2023-04-02 23:39:12
010038B015560000,FINAL FANTASY TACTICS - The Ivalice Chronicles,gpu,boots,2024-09-30 02:59:00
01001BA00AE4E000,"Final Light, The Prison",,playable,2020-07-31 21:48:44
0100FF100FB68000,"Finding Teddy 2 : Definitive Edition",gpu,ingame,2024-04-19 16:51:33
0100F4E013AAE000,"Fire & Water",,playable,2020-12-15 15:43:20
@@ -2271,6 +2272,7 @@
0100ABF008968000,"Pokémon Sword + Pokémon Sword Expansion Pass",deadlock;crash;online-broken;ldn-works;LAN,ingame,2024-08-26 15:40:37
01009AD008C4C000,"Pokémon: Let's Go, Pikachu! demo",slow;demo,playable,2023-11-26 11:23:20
0100000011D90000,"Pokémon™ Brilliant Diamond",gpu;ldn-works,ingame,2024-08-28 13:26:35
010018E011D92000,"Pokémon™ Shining Pearl",gpu;ldn-works,ingame,2024-08-28 13:26:35
010015F008C54000,"Pokémon™ HOME",Needs Update;crash;services,menus,2020-12-06 06:01:51
01001F5010DFA000,"Pokémon™ Legends: Arceus",gpu;Needs Update;ldn-works,ingame,2024-09-19 10:02:02
01005D100807A000,"Pokémon™ Quest",,playable,2022-02-22 16:12:32
@@ -2278,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™: Lets Go, Eevee!",crash;nvdec;online-broken;ldn-broken,ingame,2024-06-01 15:03:04
010003F003A34000,"Pokémon™: Lets 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
@@ -2707,6 +2710,8 @@
01008F701C074000,"SONIC SUPERSTARS",gpu;nvdec,ingame,2023-10-28 17:48:07
010088801C150000,"Sonic Superstars Digital Art Book with Mini Digital Soundtrack",,playable,2024-08-20 13:26:56
01005EA01C0FC000,"SONIC X SHADOW GENERATIONS",crash,ingame,2025-01-07 04:20:45
010064B0242BE000,"Sonic Racing: CrossWorlds - Demo",gpu;vulkan-backend-bug;demo,ingame,2024-09-25 11:27:53
01006E001823C000,"Sonic Racing: CrossWorlds",gpu;vulkan-backend-bug;ldn-broken,ingame,2024-09-30 17:23:00
010064F00C212000,"Soul Axiom Rebooted",nvdec;slow,ingame,2020-09-04 12:41:01
0100F2100F0B2000,"Soul Searching",,playable,2020-07-09 18:39:07
01008F2005154000,"South Park™: The Fractured but Whole™ - Standard Edition",slow;online-broken;vulkan-backend-bug;gpu,ingame,2025-01-21 17:35:10
@@ -2864,11 +2869,13 @@
0100BC0018138000,"Super Mario RPG™",gpu;audio;nvdec,ingame,2024-06-19 17:43:42
,"Super Mario World",homebrew,boots,2024-06-13 01:40:31
010049900F546000,"Super Mario™ 3D All-Stars",services-horizon;slow;vulkan;amd-vendor-bug,ingame,2024-05-07 02:38:16
010099C022B96000,"Super Mario Galaxy",slow;vulkan;amd-vendor-bug;vulkan-vendor-bug,ingame,2025-10-01 15:30:00
0100FD8022DAA000,"Super Mario Galaxy 2",slow;vulkan;amd-vendor-bug;vulkan-vendor-bug;deadlock,ingame,2025-10-04 18:50:00
010028600EBDA000,"Super Mario™ 3D World + Bowsers Fury",ldn-works,playable,2024-07-31 10:45:37
01004F8006A78000,"Super Meat Boy",services,playable,2020-04-02 23:10:07
01009C200D60E000,"Super Meat Boy Forever",gpu,boots,2021-04-26 14:25:39
0100BDD00EC5C000,"Super Mega Space Blaster Special Turbo",online,playable,2020-08-06 12:13:25
010031F019294000,"Super Monkey Ball Banana Rumble",,playable,2024-06-28 10:39:18
010031F019294000,"Super Monkey Ball Banana Rumble",ldn-broken,playable,2025-10-01 18:03:00
0100B2A00E1E0000,"Super Monkey Ball: Banana Blitz HD",online-broken,playable,2022-09-16 13:16:25
01006D000D2A0000,"Super Mutant Alien Assault",,playable,2020-06-07 23:32:45
01004D600AC14000,"Super Neptunia RPG",nvdec,playable,2022-08-17 16:38:52
@@ -2934,6 +2941,7 @@
0100B76011DAA000,"Taxi Chaos",slow;online-broken;UE4,playable,2022-10-25 19:13:00
0100F43011E5A000,"Tcheco in the Castle of Lucio",,playable,2020-06-27 13:35:43
010092B0091D0000,"Team Sonic Racing",online-broken;ldn-works,playable,2024-02-05 15:05:27
010084B00B36E000,"Team Sonic Racing",online-broken;ldn-works,playable,2024-02-05 15:05:27
0100FE701475A000,"Teenage Mutant Ninja Turtles: Shredder's Revenge",deadlock;crash,boots,2024-09-28 09:31:39
01005CF01E784000,"Teenage Mutant Ninja Turtles: Splintered Fate",,playable,2024-08-03 13:50:42
0100FDB0154E4000,"Teenage Mutant Ninja Turtles: The Cowabunga Collection",,playable,2024-01-22 19:39:04
@@ -3220,6 +3228,7 @@
010038400C2FE000,"TY the Tasmanian Tiger™ HD",32-bit;crash;nvdec,menus,2020-12-17 21:15:00
010073A00C4B2000,"Tyd wag vir Niemand",,playable,2021-03-02 13:39:53
0100D5B00D6DA000,"Type:Rider",,playable,2021-01-06 13:12:55
01008AF01AD22000,"The Patrick Star Game",,playable,2025-10-01 17:55:30
010040D01222C000,"UBERMOSH: SANTICIDE",,playable,2020-11-27 15:05:01
0100992010BF8000,"Ubongo",,playable,2021-02-04 21:15:01
010079000B56C000,"UglyDolls: An Imperfect Adventure",nvdec;UE4,playable,2022-08-25 14:42:16
@@ -3466,3 +3475,6 @@
0100F4401940A000,"超探偵事件簿 レインコード (Master Detective Archives: Rain Code)",crash,ingame,2024-02-12 20:58:31
010064801A01C000,"超次元ゲイム ネプテューヌ GameMaker R:Evolution",crash,nothing,2023-10-30 22:37:40
0100F3400332C000,"ブレイド2",deadlock;amd-vendor-bug,ingame,2024-03-28 14:31:41
010075000ECBE000,"超级马力欧 奥德赛",nvdec;intel-vendor-bug;mac-bug,playable,2024-08-25 01:32:34
010075100E8EC000,"马力欧卡丁车8 豪华版",32-bit;ldn-works;LAN;amd-vendor-bug,playable,2024-09-19 11:55:17
0100E8C00F506000,"新 超级马力欧兄弟U 豪华版",32-bit,playable,2023-10-08 02:06:37
1 title_id game_name labels status last_updated
1175 0100EB100AB42000 FINAL FANTASY XII THE ZODIAC AGE opengl;vulkan-backend-bug playable 2024-08-11 07:01:54
1176 010068F00AA78000 FINAL FANTASY XV POCKET EDITION HD playable 2021-01-05 17:52:08
1177 0100CE4010AAC000 FINAL FANTASY® CRYSTAL CHRONICLES™ Remastered Edition playable 2023-04-02 23:39:12
1178 010038B015560000 FINAL FANTASY TACTICS - The Ivalice Chronicles gpu boots 2024-09-30 02:59:00
1179 01001BA00AE4E000 Final Light, The Prison playable 2020-07-31 21:48:44
1180 0100FF100FB68000 Finding Teddy 2 : Definitive Edition gpu ingame 2024-04-19 16:51:33
1181 0100F4E013AAE000 Fire & Water playable 2020-12-15 15:43:20
2272 0100ABF008968000 Pokémon Sword + Pokémon Sword Expansion Pass deadlock;crash;online-broken;ldn-works;LAN ingame 2024-08-26 15:40:37
2273 01009AD008C4C000 Pokémon: Let's Go, Pikachu! demo slow;demo playable 2023-11-26 11:23:20
2274 0100000011D90000 Pokémon™ Brilliant Diamond gpu;ldn-works ingame 2024-08-28 13:26:35
2275 010018E011D92000 Pokémon™ Shining Pearl gpu;ldn-works ingame 2024-08-28 13:26:35
2276 010015F008C54000 Pokémon™ HOME Needs Update;crash;services menus 2020-12-06 06:01:51
2277 01001F5010DFA000 Pokémon™ Legends: Arceus gpu;Needs Update;ldn-works ingame 2024-09-19 10:02:02
2278 01005D100807A000 Pokémon™ Quest playable 2022-02-22 16:12:32
2280 01008F6008C5E000 Pokémon™ Violet gpu;nvdec;ldn-works;amd-vendor-bug;mac-bug ingame 2024-07-30 02:51:48
2281 0100187003A36000 Pokémon™: Let’s Go, Eevee! crash;nvdec;online-broken;ldn-broken ingame 2024-06-01 15:03:04
2282 010003F003A34000 Pokémon™: Let’s Go, Pikachu! crash;nvdec;online-broken;ldn-broken ingame 2024-03-15 07:55:41
2283 0100F43008C44000 Pokémon Legends: Z-A gpu;crash;ldn-broken ingame 2025-10-16 19:13:00
2284 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
2285 010030D005AE6000 Pokkén Tournament™ DX Demo demo;opengl-backend-bug playable 2022-08-10 12:03:19
2286 0100A3500B4EC000 Polandball: Can Into Space playable 2020-06-25 15:13:26
2710 01008F701C074000 SONIC SUPERSTARS gpu;nvdec ingame 2023-10-28 17:48:07
2711 010088801C150000 Sonic Superstars Digital Art Book with Mini Digital Soundtrack playable 2024-08-20 13:26:56
2712 01005EA01C0FC000 SONIC X SHADOW GENERATIONS crash ingame 2025-01-07 04:20:45
2713 010064B0242BE000 Sonic Racing: CrossWorlds - Demo gpu;vulkan-backend-bug;demo ingame 2024-09-25 11:27:53
2714 01006E001823C000 Sonic Racing: CrossWorlds gpu;vulkan-backend-bug;ldn-broken ingame 2024-09-30 17:23:00
2715 010064F00C212000 Soul Axiom Rebooted nvdec;slow ingame 2020-09-04 12:41:01
2716 0100F2100F0B2000 Soul Searching playable 2020-07-09 18:39:07
2717 01008F2005154000 South Park™: The Fractured but Whole™ - Standard Edition slow;online-broken;vulkan-backend-bug;gpu ingame 2025-01-21 17:35:10
2869 0100BC0018138000 Super Mario RPG™ gpu;audio;nvdec ingame 2024-06-19 17:43:42
2870 Super Mario World homebrew boots 2024-06-13 01:40:31
2871 010049900F546000 Super Mario™ 3D All-Stars services-horizon;slow;vulkan;amd-vendor-bug ingame 2024-05-07 02:38:16
2872 010099C022B96000 Super Mario Galaxy slow;vulkan;amd-vendor-bug;vulkan-vendor-bug ingame 2025-10-01 15:30:00
2873 0100FD8022DAA000 Super Mario Galaxy 2 slow;vulkan;amd-vendor-bug;vulkan-vendor-bug;deadlock ingame 2025-10-04 18:50:00
2874 010028600EBDA000 Super Mario™ 3D World + Bowser’s Fury ldn-works playable 2024-07-31 10:45:37
2875 01004F8006A78000 Super Meat Boy services playable 2020-04-02 23:10:07
2876 01009C200D60E000 Super Meat Boy Forever gpu boots 2021-04-26 14:25:39
2877 0100BDD00EC5C000 Super Mega Space Blaster Special Turbo online playable 2020-08-06 12:13:25
2878 010031F019294000 Super Monkey Ball Banana Rumble ldn-broken playable 2024-06-28 10:39:18 2025-10-01 18:03:00
2879 0100B2A00E1E0000 Super Monkey Ball: Banana Blitz HD online-broken playable 2022-09-16 13:16:25
2880 01006D000D2A0000 Super Mutant Alien Assault playable 2020-06-07 23:32:45
2881 01004D600AC14000 Super Neptunia RPG nvdec playable 2022-08-17 16:38:52
2941 0100B76011DAA000 Taxi Chaos slow;online-broken;UE4 playable 2022-10-25 19:13:00
2942 0100F43011E5A000 Tcheco in the Castle of Lucio playable 2020-06-27 13:35:43
2943 010092B0091D0000 Team Sonic Racing online-broken;ldn-works playable 2024-02-05 15:05:27
2944 010084B00B36E000 Team Sonic Racing online-broken;ldn-works playable 2024-02-05 15:05:27
2945 0100FE701475A000 Teenage Mutant Ninja Turtles: Shredder's Revenge deadlock;crash boots 2024-09-28 09:31:39
2946 01005CF01E784000 Teenage Mutant Ninja Turtles: Splintered Fate playable 2024-08-03 13:50:42
2947 0100FDB0154E4000 Teenage Mutant Ninja Turtles: The Cowabunga Collection playable 2024-01-22 19:39:04
3228 010038400C2FE000 TY the Tasmanian Tiger™ HD 32-bit;crash;nvdec menus 2020-12-17 21:15:00
3229 010073A00C4B2000 Tyd wag vir Niemand playable 2021-03-02 13:39:53
3230 0100D5B00D6DA000 Type:Rider playable 2021-01-06 13:12:55
3231 01008AF01AD22000 The Patrick Star Game playable 2025-10-01 17:55:30
3232 010040D01222C000 UBERMOSH: SANTICIDE playable 2020-11-27 15:05:01
3233 0100992010BF8000 Ubongo playable 2021-02-04 21:15:01
3234 010079000B56C000 UglyDolls: An Imperfect Adventure nvdec;UE4 playable 2022-08-25 14:42:16
3475 0100F4401940A000 超探偵事件簿 レインコード (Master Detective Archives: Rain Code) crash ingame 2024-02-12 20:58:31
3476 010064801A01C000 超次元ゲイム ネプテューヌ GameMaker R:Evolution crash nothing 2023-10-30 22:37:40
3477 0100F3400332C000 ゼノブレイド2 deadlock;amd-vendor-bug ingame 2024-03-28 14:31:41
3478 010075000ECBE000 超级马力欧 奥德赛 nvdec;intel-vendor-bug;mac-bug playable 2024-08-25 01:32:34
3479 010075100E8EC000 马力欧卡丁车8 豪华版 32-bit;ldn-works;LAN;amd-vendor-bug playable 2024-09-19 11:55:17
3480 0100E8C00F506000 新 超级马力欧兄弟U 豪华版 32-bit playable 2023-10-08 02:06:37

View File

@@ -1,5 +1,4 @@
using System;
using System.Diagnostics.CodeAnalysis;
namespace ARMeilleure.CodeGen.X86
{

View File

@@ -2,7 +2,6 @@ using ARMeilleure.CodeGen.RegisterAllocators;
using ARMeilleure.IntermediateRepresentation;
using Microsoft.IO;
using Ryujinx.Common.Memory;
using System.IO;
using System.Numerics;
namespace ARMeilleure.CodeGen.X86

View File

@@ -1,5 +1,3 @@
using System.Diagnostics.CodeAnalysis;
namespace ARMeilleure.CodeGen.X86
{
enum X86Register

View File

@@ -2,7 +2,6 @@ using ARMeilleure.Decoders;
using ARMeilleure.IntermediateRepresentation;
using ARMeilleure.Translation;
using System;
using System.Diagnostics.CodeAnalysis;
using static ARMeilleure.Instructions.InstEmitHelper;
namespace ARMeilleure.Instructions

View File

@@ -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();

View File

@@ -1,5 +1,4 @@
using System;
using System.Diagnostics.CodeAnalysis;
namespace ARMeilleure.IntermediateRepresentation
{

View File

@@ -1,9 +1,11 @@
using Ryujinx.Audio.Renderer.Server;
using Ryujinx.Audio.Renderer.Server.MemoryPool;
using System.Runtime.InteropServices;
namespace Ryujinx.Audio.Renderer.Common
{
/// <summary>
/// Represents the input parameter for <see cref="Server.BehaviourContext"/>.
/// Represents the input parameter for <see cref="BehaviourInfo"/>.
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct BehaviourParameter
@@ -21,7 +23,7 @@ namespace Ryujinx.Audio.Renderer.Common
/// <summary>
/// The flags given controlling behaviour of the audio renderer
/// </summary>
/// <remarks>See <see cref="Server.BehaviourContext.UpdateFlags(ulong)"/> and <see cref="Server.BehaviourContext.IsMemoryPoolForceMappingEnabled"/>.</remarks>
/// <remarks>See <see cref="BehaviourInfo.UpdateFlags(ulong)"/> and <see cref="BehaviourInfo.IsMemoryPoolForceMappingEnabled"/>.</remarks>
public ulong Flags;
/// <summary>
@@ -43,7 +45,7 @@ namespace Ryujinx.Audio.Renderer.Common
/// <summary>
/// Extra information given with the <see cref="ResultCode"/>
/// </summary>
/// <remarks>This is usually used to report a faulting cpu address when a <see cref="Server.MemoryPool.MemoryPoolState"/> mapping fail.</remarks>
/// <remarks>This is usually used to report a faulting cpu address when a <see cref="MemoryPoolInfo"/> mapping fail.</remarks>
public ulong ExtraErrorInfo;
}
}

View File

@@ -1,4 +1,5 @@
using Ryujinx.Audio.Renderer.Dsp.State;
using Ryujinx.Audio.Renderer.Parameter;
using Ryujinx.Common.Memory;
using Ryujinx.Common.Utilities;
using System;
@@ -11,7 +12,7 @@ namespace Ryujinx.Audio.Renderer.Common
/// </summary>
/// <remarks>This is shared between the server and audio processor.</remarks>
[StructLayout(LayoutKind.Sequential, Pack = Align)]
public struct VoiceUpdateState
public struct VoiceState
{
public const int Align = 0x10;
public const int BiquadStateOffset = 0x0;
@@ -25,7 +26,7 @@ namespace Ryujinx.Audio.Renderer.Common
/// The total amount of samples that was played.
/// </summary>
/// <remarks>This is reset to 0 when a <see cref="WaveBuffer"/> finishes playing and <see cref="WaveBuffer.IsEndOfStream"/> is set.</remarks>
/// <remarks>This is reset to 0 when looping while <see cref="Parameter.VoiceInParameter.DecodingBehaviour.PlayedSampleCountResetWhenLooping"/> is set.</remarks>
/// <remarks>This is reset to 0 when looping while <see cref="VoiceInParameter1.DecodingBehaviour.PlayedSampleCountResetWhenLooping"/> is set.</remarks>
public ulong PlayedSampleCount;
/// <summary>

View File

@@ -1,5 +1,7 @@
using Ryujinx.Audio.Renderer.Dsp.State;
using Ryujinx.Audio.Renderer.Parameter;
using Ryujinx.Audio.Renderer.Parameter.Effect;
using Ryujinx.Common.Memory;
using System;
using System.Runtime.CompilerServices;
@@ -9,6 +11,112 @@ namespace Ryujinx.Audio.Renderer.Dsp
{
private const int FixedPointPrecisionForParameter = 14;
public static BiquadFilterParameter1 ToBiquadFilterParameter1(BiquadFilterParameter2 parameter)
{
BiquadFilterParameter1 result = new()
{
Enable = parameter.Enable, Numerator = new Array3<short>(), Denominator = new Array2<short>()
};
Span<short> resultNumeratorSpan = result.Numerator.AsSpan();
Span<short> resultDenominatorSpan = result.Denominator.AsSpan();
Span<float> parameterNumeratorSpan = parameter.Numerator.AsSpan();
Span<float> parameterDenominatorSpan = parameter.Denominator.AsSpan();
resultNumeratorSpan[0] = (short)FixedPointHelper.ToFixed(parameterNumeratorSpan[0], FixedPointPrecisionForParameter);
resultNumeratorSpan[1] = (short)FixedPointHelper.ToFixed(parameterNumeratorSpan[1], FixedPointPrecisionForParameter);
resultNumeratorSpan[2] = (short)FixedPointHelper.ToFixed(parameterNumeratorSpan[2], FixedPointPrecisionForParameter);
resultDenominatorSpan[0] = (short)FixedPointHelper.ToFixed(parameterDenominatorSpan[0], FixedPointPrecisionForParameter);
resultDenominatorSpan[1] = (short)FixedPointHelper.ToFixed(parameterDenominatorSpan[1], FixedPointPrecisionForParameter);
return result;
}
public static BiquadFilterParameter2 ToBiquadFilterParameter2(BiquadFilterParameter1 parameter)
{
BiquadFilterParameter2 result = new()
{
Enable = parameter.Enable, Numerator = new Array3<float>(), Denominator = new Array2<float>()
};
Span<float> resultNumeratorSpan = result.Numerator.AsSpan();
Span<float> resultDenominatorSpan = result.Denominator.AsSpan();
Span<short> parameterNumeratorSpan = parameter.Numerator.AsSpan();
Span<short> parameterDenominatorSpan = parameter.Denominator.AsSpan();
resultNumeratorSpan[0] = FixedPointHelper.ToFloat(parameterNumeratorSpan[0], FixedPointPrecisionForParameter);
resultNumeratorSpan[1] = FixedPointHelper.ToFloat(parameterNumeratorSpan[1], FixedPointPrecisionForParameter);
resultNumeratorSpan[2] = FixedPointHelper.ToFloat(parameterNumeratorSpan[2], FixedPointPrecisionForParameter);
resultDenominatorSpan[0] = FixedPointHelper.ToFloat(parameterDenominatorSpan[0], FixedPointPrecisionForParameter);
resultDenominatorSpan[1] = FixedPointHelper.ToFloat(parameterDenominatorSpan[1], FixedPointPrecisionForParameter);
return result;
}
public static BiquadFilterEffectParameter1 ToBiquadFilterEffectParameter1(BiquadFilterEffectParameter2 parameter)
{
BiquadFilterEffectParameter1 result = new()
{
Input = parameter.Input,
Output = parameter.Output,
Numerator = new Array3<short>(),
Denominator = new Array2<short>(),
ChannelCount = parameter.ChannelCount,
Status = parameter.Status,
};
Span<short> resultNumeratorSpan = result.Numerator.AsSpan();
Span<short> resultDenominatorSpan = result.Denominator.AsSpan();
Span<float> parameterNumeratorSpan = parameter.Numerator.AsSpan();
Span<float> parameterDenominatorSpan = parameter.Denominator.AsSpan();
resultNumeratorSpan[0] = (short)FixedPointHelper.ToFixed(parameterNumeratorSpan[0], FixedPointPrecisionForParameter);
resultNumeratorSpan[1] = (short)FixedPointHelper.ToFixed(parameterNumeratorSpan[1], FixedPointPrecisionForParameter);
resultNumeratorSpan[2] = (short)FixedPointHelper.ToFixed(parameterNumeratorSpan[2], FixedPointPrecisionForParameter);
resultDenominatorSpan[0] = (short)FixedPointHelper.ToFixed(parameterDenominatorSpan[0], FixedPointPrecisionForParameter);
resultDenominatorSpan[1] = (short)FixedPointHelper.ToFixed(parameterDenominatorSpan[1], FixedPointPrecisionForParameter);
return result;
}
public static BiquadFilterEffectParameter2 ToBiquadFilterEffectParameter2(BiquadFilterEffectParameter1 parameter)
{
BiquadFilterEffectParameter2 result = new()
{
Input = parameter.Input,
Output = parameter.Output,
Numerator = new Array3<float>(),
Denominator = new Array2<float>(),
ChannelCount = parameter.ChannelCount,
Status = parameter.Status,
};
Span<float> resultNumeratorSpan = result.Numerator.AsSpan();
Span<float> resultDenominatorSpan = result.Denominator.AsSpan();
Span<short> parameterNumeratorSpan = parameter.Numerator.AsSpan();
Span<short> parameterDenominatorSpan = parameter.Denominator.AsSpan();
resultNumeratorSpan[0] = FixedPointHelper.ToFloat(parameterNumeratorSpan[0], FixedPointPrecisionForParameter);
resultNumeratorSpan[1] = FixedPointHelper.ToFloat(parameterNumeratorSpan[1], FixedPointPrecisionForParameter);
resultNumeratorSpan[2] = FixedPointHelper.ToFloat(parameterNumeratorSpan[2], FixedPointPrecisionForParameter);
resultDenominatorSpan[0] = FixedPointHelper.ToFloat(parameterDenominatorSpan[0], FixedPointPrecisionForParameter);
resultDenominatorSpan[1] = FixedPointHelper.ToFloat(parameterDenominatorSpan[1], FixedPointPrecisionForParameter);
return result;
}
/// <summary>
/// Apply a single biquad filter.
/// </summary>
@@ -20,21 +128,21 @@ namespace Ryujinx.Audio.Renderer.Dsp
/// <param name="sampleCount">The count of samples to process</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void ProcessBiquadFilter(
ref BiquadFilterParameter parameter,
ref BiquadFilterParameter2 parameter,
ref BiquadFilterState state,
Span<float> outputBuffer,
ReadOnlySpan<float> inputBuffer,
uint sampleCount)
{
Span<short> numeratorSpan = parameter.Numerator.AsSpan();
Span<short> denominatorSpan = parameter.Denominator.AsSpan();
Span<float> numeratorSpan = parameter.Numerator.AsSpan();
Span<float> denominatorSpan = parameter.Denominator.AsSpan();
float a0 = FixedPointHelper.ToFloat(numeratorSpan[0], FixedPointPrecisionForParameter);
float a1 = FixedPointHelper.ToFloat(numeratorSpan[1], FixedPointPrecisionForParameter);
float a2 = FixedPointHelper.ToFloat(numeratorSpan[2], FixedPointPrecisionForParameter);
float a0 = numeratorSpan[0];
float a1 = numeratorSpan[1];
float a2 = numeratorSpan[2];
float b1 = FixedPointHelper.ToFloat(denominatorSpan[0], FixedPointPrecisionForParameter);
float b2 = FixedPointHelper.ToFloat(denominatorSpan[1], FixedPointPrecisionForParameter);
float b1 = denominatorSpan[0];
float b2 = denominatorSpan[1];
for (int i = 0; i < sampleCount; i++)
{
@@ -60,22 +168,22 @@ namespace Ryujinx.Audio.Renderer.Dsp
/// <param name="volume">Mix volume</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void ProcessBiquadFilterAndMix(
ref BiquadFilterParameter parameter,
ref BiquadFilterParameter2 parameter,
ref BiquadFilterState state,
Span<float> outputBuffer,
ReadOnlySpan<float> inputBuffer,
uint sampleCount,
float volume)
{
Span<short> numeratorSpan = parameter.Numerator.AsSpan();
Span<short> denominatorSpan = parameter.Denominator.AsSpan();
Span<float> numeratorSpan = parameter.Numerator.AsSpan();
Span<float> denominatorSpan = parameter.Denominator.AsSpan();
float a0 = FixedPointHelper.ToFloat(numeratorSpan[0], FixedPointPrecisionForParameter);
float a1 = FixedPointHelper.ToFloat(numeratorSpan[1], FixedPointPrecisionForParameter);
float a2 = FixedPointHelper.ToFloat(numeratorSpan[2], FixedPointPrecisionForParameter);
float a0 = numeratorSpan[0];
float a1 = numeratorSpan[1];
float a2 = numeratorSpan[2];
float b1 = FixedPointHelper.ToFloat(denominatorSpan[0], FixedPointPrecisionForParameter);
float b2 = FixedPointHelper.ToFloat(denominatorSpan[1], FixedPointPrecisionForParameter);
float b1 = denominatorSpan[0];
float b2 = denominatorSpan[1];
for (int i = 0; i < sampleCount; i++)
{
@@ -105,7 +213,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
/// <returns>Last filtered sample value</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float ProcessBiquadFilterAndMixRamp(
ref BiquadFilterParameter parameter,
ref BiquadFilterParameter2 parameter,
ref BiquadFilterState state,
Span<float> outputBuffer,
ReadOnlySpan<float> inputBuffer,
@@ -113,15 +221,15 @@ namespace Ryujinx.Audio.Renderer.Dsp
float volume,
float ramp)
{
Span<short> numeratorSpan = parameter.Numerator.AsSpan();
Span<short> denominatorSpan = parameter.Denominator.AsSpan();
Span<float> numeratorSpan = parameter.Numerator.AsSpan();
Span<float> denominatorSpan = parameter.Denominator.AsSpan();
float a0 = FixedPointHelper.ToFloat(numeratorSpan[0], FixedPointPrecisionForParameter);
float a1 = FixedPointHelper.ToFloat(numeratorSpan[1], FixedPointPrecisionForParameter);
float a2 = FixedPointHelper.ToFloat(numeratorSpan[2], FixedPointPrecisionForParameter);
float a0 = numeratorSpan[0];
float a1 = numeratorSpan[1];
float a2 = numeratorSpan[2];
float b1 = FixedPointHelper.ToFloat(denominatorSpan[0], FixedPointPrecisionForParameter);
float b2 = FixedPointHelper.ToFloat(denominatorSpan[1], FixedPointPrecisionForParameter);
float b1 = denominatorSpan[0];
float b2 = denominatorSpan[1];
float mixState = 0f;
@@ -155,7 +263,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
/// <param name="sampleCount">The count of samples to process</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void ProcessBiquadFilter(
ReadOnlySpan<BiquadFilterParameter> parameters,
ReadOnlySpan<BiquadFilterParameter2> parameters,
Span<BiquadFilterState> states,
Span<float> outputBuffer,
ReadOnlySpan<float> inputBuffer,
@@ -163,19 +271,19 @@ namespace Ryujinx.Audio.Renderer.Dsp
{
for (int stageIndex = 0; stageIndex < parameters.Length; stageIndex++)
{
BiquadFilterParameter parameter = parameters[stageIndex];
BiquadFilterParameter2 parameter = parameters[stageIndex];
ref BiquadFilterState state = ref states[stageIndex];
Span<short> numeratorSpan = parameter.Numerator.AsSpan();
Span<short> denominatorSpan = parameter.Denominator.AsSpan();
Span<float> numeratorSpan = parameter.Numerator.AsSpan();
Span<float> denominatorSpan = parameter.Denominator.AsSpan();
float a0 = FixedPointHelper.ToFloat(numeratorSpan[0], FixedPointPrecisionForParameter);
float a1 = FixedPointHelper.ToFloat(numeratorSpan[1], FixedPointPrecisionForParameter);
float a2 = FixedPointHelper.ToFloat(numeratorSpan[2], FixedPointPrecisionForParameter);
float a0 = numeratorSpan[0];
float a1 = numeratorSpan[1];
float a2 = numeratorSpan[2];
float b1 = FixedPointHelper.ToFloat(denominatorSpan[0], FixedPointPrecisionForParameter);
float b2 = FixedPointHelper.ToFloat(denominatorSpan[1], FixedPointPrecisionForParameter);
float b1 = denominatorSpan[0];
float b2 = denominatorSpan[1];
for (int i = 0; i < sampleCount; i++)
{
@@ -204,8 +312,8 @@ namespace Ryujinx.Audio.Renderer.Dsp
/// <param name="volume">Mix volume</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void ProcessDoubleBiquadFilterAndMix(
ref BiquadFilterParameter parameter0,
ref BiquadFilterParameter parameter1,
ref BiquadFilterParameter2 parameter0,
ref BiquadFilterParameter2 parameter1,
ref BiquadFilterState state0,
ref BiquadFilterState state1,
Span<float> outputBuffer,
@@ -213,25 +321,25 @@ namespace Ryujinx.Audio.Renderer.Dsp
uint sampleCount,
float volume)
{
Span<short> numerator0Span = parameter0.Numerator.AsSpan();
Span<short> numerator1Span = parameter1.Numerator.AsSpan();
Span<short> denominator0Span = parameter0.Denominator.AsSpan();
Span<short> denominator1Span = parameter1.Denominator.AsSpan();
Span<float> numerator0Span = parameter0.Numerator.AsSpan();
Span<float> numerator1Span = parameter1.Numerator.AsSpan();
Span<float> denominator0Span = parameter0.Denominator.AsSpan();
Span<float> denominator1Span = parameter1.Denominator.AsSpan();
float a00 = FixedPointHelper.ToFloat(numerator0Span[0], FixedPointPrecisionForParameter);
float a10 = FixedPointHelper.ToFloat(numerator0Span[1], FixedPointPrecisionForParameter);
float a20 = FixedPointHelper.ToFloat(numerator0Span[2], FixedPointPrecisionForParameter);
float a00 = numerator0Span[0];
float a10 = numerator0Span[1];
float a20 = numerator0Span[2];
float b10 = FixedPointHelper.ToFloat(denominator0Span[0], FixedPointPrecisionForParameter);
float b20 = FixedPointHelper.ToFloat(denominator0Span[1], FixedPointPrecisionForParameter);
float b10 = denominator0Span[0];
float b20 = denominator0Span[1];
float a01 = FixedPointHelper.ToFloat(numerator1Span[0], FixedPointPrecisionForParameter);
float a11 = FixedPointHelper.ToFloat(numerator1Span[1], FixedPointPrecisionForParameter);
float a21 = FixedPointHelper.ToFloat(numerator1Span[2], FixedPointPrecisionForParameter);
float a01 = numerator1Span[0];
float a11 = numerator1Span[1];
float a21 = numerator1Span[2];
float b11 = FixedPointHelper.ToFloat(denominator1Span[0], FixedPointPrecisionForParameter);
float b21 = FixedPointHelper.ToFloat(denominator1Span[1], FixedPointPrecisionForParameter);
float b11 = denominator1Span[0];
float b21 = denominator1Span[1];
for (int i = 0; i < sampleCount; i++)
{
@@ -269,8 +377,8 @@ namespace Ryujinx.Audio.Renderer.Dsp
/// <returns>Last filtered sample value</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float ProcessDoubleBiquadFilterAndMixRamp(
ref BiquadFilterParameter parameter0,
ref BiquadFilterParameter parameter1,
ref BiquadFilterParameter2 parameter0,
ref BiquadFilterParameter2 parameter1,
ref BiquadFilterState state0,
ref BiquadFilterState state1,
Span<float> outputBuffer,
@@ -279,24 +387,24 @@ namespace Ryujinx.Audio.Renderer.Dsp
float volume,
float ramp)
{
Span<short> numerator0Span = parameter0.Numerator.AsSpan();
Span<short> numerator1Span = parameter1.Numerator.AsSpan();
Span<short> denominator0Span = parameter0.Denominator.AsSpan();
Span<short> denominator1Span = parameter1.Denominator.AsSpan();
Span<float> numerator0Span = parameter0.Numerator.AsSpan();
Span<float> numerator1Span = parameter1.Numerator.AsSpan();
Span<float> denominator0Span = parameter0.Denominator.AsSpan();
Span<float> denominator1Span = parameter1.Denominator.AsSpan();
float a00 = FixedPointHelper.ToFloat(numerator0Span[0], FixedPointPrecisionForParameter);
float a10 = FixedPointHelper.ToFloat(numerator0Span[1], FixedPointPrecisionForParameter);
float a20 = FixedPointHelper.ToFloat(numerator0Span[2], FixedPointPrecisionForParameter);
float a00 = numerator0Span[0];
float a10 = numerator0Span[1];
float a20 = numerator0Span[2];
float b10 = FixedPointHelper.ToFloat(denominator0Span[0], FixedPointPrecisionForParameter);
float b20 = FixedPointHelper.ToFloat(denominator0Span[1], FixedPointPrecisionForParameter);
float b10 = denominator0Span[0];
float b20 = denominator0Span[1];
float a01 = FixedPointHelper.ToFloat(numerator1Span[0], FixedPointPrecisionForParameter);
float a11 = FixedPointHelper.ToFloat(numerator1Span[1], FixedPointPrecisionForParameter);
float a21 = FixedPointHelper.ToFloat(numerator1Span[2], FixedPointPrecisionForParameter);
float a01 = numerator1Span[0];
float a11 = numerator1Span[1];
float a21 = numerator1Span[2];
float b11 = FixedPointHelper.ToFloat(denominator1Span[0], FixedPointPrecisionForParameter);
float b21 = FixedPointHelper.ToFloat(denominator1Span[1], FixedPointPrecisionForParameter);
float b11 = denominator1Span[0];
float b21 = denominator1Span[1];
float mixState = 0f;

View File

@@ -2,7 +2,7 @@ using Ryujinx.Audio.Common;
using Ryujinx.Audio.Renderer.Common;
using Ryujinx.Audio.Renderer.Server.Voice;
using System;
using static Ryujinx.Audio.Renderer.Parameter.VoiceInParameter;
using Ryujinx.Audio.Renderer.Parameter;
using WaveBuffer = Ryujinx.Audio.Renderer.Common.WaveBuffer;
namespace Ryujinx.Audio.Renderer.Dsp.Command
@@ -11,38 +11,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.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<VoiceUpdateState> 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 VoiceState serverState, Memory<VoiceUpdateState> 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;
OutputBufferIndex = outputBufferIndex;
SampleRate = serverState.SampleRate;
Pitch = serverState.Pitch;
SampleRate = serverInfo.SampleRate;
Pitch = serverInfo.Pitch;
Span<Server.Voice.WaveBuffer> waveBufferSpan = serverState.WaveBuffers.AsSpan();
WaveBuffers = new WaveBuffer[Constants.VoiceWaveBufferCount];
Span<Server.Voice.WaveBuffer> waveBufferSpan = serverInfo.WaveBuffers.AsSpan();
for (int i = 0; i < WaveBuffers.Length; i++)
{
@@ -51,10 +54,12 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
WaveBuffers[i] = voiceWaveBuffer.ToCommon(1);
}
AdpcmParameter = serverState.DataSourceStateAddressInfo.GetReference(true);
AdpcmParameterSize = serverState.DataSourceStateAddressInfo.Size;
AdpcmParameter = serverInfo.DataSourceStateAddressInfo.GetReference(true);
AdpcmParameterSize = serverInfo.DataSourceStateAddressInfo.Size;
State = state;
DecodingBehaviour = serverState.DecodingBehaviour;
DecodingBehaviour = serverInfo.DecodingBehaviour;
return this;
}
public void Process(CommandList context)

View File

@@ -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)]

View File

@@ -9,39 +9,44 @@ 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 BiquadFilterParameter _parameter;
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<VoiceUpdateState> 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,
uint outputBufferIndex,
int lastSampleIndex,
Memory<VoiceUpdateState> state,
ref BiquadFilterParameter filter,
Memory<VoiceState> state,
ref BiquadFilterParameter2 filter,
Memory<BiquadFilterState> biquadFilterState,
Memory<BiquadFilterState> previousBiquadFilterState,
bool needInitialization,
@@ -68,6 +73,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
NeedInitialization = needInitialization;
HasVolumeRamp = hasVolumeRamp;
IsFirstMixBuffer = isFirstMixBuffer;
return this;
}
public void Process(CommandList context)

View File

@@ -8,22 +8,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.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 BiquadFilterParameter _parameter;
private BiquadFilterParameter2 _parameter;
public BiquadFilterCommand(
public BiquadFilterCommand()
{
}
public BiquadFilterCommand Initialize(
int baseIndex,
ref BiquadFilterParameter filter,
ref BiquadFilterParameter2 filter,
Memory<BiquadFilterState> biquadFilterStateMemory,
int inputBufferOffset,
int outputBufferOffset,
@@ -38,6 +43,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
Enabled = true;
NodeId = nodeId;
return this;
}
public void Process(CommandList context)

View File

@@ -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)]

View File

@@ -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)

View File

@@ -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)

View File

@@ -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;
@@ -129,7 +130,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
{
startTime = PerformanceCounter.ElapsedNanoseconds;
}
command.Process(this);
if (shouldMeter)
@@ -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();
}

View File

@@ -12,6 +12,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
Volume,
VolumeRamp,
BiquadFilter,
BiquadFilterFloatCoeff, // new
Mix,
MixRamp,
MixRampGrouped,
@@ -31,9 +32,17 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
LimiterVersion1,
LimiterVersion2,
MultiTapBiquadFilter,
MultiTapBiquadFilterFloatCoeff, // new
CaptureBuffer,
Compressor,
BiquadFilterAndMix,
BiquadFilterAndMixFloatCoeff, // new
MultiTapBiquadFilterAndMix,
MultiTapBiquadFilterAndMixFloatCoef, // new
AuxiliaryBufferGrouped, // new
FillMixBuffer, // new
BiquadFilterCrossFade, // new
MultiTapBiquadFilterCrossFade, // new
FillBuffer, // new
}
}

View File

@@ -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)

View File

@@ -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)

View File

@@ -2,7 +2,7 @@ using Ryujinx.Audio.Common;
using Ryujinx.Audio.Renderer.Common;
using Ryujinx.Audio.Renderer.Server.Voice;
using System;
using static Ryujinx.Audio.Renderer.Parameter.VoiceInParameter;
using Ryujinx.Audio.Renderer.Parameter;
using WaveBuffer = Ryujinx.Audio.Renderer.Common.WaveBuffer;
namespace Ryujinx.Audio.Renderer.Dsp.Command
@@ -11,51 +11,54 @@ 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<VoiceUpdateState> 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 VoiceState serverState, Memory<VoiceUpdateState> 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;
ChannelIndex = channelIndex;
ChannelCount = serverState.ChannelsCount;
SampleFormat = serverState.SampleFormat;
SrcQuality = serverState.SrcQuality;
ChannelCount = serverInfo.ChannelsCount;
SampleFormat = serverInfo.SampleFormat;
SrcQuality = serverInfo.SrcQuality;
CommandType = GetCommandTypeBySampleFormat(SampleFormat);
OutputBufferIndex = (ushort)(channelIndex + outputBufferIndex);
SampleRate = serverState.SampleRate;
Pitch = serverState.Pitch;
SampleRate = serverInfo.SampleRate;
Pitch = serverInfo.Pitch;
Span<Server.Voice.WaveBuffer> waveBufferSpan = serverState.WaveBuffers.AsSpan();
WaveBuffers = new WaveBuffer[Constants.VoiceWaveBufferCount];
Span<Server.Voice.WaveBuffer> waveBufferSpan = serverInfo.WaveBuffers.AsSpan();
for (int i = 0; i < WaveBuffers.Length; i++)
{
@@ -66,12 +69,14 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
if (SampleFormat == SampleFormat.Adpcm)
{
ExtraParameter = serverState.DataSourceStateAddressInfo.GetReference(true);
ExtraParameterSize = serverState.DataSourceStateAddressInfo.Size;
ExtraParameter = serverInfo.DataSourceStateAddressInfo.GetReference(true);
ExtraParameterSize = serverInfo.DataSourceStateAddressInfo.Size;
}
State = state;
DecodingBehaviour = serverState.DecodingBehaviour;
DecodingBehaviour = serverInfo.DecodingBehaviour;
return this;
}
private static CommandType GetCommandTypeBySampleFormat(SampleFormat sampleFormat)

View File

@@ -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)]

View File

@@ -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)]

View File

@@ -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<VoiceUpdateState> State { get; }
public Memory<float> DepopBuffer { get; }
public Memory<VoiceState> State { get; private set; }
public Memory<float> DepopBuffer { get; private set; }
public DepopPrepareCommand(Memory<VoiceUpdateState> 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,11 +38,13 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
State = state;
DepopBuffer = depopBuffer;
return this;
}
public void Process(CommandList context)
{
ref VoiceUpdateState state = ref State.Span[0];
ref VoiceState state = ref State.Span[0];
Span<float> depopBuffer = DepopBuffer.Span;
Span<float> lastSamplesSpan = state.LastSamples.AsSpan();

View File

@@ -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;
@@ -42,14 +47,16 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
InputBufferIndices[i] = (ushort)(bufferOffset + inputSpan[i]);
}
if (sink.UpsamplerState != null)
if (sink.UpsamplerInfo != null)
{
Buffers = sink.UpsamplerState.OutputBuffer;
Buffers = sink.UpsamplerInfo.OutputBuffer;
}
else
{
Buffers = buffers;
}
return this;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]

View File

@@ -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)]

View File

@@ -0,0 +1,73 @@
using Ryujinx.Audio.Renderer.Server.Splitter;
using System.Runtime.CompilerServices;
namespace Ryujinx.Audio.Renderer.Dsp.Command
{
public class FillBufferCommand : ICommand
{
public bool Enabled { get; set; }
public int NodeId { get; private set; }
public CommandType CommandType => CommandType.FillBuffer;
public uint EstimatedProcessingTime { get; set; }
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()
{
}
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;
}
Length = length;
Value = value;
return this;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void ProcessFillBuffer()
{
if (IsV2)
{
for (int i = 0; i < Length; i++)
{
Destination2.PreviousMixBufferVolume[i] = Value;
}
}
else
{
for (int i = 0; i < Length; i++)
{
Destination1.PreviousMixBufferVolume[i] = Value;
}
}
}
public void Process(CommandList context)
{
ProcessFillBuffer();
}
}
}

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)]

View File

@@ -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<VoiceUpdateState> 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<VoiceUpdateState> 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)]

View File

@@ -8,29 +8,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.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<VoiceUpdateState> State { get; }
public Memory<VoiceState> State { get; private set; }
public MixRampGroupedCommand(
public MixRampGroupedCommand()
{
}
public MixRampGroupedCommand Initialize(
uint mixBufferCount,
uint inputBufferIndex,
uint outputBufferIndex,
ReadOnlySpan<float> volume0,
ReadOnlySpan<float> volume1,
Memory<VoiceUpdateState> state,
Memory<VoiceState> state,
int nodeId)
{
Enabled = true;
@@ -52,6 +57,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
}
State = state;
return this;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -79,7 +86,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
public void Process(CommandList context)
{
ref VoiceUpdateState state = ref State.Span[0];
ref VoiceState state = ref State.Span[0];
Span<float> lastSamplesSpan = state.LastSamples.AsSpan();

View File

@@ -9,44 +9,49 @@ 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 BiquadFilterParameter _parameter0;
private BiquadFilterParameter _parameter1;
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<VoiceUpdateState> 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,
uint outputBufferIndex,
int lastSampleIndex,
Memory<VoiceUpdateState> state,
ref BiquadFilterParameter filter0,
ref BiquadFilterParameter filter1,
Memory<VoiceState> state,
ref BiquadFilterParameter2 filter0,
ref BiquadFilterParameter2 filter1,
Memory<BiquadFilterState> biquadFilterState0,
Memory<BiquadFilterState> biquadFilterState1,
Memory<BiquadFilterState> previousBiquadFilterState0,
@@ -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)

View File

@@ -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 BiquadFilterParameter[] _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<BiquadFilterParameter> 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);
}
}
}

View File

@@ -2,7 +2,7 @@ using Ryujinx.Audio.Common;
using Ryujinx.Audio.Renderer.Common;
using Ryujinx.Audio.Renderer.Server.Voice;
using System;
using static Ryujinx.Audio.Renderer.Parameter.VoiceInParameter;
using Ryujinx.Audio.Renderer.Parameter;
using WaveBuffer = Ryujinx.Audio.Renderer.Common.WaveBuffer;
namespace Ryujinx.Audio.Renderer.Dsp.Command
@@ -11,39 +11,42 @@ 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<VoiceUpdateState> State { get; }
public DecodingBehaviour DecodingBehaviour { get; }
public Memory<VoiceState> State { get; private set; }
public DecodingBehaviour DecodingBehaviour { get; private set; }
public PcmFloatDataSourceCommandVersion1(ref VoiceState serverState, Memory<VoiceUpdateState> 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;
OutputBufferIndex = (ushort)(channelIndex + outputBufferIndex);
SampleRate = serverState.SampleRate;
SampleRate = serverInfo.SampleRate;
ChannelIndex = channelIndex;
ChannelCount = serverState.ChannelsCount;
Pitch = serverState.Pitch;
WaveBuffers = new WaveBuffer[Constants.VoiceWaveBufferCount];
ChannelCount = serverInfo.ChannelsCount;
Pitch = serverInfo.Pitch;
Span<Server.Voice.WaveBuffer> waveBufferSpan = serverState.WaveBuffers.AsSpan();
Span<Server.Voice.WaveBuffer> waveBufferSpan = serverInfo.WaveBuffers.AsSpan();
for (int i = 0; i < WaveBuffers.Length; i++)
{
@@ -53,7 +56,9 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
}
State = state;
DecodingBehaviour = serverState.DecodingBehaviour;
DecodingBehaviour = serverInfo.DecodingBehaviour;
return this;
}
public void Process(CommandList context)

View File

@@ -2,7 +2,7 @@ using Ryujinx.Audio.Common;
using Ryujinx.Audio.Renderer.Common;
using Ryujinx.Audio.Renderer.Server.Voice;
using System;
using static Ryujinx.Audio.Renderer.Parameter.VoiceInParameter;
using Ryujinx.Audio.Renderer.Parameter;
using WaveBuffer = Ryujinx.Audio.Renderer.Common.WaveBuffer;
namespace Ryujinx.Audio.Renderer.Dsp.Command
@@ -11,39 +11,42 @@ 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<VoiceUpdateState> State { get; }
public DecodingBehaviour DecodingBehaviour { get; }
public Memory<VoiceState> State { get; private set; }
public DecodingBehaviour DecodingBehaviour { get; private set; }
public PcmInt16DataSourceCommandVersion1(ref VoiceState serverState, Memory<VoiceUpdateState> 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;
OutputBufferIndex = (ushort)(channelIndex + outputBufferIndex);
SampleRate = serverState.SampleRate;
SampleRate = serverInfo.SampleRate;
ChannelIndex = channelIndex;
ChannelCount = serverState.ChannelsCount;
Pitch = serverState.Pitch;
WaveBuffers = new WaveBuffer[Constants.VoiceWaveBufferCount];
ChannelCount = serverInfo.ChannelsCount;
Pitch = serverInfo.Pitch;
Span<Server.Voice.WaveBuffer> waveBufferSpan = serverState.WaveBuffers.AsSpan();
Span<Server.Voice.WaveBuffer> waveBufferSpan = serverInfo.WaveBuffers.AsSpan();
for (int i = 0; i < WaveBuffers.Length; i++)
{
@@ -53,7 +56,9 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
}
State = state;
DecodingBehaviour = serverState.DecodingBehaviour;
DecodingBehaviour = serverInfo.DecodingBehaviour;
return this;
}
public void Process(CommandList context)

View File

@@ -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)

View File

@@ -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)]

View File

@@ -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)]

View File

@@ -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 UpsamplerState UpsamplerInfo { get; }
public UpsamplerInfo UpsamplerInfo { get; private set; }
public Memory<float> OutBuffer { get; }
public Memory<float> OutBuffer { get; private set; }
public UpsampleCommand(uint bufferOffset, UpsamplerState 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)

View File

@@ -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)]

View File

@@ -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)]

View File

@@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.Arm;
using System.Runtime.Intrinsics.X86;
using static Ryujinx.Audio.Renderer.Parameter.VoiceInParameter;
using Ryujinx.Audio.Renderer.Parameter;
namespace Ryujinx.Audio.Renderer.Dsp
{
@@ -42,7 +42,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
};
}
public static void ProcessWaveBuffers(IVirtualMemoryManager memoryManager, Span<float> outputBuffer, ref WaveBufferInformation info, Span<WaveBuffer> wavebuffers, ref VoiceUpdateState voiceState, uint targetSampleRate, int sampleCount)
public static void ProcessWaveBuffers(IVirtualMemoryManager memoryManager, Span<float> outputBuffer, ref WaveBufferInformation info, Span<WaveBuffer> wavebuffers, ref VoiceState voiceState, uint targetSampleRate, int sampleCount)
{
const int TempBufferSize = 0x3F00;

View File

@@ -3,7 +3,7 @@ using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.X86;
using static Ryujinx.Audio.Renderer.Parameter.VoiceInParameter;
using Ryujinx.Audio.Renderer.Parameter;
namespace Ryujinx.Audio.Renderer.Dsp
{

View File

@@ -1,3 +1,4 @@
using Ryujinx.Audio.Renderer.Server;
using Ryujinx.Audio.Renderer.Server.Types;
using System.Runtime.InteropServices;
@@ -93,7 +94,7 @@ namespace Ryujinx.Audio.Renderer.Parameter
/// <summary>
/// The user audio revision
/// </summary>
/// <seealso cref="Server.BehaviourContext"/>
/// <seealso cref="BehaviourInfo"/>
public int Revision;
}
}

View File

@@ -7,7 +7,7 @@ namespace Ryujinx.Audio.Renderer.Parameter
/// Biquad filter parameters.
/// </summary>
[StructLayout(LayoutKind.Sequential, Size = 0xC, Pack = 1)]
public struct BiquadFilterParameter
public struct BiquadFilterParameter1
{
/// <summary>
/// Set to true if the biquad filter is active.

View File

@@ -0,0 +1,36 @@
using Ryujinx.Common.Memory;
using System.Runtime.InteropServices;
namespace Ryujinx.Audio.Renderer.Parameter
{
/// <summary>
/// Biquad filter parameters.
/// </summary>
[StructLayout(LayoutKind.Sequential, Size = 0x18, Pack = 1)]
public struct BiquadFilterParameter2
{
/// <summary>
/// Set to true if the biquad filter is active.
/// </summary>
[MarshalAs(UnmanagedType.I1)]
public bool Enable;
/// <summary>
/// Reserved/padding.
/// </summary>
private readonly byte _reserved1;
private readonly byte _reserved2;
private readonly byte _reserved3;
/// <summary>
/// Biquad filter numerator (b0, b1, b2).
/// </summary>
public Array3<float> Numerator;
/// <summary>
/// Biquad filter denominator (a1, a2).
/// </summary>
/// <remarks>a0 = 1</remarks>
public Array2<float> Denominator;
}
}

View File

@@ -8,7 +8,7 @@ namespace Ryujinx.Audio.Renderer.Parameter.Effect
/// <see cref="IEffectInParameter.SpecificData"/> for <see cref="Common.EffectType.BiquadFilter"/>.
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct BiquadFilterEffectParameter
public struct BiquadFilterEffectParameter1
{
/// <summary>
/// The input channel indices that will be used by the <see cref="Dsp.AudioProcessor"/>.

View File

@@ -0,0 +1,49 @@
using Ryujinx.Audio.Renderer.Server.Effect;
using Ryujinx.Common.Memory;
using System.Runtime.InteropServices;
namespace Ryujinx.Audio.Renderer.Parameter.Effect
{
/// <summary>
/// <see cref="IEffectInParameter.SpecificData"/> for <see cref="Common.EffectType.BiquadFilter"/>.
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct BiquadFilterEffectParameter2
{
/// <summary>
/// The input channel indices that will be used by the <see cref="Dsp.AudioProcessor"/>.
/// </summary>
public Array6<byte> Input;
/// <summary>
/// The output channel indices that will be used by the <see cref="Dsp.AudioProcessor"/>.
/// </summary>
public Array6<byte> Output;
/// <summary>
/// Biquad filter numerator (b0, b1, b2).
/// </summary>
public Array3<float> Numerator;
/// <summary>
/// Biquad filter denominator (a1, a2).
/// </summary>
/// <remarks>a0 = 1</remarks>
public Array2<float> Denominator;
/// <summary>
/// The total channel count used.
/// </summary>
public byte ChannelCount;
/// <summary>
/// The current usage status of the effect on the client side.
/// </summary>
public UsageState Status;
/// <summary>
/// Reserved/unused.
/// </summary>
private readonly ushort _reserved;
}
}

View File

@@ -17,11 +17,11 @@ namespace Ryujinx.Audio.Renderer.Parameter
/// The mix to output the result of the splitter.
/// </summary>
int DestinationId { get; }
/// <summary>
/// Biquad filter parameters.
/// </summary>
Array2<BiquadFilterParameter> BiquadFilters { get; }
Array2<BiquadFilterParameter2> BiquadFilters2 { get; }
/// <summary>
/// Set to true if in use.

View File

@@ -25,7 +25,7 @@ namespace Ryujinx.Audio.Renderer.Parameter
/// <summary>
/// Reserved/padding.
/// </summary>
private readonly ushort _reserved1;
private readonly ushort _magic; // 0xCAFE
/// <summary>
/// The node id of the sink.

View File

@@ -60,8 +60,8 @@ namespace Ryujinx.Audio.Renderer.Parameter
readonly int ISplitterDestinationInParameter.Id => Id;
readonly int ISplitterDestinationInParameter.DestinationId => DestinationId;
readonly Array2<BiquadFilterParameter> ISplitterDestinationInParameter.BiquadFilters => default;
readonly Array2<BiquadFilterParameter2> ISplitterDestinationInParameter.BiquadFilters2 => default;
readonly bool ISplitterDestinationInParameter.IsUsed => IsUsed;
readonly bool ISplitterDestinationInParameter.ResetPrevVolume => ResetPrevVolume;

View File

@@ -0,0 +1,100 @@
using Ryujinx.Audio.Renderer.Dsp;
using Ryujinx.Common.Memory;
using Ryujinx.Common.Utilities;
using System;
using System.Runtime.InteropServices;
namespace Ryujinx.Audio.Renderer.Parameter
{
/// <summary>
/// Input header for a splitter destination version 2 update.
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct SplitterDestinationInParameterVersion2a : ISplitterDestinationInParameter
{
/// <summary>
/// Magic of the input header.
/// </summary>
public uint Magic;
/// <summary>
/// Target splitter destination data id.
/// </summary>
public int Id;
/// <summary>
/// Mix buffer volumes storage.
/// </summary>
private MixArray _mixBufferVolume;
/// <summary>
/// The mix to output the result of the splitter.
/// </summary>
public int DestinationId;
/// <summary>
/// Biquad filter parameters.
/// </summary>
public Array2<BiquadFilterParameter1> BiquadFilters;
/// <summary>
/// Set to true if in use.
/// </summary>
[MarshalAs(UnmanagedType.I1)]
public bool IsUsed;
/// <summary>
/// Set to true to force resetting the previous mix volumes.
/// </summary>
[MarshalAs(UnmanagedType.I1)]
public bool ResetPrevVolume;
/// <summary>
/// Reserved/padding.
/// </summary>
private unsafe fixed byte _reserved[10];
[StructLayout(LayoutKind.Sequential, Size = sizeof(float) * Constants.MixBufferCountMax, Pack = 1)]
private struct MixArray { }
/// <summary>
/// Mix buffer volumes.
/// </summary>
/// <remarks>Used when a splitter id is specified in the mix.</remarks>
public Span<float> MixBufferVolume => SpanHelpers.AsSpan<MixArray, float>(ref _mixBufferVolume);
readonly int ISplitterDestinationInParameter.Id => Id;
readonly int ISplitterDestinationInParameter.DestinationId => DestinationId;
readonly Array2<BiquadFilterParameter2> ISplitterDestinationInParameter.BiquadFilters2
{
get
{
Array2<BiquadFilterParameter2> newFilters = new();
Span<BiquadFilterParameter2> newFiltersSpan = newFilters.AsSpan();
newFiltersSpan[0] = BiquadFilterHelper.ToBiquadFilterParameter2(BiquadFilters[0]);
newFiltersSpan[1] = BiquadFilterHelper.ToBiquadFilterParameter2(BiquadFilters[1]);
return newFilters;
}
}
readonly bool ISplitterDestinationInParameter.IsUsed => IsUsed;
readonly bool ISplitterDestinationInParameter.ResetPrevVolume => ResetPrevVolume;
/// <summary>
/// The expected constant of any input header.
/// </summary>
private const uint ValidMagic = 0x44444E53;
/// <summary>
/// Check if the magic is valid.
/// </summary>
/// <returns>Returns true if the magic is valid.</returns>
public readonly bool IsMagicValid()
{
return Magic == ValidMagic;
}
}
}

View File

@@ -9,7 +9,7 @@ namespace Ryujinx.Audio.Renderer.Parameter
/// Input header for a splitter destination version 2 update.
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct SplitterDestinationInParameterVersion2 : ISplitterDestinationInParameter
public struct SplitterDestinationInParameterVersion2b : ISplitterDestinationInParameter
{
/// <summary>
/// Magic of the input header.
@@ -34,7 +34,7 @@ namespace Ryujinx.Audio.Renderer.Parameter
/// <summary>
/// Biquad filter parameters.
/// </summary>
public Array2<BiquadFilterParameter> BiquadFilters;
public Array2<BiquadFilterParameter2> BiquadFilters;
/// <summary>
/// Set to true if in use.
@@ -66,7 +66,7 @@ namespace Ryujinx.Audio.Renderer.Parameter
readonly int ISplitterDestinationInParameter.DestinationId => DestinationId;
readonly Array2<BiquadFilterParameter> ISplitterDestinationInParameter.BiquadFilters => BiquadFilters;
readonly Array2<BiquadFilterParameter2> ISplitterDestinationInParameter.BiquadFilters2 => BiquadFilters;
readonly bool ISplitterDestinationInParameter.IsUsed => IsUsed;
readonly bool ISplitterDestinationInParameter.ResetPrevVolume => ResetPrevVolume;

View File

@@ -12,7 +12,7 @@ namespace Ryujinx.Audio.Renderer.Parameter
/// Input information for a voice.
/// </summary>
[StructLayout(LayoutKind.Sequential, Size = 0x170, Pack = 1)]
public struct VoiceInParameter
public struct VoiceInParameter1
{
/// <summary>
/// Id of the voice.
@@ -79,7 +79,7 @@ namespace Ryujinx.Audio.Renderer.Parameter
/// <summary>
/// Biquad filters to apply to the output of the voice.
/// </summary>
public Array2<BiquadFilterParameter> BiquadFilters;
public Array2<BiquadFilterParameter1> BiquadFilters;
/// <summary>
/// Total count of <see cref="WaveBufferInternal"/> of the voice.
@@ -171,8 +171,9 @@ namespace Ryujinx.Audio.Renderer.Parameter
/// Reserved/unused.
/// </summary>
private unsafe fixed uint _reserved3[2];
/// <summary>
}
/// <summary>
/// Input information for a voice wavebuffer.
/// </summary>
[StructLayout(LayoutKind.Sequential, Size = 0x38, Pack = 1)]
@@ -328,5 +329,4 @@ namespace Ryujinx.Audio.Renderer.Parameter
/// </summary>
Low,
}
}
}

View File

@@ -0,0 +1,173 @@
using Ryujinx.Audio.Common;
using Ryujinx.Audio.Renderer.Common;
using Ryujinx.Common.Memory;
using System.Runtime.InteropServices;
namespace Ryujinx.Audio.Renderer.Parameter
{
/// <summary>
/// Input information for a voice.
/// </summary>
[StructLayout(LayoutKind.Sequential, Size = 0x188, Pack = 1)]
public struct VoiceInParameter2
{
/// <summary>
/// Id of the voice.
/// </summary>
public int Id;
/// <summary>
/// Node id of the voice.
/// </summary>
public int NodeId;
/// <summary>
/// Set to true if the voice is new.
/// </summary>
[MarshalAs(UnmanagedType.I1)]
public bool IsNew;
/// <summary>
/// Set to true if the voice is used.
/// </summary>
[MarshalAs(UnmanagedType.I1)]
public bool InUse;
/// <summary>
/// The voice <see cref="PlayState"/> wanted by the user.
/// </summary>
public PlayState PlayState;
/// <summary>
/// The <see cref="SampleFormat"/> of the voice.
/// </summary>
public SampleFormat SampleFormat;
/// <summary>
/// The sample rate of the voice.
/// </summary>
public uint SampleRate;
/// <summary>
/// The priority of the voice.
/// </summary>
public uint Priority;
/// <summary>
/// Target sorting position of the voice. (Used to sort voices with the same <see cref="Priority"/>)
/// </summary>
public uint SortingOrder;
/// <summary>
/// The total channel count used.
/// </summary>
public uint ChannelCount;
/// <summary>
/// The pitch used on the voice.
/// </summary>
public float Pitch;
/// <summary>
/// The output volume of the voice.
/// </summary>
public float Volume;
/// <summary>
/// Biquad filters to apply to the output of the voice.
/// </summary>
public Array2<BiquadFilterParameter2> BiquadFilters;
/// <summary>
/// Total count of <see cref="WaveBufferInternal"/> of the voice.
/// </summary>
public uint WaveBuffersCount;
/// <summary>
/// Current playing <see cref="WaveBufferInternal"/> of the voice.
/// </summary>
public uint WaveBuffersIndex;
/// <summary>
/// Reserved/unused.
/// </summary>
private readonly uint
_reserved1;
/// <summary>
/// User state address required by the data source.
/// </summary>
/// <remarks>Only used for <see cref="SampleFormat.Adpcm"/> as the address of the GC-ADPCM coefficients.</remarks>
public ulong DataSourceStateAddress;
/// <summary>
/// User state size required by the data source.
/// </summary>
/// <remarks>Only used for <see cref="SampleFormat.Adpcm"/> as the size of the GC-ADPCM coefficients.</remarks>
public ulong DataSourceStateSize;
/// <summary>
/// The target mix id of the voice.
/// </summary>
public int MixId;
/// <summary>
/// The target splitter id of the voice.
/// </summary>
public uint SplitterId;
/// <summary>
/// The wavebuffer parameters of this voice.
/// </summary>
public Array4<WaveBufferInternal> WaveBuffers;
/// <summary>
/// The channel resource ids associated to the voice.
/// </summary>
public Array6<int> ChannelResourceIds;
/// <summary>
/// Reset the voice drop flag during voice server update.
/// </summary>
[MarshalAs(UnmanagedType.I1)]
public bool ResetVoiceDropFlag;
/// <summary>
/// Flush the amount of wavebuffer specified. This will result in the wavebuffer being skipped and marked played.
/// </summary>
/// <remarks>This was added on REV5.</remarks>
public byte FlushWaveBufferCount;
/// <summary>
/// Reserved/unused.
/// </summary>
private readonly ushort _reserved2;
/// <summary>
/// Change the behaviour of the voice.
/// </summary>
/// <remarks>This was added on REV5.</remarks>
public DecodingBehaviour DecodingBehaviourFlags;
/// <summary>
/// Change the Sample Rate Conversion (SRC) quality of the voice.
/// </summary>
/// <remarks>This was added on REV8.</remarks>
public SampleRateConversionQuality SrcQuality;
/// <summary>
/// This was previously used for opus codec support on the Audio Renderer and was removed on REV3.
/// </summary>
public uint ExternalContext;
/// <summary>
/// This was previously used for opus codec support on the Audio Renderer and was removed on REV3.
/// </summary>
public uint ExternalContextSize;
/// <summary>
/// Reserved/unused.
/// </summary>
private unsafe fixed uint _reserved3[2];
}
}

View File

@@ -1,3 +1,5 @@
using Ryujinx.Audio.Renderer.Common;
using Ryujinx.Audio.Renderer.Server;
using System.Runtime.InteropServices;
namespace Ryujinx.Audio.Renderer.Parameter
@@ -5,7 +7,7 @@ namespace Ryujinx.Audio.Renderer.Parameter
/// <summary>
/// Output information about a voice.
/// </summary>
/// <remarks>See <seealso cref="Server.StateUpdater.UpdateVoices(Server.Voice.VoiceContext, System.Memory{Server.MemoryPool.MemoryPoolState})"/></remarks>
/// <remarks>See <seealso cref="StateUpdater.UpdateVoices1"/></remarks>
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct VoiceOutStatus
{
@@ -13,7 +15,7 @@ namespace Ryujinx.Audio.Renderer.Parameter
/// The total amount of samples that was played.
/// </summary>
/// <remarks>This is reset to 0 when a <see cref="Common.WaveBuffer"/> finishes playing and <see cref="Common.WaveBuffer.IsEndOfStream"/> is set.</remarks>
/// <remarks>This is reset to 0 when looping while <see cref="Parameter.VoiceInParameter.DecodingBehaviour.PlayedSampleCountResetWhenLooping"/> is set.</remarks>
/// <remarks>This is reset to 0 when looping while <see cref="DecodingBehaviour.PlayedSampleCountResetWhenLooping"/> is set.</remarks>
public ulong PlayedSampleCount;
/// <summary>

View File

@@ -31,7 +31,7 @@ namespace Ryujinx.Audio.Renderer.Server
private AudioRendererRenderingDevice _renderingDevice;
private AudioRendererExecutionMode _executionMode;
private readonly IWritableEvent _systemEvent;
private MemoryPoolState _dspMemoryPoolState;
private MemoryPoolInfo _dspMemoryPoolInfo;
private readonly VoiceContext _voiceContext;
private readonly MixContext _mixContext;
private readonly SinkContext _sinkContext;
@@ -40,13 +40,13 @@ namespace Ryujinx.Audio.Renderer.Server
private PerformanceManager _performanceManager;
private UpsamplerManager _upsamplerManager;
private bool _isActive;
private BehaviourContext _behaviourContext;
private BehaviourInfo _behaviourInfo;
#pragma warning disable IDE0052 // Remove unread private member
private ulong _totalElapsedTicksUpdating;
private ulong _totalElapsedTicks;
#pragma warning restore IDE0052
private int _sessionId;
private Memory<MemoryPoolState> _memoryPools;
private Memory<MemoryPoolInfo> _memoryPools;
private uint _sampleRate;
private uint _sampleCount;
@@ -84,7 +84,7 @@ namespace Ryujinx.Audio.Renderer.Server
public AudioRenderSystem(AudioRendererManager manager, IWritableEvent systemEvent)
{
_manager = manager;
_dspMemoryPoolState = MemoryPoolState.Create(MemoryPoolState.LocationType.Dsp);
_dspMemoryPoolInfo = MemoryPoolInfo.Create(MemoryPoolInfo.LocationType.Dsp);
_voiceContext = new VoiceContext();
_mixContext = new MixContext();
_sinkContext = new SinkContext();
@@ -93,7 +93,7 @@ namespace Ryujinx.Audio.Renderer.Server
_commandProcessingTimeEstimator = null;
_systemEvent = systemEvent;
_behaviourContext = new BehaviourContext();
_behaviourInfo = new BehaviourInfo();
_totalElapsedTicksUpdating = 0;
_sessionId = 0;
@@ -110,7 +110,7 @@ namespace Ryujinx.Audio.Renderer.Server
ulong appletResourceId,
IVirtualMemoryManager memoryManager)
{
if (!BehaviourContext.CheckValidRevision(parameter.Revision))
if (!BehaviourInfo.CheckValidRevision(parameter.Revision))
{
return ResultCode.OperationFailed;
}
@@ -122,9 +122,9 @@ namespace Ryujinx.Audio.Renderer.Server
Debug.Assert(parameter.RenderingDevice == AudioRendererRenderingDevice.Dsp && parameter.ExecutionMode == AudioRendererExecutionMode.Auto);
Logger.Info?.Print(LogClass.AudioRenderer, $"Initializing with REV{BehaviourContext.GetRevisionNumber(parameter.Revision)}");
Logger.Info?.Print(LogClass.AudioRenderer, $"Initializing with REV{BehaviourInfo.GetRevisionNumber(parameter.Revision)}");
_behaviourContext.SetUserRevision(parameter.Revision);
_behaviourInfo.SetUserRevision(parameter.Revision);
_sampleRate = parameter.SampleRate;
_sampleCount = parameter.SampleCount;
@@ -151,7 +151,7 @@ namespace Ryujinx.Audio.Renderer.Server
workBufferAllocator = new WorkBufferAllocator(workBufferMemory);
PoolMapper poolMapper = new(processHandle, false);
poolMapper.InitializeSystemPool(ref _dspMemoryPoolState, workBuffer, workBufferSize);
poolMapper.InitializeSystemPool(ref _dspMemoryPoolInfo, workBuffer, workBufferSize);
_mixBuffer = workBufferAllocator.Allocate<float>(_sampleCount * (_voiceChannelCountMax + _mixBufferCount), 0x10);
@@ -176,7 +176,7 @@ namespace Ryujinx.Audio.Renderer.Server
Memory<BiquadFilterState> splitterBqfStates = Memory<BiquadFilterState>.Empty;
if (_behaviourContext.IsBiquadFilterParameterForSplitterEnabled() &&
if (_behaviourInfo.IsBiquadFilterParameterForSplitterEnabled() &&
parameter.SplitterCount > 0 &&
parameter.SplitterDestinationCount > 0)
{
@@ -191,23 +191,23 @@ namespace Ryujinx.Audio.Renderer.Server
}
// Invalidate DSP cache on what was currently allocated with workBuffer.
AudioProcessorMemoryManager.InvalidateDspCache(_dspMemoryPoolState.Translate(workBuffer, workBufferAllocator.Offset), workBufferAllocator.Offset);
AudioProcessorMemoryManager.InvalidateDspCache(_dspMemoryPoolInfo.Translate(workBuffer, workBufferAllocator.Offset), workBufferAllocator.Offset);
Debug.Assert((workBufferAllocator.Offset % Constants.BufferAlignment) == 0);
Memory<VoiceState> voices = workBufferAllocator.Allocate<VoiceState>(parameter.VoiceCount, VoiceState.Alignment);
Memory<VoiceInfo> voices = workBufferAllocator.Allocate<VoiceInfo>(parameter.VoiceCount, VoiceInfo.Alignment);
if (voices.IsEmpty)
{
return ResultCode.WorkBufferTooSmall;
}
foreach (ref VoiceState voice in voices.Span)
foreach (ref VoiceInfo voice in voices.Span)
{
voice.Initialize();
}
// A pain to handle as we can't have VoiceState*, use indices to be a bit more safe
// A pain to handle as we can't have VoiceInfo*, use indices to be a bit more safe
Memory<int> sortedVoices = workBufferAllocator.Allocate<int>(parameter.VoiceCount, 0x10);
if (sortedVoices.IsEmpty)
@@ -233,16 +233,16 @@ namespace Ryujinx.Audio.Renderer.Server
voiceChannelResource.IsUsed = false;
}
Memory<VoiceUpdateState> voiceUpdateStates = workBufferAllocator.Allocate<VoiceUpdateState>(parameter.VoiceCount, VoiceUpdateState.Align);
Memory<VoiceState> voiceStates = workBufferAllocator.Allocate<VoiceState>(parameter.VoiceCount, VoiceState.Align);
if (voiceUpdateStates.IsEmpty)
if (voiceStates.IsEmpty)
{
return ResultCode.WorkBufferTooSmall;
}
uint mixesCount = parameter.SubMixBufferCount + 1;
Memory<MixState> mixes = workBufferAllocator.Allocate<MixState>(mixesCount, MixState.Alignment);
Memory<MixInfo> mixes = workBufferAllocator.Allocate<MixInfo>(mixesCount, MixInfo.Alignment);
if (mixes.IsEmpty)
{
@@ -251,18 +251,18 @@ namespace Ryujinx.Audio.Renderer.Server
if (parameter.EffectCount == 0)
{
foreach (ref MixState mix in mixes.Span)
foreach (ref MixInfo mix in mixes.Span)
{
mix = new MixState(Memory<int>.Empty, ref _behaviourContext);
mix = new MixInfo(Memory<int>.Empty, ref _behaviourInfo);
}
}
else
{
Memory<int> effectProcessingOrderArray = workBufferAllocator.Allocate<int>(parameter.EffectCount * mixesCount, 0x10);
foreach (ref MixState mix in mixes.Span)
foreach (ref MixInfo mix in mixes.Span)
{
mix = new MixState(effectProcessingOrderArray[..(int)parameter.EffectCount], ref _behaviourContext);
mix = new MixInfo(effectProcessingOrderArray[..(int)parameter.EffectCount], ref _behaviourInfo);
effectProcessingOrderArray = effectProcessingOrderArray[(int)parameter.EffectCount..];
}
@@ -271,20 +271,20 @@ namespace Ryujinx.Audio.Renderer.Server
// Initialize the final mix id
mixes.Span[0].MixId = Constants.FinalMixId;
Memory<int> sortedMixesState = workBufferAllocator.Allocate<int>(mixesCount, 0x10);
Memory<int> sortedMixesInfo = workBufferAllocator.Allocate<int>(mixesCount, 0x10);
if (sortedMixesState.IsEmpty)
if (sortedMixesInfo.IsEmpty)
{
return ResultCode.WorkBufferTooSmall;
}
// Clear memory (use -1 as it's an invalid index)
sortedMixesState.Span.Fill(-1);
sortedMixesInfo.Span.Fill(-1);
Memory<byte> nodeStatesWorkBuffer = Memory<byte>.Empty;
Memory<byte> edgeMatrixWorkBuffer = Memory<byte>.Empty;
if (_behaviourContext.IsSplitterSupported())
if (_behaviourInfo.IsSplitterSupported())
{
nodeStatesWorkBuffer = workBufferAllocator.Allocate((uint)NodeStates.GetWorkBufferSize((int)mixesCount), 1);
edgeMatrixWorkBuffer = workBufferAllocator.Allocate((uint)EdgeMatrix.GetWorkBufferSize((int)mixesCount), 1);
@@ -295,21 +295,21 @@ namespace Ryujinx.Audio.Renderer.Server
}
}
_mixContext.Initialize(sortedMixesState, mixes, nodeStatesWorkBuffer, edgeMatrixWorkBuffer);
_mixContext.Initialize(sortedMixesInfo, mixes, nodeStatesWorkBuffer, edgeMatrixWorkBuffer);
_memoryPools = workBufferAllocator.Allocate<MemoryPoolState>(_memoryPoolCount, MemoryPoolState.Alignment);
_memoryPools = workBufferAllocator.Allocate<MemoryPoolInfo>(_memoryPoolCount, MemoryPoolInfo.Alignment);
if (_memoryPools.IsEmpty)
{
return ResultCode.WorkBufferTooSmall;
}
foreach (ref MemoryPoolState state in _memoryPools.Span)
foreach (ref MemoryPoolInfo info in _memoryPools.Span)
{
state = MemoryPoolState.Create(MemoryPoolState.LocationType.Cpu);
info = MemoryPoolInfo.Create(MemoryPoolInfo.LocationType.Cpu);
}
if (!_splitterContext.Initialize(ref _behaviourContext, ref parameter, workBufferAllocator, splitterBqfStates))
if (!_splitterContext.Initialize(ref _behaviourInfo, ref parameter, workBufferAllocator, splitterBqfStates))
{
return ResultCode.WorkBufferTooSmall;
}
@@ -318,21 +318,21 @@ namespace Ryujinx.Audio.Renderer.Server
_upsamplerManager = new UpsamplerManager(upSamplerWorkBuffer, _upsamplerCount);
_effectContext.Initialize(parameter.EffectCount, _behaviourContext.IsEffectInfoVersion2Supported() ? parameter.EffectCount : 0);
_effectContext.Initialize(parameter.EffectCount, _behaviourInfo.IsEffectInfoVersion2Supported() ? parameter.EffectCount : 0);
_sinkContext.Initialize(parameter.SinkCount);
Memory<VoiceUpdateState> voiceUpdateStatesDsp = workBufferAllocator.Allocate<VoiceUpdateState>(parameter.VoiceCount, VoiceUpdateState.Align);
Memory<VoiceState> voiceStatesDsp = workBufferAllocator.Allocate<VoiceState>(parameter.VoiceCount, VoiceState.Align);
if (voiceUpdateStatesDsp.IsEmpty)
if (voiceStatesDsp.IsEmpty)
{
return ResultCode.WorkBufferTooSmall;
}
_voiceContext.Initialize(sortedVoices, voices, voiceChannelResources, voiceUpdateStates, voiceUpdateStatesDsp, parameter.VoiceCount);
_voiceContext.Initialize(sortedVoices, voices, voiceChannelResources, voiceStates, voiceStatesDsp, parameter.VoiceCount);
if (parameter.PerformanceMetricFramesCount > 0)
{
ulong performanceBufferSize = PerformanceManager.GetRequiredBufferSizeForPerformanceMetricsPerFrame(ref parameter, ref _behaviourContext) * (parameter.PerformanceMetricFramesCount + 1) + 0xC;
ulong performanceBufferSize = PerformanceManager.GetRequiredBufferSizeForPerformanceMetricsPerFrame(ref parameter, ref _behaviourInfo) * (parameter.PerformanceMetricFramesCount + 1) + 0xC;
_performanceBuffer = workBufferAllocator.Allocate(performanceBufferSize, Constants.BufferAlignment);
@@ -341,7 +341,7 @@ namespace Ryujinx.Audio.Renderer.Server
return ResultCode.WorkBufferTooSmall;
}
_performanceManager = PerformanceManager.Create(_performanceBuffer, ref parameter, _behaviourContext);
_performanceManager = PerformanceManager.Create(_performanceBuffer, ref parameter, _behaviourInfo);
}
else
{
@@ -359,14 +359,14 @@ namespace Ryujinx.Audio.Renderer.Server
_elapsedFrameCount = 0;
_voiceDropParameter = 1.0f;
_commandProcessingTimeEstimator = _behaviourContext.GetCommandProcessingTimeEstimatorVersion() switch
_commandProcessingTimeEstimator = _behaviourInfo.GetCommandProcessingTimeEstimatorVersion() switch
{
1 => new CommandProcessingTimeEstimatorVersion1(_sampleCount, _mixBufferCount),
2 => new CommandProcessingTimeEstimatorVersion2(_sampleCount, _mixBufferCount),
3 => new CommandProcessingTimeEstimatorVersion3(_sampleCount, _mixBufferCount),
4 => new CommandProcessingTimeEstimatorVersion4(_sampleCount, _mixBufferCount),
5 => new CommandProcessingTimeEstimatorVersion5(_sampleCount, _mixBufferCount),
_ => throw new NotImplementedException($"Unsupported processing time estimator version {_behaviourContext.GetCommandProcessingTimeEstimatorVersion()}."),
_ => throw new NotImplementedException($"Unsupported processing time estimator version {_behaviourInfo.GetCommandProcessingTimeEstimatorVersion()}."),
};
return ResultCode.Success;
@@ -411,11 +411,11 @@ namespace Ryujinx.Audio.Renderer.Server
output.Span.Clear();
StateUpdater stateUpdater = new(input, output, _processHandle, _behaviourContext);
StateUpdater stateUpdater = new(input, output, _processHandle, _behaviourInfo);
ResultCode result;
result = stateUpdater.UpdateBehaviourContext();
result = stateUpdater.UpdateBehaviourInfo();
if (result != ResultCode.Success)
{
@@ -436,9 +436,16 @@ namespace Ryujinx.Audio.Renderer.Server
return result;
}
PoolMapper poolMapper = new(_processHandle, _memoryPools, _behaviourContext.IsMemoryPoolForceMappingEnabled());
PoolMapper poolMapper = new(_processHandle, _memoryPools, _behaviourInfo.IsMemoryPoolForceMappingEnabled());
result = stateUpdater.UpdateVoices(_voiceContext, poolMapper);
if (_behaviourInfo.IsBiquadFilterParameterFloatSupported())
{
result = stateUpdater.UpdateVoices2(_voiceContext, poolMapper);
}
else
{
result = stateUpdater.UpdateVoices1(_voiceContext, poolMapper);
}
if (result != ResultCode.Success)
{
@@ -452,7 +459,7 @@ namespace Ryujinx.Audio.Renderer.Server
return result;
}
if (_behaviourContext.IsSplitterSupported())
if (_behaviourInfo.IsSplitterSupported())
{
result = stateUpdater.UpdateSplitter(_splitterContext);
@@ -490,7 +497,7 @@ namespace Ryujinx.Audio.Renderer.Server
return result;
}
if (_behaviourContext.IsElapsedFrameCountSupported())
if (_behaviourInfo.IsElapsedFrameCountSupported())
{
result = stateUpdater.UpdateRendererInfo(_elapsedFrameCount);
@@ -557,7 +564,7 @@ namespace Ryujinx.Audio.Renderer.Server
break;
}
ref VoiceState voice = ref _voiceContext.GetState(NodeIdHelper.GetBase(targetNodeId));
ref VoiceInfo voice = ref _voiceContext.GetState(NodeIdHelper.GetBase(targetNodeId));
if (voice.Priority == Constants.VoiceHighestPriority)
{
@@ -646,7 +653,7 @@ namespace Ryujinx.Audio.Renderer.Server
_voiceContext.UpdateForCommandGeneration();
if (_behaviourContext.IsEffectInfoVersion2Supported())
if (_behaviourInfo.IsEffectInfoVersion2Supported())
{
_effectContext.UpdateResultStateForCommandGeneration();
}
@@ -661,7 +668,7 @@ namespace Ryujinx.Audio.Renderer.Server
private int GetMaxAllocatedTimeForDsp()
{
return (int)(Constants.AudioProcessorMaxUpdateTimePerSessions * _behaviourContext.GetAudioRendererProcessingTimeLimit() * (GetRenderingTimeLimit() / 100.0f));
return (int)(Constants.AudioProcessorMaxUpdateTimePerSessions * _behaviourInfo.GetAudioRendererProcessingTimeLimit() * (GetRenderingTimeLimit() / 100.0f));
}
public void SendCommands()
@@ -736,7 +743,7 @@ namespace Ryujinx.Audio.Renderer.Server
return new RendererSystemContext
{
ChannelCount = _manager.Processor.OutputDevices[_sessionId].GetChannelCount(),
BehaviourContext = _behaviourContext,
BehaviourInfo = _behaviourInfo,
DepopBuffer = _depopBuffer,
MixBufferCount = GetMixBufferCount(),
SessionId = _sessionId,
@@ -751,9 +758,9 @@ namespace Ryujinx.Audio.Renderer.Server
public static ulong GetWorkBufferSize(ref AudioRendererConfiguration parameter)
{
BehaviourContext behaviourContext = new();
BehaviourInfo behaviourInfo = new();
behaviourContext.SetUserRevision(parameter.Revision);
behaviourInfo.SetUserRevision(parameter.Revision);
uint mixesCount = parameter.SubMixBufferCount + 1;
@@ -771,28 +778,28 @@ namespace Ryujinx.Audio.Renderer.Server
size = WorkBufferAllocator.GetTargetSize<float>(size, BitUtils.AlignUp<ulong>(parameter.MixBufferCount, Constants.BufferAlignment), Constants.BufferAlignment);
// Voice
size = WorkBufferAllocator.GetTargetSize<VoiceState>(size, parameter.VoiceCount, VoiceState.Alignment);
size = WorkBufferAllocator.GetTargetSize<VoiceInfo>(size, parameter.VoiceCount, VoiceInfo.Alignment);
size = WorkBufferAllocator.GetTargetSize<int>(size, parameter.VoiceCount, 0x10);
size = WorkBufferAllocator.GetTargetSize<VoiceChannelResource>(size, parameter.VoiceCount, VoiceChannelResource.Alignment);
size = WorkBufferAllocator.GetTargetSize<VoiceUpdateState>(size, parameter.VoiceCount, VoiceUpdateState.Align);
size = WorkBufferAllocator.GetTargetSize<VoiceState>(size, parameter.VoiceCount, VoiceState.Align);
// Mix
size = WorkBufferAllocator.GetTargetSize<MixState>(size, mixesCount, MixState.Alignment);
size = WorkBufferAllocator.GetTargetSize<MixInfo>(size, mixesCount, MixInfo.Alignment);
size = WorkBufferAllocator.GetTargetSize<int>(size, parameter.EffectCount * mixesCount, 0x10);
size = WorkBufferAllocator.GetTargetSize<int>(size, mixesCount, 0x10);
if (behaviourContext.IsSplitterSupported())
if (behaviourInfo.IsSplitterSupported())
{
size += (ulong)BitUtils.AlignUp(NodeStates.GetWorkBufferSize((int)mixesCount) + EdgeMatrix.GetWorkBufferSize((int)mixesCount), 0x10);
}
// Memory Pool
size = WorkBufferAllocator.GetTargetSize<MemoryPoolState>(size, memoryPoolCount, MemoryPoolState.Alignment);
size = WorkBufferAllocator.GetTargetSize<MemoryPoolInfo>(size, memoryPoolCount, MemoryPoolInfo.Alignment);
// Splitter
size = SplitterContext.GetWorkBufferSize(size, ref behaviourContext, ref parameter);
size = SplitterContext.GetWorkBufferSize(size, ref behaviourInfo, ref parameter);
if (behaviourContext.IsBiquadFilterParameterForSplitterEnabled() &&
if (behaviourInfo.IsBiquadFilterParameterForSplitterEnabled() &&
parameter.SplitterCount > 0 &&
parameter.SplitterDestinationCount > 0)
{
@@ -800,12 +807,12 @@ namespace Ryujinx.Audio.Renderer.Server
}
// DSP Voice
size = WorkBufferAllocator.GetTargetSize<VoiceUpdateState>(size, parameter.VoiceCount, VoiceUpdateState.Align);
size = WorkBufferAllocator.GetTargetSize<VoiceState>(size, parameter.VoiceCount, VoiceState.Align);
// Performance
if (parameter.PerformanceMetricFramesCount > 0)
{
ulong performanceMetricsPerFramesSize = PerformanceManager.GetRequiredBufferSizeForPerformanceMetricsPerFrame(ref parameter, ref behaviourContext) * (parameter.PerformanceMetricFramesCount + 1) + 0xC;
ulong performanceMetricsPerFramesSize = PerformanceManager.GetRequiredBufferSizeForPerformanceMetricsPerFrame(ref parameter, ref behaviourInfo) * (parameter.PerformanceMetricFramesCount + 1) + 0xC;
size += BitUtils.AlignUp<ulong>(performanceMetricsPerFramesSize, Constants.PerformanceMetricsPerFramesSizeAlignment);
}
@@ -847,13 +854,13 @@ namespace Ryujinx.Audio.Renderer.Server
}
PoolMapper mapper = new(_processHandle, false);
mapper.Unmap(ref _dspMemoryPoolState);
mapper.Unmap(ref _dspMemoryPoolInfo);
PoolMapper.ClearUsageState(_memoryPools);
for (int i = 0; i < _memoryPoolCount; i++)
{
ref MemoryPoolState memoryPool = ref _memoryPools.Span[i];
ref MemoryPoolInfo memoryPool = ref _memoryPools.Span[i];
if (memoryPool.IsMapped())
{
@@ -875,7 +882,7 @@ namespace Ryujinx.Audio.Renderer.Server
public void SetVoiceDropParameter(float voiceDropParameter)
{
_voiceDropParameter = Math.Clamp(voiceDropParameter, 0.0f, 2.0f);
_voiceDropParameter = Math.Clamp(voiceDropParameter, 0.0f, 4.0f);
}
public float GetVoiceDropParameter()

View File

@@ -1,3 +1,5 @@
using Ryujinx.Audio.Renderer.Parameter;
using Ryujinx.Common.Memory;
using System;
using System.Buffers;
using System.Diagnostics;
@@ -9,7 +11,7 @@ namespace Ryujinx.Audio.Renderer.Server
/// Behaviour context.
/// </summary>
/// <remarks>This handles features based on the audio renderer revision provided by the user.</remarks>
public class BehaviourContext
public class BehaviourInfo
{
/// <summary>
/// The base magic of the Audio Renderer revision.
@@ -40,7 +42,7 @@ namespace Ryujinx.Audio.Renderer.Server
public const int Revision4 = 4 << 24;
/// <summary>
/// REV5: <see cref="Parameter.VoiceInParameter.DecodingBehaviour"/>, <see cref="Parameter.VoiceInParameter.FlushWaveBufferCount"/> were added to voice.
/// REV5: <see cref="VoiceInParameter1.DecodingBehaviour"/>, <see cref="VoiceInParameter1.FlushWaveBufferCount"/> were added to voice.
/// A new performance frame format (version 2) was added with support for more information about DSP timing.
/// <see cref="Parameter.RendererInfoOutStatus"/> was added to supply the count of update done sent to the DSP.
/// A new version of the command estimator was added to address timing changes caused by the voice changes.
@@ -64,7 +66,7 @@ namespace Ryujinx.Audio.Renderer.Server
/// <summary>
/// REV8:
/// Wavebuffer was changed to support more control over loop (you can now specify where to start and end a loop, and how many times to loop).
/// <see cref="Parameter.VoiceInParameter.SrcQuality"/> was added (see <see cref="Parameter.VoiceInParameter.SampleRateConversionQuality"/> for more info).
/// <see cref="VoiceInParameter1.SrcQuality"/> was added (see <see cref="VoiceInParameter1.SampleRateConversionQuality"/> for more info).
/// Final leftovers of the codec system were removed.
/// <see cref="Common.SampleFormat.PcmFloat"/> support was added.
/// A new version of the command estimator was added to address timing changes caused by the voice and command changes.
@@ -115,16 +117,27 @@ namespace Ryujinx.Audio.Renderer.Server
/// </summary>
/// <remarks>This was added in system update 18.0.0</remarks>
public const int Revision13 = 13 << 24;
/// <summary>
/// REV14:
/// Fixes the Depop Bug.
///
/// </summary>
/// <remarks>This was added in system update 19.0.0 </remarks>
public const int Revision14 = 14 << 24;
/// <summary>
/// REV15:
/// Support for float coefficients in biquad filters
///
/// </summary>
/// <remarks>This was added in system update 19.0.0 </remarks>
public const int Revision15 = 15 << 24;
/// <summary>
/// Last revision supported by the implementation.
/// </summary>
public const int LastRevision = Revision13;
/// <summary>
/// Target revision magic supported by the implementation.
/// </summary>
public const int ProcessRevision = BaseRevisionMagic + LastRevision;
public const int LastRevision = Revision15;
/// <summary>
/// Get the revision number from the revision magic.
@@ -133,15 +146,25 @@ namespace Ryujinx.Audio.Renderer.Server
/// <returns>The revision number.</returns>
public static int GetRevisionNumber(int revision) => (revision - BaseRevisionMagic) >> 24;
/// <summary>
/// Target revision magic supported by the implementation.
/// </summary>
public const int ProcessRevision = BaseRevisionMagic + LastRevision;
/// <summary>
/// Current active revision.
/// </summary>
public int UserRevision { get; private set; }
/// <summary>
/// Current flags of the <see cref="BehaviourInfo"/>.
/// </summary>
private ulong _flags;
/// <summary>
/// Error storage.
/// </summary>
private readonly ErrorInfo[] _errorInfos;
private readonly Array10<ErrorInfo> _errorInfos;
/// <summary>
/// Current position in the <see cref="_errorInfos"/> array.
@@ -149,17 +172,12 @@ namespace Ryujinx.Audio.Renderer.Server
private uint _errorIndex;
/// <summary>
/// Current flags of the <see cref="BehaviourContext"/>.
/// Create a new instance of <see cref="BehaviourInfo"/>.
/// </summary>
private ulong _flags;
/// <summary>
/// Create a new instance of <see cref="BehaviourContext"/>.
/// </summary>
public BehaviourContext()
public BehaviourInfo()
{
UserRevision = 0;
_errorInfos = new ErrorInfo[Constants.MaxErrorInfos];
_errorInfos = new Array10<ErrorInfo>();
_errorIndex = 0;
}
@@ -173,7 +191,7 @@ namespace Ryujinx.Audio.Renderer.Server
}
/// <summary>
/// Update flags of the <see cref="BehaviourContext"/>.
/// Update flags of the <see cref="BehaviourInfo"/>.
/// </summary>
/// <param name="flags">The new flags.</param>
public void UpdateFlags(ulong flags)
@@ -321,9 +339,9 @@ namespace Ryujinx.Audio.Renderer.Server
}
/// <summary>
/// Check if the audio renderer should support <see cref="Parameter.VoiceInParameter.DecodingBehaviour"/>.
/// Check if the audio renderer should support <see cref="VoiceInParameter1.DecodingBehaviour"/>.
/// </summary>
/// <returns>True if the audio renderer should support <see cref="Parameter.VoiceInParameter.DecodingBehaviour"/>.</returns>
/// <returns>True if the audio renderer should support <see cref="VoiceInParameter1.DecodingBehaviour"/>.</returns>
public bool IsDecodingBehaviourFlagSupported()
{
return CheckFeatureSupported(UserRevision, BaseRevisionMagic + Revision5);
@@ -400,6 +418,24 @@ namespace Ryujinx.Audio.Renderer.Server
{
return CheckFeatureSupported(UserRevision, BaseRevisionMagic + Revision13);
}
/// <summary>
/// Check if the audio renderer should support the depop bug fix.
/// </summary>
/// <returns>True if the audio renderer supports the depop bug fix</returns>
public bool IsSplitterDepopBugFixEnabled()
{
return CheckFeatureSupported(UserRevision, BaseRevisionMagic + Revision14);
}
/// <summary>
/// Check if the audio renderer should support biquad filter with float coefficients.
/// </summary>
/// <returns>True if the audio renderer support biquad filter with float coefficients</returns>
public bool IsBiquadFilterParameterFloatSupported()
{
return CheckFeatureSupported(UserRevision, BaseRevisionMagic + Revision15);
}
/// <summary>
/// Get the version of the <see cref="ICommandProcessingTimeEstimator"/>.
@@ -440,7 +476,7 @@ namespace Ryujinx.Audio.Renderer.Server
if (_errorIndex <= Constants.MaxErrorInfos - 1)
{
_errorInfos[_errorIndex++] = errorInfo;
_errorInfos[(int)_errorIndex++] = errorInfo;
}
}
@@ -457,22 +493,8 @@ namespace Ryujinx.Audio.Renderer.Server
}
errorCount = Math.Min(_errorIndex, Constants.MaxErrorInfos);
for (int i = 0; i < Constants.MaxErrorInfos; i++)
{
if (i < errorCount)
{
errorInfos[i] = _errorInfos[i];
}
else
{
errorInfos[i] = new ErrorInfo
{
ErrorCode = 0,
ExtraErrorInfo = 0,
};
}
}
_errorInfos.AsSpan().CopyTo(errorInfos);
}
/// <summary>

View File

@@ -5,8 +5,10 @@ using Ryujinx.Audio.Renderer.Parameter;
using Ryujinx.Audio.Renderer.Parameter.Effect;
using Ryujinx.Audio.Renderer.Server.Performance;
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 CpuAddress = System.UInt64;
@@ -32,6 +34,162 @@ 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();
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();
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();
case CommandType.MultiTapBiquadFilterAndMix:
_multiTapBiquadFilterAndMixCommandPool.Release((MultiTapBiquadFilterAndMixCommand)command);
break;
case CommandType.MultiTapBiquadFilterAndMixFloatCoef:
throw new NotImplementedException();
case CommandType.AuxiliaryBufferGrouped:
throw new NotImplementedException();
case CommandType.FillMixBuffer:
throw new NotImplementedException();
case CommandType.BiquadFilterCrossFade:
throw new NotImplementedException();
case CommandType.MultiTapBiquadFilterCrossFade:
throw new NotImplementedException();
case CommandType.FillBuffer:
_fillBufferCommandPool.Release((FillBufferCommand)command);
break;
default:
throw new NotImplementedException();
}
}
/// <summary>
/// Create a new <see cref="CommandBuffer"/>.
/// </summary>
@@ -61,7 +219,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);
@@ -77,9 +235,9 @@ namespace Ryujinx.Audio.Renderer.Server
/// <param name="bufferOffset">The target buffer offset.</param>
/// <param name="nodeId">The node id associated to this command.</param>
/// <param name="wasPlaying">Set to true if the voice was playing previously.</param>
public void GenerateDepopPrepare(Memory<VoiceUpdateState> state, Memory<float> depopBuffer, uint bufferCount, uint bufferOffset, int nodeId, bool wasPlaying)
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);
@@ -94,7 +252,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);
@@ -110,7 +268,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);
@@ -120,14 +278,14 @@ namespace Ryujinx.Audio.Renderer.Server
/// <summary>
/// Create a new <see cref="DataSourceVersion2Command"/>.
/// </summary>
/// <param name="voiceState">The <see cref="VoiceState"/> to generate the command from.</param>
/// <param name="state">The <see cref="VoiceUpdateState"/> to generate the command from.</param>
/// <param name="voiceInfo">The <see cref="VoiceInfo"/> to generate the command from.</param>
/// <param name="state">The <see cref="VoiceState"/> to generate the command from.</param>
/// <param name="outputBufferIndex">The output buffer index to use.</param>
/// <param name="channelIndex">The target channel index.</param>
/// <param name="nodeId">The node id associated to this command.</param>
public void GenerateDataSourceVersion2(ref VoiceState voiceState, Memory<VoiceUpdateState> state, ushort outputBufferIndex, ushort channelIndex, int nodeId)
public void GenerateDataSourceVersion2(ref VoiceInfo voiceInfo, Memory<VoiceState> state, ushort outputBufferIndex, ushort channelIndex, int nodeId)
{
DataSourceVersion2Command command = new(ref voiceState, state, outputBufferIndex, channelIndex, nodeId);
DataSourceVersion2Command command = _dataSourceVersion2CommandPool.Allocate().Initialize(ref voiceInfo, state, outputBufferIndex, channelIndex, nodeId);
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
@@ -137,14 +295,14 @@ namespace Ryujinx.Audio.Renderer.Server
/// <summary>
/// Create a new <see cref="PcmInt16DataSourceCommandVersion1"/>.
/// </summary>
/// <param name="voiceState">The <see cref="VoiceState"/> to generate the command from.</param>
/// <param name="state">The <see cref="VoiceUpdateState"/> to generate the command from.</param>
/// <param name="voiceInfo">The <see cref="VoiceInfo"/> to generate the command from.</param>
/// <param name="state">The <see cref="VoiceState"/> to generate the command from.</param>
/// <param name="outputBufferIndex">The output buffer index to use.</param>
/// <param name="channelIndex">The target channel index.</param>
/// <param name="nodeId">The node id associated to this command.</param>
public void GeneratePcmInt16DataSourceVersion1(ref VoiceState voiceState, Memory<VoiceUpdateState> state, ushort outputBufferIndex, ushort channelIndex, int nodeId)
public void GeneratePcmInt16DataSourceVersion1(ref VoiceInfo voiceInfo, Memory<VoiceState> state, ushort outputBufferIndex, ushort channelIndex, int nodeId)
{
PcmInt16DataSourceCommandVersion1 command = new(ref voiceState, state, outputBufferIndex, channelIndex, nodeId);
PcmInt16DataSourceCommandVersion1 command = _pcmInt16DataSourceCommandVersion1Pool.Allocate().Initialize(ref voiceInfo, state, outputBufferIndex, channelIndex, nodeId);
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
@@ -154,14 +312,14 @@ namespace Ryujinx.Audio.Renderer.Server
/// <summary>
/// Create a new <see cref="PcmFloatDataSourceCommandVersion1"/>.
/// </summary>
/// <param name="voiceState">The <see cref="VoiceState"/> to generate the command from.</param>
/// <param name="state">The <see cref="VoiceUpdateState"/> to generate the command from.</param>
/// <param name="voiceInfo">The <see cref="VoiceInfo"/> to generate the command from.</param>
/// <param name="state">The <see cref="VoiceState"/> to generate the command from.</param>
/// <param name="outputBufferIndex">The output buffer index to use.</param>
/// <param name="channelIndex">The target channel index.</param>
/// <param name="nodeId">The node id associated to this command.</param>
public void GeneratePcmFloatDataSourceVersion1(ref VoiceState voiceState, Memory<VoiceUpdateState> state, ushort outputBufferIndex, ushort channelIndex, int nodeId)
public void GeneratePcmFloatDataSourceVersion1(ref VoiceInfo voiceInfo, Memory<VoiceState> state, ushort outputBufferIndex, ushort channelIndex, int nodeId)
{
PcmFloatDataSourceCommandVersion1 command = new(ref voiceState, state, outputBufferIndex, channelIndex, nodeId);
PcmFloatDataSourceCommandVersion1 command = _pcmFloatDataSourceCommandVersion1Pool.Allocate().Initialize(ref voiceInfo, state, outputBufferIndex, channelIndex, nodeId);
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
@@ -171,13 +329,13 @@ namespace Ryujinx.Audio.Renderer.Server
/// <summary>
/// Create a new <see cref="AdpcmDataSourceCommandVersion1"/>.
/// </summary>
/// <param name="voiceState">The <see cref="VoiceState"/> to generate the command from.</param>
/// <param name="state">The <see cref="VoiceUpdateState"/> to generate the command from.</param>
/// <param name="voiceInfo">The <see cref="VoiceInfo"/> to generate the command from.</param>
/// <param name="state">The <see cref="VoiceState"/> to generate the command from.</param>
/// <param name="outputBufferIndex">The output buffer index to use.</param>
/// <param name="nodeId">The node id associated to this command.</param>
public void GenerateAdpcmDataSourceVersion1(ref VoiceState voiceState, Memory<VoiceUpdateState> state, ushort outputBufferIndex, int nodeId)
public void GenerateAdpcmDataSourceVersion1(ref VoiceInfo voiceInfo, Memory<VoiceState> state, ushort outputBufferIndex, int nodeId)
{
AdpcmDataSourceCommandVersion1 command = new(ref voiceState, state, outputBufferIndex, nodeId);
AdpcmDataSourceCommandVersion1 command = _adpcmDataSourceCommandVersion1Pool.Allocate().Initialize(ref voiceInfo, state, outputBufferIndex, nodeId);
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
@@ -194,9 +352,9 @@ namespace Ryujinx.Audio.Renderer.Server
/// <param name="outputBufferOffset">The output buffer offset.</param>
/// <param name="needInitialization">Set to true if the biquad filter state needs to be initialized.</param>
/// <param name="nodeId">The node id associated to this command.</param>
public void GenerateBiquadFilter(int baseIndex, ref BiquadFilterParameter filter, Memory<BiquadFilterState> biquadFilterStateMemory, int inputBufferOffset, int outputBufferOffset, bool needInitialization, int nodeId)
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);
@@ -213,9 +371,9 @@ namespace Ryujinx.Audio.Renderer.Server
/// <param name="outputBufferOffset">The output buffer offset.</param>
/// <param name="isInitialized">Set to true if the biquad filter state is initialized.</param>
/// <param name="nodeId">The node id associated to this command.</param>
public void GenerateMultiTapBiquadFilter(int baseIndex, ReadOnlySpan<BiquadFilterParameter> filters, Memory<BiquadFilterState> biquadFilterStatesMemory, int inputBufferOffset, int outputBufferOffset, ReadOnlySpan<bool> isInitialized, int nodeId)
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);
@@ -230,11 +388,11 @@ namespace Ryujinx.Audio.Renderer.Server
/// <param name="outputBufferIndex">The base output index.</param>
/// <param name="previousVolume">The previous volume.</param>
/// <param name="volume">The new volume.</param>
/// <param name="state">The <see cref="VoiceUpdateState"/> to generate the command from.</param>
/// <param name="state">The <see cref="VoiceState"/> to generate the command from.</param>
/// <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<VoiceUpdateState> state, int nodeId)
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);
@@ -248,12 +406,12 @@ namespace Ryujinx.Audio.Renderer.Server
/// <param name="volume">The new volume.</param>
/// <param name="inputBufferIndex">The input buffer index.</param>
/// <param name="outputBufferIndex">The output buffer index.</param>
/// <param name="lastSampleIndex">The index in the <see cref="VoiceUpdateState.LastSamples"/> array to store the ramped sample.</param>
/// <param name="state">The <see cref="VoiceUpdateState"/> to generate the command from.</param>
/// <param name="lastSampleIndex">The index in the <see cref="VoiceState.LastSamples"/> array to store the ramped sample.</param>
/// <param name="state">The <see cref="VoiceState"/> to generate the command from.</param>
/// <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<VoiceUpdateState> state, int nodeId)
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);
@@ -267,8 +425,8 @@ namespace Ryujinx.Audio.Renderer.Server
/// <param name="volume">The new volume.</param>
/// <param name="inputBufferIndex">The input buffer index.</param>
/// <param name="outputBufferIndex">The output buffer index.</param>
/// <param name="lastSampleIndex">The index in the <see cref="VoiceUpdateState.LastSamples"/> array to store the ramped sample.</param>
/// <param name="state">The <see cref="VoiceUpdateState"/> to generate the command from.</param>
/// <param name="lastSampleIndex">The index in the <see cref="VoiceState.LastSamples"/> array to store the ramped sample.</param>
/// <param name="state">The <see cref="VoiceState"/> to generate the command from.</param>
/// <param name="filter">The biquad filter parameter.</param>
/// <param name="biquadFilterState">The biquad state.</param>
/// <param name="previousBiquadFilterState">The previous biquad state.</param>
@@ -282,8 +440,8 @@ namespace Ryujinx.Audio.Renderer.Server
uint inputBufferIndex,
uint outputBufferIndex,
int lastSampleIndex,
Memory<VoiceUpdateState> state,
ref BiquadFilterParameter filter,
Memory<VoiceState> state,
ref BiquadFilterParameter2 filter,
Memory<BiquadFilterState> biquadFilterState,
Memory<BiquadFilterState> previousBiquadFilterState,
bool needInitialization,
@@ -291,7 +449,7 @@ namespace Ryujinx.Audio.Renderer.Server
bool isFirstMixBuffer,
int nodeId)
{
BiquadFilterAndMixCommand command = new(
BiquadFilterAndMixCommand command = _biquadFilterAndMixCommandPool.Allocate().Initialize(
previousVolume,
volume,
inputBufferIndex,
@@ -318,8 +476,8 @@ namespace Ryujinx.Audio.Renderer.Server
/// <param name="volume">The new volume.</param>
/// <param name="inputBufferIndex">The input buffer index.</param>
/// <param name="outputBufferIndex">The output buffer index.</param>
/// <param name="lastSampleIndex">The index in the <see cref="VoiceUpdateState.LastSamples"/> array to store the ramped sample.</param>
/// <param name="state">The <see cref="VoiceUpdateState"/> to generate the command from.</param>
/// <param name="lastSampleIndex">The index in the <see cref="VoiceState.LastSamples"/> array to store the ramped sample.</param>
/// <param name="state">The <see cref="VoiceState"/> to generate the command from.</param>
/// <param name="filter0">First biquad filter parameter.</param>
/// <param name="filter1">Second biquad filter parameter.</param>
/// <param name="biquadFilterState0">First biquad state.</param>
@@ -337,9 +495,9 @@ namespace Ryujinx.Audio.Renderer.Server
uint inputBufferIndex,
uint outputBufferIndex,
int lastSampleIndex,
Memory<VoiceUpdateState> state,
ref BiquadFilterParameter filter0,
ref BiquadFilterParameter filter1,
Memory<VoiceState> state,
ref BiquadFilterParameter2 filter0,
ref BiquadFilterParameter2 filter1,
Memory<BiquadFilterState> biquadFilterState0,
Memory<BiquadFilterState> biquadFilterState1,
Memory<BiquadFilterState> previousBiquadFilterState0,
@@ -350,7 +508,7 @@ namespace Ryujinx.Audio.Renderer.Server
bool isFirstMixBuffer,
int nodeId)
{
MultiTapBiquadFilterAndMixCommand command = new(
MultiTapBiquadFilterAndMixCommand command = _multiTapBiquadFilterAndMixCommandPool.Allocate().Initialize(
previousVolume,
volume,
inputBufferIndex,
@@ -384,7 +542,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);
@@ -399,7 +557,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);
@@ -415,7 +573,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);
@@ -437,7 +595,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);
@@ -459,7 +617,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);
@@ -481,7 +639,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);
@@ -502,7 +660,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);
@@ -524,7 +682,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);
@@ -550,7 +708,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);
@@ -574,7 +732,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);
@@ -595,7 +753,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);
@@ -611,7 +769,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);
@@ -626,7 +784,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);
@@ -643,7 +801,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);
@@ -654,16 +812,16 @@ namespace Ryujinx.Audio.Renderer.Server
/// Create a new <see cref="UpsampleCommand"/>.
/// </summary>
/// <param name="bufferOffset">The offset of the mix buffer.</param>
/// <param name="upsampler">The <see cref="UpsamplerState"/> associated.</param>
/// <param name="upsampler">The <see cref="UpsamplerInfo"/> associated.</param>
/// <param name="inputCount">The total input count.</param>
/// <param name="inputBufferOffset">The input buffer mix offset.</param>
/// <param name="bufferCountPerSample">The buffer count per sample.</param>
/// <param name="sampleCount">The source sample count.</param>
/// <param name="sampleRate">The source sample rate.</param>
/// <param name="nodeId">The node id associated to this command.</param>
public void GenerateUpsample(uint bufferOffset, UpsamplerState upsampler, uint inputCount, Span<byte> inputBufferOffset, uint bufferCountPerSample, uint sampleCount, uint sampleRate, int nodeId)
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);
@@ -680,11 +838,20 @@ 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);
AddCommand(command);
}
public void GenerateFillBuffer(SplitterDestination destination, float value, int length, int nodeId)
{
FillBufferCommand command = _fillBufferCommandPool.Allocate().Initialize(destination, length, value, nodeId);
command.EstimatedProcessingTime = _commandProcessingTimeEstimator.Estimate(command);
AddCommand(command);
}
}
}

View File

@@ -41,27 +41,27 @@ namespace Ryujinx.Audio.Renderer.Server
_commandBuffer.GenerateClearMixBuffer(Constants.InvalidNodeId);
}
private void GenerateDataSource(ref VoiceState voiceState, Memory<VoiceUpdateState> dspState, int channelIndex)
private void GenerateDataSource(ref VoiceInfo voiceInfo, Memory<VoiceState> dspState, int channelIndex)
{
if (voiceState.MixId != Constants.UnusedMixId)
if (voiceInfo.MixId != Constants.UnusedMixId)
{
ref MixState mix = ref _mixContext.GetState(voiceState.MixId);
ref MixInfo mix = ref _mixContext.GetState(voiceInfo.MixId);
_commandBuffer.GenerateDepopPrepare(
dspState,
_rendererContext.DepopBuffer,
mix.BufferCount,
mix.BufferOffset,
voiceState.NodeId,
voiceState.WasPlaying);
voiceInfo.NodeId,
voiceInfo.WasPlaying);
}
else if (voiceState.SplitterId != Constants.UnusedSplitterId)
else if (voiceInfo.SplitterId != Constants.UnusedSplitterId)
{
int destinationId = 0;
while (true)
{
SplitterDestination destination = _splitterContext.GetDestination((int)voiceState.SplitterId, destinationId++);
SplitterDestination destination = _splitterContext.GetDestination((int)voiceInfo.SplitterId, destinationId++);
if (destination.IsNull)
{
@@ -74,15 +74,17 @@ namespace Ryujinx.Audio.Renderer.Server
if (mixId < _mixContext.GetCount() && mixId != Constants.UnusedSplitterIdInt)
{
ref MixState mix = ref _mixContext.GetState(mixId);
ref MixInfo mix = ref _mixContext.GetState(mixId);
// _commandBuffer.GenerateFillBuffer();
_commandBuffer.GenerateDepopPrepare(
dspState,
_rendererContext.DepopBuffer,
mix.BufferCount,
mix.BufferOffset,
voiceState.NodeId,
voiceState.WasPlaying);
voiceInfo.NodeId,
voiceInfo.WasPlaying);
destination.MarkAsNeedToUpdateInternalState();
}
@@ -90,71 +92,71 @@ namespace Ryujinx.Audio.Renderer.Server
}
}
if (!voiceState.WasPlaying)
if (!voiceInfo.WasPlaying)
{
Debug.Assert(voiceState.SampleFormat != SampleFormat.Adpcm || channelIndex == 0);
Debug.Assert(voiceInfo.SampleFormat != SampleFormat.Adpcm || channelIndex == 0);
if (_rendererContext.BehaviourContext.IsWaveBufferVersion2Supported())
if (_rendererContext.BehaviourInfo.IsWaveBufferVersion2Supported())
{
_commandBuffer.GenerateDataSourceVersion2(
ref voiceState,
ref voiceInfo,
dspState,
(ushort)_rendererContext.MixBufferCount,
(ushort)channelIndex,
voiceState.NodeId);
voiceInfo.NodeId);
}
else
{
switch (voiceState.SampleFormat)
switch (voiceInfo.SampleFormat)
{
case SampleFormat.PcmInt16:
_commandBuffer.GeneratePcmInt16DataSourceVersion1(
ref voiceState,
ref voiceInfo,
dspState,
(ushort)_rendererContext.MixBufferCount,
(ushort)channelIndex,
voiceState.NodeId);
voiceInfo.NodeId);
break;
case SampleFormat.PcmFloat:
_commandBuffer.GeneratePcmFloatDataSourceVersion1(
ref voiceState,
ref voiceInfo,
dspState,
(ushort)_rendererContext.MixBufferCount,
(ushort)channelIndex,
voiceState.NodeId);
voiceInfo.NodeId);
break;
case SampleFormat.Adpcm:
_commandBuffer.GenerateAdpcmDataSourceVersion1(
ref voiceState,
ref voiceInfo,
dspState,
(ushort)_rendererContext.MixBufferCount,
voiceState.NodeId);
voiceInfo.NodeId);
break;
default:
throw new NotImplementedException($"Unsupported data source {voiceState.SampleFormat}");
throw new NotImplementedException($"Unsupported data source {voiceInfo.SampleFormat}");
}
}
}
}
private void GenerateBiquadFilterForVoice(ref VoiceState voiceState, Memory<VoiceUpdateState> state, int baseIndex, int bufferOffset, int nodeId)
private void GenerateBiquadFilterForVoice(ref VoiceInfo voiceInfo, Memory<VoiceState> state, int baseIndex, int bufferOffset, int nodeId)
{
bool supportsOptimizedPath = _rendererContext.BehaviourContext.UseMultiTapBiquadFilterProcessing();
bool supportsOptimizedPath = _rendererContext.BehaviourInfo.UseMultiTapBiquadFilterProcessing();
Span<BiquadFilterParameter> biquadFiltersSpan = voiceState.BiquadFilters.AsSpan();
Span<BiquadFilterParameter2> biquadFiltersSpan = voiceInfo.BiquadFilters.AsSpan();
if (supportsOptimizedPath && biquadFiltersSpan[0].Enable && biquadFiltersSpan[1].Enable)
{
Memory<byte> biquadStateRawMemory = SpanMemoryManager<byte>.Cast(state)[..(Unsafe.SizeOf<BiquadFilterState>() * Constants.VoiceBiquadFilterCount)];
Memory<BiquadFilterState> stateMemory = SpanMemoryManager<BiquadFilterState>.Cast(biquadStateRawMemory);
_commandBuffer.GenerateMultiTapBiquadFilter(baseIndex, biquadFiltersSpan, stateMemory, bufferOffset, bufferOffset, voiceState.BiquadFilterNeedInitialization, nodeId);
_commandBuffer.GenerateMultiTapBiquadFilter(baseIndex, biquadFiltersSpan, stateMemory, bufferOffset, bufferOffset, voiceInfo.BiquadFilterNeedInitialization, nodeId);
}
else
{
for (int i = 0; i < biquadFiltersSpan.Length; i++)
{
ref BiquadFilterParameter filter = ref biquadFiltersSpan[i];
ref BiquadFilterParameter2 filter = ref biquadFiltersSpan[i];
if (filter.Enable)
{
@@ -167,7 +169,7 @@ namespace Ryujinx.Audio.Renderer.Server
stateMemory.Slice(i, 1),
bufferOffset,
bufferOffset,
!voiceState.BiquadFilterNeedInitialization[i],
!voiceInfo.BiquadFilterNeedInitialization[i],
nodeId);
}
}
@@ -176,7 +178,7 @@ namespace Ryujinx.Audio.Renderer.Server
private void GenerateVoiceMixWithSplitter(
SplitterDestination destination,
Memory<VoiceUpdateState> state,
Memory<VoiceState> state,
uint bufferOffset,
uint bufferCount,
uint bufferIndex,
@@ -185,8 +187,8 @@ namespace Ryujinx.Audio.Renderer.Server
ReadOnlySpan<float> mixVolumes = destination.MixBufferVolume;
ReadOnlySpan<float> previousMixVolumes = destination.PreviousMixBufferVolume;
ref BiquadFilterParameter bqf0 = ref destination.GetBiquadFilterParameter(0);
ref BiquadFilterParameter bqf1 = ref destination.GetBiquadFilterParameter(1);
ref BiquadFilterParameter2 bqf0 = ref destination.GetBiquadFilterParameter(0);
ref BiquadFilterParameter2 bqf1 = ref destination.GetBiquadFilterParameter(1);
Memory<BiquadFilterState> bqfState = _splitterContext.GetBiquadFilterState(destination);
@@ -270,7 +272,7 @@ namespace Ryujinx.Audio.Renderer.Server
private void GenerateVoiceMix(
ReadOnlySpan<float> mixVolumes,
ReadOnlySpan<float> previousMixVolumes,
Memory<VoiceUpdateState> state,
Memory<VoiceState> state,
uint bufferOffset,
uint bufferCount,
uint bufferIndex,
@@ -309,34 +311,34 @@ namespace Ryujinx.Audio.Renderer.Server
}
}
private void GenerateVoice(ref VoiceState voiceState)
private void GenerateVoice(ref VoiceInfo voiceInfo)
{
int nodeId = voiceState.NodeId;
uint channelsCount = voiceState.ChannelsCount;
int nodeId = voiceInfo.NodeId;
uint channelsCount = voiceInfo.ChannelsCount;
Span<int> channelResourceIdsSpan = voiceState.ChannelResourceIds.AsSpan();
Span<BiquadFilterParameter> biquadFiltersSpan = voiceState.BiquadFilters.AsSpan();
Span<int> channelResourceIdsSpan = voiceInfo.ChannelResourceIds.AsSpan();
Span<BiquadFilterParameter2> biquadFiltersSpan = voiceInfo.BiquadFilters.AsSpan();
for (int channelIndex = 0; channelIndex < channelsCount; channelIndex++)
{
Memory<VoiceUpdateState> dspStateMemory = _voiceContext.GetUpdateStateForDsp(channelResourceIdsSpan[channelIndex]);
Memory<VoiceState> dspStateMemory = _voiceContext.GetUpdateStateForDsp(channelResourceIdsSpan[channelIndex]);
ref VoiceChannelResource channelResource = ref _voiceContext.GetChannelResource(channelResourceIdsSpan[channelIndex]);
PerformanceDetailType dataSourceDetailType = PerformanceDetailType.Adpcm;
if (voiceState.SampleFormat == SampleFormat.PcmInt16)
if (voiceInfo.SampleFormat == SampleFormat.PcmInt16)
{
dataSourceDetailType = PerformanceDetailType.PcmInt16;
}
else if (voiceState.SampleFormat == SampleFormat.PcmFloat)
else if (voiceInfo.SampleFormat == SampleFormat.PcmFloat)
{
dataSourceDetailType = PerformanceDetailType.PcmFloat;
}
bool performanceInitialized = false;
PerformanceEntryAddresses performanceEntry = new();
PerformanceEntryAddresses performanceEntry = null;
if (_performanceManager != null && _performanceManager.IsTargetNodeId(nodeId) && _performanceManager.GetNextEntry(out performanceEntry, dataSourceDetailType, PerformanceEntryType.Voice, nodeId))
{
@@ -345,18 +347,18 @@ namespace Ryujinx.Audio.Renderer.Server
GeneratePerformance(ref performanceEntry, PerformanceCommand.Type.Start, nodeId);
}
GenerateDataSource(ref voiceState, dspStateMemory, channelIndex);
GenerateDataSource(ref voiceInfo, dspStateMemory, channelIndex);
if (performanceInitialized)
{
GeneratePerformance(ref performanceEntry, PerformanceCommand.Type.End, nodeId);
}
if (voiceState.WasPlaying)
if (voiceInfo.WasPlaying)
{
voiceState.PreviousVolume = 0.0f;
voiceInfo.PreviousVolume = 0.0f;
}
else if (voiceState.HasAnyDestination())
else if (voiceInfo.HasAnyDestination())
{
performanceInitialized = false;
@@ -367,7 +369,7 @@ namespace Ryujinx.Audio.Renderer.Server
GeneratePerformance(ref performanceEntry, PerformanceCommand.Type.Start, nodeId);
}
GenerateBiquadFilterForVoice(ref voiceState, dspStateMemory, (int)_rendererContext.MixBufferCount, channelIndex, nodeId);
GenerateBiquadFilterForVoice(ref voiceInfo, dspStateMemory, (int)_rendererContext.MixBufferCount, channelIndex, nodeId);
if (performanceInitialized)
{
@@ -384,8 +386,8 @@ namespace Ryujinx.Audio.Renderer.Server
}
_commandBuffer.GenerateVolumeRamp(
voiceState.PreviousVolume,
voiceState.Volume,
voiceInfo.PreviousVolume,
voiceInfo.Volume,
_rendererContext.MixBufferCount + (uint)channelIndex,
nodeId);
@@ -394,17 +396,17 @@ namespace Ryujinx.Audio.Renderer.Server
GeneratePerformance(ref performanceEntry, PerformanceCommand.Type.End, nodeId);
}
voiceState.PreviousVolume = voiceState.Volume;
voiceInfo.PreviousVolume = voiceInfo.Volume;
if (voiceState.MixId == Constants.UnusedMixId)
if (voiceInfo.MixId == Constants.UnusedMixId)
{
if (voiceState.SplitterId != Constants.UnusedSplitterId)
if (voiceInfo.SplitterId != Constants.UnusedSplitterId)
{
int destinationId = channelIndex;
while (true)
{
SplitterDestination destination = _splitterContext.GetDestination((int)voiceState.SplitterId, destinationId);
SplitterDestination destination = _splitterContext.GetDestination((int)voiceInfo.SplitterId, destinationId);
if (destination.IsNull)
{
@@ -419,7 +421,7 @@ namespace Ryujinx.Audio.Renderer.Server
if (mixId < _mixContext.GetCount() && mixId != Constants.UnusedSplitterIdInt)
{
ref MixState mix = ref _mixContext.GetState(mixId);
ref MixInfo mix = ref _mixContext.GetState(mixId);
if (destination.IsBiquadFilterEnabled())
{
@@ -451,7 +453,7 @@ namespace Ryujinx.Audio.Renderer.Server
}
else
{
ref MixState mix = ref _mixContext.GetState(voiceState.MixId);
ref MixInfo mix = ref _mixContext.GetState(voiceInfo.MixId);
performanceInitialized = false;
@@ -479,9 +481,9 @@ namespace Ryujinx.Audio.Renderer.Server
channelResource.UpdateState();
}
for (int i = 0; i < voiceState.BiquadFilterNeedInitialization.Length; i++)
for (int i = 0; i < voiceInfo.BiquadFilterNeedInitialization.Length; i++)
{
voiceState.BiquadFilterNeedInitialization[i] = biquadFiltersSpan[i].Enable;
voiceInfo.BiquadFilterNeedInitialization[i] = biquadFiltersSpan[i].Enable;
}
}
}
@@ -491,13 +493,13 @@ namespace Ryujinx.Audio.Renderer.Server
{
for (int i = 0; i < _voiceContext.GetCount(); i++)
{
ref VoiceState sortedState = ref _voiceContext.GetSortedState(i);
ref VoiceInfo sortedInfo = ref _voiceContext.GetSortedState(i);
if (!sortedState.ShouldSkip() && sortedState.UpdateForCommandGeneration(_voiceContext))
if (!sortedInfo.ShouldSkip() && sortedInfo.UpdateForCommandGeneration(_voiceContext))
{
int nodeId = sortedState.NodeId;
int nodeId = sortedInfo.NodeId;
PerformanceEntryAddresses performanceEntry = new();
PerformanceEntryAddresses performanceEntry = null;
bool performanceInitialized = false;
@@ -508,7 +510,7 @@ namespace Ryujinx.Audio.Renderer.Server
GeneratePerformance(ref performanceEntry, PerformanceCommand.Type.Start, nodeId);
}
GenerateVoice(ref sortedState);
GenerateVoice(ref sortedInfo);
if (performanceInitialized)
{
@@ -639,9 +641,9 @@ namespace Ryujinx.Audio.Renderer.Server
if (effect.IsEnabled)
{
bool needInitialization = effect.Parameter.Status == UsageState.Invalid ||
(effect.Parameter.Status == UsageState.New && !_rendererContext.BehaviourContext.IsBiquadFilterEffectStateClearBugFixed());
(effect.Parameter.Status == UsageState.New && !_rendererContext.BehaviourInfo.IsBiquadFilterEffectStateClearBugFixed());
BiquadFilterParameter parameter = new()
BiquadFilterParameter2 parameter = new()
{
Enable = true,
};
@@ -683,7 +685,7 @@ namespace Ryujinx.Audio.Renderer.Server
ulong workBuffer = effect.GetWorkBuffer(-1);
if (_rendererContext.BehaviourContext.IsEffectInfoVersion2Supported())
if (_rendererContext.BehaviourInfo.IsEffectInfoVersion2Supported())
{
Memory<EffectResultState> dspResultState;
@@ -777,13 +779,13 @@ namespace Ryujinx.Audio.Renderer.Server
nodeId);
}
private void GenerateEffect(ref MixState mix, int effectId, BaseEffect effect)
private void GenerateEffect(ref MixInfo mix, int effectId, BaseEffect effect)
{
int nodeId = mix.NodeId;
bool isFinalMix = mix.MixId == Constants.FinalMixId;
PerformanceEntryAddresses performanceEntry = new();
PerformanceEntryAddresses performanceEntry = null;
bool performanceInitialized = false;
@@ -807,13 +809,13 @@ namespace Ryujinx.Audio.Renderer.Server
GenerateAuxEffect(mix.BufferOffset, (AuxiliaryBufferEffect)effect, nodeId);
break;
case EffectType.Delay:
GenerateDelayEffect(mix.BufferOffset, (DelayEffect)effect, nodeId, _rendererContext.BehaviourContext.IsNewEffectChannelMappingSupported());
GenerateDelayEffect(mix.BufferOffset, (DelayEffect)effect, nodeId, _rendererContext.BehaviourInfo.IsNewEffectChannelMappingSupported());
break;
case EffectType.Reverb:
GenerateReverbEffect(mix.BufferOffset, (ReverbEffect)effect, nodeId, mix.IsLongSizePreDelaySupported, _rendererContext.BehaviourContext.IsNewEffectChannelMappingSupported());
GenerateReverbEffect(mix.BufferOffset, (ReverbEffect)effect, nodeId, mix.IsLongSizePreDelaySupported, _rendererContext.BehaviourInfo.IsNewEffectChannelMappingSupported());
break;
case EffectType.Reverb3d:
GenerateReverb3dEffect(mix.BufferOffset, (Reverb3dEffect)effect, nodeId, _rendererContext.BehaviourContext.IsNewEffectChannelMappingSupported());
GenerateReverb3dEffect(mix.BufferOffset, (Reverb3dEffect)effect, nodeId, _rendererContext.BehaviourInfo.IsNewEffectChannelMappingSupported());
break;
case EffectType.BiquadFilter:
GenerateBiquadFilterEffect(mix.BufferOffset, (BiquadFilterEffect)effect, nodeId);
@@ -839,7 +841,7 @@ namespace Ryujinx.Audio.Renderer.Server
effect.UpdateForCommandGeneration();
}
private void GenerateEffects(ref MixState mix)
private void GenerateEffects(ref MixInfo mix)
{
ReadOnlySpan<int> effectProcessingOrderArray = mix.EffectProcessingOrderArray;
@@ -875,8 +877,8 @@ namespace Ryujinx.Audio.Renderer.Server
ref bool isFirstMixBuffer,
int nodeId)
{
ref BiquadFilterParameter bqf0 = ref destination.GetBiquadFilterParameter(0);
ref BiquadFilterParameter bqf1 = ref destination.GetBiquadFilterParameter(1);
ref BiquadFilterParameter2 bqf0 = ref destination.GetBiquadFilterParameter(0);
ref BiquadFilterParameter2 bqf1 = ref destination.GetBiquadFilterParameter(1);
Memory<BiquadFilterState> bqfState = _splitterContext.GetBiquadFilterState(destination);
@@ -888,7 +890,7 @@ namespace Ryujinx.Audio.Renderer.Server
inputBufferIndex,
outputBufferIndex,
0,
Memory<VoiceUpdateState>.Empty,
Memory<VoiceState>.Empty,
ref bqf0,
ref bqf1,
bqfState[..1],
@@ -912,7 +914,7 @@ namespace Ryujinx.Audio.Renderer.Server
inputBufferIndex,
outputBufferIndex,
0,
Memory<VoiceUpdateState>.Empty,
Memory<VoiceState>.Empty,
ref bqf0,
bqfState[..1],
bqfState.Slice(1, 1),
@@ -931,7 +933,7 @@ namespace Ryujinx.Audio.Renderer.Server
inputBufferIndex,
outputBufferIndex,
0,
Memory<VoiceUpdateState>.Empty,
Memory<VoiceState>.Empty,
ref bqf1,
bqfState[..1],
bqfState.Slice(1, 1),
@@ -946,7 +948,7 @@ namespace Ryujinx.Audio.Renderer.Server
isFirstMixBuffer = false;
}
private void GenerateMix(ref MixState mix)
private void GenerateMix(ref MixInfo mix)
{
if (mix.HasAnyDestination())
{
@@ -975,7 +977,7 @@ namespace Ryujinx.Audio.Renderer.Server
if (mixId < _mixContext.GetCount() && mixId != Constants.UnusedSplitterIdInt)
{
ref MixState destinationMix = ref _mixContext.GetState(mixId);
ref MixInfo destinationMix = ref _mixContext.GetState(mixId);
uint inputBufferIndex = mix.BufferOffset + ((uint)destinationIndex % mix.BufferCount);
@@ -1014,7 +1016,7 @@ namespace Ryujinx.Audio.Renderer.Server
}
else
{
ref MixState destinationMix = ref _mixContext.GetState(mix.DestinationMixId);
ref MixInfo destinationMix = ref _mixContext.GetState(mix.DestinationMixId);
for (uint bufferIndex = 0; bufferIndex < mix.BufferCount; bufferIndex++)
{
@@ -1036,7 +1038,7 @@ namespace Ryujinx.Audio.Renderer.Server
}
}
private void GenerateSubMix(ref MixState subMix)
private void GenerateSubMix(ref MixInfo subMix)
{
_commandBuffer.GenerateDepopForMixBuffers(
_rendererContext.DepopBuffer,
@@ -1047,7 +1049,7 @@ namespace Ryujinx.Audio.Renderer.Server
GenerateEffects(ref subMix);
PerformanceEntryAddresses performanceEntry = new();
PerformanceEntryAddresses performanceEntry = null;
int nodeId = subMix.NodeId;
@@ -1072,13 +1074,13 @@ namespace Ryujinx.Audio.Renderer.Server
{
for (int id = 0; id < _mixContext.GetCount(); id++)
{
ref MixState sortedState = ref _mixContext.GetSortedState(id);
ref MixInfo sortedInfo = ref _mixContext.GetSortedState(id);
if (sortedState.IsUsed && sortedState.MixId != Constants.FinalMixId)
if (sortedInfo.IsUsed && sortedInfo.MixId != Constants.FinalMixId)
{
int nodeId = sortedState.NodeId;
int nodeId = sortedInfo.NodeId;
PerformanceEntryAddresses performanceEntry = new();
PerformanceEntryAddresses performanceEntry = null;
bool performanceInitialized = false;
@@ -1089,7 +1091,7 @@ namespace Ryujinx.Audio.Renderer.Server
GeneratePerformance(ref performanceEntry, PerformanceCommand.Type.Start, nodeId);
}
GenerateSubMix(ref sortedState);
GenerateSubMix(ref sortedInfo);
if (performanceInitialized)
{
@@ -1101,7 +1103,7 @@ namespace Ryujinx.Audio.Renderer.Server
private void GenerateFinalMix()
{
ref MixState finalMix = ref _mixContext.GetFinalState();
ref MixInfo finalMix = ref _mixContext.GetFinalState();
_commandBuffer.GenerateDepopForMixBuffers(
_rendererContext.DepopBuffer,
@@ -1112,7 +1114,7 @@ namespace Ryujinx.Audio.Renderer.Server
GenerateEffects(ref finalMix);
PerformanceEntryAddresses performanceEntry = new();
PerformanceEntryAddresses performanceEntry = null;
int nodeId = finalMix.NodeId;
@@ -1161,7 +1163,7 @@ namespace Ryujinx.Audio.Renderer.Server
{
int nodeId = _mixContext.GetFinalState().NodeId;
PerformanceEntryAddresses performanceEntry = new();
PerformanceEntryAddresses performanceEntry = null;
bool performanceInitialized = false;
@@ -1180,16 +1182,16 @@ namespace Ryujinx.Audio.Renderer.Server
}
}
private void GenerateCircularBuffer(CircularBufferSink sink, ref MixState finalMix)
private void GenerateCircularBuffer(CircularBufferSink sink, ref MixInfo finalMix)
{
_commandBuffer.GenerateCircularBuffer(finalMix.BufferOffset, sink, Constants.InvalidNodeId);
}
private void GenerateDevice(DeviceSink sink, ref MixState finalMix)
private void GenerateDevice(DeviceSink sink, ref MixInfo finalMix)
{
if (_commandBuffer.CommandList.SampleRate != 48000 && sink.UpsamplerState == null)
if (_commandBuffer.CommandList.SampleRate != 48000 && sink.UpsamplerInfo == null)
{
sink.UpsamplerState = _rendererContext.UpsamplerManager.Allocate();
sink.UpsamplerInfo = _rendererContext.UpsamplerManager.Allocate();
}
bool useCustomDownMixingCommand = _rendererContext.ChannelCount == 2 && sink.Parameter.DownMixParameterEnabled;
@@ -1216,11 +1218,11 @@ namespace Ryujinx.Audio.Renderer.Server
CommandList commandList = _commandBuffer.CommandList;
if (sink.UpsamplerState != null)
if (sink.UpsamplerInfo != null)
{
_commandBuffer.GenerateUpsample(
finalMix.BufferOffset,
sink.UpsamplerState,
sink.UpsamplerInfo,
sink.Parameter.InputCount,
sink.Parameter.Input.AsSpan(),
commandList.BufferCount,
@@ -1237,11 +1239,11 @@ namespace Ryujinx.Audio.Renderer.Server
Constants.InvalidNodeId);
}
private void GenerateSink(BaseSink sink, ref MixState finalMix)
private void GenerateSink(BaseSink sink, ref MixInfo finalMix)
{
bool performanceInitialized = false;
PerformanceEntryAddresses performanceEntry = new();
PerformanceEntryAddresses performanceEntry = null;
if (_performanceManager != null && _performanceManager.GetNextEntry(out performanceEntry, PerformanceEntryType.Sink, sink.NodeId))
{
@@ -1275,7 +1277,7 @@ namespace Ryujinx.Audio.Renderer.Server
public void GenerateSinks()
{
ref MixState finalMix = ref _mixContext.GetFinalState();
ref MixInfo finalMix = ref _mixContext.GetFinalState();
for (int i = 0; i < _sinkContext.GetCount(); i++)
{

View File

@@ -194,5 +194,10 @@ namespace Ryujinx.Audio.Renderer.Server
{
return 0;
}
public uint Estimate(FillBufferCommand command)
{
return 0;
}
}
}

View File

@@ -486,5 +486,10 @@ namespace Ryujinx.Audio.Renderer.Server
{
return 0;
}
public uint Estimate(FillBufferCommand command)
{
return 0;
}
}
}

View File

@@ -3,7 +3,7 @@ using Ryujinx.Audio.Renderer.Dsp.Command;
using Ryujinx.Audio.Renderer.Parameter.Effect;
using System;
using System.Diagnostics;
using static Ryujinx.Audio.Renderer.Parameter.VoiceInParameter;
using Ryujinx.Audio.Renderer.Parameter;
namespace Ryujinx.Audio.Renderer.Server
{
@@ -656,5 +656,10 @@ namespace Ryujinx.Audio.Renderer.Server
{
return 0;
}
public virtual uint Estimate(FillBufferCommand command)
{
return 0;
}
}
}

View File

@@ -286,5 +286,10 @@ namespace Ryujinx.Audio.Renderer.Server
return 8683;
}
}
public override uint Estimate(FillBufferCommand command)
{
return 0;
}
}
}

View File

@@ -1,4 +1,5 @@
using Ryujinx.Audio.Renderer.Common;
using Ryujinx.Audio.Renderer.Dsp;
using Ryujinx.Audio.Renderer.Dsp.State;
using Ryujinx.Audio.Renderer.Parameter;
using Ryujinx.Audio.Renderer.Parameter.Effect;
@@ -17,20 +18,26 @@ namespace Ryujinx.Audio.Renderer.Server.Effect
/// <summary>
/// The biquad filter parameter.
/// </summary>
public BiquadFilterEffectParameter Parameter;
public BiquadFilterEffectParameter2 Parameter;
/// <summary>
/// The biquad filter state.
/// </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 BiquadFilterEffectParameter();
Parameter = new BiquadFilterEffectParameter2();
State = new BiquadFilterState[Constants.ChannelCountMax];
BiquadFilterEffectVersion = version;
}
public override EffectType TargetEffectType => EffectType.BiquadFilter;
@@ -51,7 +58,17 @@ namespace Ryujinx.Audio.Renderer.Server.Effect
UpdateParameterBase(in parameter);
Parameter = MemoryMarshal.Cast<byte, BiquadFilterEffectParameter>(parameter.SpecificData)[0];
if (BiquadFilterEffectVersion == 2)
{
Parameter = MemoryMarshal.Cast<byte, BiquadFilterEffectParameter2>(parameter.SpecificData)[0];
}
else
{
BiquadFilterEffectParameter1 oldParameter =
MemoryMarshal.Cast<byte, BiquadFilterEffectParameter1>(parameter.SpecificData)[0];
Parameter = BiquadFilterHelper.ToBiquadFilterEffectParameter2(oldParameter);
}
IsEnabled = parameter.IsEnabled;
updateErrorInfo = new BehaviourParameter.ErrorInfo();

View File

@@ -38,5 +38,6 @@ namespace Ryujinx.Audio.Renderer.Server
uint Estimate(CompressorCommand command);
uint Estimate(BiquadFilterAndMixCommand command);
uint Estimate(MultiTapBiquadFilterAndMixCommand command);
uint Estimate(FillBufferCommand command);
}
}

View File

@@ -20,14 +20,14 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
/// </summary>
public ulong Size;
private unsafe MemoryPoolState* _memoryPools;
private unsafe MemoryPoolInfo* _memoryPools;
/// <summary>
/// The forced DSP address of the region.
/// </summary>
public DspAddress ForceMappedDspAddress;
private readonly unsafe ref MemoryPoolState MemoryPoolState => ref *_memoryPools;
private readonly unsafe ref MemoryPoolInfo MemoryPoolInfo => ref *_memoryPools;
public readonly unsafe bool HasMemoryPoolState => (nint)_memoryPools != nint.Zero;
@@ -53,7 +53,7 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
return new AddressInfo
{
CpuAddress = cpuAddress,
_memoryPools = MemoryPoolState.Null,
_memoryPools = MemoryPoolInfo.Null,
Size = size,
ForceMappedDspAddress = 0,
};
@@ -73,19 +73,19 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
unsafe
{
_memoryPools = MemoryPoolState.Null;
_memoryPools = MemoryPoolInfo.Null;
}
}
/// <summary>
/// Set the <see cref="MemoryPoolState"/> associated.
/// Set the <see cref="MemoryPoolInfo"/> associated.
/// </summary>
/// <param name="memoryPoolState">The <see cref="MemoryPoolState"/> associated.</param>
public void SetupMemoryPool(Span<MemoryPoolState> memoryPoolState)
/// <param name="memoryPoolState">The <see cref="MemoryPoolInfo"/> associated.</param>
public void SetupMemoryPool(Span<MemoryPoolInfo> memoryPoolState)
{
unsafe
{
fixed (MemoryPoolState* ptr = &MemoryMarshal.GetReference(memoryPoolState))
fixed (MemoryPoolInfo* ptr = &MemoryMarshal.GetReference(memoryPoolState))
{
SetupMemoryPool(ptr);
}
@@ -93,27 +93,27 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
}
/// <summary>
/// Set the <see cref="MemoryPoolState"/> associated.
/// Set the <see cref="MemoryPoolInfo"/> associated.
/// </summary>
/// <param name="memoryPoolState">The <see cref="MemoryPoolState"/> associated.</param>
public unsafe void SetupMemoryPool(MemoryPoolState* memoryPoolState)
/// <param name="memoryPoolState">The <see cref="MemoryPoolInfo"/> associated.</param>
public unsafe void SetupMemoryPool(MemoryPoolInfo* memoryPoolState)
{
_memoryPools = memoryPoolState;
}
/// <summary>
/// Check if the <see cref="MemoryPoolState"/> is mapped.
/// Check if the <see cref="MemoryPoolInfo"/> is mapped.
/// </summary>
/// <returns>Returns true if the <see cref="MemoryPoolState"/> is mapped.</returns>
/// <returns>Returns true if the <see cref="MemoryPoolInfo"/> is mapped.</returns>
public readonly bool HasMappedMemoryPool()
{
return HasMemoryPoolState && MemoryPoolState.IsMapped();
return HasMemoryPoolState && MemoryPoolInfo.IsMapped();
}
/// <summary>
/// Get the DSP address associated to the <see cref="AddressInfo"/>.
/// </summary>
/// <param name="markUsed">If true, mark the <see cref="MemoryPoolState"/> as used.</param>
/// <param name="markUsed">If true, mark the <see cref="MemoryPoolInfo"/> as used.</param>
/// <returns>Returns the DSP address associated to the <see cref="AddressInfo"/>.</returns>
public readonly DspAddress GetReference(bool markUsed)
{
@@ -124,10 +124,10 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
if (markUsed)
{
MemoryPoolState.IsUsed = true;
MemoryPoolInfo.IsUsed = true;
}
return MemoryPoolState.Translate(CpuAddress, Size);
return MemoryPoolInfo.Translate(CpuAddress, Size);
}
}
}

View File

@@ -8,62 +8,62 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
/// Server state for a memory pool.
/// </summary>
[StructLayout(LayoutKind.Sequential, Size = 0x20, Pack = Alignment)]
public struct MemoryPoolState
public struct MemoryPoolInfo
{
public const int Alignment = 0x10;
/// <summary>
/// The location of the <see cref="MemoryPoolState"/>.
/// The location of the <see cref="MemoryPoolInfo"/>.
/// </summary>
public enum LocationType : uint
{
/// <summary>
/// <see cref="MemoryPoolState"/> located on the CPU side for user use.
/// <see cref="MemoryPoolInfo"/> located on the CPU side for user use.
/// </summary>
Cpu,
/// <summary>
/// <see cref="MemoryPoolState"/> located on the DSP side for system use.
/// <see cref="MemoryPoolInfo"/> located on the DSP side for system use.
/// </summary>
Dsp,
}
/// <summary>
/// The CPU address associated to the <see cref="MemoryPoolState"/>.
/// The CPU address associated to the <see cref="MemoryPoolInfo"/>.
/// </summary>
public CpuAddress CpuAddress;
/// <summary>
/// The DSP address associated to the <see cref="MemoryPoolState"/>.
/// The DSP address associated to the <see cref="MemoryPoolInfo"/>.
/// </summary>
public DspAddress DspAddress;
/// <summary>
/// The size associated to the <see cref="MemoryPoolState"/>.
/// The size associated to the <see cref="MemoryPoolInfo"/>.
/// </summary>
public ulong Size;
/// <summary>
/// The <see cref="LocationType"/> associated to the <see cref="MemoryPoolState"/>.
/// The <see cref="LocationType"/> associated to the <see cref="MemoryPoolInfo"/>.
/// </summary>
public LocationType Location;
/// <summary>
/// Set to true if the <see cref="MemoryPoolState"/> is used.
/// Set to true if the <see cref="MemoryPoolInfo"/> is used.
/// </summary>
[MarshalAs(UnmanagedType.I1)]
public bool IsUsed;
public static unsafe MemoryPoolState* Null => (MemoryPoolState*)nint.Zero.ToPointer();
public static unsafe MemoryPoolInfo* Null => (MemoryPoolInfo*)nint.Zero.ToPointer();
/// <summary>
/// Create a new <see cref="MemoryPoolState"/> with the given <see cref="LocationType"/>.
/// Create a new <see cref="MemoryPoolInfo"/> with the given <see cref="LocationType"/>.
/// </summary>
/// <param name="location">The location type to use.</param>
/// <returns>A new <see cref="MemoryPoolState"/> with the given <see cref="LocationType"/>.</returns>
public static MemoryPoolState Create(LocationType location)
/// <returns>A new <see cref="MemoryPoolInfo"/> with the given <see cref="LocationType"/>.</returns>
public static MemoryPoolInfo Create(LocationType location)
{
return new MemoryPoolState
return new MemoryPoolInfo
{
CpuAddress = 0,
DspAddress = 0,
@@ -73,7 +73,7 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
}
/// <summary>
/// Set the <see cref="CpuAddress"/> and size of the <see cref="MemoryPoolState"/>.
/// Set the <see cref="CpuAddress"/> and size of the <see cref="MemoryPoolInfo"/>.
/// </summary>
/// <param name="cpuAddress">The <see cref="CpuAddress"/>.</param>
/// <param name="size">The size.</param>
@@ -84,11 +84,11 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
}
/// <summary>
/// Check if the given <see cref="CpuAddress"/> and size is contains in the <see cref="MemoryPoolState"/>.
/// Check if the given <see cref="CpuAddress"/> and size is contains in the <see cref="MemoryPoolInfo"/>.
/// </summary>
/// <param name="targetCpuAddress">The <see cref="CpuAddress"/>.</param>
/// <param name="size">The size.</param>
/// <returns>True if the <see cref="CpuAddress"/> is contained inside the <see cref="MemoryPoolState"/>.</returns>
/// <returns>True if the <see cref="CpuAddress"/> is contained inside the <see cref="MemoryPoolInfo"/>.</returns>
public readonly bool Contains(CpuAddress targetCpuAddress, ulong size)
{
if (CpuAddress <= targetCpuAddress && size + targetCpuAddress <= Size + CpuAddress)
@@ -118,9 +118,9 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
}
/// <summary>
/// Is the <see cref="MemoryPoolState"/> mapped on the DSP?
/// Is the <see cref="MemoryPoolInfo"/> mapped on the DSP?
/// </summary>
/// <returns>Returns true if the <see cref="MemoryPoolState"/> is mapped on the DSP.</returns>
/// <returns>Returns true if the <see cref="MemoryPoolInfo"/> is mapped on the DSP.</returns>
public readonly bool IsMapped()
{
return DspAddress != 0;

View File

@@ -18,7 +18,7 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
const uint CurrentProcessPseudoHandle = 0xFFFF8001;
/// <summary>
/// The result of <see cref="Update(ref MemoryPoolState, ref MemoryPoolInParameter, ref MemoryPoolOutStatus)"/>.
/// The result of <see cref="Update(ref MemoryPoolInfo, ref MemoryPoolInParameter, ref MemoryPoolOutStatus)"/>.
/// </summary>
public enum UpdateResult : uint
{
@@ -49,9 +49,9 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
private readonly uint _processHandle;
/// <summary>
/// The <see cref="Memory{MemoryPoolState}"/> that will be manipulated.
/// The <see cref="Memory{MemoryPoolInfo}"/> that will be manipulated.
/// </summary>
private readonly Memory<MemoryPoolState> _memoryPools;
private readonly Memory<MemoryPoolInfo> _memoryPools;
/// <summary>
/// If set to true, this will try to force map memory pool even if their state are considered invalid.
@@ -67,7 +67,7 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
{
_processHandle = processHandle;
_isForceMapEnabled = isForceMapEnabled;
_memoryPools = Memory<MemoryPoolState>.Empty;
_memoryPools = Memory<MemoryPoolInfo>.Empty;
}
/// <summary>
@@ -76,7 +76,7 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
/// <param name="processHandle">The handle of the process owning the CPU memory manipulated.</param>
/// <param name="memoryPool">The user memory pools.</param>
/// <param name="isForceMapEnabled">If set to true, this will try to force map memory pool even if their state are considered invalid.</param>
public PoolMapper(uint processHandle, Memory<MemoryPoolState> memoryPool, bool isForceMapEnabled)
public PoolMapper(uint processHandle, Memory<MemoryPoolInfo> memoryPool, bool isForceMapEnabled)
{
_processHandle = processHandle;
_memoryPools = memoryPool;
@@ -84,15 +84,15 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
}
/// <summary>
/// Initialize the <see cref="MemoryPoolState"/> for system use.
/// Initialize the <see cref="MemoryPoolInfo"/> for system use.
/// </summary>
/// <param name="memoryPool">The <see cref="MemoryPoolState"/> for system use.</param>
/// <param name="memoryPool">The <see cref="MemoryPoolInfo"/> for system use.</param>
/// <param name="cpuAddress">The <see cref="CpuAddress"/> to assign.</param>
/// <param name="size">The size to assign.</param>
/// <returns>Returns true if mapping on the <see cref="Dsp.AudioProcessor"/> succeeded.</returns>
public bool InitializeSystemPool(ref MemoryPoolState memoryPool, CpuAddress cpuAddress, ulong size)
public bool InitializeSystemPool(ref MemoryPoolInfo memoryPool, CpuAddress cpuAddress, ulong size)
{
if (memoryPool.Location != MemoryPoolState.LocationType.Dsp)
if (memoryPool.Location != MemoryPoolInfo.LocationType.Dsp)
{
return false;
}
@@ -101,13 +101,13 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
}
/// <summary>
/// Initialize the <see cref="MemoryPoolState"/>.
/// Initialize the <see cref="MemoryPoolInfo"/>.
/// </summary>
/// <param name="memoryPool">The <see cref="MemoryPoolState"/>.</param>
/// <param name="memoryPool">The <see cref="MemoryPoolInfo"/>.</param>
/// <param name="cpuAddress">The <see cref="CpuAddress"/> to assign.</param>
/// <param name="size">The size to assign.</param>
/// <returns>Returns true if mapping on the <see cref="Dsp.AudioProcessor"/> succeeded.</returns>
public bool InitializePool(ref MemoryPoolState memoryPool, CpuAddress cpuAddress, ulong size)
public bool InitializePool(ref MemoryPoolInfo memoryPool, CpuAddress cpuAddress, ulong size)
{
memoryPool.SetCpuAddress(cpuAddress, size);
@@ -115,18 +115,18 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
}
/// <summary>
/// Get the process handle associated to the <see cref="MemoryPoolState"/>.
/// Get the process handle associated to the <see cref="MemoryPoolInfo"/>.
/// </summary>
/// <param name="memoryPool">The <see cref="MemoryPoolState"/>.</param>
/// <returns>Returns the process handle associated to the <see cref="MemoryPoolState"/>.</returns>
public uint GetProcessHandle(ref MemoryPoolState memoryPool)
/// <param name="memoryPool">The <see cref="MemoryPoolInfo"/>.</param>
/// <returns>Returns the process handle associated to the <see cref="MemoryPoolInfo"/>.</returns>
public uint GetProcessHandle(ref MemoryPoolInfo memoryPool)
{
if (memoryPool.Location == MemoryPoolState.LocationType.Cpu)
if (memoryPool.Location == MemoryPoolInfo.LocationType.Cpu)
{
return CurrentProcessPseudoHandle;
}
if (memoryPool.Location == MemoryPoolState.LocationType.Dsp)
if (memoryPool.Location == MemoryPoolInfo.LocationType.Dsp)
{
return _processHandle;
}
@@ -135,11 +135,11 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
}
/// <summary>
/// Map the <see cref="MemoryPoolState"/> on the <see cref="Dsp.AudioProcessor"/>.
/// Map the <see cref="MemoryPoolInfo"/> on the <see cref="Dsp.AudioProcessor"/>.
/// </summary>
/// <param name="memoryPool">The <see cref="MemoryPoolState"/> to map.</param>
/// <param name="memoryPool">The <see cref="MemoryPoolInfo"/> to map.</param>
/// <returns>Returns the DSP address mapped.</returns>
public DspAddress Map(ref MemoryPoolState memoryPool)
public DspAddress Map(ref MemoryPoolInfo memoryPool)
{
DspAddress result = AudioProcessorMemoryManager.Map(GetProcessHandle(ref memoryPool), memoryPool.CpuAddress, memoryPool.Size);
@@ -152,11 +152,11 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
}
/// <summary>
/// Unmap the <see cref="MemoryPoolState"/> from the <see cref="Dsp.AudioProcessor"/>.
/// Unmap the <see cref="MemoryPoolInfo"/> from the <see cref="Dsp.AudioProcessor"/>.
/// </summary>
/// <param name="memoryPool">The <see cref="MemoryPoolState"/> to unmap.</param>
/// <param name="memoryPool">The <see cref="MemoryPoolInfo"/> to unmap.</param>
/// <returns>Returns true if unmapped.</returns>
public bool Unmap(ref MemoryPoolState memoryPool)
public bool Unmap(ref MemoryPoolInfo memoryPool)
{
if (memoryPool.IsUsed)
{
@@ -172,12 +172,12 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
}
/// <summary>
/// Find a <see cref="MemoryPoolState"/> associated to the region given.
/// Find a <see cref="MemoryPoolInfo"/> associated to the region given.
/// </summary>
/// <param name="cpuAddress">The region <see cref="CpuAddress"/>.</param>
/// <param name="size">The region size.</param>
/// <returns>Returns the <see cref="MemoryPoolState"/> found or <see cref="Memory{MemoryPoolState}.Empty"/> if not found.</returns>
private Span<MemoryPoolState> FindMemoryPool(CpuAddress cpuAddress, ulong size)
/// <returns>Returns the <see cref="MemoryPoolInfo"/> found or <see cref="Memory{MemoryPoolInfo}.Empty"/> if not found.</returns>
private Span<MemoryPoolInfo> FindMemoryPool(CpuAddress cpuAddress, ulong size)
{
if (!_memoryPools.IsEmpty && _memoryPools.Length > 0)
{
@@ -190,7 +190,7 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
}
}
return Span<MemoryPoolState>.Empty;
return Span<MemoryPoolInfo>.Empty;
}
/// <summary>
@@ -201,7 +201,7 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
{
if (_isForceMapEnabled)
{
Span<MemoryPoolState> memoryPool = FindMemoryPool(addressInfo.CpuAddress, addressInfo.Size);
Span<MemoryPoolInfo> memoryPool = FindMemoryPool(addressInfo.CpuAddress, addressInfo.Size);
if (!memoryPool.IsEmpty)
{
@@ -243,13 +243,13 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
}
/// <summary>
/// Update a <see cref="MemoryPoolState"/> using user parameters.
/// Update a <see cref="MemoryPoolInfo"/> using user parameters.
/// </summary>
/// <param name="memoryPool">The <see cref="MemoryPoolState"/> to update.</param>
/// <param name="memoryPool">The <see cref="MemoryPoolInfo"/> to update.</param>
/// <param name="inParameter">Input user parameter.</param>
/// <param name="outStatus">Output user parameter.</param>
/// <returns>Returns the <see cref="UpdateResult"/> of the operations performed.</returns>
public UpdateResult Update(ref MemoryPoolState memoryPool, in MemoryPoolInParameter inParameter, ref MemoryPoolOutStatus outStatus)
public UpdateResult Update(ref MemoryPoolInfo memoryPool, in MemoryPoolInParameter inParameter, ref MemoryPoolOutStatus outStatus)
{
MemoryPoolUserState inputState = inParameter.State;
@@ -321,7 +321,7 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
if (_memoryPools.Length > 0)
{
Span<MemoryPoolState> memoryPool = FindMemoryPool(addressInfo.CpuAddress, addressInfo.Size);
Span<MemoryPoolInfo> memoryPool = FindMemoryPool(addressInfo.CpuAddress, addressInfo.Size);
if (!memoryPool.IsEmpty)
{
@@ -343,7 +343,7 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
{
unsafe
{
addressInfo.SetupMemoryPool(MemoryPoolState.Null);
addressInfo.SetupMemoryPool(MemoryPoolInfo.Null);
}
}
@@ -351,12 +351,12 @@ namespace Ryujinx.Audio.Renderer.Server.MemoryPool
}
/// <summary>
/// Remove the usage flag from all the <see cref="MemoryPoolState"/>.
/// Remove the usage flag from all the <see cref="MemoryPoolInfo"/>.
/// </summary>
/// <param name="memoryPool">The <see cref="Memory{MemoryPoolState}"/> to reset.</param>
public static void ClearUsageState(Memory<MemoryPoolState> memoryPool)
/// <param name="memoryPool">The <see cref="Memory{MemoryPoolInfo}"/> to reset.</param>
public static void ClearUsageState(Memory<MemoryPoolInfo> memoryPool)
{
foreach (ref MemoryPoolState info in memoryPool.Span)
foreach (ref MemoryPoolInfo info in memoryPool.Span)
{
info.IsUsed = false;
}

View File

@@ -17,12 +17,12 @@ namespace Ryujinx.Audio.Renderer.Server.Mix
private uint _mixesCount;
/// <summary>
/// Storage for <see cref="MixState"/>.
/// Storage for <see cref="MixInfo"/>.
/// </summary>
private Memory<MixState> _mixes;
private Memory<MixInfo> _mixes;
/// <summary>
/// Storage of the sorted indices to <see cref="MixState"/>.
/// Storage of the sorted indices to <see cref="MixInfo"/>.
/// </summary>
private Memory<int> _sortedMixes;
@@ -49,10 +49,10 @@ namespace Ryujinx.Audio.Renderer.Server.Mix
/// Initialize the <see cref="MixContext"/>.
/// </summary>
/// <param name="sortedMixes">The storage for sorted indices.</param>
/// <param name="mixes">The storage of <see cref="MixState"/>.</param>
/// <param name="mixes">The storage of <see cref="MixInfo"/>.</param>
/// <param name="nodeStatesWorkBuffer">The storage used for the <see cref="NodeStates"/>.</param>
/// <param name="edgeMatrixWorkBuffer">The storage used for the <see cref="EdgeMatrix"/>.</param>
public void Initialize(Memory<int> sortedMixes, Memory<MixState> mixes, Memory<byte> nodeStatesWorkBuffer, Memory<byte> edgeMatrixWorkBuffer)
public void Initialize(Memory<int> sortedMixes, Memory<MixInfo> mixes, Memory<byte> nodeStatesWorkBuffer, Memory<byte> edgeMatrixWorkBuffer)
{
_mixesCount = (uint)mixes.Length;
_mixes = mixes;
@@ -82,30 +82,30 @@ namespace Ryujinx.Audio.Renderer.Server.Mix
}
/// <summary>
/// Get a reference to the final <see cref="MixState"/>.
/// Get a reference to the final <see cref="MixInfo"/>.
/// </summary>
/// <returns>A reference to the final <see cref="MixState"/>.</returns>
public ref MixState GetFinalState()
/// <returns>A reference to the final <see cref="MixInfo"/>.</returns>
public ref MixInfo GetFinalState()
{
return ref GetState(Constants.FinalMixId);
}
/// <summary>
/// Get a reference to a <see cref="MixState"/> at the given <paramref name="id"/>.
/// Get a reference to a <see cref="MixInfo"/> at the given <paramref name="id"/>.
/// </summary>
/// <param name="id">The index to use.</param>
/// <returns>A reference to a <see cref="MixState"/> at the given <paramref name="id"/>.</returns>
public ref MixState GetState(int id)
/// <returns>A reference to a <see cref="MixInfo"/> at the given <paramref name="id"/>.</returns>
public ref MixInfo GetState(int id)
{
return ref SpanIOHelper.GetFromMemory(_mixes, id, _mixesCount);
}
/// <summary>
/// Get a reference to a <see cref="MixState"/> at the given <paramref name="id"/> of the sorted mix info.
/// Get a reference to a <see cref="MixInfo"/> at the given <paramref name="id"/> of the sorted mix info.
/// </summary>
/// <param name="id">The index to use.</param>
/// <returns>A reference to a <see cref="MixState"/> at the given <paramref name="id"/>.</returns>
public ref MixState GetSortedState(int id)
/// <returns>A reference to a <see cref="MixInfo"/> at the given <paramref name="id"/>.</returns>
public ref MixInfo GetSortedState(int id)
{
Debug.Assert(id >= 0 && id < _mixesCount);
@@ -122,18 +122,18 @@ namespace Ryujinx.Audio.Renderer.Server.Mix
}
/// <summary>
/// Update the internal distance from the final mix value of every <see cref="MixState"/>.
/// Update the internal distance from the final mix value of every <see cref="MixInfo"/>.
/// </summary>
private void UpdateDistancesFromFinalMix()
{
foreach (ref MixState mix in _mixes.Span)
foreach (ref MixInfo mix in _mixes.Span)
{
mix.ClearDistanceFromFinalMix();
}
for (int i = 0; i < GetCount(); i++)
{
ref MixState mix = ref GetState(i);
ref MixInfo mix = ref GetState(i);
SetSortedState(i, i);
@@ -149,13 +149,13 @@ namespace Ryujinx.Audio.Renderer.Server.Mix
{
if (mixId == Constants.UnusedMixId)
{
distance = MixState.InvalidDistanceFromFinalMix;
distance = MixInfo.InvalidDistanceFromFinalMix;
break;
}
ref MixState distanceMix = ref GetState(mixId);
ref MixInfo distanceMix = ref GetState(mixId);
if (distanceMix.DistanceFromFinalMix != MixState.InvalidDistanceFromFinalMix)
if (distanceMix.DistanceFromFinalMix != MixInfo.InvalidDistanceFromFinalMix)
{
distance = distanceMix.DistanceFromFinalMix + 1;
break;
@@ -171,12 +171,12 @@ namespace Ryujinx.Audio.Renderer.Server.Mix
if (distance > GetCount())
{
distance = MixState.InvalidDistanceFromFinalMix;
distance = MixInfo.InvalidDistanceFromFinalMix;
}
}
else
{
distance = MixState.InvalidDistanceFromFinalMix;
distance = MixInfo.InvalidDistanceFromFinalMix;
}
mix.DistanceFromFinalMix = distance;
@@ -185,13 +185,13 @@ namespace Ryujinx.Audio.Renderer.Server.Mix
}
/// <summary>
/// Update the internal mix buffer offset of all <see cref="MixState"/>.
/// Update the internal mix buffer offset of all <see cref="MixInfo"/>.
/// </summary>
private void UpdateMixBufferOffset()
{
uint offset = 0;
foreach (ref MixState mix in _mixes.Span)
foreach (ref MixInfo mix in _mixes.Span)
{
mix.BufferOffset = offset;
@@ -210,10 +210,10 @@ namespace Ryujinx.Audio.Renderer.Server.Mix
Array.Sort(sortedMixesTemp, (a, b) =>
{
ref MixState stateA = ref GetState(a);
ref MixState stateB = ref GetState(b);
ref MixInfo infoA = ref GetState(a);
ref MixInfo infoB = ref GetState(b);
return stateB.DistanceFromFinalMix.CompareTo(stateA.DistanceFromFinalMix);
return infoB.DistanceFromFinalMix.CompareTo(infoA.DistanceFromFinalMix);
});
sortedMixesTemp.AsSpan().CopyTo(_sortedMixes.Span);

View File

@@ -15,7 +15,7 @@ namespace Ryujinx.Audio.Renderer.Server.Mix
/// Server state for a mix.
/// </summary>
[StructLayout(LayoutKind.Sequential, Size = 0x940, Pack = Alignment)]
public struct MixState
public struct MixInfo
{
public const uint InvalidDistanceFromFinalMix = 0x80000000;
@@ -136,11 +136,11 @@ namespace Ryujinx.Audio.Renderer.Server.Mix
}
/// <summary>
/// Create a new <see cref="MixState"/>
/// Create a new <see cref="MixInfo"/>
/// </summary>
/// <param name="effectProcessingOrderArray"></param>
/// <param name="behaviourContext"></param>
public MixState(Memory<int> effectProcessingOrderArray, ref BehaviourContext behaviourContext) : this()
/// <param name="behaviourInfo"></param>
public MixInfo(Memory<int> effectProcessingOrderArray, ref BehaviourInfo behaviourInfo) : this()
{
MixId = UnusedMixId;
@@ -158,7 +158,7 @@ namespace Ryujinx.Audio.Renderer.Server.Mix
EffectProcessingOrderArrayMaxCount = (uint)effectProcessingOrderArray.Length;
IsLongSizePreDelaySupported = behaviourContext.IsLongSizePreDelaySupported();
IsLongSizePreDelaySupported = behaviourInfo.IsLongSizePreDelaySupported();
ClearEffectProcessingOrder();
}
@@ -257,9 +257,9 @@ namespace Ryujinx.Audio.Renderer.Server.Mix
/// <param name="parameter">The input parameter of the mix.</param>
/// <param name="effectContext">The effect context.</param>
/// <param name="splitterContext">The splitter context.</param>
/// <param name="behaviourContext">The behaviour context.</param>
/// <param name="behaviourInfo">The behaviour context.</param>
/// <returns>Return true if the mix was changed.</returns>
public bool Update(EdgeMatrix edgeMatrix, in MixParameter parameter, EffectContext effectContext, SplitterContext splitterContext, BehaviourContext behaviourContext)
public bool Update(EdgeMatrix edgeMatrix, in MixParameter parameter, EffectContext effectContext, SplitterContext splitterContext, BehaviourInfo behaviourInfo)
{
bool isDirty;
@@ -271,7 +271,7 @@ namespace Ryujinx.Audio.Renderer.Server.Mix
NodeId = parameter.NodeId;
parameter.MixBufferVolume.CopyTo(MixBufferVolume);
if (behaviourContext.IsSplitterSupported())
if (behaviourInfo.IsSplitterSupported())
{
isDirty = UpdateConnection(edgeMatrix, in parameter, ref splitterContext);
}
@@ -279,10 +279,7 @@ namespace Ryujinx.Audio.Renderer.Server.Mix
{
isDirty = DestinationMixId != parameter.DestinationMixId;
if (DestinationMixId != parameter.DestinationMixId)
{
DestinationMixId = parameter.DestinationMixId;
}
DestinationMixId = parameter.DestinationMixId;
DestinationSplitterId = UnusedSplitterId;
}

View File

@@ -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()
{
}
}
}

View File

@@ -10,11 +10,11 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
/// Get the required size for a single performance frame.
/// </summary>
/// <param name="parameter">The audio renderer configuration.</param>
/// <param name="behaviourContext">The behaviour context.</param>
/// <param name="behaviourInfo">The behaviour context.</param>
/// <returns>The required size for a single performance frame.</returns>
public static ulong GetRequiredBufferSizeForPerformanceMetricsPerFrame(ref AudioRendererConfiguration parameter, ref BehaviourContext behaviourContext)
public static ulong GetRequiredBufferSizeForPerformanceMetricsPerFrame(ref AudioRendererConfiguration parameter, ref BehaviourInfo behaviourInfo)
{
uint version = behaviourContext.GetPerformanceMetricsDataFormat();
uint version = behaviourInfo.GetPerformanceMetricsDataFormat();
if (version == 2)
{
@@ -81,11 +81,11 @@ namespace Ryujinx.Audio.Renderer.Server.Performance
/// </summary>
/// <param name="performanceBuffer">The backing memory available for use by the manager.</param>
/// <param name="parameter">The audio renderer configuration.</param>
/// <param name="behaviourContext">The behaviour context;</param>
/// <param name="behaviourInfo">The behaviour context;</param>
/// <returns>A new <see cref="PerformanceManager"/>.</returns>
public static PerformanceManager Create(Memory<byte> performanceBuffer, ref AudioRendererConfiguration parameter, BehaviourContext behaviourContext)
public static PerformanceManager Create(Memory<byte> performanceBuffer, ref AudioRendererConfiguration parameter, BehaviourInfo behaviourInfo)
{
uint version = behaviourContext.GetPerformanceMetricsDataFormat();
uint version = behaviourInfo.GetPerformanceMetricsDataFormat();
return version switch
{

View File

@@ -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);

View File

@@ -1,3 +1,4 @@
using Ryujinx.Audio.Renderer.Server.Mix;
using Ryujinx.Audio.Renderer.Server.Upsampler;
using System;
@@ -19,7 +20,7 @@ namespace Ryujinx.Audio.Renderer.Server
/// <summary>
/// The target channel count for sink.
/// </summary>
/// <remarks>See <see cref="CommandGenerator.GenerateDevice(Sink.DeviceSink, ref Mix.MixState)"/> for usage.</remarks>
/// <remarks>See <see cref="CommandGenerator.GenerateDevice(Sink.DeviceSink, ref MixInfo)"/> for usage.</remarks>
public uint ChannelCount;
/// <summary>
@@ -28,12 +29,12 @@ namespace Ryujinx.Audio.Renderer.Server
public uint MixBufferCount;
/// <summary>
/// Instance of the <see cref="BehaviourContext"/> used to derive bug fixes and features of the current audio renderer revision.
/// Instance of the <see cref="BehaviourInfo"/> used to derive bug fixes and features of the current audio renderer revision.
/// </summary>
public BehaviourContext BehaviourContext;
public BehaviourInfo BehaviourInfo;
/// <summary>
/// Instance of the <see cref="UpsamplerManager"/> used for upsampling (see <see cref="UpsamplerState"/>)
/// Instance of the <see cref="UpsamplerManager"/> used for upsampling (see <see cref="UpsamplerInfo"/>)
/// </summary>
public UpsamplerManager UpsamplerManager;

View File

@@ -28,7 +28,7 @@ namespace Ryujinx.Audio.Renderer.Server.Sink
/// The upsampler instance used by this sink.
/// </summary>
/// <remarks>Null if no upsampling is needed.</remarks>
public UpsamplerState UpsamplerState;
public UpsamplerInfo UpsamplerInfo;
/// <summary>
/// Create a new <see cref="DeviceSink"/>.
@@ -40,9 +40,9 @@ namespace Ryujinx.Audio.Renderer.Server.Sink
public override void CleanUp()
{
UpsamplerState?.Release();
UpsamplerInfo?.Release();
UpsamplerState = null;
UpsamplerInfo = null;
base.CleanUp();
}

View File

@@ -55,22 +55,27 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
/// If set to true, the previous mix volume is explicitly resetted using the input parameter, instead of implicitly on first use.
/// </summary>
public bool IsSplitterPrevVolumeResetSupported { get; private set; }
/// <summary>
/// If set to true, the previous mix volume is explicitly resetted using the input parameter, instead of implicitly on first use.
/// </summary>
public bool IsBiquadFilterParameterFloatSupported { get; private set; }
/// <summary>
/// Initialize <see cref="SplitterContext"/>.
/// </summary>
/// <param name="behaviourContext">The behaviour context.</param>
/// <param name="behaviourInfo">The behaviour context.</param>
/// <param name="parameter">The audio renderer configuration.</param>
/// <param name="workBufferAllocator">The <see cref="WorkBufferAllocator"/>.</param>
/// <param name="splitterBqfStates">Memory to store the biquad filtering state for splitters during processing.</param>
/// <returns>Return true if the initialization was successful.</returns>
public bool Initialize(
ref BehaviourContext behaviourContext,
ref BehaviourInfo behaviourInfo,
ref AudioRendererConfiguration parameter,
WorkBufferAllocator workBufferAllocator,
Memory<BiquadFilterState> splitterBqfStates)
{
if (!behaviourContext.IsSplitterSupported() || parameter.SplitterCount <= 0 || parameter.SplitterDestinationCount <= 0)
if (!behaviourInfo.IsSplitterSupported() || parameter.SplitterCount <= 0 || parameter.SplitterDestinationCount <= 0)
{
Setup(Memory<SplitterState>.Empty, Memory<SplitterDestinationVersion1>.Empty, Memory<SplitterDestinationVersion2>.Empty, false);
@@ -94,7 +99,7 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
Memory<SplitterDestinationVersion1> splitterDestinationsV1 = Memory<SplitterDestinationVersion1>.Empty;
Memory<SplitterDestinationVersion2> splitterDestinationsV2 = Memory<SplitterDestinationVersion2>.Empty;
if (!behaviourContext.IsBiquadFilterParameterForSplitterEnabled())
if (!behaviourInfo.IsBiquadFilterParameterForSplitterEnabled())
{
Version = 1;
@@ -144,11 +149,12 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
}
}
IsSplitterPrevVolumeResetSupported = behaviourContext.IsSplitterPrevVolumeResetSupported();
IsSplitterPrevVolumeResetSupported = behaviourInfo.IsSplitterPrevVolumeResetSupported();
IsBiquadFilterParameterFloatSupported = behaviourInfo.IsBiquadFilterParameterFloatSupported();
SplitterState.InitializeSplitters(splitters.Span);
Setup(splitters, splitterDestinationsV1, splitterDestinationsV2, behaviourContext.IsSplitterBugFixed());
Setup(splitters, splitterDestinationsV1, splitterDestinationsV2, behaviourInfo.IsSplitterBugFixed());
return true;
}
@@ -157,16 +163,16 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
/// Get the work buffer size while adding the size needed for splitter to operate.
/// </summary>
/// <param name="size">The current size.</param>
/// <param name="behaviourContext">The behaviour context.</param>
/// <param name="behaviourInfo">The behaviour context.</param>
/// <param name="parameter">The renderer configuration.</param>
/// <returns>Return the new size taking splitter into account.</returns>
public static ulong GetWorkBufferSize(ulong size, ref BehaviourContext behaviourContext, ref AudioRendererConfiguration parameter)
public static ulong GetWorkBufferSize(ulong size, ref BehaviourInfo behaviourInfo, ref AudioRendererConfiguration parameter)
{
if (behaviourContext.IsSplitterSupported())
if (behaviourInfo.IsSplitterSupported())
{
size = WorkBufferAllocator.GetTargetSize<SplitterState>(size, parameter.SplitterCount, SplitterState.Alignment);
if (behaviourContext.IsBiquadFilterParameterForSplitterEnabled())
if (behaviourInfo.IsBiquadFilterParameterForSplitterEnabled())
{
size = WorkBufferAllocator.GetTargetSize<SplitterDestinationVersion2>(size, parameter.SplitterDestinationCount, SplitterDestinationVersion2.Alignment);
}
@@ -175,12 +181,10 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
size = WorkBufferAllocator.GetTargetSize<SplitterDestinationVersion1>(size, parameter.SplitterDestinationCount, SplitterDestinationVersion1.Alignment);
}
if (behaviourContext.IsSplitterBugFixed())
if (behaviourInfo.IsSplitterBugFixed())
{
size = WorkBufferAllocator.GetTargetSize<int>(size, parameter.SplitterDestinationCount, 0x10);
}
return size;
}
return size;
@@ -227,7 +231,16 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
return 0;
}
int length = _splitterDestinationsV2.IsEmpty ? _splitterDestinationsV1.Length : _splitterDestinationsV2.Length;
int length;
if (_splitterDestinationsV2.IsEmpty)
{
length = _splitterDestinationsV1.Length;
}
else
{
length = _splitterDestinationsV2.Length;
}
return length / _splitters.Length;
}
@@ -278,8 +291,17 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
if (parameter.IsMagicValid())
{
int length = _splitterDestinationsV2.IsEmpty ? _splitterDestinationsV1.Length : _splitterDestinationsV2.Length;
int length;
if (_splitterDestinationsV2.IsEmpty)
{
length = _splitterDestinationsV1.Length;
}
else
{
length = _splitterDestinationsV2.Length;
}
if (parameter.Id >= 0 && parameter.Id < length)
{
SplitterDestination destination = GetDestination(parameter.Id);
@@ -315,9 +337,19 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
}
else if (Version == 2)
{
if (!UpdateData<SplitterDestinationInParameterVersion2>(ref input))
if (IsBiquadFilterParameterFloatSupported)
{
break;
if (!UpdateData<SplitterDestinationInParameterVersion2b>(ref input))
{
break;
}
}
else
{
if (!UpdateData<SplitterDestinationInParameterVersion2a>(ref input))
{
break;
}
}
}
else
@@ -381,10 +413,8 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
{
return new SplitterDestination(ref SpanIOHelper.GetFromMemory(_splitterDestinationsV1, id, (uint)_splitterDestinationsV1.Length));
}
else
{
return new SplitterDestination(ref SpanIOHelper.GetFromMemory(_splitterDestinationsV2, id, (uint)_splitterDestinationsV2.Length));
}
return new SplitterDestination(ref SpanIOHelper.GetFromMemory(_splitterDestinationsV2, id, (uint)_splitterDestinationsV2.Length));
}
/// <summary>

View File

@@ -31,15 +31,11 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
{
return 0;
}
else
{
return _v1.Id;
}
}
else
{
return _v2.Id;
return _v1.Id;
}
return _v2.Id;
}
}
@@ -56,15 +52,11 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
{
return 0;
}
else
{
return _v1.DestinationId;
}
}
else
{
return _v2.DestinationId;
return _v1.DestinationId;
}
return _v2.DestinationId;
}
}
@@ -82,15 +74,11 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
{
return Span<float>.Empty;
}
else
{
return _v1.MixBufferVolume;
}
}
else
{
return _v2.MixBufferVolume;
return _v1.MixBufferVolume;
}
return _v2.MixBufferVolume;
}
}
@@ -108,15 +96,11 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
{
return Span<float>.Empty;
}
else
{
return _v1.PreviousMixBufferVolume;
}
}
else
{
return _v2.PreviousMixBufferVolume;
return _v1.PreviousMixBufferVolume;
}
return _v2.PreviousMixBufferVolume;
}
}
@@ -135,15 +119,11 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
{
return new SplitterDestination();
}
else
{
return new SplitterDestination(ref _v1.Next);
}
}
else
{
return new SplitterDestination(ref _v2.Next);
return new SplitterDestination(ref _v1.Next);
}
return new SplitterDestination(ref _v2.Next);
}
}
}
@@ -169,6 +149,7 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
_v2 = ref v2;
}
/// <summary>
/// Creates a new splitter destination wrapper for the splitter destination data.
/// </summary>
@@ -233,7 +214,12 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
/// <returns>True if the splitter destination is used and has a destination.</returns>
public readonly bool IsConfigured()
{
return Unsafe.IsNullRef(ref _v2) ? _v1.IsConfigured() : _v2.IsConfigured();
if (Unsafe.IsNullRef(ref _v2))
{
return _v1.IsConfigured();
}
return _v2.IsConfigured();
}
/// <summary>
@@ -243,7 +229,12 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
/// <returns>The volume for the given destination.</returns>
public float GetMixVolume(int destinationIndex)
{
return Unsafe.IsNullRef(ref _v2) ? _v1.GetMixVolume(destinationIndex) : _v2.GetMixVolume(destinationIndex);
if (Unsafe.IsNullRef(ref _v2))
{
return _v1.GetMixVolume(destinationIndex);
}
return _v2.GetMixVolume(destinationIndex);
}
/// <summary>
@@ -253,7 +244,12 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
/// <returns>The volume for the given destination.</returns>
public float GetMixVolumePrev(int destinationIndex)
{
return Unsafe.IsNullRef(ref _v2) ? _v1.GetMixVolumePrev(destinationIndex) : _v2.GetMixVolumePrev(destinationIndex);
if (Unsafe.IsNullRef(ref _v2))
{
return _v1.GetMixVolumePrev(destinationIndex);
}
return _v2.GetMixVolumePrev(destinationIndex);
}
/// <summary>
@@ -280,13 +276,13 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
if (Unsafe.IsNullRef(ref _v2))
{
Debug.Assert(!Unsafe.IsNullRef(ref next._v1));
_v1.Link(ref next._v1);
}
else
{
Debug.Assert(!Unsafe.IsNullRef(ref next._v2));
_v2.Link(ref next._v2);
}
}
@@ -308,6 +304,7 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
/// <summary>
/// Checks if any biquad filter is enabled.
/// Virtual function at function table + 0x8.
/// </summary>
/// <returns>True if any biquad filter is enabled.</returns>
public bool IsBiquadFilterEnabled()
@@ -326,13 +323,14 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
/// <summary>
/// Gets the biquad filter parameters.
/// /// Virtual function at function table + 0x10.
/// </summary>
/// <param name="index">Biquad filter index (0 or 1).</param>
/// <returns>Biquad filter parameters.</returns>
public ref BiquadFilterParameter GetBiquadFilterParameter(int index)
public ref BiquadFilterParameter2 GetBiquadFilterParameter(int index)
{
Debug.Assert(!Unsafe.IsNullRef(ref _v2));
return ref _v2.GetBiquadFilterParameter(index);
}

View File

@@ -11,7 +11,7 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
/// <summary>
/// Server state for a splitter destination (version 2).
/// </summary>
[StructLayout(LayoutKind.Sequential, Size = 0x110, Pack = Alignment)]
[StructLayout(LayoutKind.Sequential, Size = 0x128, Pack = Alignment)]
public struct SplitterDestinationVersion2
{
public const int Alignment = 0x10;
@@ -78,7 +78,7 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
}
}
private Array2<BiquadFilterParameter> _biquadFilters;
private Array2<BiquadFilterParameter2> _biquadFilters;
private Array2<bool> _isPreviousBiquadFilterEnabled;
@@ -109,7 +109,7 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
parameter.MixBufferVolume.CopyTo(MixBufferVolume);
_biquadFilters = parameter.BiquadFilters;
_biquadFilters = parameter.BiquadFilters2;
bool resetPrevVolume = isPrevVolumeResetSupported ? parameter.ResetPrevVolume : !IsUsed && parameter.IsUsed;
if (resetPrevVolume)
@@ -218,7 +218,7 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
/// <returns>True if any biquad filter is enabled.</returns>
public bool IsBiquadFilterEnabled()
{
Span<BiquadFilterParameter> biquadFiltersSpan = _biquadFilters.AsSpan();
Span<BiquadFilterParameter2> biquadFiltersSpan = _biquadFilters.AsSpan();
return biquadFiltersSpan[0].Enable || biquadFiltersSpan[1].Enable;
}
@@ -236,7 +236,7 @@ namespace Ryujinx.Audio.Renderer.Server.Splitter
/// </summary>
/// <param name="index">Biquad filter index (0 or 1).</param>
/// <returns>Biquad filter parameters.</returns>
public ref BiquadFilterParameter GetBiquadFilterParameter(int index)
public ref BiquadFilterParameter2 GetBiquadFilterParameter(int index)
{
return ref _biquadFilters[index];
}

View File

@@ -27,39 +27,39 @@ namespace Ryujinx.Audio.Renderer.Server
private Memory<byte> _output;
private readonly uint _processHandle;
private BehaviourContext _behaviourContext;
private BehaviourInfo _behaviourInfo;
private readonly ref readonly UpdateDataHeader _inputHeader;
private readonly Memory<UpdateDataHeader> _outputHeader;
private readonly ref UpdateDataHeader OutputHeader => ref _outputHeader.Span[0];
public StateUpdater(ReadOnlySequence<byte> input, Memory<byte> output, uint processHandle, BehaviourContext behaviourContext)
public StateUpdater(ReadOnlySequence<byte> input, Memory<byte> output, uint processHandle, BehaviourInfo behaviourInfo)
{
_inputReader = new SequenceReader<byte>(input);
_output = output;
_outputOrigin = _output;
_processHandle = processHandle;
_behaviourContext = behaviourContext;
_behaviourInfo = behaviourInfo;
_inputHeader = ref _inputReader.GetRefOrRefToCopy<UpdateDataHeader>(out _);
_outputHeader = SpanMemoryManager<UpdateDataHeader>.Cast(_output[..Unsafe.SizeOf<UpdateDataHeader>()]);
OutputHeader.Initialize(_behaviourContext.UserRevision);
OutputHeader.Initialize(_behaviourInfo.UserRevision);
_output = _output[Unsafe.SizeOf<UpdateDataHeader>()..];
}
public ResultCode UpdateBehaviourContext()
public ResultCode UpdateBehaviourInfo()
{
ref readonly BehaviourParameter parameter = ref _inputReader.GetRefOrRefToCopy<BehaviourParameter>(out _);
if (!BehaviourContext.CheckValidRevision(parameter.UserRevision) || parameter.UserRevision != _behaviourContext.UserRevision)
if (!BehaviourInfo.CheckValidRevision(parameter.UserRevision) || parameter.UserRevision != _behaviourInfo.UserRevision)
{
return ResultCode.InvalidUpdateInfo;
}
_behaviourContext.ClearError();
_behaviourContext.UpdateFlags(parameter.Flags);
_behaviourInfo.ClearError();
_behaviourInfo.UpdateFlags(parameter.Flags);
if (_inputHeader.BehaviourSize != Unsafe.SizeOf<BehaviourParameter>())
{
@@ -69,16 +69,16 @@ namespace Ryujinx.Audio.Renderer.Server
return ResultCode.Success;
}
public ResultCode UpdateMemoryPools(Span<MemoryPoolState> memoryPools)
public ResultCode UpdateMemoryPools(Span<MemoryPoolInfo> memoryPools)
{
PoolMapper mapper = new(_processHandle, _behaviourContext.IsMemoryPoolForceMappingEnabled());
PoolMapper mapper = new(_processHandle, _behaviourInfo.IsMemoryPoolForceMappingEnabled());
if (memoryPools.Length * Unsafe.SizeOf<MemoryPoolInParameter>() != _inputHeader.MemoryPoolsSize)
{
return ResultCode.InvalidUpdateInfo;
}
foreach (ref MemoryPoolState memoryPool in memoryPools)
foreach (ref MemoryPoolInfo memoryPool in memoryPools)
{
ref readonly MemoryPoolInParameter parameter = ref _inputReader.GetRefOrRefToCopy<MemoryPoolInParameter>(out _);
@@ -125,10 +125,10 @@ namespace Ryujinx.Audio.Renderer.Server
return ResultCode.Success;
}
public ResultCode UpdateVoices(VoiceContext context, PoolMapper mapper)
public ResultCode UpdateVoices2(VoiceContext context, PoolMapper mapper)
{
if (context.GetCount() * Unsafe.SizeOf<VoiceInParameter>() != _inputHeader.VoicesSize)
if (context.GetCount() * Unsafe.SizeOf<VoiceInParameter2>() != _inputHeader.VoicesSize)
{
return ResultCode.InvalidUpdateInfo;
}
@@ -140,27 +140,27 @@ namespace Ryujinx.Audio.Renderer.Server
// First make everything not in use.
for (int i = 0; i < context.GetCount(); i++)
{
ref VoiceState state = ref context.GetState(i);
ref VoiceInfo info = ref context.GetState(i);
state.InUse = false;
info.InUse = false;
}
Memory<VoiceUpdateState>[] voiceUpdateStatesArray = ArrayPool<Memory<VoiceUpdateState>>.Shared.Rent(Constants.VoiceChannelCountMax);
Memory<VoiceState>[] voiceStatesArray = ArrayPool<Memory<VoiceState>>.Shared.Rent(Constants.VoiceChannelCountMax);
Span<Memory<VoiceUpdateState>> voiceUpdateStates = voiceUpdateStatesArray.AsSpan(0, Constants.VoiceChannelCountMax);
Span<Memory<VoiceState>> voiceStates = voiceStatesArray.AsSpan(0, Constants.VoiceChannelCountMax);
// Start processing
for (int i = 0; i < context.GetCount(); i++)
{
ref readonly VoiceInParameter parameter = ref _inputReader.GetRefOrRefToCopy<VoiceInParameter>(out _);
ref readonly VoiceInParameter2 parameter = ref _inputReader.GetRefOrRefToCopy<VoiceInParameter2>(out _);
voiceUpdateStates.Fill(Memory<VoiceUpdateState>.Empty);
voiceStates.Fill(Memory<VoiceState>.Empty);
ref VoiceOutStatus outStatus = ref SpanIOHelper.GetWriteRef<VoiceOutStatus>(ref _output)[0];
if (parameter.InUse)
{
ref VoiceState currentVoiceState = ref context.GetState(i);
ref VoiceInfo currentVoiceInfo = ref context.GetState(i);
Span<int> channelResourceIdsSpan = parameter.ChannelResourceIds.AsSpan();
@@ -170,36 +170,36 @@ namespace Ryujinx.Audio.Renderer.Server
Debug.Assert(channelId >= 0 && channelId < context.GetCount());
voiceUpdateStates[channelResourceIndex] = context.GetUpdateStateForCpu(channelId);
voiceStates[channelResourceIndex] = context.GetUpdateStateForCpu(channelId);
}
if (parameter.IsNew)
{
currentVoiceState.Initialize();
currentVoiceInfo.Initialize();
}
currentVoiceState.UpdateParameters(out ErrorInfo updateParameterError, in parameter, mapper, ref _behaviourContext);
currentVoiceInfo.UpdateParameters2(out ErrorInfo updateParameterError, in parameter, mapper, ref _behaviourInfo);
if (updateParameterError.ErrorCode != ResultCode.Success)
{
_behaviourContext.AppendError(ref updateParameterError);
_behaviourInfo.AppendError(ref updateParameterError);
}
currentVoiceState.UpdateWaveBuffers(out ErrorInfo[] waveBufferUpdateErrorInfos, in parameter, voiceUpdateStates, mapper, ref _behaviourContext);
currentVoiceInfo.UpdateWaveBuffers2(out ErrorInfo[] waveBufferUpdateErrorInfos, in parameter, voiceStates, mapper, ref _behaviourInfo);
foreach (ref ErrorInfo errorInfo in waveBufferUpdateErrorInfos.AsSpan())
{
if (errorInfo.ErrorCode != ResultCode.Success)
{
_behaviourContext.AppendError(ref errorInfo);
_behaviourInfo.AppendError(ref errorInfo);
}
}
currentVoiceState.WriteOutStatus(ref outStatus, in parameter, voiceUpdateStates);
currentVoiceInfo.WriteOutStatus2(ref outStatus, in parameter, voiceStates);
}
}
ArrayPool<Memory<VoiceUpdateState>>.Shared.Return(voiceUpdateStatesArray);
ArrayPool<Memory<VoiceState>>.Shared.Return(voiceStatesArray);
int currentOutputSize = _output.Length;
@@ -213,7 +213,94 @@ 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
public ResultCode UpdateVoices1(VoiceContext context, PoolMapper mapper)
{
if (context.GetCount() * Unsafe.SizeOf<VoiceInParameter1>() != _inputHeader.VoicesSize)
{
return ResultCode.InvalidUpdateInfo;
}
int initialOutputSize = _output.Length;
long initialInputConsumed = _inputReader.Consumed;
// First make everything not in use.
for (int i = 0; i < context.GetCount(); i++)
{
ref VoiceInfo info = ref context.GetState(i);
info.InUse = false;
}
Memory<VoiceState>[] voiceStatesArray = ArrayPool<Memory<VoiceState>>.Shared.Rent(Constants.VoiceChannelCountMax);
Span<Memory<VoiceState>> voiceStates = voiceStatesArray.AsSpan(0, Constants.VoiceChannelCountMax);
// Start processing
for (int i = 0; i < context.GetCount(); i++)
{
ref readonly VoiceInParameter1 parameter = ref _inputReader.GetRefOrRefToCopy<VoiceInParameter1>(out _);
voiceStates.Fill(Memory<VoiceState>.Empty);
ref VoiceOutStatus outStatus = ref SpanIOHelper.GetWriteRef<VoiceOutStatus>(ref _output)[0];
if (parameter.InUse)
{
ref VoiceInfo currentVoiceInfo = ref context.GetState(i);
Span<int> channelResourceIdsSpan = parameter.ChannelResourceIds.AsSpan();
for (int channelResourceIndex = 0; channelResourceIndex < parameter.ChannelCount; channelResourceIndex++)
{
int channelId = channelResourceIdsSpan[channelResourceIndex];
Debug.Assert(channelId >= 0 && channelId < context.GetCount());
voiceStates[channelResourceIndex] = context.GetUpdateStateForCpu(channelId);
}
if (parameter.IsNew)
{
currentVoiceInfo.Initialize();
}
currentVoiceInfo.UpdateParameters1(out ErrorInfo updateParameterError, in parameter, mapper, ref _behaviourInfo);
if (updateParameterError.ErrorCode != ResultCode.Success)
{
_behaviourInfo.AppendError(ref updateParameterError);
}
currentVoiceInfo.UpdateWaveBuffers1(out ErrorInfo[] waveBufferUpdateErrorInfos, in parameter, voiceStates, mapper, ref _behaviourInfo);
foreach (ref ErrorInfo errorInfo in waveBufferUpdateErrorInfos.AsSpan())
{
if (errorInfo.ErrorCode != ResultCode.Success)
{
_behaviourInfo.AppendError(ref errorInfo);
}
}
currentVoiceInfo.WriteOutStatus1(ref outStatus, in parameter, voiceStates);
}
}
ArrayPool<Memory<VoiceState>>.Shared.Return(voiceStatesArray);
int currentOutputSize = _output.Length;
OutputHeader.VoicesSize = (uint)(Unsafe.SizeOf<VoiceOutStatus>() * context.GetCount());
OutputHeader.TotalSize += OutputHeader.VoicesSize;
Debug.Assert((initialOutputSize - currentOutputSize) == OutputHeader.VoicesSize);
_inputReader.SetConsumed(initialInputConsumed + _inputHeader.VoicesSize);
return ResultCode.Success;
}
private void ResetEffect<T>(ref BaseEffect effect, in T parameter, PoolMapper mapper) where T : unmanaged, IEffectInParameter
{
effect.ForceUnmapBuffers(mapper);
@@ -225,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(),
@@ -235,14 +323,14 @@ namespace Ryujinx.Audio.Renderer.Server
public ResultCode UpdateEffects(EffectContext context, bool isAudioRendererActive, PoolMapper mapper)
{
if (_behaviourContext.IsEffectInfoVersion2Supported())
if (_behaviourInfo.IsEffectInfoVersion2Supported())
{
return UpdateEffectsVersion2(context, isAudioRendererActive, mapper);
}
return UpdateEffectsVersion1(context, isAudioRendererActive, mapper);
}
public ResultCode UpdateEffectsVersion2(EffectContext context, bool isAudioRendererActive, PoolMapper mapper)
{
if (context.GetCount() * Unsafe.SizeOf<EffectInParameterVersion2>() != _inputHeader.EffectsSize)
@@ -271,7 +359,7 @@ namespace Ryujinx.Audio.Renderer.Server
if (updateErrorInfo.ErrorCode != ResultCode.Success)
{
_behaviourContext.AppendError(ref updateErrorInfo);
_behaviourInfo.AppendError(ref updateErrorInfo);
}
effect.StoreStatus(ref outStatus, isAudioRendererActive);
@@ -325,7 +413,7 @@ namespace Ryujinx.Audio.Renderer.Server
if (updateErrorInfo.ErrorCode != ResultCode.Success)
{
_behaviourContext.AppendError(ref updateErrorInfo);
_behaviourInfo.AppendError(ref updateErrorInfo);
}
effect.StoreStatus(ref outStatus, isAudioRendererActive);
@@ -384,7 +472,7 @@ namespace Ryujinx.Audio.Renderer.Server
uint inputMixSize;
uint inputSize = 0;
if (_behaviourContext.IsMixInParameterDirtyOnlyUpdateSupported())
if (_behaviourInfo.IsMixInParameterDirtyOnlyUpdateSupported())
{
ref readonly MixInParameterDirtyOnlyUpdate parameter = ref _inputReader.GetRefOrRefToCopy<MixInParameterDirtyOnlyUpdate>(out _);
@@ -423,12 +511,12 @@ namespace Ryujinx.Audio.Renderer.Server
int mixId = i;
if (_behaviourContext.IsMixInParameterDirtyOnlyUpdateSupported())
if (_behaviourInfo.IsMixInParameterDirtyOnlyUpdateSupported())
{
mixId = parameter.MixId;
}
ref MixState mix = ref mixContext.GetState(mixId);
ref MixInfo mix = ref mixContext.GetState(mixId);
if (parameter.IsUsed != mix.IsUsed)
{
@@ -444,13 +532,13 @@ namespace Ryujinx.Audio.Renderer.Server
if (mix.IsUsed)
{
isMixContextDirty |= mix.Update(mixContext.EdgeMatrix, in parameter, effectContext, splitterContext, _behaviourContext);
isMixContextDirty |= mix.Update(mixContext.EdgeMatrix, in parameter, effectContext, splitterContext, _behaviourInfo);
}
}
if (isMixContextDirty)
{
if (_behaviourContext.IsSplitterSupported() && splitterContext.UsingSplitter())
if (_behaviourInfo.IsSplitterSupported() && splitterContext.UsingSplitter())
{
if (!mixContext.Sort(splitterContext))
{
@@ -507,7 +595,7 @@ namespace Ryujinx.Audio.Renderer.Server
if (updateErrorInfo.ErrorCode != ResultCode.Success)
{
_behaviourContext.AppendError(ref updateErrorInfo);
_behaviourInfo.AppendError(ref updateErrorInfo);
}
}
@@ -555,7 +643,7 @@ namespace Ryujinx.Audio.Renderer.Server
{
ref BehaviourErrorInfoOutStatus outStatus = ref SpanIOHelper.GetWriteRef<BehaviourErrorInfoOutStatus>(ref _output)[0];
_behaviourContext.CopyErrorInfo(outStatus.ErrorInfos.AsSpan(), out outStatus.ErrorInfosCount);
_behaviourInfo.CopyErrorInfo(outStatus.ErrorInfos.AsSpan(), out outStatus.ErrorInfosCount);
OutputHeader.BehaviourSize = (uint)Unsafe.SizeOf<BehaviourErrorInfoOutStatus>();
OutputHeader.TotalSize += OutputHeader.BehaviourSize;

View File

@@ -1,7 +1,9 @@
using Ryujinx.Audio.Renderer.Server.Voice;
namespace Ryujinx.Audio.Renderer.Server.Types
{
/// <summary>
/// The internal play state of a <see cref="Voice.VoiceState"/>
/// The internal play state of a <see cref="VoiceInfo"/>
/// </summary>
public enum PlayState
{
@@ -24,7 +26,7 @@ namespace Ryujinx.Audio.Renderer.Server.Types
/// </summary>
/// <remarks>
/// This is changed to the <see cref="Stopped"/> state after command generation.
/// <seealso cref="Voice.VoiceState.UpdateForCommandGeneration(Voice.VoiceContext)"/>
/// <seealso cref="VoiceInfo.UpdateForCommandGeneration(Voice.VoiceContext)"/>
/// </remarks>
Stopping,

View File

@@ -5,7 +5,7 @@ namespace Ryujinx.Audio.Renderer.Server.Upsampler
/// <summary>
/// Server state for a upsampling.
/// </summary>
public class UpsamplerState
public class UpsamplerInfo
{
/// <summary>
/// The output buffer containing the target samples.
@@ -18,7 +18,7 @@ namespace Ryujinx.Audio.Renderer.Server.Upsampler
public uint SampleCount { get; }
/// <summary>
/// The index of the <see cref="UpsamplerState"/>. (used to free it)
/// The index of the <see cref="UpsamplerInfo"/>. (used to free it)
/// </summary>
private readonly int _index;
@@ -43,13 +43,13 @@ namespace Ryujinx.Audio.Renderer.Server.Upsampler
public UpsamplerBufferState[] BufferStates;
/// <summary>
/// Create a new <see cref="UpsamplerState"/>.
/// Create a new <see cref="UpsamplerInfo"/>.
/// </summary>
/// <param name="manager">The upsampler manager.</param>
/// <param name="index">The index of the <see cref="UpsamplerState"/>. (used to free it)</param>
/// <param name="index">The index of the <see cref="UpsamplerInfo"/>. (used to free it)</param>
/// <param name="outputBuffer">The output buffer used to contain the target samples.</param>
/// <param name="sampleCount">The target sample count.</param>
public UpsamplerState(UpsamplerManager manager, int index, Memory<float> outputBuffer, uint sampleCount)
public UpsamplerInfo(UpsamplerManager manager, int index, Memory<float> outputBuffer, uint sampleCount)
{
_manager = manager;
_index = index;
@@ -58,7 +58,7 @@ namespace Ryujinx.Audio.Renderer.Server.Upsampler
}
/// <summary>
/// Release the <see cref="UpsamplerState"/>.
/// Release the <see cref="UpsamplerInfo"/>.
/// </summary>
public void Release()
{

View File

@@ -22,7 +22,7 @@ namespace Ryujinx.Audio.Renderer.Server.Upsampler
/// <summary>
/// The upsamplers instances.
/// </summary>
private readonly UpsamplerState[] _upsamplers;
private readonly UpsamplerInfo[] _upsamplers;
/// <summary>
/// The count of upsamplers.
@@ -39,14 +39,14 @@ namespace Ryujinx.Audio.Renderer.Server.Upsampler
_upSamplerWorkBuffer = upSamplerWorkBuffer;
_count = count;
_upsamplers = new UpsamplerState[_count];
_upsamplers = new UpsamplerInfo[_count];
}
/// <summary>
/// Allocate a new <see cref="UpsamplerState"/>.
/// Allocate a new <see cref="UpsamplerInfo"/>.
/// </summary>
/// <returns>A new <see cref="UpsamplerState"/> or null if out of memory.</returns>
public UpsamplerState Allocate()
/// <returns>A new <see cref="UpsamplerInfo"/> or null if out of memory.</returns>
public UpsamplerInfo Allocate()
{
int workBufferOffset = 0;
@@ -56,7 +56,7 @@ namespace Ryujinx.Audio.Renderer.Server.Upsampler
{
if (_upsamplers[i] == null)
{
_upsamplers[i] = new UpsamplerState(this, i, _upSamplerWorkBuffer.Slice(workBufferOffset, Constants.UpSampleEntrySize), Constants.TargetSampleCount);
_upsamplers[i] = new UpsamplerInfo(this, i, _upSamplerWorkBuffer.Slice(workBufferOffset, Constants.UpSampleEntrySize), Constants.TargetSampleCount);
return _upsamplers[i];
}
@@ -69,9 +69,9 @@ namespace Ryujinx.Audio.Renderer.Server.Upsampler
}
/// <summary>
/// Free a <see cref="UpsamplerState"/> at the given index.
/// Free a <see cref="UpsamplerInfo"/> at the given index.
/// </summary>
/// <param name="index">The index of the <see cref="UpsamplerState"/> to free.</param>
/// <param name="index">The index of the <see cref="UpsamplerInfo"/> to free.</param>
public void Free(int index)
{
lock (_lock)

View File

@@ -11,14 +11,14 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
public class VoiceContext
{
/// <summary>
/// Storage of the sorted indices to <see cref="VoiceState"/>.
/// Storage of the sorted indices to <see cref="VoiceInfo"/>.
/// </summary>
private Memory<int> _sortedVoices;
/// <summary>
/// Storage for <see cref="VoiceState"/>.
/// Storage for <see cref="VoiceInfo"/>.
/// </summary>
private Memory<VoiceState> _voices;
private Memory<VoiceInfo> _voices;
/// <summary>
/// Storage for <see cref="VoiceChannelResource"/>.
@@ -26,27 +26,27 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
private Memory<VoiceChannelResource> _voiceChannelResources;
/// <summary>
/// Storage for <see cref="VoiceUpdateState"/> that are used during audio renderer server updates.
/// Storage for <see cref="VoiceState"/> that are used during audio renderer server updates.
/// </summary>
private Memory<VoiceUpdateState> _voiceUpdateStatesCpu;
private Memory<VoiceState> _voiceStatesCpu;
/// <summary>
/// Storage for <see cref="VoiceUpdateState"/> for the <see cref="Dsp.AudioProcessor"/>.
/// Storage for <see cref="VoiceState"/> for the <see cref="Dsp.AudioProcessor"/>.
/// </summary>
private Memory<VoiceUpdateState> _voiceUpdateStatesDsp;
private Memory<VoiceState> _voiceStatesDsp;
/// <summary>
/// The total voice count.
/// </summary>
private uint _voiceCount;
public void Initialize(Memory<int> sortedVoices, Memory<VoiceState> voices, Memory<VoiceChannelResource> voiceChannelResources, Memory<VoiceUpdateState> voiceUpdateStatesCpu, Memory<VoiceUpdateState> voiceUpdateStatesDsp, uint voiceCount)
public void Initialize(Memory<int> sortedVoices, Memory<VoiceInfo> voices, Memory<VoiceChannelResource> voiceChannelResources, Memory<VoiceState> voiceStatesCpu, Memory<VoiceState> voiceStatesDsp, uint voiceCount)
{
_sortedVoices = sortedVoices;
_voices = voices;
_voiceChannelResources = voiceChannelResources;
_voiceUpdateStatesCpu = voiceUpdateStatesCpu;
_voiceUpdateStatesDsp = voiceUpdateStatesDsp;
_voiceStatesCpu = voiceStatesCpu;
_voiceStatesDsp = voiceStatesDsp;
_voiceCount = voiceCount;
}
@@ -70,38 +70,38 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
}
/// <summary>
/// Get a <see cref="Memory{VoiceUpdateState}"/> at the given <paramref name="id"/>.
/// Get a <see cref="Memory{VoiceState}"/> at the given <paramref name="id"/>.
/// </summary>
/// <param name="id">The index to use.</param>
/// <returns>A <see cref="Memory{VoiceUpdateState}"/> at the given <paramref name="id"/>.</returns>
/// <remarks>The returned <see cref="Memory{VoiceUpdateState}"/> should only be used when updating the server state.</remarks>
public Memory<VoiceUpdateState> GetUpdateStateForCpu(int id)
/// <returns>A <see cref="Memory{VoiceState}"/> at the given <paramref name="id"/>.</returns>
/// <remarks>The returned <see cref="Memory{VoiceState}"/> should only be used when updating the server state.</remarks>
public Memory<VoiceState> GetUpdateStateForCpu(int id)
{
return SpanIOHelper.GetMemory(_voiceUpdateStatesCpu, id, _voiceCount);
return SpanIOHelper.GetMemory(_voiceStatesCpu, id, _voiceCount);
}
/// <summary>
/// Get a <see cref="Memory{VoiceUpdateState}"/> at the given <paramref name="id"/>.
/// Get a <see cref="Memory{VoiceState}"/> at the given <paramref name="id"/>.
/// </summary>
/// <param name="id">The index to use.</param>
/// <returns>A <see cref="Memory{VoiceUpdateState}"/> at the given <paramref name="id"/>.</returns>
/// <remarks>The returned <see cref="Memory{VoiceUpdateState}"/> should only be used in the context of processing on the <see cref="Dsp.AudioProcessor"/>.</remarks>
public Memory<VoiceUpdateState> GetUpdateStateForDsp(int id)
/// <returns>A <see cref="Memory{VoiceState}"/> at the given <paramref name="id"/>.</returns>
/// <remarks>The returned <see cref="Memory{VoiceState}"/> should only be used in the context of processing on the <see cref="Dsp.AudioProcessor"/>.</remarks>
public Memory<VoiceState> GetUpdateStateForDsp(int id)
{
return SpanIOHelper.GetMemory(_voiceUpdateStatesDsp, id, _voiceCount);
return SpanIOHelper.GetMemory(_voiceStatesDsp, id, _voiceCount);
}
/// <summary>
/// Get a reference to a <see cref="VoiceState"/> at the given <paramref name="id"/>.
/// Get a reference to a <see cref="VoiceInfo"/> at the given <paramref name="id"/>.
/// </summary>
/// <param name="id">The index to use.</param>
/// <returns>A reference to a <see cref="VoiceState"/> at the given <paramref name="id"/>.</returns>
public ref VoiceState GetState(int id)
/// <returns>A reference to a <see cref="VoiceInfo"/> at the given <paramref name="id"/>.</returns>
public ref VoiceInfo GetState(int id)
{
return ref SpanIOHelper.GetFromMemory(_voices, id, _voiceCount);
}
public ref VoiceState GetSortedState(int id)
public ref VoiceInfo GetSortedState(int id)
{
Debug.Assert(id >= 0 && id < _voiceCount);
@@ -113,7 +113,7 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
/// </summary>
public void UpdateForCommandGeneration()
{
_voiceUpdateStatesDsp.CopyTo(_voiceUpdateStatesCpu);
_voiceStatesDsp.CopyTo(_voiceStatesCpu);
}
/// <summary>
@@ -130,14 +130,14 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
sortedVoicesTemp.Sort((a, b) =>
{
ref VoiceState aState = ref GetState(a);
ref VoiceState bState = ref GetState(b);
ref VoiceInfo aInfo = ref GetState(a);
ref VoiceInfo bInfo = ref GetState(b);
int result = aState.Priority.CompareTo(bState.Priority);
int result = aInfo.Priority.CompareTo(bInfo.Priority);
if (result == 0)
{
return aState.SortingOrder.CompareTo(bState.SortingOrder);
return aInfo.SortingOrder.CompareTo(bInfo.SortingOrder);
}
return result;

View File

@@ -1,24 +1,28 @@
using Ryujinx.Audio.Common;
using Ryujinx.Audio.Renderer.Common;
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;
using static Ryujinx.Audio.Renderer.Parameter.VoiceInParameter;
using PlayState = Ryujinx.Audio.Renderer.Server.Types.PlayState;
namespace Ryujinx.Audio.Renderer.Server.Voice
{
[StructLayout(LayoutKind.Sequential, Pack = Alignment)]
public struct VoiceState
public struct VoiceInfo
{
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>
@@ -102,7 +106,7 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
/// <summary>
/// Biquad filters to apply to the output of the voice.
/// </summary>
public Array2<BiquadFilterParameter> BiquadFilters;
public Array2<BiquadFilterParameter2> BiquadFilters;
/// <summary>
/// Total count of <see cref="WaveBufferInternal"/> of the voice.
@@ -185,7 +189,7 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
public Span<bool> BiquadFilterNeedInitialization => SpanHelpers.AsSpan<BiquadFilterNeedInitializationArrayStruct, bool>(ref _biquadFilterNeedInitialization);
/// <summary>
/// Initialize the <see cref="VoiceState"/>.
/// Initialize the <see cref="VoiceInfo"/>.
/// </summary>
public void Initialize()
{
@@ -215,7 +219,7 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
}
/// <summary>
/// Initialize the <see cref="WaveBuffer"/> in this <see cref="VoiceState"/>.
/// Initialize the <see cref="WaveBuffer"/> in this <see cref="VoiceInfo"/>.
/// </summary>
private void InitializeWaveBuffers()
{
@@ -250,13 +254,13 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
{
return MixId != Constants.UnusedMixId || SplitterId != Constants.UnusedSplitterId;
}
/// <summary>
/// Indicate if the server voice information needs to be updated.
/// </summary>
/// <param name="parameter">The user parameter.</param>
/// <returns>Return true, if the server voice information needs to be updated.</returns>
private readonly bool ShouldUpdateParameters(in VoiceInParameter parameter)
private readonly bool ShouldUpdateParameters2(in VoiceInParameter2 parameter)
{
if (DataSourceStateAddressInfo.CpuAddress == parameter.DataSourceStateAddress)
{
@@ -268,14 +272,31 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
DataSourceStateUnmapped;
}
/// <summary>
/// Indicate if the server voice information needs to be updated.
/// </summary>
/// <param name="parameter">The user parameter.</param>
/// <returns>Return true, if the server voice information needs to be updated.</returns>
private readonly bool ShouldUpdateParameters1(in VoiceInParameter1 parameter)
{
if (DataSourceStateAddressInfo.CpuAddress == parameter.DataSourceStateAddress)
{
return DataSourceStateAddressInfo.Size != parameter.DataSourceStateSize;
}
return DataSourceStateAddressInfo.CpuAddress != parameter.DataSourceStateAddress ||
DataSourceStateAddressInfo.Size != parameter.DataSourceStateSize ||
DataSourceStateUnmapped;
}
/// <summary>
/// Update the internal state from a user parameter.
/// </summary>
/// <param name="outErrorInfo">The possible <see cref="ErrorInfo"/> that was generated.</param>
/// <param name="parameter">The user parameter.</param>
/// <param name="poolMapper">The mapper to use.</param>
/// <param name="behaviourContext">The behaviour context.</param>
public void UpdateParameters(out ErrorInfo outErrorInfo, in VoiceInParameter parameter, PoolMapper poolMapper, ref BehaviourContext behaviourContext)
/// <param name="behaviourInfo">The behaviour context.</param>
public void UpdateParameters2(out ErrorInfo outErrorInfo, in VoiceInParameter2 parameter, PoolMapper poolMapper, ref BehaviourInfo behaviourInfo)
{
InUse = parameter.InUse;
Id = parameter.Id;
@@ -296,14 +317,14 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
WaveBuffersCount = parameter.WaveBuffersCount;
WaveBuffersIndex = parameter.WaveBuffersIndex;
if (behaviourContext.IsFlushVoiceWaveBuffersSupported())
if (behaviourInfo.IsFlushVoiceWaveBuffersSupported())
{
FlushWaveBufferCount += parameter.FlushWaveBufferCount;
}
MixId = parameter.MixId;
if (behaviourContext.IsSplitterSupported())
if (behaviourInfo.IsSplitterSupported())
{
SplitterId = parameter.SplitterId;
}
@@ -316,7 +337,7 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
DecodingBehaviour behaviour = DecodingBehaviour.Default;
if (behaviourContext.IsDecodingBehaviourFlagSupported())
if (behaviourInfo.IsDecodingBehaviourFlagSupported())
{
behaviour = parameter.DecodingBehaviourFlags;
}
@@ -328,7 +349,78 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
VoiceDropFlag = false;
}
if (ShouldUpdateParameters(in parameter))
if (ShouldUpdateParameters2(in parameter))
{
DataSourceStateUnmapped = !poolMapper.TryAttachBuffer(out outErrorInfo, ref DataSourceStateAddressInfo, parameter.DataSourceStateAddress, parameter.DataSourceStateSize);
}
else
{
outErrorInfo = new ErrorInfo();
}
}
/// <summary>
/// Update the internal state from a user parameter.
/// </summary>
/// <param name="outErrorInfo">The possible <see cref="ErrorInfo"/> that was generated.</param>
/// <param name="parameter">The user paramter2.</param>
/// <param name="poolMapper">The mapper to use.</param>
/// <param name="behaviourInfo">The behaviour context.</param>
public void UpdateParameters1(out ErrorInfo outErrorInfo, in VoiceInParameter1 parameter, PoolMapper poolMapper, ref BehaviourInfo behaviourInfo)
{
InUse = parameter.InUse;
Id = parameter.Id;
NodeId = parameter.NodeId;
UpdatePlayState(parameter.PlayState);
SrcQuality = parameter.SrcQuality;
Priority = parameter.Priority;
SortingOrder = parameter.SortingOrder;
SampleRate = parameter.SampleRate;
SampleFormat = parameter.SampleFormat;
ChannelsCount = parameter.ChannelCount;
Pitch = parameter.Pitch;
Volume = parameter.Volume;
BiquadFilters[0] = BiquadFilterHelper.ToBiquadFilterParameter2(parameter.BiquadFilters[0]);
BiquadFilters[1] = BiquadFilterHelper.ToBiquadFilterParameter2(parameter.BiquadFilters[1]);
WaveBuffersCount = parameter.WaveBuffersCount;
WaveBuffersIndex = parameter.WaveBuffersIndex;
if (behaviourInfo.IsFlushVoiceWaveBuffersSupported())
{
FlushWaveBufferCount += parameter.FlushWaveBufferCount;
}
MixId = parameter.MixId;
if (behaviourInfo.IsSplitterSupported())
{
SplitterId = parameter.SplitterId;
}
else
{
SplitterId = Constants.UnusedSplitterId;
}
parameter.ChannelResourceIds.AsSpan().CopyTo(ChannelResourceIds.AsSpan());
DecodingBehaviour behaviour = DecodingBehaviour.Default;
if (behaviourInfo.IsDecodingBehaviourFlagSupported())
{
behaviour = parameter.DecodingBehaviourFlags;
}
DecodingBehaviour = behaviour;
if (parameter.ResetVoiceDropFlag)
{
VoiceDropFlag = false;
}
if (ShouldUpdateParameters1(in parameter))
{
DataSourceStateUnmapped = !poolMapper.TryAttachBuffer(out outErrorInfo, ref DataSourceStateAddressInfo, parameter.DataSourceStateAddress, parameter.DataSourceStateSize);
}
@@ -375,14 +467,14 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
PlayState = newServerPlayState;
}
/// <summary>
/// Write the status of the voice to the given user output.
/// </summary>
/// <param name="outStatus">The given user output.</param>
/// <param name="parameter">The user parameter.</param>
/// <param name="voiceUpdateStates">The voice states associated to the <see cref="VoiceState"/>.</param>
public void WriteOutStatus(ref VoiceOutStatus outStatus, in VoiceInParameter parameter, ReadOnlySpan<Memory<VoiceUpdateState>> voiceUpdateStates)
/// <param name="voiceStates">The voice states associated to the <see cref="VoiceInfo"/>.</param>
public void WriteOutStatus2(ref VoiceOutStatus outStatus, in VoiceInParameter2 parameter, ReadOnlySpan<Memory<VoiceState>> voiceStates)
{
#if DEBUG
// Sanity check in debug mode of the internal state
@@ -390,8 +482,8 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
{
for (int i = 1; i < ChannelsCount; i++)
{
ref VoiceUpdateState stateA = ref voiceUpdateStates[i - 1].Span[0];
ref VoiceUpdateState stateB = ref voiceUpdateStates[i].Span[0];
ref VoiceState stateA = ref voiceStates[i - 1].Span[0];
ref VoiceState stateB = ref voiceStates[i].Span[0];
Debug.Assert(stateA.WaveBufferConsumed == stateB.WaveBufferConsumed);
Debug.Assert(stateA.PlayedSampleCount == stateB.PlayedSampleCount);
@@ -412,7 +504,7 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
}
else
{
ref VoiceUpdateState state = ref voiceUpdateStates[0].Span[0];
ref VoiceState state = ref voiceStates[0].Span[0];
outStatus.VoiceDropFlag = VoiceDropFlag;
outStatus.PlayedWaveBuffersCount = state.WaveBufferConsumed;
@@ -421,21 +513,65 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
}
/// <summary>
/// Update the internal state of all the <see cref="WaveBuffer"/> of the <see cref="VoiceState"/>.
/// Write the status of the voice to the given user output.
/// </summary>
/// <param name="outStatus">The given user output.</param>
/// <param name="parameter">The user parameter.</param>
/// <param name="voiceStates">The voice states associated to the <see cref="VoiceInfo"/>.</param>
public void WriteOutStatus1(ref VoiceOutStatus outStatus, in VoiceInParameter1 parameter, ReadOnlySpan<Memory<VoiceState>> voiceStates)
{
#if DEBUG
// Sanity check in debug mode of the internal state
if (!parameter.IsNew && !IsNew)
{
for (int i = 1; i < ChannelsCount; i++)
{
ref VoiceState stateA = ref voiceStates[i - 1].Span[0];
ref VoiceState stateB = ref voiceStates[i].Span[0];
Debug.Assert(stateA.WaveBufferConsumed == stateB.WaveBufferConsumed);
Debug.Assert(stateA.PlayedSampleCount == stateB.PlayedSampleCount);
Debug.Assert(stateA.Offset == stateB.Offset);
Debug.Assert(stateA.WaveBufferIndex == stateB.WaveBufferIndex);
Debug.Assert(stateA.Fraction == stateB.Fraction);
Debug.Assert(stateA.IsWaveBufferValid.SequenceEqual(stateB.IsWaveBufferValid));
}
}
#endif
if (parameter.IsNew || IsNew)
{
IsNew = true;
outStatus.VoiceDropFlag = false;
outStatus.PlayedWaveBuffersCount = 0;
outStatus.PlayedSampleCount = 0;
}
else
{
ref VoiceState state = ref voiceStates[0].Span[0];
outStatus.VoiceDropFlag = VoiceDropFlag;
outStatus.PlayedWaveBuffersCount = state.WaveBufferConsumed;
outStatus.PlayedSampleCount = state.PlayedSampleCount;
}
}
/// <summary>
/// Update the internal state of all the <see cref="WaveBuffer"/> of the <see cref="VoiceInfo"/>.
/// </summary>
/// <param name="errorInfos">An array of <see cref="ErrorInfo"/> used to report errors when mapping any of the <see cref="WaveBuffer"/>.</param>
/// <param name="parameter">The user parameter.</param>
/// <param name="voiceUpdateStates">The voice states associated to the <see cref="VoiceState"/>.</param>
/// <param name="voiceStates">The voice states associated to the <see cref="VoiceInfo"/>.</param>
/// <param name="mapper">The mapper to use.</param>
/// <param name="behaviourContext">The behaviour context.</param>
public void UpdateWaveBuffers(
/// <param name="behaviourInfo">The behaviour context.</param>
public void UpdateWaveBuffers2(
out ErrorInfo[] errorInfos,
in VoiceInParameter parameter,
ReadOnlySpan<Memory<VoiceUpdateState>> voiceUpdateStates,
in VoiceInParameter2 parameter,
ReadOnlySpan<Memory<VoiceState>> voiceStates,
PoolMapper mapper,
ref BehaviourContext behaviourContext)
ref BehaviourInfo behaviourInfo)
{
errorInfos = new ErrorInfo[Constants.VoiceWaveBufferCount * 2];
if (parameter.IsNew)
{
@@ -443,23 +579,67 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
for (int i = 0; i < parameter.ChannelCount; i++)
{
voiceUpdateStates[i].Span[0].IsWaveBufferValid.Clear();
voiceStates[i].Span[0].IsWaveBufferValid.Clear();
}
}
ref VoiceUpdateState voiceUpdateState = ref voiceUpdateStates[0].Span[0];
ref VoiceState voiceState = ref voiceStates[0].Span[0];
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, voiceUpdateState.IsWaveBufferValid[i], mapper, ref behaviourContext);
UpdateWaveBuffer(errorInfosList, ref waveBuffersSpan[i], ref pWaveBuffersSpan[i], parameter.SampleFormat, voiceState.IsWaveBufferValid[i], mapper, ref behaviourInfo);
}
errorInfos = errorInfosList.ToArray();
}
/// <summary>
/// Update the internal state of one of the <see cref="WaveBuffer"/> of the <see cref="VoiceState"/>.
/// Update the internal state of all the <see cref="WaveBuffer"/> of the <see cref="VoiceInfo"/>.
/// </summary>
/// <param name="errorInfos">An array of <see cref="ErrorInfo"/> used to report errors when mapping any of the <see cref="WaveBuffer"/>.</param>
/// <param name="parameter">The user parameter.</param>
/// <param name="voiceStates">The voice states associated to the <see cref="VoiceInfo"/>.</param>
/// <param name="mapper">The mapper to use.</param>
/// <param name="behaviourInfo">The behaviour context.</param>
public void UpdateWaveBuffers1(
out ErrorInfo[] errorInfos,
in VoiceInParameter1 parameter,
ReadOnlySpan<Memory<VoiceState>> voiceStates,
PoolMapper mapper,
ref BehaviourInfo behaviourInfo)
{
if (parameter.IsNew)
{
InitializeWaveBuffers();
for (int i = 0; i < parameter.ChannelCount; i++)
{
voiceStates[i].Span[0].IsWaveBufferValid.Clear();
}
}
ref VoiceState voiceState = ref voiceStates[0].Span[0];
Span<WaveBuffer> waveBuffersSpan = WaveBuffers.AsSpan();
Span<WaveBufferInternal> pWaveBuffersSpan = parameter.WaveBuffers.AsSpan();
List<ErrorInfo> errorInfosList = [];
for (int i = 0; i < Constants.VoiceWaveBufferCount; i++)
{
UpdateWaveBuffer(errorInfosList, ref waveBuffersSpan[i], ref pWaveBuffersSpan[i], parameter.SampleFormat, voiceState.IsWaveBufferValid[i], mapper, ref behaviourInfo);
}
errorInfos = errorInfosList.ToArray();
}
/// <summary>
/// Update the internal state of one of the <see cref="WaveBuffer"/> of the <see cref="VoiceInfo"/>.
/// </summary>
/// <param name="errorInfos">A <see cref="Span{ErrorInfo}"/> used to report errors when mapping the <see cref="WaveBuffer"/>.</param>
/// <param name="waveBuffer">The <see cref="WaveBuffer"/> to update.</param>
@@ -467,15 +647,15 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
/// <param name="sampleFormat">The <see cref="SampleFormat"/> from the user input.</param>
/// <param name="isValid">If set to true, the server side wavebuffer is considered valid.</param>
/// <param name="mapper">The mapper to use.</param>
/// <param name="behaviourContext">The behaviour context.</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,
bool isValid,
PoolMapper mapper,
ref BehaviourContext behaviourContext)
ref BehaviourInfo behaviourInfo)
{
if (!isValid && waveBuffer.IsSendToAudioProcessor && waveBuffer.BufferAddressInfo.CpuAddress != 0)
{
@@ -500,24 +680,30 @@ 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 && behaviourContext.IsAdpcmLoopContextBugFixed() && inputWaveBuffer.ContextAddress != 0)
if (sampleFormat == SampleFormat.Adpcm && behaviourInfo.IsAdpcmLoopContextBugFixed() && inputWaveBuffer.ContextAddress != 0)
{
bool adpcmLoopContextMapped = mapper.TryAttachBuffer(out ErrorInfo adpcmLoopContextInfoError,
ref waveBuffer.ContextAddressInfo,
inputWaveBuffer.ContextAddress,
inputWaveBuffer.ContextSize);
errorInfos[1] = adpcmLoopContextInfoError;
if (adpcmLoopContextInfoError.ErrorCode != ResultCode.Success)
{
errorInfos.Add(adpcmLoopContextInfoError);
}
if (adpcmLoopContextMapped)
if (!adpcmLoopContextMapped || BufferInfoUnmapped)
{
BufferInfoUnmapped = DataSourceStateUnmapped;
BufferInfoUnmapped = true;
}
else
{
BufferInfoUnmapped = true;
BufferInfoUnmapped = false;
}
}
else
@@ -527,14 +713,17 @@ 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
});
}
}
}
/// <summary>
/// Reset the resources associated to this <see cref="VoiceState"/>.
/// Reset the resources associated to this <see cref="VoiceInfo"/>.
/// </summary>
/// <param name="context">The voice context.</param>
private void ResetResources(VoiceContext context)
@@ -549,9 +738,9 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
Debug.Assert(voiceChannelResource.IsUsed);
Memory<VoiceUpdateState> dspSharedState = context.GetUpdateStateForDsp(channelResourceId);
Memory<VoiceState> dspSharedState = context.GetUpdateStateForDsp(channelResourceId);
MemoryMarshal.Cast<VoiceUpdateState, byte>(dspSharedState.Span).Clear();
MemoryMarshal.Cast<VoiceState, byte>(dspSharedState.Span).Clear();
voiceChannelResource.UpdateState();
}
@@ -561,9 +750,9 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
/// Flush a certain amount of <see cref="WaveBuffer"/>.
/// </summary>
/// <param name="waveBufferCount">The amount of wavebuffer to flush.</param>
/// <param name="voiceUpdateStates">The voice states associated to the <see cref="VoiceState"/>.</param>
/// <param name="voiceStates">The voice states associated to the <see cref="VoiceInfo"/>.</param>
/// <param name="channelCount">The channel count from user input.</param>
private void FlushWaveBuffers(uint waveBufferCount, Memory<VoiceUpdateState>[] voiceUpdateStates, uint channelCount)
private void FlushWaveBuffers(uint waveBufferCount, Memory<VoiceState>[] voiceStates, uint channelCount)
{
uint waveBufferIndex = WaveBuffersIndex;
@@ -575,12 +764,17 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
for (int j = 0; j < channelCount; j++)
{
ref VoiceUpdateState voiceUpdateState = ref voiceUpdateStates[j].Span[0];
voiceUpdateState.WaveBufferIndex = (voiceUpdateState.WaveBufferIndex + 1) % Constants.VoiceWaveBufferCount;
voiceUpdateState.WaveBufferConsumed++;
voiceUpdateState.IsWaveBufferValid[(int)waveBufferIndex] = false;
ref VoiceState voiceState = ref voiceStates[j].Span[0];
if (!waveBuffersSpan[(int)waveBufferIndex].IsSendToAudioProcessor || voiceState.IsWaveBufferValid[(int)waveBufferIndex])
{
voiceState.WaveBufferIndex = (voiceState.WaveBufferIndex + 1) % Constants.VoiceWaveBufferCount;
voiceState.WaveBufferConsumed++;
voiceState.IsWaveBufferValid[(int)waveBufferIndex] = false;
}
}
waveBuffersSpan[(int)waveBufferIndex].IsSendToAudioProcessor = true;
waveBufferIndex = (waveBufferIndex + 1) % Constants.VoiceWaveBufferCount;
}
@@ -589,13 +783,13 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
/// <summary>
/// Update the internal parameters for command generation.
/// </summary>
/// <param name="voiceUpdateStates">The voice states associated to the <see cref="VoiceState"/>.</param>
/// <param name="voiceStates">The voice states associated to the <see cref="VoiceInfo"/>.</param>
/// <returns>Return true if this voice should be played.</returns>
public bool UpdateParametersForCommandGeneration(Memory<VoiceUpdateState>[] voiceUpdateStates)
public bool UpdateParametersForCommandGeneration(Memory<VoiceState>[] voiceStates)
{
if (FlushWaveBufferCount != 0)
{
FlushWaveBuffers(FlushWaveBufferCount, voiceUpdateStates, ChannelsCount);
FlushWaveBuffers(FlushWaveBufferCount, voiceStates, ChannelsCount);
FlushWaveBufferCount = 0;
}
@@ -615,9 +809,9 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
{
for (int y = 0; y < ChannelsCount; y++)
{
Debug.Assert(!voiceUpdateStates[y].Span[0].IsWaveBufferValid[i]);
Debug.Assert(!voiceStates[y].Span[0].IsWaveBufferValid[i]);
voiceUpdateStates[y].Span[0].IsWaveBufferValid[i] = true;
voiceStates[y].Span[0].IsWaveBufferValid[i] = true;
}
waveBuffer.IsSendToAudioProcessor = true;
@@ -626,11 +820,11 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
WasPlaying = false;
ref VoiceUpdateState primaryVoiceUpdateState = ref voiceUpdateStates[0].Span[0];
ref VoiceState primaryVoiceState = ref voiceStates[0].Span[0];
for (int i = 0; i < primaryVoiceUpdateState.IsWaveBufferValid.Length; i++)
for (int i = 0; i < primaryVoiceState.IsWaveBufferValid.Length; i++)
{
if (primaryVoiceUpdateState.IsWaveBufferValid[i])
if (primaryVoiceState.IsWaveBufferValid[i])
{
return true;
}
@@ -649,27 +843,27 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
for (int j = 0; j < ChannelsCount; j++)
{
ref VoiceUpdateState voiceUpdateState = ref voiceUpdateStates[j].Span[0];
ref VoiceState voiceState = ref voiceStates[j].Span[0];
if (voiceUpdateState.IsWaveBufferValid[i])
if (voiceState.IsWaveBufferValid[i])
{
voiceUpdateState.WaveBufferIndex = (voiceUpdateState.WaveBufferIndex + 1) % Constants.VoiceWaveBufferCount;
voiceUpdateState.WaveBufferConsumed++;
voiceState.WaveBufferIndex = (voiceState.WaveBufferIndex + 1) % Constants.VoiceWaveBufferCount;
voiceState.WaveBufferConsumed++;
}
voiceUpdateState.IsWaveBufferValid[i] = false;
voiceState.IsWaveBufferValid[i] = false;
}
}
for (int i = 0; i < ChannelsCount; i++)
{
ref VoiceUpdateState voiceUpdateState = ref voiceUpdateStates[i].Span[0];
ref VoiceState voiceState = ref voiceStates[i].Span[0];
voiceUpdateState.Offset = 0;
voiceUpdateState.PlayedSampleCount = 0;
voiceUpdateState.Pitch.AsSpan().Clear();
voiceUpdateState.Fraction = 0;
voiceUpdateState.LoopContext = new AdpcmLoopContext();
voiceState.Offset = 0;
voiceState.PlayedSampleCount = 0;
voiceState.Pitch.AsSpan().Clear();
voiceState.Fraction = 0;
voiceState.LoopContext = new AdpcmLoopContext();
}
PlayState = PlayState.Stopped;
@@ -715,16 +909,21 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
IsNew = false;
}
Memory<VoiceUpdateState>[] voiceUpdateStates = new Memory<VoiceUpdateState>[Constants.VoiceChannelCountMax];
Memory<VoiceState>[] voiceStates = voiceStatesPool.Allocate();
Span<int> channelResourceIdsSpan = ChannelResourceIds.AsSpan();
for (int i = 0; i < ChannelsCount; i++)
{
voiceUpdateStates[i] = context.GetUpdateStateForDsp(channelResourceIdsSpan[i]);
voiceStates[i] = context.GetUpdateStateForDsp(channelResourceIdsSpan[i]);
}
return UpdateParametersForCommandGeneration(voiceUpdateStates);
bool result = UpdateParametersForCommandGeneration(voiceStates);
voiceStatesPool.Release(voiceStates);
//might contain garbage data, but said data will never be accessed
return result;
}
}
}

View 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;
}
}
}
}

View File

@@ -46,10 +46,11 @@ namespace Ryujinx.Common.Configuration.Hid.Controller
// PS5 touchpad button
Touchpad,
// Virtual buttons for single joycon
// Virtual buttons for single joycon (left)
SingleLeftTrigger0,
SingleRightTrigger0,
// Virtual buttons for single joycon (right)
SingleLeftTrigger1,
SingleRightTrigger1,

View File

@@ -1,31 +0,0 @@
using Ryujinx.Common.Logging.Formatters;
using System;
using System.Text.Json.Serialization;
namespace Ryujinx.Common.Logging
{
internal class LogEventArgsJson
{
public LogLevel Level { get; }
public TimeSpan Time { get; }
public string ThreadName { get; }
public string Message { get; }
public string Data { get; }
[JsonConstructor]
public LogEventArgsJson(LogLevel level, TimeSpan time, string threadName, string message, string data = null)
{
Level = level;
Time = time;
ThreadName = threadName;
Message = message;
Data = data;
}
public static LogEventArgsJson FromLogEventArgs(LogEventArgs args)
{
return new LogEventArgsJson(args.Level, args.Time, args.ThreadName, args.Message, DynamicObjectFormatter.Format(args.Data));
}
}
}

View File

@@ -1,9 +0,0 @@
using System.Text.Json.Serialization;
namespace Ryujinx.Common.Logging
{
[JsonSerializable(typeof(LogEventArgsJson))]
internal partial class LogEventJsonSerializerContext : JsonSerializerContext
{
}
}

View File

@@ -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;
@@ -219,14 +230,14 @@ namespace Ryujinx.Common.Logging
switch (logLevel)
{
#pragma warning disable IDE0055 // Disable formatting
case LogLevel.Debug : Debug = enabled ? new Log(LogLevel.Debug) : new Log?(); break;
case LogLevel.Info : Info = enabled ? new Log(LogLevel.Info) : new Log?(); break;
case LogLevel.Warning : Warning = enabled ? new Log(LogLevel.Warning) : new Log?(); break;
case LogLevel.Error : Error = enabled ? new Log(LogLevel.Error) : new Log?(); break;
case LogLevel.Guest : Guest = enabled ? new Log(LogLevel.Guest) : new Log?(); break;
case LogLevel.AccessLog : AccessLog = enabled ? new Log(LogLevel.AccessLog) : new Log?(); break;
case LogLevel.Stub : Stub = enabled ? new Log(LogLevel.Stub) : new Log?(); break;
case LogLevel.Trace : Trace = enabled ? new Log(LogLevel.Trace) : new Log?(); break;
case LogLevel.Debug : Debug = enabled ? new Log(LogLevel.Debug) : null; break;
case LogLevel.Info : Info = enabled ? new Log(LogLevel.Info) : null; break;
case LogLevel.Warning : Warning = enabled ? new Log(LogLevel.Warning) : null; break;
case LogLevel.Error : Error = enabled ? new Log(LogLevel.Error) : null; break;
case LogLevel.Guest : Guest = enabled ? new Log(LogLevel.Guest) : null; break;
case LogLevel.AccessLog : AccessLog = enabled ? new Log(LogLevel.AccessLog) : null; break;
case LogLevel.Stub : Stub = enabled ? new Log(LogLevel.Stub) : null; break;
case LogLevel.Trace : Trace = enabled ? new Log(LogLevel.Trace) : null; break;
case LogLevel.Notice : break;
default: throw new ArgumentException("Unknown Log Level", nameof(logLevel));
#pragma warning restore IDE0055

View File

@@ -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);

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