Adds missing include for common/logging/log.h in gpu.h which was causing
compilation failures on Android. This header is needed for logging
functionality used in GPU-related operations.
The include was previously indirectly available through other headers,
but making it explicit improves code clarity and prevents potential
future compilation issues.
Implements several IPC commands in IApplicationFunctions related to GPU error
handling and system events:
- EnableApplicationAllThreadDumpOnCrash (cmd 124)
- SetDelayTimeToAbortOnGpuError (cmd 131)
- TryPopFromNotificationStorageChannel (cmd 151)
- SetHdcpAuthenticationActivated (cmd 170)
- GetLaunchRequiredVersion (cmd 180)
- UpgradeLaunchRequiredVersion (cmd 181)
Also adds the LaunchRequiredVersion struct definition to the header file.
These are currently stubbed implementations that log warnings when called.
REFS: switchbrew.org/wiki/Applet_Manager_services#GetGpuErrorDetectedSystemEvent
Reverts overly restrictive storage buffer validation and size calculation
that was causing rendering issues in The Legend of Zelda: Tears of the
Kingdom, particularly in underground/depth areas. The simplified approach:
- Uses GetMemoryLayoutSize() instead of manual page probing
- Removes unnecessary 4GB memory bounds validation
- Streamlines address translation and alignment handling
This fixes numerous reported cases of missing or corrupted rendering in
TOTK's underground areas where storage buffer operations are heavily used
for depth-related effects.
Implements proper reference counting for binder objects based on the official
documentation. This adds both weak and strong reference counting support to
the IBinder interface and its implementations (BufferQueueProducer and
BufferQueueConsumer).
The implementation follows the documented behavior where:
- type 0 affects weak references
- type 1 affects strong references
- During initialization: {addval=1, type=0} followed by {addval=1, type=1}
- For onFirstRef: {addval=1, type=1}
- For onLastStrongRef: {addval=-1, type=1}
Reference counters are implemented using std::atomic to ensure thread safety.
REFS: switchbrew.org/wiki/Nvnflinger_services#AdjustRefcount
Implements missing functions and improves permission handling in the VI
(Visual Interface) IApplicationDisplayService based on official documentation.
Key changes:
- Add session type enum to properly handle vi:u/vi:s/vi:m permissions
- Implement GetIndirectLayerImageCropMap for handling cropped layer images
- Implement GetDisplayVsyncEventForDebug for debug vsync event handling
- Add proper permission checks for GetSystemDisplayService and GetManagerDisplayService
- Improve AppletResourceUserId validation in OpenLayer
- Clean up logging and error handling
The changes follow the official documentation for permission handling:
- vi:u sessions can only use GetRelayService
- vi:s sessions can use everything except GetManagerDisplayService
- vi:m sessions can use all commands
REFS: switchbrew.org/wiki/Display_services#IApplicationDisplayService
Reorganizes the ErrorModule enum in result.h by grouping error codes into
numerical ranges with descriptive comments. This improves readability and
makes it easier to:
- Find specific modules by their number
- See which numbers are used/unused in each range
- Understand the overall distribution of module numbers
Also standardizes naming conventions across modules and fixes some
inconsistent casing (e.g. FS -> Fs, HDCP -> Hdcp).
REFS: switchbrew.org/w/index.php?title=Error_codes
Updates the SM service implementation to better match the official
"nn::sm::detail::IUserInterface" interface. Key changes include:
- Replace Initialize with RegisterClient command (cmd 0)
- Add DetachClient command implementation (cmd 4)
- Update service name handling to use u64-encoded names
- Add proper PID descriptor handling for RegisterClient/DetachClient
- Add ResultNotAllowed error code
- Update handler registration for both CMIF and TIPC
This brings the implementation closer to the official documentation while
maintaining compatibility with existing code.
Refs: switchbrew.org/wiki/Services_API#sm:
Removes the save states menu and unused help menu items as they require
additional research and implementation work. Specifically:
- Remove save states menu and associated actions (Save/Load)
as proper implementation requires more research
- Remove unused help menu items:
* Open Mods Page
* Open Quickstart Guide
* Open FAQ
- Keep core help functionality (Report Compatibility and About)
- Reorder menu properties for better organization
This change helps maintain a cleaner UI by removing placeholder
features that are not yet ready for implementation.
Refactors the MM (Memory Management) service implementation with improved:
- Session management using a vector of Session objects instead of global vars
- Type safety with proper enums and member encapsulation
- Error handling with consistent patterns
- Modern C++ features (std::erase_if, std::find_if, emplace_back)
- Logging with detailed debug messages
- Code organization and const correctness
Key changes:
- Add Session class with proper encapsulation
- Add EventClearMode enum (Manual = 0, Auto = 1)
- Update Module enum naming for consistency
- Implement proper session tracking and lookup
- Add detailed parameter logging
- Use modern C++ algorithms for session management
The implementation now properly handles multiple sessions and matches
the documented nn::mmnv::IRequest interface more closely.
Refs: switchbrew.org/wiki/Display_services#mm:u
Add proper type definitions and parameter handling for the Memory Management
(mm:u) service based on the Switch documentation:
- Add Module enum for hardware components (CPU, GPU, EMC, etc)
- Add Priority and Setting type definitions as u32
- Add EventClearMode enum for initialization
- Implement proper parameter handling for all IPC calls
- Add detailed logging with parameter values
The Module enum now properly reflects the documented hardware components:
CPU, GPU, EMC, System Bus, Memory Select, and NVIDIA modules (NVDEC,
NVENC, NVJPG).
This makes the implementation match the documented nn::mmnv::IRequest
interface.
Refs: switchbrew.org/wiki/Display_services#mm:u
- Redesign loading screen progress bar with gradient animation
- Update loading screen typography using Segoe UI
- Add comprehensive dark theme styling to main window
- Modernize menu, toolbar, and dock widget appearances
Relaxes validation checks in the NVDRV GPU service and improves error notifier
handling to prevent potential hangs. Key changes:
- Remove strict size validation in SetErrorNotifier
- Relax GPFIFO entry count validation to only check for non-zero values
- Add proper error notifier state tracking in GPU class
- Improve debug logging messages
The previous strict validation was causing issues with some games like ACNH.
These changes maintain necessary checks while being more permissive with
edge cases that don't impact functionality.
Technical changes:
- Store error notifier state in GPU class for future implementation
- Remove upper bound check on GPFIFO entries
- Simplify error notifier setup flow
This should resolve hanging issues while maintaining core functionality.
Implements several previously stubbed functions in the NVDRV service:
- Initialize proper transfer memory handling
- Add error notifier configuration
- Implement channel timeout and timeslice management
- Add object context allocation and tracking
- Add GPU interface stubs for new functionality
The changes improve the accuracy of GPU-related operations while maintaining
compatibility with the existing codebase. All functions now properly validate
parameters and handle endianness correctly using _le types.
Adds UI elements for future save state support:
- New "Save States" menu in the main menubar
- Save and Load action items with keyboard shortcuts
- No functionality implemented yet, just UI stubs
- Add proper invocation info handling for tessellation and fragment stages
- Return patch vertices info shifted by 16 bits for tessellation stages
- Return sample mask shifted by 16 bits for fragment stage
- Return standard format (0x00ff0000) for compute and other stages
- Implement consistently across SPIRV, GLSL, and GLASM backends
- Remove stubbed warning message
- The GetManagerDisplayService function in IApplicationDisplayService is fully implemented, so remove the stubbed warning and change the log level to DEBUG to match its implementation status.
- Updates vcpkg baseline to 7adc2e4d49e8d0efc07a369079faa6bc3dbb90f3 to fix Windows compilation issues by avoiding Visual Studio 2019 build tools and using the latest.
Two main changes in this commit:
1. Replace NVIDIA-specific GL_NV_gpu_shader5 extension with the more widely
supported GL_EXT_shader_explicit_arithmetic_types_float16 in the scaleforce
shader. This improves compatibility across different GPU vendors.
2. Refactor ARM32 exception handling:
- Restructure exception cases for better readability
- Update exception handling to match current Dynarmic API
- Fix indentation in switch statement
- Remove AccessViolation case as it's no longer supported in current API
These changes improve shader compatibility and align the exception handling
with the current Dynarmic implementation.
The SPIRV-Tools and SPIRV-Headers submodules are being temporarily removed
to fix their directory structure. They will be re-added in a follow-up
commit with the correct directory organization.
- Update vcpkg baseline to a42af01b72c28a8e1d7b48107b33e4f286a55ef6
- Add SPIRV-Tools and SPIRV-Headers as submodules
- Update Vulkan-related submodules to latest stable versions
- Improve memory access error handling:
- Add specific handling for null pointer accesses in ARM32 emulation
- Return 0 for null pointer reads instead of undefined behavior
- Silently ignore writes to null pointers
- Add more detailed error messages distinguishing between null pointer
access and other unmapped memory errors
- Treat addresses below 0x1000 as potential null pointer accesses
These changes should provide more graceful handling of null pointer
accesses and improve stability when running games that attempt invalid
memory operations.
Replaces the battery temperature reading implementation with a more
compatible approach using ACTION_BATTERY_CHANGED broadcast intent.
This change provides better backwards compatibility and adds proper
error handling for the temperature reading functionality.
Add stub implementations for previously unhandled flow test conditions in the
shader recompiler's IR emitter. These conditions were previously throwing
"Not Implemented" exceptions when encountered.
The following flow test cases are now stubbed:
- FCSM_TR (Fragment Shader Coarse/Fine Mode Test and Reject)
- CSM_TA (Coarse/Fine Mode Test Accept)
- CSM_TR (Coarse/Fine Mode Test and Reject)
- CSM_MX (Coarse/Fine Mode Maximum)
- FCSM_TA (Fragment Shader Coarse/Fine Mode Test Accept)
- FCSM_MX (Fragment Shader Coarse/Fine Mode Maximum)
Currently these stubs:
1. Return false (ir.Imm1(false)) as a placeholder value
2. Log a warning message indicating the stub
3. Allow shaders using these conditions to compile rather than fail
This is a step toward proper implementation of coarse/fine mode shader
operations. The stubs prevent crashes while making it clear which code paths
need full implementation.
Technical notes:
- Removed the previous FCSM_TR implementation that used flag operations
- Added consistent warning messages for tracking stub usage
- Kept within the existing GetFlowTest switch statement structure
Remove the x86-64 instruction set architecture (ISA) compatibility flags and
associated toolchain file that were setting CPU architecture compatibility
levels. This simplifies the build system by removing the custom ISA flag
handling and x86-64-v2 option.
Changes:
- Remove x86-64 ISA flags configuration block from CMakeLists.txt
- Delete unused x86-64-toolchain.cmake file
- Remove CITRON_USE_X86_64_V2 option
- Reduce compileSdkVersion and targetSdk from 35 to 34
- Change NDK version to 26.1.10909125
- Downgrade Android Gradle Plugin from 8.8.0 to 8.1.2
- Add androidx.constraintlayout dependency
These changes improve compatibility with current Android development
environment and add necessary layout support.
Implements the USE_AUTO_STUB setting in the Android frontend:
- Added USE_AUTO_STUB to BooleanSetting enum
- Added UI switch setting with description in SettingsItem
- Added setting to system settings section in SettingsFragmentPresenter
- Added string resources for setting title and description
The setting allows users to toggle automatic stubbing of missing services
and functions, which may improve compatibility at the cost of stability.
Update VulkanHeaders minimum required version from 1.3.274 to 1.4.304 and
update vcpkg baseline to latest version to ensure compatibility with newer
Vulkan features.
Changes:
- VulkanHeaders: 1.3.274 -> 1.4.304
- vcpkg baseline: c82f74667 -> 7adc2e4d4
Remove the stubbed implementation of FCSM_TR (Forward Condition Set Mode -
Thread Reduction) flow test and replace it with an initial implementation
using SFlag and ZFlag conditions. This provides basic functionality while
allowing for future refinement based on specific shader architecture
requirements.
- Updated the QueryPointerBufferSize function to return the correct u16 pointer buffer size.
- Ensured the function logs its call at the debug level.
- Used IPC::ResponseBuilder to construct the response with the correct buffer size.
This change addresses the stubbed implementation and ensures compliance with the HIPC protocol.
- Added the SetGestureOutputRanges function to the IHidServer class to address the unimplemented function '92' error.
- This fix was discovered through log analysis, which showed a critical assertion failure in the HID service for an unknown function '92'.
- The log indicated a userspace panic and backtrace, pointing to the need for implementing this function to prevent execution breaks.
- Updated CMakeLists.txt to remove specific version requirements for several packages, enhancing flexibility.
- Updated subproject commit references for VulkanMemoryAllocator and vcpkg.
- REF: https://switchbrew.org/wiki/HID_services#ActivateGesture
- Replace emoji thermal indicators with modern progress bar UI
- Switch temperature source to battery sensor for better accuracy
- Adjust temperature thresholds (30°C-45°C range)
- Add automatic Vulkan Validation Layer download for Android
- Downgrade Java/Kotlin target to 17 for wider compatibility
The thermal display now shows a visual progress bar with percentage
instead of emojis, making it easier to gauge system temperature at
a glance. Temperature reading now comes from the battery sensor
which is more reliable across devices.
Build system improvements include automated VVL binary downloads
and installation for Android builds when CITRON_DOWNLOAD_ANDROID_VVL
is enabled. Java target downgraded to 17 to ensure compatibility
with current Android toolchain.
- In commit b3facaa6bb, the copyright header was
updated to include "Citron Homebrew Project" across multiple files, regardless
of whether any contributions were made.
- This commit removes the incorrect attribution and reverts the copyright header
to its previous state.
- Copyright attribution should only be added when meaningful contributions have
been made to the file.
- This commit ensures proper compliance with copyright standards and maintains
correct attribution to the respective contributors.
- Special thanks to Tachi for pointing out the need for these corrections and
ensuring that proper attribution practices are followed.
Expand ISA level enforcement to ensure all components, including vcpkg
dependencies, are built with x86-64-v2 instruction set. This addresses
remaining compatibility issues where dependencies were potentially being
built with higher ISA levels.
Changes:
- Add dedicated x86-64-v2 toolchain file for vcpkg
- Set ISA flags for both main project and dependencies
- Ensure proper quoting of compiler flags
- Configure vcpkg to use consistent toolchain settings
The fix requires cleaning both build and vcpkg directories before
rebuilding:
rm -rf build/
rm -rf vcpkg_installed/
Credits to Alex&Indie for the original ISA compatibility fix.
Fixes remaining instances of Linux Compilation
Enforce x86-64-v2 instruction set level to prevent compatibility issues
on systems that default to higher ISA levels (v3/v4). This fixes crashes
reported on certain Linux distributions like CachyOS that force higher
instruction set levels by default.
The fix:
- Sets -march=x86-64-v2 for both C and CXX flags
- Adds compile options to ensure system defaults don't override
- Explicitly disables v3 and v4 instruction sets
- Only applies to x86_64 architectures
Credits to Alex&Indie for identifying the ISA level compatibility
issue.
Fixes: Linux Compilation.
- Update Kotlin and various AndroidX dependencies to stable versions
- Add temperature monitoring with color-coded display in emulation
- Add FPS color indication (red to green based on performance)
- Add legal disclaimer page to initial setup
- Remove x86_64 ABI filter to focus on arm64-v8a
- Adjust thermal and FPS update intervals for consistency
- Clean up redundant dependency declarations
The temperature display now shows both Celsius and Fahrenheit with
color coding based on safe operating ranges [WIP]. FPS counter provides
visual feedback through colors, making performance issues more
immediately apparent to users.
- Update Gradle from 8.1 to 8.10.2
- Update Android Gradle Plugin from 8.1.2 to 8.8.0
- Update Kotlin from 1.9.20 to 2.1.20-Beta1
- Update various AndroidX dependencies to latest versions
- Update NDK from 26.1 to 27.2 (with RC1/RC2 options commented)
- Update Java target from 17 to 21
- Update Android target SDK from 34 to 35
- Enable additional optimizations in release builds:
- Enable shrinkResources
- Use proguard-android-optimize.txt
- Disable JNI debugging
- Replace vector drawables with PNG for ic_citron
- Comment out unused ComputeInline constant in dma_pusher.cpp
- Update Gradle wrapper and configuration files
This updates the Android build system and dependencies to their latest
versions while enabling additional optimizations for release builds.
The ic_citron icon was converted from vector to PNG format for better
compatibility.
Added new CMake option CITRON_USE_LLVM_DEMANGLE (default: ON) to control whether
the project uses LLVM's Demangle component. This allows building without LLVM
dependencies when demangling support is not needed.
Co-authored-by: reg_server
Previously, the code would unconditionally add a constant buffer descriptor
at index 0 whenever storage buffers were present, which could cause conflicts
and crashes. This change:
- Adds validation to check if constant buffer 0 already exists
- Only adds the descriptor if it's not already present
- Prevents potential descriptor conflicts in shaders
This should resolve crashes in Vulkan games related to invalid descriptor
layouts and resource binding conflicts.
Add conditional compilation directives to handle packed struct definitions
differently between MSVC and other compilers. MSVC uses #pragma pack
while GCC/Clang use __attribute__((packed)). This change affects:
- ZBCColorEntry
- ZBCDepthEntry
- IoctlZbcSetTable
The functionality remains the same, but ensures proper struct packing
across different compiler environments.
Add support for bindless texture constant buffers in the compute pipeline
creation process. When storage buffer descriptors are present, create a
constant buffer descriptor to handle bindless textures. This fixes the
"Failed to track bindless texture constant buffer" error.
Changes:
- Add constant buffer descriptor with index 0 and count 1 when storage
buffers are present
- Place descriptor creation before SPIR-V code generation to ensure proper
shader compilation
This resolves issues with bindless texture access in compute shaders.
Adds support for InfoType::SystemResourceSize (0x1C) which is required for
proper initialization of the Virtual Address Memory Manager (VAMM). This
implementation:
1. Adds SystemResourceSize to the InfoType enum in svc_types.h
2. Implements the GetInfo handler for SystemResourceSize in svc_info.cpp
3. Returns 512MB (0x20000000 bytes) as the system resource size
4. Adds debug logging for the SVC call
The 512MB value is chosen based on typical system resource allocations
needed for VAMM initialization on the Nintendo Switch.
This fixes crashes in games that rely on VAMM functionality, particularly
during nn::os::detail::VammManager::InitializeIfEnabled().
This commit makes several improvements to device memory management and buffer
queue handling:
DeviceMemoryManager:
- Add null pointer and size checks for ReadBlock
- Fill unmapped memory with a known pattern (0xCC) instead of zeros
- Add better error logging for invalid memory accesses
- Add null pointer check for source pointer in memcpy
BufferQueueProducer:
- Improve error handling in WaitForFreeSlotThenRelock
- Add proper abandoned state checking during wait conditions
- Clean up and simplify buffer scanning logic
- Improve logging messages with more descriptive information
- Remove redundant buffer count validation
- Fix potential infinite loop condition during wait
These changes improve stability and error handling while making the code more
maintainable and debuggable. The use of a known pattern for unmapped memory
helps identify uninitialized memory access issues.
Implements TryPopFromFriendInvitationStorageChannel to properly handle
friend invitation data storage and retrieval. This includes:
- Add ResultNoData error code to am_results.h
- Add friend_invitation_storage_channel storage queue to Applet struct
- Implement proper data handling in TryPopFromFriendInvitationStorageChannel
The implementation now properly manages a queue of friend invitation data
and returns appropriate results based on data availability.
Refactors the game list scanning code to use std::filesystem instead of custom
directory iteration functions. Main changes include:
- Replace Common::FS directory iteration with std::filesystem iterators
- Split game file processing logic into separate ProcessGameFile method
- Improve error handling with try-catch for filesystem operations
- Simplify control NCA metadata extraction
- Use more modern C++ features and cleaner code organization
This change should improve maintainability and reliability of the game
scanning system while potentially offering better performance through
native filesystem APIs.