Skip to content

feat(driver): link the GPU views' and glass effects' writers on use only - #2508

Open
Laotree wants to merge 4 commits into
nsgo-dev:mainfrom
Laotree:feature/gpu-link-gating
Open

Laotree wants to merge 4 commits into
nsgo-dev:mainfrom
Laotree:feature/gpu-link-gating

Conversation

@Laotree

@Laotree Laotree commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Summary

GPU views and glass effects are now gated like the other optional backend features, so an app that uses neither links none of the MSL, HLSL or GLSL writer.

  • driver.GPUEnabler and a table per backend hold a GPU view's item, resize, frame and release entry points; driver.GPUSubmitter connects the frame submitter when an app mounts a GPU view instead of at engine attach, which kept every backend's frame path linked.
  • driver.GlassEnabler fills the glass table from style resolution, and a shader effect's backdrop picture goes through the shader table.
  • The pipeline structs that an interface keeps (Apple's, Linux's, Windows' and Web's) name local mirror types instead of the writers' BindingSlot, RegisterBinding, UniformBlockSlot and SamplerPair, and Linux registers its GPU GL callbacks when a GPU view mounts rather than at start.
  • msl, hlsl and glsl join unlinked in the link test, and testdata/features mounts a core.GPUView so the feature app checks that the writers still link on use.

Fixes #2265.

Targets

  • Shared code (core, base, ui, tsx, the nsgo tool)
  • macOS
  • iOS
  • tvOS
  • watchOS
  • Android
  • Windows
  • Linux
  • Web
  • Mini programs
  • Docs or website only

Screenshots

None.

Verification

  • go tool nsgo check — exit 0 on the host and on macos_arm64, ios, tvos, watchos, windows_x64, linux_x64, android_arm64 and web.
  • go tool nsgo test — 5068 passed, 3 failed, 85 skipped. All three also fail on upstream/main before this branch: TestMaxRefreshRateReadsEveryMode (this host reports a 0 Hz fastest display mode), TestLayering (cmd/nsgo imports i18n across layers) and TestWebViewUnderOverlayIgnoresHoverAndCursor.
  • go tool nsgo test -target <target> — the link tests build every target:
$ go tool nsgo test -run 'TestMinimalAppLinks|TestFeatureAppLinks' ./internal/moduletest
  ✓ TestMinimalAppLinks/js_wasm
  ✓ TestMinimalAppLinks/windows_amd64
  ✓ TestMinimalAppLinks/android_arm64
  ✓ TestMinimalAppLinks/darwin_arm64
  ✓ TestMinimalAppLinks/linux_amd64
  ✓ TestFeatureAppLinks/js_wasm
  ✓ TestFeatureAppLinks/android_arm64
  ✓ TestFeatureAppLinks/darwin_arm64
  ✓ TestFeatureAppLinks/linux_amd64
  ✓ TestFeatureAppLinks/windows_amd64
  2 passed, 0 failed, 0 skipped

TestMinimalAppLinks now lists msl, hlsl and glsl in unlinked per target and passes, and TestFeatureAppLinks still links all three for an app that mounts a core.GPUView. GPU views' own behaviour is unchanged on the backends this host can run (macOS and the web tests in the suite); Windows, Android and Linux were checked by veting and linking only.

Checklist

  • The title is a Conventional Commit, such as fix(linux): keep the caret after a paste; a squash merge uses it as the commit subject.
  • Docs whose facts change are updated, and a capability users can see has a line in a changelog.d/ fragment, not in CHANGELOG.md.
  • New third-party code, assets and dependencies name their source and license.

🤖 Generated with Claude Code

@Laotree

Laotree commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

The TestLayering failures in the suite are not from this branch. They reproduce on upstream/main at 1abf8b5 with nothing else applied:

$ git switch --detach upstream/main
$ go tool nsgo test -run 'TestLayering/darwin_arm64$' ./internal/moduletest
  ✗ TestLayering/darwin_arm64
      layering_test.go:209: github.com/nsgo-dev/nsgo/cmd/nsgo imports github.com/nsgo-dev/nsgo/i18n across layers

cmd/nsgo/i18n_build.go imports github.com/nsgo-dev/nsgo/i18n on main, and the layering rules do not allow cmd/nsgo that edge. This branch touches core, internal/driver, the six backends and the link test only.

Laotree and others added 4 commits November 26, 2026 19:18
Add driver.GPUEnabler and a table per backend for a GPU view's item,
resize, frame and release entry points, and connect the frame submitter
only when an app mounts a GPU view. Android's minimal app links neither
glsl nor the frame path now. On macOS, Linux, Windows and the web the
minimal app still links its writer: the pipeline types name writer types
(macOS, Linux), and the glass and effect paths compile a program without
a GPU view (Windows, web). The minimal-app link test fails on those four.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Mirror the writers' pipeline types locally, so a struct kept by an
interface no longer names msl or glsl, and register Linux's GPU GL
callbacks when a GPU view mounts instead of at start. The minimal-app
link test now passes on macOS, Linux and Android; Windows and the web
still link their writer through the glass and backdrop effect paths,
which compile a program without a GPU view.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Route a glass effect's program and a shader effect's backdrop picture
through the glass and shader tables, mirror the writers' register and
slot types locally so an interface-kept struct does not name them, and
enable the glass table from style resolution. The minimal-app link test
passes on every target now, and the feature app still links all three
writers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
iOS refuses GPU views when the environment has no GPU, and its enabler
said nothing about it. The guard also keeps the macOS and iOS enablers
from being the same copy, which the duplicate backend check refuses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Laotree
Laotree force-pushed the feature/gpu-link-gating branch from 2c72c12 to 4ab7ac8 Compare November 26, 2026 11:21

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Android core documentation Improvements or additions to documentation enhancement New feature or request iOS Linux macOS size/M Web Windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Platforms: link GPU view support only when an app mounts a GPU view

1 participant