Go to file
GPUCode 26d6f9d1c6
Rasterizer cache refactor (#6375)
* rasterizer_cache: Remove custom texture code

* It's a hacky buggy mess, will be reimplemented later when the cache is in a better state

* rasterizer_cache: Refactor surface upload/download

* Switch to the texture_codec header which was written as part of the vulkan backend by steveice and me

* Move most of the upload logic to the rasterizer cache and out of the surface object

* Scaled uploads/downloads have been disabled for now since they require more runtime infrastructure

* rasterizer_cache: Refactor runtime interface

* Remove aspect enum which is the same as SurfaceType

* Replace Subresource with specific structures for each operation (blit/copy/clear). This mimics moderns APIs vulkan much better

* Pass the surface to the runtime instead of the texture

* Implement CopyTextures with glCopyImageSubData which is available on 4.3 and gles.
  This function also has an overload for cubes which will be removed later.

* rasterizer_cache: Move texture allocation to the runtime

* renderer_opengl: Remove TextureDownloaderES

* It's overly compilcated and unused at the moment. Will be replaced with a simple compute shader in a later commit

* rasterizer_cache: Split CachedSurface

* This commit splits CachedSurface into two classes, SurfaceBase which contains the backend agnostic functions and Surface which is the opengl specific part

* For now the cache uses the opengl surface directly and there are a few ugly casts with watchers, those will be taken care of when the template convertion and watcher removal are added respectively

* rasterizer_cache: Move reinterpreters to the runtime

* rasterizer_cache: Move some pixel format function to the cpp file

* rasterizer_cache: Common texture acceleration functions

* They don't contain any backend specific code so they shouldn't be duplicated

* rasterizer_cache: Remove BlitSurfaces

* It's better to prefer copy/blit in the caller anyway

* rasterizer_cache: Only allocate needed levels

* rasterizer_cache: Move texture runtime out of common dir

* Also shorten the util header filename

* surface_params: Cleanup code

* Add more comments, organize it a bit etc

* rasterizer_cache: Move texture filtering to the runtime

* rasterizer_cache: Move to VideoCore

* renderer_opengl: Reimplement scaled uploads/downloads

* Instead of looking up for temporary textures, each allocation now contains both a scaled and unscaled handle
  This allows the scale operations to be done inside the surface object itself and improves performance in general

* In particular the scaled download code has been expanded to use ARB_get_texture_sub_image when possible
  which is faster and more convenient than glReadPixels. The latter is still relevant for OpenGLES though.

* Finally allocations are now given a handy debug name that can be viewed from renderdoc.

* rasterizer_cache: Remove global state

* gl_rasterizer: Abstract common draw operations to Framebuffer

* This also allows to cache framebuffer objects instead of always swapping the textures, something that particularly benefits mali gpus

* rasterizer_cache: Implement multi-level surfaces

* With this commit the cache can now directly upload and use mipmaps
  without needing to sync them with watchers. By using native mimaps
  directly this also adds support for mipmap for cube

* Texture cubes have also been updated to drop the watcher requirement

* host_shaders: Add CMake integration for string shaders

* Improves build time shader generation making it much less prone to errors.
  Also moves the presentation shaders here to avoid embedding them to the cpp file.

* Texture filter shaders now make explicit use of uniform bindings for better vulkan compatibility

* renderer_opengl: Emulate lod bias in the shader

* This way opengles can emulate it correctly

* gl_rasterizer: Respect GL_MAX_TEXTURE_BUFFER_SIZE

* Older Bifrost Mali GPUs only support up to 64kb texture buffers. Citra would try to allocate a much larger buffer the first 64kb of which would work fine but after that the driver starts misbehaving and showing various graphical glitches

* rasterizer_cache: Cleanup CopySurface

* renderer_opengl: Keep frames synchronized when using a GPU debugger

* rasterizer_cache: Rename Surface to SurfaceRef

* Makes it clear that surface is a shared_ptr and not an object

* rasterizer_cache: Cleanup

* Move constructor to the top of the file

* Move FindMatch to the top as well and remove the Invalid flag which was redudant;
  all FindMatch calls used it expect from MatchFlags::Copy which ignores it anyway

* gl_texture_runtime: Make driver const

* gl_texture_runtime: Fix RGB8 format handling

* The texture_codec header, being written with vulkan in mind converts RGB8 to RGBA8. The backend wasn't adjusted to account for this though and treated the data as RGB8.

* Also remove D16 convertions, both opengl and vulkan are required to support this format so these are not needed

* gl_texture_runtime: Reduce state switches during FBO blits

* glBlitFramebuffer is only affected by the scissor rectangle so just disable scissor testing instead of resetting our entire state

* surface_params: Prevent texcopy that spans multiple levels

* It would have failed before as well, with multi-level surfaces it triggers the assert though

* renderer_opengl: Centralize texture filters

* A lot of code is shared between the filters thus is makes it sense to centralize them

* Also fix an issue with partial texture uploads

* Address review comments

* rasterizer_cache: Use leading return types

* rasterizer_cache: Cleanup null checks

* renderer_opengl: Add additional logging

* externals: Actually downgrade glad

* For some reason I missed adding the files to git

* surface_params: Do not check for levels in exact match

* Some games will try to use the base level of a multi level surface. Checking for levels forces another surface to be created and a copy to be made which is both unncessary and breaks custom textures

---------

Co-authored-by: bunnei <bunneidev@gmail.com>
2023-04-21 10:14:55 +03:00
.ci .ci\android\upload.sh: follow naming convention of other artifacts (#6440) 2023-04-16 19:53:17 +02:00
.github Updates to github actions (#6358) 2023-04-06 14:34:35 +02:00
CMakeModules Updates to github actions (#6358) 2023-04-06 14:34:35 +02:00
dist Add consolidated GodMode9 key dumping script. (#6396) 2023-04-09 21:16:31 +02:00
externals Rasterizer cache refactor (#6375) 2023-04-21 10:14:55 +03:00
hooks hook: remove clang-format check 2017-02-17 13:52:23 +02:00
src Rasterizer cache refactor (#6375) 2023-04-21 10:14:55 +03:00
.gitattributes Meta: Add gitattributes file 2018-09-22 14:59:15 -06:00
.gitignore Upgrade codebase to C++ 20 + fix warnings + update submodules (#6115) 2022-09-21 18:36:12 +02:00
.gitmodules externals: Bundle cryptopp as submodule. (#6272) 2023-02-02 16:26:21 +01:00
.lgtm.yml Add LGTM static analyzer config file (#5495) 2020-08-07 09:34:39 +08:00
CMakeLists.txt citra_qt: Prevent OS sleep on Linux when a game is running (#6249) 2023-03-23 19:37:10 +01: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
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 github: Improve Readme and add better issue templates (#6276) 2023-02-13 14:51:09 +01:00


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.