Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

blade: Fix initialization of atlas textures used for path rasterization (#8000)

Dzmitry Malyshau4e1e26b69667
diff --git a/crates/gpui/src/platform/blade/blade_atlas.rs b/crates/gpui/src/platform/blade/blade_atlas.rs
index 46156664889..ccebc93b308 100644
--- a/crates/gpui/src/platform/blade/blade_atlas.rs
+++ b/crates/gpui/src/platform/blade/blade_atlas.rs
@@ -69,9 +69,17 @@ impl BladeAtlas {
}
}
- pub fn allocate(&self, size: Size<DevicePixels>, texture_kind: AtlasTextureKind) -> AtlasTile {
+ /// Allocate a rectangle and make it available for rendering immediately (without waiting for `before_frame`)
+ pub fn allocate_for_rendering(
+ &self,
+ size: Size<DevicePixels>,
+ texture_kind: AtlasTextureKind,
+ gpu_encoder: &mut gpu::CommandEncoder,
+ ) -> AtlasTile {
let mut lock = self.0.lock();
- lock.allocate(size, texture_kind)
+ let tile = lock.allocate(size, texture_kind);
+ lock.flush_initializations(gpu_encoder);
+ tile
}
pub fn before_frame(&self, gpu_encoder: &mut gpu::CommandEncoder) {
@@ -204,11 +212,15 @@ impl BladeAtlasState {
self.uploads.push(PendingUpload { id, bounds, data });
}
- fn flush(&mut self, encoder: &mut gpu::CommandEncoder) {
+ fn flush_initializations(&mut self, encoder: &mut gpu::CommandEncoder) {
for id in self.initializations.drain(..) {
let texture = &self.storage[id];
encoder.init_texture(texture.raw);
}
+ }
+
+ fn flush(&mut self, encoder: &mut gpu::CommandEncoder) {
+ self.flush_initializations(encoder);
let mut transfers = encoder.transfer();
for upload in self.uploads.drain(..) {
diff --git a/crates/gpui/src/platform/blade/blade_renderer.rs b/crates/gpui/src/platform/blade/blade_renderer.rs
index ce835073b15..d715bed895b 100644
--- a/crates/gpui/src/platform/blade/blade_renderer.rs
+++ b/crates/gpui/src/platform/blade/blade_renderer.rs
@@ -450,9 +450,11 @@ impl BladeRenderer {
for path in paths {
let clipped_bounds = path.bounds.intersect(&path.content_mask.bounds);
- let tile = self
- .atlas
- .allocate(clipped_bounds.size.map(Into::into), AtlasTextureKind::Path);
+ let tile = self.atlas.allocate_for_rendering(
+ clipped_bounds.size.map(Into::into),
+ AtlasTextureKind::Path,
+ &mut self.command_encoder,
+ );
vertices_by_texture_id
.entry(tile.texture_id)
.or_insert(Vec::new())