Commit Graph

1055 Commits

Author SHA1 Message Date
Steveice10 cca8c08a9a
build: Fix non-PCH build on Linux and add non-PCH verification to CI. (#7351) 2024-01-13 19:58:09 -08:00
PabloMK7 a177769c3b
Add random sleep to game main thread on first boot when using LLE modules (#7199)
* Add random delay to app main thread

* Suggestions

* Remove randomness, only delay with lle

* Apply suggestions

* Fix clang format

* Fix compilation (again)

* Remove unused include
2024-01-12 12:48:00 -08:00
Vitor K c8c2beaeff
misc: fix issues pointed out by msvc (#7316)
* do not move constant variables

* applet_manager: avoid possible use after move

* use constant references where pointed out by msvc

* extra_hid: initialize response

* ValidateSaveState: passing slot separately is not necessary

* common: mark HashCombine as nodiscard

* cityhash: remove use of using namespace std

* Prefix all size_t with std::

done automatically by executing regex replace `([^:0-9a-zA-Z_])size_t([^0-9a-zA-Z_])` -> `$1std::size_t$2`
based on 7d8f115

* shared_memory.cpp: fix log error format

* fix compiling with pch off
2024-01-07 12:37:42 -08:00
Steveice10 0165012ba4
core_timing: Allow configuring a fixed or random initial system tick value. (#7309)
* core_timing: Apply random base ticks value on startup.

* core: Maintain consistent base system ticks in TAS movies.

* frontend: Add setting to configure a fixed base system ticks value.
2024-01-07 09:38:02 -08:00
GPUCode 2bb7f89c30
video_core: Refactor GPU interface (#7272)
* video_core: Refactor GPU interface

* citra_qt: Better debug widget lifetime
2023-12-28 11:46:57 +01:00
Steveice10 178e602589
misc: Improve defaults for macOS and handling of missing audio backends. (#7273)
* misc: Improve backend defaults for macOS.

* audio_core: Improve handling of missing audio backends.
2023-12-22 11:38:06 -08:00
Tobias c7e9f8449e
Port yuzu-emu/yuzu#11946: "Enable (Feral Interactive) Gamemode on Linux" (#7245) 2023-12-20 06:08:07 -08:00
GPUCode 2b20082581
common: Miscellaneous cleanups (#7239)
* code: Remove some old msvc workarounds

* android: Upgrade to NDK 26

* Allows access to newer libc++

* common/swap: Make use of std::endian

Allows removing a bunch of defines in favor of a two liner.

* common: Remove misc.cpp

* GetLastErrorMsg has been in error.h for a while and also helps removing a depedency from a hot header like common_funcs

* common: use SetThreadDescription API for thread names

* common: Remove linear disk cache

* Has never been used?

* bit_set: Make constexpr

* ring_buffer: Use feature macro

* bit_set: Use <bit> and concepts

* gsp_gpu: Restore comment

* core: Ignore GCC warning

---------

Co-authored-by: Lioncash <mathew1800@gmail.com>
Co-authored-by: Liam <byteslice@airmail.cc>
2023-12-14 16:26:33 +02:00
Steveice10 24b5ffbfca
boss: Implement Spotpass service (part 1) (#7232)
* boss: Implement Spotpass service (part 1)

* boss: Fix save state (de)serialization.

* boss: Fix casing of SpotPass in log messages.

* boss: Minor logging improvements.

* common: Add boost serialization support for std::variant.

---------

Co-authored-by: Rokkubro <lachlanb03@gmail.com>
Co-authored-by: FearlessTobi <thm.frey@gmail.com>
2023-12-08 23:34:44 -08:00
Wunk 83b329f6e1
video_core/shader: Refactor JIT-Engines into `JitEngine` type (#7210) 2023-11-26 15:15:36 -08:00
GPUCode 85bd1be852
code: Add texture sampling option (#7118)
* This replaces the nearest neighbour filter that shouldn't have existed in the first place
2023-11-23 02:04:47 +02:00
PabloMK7 680e132318
Unlock RW access to opened files on windows (#7161)
* Unlock RW access to opened files on windows

* Add missing include
2023-11-17 03:14:00 -08:00
Wunk 831c9c4a38
renderer_vulkan: Import host memory for screenshots (#7132) 2023-11-12 13:02:55 -08:00
SachinVin ceeda05798
assert/logging: Stop the logging thread and flush the backends before crashing (#7146) 2023-11-11 11:55:42 -08:00
Wunk ee372572a6
common/aarch64: Push/Pop pairs of registers at a time (#7129) 2023-11-08 15:39:11 -08:00
GPUCode 1f6393e7d5
video_core: Refactor GLSL fragment emitter (#7093)
* video_core: Refactor GLSL fragment emitter

* shader: Add back custom normal maps
2023-11-06 12:26:28 -08:00
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
Steveice10 27bad3a699
audio_core: Replace AAC decoders with single FAAD2-based decoder. (#7098) 2023-11-04 14:56:13 -07:00
PabloMK7 4284893044
Implement RomFS cache and async reads. (#7089)
* Implement RomFS cache and async reads.

* Suggestions and fix compilation.

* Apply suggestions
2023-11-02 17:19:00 -07:00
Castor215 ec55807669
build: fix build failure when not using precompiled headers (#7087)
Co-authored-by: vitor-k <vitor-kiguchi@hotmail.com>
2023-10-23 17:21:35 -03:00
Castor215 4ac10c4a9d
externals: allow users to use system Zstandard (#7083) 2023-10-21 16:10:02 -07:00
Steveice10 4c59443ed2
common: Add more robust ZSTD handling. (#7071) 2023-10-15 14:08:29 -07:00
PabloMK7 897d1fa957
Implement more HTTP:C functionality (#7035)
* Implement missing http:c functionality.

* More implementation details and cleanup.

* Organize code

* Disable treat errors as warnings for httplib

* Fix defines

* Remove pragmas that do nothing and mark as SYSTEM

* Make httplib system

* Try to fix issue from httplib

* Apply suggestions

* Fix header ordering

* Fix compilation issue

* Create and use ctx.CommandID()

* Add and use Common::TruncateString

* Apply more suggestions

* Apply suggestions

* Fix compilation

* Apply suggestions

* Fix format

* Revert SplitURL to previous version

* Apply suggestions
2023-10-11 10:09:16 -07:00
Castor215 f5b8888686
externals: allow user to use system fmt (#7052) 2023-10-07 16:00:02 -07:00
Steveice10 50f22d1f59
video_core: Abstract shader generators. (#6990)
* video_core: Abstract shader generators.

* shader: Extract common generator structures and move generators to specific namespaces.

* shader: Minor fixes and clean-up.
2023-09-30 02:06:06 -07:00
Vitor K 6cfb8e02a8
clang format (#7017) 2023-09-27 13:42:19 -03:00
GPUCode 30fcdc5474
renderer_vulkan: Misc fixes (#6974)
* vk_platform: Check if library was loaded

* pica_to_vk: Dont crash on unknow blend equation
2023-09-15 00:21:12 +03:00
GPUCode dfa2fd0e0d
Add vulkan backend (#6512)
* code: Prepare frontend for vulkan support

* citra_qt: Add vulkan options to the GUI

* vk_instance: Collect tooling info

* renderer_vulkan: Add vulkan backend

* qt: Fix fullscreen and resize issues on macOS. (#47)

* qt: Fix bugged macOS full screen transition.

* renderer/vulkan: Fix swapchain recreation destroying in-use semaphore.

* renderer/vulkan: Make gl_Position invariant. (#48)

This fixes an issue with black artifacts in Pokemon games on Apple GPUs.
If the vertex calculations differ slightly between render passes, it can
cause parts of model faces to fail depth test.

* vk_renderpass_cache: Bump pixel format count

* android: Custom driver code

* vk_instance: Set moltenvk configuration

* rasterizer_cache: Proper surface unregister

* citra_qt: Fix invalid characters

* vk_rasterizer: Correct special unbind

* android: Allow async presentation toggle

* vk_graphics_pipeline: Fix async shader compilation

* We were actually waiting for the pipelines regardless of the setting, oops

* vk_rasterizer: More robust attribute loading

* android: Move PollEvents to OpenGL window

* Vulkan does not need this and it causes problems

* vk_instance: Enable robust buffer access

* Improves stability on mali devices

* vk_renderpass_cache: Bring back renderpass flushing

* externals: Update vulkan-headers

* gl_rasterizer: Separable shaders for everyone

* vk_blit_helper: Corect depth to color convertion

* renderer_vulkan: Implement reinterpretation with copy

* Allows reinterpreteration with simply copy on AMD

* vk_graphics_pipeline: Only fast compile if no shaders are pending

* With this shaders weren't being compiled in parallel

* vk_swapchain: Ensure vsync doesn't lock framerate

* vk_present_window: Match guest swapchain size to vulkan image count

* Less latency and fixes crashes that were caused by images being deleted before free

* vk_instance: Blacklist VK_EXT_pipeline_creation_cache_control with nvidia gpus

* Resolves crashes when async shader compilation is enabled

* vk_rasterizer: Bump async threshold to 6

* Many games have fullscreen quads with 6 vertices. Fixes pokemon textures missing with async shaders

* android: More robust surface recreation

* renderer_vulkan: Fix dynamic state being lost

* vk_pipeline_cache: Skip cache save when no pipeline cache exists

* This is the cache when loading a save state

* sdl: Fix surface initialization on macOS. (#49)

* sdl: Fix surface initialization on macOS.

* sdl: Fix render window events not being handled under Vulkan.

* renderer/vulkan: Fix binding/unbinding of shadow rendering buffer.

* vk_stream_buffer: Respect non coherent access alignment

* Required by nvidia GPUs on MacOS

* renderer/vulkan: Support VK_EXT_fragment_shader_interlock for shadow rendering. (#51)

* renderer_vulkan: Port some recent shader fixes

* vk_pipeline_cache: Improve shadow detection

* vk_swapchain: Add missing check

* renderer_vulkan: Fix hybrid screen

* Revert "gl_rasterizer: Separable shaders for everyone"

Causes crashes on mali GPUs, will need separate PR

This reverts commit d22d556d30.

* renderer_vulkan: Fix flipped screenshot

---------

Co-authored-by: Steveice10 <1269164+Steveice10@users.noreply.github.com>
2023-09-13 01:28:50 +03:00
Steveice10 f2e0748a22
build: Enable link time optimization in release builds. (#6887) 2023-08-26 11:15:13 -07:00
Steveice10 66404a669f
build: Fixes for a few minor issues (#6886) 2023-08-14 09:47:17 -07:00
GPUCode a955f02771
rasterizer_cache: Remove runtime allocation caching (#6705)
* rasterizer_cache: Sentence surfaces

* gl_texture_runtime: Remove runtime side allocation cache

* rasterizer_cache: Adjust surface scale during reinterpreration

* Fixes pixelated outlines. Also allows to remove the d24s8 specific hack and is more generic in general

* rasterizer_cache: Remove Expand flag

* Begone!

* rasterizer_cache: Cache framebuffers with surface id

* rasterizer_cache: Sentence texture cubes

* renderer_opengl: Move texture mailbox to separate file

* Makes renderer_opengl cleaner overall and allows to report removal threshold from runtime instead of hardcoding. Vulkan requires this

* rasterizer_cache: Dont flush cache on layout change

* rasterizer_cache: Overhaul framebuffer management

* video_core: Remove duplicate

* rasterizer_cache: Sentence custom surfaces

* Vulkan cannot destroy images immediately so this ensures we use our garbage collector for that purpose
2023-08-01 03:35:41 +03:00
Steveice10 3fedc68230
common: Only use libbacktrace if present. (#6827) 2023-07-31 14:24:27 -07:00
Steveice10 bb364d9bc0
service/apt: Add and implement more service commands. (#6721)
* service/apt: Add and implement more service commands.

* service/apt: Implement power button.

* Address review comments and fix GetApplicationRunningMode bug.
2023-07-29 00:26:16 -07:00
Steveice10 662bb9ba77
hle: Stub some service calls used by the home menu. (#6675) 2023-07-07 22:05:38 -07:00
GPUCode cf9bb90ae3
code: Use std::span where appropriate (#6658)
* code: Use std::span when possible

* code: Prefix memcpy and memcmp with std::
2023-07-07 01:52:40 +03:00
GPUCode 4ccd9f24fb
Merge pull request #6638 from GPUCode/new-log
common: Backport yuzu log improvements
2023-07-06 23:44:54 +03:00
Steveice10 13a8969824
build: Clear out remaining compile warnings. (#6662) 2023-07-04 21:00:24 -07:00
GPUCode d7b4260389 common: Address feedback 2023-07-03 17:13:00 +03:00
GPUCode 2126c240cd
core: backport some ResultCode updates (#6645)
Co-authored-by: Lioncash <mathew1800@gmail.com>
Co-authored-by: Morph <39850852+Morph1984@users.noreply.github.com>
2023-07-03 02:23:53 +02:00
GPUCode 9527bfffed common: Remove dependency from core 2023-07-03 02:18:37 +03:00
GPUCode ba98bf058a logging: Address some issues 2023-07-03 02:18:35 +03:00
Morph 0ddb095273 logging: Make use of bounded queue 2023-06-30 12:15:52 +03:00
ameerj 52b9007fcf common: Reduce unused includes 2023-06-30 12:15:52 +03:00
Merry e112421db8 backend: Ensure backend_thread is destructed before message_queue
Ensures that stop_token signals that stop has been requested before destruction of conditional_variable
2023-06-30 12:15:52 +03:00
Wunkolo ae6fda8638 logging: Convert backend_thread into an std::jthread
Was getting an unhandled `invalid_argument` [exception](https://en.cppreference.com/w/cpp/thread/thread/join) during
shutdown on my linux machine. This removes the need for a `StopBackendThread` function entirely since `jthread`
[automatically handles both checking if the thread is joinable and stopping the token before attempting to join](https://en.cppreference.com/w/cpp/thread/jthread/~jthread) in the case that `StartBackendThread` was never called.
2023-06-30 12:15:52 +03:00
Levi Behunin 197c1adcba Refactor Logging Impl
Loop on stop_token and remove final_entry in Entry.
Move Backend thread out of Impl Constructor to its own function.
Add Start function for backend thread.
Use stop token in PopWait and check if entry filename is nullptr before logging.
2023-06-30 12:15:52 +03:00
Merry fe027a96fb common: Replace lock_guard with scoped_lock 2023-06-30 12:15:52 +03:00
yzct12345 637ade3b25 threadsafe_queue: Fix deadlock
This fixes a lost wakeup in SPSCQueue. If the reader is in just the right position, the writer's notification will be lost and this will be a problem if the writer then does something to wait on the reader.

This was discovered to affect my upcoming stacktrace PR. I don't think any performance decrease will be noticeable because an uncontended mutex is smart enough to skip the syscall. This PR might also resolve some rare deadlocks but I don't know of any examples.
2023-06-30 12:15:52 +03:00
ameerj a1443356f1 threadsafe_queue: Add std::stop_token overload to PopWait
Useful for jthreads which make use of the threadsafe queues.
2023-06-30 12:15:52 +03:00
ameerj aa39430e2c common/logging: Reduce scope of fmt include 2023-06-30 12:15:52 +03:00