Commit Graph

27261 Commits

Author SHA1 Message Date
Zephyron
66703870b5 common/nvdrv: improve memory validation and error handling
Implements several improvements to memory handling and validation:

- host_memory: Add IsValidMapping() and IsDirectMappingEnabled() methods to
  validate memory access
- host_memory: Fix virtual base offset calculation to use proper pointer
  arithmetic
- host_memory: Add size field to track allocation size
- nvhost_ctrl_gpu: Return InvalidState instead of InvalidValue for TPC mask
  buffer size validation
- Update copyright year for citron

The changes improve memory safety by adding explicit validation checks and
fixing pointer arithmetic in the virtual memory implementation.
2025-05-11 14:54:45 +01:00
Zephyron
9f49882c24 build: update Qt to 6.8.1 and add permissive flag for discord-rpc
Updates the Qt dependency from 6.7.3 to 6.8.1 when downloading Qt.
Adds -fpermissive compile flag for discord-rpc target to fix build issues.
2025-05-11 14:54:45 +01:00
Zephyron
8c66caeb5e nvdrv: Add GetTpcMasks2 support and improve memory mapping validation
This commit makes two main changes:

1. Adds support for GetTpcMasks2 (ioctl 0x13) in nvhost_ctrl_gpu:
- Implements new GetTpcMasks2 method to handle TPC mask queries
- Adds IoctlGetTpcMasks structure to store mask parameters
- Returns conservative single TPC configuration for compatibility

2. Enhances memory mapping validation in HostMemory:
- Adds verification check after memory mapping operations
- Improves error handling for direct mapped address enabling
- Adds logging for mapping and direct address failures

Additional changes:
- Updates copyright headers to include citron Emulator Project
- Improves error handling and validation in several paths
- Adds debug logging for TPC mask operations

This improves GPU virtualization support and memory mapping reliability.
2025-05-11 14:54:45 +01:00
Zephyron
25de2e9e47 externals: Update Vulkan and related dependencies
Update the following external dependencies:
- Vulkan-Headers e43027a -> 39f924b
- Vulkan-Utility-Libraries 8ec8482 -> fe7a09b
- VulkanMemoryAllocator 7ab8483 -> 72c309a
- libadrenotools 5cd3f5c -> 8fae8ce
- vcpkg 2b8927f -> 2ded45c
2025-05-11 14:54:45 +01:00
Zephyron
255914f80c feat: Add RAM usage overlay and improve thermal display
- Add new RAM usage overlay showing current/max memory usage with color gradient
- Simplify thermal overlay to show temperature in C/F with color indication
- Add SHOW_RAM_OVERLAY boolean setting (disabled by default in UI)
- Set default values for thermal overlay and black backgrounds to true
- Update copyright headers to include Citron Emulator Project

The RAM overlay displays native heap usage with color gradient from green
(low usage) to red (high usage). The thermal display was simplified to show
just temperatures while maintaining the color indication based on system
thermal status.
2025-05-11 14:54:45 +01:00
Zephyron
a69dc81b34 video_core: Add sRGB to D24S8 depth-stencil conversion support
Implements conversion from sRGB color formats to D24S8 depth-stencil format
in the Vulkan renderer. This change includes:

- New fragment shader convert_abgr8_srgb_to_d24s8.frag that handles proper
  sRGB to linear conversion before depth calculation
- Added shader to CMake build system
- Extended BlitImageHelper with new conversion pipeline and methods
- Updated texture cache to handle sRGB to D24S8 format conversion paths

The conversion properly handles sRGB color space by first converting to
linear space before calculating luminance values for the depth component,
while preserving alpha channel data for the stencil component.
2025-05-11 14:54:45 +01:00
Zephyron
309c2d980d string_util: Replace deprecated wstring_convert with direct UTF conversions
Removes usage of std::wstring_convert and std::codecvt_utf8_utf16 which are
deprecated since C++17. Implements direct UTF conversions for:

- UTF16ToUTF8: Manual conversion with proper surrogate pair handling
- UTF8ToUTF16: Direct conversion supporting full Unicode range
- UTF8ToUTF32: New implementation with proper code point extraction

The new implementations are more robust and handle edge cases better while
avoiding deprecated functionality. Windows-specific code paths remain unchanged
using the existing UTF16W conversions.

This change improves maintainability and removes compiler warnings about
deprecated features while maintaining full Unicode support.
2025-05-11 14:54:45 +01:00
Zephyron
8565c47b5f common: Improve error handling in host memory management
Add proper error handling and recovery mechanisms for memory mapping
operations instead of using assertions.
2025-05-11 14:54:45 +01:00
Mike Lothian
36d60f5166 Update build.gradle.kts 2025-05-11 14:54:45 +01:00
Zephyron
c69ef17cdd service: Implement rebootless system update stubs and types
Adds initial support for rebootless system update related functionality:

- Add system archive title IDs for ApplicationBlackList, RebootlessSystemUpdateVersion,
  and ContentActionTable
- Add NS service result codes for system update operations
- Implement stubs for ISystemUpdateControl::SetupToReceiveSystemUpdate and
  RequestCheckLatestUpdateIncludesRebootlessUpdate
- Add RebootlessSystemUpdateVersion settings type and implement
  GetRebootlessSystemUpdateVersion in SET service
- Fix GetSettingsItemValueImpl template implementation

This provides basic infrastructure for handling system updates, particularly
the rebootless update feature, though actual update functionality remains
stubbed.
2025-05-11 14:54:37 +01:00
vampiric_x
e61f612d8d android: Fix non-scrollable legal disclaimer on setup 2025-05-11 14:29:04 +01:00
Zephyron
1c92306360 kernel/svc: Implement InitialProcessIdRange and improve process exit handling
- Replace stubbed InitialProcessIdRange implementation with proper bounds (1-0x50)
- Add handle and info_sub_id validation for InitialProcessIdRange
- Replace process exit ASSERT with graceful error handling and logging
- Add try-catch block around system.Exit() for safer shutdown
- Add atomic header inclusion for binder.h

This improves system call reliability by properly implementing process ID
range checks and adding safer process exit handling with proper error logging.
2025-05-11 14:29:04 +01:00
Zephyron
78d43b234f network: Add NOMEM errno handling for socket operations
Implements support for ENOMEM (errno 12) across the network stack:
- Added NOMEM to Network::Errno enum
- Added NOMEM = 12 to sockets Errno enum
- Added translation case in sockets_translate.cpp

This is the first step towards addressing the 0.0 FPS bug that occurs
when the system runs out of memory during socket operations. Previously,
these operations would trigger an unimplemented assertion, causing the
emulator to halt. Now the error will be properly propagated to the guest
application.
2025-05-11 14:29:04 +01:00
Zephyron
f138e07556 qt: Replace deprecated stateChanged with checkStateChanged
Updates QCheckBox signal connections to use checkStateChanged instead of
the deprecated stateChanged signal. This change affects:

- qt_controller.cpp
- configure_filesystem.cpp
- configure_input.cpp
- configure_input_advanced.cpp
- configure_system.cpp
- configure_ui.cpp
- shared_widget.cpp

Also updates lambda signatures to use Qt::CheckState instead of int for
the state parameter where needed.
2025-05-11 14:29:04 +01:00
Zephyron
f50aa799df vulkan: Relax VRAM allocation limits for better stability
Adjusts VRAM allocation strategy to be more conservative while maintaining
performance:

- Increases reserve memory from 1/8th to 1/4th (max 2GB) for discrete GPUs
- Increases base memory limit from 6GB to 8GB
- Doubles resolution scaling memory from 1GB to 2GB per scale factor
- Reduces system memory reservation from 8GB to 4GB for integrated GPUs
- Increases maximum memory limit from 4GB to 6GB for integrated GPUs

These changes help prevent memory leaks while still providing adequate
VRAM for optimal performance.
2025-05-11 14:29:04 +01:00
Zephyron
b5371eb41a deps: Update Vulkan dependencies and remove fmt version constraint
- Update Vulkan-Headers to e43027a (1.4.306)
- Update Vulkan-Utility-Libraries to 8ec8482
- Update vcpkg to 2b8927f
- Remove version constraint for fmt package requirement
- Update VulkanHeaders version requirement to 1.4.306

This updates several external dependencies to their latest versions and
removes the specific version requirement for fmt while maintaining the
REQUIRED flag. The Vulkan-Headers version requirement is updated to match
the new submodule version.
2025-05-11 14:29:04 +01:00
Zephyron
f32c7108c0 android: Update Gradle and Java version requirements
Updates Android build configuration to use newer versions:
- Upgrade Java/JVM target from 17 to 21
- Update Android Gradle Plugin from 8.1.2 to 8.8.0

These changes modernize the Android build system to use the latest LTS
version of Java and the most recent stable Android Gradle Plugin.
This enables access to newer language features and build optimizations
while maintaining compatibility with modern Android development tools.
2025-05-11 14:29:04 +01:00
Zephyron
b78d35014a android: Fix compilation by adding missing log.h include
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.
2025-05-11 14:29:04 +01:00
Zephyron
5c4e34d802 service: Implement GPU error handling IPC commands for AM
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
2025-05-11 14:29:04 +01:00
Zephyron
9697037644 buffer_cache: Simplify storage buffer binding logic
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.
2025-05-11 14:29:04 +01:00
Zephyron
14378f5c16 nvnflinger: Implement reference counting for binder objects
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
2025-05-11 14:29:04 +01:00
Zephyron
8f0b1df7f6 service: vi: Implement missing IApplicationDisplayService functions
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
2025-05-11 14:29:04 +01:00
Zephyron
65b178cfd0 ui: Remove save states menu and unused help links
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.
2025-05-11 14:29:04 +01:00
Zephyron
6f30786173 service: mm: Refactor Memory Management service 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

service/mm: add missing vector include and update copyright

- Add missing <vector> include for std::vector usage
- Add Citron copyright notice
- Maintain existing include ordering

This is a minor cleanup change to ensure proper header inclusion
and copyright attribution.
2025-05-11 14:28:58 +01:00
Zephyron
49b17b42d0 service: mm: Implement proper parameter handling for MM service
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
2025-05-11 12:38:23 +01:00
Zephyron
884a47cab0 feat: implement modern dark theme and loading screen redesign
- 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
2025-05-11 12:18:50 +01:00
Zephyron
1a160d651d service/nvdrv: Relax GPU validation and improve error handling
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.
2025-05-11 12:18:43 +01:00
Zephyron
5117f6496a service/nvdrv: Implement stubbed GPU functions
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.
2025-05-11 12:18:33 +01:00
Zephyron
974dd4a7cf ui: Add Save States menu stubs
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
2025-05-11 12:18:02 +01:00
Zephyron
3189fe941a shader: Implement EmitInvocationInfo across all backends
- 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
2025-05-11 12:17:03 +01:00
Zephyron
7f1e5090e9 service-am: Handle panic conditions in SetTerminateResult
- Prevents propagation of panic conditions when setting termination results
- Previously, panic error codes could trigger cascading crashes
- Only stores non-error termination results while allowing successful completion
- Fixes crash when applications set panic-related termination codes (0x1A80A)
2025-05-11 12:17:03 +01:00
Zephyron
bc82a4f41b service: vi: Remove stubbed warning from GetManagerDisplayService
- 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.
2025-05-11 12:17:03 +01:00
Zephyron
96b777e40a fix: update vcpkg baseline to avoid VS2019 build tools
- Updates vcpkg baseline to 7adc2e4d49e8d0efc07a369079faa6bc3dbb90f3 to fix Windows compilation issues by avoiding Visual Studio 2019 build tools and using the latest.
2025-05-11 12:17:03 +01:00
Zephyron
9ef8867bd4 arm/video: Fix shader extension and exception handling
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.
2025-05-11 12:17:03 +01:00
Zephyron
221efc2294 memory: Improve null pointer and unmapped memory handling
- 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.
2025-05-11 12:17:03 +01:00
vampiric_x
07a40fef9c Add QT Network package 2025-05-11 12:17:03 +01:00
vampiric_x
fbe08d0b73 feat(network): Ip input field for multiplayer room creation 2025-05-11 12:17:03 +01:00
Zephyron
3341368074 android: Fix battery temperature reading in EmulationFragment
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.
2025-05-11 12:17:03 +01:00
Zephyron
72e2f7130e shader_recompiler: Add stubs for CSM/FCSM flow test conditions
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
2025-05-11 12:17:03 +01:00
Zephyron
68d4e7b7cc android: Add USE_AUTO_STUB setting
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.
2025-05-11 12:17:03 +01:00
Zephyron
abcc044bab build: update vulkan headers to 1.4.304 and vcpkg baseline
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
2025-05-11 12:17:03 +01:00
Zephyron
75c7b8a672 fix(sm_controller): Correct QueryPointerBufferSize implementation
- 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.
2025-05-11 12:17:03 +01:00
Zephyron
b3ff92116e fix: Implement SetGestureOutputRanges to handle unimplemented function error
- 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
2025-05-11 12:17:03 +01:00
Zephyron
9ce7c82b18 feat: Improve thermal display and build system
- 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

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.
2025-05-11 12:17:03 +01:00
vampiric_x
58eaee33b5 ui(QT): QT 6.7.3 Implementation 2025-05-11 12:17:03 +01:00
Zephyron
4768701377 feat: make LLVM Demangle optional via CMake flag
Added new CMake option YUZU_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
2025-05-11 12:17:03 +01:00
Zephyron
c3a7aa41d8 vulkan: Fix crashes with bindless texture constant buffer handling
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.
2025-05-11 12:17:03 +01:00
Zephyron
d34cc695df vulkan: Add bindless texture constant buffer support in compute pipeline
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.
2025-05-11 12:17:03 +01:00
Zephyron
455992c2a7 kernel: Implement SystemResourceSize info type for VAMM initialization
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().
2025-05-11 12:17:03 +01:00
Zephyron
4f61ee284f core: Improve device memory and buffer queue handling
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.
2025-05-11 12:17:03 +01:00