Skip to content

Conversation

iwoplaza
Copy link
Collaborator

@iwoplaza iwoplaza commented Sep 26, 2025

Changes:

  • Track referentiality of snippets (and their address space)
  • Generate pointer types for shell-less arguments if the passed-in values are referential
  • Forbid assignment of references
  • Not allowing references to be returned from a function (unless it’s a reference to something define in that function)
  • Make JS const statements be pointers if they take in a referential type (let statements)
  • Treat JS const statements with naturally non-referential types to be WGSL const 🎉
  • Track constant expressions

Reference assignment errors:

image

Invalid 'let' statement errors:
image

@github-actions
Copy link

github-actions bot commented Sep 26, 2025

pkg.pr.new

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

https://pkg.pr.new/software-mansion/TypeGPU/typegpu@1e2df56dd78e70b4663aa8db2e1abcf39a1838c7
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/noise@1e2df56dd78e70b4663aa8db2e1abcf39a1838c7
https://pkg.pr.new/software-mansion/TypeGPU/unplugin-typegpu@1e2df56dd78e70b4663aa8db2e1abcf39a1838c7

benchmark
view benchmark

commit
view commit

@iwoplaza iwoplaza marked this pull request as ready for review October 7, 2025 14:45
@aleksanderkatan
Copy link
Contributor

aleksanderkatan commented Oct 8, 2025

Something weird happened to the vaporrave example, some of the effects seem to have disappeared.

Also, Slime Mold 3D throws when switching to another example, but this might have been the case before.

Copy link
Contributor

@aleksanderkatan aleksanderkatan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks really promising!! 🧑‍🚒🇹🇻

I didn't have time to review everything yet


type AnyFn = (...args: never[]) => unknown;

function shallowEqualSchemas(a: AnyData, b: AnyData): boolean {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Different structs will be equal. I'd rename this, though I have no ideas right now

iwoplaza and others added 2 commits October 8, 2025 19:08
Co-authored-by: Aleksander Katan <56294622+aleksanderkatan@users.noreply.github.com>
Co-authored-by: Aleksander Katan <56294622+aleksanderkatan@users.noreply.github.com>
}

return this.#value;
return schemaCallWrapper(this.dataType, this.#value);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm worried about the performance of this. Sometimes these constants are not insignificant in size, e.g. in cube-marching, I use a tgpu.const(d.arrayOf(d.u32, 256), ...). I don't use it on JS side, but still, if we allow that, it should not be unnecessarily slow.


ctx.addDeclaration(`${fnAttribute}fn ${id}${header}${body}`);
return snip(id, returnType);
return snip(id, returnType, /* ref */ 'runtime');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little hesitant about calling everything 'runtime' bu default, maybe we could find a more fitting name, like 'unknown'?

return data;
}

export function toStorable(schema: AnyData): AnyData {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add some docs to this? At a glance, I don't know what it does e.g. to atomic types.

@iwoplaza
Copy link
Collaborator Author

iwoplaza commented Oct 9, 2025

Something weird happened to the vaporrave example, some of the effects seem to have disappeared.

Also, Slime Mold 3D throws when switching to another example, but this might have been the case before.

Vaporrave looks fine to me, how does it look like for you?
image

@aleksanderkatan
Copy link
Contributor

aleksanderkatan commented Oct 9, 2025

Vaporrave looks fine to me, how does it look like for you? <img alt="image" width="854" height="883"

Sorry, I meant Disco

New:
image

Old:
image

@aleksanderkatan
Copy link
Contributor

Docs have TGSL that is no longer valid

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.

2 participants