-
-
Notifications
You must be signed in to change notification settings - Fork 43
feat: Callable unstructs and disarrays #1584
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 |
| if (item === undefined) { | ||
| return callSchema(); | ||
| } |
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.
This if is necessary because vector constructors actually distinguish between vec2f() and vec2f(undefined) (the second throws an error, I'm not sure, do we consider this an issue?)
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.
I would say the error is correct. Calling vec2f(undefined) is not valid imo.
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.
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 implements callable functionality for unstruct and disarray schemas, consolidating schema wrapper utilities and adding copy semantics. The changes enable schemas to be called as functions to create instances with proper deep copying behavior.
Key Changes
- Merged
schemaDefaultWrapperandschemaCloneWrapperinto unifiedschemaCallWrapperthat handles vertex formats - Added callable functionality to unstruct and disarray schemas with copy semantics
- Updated error messages for consistency across array and disarray types
Reviewed Changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
packages/typegpu/src/data/utils.ts |
Consolidates wrapper functions into schemaCallWrapper with vertex format support |
packages/typegpu/src/data/unstruct.ts |
Implements callable unstruct with deep copy semantics |
packages/typegpu/src/data/disarray.ts |
Implements callable disarray with validation and deep copy |
packages/typegpu/src/data/dataTypes.ts |
Adds callable type signatures to Disarray and Unstruct interfaces |
packages/typegpu/tests/unstruct.test.ts |
Adds comprehensive tests for callable unstruct functionality |
packages/typegpu/tests/disarray.test.ts |
Adds comprehensive tests for callable disarray functionality |
packages/typegpu/tests/data/utils.test.ts |
Tests for the new unified schema wrapper function |
packages/typegpu/src/data/struct.ts |
Updates to use new unified wrapper function |
packages/typegpu/src/data/array.ts |
Updates to use new wrapper and consistent error messages |
packages/typegpu/src/core/function/tgpuFn.ts |
Updates import and usage of wrapper function |
packages/typegpu/src/core/buffer/bufferUsage.ts |
Updates to use new unified wrapper function |
Co-authored-by: Copilot <[email protected]>
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.
Merge! Merge! Merge! (after nit fix)
Co-authored-by: Iwo Plaza <[email protected]>

Changes:
schemaDefaultWrapperandschemaCloneWrapperintoschemaCallWrapperthat also handles vertex formats,The wgslGenerator is left as is.