Compare commits
38 Commits
Author | SHA1 | Date | |
---|---|---|---|
bbed3b9926 | |||
24c8b0edc0 | |||
e5066449a5 | |||
d704bcd93b | |||
c94f0fbb83 | |||
d1b30fbe08 | |||
4505a7f162 | |||
ccbbaddbcb | |||
8bf102d2cd | |||
2adf031830 | |||
bb4a28b525 | |||
a8fbcdae9f | |||
4e81ab4229 | |||
4117c13377 | |||
20a392ad55 | |||
70fcba39de | |||
7795b662a9 | |||
30bdc4544e | |||
f6475cca17 | |||
0335c52254 | |||
b8d992e5a7 | |||
a620cbcc90 | |||
cea204d48e | |||
35fb409e85 | |||
d7ec4308b4 | |||
fbdd390f90 | |||
f33fea3287 | |||
5d3eea40be | |||
cd37c75b82 | |||
43705c2320 | |||
371e6fa24c | |||
1d9b63cc6a | |||
795539bc82 | |||
dd2e851e95 | |||
2ca70eb9a0 | |||
6575952432 | |||
9a28ba72b1 | |||
34a9922b57 |
@ -17,8 +17,8 @@ tab_width = 4
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
|
||||
# JSON files
|
||||
[*.json]
|
||||
# Markdown, JSON, YAML, props and csproj files
|
||||
[*.{md,json,yml,props,csproj}]
|
||||
|
||||
# Indentation and spacing
|
||||
indent_size = 2
|
||||
|
17
.github/workflows/build.yml
vendored
17
.github/workflows/build.yml
vendored
@ -40,7 +40,7 @@ jobs:
|
||||
- uses: actions/setup-dotnet@v4
|
||||
with:
|
||||
global-json-file: global.json
|
||||
|
||||
|
||||
- name: Overwrite csc problem matcher
|
||||
run: echo "::add-matcher::.github/csc.json"
|
||||
|
||||
@ -49,6 +49,16 @@ jobs:
|
||||
run: echo "result=$(git rev-parse --short "${{ github.sha }}")" >> $GITHUB_OUTPUT
|
||||
shell: bash
|
||||
|
||||
- name: Change config filename
|
||||
run: sed -r --in-place 's/\%\%RYUJINX_CONFIG_FILE_NAME\%\%/PRConfig\.json/g;' src/Ryujinx.Common/ReleaseInformation.cs
|
||||
shell: bash
|
||||
if: github.event_name == 'pull_request' && matrix.os != 'macOS-latest'
|
||||
|
||||
- name: Change config filename for macOS
|
||||
run: sed -r -i '' 's/\%\%RYUJINX_CONFIG_FILE_NAME\%\%/PRConfig\.json/g;' src/Ryujinx.Common/ReleaseInformation.cs
|
||||
shell: bash
|
||||
if: github.event_name == 'pull_request' && matrix.os == 'macOS-latest'
|
||||
|
||||
- name: Build
|
||||
run: dotnet build -c "${{ matrix.configuration }}" -p:Version="${{ env.RYUJINX_BASE_VERSION }}" -p:SourceRevisionId="${{ steps.git_short_hash.outputs.result }}" -p:ExtraDefineConstants=DISABLE_UPDATER
|
||||
|
||||
@ -135,6 +145,11 @@ jobs:
|
||||
id: git_short_hash
|
||||
run: echo "result=$(git rev-parse --short "${{ github.sha }}")" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Change config filename
|
||||
run: sed -r --in-place 's/\%\%RYUJINX_CONFIG_FILE_NAME\%\%/PRConfig\.json/g;' src/Ryujinx.Common/ReleaseInformation.cs
|
||||
shell: bash
|
||||
if: github.event_name == 'pull_request'
|
||||
|
||||
- name: Publish macOS Ryujinx.Ava
|
||||
run: |
|
||||
./distribution/macos/create_macos_build_ava.sh . publish_tmp_ava publish_ava ./distribution/macos/entitlements.xml "${{ env.RYUJINX_BASE_VERSION }}" "${{ steps.git_short_hash.outputs.result }}" "${{ matrix.configuration }}" "-p:ExtraDefineConstants=DISABLE_UPDATER"
|
||||
|
2
.github/workflows/checks.yml
vendored
2
.github/workflows/checks.yml
vendored
@ -8,7 +8,7 @@ on:
|
||||
- '!.github/**'
|
||||
- '!*.yml'
|
||||
- '!*.config'
|
||||
- '!README.md'
|
||||
- '!*.md'
|
||||
- '.github/workflows/*.yml'
|
||||
|
||||
permissions:
|
||||
|
41
.github/workflows/mako.yml
vendored
Normal file
41
.github/workflows/mako.yml
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
name: Mako
|
||||
on:
|
||||
discussion:
|
||||
types: [created, edited, answered, unanswered, category_changed]
|
||||
discussion_comment:
|
||||
types: [created, edited]
|
||||
gollum:
|
||||
issue_comment:
|
||||
types: [created, edited]
|
||||
issues:
|
||||
types: [opened, edited, reopened, pinned, milestoned, demilestoned, assigned, unassigned, labeled, unlabeled]
|
||||
pull_request_target:
|
||||
types: [opened, edited, reopened, synchronize, ready_for_review, assigned, unassigned]
|
||||
|
||||
jobs:
|
||||
tasks:
|
||||
name: Run Ryujinx tasks
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
discussions: write
|
||||
issues: write
|
||||
pull-requests: write
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
if: github.event_name == 'pull_request_target'
|
||||
with:
|
||||
# Ensure we pin the source origin as pull_request_target run under forks.
|
||||
fetch-depth: 0
|
||||
repository: Ryujinx/Ryujinx
|
||||
ref: master
|
||||
|
||||
- name: Run Mako command
|
||||
uses: Ryujinx/Ryujinx-Mako@master
|
||||
with:
|
||||
command: exec-ryujinx-tasks
|
||||
args: --event-name "${{ github.event_name }}" --event-path "${{ github.event_path }}" -w "${{ github.workspace }}" "${{ github.repository }}" "${{ github.run_id }}"
|
||||
app_id: ${{ secrets.MAKO_APP_ID }}
|
||||
private_key: ${{ secrets.MAKO_PRIVATE_KEY }}
|
||||
installation_id: ${{ secrets.MAKO_INSTALLATION_ID }}
|
19
.github/workflows/pr_triage.yml
vendored
19
.github/workflows/pr_triage.yml
vendored
@ -21,27 +21,8 @@ jobs:
|
||||
repository: Ryujinx/Ryujinx
|
||||
ref: master
|
||||
|
||||
- name: Checkout Ryujinx-Mako
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: Ryujinx/Ryujinx-Mako
|
||||
ref: master
|
||||
path: '.ryujinx-mako'
|
||||
|
||||
- name: Setup Ryujinx-Mako
|
||||
uses: ./.ryujinx-mako/.github/actions/setup-mako
|
||||
|
||||
- name: Update labels based on changes
|
||||
uses: actions/labeler@v5
|
||||
with:
|
||||
sync-labels: true
|
||||
dot: true
|
||||
|
||||
- name: Assign reviewers
|
||||
run: |
|
||||
poetry -n -C .ryujinx-mako run ryujinx-mako update-reviewers ${{ github.repository }} ${{ github.event.pull_request.number }} .github/reviewers.yml
|
||||
shell: bash
|
||||
env:
|
||||
MAKO_APP_ID: ${{ secrets.MAKO_APP_ID }}
|
||||
MAKO_PRIVATE_KEY: ${{ secrets.MAKO_PRIVATE_KEY }}
|
||||
MAKO_INSTALLATION_ID: ${{ secrets.MAKO_INSTALLATION_ID }}
|
||||
|
4
.github/workflows/release.yml
vendored
4
.github/workflows/release.yml
vendored
@ -10,7 +10,7 @@ on:
|
||||
- '*.yml'
|
||||
- '*.json'
|
||||
- '*.config'
|
||||
- 'README.md'
|
||||
- '*.md'
|
||||
|
||||
concurrency: release
|
||||
|
||||
@ -85,6 +85,7 @@ jobs:
|
||||
sed -r --in-place 's/\%\%RYUJINX_TARGET_RELEASE_CHANNEL_NAME\%\%/${{ env.RYUJINX_TARGET_RELEASE_CHANNEL_NAME }}/g;' src/Ryujinx.Common/ReleaseInformation.cs
|
||||
sed -r --in-place 's/\%\%RYUJINX_TARGET_RELEASE_CHANNEL_OWNER\%\%/${{ env.RYUJINX_TARGET_RELEASE_CHANNEL_OWNER }}/g;' src/Ryujinx.Common/ReleaseInformation.cs
|
||||
sed -r --in-place 's/\%\%RYUJINX_TARGET_RELEASE_CHANNEL_REPO\%\%/${{ env.RYUJINX_TARGET_RELEASE_CHANNEL_REPO }}/g;' src/Ryujinx.Common/ReleaseInformation.cs
|
||||
sed -r --in-place 's/\%\%RYUJINX_CONFIG_FILE_NAME\%\%/Config\.json/g;' src/Ryujinx.Common/ReleaseInformation.cs
|
||||
shell: bash
|
||||
|
||||
- name: Create output dir
|
||||
@ -186,6 +187,7 @@ jobs:
|
||||
sed -r --in-place 's/\%\%RYUJINX_TARGET_RELEASE_CHANNEL_NAME\%\%/${{ env.RYUJINX_TARGET_RELEASE_CHANNEL_NAME }}/g;' src/Ryujinx.Common/ReleaseInformation.cs
|
||||
sed -r --in-place 's/\%\%RYUJINX_TARGET_RELEASE_CHANNEL_OWNER\%\%/${{ env.RYUJINX_TARGET_RELEASE_CHANNEL_OWNER }}/g;' src/Ryujinx.Common/ReleaseInformation.cs
|
||||
sed -r --in-place 's/\%\%RYUJINX_TARGET_RELEASE_CHANNEL_REPO\%\%/${{ env.RYUJINX_TARGET_RELEASE_CHANNEL_REPO }}/g;' src/Ryujinx.Common/ReleaseInformation.cs
|
||||
sed -r --in-place 's/\%\%RYUJINX_CONFIG_FILE_NAME\%\%/Config\.json/g;' src/Ryujinx.Common/ReleaseInformation.cs
|
||||
shell: bash
|
||||
|
||||
- name: Publish macOS Ryujinx.Ava
|
||||
|
@ -8,30 +8,30 @@
|
||||
<PackageVersion Include="Avalonia.Desktop" Version="11.0.7" />
|
||||
<PackageVersion Include="Avalonia.Diagnostics" Version="11.0.7" />
|
||||
<PackageVersion Include="Avalonia.Markup.Xaml.Loader" Version="11.0.7" />
|
||||
<PackageVersion Include="Avalonia.Svg" Version="11.0.0.10" />
|
||||
<PackageVersion Include="Avalonia.Svg.Skia" Version="11.0.0.10" />
|
||||
<PackageVersion Include="Avalonia.Svg" Version="11.0.0.13" />
|
||||
<PackageVersion Include="Avalonia.Svg.Skia" Version="11.0.0.13" />
|
||||
<PackageVersion Include="CommandLineParser" Version="2.9.1" />
|
||||
<PackageVersion Include="Concentus" Version="1.1.7" />
|
||||
<PackageVersion Include="DiscordRichPresence" Version="1.2.1.24" />
|
||||
<PackageVersion Include="DynamicData" Version="7.14.2" />
|
||||
<PackageVersion Include="DynamicData" Version="8.3.27" />
|
||||
<PackageVersion Include="FluentAvaloniaUI" Version="2.0.5" />
|
||||
<PackageVersion Include="GtkSharp.Dependencies" Version="1.1.1" />
|
||||
<PackageVersion Include="GtkSharp.Dependencies.osx" Version="0.0.5" />
|
||||
<PackageVersion Include="jp2masa.Avalonia.Flexbox" Version="0.3.0-beta.4" />
|
||||
<PackageVersion Include="LibHac" Version="0.19.0" />
|
||||
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" />
|
||||
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.7.0" />
|
||||
<PackageVersion Include="Microsoft.IdentityModel.JsonWebTokens" Version="7.2.0" />
|
||||
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.8.0" />
|
||||
<PackageVersion Include="Microsoft.IdentityModel.JsonWebTokens" Version="7.3.0" />
|
||||
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
|
||||
<PackageVersion Include="Microsoft.IO.RecyclableMemoryStream" Version="2.3.2" />
|
||||
<PackageVersion Include="Microsoft.IO.RecyclableMemoryStream" Version="3.0.0" />
|
||||
<PackageVersion Include="MsgPack.Cli" Version="1.0.1" />
|
||||
<PackageVersion Include="NetCoreServer" Version="7.0.0" />
|
||||
<PackageVersion Include="NetCoreServer" Version="8.0.7" />
|
||||
<PackageVersion Include="NUnit" Version="3.13.3" />
|
||||
<PackageVersion Include="NUnit3TestAdapter" Version="4.1.0" />
|
||||
<PackageVersion Include="OpenTK.Core" Version="4.8.1" />
|
||||
<PackageVersion Include="OpenTK.Graphics" Version="4.8.1" />
|
||||
<PackageVersion Include="OpenTK.Audio.OpenAL" Version="4.8.1" />
|
||||
<PackageVersion Include="OpenTK.Windowing.GraphicsLibraryFramework" Version="4.8.1" />
|
||||
<PackageVersion Include="OpenTK.Core" Version="4.8.2" />
|
||||
<PackageVersion Include="OpenTK.Graphics" Version="4.8.2" />
|
||||
<PackageVersion Include="OpenTK.Audio.OpenAL" Version="4.8.2" />
|
||||
<PackageVersion Include="OpenTK.Windowing.GraphicsLibraryFramework" Version="4.8.2" />
|
||||
<PackageVersion Include="Ryujinx.Audio.OpenAL.Dependencies" Version="1.21.0.1" />
|
||||
<PackageVersion Include="Ryujinx.Graphics.Nvdec.Dependencies" Version="5.0.1-build13" />
|
||||
<PackageVersion Include="Ryujinx.Graphics.Vulkan.Dependencies.MoltenVK" Version="1.2.0" />
|
||||
@ -46,7 +46,7 @@
|
||||
<PackageVersion Include="SixLabors.ImageSharp" Version="1.0.4" />
|
||||
<PackageVersion Include="SixLabors.ImageSharp.Drawing" Version="1.0.0-beta11" />
|
||||
<PackageVersion Include="SPB" Version="0.0.4-build28" />
|
||||
<PackageVersion Include="System.Drawing.Common" Version="8.0.0" />
|
||||
<PackageVersion Include="System.Drawing.Common" Version="8.0.1" />
|
||||
<PackageVersion Include="System.IO.Hashing" Version="8.0.0" />
|
||||
<PackageVersion Include="System.Management" Version="8.0.0" />
|
||||
<PackageVersion Include="UnicornEngine.Unicorn" Version="2.0.2-rc1-fb78016" />
|
||||
|
93
README.md
93
README.md
@ -1,21 +1,21 @@
|
||||
|
||||
<h1 align="center">
|
||||
<br>
|
||||
<a href="https://ryujinx.org/"><img src="https://i.imgur.com/WcCj6Rt.png" alt="Ryujinx" width="150"></a>
|
||||
<a href="https://ryujinx.org/"><img src="https://raw.githubusercontent.com/Ryujinx/Ryujinx/master/distribution/misc/Logo.svg" alt="Ryujinx" width="150"></a>
|
||||
<br>
|
||||
<b>Ryujinx</b>
|
||||
<br>
|
||||
<sub><sup><b>(REE-YOU-JINX)</b></sup></sub>
|
||||
<br>
|
||||
|
||||
</h1>
|
||||
|
||||
<p align="center">
|
||||
Ryujinx is an open-source Nintendo Switch emulator, created by gdkchan, written in C#.
|
||||
This emulator aims at providing excellent accuracy and performance, a user-friendly interface and consistent builds.
|
||||
It was written from scratch and development on the project began in September 2017. Ryujinx is available on Github under the <a href="https://github.com/Ryujinx/Ryujinx/blob/master/LICENSE.txt" target="_blank">MIT license</a>. <br />
|
||||
|
||||
Ryujinx is an open-source Nintendo Switch emulator, created by gdkchan, written in C#.
|
||||
This emulator aims at providing excellent accuracy and performance, a user-friendly interface and consistent builds.
|
||||
It was written from scratch and development on the project began in September 2017.
|
||||
Ryujinx is available on Github under the <a href="https://github.com/Ryujinx/Ryujinx/blob/master/LICENSE.txt" target="_blank">MIT license</a>.
|
||||
<br />
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://github.com/Ryujinx/Ryujinx/actions/workflows/release.yml">
|
||||
<img src="https://github.com/Ryujinx/Ryujinx/actions/workflows/release.yml/badge.svg"
|
||||
@ -34,87 +34,111 @@
|
||||
<img src="https://raw.githubusercontent.com/Ryujinx/Ryujinx-Website/master/public/assets/images/shell.png">
|
||||
</p>
|
||||
|
||||
<h5 align="center">
|
||||
|
||||
</h5>
|
||||
|
||||
## Compatibility
|
||||
|
||||
As of April 2023, Ryujinx has been tested on approximately 4,050 titles; over 4,000 boot past menus and into gameplay, with roughly 3,400 of those being considered playable.
|
||||
You can check out the compatibility list [here](https://github.com/Ryujinx/Ryujinx-Games-List/issues). Anyone is free to submit a new game test or update an existing game test entry; simply follow the new issue template and testing guidelines, or post as a reply to the applicable game issue. Use the search function to see if a game has been tested already!
|
||||
As of October 2023, Ryujinx has been tested on approximately 4,200 titles;
|
||||
over 4,150 boot past menus and into gameplay, with roughly 3,500 of those being considered playable.
|
||||
|
||||
You can check out the compatibility list [here](https://github.com/Ryujinx/Ryujinx-Games-List/issues).
|
||||
|
||||
Anyone is free to submit a new game test or update an existing game test entry;
|
||||
simply follow the new issue template and testing guidelines, or post as a reply to the applicable game issue.
|
||||
Use the search function to see if a game has been tested already!
|
||||
|
||||
## Usage
|
||||
|
||||
To run this emulator, your PC must be equipped with at least 8GiB of RAM; failing to meet this requirement may result in a poor gameplay experience or unexpected crashes.
|
||||
To run this emulator, your PC must be equipped with at least 8GiB of RAM;
|
||||
failing to meet this requirement may result in a poor gameplay experience or unexpected crashes.
|
||||
|
||||
See our [Setup & Configuration Guide](https://github.com/Ryujinx/Ryujinx/wiki/Ryujinx-Setup-&-Configuration-Guide) on how to set up the emulator.
|
||||
|
||||
For our Local Wireless and LAN builds, see our [Multiplayer: Local Play/Local Wireless Guide
|
||||
For our Local Wireless (LDN) builds, see our [Multiplayer: Local Play/Local Wireless Guide
|
||||
](https://github.com/Ryujinx/Ryujinx/wiki/Multiplayer-(LDN-Local-Wireless)-Guide).
|
||||
|
||||
Avalonia UI comes with translations for various languages. See [Crowdin](https://crwd.in/ryujinx) for more information.
|
||||
|
||||
## Latest build
|
||||
|
||||
These builds are compiled automatically for each commit on the master branch. While we strive to ensure optimal stability and performance prior to pushing an update, our automated builds **may be unstable or completely broken.**
|
||||
These builds are compiled automatically for each commit on the master branch.
|
||||
While we strive to ensure optimal stability and performance prior to pushing an update, our automated builds **may be unstable or completely broken**.
|
||||
|
||||
If you want to see details on updates to the emulator, you can visit our [Changelog](https://github.com/Ryujinx/Ryujinx/wiki/Changelog).
|
||||
|
||||
The latest automatic build for Windows, macOS, and Linux can be found on the [Official Website](https://ryujinx.org/download).
|
||||
|
||||
## Documentation
|
||||
|
||||
If you are planning to contribute or just want to learn more about this project please read through our [documentation](docs/README.md).
|
||||
|
||||
## Building
|
||||
|
||||
If you wish to build the emulator yourself, follow these steps:
|
||||
|
||||
### Step 1
|
||||
Install the X64 version of [.NET 8.0 (or higher) SDK](https://dotnet.microsoft.com/download/dotnet/8.0).
|
||||
|
||||
Install the [.NET 8.0 (or higher) SDK](https://dotnet.microsoft.com/download/dotnet/8.0).
|
||||
Make sure your SDK version is higher or equal to the required version specified in [global.json](global.json).
|
||||
|
||||
### Step 2
|
||||
|
||||
Either use `git clone https://github.com/Ryujinx/Ryujinx` on the command line to clone the repository or use Code --> Download zip button to get the files.
|
||||
|
||||
### Step 3
|
||||
|
||||
To build Ryujinx, open a command prompt inside the project directory. You can quickly access it on Windows by holding shift in File Explorer, then right clicking and selecting `Open command window here`. Then type the following command:
|
||||
`dotnet build -c Release -o build`
|
||||
To build Ryujinx, open a command prompt inside the project directory.
|
||||
You can quickly access it on Windows by holding shift in File Explorer, then right clicking and selecting `Open command window here`.
|
||||
Then type the following command: `dotnet build -c Release -o build`
|
||||
the built files will be found in the newly created build directory.
|
||||
|
||||
Ryujinx system files are stored in the `Ryujinx` folder. This folder is located in the user folder, which can be accessed by clicking `Open Ryujinx Folder` under the File menu in the GUI.
|
||||
|
||||
Ryujinx system files are stored in the `Ryujinx` folder.
|
||||
This folder is located in the user folder, which can be accessed by clicking `Open Ryujinx Folder` under the File menu in the GUI.
|
||||
|
||||
## Features
|
||||
|
||||
- **Audio**
|
||||
- **Audio**
|
||||
|
||||
Audio output is entirely supported, audio input (microphone) isn't supported. We use C# wrappers for [OpenAL](https://openal-soft.org/), and [SDL2](https://www.libsdl.org/) & [libsoundio](http://libsound.io/) as fallbacks.
|
||||
Audio output is entirely supported, audio input (microphone) isn't supported.
|
||||
We use C# wrappers for [OpenAL](https://openal-soft.org/), and [SDL2](https://www.libsdl.org/) & [libsoundio](http://libsound.io/) as fallbacks.
|
||||
|
||||
- **CPU**
|
||||
|
||||
The CPU emulator, ARMeilleure, emulates an ARMv8 CPU and currently has support for most 64-bit ARMv8 and some of the ARMv7 (and older) instructions, including partial 32-bit support. It translates the ARM code to a custom IR, performs a few optimizations, and turns that into x86 code.
|
||||
There are three memory manager options available depending on the user's preference, leveraging both software-based (slower) and host-mapped modes (much faster). The fastest option (host, unchecked) is set by default.
|
||||
Ryujinx also features an optional Profiled Persistent Translation Cache, which essentially caches translated functions so that they do not need to be translated every time the game loads. The net result is a significant reduction in load times (the amount of time between launching a game and arriving at the title screen) for nearly every game. NOTE: this feature is enabled by default in the Options menu > System tab. You must launch the game at least twice to the title screen or beyond before performance improvements are unlocked on the third launch! These improvements are permanent and do not require any extra launches going forward.
|
||||
The CPU emulator, ARMeilleure, emulates an ARMv8 CPU and currently has support for most 64-bit ARMv8 and some of the ARMv7 (and older) instructions, including partial 32-bit support.
|
||||
It translates the ARM code to a custom IR, performs a few optimizations, and turns that into x86 code.
|
||||
There are three memory manager options available depending on the user's preference, leveraging both software-based (slower) and host-mapped modes (much faster).
|
||||
The fastest option (host, unchecked) is set by default.
|
||||
Ryujinx also features an optional Profiled Persistent Translation Cache, which essentially caches translated functions so that they do not need to be translated every time the game loads.
|
||||
The net result is a significant reduction in load times (the amount of time between launching a game and arriving at the title screen) for nearly every game.
|
||||
NOTE: This feature is enabled by default in the Options menu > System tab.
|
||||
You must launch the game at least twice to the title screen or beyond before performance improvements are unlocked on the third launch!
|
||||
These improvements are permanent and do not require any extra launches going forward.
|
||||
|
||||
- **GPU**
|
||||
|
||||
The GPU emulator emulates the Switch's Maxwell GPU using either the OpenGL (version 4.5 minimum), Vulkan, or Metal (via MoltenVK) APIs through a custom build of OpenTK or Silk.NET respectively. There are currently six graphics enhancements available to the end user in Ryujinx: Disk Shader Caching, Resolution Scaling, Anti-Aliasing, Scaling Filters (including FSR), Anisotropic Filtering and Aspect Ratio Adjustment. These enhancements can be adjusted or toggled as desired in the GUI.
|
||||
The GPU emulator emulates the Switch's Maxwell GPU using either the OpenGL (version 4.5 minimum), Vulkan, or Metal (via MoltenVK) APIs through a custom build of OpenTK or Silk.NET respectively.
|
||||
There are currently six graphics enhancements available to the end user in Ryujinx: Disk Shader Caching, Resolution Scaling, Anti-Aliasing, Scaling Filters (including FSR), Anisotropic Filtering and Aspect Ratio Adjustment.
|
||||
These enhancements can be adjusted or toggled as desired in the GUI.
|
||||
|
||||
- **Input**
|
||||
|
||||
We currently have support for keyboard, mouse, touch input, JoyCon input support, and nearly all controllers. Motion controls are natively supported in most cases; for dual-JoyCon motion support, DS4Windows or BetterJoy are currently required.
|
||||
In all scenarios, you can set up everything inside the input configuration menu.
|
||||
We currently have support for keyboard, mouse, touch input, JoyCon input support, and nearly all controllers.
|
||||
Motion controls are natively supported in most cases; for dual-JoyCon motion support, DS4Windows or BetterJoy are currently required.
|
||||
In all scenarios, you can set up everything inside the input configuration menu.
|
||||
|
||||
- **DLC & Modifications**
|
||||
|
||||
Ryujinx is able to manage add-on content/downloadable content through the GUI. Mods (romfs, exefs, and runtime mods such as cheats) are also supported; the GUI contains a shortcut to open the respective mods folder for a particular game.
|
||||
Ryujinx is able to manage add-on content/downloadable content through the GUI.
|
||||
Mods (romfs, exefs, and runtime mods such as cheats) are also supported;
|
||||
the GUI contains a shortcut to open the respective mods folder for a particular game.
|
||||
|
||||
- **Configuration**
|
||||
|
||||
The emulator has settings for enabling or disabling some logging, remapping controllers, and more. You can configure all of them through the graphical interface or manually through the config file, `Config.json`, found in the user folder which can be accessed by clicking `Open Ryujinx Folder` under the File menu in the GUI.
|
||||
|
||||
The emulator has settings for enabling or disabling some logging, remapping controllers, and more.
|
||||
You can configure all of them through the graphical interface or manually through the config file, `Config.json`, found in the user folder which can be accessed by clicking `Open Ryujinx Folder` under the File menu in the GUI.
|
||||
|
||||
## Contact
|
||||
|
||||
If you have contributions, suggestions, need emulator support or just want to get in touch with the team, join our [Discord server](https://discord.com/invite/Ryujinx). You may also review our [FAQ](https://github.com/Ryujinx/Ryujinx/wiki/Frequently-Asked-Questions).
|
||||
If you have contributions, suggestions, need emulator support or just want to get in touch with the team, join our [Discord server](https://discord.com/invite/Ryujinx).
|
||||
You may also review our [FAQ](https://github.com/Ryujinx/Ryujinx/wiki/Frequently-Asked-Questions).
|
||||
|
||||
## Donations
|
||||
|
||||
@ -134,9 +158,10 @@ All funds received through Patreon are considered a donation to support the proj
|
||||
|
||||
## License
|
||||
|
||||
This software is licensed under the terms of the <a href="https://github.com/Ryujinx/Ryujinx/blob/master/LICENSE.txt" target="_blank">MIT license.</a></i><br />
|
||||
This software is licensed under the terms of the [MIT license](LICENSE.txt).
|
||||
This project makes use of code authored by the libvpx project, licensed under BSD and the ffmpeg project, licensed under LGPLv3.
|
||||
See [LICENSE.txt](LICENSE.txt) and [THIRDPARTY.md](distribution/legal/THIRDPARTY.md) for more details.
|
||||
|
||||
## Credits
|
||||
|
||||
- [LibHac](https://github.com/Thealexbarney/LibHac) is used for our file-system.
|
||||
|
@ -4,7 +4,7 @@ Name=Ryujinx
|
||||
Type=Application
|
||||
Icon=Ryujinx
|
||||
Exec=Ryujinx.sh %f
|
||||
Comment=Plays Nintendo Switch applications
|
||||
Comment=A Nintendo Switch Emulator
|
||||
GenericName=Nintendo Switch Emulator
|
||||
Terminal=false
|
||||
Categories=Game;Emulator;
|
||||
|
2
distribution/linux/Ryujinx.sh
Normal file → Executable file
2
distribution/linux/Ryujinx.sh
Normal file → Executable file
@ -17,4 +17,4 @@ if command -v gamemoderun > /dev/null 2>&1; then
|
||||
COMMAND="$COMMAND gamemoderun"
|
||||
fi
|
||||
|
||||
$COMMAND "$SCRIPT_DIR/$RYUJINX_BIN" "$@"
|
||||
$COMMAND "$SCRIPT_DIR/$RYUJINX_BIN" "$@"
|
||||
|
8
distribution/macos/shortcut-launch-script.sh
Normal file
8
distribution/macos/shortcut-launch-script.sh
Normal file
@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
launch_arch="$(uname -m)"
|
||||
if [ "$(sysctl -in sysctl.proc_translated)" = "1" ]
|
||||
then
|
||||
launch_arch="arm64"
|
||||
fi
|
||||
|
||||
arch -$launch_arch {0} {1}
|
@ -517,7 +517,10 @@ namespace ARMeilleure.Decoders
|
||||
SetA64("0x00111100>>>xxx100111xxxxxxxxxx", InstName.Sqrshrn_V, InstEmit.Sqrshrn_V, OpCodeSimdShImm.Create);
|
||||
SetA64("0111111100>>>xxx100011xxxxxxxxxx", InstName.Sqrshrun_S, InstEmit.Sqrshrun_S, OpCodeSimdShImm.Create);
|
||||
SetA64("0x10111100>>>xxx100011xxxxxxxxxx", InstName.Sqrshrun_V, InstEmit.Sqrshrun_V, OpCodeSimdShImm.Create);
|
||||
SetA64("010111110>>>>xxx011101xxxxxxxxxx", InstName.Sqshl_Si, InstEmit.Sqshl_Si, OpCodeSimdShImm.Create);
|
||||
SetA64("0>001110<<1xxxxx010011xxxxxxxxxx", InstName.Sqshl_V, InstEmit.Sqshl_V, OpCodeSimdReg.Create);
|
||||
SetA64("0000111100>>>xxx011101xxxxxxxxxx", InstName.Sqshl_Vi, InstEmit.Sqshl_Vi, OpCodeSimdShImm.Create);
|
||||
SetA64("010011110>>>>xxx011101xxxxxxxxxx", InstName.Sqshl_Vi, InstEmit.Sqshl_Vi, OpCodeSimdShImm.Create);
|
||||
SetA64("0101111100>>>xxx100101xxxxxxxxxx", InstName.Sqshrn_S, InstEmit.Sqshrn_S, OpCodeSimdShImm.Create);
|
||||
SetA64("0x00111100>>>xxx100101xxxxxxxxxx", InstName.Sqshrn_V, InstEmit.Sqshrn_V, OpCodeSimdShImm.Create);
|
||||
SetA64("0111111100>>>xxx100001xxxxxxxxxx", InstName.Sqshrun_S, InstEmit.Sqshrun_S, OpCodeSimdShImm.Create);
|
||||
@ -872,6 +875,7 @@ namespace ARMeilleure.Decoders
|
||||
SetVfp("<<<<11100x10xxxxxxxx101xx1x0xxxx", InstName.Vnmul, InstEmit32.Vnmul_S, OpCode32SimdRegS.Create, OpCode32SimdRegS.CreateT32);
|
||||
SetVfp("111111101x1110xxxxxx101x01x0xxxx", InstName.Vrint, InstEmit32.Vrint_RM, OpCode32SimdS.Create, OpCode32SimdS.CreateT32);
|
||||
SetVfp("<<<<11101x110110xxxx101x11x0xxxx", InstName.Vrint, InstEmit32.Vrint_Z, OpCode32SimdS.Create, OpCode32SimdS.CreateT32);
|
||||
SetVfp("<<<<11101x110110xxxx101x01x0xxxx", InstName.Vrintr, InstEmit32.Vrintr_S, OpCode32SimdS.Create, OpCode32SimdS.CreateT32);
|
||||
SetVfp("<<<<11101x110111xxxx101x01x0xxxx", InstName.Vrintx, InstEmit32.Vrintx_S, OpCode32SimdS.Create, OpCode32SimdS.CreateT32);
|
||||
SetVfp("<<<<11101x110001xxxx101x11x0xxxx", InstName.Vsqrt, InstEmit32.Vsqrt_S, OpCode32SimdS.Create, OpCode32SimdS.CreateT32);
|
||||
SetVfp("111111100xxxxxxxxxxx101xx0x0xxxx", InstName.Vsel, InstEmit32.Vsel, OpCode32SimdSel.Create, OpCode32SimdSel.CreateT32);
|
||||
@ -992,6 +996,7 @@ namespace ARMeilleure.Decoders
|
||||
SetAsimd("1111001x1x000xxxxxxx<<x10x01xxxx", InstName.Vorr, InstEmit32.Vorr_II, OpCode32SimdImm.Create, OpCode32SimdImm.CreateT32);
|
||||
SetAsimd("111100100x<<xxxxxxxx1011x0x1xxxx", InstName.Vpadd, InstEmit32.Vpadd_I, OpCode32SimdReg.Create, OpCode32SimdReg.CreateT32);
|
||||
SetAsimd("111100110x00xxxxxxxx1101x0x0xxxx", InstName.Vpadd, InstEmit32.Vpadd_V, OpCode32SimdReg.Create, OpCode32SimdReg.CreateT32);
|
||||
SetAsimd("111100111x11<<00xxxx0110xxx0xxxx", InstName.Vpadal, InstEmit32.Vpadal, OpCode32SimdCmpZ.Create, OpCode32SimdCmpZ.CreateT32);
|
||||
SetAsimd("111100111x11<<00xxxx0010xxx0xxxx", InstName.Vpaddl, InstEmit32.Vpaddl, OpCode32SimdCmpZ.Create, OpCode32SimdCmpZ.CreateT32);
|
||||
SetAsimd("1111001x0x<<xxxxxxxx1010x0x0xxxx", InstName.Vpmax, InstEmit32.Vpmax_I, OpCode32SimdReg.Create, OpCode32SimdReg.CreateT32);
|
||||
SetAsimd("111100110x00xxxxxxxx1111x0x0xxxx", InstName.Vpmax, InstEmit32.Vpmax_V, OpCode32SimdReg.Create, OpCode32SimdReg.CreateT32);
|
||||
|
@ -1115,6 +1115,13 @@ namespace ARMeilleure.Instructions
|
||||
}
|
||||
}
|
||||
|
||||
public static void Vpadal(ArmEmitterContext context)
|
||||
{
|
||||
OpCode32Simd op = (OpCode32Simd)context.CurrOp;
|
||||
|
||||
EmitVectorPairwiseTernaryLongOpI32(context, (op1, op2, op3) => context.Add(context.Add(op1, op2), op3), op.Opc != 1);
|
||||
}
|
||||
|
||||
public static void Vpaddl(ArmEmitterContext context)
|
||||
{
|
||||
OpCode32Simd op = (OpCode32Simd)context.CurrOp;
|
||||
|
@ -578,6 +578,22 @@ namespace ARMeilleure.Instructions
|
||||
}
|
||||
}
|
||||
|
||||
// VRINTR (floating-point).
|
||||
public static void Vrintr_S(ArmEmitterContext context)
|
||||
{
|
||||
if (Optimizations.UseAdvSimd)
|
||||
{
|
||||
InstEmitSimdHelper32Arm64.EmitScalarUnaryOpF32(context, Intrinsic.Arm64FrintiS);
|
||||
}
|
||||
else
|
||||
{
|
||||
EmitScalarUnaryOpF32(context, (op1) =>
|
||||
{
|
||||
return EmitRoundByRMode(context, op1);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// VRINTZ (floating-point).
|
||||
public static void Vrint_Z(ArmEmitterContext context)
|
||||
{
|
||||
|
@ -673,6 +673,35 @@ namespace ARMeilleure.Instructions
|
||||
context.Copy(GetVecA32(op.Qd), res);
|
||||
}
|
||||
|
||||
public static void EmitVectorPairwiseTernaryLongOpI32(ArmEmitterContext context, Func3I emit, bool signed)
|
||||
{
|
||||
OpCode32Simd op = (OpCode32Simd)context.CurrOp;
|
||||
|
||||
int elems = op.GetBytesCount() >> op.Size;
|
||||
int pairs = elems >> 1;
|
||||
|
||||
Operand res = GetVecA32(op.Qd);
|
||||
|
||||
for (int index = 0; index < pairs; index++)
|
||||
{
|
||||
int pairIndex = index * 2;
|
||||
Operand m1 = EmitVectorExtract32(context, op.Qm, op.Im + pairIndex, op.Size, signed);
|
||||
Operand m2 = EmitVectorExtract32(context, op.Qm, op.Im + pairIndex + 1, op.Size, signed);
|
||||
|
||||
if (op.Size == 2)
|
||||
{
|
||||
m1 = signed ? context.SignExtend32(OperandType.I64, m1) : context.ZeroExtend32(OperandType.I64, m1);
|
||||
m2 = signed ? context.SignExtend32(OperandType.I64, m2) : context.ZeroExtend32(OperandType.I64, m2);
|
||||
}
|
||||
|
||||
Operand d1 = EmitVectorExtract32(context, op.Qd, op.Id + index, op.Size + 1, signed);
|
||||
|
||||
res = EmitVectorInsert(context, res, emit(m1, m2, d1), op.Id + index, op.Size + 1);
|
||||
}
|
||||
|
||||
context.Copy(GetVecA32(op.Qd), res);
|
||||
}
|
||||
|
||||
// Narrow
|
||||
|
||||
public static void EmitVectorUnaryNarrowOp32(ArmEmitterContext context, Func1I emit, bool signed = false)
|
||||
|
@ -116,7 +116,7 @@ namespace ARMeilleure.Instructions
|
||||
}
|
||||
else if (shift >= eSize)
|
||||
{
|
||||
if ((op.RegisterSize == RegisterSize.Simd64))
|
||||
if (op.RegisterSize == RegisterSize.Simd64)
|
||||
{
|
||||
Operand res = context.VectorZeroUpper64(GetVec(op.Rd));
|
||||
|
||||
@ -359,6 +359,16 @@ namespace ARMeilleure.Instructions
|
||||
}
|
||||
}
|
||||
|
||||
public static void Sqshl_Si(ArmEmitterContext context)
|
||||
{
|
||||
EmitShlImmOp(context, signedDst: true, ShlRegFlags.Signed | ShlRegFlags.Scalar | ShlRegFlags.Saturating);
|
||||
}
|
||||
|
||||
public static void Sqshl_Vi(ArmEmitterContext context)
|
||||
{
|
||||
EmitShlImmOp(context, signedDst: true, ShlRegFlags.Signed | ShlRegFlags.Saturating);
|
||||
}
|
||||
|
||||
public static void Sqshrn_S(ArmEmitterContext context)
|
||||
{
|
||||
if (Optimizations.UseAdvSimd)
|
||||
@ -1593,6 +1603,99 @@ namespace ARMeilleure.Instructions
|
||||
Saturating = 1 << 3,
|
||||
}
|
||||
|
||||
private static void EmitShlImmOp(ArmEmitterContext context, bool signedDst, ShlRegFlags flags = ShlRegFlags.None)
|
||||
{
|
||||
bool scalar = flags.HasFlag(ShlRegFlags.Scalar);
|
||||
bool signed = flags.HasFlag(ShlRegFlags.Signed);
|
||||
bool saturating = flags.HasFlag(ShlRegFlags.Saturating);
|
||||
|
||||
OpCodeSimdShImm op = (OpCodeSimdShImm)context.CurrOp;
|
||||
|
||||
Operand res = context.VectorZero();
|
||||
|
||||
int elems = !scalar ? op.GetBytesCount() >> op.Size : 1;
|
||||
|
||||
for (int index = 0; index < elems; index++)
|
||||
{
|
||||
Operand ne = EmitVectorExtract(context, op.Rn, index, op.Size, signed);
|
||||
|
||||
Operand e = !saturating
|
||||
? EmitShlImm(context, ne, GetImmShl(op), op.Size)
|
||||
: EmitShlImmSatQ(context, ne, GetImmShl(op), op.Size, signed, signedDst);
|
||||
|
||||
res = EmitVectorInsert(context, res, e, index, op.Size);
|
||||
}
|
||||
|
||||
context.Copy(GetVec(op.Rd), res);
|
||||
}
|
||||
|
||||
private static Operand EmitShlImm(ArmEmitterContext context, Operand op, int shiftLsB, int size)
|
||||
{
|
||||
int eSize = 8 << size;
|
||||
|
||||
Debug.Assert(op.Type == OperandType.I64);
|
||||
Debug.Assert(eSize == 8 || eSize == 16 || eSize == 32 || eSize == 64);
|
||||
|
||||
Operand res = context.AllocateLocal(OperandType.I64);
|
||||
|
||||
if (shiftLsB >= eSize)
|
||||
{
|
||||
Operand shl = context.ShiftLeft(op, Const(shiftLsB));
|
||||
context.Copy(res, shl);
|
||||
}
|
||||
else
|
||||
{
|
||||
Operand zeroL = Const(0L);
|
||||
context.Copy(res, zeroL);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
private static Operand EmitShlImmSatQ(ArmEmitterContext context, Operand op, int shiftLsB, int size, bool signedSrc, bool signedDst)
|
||||
{
|
||||
int eSize = 8 << size;
|
||||
|
||||
Debug.Assert(op.Type == OperandType.I64);
|
||||
Debug.Assert(eSize == 8 || eSize == 16 || eSize == 32 || eSize == 64);
|
||||
|
||||
Operand lblEnd = Label();
|
||||
|
||||
Operand res = context.Copy(context.AllocateLocal(OperandType.I64), op);
|
||||
|
||||
if (shiftLsB >= eSize)
|
||||
{
|
||||
context.Copy(res, signedSrc
|
||||
? EmitSignedSignSatQ(context, op, size)
|
||||
: EmitUnsignedSignSatQ(context, op, size));
|
||||
}
|
||||
else
|
||||
{
|
||||
Operand shl = context.ShiftLeft(op, Const(shiftLsB));
|
||||
if (eSize == 64)
|
||||
{
|
||||
Operand sarOrShr = signedSrc
|
||||
? context.ShiftRightSI(shl, Const(shiftLsB))
|
||||
: context.ShiftRightUI(shl, Const(shiftLsB));
|
||||
context.Copy(res, shl);
|
||||
context.BranchIf(lblEnd, sarOrShr, op, Comparison.Equal);
|
||||
context.Copy(res, signedSrc
|
||||
? EmitSignedSignSatQ(context, op, size)
|
||||
: EmitUnsignedSignSatQ(context, op, size));
|
||||
}
|
||||
else
|
||||
{
|
||||
context.Copy(res, signedSrc
|
||||
? EmitSignedSrcSatQ(context, shl, size, signedDst)
|
||||
: EmitUnsignedSrcSatQ(context, shl, size, signedDst));
|
||||
}
|
||||
}
|
||||
|
||||
context.MarkLabel(lblEnd);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
private static void EmitShlRegOp(ArmEmitterContext context, ShlRegFlags flags = ShlRegFlags.None)
|
||||
{
|
||||
bool scalar = flags.HasFlag(ShlRegFlags.Scalar);
|
||||
|
@ -384,7 +384,9 @@ namespace ARMeilleure.Instructions
|
||||
Sqrshrn_V,
|
||||
Sqrshrun_S,
|
||||
Sqrshrun_V,
|
||||
Sqshl_Si,
|
||||
Sqshl_V,
|
||||
Sqshl_Vi,
|
||||
Sqshrn_S,
|
||||
Sqshrn_V,
|
||||
Sqshrun_S,
|
||||
@ -635,6 +637,7 @@ namespace ARMeilleure.Instructions
|
||||
Vorn,
|
||||
Vorr,
|
||||
Vpadd,
|
||||
Vpadal,
|
||||
Vpaddl,
|
||||
Vpmax,
|
||||
Vpmin,
|
||||
@ -654,6 +657,7 @@ namespace ARMeilleure.Instructions
|
||||
Vrintm,
|
||||
Vrintn,
|
||||
Vrintp,
|
||||
Vrintr,
|
||||
Vrintx,
|
||||
Vrshr,
|
||||
Vrshrn,
|
||||
|
@ -12,7 +12,6 @@ using Ryujinx.Ui.Common.Configuration;
|
||||
using Ryujinx.Ui.Common.Helper;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.Ava
|
||||
{
|
||||
@ -90,8 +89,6 @@ namespace Ryujinx.Ava
|
||||
try
|
||||
{
|
||||
string baseStyle = ConfigurationState.Instance.Ui.BaseStyle;
|
||||
string themePath = ConfigurationState.Instance.Ui.CustomThemePath;
|
||||
bool enableCustomTheme = ConfigurationState.Instance.Ui.EnableCustomTheme;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(baseStyle))
|
||||
{
|
||||
@ -106,24 +103,6 @@ namespace Ryujinx.Ava
|
||||
"Dark" => ThemeVariant.Dark,
|
||||
_ => ThemeVariant.Default,
|
||||
};
|
||||
|
||||
if (enableCustomTheme)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(themePath))
|
||||
{
|
||||
try
|
||||
{
|
||||
var themeContent = File.ReadAllText(themePath);
|
||||
var customStyle = AvaloniaRuntimeXamlLoader.Parse<IStyle>(themeContent);
|
||||
|
||||
Styles.Add(customStyle);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Error?.Print(LogClass.Application, $"Failed to Apply Custom Theme. Error: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
@ -978,7 +978,7 @@ namespace Ryujinx.Ava
|
||||
ConfigurationState.Instance.Graphics.AspectRatio.Value.ToText(),
|
||||
LocaleManager.Instance[LocaleKeys.Game] + $": {Device.Statistics.GetGameFrameRate():00.00} FPS ({Device.Statistics.GetGameFrameTime():00.00} ms)",
|
||||
$"FIFO: {Device.Statistics.GetFifoPercent():00.00} %",
|
||||
$"GPU: {_renderer.GetHardwareInfo().GpuVendor}"));
|
||||
$"GPU: {_renderer.GetHardwareInfo().GpuDriver}"));
|
||||
}
|
||||
|
||||
public async Task ShowExitPrompt()
|
||||
|
@ -54,8 +54,6 @@
|
||||
"GameListContextMenuManageTitleUpdatesToolTip": "Opens the Title Update management window",
|
||||
"GameListContextMenuManageDlc": "Manage DLC",
|
||||
"GameListContextMenuManageDlcToolTip": "Opens the DLC management window",
|
||||
"GameListContextMenuOpenModsDirectory": "Open Mods Directory",
|
||||
"GameListContextMenuOpenModsDirectoryToolTip": "Opens the directory which contains Application's Mods",
|
||||
"GameListContextMenuCacheManagement": "Cache Management",
|
||||
"GameListContextMenuCacheManagementPurgePptc": "Queue PPTC Rebuild",
|
||||
"GameListContextMenuCacheManagementPurgePptcToolTip": "Trigger PPTC to rebuild at boot time on the next game launch",
|
||||
@ -74,6 +72,7 @@
|
||||
"GameListContextMenuExtractDataLogoToolTip": "Extract the Logo section from Application's current config (including updates)",
|
||||
"GameListContextMenuCreateShortcut": "Create Application Shortcut",
|
||||
"GameListContextMenuCreateShortcutToolTip": "Create a Desktop Shortcut that launches the selected Application",
|
||||
"GameListContextMenuCreateShortcutToolTipMacOS": "Create a shortcut in macOS's Applications folder that launches the selected Application",
|
||||
"StatusBarGamesLoaded": "{0}/{1} Games Loaded",
|
||||
"StatusBarSystemVersion": "System Version: {0}",
|
||||
"LinuxVmMaxMapCountDialogTitle": "Low limit for memory mappings detected",
|
||||
@ -294,13 +293,9 @@
|
||||
"GameListContextMenuRunApplication": "Run Application",
|
||||
"GameListContextMenuToggleFavorite": "Toggle Favorite",
|
||||
"GameListContextMenuToggleFavoriteToolTip": "Toggle Favorite status of Game",
|
||||
"SettingsTabGeneralTheme": "Theme",
|
||||
"SettingsTabGeneralThemeCustomTheme": "Custom Theme Path",
|
||||
"SettingsTabGeneralThemeBaseStyle": "Base Style",
|
||||
"SettingsTabGeneralThemeBaseStyleDark": "Dark",
|
||||
"SettingsTabGeneralThemeBaseStyleLight": "Light",
|
||||
"SettingsTabGeneralThemeEnableCustomTheme": "Enable Custom Theme",
|
||||
"ButtonBrowse": "Browse",
|
||||
"SettingsTabGeneralTheme": "Theme:",
|
||||
"SettingsTabGeneralThemeDark": "Dark",
|
||||
"SettingsTabGeneralThemeLight": "Light",
|
||||
"ControllerSettingsConfigureGeneral": "Configure",
|
||||
"ControllerSettingsRumble": "Rumble",
|
||||
"ControllerSettingsRumbleStrongMultiplier": "Strong Rumble Multiplier",
|
||||
@ -387,7 +382,10 @@
|
||||
"DialogUserProfileUnsavedChangesSubMessage": "Do you want to discard your changes?",
|
||||
"DialogControllerSettingsModifiedConfirmMessage": "The current controller settings has been updated.",
|
||||
"DialogControllerSettingsModifiedConfirmSubMessage": "Do you want to save?",
|
||||
"DialogLoadNcaErrorMessage": "{0}. Errored File: {1}",
|
||||
"DialogLoadFileErrorMessage": "{0}. Errored File: {1}",
|
||||
"DialogModAlreadyExistsMessage": "Mod already exists",
|
||||
"DialogModInvalidMessage": "The specified directory does not contain a mod!",
|
||||
"DialogModDeleteNoParentMessage": "Failed to Delete: Could not find the parent directory for mod \"{0}\"!",
|
||||
"DialogDlcNoDlcErrorMessage": "The specified file does not contain a DLC for the selected title!",
|
||||
"DialogPerformanceCheckLoggingEnabledMessage": "You have trace logging enabled, which is designed to be used by developers only.",
|
||||
"DialogPerformanceCheckLoggingEnabledConfirmMessage": "For optimal performance, it's recommended to disable trace logging. Would you like to disable trace logging now?",
|
||||
@ -398,6 +396,8 @@
|
||||
"DialogUpdateAddUpdateErrorMessage": "The specified file does not contain an update for the selected title!",
|
||||
"DialogSettingsBackendThreadingWarningTitle": "Warning - Backend Threading",
|
||||
"DialogSettingsBackendThreadingWarningMessage": "Ryujinx must be restarted after changing this option for it to apply fully. Depending on your platform, you may need to manually disable your driver's own multithreading when using Ryujinx's.",
|
||||
"DialogModManagerDeletionWarningMessage": "You are about to delete the mod: {0}\n\nAre you sure you want to proceed?",
|
||||
"DialogModManagerDeletionAllWarningMessage": "You are about to delete all mods for this title.\n\nAre you sure you want to proceed?",
|
||||
"SettingsTabGraphicsFeaturesOptions": "Features",
|
||||
"SettingsTabGraphicsBackendMultithreading": "Graphics Backend Multithreading:",
|
||||
"CommonAuto": "Auto",
|
||||
@ -432,6 +432,7 @@
|
||||
"DlcManagerRemoveAllButton": "Remove All",
|
||||
"DlcManagerEnableAllButton": "Enable All",
|
||||
"DlcManagerDisableAllButton": "Disable All",
|
||||
"ModManagerDeleteAllButton": "Delete All",
|
||||
"MenuBarOptionsChangeLanguage": "Change Language",
|
||||
"MenuBarShowFileTypes": "Show File Types",
|
||||
"CommonSort": "Sort",
|
||||
@ -506,6 +507,8 @@
|
||||
"EnableInternetAccessTooltip": "Allows the emulated application to connect to the Internet.\n\nGames with a LAN mode can connect to each other when this is enabled and the systems are connected to the same access point. This includes real consoles as well.\n\nDoes NOT allow connecting to Nintendo servers. May cause crashing in certain games that try to connect to the Internet.\n\nLeave OFF if unsure.",
|
||||
"GameListContextMenuManageCheatToolTip": "Manage Cheats",
|
||||
"GameListContextMenuManageCheat": "Manage Cheats",
|
||||
"GameListContextMenuManageModToolTip": "Manage Mods",
|
||||
"GameListContextMenuManageMod": "Manage Mods",
|
||||
"ControllerSettingsStickRange": "Range:",
|
||||
"DialogStopEmulationTitle": "Ryujinx - Stop Emulation",
|
||||
"DialogStopEmulationMessage": "Are you sure you want to stop emulation?",
|
||||
@ -517,8 +520,6 @@
|
||||
"SettingsTabCpuMemory": "CPU Mode",
|
||||
"DialogUpdaterFlatpakNotSupportedMessage": "Please update Ryujinx via FlatHub.",
|
||||
"UpdaterDisabledWarningTitle": "Updater Disabled!",
|
||||
"GameListContextMenuOpenSdModsDirectory": "Open Atmosphere Mods Directory",
|
||||
"GameListContextMenuOpenSdModsDirectoryToolTip": "Opens the alternative SD card Atmosphere directory which contains Application's Mods. Useful for mods that are packaged for real hardware.",
|
||||
"ControllerSettingsRotate90": "Rotate 90° Clockwise",
|
||||
"IconSize": "Icon Size",
|
||||
"IconSizeTooltip": "Change the size of game icons",
|
||||
@ -590,6 +591,7 @@
|
||||
"Writable": "Writable",
|
||||
"SelectDlcDialogTitle": "Select DLC files",
|
||||
"SelectUpdateDialogTitle": "Select update files",
|
||||
"SelectModDialogTitle": "Select mod directory",
|
||||
"UserProfileWindowTitle": "User Profiles Manager",
|
||||
"CheatWindowTitle": "Cheats Manager",
|
||||
"DlcWindowTitle": "Manage Downloadable Content for {0} ({1})",
|
||||
@ -597,6 +599,7 @@
|
||||
"CheatWindowHeading": "Cheats Available for {0} [{1}]",
|
||||
"BuildId": "BuildId:",
|
||||
"DlcWindowHeading": "{0} Downloadable Content(s)",
|
||||
"ModWindowHeading": "{0} Mod(s)",
|
||||
"UserProfilesEditProfile": "Edit Selected",
|
||||
"Cancel": "Cancel",
|
||||
"Save": "Save",
|
||||
|
@ -665,7 +665,7 @@ namespace Ryujinx.Modules
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Program.Version.Contains("dirty") || !ReleaseInformation.IsValid())
|
||||
if (Program.Version.Contains("dirty") || !ReleaseInformation.IsValid)
|
||||
{
|
||||
if (showWarnings)
|
||||
{
|
||||
@ -683,7 +683,7 @@ namespace Ryujinx.Modules
|
||||
#else
|
||||
if (showWarnings)
|
||||
{
|
||||
if (ReleaseInformation.IsFlatHubBuild())
|
||||
if (ReleaseInformation.IsFlatHubBuild)
|
||||
{
|
||||
Dispatcher.UIThread.InvokeAsync(() =>
|
||||
ContentDialogHelper.CreateWarningDialog(
|
||||
|
@ -35,7 +35,7 @@ namespace Ryujinx.Ava
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
Version = ReleaseInformation.GetVersion();
|
||||
Version = ReleaseInformation.Version;
|
||||
|
||||
if (OperatingSystem.IsWindows() && !OperatingSystem.IsWindowsVersionAtLeast(10, 0, 17134))
|
||||
{
|
||||
@ -125,8 +125,8 @@ namespace Ryujinx.Ava
|
||||
|
||||
public static void ReloadConfig()
|
||||
{
|
||||
string localConfigurationPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config.json");
|
||||
string appDataConfigurationPath = Path.Combine(AppDataManager.BaseDirPath, "Config.json");
|
||||
string localConfigurationPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ReleaseInformation.ConfigName);
|
||||
string appDataConfigurationPath = Path.Combine(AppDataManager.BaseDirPath, ReleaseInformation.ConfigName);
|
||||
|
||||
// Now load the configuration as the other subsystems are now registered
|
||||
if (File.Exists(localConfigurationPath))
|
||||
|
@ -9,6 +9,7 @@ using Ryujinx.Ava.UI.Windows;
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.HLE.HOS.Applets;
|
||||
using Ryujinx.HLE.HOS.Services.Hid;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@ -103,7 +104,7 @@ namespace Ryujinx.Ava.UI.Applet
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(path))
|
||||
{
|
||||
SvgSource source = new();
|
||||
SvgSource source = new(default(Uri));
|
||||
|
||||
source.Load(EmbeddedResources.GetStream(path));
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
Click="CreateApplicationShortcut_Click"
|
||||
Header="{locale:Locale GameListContextMenuCreateShortcut}"
|
||||
IsEnabled="{Binding CreateShortcutEnabled}"
|
||||
ToolTip.Tip="{locale:Locale GameListContextMenuCreateShortcutToolTip}" />
|
||||
ToolTip.Tip="{OnPlatform Default={locale:Locale GameListContextMenuCreateShortcutToolTip}, macOS={locale:Locale GameListContextMenuCreateShortcutToolTipMacOS}}" />
|
||||
<Separator />
|
||||
<MenuItem
|
||||
Click="OpenUserSaveDirectory_Click"
|
||||
@ -47,13 +47,9 @@
|
||||
Header="{locale:Locale GameListContextMenuManageCheat}"
|
||||
ToolTip.Tip="{locale:Locale GameListContextMenuManageCheatToolTip}" />
|
||||
<MenuItem
|
||||
Click="OpenModsDirectory_Click"
|
||||
Header="{locale:Locale GameListContextMenuOpenModsDirectory}"
|
||||
ToolTip.Tip="{locale:Locale GameListContextMenuOpenModsDirectoryToolTip}" />
|
||||
<MenuItem
|
||||
Click="OpenSdModsDirectory_Click"
|
||||
Header="{locale:Locale GameListContextMenuOpenSdModsDirectory}"
|
||||
ToolTip.Tip="{locale:Locale GameListContextMenuOpenSdModsDirectoryToolTip}" />
|
||||
Click="OpenModManager_Click"
|
||||
Header="{locale:Locale GameListContextMenuManageMod}"
|
||||
ToolTip.Tip="{locale:Locale GameListContextMenuManageModToolTip}" />
|
||||
<Separator />
|
||||
<MenuItem Header="{locale:Locale GameListContextMenuCacheManagement}">
|
||||
<MenuItem
|
||||
|
@ -126,29 +126,13 @@ namespace Ryujinx.Ava.UI.Controls
|
||||
}
|
||||
}
|
||||
|
||||
public void OpenModsDirectory_Click(object sender, RoutedEventArgs args)
|
||||
public async void OpenModManager_Click(object sender, RoutedEventArgs args)
|
||||
{
|
||||
var viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
|
||||
|
||||
if (viewModel?.SelectedApplication != null)
|
||||
{
|
||||
string modsBasePath = ModLoader.GetModsBasePath();
|
||||
string titleModsPath = ModLoader.GetTitleDir(modsBasePath, viewModel.SelectedApplication.TitleId);
|
||||
|
||||
OpenHelper.OpenFolder(titleModsPath);
|
||||
}
|
||||
}
|
||||
|
||||
public void OpenSdModsDirectory_Click(object sender, RoutedEventArgs args)
|
||||
{
|
||||
var viewModel = (sender as MenuItem)?.DataContext as MainWindowViewModel;
|
||||
|
||||
if (viewModel?.SelectedApplication != null)
|
||||
{
|
||||
string sdModsBasePath = ModLoader.GetSdModsBasePath();
|
||||
string titleModsPath = ModLoader.GetTitleDir(sdModsBasePath, viewModel.SelectedApplication.TitleId);
|
||||
|
||||
OpenHelper.OpenFolder(titleModsPath);
|
||||
await ModManagerWindow.Show(ulong.Parse(viewModel.SelectedApplication.TitleId, NumberStyles.HexNumber), viewModel.SelectedApplication.TitleName);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -388,6 +388,7 @@ namespace Ryujinx.Ava.UI.Helpers
|
||||
{
|
||||
_contentDialogOverlayWindow.Content = null;
|
||||
_contentDialogOverlayWindow.Close();
|
||||
_contentDialogOverlayWindow = null;
|
||||
}
|
||||
|
||||
return result;
|
||||
|
32
src/Ryujinx.Ava/UI/Models/ModModel.cs
Normal file
32
src/Ryujinx.Ava/UI/Models/ModModel.cs
Normal file
@ -0,0 +1,32 @@
|
||||
using Ryujinx.Ava.UI.ViewModels;
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.Ava.UI.Models
|
||||
{
|
||||
public class ModModel : BaseModel
|
||||
{
|
||||
private bool _enabled;
|
||||
|
||||
public bool Enabled
|
||||
{
|
||||
get => _enabled;
|
||||
set
|
||||
{
|
||||
_enabled = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public bool InSd { get; }
|
||||
public string Path { get; }
|
||||
public string Name { get; }
|
||||
|
||||
public ModModel(string path, string name, bool enabled, bool inSd)
|
||||
{
|
||||
Path = path;
|
||||
Name = name;
|
||||
Enabled = enabled;
|
||||
InSd = inSd;
|
||||
}
|
||||
}
|
||||
}
|
@ -180,7 +180,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(_controllerImage))
|
||||
{
|
||||
SvgSource source = new();
|
||||
SvgSource source = new(default(Uri));
|
||||
|
||||
source.Load(EmbeddedResources.GetStream(_controllerImage));
|
||||
|
||||
|
@ -39,6 +39,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
|
||||
private string _search;
|
||||
private readonly ulong _titleId;
|
||||
private readonly IStorageProvider _storageProvider;
|
||||
|
||||
private static readonly DownloadableContentJsonSerializerContext _serializerContext = new(JsonHelper.GetDefaultSerializerOptions());
|
||||
|
||||
@ -90,8 +91,6 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
get => string.Format(LocaleManager.Instance[LocaleKeys.DlcWindowHeading], DownloadableContents.Count);
|
||||
}
|
||||
|
||||
public IStorageProvider StorageProvider;
|
||||
|
||||
public DownloadableContentManagerViewModel(VirtualFileSystem virtualFileSystem, ulong titleId)
|
||||
{
|
||||
_virtualFileSystem = virtualFileSystem;
|
||||
@ -100,7 +99,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
|
||||
if (Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||
{
|
||||
StorageProvider = desktop.MainWindow.StorageProvider;
|
||||
_storageProvider = desktop.MainWindow.StorageProvider;
|
||||
}
|
||||
|
||||
_downloadableContentJsonPath = Path.Combine(AppDataManager.GamesDirPath, titleId.ToString("x16"), "dlc.json");
|
||||
@ -194,7 +193,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
{
|
||||
Dispatcher.UIThread.InvokeAsync(async () =>
|
||||
{
|
||||
await ContentDialogHelper.CreateErrorDialog(string.Format(LocaleManager.Instance[LocaleKeys.DialogLoadNcaErrorMessage], ex.Message, containerPath));
|
||||
await ContentDialogHelper.CreateErrorDialog(string.Format(LocaleManager.Instance[LocaleKeys.DialogLoadFileErrorMessage], ex.Message, containerPath));
|
||||
});
|
||||
}
|
||||
|
||||
@ -203,7 +202,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
|
||||
public async void Add()
|
||||
{
|
||||
var result = await StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
|
||||
var result = await _storageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
|
||||
{
|
||||
Title = LocaleManager.Instance[LocaleKeys.SelectDlcDialogTitle],
|
||||
AllowMultiple = true,
|
||||
|
@ -357,7 +357,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
|
||||
public bool OpenBcatSaveDirectoryEnabled => !SelectedApplication.ControlHolder.ByteSpan.IsZeros() && SelectedApplication.ControlHolder.Value.BcatDeliveryCacheStorageSize > 0;
|
||||
|
||||
public bool CreateShortcutEnabled => !ReleaseInformation.IsFlatHubBuild();
|
||||
public bool CreateShortcutEnabled => !ReleaseInformation.IsFlatHubBuild;
|
||||
|
||||
public string LoadHeading
|
||||
{
|
||||
@ -1350,7 +1350,12 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
|
||||
public void OpenLogsFolder()
|
||||
{
|
||||
string logPath = Path.Combine(ReleaseInformation.GetBaseApplicationDirectory(), "Logs");
|
||||
string logPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Logs");
|
||||
|
||||
if (LoggerModule.LogDirectoryPath != null)
|
||||
{
|
||||
logPath = LoggerModule.LogDirectoryPath;
|
||||
}
|
||||
|
||||
new DirectoryInfo(logPath).Create();
|
||||
|
||||
|
336
src/Ryujinx.Ava/UI/ViewModels/ModManagerViewModel.cs
Normal file
336
src/Ryujinx.Ava/UI/ViewModels/ModManagerViewModel.cs
Normal file
@ -0,0 +1,336 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Collections;
|
||||
using Avalonia.Controls.ApplicationLifetimes;
|
||||
using Avalonia.Platform.Storage;
|
||||
using Avalonia.Threading;
|
||||
using DynamicData;
|
||||
using Ryujinx.Ava.Common.Locale;
|
||||
using Ryujinx.Ava.UI.Helpers;
|
||||
using Ryujinx.Ava.UI.Models;
|
||||
using Ryujinx.Common.Configuration;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Common.Utilities;
|
||||
using Ryujinx.HLE.HOS;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace Ryujinx.Ava.UI.ViewModels
|
||||
{
|
||||
public class ModManagerViewModel : BaseModel
|
||||
{
|
||||
private readonly string _modJsonPath;
|
||||
|
||||
private AvaloniaList<ModModel> _mods = new();
|
||||
private AvaloniaList<ModModel> _views = new();
|
||||
private AvaloniaList<ModModel> _selectedMods = new();
|
||||
|
||||
private string _search;
|
||||
private readonly ulong _applicationId;
|
||||
private readonly IStorageProvider _storageProvider;
|
||||
|
||||
private static readonly ModMetadataJsonSerializerContext _serializerContext = new(JsonHelper.GetDefaultSerializerOptions());
|
||||
|
||||
public AvaloniaList<ModModel> Mods
|
||||
{
|
||||
get => _mods;
|
||||
set
|
||||
{
|
||||
_mods = value;
|
||||
OnPropertyChanged();
|
||||
OnPropertyChanged(nameof(ModCount));
|
||||
Sort();
|
||||
}
|
||||
}
|
||||
|
||||
public AvaloniaList<ModModel> Views
|
||||
{
|
||||
get => _views;
|
||||
set
|
||||
{
|
||||
_views = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public AvaloniaList<ModModel> SelectedMods
|
||||
{
|
||||
get => _selectedMods;
|
||||
set
|
||||
{
|
||||
_selectedMods = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public string Search
|
||||
{
|
||||
get => _search;
|
||||
set
|
||||
{
|
||||
_search = value;
|
||||
OnPropertyChanged();
|
||||
Sort();
|
||||
}
|
||||
}
|
||||
|
||||
public string ModCount
|
||||
{
|
||||
get => string.Format(LocaleManager.Instance[LocaleKeys.ModWindowHeading], Mods.Count);
|
||||
}
|
||||
|
||||
public ModManagerViewModel(ulong applicationId)
|
||||
{
|
||||
_applicationId = applicationId;
|
||||
|
||||
_modJsonPath = Path.Combine(AppDataManager.GamesDirPath, applicationId.ToString("x16"), "mods.json");
|
||||
|
||||
if (Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||
{
|
||||
_storageProvider = desktop.MainWindow.StorageProvider;
|
||||
}
|
||||
|
||||
LoadMods(applicationId);
|
||||
}
|
||||
|
||||
private void LoadMods(ulong applicationId)
|
||||
{
|
||||
Mods.Clear();
|
||||
SelectedMods.Clear();
|
||||
|
||||
string[] modsBasePaths = [ModLoader.GetSdModsBasePath(), ModLoader.GetModsBasePath()];
|
||||
|
||||
foreach (var path in modsBasePaths)
|
||||
{
|
||||
var inSd = path == ModLoader.GetSdModsBasePath();
|
||||
var modCache = new ModLoader.ModCache();
|
||||
|
||||
ModLoader.QueryContentsDir(modCache, new DirectoryInfo(Path.Combine(path, "contents")), applicationId);
|
||||
|
||||
foreach (var mod in modCache.RomfsDirs)
|
||||
{
|
||||
var modModel = new ModModel(mod.Path.Parent.FullName, mod.Name, mod.Enabled, inSd);
|
||||
if (Mods.All(x => x.Path != mod.Path.Parent.FullName))
|
||||
{
|
||||
Mods.Add(modModel);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var mod in modCache.RomfsContainers)
|
||||
{
|
||||
Mods.Add(new ModModel(mod.Path.FullName, mod.Name, mod.Enabled, inSd));
|
||||
}
|
||||
|
||||
foreach (var mod in modCache.ExefsDirs)
|
||||
{
|
||||
var modModel = new ModModel(mod.Path.Parent.FullName, mod.Name, mod.Enabled, inSd);
|
||||
if (Mods.All(x => x.Path != mod.Path.Parent.FullName))
|
||||
{
|
||||
Mods.Add(modModel);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var mod in modCache.ExefsContainers)
|
||||
{
|
||||
Mods.Add(new ModModel(mod.Path.FullName, mod.Name, mod.Enabled, inSd));
|
||||
}
|
||||
}
|
||||
|
||||
Sort();
|
||||
}
|
||||
|
||||
public void Sort()
|
||||
{
|
||||
Mods.AsObservableChangeSet()
|
||||
.Filter(Filter)
|
||||
.Bind(out var view).AsObservableList();
|
||||
|
||||
_views.Clear();
|
||||
_views.AddRange(view);
|
||||
|
||||
SelectedMods = new(Views.Where(x => x.Enabled));
|
||||
|
||||
OnPropertyChanged(nameof(ModCount));
|
||||
OnPropertyChanged(nameof(Views));
|
||||
OnPropertyChanged(nameof(SelectedMods));
|
||||
}
|
||||
|
||||
private bool Filter(object arg)
|
||||
{
|
||||
if (arg is ModModel content)
|
||||
{
|
||||
return string.IsNullOrWhiteSpace(_search) || content.Name.ToLower().Contains(_search.ToLower());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
ModMetadata modData = new();
|
||||
|
||||
foreach (ModModel mod in Mods)
|
||||
{
|
||||
modData.Mods.Add(new Mod
|
||||
{
|
||||
Name = mod.Name,
|
||||
Path = mod.Path,
|
||||
Enabled = SelectedMods.Contains(mod),
|
||||
});
|
||||
}
|
||||
|
||||
JsonHelper.SerializeToFile(_modJsonPath, modData, _serializerContext.ModMetadata);
|
||||
}
|
||||
|
||||
public void Delete(ModModel model)
|
||||
{
|
||||
var isSubdir = true;
|
||||
var pathToDelete = model.Path;
|
||||
var basePath = model.InSd ? ModLoader.GetSdModsBasePath() : ModLoader.GetModsBasePath();
|
||||
var modsDir = ModLoader.GetApplicationDir(basePath, _applicationId.ToString("x16"));
|
||||
|
||||
if (new DirectoryInfo(model.Path).Parent?.FullName == modsDir)
|
||||
{
|
||||
isSubdir = false;
|
||||
}
|
||||
|
||||
if (isSubdir)
|
||||
{
|
||||
var parentDir = String.Empty;
|
||||
|
||||
foreach (var dir in Directory.GetDirectories(modsDir, "*", SearchOption.TopDirectoryOnly))
|
||||
{
|
||||
if (Directory.GetDirectories(dir, "*", SearchOption.AllDirectories).Contains(model.Path))
|
||||
{
|
||||
parentDir = dir;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (parentDir == String.Empty)
|
||||
{
|
||||
Dispatcher.UIThread.Post(async () =>
|
||||
{
|
||||
await ContentDialogHelper.CreateErrorDialog(LocaleManager.Instance.UpdateAndGetDynamicValue(
|
||||
LocaleKeys.DialogModDeleteNoParentMessage,
|
||||
model.Path));
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Logger.Info?.Print(LogClass.Application, $"Deleting mod at \"{pathToDelete}\"");
|
||||
Directory.Delete(pathToDelete, true);
|
||||
|
||||
Mods.Remove(model);
|
||||
OnPropertyChanged(nameof(ModCount));
|
||||
Sort();
|
||||
}
|
||||
|
||||
private void AddMod(DirectoryInfo directory)
|
||||
{
|
||||
string[] directories;
|
||||
|
||||
try
|
||||
{
|
||||
directories = Directory.GetDirectories(directory.ToString(), "*", SearchOption.AllDirectories);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Dispatcher.UIThread.Post(async () =>
|
||||
{
|
||||
await ContentDialogHelper.CreateErrorDialog(LocaleManager.Instance.UpdateAndGetDynamicValue(
|
||||
LocaleKeys.DialogLoadFileErrorMessage,
|
||||
exception.ToString(),
|
||||
directory));
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
var destinationDir = ModLoader.GetApplicationDir(ModLoader.GetSdModsBasePath(), _applicationId.ToString("x16"));
|
||||
|
||||
// TODO: More robust checking for valid mod folders
|
||||
var isDirectoryValid = true;
|
||||
|
||||
if (directories.Length == 0)
|
||||
{
|
||||
isDirectoryValid = false;
|
||||
}
|
||||
|
||||
if (!isDirectoryValid)
|
||||
{
|
||||
Dispatcher.UIThread.Post(async () =>
|
||||
{
|
||||
await ContentDialogHelper.CreateErrorDialog(LocaleManager.Instance[LocaleKeys.DialogModInvalidMessage]);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var dir in directories)
|
||||
{
|
||||
string dirToCreate = dir.Replace(directory.Parent.ToString(), destinationDir);
|
||||
|
||||
// Mod already exists
|
||||
if (Directory.Exists(dirToCreate))
|
||||
{
|
||||
Dispatcher.UIThread.Post(async () =>
|
||||
{
|
||||
await ContentDialogHelper.CreateErrorDialog(LocaleManager.Instance.UpdateAndGetDynamicValue(
|
||||
LocaleKeys.DialogLoadFileErrorMessage,
|
||||
LocaleManager.Instance[LocaleKeys.DialogModAlreadyExistsMessage],
|
||||
dirToCreate));
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Directory.CreateDirectory(dirToCreate);
|
||||
}
|
||||
|
||||
var files = Directory.GetFiles(directory.ToString(), "*", SearchOption.AllDirectories);
|
||||
|
||||
foreach (var file in files)
|
||||
{
|
||||
File.Copy(file, file.Replace(directory.Parent.ToString(), destinationDir), true);
|
||||
}
|
||||
|
||||
LoadMods(_applicationId);
|
||||
}
|
||||
|
||||
public async void Add()
|
||||
{
|
||||
var result = await _storageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions
|
||||
{
|
||||
Title = LocaleManager.Instance[LocaleKeys.SelectModDialogTitle],
|
||||
AllowMultiple = true,
|
||||
});
|
||||
|
||||
foreach (var folder in result)
|
||||
{
|
||||
AddMod(new DirectoryInfo(folder.Path.LocalPath));
|
||||
}
|
||||
}
|
||||
|
||||
public void DeleteAll()
|
||||
{
|
||||
foreach (var mod in Mods)
|
||||
{
|
||||
Delete(mod);
|
||||
}
|
||||
|
||||
Mods.Clear();
|
||||
OnPropertyChanged(nameof(ModCount));
|
||||
Sort();
|
||||
}
|
||||
|
||||
public void EnableAll()
|
||||
{
|
||||
SelectedMods = new(Mods);
|
||||
}
|
||||
|
||||
public void DisableAll()
|
||||
{
|
||||
SelectedMods.Clear();
|
||||
}
|
||||
}
|
||||
}
|
@ -48,7 +48,6 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
private readonly List<string> _gpuIds = new();
|
||||
private KeyboardHotkeys _keyboardHotkeys;
|
||||
private int _graphicsBackendIndex;
|
||||
private string _customThemePath;
|
||||
private int _scalingFilter;
|
||||
private int _scalingFilterLevel;
|
||||
|
||||
@ -160,7 +159,6 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
public bool IsOpenAlEnabled { get; set; }
|
||||
public bool IsSoundIoEnabled { get; set; }
|
||||
public bool IsSDL2Enabled { get; set; }
|
||||
public bool EnableCustomTheme { get; set; }
|
||||
public bool IsCustomResolutionScaleActive => _resolutionScale == 4;
|
||||
public bool IsScalingFilterActive => _scalingFilter == (int)Ryujinx.Common.Configuration.ScalingFilter.Fsr;
|
||||
|
||||
@ -170,20 +168,6 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
public string TimeZone { get; set; }
|
||||
public string ShaderDumpPath { get; set; }
|
||||
|
||||
public string CustomThemePath
|
||||
{
|
||||
get
|
||||
{
|
||||
return _customThemePath;
|
||||
}
|
||||
set
|
||||
{
|
||||
_customThemePath = value;
|
||||
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public int Language { get; set; }
|
||||
public int Region { get; set; }
|
||||
public int FsGlobalAccessLogMode { get; set; }
|
||||
@ -426,8 +410,6 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
GameDirectories.Clear();
|
||||
GameDirectories.AddRange(config.Ui.GameDirs.Value);
|
||||
|
||||
EnableCustomTheme = config.Ui.EnableCustomTheme;
|
||||
CustomThemePath = config.Ui.CustomThemePath;
|
||||
BaseStyleIndex = config.Ui.BaseStyle == "Light" ? 0 : 1;
|
||||
|
||||
// Input
|
||||
@ -515,8 +497,6 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
config.Ui.GameDirs.Value = gameDirs;
|
||||
}
|
||||
|
||||
config.Ui.EnableCustomTheme.Value = EnableCustomTheme;
|
||||
config.Ui.CustomThemePath.Value = CustomThemePath;
|
||||
config.Ui.BaseStyle.Value = BaseStyleIndex == 0 ? "Light" : "Dark";
|
||||
|
||||
// Input
|
||||
|
@ -192,7 +192,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Dispatcher.UIThread.InvokeAsync(() => ContentDialogHelper.CreateErrorDialog(LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.DialogLoadNcaErrorMessage, ex.Message, path)));
|
||||
Dispatcher.UIThread.InvokeAsync(() => ContentDialogHelper.CreateErrorDialog(LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.DialogLoadFileErrorMessage, ex.Message, path)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@
|
||||
<CheckBox IsChecked="{Binding ShowConfirmExit}">
|
||||
<TextBlock Text="{locale:Locale SettingsTabGeneralShowConfirmExitDialog}" />
|
||||
</CheckBox>
|
||||
<StackPanel Margin="0, 15, 0, 10" Orientation="Horizontal">
|
||||
<StackPanel Margin="0, 15, 0, 0" Orientation="Horizontal">
|
||||
<TextBlock VerticalAlignment="Center"
|
||||
Text="{locale:Locale SettingsTabGeneralHideCursor}"
|
||||
Width="150" />
|
||||
@ -54,6 +54,22 @@
|
||||
</ComboBoxItem>
|
||||
</ComboBox>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="0, 15, 0, 10" Orientation="Horizontal">
|
||||
<TextBlock
|
||||
VerticalAlignment="Center"
|
||||
Text="{locale:Locale SettingsTabGeneralTheme}"
|
||||
Width="150" />
|
||||
<ComboBox SelectedIndex="{Binding BaseStyleIndex}"
|
||||
HorizontalContentAlignment="Left"
|
||||
MinWidth="100">
|
||||
<ComboBoxItem>
|
||||
<TextBlock Text="{locale:Locale SettingsTabGeneralThemeLight}" />
|
||||
</ComboBoxItem>
|
||||
<ComboBoxItem>
|
||||
<TextBlock Text="{locale:Locale SettingsTabGeneralThemeDark}" />
|
||||
</ComboBoxItem>
|
||||
</ComboBox>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
<Separator Height="1" />
|
||||
<TextBlock Classes="h1" Text="{locale:Locale SettingsTabGeneralGameDirectories}" />
|
||||
@ -106,64 +122,6 @@
|
||||
</Button>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
<Separator Height="1" />
|
||||
<TextBlock Classes="h1" Text="{locale:Locale SettingsTabGeneralTheme}" />
|
||||
<Grid Margin="10,0,0,0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<CheckBox
|
||||
IsChecked="{Binding EnableCustomTheme}"
|
||||
ToolTip.Tip="{locale:Locale CustomThemeCheckTooltip}">
|
||||
<TextBlock Text="{locale:Locale SettingsTabGeneralThemeEnableCustomTheme}" />
|
||||
</CheckBox>
|
||||
<TextBlock
|
||||
Grid.Column="0"
|
||||
Grid.Row="1"
|
||||
VerticalAlignment="Center"
|
||||
Margin="0,10,0,0"
|
||||
Text="{locale:Locale SettingsTabGeneralThemeCustomTheme}"
|
||||
ToolTip.Tip="{locale:Locale CustomThemePathTooltip}" />
|
||||
<TextBox
|
||||
Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
Margin="0,10,0,0"
|
||||
Text="{Binding CustomThemePath}" />
|
||||
<Button
|
||||
Grid.Row="1"
|
||||
Grid.Column="2"
|
||||
Margin="10,10,0,0"
|
||||
Click="BrowseTheme"
|
||||
ToolTip.Tip="{locale:Locale CustomThemeBrowseTooltip}"
|
||||
Content="{locale:Locale ButtonBrowse}" />
|
||||
<TextBlock
|
||||
Grid.Column="0"
|
||||
Grid.Row="2"
|
||||
VerticalAlignment="Center"
|
||||
Margin="0,10,0,0"
|
||||
Text="{locale:Locale SettingsTabGeneralThemeBaseStyle}" />
|
||||
<ComboBox
|
||||
Grid.Column="1"
|
||||
Grid.Row="2"
|
||||
VerticalAlignment="Center"
|
||||
Margin="0,10,0,0"
|
||||
MinWidth="100"
|
||||
SelectedIndex="{Binding BaseStyleIndex}">
|
||||
<ComboBoxItem>
|
||||
<TextBlock Text="{locale:Locale SettingsTabGeneralThemeBaseStyleLight}" />
|
||||
</ComboBoxItem>
|
||||
<ComboBoxItem>
|
||||
<TextBlock Text="{locale:Locale SettingsTabGeneralThemeBaseStyleDark}" />
|
||||
</ComboBoxItem>
|
||||
</ComboBox>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</ScrollViewer>
|
||||
|
@ -61,29 +61,5 @@ namespace Ryujinx.Ava.UI.Views.Settings
|
||||
GameList.SelectedIndex = oldIndex < GameList.ItemCount ? oldIndex : 0;
|
||||
}
|
||||
}
|
||||
|
||||
public async void BrowseTheme(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var window = this.GetVisualRoot() as Window;
|
||||
var result = await window.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
|
||||
{
|
||||
Title = LocaleManager.Instance[LocaleKeys.SettingsSelectThemeFileDialogTitle],
|
||||
AllowMultiple = false,
|
||||
FileTypeFilter = new List<FilePickerFileType>
|
||||
{
|
||||
new("xml")
|
||||
{
|
||||
Patterns = new[] { "*.xaml" },
|
||||
AppleUniformTypeIdentifiers = new[] { "com.ryujinx.xaml" },
|
||||
MimeTypes = new[] { "application/xaml+xml" },
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (result.Count > 0)
|
||||
{
|
||||
ViewModel.CustomThemePath = result[0].Path.LocalPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ namespace Ryujinx.Ava.UI.Windows
|
||||
InitializeComponent();
|
||||
|
||||
string modsBasePath = ModLoader.GetModsBasePath();
|
||||
string titleModsPath = ModLoader.GetTitleDir(modsBasePath, titleId);
|
||||
string titleModsPath = ModLoader.GetApplicationDir(modsBasePath, titleId);
|
||||
ulong titleIdValue = ulong.Parse(titleId, NumberStyles.HexNumber);
|
||||
|
||||
_enabledCheatsPath = Path.Combine(titleModsPath, "cheats", "enabled.txt");
|
||||
|
@ -263,7 +263,7 @@ namespace Ryujinx.Ava.UI.Windows
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckLaunchState()
|
||||
private async Task CheckLaunchState()
|
||||
{
|
||||
if (OperatingSystem.IsLinux() && LinuxHelper.VmMaxMapCount < LinuxHelper.RecommendedVmMaxMapCount)
|
||||
{
|
||||
@ -271,23 +271,11 @@ namespace Ryujinx.Ava.UI.Windows
|
||||
|
||||
if (LinuxHelper.PkExecPath is not null)
|
||||
{
|
||||
Dispatcher.UIThread.Post(async () =>
|
||||
{
|
||||
if (OperatingSystem.IsLinux())
|
||||
{
|
||||
await ShowVmMaxMapCountDialog();
|
||||
}
|
||||
});
|
||||
await Dispatcher.UIThread.InvokeAsync(ShowVmMaxMapCountDialog);
|
||||
}
|
||||
else
|
||||
{
|
||||
Dispatcher.UIThread.Post(async () =>
|
||||
{
|
||||
if (OperatingSystem.IsLinux())
|
||||
{
|
||||
await ShowVmMaxMapCountWarning();
|
||||
}
|
||||
});
|
||||
await Dispatcher.UIThread.InvokeAsync(ShowVmMaxMapCountWarning);
|
||||
}
|
||||
}
|
||||
|
||||
@ -304,12 +292,12 @@ namespace Ryujinx.Ava.UI.Windows
|
||||
{
|
||||
ShowKeyErrorOnLoad = false;
|
||||
|
||||
Dispatcher.UIThread.Post(async () => await UserErrorDialog.ShowUserErrorDialog(UserError.NoKeys));
|
||||
await Dispatcher.UIThread.InvokeAsync(async () => await UserErrorDialog.ShowUserErrorDialog(UserError.NoKeys));
|
||||
}
|
||||
|
||||
if (ConfigurationState.Instance.CheckUpdatesOnStart.Value && Updater.CanUpdate(false))
|
||||
{
|
||||
Updater.BeginParse(this, false).ContinueWith(task =>
|
||||
await Updater.BeginParse(this, false).ContinueWith(task =>
|
||||
{
|
||||
Logger.Error?.Print(LogClass.Application, $"Updater Error: {task.Exception}");
|
||||
}, TaskContinuationOptions.OnlyOnFaulted);
|
||||
@ -404,7 +392,9 @@ namespace Ryujinx.Ava.UI.Windows
|
||||
|
||||
LoadApplications();
|
||||
|
||||
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
||||
CheckLaunchState();
|
||||
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
||||
}
|
||||
|
||||
private void SetMainContent(Control content = null)
|
||||
|
179
src/Ryujinx.Ava/UI/Windows/ModManagerWindow.axaml
Normal file
179
src/Ryujinx.Ava/UI/Windows/ModManagerWindow.axaml
Normal file
@ -0,0 +1,179 @@
|
||||
<UserControl
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:locale="clr-namespace:Ryujinx.Ava.Common.Locale"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:viewModels="clr-namespace:Ryujinx.Ava.UI.ViewModels"
|
||||
xmlns:models="clr-namespace:Ryujinx.Ava.UI.Models"
|
||||
xmlns:ui="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
|
||||
Width="500"
|
||||
Height="380"
|
||||
mc:Ignorable="d"
|
||||
x:Class="Ryujinx.Ava.UI.Windows.ModManagerWindow"
|
||||
x:CompileBindings="True"
|
||||
x:DataType="viewModels:ModManagerViewModel"
|
||||
Focusable="True">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Panel
|
||||
Margin="0 0 0 10"
|
||||
Grid.Row="0">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock
|
||||
Grid.Column="0"
|
||||
Text="{Binding ModCount}" />
|
||||
<StackPanel
|
||||
Margin="10 0"
|
||||
Grid.Column="1"
|
||||
Orientation="Horizontal">
|
||||
<Button
|
||||
Name="EnableAllButton"
|
||||
MinWidth="90"
|
||||
Margin="5"
|
||||
Command="{ReflectionBinding EnableAll}">
|
||||
<TextBlock Text="{locale:Locale DlcManagerEnableAllButton}" />
|
||||
</Button>
|
||||
<Button
|
||||
Name="DisableAllButton"
|
||||
MinWidth="90"
|
||||
Margin="5"
|
||||
Command="{ReflectionBinding DisableAll}">
|
||||
<TextBlock Text="{locale:Locale DlcManagerDisableAllButton}" />
|
||||
</Button>
|
||||
</StackPanel>
|
||||
<TextBox
|
||||
Grid.Column="2"
|
||||
MinHeight="27"
|
||||
MaxHeight="27"
|
||||
HorizontalAlignment="Stretch"
|
||||
Watermark="{locale:Locale Search}"
|
||||
Text="{Binding Search}" />
|
||||
</Grid>
|
||||
</Panel>
|
||||
<Border
|
||||
Grid.Row="1"
|
||||
Margin="0 0 0 24"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
BorderBrush="{DynamicResource AppListHoverBackgroundColor}"
|
||||
BorderThickness="1"
|
||||
CornerRadius="5"
|
||||
Padding="2.5">
|
||||
<ListBox
|
||||
AutoScrollToSelectedItem="False"
|
||||
SelectionMode="Multiple, Toggle"
|
||||
Background="Transparent"
|
||||
SelectionChanged="OnSelectionChanged"
|
||||
SelectedItems="{Binding SelectedMods, Mode=TwoWay}"
|
||||
ItemsSource="{Binding Views}">
|
||||
<ListBox.DataTemplates>
|
||||
<DataTemplate
|
||||
DataType="models:ModModel">
|
||||
<Panel Margin="10">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
MaxLines="2"
|
||||
TextWrapping="Wrap"
|
||||
TextTrimming="CharacterEllipsis"
|
||||
Text="{Binding Name}" />
|
||||
<StackPanel
|
||||
Grid.Column="1"
|
||||
Spacing="10"
|
||||
Orientation="Horizontal"
|
||||
HorizontalAlignment="Right">
|
||||
<Button
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Right"
|
||||
Padding="10"
|
||||
MinWidth="0"
|
||||
MinHeight="0"
|
||||
Click="OpenLocation">
|
||||
<ui:SymbolIcon
|
||||
Symbol="OpenFolder"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center" />
|
||||
</Button>
|
||||
<Button
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Right"
|
||||
Padding="10"
|
||||
MinWidth="0"
|
||||
MinHeight="0"
|
||||
Click="DeleteMod">
|
||||
<ui:SymbolIcon
|
||||
Symbol="Cancel"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center" />
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Panel>
|
||||
</DataTemplate>
|
||||
</ListBox.DataTemplates>
|
||||
<ListBox.Styles>
|
||||
<Style Selector="ListBoxItem">
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
</Style>
|
||||
</ListBox.Styles>
|
||||
</ListBox>
|
||||
</Border>
|
||||
<Panel
|
||||
Grid.Row="2"
|
||||
HorizontalAlignment="Stretch">
|
||||
<StackPanel
|
||||
Orientation="Horizontal"
|
||||
Spacing="10"
|
||||
HorizontalAlignment="Left">
|
||||
<Button
|
||||
Name="AddButton"
|
||||
MinWidth="90"
|
||||
Margin="5"
|
||||
Command="{Binding Add}">
|
||||
<TextBlock Text="{locale:Locale SettingsTabGeneralAdd}" />
|
||||
</Button>
|
||||
<Button
|
||||
Name="RemoveAllButton"
|
||||
MinWidth="90"
|
||||
Margin="5"
|
||||
Click="DeleteAll">
|
||||
<TextBlock Text="{locale:Locale ModManagerDeleteAllButton}" />
|
||||
</Button>
|
||||
</StackPanel>
|
||||
<StackPanel
|
||||
Orientation="Horizontal"
|
||||
Spacing="10"
|
||||
HorizontalAlignment="Right">
|
||||
<Button
|
||||
Name="SaveButton"
|
||||
MinWidth="90"
|
||||
Margin="5"
|
||||
Click="SaveAndClose">
|
||||
<TextBlock Text="{locale:Locale SettingsButtonSave}" />
|
||||
</Button>
|
||||
<Button
|
||||
Name="CancelButton"
|
||||
MinWidth="90"
|
||||
Margin="5"
|
||||
Click="Close">
|
||||
<TextBlock Text="{locale:Locale InputDialogCancel}" />
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</Panel>
|
||||
</Grid>
|
||||
</UserControl>
|
139
src/Ryujinx.Ava/UI/Windows/ModManagerWindow.axaml.cs
Normal file
139
src/Ryujinx.Ava/UI/Windows/ModManagerWindow.axaml.cs
Normal file
@ -0,0 +1,139 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Styling;
|
||||
using FluentAvalonia.UI.Controls;
|
||||
using Ryujinx.Ava.Common.Locale;
|
||||
using Ryujinx.Ava.UI.Helpers;
|
||||
using Ryujinx.Ava.UI.Models;
|
||||
using Ryujinx.Ava.UI.ViewModels;
|
||||
using Ryujinx.Ui.Common.Helper;
|
||||
using System.Threading.Tasks;
|
||||
using Button = Avalonia.Controls.Button;
|
||||
|
||||
namespace Ryujinx.Ava.UI.Windows
|
||||
{
|
||||
public partial class ModManagerWindow : UserControl
|
||||
{
|
||||
public ModManagerViewModel ViewModel;
|
||||
|
||||
public ModManagerWindow()
|
||||
{
|
||||
DataContext = this;
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public ModManagerWindow(ulong titleId)
|
||||
{
|
||||
DataContext = ViewModel = new ModManagerViewModel(titleId);
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public static async Task Show(ulong titleId, string titleName)
|
||||
{
|
||||
ContentDialog contentDialog = new()
|
||||
{
|
||||
PrimaryButtonText = "",
|
||||
SecondaryButtonText = "",
|
||||
CloseButtonText = "",
|
||||
Content = new ModManagerWindow(titleId),
|
||||
Title = string.Format(LocaleManager.Instance[LocaleKeys.ModWindowHeading], titleName, titleId.ToString("X16")),
|
||||
};
|
||||
|
||||
Style bottomBorder = new(x => x.OfType<Grid>().Name("DialogSpace").Child().OfType<Border>());
|
||||
bottomBorder.Setters.Add(new Setter(IsVisibleProperty, false));
|
||||
|
||||
contentDialog.Styles.Add(bottomBorder);
|
||||
|
||||
await contentDialog.ShowAsync();
|
||||
}
|
||||
|
||||
private void SaveAndClose(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ViewModel.Save();
|
||||
((ContentDialog)Parent).Hide();
|
||||
}
|
||||
|
||||
private void Close(object sender, RoutedEventArgs e)
|
||||
{
|
||||
((ContentDialog)Parent).Hide();
|
||||
}
|
||||
|
||||
private async void DeleteMod(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (sender is Button button)
|
||||
{
|
||||
if (button.DataContext is ModModel model)
|
||||
{
|
||||
var result = await ContentDialogHelper.CreateConfirmationDialog(
|
||||
LocaleManager.Instance[LocaleKeys.DialogWarning],
|
||||
LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.DialogModManagerDeletionWarningMessage, model.Name),
|
||||
LocaleManager.Instance[LocaleKeys.InputDialogYes],
|
||||
LocaleManager.Instance[LocaleKeys.InputDialogNo],
|
||||
LocaleManager.Instance[LocaleKeys.RyujinxConfirm]);
|
||||
|
||||
if (result == UserResult.Yes)
|
||||
{
|
||||
ViewModel.Delete(model);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async void DeleteAll(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var result = await ContentDialogHelper.CreateConfirmationDialog(
|
||||
LocaleManager.Instance[LocaleKeys.DialogWarning],
|
||||
LocaleManager.Instance[LocaleKeys.DialogModManagerDeletionAllWarningMessage],
|
||||
LocaleManager.Instance[LocaleKeys.InputDialogYes],
|
||||
LocaleManager.Instance[LocaleKeys.InputDialogNo],
|
||||
LocaleManager.Instance[LocaleKeys.RyujinxConfirm]);
|
||||
|
||||
if (result == UserResult.Yes)
|
||||
{
|
||||
ViewModel.DeleteAll();
|
||||
}
|
||||
}
|
||||
|
||||
private void OpenLocation(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (sender is Button button)
|
||||
{
|
||||
if (button.DataContext is ModModel model)
|
||||
{
|
||||
OpenHelper.OpenFolder(model.Path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
foreach (var content in e.AddedItems)
|
||||
{
|
||||
if (content is ModModel model)
|
||||
{
|
||||
var index = ViewModel.Mods.IndexOf(model);
|
||||
|
||||
if (index != -1)
|
||||
{
|
||||
ViewModel.Mods[index].Enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var content in e.RemovedItems)
|
||||
{
|
||||
if (content is ModModel model)
|
||||
{
|
||||
var index = ViewModel.Mods.IndexOf(model);
|
||||
|
||||
if (index != -1)
|
||||
{
|
||||
ViewModel.Mods[index].Enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Common.Utilities;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
@ -6,8 +7,8 @@ namespace Ryujinx.Common.Configuration
|
||||
{
|
||||
public static class AppDataManager
|
||||
{
|
||||
public const string DefaultBaseDir = "Ryujinx";
|
||||
public const string DefaultPortableDir = "portable";
|
||||
private const string DefaultBaseDir = "Ryujinx";
|
||||
private const string DefaultPortableDir = "portable";
|
||||
|
||||
// The following 3 are always part of Base Directory
|
||||
private const string GamesDir = "games";
|
||||
@ -109,8 +110,7 @@ namespace Ryujinx.Common.Configuration
|
||||
string oldConfigPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), DefaultBaseDir);
|
||||
if (Path.Exists(oldConfigPath) && !IsPathSymlink(oldConfigPath) && !Path.Exists(BaseDirPath))
|
||||
{
|
||||
CopyDirectory(oldConfigPath, BaseDirPath);
|
||||
Directory.Delete(oldConfigPath, true);
|
||||
FileSystemUtils.MoveDirectory(oldConfigPath, BaseDirPath);
|
||||
Directory.CreateSymbolicLink(oldConfigPath, BaseDirPath);
|
||||
}
|
||||
}
|
||||
@ -127,41 +127,13 @@ namespace Ryujinx.Common.Configuration
|
||||
}
|
||||
|
||||
// Check if existing old baseDirPath is a symlink, to prevent possible errors.
|
||||
// Should be removed, when the existance of the old directory isn't checked anymore.
|
||||
// Should be removed, when the existence of the old directory isn't checked anymore.
|
||||
private static bool IsPathSymlink(string path)
|
||||
{
|
||||
FileAttributes attributes = File.GetAttributes(path);
|
||||
return (attributes & FileAttributes.ReparsePoint) == FileAttributes.ReparsePoint;
|
||||
}
|
||||
|
||||
private static void CopyDirectory(string sourceDir, string destinationDir)
|
||||
{
|
||||
var dir = new DirectoryInfo(sourceDir);
|
||||
|
||||
if (!dir.Exists)
|
||||
{
|
||||
throw new DirectoryNotFoundException($"Source directory not found: {dir.FullName}");
|
||||
}
|
||||
|
||||
DirectoryInfo[] subDirs = dir.GetDirectories();
|
||||
Directory.CreateDirectory(destinationDir);
|
||||
|
||||
foreach (FileInfo file in dir.GetFiles())
|
||||
{
|
||||
if (file.Name == ".DS_Store")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
file.CopyTo(Path.Combine(destinationDir, file.Name));
|
||||
}
|
||||
|
||||
foreach (DirectoryInfo subDir in subDirs)
|
||||
{
|
||||
CopyDirectory(subDir.FullName, Path.Combine(destinationDir, subDir.Name));
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetModsPath() => CustomModsPath ?? Directory.CreateDirectory(Path.Combine(BaseDirPath, DefaultModsDir)).FullName;
|
||||
public static string GetSdModsPath() => CustomSdModsPath ?? Directory.CreateDirectory(Path.Combine(BaseDirPath, DefaultSdcardDir, "atmosphere")).FullName;
|
||||
}
|
||||
|
9
src/Ryujinx.Common/Configuration/Mod.cs
Normal file
9
src/Ryujinx.Common/Configuration/Mod.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace Ryujinx.Common.Configuration
|
||||
{
|
||||
public class Mod
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Path { get; set; }
|
||||
public bool Enabled { get; set; }
|
||||
}
|
||||
}
|
14
src/Ryujinx.Common/Configuration/ModMetadata.cs
Normal file
14
src/Ryujinx.Common/Configuration/ModMetadata.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Ryujinx.Common.Configuration
|
||||
{
|
||||
public struct ModMetadata
|
||||
{
|
||||
public List<Mod> Mods { get; set; }
|
||||
|
||||
public ModMetadata()
|
||||
{
|
||||
Mods = new List<Mod>();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Ryujinx.Common.Configuration
|
||||
{
|
||||
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||
[JsonSerializable(typeof(ModMetadata))]
|
||||
public partial class ModMetadataJsonSerializerContext : JsonSerializerContext
|
||||
{
|
||||
}
|
||||
}
|
@ -13,31 +13,71 @@ namespace Ryujinx.Common.Logging.Targets
|
||||
|
||||
string ILogTarget.Name { get => _name; }
|
||||
|
||||
public FileLogTarget(string path, string name)
|
||||
: this(path, name, FileShare.Read, FileMode.Append)
|
||||
{ }
|
||||
public FileLogTarget(string name, FileStream fileStream)
|
||||
{
|
||||
_name = name;
|
||||
_logWriter = new StreamWriter(fileStream);
|
||||
_formatter = new DefaultLogFormatter();
|
||||
}
|
||||
|
||||
public FileLogTarget(string path, string name, FileShare fileShare, FileMode fileMode)
|
||||
public static FileStream PrepareLogFile(string path)
|
||||
{
|
||||
// Ensure directory is present
|
||||
DirectoryInfo logDir = new(Path.Combine(path, "Logs"));
|
||||
logDir.Create();
|
||||
DirectoryInfo logDir = new(path);
|
||||
try
|
||||
{
|
||||
logDir.Create();
|
||||
}
|
||||
catch (IOException exception)
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.Application, $"Logging directory could not be created '{logDir}': {exception}");
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// Clean up old logs, should only keep 3
|
||||
FileInfo[] files = logDir.GetFiles("*.log").OrderBy((info => info.CreationTime)).ToArray();
|
||||
for (int i = 0; i < files.Length - 2; i++)
|
||||
{
|
||||
files[i].Delete();
|
||||
try
|
||||
{
|
||||
files[i].Delete();
|
||||
}
|
||||
catch (UnauthorizedAccessException exception)
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.Application, $"Old log file could not be deleted '{files[i].FullName}': {exception}");
|
||||
|
||||
return null;
|
||||
}
|
||||
catch (IOException exception)
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.Application, $"Old log file could not be deleted '{files[i].FullName}': {exception}");
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
string version = ReleaseInformation.GetVersion();
|
||||
string version = ReleaseInformation.Version;
|
||||
|
||||
// Get path for the current time
|
||||
path = Path.Combine(logDir.FullName, $"Ryujinx_{version}_{DateTime.Now:yyyy-MM-dd_HH-mm-ss}.log");
|
||||
|
||||
_name = name;
|
||||
_logWriter = new StreamWriter(File.Open(path, fileMode, FileAccess.Write, fileShare));
|
||||
_formatter = new DefaultLogFormatter();
|
||||
try
|
||||
{
|
||||
return File.Open(path, FileMode.Append, FileAccess.Write, FileShare.Read);
|
||||
}
|
||||
catch (UnauthorizedAccessException exception)
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.Application, $"Log file could not be created '{path}': {exception}");
|
||||
|
||||
return null;
|
||||
}
|
||||
catch (IOException exception)
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.Application, $"Log file could not be created '{path}': {exception}");
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void Log(object sender, LogEventArgs args)
|
||||
|
@ -744,6 +744,17 @@ namespace Ryujinx.Common.Memory
|
||||
public Span<T> AsSpan() => MemoryMarshal.CreateSpan(ref _e0, Length);
|
||||
}
|
||||
|
||||
public struct Array65<T> : IArray<T> where T : unmanaged
|
||||
{
|
||||
T _e0;
|
||||
Array64<T> _other;
|
||||
public readonly int Length => 65;
|
||||
public ref T this[int index] => ref AsSpan()[index];
|
||||
|
||||
[Pure]
|
||||
public Span<T> AsSpan() => MemoryMarshal.CreateSpan(ref _e0, Length);
|
||||
}
|
||||
|
||||
public struct Array73<T> : IArray<T> where T : unmanaged
|
||||
{
|
||||
T _e0;
|
||||
|
@ -63,6 +63,18 @@ namespace Ryujinx.Common.Memory
|
||||
public Span<byte> AsSpan() => MemoryMarshal.CreateSpan(ref _element, Size);
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Size = Size, Pack = 1)]
|
||||
public struct ByteArray3000 : IArray<byte>
|
||||
{
|
||||
private const int Size = 3000;
|
||||
|
||||
byte _element;
|
||||
|
||||
public readonly int Length => Size;
|
||||
public ref byte this[int index] => ref AsSpan()[index];
|
||||
public Span<byte> AsSpan() => MemoryMarshal.CreateSpan(ref _element, Size);
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Size = Size, Pack = 1)]
|
||||
public struct ByteArray4096 : IArray<byte>
|
||||
{
|
||||
|
@ -1,5 +1,3 @@
|
||||
using Ryujinx.Common.Configuration;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Ryujinx.Common
|
||||
@ -9,50 +7,25 @@ namespace Ryujinx.Common
|
||||
{
|
||||
private const string FlatHubChannelOwner = "flathub";
|
||||
|
||||
public const string BuildVersion = "%%RYUJINX_BUILD_VERSION%%";
|
||||
public const string BuildGitHash = "%%RYUJINX_BUILD_GIT_HASH%%";
|
||||
public const string ReleaseChannelName = "%%RYUJINX_TARGET_RELEASE_CHANNEL_NAME%%";
|
||||
private const string BuildVersion = "%%RYUJINX_BUILD_VERSION%%";
|
||||
private const string BuildGitHash = "%%RYUJINX_BUILD_GIT_HASH%%";
|
||||
private const string ReleaseChannelName = "%%RYUJINX_TARGET_RELEASE_CHANNEL_NAME%%";
|
||||
private const string ConfigFileName = "%%RYUJINX_CONFIG_FILE_NAME%%";
|
||||
|
||||
public const string ReleaseChannelOwner = "%%RYUJINX_TARGET_RELEASE_CHANNEL_OWNER%%";
|
||||
public const string ReleaseChannelRepo = "%%RYUJINX_TARGET_RELEASE_CHANNEL_REPO%%";
|
||||
|
||||
public static bool IsValid()
|
||||
{
|
||||
return !BuildGitHash.StartsWith("%%") &&
|
||||
!ReleaseChannelName.StartsWith("%%") &&
|
||||
!ReleaseChannelOwner.StartsWith("%%") &&
|
||||
!ReleaseChannelRepo.StartsWith("%%");
|
||||
}
|
||||
public static string ConfigName => !ConfigFileName.StartsWith("%%") ? ConfigFileName : "Config.json";
|
||||
|
||||
public static bool IsFlatHubBuild()
|
||||
{
|
||||
return IsValid() && ReleaseChannelOwner.Equals(FlatHubChannelOwner);
|
||||
}
|
||||
public static bool IsValid =>
|
||||
!BuildGitHash.StartsWith("%%") &&
|
||||
!ReleaseChannelName.StartsWith("%%") &&
|
||||
!ReleaseChannelOwner.StartsWith("%%") &&
|
||||
!ReleaseChannelRepo.StartsWith("%%") &&
|
||||
!ConfigFileName.StartsWith("%%");
|
||||
|
||||
public static string GetVersion()
|
||||
{
|
||||
if (IsValid())
|
||||
{
|
||||
return BuildVersion;
|
||||
}
|
||||
public static bool IsFlatHubBuild => IsValid && ReleaseChannelOwner.Equals(FlatHubChannelOwner);
|
||||
|
||||
return Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;
|
||||
}
|
||||
|
||||
#if FORCE_EXTERNAL_BASE_DIR
|
||||
public static string GetBaseApplicationDirectory()
|
||||
{
|
||||
return AppDataManager.BaseDirPath;
|
||||
}
|
||||
#else
|
||||
public static string GetBaseApplicationDirectory()
|
||||
{
|
||||
if (IsFlatHubBuild() || OperatingSystem.IsMacOS())
|
||||
{
|
||||
return AppDataManager.BaseDirPath;
|
||||
}
|
||||
|
||||
return AppDomain.CurrentDomain.BaseDirectory;
|
||||
}
|
||||
#endif
|
||||
public static string Version => IsValid ? BuildVersion : Assembly.GetEntryAssembly()!.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion;
|
||||
}
|
||||
}
|
||||
|
48
src/Ryujinx.Common/Utilities/FileSystemUtils.cs
Normal file
48
src/Ryujinx.Common/Utilities/FileSystemUtils.cs
Normal file
@ -0,0 +1,48 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.Common.Utilities
|
||||
{
|
||||
public static class FileSystemUtils
|
||||
{
|
||||
public static void CopyDirectory(string sourceDir, string destinationDir, bool recursive)
|
||||
{
|
||||
// Get information about the source directory
|
||||
var dir = new DirectoryInfo(sourceDir);
|
||||
|
||||
// Check if the source directory exists
|
||||
if (!dir.Exists)
|
||||
{
|
||||
throw new DirectoryNotFoundException($"Source directory not found: {dir.FullName}");
|
||||
}
|
||||
|
||||
// Cache directories before we start copying
|
||||
DirectoryInfo[] dirs = dir.GetDirectories();
|
||||
|
||||
// Create the destination directory
|
||||
Directory.CreateDirectory(destinationDir);
|
||||
|
||||
// Get the files in the source directory and copy to the destination directory
|
||||
foreach (FileInfo file in dir.GetFiles())
|
||||
{
|
||||
string targetFilePath = Path.Combine(destinationDir, file.Name);
|
||||
file.CopyTo(targetFilePath);
|
||||
}
|
||||
|
||||
// If recursive and copying subdirectories, recursively call this method
|
||||
if (recursive)
|
||||
{
|
||||
foreach (DirectoryInfo subDir in dirs)
|
||||
{
|
||||
string newDestinationDir = Path.Combine(destinationDir, subDir.Name);
|
||||
CopyDirectory(subDir.FullName, newDestinationDir, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void MoveDirectory(string sourceDir, string destinationDir)
|
||||
{
|
||||
CopyDirectory(sourceDir, destinationDir, true);
|
||||
Directory.Delete(sourceDir, true);
|
||||
}
|
||||
}
|
||||
}
|
@ -4,11 +4,13 @@ namespace Ryujinx.Graphics.GAL
|
||||
{
|
||||
public string GpuVendor { get; }
|
||||
public string GpuModel { get; }
|
||||
public string GpuDriver { get; }
|
||||
|
||||
public HardwareInfo(string gpuVendor, string gpuModel)
|
||||
public HardwareInfo(string gpuVendor, string gpuModel, string gpuDriver)
|
||||
{
|
||||
GpuVendor = gpuVendor;
|
||||
GpuModel = gpuModel;
|
||||
GpuDriver = gpuDriver;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
|
||||
private const ushort FileFormatVersionMajor = 1;
|
||||
private const ushort FileFormatVersionMinor = 2;
|
||||
private const uint FileFormatVersionPacked = ((uint)FileFormatVersionMajor << 16) | FileFormatVersionMinor;
|
||||
private const uint CodeGenVersion = 5958;
|
||||
private const uint CodeGenVersion = 6253;
|
||||
|
||||
private const string SharedTocFileName = "shared.toc";
|
||||
private const string SharedDataFileName = "shared.data";
|
||||
|
@ -121,7 +121,7 @@ namespace Ryujinx.Graphics.OpenGL
|
||||
|
||||
public HardwareInfo GetHardwareInfo()
|
||||
{
|
||||
return new HardwareInfo(GpuVendor, GpuRenderer);
|
||||
return new HardwareInfo(GpuVendor, GpuRenderer, GpuVendor); // OpenGL does not provide a driver name, vendor name is closest analogue.
|
||||
}
|
||||
|
||||
public PinnedSpan<byte> GetBufferData(BufferHandle buffer, int offset, int size)
|
||||
|
@ -578,12 +578,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
||||
type = SamplerType.Texture2D;
|
||||
flags = TextureFlags.Gather;
|
||||
|
||||
if (tld4sOp.Dc)
|
||||
{
|
||||
sourcesList.Add(Rb());
|
||||
|
||||
type |= SamplerType.Shadow;
|
||||
}
|
||||
int depthCompareIndex = sourcesList.Count;
|
||||
|
||||
if (tld4sOp.Aoffi)
|
||||
{
|
||||
@ -592,7 +587,16 @@ namespace Ryujinx.Graphics.Shader.Instructions
|
||||
flags |= TextureFlags.Offset;
|
||||
}
|
||||
|
||||
sourcesList.Add(Const((int)tld4sOp.TexComp));
|
||||
if (tld4sOp.Dc)
|
||||
{
|
||||
sourcesList.Insert(depthCompareIndex, Rb());
|
||||
|
||||
type |= SamplerType.Shadow;
|
||||
}
|
||||
else
|
||||
{
|
||||
sourcesList.Add(Const((int)tld4sOp.TexComp));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -4,6 +4,7 @@ using Silk.NET.Vulkan;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using VkBuffer = Silk.NET.Vulkan.Buffer;
|
||||
using VkFormat = Silk.NET.Vulkan.Format;
|
||||
@ -384,7 +385,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
var baseData = new Span<byte>((void*)(_map + offset), size);
|
||||
var modData = _pendingData.AsSpan(offset, size);
|
||||
|
||||
StagingBufferReserved? newMirror = _gd.BufferManager.StagingBuffer.TryReserveData(cbs, size, (int)_gd.Capabilities.MinResourceAlignment);
|
||||
StagingBufferReserved? newMirror = _gd.BufferManager.StagingBuffer.TryReserveData(cbs, size);
|
||||
|
||||
if (newMirror != null)
|
||||
{
|
||||
@ -838,6 +839,11 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
}
|
||||
}
|
||||
|
||||
public unsafe void SetDataUnchecked<T>(int offset, ReadOnlySpan<T> data) where T : unmanaged
|
||||
{
|
||||
SetDataUnchecked(offset, MemoryMarshal.AsBytes(data));
|
||||
}
|
||||
|
||||
public void SetDataInline(CommandBufferScoped cbs, Action endRenderPass, int dstOffset, ReadOnlySpan<byte> data)
|
||||
{
|
||||
if (!TryPushData(cbs, endRenderPass, dstOffset, data))
|
||||
|
@ -9,6 +9,36 @@ using VkFormat = Silk.NET.Vulkan.Format;
|
||||
|
||||
namespace Ryujinx.Graphics.Vulkan
|
||||
{
|
||||
readonly struct ScopedTemporaryBuffer : IDisposable
|
||||
{
|
||||
private readonly BufferManager _bufferManager;
|
||||
private readonly bool _isReserved;
|
||||
|
||||
public readonly BufferRange Range;
|
||||
public readonly BufferHolder Holder;
|
||||
|
||||
public BufferHandle Handle => Range.Handle;
|
||||
public int Offset => Range.Offset;
|
||||
|
||||
public ScopedTemporaryBuffer(BufferManager bufferManager, BufferHolder holder, BufferHandle handle, int offset, int size, bool isReserved)
|
||||
{
|
||||
_bufferManager = bufferManager;
|
||||
|
||||
Range = new BufferRange(handle, offset, size);
|
||||
Holder = holder;
|
||||
|
||||
_isReserved = isReserved;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (!_isReserved)
|
||||
{
|
||||
_bufferManager.Delete(Range.Handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class BufferManager : IDisposable
|
||||
{
|
||||
public const MemoryPropertyFlags DefaultBufferMemoryFlags =
|
||||
@ -238,6 +268,23 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
return Unsafe.As<ulong, BufferHandle>(ref handle64);
|
||||
}
|
||||
|
||||
public ScopedTemporaryBuffer ReserveOrCreate(VulkanRenderer gd, CommandBufferScoped cbs, int size)
|
||||
{
|
||||
StagingBufferReserved? result = StagingBuffer.TryReserveData(cbs, size);
|
||||
|
||||
if (result.HasValue)
|
||||
{
|
||||
return new ScopedTemporaryBuffer(this, result.Value.Buffer, StagingBuffer.Handle, result.Value.Offset, result.Value.Size, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Create a temporary buffer.
|
||||
BufferHandle handle = CreateWithHandle(gd, size, out BufferHolder holder);
|
||||
|
||||
return new ScopedTemporaryBuffer(this, holder, handle, 0, size, false);
|
||||
}
|
||||
}
|
||||
|
||||
public unsafe MemoryRequirements GetHostImportedUsageRequirements(VulkanRenderer gd)
|
||||
{
|
||||
var usage = HostImportedBufferUsageFlags;
|
||||
@ -635,13 +682,14 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
StagingBuffer.Dispose();
|
||||
|
||||
foreach (BufferHolder buffer in _buffers)
|
||||
{
|
||||
buffer.Dispose();
|
||||
}
|
||||
|
||||
_buffers.Clear();
|
||||
StagingBuffer.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -142,19 +142,18 @@ namespace Ryujinx.Graphics.Vulkan.Effects
|
||||
};
|
||||
|
||||
int rangeSize = dimensionsBuffer.Length * sizeof(float);
|
||||
var bufferHandle = _renderer.BufferManager.CreateWithHandle(_renderer, rangeSize);
|
||||
_renderer.BufferManager.SetData(bufferHandle, 0, dimensionsBuffer);
|
||||
using var buffer = _renderer.BufferManager.ReserveOrCreate(_renderer, cbs, rangeSize);
|
||||
buffer.Holder.SetDataUnchecked(buffer.Offset, dimensionsBuffer);
|
||||
|
||||
ReadOnlySpan<float> sharpeningBuffer = stackalloc float[] { 1.5f - (Level * 0.01f * 1.5f) };
|
||||
var sharpeningBufferHandle = _renderer.BufferManager.CreateWithHandle(_renderer, sizeof(float));
|
||||
_renderer.BufferManager.SetData(sharpeningBufferHandle, 0, sharpeningBuffer);
|
||||
ReadOnlySpan<float> sharpeningBufferData = stackalloc float[] { 1.5f - (Level * 0.01f * 1.5f) };
|
||||
using var sharpeningBuffer = _renderer.BufferManager.ReserveOrCreate(_renderer, cbs, sizeof(float));
|
||||
sharpeningBuffer.Holder.SetDataUnchecked(sharpeningBuffer.Offset, sharpeningBufferData);
|
||||
|
||||
int threadGroupWorkRegionDim = 16;
|
||||
int dispatchX = (width + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim;
|
||||
int dispatchY = (height + (threadGroupWorkRegionDim - 1)) / threadGroupWorkRegionDim;
|
||||
|
||||
var bufferRanges = new BufferRange(bufferHandle, 0, rangeSize);
|
||||
_pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(2, bufferRanges) });
|
||||
_pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(2, buffer.Range) });
|
||||
_pipeline.SetImage(0, _intermediaryTexture, FormatTable.ConvertRgba8SrgbToUnorm(view.Info.Format));
|
||||
_pipeline.DispatchCompute(dispatchX, dispatchY, 1);
|
||||
_pipeline.ComputeBarrier();
|
||||
@ -162,16 +161,12 @@ namespace Ryujinx.Graphics.Vulkan.Effects
|
||||
// Sharpening pass
|
||||
_pipeline.SetProgram(_sharpeningProgram);
|
||||
_pipeline.SetTextureAndSampler(ShaderStage.Compute, 1, _intermediaryTexture, _sampler);
|
||||
var sharpeningRange = new BufferRange(sharpeningBufferHandle, 0, sizeof(float));
|
||||
_pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(4, sharpeningRange) });
|
||||
_pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(4, sharpeningBuffer.Range) });
|
||||
_pipeline.SetImage(0, destinationTexture);
|
||||
_pipeline.DispatchCompute(dispatchX, dispatchY, 1);
|
||||
_pipeline.ComputeBarrier();
|
||||
|
||||
_pipeline.Finish();
|
||||
|
||||
_renderer.BufferManager.Delete(bufferHandle);
|
||||
_renderer.BufferManager.Delete(sharpeningBufferHandle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -66,12 +66,11 @@ namespace Ryujinx.Graphics.Vulkan.Effects
|
||||
|
||||
ReadOnlySpan<float> resolutionBuffer = stackalloc float[] { view.Width, view.Height };
|
||||
int rangeSize = resolutionBuffer.Length * sizeof(float);
|
||||
var bufferHandle = _renderer.BufferManager.CreateWithHandle(_renderer, rangeSize);
|
||||
using var buffer = _renderer.BufferManager.ReserveOrCreate(_renderer, cbs, rangeSize);
|
||||
|
||||
_renderer.BufferManager.SetData(bufferHandle, 0, resolutionBuffer);
|
||||
buffer.Holder.SetDataUnchecked(buffer.Offset, resolutionBuffer);
|
||||
|
||||
var bufferRanges = new BufferRange(bufferHandle, 0, rangeSize);
|
||||
_pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(2, bufferRanges) });
|
||||
_pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(2, buffer.Range) });
|
||||
|
||||
var dispatchX = BitUtils.DivRoundUp(view.Width, IPostProcessingEffect.LocalGroupSize);
|
||||
var dispatchY = BitUtils.DivRoundUp(view.Height, IPostProcessingEffect.LocalGroupSize);
|
||||
@ -79,7 +78,6 @@ namespace Ryujinx.Graphics.Vulkan.Effects
|
||||
_pipeline.SetImage(0, _texture, FormatTable.ConvertRgba8SrgbToUnorm(view.Info.Format));
|
||||
_pipeline.DispatchCompute(dispatchX, dispatchY, 1);
|
||||
|
||||
_renderer.BufferManager.Delete(bufferHandle);
|
||||
_pipeline.ComputeBarrier();
|
||||
|
||||
_pipeline.Finish();
|
||||
|
@ -215,11 +215,10 @@ namespace Ryujinx.Graphics.Vulkan.Effects
|
||||
|
||||
ReadOnlySpan<float> resolutionBuffer = stackalloc float[] { view.Width, view.Height };
|
||||
int rangeSize = resolutionBuffer.Length * sizeof(float);
|
||||
var bufferHandle = _renderer.BufferManager.CreateWithHandle(_renderer, rangeSize);
|
||||
using var buffer = _renderer.BufferManager.ReserveOrCreate(_renderer, cbs, rangeSize);
|
||||
|
||||
_renderer.BufferManager.SetData(bufferHandle, 0, resolutionBuffer);
|
||||
var bufferRanges = new BufferRange(bufferHandle, 0, rangeSize);
|
||||
_pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(2, bufferRanges) });
|
||||
buffer.Holder.SetDataUnchecked(buffer.Offset, resolutionBuffer);
|
||||
_pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(2, buffer.Range) });
|
||||
_pipeline.SetImage(0, _edgeOutputTexture, FormatTable.ConvertRgba8SrgbToUnorm(view.Info.Format));
|
||||
_pipeline.DispatchCompute(dispatchX, dispatchY, 1);
|
||||
_pipeline.ComputeBarrier();
|
||||
@ -245,8 +244,6 @@ namespace Ryujinx.Graphics.Vulkan.Effects
|
||||
|
||||
_pipeline.Finish();
|
||||
|
||||
_renderer.BufferManager.Delete(bufferHandle);
|
||||
|
||||
return _outputTexture;
|
||||
}
|
||||
|
||||
@ -260,7 +257,7 @@ namespace Ryujinx.Graphics.Vulkan.Effects
|
||||
|
||||
scissors[0] = new Rectangle<int>(0, 0, texture.Width, texture.Height);
|
||||
|
||||
_pipeline.SetRenderTarget(texture.GetImageViewForAttachment(), (uint)texture.Width, (uint)texture.Height, false, texture.VkFormat);
|
||||
_pipeline.SetRenderTarget(texture, (uint)texture.Width, (uint)texture.Height);
|
||||
_pipeline.SetRenderTargetColorMasks(colorMasks);
|
||||
_pipeline.SetScissors(scissors);
|
||||
_pipeline.ClearRenderTargetColor(0, 0, 1, new ColorF(0f, 0f, 0f, 1f));
|
||||
|
@ -1,5 +1,6 @@
|
||||
using Ryujinx.Graphics.GAL;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using VkFormat = Silk.NET.Vulkan.Format;
|
||||
|
||||
namespace Ryujinx.Graphics.Vulkan
|
||||
@ -7,10 +8,12 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
static class FormatTable
|
||||
{
|
||||
private static readonly VkFormat[] _table;
|
||||
private static readonly Dictionary<VkFormat, Format> _reverseMap;
|
||||
|
||||
static FormatTable()
|
||||
{
|
||||
_table = new VkFormat[Enum.GetNames(typeof(Format)).Length];
|
||||
_reverseMap = new Dictionary<VkFormat, Format>();
|
||||
|
||||
#pragma warning disable IDE0055 // Disable formatting
|
||||
Add(Format.R8Unorm, VkFormat.R8Unorm);
|
||||
@ -164,6 +167,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
private static void Add(Format format, VkFormat vkFormat)
|
||||
{
|
||||
_table[(int)format] = vkFormat;
|
||||
_reverseMap[vkFormat] = format;
|
||||
}
|
||||
|
||||
public static VkFormat GetFormat(Format format)
|
||||
@ -171,6 +175,16 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
return _table[(int)format];
|
||||
}
|
||||
|
||||
public static Format GetFormat(VkFormat format)
|
||||
{
|
||||
if (!_reverseMap.TryGetValue(format, out Format result))
|
||||
{
|
||||
return Format.B8G8R8A8Unorm;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Format ConvertRgba8SrgbToUnorm(Format format)
|
||||
{
|
||||
return format switch
|
||||
|
@ -12,6 +12,8 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
private readonly Auto<DisposableImageView>[] _attachments;
|
||||
private readonly TextureView[] _colors;
|
||||
private readonly TextureView _depthStencil;
|
||||
private readonly TextureView[] _colorsCanonical;
|
||||
private readonly TextureView _baseAttachment;
|
||||
private readonly uint _validColorAttachments;
|
||||
|
||||
public uint Width { get; }
|
||||
@ -28,25 +30,31 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
public bool HasDepthStencil { get; }
|
||||
public int ColorAttachmentsCount => AttachmentsCount - (HasDepthStencil ? 1 : 0);
|
||||
|
||||
public FramebufferParams(
|
||||
Device device,
|
||||
Auto<DisposableImageView> view,
|
||||
uint width,
|
||||
uint height,
|
||||
uint samples,
|
||||
bool isDepthStencil,
|
||||
VkFormat format)
|
||||
public FramebufferParams(Device device, TextureView view, uint width, uint height)
|
||||
{
|
||||
bool isDepthStencil = view.Info.Format.IsDepthOrStencil();
|
||||
|
||||
_device = device;
|
||||
_attachments = new[] { view };
|
||||
_attachments = new[] { view.GetImageViewForAttachment() };
|
||||
_validColorAttachments = isDepthStencil ? 0u : 1u;
|
||||
_baseAttachment = view;
|
||||
|
||||
if (isDepthStencil)
|
||||
{
|
||||
_depthStencil = view;
|
||||
}
|
||||
else
|
||||
{
|
||||
_colors = new TextureView[] { view };
|
||||
_colorsCanonical = _colors;
|
||||
}
|
||||
|
||||
Width = width;
|
||||
Height = height;
|
||||
Layers = 1;
|
||||
|
||||
AttachmentSamples = new[] { samples };
|
||||
AttachmentFormats = new[] { format };
|
||||
AttachmentSamples = new[] { (uint)view.Info.Samples };
|
||||
AttachmentFormats = new[] { view.VkFormat };
|
||||
AttachmentIndices = isDepthStencil ? Array.Empty<int>() : new[] { 0 };
|
||||
|
||||
AttachmentsCount = 1;
|
||||
@ -64,6 +72,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
_attachments = new Auto<DisposableImageView>[count];
|
||||
_colors = new TextureView[colorsCount];
|
||||
_colorsCanonical = colors.Select(color => color is TextureView view && view.Valid ? view : null).ToArray();
|
||||
|
||||
AttachmentSamples = new uint[count];
|
||||
AttachmentFormats = new VkFormat[count];
|
||||
@ -86,6 +95,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
_attachments[index] = texture.GetImageViewForAttachment();
|
||||
_colors[index] = texture;
|
||||
_validColorAttachments |= 1u << bindIndex;
|
||||
_baseAttachment = texture;
|
||||
|
||||
AttachmentSamples[index] = (uint)texture.Info.Samples;
|
||||
AttachmentFormats[index] = texture.VkFormat;
|
||||
@ -115,6 +125,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
{
|
||||
_attachments[count - 1] = dsTexture.GetImageViewForAttachment();
|
||||
_depthStencil = dsTexture;
|
||||
_baseAttachment ??= dsTexture;
|
||||
|
||||
AttachmentSamples[count - 1] = (uint)dsTexture.Info.Samples;
|
||||
AttachmentFormats[count - 1] = dsTexture.VkFormat;
|
||||
@ -251,19 +262,11 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
public void InsertClearBarrier(CommandBufferScoped cbs, int index)
|
||||
{
|
||||
if (_colors != null)
|
||||
{
|
||||
int realIndex = Array.IndexOf(AttachmentIndices, index);
|
||||
|
||||
if (realIndex != -1)
|
||||
{
|
||||
_colors[realIndex].Storage?.InsertReadToWriteBarrier(
|
||||
cbs,
|
||||
AccessFlags.ColorAttachmentWriteBit,
|
||||
PipelineStageFlags.ColorAttachmentOutputBit,
|
||||
insideRenderPass: true);
|
||||
}
|
||||
}
|
||||
_colorsCanonical?[index]?.Storage?.InsertReadToWriteBarrier(
|
||||
cbs,
|
||||
AccessFlags.ColorAttachmentWriteBit,
|
||||
PipelineStageFlags.ColorAttachmentOutputBit,
|
||||
insideRenderPass: true);
|
||||
}
|
||||
|
||||
public void InsertClearBarrierDS(CommandBufferScoped cbs)
|
||||
@ -274,5 +277,61 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
PipelineStageFlags.LateFragmentTestsBit,
|
||||
insideRenderPass: true);
|
||||
}
|
||||
|
||||
public TextureView[] GetAttachmentViews()
|
||||
{
|
||||
var result = new TextureView[_attachments.Length];
|
||||
|
||||
_colors?.CopyTo(result, 0);
|
||||
|
||||
if (_depthStencil != null)
|
||||
{
|
||||
result[^1] = _depthStencil;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public RenderPassCacheKey GetRenderPassCacheKey()
|
||||
{
|
||||
return new RenderPassCacheKey(_depthStencil, _colorsCanonical);
|
||||
}
|
||||
|
||||
public void InsertLoadOpBarriers(CommandBufferScoped cbs)
|
||||
{
|
||||
if (_colors != null)
|
||||
{
|
||||
foreach (var color in _colors)
|
||||
{
|
||||
// If Clear or DontCare were used, this would need to be write bit.
|
||||
color.Storage?.InsertWriteToReadBarrier(cbs, AccessFlags.ColorAttachmentReadBit, PipelineStageFlags.ColorAttachmentOutputBit);
|
||||
color.Storage?.SetModification(AccessFlags.ColorAttachmentWriteBit, PipelineStageFlags.ColorAttachmentOutputBit);
|
||||
}
|
||||
}
|
||||
|
||||
if (_depthStencil != null)
|
||||
{
|
||||
_depthStencil.Storage?.InsertWriteToReadBarrier(cbs, AccessFlags.DepthStencilAttachmentReadBit, PipelineStageFlags.EarlyFragmentTestsBit);
|
||||
_depthStencil.Storage?.SetModification(AccessFlags.DepthStencilAttachmentWriteBit, PipelineStageFlags.LateFragmentTestsBit);
|
||||
}
|
||||
}
|
||||
|
||||
public (Auto<DisposableRenderPass> renderPass, Auto<DisposableFramebuffer> framebuffer) GetPassAndFramebuffer(
|
||||
VulkanRenderer gd,
|
||||
Device device,
|
||||
CommandBufferScoped cbs)
|
||||
{
|
||||
return _baseAttachment.GetPassAndFramebuffer(gd, device, cbs, this);
|
||||
}
|
||||
|
||||
public TextureView GetColorView(int index)
|
||||
{
|
||||
return _colorsCanonical[index];
|
||||
}
|
||||
|
||||
public TextureView GetDepthStencilView()
|
||||
{
|
||||
return _depthStencil;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Ryujinx.Graphics.Vulkan
|
||||
{
|
||||
@ -20,20 +21,29 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
public TValue Value;
|
||||
}
|
||||
|
||||
private readonly Entry[][] _hashTable = new Entry[TotalBuckets][];
|
||||
private struct Bucket
|
||||
{
|
||||
public int Length;
|
||||
public Entry[] Entries;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly Span<Entry> AsSpan()
|
||||
{
|
||||
return Entries == null ? Span<Entry>.Empty : Entries.AsSpan(0, Length);
|
||||
}
|
||||
}
|
||||
|
||||
private readonly Bucket[] _hashTable = new Bucket[TotalBuckets];
|
||||
|
||||
public IEnumerable<TKey> Keys
|
||||
{
|
||||
get
|
||||
{
|
||||
foreach (Entry[] bucket in _hashTable)
|
||||
foreach (Bucket bucket in _hashTable)
|
||||
{
|
||||
if (bucket != null)
|
||||
for (int i = 0; i < bucket.Length; i++)
|
||||
{
|
||||
foreach (Entry entry in bucket)
|
||||
{
|
||||
yield return entry.Key;
|
||||
}
|
||||
yield return bucket.Entries[i].Key;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -43,14 +53,11 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
{
|
||||
get
|
||||
{
|
||||
foreach (Entry[] bucket in _hashTable)
|
||||
foreach (Bucket bucket in _hashTable)
|
||||
{
|
||||
if (bucket != null)
|
||||
for (int i = 0; i < bucket.Length; i++)
|
||||
{
|
||||
foreach (Entry entry in bucket)
|
||||
{
|
||||
yield return entry.Value;
|
||||
}
|
||||
yield return bucket.Entries[i].Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -68,40 +75,64 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
int hashCode = key.GetHashCode();
|
||||
int bucketIndex = hashCode & TotalBucketsMask;
|
||||
|
||||
var bucket = _hashTable[bucketIndex];
|
||||
if (bucket != null)
|
||||
ref var bucket = ref _hashTable[bucketIndex];
|
||||
if (bucket.Entries != null)
|
||||
{
|
||||
int index = bucket.Length;
|
||||
|
||||
Array.Resize(ref _hashTable[bucketIndex], index + 1);
|
||||
if (index >= bucket.Entries.Length)
|
||||
{
|
||||
Array.Resize(ref bucket.Entries, index + 1);
|
||||
}
|
||||
|
||||
_hashTable[bucketIndex][index] = entry;
|
||||
bucket.Entries[index] = entry;
|
||||
}
|
||||
else
|
||||
{
|
||||
_hashTable[bucketIndex] = new[]
|
||||
bucket.Entries = new[]
|
||||
{
|
||||
entry,
|
||||
};
|
||||
}
|
||||
|
||||
bucket.Length++;
|
||||
}
|
||||
|
||||
public bool Remove(ref TKey key)
|
||||
{
|
||||
int hashCode = key.GetHashCode();
|
||||
|
||||
ref var bucket = ref _hashTable[hashCode & TotalBucketsMask];
|
||||
var entries = bucket.AsSpan();
|
||||
for (int i = 0; i < entries.Length; i++)
|
||||
{
|
||||
ref var entry = ref entries[i];
|
||||
|
||||
if (entry.Hash == hashCode && entry.Key.Equals(ref key))
|
||||
{
|
||||
entries[(i + 1)..].CopyTo(entries[i..]);
|
||||
bucket.Length--;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool TryGetValue(ref TKey key, out TValue value)
|
||||
{
|
||||
int hashCode = key.GetHashCode();
|
||||
|
||||
var bucket = _hashTable[hashCode & TotalBucketsMask];
|
||||
if (bucket != null)
|
||||
var entries = _hashTable[hashCode & TotalBucketsMask].AsSpan();
|
||||
for (int i = 0; i < entries.Length; i++)
|
||||
{
|
||||
for (int i = 0; i < bucket.Length; i++)
|
||||
{
|
||||
ref var entry = ref bucket[i];
|
||||
ref var entry = ref entries[i];
|
||||
|
||||
if (entry.Hash == hashCode && entry.Key.Equals(ref key))
|
||||
{
|
||||
value = entry.Value;
|
||||
return true;
|
||||
}
|
||||
if (entry.Hash == hashCode && entry.Key.Equals(ref key))
|
||||
{
|
||||
value = entry.Value;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -256,17 +256,8 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
using var cbs = gd.CommandBufferPool.Rent();
|
||||
|
||||
var dstFormat = dst.VkFormat;
|
||||
var dstSamples = dst.Info.Samples;
|
||||
|
||||
for (int l = 0; l < levels; l++)
|
||||
{
|
||||
int srcWidth = Math.Max(1, src.Width >> l);
|
||||
int srcHeight = Math.Max(1, src.Height >> l);
|
||||
|
||||
int dstWidth = Math.Max(1, dst.Width >> l);
|
||||
int dstHeight = Math.Max(1, dst.Height >> l);
|
||||
|
||||
var mipSrcRegion = new Extents2D(
|
||||
srcRegion.X1 >> l,
|
||||
srcRegion.Y1 >> l,
|
||||
@ -290,11 +281,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
gd,
|
||||
cbs,
|
||||
srcView,
|
||||
dst.GetImageViewForAttachment(),
|
||||
dstWidth,
|
||||
dstHeight,
|
||||
dstSamples,
|
||||
dstFormat,
|
||||
dstView,
|
||||
mipSrcRegion,
|
||||
mipDstRegion);
|
||||
}
|
||||
@ -304,12 +291,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
gd,
|
||||
cbs,
|
||||
srcView,
|
||||
dst.GetImageViewForAttachment(),
|
||||
dstWidth,
|
||||
dstHeight,
|
||||
dstSamples,
|
||||
dstFormat,
|
||||
false,
|
||||
dstView,
|
||||
mipSrcRegion,
|
||||
mipDstRegion,
|
||||
linearFilter,
|
||||
@ -367,12 +349,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
gd,
|
||||
cbs,
|
||||
srcView,
|
||||
dstView.GetImageViewForAttachment(),
|
||||
dstView.Width,
|
||||
dstView.Height,
|
||||
dstView.Info.Samples,
|
||||
dstView.VkFormat,
|
||||
dstView.Info.Format.IsDepthOrStencil(),
|
||||
dstView,
|
||||
extents,
|
||||
extents,
|
||||
false);
|
||||
@ -394,12 +371,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
VulkanRenderer gd,
|
||||
CommandBufferScoped cbs,
|
||||
TextureView src,
|
||||
Auto<DisposableImageView> dst,
|
||||
int dstWidth,
|
||||
int dstHeight,
|
||||
int dstSamples,
|
||||
VkFormat dstFormat,
|
||||
bool dstIsDepthOrStencil,
|
||||
TextureView dst,
|
||||
Extents2D srcRegion,
|
||||
Extents2D dstRegion,
|
||||
bool linearFilter,
|
||||
@ -430,11 +402,11 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
(region[2], region[3]) = (region[3], region[2]);
|
||||
}
|
||||
|
||||
var bufferHandle = gd.BufferManager.CreateWithHandle(gd, RegionBufferSize);
|
||||
using var buffer = gd.BufferManager.ReserveOrCreate(gd, cbs, RegionBufferSize);
|
||||
|
||||
gd.BufferManager.SetData<float>(bufferHandle, 0, region);
|
||||
buffer.Holder.SetDataUnchecked<float>(buffer.Offset, region);
|
||||
|
||||
_pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(1, new BufferRange(bufferHandle, 0, RegionBufferSize)) });
|
||||
_pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(1, buffer.Range) });
|
||||
|
||||
Span<Viewport> viewports = stackalloc Viewport[1];
|
||||
|
||||
@ -453,6 +425,8 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
0f,
|
||||
1f);
|
||||
|
||||
bool dstIsDepthOrStencil = dst.Info.Format.IsDepthOrStencil();
|
||||
|
||||
if (dstIsDepthOrStencil)
|
||||
{
|
||||
_pipeline.SetProgram(src.Info.Target.IsMultisample() ? _programDepthBlitMs : _programDepthBlit);
|
||||
@ -471,7 +445,10 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
_pipeline.SetProgram(_programColorBlit);
|
||||
}
|
||||
|
||||
_pipeline.SetRenderTarget(dst, (uint)dstWidth, (uint)dstHeight, (uint)dstSamples, dstIsDepthOrStencil, dstFormat);
|
||||
int dstWidth = dst.Width;
|
||||
int dstHeight = dst.Height;
|
||||
|
||||
_pipeline.SetRenderTarget(dst, (uint)dstWidth, (uint)dstHeight);
|
||||
_pipeline.SetRenderTargetColorMasks(new uint[] { 0xf });
|
||||
_pipeline.SetScissors(stackalloc Rectangle<int>[] { new Rectangle<int>(0, 0, dstWidth, dstHeight) });
|
||||
|
||||
@ -490,19 +467,13 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
}
|
||||
|
||||
_pipeline.Finish(gd, cbs);
|
||||
|
||||
gd.BufferManager.Delete(bufferHandle);
|
||||
}
|
||||
|
||||
private void BlitDepthStencil(
|
||||
VulkanRenderer gd,
|
||||
CommandBufferScoped cbs,
|
||||
TextureView src,
|
||||
Auto<DisposableImageView> dst,
|
||||
int dstWidth,
|
||||
int dstHeight,
|
||||
int dstSamples,
|
||||
VkFormat dstFormat,
|
||||
TextureView dst,
|
||||
Extents2D srcRegion,
|
||||
Extents2D dstRegion)
|
||||
{
|
||||
@ -527,11 +498,11 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
(region[2], region[3]) = (region[3], region[2]);
|
||||
}
|
||||
|
||||
var bufferHandle = gd.BufferManager.CreateWithHandle(gd, RegionBufferSize);
|
||||
using var buffer = gd.BufferManager.ReserveOrCreate(gd, cbs, RegionBufferSize);
|
||||
|
||||
gd.BufferManager.SetData<float>(bufferHandle, 0, region);
|
||||
buffer.Holder.SetDataUnchecked<float>(buffer.Offset, region);
|
||||
|
||||
_pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(1, new BufferRange(bufferHandle, 0, RegionBufferSize)) });
|
||||
_pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(1, buffer.Range) });
|
||||
|
||||
Span<Viewport> viewports = stackalloc Viewport[1];
|
||||
|
||||
@ -550,7 +521,10 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
0f,
|
||||
1f);
|
||||
|
||||
_pipeline.SetRenderTarget(dst, (uint)dstWidth, (uint)dstHeight, (uint)dstSamples, true, dstFormat);
|
||||
int dstWidth = dst.Width;
|
||||
int dstHeight = dst.Height;
|
||||
|
||||
_pipeline.SetRenderTarget(dst, (uint)dstWidth, (uint)dstHeight);
|
||||
_pipeline.SetScissors(stackalloc Rectangle<int>[] { new Rectangle<int>(0, 0, dstWidth, dstHeight) });
|
||||
_pipeline.SetViewports(viewports);
|
||||
_pipeline.SetPrimitiveTopology(PrimitiveTopology.TriangleStrip);
|
||||
@ -582,8 +556,6 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
}
|
||||
|
||||
_pipeline.Finish(gd, cbs);
|
||||
|
||||
gd.BufferManager.Delete(bufferHandle);
|
||||
}
|
||||
|
||||
private static TextureView CreateDepthOrStencilView(TextureView depthStencilTexture, DepthStencilMode depthStencilMode)
|
||||
@ -664,12 +636,11 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
public void Clear(
|
||||
VulkanRenderer gd,
|
||||
Auto<DisposableImageView> dst,
|
||||
TextureView dst,
|
||||
ReadOnlySpan<float> clearColor,
|
||||
uint componentMask,
|
||||
int dstWidth,
|
||||
int dstHeight,
|
||||
VkFormat dstFormat,
|
||||
ComponentType type,
|
||||
Rectangle<int> scissor)
|
||||
{
|
||||
@ -681,11 +652,11 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
_pipeline.SetCommandBuffer(cbs);
|
||||
|
||||
var bufferHandle = gd.BufferManager.CreateWithHandle(gd, ClearColorBufferSize);
|
||||
using var buffer = gd.BufferManager.ReserveOrCreate(gd, cbs, ClearColorBufferSize);
|
||||
|
||||
gd.BufferManager.SetData(bufferHandle, 0, clearColor);
|
||||
buffer.Holder.SetDataUnchecked(buffer.Offset, clearColor);
|
||||
|
||||
_pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(1, new BufferRange(bufferHandle, 0, ClearColorBufferSize)) });
|
||||
_pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(1, buffer.Range) });
|
||||
|
||||
Span<Viewport> viewports = stackalloc Viewport[1];
|
||||
|
||||
@ -714,20 +685,18 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
}
|
||||
|
||||
_pipeline.SetProgram(program);
|
||||
_pipeline.SetRenderTarget(dst, (uint)dstWidth, (uint)dstHeight, false, dstFormat);
|
||||
_pipeline.SetRenderTarget(dst, (uint)dstWidth, (uint)dstHeight);
|
||||
_pipeline.SetRenderTargetColorMasks(new[] { componentMask });
|
||||
_pipeline.SetViewports(viewports);
|
||||
_pipeline.SetScissors(stackalloc Rectangle<int>[] { scissor });
|
||||
_pipeline.SetPrimitiveTopology(PrimitiveTopology.TriangleStrip);
|
||||
_pipeline.Draw(4, 1, 0, 0);
|
||||
_pipeline.Finish();
|
||||
|
||||
gd.BufferManager.Delete(bufferHandle);
|
||||
}
|
||||
|
||||
public void Clear(
|
||||
VulkanRenderer gd,
|
||||
Auto<DisposableImageView> dst,
|
||||
TextureView dst,
|
||||
float depthValue,
|
||||
bool depthMask,
|
||||
int stencilValue,
|
||||
@ -745,11 +714,11 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
_pipeline.SetCommandBuffer(cbs);
|
||||
|
||||
var bufferHandle = gd.BufferManager.CreateWithHandle(gd, ClearColorBufferSize);
|
||||
using var buffer = gd.BufferManager.ReserveOrCreate(gd, cbs, ClearColorBufferSize);
|
||||
|
||||
gd.BufferManager.SetData<float>(bufferHandle, 0, stackalloc float[] { depthValue });
|
||||
buffer.Holder.SetDataUnchecked<float>(buffer.Offset, stackalloc float[] { depthValue });
|
||||
|
||||
_pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(1, new BufferRange(bufferHandle, 0, ClearColorBufferSize)) });
|
||||
_pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(1, buffer.Range) });
|
||||
|
||||
Span<Viewport> viewports = stackalloc Viewport[1];
|
||||
|
||||
@ -763,7 +732,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
1f);
|
||||
|
||||
_pipeline.SetProgram(_programDepthStencilClear);
|
||||
_pipeline.SetRenderTarget(dst, (uint)dstWidth, (uint)dstHeight, true, dstFormat);
|
||||
_pipeline.SetRenderTarget(dst, (uint)dstWidth, (uint)dstHeight);
|
||||
_pipeline.SetViewports(viewports);
|
||||
_pipeline.SetScissors(stackalloc Rectangle<int>[] { scissor });
|
||||
_pipeline.SetPrimitiveTopology(PrimitiveTopology.TriangleStrip);
|
||||
@ -771,8 +740,6 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
_pipeline.SetStencilTest(CreateStencilTestDescriptor(stencilMask != 0, stencilValue, 0xff, stencilMask));
|
||||
_pipeline.Draw(4, 1, 0, 0);
|
||||
_pipeline.Finish();
|
||||
|
||||
gd.BufferManager.Delete(bufferHandle);
|
||||
}
|
||||
|
||||
public void DrawTexture(
|
||||
@ -878,13 +845,13 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
shaderParams[2] = size;
|
||||
shaderParams[3] = srcOffset;
|
||||
|
||||
var bufferHandle = gd.BufferManager.CreateWithHandle(gd, ParamsBufferSize);
|
||||
using var buffer = gd.BufferManager.ReserveOrCreate(gd, cbs, ParamsBufferSize);
|
||||
|
||||
gd.BufferManager.SetData<int>(bufferHandle, 0, shaderParams);
|
||||
buffer.Holder.SetDataUnchecked<int>(buffer.Offset, shaderParams);
|
||||
|
||||
_pipeline.SetCommandBuffer(cbs);
|
||||
|
||||
_pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(0, new BufferRange(bufferHandle, 0, ParamsBufferSize)) });
|
||||
_pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(0, buffer.Range) });
|
||||
|
||||
Span<Auto<DisposableBuffer>> sbRanges = new Auto<DisposableBuffer>[2];
|
||||
|
||||
@ -896,8 +863,6 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
_pipeline.SetProgram(_programStrideChange);
|
||||
_pipeline.DispatchCompute(1 + elems / ConvertElementsPerWorkgroup, 1, 1);
|
||||
|
||||
gd.BufferManager.Delete(bufferHandle);
|
||||
|
||||
_pipeline.Finish(gd, cbs);
|
||||
}
|
||||
else
|
||||
@ -1025,7 +990,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
{
|
||||
const int ParamsBufferSize = 4;
|
||||
|
||||
Span<int> shaderParams = stackalloc int[sizeof(int)];
|
||||
Span<int> shaderParams = stackalloc int[ParamsBufferSize / sizeof(int)];
|
||||
|
||||
int srcBpp = src.Info.BytesPerPixel;
|
||||
int dstBpp = dst.Info.BytesPerPixel;
|
||||
@ -1034,9 +999,9 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
shaderParams[0] = BitOperations.Log2((uint)ratio);
|
||||
|
||||
var bufferHandle = gd.BufferManager.CreateWithHandle(gd, ParamsBufferSize);
|
||||
using var buffer = gd.BufferManager.ReserveOrCreate(gd, cbs, ParamsBufferSize);
|
||||
|
||||
gd.BufferManager.SetData<int>(bufferHandle, 0, shaderParams);
|
||||
buffer.Holder.SetDataUnchecked<int>(buffer.Offset, shaderParams);
|
||||
|
||||
TextureView.InsertImageBarrier(
|
||||
gd.Api,
|
||||
@ -1064,7 +1029,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
var srcFormat = GetFormat(componentSize, srcBpp / componentSize);
|
||||
var dstFormat = GetFormat(componentSize, dstBpp / componentSize);
|
||||
|
||||
_pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(0, new BufferRange(bufferHandle, 0, ParamsBufferSize)) });
|
||||
_pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(0, buffer.Range) });
|
||||
|
||||
for (int l = 0; l < levels; l++)
|
||||
{
|
||||
@ -1093,8 +1058,6 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
}
|
||||
}
|
||||
|
||||
gd.BufferManager.Delete(bufferHandle);
|
||||
|
||||
_pipeline.Finish(gd, cbs);
|
||||
|
||||
TextureView.InsertImageBarrier(
|
||||
@ -1128,9 +1091,9 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
(shaderParams[0], shaderParams[1]) = GetSampleCountXYLog2(samples);
|
||||
(shaderParams[2], shaderParams[3]) = GetSampleCountXYLog2((int)TextureStorage.ConvertToSampleCountFlags(gd.Capabilities.SupportedSampleCounts, (uint)samples));
|
||||
|
||||
var bufferHandle = gd.BufferManager.CreateWithHandle(gd, ParamsBufferSize);
|
||||
using var buffer = gd.BufferManager.ReserveOrCreate(gd, cbs, ParamsBufferSize);
|
||||
|
||||
gd.BufferManager.SetData<int>(bufferHandle, 0, shaderParams);
|
||||
buffer.Holder.SetDataUnchecked<int>(buffer.Offset, shaderParams);
|
||||
|
||||
TextureView.InsertImageBarrier(
|
||||
gd.Api,
|
||||
@ -1147,7 +1110,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
1);
|
||||
|
||||
_pipeline.SetCommandBuffer(cbs);
|
||||
_pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(0, new BufferRange(bufferHandle, 0, ParamsBufferSize)) });
|
||||
_pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(0, buffer.Range) });
|
||||
|
||||
if (isDepthOrStencil)
|
||||
{
|
||||
@ -1175,12 +1138,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
var srcView = Create2DLayerView(src, srcLayer + z, 0);
|
||||
var dstView = Create2DLayerView(dst, dstLayer + z, 0);
|
||||
|
||||
_pipeline.SetRenderTarget(
|
||||
dstView.GetImageViewForAttachment(),
|
||||
(uint)dst.Width,
|
||||
(uint)dst.Height,
|
||||
true,
|
||||
dst.VkFormat);
|
||||
_pipeline.SetRenderTarget(dstView, (uint)dst.Width, (uint)dst.Height);
|
||||
|
||||
CopyMSDraw(srcView, aspectFlags, fromMS: true);
|
||||
|
||||
@ -1226,8 +1184,6 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
}
|
||||
}
|
||||
|
||||
gd.BufferManager.Delete(bufferHandle);
|
||||
|
||||
_pipeline.Finish(gd, cbs);
|
||||
|
||||
TextureView.InsertImageBarrier(
|
||||
@ -1261,9 +1217,9 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
(shaderParams[0], shaderParams[1]) = GetSampleCountXYLog2(samples);
|
||||
(shaderParams[2], shaderParams[3]) = GetSampleCountXYLog2((int)TextureStorage.ConvertToSampleCountFlags(gd.Capabilities.SupportedSampleCounts, (uint)samples));
|
||||
|
||||
var bufferHandle = gd.BufferManager.CreateWithHandle(gd, ParamsBufferSize);
|
||||
using var buffer = gd.BufferManager.ReserveOrCreate(gd, cbs, ParamsBufferSize);
|
||||
|
||||
gd.BufferManager.SetData<int>(bufferHandle, 0, shaderParams);
|
||||
buffer.Holder.SetDataUnchecked<int>(buffer.Offset, shaderParams);
|
||||
|
||||
TextureView.InsertImageBarrier(
|
||||
gd.Api,
|
||||
@ -1299,7 +1255,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
_pipeline.SetViewports(viewports);
|
||||
_pipeline.SetPrimitiveTopology(PrimitiveTopology.TriangleStrip);
|
||||
|
||||
_pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(0, new BufferRange(bufferHandle, 0, ParamsBufferSize)) });
|
||||
_pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(0, buffer.Range) });
|
||||
|
||||
if (isDepthOrStencil)
|
||||
{
|
||||
@ -1308,13 +1264,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
var srcView = Create2DLayerView(src, srcLayer + z, 0);
|
||||
var dstView = Create2DLayerView(dst, dstLayer + z, 0);
|
||||
|
||||
_pipeline.SetRenderTarget(
|
||||
dstView.GetImageViewForAttachment(),
|
||||
(uint)dst.Width,
|
||||
(uint)dst.Height,
|
||||
(uint)samples,
|
||||
true,
|
||||
dst.VkFormat);
|
||||
_pipeline.SetRenderTarget(dstView, (uint)dst.Width, (uint)dst.Height);
|
||||
|
||||
CopyMSDraw(srcView, aspectFlags, fromMS: false);
|
||||
|
||||
@ -1342,13 +1292,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
var dstView = Create2DLayerView(dst, dstLayer + z, 0);
|
||||
|
||||
_pipeline.SetTextureAndSamplerIdentitySwizzle(ShaderStage.Fragment, 0, srcView, null);
|
||||
_pipeline.SetRenderTarget(
|
||||
dstView.GetView(format).GetImageViewForAttachment(),
|
||||
(uint)dst.Width,
|
||||
(uint)dst.Height,
|
||||
(uint)samples,
|
||||
false,
|
||||
vkFormat);
|
||||
_pipeline.SetRenderTarget(dstView.GetView(format), (uint)dst.Width, (uint)dst.Height);
|
||||
|
||||
_pipeline.Draw(4, 1, 0, 0);
|
||||
|
||||
@ -1364,8 +1308,6 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
}
|
||||
}
|
||||
|
||||
gd.BufferManager.Delete(bufferHandle);
|
||||
|
||||
_pipeline.Finish(gd, cbs);
|
||||
|
||||
TextureView.InsertImageBarrier(
|
||||
@ -1487,9 +1429,9 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
};
|
||||
|
||||
var info = new TextureCreateInfo(
|
||||
from.Info.Width,
|
||||
from.Info.Height,
|
||||
from.Info.Depth,
|
||||
Math.Max(1, from.Info.Width >> level),
|
||||
Math.Max(1, from.Info.Height >> level),
|
||||
1,
|
||||
1,
|
||||
from.Info.Samples,
|
||||
from.Info.BlockWidth,
|
||||
@ -1616,10 +1558,11 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
pattern.OffsetIndex.CopyTo(shaderParams[..pattern.OffsetIndex.Length]);
|
||||
|
||||
var patternBufferHandle = gd.BufferManager.CreateWithHandle(gd, ParamsBufferSize, out var patternBuffer);
|
||||
using var patternScoped = gd.BufferManager.ReserveOrCreate(gd, cbs, ParamsBufferSize);
|
||||
var patternBuffer = patternScoped.Holder;
|
||||
var patternBufferAuto = patternBuffer.GetBuffer();
|
||||
|
||||
gd.BufferManager.SetData<int>(patternBufferHandle, 0, shaderParams);
|
||||
patternBuffer.SetDataUnchecked<int>(patternScoped.Offset, shaderParams);
|
||||
|
||||
_pipeline.SetCommandBuffer(cbs);
|
||||
|
||||
@ -1635,7 +1578,8 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
indirectDataSize);
|
||||
|
||||
_pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(0, drawCountBufferAligned) });
|
||||
_pipeline.SetStorageBuffers(1, new[] { srcIndirectBuffer.GetBuffer(), dstIndirectBuffer.GetBuffer(), patternBuffer.GetBuffer() });
|
||||
_pipeline.SetStorageBuffers(1, new[] { srcIndirectBuffer.GetBuffer(), dstIndirectBuffer.GetBuffer() });
|
||||
_pipeline.SetStorageBuffers(stackalloc[] { new BufferAssignment(3, patternScoped.Range) });
|
||||
|
||||
_pipeline.SetProgram(_programConvertIndirectData);
|
||||
_pipeline.DispatchCompute(1, 1, 1);
|
||||
@ -1643,12 +1587,12 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
BufferHolder.InsertBufferBarrier(
|
||||
gd,
|
||||
cbs.CommandBuffer,
|
||||
patternBufferAuto.Get(cbs, ParamsIndirectDispatchOffset, ParamsIndirectDispatchSize).Value,
|
||||
patternBufferAuto.Get(cbs, patternScoped.Offset + ParamsIndirectDispatchOffset, ParamsIndirectDispatchSize).Value,
|
||||
AccessFlags.ShaderWriteBit,
|
||||
AccessFlags.IndirectCommandReadBit,
|
||||
PipelineStageFlags.ComputeShaderBit,
|
||||
PipelineStageFlags.DrawIndirectBit,
|
||||
ParamsIndirectDispatchOffset,
|
||||
patternScoped.Offset + ParamsIndirectDispatchOffset,
|
||||
ParamsIndirectDispatchSize);
|
||||
|
||||
BufferHolder.InsertBufferBarrier(
|
||||
@ -1662,11 +1606,11 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
0,
|
||||
convertedCount * outputIndexSize);
|
||||
|
||||
_pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(0, new BufferRange(patternBufferHandle, 0, ParamsBufferSize)) });
|
||||
_pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(0, new BufferRange(patternScoped.Handle, patternScoped.Offset, ParamsBufferSize)) });
|
||||
_pipeline.SetStorageBuffers(1, new[] { srcIndexBuffer.GetBuffer(), dstIndexBuffer.GetBuffer() });
|
||||
|
||||
_pipeline.SetProgram(_programConvertIndexBuffer);
|
||||
_pipeline.DispatchComputeIndirect(patternBufferAuto, ParamsIndirectDispatchOffset);
|
||||
_pipeline.DispatchComputeIndirect(patternBufferAuto, patternScoped.Offset + ParamsIndirectDispatchOffset);
|
||||
|
||||
BufferHolder.InsertBufferBarrier(
|
||||
gd,
|
||||
@ -1679,8 +1623,6 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
0,
|
||||
convertedCount * outputIndexSize);
|
||||
|
||||
gd.BufferManager.Delete(patternBufferHandle);
|
||||
|
||||
_pipeline.Finish(gd, cbs);
|
||||
}
|
||||
|
||||
@ -1726,13 +1668,13 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
shaderParams[0] = pixelCount;
|
||||
shaderParams[1] = dstOffset;
|
||||
|
||||
var bufferHandle = gd.BufferManager.CreateWithHandle(gd, ParamsBufferSize);
|
||||
using var buffer = gd.BufferManager.ReserveOrCreate(gd, cbs, ParamsBufferSize);
|
||||
|
||||
gd.BufferManager.SetData<int>(bufferHandle, 0, shaderParams);
|
||||
buffer.Holder.SetDataUnchecked<int>(buffer.Offset, shaderParams);
|
||||
|
||||
_pipeline.SetCommandBuffer(cbs);
|
||||
|
||||
_pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(0, new BufferRange(bufferHandle, 0, ParamsBufferSize)) });
|
||||
_pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(0, buffer.Range) });
|
||||
|
||||
Span<Auto<DisposableBuffer>> sbRanges = new Auto<DisposableBuffer>[2];
|
||||
|
||||
@ -1744,8 +1686,6 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
_pipeline.SetProgram(_programConvertD32S8ToD24S8);
|
||||
_pipeline.DispatchCompute(1 + inSize / ConvertElementsPerWorkgroup, 1, 1);
|
||||
|
||||
gd.BufferManager.Delete(bufferHandle);
|
||||
|
||||
_pipeline.Finish(gd, cbs);
|
||||
|
||||
BufferHolder.InsertBufferBarrier(
|
||||
|
@ -34,7 +34,8 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
protected PipelineDynamicState DynamicState;
|
||||
private PipelineState _newState;
|
||||
private bool _stateDirty;
|
||||
private bool _graphicsStateDirty;
|
||||
private bool _computeStateDirty;
|
||||
private PrimitiveTopology _topology;
|
||||
|
||||
private ulong _currentPipelineHandle;
|
||||
@ -54,6 +55,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
protected FramebufferParams FramebufferParams;
|
||||
private Auto<DisposableFramebuffer> _framebuffer;
|
||||
private Auto<DisposableRenderPass> _renderPass;
|
||||
private RenderPassHolder _nullRenderPass;
|
||||
private int _writtenAttachmentCount;
|
||||
|
||||
private bool _framebufferUsingColorWriteMask;
|
||||
@ -353,7 +355,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
}
|
||||
|
||||
EndRenderPass();
|
||||
RecreatePipelineIfNeeded(PipelineBindPoint.Compute);
|
||||
RecreateComputePipelineIfNeeded();
|
||||
|
||||
Gd.Api.CmdDispatch(CommandBuffer, (uint)groupsX, (uint)groupsY, (uint)groupsZ);
|
||||
}
|
||||
@ -366,19 +368,23 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
}
|
||||
|
||||
EndRenderPass();
|
||||
RecreatePipelineIfNeeded(PipelineBindPoint.Compute);
|
||||
RecreateComputePipelineIfNeeded();
|
||||
|
||||
Gd.Api.CmdDispatchIndirect(CommandBuffer, indirectBuffer.Get(Cbs, indirectBufferOffset, 12).Value, (ulong)indirectBufferOffset);
|
||||
}
|
||||
|
||||
public void Draw(int vertexCount, int instanceCount, int firstVertex, int firstInstance)
|
||||
{
|
||||
if (!_program.IsLinked || vertexCount == 0)
|
||||
if (vertexCount == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!RecreateGraphicsPipelineIfNeeded())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
RecreatePipelineIfNeeded(PipelineBindPoint.Graphics);
|
||||
BeginRenderPass();
|
||||
DrawCount++;
|
||||
|
||||
@ -437,13 +443,18 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
public void DrawIndexed(int indexCount, int instanceCount, int firstIndex, int firstVertex, int firstInstance)
|
||||
{
|
||||
if (!_program.IsLinked || indexCount == 0)
|
||||
if (indexCount == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
UpdateIndexBufferPattern();
|
||||
RecreatePipelineIfNeeded(PipelineBindPoint.Graphics);
|
||||
|
||||
if (!RecreateGraphicsPipelineIfNeeded())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
BeginRenderPass();
|
||||
DrawCount++;
|
||||
|
||||
@ -476,17 +487,17 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
public void DrawIndexedIndirect(BufferRange indirectBuffer)
|
||||
{
|
||||
if (!_program.IsLinked)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var buffer = Gd.BufferManager
|
||||
.GetBuffer(CommandBuffer, indirectBuffer.Handle, indirectBuffer.Offset, indirectBuffer.Size, false)
|
||||
.Get(Cbs, indirectBuffer.Offset, indirectBuffer.Size).Value;
|
||||
|
||||
UpdateIndexBufferPattern();
|
||||
RecreatePipelineIfNeeded(PipelineBindPoint.Graphics);
|
||||
|
||||
if (!RecreateGraphicsPipelineIfNeeded())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
BeginRenderPass();
|
||||
DrawCount++;
|
||||
|
||||
@ -522,11 +533,6 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
public void DrawIndexedIndirectCount(BufferRange indirectBuffer, BufferRange parameterBuffer, int maxDrawCount, int stride)
|
||||
{
|
||||
if (!_program.IsLinked)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var countBuffer = Gd.BufferManager
|
||||
.GetBuffer(CommandBuffer, parameterBuffer.Handle, parameterBuffer.Offset, parameterBuffer.Size, false)
|
||||
.Get(Cbs, parameterBuffer.Offset, parameterBuffer.Size).Value;
|
||||
@ -536,7 +542,12 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
.Get(Cbs, indirectBuffer.Offset, indirectBuffer.Size).Value;
|
||||
|
||||
UpdateIndexBufferPattern();
|
||||
RecreatePipelineIfNeeded(PipelineBindPoint.Graphics);
|
||||
|
||||
if (!RecreateGraphicsPipelineIfNeeded())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
BeginRenderPass();
|
||||
DrawCount++;
|
||||
|
||||
@ -614,18 +625,17 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
public void DrawIndirect(BufferRange indirectBuffer)
|
||||
{
|
||||
if (!_program.IsLinked)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: Support quads and other unsupported topologies.
|
||||
|
||||
var buffer = Gd.BufferManager
|
||||
.GetBuffer(CommandBuffer, indirectBuffer.Handle, indirectBuffer.Offset, indirectBuffer.Size, false)
|
||||
.Get(Cbs, indirectBuffer.Offset, indirectBuffer.Size, false).Value;
|
||||
|
||||
RecreatePipelineIfNeeded(PipelineBindPoint.Graphics);
|
||||
if (!RecreateGraphicsPipelineIfNeeded())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
BeginRenderPass();
|
||||
ResumeTransformFeedbackInternal();
|
||||
DrawCount++;
|
||||
@ -641,11 +651,6 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
if (!_program.IsLinked)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var buffer = Gd.BufferManager
|
||||
.GetBuffer(CommandBuffer, indirectBuffer.Handle, indirectBuffer.Offset, indirectBuffer.Size, false)
|
||||
.Get(Cbs, indirectBuffer.Offset, indirectBuffer.Size, false).Value;
|
||||
@ -656,7 +661,11 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
// TODO: Support quads and other unsupported topologies.
|
||||
|
||||
RecreatePipelineIfNeeded(PipelineBindPoint.Graphics);
|
||||
if (!RecreateGraphicsPipelineIfNeeded())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
BeginRenderPass();
|
||||
ResumeTransformFeedbackInternal();
|
||||
DrawCount++;
|
||||
@ -1480,106 +1489,43 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
protected unsafe void CreateRenderPass()
|
||||
{
|
||||
const int MaxAttachments = Constants.MaxRenderTargets + 1;
|
||||
|
||||
AttachmentDescription[] attachmentDescs = null;
|
||||
|
||||
var subpass = new SubpassDescription
|
||||
{
|
||||
PipelineBindPoint = PipelineBindPoint.Graphics,
|
||||
};
|
||||
|
||||
AttachmentReference* attachmentReferences = stackalloc AttachmentReference[MaxAttachments];
|
||||
|
||||
var hasFramebuffer = FramebufferParams != null;
|
||||
|
||||
if (hasFramebuffer && FramebufferParams.AttachmentsCount != 0)
|
||||
{
|
||||
attachmentDescs = new AttachmentDescription[FramebufferParams.AttachmentsCount];
|
||||
|
||||
for (int i = 0; i < FramebufferParams.AttachmentsCount; i++)
|
||||
{
|
||||
attachmentDescs[i] = new AttachmentDescription(
|
||||
0,
|
||||
FramebufferParams.AttachmentFormats[i],
|
||||
TextureStorage.ConvertToSampleCountFlags(Gd.Capabilities.SupportedSampleCounts, FramebufferParams.AttachmentSamples[i]),
|
||||
AttachmentLoadOp.Load,
|
||||
AttachmentStoreOp.Store,
|
||||
AttachmentLoadOp.Load,
|
||||
AttachmentStoreOp.Store,
|
||||
ImageLayout.General,
|
||||
ImageLayout.General);
|
||||
}
|
||||
|
||||
int colorAttachmentsCount = FramebufferParams.ColorAttachmentsCount;
|
||||
|
||||
if (colorAttachmentsCount > MaxAttachments - 1)
|
||||
{
|
||||
colorAttachmentsCount = MaxAttachments - 1;
|
||||
}
|
||||
|
||||
if (colorAttachmentsCount != 0)
|
||||
{
|
||||
int maxAttachmentIndex = FramebufferParams.MaxColorAttachmentIndex;
|
||||
subpass.ColorAttachmentCount = (uint)maxAttachmentIndex + 1;
|
||||
subpass.PColorAttachments = &attachmentReferences[0];
|
||||
|
||||
// Fill with VK_ATTACHMENT_UNUSED to cover any gaps.
|
||||
for (int i = 0; i <= maxAttachmentIndex; i++)
|
||||
{
|
||||
subpass.PColorAttachments[i] = new AttachmentReference(Vk.AttachmentUnused, ImageLayout.Undefined);
|
||||
}
|
||||
|
||||
for (int i = 0; i < colorAttachmentsCount; i++)
|
||||
{
|
||||
int bindIndex = FramebufferParams.AttachmentIndices[i];
|
||||
|
||||
subpass.PColorAttachments[bindIndex] = new AttachmentReference((uint)i, ImageLayout.General);
|
||||
}
|
||||
}
|
||||
|
||||
if (FramebufferParams.HasDepthStencil)
|
||||
{
|
||||
uint dsIndex = (uint)FramebufferParams.AttachmentsCount - 1;
|
||||
|
||||
subpass.PDepthStencilAttachment = &attachmentReferences[MaxAttachments - 1];
|
||||
*subpass.PDepthStencilAttachment = new AttachmentReference(dsIndex, ImageLayout.General);
|
||||
}
|
||||
}
|
||||
|
||||
var subpassDependency = PipelineConverter.CreateSubpassDependency();
|
||||
|
||||
fixed (AttachmentDescription* pAttachmentDescs = attachmentDescs)
|
||||
{
|
||||
var renderPassCreateInfo = new RenderPassCreateInfo
|
||||
{
|
||||
SType = StructureType.RenderPassCreateInfo,
|
||||
PAttachments = pAttachmentDescs,
|
||||
AttachmentCount = attachmentDescs != null ? (uint)attachmentDescs.Length : 0,
|
||||
PSubpasses = &subpass,
|
||||
SubpassCount = 1,
|
||||
PDependencies = &subpassDependency,
|
||||
DependencyCount = 1,
|
||||
};
|
||||
|
||||
Gd.Api.CreateRenderPass(Device, renderPassCreateInfo, null, out var renderPass).ThrowOnError();
|
||||
|
||||
_renderPass?.Dispose();
|
||||
_renderPass = new Auto<DisposableRenderPass>(new DisposableRenderPass(Gd.Api, Device, renderPass));
|
||||
}
|
||||
|
||||
EndRenderPass();
|
||||
|
||||
_framebuffer?.Dispose();
|
||||
_framebuffer = hasFramebuffer ? FramebufferParams.Create(Gd.Api, Cbs, _renderPass) : null;
|
||||
if (!hasFramebuffer || FramebufferParams.AttachmentsCount == 0)
|
||||
{
|
||||
// Use the null framebuffer.
|
||||
_nullRenderPass ??= new RenderPassHolder(Gd, Device, new RenderPassCacheKey(), FramebufferParams);
|
||||
|
||||
_renderPass = _nullRenderPass.GetRenderPass();
|
||||
_framebuffer = _nullRenderPass.GetFramebuffer(Gd, Cbs, FramebufferParams);
|
||||
}
|
||||
else
|
||||
{
|
||||
(_renderPass, _framebuffer) = FramebufferParams.GetPassAndFramebuffer(Gd, Device, Cbs);
|
||||
}
|
||||
}
|
||||
|
||||
protected void SignalStateChange()
|
||||
{
|
||||
_stateDirty = true;
|
||||
_graphicsStateDirty = true;
|
||||
_computeStateDirty = true;
|
||||
}
|
||||
|
||||
private void RecreatePipelineIfNeeded(PipelineBindPoint pbp)
|
||||
private void RecreateComputePipelineIfNeeded()
|
||||
{
|
||||
if (_computeStateDirty || Pbp != PipelineBindPoint.Compute)
|
||||
{
|
||||
CreatePipeline(PipelineBindPoint.Compute);
|
||||
_computeStateDirty = false;
|
||||
Pbp = PipelineBindPoint.Compute;
|
||||
}
|
||||
|
||||
_descriptorSetUpdater.UpdateAndBindDescriptorSets(Cbs, PipelineBindPoint.Compute);
|
||||
}
|
||||
|
||||
private bool RecreateGraphicsPipelineIfNeeded()
|
||||
{
|
||||
if (AutoFlush.ShouldFlushDraw(DrawCount))
|
||||
{
|
||||
@ -1620,17 +1566,23 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
_vertexBufferUpdater.Commit(Cbs);
|
||||
}
|
||||
|
||||
if (_stateDirty || Pbp != pbp)
|
||||
if (_graphicsStateDirty || Pbp != PipelineBindPoint.Graphics)
|
||||
{
|
||||
CreatePipeline(pbp);
|
||||
_stateDirty = false;
|
||||
Pbp = pbp;
|
||||
if (!CreatePipeline(PipelineBindPoint.Graphics))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
_graphicsStateDirty = false;
|
||||
Pbp = PipelineBindPoint.Graphics;
|
||||
}
|
||||
|
||||
_descriptorSetUpdater.UpdateAndBindDescriptorSets(Cbs, pbp);
|
||||
_descriptorSetUpdater.UpdateAndBindDescriptorSets(Cbs, PipelineBindPoint.Graphics);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CreatePipeline(PipelineBindPoint pbp)
|
||||
private bool CreatePipeline(PipelineBindPoint pbp)
|
||||
{
|
||||
// We can only create a pipeline if the have the shader stages set.
|
||||
if (_newState.Stages != null)
|
||||
@ -1640,10 +1592,25 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
CreateRenderPass();
|
||||
}
|
||||
|
||||
if (!_program.IsLinked)
|
||||
{
|
||||
// Background compile failed, we likely can't create the pipeline because the shader is broken
|
||||
// or the driver failed to compile it.
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
var pipeline = pbp == PipelineBindPoint.Compute
|
||||
? _newState.CreateComputePipeline(Gd, Device, _program, PipelineCache)
|
||||
: _newState.CreateGraphicsPipeline(Gd, Device, _program, PipelineCache, _renderPass.Get(Cbs).Value);
|
||||
|
||||
if (pipeline == null)
|
||||
{
|
||||
// Host failed to create the pipeline, likely due to driver bugs.
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
ulong pipelineHandle = pipeline.GetUnsafe().Value.Handle;
|
||||
|
||||
if (_currentPipelineHandle != pipelineHandle)
|
||||
@ -1655,6 +1622,8 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
Gd.Api.CmdBindPipeline(CommandBuffer, pbp, Pipeline.Get(Cbs).Value);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private unsafe void BeginRenderPass()
|
||||
@ -1726,8 +1695,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
_renderPass?.Dispose();
|
||||
_framebuffer?.Dispose();
|
||||
_nullRenderPass?.Dispose();
|
||||
_newState.Dispose();
|
||||
_descriptorSetUpdater.Dispose();
|
||||
_vertexBufferUpdater.Dispose();
|
||||
|
@ -51,7 +51,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
{
|
||||
// We can't use CmdClearAttachments if not writing all components,
|
||||
// because on Vulkan, the pipeline state does not affect clears.
|
||||
var dstTexture = FramebufferParams.GetAttachment(index);
|
||||
var dstTexture = FramebufferParams.GetColorView(index);
|
||||
if (dstTexture == null)
|
||||
{
|
||||
return;
|
||||
@ -71,7 +71,6 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
componentMask,
|
||||
(int)FramebufferParams.Width,
|
||||
(int)FramebufferParams.Height,
|
||||
FramebufferParams.AttachmentFormats[index],
|
||||
FramebufferParams.GetAttachmentComponentType(index),
|
||||
ClearScissor);
|
||||
}
|
||||
@ -92,7 +91,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
{
|
||||
// We can't use CmdClearAttachments if not clearing all (mask is all ones, 0xFF) or none (mask is 0) of the stencil bits,
|
||||
// because on Vulkan, the pipeline state does not affect clears.
|
||||
var dstTexture = FramebufferParams.GetDepthStencilAttachment();
|
||||
var dstTexture = FramebufferParams.GetDepthStencilView();
|
||||
if (dstTexture == null)
|
||||
{
|
||||
return;
|
||||
@ -246,7 +245,10 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
SignalCommandBufferChange();
|
||||
|
||||
DynamicState.ReplayIfDirty(Gd.Api, CommandBuffer);
|
||||
if (Pipeline != null && Pbp == PipelineBindPoint.Graphics)
|
||||
{
|
||||
DynamicState.ReplayIfDirty(Gd.Api, CommandBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
public void FlushCommandsImpl()
|
||||
|
@ -9,21 +9,16 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
{
|
||||
}
|
||||
|
||||
public void SetRenderTarget(Auto<DisposableImageView> view, uint width, uint height, bool isDepthStencil, VkFormat format)
|
||||
public void SetRenderTarget(TextureView view, uint width, uint height)
|
||||
{
|
||||
SetRenderTarget(view, width, height, 1u, isDepthStencil, format);
|
||||
}
|
||||
|
||||
public void SetRenderTarget(Auto<DisposableImageView> view, uint width, uint height, uint samples, bool isDepthStencil, VkFormat format)
|
||||
{
|
||||
CreateFramebuffer(view, width, height, samples, isDepthStencil, format);
|
||||
CreateFramebuffer(view, width, height);
|
||||
CreateRenderPass();
|
||||
SignalStateChange();
|
||||
}
|
||||
|
||||
private void CreateFramebuffer(Auto<DisposableImageView> view, uint width, uint height, uint samples, bool isDepthStencil, VkFormat format)
|
||||
private void CreateFramebuffer(TextureView view, uint width, uint height)
|
||||
{
|
||||
FramebufferParams = new FramebufferParams(Device, view, width, height, samples, isDepthStencil, format);
|
||||
FramebufferParams = new FramebufferParams(Device, view, width, height);
|
||||
UpdatePipelineAttachmentFormats();
|
||||
}
|
||||
|
||||
|
@ -312,7 +312,6 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
}
|
||||
|
||||
public NativeArray<PipelineShaderStageCreateInfo> Stages;
|
||||
public NativeArray<PipelineShaderStageRequiredSubgroupSizeCreateInfoEXT> StageRequiredSubgroupSizes;
|
||||
public PipelineLayout PipelineLayout;
|
||||
public SpecData SpecializationData;
|
||||
|
||||
@ -321,16 +320,6 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
public void Initialize()
|
||||
{
|
||||
Stages = new NativeArray<PipelineShaderStageCreateInfo>(Constants.MaxShaderStages);
|
||||
StageRequiredSubgroupSizes = new NativeArray<PipelineShaderStageRequiredSubgroupSizeCreateInfoEXT>(Constants.MaxShaderStages);
|
||||
|
||||
for (int index = 0; index < Constants.MaxShaderStages; index++)
|
||||
{
|
||||
StageRequiredSubgroupSizes[index] = new PipelineShaderStageRequiredSubgroupSizeCreateInfoEXT
|
||||
{
|
||||
SType = StructureType.PipelineShaderStageRequiredSubgroupSizeCreateInfoExt,
|
||||
RequiredSubgroupSize = RequiredSubgroupSize,
|
||||
};
|
||||
}
|
||||
|
||||
AdvancedBlendSrcPreMultiplied = true;
|
||||
AdvancedBlendDstPreMultiplied = true;
|
||||
@ -397,7 +386,8 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
Device device,
|
||||
ShaderCollection program,
|
||||
PipelineCache cache,
|
||||
RenderPass renderPass)
|
||||
RenderPass renderPass,
|
||||
bool throwOnError = false)
|
||||
{
|
||||
if (program.TryGetGraphicsPipeline(ref Internal, out var pipeline))
|
||||
{
|
||||
@ -630,7 +620,18 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
BasePipelineIndex = -1,
|
||||
};
|
||||
|
||||
gd.Api.CreateGraphicsPipelines(device, cache, 1, &pipelineCreateInfo, null, &pipelineHandle).ThrowOnError();
|
||||
Result result = gd.Api.CreateGraphicsPipelines(device, cache, 1, &pipelineCreateInfo, null, &pipelineHandle);
|
||||
|
||||
if (throwOnError)
|
||||
{
|
||||
result.ThrowOnError();
|
||||
}
|
||||
else if (result.IsError())
|
||||
{
|
||||
program.AddGraphicsPipeline(ref Internal, null);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// Restore previous blend enable values if we changed it.
|
||||
while (blendEnables != 0)
|
||||
@ -708,7 +709,6 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
public readonly void Dispose()
|
||||
{
|
||||
Stages.Dispose();
|
||||
StageRequiredSubgroupSizes.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -67,9 +67,18 @@ namespace Ryujinx.Graphics.Vulkan.Queries
|
||||
lock (_queryPool)
|
||||
{
|
||||
count = Math.Min(count, _queryPool.Count);
|
||||
for (int i = 0; i < count; i++)
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
_queryPool.ElementAt(i).PoolReset(cmd, ResetSequence);
|
||||
foreach (BufferedQuery query in _queryPool)
|
||||
{
|
||||
query.PoolReset(cmd, ResetSequence);
|
||||
|
||||
if (--count == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
43
src/Ryujinx.Graphics.Vulkan/RenderPassCacheKey.cs
Normal file
43
src/Ryujinx.Graphics.Vulkan/RenderPassCacheKey.cs
Normal file
@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace Ryujinx.Graphics.Vulkan
|
||||
{
|
||||
internal readonly struct RenderPassCacheKey : IRefEquatable<RenderPassCacheKey>
|
||||
{
|
||||
private readonly TextureView _depthStencil;
|
||||
private readonly TextureView[] _colors;
|
||||
|
||||
public RenderPassCacheKey(TextureView depthStencil, TextureView[] colors)
|
||||
{
|
||||
_depthStencil = depthStencil;
|
||||
_colors = colors;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
HashCode hc = new();
|
||||
|
||||
hc.Add(_depthStencil);
|
||||
|
||||
if (_colors != null)
|
||||
{
|
||||
foreach (var color in _colors)
|
||||
{
|
||||
hc.Add(color);
|
||||
}
|
||||
}
|
||||
|
||||
return hc.ToHashCode();
|
||||
}
|
||||
|
||||
public bool Equals(ref RenderPassCacheKey other)
|
||||
{
|
||||
bool colorsNull = _colors == null;
|
||||
bool otherNull = other._colors == null;
|
||||
return other._depthStencil == _depthStencil &&
|
||||
colorsNull == otherNull &&
|
||||
(colorsNull || other._colors.SequenceEqual(_colors));
|
||||
}
|
||||
}
|
||||
}
|
180
src/Ryujinx.Graphics.Vulkan/RenderPassHolder.cs
Normal file
180
src/Ryujinx.Graphics.Vulkan/RenderPassHolder.cs
Normal file
@ -0,0 +1,180 @@
|
||||
using Silk.NET.Vulkan;
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.Graphics.Vulkan
|
||||
{
|
||||
internal class RenderPassHolder
|
||||
{
|
||||
private readonly struct FramebufferCacheKey : IRefEquatable<FramebufferCacheKey>
|
||||
{
|
||||
private readonly uint _width;
|
||||
private readonly uint _height;
|
||||
private readonly uint _layers;
|
||||
|
||||
public FramebufferCacheKey(uint width, uint height, uint layers)
|
||||
{
|
||||
_width = width;
|
||||
_height = height;
|
||||
_layers = layers;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return HashCode.Combine(_width, _height, _layers);
|
||||
}
|
||||
|
||||
public bool Equals(ref FramebufferCacheKey other)
|
||||
{
|
||||
return other._width == _width && other._height == _height && other._layers == _layers;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly TextureView[] _textures;
|
||||
private readonly Auto<DisposableRenderPass> _renderPass;
|
||||
private readonly HashTableSlim<FramebufferCacheKey, Auto<DisposableFramebuffer>> _framebuffers;
|
||||
private readonly RenderPassCacheKey _key;
|
||||
|
||||
public unsafe RenderPassHolder(VulkanRenderer gd, Device device, RenderPassCacheKey key, FramebufferParams fb)
|
||||
{
|
||||
// Create render pass using framebuffer params.
|
||||
|
||||
const int MaxAttachments = Constants.MaxRenderTargets + 1;
|
||||
|
||||
AttachmentDescription[] attachmentDescs = null;
|
||||
|
||||
var subpass = new SubpassDescription
|
||||
{
|
||||
PipelineBindPoint = PipelineBindPoint.Graphics,
|
||||
};
|
||||
|
||||
AttachmentReference* attachmentReferences = stackalloc AttachmentReference[MaxAttachments];
|
||||
|
||||
var hasFramebuffer = fb != null;
|
||||
|
||||
if (hasFramebuffer && fb.AttachmentsCount != 0)
|
||||
{
|
||||
attachmentDescs = new AttachmentDescription[fb.AttachmentsCount];
|
||||
|
||||
for (int i = 0; i < fb.AttachmentsCount; i++)
|
||||
{
|
||||
attachmentDescs[i] = new AttachmentDescription(
|
||||
0,
|
||||
fb.AttachmentFormats[i],
|
||||
TextureStorage.ConvertToSampleCountFlags(gd.Capabilities.SupportedSampleCounts, fb.AttachmentSamples[i]),
|
||||
AttachmentLoadOp.Load,
|
||||
AttachmentStoreOp.Store,
|
||||
AttachmentLoadOp.Load,
|
||||
AttachmentStoreOp.Store,
|
||||
ImageLayout.General,
|
||||
ImageLayout.General);
|
||||
}
|
||||
|
||||
int colorAttachmentsCount = fb.ColorAttachmentsCount;
|
||||
|
||||
if (colorAttachmentsCount > MaxAttachments - 1)
|
||||
{
|
||||
colorAttachmentsCount = MaxAttachments - 1;
|
||||
}
|
||||
|
||||
if (colorAttachmentsCount != 0)
|
||||
{
|
||||
int maxAttachmentIndex = fb.MaxColorAttachmentIndex;
|
||||
subpass.ColorAttachmentCount = (uint)maxAttachmentIndex + 1;
|
||||
subpass.PColorAttachments = &attachmentReferences[0];
|
||||
|
||||
// Fill with VK_ATTACHMENT_UNUSED to cover any gaps.
|
||||
for (int i = 0; i <= maxAttachmentIndex; i++)
|
||||
{
|
||||
subpass.PColorAttachments[i] = new AttachmentReference(Vk.AttachmentUnused, ImageLayout.Undefined);
|
||||
}
|
||||
|
||||
for (int i = 0; i < colorAttachmentsCount; i++)
|
||||
{
|
||||
int bindIndex = fb.AttachmentIndices[i];
|
||||
|
||||
subpass.PColorAttachments[bindIndex] = new AttachmentReference((uint)i, ImageLayout.General);
|
||||
}
|
||||
}
|
||||
|
||||
if (fb.HasDepthStencil)
|
||||
{
|
||||
uint dsIndex = (uint)fb.AttachmentsCount - 1;
|
||||
|
||||
subpass.PDepthStencilAttachment = &attachmentReferences[MaxAttachments - 1];
|
||||
*subpass.PDepthStencilAttachment = new AttachmentReference(dsIndex, ImageLayout.General);
|
||||
}
|
||||
}
|
||||
|
||||
var subpassDependency = PipelineConverter.CreateSubpassDependency();
|
||||
|
||||
fixed (AttachmentDescription* pAttachmentDescs = attachmentDescs)
|
||||
{
|
||||
var renderPassCreateInfo = new RenderPassCreateInfo
|
||||
{
|
||||
SType = StructureType.RenderPassCreateInfo,
|
||||
PAttachments = pAttachmentDescs,
|
||||
AttachmentCount = attachmentDescs != null ? (uint)attachmentDescs.Length : 0,
|
||||
PSubpasses = &subpass,
|
||||
SubpassCount = 1,
|
||||
PDependencies = &subpassDependency,
|
||||
DependencyCount = 1,
|
||||
};
|
||||
|
||||
gd.Api.CreateRenderPass(device, renderPassCreateInfo, null, out var renderPass).ThrowOnError();
|
||||
|
||||
_renderPass?.Dispose();
|
||||
_renderPass = new Auto<DisposableRenderPass>(new DisposableRenderPass(gd.Api, device, renderPass));
|
||||
}
|
||||
|
||||
_framebuffers = new HashTableSlim<FramebufferCacheKey, Auto<DisposableFramebuffer>>();
|
||||
|
||||
// Register this render pass with all render target views.
|
||||
|
||||
var textures = fb.GetAttachmentViews();
|
||||
|
||||
foreach (var texture in textures)
|
||||
{
|
||||
texture.AddRenderPass(key, this);
|
||||
}
|
||||
|
||||
_textures = textures;
|
||||
_key = key;
|
||||
}
|
||||
|
||||
public Auto<DisposableFramebuffer> GetFramebuffer(VulkanRenderer gd, CommandBufferScoped cbs, FramebufferParams fb)
|
||||
{
|
||||
var key = new FramebufferCacheKey(fb.Width, fb.Height, fb.Layers);
|
||||
|
||||
if (!_framebuffers.TryGetValue(ref key, out Auto<DisposableFramebuffer> result))
|
||||
{
|
||||
result = fb.Create(gd.Api, cbs, _renderPass);
|
||||
|
||||
_framebuffers.Add(ref key, result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public Auto<DisposableRenderPass> GetRenderPass()
|
||||
{
|
||||
return _renderPass;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// Dispose all framebuffers
|
||||
|
||||
foreach (var fb in _framebuffers.Values)
|
||||
{
|
||||
fb.Dispose();
|
||||
}
|
||||
|
||||
// Notify all texture views that this render pass has been disposed.
|
||||
|
||||
foreach (var texture in _textures)
|
||||
{
|
||||
texture.RemoveRenderPass(_key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -374,7 +374,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
pipeline.StagesCount = (uint)_shaders.Length;
|
||||
pipeline.PipelineLayout = PipelineLayout;
|
||||
|
||||
pipeline.CreateGraphicsPipeline(_gd, _device, this, (_gd.Pipeline as PipelineBase).PipelineCache, renderPass.Value);
|
||||
pipeline.CreateGraphicsPipeline(_gd, _device, this, (_gd.Pipeline as PipelineBase).PipelineCache, renderPass.Value, throwOnError: true);
|
||||
pipeline.Dispose();
|
||||
}
|
||||
|
||||
@ -511,7 +511,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
{
|
||||
foreach (Auto<DisposablePipeline> pipeline in _graphicsPipelineCache.Values)
|
||||
{
|
||||
pipeline.Dispose();
|
||||
pipeline?.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Graphics.GAL;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
@ -29,6 +30,9 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
private readonly VulkanRenderer _gd;
|
||||
private readonly BufferHolder _buffer;
|
||||
private readonly int _resourceAlignment;
|
||||
|
||||
public readonly BufferHandle Handle;
|
||||
|
||||
private readonly struct PendingCopy
|
||||
{
|
||||
@ -48,9 +52,10 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
public StagingBuffer(VulkanRenderer gd, BufferManager bufferManager)
|
||||
{
|
||||
_gd = gd;
|
||||
_buffer = bufferManager.Create(gd, BufferSize);
|
||||
Handle = bufferManager.CreateWithHandle(gd, BufferSize, out _buffer);
|
||||
_pendingCopies = new Queue<PendingCopy>();
|
||||
_freeSize = BufferSize;
|
||||
_resourceAlignment = (int)gd.Capabilities.MinResourceAlignment;
|
||||
}
|
||||
|
||||
public void PushData(CommandBufferPool cbp, CommandBufferScoped? cbs, Action endRenderPass, BufferHolder dst, int dstOffset, ReadOnlySpan<byte> data)
|
||||
@ -197,7 +202,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
/// Reserve a range on the staging buffer for the current command buffer and upload data to it.
|
||||
/// </summary>
|
||||
/// <param name="cbs">Command buffer to reserve the data on</param>
|
||||
/// <param name="data">The data to upload</param>
|
||||
/// <param name="size">The minimum size the reserved data requires</param>
|
||||
/// <param name="alignment">The required alignment for the buffer offset</param>
|
||||
/// <returns>The reserved range of the staging buffer</returns>
|
||||
public unsafe StagingBufferReserved? TryReserveData(CommandBufferScoped cbs, int size, int alignment)
|
||||
@ -223,6 +228,18 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
return ReserveDataImpl(cbs, size, alignment);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reserve a range on the staging buffer for the current command buffer and upload data to it.
|
||||
/// Uses the most permissive byte alignment.
|
||||
/// </summary>
|
||||
/// <param name="cbs">Command buffer to reserve the data on</param>
|
||||
/// <param name="size">The minimum size the reserved data requires</param>
|
||||
/// <returns>The reserved range of the staging buffer</returns>
|
||||
public unsafe StagingBufferReserved? TryReserveData(CommandBufferScoped cbs, int size)
|
||||
{
|
||||
return TryReserveData(cbs, size, _resourceAlignment);
|
||||
}
|
||||
|
||||
private bool WaitFreeCompleted(CommandBufferPool cbp)
|
||||
{
|
||||
if (_pendingCopies.TryPeek(out var pc))
|
||||
@ -263,7 +280,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
_buffer.Dispose();
|
||||
_gd.BufferManager.Delete(Handle);
|
||||
|
||||
while (_pendingCopies.TryDequeue(out var pc))
|
||||
{
|
||||
|
@ -3,6 +3,7 @@ using Ryujinx.Graphics.GAL;
|
||||
using Silk.NET.Vulkan;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Format = Ryujinx.Graphics.GAL.Format;
|
||||
using VkBuffer = Silk.NET.Vulkan.Buffer;
|
||||
using VkFormat = Silk.NET.Vulkan.Format;
|
||||
@ -23,6 +24,8 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
private readonly TextureCreateInfo _info;
|
||||
|
||||
private HashTableSlim<RenderPassCacheKey, RenderPassHolder> _renderPasses;
|
||||
|
||||
public TextureCreateInfo Info => _info;
|
||||
|
||||
public TextureStorage Storage { get; }
|
||||
@ -158,6 +161,26 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
Valid = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a texture view for an existing swapchain image view.
|
||||
/// Does not set storage, so only appropriate for swapchain use.
|
||||
/// </summary>
|
||||
/// <remarks>Do not use this for normal textures, and make sure uses do not try to read storage.</remarks>
|
||||
public TextureView(VulkanRenderer gd, Device device, DisposableImageView view, TextureCreateInfo info, VkFormat format)
|
||||
{
|
||||
_gd = gd;
|
||||
_device = device;
|
||||
|
||||
_imageView = new Auto<DisposableImageView>(view);
|
||||
_imageViewDraw = _imageView;
|
||||
_imageViewIdentity = _imageView;
|
||||
_info = info;
|
||||
|
||||
VkFormat = format;
|
||||
|
||||
Valid = true;
|
||||
}
|
||||
|
||||
public Auto<DisposableImage> GetImage()
|
||||
{
|
||||
return Storage.GetImage();
|
||||
@ -939,6 +962,34 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public (Auto<DisposableRenderPass> renderPass, Auto<DisposableFramebuffer> framebuffer) GetPassAndFramebuffer(
|
||||
VulkanRenderer gd,
|
||||
Device device,
|
||||
CommandBufferScoped cbs,
|
||||
FramebufferParams fb)
|
||||
{
|
||||
var key = fb.GetRenderPassCacheKey();
|
||||
|
||||
if (_renderPasses == null || !_renderPasses.TryGetValue(ref key, out RenderPassHolder rpHolder))
|
||||
{
|
||||
rpHolder = new RenderPassHolder(gd, device, key, fb);
|
||||
}
|
||||
|
||||
return (rpHolder.GetRenderPass(), rpHolder.GetFramebuffer(gd, cbs, fb));
|
||||
}
|
||||
|
||||
public void AddRenderPass(RenderPassCacheKey key, RenderPassHolder renderPass)
|
||||
{
|
||||
_renderPasses ??= new HashTableSlim<RenderPassCacheKey, RenderPassHolder>();
|
||||
|
||||
_renderPasses.Add(ref key, renderPass);
|
||||
}
|
||||
|
||||
public void RemoveRenderPass(RenderPassCacheKey key)
|
||||
{
|
||||
_renderPasses.Remove(ref key);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
@ -948,15 +999,29 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
if (_gd.Textures.Remove(this))
|
||||
{
|
||||
_imageView.Dispose();
|
||||
_imageViewIdentity.Dispose();
|
||||
_imageView2dArray?.Dispose();
|
||||
|
||||
if (_imageViewIdentity != _imageView)
|
||||
{
|
||||
_imageViewIdentity.Dispose();
|
||||
}
|
||||
|
||||
if (_imageViewDraw != _imageViewIdentity)
|
||||
{
|
||||
_imageViewDraw.Dispose();
|
||||
}
|
||||
|
||||
Storage.DecrementViewsCount();
|
||||
|
||||
if (_renderPasses != null)
|
||||
{
|
||||
var renderPasses = _renderPasses.Values.ToArray();
|
||||
|
||||
foreach (var pass in renderPasses)
|
||||
{
|
||||
pass.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,10 +6,16 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
{
|
||||
static class ResultExtensions
|
||||
{
|
||||
public static bool IsError(this Result result)
|
||||
{
|
||||
// Only negative result codes are errors.
|
||||
return result < Result.Success;
|
||||
}
|
||||
|
||||
public static void ThrowOnError(this Result result)
|
||||
{
|
||||
// Only negative result codes are errors.
|
||||
if ((int)result < (int)Result.Success)
|
||||
if (result.IsError())
|
||||
{
|
||||
throw new VulkanException(result);
|
||||
}
|
||||
|
@ -58,6 +58,33 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
public bool IsDeviceExtensionPresent(string extension) => DeviceExtensions.Contains(extension);
|
||||
|
||||
public unsafe bool TryGetPhysicalDeviceDriverPropertiesKHR(Vk api, out PhysicalDeviceDriverPropertiesKHR res)
|
||||
{
|
||||
if (!IsDeviceExtensionPresent("VK_KHR_driver_properties"))
|
||||
{
|
||||
res = default;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
PhysicalDeviceDriverPropertiesKHR physicalDeviceDriverProperties = new()
|
||||
{
|
||||
SType = StructureType.PhysicalDeviceDriverPropertiesKhr
|
||||
};
|
||||
|
||||
PhysicalDeviceProperties2 physicalDeviceProperties2 = new()
|
||||
{
|
||||
SType = StructureType.PhysicalDeviceProperties2,
|
||||
PNext = &physicalDeviceDriverProperties
|
||||
};
|
||||
|
||||
api.GetPhysicalDeviceProperties2(PhysicalDevice, &physicalDeviceProperties2);
|
||||
|
||||
res = physicalDeviceDriverProperties;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public DeviceInfo ToDeviceInfo()
|
||||
{
|
||||
return new DeviceInfo(
|
||||
|
@ -84,6 +84,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
internal bool IsTBDR { get; private set; }
|
||||
internal bool IsSharedMemory { get; private set; }
|
||||
public string GpuVendor { get; private set; }
|
||||
public string GpuDriver { get; private set; }
|
||||
public string GpuRenderer { get; private set; }
|
||||
public string GpuVersion { get; private set; }
|
||||
|
||||
@ -636,7 +637,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
|
||||
public HardwareInfo GetHardwareInfo()
|
||||
{
|
||||
return new HardwareInfo(GpuVendor, GpuRenderer);
|
||||
return new HardwareInfo(GpuVendor, GpuRenderer, GpuDriver);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -693,6 +694,8 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
{
|
||||
var properties = _physicalDevice.PhysicalDeviceProperties;
|
||||
|
||||
var hasDriverProperties = _physicalDevice.TryGetPhysicalDeviceDriverPropertiesKHR(Api, out var driverProperties);
|
||||
|
||||
string vendorName = VendorUtils.GetNameFromId(properties.VendorID);
|
||||
|
||||
Vendor = VendorUtils.FromId(properties.VendorID);
|
||||
@ -707,6 +710,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
Vendor == Vendor.ImgTec;
|
||||
|
||||
GpuVendor = vendorName;
|
||||
GpuDriver = hasDriverProperties ? Marshal.PtrToStringAnsi((IntPtr)driverProperties.DriverName) : vendorName; // Fall back to vendor name if driver name isn't available.
|
||||
GpuRenderer = Marshal.PtrToStringAnsi((IntPtr)properties.DeviceName);
|
||||
GpuVersion = $"Vulkan v{ParseStandardVulkanVersion(properties.ApiVersion)}, Driver v{ParseDriverVersion(ref properties)}";
|
||||
|
||||
|
@ -20,7 +20,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
private SwapchainKHR _swapchain;
|
||||
|
||||
private Image[] _swapchainImages;
|
||||
private Auto<DisposableImageView>[] _swapchainImageViews;
|
||||
private TextureView[] _swapchainImageViews;
|
||||
|
||||
private Semaphore[] _imageAvailableSemaphores;
|
||||
private Semaphore[] _renderFinishedSemaphores;
|
||||
@ -143,6 +143,23 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
Clipped = true,
|
||||
};
|
||||
|
||||
var textureCreateInfo = new TextureCreateInfo(
|
||||
_width,
|
||||
_height,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
FormatTable.GetFormat(surfaceFormat.Format),
|
||||
DepthStencilMode.Depth,
|
||||
Target.Texture2D,
|
||||
SwizzleComponent.Red,
|
||||
SwizzleComponent.Green,
|
||||
SwizzleComponent.Blue,
|
||||
SwizzleComponent.Alpha);
|
||||
|
||||
_gd.SwapchainApi.CreateSwapchain(_device, swapchainCreateInfo, null, out _swapchain).ThrowOnError();
|
||||
|
||||
_gd.SwapchainApi.GetSwapchainImages(_device, _swapchain, &imageCount, null);
|
||||
@ -154,11 +171,11 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
_gd.SwapchainApi.GetSwapchainImages(_device, _swapchain, &imageCount, pSwapchainImages);
|
||||
}
|
||||
|
||||
_swapchainImageViews = new Auto<DisposableImageView>[imageCount];
|
||||
_swapchainImageViews = new TextureView[imageCount];
|
||||
|
||||
for (int i = 0; i < _swapchainImageViews.Length; i++)
|
||||
{
|
||||
_swapchainImageViews[i] = CreateSwapchainImageView(_swapchainImages[i], surfaceFormat.Format);
|
||||
_swapchainImageViews[i] = CreateSwapchainImageView(_swapchainImages[i], surfaceFormat.Format, textureCreateInfo);
|
||||
}
|
||||
|
||||
var semaphoreCreateInfo = new SemaphoreCreateInfo
|
||||
@ -181,7 +198,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
}
|
||||
}
|
||||
|
||||
private unsafe Auto<DisposableImageView> CreateSwapchainImageView(Image swapchainImage, VkFormat format)
|
||||
private unsafe TextureView CreateSwapchainImageView(Image swapchainImage, VkFormat format, TextureCreateInfo info)
|
||||
{
|
||||
var componentMapping = new ComponentMapping(
|
||||
ComponentSwizzle.R,
|
||||
@ -204,7 +221,8 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
};
|
||||
|
||||
_gd.Api.CreateImageView(_device, imageCreateInfo, null, out var imageView).ThrowOnError();
|
||||
return new Auto<DisposableImageView>(new DisposableImageView(_gd.Api, _device, imageView));
|
||||
|
||||
return new TextureView(_gd, _device, new DisposableImageView(_gd.Api, _device, imageView), info, format);
|
||||
}
|
||||
|
||||
private static SurfaceFormatKHR ChooseSwapSurfaceFormat(SurfaceFormatKHR[] availableFormats, bool colorSpacePassthroughEnabled)
|
||||
@ -406,7 +424,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
_scalingFilter.Run(
|
||||
view,
|
||||
cbs,
|
||||
_swapchainImageViews[nextImage],
|
||||
_swapchainImageViews[nextImage].GetImageViewForAttachment(),
|
||||
_format,
|
||||
_width,
|
||||
_height,
|
||||
@ -421,11 +439,6 @@ namespace Ryujinx.Graphics.Vulkan
|
||||
cbs,
|
||||
view,
|
||||
_swapchainImageViews[nextImage],
|
||||
_width,
|
||||
_height,
|
||||
1,
|
||||
_format,
|
||||
false,
|
||||
new Extents2D(srcX0, srcY0, srcX1, srcY1),
|
||||
new Extents2D(dstX0, dstY1, dstX1, dstY0),
|
||||
_isLinear,
|
||||
|
@ -186,7 +186,12 @@ namespace Ryujinx.HLE.FileSystem
|
||||
|
||||
public void InitializeFsServer(LibHac.Horizon horizon, out HorizonClient fsServerClient)
|
||||
{
|
||||
LocalFileSystem serverBaseFs = new(AppDataManager.BaseDirPath);
|
||||
LocalFileSystem serverBaseFs = new(useUnixTimeStamps: true);
|
||||
Result result = serverBaseFs.Initialize(AppDataManager.BaseDirPath, LocalFileSystem.PathMode.DefaultCaseSensitivity, ensurePathExists: true);
|
||||
if (result.IsFailure())
|
||||
{
|
||||
throw new HorizonResultException(result, "Error creating LocalFileSystem.");
|
||||
}
|
||||
|
||||
fsServerClient = horizon.CreatePrivilegedHorizonClient();
|
||||
var fsServer = new FileSystemServer(fsServerClient);
|
||||
|
@ -330,7 +330,7 @@ namespace Ryujinx.HLE.HOS
|
||||
HorizonFsClient fsClient = new(this);
|
||||
|
||||
ServiceTable = new ServiceTable();
|
||||
var services = ServiceTable.GetServices(new HorizonOptions(Device.Configuration.IgnoreMissingServices, LibHacHorizonManager.BcatClient, fsClient));
|
||||
var services = ServiceTable.GetServices(new HorizonOptions(Device.Configuration.IgnoreMissingServices, LibHacHorizonManager.BcatClient, fsClient, AccountManager));
|
||||
|
||||
foreach (var service in services)
|
||||
{
|
||||
|
@ -7,6 +7,7 @@ using LibHac.Tools.FsSystem;
|
||||
using LibHac.Tools.FsSystem.RomFs;
|
||||
using Ryujinx.Common.Configuration;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Common.Utilities;
|
||||
using Ryujinx.HLE.HOS.Kernel.Process;
|
||||
using Ryujinx.HLE.Loaders.Executables;
|
||||
using Ryujinx.HLE.Loaders.Mods;
|
||||
@ -17,6 +18,7 @@ using System.Collections.Specialized;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using LazyFile = Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy.LazyFile;
|
||||
using Path = System.IO.Path;
|
||||
|
||||
namespace Ryujinx.HLE.HOS
|
||||
@ -37,15 +39,19 @@ namespace Ryujinx.HLE.HOS
|
||||
private const string AmsNroPatchDir = "nro_patches";
|
||||
private const string AmsKipPatchDir = "kip_patches";
|
||||
|
||||
private static readonly ModMetadataJsonSerializerContext _serializerContext = new(JsonHelper.GetDefaultSerializerOptions());
|
||||
|
||||
public readonly struct Mod<T> where T : FileSystemInfo
|
||||
{
|
||||
public readonly string Name;
|
||||
public readonly T Path;
|
||||
public readonly bool Enabled;
|
||||
|
||||
public Mod(string name, T path)
|
||||
public Mod(string name, T path, bool enabled)
|
||||
{
|
||||
Name = name;
|
||||
Path = path;
|
||||
Enabled = enabled;
|
||||
}
|
||||
}
|
||||
|
||||
@ -67,7 +73,7 @@ namespace Ryujinx.HLE.HOS
|
||||
}
|
||||
}
|
||||
|
||||
// Title dependent mods
|
||||
// Application dependent mods
|
||||
public class ModCache
|
||||
{
|
||||
public List<Mod<FileInfo>> RomfsContainers { get; }
|
||||
@ -88,7 +94,7 @@ namespace Ryujinx.HLE.HOS
|
||||
}
|
||||
}
|
||||
|
||||
// Title independent mods
|
||||
// Application independent mods
|
||||
private class PatchCache
|
||||
{
|
||||
public List<Mod<DirectoryInfo>> NsoPatches { get; }
|
||||
@ -107,7 +113,7 @@ namespace Ryujinx.HLE.HOS
|
||||
}
|
||||
}
|
||||
|
||||
private readonly Dictionary<ulong, ModCache> _appMods; // key is TitleId
|
||||
private readonly Dictionary<ulong, ModCache> _appMods; // key is ApplicationId
|
||||
private PatchCache _patches;
|
||||
|
||||
private static readonly EnumerationOptions _dirEnumOptions;
|
||||
@ -153,26 +159,52 @@ namespace Ryujinx.HLE.HOS
|
||||
return modsDir.FullName;
|
||||
}
|
||||
|
||||
private static DirectoryInfo FindTitleDir(DirectoryInfo contentsDir, string titleId)
|
||||
=> contentsDir.EnumerateDirectories(titleId, _dirEnumOptions).FirstOrDefault();
|
||||
private static DirectoryInfo FindApplicationDir(DirectoryInfo contentsDir, string applicationId)
|
||||
=> contentsDir.EnumerateDirectories(applicationId, _dirEnumOptions).FirstOrDefault();
|
||||
|
||||
private static void AddModsFromDirectory(ModCache mods, DirectoryInfo dir, string titleId)
|
||||
private static void AddModsFromDirectory(ModCache mods, DirectoryInfo dir, ModMetadata modMetadata)
|
||||
{
|
||||
System.Text.StringBuilder types = new();
|
||||
|
||||
foreach (var modDir in dir.EnumerateDirectories())
|
||||
{
|
||||
types.Clear();
|
||||
Mod<DirectoryInfo> mod = new("", null);
|
||||
Mod<DirectoryInfo> mod = new("", null, true);
|
||||
|
||||
if (StrEquals(RomfsDir, modDir.Name))
|
||||
{
|
||||
mods.RomfsDirs.Add(mod = new Mod<DirectoryInfo>(dir.Name, modDir));
|
||||
bool enabled;
|
||||
|
||||
try
|
||||
{
|
||||
var modData = modMetadata.Mods.Find(x => modDir.FullName.Contains(x.Path));
|
||||
enabled = modData.Enabled;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Mod is not in the list yet. New mods should be enabled by default.
|
||||
enabled = true;
|
||||
}
|
||||
|
||||
mods.RomfsDirs.Add(mod = new Mod<DirectoryInfo>(dir.Name, modDir, enabled));
|
||||
types.Append('R');
|
||||
}
|
||||
else if (StrEquals(ExefsDir, modDir.Name))
|
||||
{
|
||||
mods.ExefsDirs.Add(mod = new Mod<DirectoryInfo>(dir.Name, modDir));
|
||||
bool enabled;
|
||||
|
||||
try
|
||||
{
|
||||
var modData = modMetadata.Mods.Find(x => modDir.FullName.Contains(x.Path));
|
||||
enabled = modData.Enabled;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Mod is not in the list yet. New mods should be enabled by default.
|
||||
enabled = true;
|
||||
}
|
||||
|
||||
mods.ExefsDirs.Add(mod = new Mod<DirectoryInfo>(dir.Name, modDir, enabled));
|
||||
types.Append('E');
|
||||
}
|
||||
else if (StrEquals(CheatDir, modDir.Name))
|
||||
@ -181,7 +213,7 @@ namespace Ryujinx.HLE.HOS
|
||||
}
|
||||
else
|
||||
{
|
||||
AddModsFromDirectory(mods, modDir, titleId);
|
||||
AddModsFromDirectory(mods, modDir, modMetadata);
|
||||
}
|
||||
|
||||
if (types.Length > 0)
|
||||
@ -191,18 +223,18 @@ namespace Ryujinx.HLE.HOS
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetTitleDir(string modsBasePath, string titleId)
|
||||
public static string GetApplicationDir(string modsBasePath, string applicationId)
|
||||
{
|
||||
var contentsDir = new DirectoryInfo(Path.Combine(modsBasePath, AmsContentsDir));
|
||||
var titleModsPath = FindTitleDir(contentsDir, titleId);
|
||||
var applicationModsPath = FindApplicationDir(contentsDir, applicationId);
|
||||
|
||||
if (titleModsPath == null)
|
||||
if (applicationModsPath == null)
|
||||
{
|
||||
Logger.Info?.Print(LogClass.ModLoader, $"Creating mods directory for Title {titleId.ToUpper()}");
|
||||
titleModsPath = contentsDir.CreateSubdirectory(titleId);
|
||||
Logger.Info?.Print(LogClass.ModLoader, $"Creating mods directory for Application {applicationId.ToUpper()}");
|
||||
applicationModsPath = contentsDir.CreateSubdirectory(applicationId);
|
||||
}
|
||||
|
||||
return titleModsPath.FullName;
|
||||
return applicationModsPath.FullName;
|
||||
}
|
||||
|
||||
// Static Query Methods
|
||||
@ -238,47 +270,68 @@ namespace Ryujinx.HLE.HOS
|
||||
|
||||
foreach (var modDir in patchDir.EnumerateDirectories())
|
||||
{
|
||||
patches.Add(new Mod<DirectoryInfo>(modDir.Name, modDir));
|
||||
patches.Add(new Mod<DirectoryInfo>(modDir.Name, modDir, true));
|
||||
Logger.Info?.Print(LogClass.ModLoader, $"Found {type} patch '{modDir.Name}'");
|
||||
}
|
||||
}
|
||||
|
||||
private static void QueryTitleDir(ModCache mods, DirectoryInfo titleDir)
|
||||
private static void QueryApplicationDir(ModCache mods, DirectoryInfo applicationDir, ulong applicationId)
|
||||
{
|
||||
if (!titleDir.Exists)
|
||||
if (!applicationDir.Exists)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var fsFile = new FileInfo(Path.Combine(titleDir.FullName, RomfsContainer));
|
||||
if (fsFile.Exists)
|
||||
string modJsonPath = Path.Combine(AppDataManager.GamesDirPath, applicationId.ToString("x16"), "mods.json");
|
||||
ModMetadata modMetadata = new();
|
||||
|
||||
if (File.Exists(modJsonPath))
|
||||
{
|
||||
mods.RomfsContainers.Add(new Mod<FileInfo>($"<{titleDir.Name} RomFs>", fsFile));
|
||||
try
|
||||
{
|
||||
modMetadata = JsonHelper.DeserializeFromFile(modJsonPath, _serializerContext.ModMetadata);
|
||||
}
|
||||
catch
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.ModLoader, $"Failed to deserialize mod data for {applicationId:X16} at {modJsonPath}");
|
||||
}
|
||||
}
|
||||
|
||||
fsFile = new FileInfo(Path.Combine(titleDir.FullName, ExefsContainer));
|
||||
var fsFile = new FileInfo(Path.Combine(applicationDir.FullName, RomfsContainer));
|
||||
if (fsFile.Exists)
|
||||
{
|
||||
mods.ExefsContainers.Add(new Mod<FileInfo>($"<{titleDir.Name} ExeFs>", fsFile));
|
||||
var modData = modMetadata.Mods.Find(x => fsFile.FullName.Contains(x.Path));
|
||||
var enabled = modData == null || modData.Enabled;
|
||||
|
||||
mods.RomfsContainers.Add(new Mod<FileInfo>($"<{applicationDir.Name} RomFs>", fsFile, enabled));
|
||||
}
|
||||
|
||||
AddModsFromDirectory(mods, titleDir, titleDir.Name);
|
||||
fsFile = new FileInfo(Path.Combine(applicationDir.FullName, ExefsContainer));
|
||||
if (fsFile.Exists)
|
||||
{
|
||||
var modData = modMetadata.Mods.Find(x => fsFile.FullName.Contains(x.Path));
|
||||
var enabled = modData == null || modData.Enabled;
|
||||
|
||||
mods.ExefsContainers.Add(new Mod<FileInfo>($"<{applicationDir.Name} ExeFs>", fsFile, enabled));
|
||||
}
|
||||
|
||||
AddModsFromDirectory(mods, applicationDir, modMetadata);
|
||||
}
|
||||
|
||||
public static void QueryContentsDir(ModCache mods, DirectoryInfo contentsDir, ulong titleId)
|
||||
public static void QueryContentsDir(ModCache mods, DirectoryInfo contentsDir, ulong applicationId)
|
||||
{
|
||||
if (!contentsDir.Exists)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Logger.Info?.Print(LogClass.ModLoader, $"Searching mods for {((titleId & 0x1000) != 0 ? "DLC" : "Title")} {titleId:X16}");
|
||||
Logger.Info?.Print(LogClass.ModLoader, $"Searching mods for {((applicationId & 0x1000) != 0 ? "DLC" : "Application")} {applicationId:X16} in \"{contentsDir.FullName}\"");
|
||||
|
||||
var titleDir = FindTitleDir(contentsDir, $"{titleId:x16}");
|
||||
var applicationDir = FindApplicationDir(contentsDir, $"{applicationId:x16}");
|
||||
|
||||
if (titleDir != null)
|
||||
if (applicationDir != null)
|
||||
{
|
||||
QueryTitleDir(mods, titleDir);
|
||||
QueryApplicationDir(mods, applicationDir, applicationId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -387,9 +440,9 @@ namespace Ryujinx.HLE.HOS
|
||||
{
|
||||
if (IsContentsDir(searchDir.Name))
|
||||
{
|
||||
foreach ((ulong titleId, ModCache cache) in modCaches)
|
||||
foreach ((ulong applicationId, ModCache cache) in modCaches)
|
||||
{
|
||||
QueryContentsDir(cache, searchDir, titleId);
|
||||
QueryContentsDir(cache, searchDir, applicationId);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -410,7 +463,7 @@ namespace Ryujinx.HLE.HOS
|
||||
if (!searchDir.Exists)
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.ModLoader, $"Mod Search Dir '{searchDir.FullName}' doesn't exist");
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!TryQuery(searchDir, patches, modCaches))
|
||||
@ -425,21 +478,21 @@ namespace Ryujinx.HLE.HOS
|
||||
patches.Initialized = true;
|
||||
}
|
||||
|
||||
public void CollectMods(IEnumerable<ulong> titles, params string[] searchDirPaths)
|
||||
public void CollectMods(IEnumerable<ulong> applications, params string[] searchDirPaths)
|
||||
{
|
||||
Clear();
|
||||
|
||||
foreach (ulong titleId in titles)
|
||||
foreach (ulong applicationId in applications)
|
||||
{
|
||||
_appMods[titleId] = new ModCache();
|
||||
_appMods[applicationId] = new ModCache();
|
||||
}
|
||||
|
||||
CollectMods(_appMods, _patches, searchDirPaths);
|
||||
}
|
||||
|
||||
internal IStorage ApplyRomFsMods(ulong titleId, IStorage baseStorage)
|
||||
internal IStorage ApplyRomFsMods(ulong applicationId, IStorage baseStorage)
|
||||
{
|
||||
if (!_appMods.TryGetValue(titleId, out ModCache mods) || mods.RomfsDirs.Count + mods.RomfsContainers.Count == 0)
|
||||
if (!_appMods.TryGetValue(applicationId, out ModCache mods) || mods.RomfsDirs.Count + mods.RomfsContainers.Count == 0)
|
||||
{
|
||||
return baseStorage;
|
||||
}
|
||||
@ -448,14 +501,19 @@ namespace Ryujinx.HLE.HOS
|
||||
var builder = new RomFsBuilder();
|
||||
int count = 0;
|
||||
|
||||
Logger.Info?.Print(LogClass.ModLoader, $"Applying RomFS mods for Title {titleId:X16}");
|
||||
Logger.Info?.Print(LogClass.ModLoader, $"Applying RomFS mods for Application {applicationId:X16}");
|
||||
|
||||
// Prioritize loose files first
|
||||
foreach (var mod in mods.RomfsDirs)
|
||||
{
|
||||
if (!mod.Enabled)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
using (IFileSystem fs = new LocalFileSystem(mod.Path.FullName))
|
||||
{
|
||||
AddFiles(fs, mod.Name, fileSet, builder);
|
||||
AddFiles(fs, mod.Name, mod.Path.FullName, fileSet, builder);
|
||||
}
|
||||
count++;
|
||||
}
|
||||
@ -463,10 +521,15 @@ namespace Ryujinx.HLE.HOS
|
||||
// Then files inside images
|
||||
foreach (var mod in mods.RomfsContainers)
|
||||
{
|
||||
Logger.Info?.Print(LogClass.ModLoader, $"Found 'romfs.bin' for Title {titleId:X16}");
|
||||
if (!mod.Enabled)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Logger.Info?.Print(LogClass.ModLoader, $"Found 'romfs.bin' for Application {applicationId:X16}");
|
||||
using (IFileSystem fs = new RomFsFileSystem(mod.Path.OpenRead().AsStorage()))
|
||||
{
|
||||
AddFiles(fs, mod.Name, fileSet, builder);
|
||||
AddFiles(fs, mod.Name, mod.Path.FullName, fileSet, builder);
|
||||
}
|
||||
count++;
|
||||
}
|
||||
@ -499,18 +562,18 @@ namespace Ryujinx.HLE.HOS
|
||||
return newStorage;
|
||||
}
|
||||
|
||||
private static void AddFiles(IFileSystem fs, string modName, ISet<string> fileSet, RomFsBuilder builder)
|
||||
private static void AddFiles(IFileSystem fs, string modName, string rootPath, ISet<string> fileSet, RomFsBuilder builder)
|
||||
{
|
||||
foreach (var entry in fs.EnumerateEntries()
|
||||
.AsParallel()
|
||||
.Where(f => f.Type == DirectoryEntryType.File)
|
||||
.OrderBy(f => f.FullPath, StringComparer.Ordinal))
|
||||
{
|
||||
using var file = new UniqueRef<IFile>();
|
||||
var file = new LazyFile(entry.FullPath, rootPath, fs);
|
||||
|
||||
fs.OpenFile(ref file.Ref, entry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
|
||||
if (fileSet.Add(entry.FullPath))
|
||||
{
|
||||
builder.AddFile(entry.FullPath, file.Release());
|
||||
builder.AddFile(entry.FullPath, file);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -519,9 +582,9 @@ namespace Ryujinx.HLE.HOS
|
||||
}
|
||||
}
|
||||
|
||||
internal bool ReplaceExefsPartition(ulong titleId, ref IFileSystem exefs)
|
||||
internal bool ReplaceExefsPartition(ulong applicationId, ref IFileSystem exefs)
|
||||
{
|
||||
if (!_appMods.TryGetValue(titleId, out ModCache mods) || mods.ExefsContainers.Count == 0)
|
||||
if (!_appMods.TryGetValue(applicationId, out ModCache mods) || mods.ExefsContainers.Count == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -549,7 +612,7 @@ namespace Ryujinx.HLE.HOS
|
||||
public bool Modified => (Stubs.Data | Replaces.Data) != 0;
|
||||
}
|
||||
|
||||
internal ModLoadResult ApplyExefsMods(ulong titleId, NsoExecutable[] nsos)
|
||||
internal ModLoadResult ApplyExefsMods(ulong applicationId, NsoExecutable[] nsos)
|
||||
{
|
||||
ModLoadResult modLoadResult = new()
|
||||
{
|
||||
@ -557,7 +620,7 @@ namespace Ryujinx.HLE.HOS
|
||||
Replaces = new BitVector32(),
|
||||
};
|
||||
|
||||
if (!_appMods.TryGetValue(titleId, out ModCache mods) || mods.ExefsDirs.Count == 0)
|
||||
if (!_appMods.TryGetValue(applicationId, out ModCache mods) || mods.ExefsDirs.Count == 0)
|
||||
{
|
||||
return modLoadResult;
|
||||
}
|
||||
@ -571,6 +634,11 @@ namespace Ryujinx.HLE.HOS
|
||||
|
||||
foreach (var mod in exeMods)
|
||||
{
|
||||
if (!mod.Enabled)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int i = 0; i < ProcessConst.ExeFsPrefixes.Length; ++i)
|
||||
{
|
||||
var nsoName = ProcessConst.ExeFsPrefixes[i];
|
||||
@ -637,11 +705,11 @@ namespace Ryujinx.HLE.HOS
|
||||
ApplyProgramPatches(nroPatches, 0, nro);
|
||||
}
|
||||
|
||||
internal bool ApplyNsoPatches(ulong titleId, params IExecutable[] programs)
|
||||
internal bool ApplyNsoPatches(ulong applicationId, params IExecutable[] programs)
|
||||
{
|
||||
IEnumerable<Mod<DirectoryInfo>> nsoMods = _patches.NsoPatches;
|
||||
|
||||
if (_appMods.TryGetValue(titleId, out ModCache mods))
|
||||
if (_appMods.TryGetValue(applicationId, out ModCache mods))
|
||||
{
|
||||
nsoMods = nsoMods.Concat(mods.ExefsDirs);
|
||||
}
|
||||
@ -651,7 +719,7 @@ namespace Ryujinx.HLE.HOS
|
||||
return ApplyProgramPatches(nsoMods, 0x100, programs);
|
||||
}
|
||||
|
||||
internal void LoadCheats(ulong titleId, ProcessTamperInfo tamperInfo, TamperMachine tamperMachine)
|
||||
internal void LoadCheats(ulong applicationId, ProcessTamperInfo tamperInfo, TamperMachine tamperMachine)
|
||||
{
|
||||
if (tamperInfo?.BuildIds == null || tamperInfo.CodeAddresses == null)
|
||||
{
|
||||
@ -660,9 +728,9 @@ namespace Ryujinx.HLE.HOS
|
||||
return;
|
||||
}
|
||||
|
||||
Logger.Info?.Print(LogClass.ModLoader, $"Build ids found for title {titleId:X16}:\n {String.Join("\n ", tamperInfo.BuildIds)}");
|
||||
Logger.Info?.Print(LogClass.ModLoader, $"Build ids found for application {applicationId:X16}:\n {String.Join("\n ", tamperInfo.BuildIds)}");
|
||||
|
||||
if (!_appMods.TryGetValue(titleId, out ModCache mods) || mods.Cheats.Count == 0)
|
||||
if (!_appMods.TryGetValue(applicationId, out ModCache mods) || mods.Cheats.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -687,12 +755,12 @@ namespace Ryujinx.HLE.HOS
|
||||
tamperMachine.InstallAtmosphereCheat(cheat.Name, cheatId, cheat.Instructions, tamperInfo, exeAddress);
|
||||
}
|
||||
|
||||
EnableCheats(titleId, tamperMachine);
|
||||
EnableCheats(applicationId, tamperMachine);
|
||||
}
|
||||
|
||||
internal static void EnableCheats(ulong titleId, TamperMachine tamperMachine)
|
||||
internal static void EnableCheats(ulong applicationId, TamperMachine tamperMachine)
|
||||
{
|
||||
var contentDirectory = FindTitleDir(new DirectoryInfo(Path.Combine(GetModsBasePath(), AmsContentsDir)), $"{titleId:x16}");
|
||||
var contentDirectory = FindApplicationDir(new DirectoryInfo(Path.Combine(GetModsBasePath(), AmsContentsDir)), $"{applicationId:x16}");
|
||||
string enabledCheatsPath = Path.Combine(contentDirectory.FullName, CheatDir, "enabled.txt");
|
||||
|
||||
if (File.Exists(enabledCheatsPath))
|
||||
@ -724,6 +792,11 @@ namespace Ryujinx.HLE.HOS
|
||||
// Collect patches
|
||||
foreach (var mod in mods)
|
||||
{
|
||||
if (!mod.Enabled)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var patchDir = mod.Path;
|
||||
foreach (var patchFile in patchDir.EnumerateFiles())
|
||||
{
|
||||
|
@ -4,6 +4,7 @@ using LibHac.Fs;
|
||||
using LibHac.Fs.Shim;
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Horizon.Sdk.Account;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
@ -11,7 +12,7 @@ using System.Linq;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Account.Acc
|
||||
{
|
||||
public class AccountManager
|
||||
public class AccountManager : IEmulatorAccountManager
|
||||
{
|
||||
public static readonly UserId DefaultUserId = new("00000000000000010000000000000000");
|
||||
|
||||
@ -106,6 +107,11 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
|
||||
_accountSaveDataManager.Save(_profiles);
|
||||
}
|
||||
|
||||
public void OpenUserOnlinePlay(Uid userId)
|
||||
{
|
||||
OpenUserOnlinePlay(new UserId((long)userId.Low, (long)userId.High));
|
||||
}
|
||||
|
||||
public void OpenUserOnlinePlay(UserId userId)
|
||||
{
|
||||
if (_profiles.TryGetValue(userId.ToString(), out UserProfile profile))
|
||||
@ -127,6 +133,11 @@ namespace Ryujinx.HLE.HOS.Services.Account.Acc
|
||||
_accountSaveDataManager.Save(_profiles);
|
||||
}
|
||||
|
||||
public void CloseUserOnlinePlay(Uid userId)
|
||||
{
|
||||
CloseUserOnlinePlay(new UserId((long)userId.Low, (long)userId.High));
|
||||
}
|
||||
|
||||
public void CloseUserOnlinePlay(UserId userId)
|
||||
{
|
||||
if (_profiles.TryGetValue(userId.ToString(), out UserProfile profile))
|
||||
|
@ -1,8 +0,0 @@
|
||||
namespace Ryujinx.HLE.HOS.Services.Arp
|
||||
{
|
||||
[Service("arp:r")]
|
||||
class IReader : IpcService
|
||||
{
|
||||
public IReader(ServiceCtx context) { }
|
||||
}
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
namespace Ryujinx.HLE.HOS.Services.Arp
|
||||
{
|
||||
[Service("arp:w")]
|
||||
class IWriter : IpcService
|
||||
{
|
||||
public IWriter(ServiceCtx context) { }
|
||||
}
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.HLE.HOS.Services.Account.Acc;
|
||||
using Ryujinx.HLE.HOS.Services.Friend.ServiceCreator;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Friend
|
||||
{
|
||||
[Service("friend:a", FriendServicePermissionLevel.Administrator)]
|
||||
[Service("friend:m", FriendServicePermissionLevel.Manager)]
|
||||
[Service("friend:s", FriendServicePermissionLevel.System)]
|
||||
[Service("friend:u", FriendServicePermissionLevel.User)]
|
||||
[Service("friend:v", FriendServicePermissionLevel.Viewer)]
|
||||
class IServiceCreator : IpcService
|
||||
{
|
||||
private readonly FriendServicePermissionLevel _permissionLevel;
|
||||
|
||||
public IServiceCreator(ServiceCtx context, FriendServicePermissionLevel permissionLevel)
|
||||
{
|
||||
_permissionLevel = permissionLevel;
|
||||
}
|
||||
|
||||
[CommandCmif(0)]
|
||||
// CreateFriendService() -> object<nn::friends::detail::ipc::IFriendService>
|
||||
public ResultCode CreateFriendService(ServiceCtx context)
|
||||
{
|
||||
MakeObject(context, new IFriendService(_permissionLevel));
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[CommandCmif(1)] // 2.0.0+
|
||||
// CreateNotificationService(nn::account::Uid userId) -> object<nn::friends::detail::ipc::INotificationService>
|
||||
public ResultCode CreateNotificationService(ServiceCtx context)
|
||||
{
|
||||
UserId userId = context.RequestData.ReadStruct<UserId>();
|
||||
|
||||
if (userId.IsNull)
|
||||
{
|
||||
return ResultCode.InvalidArgument;
|
||||
}
|
||||
|
||||
MakeObject(context, new INotificationService(context, userId, _permissionLevel));
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[CommandCmif(2)] // 4.0.0+
|
||||
// CreateDaemonSuspendSessionService() -> object<nn::friends::detail::ipc::IDaemonSuspendSessionService>
|
||||
public ResultCode CreateDaemonSuspendSessionService(ServiceCtx context)
|
||||
{
|
||||
MakeObject(context, new IDaemonSuspendSessionService(_permissionLevel));
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
namespace Ryujinx.HLE.HOS.Services.Friend
|
||||
{
|
||||
enum ResultCode
|
||||
{
|
||||
ModuleId = 121,
|
||||
ErrorCodeShift = 9,
|
||||
|
||||
Success = 0,
|
||||
|
||||
InvalidArgument = (2 << ErrorCodeShift) | ModuleId,
|
||||
InternetRequestDenied = (6 << ErrorCodeShift) | ModuleId,
|
||||
NotificationQueueEmpty = (15 << ErrorCodeShift) | ModuleId,
|
||||
}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
using Ryujinx.HLE.HOS.Services.Account.Acc;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Friend.ServiceCreator.FriendService
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 0x8, Size = 0x200, CharSet = CharSet.Ansi)]
|
||||
struct Friend
|
||||
{
|
||||
public UserId UserId;
|
||||
public long NetworkUserId;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x21)]
|
||||
public string Nickname;
|
||||
|
||||
public UserPresence presence;
|
||||
|
||||
[MarshalAs(UnmanagedType.I1)]
|
||||
public bool IsFavourite;
|
||||
|
||||
[MarshalAs(UnmanagedType.I1)]
|
||||
public bool IsNew;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x6)]
|
||||
readonly char[] Unknown;
|
||||
|
||||
[MarshalAs(UnmanagedType.I1)]
|
||||
public bool IsValid;
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Friend.ServiceCreator.FriendService
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
struct FriendFilter
|
||||
{
|
||||
public PresenceStatusFilter PresenceStatus;
|
||||
|
||||
[MarshalAs(UnmanagedType.I1)]
|
||||
public bool IsFavoriteOnly;
|
||||
|
||||
[MarshalAs(UnmanagedType.I1)]
|
||||
public bool IsSameAppPresenceOnly;
|
||||
|
||||
[MarshalAs(UnmanagedType.I1)]
|
||||
public bool IsSameAppPlayedOnly;
|
||||
|
||||
[MarshalAs(UnmanagedType.I1)]
|
||||
public bool IsArbitraryAppPlayedOnly;
|
||||
|
||||
public long PresenceGroupId;
|
||||
}
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
using Ryujinx.Common.Memory;
|
||||
using Ryujinx.HLE.HOS.Services.Account.Acc;
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Friend.ServiceCreator.FriendService
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 0x8)]
|
||||
struct UserPresence
|
||||
{
|
||||
public UserId UserId;
|
||||
public long LastTimeOnlineTimestamp;
|
||||
public PresenceStatus Status;
|
||||
|
||||
[MarshalAs(UnmanagedType.I1)]
|
||||
public bool SamePresenceGroupApplication;
|
||||
|
||||
public Array3<byte> Unknown;
|
||||
private AppKeyValueStorageHolder _appKeyValueStorage;
|
||||
|
||||
public Span<byte> AppKeyValueStorage => MemoryMarshal.Cast<AppKeyValueStorageHolder, byte>(MemoryMarshal.CreateSpan(ref _appKeyValueStorage, AppKeyValueStorageHolder.Size));
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 0x1, Size = Size)]
|
||||
private struct AppKeyValueStorageHolder
|
||||
{
|
||||
public const int Size = 0xC0;
|
||||
}
|
||||
|
||||
public readonly override string ToString()
|
||||
{
|
||||
return $"UserPresence {{ UserId: {UserId}, LastTimeOnlineTimestamp: {LastTimeOnlineTimestamp}, Status: {Status} }}";
|
||||
}
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
namespace Ryujinx.HLE.HOS.Services.Friend.ServiceCreator
|
||||
{
|
||||
class IDaemonSuspendSessionService : IpcService
|
||||
{
|
||||
#pragma warning disable IDE0052 // Remove unread private member
|
||||
private readonly FriendServicePermissionLevel _permissionLevel;
|
||||
#pragma warning restore IDE0052
|
||||
|
||||
public IDaemonSuspendSessionService(FriendServicePermissionLevel permissionLevel)
|
||||
{
|
||||
_permissionLevel = permissionLevel;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,374 +0,0 @@
|
||||
using LibHac.Ns;
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Common.Memory;
|
||||
using Ryujinx.Common.Utilities;
|
||||
using Ryujinx.HLE.HOS.Ipc;
|
||||
using Ryujinx.HLE.HOS.Kernel.Threading;
|
||||
using Ryujinx.HLE.HOS.Services.Account.Acc;
|
||||
using Ryujinx.HLE.HOS.Services.Friend.ServiceCreator.FriendService;
|
||||
using Ryujinx.Horizon.Common;
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Friend.ServiceCreator
|
||||
{
|
||||
class IFriendService : IpcService
|
||||
{
|
||||
#pragma warning disable IDE0052 // Remove unread private member
|
||||
private readonly FriendServicePermissionLevel _permissionLevel;
|
||||
#pragma warning restore IDE0052
|
||||
private KEvent _completionEvent;
|
||||
|
||||
public IFriendService(FriendServicePermissionLevel permissionLevel)
|
||||
{
|
||||
_permissionLevel = permissionLevel;
|
||||
}
|
||||
|
||||
[CommandCmif(0)]
|
||||
// GetCompletionEvent() -> handle<copy>
|
||||
public ResultCode GetCompletionEvent(ServiceCtx context)
|
||||
{
|
||||
_completionEvent ??= new KEvent(context.Device.System.KernelContext);
|
||||
|
||||
if (context.Process.HandleTable.GenerateHandle(_completionEvent.ReadableEvent, out int completionEventHandle) != Result.Success)
|
||||
{
|
||||
throw new InvalidOperationException("Out of handles!");
|
||||
}
|
||||
|
||||
_completionEvent.WritableEvent.Signal();
|
||||
|
||||
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(completionEventHandle);
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[CommandCmif(1)]
|
||||
// nn::friends::Cancel()
|
||||
public ResultCode Cancel(ServiceCtx context)
|
||||
{
|
||||
// TODO: Original service sets an internal field to 1 here. Determine usage.
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceFriend);
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[CommandCmif(10100)]
|
||||
// nn::friends::GetFriendListIds(int offset, nn::account::Uid userId, nn::friends::detail::ipc::SizedFriendFilter friendFilter, ulong pidPlaceHolder, pid)
|
||||
// -> int outCount, array<nn::account::NetworkServiceAccountId, 0xa>
|
||||
public ResultCode GetFriendListIds(ServiceCtx context)
|
||||
{
|
||||
int offset = context.RequestData.ReadInt32();
|
||||
|
||||
// Padding
|
||||
context.RequestData.ReadInt32();
|
||||
|
||||
UserId userId = context.RequestData.ReadStruct<UserId>();
|
||||
FriendFilter filter = context.RequestData.ReadStruct<FriendFilter>();
|
||||
|
||||
// Pid placeholder
|
||||
context.RequestData.ReadInt64();
|
||||
|
||||
if (userId.IsNull)
|
||||
{
|
||||
return ResultCode.InvalidArgument;
|
||||
}
|
||||
|
||||
// There are no friends online, so we return 0 because the nn::account::NetworkServiceAccountId array is empty.
|
||||
context.ResponseData.Write(0);
|
||||
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceFriend, new
|
||||
{
|
||||
UserId = userId.ToString(),
|
||||
offset,
|
||||
filter.PresenceStatus,
|
||||
filter.IsFavoriteOnly,
|
||||
filter.IsSameAppPresenceOnly,
|
||||
filter.IsSameAppPlayedOnly,
|
||||
filter.IsArbitraryAppPlayedOnly,
|
||||
filter.PresenceGroupId,
|
||||
});
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[CommandCmif(10101)]
|
||||
// nn::friends::GetFriendList(int offset, nn::account::Uid userId, nn::friends::detail::ipc::SizedFriendFilter friendFilter, ulong pidPlaceHolder, pid)
|
||||
// -> int outCount, array<nn::friends::detail::FriendImpl, 0x6>
|
||||
public ResultCode GetFriendList(ServiceCtx context)
|
||||
{
|
||||
int offset = context.RequestData.ReadInt32();
|
||||
|
||||
// Padding
|
||||
context.RequestData.ReadInt32();
|
||||
|
||||
UserId userId = context.RequestData.ReadStruct<UserId>();
|
||||
FriendFilter filter = context.RequestData.ReadStruct<FriendFilter>();
|
||||
|
||||
// Pid placeholder
|
||||
context.RequestData.ReadInt64();
|
||||
|
||||
if (userId.IsNull)
|
||||
{
|
||||
return ResultCode.InvalidArgument;
|
||||
}
|
||||
|
||||
// There are no friends online, so we return 0 because the nn::account::NetworkServiceAccountId array is empty.
|
||||
context.ResponseData.Write(0);
|
||||
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceFriend, new
|
||||
{
|
||||
UserId = userId.ToString(),
|
||||
offset,
|
||||
filter.PresenceStatus,
|
||||
filter.IsFavoriteOnly,
|
||||
filter.IsSameAppPresenceOnly,
|
||||
filter.IsSameAppPlayedOnly,
|
||||
filter.IsArbitraryAppPlayedOnly,
|
||||
filter.PresenceGroupId,
|
||||
});
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[CommandCmif(10120)] // 10.0.0+
|
||||
// nn::friends::IsFriendListCacheAvailable(nn::account::Uid userId) -> bool
|
||||
public ResultCode IsFriendListCacheAvailable(ServiceCtx context)
|
||||
{
|
||||
UserId userId = context.RequestData.ReadStruct<UserId>();
|
||||
|
||||
if (userId.IsNull)
|
||||
{
|
||||
return ResultCode.InvalidArgument;
|
||||
}
|
||||
|
||||
// TODO: Service mount the friends:/ system savedata and try to load friend.cache file, returns true if exists, false otherwise.
|
||||
// NOTE: If no cache is available, guest then calls nn::friends::EnsureFriendListAvailable, we can avoid that by faking the cache check.
|
||||
context.ResponseData.Write(true);
|
||||
|
||||
// TODO: Since we don't support friend features, it's fine to stub it for now.
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceFriend, new { UserId = userId.ToString() });
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[CommandCmif(10121)] // 10.0.0+
|
||||
// nn::friends::EnsureFriendListAvailable(nn::account::Uid userId)
|
||||
public ResultCode EnsureFriendListAvailable(ServiceCtx context)
|
||||
{
|
||||
UserId userId = context.RequestData.ReadStruct<UserId>();
|
||||
|
||||
if (userId.IsNull)
|
||||
{
|
||||
return ResultCode.InvalidArgument;
|
||||
}
|
||||
|
||||
// TODO: Service mount the friends:/ system savedata and create a friend.cache file for the given user id.
|
||||
// Since we don't support friend features, it's fine to stub it for now.
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceFriend, new { UserId = userId.ToString() });
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[CommandCmif(10400)]
|
||||
// nn::friends::GetBlockedUserListIds(int offset, nn::account::Uid userId) -> (u32, buffer<nn::account::NetworkServiceAccountId, 0xa>)
|
||||
public ResultCode GetBlockedUserListIds(ServiceCtx context)
|
||||
{
|
||||
int offset = context.RequestData.ReadInt32();
|
||||
|
||||
// Padding
|
||||
context.RequestData.ReadInt32();
|
||||
|
||||
UserId userId = context.RequestData.ReadStruct<UserId>();
|
||||
|
||||
// There are no friends blocked, so we return 0 because the nn::account::NetworkServiceAccountId array is empty.
|
||||
context.ResponseData.Write(0);
|
||||
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceFriend, new { offset, UserId = userId.ToString() });
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[CommandCmif(10420)]
|
||||
// nn::friends::CheckBlockedUserListAvailability(nn::account::Uid userId) -> bool
|
||||
public ResultCode CheckBlockedUserListAvailability(ServiceCtx context)
|
||||
{
|
||||
UserId userId = context.RequestData.ReadStruct<UserId>();
|
||||
|
||||
// Yes, it is available.
|
||||
context.ResponseData.Write(true);
|
||||
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceFriend, new { UserId = userId.ToString() });
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[CommandCmif(10600)]
|
||||
// nn::friends::DeclareOpenOnlinePlaySession(nn::account::Uid userId)
|
||||
public ResultCode DeclareOpenOnlinePlaySession(ServiceCtx context)
|
||||
{
|
||||
UserId userId = context.RequestData.ReadStruct<UserId>();
|
||||
|
||||
if (userId.IsNull)
|
||||
{
|
||||
return ResultCode.InvalidArgument;
|
||||
}
|
||||
|
||||
context.Device.System.AccountManager.OpenUserOnlinePlay(userId);
|
||||
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceFriend, new { UserId = userId.ToString() });
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[CommandCmif(10601)]
|
||||
// nn::friends::DeclareCloseOnlinePlaySession(nn::account::Uid userId)
|
||||
public ResultCode DeclareCloseOnlinePlaySession(ServiceCtx context)
|
||||
{
|
||||
UserId userId = context.RequestData.ReadStruct<UserId>();
|
||||
|
||||
if (userId.IsNull)
|
||||
{
|
||||
return ResultCode.InvalidArgument;
|
||||
}
|
||||
|
||||
context.Device.System.AccountManager.CloseUserOnlinePlay(userId);
|
||||
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceFriend, new { UserId = userId.ToString() });
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[CommandCmif(10610)]
|
||||
// nn::friends::UpdateUserPresence(nn::account::Uid, u64, pid, buffer<nn::friends::detail::UserPresenceImpl, 0x19>)
|
||||
public ResultCode UpdateUserPresence(ServiceCtx context)
|
||||
{
|
||||
UserId uuid = context.RequestData.ReadStruct<UserId>();
|
||||
|
||||
// Pid placeholder
|
||||
context.RequestData.ReadInt64();
|
||||
|
||||
ulong position = context.Request.PtrBuff[0].Position;
|
||||
ulong size = context.Request.PtrBuff[0].Size;
|
||||
|
||||
ReadOnlySpan<UserPresence> userPresenceInputArray = MemoryMarshal.Cast<byte, UserPresence>(context.Memory.GetSpan(position, (int)size));
|
||||
|
||||
if (uuid.IsNull)
|
||||
{
|
||||
return ResultCode.InvalidArgument;
|
||||
}
|
||||
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceFriend, new { UserId = uuid.ToString(), userPresenceInputArray = userPresenceInputArray.ToArray() });
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[CommandCmif(10700)]
|
||||
// nn::friends::GetPlayHistoryRegistrationKey(b8 unknown, nn::account::Uid) -> buffer<nn::friends::PlayHistoryRegistrationKey, 0x1a>
|
||||
public ResultCode GetPlayHistoryRegistrationKey(ServiceCtx context)
|
||||
{
|
||||
bool unknownBool = context.RequestData.ReadBoolean();
|
||||
UserId userId = context.RequestData.ReadStruct<UserId>();
|
||||
|
||||
context.Response.PtrBuff[0] = context.Response.PtrBuff[0].WithSize(0x40UL);
|
||||
|
||||
ulong bufferPosition = context.Request.RecvListBuff[0].Position;
|
||||
|
||||
if (userId.IsNull)
|
||||
{
|
||||
return ResultCode.InvalidArgument;
|
||||
}
|
||||
|
||||
// NOTE: Calls nn::friends::detail::service::core::PlayHistoryManager::GetInstance and stores the instance.
|
||||
|
||||
byte[] randomBytes = new byte[8];
|
||||
|
||||
Random.Shared.NextBytes(randomBytes);
|
||||
|
||||
// NOTE: Calls nn::friends::detail::service::core::UuidManager::GetInstance and stores the instance.
|
||||
// Then call nn::friends::detail::service::core::AccountStorageManager::GetInstance and store the instance.
|
||||
// Then it checks if an Uuid is already stored for the UserId, if not it generates a random Uuid.
|
||||
// And store it in the savedata 8000000000000080 in the friends:/uid.bin file.
|
||||
|
||||
Array16<byte> randomGuid = new();
|
||||
|
||||
Guid.NewGuid().ToByteArray().AsSpan().CopyTo(randomGuid.AsSpan());
|
||||
|
||||
PlayHistoryRegistrationKey playHistoryRegistrationKey = new()
|
||||
{
|
||||
Type = 0x101,
|
||||
KeyIndex = (byte)(randomBytes[0] & 7),
|
||||
UserIdBool = 0, // TODO: Find it.
|
||||
UnknownBool = (byte)(unknownBool ? 1 : 0), // TODO: Find it.
|
||||
Reserved = new Array11<byte>(),
|
||||
Uuid = randomGuid,
|
||||
};
|
||||
|
||||
ReadOnlySpan<byte> playHistoryRegistrationKeyBuffer = SpanHelpers.AsByteSpan(ref playHistoryRegistrationKey);
|
||||
|
||||
/*
|
||||
|
||||
NOTE: The service uses the KeyIndex to get a random key from a keys buffer (since the key index is stored in the returned buffer).
|
||||
We currently don't support play history and online services so we can use a blank key for now.
|
||||
Code for reference:
|
||||
|
||||
byte[] hmacKey = new byte[0x20];
|
||||
|
||||
HMACSHA256 hmacSha256 = new HMACSHA256(hmacKey);
|
||||
byte[] hmacHash = hmacSha256.ComputeHash(playHistoryRegistrationKeyBuffer);
|
||||
|
||||
*/
|
||||
|
||||
context.Memory.Write(bufferPosition, playHistoryRegistrationKeyBuffer);
|
||||
context.Memory.Write(bufferPosition + 0x20, new byte[0x20]); // HmacHash
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[CommandCmif(10702)]
|
||||
// nn::friends::AddPlayHistory(nn::account::Uid, u64, pid, buffer<nn::friends::PlayHistoryRegistrationKey, 0x19>, buffer<nn::friends::InAppScreenName, 0x19>, buffer<nn::friends::InAppScreenName, 0x19>)
|
||||
public ResultCode AddPlayHistory(ServiceCtx context)
|
||||
{
|
||||
UserId userId = context.RequestData.ReadStruct<UserId>();
|
||||
|
||||
// Pid placeholder
|
||||
context.RequestData.ReadInt64();
|
||||
#pragma warning disable IDE0059 // Remove unnecessary value assignment
|
||||
ulong pid = context.Request.HandleDesc.PId;
|
||||
|
||||
ulong playHistoryRegistrationKeyPosition = context.Request.PtrBuff[0].Position;
|
||||
ulong playHistoryRegistrationKeySize = context.Request.PtrBuff[0].Size;
|
||||
|
||||
ulong inAppScreenName1Position = context.Request.PtrBuff[1].Position;
|
||||
#pragma warning restore IDE0059
|
||||
ulong inAppScreenName1Size = context.Request.PtrBuff[1].Size;
|
||||
|
||||
#pragma warning disable IDE0059 // Remove unnecessary value assignment
|
||||
ulong inAppScreenName2Position = context.Request.PtrBuff[2].Position;
|
||||
#pragma warning restore IDE0059
|
||||
ulong inAppScreenName2Size = context.Request.PtrBuff[2].Size;
|
||||
|
||||
if (userId.IsNull || inAppScreenName1Size > 0x48 || inAppScreenName2Size > 0x48)
|
||||
{
|
||||
return ResultCode.InvalidArgument;
|
||||
}
|
||||
|
||||
// TODO: Call nn::arp::GetApplicationControlProperty here when implemented.
|
||||
#pragma warning disable IDE0059 // Remove unnecessary value assignment
|
||||
ApplicationControlProperty controlProperty = context.Device.Processes.ActiveApplication.ApplicationControlProperties;
|
||||
#pragma warning restore IDE0059
|
||||
|
||||
/*
|
||||
|
||||
NOTE: The service calls nn::friends::detail::service::core::PlayHistoryManager to store informations using the registration key computed in GetPlayHistoryRegistrationKey.
|
||||
Then calls nn::friends::detail::service::core::FriendListManager to update informations on the friend list.
|
||||
We currently don't support play history and online services so it's fine to do nothing.
|
||||
|
||||
*/
|
||||
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceFriend);
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,178 +0,0 @@
|
||||
using Ryujinx.Common;
|
||||
using Ryujinx.HLE.HOS.Ipc;
|
||||
using Ryujinx.HLE.HOS.Kernel.Threading;
|
||||
using Ryujinx.HLE.HOS.Services.Account.Acc;
|
||||
using Ryujinx.HLE.HOS.Services.Friend.ServiceCreator.NotificationService;
|
||||
using Ryujinx.Horizon.Common;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Friend.ServiceCreator
|
||||
{
|
||||
class INotificationService : DisposableIpcService
|
||||
{
|
||||
private readonly UserId _userId;
|
||||
private readonly FriendServicePermissionLevel _permissionLevel;
|
||||
|
||||
private readonly object _lock = new();
|
||||
|
||||
private readonly KEvent _notificationEvent;
|
||||
private int _notificationEventHandle = 0;
|
||||
|
||||
private readonly LinkedList<NotificationInfo> _notifications;
|
||||
|
||||
private bool _hasNewFriendRequest;
|
||||
private bool _hasFriendListUpdate;
|
||||
|
||||
public INotificationService(ServiceCtx context, UserId userId, FriendServicePermissionLevel permissionLevel)
|
||||
{
|
||||
_userId = userId;
|
||||
_permissionLevel = permissionLevel;
|
||||
_notifications = new LinkedList<NotificationInfo>();
|
||||
_notificationEvent = new KEvent(context.Device.System.KernelContext);
|
||||
|
||||
_hasNewFriendRequest = false;
|
||||
_hasFriendListUpdate = false;
|
||||
|
||||
NotificationEventHandler.Instance.RegisterNotificationService(this);
|
||||
}
|
||||
|
||||
[CommandCmif(0)] //2.0.0+
|
||||
// nn::friends::detail::ipc::INotificationService::GetEvent() -> handle<copy>
|
||||
public ResultCode GetEvent(ServiceCtx context)
|
||||
{
|
||||
if (_notificationEventHandle == 0)
|
||||
{
|
||||
if (context.Process.HandleTable.GenerateHandle(_notificationEvent.ReadableEvent, out _notificationEventHandle) != Result.Success)
|
||||
{
|
||||
throw new InvalidOperationException("Out of handles!");
|
||||
}
|
||||
}
|
||||
|
||||
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_notificationEventHandle);
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[CommandCmif(1)] //2.0.0+
|
||||
// nn::friends::detail::ipc::INotificationService::Clear()
|
||||
public ResultCode Clear(ServiceCtx context)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
_hasNewFriendRequest = false;
|
||||
_hasFriendListUpdate = false;
|
||||
|
||||
_notifications.Clear();
|
||||
}
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[CommandCmif(2)] // 2.0.0+
|
||||
// nn::friends::detail::ipc::INotificationService::Pop() -> nn::friends::detail::ipc::SizedNotificationInfo
|
||||
public ResultCode Pop(ServiceCtx context)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if (_notifications.Count >= 1)
|
||||
{
|
||||
NotificationInfo notificationInfo = _notifications.First.Value;
|
||||
_notifications.RemoveFirst();
|
||||
|
||||
if (notificationInfo.Type == NotificationEventType.FriendListUpdate)
|
||||
{
|
||||
_hasFriendListUpdate = false;
|
||||
}
|
||||
else if (notificationInfo.Type == NotificationEventType.NewFriendRequest)
|
||||
{
|
||||
_hasNewFriendRequest = false;
|
||||
}
|
||||
|
||||
context.ResponseData.WriteStruct(notificationInfo);
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
}
|
||||
|
||||
return ResultCode.NotificationQueueEmpty;
|
||||
}
|
||||
|
||||
public void SignalFriendListUpdate(UserId targetId)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if (_userId == targetId)
|
||||
{
|
||||
if (!_hasFriendListUpdate)
|
||||
{
|
||||
NotificationInfo friendListNotification = new();
|
||||
|
||||
if (_notifications.Count != 0)
|
||||
{
|
||||
friendListNotification = _notifications.First.Value;
|
||||
_notifications.RemoveFirst();
|
||||
}
|
||||
|
||||
friendListNotification.Type = NotificationEventType.FriendListUpdate;
|
||||
_hasFriendListUpdate = true;
|
||||
|
||||
if (_hasNewFriendRequest)
|
||||
{
|
||||
NotificationInfo newFriendRequestNotification = new();
|
||||
|
||||
if (_notifications.Count != 0)
|
||||
{
|
||||
newFriendRequestNotification = _notifications.First.Value;
|
||||
_notifications.RemoveFirst();
|
||||
}
|
||||
|
||||
newFriendRequestNotification.Type = NotificationEventType.NewFriendRequest;
|
||||
_notifications.AddFirst(newFriendRequestNotification);
|
||||
}
|
||||
|
||||
// We defer this to make sure we are on top of the queue.
|
||||
_notifications.AddFirst(friendListNotification);
|
||||
}
|
||||
|
||||
_notificationEvent.ReadableEvent.Signal();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SignalNewFriendRequest(UserId targetId)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if ((_permissionLevel & FriendServicePermissionLevel.ViewerMask) != 0 && _userId == targetId)
|
||||
{
|
||||
if (!_hasNewFriendRequest)
|
||||
{
|
||||
if (_notifications.Count == 100)
|
||||
{
|
||||
SignalFriendListUpdate(targetId);
|
||||
}
|
||||
|
||||
NotificationInfo newFriendRequestNotification = new()
|
||||
{
|
||||
Type = NotificationEventType.NewFriendRequest,
|
||||
};
|
||||
|
||||
_notifications.AddLast(newFriendRequestNotification);
|
||||
_hasNewFriendRequest = true;
|
||||
}
|
||||
|
||||
_notificationEvent.ReadableEvent.Signal();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
if (isDisposing)
|
||||
{
|
||||
NotificationEventHandler.Instance.UnregisterNotificationService(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,74 +0,0 @@
|
||||
using Ryujinx.HLE.HOS.Services.Account.Acc;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Friend.ServiceCreator.NotificationService
|
||||
{
|
||||
public sealed class NotificationEventHandler
|
||||
{
|
||||
private static NotificationEventHandler _instance;
|
||||
private static readonly object _instanceLock = new();
|
||||
|
||||
private readonly INotificationService[] _registry;
|
||||
|
||||
public static NotificationEventHandler Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_instanceLock)
|
||||
{
|
||||
_instance ??= new NotificationEventHandler();
|
||||
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NotificationEventHandler()
|
||||
{
|
||||
_registry = new INotificationService[0x20];
|
||||
}
|
||||
|
||||
internal void RegisterNotificationService(INotificationService service)
|
||||
{
|
||||
// NOTE: in case there isn't space anymore in the registry array, Nintendo doesn't return any errors.
|
||||
for (int i = 0; i < _registry.Length; i++)
|
||||
{
|
||||
if (_registry[i] == null)
|
||||
{
|
||||
_registry[i] = service;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal void UnregisterNotificationService(INotificationService service)
|
||||
{
|
||||
// NOTE: in case there isn't the entry in the registry array, Nintendo doesn't return any errors.
|
||||
for (int i = 0; i < _registry.Length; i++)
|
||||
{
|
||||
if (_registry[i] == service)
|
||||
{
|
||||
_registry[i] = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Use this when we will have enough things to go online.
|
||||
public void SignalFriendListUpdate(UserId targetId)
|
||||
{
|
||||
for (int i = 0; i < _registry.Length; i++)
|
||||
{
|
||||
_registry[i]?.SignalFriendListUpdate(targetId);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Use this when we will have enough things to go online.
|
||||
public void SignalNewFriendRequest(UserId targetId)
|
||||
{
|
||||
for (int i = 0; i < _registry.Length; i++)
|
||||
{
|
||||
_registry[i]?.SignalNewFriendRequest(targetId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
using Ryujinx.Common.Memory;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Friend.ServiceCreator.NotificationService
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Size = 0x10)]
|
||||
struct NotificationInfo
|
||||
{
|
||||
public NotificationEventType Type;
|
||||
private Array4<byte> _padding;
|
||||
public long NetworkUserIdPlaceholder;
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@ using LibHac;
|
||||
using LibHac.Common;
|
||||
using LibHac.Fs;
|
||||
using LibHac.Fs.Fsa;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Path = LibHac.FsSrv.Sf.Path;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
@ -149,7 +150,13 @@ namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
// Commit()
|
||||
public ResultCode Commit(ServiceCtx context)
|
||||
{
|
||||
return (ResultCode)_fileSystem.Get.Commit().Value;
|
||||
ResultCode resultCode = (ResultCode)_fileSystem.Get.Commit().Value;
|
||||
if (resultCode == ResultCode.PathAlreadyInUse)
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.ServiceFs, "The file system is already in use by another process.");
|
||||
}
|
||||
|
||||
return resultCode;
|
||||
}
|
||||
|
||||
[CommandCmif(11)]
|
||||
|
65
src/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/LazyFile.cs
Normal file
65
src/Ryujinx.HLE/HOS/Services/Fs/FileSystemProxy/LazyFile.cs
Normal file
@ -0,0 +1,65 @@
|
||||
using LibHac;
|
||||
using LibHac.Common;
|
||||
using LibHac.Fs;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy
|
||||
{
|
||||
class LazyFile : LibHac.Fs.Fsa.IFile
|
||||
{
|
||||
private readonly LibHac.Fs.Fsa.IFileSystem _fs;
|
||||
private readonly string _filePath;
|
||||
private readonly UniqueRef<LibHac.Fs.Fsa.IFile> _fileReference = new();
|
||||
private readonly FileInfo _fileInfo;
|
||||
|
||||
public LazyFile(string filePath, string prefix, LibHac.Fs.Fsa.IFileSystem fs)
|
||||
{
|
||||
_fs = fs;
|
||||
_filePath = filePath;
|
||||
_fileInfo = new FileInfo(prefix + "/" + filePath);
|
||||
}
|
||||
|
||||
private void PrepareFile()
|
||||
{
|
||||
if (_fileReference.Get == null)
|
||||
{
|
||||
_fs.OpenFile(ref _fileReference.Ref, _filePath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
|
||||
}
|
||||
}
|
||||
|
||||
protected override Result DoRead(out long bytesRead, long offset, Span<byte> destination, in ReadOption option)
|
||||
{
|
||||
PrepareFile();
|
||||
|
||||
return _fileReference.Get!.Read(out bytesRead, offset, destination);
|
||||
}
|
||||
|
||||
protected override Result DoWrite(long offset, ReadOnlySpan<byte> source, in WriteOption option)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
protected override Result DoFlush()
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
protected override Result DoSetSize(long size)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
protected override Result DoGetSize(out long size)
|
||||
{
|
||||
size = _fileInfo.Length;
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
protected override Result DoOperateRange(Span<byte> outBuffer, OperationId operationId, long offset, long size, ReadOnlySpan<byte> inBuffer)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
}
|
@ -159,9 +159,7 @@ namespace Ryujinx.HLE.HOS.Services.Pctl.ParentalControlServiceFactory
|
||||
}
|
||||
else
|
||||
{
|
||||
#pragma warning disable CS0162 // Unreachable code
|
||||
return ResultCode.StereoVisionRestrictionConfigurableDisabled;
|
||||
#pragma warning restore CS0162
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -287,6 +287,10 @@ namespace Ryujinx.HLE.HOS.Services
|
||||
_wakeEvent.WritableEvent.Clear();
|
||||
}
|
||||
}
|
||||
else if (rc == KernelResult.PortRemoteClosed && signaledIndex >= 0 && SmObjectFactory != null)
|
||||
{
|
||||
DestroySession(handles[signaledIndex]);
|
||||
}
|
||||
|
||||
_selfProcess.CpuMemory.Write(messagePtr + 0x0, 0);
|
||||
_selfProcess.CpuMemory.Write(messagePtr + 0x4, 2 << 10);
|
||||
@ -299,6 +303,16 @@ namespace Ryujinx.HLE.HOS.Services
|
||||
Dispose();
|
||||
}
|
||||
|
||||
private void DestroySession(int serverSessionHandle)
|
||||
{
|
||||
_context.Syscall.CloseHandle(serverSessionHandle);
|
||||
|
||||
if (RemoveSessionObj(serverSessionHandle, out var session))
|
||||
{
|
||||
(session as IDisposable)?.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private bool Process(int serverSessionHandle, ulong recvListAddr)
|
||||
{
|
||||
IpcMessage request = ReadRequest();
|
||||
@ -360,7 +374,7 @@ namespace Ryujinx.HLE.HOS.Services
|
||||
response.RawData = _responseDataStream.ToArray();
|
||||
}
|
||||
else if (request.Type == IpcMessageType.CmifControl ||
|
||||
request.Type == IpcMessageType.CmifControlWithContext)
|
||||
request.Type == IpcMessageType.CmifControlWithContext)
|
||||
{
|
||||
#pragma warning disable IDE0059 // Remove unnecessary value assignment
|
||||
uint magic = (uint)_requestDataReader.ReadUInt64();
|
||||
@ -412,11 +426,7 @@ namespace Ryujinx.HLE.HOS.Services
|
||||
}
|
||||
else if (request.Type == IpcMessageType.CmifCloseSession || request.Type == IpcMessageType.TipcCloseSession)
|
||||
{
|
||||
_context.Syscall.CloseHandle(serverSessionHandle);
|
||||
if (RemoveSessionObj(serverSessionHandle, out var session))
|
||||
{
|
||||
(session as IDisposable)?.Dispose();
|
||||
}
|
||||
DestroySession(serverSessionHandle);
|
||||
shouldReply = false;
|
||||
}
|
||||
// If the type is past 0xF, we are using TIPC
|
||||
|
@ -121,7 +121,14 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
|
||||
{
|
||||
IPEndPoint endPoint = isRemote ? socket.RemoteEndPoint : socket.LocalEndPoint;
|
||||
|
||||
context.Memory.Write(bufferPosition, BsdSockAddr.FromIPEndPoint(endPoint));
|
||||
if (endPoint != null)
|
||||
{
|
||||
context.Memory.Write(bufferPosition, BsdSockAddr.FromIPEndPoint(endPoint));
|
||||
}
|
||||
else
|
||||
{
|
||||
context.Memory.Write(bufferPosition, new BsdSockAddr());
|
||||
}
|
||||
}
|
||||
|
||||
[CommandCmif(0)]
|
||||
|
@ -3,6 +3,7 @@ using Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl;
|
||||
using Ryujinx.HLE.HOS.Services.Ssl.Types;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Security;
|
||||
using System.Net.Sockets;
|
||||
using System.Security.Authentication;
|
||||
@ -83,10 +84,40 @@ namespace Ryujinx.HLE.HOS.Services.Ssl.SslService
|
||||
}
|
||||
#pragma warning restore SYSLIB0039
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve the hostname of the current remote in case the provided hostname is null or empty.
|
||||
/// </summary>
|
||||
/// <param name="hostName">The current hostname</param>
|
||||
/// <returns>Either the resolved or provided hostname</returns>
|
||||
/// <remarks>
|
||||
/// This is done to avoid getting an <see cref="System.Security.Authentication.AuthenticationException"/>
|
||||
/// as the remote certificate will be rejected with <c>RemoteCertificateNameMismatch</c> due to an empty hostname.
|
||||
/// This is not what the switch does!
|
||||
/// It might just skip remote hostname verification if the hostname wasn't set with <see cref="ISslConnection.SetHostName"/> before.
|
||||
/// TODO: Remove this as soon as we know how the switch deals with empty hostnames
|
||||
/// </remarks>
|
||||
private string RetrieveHostName(string hostName)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(hostName))
|
||||
{
|
||||
return hostName;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return Dns.GetHostEntry(Socket.RemoteEndPoint.Address).HostName;
|
||||
}
|
||||
catch (SocketException)
|
||||
{
|
||||
return hostName;
|
||||
}
|
||||
}
|
||||
|
||||
public ResultCode Handshake(string hostName)
|
||||
{
|
||||
StartSslOperation();
|
||||
_stream = new SslStream(new NetworkStream(((ManagedSocket)Socket).Socket, false), false, null, null);
|
||||
hostName = RetrieveHostName(hostName);
|
||||
_stream.AuthenticateAsClient(hostName, null, TranslateSslVersion(_sslVersion), false);
|
||||
EndSslOperation();
|
||||
|
||||
|
@ -34,7 +34,7 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions
|
||||
return metaLoader;
|
||||
}
|
||||
|
||||
public static ProcessResult Load(this IFileSystem exeFs, Switch device, BlitStruct<ApplicationControlProperty> nacpData, MetaLoader metaLoader, bool isHomebrew = false)
|
||||
public static ProcessResult Load(this IFileSystem exeFs, Switch device, BlitStruct<ApplicationControlProperty> nacpData, MetaLoader metaLoader, byte programIndex, bool isHomebrew = false)
|
||||
{
|
||||
ulong programId = metaLoader.GetProgramId();
|
||||
|
||||
@ -119,6 +119,7 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions
|
||||
true,
|
||||
programName,
|
||||
metaLoader.GetProgramId(),
|
||||
programIndex,
|
||||
null,
|
||||
nsoExecutables);
|
||||
|
||||
|
@ -16,17 +16,14 @@ namespace Ryujinx.HLE.Loaders.Processes
|
||||
var nacpData = new BlitStruct<ApplicationControlProperty>(1);
|
||||
ulong programId = metaLoader.GetProgramId();
|
||||
|
||||
device.Configuration.VirtualFileSystem.ModLoader.CollectMods(
|
||||
new[] { programId },
|
||||
ModLoader.GetModsBasePath(),
|
||||
ModLoader.GetSdModsBasePath());
|
||||
device.Configuration.VirtualFileSystem.ModLoader.CollectMods(new[] { programId });
|
||||
|
||||
if (programId != 0)
|
||||
{
|
||||
ProcessLoaderHelper.EnsureSaveData(device, new ApplicationId(programId), nacpData);
|
||||
}
|
||||
|
||||
ProcessResult processResult = exeFs.Load(device, nacpData, metaLoader);
|
||||
ProcessResult processResult = exeFs.Load(device, nacpData, metaLoader, 0);
|
||||
|
||||
// Load RomFS.
|
||||
if (!string.IsNullOrEmpty(romFsPath))
|
||||
|
@ -61,7 +61,7 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions
|
||||
|
||||
*/
|
||||
|
||||
ProcessResult processResult = exeFs.Load(device, nacpData, metaLoader);
|
||||
ProcessResult processResult = exeFs.Load(device, nacpData, metaLoader, (byte)nca.GetProgramIndex());
|
||||
|
||||
// Load RomFS.
|
||||
if (romFs == null)
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user