summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-14 19:21:05 +0100
committerskal <pascal.massimino@gmail.com>2026-02-14 19:21:05 +0100
commitc98286860885d1f025cd8cf9da699f174118ccba (patch)
treebafb73833ae62e2c8b04b211d4f473f3e97c3db7 /doc
parentb8d4a815453acac752c6fb3c56d047e39a76fd05 (diff)
feat(gpu): add two-pass raymarching infrastructure
Add RayMarchResult struct and functions for deferred SDF rendering: - rayMarchWithID() tracks object ID and distance_max - reconstructPosition(), normalWithID(), shadowWithStoredDistance() - Pass 1: store geometry data, Pass 2: reuse for shading Add WGSL style rule: prefer return values over pointers for small structs (≤16 bytes). Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Diffstat (limited to 'doc')
-rw-r--r--doc/CODING_STYLE.md27
1 files changed, 27 insertions, 0 deletions
diff --git a/doc/CODING_STYLE.md b/doc/CODING_STYLE.md
index 533cffb..5c86409 100644
--- a/doc/CODING_STYLE.md
+++ b/doc/CODING_STYLE.md
@@ -107,3 +107,30 @@ One-line comment for non-obvious functions.
```
Three-line header for all source files.
+
+---
+
+## WGSL Shader Style
+
+### Return vs Pointer Parameters
+
+**Rule:** Prefer return values over pointer parameters for small structs (≤16 bytes).
+
+```wgsl
+// Correct - return value (12 bytes: 3×f32)
+fn rayMarchWithID(ro: vec3<f32>, rd: vec3<f32>, init: RayMarchResult) -> RayMarchResult {
+ var result = init;
+ // ... modify result
+ return result;
+}
+
+// Wrong - pointer parameter (unnecessary complexity)
+fn rayMarchWithID(ro: vec3<f32>, rd: vec3<f32>, result: ptr<function, RayMarchResult>) {
+ // ... modify *result
+}
+```
+
+**Rationale:**
+- Small structs (≤16 bytes) are efficiently handled by GPU return value optimization
+- Functional style is clearer and less error-prone
+- `ptr<function, T>` adds complexity with no performance gain for small types