Skip to content

[RFC] feat: Generate requires directives - #3207

Draft
aleksanderkatan wants to merge 1 commit into
feat/wgsl-swizzle-assignmentfrom
feat/requires
Draft

aleksanderkatan wants to merge 1 commit into
feat/wgsl-swizzle-assignmentfrom
feat/requires

Conversation

@aleksanderkatan

@aleksanderkatan aleksanderkatan commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

See https://www.w3.org/TR/WGSL/#language-extensions-sec

Requires directive must be located before any declarations in the WGSL code.
This breaks when concatenating multiple resolves, even with a namespace enabled.
A possible solution:

  • add a flag (default=true) for generating 'requires' in resolve/root,
  • ignore new requires in subsequent resolves with a namespace.

Or we can just don't generate the 'requires' directive at all, it is not necessary.
Or we could check the navigator (if available), and warn if features are unavailable on the resolving host instead of emitting 'requires'.

@aleksanderkatan
aleksanderkatan added this pull request to stack #3206 October 16, 2026 08:22
@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

pkg.pr.new

packages
Ready to be installed by your favorite package manager ⬇️

https://pkg.pr.new/software-mansion/TypeGPU/typegpu@e3086a1f3608a5e01d6f6d83a12c12bcbc7f6d6b

benchmark
view benchmark

commit
view commit

@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Resolution Time Benchmark

---
config:
  themeVariables:
    xyChart:
      plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
  title "Random Branching (🔴 PR | 🔵 main | 🟢 release)"
  x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
  y-axis "time (ms)"
  line [0.96, 1.97, 4.31, 6.30, 7.29, 12.72, 23.51, 25.41]
  line [0.92, 1.89, 3.95, 6.21, 7.64, 12.67, 23.68, 26.64]
  line [0.93, 1.79, 4.02, 5.81, 6.68, 11.33, 23.29, 25.36]
Loading
---
config:
  themeVariables:
    xyChart:
      plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
  title "Linear Recursion (🔴 PR | 🔵 main | 🟢 release)"
  x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
  y-axis "time (ms)"
  line [0.29, 0.49, 0.69, 0.87, 1.11, 1.21, 1.42, 1.58]
  line [0.29, 0.49, 0.65, 0.83, 1.09, 1.16, 1.36, 1.49]
  line [0.34, 0.50, 0.65, 0.75, 1.03, 1.10, 1.29, 1.45]
Loading
---
config:
  themeVariables:
    xyChart:
      plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
  title "Full Tree (🔴 PR | 🔵 main | 🟢 release)"
  x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
  y-axis "time (ms)"
  line [0.81, 2.04, 3.82, 6.76, 12.39, 25.75, 54.71, 114.64]
  line [0.83, 2.01, 3.36, 6.67, 11.92, 27.96, 54.71, 106.89]
  line [0.86, 2.04, 4.37, 6.51, 11.77, 24.83, 52.69, 106.18]
Loading

@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Bundle size comparison (import * as ... in PR vs import * as ... in target):

🟢 Decreased ➖ Unchanged 🔴 Increased (max 1.36%) ❔ Unknown
0 84 265 0

import * as ... in PR vs import * as ... in target (did bundle size increase?):

Test tsdown
tgpu_lazy.ts 63.56 kB ($${\color{red}+1.4\%}$$)
tgpu_const.ts 63.76 kB ($${\color{red}+1.4\%}$$)
tgpu_workgroupVar.ts 64.34 kB ($${\color{red}+1.3\%}$$)
tgpu_privateVar.ts 64.34 kB ($${\color{red}+1.3\%}$$)
tgpu_accessor.ts 68.72 kB ($${\color{red}+1.3\%}$$)
tgpu_mutableAccessor.ts 68.72 kB ($${\color{red}+1.3\%}$$)
tgpu_bindGroupLayout.ts 70.95 kB ($${\color{red}+1.2\%}$$)
tgpu_resolveWithContext.ts 174.10 kB ($${\color{red}+0.9\%}$$)
tgpu_resolve.ts 174.17 kB ($${\color{red}+0.9\%}$$)
tgpu_initFromDevice.ts 283.96 kB ($${\color{red}+0.5\%}$$)
tgpu_init.ts 284.50 kB ($${\color{red}+0.5\%}$$)
STATIC_tgpu.ts 296.66 kB ($${\color{red}+0.5\%}$$)

If you wish to run a comparison for other, slower bundlers, run the 'Tree-shake test' from the GitHub Actions menu.

@aleksanderkatan
aleksanderkatan force-pushed the feat/requires branch 2 times, most recently from 8b4cb2a to d953332 Compare October 19, 2026 09:04
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant