Restructure GPU compilation execution pipeline (#903)

* Restructure gpu compilation execution pipeline

* Add compilation server/client infrastructure

* Add wgpu executor
This commit is contained in:
Dennis Kobert 2022-12-31 02:52:04 +01:00 committed by Keavon Chambers
parent be32f7949f
commit 79ad3e7908
43 changed files with 2744 additions and 482 deletions

View file

@ -0,0 +1,48 @@
use std::sync::Arc;
use wgpu::{Device, Instance, Queue};
#[derive(Debug)]
pub struct Context {
pub device: Arc<Device>,
pub queue: Arc<Queue>,
pub instance: Arc<Instance>,
}
impl Context {
pub async fn new() -> Option<Self> {
// Instantiates instance of WebGPU
let instance = wgpu::Instance::new(wgpu::Backends::all());
// `request_adapter` instantiates the general connection to the GPU
let adapter = instance.request_adapter(&wgpu::RequestAdapterOptions::default()).await?;
// `request_device` instantiates the feature specific connection to the GPU, defining some parameters,
// `features` being the available features.
let (device, queue) = adapter
.request_device(
&wgpu::DeviceDescriptor {
label: None,
features: wgpu::Features::empty(),
limits: wgpu::Limits::downlevel_defaults(),
},
None,
)
.await
.unwrap();
let info = adapter.get_info();
// skip this on LavaPipe temporarily
if info.vendor == 0x10005 {
return None;
}
Some(Self {
device: Arc::new(device),
queue: Arc::new(queue),
instance: Arc::new(instance),
})
}
pub fn new_sync() -> Option<Self> {
future_executor::block_on(Self::new())
}
}