mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-16 23:08:05 +08:00
Disable Vello renderer checkbox in preferences if browser doesn't support WebGPU (#1844)
* Disable vello checkbox if no wgpu support is available * Fix compile error * Check wgpu status on every diagogue open * Execute graph on settings change * Remove tooltip and disabled status from settings category --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
@@ -43,6 +43,7 @@ tokio = { workspace = true, optional = true }
|
||||
web-sys = { workspace = true }
|
||||
js-sys = { workspace = true }
|
||||
wasm-bindgen = { workspace = true }
|
||||
wasm-bindgen-futures = { workspace = true }
|
||||
|
||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||
# Workspace dependencies
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
use dyn_any::StaticType;
|
||||
use graphene_core::application_io::SurfaceHandleFrame;
|
||||
use graphene_core::application_io::{ApplicationError, ApplicationIo, ResourceFuture, SurfaceHandle, SurfaceId};
|
||||
#[cfg(feature = "wgpu")]
|
||||
use wgpu_executor::WgpuExecutor;
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
@@ -34,9 +33,19 @@ pub struct WasmApplicationIo {
|
||||
pub resources: HashMap<String, Arc<[u8]>>,
|
||||
}
|
||||
|
||||
static WGPU_AVAILABLE: std::sync::atomic::AtomicI8 = std::sync::atomic::AtomicI8::new(-1);
|
||||
|
||||
pub fn wgpu_available() -> Option<bool> {
|
||||
match WGPU_AVAILABLE.load(::std::sync::atomic::Ordering::SeqCst) {
|
||||
-1 => None,
|
||||
0 => Some(false),
|
||||
_ => Some(true),
|
||||
}
|
||||
}
|
||||
|
||||
impl WasmApplicationIo {
|
||||
pub async fn new() -> Self {
|
||||
#[cfg(all(feature = "wgpu", target_arch = "wasm32"))]
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
let executor = if let Some(gpu) = web_sys::window().map(|w| w.navigator().gpu()) {
|
||||
let request_adapter = || {
|
||||
let request_adapter = js_sys::Reflect::get(&gpu, &wasm_bindgen::JsValue::from_str("requestAdapter")).ok()?;
|
||||
@@ -51,8 +60,9 @@ impl WasmApplicationIo {
|
||||
} else {
|
||||
None
|
||||
};
|
||||
#[cfg(all(feature = "wgpu", not(target_arch = "wasm32")))]
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let executor = WgpuExecutor::new().await;
|
||||
WGPU_AVAILABLE.store(executor.is_some() as i8, ::std::sync::atomic::Ordering::SeqCst);
|
||||
let mut io = Self {
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
ids: AtomicU64::new(0),
|
||||
|
||||
Reference in New Issue
Block a user