Skip to content

chore(sokol): un-pin from labelle-toolkit/sokol-zig fork; use upstream - #134

Merged
apotema merged 1 commit into
mainfrom
chore/unpin-sokol-fork
May 16, 2026
Merged

apotema merged 1 commit into
mainfrom
chore/unpin-sokol-fork

Conversation

@apotema

@apotema apotema commented May 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Re-pin backends/sokol/build.zig.zon's .sokol dep from the labelle-toolkit/sokol-zig fork (branch feat/expose-cached-metal-drawable) to upstream floooh/sokol-zig@8b1a651e — the commit the fork was branched from.
  • Refresh the inline comment to record why the fork existed and why it's no longer needed.

Why

The fork's only patch exposed sapp_metal_get_current_drawable, which the early Path B Metal/IOSurface readback (#128) needed to grab the just-rendered drawable. Path A (#132 / v0.22.0) flipped the producer side: the engine owns an offscreen IOSurface-backed render target and sokol writes straight into it via sg_image.mtl_textures[…]. Path A never reads the post-frame drawable, so the fork patch is vestigial. floooh/sokol#1510 (closed) confirmed the offscreen render target is the canonical approach.

The fork repo stays alive for now; archiving it is a separate low-priority cleanup.

Test plan

  • zig build test --summary all — 16/16 steps green, 305/309 pass + 4 skipped (matches v0.22.0 baseline).
  • Reviewer sanity-check: comment text in backends/sokol/build.zig.zon reads cleanly.

🤖 Generated with Claude Code

The fork's `feat/expose-cached-metal-drawable` branch restored a
`sapp_metal_get_current_drawable` accessor for the early Path B
Metal/IOSurface readback experiment (#128). Path A (#132 / v0.22.0)
renders directly into IOSurfaces via offscreen render targets and
never reaches for the post-frame drawable, so the fork patch is
vestigial.

Re-pin to floooh/sokol-zig@8b1a651 (current upstream master, the
exact commit the fork was branched from). See floooh/sokol#1510
(closed) for the upstream rationale.

`zig build test`: 16/16 steps green, 305/309 pass + 4 skipped.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@cursor

cursor Bot commented May 16, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
Low risk build/dependency-only change: updates the pinned sokol-zig source URL/hash back to upstream, which could only affect builds if upstream packaging differs from the fork.

Overview
Switches the backends/sokol/build.zig.zon .sokol dependency from the labelle-toolkit/sokol-zig fork back to an upstream floooh/sokol-zig commit (updating the pinned URL and hash).

Updates the inline comment to document why the fork was previously required for a Metal drawable accessor and why it’s no longer needed with the current IOSurface offscreen render-target approach.

Reviewed by Cursor Bugbot for commit d72911d. Bugbot is set up for automated code reviews on this repo. Configure here.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the sokol dependency in backends/sokol/build.zig.zon to point back to the upstream floooh/sokol-zig repository, replacing the previous labelle-toolkit fork. The change includes an updated hash and revised comments explaining that the fork's specific Metal/IOSurface readback functionality is no longer required due to architectural changes. I have no feedback to provide.

@apotema
apotema merged commit b1f3aea into main May 16, 2026
4 checks passed
@apotema
apotema deleted the chore/unpin-sokol-fork branch May 16, 2026 19:02
apotema added a commit that referenced this pull request May 16, 2026
Minor release completing the **sokol-Metal Path A** stack:

- **#133 / #135** — route the game's `sg.beginPass` into the
  Path-A offscreen IOSurface render target. New gfx-layer shim
  in `backends/sokol/src/window.zig` (`setEditorRenderTarget` /
  `clearEditorRenderTarget`); new template slot
  `{{preview_pre_render}}` fires before the game render to arm
  the shim with the current ring slot's `sg.View` +
  `sg.Attachments`. The existing `{{preview_readback}}` slot
  disarms it and calls `signalSlotReady` after the render.
- **#134** — un-pinned `backends/sokol/build.zig.zon` from the
  labelle-toolkit/sokol-zig fork (`feat/expose-cached-metal-drawable`
  branch) back to upstream `floooh/sokol-zig@8b1a651e`. Path A
  doesn't need the fork's `sapp_metal_get_current_drawable`
  accessor.

Together with assembler v0.22.0's Path A scaffolding and engine
v1.37.4's `getIOSurfaceAt`/`signalSlotReady` APIs, the sokol-Metal
PIE producer is now **end-to-end functional**: the game renders
directly into IOSurface-backed `sg.Image`s, the editor samples them
zero-copy via `CGLTexImageIOSurface2D`, no post-frame blit, no
drawable lifetime concerns.

Plus bonus latent compile fix from #132's Path A bringup that
codegen tests didn't catch (#135 surfaced it during live build).

Review-fix from #135: null-check `makeImage`/`makeView` returns +
extend the rollback loop to cover the just-failed slot's partial
state (caught a leak path).

Out of scope: the sokol-zig fork repo itself (un-archive cleanup
is a separate task; harmless to leave it alive).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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