diff --git a/Cargo.lock b/Cargo.lock index f354afb2df..c4b8ff06e7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2328,7 +2328,7 @@ dependencies = [ "objc", "parking_lot", "serde", - "sugarloaf 0.0.7", + "sugarloaf", "teletypewriter", "tokio", "unicode-width", @@ -2579,27 +2579,6 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" -[[package]] -name = "sugarloaf" -version = "0.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd59dd02531ccab767643907a0f9727c0984a2384e1a4f16025b6aef591b8d9f" -dependencies = [ - "bytemuck", - "console_error_panic_hook", - "console_log", - "font-kit", - "glyph_brush", - "js-sys", - "log 0.4.18", - "wasm-bindgen", - "wasm-bindgen-futures", - "wasm-bindgen-test", - "web-sys", - "wgpu", - "winit", -] - [[package]] name = "sugarloaf" version = "0.0.9-canary" @@ -2631,7 +2610,7 @@ dependencies = [ "console_log", "env_logger 0.10.0", "log 0.4.18", - "sugarloaf 0.0.9-canary", + "sugarloaf", "wasm-bindgen", "wasm-bindgen-futures", "wasm-bindgen-test", diff --git a/Cargo.toml b/Cargo.toml index ec5e220edd..2a338732a5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,6 +26,7 @@ bytemuck = { version = "1.13.1", features = [ "derive" ] } log = "0.4.18" serde = { version = "1.0.163", features = ["derive"] } teletypewriter = { path = "teletypewriter" } +sugarloaf = { path = "sugarloaf" } corcovado = { path = "corcovado" } tokio = { version = "1.26.0", features = ["full"] } wgpu = "0.16.2" diff --git a/rio/Cargo.toml b/rio/Cargo.toml index 3f482c83b4..d87a1ac616 100644 --- a/rio/Cargo.toml +++ b/rio/Cargo.toml @@ -27,7 +27,7 @@ libc = { workspace = true } log = { workspace = true } parking_lot = "0.12" serde = { workspace = true } -sugarloaf = "0.0.7" +sugarloaf = { workspace = true } teletypewriter = { workspace = true } tokio = { version = "1.26.0", features = ["full"] } unicode-width = "0.1.5" diff --git a/sugarloaf/src/context/mod.rs b/sugarloaf/src/context/mod.rs index 99b17a573d..2acc25982c 100644 --- a/sugarloaf/src/context/mod.rs +++ b/sugarloaf/src/context/mod.rs @@ -65,14 +65,24 @@ impl Context { log::info!("Selected adapter: {:?}", adapter.get_info()); let caps = surface.get_capabilities(&adapter); - let format = caps - .formats + + // TODO: Fix formats with signs + let unsupported_formats = wgpu::TextureFormat::Rgb10a2Unorm; + let filtered_formats: Vec = caps.formats .iter() .copied() - .find(wgpu::TextureFormat::is_srgb) - .or_else(|| caps.formats.first().copied()) - .expect("Get preferred format"); + .filter(|&x| { + x != unsupported_formats && + wgpu::TextureFormat::has_color_aspect(&x) + }) + .collect(); + + let mut format: wgpu::TextureFormat = caps.formats.first().unwrap().to_owned(); + if !filtered_formats.is_empty() { + format = filtered_formats.last().unwrap().to_owned(); + } + log::info!("Sugarloaf selected format: {format:?} from {:?}", caps.formats); let (device, queue) = (async { { if let Ok(result) = adapter