Skip to content

Support embedded Metal rendering - #83

Draft
treeform wants to merge 7 commits into
masterfrom
polyworld-metal-compositing
Draft

treeform wants to merge 7 commits into
masterfrom
polyworld-metal-compositing

Conversation

@treeform

@treeform treeform commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Silky’s Metal drawer currently creates its own layer and submits a cleared frame, so an application cannot add Silky UI to existing Metal rendering. Add an external drawer that borrows the application’s device and records into its color target and command buffer. Both newSilky constructors accept a supplied drawer, and ordinary endUi preserves the scene without presenting or submitting.

Each external pass uses its own vertex buffer, allowing several UI passes before submission. Borrowed atlas textures now have mipmaps, with explicit dirty-only prepareAtlas encoding before application shaders sample them. A generic isolatedDrawing scope preserves queued UI geometry, deferred clip captures, layouts, and layers while the application bakes offscreen content. Standalone rendering remains the default; application-owned lifetime and synchronization are documented.

Validation:

  • Real macOS GPU tests cover BGRA/RGBA targets, background preservation, alpha blending, resize, multiple pending passes, invalid frames, and public newSilky/beginUi/endUi with input hooks and UI scaling.
  • Mip readback verifies initial atlas upload, partial updates, and automatic regeneration during UI rendering. Existing Metal texture GPU tests pass.
  • Isolated-drawing regressions preserve exact queued HUD output across four layout directions, nested deferred layouts, clips, layers, nesting, and exception cleanup. Native OpenGL, Metal, CPU, and semantic test modes pass.
  • Metal, OpenGL, and CPU nim check pass with isolated dependencies. CI runs drawing-scope tests and compiles the Metal GPU test.

The Shady dependency is pinned to de68342 from treeform/shady#41. Metal modulo and array texture operations are emitted inline, so generated shaders no longer receive the universal helper-function preamble. Silky's shader generation, Metal compositing/texture pixel tests, and desktop/WebGL shader linking pass with this compiler.

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