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.

gpui: Group sprites by atlas texture and colocate sort keys (#65814)

Lukas Wirthb4ecc454225f
diff --git a/crates/gpui/src/scene.rs b/crates/gpui/src/scene.rs
index be378132478..6cb33874b23 100644
--- a/crates/gpui/src/scene.rs
+++ b/crates/gpui/src/scene.rs
@@ -154,11 +154,11 @@ impl Scene {
self.paths.sort_by_key(|path| path.order);
self.underlines.sort_by_key(|underline| underline.order);
self.monochrome_sprites
- .sort_by_key(|sprite| (sprite.order, sprite.tile.tile_id));
+ .sort_by_key(|sprite| (sprite.order, sprite.tile.texture_id.index));
self.subpixel_sprites
- .sort_by_key(|sprite| (sprite.order, sprite.tile.tile_id));
+ .sort_by_key(|sprite| (sprite.order, sprite.tile.texture_id.index));
self.polychrome_sprites
- .sort_by_key(|sprite| (sprite.order, sprite.tile.tile_id));
+ .sort_by_key(|sprite| (sprite.order, sprite.tile.texture_id.index));
self.surfaces.sort_by_key(|surface| surface.order);
}
@@ -711,10 +711,10 @@ impl Default for TransformationMatrix {
pub struct MonochromeSprite {
pub order: DrawOrder,
pub pad: u32,
+ pub tile: AtlasTile,
pub bounds: Bounds<ScaledPixels>,
pub content_mask: ContentMask<ScaledPixels>,
pub color: Hsla,
- pub tile: AtlasTile,
pub transformation: TransformationMatrix,
}
@@ -730,10 +730,10 @@ impl From<MonochromeSprite> for Primitive {
pub struct SubpixelSprite {
pub order: DrawOrder,
pub pad: u32, // align to 8 bytes
+ pub tile: AtlasTile,
pub bounds: Bounds<ScaledPixels>,
pub content_mask: ContentMask<ScaledPixels>,
pub color: Hsla,
- pub tile: AtlasTile,
pub transformation: TransformationMatrix,
}
@@ -749,12 +749,12 @@ impl From<SubpixelSprite> for Primitive {
pub struct PolychromeSprite {
pub order: DrawOrder,
pub pad: u32,
+ pub tile: AtlasTile,
pub grayscale: PaddedBool32,
pub opacity: f32,
pub bounds: Bounds<ScaledPixels>,
pub content_mask: ContentMask<ScaledPixels>,
pub corner_radii: Corners<ScaledPixels>,
- pub tile: AtlasTile,
}
impl From<PolychromeSprite> for Primitive {
diff --git a/crates/gpui_wgpu/src/shaders.wgsl b/crates/gpui_wgpu/src/shaders.wgsl
index 718cb7595d8..9be210bf225 100644
--- a/crates/gpui_wgpu/src/shaders.wgsl
+++ b/crates/gpui_wgpu/src/shaders.wgsl
@@ -1215,10 +1215,10 @@ fn fs_underline(input: UnderlineVarying) -> @location(0) vec4<f32> {
struct MonochromeSprite {
order: u32,
pad: u32,
+ tile: AtlasTile,
bounds: Bounds,
content_mask: Bounds,
color: Hsla,
- tile: AtlasTile,
transformation: TransformationMatrix,
}
@@ -1262,12 +1262,12 @@ fn fs_mono_sprite(input: MonoSpriteVarying) -> @location(0) vec4<f32> {
struct PolychromeSprite {
order: u32,
pad: u32,
+ tile: AtlasTile,
grayscale: u32,
opacity: f32,
bounds: Bounds,
content_mask: Bounds,
corner_radii: Corners,
- tile: AtlasTile,
}
diff --git a/crates/gpui_wgpu/src/shaders_subpixel.wgsl b/crates/gpui_wgpu/src/shaders_subpixel.wgsl
index 8fd936469dc..074d4306d23 100644
--- a/crates/gpui_wgpu/src/shaders_subpixel.wgsl
+++ b/crates/gpui_wgpu/src/shaders_subpixel.wgsl
@@ -3,10 +3,10 @@
struct SubpixelSprite {
order: u32,
pad: u32,
+ tile: AtlasTile,
bounds: Bounds,
content_mask: Bounds,
color: Hsla,
- tile: AtlasTile,
transformation: TransformationMatrix,
}
@group(1) @binding(0) var<storage, read> b_subpixel_sprites: array<SubpixelSprite>;
diff --git a/crates/gpui_wgpu/src/shaders_webgl.wgsl b/crates/gpui_wgpu/src/shaders_webgl.wgsl
index bf5f629cf9d..e28a56568c6 100644
--- a/crates/gpui_wgpu/src/shaders_webgl.wgsl
+++ b/crates/gpui_wgpu/src/shaders_webgl.wgsl
@@ -239,10 +239,10 @@ fn load_mono_sprite(instance_id: u32) -> MonochromeSprite {
return MonochromeSprite(
read_word(&cursor),
read_word(&cursor),
+ read_atlas_tile(&cursor),
read_bounds(&cursor),
read_bounds(&cursor),
read_hsla(&cursor),
- read_atlas_tile(&cursor),
read_transformation(&cursor),
);
}
@@ -252,11 +252,11 @@ fn load_poly_sprite(instance_id: u32) -> PolychromeSprite {
return PolychromeSprite(
read_word(&cursor),
read_word(&cursor),
+ read_atlas_tile(&cursor),
read_word(&cursor),
read_f32(&cursor),
read_bounds(&cursor),
read_bounds(&cursor),
read_corners(&cursor),
- read_atlas_tile(&cursor),
);
}
diff --git a/crates/gpui_windows/src/shaders.hlsl b/crates/gpui_windows/src/shaders.hlsl
index ba89c687335..2f9a00c4186 100644
--- a/crates/gpui_windows/src/shaders.hlsl
+++ b/crates/gpui_windows/src/shaders.hlsl
@@ -1140,10 +1140,10 @@ float4 underline_fragment(UnderlineFragmentInput input): SV_Target {
struct MonochromeSprite {
uint order;
uint pad;
+ AtlasTile tile;
Bounds bounds;
Bounds content_mask;
Hsla color;
- AtlasTile tile;
TransformationMatrix transformation;
};
@@ -1213,12 +1213,12 @@ SubpixelSpriteFragmentOutput subpixel_sprite_fragment(MonochromeSpriteFragmentIn
struct PolychromeSprite {
uint order;
uint pad;
+ AtlasTile tile;
uint grayscale;
float opacity;
Bounds bounds;
Bounds content_mask;
Corners corner_radii;
- AtlasTile tile;
};
struct PolychromeSpriteVertexOutput {