summaryrefslogtreecommitdiff
path: root/src/gpu/effects/shader_composer.cc
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-11 16:06:16 +0100
committerskal <pascal.massimino@gmail.com>2026-02-11 16:06:16 +0100
commit09eba6004eb5faa5273e310ca560bfd41e1bc901 (patch)
tree670ee9a4e5bdbe91a84bec459bbec475d33e3414 /src/gpu/effects/shader_composer.cc
parent3d2ff01e45bf0229d609ffdf84080f0b722f1f24 (diff)
fix: Register cnn_conv1x1 snippet and add verification
- Add cnn_conv1x1 to shader composer registration - Add VerifyIncludes() to detect missing snippet registrations - STRIP_ALL-protected verification warns about unregistered includes - Fixes cnn_test runtime failure loading cnn_layer.wgsl Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Diffstat (limited to 'src/gpu/effects/shader_composer.cc')
-rw-r--r--src/gpu/effects/shader_composer.cc28
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
+}