Skip to content

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

Backlog

Description

@houko

Context

#1741 (for #1536) routes every backend's optional features (shaders, video, web views, canvas) through feature tables, so a minimal app no longer links code it never shows. GPU views were left out of that work: mountGPU (core/gpu.go:114) never calls an enabler, and every backend handles driver.ItemGPU directly:

  • internal/platform/macos/macos.go:2576 calls v.newGPU
  • internal/platform/ios/ios.go:1601 calls v.newGPU
  • internal/platform/linux/linux.go:1563 calls w.setGPU
  • internal/platform/windows/windows.go:1821 calls w.configureGPU
  • internal/platform/android/android.go:1786 calls writeGPUViewConfig
  • internal/platform/web/web.go:1906 calls s.configureGPU

Through those paths each backend's GPU pipeline compiler and its shading-language writer link into every app: internal/platform/apple/gpu.go:389 (msl.CompilePipeline), internal/platform/windows/gpu_d3d11_desc.go:939,962 (hlsl.CompilePipeline), internal/platform/linux/gpu_gl.go, internal/platform/android/gpu.go:39-54, and internal/platform/web/gpu_common.go / gpu_webgl2.go (GLSL).

Because of this, #1741 leaves msl, hlsl and glsl out of the minimal-app link check, and layers.md says so.

Why it matters

The MSL, HLSL and GLSL writers are a sizeable part of every binary and wasm bundle, including apps that never mount a GPU view. That is the case #1536 set out to remove.

Proposal

  • Add a GPUEnabler and call it from mountGPU, the same way the other features are enabled.
  • In each backend, move ItemGPU handling, GPU view creation and release into a gpus feature table that the enabler fills.
  • Add msl, hlsl and glsl to unlinked in internal/moduletest/linked_test.go. Shaders also use these writers, so they should stay linked when an app uses shaders; the minimal-app check should cover an app with neither.

Acceptance

  • TestMinimalAppLinks fails if msl, hlsl or glsl links into a minimal app on any backend.
  • A feature-app link test shows the writers link when an app mounts a GPU view.
  • GPU views still work on all six backends.

Activity

  1. Laotree commented on Nov 26, 2026

    @Laotree
    Contributor

    Task record

    • Task: Platforms: link GPU view support only when an app mounts a GPU view #2265
    • Status: working
    • Risk: medium — moves GPU view handling into the backends' feature tables; no release, CI or data changes.
    • Acceptance: TestMinimalAppLinks fails if msl, hlsl or glsl links into a minimal app on any backend; a feature-app link test shows the writers link when an app mounts a GPU view; GPU views still work on all six backends.
    • PR: to follow
  2. Laotree commented on Nov 26, 2026

    @Laotree
    Contributor

    On where the writers are reached: the MSL, HLSL and GLSL writers are called from the GPU pipeline compile path, not only from ItemGPU handling. Android compiles in writeGPUResourceOp (its frame encoding), Windows in d3dCompilePipelineHLSL (its frame execution), Web in gpu_common.go and Linux in gpu_gl.go. So each backend's GPUEnabler has to cover the frame path as well as view creation and release, which is why msl, hlsl and glsl stay linked today.

  3. Laotree commented on Nov 26, 2026

    @Laotree
    Contributor

    A work-in-progress branch has the enabler in place; what remains, measured with -ldflags=-dumpdep on testdata/minimal:

    • Android: done — glsl and the frame path unlink once the submitter is connected on mountGPU instead of at engine attach.
    • macOS, Linux: the writers survive as types: apple.gpuPipeline holds []msl.BindingSlot, and linux.glGPUPipeline holds []glsl.UniformBlockSlot and []glsl.SamplerPair, both <UsedInIface>. Those pipeline types must name local binding/sampler types instead.
    • Windows: (*gfx).program stays reachable from the glass path (glass.go), which compiles a program without a GPU view.
    • Web: (*glShader).link stays reachable from the effect path (effect.go), likewise.

    The feature app links every writer on all five targets already.

  4. Laotree commented on Nov 26, 2026

    @Laotree
    Contributor

    Progress on the branch: macOS, Linux and Android now pass TestMinimalAppLinks (local pipeline types replace the writers' types, and Linux's GPU GL callbacks register when a GPU view mounts instead of at start). Windows and the web still link their writer, and the cause is the same on both: the glass and backdrop effect paths draw through a GL/HLSL program without a GPU view. Closing that needs the effect draw to go through the shader enabler's table, with core enabling shaders when a style asks for a glass effect, so the writers link only for apps that use either.

  5. Laotree commented on Nov 26, 2026

    @Laotree
    Contributor

    Task record

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions