Skip to main content

cache_shader_object_deferred

Function cache_shader_object_deferred 

Source
pub fn cache_shader_object_deferred<'a, E, T, R, H, const KEY_SIZE: usize>(
    index: &str,
    keys: &[H; KEY_SIZE],
    factory: impl Fn(&[H; KEY_SIZE]) -> Result<T, E> + RefUnwindSafe,
    load: impl FnOnce(T) -> Result<R, E> + Send + 'a,
    bypass_cache: bool,
) -> Result<Box<dyn FnOnce() -> Result<R, E> + Send + 'a>, E>
where H: CacheKey + RefUnwindSafe, T: Cacheable + Send + 'a,
Expand description

Cache a shader object (usually bytecode) created by the keyed objects, deferring the load step.

This behaves like cache_shader_object, except that load is not executed immediately. Instead, the compiled (or cached) shader object is curried into the returned closure, which can be invoked later to produce the driver-specialized result. This allows shader objects to be compiled in parallel via factory, then have their driver resources created sequentially by the returned closures, for drivers whose object creation is not safe to call concurrently.

Because load is deferred, a cached shader object can not be validated by load at fetch time: unlike cache_shader_object, a cached object that fails to load will not be transparently recompiled.