Changes the StartupWMClass from "citron" to "org.citron_emu.citron" to ensure proper icon display in GNOME and other desktop environments. Without this matching the application ID, a generic icon is displayed instead of the proper application icon.
Credit: Shikakiben (shikakiru)
Signed-off-by: Zephyron <zephyron@citron-emu.org>
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>
This update further improves shader management and pipeline handling:
- Add advanced heuristics for smarter async shader compilation in both OpenGL
and Vulkan renderers, with better detection of UI and critical shaders
- Implement thread pool for prioritized shader compilation with proper progress
tracking and reporting
- Add predictive shader loading system to preload related shaders based on
pipeline transitions
- Implement pipeline deduplication through Clone() method to reduce memory
usage and improve performance
- Add memory optimizations for shader translation and SPIR-V generation
- Enhance error handling and logging for shader operations
- Introduce batch loading and directory-based shader preloading capabilities
Signed-off-by: Zephyron <zephyron@citron-emu.org>
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>
This commit disables GPU memory management, memory snapshots, and NCE
functionality by forcing these settings to false throughout the codebase.
The changes include:
- Hardcoding false values in renderer_vulkan.cpp initialization
- Disabling UI controls for these features in configuration screens
- Forcing settings to false during configuration read/write operations
These features are being disabled to improve stability and prevent
potential memory-related issues.
Signed-off-by: Zephyron <zephyron@citron-emu.org>
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>
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>
Temporarily roll back the following submodules:
- VulkanMemoryAllocator: 2f382df → 539c0a8
- Vulkan-Headers: 80207f9 → e2e53a7
- Vulkan-Utility-Libraries: 524f891 → 4e246c5
This is for testing purposes only and should only be used for developers.
Signed-off-by: Zephyron <zephyron@citron-emu.org>
- 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>
Updates UDP client and related test files to use boost::asio::io_context
instead of the deprecated io_service. This change is required for compatibility
with newer versions of Boost ASIO, which has renamed the class.
Signed-off-by: Zephyron <zephyron@citron-emu.org>
- 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>
- 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>
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>
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>
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>
Resolves a variable shadowing issue in AsyncCompileShader where the callback
lambda parameter was shadowing the outer callback variable. This was causing
compilation warnings/errors in Android Studio. The fix:
- Renames the outer callback variable to 'outer_callback'
- Renames the inner lambda callback parameters to 'inner_callback'
- Maintains consistent naming across all error handling paths
This change improves code clarity and eliminates compiler warnings while
maintaining the same functionality for async shader compilation.
Signed-off-by: Zephyron <zephyron@citron-emu.org>
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>
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>
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>
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>
- Fix variable shadowing in ShaderManager constructor by renaming parameter
- Remove unused variables in vk_texture_manager.cpp to avoid warnings
- Fix int conversion warning in syscall return value
These changes fix build errors when using certain optimized compile flags for Linux.
Signed-off-by: Zephyron <zephyron@citron-emu.org>
Fixes issues in commit bbd3253169 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>
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>
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>
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>
- Remove special handling for reversed depth scenarios that were added for Civilization 7
- Remove excessive logging in Vulkan renderer
- Update Discord client ID
- Update Vulkan-related external dependencies
Signed-off-by: Zephyron <zephyron@citron-emu.org>
- Added missing <thread> header for std::thread usage
- Added <fcntl.h> for O_CLOEXEC and O_NONBLOCK definitions
- Fixed struct initialization order in uffdio_copy to match declaration order
Signed-off-by: Zephyron <zephyron@citron-emu.org>
This commit adds Windows-specific implementation of the fault-managed memory
system, providing similar functionality to the existing Linux/Android implementation.
Key changes:
- Added Windows-specific memory management using VirtualAlloc/VirtualFree
- Implemented Windows vectored exception handler for page fault handling
- Added proper memory protection and page fault handling on Windows
- Updated memory snapshot functionality to work on Windows
- Added proper cleanup of Windows-specific resources
- Fixed type conversion issues in memory management code
- Added proper error handling for Windows memory operations
- Fixed VRAM Memory Layout Mode to allow up to 12Gb
The implementation uses Windows-specific APIs:
- VirtualAlloc/VirtualFree for memory management
- AddVectoredExceptionHandler for page fault handling
- VirtualProtect for memory protection management
This change maintains feature parity with the Linux/Android implementation
while using Windows-native APIs for better performance and reliability.
Signed-off-by: Zephyron <zephyron@citron-emu.org>
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>
Adds a new cross-platform memory management system with enhanced capabilities:
- Fault-managed memory allocation for Linux/Android platforms
- Memory snapshot and differential snapshot support
- Predictive memory reuse tracking for optimized access patterns
- Vulkan compute buffer integration
- User-configurable settings for enabling features
The system integrates with the existing Vulkan renderer to provide more
efficient memory handling, especially for compute-intensive workloads.
Co-authored-by: boss.sfc <boss.sfc@citron-emu.org>
Co-committed-by: boss.sfc <boss.sfc@citron-emu.org>
Signed-off-by: Zephyron <zephyron@citron-emu.org>
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.
Update Vulkan dependencies to their latest versions.
Signed-off-by: Zephyron <zephyron@citron-emu.org>
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>
Implement a robust asynchronous shader compilation system inspired by commit
1fd5fefcb1. This enhancement provides:
- True multi-threaded shader compilation with atomic status tracking
- Persistent disk caching for faster shader loading
- Command queue system for background processing
- Integration with Citron's scheduler for better resource management
- Parallel shader loading to reduce startup times
- Improved error handling and recovery mechanisms
These changes significantly reduce shader compilation stuttering and improve
overall performance when using asynchronous shaders. The implementation
maintains compatibility with Citron's existing architecture while adding
more robust threading capabilities.
Co-authored-by: boss.sfc <boss.sfc@citron-emu.org>
Co-committed-by: boss.sfc <boss.sfc@citron-emu.org>
Signed-off-by: Zephyron <zephyron@citron-emu.org>
This commit adds improved Vulkan functionality to the Citron emulator:
- Add thread-safe texture management with automatic error recovery
- Implement shader caching with validation support
- Add robust error handling for Vulkan operations
- Implement platform-specific initialization for Windows, Linux, and Android
These enhancements improve stability when handling texture loading errors
and provide better recovery mechanisms for Vulkan failures.
Co-authored-by: boss.sfc <boss.sfc@citron-emu.org>
Co-committed-by: boss.sfc <boss.sfc@citron-emu.org>
Signed-off-by: Zephyron <zephyron@citron-emu.org>
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>
This commit adds new settings and optimizations for shader compilation:
- Add new settings:
- use_enhanced_shader_building: Enable enhanced shader compilation
- shader_compilation_priority: Control shader compilation priority
- Improve shader compilation performance:
- Optimize worker thread allocation based on CPU cores
- Add smarter async shader compilation heuristics
- Prioritize vertex and fragment shader compilation
- Add performance tracking and logging
- Add performance monitoring:
- Track shader compilation times
- Log slow shader compilations
- Monitor async shader compilation statistics
This is a work in progress commit. Further optimizations and refinements
will be needed based on testing and feedback.
Signed-off-by: Zephyron <zephyron@citron-emu.org>