Archetype Asset
A modular asset pipeline that handles the "boring" parts of loading files into GPU memory.
What This Is (Probably)
archetype_asset is a high-performance bridge between files on disk and data in your GPU. It follows the "Dumb Pipe" philosophy: it handles the messy parsing, parallel decoding, and memory management, but stays out of your way when it comes to actual rendering.
Fair Warning: This is a library component, not a engine. You'll need to provide your own GpuDevice implementation (though a Mock is provided for testing) and your own rendering logic. Think of it as the gas station for your car—it provides the fuel, but you still have to drive.
Core Concepts
What It Does
- ✅ Optimized GLTF Loading: Parallel mesh and material extraction.
- ✅ Async Pipeline: Non-blocking I/O and decoding.
- ✅ Spatial Preloading: Background loading triggered by player proximity.
- ✅ LOD Generation: Automatic mesh simplification via
meshopt. - ✅ Memory Pooling: Contiguous arenas for vertex/index data to minimize fragmentation.
- ✅ Zero-Copy IBL: Memory-mapped access to HDR/Irradiance cubemaps.
- ✅ Texture Compression: Native support for WebP and KTX2 (ETC1S/UASTC).
What It Doesn't Do
- ❌ Rendering: (Use
ash,wgpu, or your own). - ❌ Scene Management: (That's your engine's job).
- ❌ Physics: (Maybe in another life).
Quick Start
1. The Async Asset Cache
The heart of the system. It manages memory budgets and handles deduplication.
use AssetCache;
use MockGpu;
use TokioSpawner;
async
2. Spatial Preloading
Stop your game from stuttering when moving through large worlds.
// Update player position to trigger background preloading
cache.update_player_position.await;
// Call this once per frame to progress the preload queue
cache.frame_update.await;
3. Zero-Copy Cubemaps (IBL)
Load massive HDR cubemaps without the memcpy tax.
use MappedIblAsset;
Performance Notes
We take performance seriously because we have to.
- 20% faster model loader instantiation compared to v0.1.2.
- 7% faster cache hit lookups via
DashMapconcurrency. - Zero allocation path for mesh creation when using internal pools.
Benchmarks run on: Intel Core i5-11400F, Intel Arc A380, 16GB RAM.
Architecture
Data flows from disk to GPU in a clean, isolated stream:
- Loader: Reads raw bytes (supports
mmap). - Parser: GLTF/HDR/Ktx2 decoding (Parallel on
AsyncSpawner). - Pooler: Allocates contiguous memory in
AssetMemoryPool. - Cache: Atomic deduplication using
DashMap. - GPU: Direct upload via your
GpuDeviceimplementation.
Known Limitations
- GLTF: Currently reads the first skin/scene only.
- LOD: Requires the
lodfeature (depends onmeshopt). - Platforms: Primary testing on Windows (Vulkan/Arc).
Version History
v0.2.1 — The Polish Release
- ✅ Refactored
AssetCacheto be generic overAsyncSpawner. - ✅ Replaced sync locks with
DashMapfor concurrent performance. - ✅ Fixed
await-holding-lockdeadlocks in spatial updates. - ✅ Added support for Ktx2 (ETC1S/UASTC) and WebP.
- ✅ Achievement: 100% Documentation coverage.