Expand description
Pipeline object cache for the GPU crate.
Avoids redundant pipeline compilation by keying compiled pipeline
binaries on a u64 hash. On a cache miss, a user-supplied closure
is called to produce the binary and the result is stored for subsequent
hits.
The cache is entirely in-memory; for disk persistence see the
higher-level shader_cache module.
§Example
use oximedia_gpu::pipeline_cache::PipelineCache;
let mut cache = PipelineCache::new();
let binary = cache.get_or_create(0xDEAD_BEEF, || vec![0x01, 0x02, 0x03]);
assert_eq!(binary, &[0x01, 0x02, 0x03]);
// Second call returns cached value without invoking the closure.
let again = cache.get_or_create(0xDEAD_BEEF, || panic!("should not be called"));
assert_eq!(again, &[0x01, 0x02, 0x03]);Structs§
- Pipeline
Cache - In-memory cache mapping pipeline keys to compiled pipeline binaries.