Move the Metal renderer and CoreVideo surfaces onto objc2-metal and objc2-core-video - #3
Merged
Conversation
…bjc2-core-video block 0.1.6 trips rustc's future-incompatibility warning, and it only reached the tree through the legacy objc 0.2 stack: our own metal_renderer used block::ConcreteBlock, gpui_media used objc, and the metal 0.33 and core-video 0.5 crates (plus core-graphics2 under core-video) depend on block and objc unconditionally. Removing our own uses was not enough, so this replaces both crates. - gpui_apple: the Metal renderer and atlas use objc2-metal and objc2-quartz-core's CAMetalLayer directly. Selectors, blend state, storage modes and pass structure are unchanged; the completed handler is a block2 RcBlock. Instance buffers are wrapped in a PooledBuffer that is Send, restating the ownership contract the metal crate's Send impls asserted (objc2 leaves MTLBuffer !Send). - gpui, gpui_wgpu, gpui_macos: CVPixelBuffer/CVImageBuffer come from objc2-core-video as CFRetained values. This changes the type carried by SurfaceSource::Surface and ScreenCaptureFrame on macOS. - gpui_macos: screen capture reads the image buffer through objc2-core-media and no longer depends on gpui_media; the layer's contentsScale is set through the typed CALayer setter. - gpui_media: its core_video module takes and returns objc2 types, and the unused objc glob import in the bindgen wrapper is gone. block, objc, malloc_buf, metal, core-video, core-graphics2, io-surface, cgl, leak and leaky-cow leave Cargo.lock. No remaining version moves. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Moves gpui's macOS code off the legacy
objc0.2,block0.1,metal0.33 andcore-video0.5 crates ontoobjc2-metalandobjc2-core-video0.3.2. Both were already in the lockfile, so this adds no crates and changes no versions.block0.1.6 is what triggered rustc's "code that will be rejected by a future version of Rust" warning.Removed from the tree:
block,objc,malloc_buf,metal,core-video,core-graphics2,io-surface,cgl,leak,leaky-cow.cargo tree --workspace -e all --target all -i <crate>finds none of them.Scope
block::ConcreteBlockinmetal_renderer.rsand oneuse objc::*in the gpui_media bindings.gpui_macosalready usedobjc2::msg_send!throughout.blockandobjconly left the tree oncemetalandcore-videowere replaced too:metal0.33 depends on both, andcore-video0.5.2 depends onblockeven without itsmetalfeature.core-videoandmetal:SurfaceSource::SurfacecarriesCFRetained<objc2_core_video::CVPixelBuffer>.ScreenCaptureFrame.0isCFRetained<CVImageBuffer>.MetalRenderer::layer()andlayer_ptr()return objc2'sCAMetalLayer.media::core_mediaandmedia::core_videotake and return objc2 types.create/newcalls are taken as owned, and getter results are retained.render_scene_to_imagewhen the blit encoder can't be created, anddraw_primitives_to_textureon a command-buffer failure.PooledBuffer(unsafe impl Send), with the justification next to it. The oldmetalcrate made the same claim for its buffer type.gpui_macosno longer depends ongpui_media: screen capture reads the image buffer throughobjc2-core-media.Verification
cargo clippy --locked --workspace --all-targets -- -D warningspasses on macOS, and the future-incompatibility warning is gone.cargo testpasses forgpui-ce(356),gpui_ce_apple(13, including the 9 headless Metal pixel checks for quads, borders, shadows, blur, sprites and paths),gpui_ce_macos(13) andgpui_ce_wgpu(42).hello_worldandblurexamples open on-screen windows and run cleanly. No visual capture: the session had no Screen Recording permission.cargo fmt --all -- --checkis clean.79ace671, unchanged by this PR:redundant_cloneingpui_macos/src/screen_capture.rswhen thescreen-capturefeature is on;bench-supportfeature doesn't compile.🤖 Generated with Claude Code