mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2025-02-16 19:05:39 +00:00
common: Log bad shaders to disk
This commit is contained in:
parent
b75674b149
commit
332b5481e8
|
@ -1,8 +1,12 @@
|
||||||
#include "gl_program.h"
|
#include "gl_program.h"
|
||||||
#include "YBaseLib/Log.h"
|
#include "YBaseLib/Log.h"
|
||||||
|
#include "YBaseLib/String.h"
|
||||||
#include <array>
|
#include <array>
|
||||||
|
#include <fstream>
|
||||||
Log_SetChannel(GL);
|
Log_SetChannel(GL);
|
||||||
|
|
||||||
|
static u32 s_next_bad_shader_id = 1;
|
||||||
|
|
||||||
namespace GL {
|
namespace GL {
|
||||||
|
|
||||||
Program::Program() = default;
|
Program::Program() = default;
|
||||||
|
@ -40,6 +44,17 @@ GLuint Program::CompileShader(GLenum type, const char* source)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log_ErrorPrintf("Shader failed to compile:\n%s", info_log.c_str());
|
Log_ErrorPrintf("Shader failed to compile:\n%s", info_log.c_str());
|
||||||
|
|
||||||
|
std::ofstream ofs(SmallString::FromFormat("bad_shader_%u.txt", s_next_bad_shader_id++),
|
||||||
|
std::ofstream::out | std::ofstream::binary);
|
||||||
|
if (ofs.is_open())
|
||||||
|
{
|
||||||
|
ofs.write(sources[0], source_lengths[0]);
|
||||||
|
ofs << "\n\nCompile failed, info log:\n";
|
||||||
|
ofs << info_log;
|
||||||
|
ofs.close();
|
||||||
|
}
|
||||||
|
|
||||||
glDeleteShader(id);
|
glDeleteShader(id);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue