Commit Graph

1547 Commits

Author SHA1 Message Date
Zephyron
8a606458d6 fix(vulkan): coordinate query cache with render pass boundaries
- Close queries before ending render pass in EndRenderPass

- Close queries before starting new render pass in RequestRenderpass

- Simplify EndPendingOperations to delegate to EndRenderPass

- Fixes validation errors about queries started in wrong render pass context
2026-01-21 18:53:01 +10:00
Zephyron
3295065597 fix(vulkan): clamp image dimensions and copy extents to GPU limits
- Add validation in MakeImage to clamp dimensions to maxImageDimension2D

- Add validation in UploadMemory to clamp buffer-to-image copy extents

- Check framebuffer limits for attachment images

- Fixes crashes when games request textures exceeding GPU capabilities
2026-01-21 18:52:10 +10:00
Zephyron
07180ad265 fix(vulkan): add fallback for unsupported line rasterization modes
- Check for rectangularLines and smoothLines feature support

- Fall back to VK_LINE_RASTERIZATION_MODE_DEFAULT when unavailable

- Fixes validation errors on GPUs without rectangular line support
2026-01-21 18:51:17 +10:00
Zephyron
d344908a8b feat(vulkan): add VK_KHR_buffer_device_address support infrastructure
- Add vkGetBufferDeviceAddress function pointer loading

- Add GetBufferAddress method to Device wrapper with null checks

- Add buffer device address feature detection and AMD GPU disable

- Add VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT to buffer creation

- Store and expose device address in Buffer class

- Update VMA allocator with BUFFER_DEVICE_ADDRESS_BIT flag

- Add IsRectangularLinesSupported/IsSmoothLinesSupported checks

- Disable buffer_device_address on AMD GPUs for stability
2026-01-21 18:50:53 +10:00
Collecting
1a8e019e36 fix(core): Properly release memory when stopping emulation
Signed-off-by: Collecting <collecting@noreply.localhost>
2026-01-09 04:48:01 +00:00
Collecting
e150d1e910 fix(core): Properly release memory when stopping emulation
Signed-off-by: Collecting <collecting@noreply.localhost>
2026-01-09 04:47:18 +00:00
Collecting
e731bb0ba1 fix(core): Properly release memory when stopping emulation
Signed-off-by: Collecting <collecting@noreply.localhost>
2026-01-09 04:41:14 +00:00
Collecting
b15302cf24 fix(renderer): TAA graphical artifacts and pixel noise on AMD hardware
Signed-off-by: Collecting <collecting@noreply.localhost>
2026-01-08 03:10:29 +00:00
Zephyron
efef746299 feat(renderer): add CRT shader filter with configurable effects
Add CRT (Cathode Ray Tube) shader implementation as scaling filter
options (CRT EasyMode and CRT Royale) in the Window Adapting Filter
dropdown. Provides classic TV effects including scanlines, phosphor
masks, curvature distortion, gamma correction, bloom, brightness, and
alpha transparency.

- Add CRTEasyMode and CRTRoyale to ScalingFilter enum
- Implement vulkan_crt_easymode.frag shader with single-pass effects
- Integrate CRT filter into WindowAdaptPass rendering pipeline
- Add configurable CRT parameters to settings with user-friendly labels
- Add UI translations for desktop and Android platforms
- Support CRT push constants in present pipeline

The CRT filter appears alongside other scaling filters like FSR and
FSR 2.0. CRT parameter settings are only active when a CRT filter
is selected.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2026-01-01 18:18:05 +10:00
Zephyron
e166c4aba9 Merge pull request 'video_core: Add ETC2 texture compression format support' (#80) from feature/etc2-texture-compression-support into main
Reviewed-on: https://git.citron-emu.org/Citron/Emulator/pulls/80
2025-12-31 04:57:54 +00:00
Zephyron
c5f35b0712 fix(video_core/vulkan): remove alpha_to_coverage_enabled to fix black square artifacts
Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-12-28 15:32:01 +10:00
Zephyron
855a38ee97 video_core: Add ETC2 texture compression format support
Adds comprehensive support for ETC2 compressed texture formats (ETC2_RGB,
ETC2_RGBA, ETC2_RGB_PTA) in both UNORM and SRGB variants. This addresses
rendering issues in games like Hogwarts Legacy that use these formats.

Changes:
- Add ETC2 texture format enums (TextureFormat::ETC2_RGB_SRGB,
  ETC2_RGBA_SRGB) and component types (SNORM_FORCE_FP16, UNORM_FORCE_FP16)
- Implement format lookup mappings for all ETC2 variants in
  format_lookup_table.cpp
- Add PixelFormat enum values and block size tables for ETC2 formats
- Integrate ETC2 support into Vulkan backend with proper VkFormat mappings
- Add IsOptimalEtc2Supported() device capability check
- Update texture cache to handle ETC2 format conversion when needed
- Add ETC2 format cases to PixelFormat formatter for logging
- Improve shader environment texture handle validation with graceful
  fallback for invalid handles

Fixes assertion failures for texture formats 90 and 99, enabling proper
rendering of ETC2 compressed textures using native Vulkan support.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-12-28 11:57:18 +10:00
Zephyron
b1192de0c4 vulkan: Add memory pressure handling and pipeline eviction
Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-12-16 19:56:27 +10:00
Zephyron
3bcdad1948 WIP: fix(video_core): shadow map square artifacts for Metroid Prime 4
- Force shadow maps to use CLAMP_TO_BORDER with white border color
- Convert CLAMP_TO_EDGE to CLAMP_TO_BORDER for shadow maps
- Improve GL_CLAMP handling for shadow maps on AMD

Issue may persist - likely needs investigation of shadow map rendering
or shader coordinate generation.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-12-13 11:37:53 +10:00
Zephyron
7db12d7e80 video_core: MCI boot fixes and DMA multisized components support
Add workarounds for Marvel Cosmic Invasion boot issues:
- Skip first 2 compute dispatches (xbzk@eden-emu.dev)
- Clamp staging buffers to 2GB to prevent Vulkan failures (xbzk@eden-emu.dev)
- Validate staging buffer sizes before uploads (xbzk@eden-emu.dev)

Also improve DMA engine to support multisized components (1-4 bytes)
instead of hardcoded 4-byte components.

Co-authored-by: xbzk <xbzk@eden-emu.dev>
Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-12-13 09:49:04 +10:00
Zephyron
eaff58aa81 revert d5efa255ee
revert refactor(vulkan): Remove redundant query cache segment notifications

- Remove NotifySegment(true) from PrepareDraw, DrawTexture, and Clear
- Remove NotifySegment(false) from AccelerateDisplay
- Add state tracking for transform feedback to avoid redundant CounterEnable calls
- Only call CounterEnable when transform feedback enable state changes

This prevents double resume/pause operations and state management conflicts.

Co-authored-by: Maufeat <maufeat@eden-emu.dev>
Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-12-08 20:13:09 +00:00
Zephyron
ae1b97a6dd fix(vulkan): Fix viewport handling when transformations are disabled
When viewport_scale_offset_enabled is false, properly set all viewports
using surface_clip dimensions instead of just one. This prevents vertex
explosions caused by invalid or zero-sized viewports.

- Set all viewports (Maxwell::NumViewports) when transformations disabled
- Ensure minimum viewport dimensions (1.0f) to prevent zero-sized viewports
- Respect device viewport limits when setting viewports
- Use proper viewport array instead of single viewport

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-12-08 16:20:12 +10:00
Zephyron
d5efa255ee refactor(vulkan): Remove redundant query cache segment notifications
- Remove NotifySegment(true) from PrepareDraw, DrawTexture, and Clear
- Remove NotifySegment(false) from AccelerateDisplay
- Add state tracking for transform feedback to avoid redundant CounterEnable calls
- Only call CounterEnable when transform feedback enable state changes

This prevents double resume/pause operations and state management conflicts.

Co-authored-by: Maufeat <maufeat@eden-emu.dev>
Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-12-08 16:18:27 +10:00
Zephyron
220c06b5e7 fix(vulkan): Properly handle RGBX render target formats
- Filter blend factors: replace DestAlpha with One and OneMinusDestAlpha
  with Zero for RGBX formats
- Disable alpha component in color write mask for RGBX formats
- Always use actual depth test function instead of defaulting when disabled
- Add FormatHasNoAlpha helper to detect RGBX formats
- Add FilterBlendFactor helper to adjust blend factors for RGBX formats

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-12-08 16:14:36 +10:00
Zephyron
9efe66e5b2 fix(vulkan): implement MirrorOnceClampOGL wrap mode
Adds support for wrap mode 7 (MirrorOnceClampOGL) in the Vulkan renderer's
WrapMode function. This mode is mapped to VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE
as Vulkan doesn't have a direct equivalent to OpenGL's GL_MIRROR_CLAMP.

Fixes assertion failure: "Unimplemented wrap mode=7"

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-12-07 17:43:30 +10:00
Zephyron
45d58d53aa refactor: Clean up setup wizard and improve updater
- Refactor setup_wizard code (remove 100+ lines of unused code)
- Change default update channel from Stable to Nightly
- Fix Windows build detection in updater (skip PGO builds)
- Remove verbose Wayland logging from Vulkan swapchain

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-12-03 11:56:01 +10:00
Zephyron
b85fd5fc73 renderer_vulkan: add Extended Dynamic State user setting
Add configurable EDS levels (Disabled/EDS1/EDS2/EDS3) to allow users to
troubleshoot graphics issues by controlling which Vulkan Extended Dynamic
State features are enabled. Defaults to EDS3 for maximum performance.

Implements setting in both desktop and Android frontends with proper
translations and descriptions.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-10-17 18:52:30 +10:00
Zephyron
ac21b19165 vulkan: fix flickering objects and texture corruption
- Fix critical memory barrier bug: add missing newLayout assignment in write_barrier
- Improve texture swizzling with dynamic block height calculation:
  * RGB565 format: use block_height_log2 = 3
  * Small textures (≤256x256): use block_height_log2 = 3
  * Add validation to prevent corruption from invalid sizes
- Enhance memory barriers with proper stage synchronization:
  * Add VK_ACCESS_SHADER_READ_BIT to source access mask
  * Use correct pipeline stages for transfer operations
  * Ensure proper layout transitions (UNDEFINED → TRANSFER_DST → SHADER_READ_ONLY)
- Fix descriptor set layout: use VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
- Add framebuffer dimension validation (max 8192x8192) to prevent crashes
- Add fallback mechanism for invalid texture data (raw memory copy)

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-10-17 18:44:07 +10:00
Zephyron
99073c8e19 renderer_vulkan: Add conditional rendering control setting
Adds user option to disable Vulkan conditional rendering, which can fix
flickering objects in some games caused by rapidly toggled draw calls.

Changes:
- Add use_conditional_rendering setting (default: enabled)
- Guard conditional rendering functions with setting check using [[unlikely]]
- Early exit in Pause/Resume and Compare functions when disabled

Disabling this in Graphics (Advanced) fixes flickering at cost of performance.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-10-17 16:47:57 +10:00
Zephyron
d8d54c5ccf shader_recompiler: Fix alpha-to-coverage fragment output interface
The Vulkan spec requires fragment shaders to declare an output covering
Location 0, Component 3 (alpha) when alpha-to-coverage is enabled. This change:

- Tracks alpha_to_coverage_enabled through RuntimeInfo from pipeline state
- Forces declaration of frag_color[0] with full RGBA when enabled
- Initializes alpha to 1.0 in shader epilogue if not explicitly written

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-10-17 16:07:35 +10:00
Zephyron
568ab699f6 feat(renderer): Add ScaleFX pixel art upscaling filter
Implements ScaleFX algorithm for pixel art upscaling with edge
preservation. Supports both OpenGL and Vulkan with FP16/FP32
variants for hardware optimization.

ScaleFX is designed to reduce pixelation while preserving sharp
edges, ideal for low-resolution and pixel art games.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-10-11 13:35:19 +10:00
collecting
5785ae746e feat: Add Lanczos 2025-10-06 02:12:38 +00:00
collecting
5fb1a16344 feat: Add Lanczos 2025-10-06 02:11:27 +00:00
collecting
c0c75e43ad feat: Add Lanczos 2025-10-06 02:09:42 +00:00
collecting
0202478a37 feat: Add Lanczos 2025-10-06 02:08:29 +00:00
Zephyron
b903fccf84 Merge branch 'is_wayland_platform' into 'main'
fix: is_wayland_platform flag to prioritize low-latency

See merge request citron/emulator!62
2025-10-01 22:17:07 +10:00
Zephyron
9090a24c2e feat: add Low GPU Accuracy setting for maximum performance
Implements a new "Low" GPU accuracy level that prioritizes performance
over accuracy by aggressively cutting corners in GPU emulation.

Changes:
- Add GpuAccuracy::Low enum and setting infrastructure
- Implement IsGPULevelNormal() helper function
- Skip texture cache checks and query operations
- Use unsafe memory reads for DMA operations
- Disable fence delays and query precision
- Add UI support for desktop (Qt) and Android

Performance optimizations:
- Skips texture cache coherency checks (vk/gl_rasterizer.cpp)
- Non-blocking query synchronization (query_cache.h)
- Unsafe memory operations (dma_pusher.cpp)
- No macro parameter refresh (maxwell_3d.cpp)
- Immediate fence signaling (fence_manager.h)
- Non-precise Vulkan queries (vk_query_cache.cpp)

Ideal for lower-end hardware and users prioritizing FPS over accuracy.
Works on both desktop and Android platforms.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-10-01 21:45:23 +10:00
collecting
ce2909299f fix: is_wayland_platform flag to prioritize low-latency 2025-09-29 04:11:44 +00:00
collecting
90e39d3c3b Remove unused variable 2025-09-24 04:51:15 +00:00
collecting
bc6a169829 static_cast 2025-09-23 01:10:58 +00:00
Zephyron
19cf31b215 feat: add Temporal Anti-Aliasing (TAA) support for OpenGL and Vulkan
- Add TAA option to AntiAliasing enum in settings
- Implement TAA shaders for both OpenGL (GLSL) and Vulkan (SPIR-V)
- Add OpenGL TAA class with framebuffer management and temporal blending
- Add Vulkan TAA class following existing AntiAliasPass architecture
- Integrate TAA into OpenGL and Vulkan rendering pipelines
- Add UI translations and Android string resources for TAA option
- Implement Halton sequence jittering for temporal sampling
- Add motion vector validation and neighborhood clamping to reduce ghosting
- Configure aggressive temporal blending to minimize visual artifacts
- Add proper descriptor set management for Vulkan TAA implementation

The TAA implementation provides high-quality anti-aliasing by combining
information from multiple frames with per-pixel jittering, resulting
in smoother edges and reduced aliasing artifacts while maintaining
good performance and temporal stability.

Fixes: Black screen issues with proper descriptor set bindings
Fixes: Ghosting artifacts with improved temporal blending parameters
Fixes: Jitter visibility with reduced jitter intensity (50% scaling)
Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-09-21 10:34:19 +10:00
Zephyron
94119302ec feat: Add OpenGL ZBC clear support and refactor ZBC management
Moved ZBCManager to `video_core/zbc_manager.cpp/h` for modularity. Added
`gl_zbc_clear.cpp/h` for efficient OpenGL color, depth, and stencil clears.
Updated `RasterizerOpenGL::Clear` to use ZBC with fallback. Added stencil
type validation. Fixed color mask and logging. Updated `CMakeLists.txt`.
Enhances performance and code organization.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-09-14 20:28:39 +10:00
Zephyron
6e6b2f438e feat: add High-End and Insane VRAM modes with leak prevention
- Add HighEnd and Insane VRAM usage modes for RTX 4090/4080+ users
- Implement VRAM limits: HighEnd (12GB), Insane (22GB) with scaling
- Optimize buffer allocation with larger chunks for high-end GPUs
- Add VRAM leak detection and aggressive cleanup for Insane mode
- Increase shader compilation buffer sizes for better performance
- Add VRAM monitoring functions to Vulkan rasterizer
- Implement memory usage tracking for staging buffers

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-09-14 16:05:31 +10:00
Zephyron
50afaefffb feat: Enhanced Nintendo SDK crash detection and recovery system
* Enhanced ARM interface backtrace logging with Nintendo SDK crash detection
  - Detects nnSdk module crashes and initialization-time failures
  - Provides detailed recovery suggestions and logging
  - Identifies recoverable vs non-recoverable crashes

* Improved physical core crash handling
  - Enhanced prefetch abort and data abort recovery
  - Continues execution for Nintendo SDK crashes instead of suspending
  - Better logging for crash analysis and debugging

* Expanded SVC exception handling
  - Added Nintendo SDK-specific crash recovery logic
  - Enhanced general crash recovery for low-address and assertion failures
  - Improved UE4 crash handling integration

* Updated Horizon OS version to 20.4.0
  - Updated HOS_VERSION_MINOR from 1 to 4
  - Updated HOS_VERSION_MICRO from 5 to 0
  - Updated version hash and display strings accordingly

* Fixed Vulkan turbo mode performance metrics
  - Added proper type casting for execution time comparisons
  - Prevents potential integer overflow issues

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-09-05 14:57:58 +10:00
Zephyron
ae46d4629f Merge branch 'vulkan-turbo-mode-optimization' into 'master'
vulkan: Add adaptive timeout and auto-disable to turbo mode

See merge request citron/rewrite!56
2025-08-26 08:33:43 +00:00
Zephyron
c851521a6b vulkan: Add adaptive timeout and auto-disable to turbo mode
- Implement adaptive timeout system that adjusts based on GPU performance
- Add auto-disable after 10 cycles of persistent timeouts
- Reduce workload (32x32 dispatch, 1MB buffer) for better compatibility
- Add performance monitoring and runtime control
- Fixes persistent timeout warnings by gracefully degrading when GPU is busy

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-08-26 18:30:58 +10:00
Zephyron
4cdc602f1e vulkan: Optimize descriptor update queue performance
- Increase frame count (8→12) and payload size (0x20000→0x40000)
- Add batch operations and memory management helpers
- Improve overflow handling with statistics tracking
- Create specialized classes for different workload types
- Implement smart pre-allocation and memory optimization
- Add comprehensive performance monitoring

Improves performance for Switch titles with complex shaders under Vulkan.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-08-26 16:15:10 +10:00
Zephyron
e27fc65d11 feat: remove frame generation options from all platforms
Frame generation was marked as WIP and not ready for production use.
This commit removes all frame generation related code and UI elements
to prevent users from enabling an incomplete feature.

Changes:
- Remove frame generation settings from Android UI (Kotlin/XML)
- Remove frame generation settings from Desktop UI (Qt/C++)
- Remove frame generation enums and settings from core (C++)
- Remove frame generation Vulkan renderer implementation
- Remove frame generation shader files
- Update CMake build configuration

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-08-17 16:09:05 +10:00
Zephyron
06f13f3cb1 android: Add shader building overlay with performance graph
- Add new settings for shader building overlay and performance graph
- Create ShaderBuildingOverlayView with animated shader building indicator
- Implement JNI bridge to get shader building count from core
- Add performance metrics display (FPS, frametime, emulation speed)
- Include real-time frametime graph with min/avg/max statistics
- Add menu options to toggle overlay and graph independently
- Integrate with existing overlay system in EmulationFragment
- Optimize Vulkan pipeline cache loading with pre-reservation
- Improve async shader building to reduce main thread blocking

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-08-17 15:48:06 +10:00
Zephyron
117c467ff3 feat: Add frame generation and enhance UE4 game compatibility
- Add frame generation settings (enabled/disabled, interpolation/extrapolation modes)
- Add frame skipping settings (enabled/disabled, adaptive/fixed modes)
- Implement frame skipping logic with adaptive and fixed modes
- Enhance UE4 crash handling with recovery mechanisms
- Add support for signed and float 32-bit image formats across shader backends
- Update Vulkan Validation Layers to v1.4.321.0
- Fix duplicate frame skipping options in Qt UI
- Improve memory handling for UE4 games (Hogwarts Legacy compatibility)
- Add enhanced bindless texture handling with fallback approach
- Update Android build configuration and dependencies

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-08-05 19:32:28 +10:00
Zephyron
568999fd59 feat: Improve FSR2 UI with dropdown quality mode and conditional FSR sharpness
- Convert FSR2 quality mode from number input to dropdown with 4 options
- Disable and grey out FSR sharpness slider when FSR2 is selected
- Add proper enum-based settings for FSR2 quality modes
- Update both Vulkan and OpenGL FSR2 implementations
- Connect UI state changes automatically

Provides better UX by using appropriate controls and preventing confusion
between FSR 1.0 and FSR 2.0 sharpening options.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-07-29 15:49:05 +10:00
Zephyron
3b8da3d80a feat: Add FSR 2.0 scaling filter option
- Add FSR2 to ScalingFilter enum alongside existing FSR
- Implement FSR2 classes for both Vulkan and OpenGL renderers
- Add fsr2_quality_mode setting with 4 quality levels (Quality, Balanced, Performance, Ultra Performance)
- Integrate FSR2 into present pipeline for both renderers
- Add UI support for FSR2 option in scaling filter dropdown
- Add FSR2 quality mode setting with dropdown selection
- Update translations and Android strings for new options
- Default to Performance mode for optimal balance

This provides users with FSR 2.0 as a scaling option, offering different
quality/performance characteristics compared to FSR 1.0. The implementation
uses quality-based sharpening values and integrates seamlessly with the
existing rendering pipeline.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-07-29 15:21:36 +10:00
Boss.sfc
0fb39034c1 fix: Resolve compilation issues with fmt library and formatters
Fix multiple compilation errors preventing successful build:

* Add const qualifier to custom fmt formatter functions across codebase
  - Updated formatters in logging, shader recompiler, texture cache, and other modules
  - Ensures compatibility with newer fmt library versions

* Add missing fmt/ranges.h includes for fmt::join usage
  - Fixed fmt::join calls in Vulkan renderer, GDB stub, NFC service, and main window
  - Resolves "no member named 'join' in namespace 'fmt'" errors

* Exclude unsupported platforms from Boost.Process usage in debugger
  - Extended conditional compilation to avoid Boost.Process where unavailable

* Fix type casting issues in AOC service manager
  - Resolved std::min type mismatch with explicit casting
2025-07-16 11:11:33 +07:00
Zephyron
5e16e20427 chore: update project branding to Citron
Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-05-06 16:08:59 +10:00
liamwhite
6948ac8c16 general: workarounds for SMMU syncing issues (#12749) 2024-02-27 15:42:15 +01:00