summaryrefslogtreecommitdiff
path: root/src/video_core
AgeCommit message (Collapse)Author
2025-06-17video_core: Rework VAAPI codeMike Lothian
Use public ffmpeg headers only Fall back gracefully to software decoding when codec is unsupported on VAAPI e.g. VP8
2025-06-15Update FFmpeg to 7.1.1, libvpx to 1.13.1 and libx264 to c24e06c on Android ↵MaranBr
(#187) This updates FFmpeg to 7.1.1, libvpx to 1.13.1 and libx264 to c24e06c on Android. Co-authored-by: MaranBr <maranbr@outlook.com> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/187 Reviewed-by: crueter <crueter@noreply.localhost> Co-authored-by: MaranBr <maranbr@noreply.localhost> Co-committed-by: MaranBr <maranbr@noreply.localhost>
2025-06-15Fix video decoding on newer versions of FFmpeg (#155)MaranBr
Fixes video decoding issues and enables compatibility with newer versions of FFmpeg. Co-authored-by: MaranBr <maranbr@outlook.com> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/155
2025-05-12fix(renderer_vulkan): resolve asynchronous presentation crashes and ↵Zephyron
compilation errors Fix multiple issues in the Vulkan asynchronous presentation implementation: - Convert regular mutexes to timed_mutex for timeout support - Use condition_variable_any for compatibility with timed_mutex - Fix thread synchronization with proper locking and error handling - Add VkResultToString helper to replace missing ToString function - Implement better error recovery with recreation attempt limits - Add comprehensive logging for better troubleshooting These changes make the asynchronous presentation feature more robust and less prone to deadlocks, while keeping it disabled by default since it may still cause instability in some games. Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-05-12video_core: Add fallback handling for failed storage buffer lookupsZephyron
Implements a more robust error handling approach when storage buffer lookups fail in the buffer cache. Instead of returning a null binding, the code now: - Provides a fallback buffer with safe default values - Implements warning rate limiting to prevent log spam - Tracks warning counts per cbuf_index - Logs detailed debug information periodically This change helps prevent potential crashes when storage buffer lookups fail while still maintaining visibility into the issue through strategic logging. The fallback mechanism uses a safe static address and a reasonable buffer size (16KB) to handle cases where the normal GPU to CPU address translation fails. Also updates copyright headers to include citron Emulator Project. Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-05-12video_core: Improve texture cache memory management to prevent leaksZephyron
Implement several improvements to the texture cache memory management system to address memory leaks that occur in memory-intensive games like TOTK (Title ID 0100F2C0115B6000). These changes prevent the gradual memory increase that eventually leads to crashes or undefined behavior. Key improvements: - Enhance garbage collection with more aggressive cleanup thresholds - Add emergency resource cleanup for persistent high memory usage - Improve DeleteImage to ensure proper resource deallocation - Make DelayedDestructionRing thread-safe with proper mutex protection - Track consecutive high-memory frames to detect potential leaks - Add emergency cleanup mechanism for extreme memory pressure situations - Use proper type casting in std::max to fix compilation errors This should significantly improve stability during extended gameplay sessions with memory-intensive titles. Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-05-12refactor(vulkan): remove depth buffer workarounds and excessive loggingZephyron
- Remove special handling for reversed depth scenarios that were added for Civilization 7 - Remove excessive logging in Vulkan renderer - Update Discord client ID
2025-05-12renderer/friend: Improve reversed depth handling and Friend serviceZephyron
This commit makes two significant improvements: 1. Vulkan renderer: - Detect and properly handle reversed depth buffers (clear_depth < 0.5) - Force depth write enable when needed with reversed depth - Use GREATER_OR_EQUAL comparison for reversed depth scenarios - Fix transparency issues in games like Civilization 7 by adjusting blend factors - Add detailed logging for depth buffer operations 2. Friend service: - Implement previously stubbed functions including EnsureFriendListAvailable and EnsureBlockedUserListAvailable - Add proper event signaling to prevent games from hanging - Implement Cancel function for improved compatibility - Update copyright notice for the Citron project These changes improve compatibility with modern games using reversed depth buffers and prevent hangs in titles that rely on Friend service functionality. Co-authored-by: m33ts4k0z <m33ts4k0z@citron-emu.org> Co-committed-by: m33ts4k0z <m33ts4k0z@citron-emu.org> Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-05-12vulkan: Implement AMD driver workaround for logic operationsZephyron
- Added conditional check for AMD graphics drivers - Automatically disable logic operations when float vertex attributes are present to work around driver quirks - Maintain original logic op state to preserve emulator behavior - Prepare dynamic state management infrastructure for future OpenGL implementation changes OpenGL implementation will follow in subsequent commits. Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-05-12vulkan: Improve memory allocation robustnessZephyron
Enhances the Vulkan memory allocator with better OOM handling and memory alignment: * Add memory recovery by cleaning up empty allocations before failing * Implement proper fallback to non-device-local memory * Simplify memory alignment handling for different vendors * Add better error logging for allocation failures * Add IsEmpty() helper to track unused allocations * Fix alignment requirements for Adreno (4KB) vs other vendors These changes improve the robustness of memory allocation, particularly in low-memory situations, and streamline vendor-specific alignment requirements.
2025-05-12texture_cache: Add equality operators for ImageInfo and ImageViewInfoZephyron
- Add operator== to ImageInfo and ImageViewInfo classes to enable direct equality comparisons. The implementations use std::tie to perform member-wise comparisons of all relevant fields in a safe and efficient manner. This allows for easier comparison of texture cache entries and view information, which can be useful for cache management and debugging.
2025-05-12build: upgrade fmt and SDL2Zephyron
Update fmt library to version 11.0.2 and make necessary adjustments: - Replace fmt/format.h includes with fmt/ranges.h - Add const qualifiers to formatter::format functions - Update CMake to require fmt version 11 Additional dependency updates: - Update SDL2 bundled version from 2.28.2 to 2.32.0 - Update catch2 to version 3.7.1 - Update vcpkg baseline to ca846b21276c9a3171074ac8d2b4f6516894a7d0
2025-05-11vulkan: Rename resolve_image to resolve_image_holderZephyron
Fix Android compilation with latest NDK (28.0.13004108) and Java JDK 21 by renaming the resolve_image variable to resolve_image_holder to avoid potential naming conflicts. This change helps maintain compatibility with the updated build toolchain while keeping the core functionality intact. The change affects the MSAA image copy operation in the Vulkan texture cache implementation.
2025-05-11vulkan: Add Samsung driver workaroundsZephyron
Add workarounds for Samsung Xclipse GPUs: - Disable extendedDynamicState3ColorBlendEquation as it is broken in Samsung drivers, similar to AMD drivers - Add Samsung's proprietary driver to the validated driver list for clock boosting - Fix log message to indicate both AMD and Samsung drivers have broken color blend equation support Remove stray logical OR operator from validated_driver condition.
2025-05-11video_core/vulkan: Improve texture format conversion handlingZephyron
Refactors and improves the texture format conversion system in the Vulkan renderer: - Adds proper sRGB to linear conversion for depth formats - Improves shader accuracy for ABGR8 SRGB to D24S8 conversion - Adds gamma correction and proper depth range clamping - Moves GetSupportedFormat implementation to header - Cleans up format conversion switch statement - Removes redundant format conversion paths The changes improve accuracy when converting between color and depth formats, particularly for sRGB sources. The shader improvements ensure proper gamma correction and depth range handling. Technical changes: - Improves sRGB to linear conversion in fragment shader - Adds proper depth value clamping - Consolidates format conversion logic - Removes duplicate GetSupportedFormat implementation
2025-05-11vulkan: Implement native MSAA resolve in texture cacheZephyron
Implements hardware-accelerated MSAA resolve functionality in the Vulkan texture cache instead of relying on compute shaders. This change: - Adds proper MSAA to non-MSAA image copy support using VkResolveImage - Creates temporary resolve images with appropriate memory allocation - Handles format compatibility checks with proper fallback to compute - Manages image layout transitions and memory barriers - Preserves existing compute shader fallback for unsupported formats The implementation follows Vulkan best practices for MSAA resolve operations and should provide better performance for supported formats.
2025-05-11vulkan: Add 4KB memory alignment for AMD and Qualcomm driversZephyron
Adds special handling for memory allocation size on AMD and Qualcomm (Adreno) drivers by aligning allocations to 4KB boundaries. This fixes potential memory allocation issues on these drivers where unaligned allocations may fail or cause undefined behavior. Affected drivers: - AMD Proprietary (AMDVLK) - AMD Open Source (RADV) - Qualcomm Proprietary (Adreno)
2025-05-11video_core: Add new shader format conversion pipelinesZephyron
Adds several new shader-based format conversion pipelines to support additional texture formats and operations: - RGBA8 to BGRA8 conversion - YUV420/RGB conversions - BC7 to RGBA8 decompression - ASTC HDR to RGBA16F decompression - RGBA16F to RGBA8 conversion - Temporal dithering - Dynamic resolution scaling Updates the texture cache runtime to handle these new conversion paths and adds helper functions to check format compatibility for dithering and scaling operations. The changes include: - New shader files and CMake entries - Additional conversion pipeline setup in BlitImageHelper - Extended format conversion logic in TextureCacheRuntime - New format compatibility check helpers
2025-05-11video_core: Add sRGB to D24S8 depth-stencil conversion supportZephyron
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-11vulkan: Relax VRAM allocation limits for better stabilityZephyron
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-11android: Fix compilation by adding missing log.h includeZephyron
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-11buffer_cache: Simplify storage buffer binding logicZephyron
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-11service/nvdrv: Relax GPU validation and improve error handlingZephyron
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-11service/nvdrv: Implement stubbed GPU functionsZephyron
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-11arm/video: Fix shader extension and exception handlingZephyron
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-11vulkan: Fix crashes with bindless texture constant buffer handlingZephyron
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-11vulkan: Add bindless texture constant buffer support in compute pipelineZephyron
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-11buffer_cache: Fix storage buffer memory validation and size detectionZephyron
Fixes the StorageBufferBinding function to properly handle memory validation and size detection. Key changes include: - Fix ReadBlock usage to properly handle void return values - Implement safer memory validation using byte-level reads - Improve size detection logic for storage buffers - Fix NVN buffer size reading - Add proper bounds checking for device memory addresses - Add better error logging for invalid conditions This addresses the "Failed to find storage buffer for cbuf index 0" errors by implementing more robust memory validation and size detection. The changes ensure proper handling of invalid memory addresses and prevent crashes from accessing out-of-bounds memory.
2025-05-11video_core: Enforce safe memory reads for compute dispatchZephyron
- Modify DmaPusher to use safe memory reads when handling compute operations at High GPU accuracy - Prevent potential memory corruption issues that could lead to invalid dispatch parameters - Previously, unsafe reads could result in corrupted launch_description data in KeplerCompute::ProcessLaunch, causing invalid vkCmdDispatch calls - By enforcing safe reads specifically for compute operations, we maintain performance for other GPU tasks while ensuring compute dispatch stability This change requires >= High GPU accuracy level to take effect.
2024-12-20perf(VideoCore): Refactor DispatchIndirectEmulationEnjoyer
- Added automatic safe or unsafe processing for better emulation accuracy. ref: https://git.citron-emu.org/Citron/Citron/commit/8cae0310e3aece0135e8c8e82e5fbeb379560b78
2024-12-20dma_pusher.cpp: remove now unused variable that breaks the android build (#76)anon
Completes http://vub63vv26q6v27xzv2dtcd25xumubshogm67yrpaz2rculqxs7jlfqad.onion/torzu-emu/torzu/pulls/71 Discovered when building android version on debian via command line. Reviewed-on: http://vub63vv26q6v27xzv2dtcd25xumubshogm67yrpaz2rculqxs7jlfqad.onion/torzu-emu/torzu/pulls/76 Co-authored-by: anon <anon@noreply.localhost> Co-committed-by: anon <anon@noreply.localhost>
2024-12-20externals: update fmt to 11.0.2 and vcpkg to 2024.09.30 (#68)lui
Updated to fmt 11 with the required source changes for it to work. Also updated vcpkg for this, and as an added benefit it fixes the `Unable to find a valid Visual Studio instance` error, and the VS 2019 build tools are no longer required. Just make sure to delete the existing downloaded vcpkg tool and binaries in `externals/vcpkg` if you have compiled before, or else it will continue to use the old version and give the error. Reviewed-on: http://vub63vv26q6v27xzv2dtcd25xumubshogm67yrpaz2rculqxs7jlfqad.onion/torzu-emu/torzu/pulls/68 Co-authored-by: lui <lui@vub63vv26q6v27xzv2dtcd25xumubshogm67yrpaz2rculqxs7jlfqad.onion> Co-committed-by: lui <lui@vub63vv26q6v27xzv2dtcd25xumubshogm67yrpaz2rculqxs7jlfqad.onion>
2024-12-20kepler_compute: use safe memory readcow
If unsafe read is done there can sometimes be corrupt data in the KeplerCompute::ProcessLaunch qmd structure. Fixes GPU crashes in 'Princess Peach: Showtime!' when using vulkan renderer. Requires using "Accuracy Level High" (crashes will still happen if using "Normal"). Tested on Radeon 6750XT, Linux 6.11.2, Mesa 24.2.5 (RADV driver). Unsafe read was introduced in 115792158d3ac4ca746d1775f2381e8f8dd18582 "VideoCore: Implement DispatchIndirect" How did I debug this: - Used VK_LAYER_KHRONOS_validation which found invalid vkCmdDispatch (along with a lot of other noise!) - Instrumented all calls to vulkan Dispatch(), set breakpoint when grid_dim_x > 1024 (an obviously invalid value). Found dispatch came from RasterizerVulkan::DispatchCompute(). - Commented out DispatchCompute() entirely, game runs with no crashes but some graphics effects are missing. - Keep going one layer up, observe corrupted `launch_description` in KeplerCompute::ProcessLaunch() - Attempted safe ReadBlock (`which = VideoCommon::CacheType::All`) instead of ReadBlockUnsafe in KeplerCompute::ProcessLaunch(), did not help - Go one layer up to DmaPusher. Switch to safe_process(). No more corrupt `launch_description`.
2024-12-20mark format functions as constSamuliak
2024-12-20renderer: add area sampling scaling method (#57)lui
Adds Area Sampling to the list of scaling options. Works well to achieve a high-quality, smooth super-sampling effect. Dolphin has had this for a while, and now Ryujinx has recently added it too, so I decided to port it. Not sure if adding the extra uniform to the OpenGL WindowAdaptPass was a good idea or not, or if using the push constants under Vulkan was either, but I wasn't sure about the best way to get the window size for use in the shader, and other scaling methods still work fine. Implementation seems to work fine under both Vulkan and OpenGL, but might still need some minor tweaks to the shader. Should definitely do some testing before merging, I have tested on an Nvidia RTX 3080 under Windows. Adapted from these two PRs: https://github.com/Ryujinx/Ryujinx/pull/7304 https://github.com/dolphin-emu/dolphin/pull/11999 Reviewed-on: http://vub63vv26q6v27xzv2dtcd25xumubshogm67yrpaz2rculqxs7jlfqad.onion/torzu-emu/torzu/pulls/57 Co-authored-by: lui <lui@vub63vv26q6v27xzv2dtcd25xumubshogm67yrpaz2rculqxs7jlfqad.onion> Co-committed-by: lui <lui@vub63vv26q6v27xzv2dtcd25xumubshogm67yrpaz2rculqxs7jlfqad.onion>
2024-12-20Using reserve() for optimization inserts, marked unused pair items and minor ↵Herman Semenov
code refactor
2024-12-20Add option to only optimize SPIRV during load (#13)echosys
Adds a new option "On Load" to the "Optimize SPIRV output" option that turns on optimizations during the loading of the shader cache from disk, but turns it off after that. The previous checkbox states have been named "Never" for unchecked and "Always" for checked. The idea is that once the shader cache has most of the shaders in a game cached they can be optimized during initial game startup (where a performance hit matters less) and the few shaders that get compiled during runtime are not optimized to reduce performance hits. Most of the commit is adding the setting to the Android app, the main logic is in the `gl_shader_cache.cpp` and `vk_pipeline_cache.cpp` files. Reviewed-on: http://vub63vv26q6v27xzv2dtcd25xumubshogm67yrpaz2rculqxs7jlfqad.onion/torzu-emu/torzu/pulls/13 Co-authored-by: echosys <echosys@noreply.localhost> Co-committed-by: echosys <echosys@noreply.localhost>
2024-12-20Implemented LogicOp fixJarrod Norwell
2024-12-20Use fmt 11.0.0Mike Lothian
2024-12-20Disabled problematic MSVC warning-to-errorsspectranator
2024-12-20Optionally optimize generated SPIRV with spirv-opt (#10)darktux
Reviewed-on: http://y2nlvhmmk5jnsvechppxnbyzmmv3vbl7dvzn6ltwcdbpgxixp3clkgqd.onion/darktux/torzu/pulls/10 Co-authored-by: darktux <darktux@y2nlvhmmk5jnsvechppxnbyzmmv3vbl7dvzn6ltwcdbpgxixp3clkgqd.onion> Co-committed-by: darktux <darktux@y2nlvhmmk5jnsvechppxnbyzmmv3vbl7dvzn6ltwcdbpgxixp3clkgqd.onion>
2024-12-20Removed telemetry and anonymized SCM (git) stringsdarktux
2024-12-20Fix GCC builds with Debug build typedarktux
When compiling with -DCMAKE_BUILD_TYPE=Debug, GCC would (correctly) fail to compile intrinsics in stb and host1x due to lack of optimizations. Sadly, the compilation error given is bogus and Clang completing the builds without issues does raise some eyebrows. Therefore, force optimizations for the offending files under GCC when creating Debug builds. Signed-off-by: voidanix <voidanix@keyedlimepie.org>
2024-12-20Vulkan validation error fix.Lucas Clemente Vella
Different image usage flags between image creation and image view creation.
2024-12-20Radeon gpu profiler detection supportAlessio
2024-12-20fix: Fixes compiling to non-Apple OSes on arm64Exverge
2024-12-20Macos moltenvk headersNick Majkic
2024-12-20Clean up CMAKE files for mac and xcode buildingNick Majkic
2024-12-20Better surface loggingAlessio
2024-12-20fix for amd video playback (green videos)Alessio