Conversation
|
pkg.pr.new packages benchmark commit |
📊 Bundle Size Comparison
👀 Notable resultsStatic test results:
Dynamic test results:
📋 All resultsClick to reveal the results table (340 entries).
If you wish to run a comparison for other, slower bundlers, run the 'Tree-shake test' from the GitHub Actions menu. |
9a57a37 to
22b876c
Compare
74a9126 to
8fce4e4
Compare
There was a problem hiding this comment.
Pull request overview
This pull request implements operator overloading for vectors and matrices in TypeGPU by adopting tsover, a TypeScript fork that supports custom operator overloading. The change enables more natural mathematical syntax (e.g., vec1 + vec2 instead of vec1.add(vec2)) within GPU shader functions.
Changes:
- Replaced TypeScript with tsover (version 5.9.6) across the entire monorepo via pnpm catalog
- Added operator overload signatures (
[Operator.plus],[Operator.minus], etc.) to vector and matrix types alongside existing method-based APIs - Implemented build-time transformations in Babel and Rollup plugins to convert operators to runtime function calls (
__tsover_add, etc.) within 'use gpu' functions - Created documentation transformation script to generate operator-free versions of example files for StackBlitz compatibility
- Updated all examples and tests to use the new operator syntax
Reviewed changes
Copilot reviewed 24 out of 25 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| pnpm-workspace.yaml | Updated TypeScript catalog entry to use tsover package |
| pnpm-lock.yaml | Lockfile updates for tsover and tsover-runtime dependencies |
| packages/typegpu/src/data/wgslTypes.ts | Added operator overload type signatures for vectors and matrices |
| packages/typegpu/src/data/index.ts | Assigned operator symbols to prototype methods for runtime execution |
| packages/typegpu/package.json | Added tsover-runtime dependency |
| packages/unplugin-typegpu/src/common.ts | Defined operator-to-runtime-function mappings |
| packages/unplugin-typegpu/src/babel.ts | Implemented Babel transformation for operators within GPU functions |
| packages/unplugin-typegpu/src/rollup-impl.ts | Implemented Rollup transformation for operators within GPU functions |
| packages/unplugin-typegpu/test/*.test.ts | Updated test snapshots with transformed operator calls |
| apps/typegpu-docs/scripts/transform-overloads.ts | Created script to strip overloaded operators for documentation examples |
| apps/typegpu-docs/package.json | Added transform-overloads script to dev and build workflows |
| apps/typegpu-docs/.gitignore | Excluded generated .tsnotover files from version control |
| apps/typegpu-docs/src/examples/**/*.ts | Updated examples to use operator syntax |
| apps/typegpu-docs/src/components/*.tsx | Updated to use tsnotover content when available |
| package.json | Added TypeScript override to use catalog version (tsover) |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
7bffd1e to
b87e71f
Compare
0f2d1b6 to
4609f92
Compare
4609f92 to
e959cd3
Compare
Our shader generator kind of always understood how to add vectors together, it just had two limitations:
Changes:
use gpufunctions that contain overloaded operators in JSa + bintoa.add(b)(etc.) in examples, and showing the down-leveled code to the usertsovercode will require us to do more changes to the examples platform, we can do that after the release