diff options
Diffstat (limited to 'src/gpu/effects/shader_composer.cc')
| -rw-r--r-- | src/gpu/effects/shader_composer.cc | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/gpu/effects/shader_composer.cc b/src/gpu/effects/shader_composer.cc index b746f8b..fe3ad74 100644 --- a/src/gpu/effects/shader_composer.cc +++ b/src/gpu/effects/shader_composer.cc @@ -86,3 +86,31 @@ ShaderComposer::Compose(const std::vector<std::string>& dependencies, return ss.str(); } + +void ShaderComposer::VerifyIncludes() const { +#if !defined(STRIP_ALL) + std::set<std::string> missing; + for (const auto& [name, code] : snippets_) { + std::istringstream stream(code); + std::string line; + while (std::getline(stream, line)) { + if (line.compare(0, 9, "#include ") == 0) { + size_t start = line.find('"'); + size_t end = line.find('"', start + 1); + if (start != std::string::npos && end != std::string::npos) { + std::string included = line.substr(start + 1, end - start - 1); + if (snippets_.find(included) == snippets_.end()) { + missing.insert(included); + } + } + } + } + } + if (!missing.empty()) { + fprintf(stderr, "WARNING: Unregistered shader snippets:\n"); + for (const auto& name : missing) { + fprintf(stderr, " - %s\n", name.c_str()); + } + } +#endif +} |
