Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
27 changes: 23 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ members = [
"crates/google_ai",
"crates/grammars",
"crates/gpui",
"crates/gpui_apple",
"crates/gpui_shared_string",
"crates/gpui_linux",
"crates/gpui_macos",
Expand Down Expand Up @@ -353,6 +354,7 @@ go_to_line = { path = "crates/go_to_line" }
google_ai = { path = "crates/google_ai" }
grammars = { path = "crates/grammars" }
gpui = { path = "crates/gpui", default-features = false }
gpui_apple = { path = "crates/gpui_apple" }
gpui_shared_string = { path = "crates/gpui_shared_string" }
gpui_linux = { path = "crates/gpui_linux", default-features = false }
gpui_macos = { path = "crates/gpui_macos", default-features = false }
Expand Down
43 changes: 43 additions & 0 deletions crates/gpui_apple/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[package]
name = "gpui_apple"
version = "0.1.0"
edition.workspace = true
publish.workspace = true
license = "Apache-2.0"

[lints]
workspace = true

[lib]
path = "src/gpui_apple.rs"

[features]
default = []
test-support = ["gpui/test-support"]
runtime_shaders = []

[dependencies]
gpui.workspace = true

[target.'cfg(target_os = "macos")'.dependencies]
anyhow.workspace = true
block.workspace = true
cocoa.workspace = true
collections.workspace = true
core-foundation.workspace = true
core-video.workspace = true
derive_more.workspace = true
etagere.workspace = true
foreign-types.workspace = true
image.workspace = true
log.workspace = true
metal.workspace = true
objc.workspace = true
parking_lot.workspace = true

[target.'cfg(target_os = "macos")'.build-dependencies]
cbindgen.workspace = true
gpui.workspace = true

[target.'cfg(target_os = "macos")'.dev-dependencies]
gpui = { workspace = true, features = ["test-support"] }
1 change: 1 addition & 0 deletions crates/gpui_apple/LICENSE-APACHE
File renamed without changes.
8 changes: 8 additions & 0 deletions crates/gpui_apple/src/gpui_apple.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#![cfg(target_os = "macos")]
//! Shared Apple platform support for GPUI.
//!
//! This crate contains the Metal renderer and GPU resource management shared
//! by GPUI's Apple platform backends.

mod metal_atlas;
pub mod metal_renderer;
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use metal::Device;
use parking_lot::Mutex;
use std::borrow::Cow;

pub(crate) struct MetalAtlas(Mutex<MetalAtlasState>);
pub struct MetalAtlas(Mutex<MetalAtlasState>);

impl MetalAtlas {
pub(crate) fn new(device: Device, is_apple_gpu: bool) -> Self {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ const PATH_SAMPLE_COUNT: u32 = 4;
const INSTANCE_BUFFER_ALIGNMENT: usize = 256;
const MAX_INSTANCE_BUFFER_SIZE: usize = 256 * 1024 * 1024;

pub(crate) type Context = Arc<Mutex<InstanceBufferPool>>;
pub(crate) type Renderer = MetalRenderer;
pub type Context = Arc<Mutex<InstanceBufferPool>>;
pub type Renderer = MetalRenderer;

pub(crate) unsafe fn new_renderer(
pub unsafe fn new_renderer(
context: self::Context,
_native_window: *mut c_void,
_native_view: *mut c_void,
Expand All @@ -54,7 +54,7 @@ pub(crate) unsafe fn new_renderer(
MetalRenderer::new(context, transparent)
}

pub(crate) struct InstanceBufferPool {
pub struct InstanceBufferPool {
buffer_size: usize,
buffers: Vec<metal::Buffer>,
}
Expand Down Expand Up @@ -109,7 +109,7 @@ impl InstanceBufferPool {
}
}

pub(crate) struct MetalRenderer {
pub struct MetalRenderer {
device: metal::Device,
layer: Option<metal::MetalLayer>,
is_apple_gpu: bool,
Expand Down
23 changes: 7 additions & 16 deletions crates/gpui_macos/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ path = "src/gpui_macos.rs"

[features]
default = ["gpui/default"]
test-support = ["gpui/test-support"]
runtime_shaders = []
test-support = ["gpui/test-support", "gpui_apple/test-support"]
runtime_shaders = ["gpui_apple/runtime_shaders"]
font-kit = ["dep:font-kit"]
screen-capture = ["gpui/screen-capture"]

Expand All @@ -34,15 +34,13 @@ core-foundation.workspace = true
core-foundation-sys.workspace = true
core-graphics.workspace = true
core-text.workspace = true
core-video.workspace = true
ctor.workspace = true
derive_more.workspace = true
dispatch2 = "0.3.1"
etagere.workspace = true
# WARNING: If you change this, you must also publish a new version of zed-font-kit to crates.io
font-kit = { git = "https://github.com/zed-industries/font-kit", rev = "94b0f28166665e8fd2f53ff6d268a14955c82269", package = "zed-font-kit", version = "0.14.1-zed", optional = true }
foreign-types.workspace = true
futures.workspace = true
gpui_apple.workspace = true
gpui_util.workspace = true
image.workspace = true
itertools.workspace = true
Expand All @@ -64,16 +62,9 @@ smallvec.workspace = true
strum.workspace = true
uuid.workspace = true

[target.'cfg(target_os = "macos")'.build-dependencies]
cbindgen.workspace = true
gpui.workspace = true

# When this crate is itself being tested (cargo test -p gpui_macos), its own
# cfg(test) flag enables impls of test-only traits like PlatformHeadlessRenderer
# and PlatformWindow::render_to_image. Those traits/methods only exist in gpui
# when gpui's `test-support` feature is on, so we have to turn that feature on
# as a dev-dependency. The `cfg(test)` flag of a dependent crate doesn't
# propagate to its dependencies, but dev-dependencies do, so this is the
# correct way to enable the feature exactly when needed.
# The macOS test-only window implementation depends on test-only APIs from both
# GPUI and the extracted renderer. A dependency does not inherit this crate's
# `cfg(test)`, so dev-dependencies enable those APIs only for test builds.
[target.'cfg(target_os = "macos")'.dev-dependencies]
gpui = { workspace = true, features = ["test-support"] }
gpui_apple = { workspace = true, features = ["test-support"] }
10 changes: 7 additions & 3 deletions crates/gpui_macos/src/gpui_macos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ mod system_notifications;
#[cfg(feature = "screen-capture")]
mod screen_capture;

mod metal_atlas;
pub mod metal_renderer;
use gpui_apple::metal_renderer as renderer;

use metal_renderer as renderer;
pub mod metal_renderer {
pub use gpui_apple::metal_renderer::{PathRasterizationVertex, PathSprite, SurfaceBounds};

#[cfg(any(test, feature = "test-support"))]
pub use gpui_apple::metal_renderer::MetalHeadlessRenderer;
}

#[cfg(feature = "font-kit")]
mod open_type;
Expand Down
Loading