vyre_driver_wgpu/
executable_api.rs1use crate::{pipeline, WgpuBackend};
2
3pub struct WgpuIR {
9 pub pipeline: pipeline::WgpuPipeline,
12}
13
14impl vyre_driver::Executable for WgpuBackend {
15 fn dispatch(
16 &self,
17 program: &vyre_foundation::ir::Program,
18 inputs: &[vyre_driver::MemoryRef<'_>],
19 config: &vyre_driver::DispatchConfig,
20 ) -> Result<Vec<vyre_driver::Memory>, vyre_driver::BackendError> {
21 <Self as vyre_driver::VyreBackend>::dispatch_borrowed(self, program, inputs, config)
22 }
23}
24
25impl WgpuBackend {
26 pub fn compile(
28 &self,
29 program: &vyre_foundation::ir::Program,
30 ) -> Result<WgpuIR, vyre_driver::BackendError> {
31 let config = vyre_driver::DispatchConfig::default();
32 self.validate_with_cache(program)?;
33 let pipeline = crate::pipeline::WgpuPipeline::compile_with_device_queue(
34 program,
35 &config,
36 self.adapter_info.clone(),
37 self.enabled_features,
38 self.current_device_queue(),
39 self.dispatch_arena_snapshot(),
40 self.current_persistent_pool(),
41 self.pipeline_cache.clone(),
42 self.bind_group_layout_cache.clone(),
43 )?;
44 Ok(WgpuIR {
45 pipeline: (*pipeline).clone(),
46 })
47 }
48
49 pub fn dispatch_compiled(
51 &self,
52 compiled: &WgpuIR,
53 inputs: &[vyre_driver::MemoryRef<'_>],
54 config: &vyre_driver::DispatchConfig,
55 ) -> Result<Vec<vyre_driver::Memory>, vyre_driver::BackendError> {
56 vyre_driver::CompiledPipeline::dispatch_borrowed(&compiled.pipeline, inputs, config)
57 }
58}