diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-04 11:56:03 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-04 11:56:03 +0100 |
| commit | 2e34965e5e48175c5ee6016af1a858f7f3f02c1d (patch) | |
| tree | a41ea2fdc50a18183742bffaf0705b394f2be69f /src/gpu/effects/shader_composer.h | |
| parent | 0d29f340b9de8f6a14baa0a2c6f3c57b8d1458a5 (diff) | |
feat(gpu): Implement recursive WGSL composition and modularize shaders (Task #50)
- Updated ShaderComposer to support recursive #include "snippet_name" with cycle detection.
- Extracted granular WGSL snippets: math/sdf_shapes, math/sdf_utils, render/shadows, render/scene_query, render/lighting_utils.
- Refactored Renderer3D to use #include in shaders, simplifying C++ dependency lists.
- Fixed WGPUShaderSourceWGSL usage on macOS to correctly handle composed shader strings.
- Added comprehensive unit tests for recursive composition in test_shader_composer.
- Verified system stability with test_3d_render and full test suite.
- Marked Task #50 as recurrent for future code hygiene.
Diffstat (limited to 'src/gpu/effects/shader_composer.h')
| -rw-r--r-- | src/gpu/effects/shader_composer.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/gpu/effects/shader_composer.h b/src/gpu/effects/shader_composer.h index 49bf00c..a63a6a4 100644 --- a/src/gpu/effects/shader_composer.h +++ b/src/gpu/effects/shader_composer.h @@ -4,6 +4,7 @@ #pragma once #include <map> +#include <set> #include <string> #include <vector> @@ -15,10 +16,15 @@ class ShaderComposer { void RegisterSnippet(const std::string& name, const std::string& code); // Assemble a final shader string by prepending required snippets + // and recursively resolving #include "snippet_name" directives. std::string Compose(const std::vector<std::string>& dependencies, const std::string& main_code); private: ShaderComposer() = default; + + void ResolveRecursive(const std::string& source, std::stringstream& ss, + std::set<std::string>& included); + std::map<std::string, std::string> snippets_; }; |
