From 09eba6004eb5faa5273e310ca560bfd41e1bc901 Mon Sep 17 00:00:00 2001 From: skal Date: Wed, 11 Feb 2026 16:06:16 +0100 Subject: 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 --- src/gpu/effects/shader_composer.cc | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/gpu/effects/shader_composer.cc') 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& dependencies, return ss.str(); } + +void ShaderComposer::VerifyIncludes() const { +#if !defined(STRIP_ALL) + std::set 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 +} -- cgit v1.2.3