A Nintendo 3DS Emulator
Go to file
Wunk e13735b624
video_core: Implement an arm64 shader-jit backend (#7002)
* externals: Add oaksim submodule

Used for emitting ARM64 assembly

* common: Implement aarch64 ABI

Utilize oaknut to implement a stack frame.

* tests: Allow shader-jit tests for x64 and a64

Run the shader-jit tests for both x86_64 and arm64 targets

* video_core: Initialize arm64 shader-jit backend

Passes all current unit tests!

* shader_jit_a64: protect/unprotect memory when jit-ing

Required on MacOS. Memory needs to be fully unprotected and then
re-protected when writing or there will be memory access errors on
MacOS.

* shader_jit_a64: Fix ARM64-Imm overflow

These conditionals were throwing exceptions since the immediate values
were overflowing the available space in the `EOR` instructions. Instead
they are generated from `MOV` and then `EOR`-ed after.

* shader_jit_a64: Fix Geometry shader conditional

* shader_jit_a64: Replace `ADRL` with `MOVP2R`

Fixes some immediate-generation exceptions.

* common/aarch64: Fix CallFarFunction

* shader_jit_a64: Optimize `SantitizedMul`

Co-authored-by: merryhime <merryhime@users.noreply.github.com>

* shader_jit_a64: Fix address register offset behavior

Based on https://github.com/citra-emu/citra/pull/6942
Passes unit tests.

* shader_jit_a64: Fix `RET` address offset

A64 stack is 16-byte aligned rather than 8. So a direct port of the x64
code won't work. Fixes weird branches into invalid memory for any
shaders with subroutines.

* shader_jit_a64: Increase max program size

Tuned for A64 program size.

* shader_jit_a64: Use `UBFX` for extracting loop-state

Co-authored-by: JosJuice <JosJuice@users.noreply.github.com>

* shader_jit_a64: Optimize `SUB+CMP` to `SUBS`

Co-authored-by: JosJuice <JosJuice@users.noreply.github.com>

* shader_jit_a64: Optimize `CMP+B` to `CBNZ`

Co-authored-by: JosJuice <JosJuice@users.noreply.github.com>

* shader_jit_a64: Use `FMOV` for `ONE` vector

Co-authored-by: JosJuice <JosJuice@users.noreply.github.com>

* shader_jit_a64: Remove x86-specific documentation

* shader_jit_a64: Use `UBFX` to extract exponent

Co-authored-by: JosJuice <JosJuice@users.noreply.github.com>

* shader_jit_a64: Remove redundant MIN/MAX `SRC2`-NaN check

Special handling only needs to check SRC1 for NaN, not SRC2.
It would work as follows in the four possible cases:

No NaN: No special handling needed.
Only SRC1 is NaN: The special handling is triggered because SRC1 is NaN, and SRC2 is picked.
Only SRC2 is NaN: FMAX automatically picks SRC2 because it always picks the NaN if there is one.
Both SRC1 and SRC2 are NaN: The special handling is triggered because SRC1 is NaN, and SRC2 is picked.

Co-authored-by: JosJuice <JosJuice@users.noreply.github.com>

* shader_jit/tests:: Add catch-stringifier for vec2f/vec3f

* shader_jit/tests: Add Dest Mask unit test

* shader_jit_a64: Fix Dest-Mask `BSL` operand order

Passes the dest-mask unit tests now.

* shader_jit_a64: Use `MOVI` for DestEnable mask

Accelerate certain cases of masking with MOVI as well

Co-authored-by: JosJuice <JosJuice@users.noreply.github.com>

* shader_jit/tests: Add source-swizzle unit test

This is not expansive. Generating all `4^4` cases seems to make Catch2
crash. So I've added some component-masking(non-reordering) tests based
on the Dest-Mask unit-test and some additional ones to test
broadcasts/splats and component re-ordering.

* shader_jit_a64: Fix swizzle index generation

This was still generating `SHUFPS` indices and not the ones that we wanted for the `TBL` instruction. Passes all unit tests now.

* shader_jit/tests: Add `ShaderSetup` constructor to `ShaderTest`

Rather than using the direct output of `CompileShaderSetup` allow a
`ShaderSetup` object to be passed in directly.  This enabled the ability
emit assembly that is not directly supported by nihstro.

* shader_jit/tests: Add `CALL` unit-test

Tests nested `CALL` instructions to eventually reach an `EX2`
instruction.

EX2 is picked in particular since it is implemented as an even deeper
dispatch and ensures subroutines are properly implemented between `CALL`
instructions and implementation-calls.

* shader_jit_a64: Fix nested `BL` subroutines

`lr` was getting writen over by nested calls to `BL`, causing undefined
behavior with mixtures of `CALL`, `EX2`, and `LG2` instructions.

Each usage of `BL` is now protected with a stach push/pop to preserve
and restore teh `lr` register to allow nested subroutines to work
properly.

* shader_jit/tests: Allocate generated tests on heap

Each of these generated shader-test objects were causing the stack to
overflow.  Allocate each of the generated tests on the heap and use
unique_ptr so they only exist within the life-time of the `REQUIRE`
statement.

* shader_jit_a64: Preserve `lr` register from external function calls

`EMIT` makes an external function call, and should be preserving `lr`

* shader_jit/tests: Add `MAD` unit-test

The Inline Asm version requires an upstream fix:
https://github.com/neobrain/nihstro/issues/68

Instead, the program code is manually configured and added.

* shader_jit/tests: Fix uninitialized instructions

These `union`-type instruction-types were uninitialized, causing tests
to indeterminantly fail at times.

* shader_jit_a64: Remove unneeded `MOV`

Residue from the direct-port of x64 code.

* shader_jit_a64: Use `std::array` for `instr_table`

Add some type-safety and const-correctness around this type as well.

* shader_jit_a64: Avoid c-style offset casting

Add some more const-correctness to this function as well.

* video_core: Add arch preprocessor comments

* common/aarch64: Use X16 as the veneer register

https://developer.arm.com/documentation/102374/0101/Procedure-Call-Standard

* shader_jit/tests: Add uniform reading unit-test

Particularly to ensure that addresses are being properly truncated

* common/aarch64: Use `X0` as `ABI_RETURN`

`X8` is used as the indirect return result value in the case that the
result is bigger than 128-bits. Principally `X0` is the general-case
return register though.

* common/aarch64: Add veneer register note

`LR` is generally overwritten by `BLR` anyways, and would also be a safe
veneer to utilize for far-calls.

* shader_jit_a64: Remove unneeded scratch register from `SanitizedMul`

* shader_jit_a64: Fix CALLU condition

Should be `EQ` not `NE`. Fixes the regression on Kid Icarus.
No known regressions anymore!

---------

Co-authored-by: merryhime <merryhime@users.noreply.github.com>
Co-authored-by: JosJuice <JosJuice@users.noreply.github.com>
2023-11-05 21:40:31 +01:00
.ci ci: Work around macOS GitHub runner pip install failures. (#7110) 2023-11-03 03:35:32 -07:00
.github qt: Update to 6.6.0 (#7099) 2023-11-01 17:58:02 -07:00
CMakeModules video_core: Abstract shader generators. (#6990) 2023-09-30 02:06:06 -07:00
dist qt: Update to 6.6.0 (#7099) 2023-11-01 17:58:02 -07:00
externals video_core: Implement an arm64 shader-jit backend (#7002) 2023-11-05 21:40:31 +01:00
hooks hook: remove clang-format check 2017-02-17 13:52:23 +02:00
src video_core: Implement an arm64 shader-jit backend (#7002) 2023-11-05 21:40:31 +01:00
.gitattributes Meta: Add gitattributes file 2018-09-22 14:59:15 -06:00
.gitignore Add Kdevelop files to .gitignore (#6951) 2023-09-07 11:52:40 -07:00
.gitmodules video_core: Implement an arm64 shader-jit backend (#7002) 2023-11-05 21:40:31 +01:00
CMakeLists.txt audio_core: Replace AAC decoders with single FAAD2-based decoder. (#7098) 2023-11-04 14:56:13 -07:00
CONTRIBUTING.md CONTRIBUTING.md: migrate to the wiki 2018-11-08 00:15:55 -05:00
Doxyfile Remove every trailing whitespace from the project (but externals). 2015-05-29 21:59:29 +01:00
README.md github: Improve Readme and add better issue templates (#6276) 2023-02-13 14:51:09 +01:00
keys.tar.enc Flatpak support (#4383) 2018-11-07 21:33:36 -05:00
license.txt Replace non-commercial icons with free icons from icons8 (#5093) 2020-03-26 13:40:03 -05:00

README.md


Citra
Citra

Citra is the world's most popular, open-source, Nintendo 3DS emulator.
It is written in C++ with portability in mind and builds are actively maintained for Windows, Linux, Android and macOS.

GitHub Actions Build Status Discord

Compatibility | Releases | Development | Building | Support | License

Compatibility

The emulator is capable of running most commercial games at full speed, provided you meet the necessary hardware requirements.

For a full list of games Citra supports, please visit our Compatibility page

Check out our website for the latest news on exciting features, progress reports, and more! Please read the FAQ before getting started with the project.

Need help? Check out our asking for help guide.

Releases

Citra has two main release channels: Nightly and Canary.

The Nightly build is based on the master branch, and contains already reviewed and tested features.

The Canary build is based on the master branch, but with additional features still under review. PRs tagged canary-merge are merged only into the Canary builds.

Both builds can be installed with the installer provided on the website, but those looking for specific versions or standalone releases can find them in the release tabs of the Nightly and Canary repositories.

Android builds can be downloaded from the Google Play Store.

A Flatpak for Citra is available on Flathub. Details on the build process can be found in our Flathub repository.

Development

Most of the development happens on GitHub. It's also where our central repository is hosted. For development discussion, please join us on our Discord server or at #citra-dev on libera.

If you want to contribute please take a look at the Contributor's Guide and Developer Information. You can also contact any of the developers on Discord in order to know about the current state of the emulator.

If you want to contribute to the user interface translation, please check out the Citra project on transifex. We centralize the translation work there, and periodically upstream translations.

Building

Support

If you enjoy the project and want to support us financially, check out our Patreon!

We also happily accept donated games and hardware. Please see our donations page for more information on how you can contribute to Citra. Any donations received will go towards things like:

  • 3DS consoles for developers to explore the hardware
  • 3DS games for testing
  • Any equipment required for homebrew
  • Infrastructure setup

We also more than gladly accept used 3DS consoles! If you would like to give yours away, don't hesitate to join our Discord server and talk to bunnei.

License

Citra is licensed under the GPLv2 (or any later version). Refer to the LICENSE.txt file.