blade: fix tile bounds shader FFI

Dzmitry Malyshau created

Change summary

crates/gpui/src/platform/linux/platform.rs  | 12 ++++++++----
crates/gpui/src/platform/linux/shaders.wgsl |  8 ++++++--
2 files changed, 14 insertions(+), 6 deletions(-)

Detailed changes

crates/gpui/src/platform/linux/platform.rs 🔗

@@ -3,8 +3,9 @@
 use crate::{
     Action, AnyWindowHandle, BackgroundExecutor, Bounds, ClipboardItem, CursorStyle, DisplayId,
     ForegroundExecutor, Keymap, LinuxDispatcher, LinuxDisplay, LinuxTextSystem, LinuxWindow,
-    LinuxWindowState, Menu, PathPromptOptions, Platform, PlatformDisplay, PlatformInput,
-    PlatformTextSystem, PlatformWindow, Point, Result, SemanticVersion, Size, Task, WindowOptions,
+    LinuxWindowState, Menu, PathPromptOptions, Platform, PlatformDispatcher as _, PlatformDisplay,
+    PlatformInput, PlatformTextSystem, PlatformWindow, Point, Result, SemanticVersion, Size, Task,
+    WindowOptions,
 };
 
 use collections::{HashMap, HashSet};
@@ -39,6 +40,7 @@ pub(crate) struct LinuxPlatformState {
     atoms: XcbAtoms,
     background_executor: BackgroundExecutor,
     foreground_executor: ForegroundExecutor,
+    dispatcher: Arc<LinuxDispatcher>,
     windows: HashMap<x::Window, Arc<LinuxWindowState>>,
     text_system: Arc<LinuxTextSystem>,
 }
@@ -61,7 +63,8 @@ impl LinuxPlatform {
             x_root_index,
             atoms,
             background_executor: BackgroundExecutor::new(dispatcher.clone()),
-            foreground_executor: ForegroundExecutor::new(dispatcher),
+            foreground_executor: ForegroundExecutor::new(dispatcher.clone()),
+            dispatcher,
             windows: HashMap::default(),
             text_system: Arc::new(LinuxTextSystem::new()),
         }))
@@ -118,6 +121,7 @@ impl Platform for LinuxPlatform {
                 }
                 _ => {}
             }
+            self.0.lock().dispatcher.tick(false);
         }
     }
 
@@ -182,7 +186,7 @@ impl Platform for LinuxPlatform {
         display_id: DisplayId,
         callback: Box<dyn FnMut() + Send>,
     ) {
-        unimplemented!()
+        log::warn!("unimplemented: set_display_link_output_callback");
     }
 
     fn start_display_link(&self, display_id: DisplayId) {}

crates/gpui/src/platform/linux/shaders.wgsl 🔗

@@ -43,11 +43,15 @@ struct AtlasTextureId {
     kind: u32,
 }
 
+struct AtlasBounds {
+    origin: vec2<i32>,
+    size: vec2<i32>,
+}
 struct AtlasTile {
     texture_id: AtlasTextureId,
     tile_id: u32,
     padding: u32,
-    bounds: Bounds,
+    bounds: AtlasBounds,
 }
 
 fn to_device_position_impl(position: vec2<f32>) -> vec4<f32> {
@@ -62,7 +66,7 @@ fn to_device_position(unit_vertex: vec2<f32>, bounds: Bounds) -> vec4<f32> {
 
 fn to_tile_position(unit_vertex: vec2<f32>, tile: AtlasTile) -> vec2<f32> {
   let atlas_size = vec2<f32>(textureDimensions(t_sprite, 0));
-  return (tile.bounds.origin + unit_vertex * tile.bounds.size) / atlas_size;
+  return (vec2<f32>(tile.bounds.origin) + unit_vertex * vec2<f32>(tile.bounds.size)) / atlas_size;
 }
 
 fn distance_from_clip_rect_impl(position: vec2<f32>, clip_bounds: Bounds) -> vec4<f32> {