Skip to content

feat(embed): attach custom Compositor to LayerHost and use iOS adapter limits - #48

Merged
kitlangton merged 6 commits into
devfrom
p98-embed-compositor
Oct 30, 2026
Merged

kitlangton merged 6 commits into
devfrom
p98-embed-compositor

Conversation

@kitlangton

Copy link
Copy Markdown
Contributor

Embedded CAMetalLayer hosts can now attach a custom Compositor for effect-slot shaders and initialize cleanly on iOS Metal adapters.
LayerHost without a compositor and all desktop GPU limits remain unchanged.

❌ Before

  1. LayerHost::frame always ran the plain Renderer::draw path with rt.track_marks == false, so embedded CAMetalLayer views could not run Compositor<S> passes on El::effect slots.
  2. Gpu::try_for requested wgpu::Limits::default() (max_inter_stage_shader_variables = 16) unconditionally, failing device creation on iOS Metal adapters where the ceiling is 15.

✅ After

  1. LayerHost::with_compositor enables rt.track_marks, hands a compose::Frame to Compositor::render, and includes Compositor::animating() in EmbedFrame::animating.
  2. On target_os = "ios", Gpu::try_for bases required_limits on adapter.limits() (Rune's uber shader uses 9 inter-stage locations).
- LayerHost::frame -> Renderer::prepare + Renderer::draw (no Compositor, track_marks = false)
- Gpu::try_for -> wgpu::Limits::default() on iOS (requests 16 inter-stage vars, iOS allows 15)
+ LayerHost::with_compositor -> Compositor::render(&mut Frame) + track_marks = true
+ Gpu::try_for -> adapter.limits() on target_os = "ios"

📊 Proof

Case Before After
El::effect(mark) + Compositor inside LayerHost ❌ Ignored (marks untracked) ✅ Draws in painter order with tracked marks
Gpu::try_new on iOS / iOS Simulator Metal ❌ max_inter_stage_shader_variables 16 > 15 ✅ Succeeds with adapter.limits()

New test embed::tests::layer_host_runs_compositor_with_tracked_marks fails without the change; 1 new test + iOS target checks pass.

👀 Read: crates/rune/src/embed.rs (LayerHost::with_compositor and the compositor branch in LayerHost::frame). The rest is routine.

🔍 Built while spiking an embedded iOS Metal host with custom WGSL effect-slot shaders

Checks run
  • cargo test -p rune embed::tests: pass
  • cargo check -p rune --no-default-features --features embedded-fonts --target aarch64-apple-ios-sim: pass
  • cargo check -p rune-kit --no-default-features --target aarch64-apple-ios-sim: pass

@kitlangton
kitlangton changed the base branch from t1014-ios to dev October 30, 2026 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant