Commit Graph

7072 Commits

Author SHA1 Message Date
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
24fe7ed36e fix(core): Properly release memory when stopping emulation
Signed-off-by: Collecting <collecting@noreply.localhost>
2026-01-09 04:42:27 +00:00
Collecting
b3aefed75b fix(core): Properly release memory when stopping emulation
Signed-off-by: Collecting <collecting@noreply.localhost>
2026-01-09 04:41:54 +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
29e5a963ba revert 1274fcec3b
revert Merge pull request 'feature/texture-component-type-support' (#81) from feature/texture-component-type-support into main

Reviewed-on: https://git.citron-emu.org/Citron/Emulator/pulls/81
2026-01-01 21:33:19 +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
aaa565203c feat(renderer): add BCn unswizzle shader and build improvements
- Add block_linear_unswizzle_3d_bcn.comp compute shader for BCn format support
- Update host shaders CMakeLists to include new shader

This adds a new compute shader for BCn format handling.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-12-31 16:12:36 +10:00
Zephyron
f09951331b feat(video-core): update shader environment to support texture component types
- Add ConvertSamplerComponentType conversion function
- Implement ReadTextureComponentType for Graphics/Compute/File environments
- Update Serialize/Deserialize to include texture_component_types
- Cache component types alongside texture types

This enables proper component type caching and serialization.

Co-Authored-By: ForrestMarkX <forrestmarkx@outlook.com>
Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-12-31 16:10:06 +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
Collecting
a38074c89c revert 989049df07
needs a branch with more work to be done, partial inlining that is invisible to performance (5kb which is nothing), PGO + BOLT optimization path yielding better results regardless
2025-12-28 22:33:24 +00:00
Collecting
989049df07 video_core: Optimize CDmaPusher command execution and logging
Force inlining of the ExecuteCommand function to reduce CPU overhead in the GPU command processing hot path. Additionally, silence debug logging metadata within the function to prevent string-processing logic from blocking compiler optimizations. Includes safe guards for multi-compiler and cross-platform compatibility.

Signed-off-by: Collecting <collecting@noreply.localhost>
2025-12-28 19:09:08 +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
d7a3c585ae fix(dma): allow pipelined transfers to prevent assertion failures
Remove strict assertion on data_transfer_type and allow PIPELINED
transfers (treating them as NON_PIPELINED). Some games like Marvel
Cosmic Invasion use pipelined transfers, causing crashes.

Fixes assertion at maxwell_dma.cpp:76

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-12-13 12:16:07 +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
10daa1e625 fix(texture_cache): handle GPU-modified ignored textures
Fix UNIMPLEMENTED assertion when handling GPU-modified ignored textures
in texture cache. When ignored textures (remapped or same address/size)
have GpuModified flag set, now properly copies data to new image if
formats match, or marks new image as modified otherwise.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-12-13 10:43:22 +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
sylveondeko
3b35c2eeb9 fix(macos): macOS build fixes and MoltenVK improvements
- Switch to Ryujinx MoltenVK build compiled with older Metal SDK to avoid
  MSL 3.2 thread_scope_subgroup bugs that cause text rendering issues
- Exclude Apple from GNU ld.bfd linker option (macOS uses different linker)
- Handle VK_ERROR_FRAGMENTED_POOL in Vulkan descriptor pool allocation
2025-12-12 10:57:23 -05: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
750af88ed9 fix(video): handle invalid texture format in format lookup table
Return default pixel format for uninitialized texture descriptors
(format=0, components=0) instead of asserting. Prevents crashes when
texture cache encounters uninitialized texture data.

Fixes assertion failures in format_lookup_table.cpp:250.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-12-08 19:39:23 +10:00
Zephyron
34800248cc fix(video_core): Replace assertions with warnings in Fermi2D and BSD sockets
- Fermi2D: Log warnings for unsupported operations, layers, depth, and clip
- BSD sockets: Return INVAL for unimplemented getsockopt optnames instead of SUCCESS

Co-authored-by: JPikachu <jpikachu.eden@gmail.com>
Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-12-08 17:03:51 +10: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
7b532d8ec7 fix(host1x): suppress VIC warnings for small dimension mismatches
Only warn when dimension differences exceed 16 pixels to avoid noise
from common codec alignment padding (e.g., 1088 vs 1080).

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-12-07 17:46:37 +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
652a6a56ef feat: add Snapdragon 8 Elite support and implement shader features
- Add device detection for Snapdragon 8 Elite (device ID 0x43052c01)
- Disable shader float controls and 64-bit integer atomics on Qualcomm
  proprietary drivers to work around driver limitations
- Enable native BGR format support on S8 Elite (similar to S8 Gen 2)
- Implement VOTE_vtg instruction for vertex/tessellation/geometry shaders
  with proper single-thread semantics
- Replace stub warnings with detailed comments for FCSM_TR flow test and
  SR_WSCALEFACTOR special registers to document expected behavior

These changes improve compatibility with Qualcomm Snapdragon 8 Elite
devices and reduce spurious warnings by documenting shader features
that are correctly handled as conservative defaults.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-11-04 20:41:13 +10:00
Zephyron
9a5b75db83 video_core: Add mip level clamping for CTGP-DX compatibility
Fixes crashes when games/mods request more than MAX_MIP_LEVELS (14).

Implements defensive clamping at four critical points in the texture
cache (CalculateLevelSizes, CalculateMipLevelOffsets,
CalculateMipLevelSizes, CalculateLevelBytes) to gracefully handle
excessive mip level requests.

When >14 mip levels are requested:
- Logs informative warning (debug builds)
- Clamps to MAX_MIP_LEVELS
- Continues execution safely

This improves upon Eden's solution by adding actual bounds checking
instead of just converting ASSERT to ASSERT_MSG.

Fixes: CTGP-DX (Mario Kart 8 Deluxe mod)

Co-authored-by: JPikachu <jpikachu.eden@gmail.com>
Co-authored-by: JPikachu <jpikachu@eden-emu.dev>
Co-authored-by: MaranBr <maranbr@outlook.com>
Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-11-01 16:22:25 +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
7dea15e642 Revert "fix: Prevent race condition on unmapped memory reads"
This reverts commit 13c60ebcde.

This needs a rework as it caused Shader Corruption On Many Titles
2025-10-16 17:40:53 +10:00
collecting
13c60ebcde fix: Prevent race condition on unmapped memory reads 2025-10-15 04:24:03 +00: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
c2d984610b refine: Lanczos Filter 2025-10-07 20:39:18 +00:00
collecting
f0ccc3108e fix: Copyright 2025-10-06 05:00:49 +00:00
collecting
6e315c09e8 fix: Lanczos Frag 2025-10-06 03:24:35 +00:00
collecting
81630008b6 fix: Lanczos 2025-10-06 02:35:05 +00:00
collecting
41fc8ee272 feat: Add Lanczos 2025-10-06 02:13:55 +00: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
37bebbea10 feat: Add Lanczos 2025-10-06 02:10:57 +00:00
collecting
7feef45cee feat: Add Lanczos 2025-10-06 02:10:20 +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