Skip to content
Snippets Groups Projects
Commit f253ff9f authored by RealBadAngel's avatar RealBadAngel Committed by Kahrl
Browse files

Dump shader programs on compile errors

parent 7e5eea9a
No related branches found
No related tags found
No related merge requests found
......@@ -808,6 +808,9 @@ ShaderInfo generate_shader(std::string name, u8 material_type, u8 drawtype,
"failed to generate \""<<name<<"\", "
"addHighLevelShaderMaterial failed."
<<std::endl;
dumpShaderProgram(warningstream, "Vertex", vertex_program);
dumpShaderProgram(warningstream, "Pixel", pixel_program);
dumpShaderProgram(warningstream, "Geometry", geometry_program);
return shaderinfo;
}
}
......@@ -826,6 +829,8 @@ ShaderInfo generate_shader(std::string name, u8 material_type, u8 drawtype,
"failed to generate \""<<name<<"\", "
"addShaderMaterial failed."
<<std::endl;
dumpShaderProgram(warningstream, "Vertex", vertex_program);
dumpShaderProgram(warningstream,"Pixel", pixel_program);
return shaderinfo;
}
}
......@@ -871,3 +876,21 @@ void load_shaders(std::string name, SourceShaderCache *sourcecache,
}
}
void dumpShaderProgram(std::ostream &output_stream,
const std::string &program_type, const std::string &program)
{
output_stream << program_type << " shader program:" << std::endl <<
"----------------------------------" << std::endl;
size_t pos = 0;
size_t prev = 0;
s16 line = 1;
while ((pos = program.find("\n", prev)) != std::string::npos) {
output_stream << line++ << ": "<< program.substr(prev, pos - prev) <<
std::endl;
prev = pos + 1;
}
output_stream << line << ": " << program.substr(prev) << std::endl <<
"End of " << program_type << " shader program." << std::endl <<
" " << std::endl;
}
......@@ -110,4 +110,7 @@ class IWritableShaderSource : public IShaderSource
IWritableShaderSource* createShaderSource(IrrlichtDevice *device);
void dumpShaderProgram(std::ostream &output_stream,
const std::string &program_type, const std::string &program);
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment