From e5f6d9320f5ccefa8160bd4a27d156285ae8b536 Mon Sep 17 00:00:00 2001 From: Ryan Meredith Date: Fri, 24 Jan 2020 03:29:38 -0500 Subject: [PATCH] Add Dolphin version and current video backend to shader compilation logs --- Source/Core/VideoBackends/D3DCommon/Shader.cpp | 9 +++++++-- .../Core/VideoBackends/OGL/ProgramShaderCache.cpp | 14 ++++++++++---- .../Core/VideoBackends/Vulkan/ShaderCompiler.cpp | 10 +++++++--- Source/Core/VideoCommon/VideoBackendBase.cpp | 9 +++++++++ Source/Core/VideoCommon/VideoBackendBase.h | 2 ++ 5 files changed, 35 insertions(+), 9 deletions(-) diff --git a/Source/Core/VideoBackends/D3DCommon/Shader.cpp b/Source/Core/VideoBackends/D3DCommon/Shader.cpp index 3194fd8aa4..4535fae6ef 100644 --- a/Source/Core/VideoBackends/D3DCommon/Shader.cpp +++ b/Source/Core/VideoBackends/D3DCommon/Shader.cpp @@ -10,8 +10,11 @@ #include "Common/Logging/Log.h" #include "Common/MsgHandler.h" #include "Common/StringUtil.h" +#include "Common/Version.h" #include "VideoBackends/D3DCommon/Shader.h" + +#include "VideoCommon/VideoBackendBase.h" #include "VideoCommon/VideoConfig.h" namespace D3DCommon @@ -105,13 +108,15 @@ std::optional Shader::CompileShader(D3D_FEATURE_LEVEL featur if (FAILED(hr)) { static int num_failures = 0; - std::string filename = StringFromFormat( - "%sbad_%s_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), target, num_failures++); + std::string filename = VideoBackendBase::BadShaderFilename(target, num_failures++); std::ofstream file; File::OpenFStream(file, filename, std::ios_base::out); file.write(source.data(), source.size()); file << "\n"; file.write(static_cast(errors->GetBufferPointer()), errors->GetBufferSize()); + file << "\n"; + file << "Dolphin Version: " + Common::scm_rev_str + "\n"; + file << "Video Backend: " + g_video_backend->GetDisplayName(); file.close(); PanicAlert("Failed to compile %s:\nDebug info (%s):\n%s", filename.c_str(), target, diff --git a/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp b/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp index 144d35e5a5..52523e59c5 100644 --- a/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp +++ b/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp @@ -17,6 +17,7 @@ #include "Common/Logging/Log.h" #include "Common/MsgHandler.h" #include "Common/StringUtil.h" +#include "Common/Version.h" #include "Core/ConfigManager.h" @@ -31,6 +32,7 @@ #include "VideoCommon/Statistics.h" #include "VideoCommon/VertexLoaderManager.h" #include "VideoCommon/VertexShaderManager.h" +#include "VideoCommon/VideoBackendBase.h" namespace OGL { @@ -356,11 +358,13 @@ bool ProgramShaderCache::CheckShaderCompileResult(GLuint id, GLenum type, std::s { ERROR_LOG(VIDEO, "%s failed compilation:\n%s", prefix, info_log.c_str()); - std::string filename = StringFromFormat( - "%sbad_%s_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), prefix, num_failures++); + std::string filename = VideoBackendBase::BadShaderFilename(prefix, num_failures++); std::ofstream file; File::OpenFStream(file, filename, std::ios_base::out); file << s_glsl_header << code << info_log; + file << "\n"; + file << "Dolphin Version: " + Common::scm_rev_str + "\n"; + file << "Video Backend: " + g_video_backend->GetDisplayName(); file.close(); PanicAlert("Failed to compile %s shader: %s\n" @@ -392,8 +396,7 @@ bool ProgramShaderCache::CheckProgramLinkResult(GLuint id, std::string_view vcod if (linkStatus != GL_TRUE) { ERROR_LOG(VIDEO, "Program failed linking:\n%s", info_log.c_str()); - std::string filename = - StringFromFormat("%sbad_p_%d.txt", File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++); + std::string filename = VideoBackendBase::BadShaderFilename("p", num_failures++); std::ofstream file; File::OpenFStream(file, filename, std::ios_base::out); if (!vcode.empty()) @@ -404,6 +407,9 @@ bool ProgramShaderCache::CheckProgramLinkResult(GLuint id, std::string_view vcod file << s_glsl_header << pcode << '\n'; file << info_log; + file << "\n"; + file << "Dolphin Version: " + Common::scm_rev_str + "\n"; + file << "Video Backend: " + g_video_backend->GetDisplayName(); file.close(); PanicAlert("Failed to link shaders: %s\n" diff --git a/Source/Core/VideoBackends/Vulkan/ShaderCompiler.cpp b/Source/Core/VideoBackends/Vulkan/ShaderCompiler.cpp index a245935995..7b6beb11b0 100644 --- a/Source/Core/VideoBackends/Vulkan/ShaderCompiler.cpp +++ b/Source/Core/VideoBackends/Vulkan/ShaderCompiler.cpp @@ -21,7 +21,9 @@ #include "Common/Logging/Log.h" #include "Common/MsgHandler.h" #include "Common/StringUtil.h" +#include "Common/Version.h" +#include "VideoCommon/VideoBackendBase.h" #include "VideoCommon/VideoConfig.h" namespace Vulkan::ShaderCompiler @@ -142,9 +144,7 @@ std::optional CompileShaderToSPV(EShLanguage stage, const char* auto DumpBadShader = [&](const char* msg) { static int counter = 0; - std::string filename = StringFromFormat( - "%sbad_%s_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), stage_filename, counter++); - + std::string filename = VideoBackendBase::BadShaderFilename(stage_filename, counter++); std::ofstream stream; File::OpenFStream(stream, filename, std::ios_base::out); if (stream.good()) @@ -162,6 +162,10 @@ std::optional CompileShaderToSPV(EShLanguage stage, const char* } } + stream << "\n"; + stream << "Dolphin Version: " + Common::scm_rev_str + "\n"; + stream << "Video Backend: " + g_video_backend->GetDisplayName(); + PanicAlert("%s (written to %s)", msg, filename.c_str()); }; diff --git a/Source/Core/VideoCommon/VideoBackendBase.cpp b/Source/Core/VideoCommon/VideoBackendBase.cpp index 9a6a92a01a..2c58449e1d 100644 --- a/Source/Core/VideoCommon/VideoBackendBase.cpp +++ b/Source/Core/VideoCommon/VideoBackendBase.cpp @@ -10,10 +10,13 @@ #include #include +#include "fmt/format.h" + #include "Common/ChunkFile.h" #include "Common/CommonTypes.h" #include "Common/Event.h" #include "Common/Logging/Log.h" + #include "Core/ConfigManager.h" #include "Core/Core.h" @@ -68,6 +71,12 @@ __declspec(dllexport) DWORD NvOptimusEnablement = 1; } #endif +std::string VideoBackendBase::BadShaderFilename(const char* shader_stage, int counter) +{ + return fmt::format("{}bad_{}_{}_{}.txt", File::GetUserPath(D_DUMP_IDX), shader_stage, + g_video_backend->GetName(), counter); +} + void VideoBackendBase::Video_ExitLoop() { Fifo::ExitGpuLoop(); diff --git a/Source/Core/VideoCommon/VideoBackendBase.h b/Source/Core/VideoCommon/VideoBackendBase.h index c7587dea9e..b02122621b 100644 --- a/Source/Core/VideoCommon/VideoBackendBase.h +++ b/Source/Core/VideoCommon/VideoBackendBase.h @@ -49,6 +49,8 @@ public: // thread which owns the window. virtual void PrepareWindow(const WindowSystemInfo& wsi) {} + static std::string BadShaderFilename(const char* shader_stage, int counter); + void Video_ExitLoop(); void Video_BeginField(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height, u64 ticks);