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

Vulkan: Improve shader compile error handling #10601

Merged
merged 2 commits into from Apr 24, 2022

Conversation

Pokechu22
Copy link
Contributor

Two fairly minor improvements:

  • Close the output stream on shader compile error before showing the panic alert: This fixes the file showing up as 0 bytes in Windows Explorer (although the file would still display properly when opened).
  • Include the info log in the shader compile error panic alert: The other backends do this, and it is helpful for quickly identifying errors during development.

Here's what the warning looked like beforehand:

image

And here's the new warning:

image

And the relevant code on other backends, for reference:

if (compileStatus != GL_TRUE)
{
ERROR_LOG_FMT(VIDEO, "{} failed compilation:\n{}", prefix, info_log);
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::GetScmRevStr() + "\n";
file << "Video Backend: " + g_video_backend->GetDisplayName();
file.close();
PanicAlertFmt("Failed to compile {} shader: {}\n"
"Debug info ({}, {}, {}):\n{}",
prefix, filename, g_ogl_config.gl_vendor, g_ogl_config.gl_renderer,
g_ogl_config.gl_version, info_log);
return false;
}

if (FAILED(hr))
{
static int num_failures = 0;
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::GetScmRevStr() + "\n";
file << "Video Backend: " + g_video_backend->GetDisplayName();
file.close();
PanicAlertFmt("Failed to compile {}: {}\nDebug info ({}):\n{}", filename, Common::HRWrap(hr),
target, static_cast<const char*>(errors->GetBufferPointer()));
return std::nullopt;
}

…g the panic alert

This fixes the file showing up as 0 bytes in Windows Explorer (although the file would still display properly when opened).
The other backends do this, and it is helpful for quickly identifying errors during development.
@Pokechu22 Pokechu22 merged commit 8e7c848 into dolphin-emu:master Apr 24, 2022
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants