summaryrefslogtreecommitdiff
path: root/doc/ASSET_SYSTEM.md
diff options
context:
space:
mode:
Diffstat (limited to 'doc/ASSET_SYSTEM.md')
-rw-r--r--doc/ASSET_SYSTEM.md14
1 files changed, 12 insertions, 2 deletions
diff --git a/doc/ASSET_SYSTEM.md b/doc/ASSET_SYSTEM.md
index a97886c..415342d 100644
--- a/doc/ASSET_SYSTEM.md
+++ b/doc/ASSET_SYSTEM.md
@@ -60,6 +60,16 @@ enum class AssetType : uint8_t {
};
```
+## Compression
+
+Each `AssetRecord` carries an `AssetCompression` flag and an
+`uncompressed_size`. In **Release Mode** the asset packer runs an order-0
+rANS coder over every `WGSL` asset, seeded with a histogram derived from
+the full shader corpus. `AssetManager::GetAsset()` decompresses lazily on
+first access and caches the result. Other asset types and **Development
+Mode** are unaffected. See `doc/ANS.md` for the algorithm, bitstream, and
+runtime API.
+
Query at runtime:
```cpp
if (GetAssetType(AssetId::NEVER_MP3) == AssetType::MP3) { ... }
@@ -93,8 +103,8 @@ Tool: `tools/asset_packer.cc`
## Technical Guarantees
- **Alignment**: All embedded data arrays are declared `alignas(16)` for safe `reinterpret_cast`.
-- **String Safety**: Embedded assets are null-terminated (safe as C-strings). In disk-load mode, the path itself is a null-terminated C-string.
-- **Size**: For embedded assets, `size` reflects the original file size (the buffer is `size + 1`). For disk-loaded assets, it reflects the file path's string length.
+- **String Safety**: Embedded assets are null-terminated (safe as C-strings). In disk-load mode, the path itself is a null-terminated C-string. ANS-compressed assets are NUL-terminated by the decompressor on first access.
+- **Size**: For uncompressed embedded assets, `size` is the original file size (the buffer is `size + 1`). For disk-loaded assets, it is the file path's string length. For ANS-compressed assets, `size` is the *compressed* byte count; query `uncompressed_size` for the decoded length.
## Developer Workflow