Commit Graph

27308 Commits

Author SHA1 Message Date
Mike Lothian
3785caf55f CMakeLists: Fix build with Qt6.10 2025-10-23 18:03:21 +01:00
Mike Lothian
ae235df7ee Use NDK 29.0.14033849 2025-10-03 12:24:53 +01:00
Mike Lothian
c4f27bcefb android: Fix build with newer Ndk 2025-09-02 14:59:35 +01:00
Mike Lothian
1f01785721 vcpkg: Bump vcpkg to 2025.08.27 and fmt to 11.2.0 2025-09-02 14:47:59 +01:00
Mike Lothian
25a7251115 Use NDK 29.0.13846066 2025-09-02 14:22:50 +01:00
Mike Lothian
72d5224bc8 service: mii: Fix building with Clang 21 2025-09-02 14:21:55 +01:00
Mike Lothian
b83c049b4c kernel: Fix compilation with Clang 21 2025-09-02 14:21:55 +01:00
Mike Lothian
a9cde6f765 video_core: Rework VAAPI code
Use public ffmpeg headers only

Fall back gracefully to software decoding when codec is unsupported on
VAAPI e.g. VP8
2025-06-17 15:30:11 +01:00
MaranBr
37e9208842 Update FFmpeg to 7.1.1, libvpx to 1.13.1 and libx264 to c24e06c on Android (#187)
This updates FFmpeg to 7.1.1, libvpx to 1.13.1 and libx264 to c24e06c on Android.

Co-authored-by: MaranBr <maranbr@outlook.com>
Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/187
Reviewed-by: crueter <crueter@noreply.localhost>
Co-authored-by: MaranBr <maranbr@noreply.localhost>
Co-committed-by: MaranBr <maranbr@noreply.localhost>
2025-06-15 02:41:49 +01:00
MaranBr
cea7a49c39 Fix video decoding on newer versions of FFmpeg (#155)
Fixes video decoding issues and enables compatibility with newer versions of FFmpeg.

Co-authored-by: MaranBr <maranbr@outlook.com>
Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/155
2025-06-15 02:39:20 +01:00
Mike Lothian
39df9d0042 Fix compile warning 2025-05-12 12:46:19 +01:00
Wasted
e617ed79f3 Add Samsung Game Hub support, GAME category, optional NFC, and minor cleanup 2025-05-12 12:46:19 +01:00
Zephyron
24277b28e4 api_version: Update constants for HOS 20.0.1
Updates version constants to match Nintendo Switch firmware 20.0.1:
- HOS version numbers (20.0.1)
- Version hash
- Display version string
- Display title string

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-05-12 12:46:19 +01:00
Zephyron
321829c7d0 fix(renderer_vulkan): resolve asynchronous presentation crashes and compilation errors
Fix multiple issues in the Vulkan asynchronous presentation implementation:

- Convert regular mutexes to timed_mutex for timeout support
- Use condition_variable_any for compatibility with timed_mutex
- Fix thread synchronization with proper locking and error handling
- Add VkResultToString helper to replace missing ToString function
- Implement better error recovery with recreation attempt limits
- Add comprehensive logging for better troubleshooting

These changes make the asynchronous presentation feature more robust
and less prone to deadlocks, while keeping it disabled by default since
it may still cause instability in some games.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-05-12 12:46:19 +01:00
Zephyron
0963c72281 api_version: Update constants for HOS 20.0.0
Updates version constants to match Nintendo Switch firmware 20.0.0:
- HOS version numbers (20.0.0)
- Version hash
- Display version string
- Display title string

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-05-12 12:46:19 +01:00
Zephyron
f827298648 externals: Update Vulkan-related submodules to latest versions
- vcpkg: 96d5fb3 → 5a874b0
- Vulkan-Headers: 80207f9 → e2e53a7
- Vulkan-Utility-Libraries: 524f891 → 4e246c5
- VulkanMemoryAllocator: 2f382df → 539c0a8

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-05-12 12:46:19 +01:00
Zephyron
88d153ae69 chore: Make firmware optional rather than required
This commit makes firmware non-mandatory for the emulator to function. Changes include:
- Converting firmware errors to warnings in loader
- Removing firmware requirement checks in Android
- Removing firmware and title.keys setup screens
- Adding --allow-unsupported flag for Android vcpkg
- Updating vcpkg baseline
- Enforce software keyboard in Android

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-05-12 12:46:19 +01:00
Zephyron
6d023e89b8 build: bump VulkanHeaders minimum version
- Update required VulkanHeaders from 1.4.307 to 1.4.313
- Ensures compatibility with newer Vulkan development packages

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-05-12 12:46:19 +01:00
Zephyron
01267e5f63 fix: remove invalid WSAEBUSY Windows socket error code
- Fixes Windows compilation error by removing the WSAEBUSY case in TranslateNativeError.
- This error code does not exist in the Windows Sockets API as documented in the Microsoft documentation, but was incorrectly included in the Windows-specific error handling code.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-05-12 12:46:19 +01:00
Zephyron
75a596a5f9 Update submodules: SDL, vcpkg, and Vulkan-Headers
- Update SDL to fix pipewire-related compile error
  - Removes need to hardcode -DSDL_PIPEWIRE=OFF in toolchain
- Update vcpkg to latest version
- Update Vulkan-Headers to latest version

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-05-12 12:46:19 +01:00
Zephyron
932e013226 socket: Implement missing errno values and improve network error handling
Add support for missing errno values needed by TOTK:
- Add BUSY (16) for "Device or resource busy" errors
- Add NOTSOCK (88) for "Socket operation on non-socket" errors

Improvements:
- Update TranslateNativeError on both Windows and Unix to handle new error codes
- Change socket error logging for NOTSOCK from WARNING to DEBUG level
- Fix formatting in Unix errno translation code
- Update shader storage buffer tracking range to accommodate TOTK buffers
- Add hex format to storage buffer logging for easier comparison with bias range
- Change storage buffer tracking log level from WARNING to DEBUG

These changes help prevent error messages in games
that use network features not fully implemented in the emulator yet.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-05-12 12:46:19 +01:00
Zephyron
0763567da8 android: Update Vulkan Validation Layer to 1.4.309.0
Updates the Android Vulkan Validation Layer (VVL) from version 1.4.304.1
to 1.4.309.0. This ensures compatibility with the latest Vulkan specification
and provides improved validation capabilities for the Android build.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-05-12 12:46:19 +01:00
Zephyron
ff8ce59f90 android: Update build configuration and package identifiers
Updates the Android build configuration with several important changes:

- Change application ID from com.antutu.ABenchMark to org.citron.citron_emu
- Upgrade CMake version from 3.31.6 to 4.0.1
- Update Android Gradle plugin from 8.9.0 to 8.9.2
- Add CMAKE_POLICY_VERSION_MINIMUM=3.5 to CMake arguments
- Keep Kotlin version at 1.9.20

These changes align the Android package identifier with the Citron project
and update build tool versions to ensure compatibility with modern Android
development requirements.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-05-12 12:46:19 +01:00
Zephyron
0bf9615693 video_core: Add fallback handling for failed storage buffer lookups
Implements a more robust error handling approach when storage buffer lookups
fail in the buffer cache. Instead of returning a null binding, the code now:

- Provides a fallback buffer with safe default values
- Implements warning rate limiting to prevent log spam
- Tracks warning counts per cbuf_index
- Logs detailed debug information periodically

This change helps prevent potential crashes when storage buffer lookups fail
while still maintaining visibility into the issue through strategic logging.

The fallback mechanism uses a safe static address and a reasonable buffer
size (16KB) to handle cases where the normal GPU to CPU address translation
fails.

Also updates copyright headers to include citron Emulator Project.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-05-12 12:46:19 +01:00
Zephyron
00f7ddafa3 video_core: Improve texture cache memory management to prevent leaks
Implement several improvements to the texture cache memory management system
to address memory leaks that occur in memory-intensive games like TOTK
(Title ID 0100F2C0115B6000). These changes prevent the gradual memory
increase that eventually leads to crashes or undefined behavior.

Key improvements:
- Enhance garbage collection with more aggressive cleanup thresholds
- Add emergency resource cleanup for persistent high memory usage
- Improve DeleteImage to ensure proper resource deallocation
- Make DelayedDestructionRing thread-safe with proper mutex protection
- Track consecutive high-memory frames to detect potential leaks
- Add emergency cleanup mechanism for extreme memory pressure situations
- Use proper type casting in std::max to fix compilation errors

This should significantly improve stability during extended gameplay
sessions with memory-intensive titles.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-05-12 12:46:19 +01:00
Zephyron
654f4c4fe3 feat(services): Implement nn::socket, nn::nifm, and nn::nim networking services
Add Nintendo Switch network service implementations to support modders
working with network functionality in their game modifications:

- Add nn::socket utilities including InetAton and Connect functions
- Implement sockaddr/in_addr structures matching official Nintendo APIs
- Add nn::nifm networking interface services with IsNetworkAvailable and SubmitNetworkRequest
- Implement nn::nim network installation management services
- Fix BSD socket implementation to properly handle proxy packets
- Add Service_BSD log category for better debugging

These changes provide crucial networking API support for modders like
MaxLastBreath and projects like NX Optimizer (https://www.nxoptimizer.com/)
that need to hook into Nintendo's network services for code injection mods.
This implementation follows the official documentation at SwitchBrew and
enables proper network connectivity in modded games.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-05-12 12:46:19 +01:00
Zephyron
e309365f39 externals: Update Vulkan dependencies to latest versions
Update Vulkan-Headers, Vulkan-Utility-Libraries, VulkanMemoryAllocator, and vcpkg submodules to their latest versions to ensure compatibility with newer Vulkan features and improve rendering performance.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-05-12 12:46:19 +01:00
Zephyron
c8ee0041f2 fix: correct implementation of present interval 0 for unlocked FPS
Fixes issues in commit bbd32531697fbfb8ed5b6859d3951bf8380e5999 that could cause
crashes and deadlocks. The feature now works as intended, allowing games using
present interval 0 to run with truly unlocked FPS.

This ensures proper functionality of dynamic framerate mods like UltraCam
by MaxLastBreath (https://www.nxoptimizer.com/) without stability problems.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-05-12 12:46:19 +01:00
Zephyron
ea8bb22148 feat: add CPU clock rate slider to settings
Implement a slider in the CPU settings tab to adjust the BASE_CLOCK_RATE
up to 1,785 MHz (Switch's official maximum clock rate). Default remains
at 1,020 MHz.

This change:
- Adds UI slider and spinbox to configure_cpu.ui with range 500-1785 MHz
- Makes BASE_CLOCK_RATE dynamic by reading from settings
- Modifies WallClock to handle dynamic clock rate changes
- Updates APM controller to properly set the clock rate
- Changes clock rate settings category from Core to CPU

The user can now easily adjust the CPU clock rate to improve performance
or manage thermals and power consumption.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-05-12 12:46:19 +01:00
Zephyron
6a845fd03b feat: add option to respect present interval 0 as unlocked FPS
When enabled, this feature allows games using present interval 0 to run with
truly unlocked FPS, matching actual hardware behavior more accurately.

Previously, Citron would cap present interval 0 at 120FPS to conserve battery,
but this prevented proper functionality of dynamic framerate mods like UltraCam
by MaxLastBreath (https://www.nxoptimizer.com/).

The setting is disabled by default to maintain the current behavior for most users.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-05-12 12:46:19 +01:00
Zephyron
ac99769213 service/sockets: Implement network services for new firmware versions
This commit implements various network services required for newer firmware
versions. Key changes include:

- Add bsd:nu service for firmware 15.0.0+ with proper event handling
- Add bsdcfg implementation with complete interface declarations
- Add dns:priv and ethc (c/i) services
- Register all new services in the service manager
- Extend BSD implementation with additional socket operations
- Remove room_network instance variable in favor of system.GetRoomNetwork()
- Fix kernel event creation by using ServiceContext in all appropriate places
- Update build system to include new source files

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-05-12 12:46:19 +01:00
Zephyron
8f48f0865b refactor(vulkan): remove depth buffer workarounds and excessive logging
- Remove special handling for reversed depth scenarios that were added for Civilization 7
- Remove excessive logging in Vulkan renderer
- Update Discord client ID
2025-05-12 12:46:19 +01:00
Zephyron
459b77bb6f nvn(fix): Optimize shader performance by enhancing NVN bias settings
Improve GPU storage buffer detection and memory access patterns:
- Expand NVN bias address range (0x100-0x800 vs 0x110-0x610)
- Increase alignment from 16 to 32 bytes for optimal memory access
- Raise default alignment from 8 to 16 bytes for non-biased addresses
- Refactor bias handling code for better readability
- Add detailed performance-related comments

These changes help identify more storage buffers within shaders and
ensure memory accesses are better aligned, which improves overall
shader compilation and execution performance.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-05-12 12:46:19 +01:00
Zephyron
2d4f1b4d2f renderer/friend: Improve reversed depth handling and Friend service
This commit makes two significant improvements:

1. Vulkan renderer:
   - Detect and properly handle reversed depth buffers (clear_depth < 0.5)
   - Force depth write enable when needed with reversed depth
   - Use GREATER_OR_EQUAL comparison for reversed depth scenarios
   - Fix transparency issues in games like Civilization 7 by adjusting blend factors
   - Add detailed logging for depth buffer operations

2. Friend service:
   - Implement previously stubbed functions including EnsureFriendListAvailable
     and EnsureBlockedUserListAvailable
   - Add proper event signaling to prevent games from hanging
   - Implement Cancel function for improved compatibility
   - Update copyright notice for the Citron project

These changes improve compatibility with modern games using reversed depth
buffers and prevent hangs in titles that rely on Friend service functionality.

Co-authored-by: m33ts4k0z <m33ts4k0z@citron-emu.org>
Co-committed-by: m33ts4k0z <m33ts4k0z@citron-emu.org>
Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-05-12 12:46:19 +01:00
Zephyron
79c7213e9f memory: Implement enhanced memory management system
Add a flexible memory region management system that provides:
- Memory region type classification (System, Graphics, IO, Binary)
- Memory region permission management (executable, writable)
- Binary base address randomization for ASLR
- Dynamic memory mapping capabilities

Credit: boss.smc@citron-emu.org
Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-05-12 12:46:19 +01:00
Zephyron
898ef9d511 Update Vulkan-related dependencies and vcpkg
- Update Vulkan-Headers from cacef303 to 78c35974
- Update VulkanMemoryAllocator from c788c521 to 29b35ea4
- Update vcpkg from e40d24cb to a7d06b3a

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-05-12 12:46:19 +01:00
Zephyron
b5524254f4 feat(build): Add host system detection for Android cross-compilation
- Modify CMakeLists.txt to detect whether the host system is Windows or Linux
- Set VCPKG_HOST_TRIPLET dynamically to either "x64-windows" or "x64-linux" based on CMAKE_HOST_SYSTEM_NAME
- Previously, the host triplet was hardcoded to "x64-windows", which prevented proper building on Linux hosts

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-05-12 12:46:19 +01:00
Zephyron
db56982a8d service/ssl: Register ssl:s service to fix game hangs
Added registration for the 'ssl:s' service using the same implementation as
the regular 'ssl' service. This fixes issues with certain titles that hang indefinitely while
waiting for this service to become available.

The issue appears in logs as:
"Server is not registered! service=ssl:s"
"Waiting for service ssl:s to become available"

This is a simple fix that reuses the existing SSL implementation instead of
creating a separate one, as both services share the same functionality.

This commit enhances the Multiplayer Function

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-05-12 12:46:19 +01:00
Zephyron
70b38c0ce8 vulkan: Implement AMD driver workaround for logic operations
- Added conditional check for AMD graphics drivers
- Automatically disable logic operations when float vertex attributes
  are present to work around driver quirks
- Maintain original logic op state to preserve emulator behavior
- Prepare dynamic state management infrastructure for future
  OpenGL implementation changes

OpenGL implementation will follow in subsequent commits.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-05-12 12:46:19 +01:00
Zephyron
6656c60bca core(base_clock_rate): Revert Back To 1,020 MHz
- This Commit Accidentally Slipped By In A Previous Commit (dad885967942477d887b5dd16a97f07d2316bd3a)
- This Has Caused Many Errors & Networking Issues Particularly On Android
- Now Uses Safe, Default 1.02 GHz

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-05-12 12:46:19 +01:00
Zephyron
c8884fb039 android: Update build system and optimize ARM NCE implementation
- Update Kotlin from 1.9.20 to 2.1.20-RC2
- Upgrade Java version from 17 to 21
- Update Android Gradle plugin from 8.1.2 to 8.9.0
- Update Gradle wrapper from 8.10.2 to 8.11.1
- Update NDK version to 29.0.13113456 rc1
- Update all Android dependencies to latest versions
- Simplify ARM NCE implementation by removing custom TLB handling
- Improve alignment and access fault handling
- Update hardware BASE_CLOCK_RATE from 1.02GHz to 1.785GHz
- Add citron Emulator Project copyright notices

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-05-12 12:46:19 +01:00
vampiric_x
eae6f34259 Fix a few strings 2025-05-12 12:46:19 +01:00
vampiric_x
17c2000510 android: Initial multiplayer support
And give room owners mod access on both Android and QT
2025-05-12 12:46:19 +01:00
Zephyron
481bf648aa Remove quickstart guide references to address legal concerns
- Removed "Open Quickstart Guide" menu item and associated functions
- Replaced ROM loading error popup containing quickstart guide links
  with a neutral disclaimer stating the software is provided as-is
  without warranty or support
- This change helps minimize legal liability by avoiding
  specific instructional content while directing users to community
  resources for assistance
2025-05-12 12:46:19 +01:00
Zephyron
26f0251b93 Update external dependencies
- Update Vulkan-Utility-Libraries submodule to 5f41f2a
- Update vcpkg submodule to efb1e74
2025-05-12 12:46:19 +01:00
Zephyron
856c00f19c arm: Improve TLB implementation and fault handling in NCE
This commit enhances the Translation Lookaside Buffer (TLB) implementation
in the ARM Native Code Execution (NCE) component to increase stability,
particularly on Android devices. The changes prioritize robustness and
error recovery over performance optimizations.

Key improvements:
- Replace set-associative TLB with a simpler linear search implementation
- Implement a basic LRU replacement policy for TLB entries
- Add validation checks for memory addresses before TLB insertion
- Ensure proper page alignment for guest and host addresses
- Enhance alignment fault handling with instruction skipping as fallback
- Add comprehensive debug logging for memory access errors
- Improve error recovery in guest memory access scenarios

These changes should significantly reduce crashes during emulation on
Android devices by gracefully handling memory access edge cases that
previously resulted in hard crashes.

Co-Authored-By: Camille LaVey <camillelavey@citron-emu.org>
Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-05-12 12:46:19 +01:00
Zephyron
9cd38cd8bf shader_recompiler: Implement vertex count lookup for Geometry stage
Add proper handling of input topologies in the Geometry stage for all three
shader backends (GLASM, GLSL, SPIRV). This implementation uses a lookup table
approach to determine vertex counts based on input topology type (Points,
Lines, LinesAdjacency, Triangles, TrianglesAdjacency) and shifts the vertex
count by 16 bits as required by the invocation info format.

Additional changes:
- Fixed TessellationControl and TessellationEval stages to properly break
  after emitting code
- Added proper header include for runtime_info.h in GLASM backend
- Improved code documentation with clear commenting patterns

This change ensures accurate geometry shader behavior across all backends,
improving compatibility with games that rely on proper vertex count reporting.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-05-12 12:46:19 +01:00
Zephyron
a164adfad6 Update external dependencies
- Vulkan-Utility-Libraries: 6be00ca → 2d8f273
- FFmpeg: d161604 → 99e2af4
- vcpkg: 9a7a33f → 23b33f5
2025-05-12 12:46:19 +01:00
Zephyron
d187d7c52c core/arm/nce: Implement TLB caching system
Adds a software TLB cache to improve memory access performance in the NCE
(Native Code Execution) system. Key changes include:

- Implement set-associative TLB with 64 sets and 8 ways
- Add TLB lookup before memory access in HandleGuestAccessFault
- Implement LRU replacement policy with access frequency consideration
- Add thread context caching to reduce overhead
- Add proper synchronization with mutex locks
- Add helper functions for TLB management (lookup, insert, invalidate)

This change should improve performance by reducing redundant memory
translations and providing faster access to frequently used pages.
2025-05-12 12:46:19 +01:00
Zephyron
2eedcf1bf7 externals: Update submodule versions
- vcpkg: 37d46ed → 9a7a33f
- Vulkan-Headers: 234c4b7 → 952f776
- Vulkan-Utility-Libraries: fe7a09b → 6be00ca
- ffmpeg: 9c1294e → d161604
2025-05-12 12:46:19 +01:00