Update blade to a version that can run GLES for Zed (#10243)

Dzmitry Malyshau and Mikayla Maki created

Release Notes:
- N/A

Picks up https://github.com/kvark/blade/pull/105,
https://github.com/kvark/blade/pull/97, and more

Switches the presentation to be non-blocking, which will improve the
latency slightly.

Allows to start playing with GLES backend, e.g.
```bash
cd crates/gpui
RUSTFLAGS="--cfg gles" CARGO_TARGET_DIR=./target-gl cargo run --example hello_world
```

It doesn't currently render properly due to an issue that needs
investigation, see
https://github.com/kvark/blade/pull/105#issuecomment-2041006542
But at least it's a start

Co-authored-by: Mikayla Maki <mikayla@zed.dev>

Change summary

Cargo.lock                                       |  6 +++---
Cargo.toml                                       |  5 ++---
crates/gpui/src/platform/blade/blade_atlas.rs    |  3 +++
crates/gpui/src/platform/blade/blade_renderer.rs | 11 +++++++++--
4 files changed, 17 insertions(+), 8 deletions(-)

Detailed changes

Cargo.lock 🔗

@@ -1439,8 +1439,8 @@ dependencies = [
 
 [[package]]
 name = "blade-graphics"
-version = "0.3.0"
-source = "git+https://github.com/zed-industries/blade?rev=85981c0f4890a5fcd08da2a53cc4a0459247af44#85981c0f4890a5fcd08da2a53cc4a0459247af44"
+version = "0.4.0"
+source = "git+https://github.com/kvark/blade?rev=810ec594358aafea29a4a3d8ab601d25292b2ce4#810ec594358aafea29a4a3d8ab601d25292b2ce4"
 dependencies = [
  "ash",
  "ash-window",
@@ -1470,7 +1470,7 @@ dependencies = [
 [[package]]
 name = "blade-macros"
 version = "0.2.1"
-source = "git+https://github.com/zed-industries/blade?rev=85981c0f4890a5fcd08da2a53cc4a0459247af44#85981c0f4890a5fcd08da2a53cc4a0459247af44"
+source = "git+https://github.com/kvark/blade?rev=810ec594358aafea29a4a3d8ab601d25292b2ce4#810ec594358aafea29a4a3d8ab601d25292b2ce4"
 dependencies = [
  "proc-macro2",
  "quote",

Cargo.toml 🔗

@@ -230,9 +230,8 @@ async-recursion = "1.0.0"
 async-tar = "0.4.2"
 async-trait = "0.1"
 bitflags = "2.4.2"
-# todo(linux): Remove these once https://github.com/kvark/blade/pull/107 is merged and we've upgraded our renderer
-blade-graphics = { git = "https://github.com/zed-industries/blade", rev = "85981c0f4890a5fcd08da2a53cc4a0459247af44" }
-blade-macros = { git = "https://github.com/zed-industries/blade", rev = "85981c0f4890a5fcd08da2a53cc4a0459247af44" }
+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"] }

crates/gpui/src/platform/blade/blade_atlas.rs 🔗

@@ -29,6 +29,9 @@ struct BladeAtlasState {
     uploads: Vec<PendingUpload>,
 }
 
+#[cfg(gles)]
+unsafe impl Send for BladeAtlasState {}
+
 impl BladeAtlasState {
     fn destroy(&mut self) {
         self.storage.destroy(&self.gpu);

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,