diff options
| author | xbzk <xbzk@eden-emu.dev> | 2026-06-27 02:52:13 +0200 |
|---|---|---|
| committer | crueter <crueter@eden-emu.dev> | 2026-06-27 02:52:13 +0200 |
| commit | 09b6b3b71e74a47ae8b8ffe64b1803fc34bae6a2 (patch) | |
| tree | 7949d8522bafb1565b98c3821db07c2b96867f89 /src/video_core/gpu_logging/gpu_logging.cpp | |
| parent | 629ebf1bdee023d3d3ecc96c3276cf3285f8f727 (diff) | |
xbzk/gpu-logging_qt-controls_android-fix (#4018)
5af7771f83-Bugfix: Made gpu_log_level global-only (was per-game switchable). Fixed Android non-determinism where a per-game profile silently overrode the global to Off and trapped GPULogger::Initialize() in a dead state, making shader dumps fail invisibly. Android per-game UI now hides the whole GPU logging block; Qt UI is untouched (global-only anyway).
bf4aabe8ab-Refactor/Cleanup: Removed gpu_logging_enabled master toggle as redundant with gpu_log_level == Off. Introduced GPU::Logging::IsActive() helper, replaced 14 call sites across vk_*.cpp. Refactored LogShaderCompilation() to be text-only and extracted SPIR-V dumping into a standalone GPU::Logging::DumpSpirvShader() free function. No singleton dependency, gated only by gpu_log_shader_dumps. Now gpu_log_level and gpu_log_shader_dumps are fully orthogonal. Cleaned up Android (BooleanSetting, SettingsItem, presenter, 7 locale string files).
865a1c5027-Refactor: Renamed dump_shaders → dump_guest_shaders to disambiguate from gpu_log_shader_dumps. Updated Qt label to "Dump Guest (Maxwell) Shaders" and rewrote the tooltip to mention .ash, the DumpDir/shaders/ location, and nvdisasm.
7cab456fdf-Feature: Added Qt UI control for GPU log level in the Logging session. Added gpu_log_shader_dumps checkbox to the Graphics column right below dump_guest_shaders.
Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4018
Reviewed-by: MaranBr <maranbr@eden-emu.dev>
Diffstat (limited to 'src/video_core/gpu_logging/gpu_logging.cpp')
| -rw-r--r-- | src/video_core/gpu_logging/gpu_logging.cpp | 62 |
1 files changed, 28 insertions, 34 deletions
diff --git a/src/video_core/gpu_logging/gpu_logging.cpp b/src/video_core/gpu_logging/gpu_logging.cpp index 5f5e376e99..72e48e4996 100644 --- a/src/video_core/gpu_logging/gpu_logging.cpp +++ b/src/video_core/gpu_logging/gpu_logging.cpp @@ -4,6 +4,7 @@ #include "video_core/gpu_logging/gpu_logging.h" #include <fmt/format.h> +#include <mutex> #include <thread> #include "common/fs/file.h" @@ -280,13 +281,12 @@ void GPULogger::LogMemoryDeallocation(uintptr_t memory) { } void GPULogger::LogShaderCompilation(const std::string& shader_name, - const std::string& shader_info, - std::span<const u32> spirv_code) { + const std::string& shader_info) { if (!initialized || current_level == LogLevel::Off) { return; } - if (!dump_shaders && current_level < LogLevel::Verbose) { + if (current_level < LogLevel::Verbose) { return; } @@ -294,38 +294,36 @@ void GPULogger::LogShaderCompilation(const std::string& shader_name, std::chrono::steady_clock::now().time_since_epoch()); const auto log_entry = fmt::format("[{}] [Shader] Compiled: {} ({})\n", - FormatTimestamp(timestamp), shader_name, shader_info); + FormatTimestamp(timestamp), shader_name, shader_info); WriteToLog(log_entry); +} - // Dump SPIR-V binary if enabled and we have data - if (dump_shaders && !spirv_code.empty()) { - using namespace Common::FS; - const auto& log_dir = GetEdenPath(EdenPath::LogDir); - const auto shaders_dir = log_dir / "shaders"; +bool IsActive() noexcept { + return Settings::values.gpu_log_level.GetValue() != Settings::GpuLogLevel::Off; +} - // Create directory on first dump - if (!shader_dump_dir_created) { - [[maybe_unused]] const bool created = CreateDir(shaders_dir); - shader_dump_dir_created = true; - } +void DumpSpirvShader(u64 shader_hash, std::span<const u32> spirv_code) { + if (spirv_code.empty()) { + return; + } - // Write SPIR-V binary file - const auto shader_path = shaders_dir / fmt::format("{}.spv", shader_name); - auto shader_file = std::make_unique<Common::FS::IOFile>( - shader_path, FileAccessMode::Write, FileType::BinaryFile); - - if (shader_file->IsOpen()) { - const size_t bytes_to_write = spirv_code.size() * sizeof(u32); - static_cast<void>(shader_file->WriteSpan(spirv_code)); - shader_file->Close(); - - const auto dump_log = fmt::format("[{}] [Shader] Dumped SPIR-V: {} ({} bytes)\n", - FormatTimestamp(timestamp), shader_path.string(), bytes_to_write); - WriteToLog(dump_log); - } else { - LOG_WARNING(Render_Vulkan, "[GPU Logging] Failed to dump shader: {}", shader_path.string()); - } + using namespace Common::FS; + const auto& dump_dir = GetEdenPath(EdenPath::DumpDir); + + // Ensure DumpDir exists once. CreateDir is idempotent, so guarded to skip the syscall. + static std::once_flag dump_dir_flag; + std::call_once(dump_dir_flag, [&dump_dir]() { + [[maybe_unused]] const bool created = CreateDir(dump_dir); + }); + + const auto shader_path = dump_dir / fmt::format("{:016x}_{:016x}.spv", + Settings::GetCurrentProgramID(), shader_hash); + Common::FS::IOFile shader_file(shader_path, FileAccessMode::Write, FileType::BinaryFile); + if (!shader_file.IsOpen()) { + LOG_WARNING(Render_Vulkan, "[Shader Dump] Failed to open {}", shader_path.string()); + return; } + static_cast<void>(shader_file.WriteSpan(spirv_code)); } void GPULogger::LogPipelineStateChange(const std::string& state_info) { @@ -657,10 +655,6 @@ void GPULogger::EnableVulkanCallTracking(bool enabled) { track_vulkan_calls = enabled; } -void GPULogger::EnableShaderDumps(bool enabled) { - dump_shaders = enabled; -} - void GPULogger::EnableMemoryTracking(bool enabled) { track_memory = enabled; } |
