summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-02 16:12:09 +0100
committerskal <pascal.massimino@gmail.com>2026-02-02 16:12:09 +0100
commit47b6253049b54186663b4205d3441f88656dc22e (patch)
treebd743c635e2f3abb712f734b2f55b3f067499bdc /doc
parent06670897f15695c5bd33221841ce057a1778ee24 (diff)
flesh out extra details in the MD files
Diffstat (limited to 'doc')
-rw-r--r--doc/CONTRIBUTING.md29
1 files changed, 29 insertions, 0 deletions
diff --git a/doc/CONTRIBUTING.md b/doc/CONTRIBUTING.md
index 265b686..13be092 100644
--- a/doc/CONTRIBUTING.md
+++ b/doc/CONTRIBUTING.md
@@ -94,6 +94,8 @@ if variable_name is not mutated afterward.
Also: pass parameter as "const ref" as much as possible
(```const Struct& param``` instead of pointers or non-const refs)
+In summary: use 'const variable = ...;` as much as possible.
+
### put spaces around code and operators (cosmetics)
Don't compact the code to much horizontally, and prefer adding extra
@@ -169,6 +171,33 @@ private:
int field_;
```
+### try to use per-field initialized const struct
+
+Use the `.field = ...,` initialization pattern instead for `var.field =
+...;`, especially if it means you can have the variable be declared 'const'
+that way.
+
+Example, instead of:
+```cpp
+WGPUTextureViewDescriptor view_desc = {};
+view_desc.format = g_format;
+view_desc.dimension = WGPUTextureViewDimension_2D;
+view_desc.mipLevelCount = 1;
+view_desc.arrayLayerCount = 1;
+```
+
+use:
+```cpp
+const WGPUTextureViewDescriptor view_desc = {
+ .format = g_format,
+ .dimension = WGPUTextureViewDimension_2D,
+ .mipLevelCount = 1,
+ .arrayLayerCount = 1,
+};
+```
+
+Make sure the `.field = ...,` initialization pattern is compatible with the compiler / c++ version used.
+
### vertical space
keep the code compact vertically. That includes shader code, too.