diff --git a/crates/gpui/src/platform/blade/blade_atlas.rs b/crates/gpui/src/platform/blade/blade_atlas.rs index 461566648897c8d5e3bd508f657173edf264098d..ccebc93b308da264c0b3f45ac6cd1f45a3098bbf 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, 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, + 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 ce835073b15ebf3a67e7c9375402ede92ee87c5d..d715bed895b9b5d2cdf449bd9ffe3e5f0d439b86 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())