Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Dolphin version and current video backend to shader compilation logs #8336

Merged
merged 1 commit into from
Jan 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions Source/Core/VideoBackends/D3DCommon/Shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -105,13 +108,15 @@ std::optional<Shader::BinaryData> 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<const char*>(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,
Expand Down
14 changes: 10 additions & 4 deletions Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -31,6 +32,7 @@
#include "VideoCommon/Statistics.h"
#include "VideoCommon/VertexLoaderManager.h"
#include "VideoCommon/VertexShaderManager.h"
#include "VideoCommon/VideoBackendBase.h"

namespace OGL
{
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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())
Expand All @@ -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"
Expand Down
10 changes: 7 additions & 3 deletions Source/Core/VideoBackends/Vulkan/ShaderCompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -142,9 +144,7 @@ std::optional<SPIRVCodeVector> 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())
Expand All @@ -162,6 +162,10 @@ std::optional<SPIRVCodeVector> 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());
};

Expand Down
9 changes: 9 additions & 0 deletions Source/Core/VideoCommon/VideoBackendBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@
#include <string>
#include <vector>

#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"

Expand Down Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions Source/Core/VideoCommon/VideoBackendBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class VideoBackendBase
// 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);
Expand Down