fix: Pointers for reference types#1591
Merged
aleksanderkatan merged 21 commits intomainfrom Aug 21, 2025
Merged
Conversation
added 2 commits
August 8, 2025 12:23
|
pkg.pr.new packages benchmark commit |
There was a problem hiding this comment.
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
iwoplaza
reviewed
Aug 11, 2025
reczkok
reviewed
Aug 12, 2025
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
approved these changes
Aug 18, 2025
apps/typegpu-docs/src/content/docs/fundamentals/data-schemas.mdx
Outdated
Show resolved
Hide resolved
Co-authored-by: Iwo Plaza <iwoplaza@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes:
schemaCallWrapperto return the inner type when the schema is a pointer,StorableTypeand change pointer inner type to it,