summaryrefslogtreecommitdiff
path: root/src/gpu/shader_composer.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu/shader_composer.cc')
-rw-r--r--src/gpu/shader_composer.cc42
1 files changed, 40 insertions, 2 deletions
diff --git a/src/gpu/shader_composer.cc b/src/gpu/shader_composer.cc
index fce6de4..be311dd 100644
--- a/src/gpu/shader_composer.cc
+++ b/src/gpu/shader_composer.cc
@@ -2,6 +2,7 @@
// It implements the ShaderComposer class.
#include "gpu/shader_composer.h"
+#include <cassert>
#include <set>
#include <sstream>
@@ -44,6 +45,27 @@ void ShaderComposer::ResolveRecursive(const std::string& source,
ss << "// --- End Include: " << name << " ---\n";
} else {
ss << "// ERROR: Snippet not found: " << name << "\n";
+#if !defined(STRIP_ALL)
+ // Find suggestions: registered snippets whose basename matches.
+ std::string suggestion;
+ for (const auto& [sname, _] : snippets_) {
+ auto slash = sname.rfind('/');
+ std::string basename =
+ (slash == std::string::npos) ? sname : sname.substr(slash + 1);
+ if (basename == name) {
+ suggestion = sname;
+ break;
+ }
+ }
+ fprintf(stderr,
+ "FATAL: #include \"%s\" - snippet not registered.\n",
+ name.c_str());
+ if (!suggestion.empty()) {
+ fprintf(stderr, " Fix: use #include \"%s\"\n",
+ suggestion.c_str());
+ }
+ assert(false && "Unresolved shader #include");
+#endif
}
}
}
@@ -111,10 +133,26 @@ void ShaderComposer::VerifyIncludes() const {
}
}
if (!missing.empty()) {
- fprintf(stderr, "WARNING: Unregistered shader snippets:\n");
+ fprintf(stderr, "ERROR: Unregistered shader snippets referenced in #include:\n");
for (const auto& name : missing) {
- fprintf(stderr, " - %s\n", name.c_str());
+ std::string suggestion;
+ for (const auto& [sname, _] : snippets_) {
+ auto slash = sname.rfind('/');
+ std::string basename =
+ (slash == std::string::npos) ? sname : sname.substr(slash + 1);
+ if (basename == name) {
+ suggestion = sname;
+ break;
+ }
+ }
+ if (!suggestion.empty()) {
+ fprintf(stderr, " - \"%s\" (did you mean \"%s\"?)\n", name.c_str(),
+ suggestion.c_str());
+ } else {
+ fprintf(stderr, " - \"%s\"\n", name.c_str());
+ }
}
+ assert(false && "Unregistered shader snippets - fix #include paths");
}
#endif
}