Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux port via Blade #7343

Merged
merged 53 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
ef4ef5f
Add blade dependency
kvark Jan 25, 2024
d675abf
Add Linux platform, gate usage of CVImageBuffer by macOS
kvark Jan 25, 2024
ca62d22
linux: implement dispatcher, add dummy textsystem
kvark Jan 26, 2024
b0376aa
linux: start the text system
kvark Jan 26, 2024
e95bf24
linux: basic window, display, and atlas
kvark Jan 27, 2024
cefc982
linux: hook up X11rb for Window creation
kvark Jan 28, 2024
aed363d
x11: create window and route events
kvark Jan 28, 2024
7f8c64a
linux: port from x11rb to xcb and hook up RawWindowHandle
kvark Jan 29, 2024
74fde59
linux: hook up render event, basic renderer command buffer
kvark Jan 29, 2024
503ac7a
linux: work around the mutex locks for request_frame and resize
kvark Jan 29, 2024
8aa7687
linux: basic quad renderer logic
kvark Jan 30, 2024
ecf4955
hide MacOS dependencie of live_kit_client and media
kvark Jan 31, 2024
666b134
linux: shadow rendering
kvark Jan 31, 2024
c9ec337
linux: share corner picking code between shaders
kvark Jan 31, 2024
ce84a2a
linux: refactor window structure, support move callback
kvark Feb 1, 2024
ed679c9
WIP path rasterization
kvark Feb 1, 2024
05c4221
linux: implement RWH for LinuxWindow
kvark Feb 2, 2024
fdaffdb
linux: path rasterization shader
kvark Feb 2, 2024
c000d2e
blade: path sprite rendering
kvark Feb 2, 2024
04e49dc
blade: refactor the atlas to not own the command encoder
kvark Feb 3, 2024
7c7aad5
blade: port underline shader
kvark Feb 3, 2024
2e32f58
linux: various fixes across the crates to make it compile
kvark Feb 3, 2024
59642bf
blade: point to master, remove the override
kvark Feb 3, 2024
d0a0ce1
blade: mono/poly chrome sprite rendering
kvark Feb 4, 2024
cf71fe8
fix MacOS build, switch external RWH to 0.6
kvark Feb 4, 2024
c5ff46e
blade: fix shadow vertex bounds
kvark Feb 4, 2024
d6bbcf5
blade: enforce alignment in the belt
kvark Feb 4, 2024
13ba8b6
Fix linux target in rust-toolchain.toml
kvark Feb 4, 2024
aae5329
blade: tune belt alignment to match Intel Iris Xe
kvark Feb 4, 2024
61fa5e9
blade: always create texture views for atlas tiles
kvark Feb 4, 2024
26ca798
blade: initialize atlas textures
kvark Feb 4, 2024
0a5ebee
blade: encapsulate BladeAtlasStorage for indexing
kvark Feb 4, 2024
224fe13
blade: fix tile bounds shader FFI
kvark Feb 4, 2024
b13b572
linux: disable mac-os specific build commands
kvark Feb 4, 2024
f92be4b
linux: temporarily disable purescript tree sitter
kvark Feb 4, 2024
1c410c1
linux: only tick the main thread tasks and one at a time in the event…
kvark Feb 5, 2024
d03f3b9
linux: switch folders to use CONFIG_DIR
kvark Feb 5, 2024
8d339ed
linux: HACK disable watcher and crash uploader temporarily
kvark Feb 5, 2024
282cc71
linux: refactor LinuxPlatform to avoid recursive locking from the win…
kvark Feb 5, 2024
521b2b1
linux: create a hidden window inside the platform
kvark Feb 5, 2024
fde159f
build: add Blade font-config sys deps on Linux
aminya Feb 5, 2024
81bfa5f
fix: create the settings and keymaps to unblock file watching
aminya Feb 5, 2024
7721b55
Refactor cli and gpui dependnecies based on PR review feedback
kvark Feb 6, 2024
78f32f3
linux: introduce platform callbacks
kvark Feb 6, 2024
7509677
add a few more libraries to the linux script
mikayla-maki Feb 6, 2024
11964dc
blade: cull mask support for sprites
kvark Feb 6, 2024
d3562d4
Fixes for file-watching, user assets, and system dependencies (#2)
aminya Feb 7, 2024
e3ae7c4
linux: query window geometry for determining the surface extents
kvark Feb 7, 2024
3734a39
Mark TODOs and prep for merging main
mikayla-maki Feb 7, 2024
67555ee
Merge branch 'main' into kvark-linux
mikayla-maki Feb 7, 2024
f507698
Fix a few out of date warnings
mikayla-maki Feb 7, 2024
be455f7
Restore nanoid dependency
mikayla-maki Feb 7, 2024
3a53db6
Merge branch 'main' into kvark-linux
mikayla-maki Feb 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
274 changes: 268 additions & 6 deletions Cargo.lock

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,11 @@ wasmtime = { git = "https://github.com/bytecodealliance/wasmtime", rev = "v16.0.
split-debuginfo = "unpacked"
debug = "limited"

# todo!(linux) - Remove this
[profile.dev.package.blade-graphics]
split-debuginfo = "off"
debug = "full"

[profile.dev.package.taffy]
opt-level = 3

Expand Down
7 changes: 6 additions & 1 deletion crates/fs/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,12 +287,17 @@ impl Fs for RealFs {
) -> Pin<Box<dyn Send + Stream<Item = Vec<Event>>>> {
let (tx, rx) = smol::channel::unbounded();

if !path.exists() {
log::error!("watch path does not exist: {}", path.display());
return Box::pin(rx);
}

let mut watcher = notify::recommended_watcher(move |res| match res {
Ok(event) => {
let _ = tx.try_send(vec![event]);
}
Err(err) => {
eprintln!("watch error: {:?}", err);
log::error!("watch error: {}", err);
}
})
.unwrap();
Expand Down
14 changes: 12 additions & 2 deletions crates/gpui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ dhat = { version = "0.3", optional = true }
env_logger = { version = "0.9", optional = true }
etagere = "0.2"
futures.workspace = true
font-kit = { git = "https://github.com/zed-industries/font-kit", rev = "d97147f" }
gpui_macros.workspace = true
image = "0.23"
itertools = "0.10"
Expand All @@ -46,7 +47,8 @@ parking_lot.workspace = true
pathfinder_geometry = "0.5"
postage.workspace = true
rand.workspace = true
raw-window-handle = "0.6.0"
raw-window-handle = "0.6"
blade-rwh = { package = "raw-window-handle", version = "0.5" }
refineable.workspace = true
resvg = "0.14"
schemars.workspace = true
Expand Down Expand Up @@ -86,9 +88,17 @@ cocoa = "0.25"
core-foundation = { version = "0.9.3", features = ["with-uuid"] }
core-graphics = "0.22.3"
core-text = "19.2"
font-kit = { git = "https://github.com/zed-industries/font-kit", rev = "d97147f" }
foreign-types = "0.3"
log.workspace = true
media.workspace = true
metal = "0.21.0"
objc = "0.2"

[target.'cfg(target_os = "linux")'.dependencies]
flume = "0.11"
xcb = { version = "1.3", features = ["as-raw-xcb-connection"] }
as-raw-xcb-connection = "1"
#TODO: use these on all platforms
blade-graphics = { git = "https://github.com/kvark/blade", rev = "f35bc605154e210ab6190291235889b6ddad73f1" }
blade-macros = { git = "https://github.com/kvark/blade", rev = "f35bc605154e210ab6190291235889b6ddad73f1" }
bytemuck = "1"
6 changes: 6 additions & 0 deletions crates/gpui/build.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg_attr(not(target_os = "macos"), allow(unused))]

use std::{
env,
path::{Path, PathBuf},
Expand All @@ -6,10 +8,14 @@ use std::{
use cbindgen::Config;

fn main() {
#[cfg(target_os = "macos")]
generate_dispatch_bindings();
#[cfg(target_os = "macos")]
let header_path = generate_shader_bindings();
#[cfg(target_os = "macos")]
#[cfg(feature = "runtime_shaders")]
emit_stitched_shaders(&header_path);
#[cfg(target_os = "macos")]
#[cfg(not(feature = "runtime_shaders"))]
compile_metal_shaders(&header_path);
}
Expand Down
5 changes: 4 additions & 1 deletion crates/gpui/examples/hello_world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ impl Render for HelloWorld {
div()
.flex()
.bg(rgb(0x2e7d32))
.size_full()
.size(Length::Definite(Pixels(300.0).into()))
.justify_center()
.items_center()
.shadow_lg()
.border()
.border_color(rgb(0x0000ff))
.text_xl()
.text_color(rgb(0xffffff))
.child(format!("Hello, {}!", &self.text))
Expand Down
4 changes: 4 additions & 0 deletions crates/gpui/src/elements/img.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use crate::{
StyleRefinement, Styled, UriOrPath,
};
use futures::FutureExt;
#[cfg(target_os = "macos")]
use media::core_video::CVImageBuffer;
use util::ResultExt;

Expand All @@ -21,6 +22,7 @@ pub enum ImageSource {
Data(Arc<ImageData>),
// TODO: move surface definitions into mac platform module
/// A CoreVideo image buffer
#[cfg(target_os = "macos")]
Surface(CVImageBuffer),
}

Expand Down Expand Up @@ -54,6 +56,7 @@ impl From<Arc<ImageData>> for ImageSource {
}
}

#[cfg(target_os = "macos")]
impl From<CVImageBuffer> for ImageSource {
fn from(value: CVImageBuffer) -> Self {
Self::Surface(value)
Expand Down Expand Up @@ -144,6 +147,7 @@ impl Element for Img {
.log_err();
}

#[cfg(target_os = "macos")]
ImageSource::Surface(surface) => {
let size = size(surface.width().into(), surface.height().into());
let new_bounds = preserve_aspect_ratio(bounds, size);
Expand Down
3 changes: 1 addition & 2 deletions crates/gpui/src/gpui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
//! ## Getting Started
//!
//! GPUI is still in active development as we work on the Zed code editor and isn't yet on crates.io.
//! You'll also need to use the latest version of stable rust and be on macOS. Add the following to your
//! Cargo.toml:
//! You'll also need to use the latest version of stable rust. Add the following to your Cargo.toml:
//!
//! ```
//! gpui = { git = "https://github.com/zed-industries/zed" }
Expand Down
9 changes: 9 additions & 0 deletions crates/gpui/src/platform.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
mod app_menu;
mod keystroke;
#[cfg(target_os = "linux")]
mod linux;
#[cfg(target_os = "macos")]
mod mac;
#[cfg(any(test, feature = "test-support"))]
Expand Down Expand Up @@ -33,6 +35,8 @@ use uuid::Uuid;

pub use app_menu::*;
pub use keystroke::*;
#[cfg(target_os = "linux")]
pub(crate) use linux::*;
#[cfg(target_os = "macos")]
pub(crate) use mac::*;
#[cfg(any(test, feature = "test-support"))]
Expand All @@ -44,6 +48,10 @@ pub use util::SemanticVersion;
pub(crate) fn current_platform() -> Rc<dyn Platform> {
Rc::new(MacPlatform::new())
}
#[cfg(target_os = "linux")]
pub(crate) fn current_platform() -> Rc<dyn Platform> {
Rc::new(LinuxPlatform::new())
}

pub(crate) trait Platform: 'static {
fn background_executor(&self) -> BackgroundExecutor;
Expand Down Expand Up @@ -298,6 +306,7 @@ pub(crate) trait PlatformAtlas: Send + Sync {
pub(crate) struct AtlasTile {
pub(crate) texture_id: AtlasTextureId,
pub(crate) tile_id: TileId,
pub(crate) padding: u32,
pub(crate) bounds: Bounds<DevicePixels>,
}

Expand Down
18 changes: 18 additions & 0 deletions crates/gpui/src/platform/linux.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
mod blade_atlas;
mod blade_belt;
mod blade_renderer;
mod dispatcher;
mod display;
mod platform;
mod text_system;
mod window;

pub(crate) use blade_atlas::*;
pub(crate) use dispatcher::*;
pub(crate) use display::*;
pub(crate) use platform::*;
pub(crate) use text_system::*;
pub(crate) use window::*;

use blade_belt::*;
use blade_renderer::*;
Loading
Loading