Compare commits

...

5 Commits

Author SHA1 Message Date
Ac_K
7795b662a9 Mod: Do LayeredFs loading Parallel to improve speed (#6180)
* Mod: Do LayeredFs loading Parallel to improve speed

This fixes and superseed #5672 due to inactivity, nothing more.
(See original PR for description)

Testing are welcome.

Close #5661

* Addresses gdkchan's feedback

* commit to test mako change

* Revert "commit to test mako change"

This reverts commit 8b0caa8a21.
2024-01-29 16:32:34 +01:00
gdkchan
30bdc4544e Fix NRE when calling GetSockName before Bind (#6206) 2024-01-29 16:28:32 +01:00
TSRBerry
f6475cca17 infra: Reformat README.md & add new generic Mako workflow (#5791)
* Adjust workflow paths to exclude all markdown files

* editorconfig: Add default charset and adjust indention for a few file types

* Reformat README.md and add a link to our documentation

* Add generic Mako workflow and remove old Mako steps

* editorconfig: Move charset change to a different PR

* Update compatibility stats

Co-authored-by: Ac_K <Acoustik666@gmail.com>

---------

Co-authored-by: Ac_K <Acoustik666@gmail.com>
2024-01-27 20:50:28 +01:00
dependabot[bot]
0335c52254 nuget: bump NetCoreServer from 7.0.0 to 8.0.7 (#6119)
Bumps [NetCoreServer](https://github.com/chronoxor/NetCoreServer) from 7.0.0 to 8.0.7.
- [Release notes](https://github.com/chronoxor/NetCoreServer/releases)
- [Commits](https://github.com/chronoxor/NetCoreServer/commits)

---
updated-dependencies:
- dependency-name: NetCoreServer
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-27 02:02:12 +01:00
gdkchan
b8d992e5a7 Allow skipping draws with broken pipeline variants on Vulkan (#5807)
* Allow skipping draws with broken pipeline variants on Vulkan

* Move IsLinked check to CreatePipeline

* Restore throw on error behaviour for background compile

* Can't remove SetAlphaTest pragmas yet

* Double new line
2024-01-26 13:58:57 -03:00
15 changed files with 299 additions and 122 deletions

View File

@@ -17,8 +17,8 @@ tab_width = 4
end_of_line = lf end_of_line = lf
insert_final_newline = true insert_final_newline = true
# JSON files # Markdown, JSON, YAML, props and csproj files
[*.json] [*.{md,json,yml,props,csproj}]
# Indentation and spacing # Indentation and spacing
indent_size = 2 indent_size = 2

View File

@@ -8,7 +8,7 @@ on:
- '!.github/**' - '!.github/**'
- '!*.yml' - '!*.yml'
- '!*.config' - '!*.config'
- '!README.md' - '!*.md'
- '.github/workflows/*.yml' - '.github/workflows/*.yml'
permissions: permissions:

45
.github/workflows/mako.yml vendored Normal file
View File

@@ -0,0 +1,45 @@
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_review:
types: [submitted, dismissed]
pull_request_review_comment:
types: [created, edited]
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 }}

View File

@@ -21,27 +21,8 @@ jobs:
repository: Ryujinx/Ryujinx repository: Ryujinx/Ryujinx
ref: master 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 - name: Update labels based on changes
uses: actions/labeler@v5 uses: actions/labeler@v5
with: with:
sync-labels: true sync-labels: true
dot: 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 }}

View File

@@ -10,7 +10,7 @@ on:
- '*.yml' - '*.yml'
- '*.json' - '*.json'
- '*.config' - '*.config'
- 'README.md' - '*.md'
concurrency: release concurrency: release

View File

@@ -25,7 +25,7 @@
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.8.0" /> <PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageVersion Include="Microsoft.IO.RecyclableMemoryStream" Version="3.0.0" /> <PackageVersion Include="Microsoft.IO.RecyclableMemoryStream" Version="3.0.0" />
<PackageVersion Include="MsgPack.Cli" Version="1.0.1" /> <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="NUnit" Version="3.13.3" />
<PackageVersion Include="NUnit3TestAdapter" Version="4.1.0" /> <PackageVersion Include="NUnit3TestAdapter" Version="4.1.0" />
<PackageVersion Include="OpenTK.Core" Version="4.8.2" /> <PackageVersion Include="OpenTK.Core" Version="4.8.2" />

View File

@@ -1,21 +1,21 @@
<h1 align="center"> <h1 align="center">
<br> <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> <br>
<b>Ryujinx</b> <b>Ryujinx</b>
<br> <br>
<sub><sup><b>(REE-YOU-JINX)</b></sup></sub> <sub><sup><b>(REE-YOU-JINX)</b></sup></sub>
<br> <br>
</h1> </h1>
<p align="center"> <p align="center">
Ryujinx is an open-source Nintendo Switch emulator, created by gdkchan, written in C#. 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. 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 /> 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>
<p align="center"> <p align="center">
<a href="https://github.com/Ryujinx/Ryujinx/actions/workflows/release.yml"> <a href="https://github.com/Ryujinx/Ryujinx/actions/workflows/release.yml">
<img src="https://github.com/Ryujinx/Ryujinx/actions/workflows/release.yml/badge.svg" <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"> <img src="https://raw.githubusercontent.com/Ryujinx/Ryujinx-Website/master/public/assets/images/shell.png">
</p> </p>
<h5 align="center">
</h5>
## Compatibility ## 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. As of October 2023, Ryujinx has been tested on approximately 4,200 titles;
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! 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 ## 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. 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). ](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. Avalonia UI comes with translations for various languages. See [Crowdin](https://crwd.in/ryujinx) for more information.
## Latest build ## 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). 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). 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 ## Building
If you wish to build the emulator yourself, follow these steps: If you wish to build the emulator yourself, follow these steps:
### Step 1 ### 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 ### 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. 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 ### 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: To build Ryujinx, open a command prompt inside the project directory.
`dotnet build -c Release -o build` 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. 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 ## 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** - **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. 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.
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. It translates the ARM code to a custom IR, performs a few optimizations, and turns that into x86 code.
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. 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** - **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** - **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. We currently have support for keyboard, mouse, touch input, JoyCon input support, and nearly all controllers.
In all scenarios, you can set up everything inside the input configuration menu. 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** - **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** - **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 ## 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 ## Donations
@@ -134,9 +158,10 @@ All funds received through Patreon are considered a donation to support the proj
## License ## 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. 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. See [LICENSE.txt](LICENSE.txt) and [THIRDPARTY.md](distribution/legal/THIRDPARTY.md) for more details.
## Credits ## Credits
- [LibHac](https://github.com/Thealexbarney/LibHac) is used for our file-system. - [LibHac](https://github.com/Thealexbarney/LibHac) is used for our file-system.

View File

@@ -34,7 +34,8 @@ namespace Ryujinx.Graphics.Vulkan
protected PipelineDynamicState DynamicState; protected PipelineDynamicState DynamicState;
private PipelineState _newState; private PipelineState _newState;
private bool _stateDirty; private bool _graphicsStateDirty;
private bool _computeStateDirty;
private PrimitiveTopology _topology; private PrimitiveTopology _topology;
private ulong _currentPipelineHandle; private ulong _currentPipelineHandle;
@@ -353,7 +354,7 @@ namespace Ryujinx.Graphics.Vulkan
} }
EndRenderPass(); EndRenderPass();
RecreatePipelineIfNeeded(PipelineBindPoint.Compute); RecreateComputePipelineIfNeeded();
Gd.Api.CmdDispatch(CommandBuffer, (uint)groupsX, (uint)groupsY, (uint)groupsZ); Gd.Api.CmdDispatch(CommandBuffer, (uint)groupsX, (uint)groupsY, (uint)groupsZ);
} }
@@ -366,19 +367,23 @@ namespace Ryujinx.Graphics.Vulkan
} }
EndRenderPass(); EndRenderPass();
RecreatePipelineIfNeeded(PipelineBindPoint.Compute); RecreateComputePipelineIfNeeded();
Gd.Api.CmdDispatchIndirect(CommandBuffer, indirectBuffer.Get(Cbs, indirectBufferOffset, 12).Value, (ulong)indirectBufferOffset); Gd.Api.CmdDispatchIndirect(CommandBuffer, indirectBuffer.Get(Cbs, indirectBufferOffset, 12).Value, (ulong)indirectBufferOffset);
} }
public void Draw(int vertexCount, int instanceCount, int firstVertex, int firstInstance) public void Draw(int vertexCount, int instanceCount, int firstVertex, int firstInstance)
{ {
if (!_program.IsLinked || vertexCount == 0) if (vertexCount == 0)
{
return;
}
if (!RecreateGraphicsPipelineIfNeeded())
{ {
return; return;
} }
RecreatePipelineIfNeeded(PipelineBindPoint.Graphics);
BeginRenderPass(); BeginRenderPass();
DrawCount++; DrawCount++;
@@ -437,13 +442,18 @@ namespace Ryujinx.Graphics.Vulkan
public void DrawIndexed(int indexCount, int instanceCount, int firstIndex, int firstVertex, int firstInstance) public void DrawIndexed(int indexCount, int instanceCount, int firstIndex, int firstVertex, int firstInstance)
{ {
if (!_program.IsLinked || indexCount == 0) if (indexCount == 0)
{ {
return; return;
} }
UpdateIndexBufferPattern(); UpdateIndexBufferPattern();
RecreatePipelineIfNeeded(PipelineBindPoint.Graphics);
if (!RecreateGraphicsPipelineIfNeeded())
{
return;
}
BeginRenderPass(); BeginRenderPass();
DrawCount++; DrawCount++;
@@ -476,17 +486,17 @@ namespace Ryujinx.Graphics.Vulkan
public void DrawIndexedIndirect(BufferRange indirectBuffer) public void DrawIndexedIndirect(BufferRange indirectBuffer)
{ {
if (!_program.IsLinked)
{
return;
}
var buffer = Gd.BufferManager var buffer = Gd.BufferManager
.GetBuffer(CommandBuffer, indirectBuffer.Handle, indirectBuffer.Offset, indirectBuffer.Size, false) .GetBuffer(CommandBuffer, indirectBuffer.Handle, indirectBuffer.Offset, indirectBuffer.Size, false)
.Get(Cbs, indirectBuffer.Offset, indirectBuffer.Size).Value; .Get(Cbs, indirectBuffer.Offset, indirectBuffer.Size).Value;
UpdateIndexBufferPattern(); UpdateIndexBufferPattern();
RecreatePipelineIfNeeded(PipelineBindPoint.Graphics);
if (!RecreateGraphicsPipelineIfNeeded())
{
return;
}
BeginRenderPass(); BeginRenderPass();
DrawCount++; DrawCount++;
@@ -522,11 +532,6 @@ namespace Ryujinx.Graphics.Vulkan
public void DrawIndexedIndirectCount(BufferRange indirectBuffer, BufferRange parameterBuffer, int maxDrawCount, int stride) public void DrawIndexedIndirectCount(BufferRange indirectBuffer, BufferRange parameterBuffer, int maxDrawCount, int stride)
{ {
if (!_program.IsLinked)
{
return;
}
var countBuffer = Gd.BufferManager var countBuffer = Gd.BufferManager
.GetBuffer(CommandBuffer, parameterBuffer.Handle, parameterBuffer.Offset, parameterBuffer.Size, false) .GetBuffer(CommandBuffer, parameterBuffer.Handle, parameterBuffer.Offset, parameterBuffer.Size, false)
.Get(Cbs, parameterBuffer.Offset, parameterBuffer.Size).Value; .Get(Cbs, parameterBuffer.Offset, parameterBuffer.Size).Value;
@@ -536,7 +541,12 @@ namespace Ryujinx.Graphics.Vulkan
.Get(Cbs, indirectBuffer.Offset, indirectBuffer.Size).Value; .Get(Cbs, indirectBuffer.Offset, indirectBuffer.Size).Value;
UpdateIndexBufferPattern(); UpdateIndexBufferPattern();
RecreatePipelineIfNeeded(PipelineBindPoint.Graphics);
if (!RecreateGraphicsPipelineIfNeeded())
{
return;
}
BeginRenderPass(); BeginRenderPass();
DrawCount++; DrawCount++;
@@ -614,18 +624,17 @@ namespace Ryujinx.Graphics.Vulkan
public void DrawIndirect(BufferRange indirectBuffer) public void DrawIndirect(BufferRange indirectBuffer)
{ {
if (!_program.IsLinked)
{
return;
}
// TODO: Support quads and other unsupported topologies. // TODO: Support quads and other unsupported topologies.
var buffer = Gd.BufferManager var buffer = Gd.BufferManager
.GetBuffer(CommandBuffer, indirectBuffer.Handle, indirectBuffer.Offset, indirectBuffer.Size, false) .GetBuffer(CommandBuffer, indirectBuffer.Handle, indirectBuffer.Offset, indirectBuffer.Size, false)
.Get(Cbs, indirectBuffer.Offset, indirectBuffer.Size, false).Value; .Get(Cbs, indirectBuffer.Offset, indirectBuffer.Size, false).Value;
RecreatePipelineIfNeeded(PipelineBindPoint.Graphics); if (!RecreateGraphicsPipelineIfNeeded())
{
return;
}
BeginRenderPass(); BeginRenderPass();
ResumeTransformFeedbackInternal(); ResumeTransformFeedbackInternal();
DrawCount++; DrawCount++;
@@ -641,11 +650,6 @@ namespace Ryujinx.Graphics.Vulkan
throw new NotSupportedException(); throw new NotSupportedException();
} }
if (!_program.IsLinked)
{
return;
}
var buffer = Gd.BufferManager var buffer = Gd.BufferManager
.GetBuffer(CommandBuffer, indirectBuffer.Handle, indirectBuffer.Offset, indirectBuffer.Size, false) .GetBuffer(CommandBuffer, indirectBuffer.Handle, indirectBuffer.Offset, indirectBuffer.Size, false)
.Get(Cbs, indirectBuffer.Offset, indirectBuffer.Size, false).Value; .Get(Cbs, indirectBuffer.Offset, indirectBuffer.Size, false).Value;
@@ -656,7 +660,11 @@ namespace Ryujinx.Graphics.Vulkan
// TODO: Support quads and other unsupported topologies. // TODO: Support quads and other unsupported topologies.
RecreatePipelineIfNeeded(PipelineBindPoint.Graphics); if (!RecreateGraphicsPipelineIfNeeded())
{
return;
}
BeginRenderPass(); BeginRenderPass();
ResumeTransformFeedbackInternal(); ResumeTransformFeedbackInternal();
DrawCount++; DrawCount++;
@@ -1576,10 +1584,23 @@ namespace Ryujinx.Graphics.Vulkan
protected void SignalStateChange() 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)) if (AutoFlush.ShouldFlushDraw(DrawCount))
{ {
@@ -1620,17 +1641,23 @@ namespace Ryujinx.Graphics.Vulkan
_vertexBufferUpdater.Commit(Cbs); _vertexBufferUpdater.Commit(Cbs);
} }
if (_stateDirty || Pbp != pbp) if (_graphicsStateDirty || Pbp != PipelineBindPoint.Graphics)
{ {
CreatePipeline(pbp); if (!CreatePipeline(PipelineBindPoint.Graphics))
_stateDirty = false; {
Pbp = pbp; 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. // We can only create a pipeline if the have the shader stages set.
if (_newState.Stages != null) if (_newState.Stages != null)
@@ -1640,10 +1667,25 @@ namespace Ryujinx.Graphics.Vulkan
CreateRenderPass(); 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 var pipeline = pbp == PipelineBindPoint.Compute
? _newState.CreateComputePipeline(Gd, Device, _program, PipelineCache) ? _newState.CreateComputePipeline(Gd, Device, _program, PipelineCache)
: _newState.CreateGraphicsPipeline(Gd, Device, _program, PipelineCache, _renderPass.Get(Cbs).Value); : _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; ulong pipelineHandle = pipeline.GetUnsafe().Value.Handle;
if (_currentPipelineHandle != pipelineHandle) if (_currentPipelineHandle != pipelineHandle)
@@ -1655,6 +1697,8 @@ namespace Ryujinx.Graphics.Vulkan
Gd.Api.CmdBindPipeline(CommandBuffer, pbp, Pipeline.Get(Cbs).Value); Gd.Api.CmdBindPipeline(CommandBuffer, pbp, Pipeline.Get(Cbs).Value);
} }
} }
return true;
} }
private unsafe void BeginRenderPass() private unsafe void BeginRenderPass()

View File

@@ -246,7 +246,10 @@ namespace Ryujinx.Graphics.Vulkan
SignalCommandBufferChange(); SignalCommandBufferChange();
DynamicState.ReplayIfDirty(Gd.Api, CommandBuffer); if (Pipeline != null && Pbp == PipelineBindPoint.Graphics)
{
DynamicState.ReplayIfDirty(Gd.Api, CommandBuffer);
}
} }
public void FlushCommandsImpl() public void FlushCommandsImpl()

View File

@@ -312,7 +312,6 @@ namespace Ryujinx.Graphics.Vulkan
} }
public NativeArray<PipelineShaderStageCreateInfo> Stages; public NativeArray<PipelineShaderStageCreateInfo> Stages;
public NativeArray<PipelineShaderStageRequiredSubgroupSizeCreateInfoEXT> StageRequiredSubgroupSizes;
public PipelineLayout PipelineLayout; public PipelineLayout PipelineLayout;
public SpecData SpecializationData; public SpecData SpecializationData;
@@ -321,16 +320,6 @@ namespace Ryujinx.Graphics.Vulkan
public void Initialize() public void Initialize()
{ {
Stages = new NativeArray<PipelineShaderStageCreateInfo>(Constants.MaxShaderStages); 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; AdvancedBlendSrcPreMultiplied = true;
AdvancedBlendDstPreMultiplied = true; AdvancedBlendDstPreMultiplied = true;
@@ -397,7 +386,8 @@ namespace Ryujinx.Graphics.Vulkan
Device device, Device device,
ShaderCollection program, ShaderCollection program,
PipelineCache cache, PipelineCache cache,
RenderPass renderPass) RenderPass renderPass,
bool throwOnError = false)
{ {
if (program.TryGetGraphicsPipeline(ref Internal, out var pipeline)) if (program.TryGetGraphicsPipeline(ref Internal, out var pipeline))
{ {
@@ -630,7 +620,18 @@ namespace Ryujinx.Graphics.Vulkan
BasePipelineIndex = -1, 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. // Restore previous blend enable values if we changed it.
while (blendEnables != 0) while (blendEnables != 0)
@@ -708,7 +709,6 @@ namespace Ryujinx.Graphics.Vulkan
public readonly void Dispose() public readonly void Dispose()
{ {
Stages.Dispose(); Stages.Dispose();
StageRequiredSubgroupSizes.Dispose();
} }
} }
} }

View File

@@ -374,7 +374,7 @@ namespace Ryujinx.Graphics.Vulkan
pipeline.StagesCount = (uint)_shaders.Length; pipeline.StagesCount = (uint)_shaders.Length;
pipeline.PipelineLayout = PipelineLayout; 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(); pipeline.Dispose();
} }
@@ -511,7 +511,7 @@ namespace Ryujinx.Graphics.Vulkan
{ {
foreach (Auto<DisposablePipeline> pipeline in _graphicsPipelineCache.Values) foreach (Auto<DisposablePipeline> pipeline in _graphicsPipelineCache.Values)
{ {
pipeline.Dispose(); pipeline?.Dispose();
} }
} }

View File

@@ -6,10 +6,16 @@ namespace Ryujinx.Graphics.Vulkan
{ {
static class ResultExtensions 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) public static void ThrowOnError(this Result result)
{ {
// Only negative result codes are errors. // Only negative result codes are errors.
if ((int)result < (int)Result.Success) if (result.IsError())
{ {
throw new VulkanException(result); throw new VulkanException(result);
} }

View File

@@ -18,6 +18,7 @@ using System.Collections.Specialized;
using System.Globalization; using System.Globalization;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using LazyFile = Ryujinx.HLE.HOS.Services.Fs.FileSystemProxy.LazyFile;
using Path = System.IO.Path; using Path = System.IO.Path;
namespace Ryujinx.HLE.HOS namespace Ryujinx.HLE.HOS
@@ -512,7 +513,7 @@ namespace Ryujinx.HLE.HOS
using (IFileSystem fs = new LocalFileSystem(mod.Path.FullName)) using (IFileSystem fs = new LocalFileSystem(mod.Path.FullName))
{ {
AddFiles(fs, mod.Name, fileSet, builder); AddFiles(fs, mod.Name, mod.Path.FullName, fileSet, builder);
} }
count++; count++;
} }
@@ -528,7 +529,7 @@ namespace Ryujinx.HLE.HOS
Logger.Info?.Print(LogClass.ModLoader, $"Found 'romfs.bin' for Application {applicationId:X16}"); Logger.Info?.Print(LogClass.ModLoader, $"Found 'romfs.bin' for Application {applicationId:X16}");
using (IFileSystem fs = new RomFsFileSystem(mod.Path.OpenRead().AsStorage())) 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++; count++;
} }
@@ -561,18 +562,18 @@ namespace Ryujinx.HLE.HOS
return newStorage; 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() foreach (var entry in fs.EnumerateEntries()
.AsParallel()
.Where(f => f.Type == DirectoryEntryType.File) .Where(f => f.Type == DirectoryEntryType.File)
.OrderBy(f => f.FullPath, StringComparer.Ordinal)) .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)) if (fileSet.Add(entry.FullPath))
{ {
builder.AddFile(entry.FullPath, file.Release()); builder.AddFile(entry.FullPath, file);
} }
else else
{ {

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

View File

@@ -121,7 +121,14 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
{ {
IPEndPoint endPoint = isRemote ? socket.RemoteEndPoint : socket.LocalEndPoint; 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)] [CommandCmif(0)]