Skip to content

[RFC] feat: Generate requires directives - #3207

Draft
aleksanderkatan wants to merge 1 commit into
mainfrom
feat/requires
Draft

aleksanderkatan wants to merge 1 commit into
mainfrom
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'.

@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/tgpu-gen@fb53354df139372904b5ca58132e662f81ce712f
https://pkg.pr.new/software-mansion/TypeGPU/typegpu@fb53354df139372904b5ca58132e662f81ce712f
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/cli@fb53354df139372904b5ca58132e662f81ce712f
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/gl@fb53354df139372904b5ca58132e662f81ce712f

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 [1.07, 2.14, 4.93, 7.43, 8.59, 13.58, 29.13, 29.23]
  line [0.99, 2.01, 4.49, 7.45, 8.17, 12.86, 26.95, 27.45]
  line [1.03, 2.06, 4.31, 7.26, 8.59, 12.25, 27.13, 28.39]
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.37, 0.60, 0.73, 0.82, 1.17, 1.23, 1.51, 1.62]
  line [0.37, 0.59, 0.77, 0.84, 1.12, 1.23, 1.41, 1.60]
  line [0.30, 0.57, 0.78, 0.92, 1.28, 1.29, 1.56, 1.78]
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 [1.01, 2.51, 4.37, 8.19, 15.76, 29.99, 62.83, 128.31]
  line [0.82, 2.26, 4.45, 7.75, 13.60, 28.43, 59.27, 119.72]
  line [0.88, 2.26, 4.30, 8.11, 14.53, 27.57, 59.39, 122.71]
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 0.20%) ❔ Unknown
0 349 6 0

No notable changes.

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 3 times, most recently from d953332 to e3086a1 Compare October 19, 2026 09:16
@aleksanderkatan
aleksanderkatan force-pushed the feat/requires branch 2 times, most recently from 1a7db81 to 8e3ddfc Compare October 29, 2026 15:18
Base automatically changed from feat/wgsl-swizzle-assignment to main October 29, 2026 15:35

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