diff options
Diffstat (limited to 'TODO.md')
| -rw-r--r-- | TODO.md | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -93,6 +93,34 @@ This file tracks prioritized tasks with detailed attack plans. - **Impact**: Minimal (most shaders only use CommonUniforms anyway) - **Priority**: Low (nice-to-have for code organization) +### Sub-task: Type-safe shader composition (Low Priority) +- **Problem**: Recurrent error of forgetting `ShaderComposer::Get().Compose({}, code)` and using raw `code` directly + - Happened in: `create_post_process_pipeline`, `gpu_create_render_pass`, `gpu_create_compute_pass`, `CircleMaskEffect` + - Runtime error only (crashes demo, but tests may pass) +- **Solution**: Use strong typing to make it a compile-time error + ```cpp + class ComposedShader { + private: + std::string code_; + friend class ShaderComposer; + explicit ComposedShader(std::string code) : code_(std::move(code)) {} + public: + const char* c_str() const { return code_.c_str(); } + }; + ``` +- **Changes needed**: + - `ShaderComposer::Compose()` returns `ComposedShader` instead of `std::string` + - All shader creation functions take `const ComposedShader&` instead of `const char*` + - Cannot pass raw string to shader functions (compile error) +- **Benefits**: + - Impossible to forget composition (type mismatch) + - Self-documenting API (signature shows shader must be composed) + - Catches errors at compile-time instead of runtime +- **Trade-offs**: + - More verbose code (`auto shader = ShaderComposer::Get().Compose(...)`) + - Small overhead (extra std::string copy, but negligible) +- **Priority**: Low (recurrent but rare, easy to catch in testing) + ## Phase 2: Size Optimization (Final Goal) - [ ] **Task #34: Full STL Removal**: Replace all remaining `std::vector`, `std::map`, and `std::string` usage with custom minimal containers or C-style arrays to allow for CRT replacement. (Minimal Priority - deferred to end). |
