aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRealBadAngel <maciej.kasatkin@o2.pl>2016-02-10 04:27:45 +0100
committerKahrl <kahrl@gmx.net>2016-02-11 07:13:07 +0100
commitf253ff9f1ab246c67ee5d3fb520c584b384ee708 (patch)
treee7b04bf84958fe1cccfea7a703333774f8dec882 /src
parent7e5eea9ad5f6b5a88c5b4b5bc1b2733cf451b9fd (diff)
downloadminetest-f253ff9f1ab246c67ee5d3fb520c584b384ee708.tar.gz
minetest-f253ff9f1ab246c67ee5d3fb520c584b384ee708.tar.bz2
minetest-f253ff9f1ab246c67ee5d3fb520c584b384ee708.zip
Dump shader programs on compile errors
Diffstat (limited to 'src')
-rw-r--r--src/shader.cpp23
-rw-r--r--src/shader.h3
2 files changed, 26 insertions, 0 deletions
diff --git a/src/shader.cpp b/src/shader.cpp
index d39a8307c..1d990eafe 100644
--- a/src/shader.cpp
+++ b/src/shader.cpp
@@ -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;
+}
diff --git a/src/shader.h b/src/shader.h
index 811f33080..b8aa88bce 100644
--- a/src/shader.h
+++ b/src/shader.h
@@ -110,4 +110,7 @@ public:
IWritableShaderSource* createShaderSource(IrrlichtDevice *device);
+void dumpShaderProgram(std::ostream &output_stream,
+ const std::string &program_type, const std::string &program);
+
#endif