From eb5e18c66dbcf5c786cee595484fca44b36c3f2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=B1=B1=E9=A2=A8=E9=9C=B2?= Date: Tue, 12 Mar 2024 00:06:20 +0900 Subject: [PATCH] Fix blade validation failure (#9172) Fix: #9167 Release Notes: - N/A --- crates/gpui/src/platform/blade/shaders.wgsl | 23 ++++----------------- crates/gpui/src/scene.rs | 9 ++++---- crates/gpui/src/window/element_cx.rs | 14 +++++++------ 3 files changed, 17 insertions(+), 29 deletions(-) diff --git a/crates/gpui/src/platform/blade/shaders.wgsl b/crates/gpui/src/platform/blade/shaders.wgsl index 84130316552f9054f4a98cc108796d48086fe329..f8053d452ad47b77706c7c5e6ecba1602e7401de 100644 --- a/crates/gpui/src/platform/blade/shaders.wgsl +++ b/crates/gpui/src/platform/blade/shaders.wgsl @@ -10,11 +10,6 @@ var s_sprite: sampler; const M_PI_F: f32 = 3.1415926; const GRAYSCALE_FACTORS: vec3 = vec3(0.2126, 0.7152, 0.0722); -struct ViewId { - lo: u32, - hi: u32, -} - struct Bounds { origin: vec2, size: vec2, @@ -172,8 +167,6 @@ fn quad_sdf(point: vec2, bounds: Bounds, corner_radii: Corners) -> f32 { // --- quads --- // struct Quad { - view_id: ViewId, - layer_id: u32, order: u32, bounds: Bounds, content_mask: Bounds, @@ -266,15 +259,12 @@ fn fs_quad(input: QuadVarying) -> @location(0) vec4 { // --- shadows --- // struct Shadow { - view_id: ViewId, - layer_id: u32, order: u32, + blur_radius: f32, bounds: Bounds, corner_radii: Corners, content_mask: Bounds, color: Hsla, - blur_radius: f32, - pad: u32, } var b_shadows: array; @@ -418,9 +408,8 @@ fn fs_path(input: PathVarying) -> @location(0) vec4 { // --- underlines --- // struct Underline { - view_id: ViewId, - layer_id: u32, order: u32, + pad: u32, bounds: Bounds, content_mask: Bounds, color: Hsla, @@ -480,9 +469,8 @@ fn fs_underline(input: UnderlineVarying) -> @location(0) vec4 { // --- monochrome sprites --- // struct MonochromeSprite { - view_id: ViewId, - layer_id: u32, order: u32, + pad: u32, bounds: Bounds, content_mask: Bounds, color: Hsla, @@ -523,15 +511,12 @@ fn fs_mono_sprite(input: MonoSpriteVarying) -> @location(0) vec4 { // --- polychrome sprites --- // struct PolychromeSprite { - view_id: ViewId, - layer_id: u32, order: u32, + grayscale: u32, bounds: Bounds, content_mask: Bounds, corner_radii: Corners, tile: AtlasTile, - grayscale: u32, - pad: u32, } var b_poly_sprites: array; diff --git a/crates/gpui/src/scene.rs b/crates/gpui/src/scene.rs index 21111c8bc75cd3668fb79bb63d01c58b7959e652..844b854903ddc66fdf1e664bba653cd348ad85b3 100644 --- a/crates/gpui/src/scene.rs +++ b/crates/gpui/src/scene.rs @@ -418,6 +418,7 @@ pub(crate) enum PrimitiveBatch<'a> { #[repr(C)] pub(crate) struct Quad { pub order: DrawOrder, + pub pad: u32, // align to 8 bytes pub bounds: Bounds, pub content_mask: ContentMask, pub background: Hsla, @@ -448,6 +449,7 @@ impl From for Primitive { #[repr(C)] pub(crate) struct Underline { pub order: DrawOrder, + pub pad: u32, // align to 8 bytes pub bounds: Bounds, pub content_mask: ContentMask, pub color: Hsla, @@ -477,12 +479,11 @@ impl From for Primitive { #[repr(C)] pub(crate) struct Shadow { pub order: DrawOrder, + pub blur_radius: ScaledPixels, pub bounds: Bounds, pub corner_radii: Corners, pub content_mask: ContentMask, pub color: Hsla, - pub blur_radius: ScaledPixels, - pub pad: u32, // align to 8 bytes } impl Ord for Shadow { @@ -507,6 +508,7 @@ impl From for Primitive { #[repr(C)] pub(crate) struct MonochromeSprite { pub order: DrawOrder, + pub pad: u32, // align to 8 bytes pub bounds: Bounds, pub content_mask: ContentMask, pub color: Hsla, @@ -538,12 +540,11 @@ impl From for Primitive { #[repr(C)] pub(crate) struct PolychromeSprite { pub order: DrawOrder, + pub grayscale: bool, pub bounds: Bounds, pub content_mask: ContentMask, pub corner_radii: Corners, pub tile: AtlasTile, - pub grayscale: bool, - pub pad: u32, // align to 8 bytes } impl Ord for PolychromeSprite { diff --git a/crates/gpui/src/window/element_cx.rs b/crates/gpui/src/window/element_cx.rs index ec58d25c3083185f498e8cad492853d3b97c43e7..4a30becbe2d032ab5cb10a49c927de09324f6485 100644 --- a/crates/gpui/src/window/element_cx.rs +++ b/crates/gpui/src/window/element_cx.rs @@ -859,12 +859,11 @@ impl<'a> ElementContext<'a> { shadow_bounds.dilate(shadow.spread_radius); self.window.next_frame.scene.insert_primitive(Shadow { order: 0, + blur_radius: shadow.blur_radius.scale(scale_factor), bounds: shadow_bounds.scale(scale_factor), content_mask: content_mask.scale(scale_factor), corner_radii: corner_radii.scale(scale_factor), color: shadow.color, - blur_radius: shadow.blur_radius.scale(scale_factor), - pad: 0, }); } } @@ -877,6 +876,7 @@ impl<'a> ElementContext<'a> { let content_mask = self.content_mask(); self.window.next_frame.scene.insert_primitive(Quad { order: 0, + pad: 0, bounds: quad.bounds.scale(scale_factor), content_mask: content_mask.scale(scale_factor), background: quad.background, @@ -919,6 +919,7 @@ impl<'a> ElementContext<'a> { self.window.next_frame.scene.insert_primitive(Underline { order: 0, + pad: 0, bounds: bounds.scale(scale_factor), content_mask: content_mask.scale(scale_factor), color: style.color.unwrap_or_default(), @@ -944,6 +945,7 @@ impl<'a> ElementContext<'a> { self.window.next_frame.scene.insert_primitive(Underline { order: 0, + pad: 0, bounds: bounds.scale(scale_factor), content_mask: content_mask.scale(scale_factor), thickness: style.thickness.scale(scale_factor), @@ -1000,6 +1002,7 @@ impl<'a> ElementContext<'a> { .scene .insert_primitive(MonochromeSprite { order: 0, + pad: 0, bounds, content_mask, color, @@ -1054,12 +1057,11 @@ impl<'a> ElementContext<'a> { .scene .insert_primitive(PolychromeSprite { order: 0, + grayscale: false, bounds, corner_radii: Default::default(), content_mask, tile, - grayscale: false, - pad: 0, }); } Ok(()) @@ -1096,6 +1098,7 @@ impl<'a> ElementContext<'a> { .scene .insert_primitive(MonochromeSprite { order: 0, + pad: 0, bounds, content_mask, color, @@ -1131,12 +1134,11 @@ impl<'a> ElementContext<'a> { .scene .insert_primitive(PolychromeSprite { order: 0, + grayscale, bounds, content_mask, corner_radii, tile, - grayscale, - pad: 0, }); Ok(()) }