Skip to content

Commit

Permalink
Dump shader programs on compile errors
Browse files Browse the repository at this point in the history
  • Loading branch information
RealBadAngel authored and kahrl committed Feb 11, 2016
1 parent 7e5eea9 commit f253ff9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand All @@ -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;
}
}
Expand Down Expand Up @@ -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;
}
3 changes: 3 additions & 0 deletions src/shader.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 comments on commit f253ff9

Please sign in to comment.