From 7cbebea3a0cce82f3a756c26ab0e1323bbf1d169 Mon Sep 17 00:00:00 2001 From: skal Date: Tue, 3 Feb 2026 08:04:06 +0100 Subject: docs: Document asset system technical details Adds a section on Alignment, String Safety, and Size Reporting to ASSET_SYSTEM.md. --- doc/ASSET_SYSTEM.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doc/ASSET_SYSTEM.md b/doc/ASSET_SYSTEM.md index bd5a266..3493936 100644 --- a/doc/ASSET_SYSTEM.md +++ b/doc/ASSET_SYSTEM.md @@ -56,6 +56,13 @@ we need a simple tool that: * put these in the source tree * this process needs a script for automation +## Technical Details + +To support diverse usage (binary data, strings, typed structs), the asset packer enforces the following: +1. **Alignment**: All static asset arrays are declared with `alignas(16)`. This ensures that `reinterpret_cast` to types like `float*` or SIMD vectors is safe (provided the data layout matches). +2. **String Safety**: Every static asset is appended with a null-terminator (`0x00`). This allows the raw pointer to be safely used as a `const char*` C-string. +3. **Size Reporting**: The `size` field in `AssetRecord` reflects the *original* file size. However, the underlying buffer is guaranteed to be at least `size + 1` bytes long (due to the null terminator). + # Shader Snippets Shader code (WGSL) can also be managed as assets. -- cgit v1.2.3