From 224fe13f9f7c8052c381456ebf297f88fcd04001 Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Sun, 4 Feb 2024 13:59:41 -0800 Subject: [PATCH] blade: fix tile bounds shader FFI --- crates/gpui/src/platform/linux/platform.rs | 12 ++++++++---- crates/gpui/src/platform/linux/shaders.wgsl | 8 ++++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/crates/gpui/src/platform/linux/platform.rs b/crates/gpui/src/platform/linux/platform.rs index f5f251f1effec29b607988a985e6ee32e1e0a6bb..b7d51971a1964991b66c1810131bbae395b3261c 100644 --- a/crates/gpui/src/platform/linux/platform.rs +++ b/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, windows: HashMap>, text_system: Arc, } @@ -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, ) { - unimplemented!() + log::warn!("unimplemented: set_display_link_output_callback"); } fn start_display_link(&self, display_id: DisplayId) {} diff --git a/crates/gpui/src/platform/linux/shaders.wgsl b/crates/gpui/src/platform/linux/shaders.wgsl index 05174c0d7f7fe7a7115f4aa08ceb2e9637883549..58dd3265bf9be24a3836cda13f24215d1e19c749 100644 --- a/crates/gpui/src/platform/linux/shaders.wgsl +++ b/crates/gpui/src/platform/linux/shaders.wgsl @@ -43,11 +43,15 @@ struct AtlasTextureId { kind: u32, } +struct AtlasBounds { + origin: vec2, + size: vec2, +} struct AtlasTile { texture_id: AtlasTextureId, tile_id: u32, padding: u32, - bounds: Bounds, + bounds: AtlasBounds, } fn to_device_position_impl(position: vec2) -> vec4 { @@ -62,7 +66,7 @@ fn to_device_position(unit_vertex: vec2, bounds: Bounds) -> vec4 { fn to_tile_position(unit_vertex: vec2, tile: AtlasTile) -> vec2 { let atlas_size = vec2(textureDimensions(t_sprite, 0)); - return (tile.bounds.origin + unit_vertex * tile.bounds.size) / atlas_size; + return (vec2(tile.bounds.origin) + unit_vertex * vec2(tile.bounds.size)) / atlas_size; } fn distance_from_clip_rect_impl(position: vec2, clip_bounds: Bounds) -> vec4 {