-
-
Notifications
You must be signed in to change notification settings - Fork 10
feat: Automatically assign names to resources in Unplugin #1344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: Automatically assign names to resources in Unplugin #1344
Conversation
pkg.pr.new packages
benchmark commit |
At least +500, -100 of these changes are tests :) <moved to description> |
As of right now, functions marked with our directives are not assigned any names (no |
Please add that to the PR description |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job!! 🦾
I added const myFn = tgpu['~unstable'].fn([Item], Item) /* wgsl */`(item: Item) -> Item { return item; }`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing work, a great push forward! 👏👏👏
'(($ => (globalThis.__TYPEGPU_META__ ??= new WeakMap()).set($.f = (', | ||
).appendRight( | ||
node.end, | ||
`) , ${metadata}) && $.f)({}))`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this space here? 👀
`) , ${metadata}) && $.f)({}))`, | |
`), ${metadata}) && $.f)({}))`, |
The high-level rule for autonaming is like this: if there is an assignment to a variable, we try to find one of the
resourceConstructors
among the identifiers in the assigned expression; if we succeed (and we don't find the$name
identifier), we wrap the expression in a call to__TYPEGPU_AUTONAME__
. If typegpu is initialized, this function checks if the expression has the$internal
symbol, and names it (using$name
) if it isn't already named.I also needed to add
[$internal]: true
to some of the resources.Let me know if I missed any of the resource generating functions.