Skip to content

feat(wgpu): add backend.manifest.zon — manifest-splice codegen (#386 step 2) - #426

Merged
apotema merged 2 commits into
mainfrom
feat/386-wgpu-manifest
Jun 30, 2026
Merged

apotema merged 2 commits into
mainfrom
feat/386-wgpu-manifest

Conversation

@apotema

@apotema apotema commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

wgpu extraction step 2 (after window conformance #424). Mirrors bgfx #396.

Adds backends/wgpu/backend.manifest.zon + build_fragments/{backend_dep,link}.txt. Presence of the manifest opts the wgpu desktop build into the manifest-splice codegen path (manifest_splice.zig) instead of the enum switch (cfg.backend) sections in build_zig.txt.

  • Loop-style, desktop-only (wgpu has no wasm/android target — the CLI rejects wgpu+wasm).
  • No params: the fragments take no gamepad/gui toggles, and wgpu pulls no shared gamepad sub-package, so (unlike bgfx) there's no core-diamond override.
  • Fragments are the verbatim .backend_wgpu / .link_wgpu section bodies.

Verified byte-identical

Generated a wgpu desktop build.zig baseline (enum path), added the manifest, regenerated (splice path) → 0 diff. zig build test green (golden suites unchanged).

Next: extract wgpu to labelle-wgpu, then flip builtinProvider(.wgpu).

Summary by CodeRabbit

  • New Features

    • Added support for the wgpu desktop backend in the app’s build and launch flow.
    • Improved platform-specific linking for Apple devices to help the backend run more reliably.
  • Bug Fixes

    • Fixed an issue where reopening a window could immediately close the app again.
    • Fixed an incorrect first-frame time jump after creating a new window, improving startup smoothness.

apotema added 2 commits June 30, 2026 12:56
quit_requested + last_frame_time persisted across a window close→reopen: a prior
requestQuit would close the new window immediately, and the first frameDuration
would be a huge time-since-old-baseline. Reset both at initWindow (same fix
raylib got in #411). CodeRabbit/gemini on #424.
…step 2)

wgpu step 2 of out-of-tree extraction (after window conformance #424). Presence
of backends/wgpu/backend.manifest.zon opts the wgpu DESKTOP build into the
manifest-splice path (manifest_splice.zig) instead of the enum
`switch (cfg.backend)` sections in build_zig.txt — exactly as bgfx did in #396.

Loop-style, desktop-only (wgpu has no wasm/android target). No params: the
fragments take no gamepad/gui toggles and wgpu pulls no shared gamepad
sub-package, so unlike bgfx there's no core-diamond override.

build_fragments/{backend_dep,link}.txt are the verbatim .backend_wgpu / .link_wgpu
section bodies. Output is BYTE-IDENTICAL to the enum path (diffed a generated
baseline: 0 differences). `zig build test` green (golden suites unchanged). This
is the step that lets wgpu's build sections travel WITH the package on extraction.
@coderabbitai

coderabbitai Bot commented Jun 30, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c0e48ade-ff4c-4767-bdea-d2889c45bc16

📥 Commits

Reviewing files that changed from the base of the PR and between 1ee54d7 and aedcc31.

📒 Files selected for processing (4)
  • backends/wgpu/backend.manifest.zon
  • backends/wgpu/build_fragments/backend_dep.txt
  • backends/wgpu/build_fragments/link.txt
  • backends/wgpu/src/window.zig

📝 Walkthrough

Walkthrough

Adds backends/wgpu/backend.manifest.zon to opt the wgpu DESKTOP build into the manifest_splice.zig codegen path, plus two build fragment files (backend_dep.txt, link.txt) for dependency wiring and platform-specific linking. Also resets quit_requested and last_frame_time in initWindow on window creation.

Changes

wgpu Backend Manifest and Build Wiring

Layer / File(s) Summary
Manifest and dependency build fragment
backends/wgpu/backend.manifest.zon, backends/wgpu/build_fragments/backend_dep.txt
Declares the wgpu backend manifest configuring identity (wgpu/labelle_wgpu), loop style, desktop template, and fragment file references; the backend_dep fragment creates the labelle_wgpu dependency and assigns module handles (gfx, input, audio, window) and the glfw artifact.
Platform linking fragment
backends/wgpu/build_fragments/link.txt
Links glfw_artifact into exe.root_module and conditionally links Foundation, QuartzCore, and Metal frameworks for macos/ios targets.
Window state reset on reopen
backends/wgpu/src/window.zig
Resets quit_requested to false and last_frame_time to 0 in initWindow to prevent stale state after a close→reopen sequence.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • labelle-toolkit/labelle-assembler#397: Establishes the backend_registry convention (subpath/zon_name/link_name) that manifest_splice uses to resolve backend packages, directly coupled to the new backend.manifest.zon naming.
  • labelle-toolkit/labelle-assembler#398: Adds/enforces the manifest_splice-based manifest workflow for external backends that this PR's backend.manifest.zon opts into.

Poem

🐇 A manifest appears, fresh and new,
Fragments for linking, one, two!
The wgpu backend takes its place,
With Apple frameworks joined in grace.
Reset the clock, reset the latch—
No stale state this hop will catch! 🌟

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding the wgpu backend manifest and moving to manifest-splice codegen.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/386-wgpu-manifest

Comment @coderabbitai help to get the list of available commands.

@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 introduces the wgpu backend manifest and build fragments to support the pluggable-backends codegen path, and updates backends/wgpu/src/window.zig to reset the window contract state (quit_requested and last_frame_time) during initialization. The reviewer suggests also resetting the gpu_ready flag to false in initWindow to prevent potential panics or undefined behavior during sequential runs or integration tests.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +661 to +662
quit_requested = false;
last_frame_time = 0;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The persistent state flag gpu_ready is not reset to false when the window is closed or re-initialized. If a subsequent call to initWindow fails during initGpu (or if closeWindow is called), gpu_ready will remain true from the previous successful run. This can cause endDrawing or ensureSurface to proceed with rendering, attempting to access invalid or unallocated GPU resources (such as sprite_vertex_buffer which is set to null in closeWindow), leading to a panic or undefined behavior.

Resetting gpu_ready to false during initialization ensures a clean state for sequential runs or integration tests, adhering to the general rule: Reset persistent state flags (such as exit or quit request latches) during initialization functions to ensure a clean state for sequential runs or integration tests.

    quit_requested = false;
    last_frame_time = 0;
    gpu_ready = false;
References
  1. Reset persistent state flags (such as exit or quit request latches) during initialization functions to ensure a clean state for sequential runs or integration tests.

@apotema
apotema merged commit e5c2815 into main Jun 30, 2026
4 checks passed
@apotema
apotema deleted the feat/386-wgpu-manifest branch June 30, 2026 16:11
apotema added a commit that referenced this pull request Jun 30, 2026
…427)

gpu_ready stayed true after closeWindow released the GPU resources (sprite
buffers/pipeline → null), so a stray endDrawing/ensureSurface post-close — or a
re-init whose initGpu fails — would pass the `if (!gpu_ready)` guard and touch
freed handles. Reset it to false in closeWindow (resources freed) and at the top
of initWindow (initGpu sets it true on success). gemini High on #426; completes
the re-init state hygiene started in #425.
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