From 75e561bd092895a031ae4475f7d1fdc35b1b1832 Mon Sep 17 00:00:00 2001 From: skal Date: Sat, 28 Feb 2026 00:39:32 +0100 Subject: fix(shaders): deduplicate VertexOutput/vs_main via render/fullscreen_uv_vs snippet - Fix vs_main return type (VertexOutput, not vec4) - Fix #include paths in passthrough, gaussian_blur, heptagon, combined_postprocess - ShaderComposer: assert + suggest correct path on missing #include (non-STRIP_ALL) - VerifyIncludes: upgrade WARNING to ERROR + assert, add "did you mean?" hint Co-Authored-By: Claude Sonnet 4.6 --- src/gpu/shader_composer.cc | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) (limited to 'src/gpu/shader_composer.cc') 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 #include #include @@ -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 } -- cgit v1.2.3