Skip to content

Conversation

@aleksanderkatan
Copy link
Contributor

@aleksanderkatan aleksanderkatan commented Aug 8, 2025

Changes:

  • update schemaCallWrapper to return the inner type when the schema is a pointer,
  • add an internal function for creating pointers,
  • add StorableType and change pointer inner type to it,
  • some new docs and tests.

@github-actions
Copy link

github-actions bot commented Aug 8, 2025

pkg.pr.new

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

https://pkg.pr.new/software-mansion/TypeGPU/typegpu@106d41129820773d496bc784a7b06698cf319356
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/noise@106d41129820773d496bc784a7b06698cf319356
https://pkg.pr.new/software-mansion/TypeGPU/unplugin-typegpu@106d41129820773d496bc784a7b06698cf319356

benchmark
view benchmark

commit
view commit

This comment was marked as outdated.

Copy link

Copilot AI left a 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 BaseData to the more restrictive StorableData
  • Modifies schemaCallWrapper to 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

@aleksanderkatan aleksanderkatan marked this pull request as ready for review August 11, 2025 12:03
Copy link
Contributor

@reczkok reczkok left a comment

Choose a reason for hiding this comment

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

Looks great! 📚

Copy link
Collaborator

@iwoplaza iwoplaza left a comment

Choose a reason for hiding this comment

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

Looks great! 👏

@aleksanderkatan aleksanderkatan merged commit a3ed827 into main Aug 21, 2025
6 checks passed
@aleksanderkatan aleksanderkatan deleted the fix/pointers-for-reference-types branch September 25, 2025 11:22
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.

4 participants