mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 22:28:10 +08:00
* Start integrating vello into render pipeline Cache vello render creation Implement viewport navigation Close vello path Add transform parameter to vello render pass * Fix render node types * Fix a bunch of bugs in the path translation * Avoid panic on empty document * Fix rendering of holes * Implement image rendering * Implement graph recompilation afer editor api change * Implement preferences toggle for using vello as the renderer * Make surface creation optional * Feature gate vello usages * Implement skeleton for radial gradient * Rename vello preference * Fix some gradients * Only update monitor nodes on graph recompile * Fix warnings + remove dead code * Update everything except for thumbnails after a node graph evaluation * Fix missing click targets for Image frames * Improve perfamance by removing unecessary widget updates * Fix node graph paning * Fix thumbnail loading * Implement proper hash for vector modification * Fix test and warnings * Code review * Fix dep * Remove warning --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
60 lines
1.6 KiB
Rust
60 lines
1.6 KiB
Rust
use std::sync::Arc;
|
|
use wgpu::{Device, Instance, Queue};
|
|
|
|
#[derive(Debug, Clone)]
|
|
pub struct Context {
|
|
pub device: Arc<Device>,
|
|
pub queue: Arc<Queue>,
|
|
pub instance: Arc<Instance>,
|
|
pub adapter: Arc<wgpu::Adapter>,
|
|
}
|
|
|
|
impl Context {
|
|
pub async fn new() -> Option<Self> {
|
|
// Instantiates instance of WebGPU
|
|
let instance_descriptor = wgpu::InstanceDescriptor {
|
|
backends: wgpu::Backends::VULKAN | wgpu::Backends::BROWSER_WEBGPU,
|
|
..Default::default()
|
|
};
|
|
let instance = wgpu::Instance::new(instance_descriptor);
|
|
|
|
let adapter_options = wgpu::RequestAdapterOptions {
|
|
power_preference: wgpu::PowerPreference::HighPerformance,
|
|
compatible_surface: None,
|
|
force_fallback_adapter: false,
|
|
};
|
|
// `request_adapter` instantiates the general connection to the GPU
|
|
let adapter = instance.request_adapter(&adapter_options).await?;
|
|
|
|
let required_limits = adapter.limits();
|
|
// `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,
|
|
#[cfg(not(feature = "passthrough"))]
|
|
required_features: wgpu::Features::empty(),
|
|
#[cfg(feature = "passthrough")]
|
|
required_features: wgpu::Features::SPIRV_SHADER_PASSTHROUGH,
|
|
required_limits,
|
|
},
|
|
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),
|
|
adapter: Arc::new(adapter),
|
|
instance: Arc::new(instance),
|
|
})
|
|
}
|
|
}
|