From 8ea2bc7ad6ae26443d6e61d3edf2e79a4eedc68a Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Sat, 6 Apr 2024 16:28:34 -0700 Subject: [PATCH] Update blade to a version that can run GLES for Zed --- Cargo.lock | 6 +++--- Cargo.toml | 4 ++-- crates/gpui/src/platform/blade/blade_atlas.rs | 3 +++ crates/gpui/src/platform/blade/blade_renderer.rs | 11 +++++++++-- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bf7bea9f4228b..4eb7b5df16637 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1433,8 +1433,8 @@ dependencies = [ [[package]] name = "blade-graphics" -version = "0.3.0" -source = "git+https://github.com/kvark/blade?rev=61cbd6b2c224791d52b150fe535cee665cc91bb2#61cbd6b2c224791d52b150fe535cee665cc91bb2" +version = "0.4.0" +source = "git+https://github.com/kvark/blade?rev=810ec594358aafea29a4a3d8ab601d25292b2ce4#810ec594358aafea29a4a3d8ab601d25292b2ce4" dependencies = [ "ash", "ash-window", @@ -1464,7 +1464,7 @@ dependencies = [ [[package]] name = "blade-macros" version = "0.2.1" -source = "git+https://github.com/kvark/blade?rev=61cbd6b2c224791d52b150fe535cee665cc91bb2#61cbd6b2c224791d52b150fe535cee665cc91bb2" +source = "git+https://github.com/kvark/blade?rev=810ec594358aafea29a4a3d8ab601d25292b2ce4#810ec594358aafea29a4a3d8ab601d25292b2ce4" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 0955d9bdc9b61..13d5d3f8cc2cd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -229,8 +229,8 @@ async-recursion = "1.0.0" async-tar = "0.4.2" async-trait = "0.1" bitflags = "2.4.2" -blade-graphics = { git = "https://github.com/kvark/blade", rev = "61cbd6b2c224791d52b150fe535cee665cc91bb2" } -blade-macros = { git = "https://github.com/kvark/blade", rev = "61cbd6b2c224791d52b150fe535cee665cc91bb2" } +blade-graphics = { git = "https://github.com/kvark/blade", rev = "810ec594358aafea29a4a3d8ab601d25292b2ce4" } +blade-macros = { git = "https://github.com/kvark/blade", rev = "810ec594358aafea29a4a3d8ab601d25292b2ce4" } blade-rwh = { package = "raw-window-handle", version = "0.5" } cap-std = "3.0" chrono = { version = "0.4", features = ["serde"] } diff --git a/crates/gpui/src/platform/blade/blade_atlas.rs b/crates/gpui/src/platform/blade/blade_atlas.rs index c2886f5cc06b3..5e093c2e46865 100644 --- a/crates/gpui/src/platform/blade/blade_atlas.rs +++ b/crates/gpui/src/platform/blade/blade_atlas.rs @@ -29,6 +29,9 @@ struct BladeAtlasState { uploads: Vec, } +#[cfg(gles)] +unsafe impl Send for BladeAtlasState {} + impl BladeAtlasState { fn destroy(&mut self) { self.storage.destroy(&self.gpu); diff --git a/crates/gpui/src/platform/blade/blade_renderer.rs b/crates/gpui/src/platform/blade/blade_renderer.rs index 192f487d77d96..ae7dda2f92bbb 100644 --- a/crates/gpui/src/platform/blade/blade_renderer.rs +++ b/crates/gpui/src/platform/blade/blade_renderer.rs @@ -17,7 +17,6 @@ use std::ffi::c_void; use blade_graphics as gpu; use std::{mem, sync::Arc}; -const SURFACE_FRAME_COUNT: u32 = 3; const MAX_FRAME_TIME_MS: u32 = 1000; pub type Context = (); @@ -209,6 +208,7 @@ impl BladePipelines { name: "quads", data_layouts: &[&ShaderQuadsData::layout()], vertex: shader.at("vs_quad"), + vertex_fetches: &[], primitive: gpu::PrimitiveState { topology: gpu::PrimitiveTopology::TriangleStrip, ..Default::default() @@ -225,6 +225,7 @@ impl BladePipelines { name: "shadows", data_layouts: &[&ShaderShadowsData::layout()], vertex: shader.at("vs_shadow"), + vertex_fetches: &[], primitive: gpu::PrimitiveState { topology: gpu::PrimitiveTopology::TriangleStrip, ..Default::default() @@ -241,6 +242,7 @@ impl BladePipelines { name: "path_rasterization", data_layouts: &[&ShaderPathRasterizationData::layout()], vertex: shader.at("vs_path_rasterization"), + vertex_fetches: &[], primitive: gpu::PrimitiveState { topology: gpu::PrimitiveTopology::TriangleList, ..Default::default() @@ -257,6 +259,7 @@ impl BladePipelines { name: "paths", data_layouts: &[&ShaderPathsData::layout()], vertex: shader.at("vs_path"), + vertex_fetches: &[], primitive: gpu::PrimitiveState { topology: gpu::PrimitiveTopology::TriangleStrip, ..Default::default() @@ -273,6 +276,7 @@ impl BladePipelines { name: "underlines", data_layouts: &[&ShaderUnderlinesData::layout()], vertex: shader.at("vs_underline"), + vertex_fetches: &[], primitive: gpu::PrimitiveState { topology: gpu::PrimitiveTopology::TriangleStrip, ..Default::default() @@ -289,6 +293,7 @@ impl BladePipelines { name: "mono-sprites", data_layouts: &[&ShaderMonoSpritesData::layout()], vertex: shader.at("vs_mono_sprite"), + vertex_fetches: &[], primitive: gpu::PrimitiveState { topology: gpu::PrimitiveTopology::TriangleStrip, ..Default::default() @@ -305,6 +310,7 @@ impl BladePipelines { name: "poly-sprites", data_layouts: &[&ShaderPolySpritesData::layout()], vertex: shader.at("vs_poly_sprite"), + vertex_fetches: &[], primitive: gpu::PrimitiveState { topology: gpu::PrimitiveTopology::TriangleStrip, ..Default::default() @@ -321,6 +327,7 @@ impl BladePipelines { name: "surfaces", data_layouts: &[&ShaderSurfacesData::layout()], vertex: shader.at("vs_surface"), + vertex_fetches: &[], primitive: gpu::PrimitiveState { topology: gpu::PrimitiveTopology::TriangleStrip, ..Default::default() @@ -356,7 +363,7 @@ impl BladeRenderer { gpu::SurfaceConfig { size, usage: gpu::TextureUsage::TARGET, - frame_count: SURFACE_FRAME_COUNT, + display_sync: gpu::DisplaySync::Recent, //Note: this matches the original logic of the Metal backend, // but ultimaterly we need to switch to `Linear`. color_space: gpu::ColorSpace::Srgb,