From ef205b6eda78f1dcf65aa696dedf1f8c0707ff30 Mon Sep 17 00:00:00 2001 From: skal Date: Tue, 10 Mar 2026 09:28:08 +0100 Subject: fix: use ShaderComposer in RotatingCube; add rule to CODING_STYLE rotating_cube_effect.cc was bypassing ShaderComposer, causing #include directives in rotating_cube.wgsl to fail at runtime. handoff(Claude): ShaderComposer rule documented and enforced in rotating_cube. Co-Authored-By: Claude Sonnet 4.6 --- doc/CODING_STYLE.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'doc') diff --git a/doc/CODING_STYLE.md b/doc/CODING_STYLE.md index 7d45027..6ef7326 100644 --- a/doc/CODING_STYLE.md +++ b/doc/CODING_STYLE.md @@ -166,6 +166,24 @@ Three-line header for all source files. ## WGSL Shader Style +### Always Use ShaderComposer (Required) + +**Rule:** Always load `.wgsl` shaders via `ShaderComposer::Get().Compose(...)`, even if the shader has no `#include` directives. Never pass the raw shader string directly to `wgpuDeviceCreateShaderModule`. + +```cpp +// Correct +const std::string src = ShaderComposer::Get().Compose({}, my_shader_wgsl); +WGPUShaderSourceWGSL wgsl_src = {}; +wgsl_src.code = str_view(src); + +// Wrong - bypasses #include resolution +wgsl_src.code = str_view(my_shader_wgsl); +``` + +**Rationale:** Shaders may gain `#include` directives later; bypassing `ShaderComposer` silently breaks them at runtime with no compile error. + +--- + ### File Header (Required) Every `.wgsl` file must start with a 2-line comment header: -- cgit v1.2.3