Function resolve_execution_backend
pub fn resolve_execution_backend(
preferred: TargetBackend,
native_available: impl Fn(TargetBackend) -> bool,
) -> (TargetBackend, Option<String>)Expand description
Resolve which backend the execution/validation pipeline should actually use,
given a preferred target and a predicate reporting whether a given backend’s
native toolchain is available on this host.
Policy (plan §2):
- If
preferredis available, use it unchanged: returns(preferred, None). - Otherwise walk
fallback_chainto the first available tier and return(chosen, Some(note)), wherenoteexplains the downgrade. Wgslis always considered available — it is the universal fallback and needs no native toolchain (naga compiles it in-process), so this function never fails to resolve a backend. The predicate is therefore not consulted forWgsl; whatever it returns forWgslis ignored.
The function is pure and deterministic: identical inputs (including predicate behaviour) yield identical output, with no I/O or global state. This is what makes it unit-testable against a mock predicate.