-
-
Notifications
You must be signed in to change notification settings - Fork 43
fix: Pointers for reference types #1591
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
Conversation
|
pkg.pr.new packages benchmark commit |
Co-authored-by: Copilot <[email protected]>
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.
Pull Request Overview
This PR fixes pointer handling for reference types in TypeGPU by updating the type system and JavaScript execution behavior. The changes ensure that pointers to reference types (vectors, matrices, structs) work correctly in both WGSL generation and JavaScript execution.
- Updates pointer inner type constraint from
BaseDatato the more restrictiveStorableData - Modifies
schemaCallWrapperto return the pointed-to value directly when dealing with pointers in JavaScript - Refactors pointer creation functions to use a shared internal implementation
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/typegpu/src/data/wgslTypes.ts | Defines new StorableData type and updates pointer type constraint |
| packages/typegpu/src/data/ptr.ts | Refactors pointer creation functions to use shared implementation with StorableData |
| packages/typegpu/src/data/utils.ts | Updates schemaCallWrapper to handle pointer dereferencing in JavaScript |
| packages/typegpu/src/std/array.ts | Updates type annotation to use StorableData instead of AnyWgslData |
| packages/typegpu/tests/data/ptr.test.ts | Adds test for pointer modification of reference types in JavaScript |
| apps/typegpu-docs/src/content/examples/tests/tgsl-parsing-test/pointers.ts | Adds comprehensive pointer test examples |
| apps/typegpu-docs/src/content/docs/fundamentals/tgsl.mdx | Documents pointer behavior and JavaScript execution limitations |
| apps/typegpu-docs/src/content/docs/fundamentals/data-schemas.mdx | Adds documentation for atomic and pointer schema creation |
apps/typegpu-docs/src/content/examples/tests/tgsl-parsing-test/pointers.ts
Show resolved
Hide resolved
apps/typegpu-docs/src/content/docs/fundamentals/data-schemas.mdx
Outdated
Show resolved
Hide resolved
apps/typegpu-docs/src/content/docs/fundamentals/data-schemas.mdx
Outdated
Show resolved
Hide resolved
apps/typegpu-docs/src/content/examples/tests/tgsl-parsing-test/pointers.ts
Show resolved
Hide resolved
reczkok
left a comment
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.
Looks great! 📚
apps/typegpu-docs/src/content/docs/fundamentals/data-schemas.mdx
Outdated
Show resolved
Hide resolved
iwoplaza
left a comment
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.
Looks great! 👏
Co-authored-by: Iwo Plaza <[email protected]>
Changes:
schemaCallWrapperto return the inner type when the schema is a pointer,StorableTypeand change pointer inner type to it,