diff options
Diffstat (limited to 'src/video_core/renderer_vulkan/renderer_vulkan.cpp')
| -rw-r--r-- | src/video_core/renderer_vulkan/renderer_vulkan.cpp | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/video_core/renderer_vulkan/renderer_vulkan.cpp b/src/video_core/renderer_vulkan/renderer_vulkan.cpp index 4bd4917fdf..7ef1998263 100644 --- a/src/video_core/renderer_vulkan/renderer_vulkan.cpp +++ b/src/video_core/renderer_vulkan/renderer_vulkan.cpp @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project +// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #include <algorithm> @@ -122,12 +123,15 @@ RendererVulkan::RendererVulkan(Core::Frontend::EmuWindow& emu_window, PresentFiltersForAppletCapture), rasterizer(render_window, gpu, device_memory, device, memory_allocator, state_tracker, scheduler), + texture_manager(device, memory_allocator), + shader_manager(device), applet_frame() { if (Settings::values.renderer_force_max_clock.GetValue() && device.ShouldBoostClocks()) { turbo_mode.emplace(instance, dld); scheduler.RegisterOnSubmit([this] { turbo_mode->QueueSubmitted(); }); } Report(); + InitializePlatformSpecific(); } catch (const vk::Exception& exception) { LOG_ERROR(Render_Vulkan, "Vulkan initialization failed with error: {}", exception.what()); throw std::runtime_error{fmt::format("Vulkan initialization error {}", exception.what())}; @@ -403,4 +407,58 @@ void RendererVulkan::RenderAppletCaptureLayer( CaptureFormat); } +bool RendererVulkan::HandleVulkanError(VkResult result, const std::string& operation) { + if (result == VK_SUCCESS) { + return true; + } + + if (result == VK_ERROR_DEVICE_LOST) { + LOG_CRITICAL(Render_Vulkan, "Vulkan device lost during {}", operation); + RecoverFromError(); + return false; + } + + if (result == VK_ERROR_OUT_OF_DEVICE_MEMORY || result == VK_ERROR_OUT_OF_HOST_MEMORY) { + LOG_CRITICAL(Render_Vulkan, "Vulkan out of memory during {}", operation); + // Potential recovery: clear caches, reduce workload + texture_manager.CleanupTextureCache(); + return false; + } + + LOG_ERROR(Render_Vulkan, "Vulkan error during {}: {}", operation, result); + return false; +} + +void RendererVulkan::RecoverFromError() { + LOG_INFO(Render_Vulkan, "Attempting to recover from Vulkan error"); + + // Wait for device to finish operations + void(device.GetLogical().WaitIdle()); + + // Clean up resources that might be causing problems + texture_manager.CleanupTextureCache(); + + // Reset command buffers and pipelines + scheduler.Flush(); + + LOG_INFO(Render_Vulkan, "Recovery attempt completed"); +} + +void RendererVulkan::InitializePlatformSpecific() { + LOG_INFO(Render_Vulkan, "Initializing platform-specific Vulkan components"); + +#if defined(_WIN32) || defined(_WIN64) + LOG_INFO(Render_Vulkan, "Initializing Vulkan for Windows"); + // Windows-specific initialization +#elif defined(__linux__) + LOG_INFO(Render_Vulkan, "Initializing Vulkan for Linux"); + // Linux-specific initialization +#elif defined(__ANDROID__) + LOG_INFO(Render_Vulkan, "Initializing Vulkan for Android"); + // Android-specific initialization +#else + LOG_INFO(Render_Vulkan, "Platform-specific Vulkan initialization not implemented for this platform"); +#endif +} + } // namespace Vulkan |
