impr: Infix dispatch handling#2439
Conversation
|
pkg.pr.new packages benchmark commit |
📊 Bundle Size Comparison
👀 Notable resultsStatic test results:No major changes. Dynamic test results:No major changes. 📋 All resultsClick to reveal the results table (350 entries).
If you wish to run a comparison for other, slower bundlers, run the 'Tree-shake test' from the GitHub Actions menu. |
Resolution Time Benchmark---
config:
themeVariables:
xyChart:
plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
title "Random Branching (🔴 PR | 🔵 main | 🟢 release)"
x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
y-axis "time (ms)"
line [0.64, 1.39, 2.90, 4.19, 5.02, 7.18, 15.64, 16.77]
line [0.66, 1.30, 2.87, 4.56, 4.87, 6.66, 14.72, 14.65]
line [0.67, 1.31, 2.92, 4.40, 4.75, 7.99, 15.13, 14.33]
---
config:
themeVariables:
xyChart:
plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
title "Linear Recursion (🔴 PR | 🔵 main | 🟢 release)"
x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
y-axis "time (ms)"
line [0.21, 0.37, 0.48, 0.60, 0.77, 0.86, 1.03, 1.15]
line [0.26, 0.39, 0.50, 0.61, 0.75, 0.79, 0.99, 1.11]
line [0.24, 0.41, 0.51, 0.60, 0.77, 0.83, 1.00, 1.09]
---
config:
themeVariables:
xyChart:
plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
title "Full Tree (🔴 PR | 🔵 main | 🟢 release)"
x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
y-axis "time (ms)"
line [0.57, 1.38, 2.78, 4.84, 8.11, 17.94, 38.77, 79.82]
line [0.65, 1.32, 2.59, 4.11, 8.60, 18.62, 39.20, 78.41]
line [0.58, 1.37, 2.86, 4.64, 8.59, 17.53, 37.01, 76.07]
|
d387702 to
f49bffe
Compare
There was a problem hiding this comment.
Pull request overview
Refactors infix operator dispatch so extracted operator properties can flow through TGSL resolution, which looks like groundwork for #2425’s expanded external property access support.
Changes:
- Replaces the old
InfixDispatchclass with a callable dispatch object and updates WGSL call handling to recognize it. - Changes vector/matrix infix operators from prototype methods to getter-based dispatchers so expressions like deferred/external
mul/addcan be carried around. - Expands TGSL tests around compile-time/runtime/deferred infix usage and updates mixed-swizzle validation commentary.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
packages/typegpu/tests/tgsl/infixOperators.test.ts |
Adds coverage for deferred/runtime/external infix dispatch scenarios. |
packages/typegpu/tests/swizzleMixedValidation.test.ts |
Updates explanatory test comment for mixed-swizzle failure behavior. |
packages/typegpu/src/tgsl/wgslGenerator.ts |
Switches infix call resolution to the new callable dispatch shape. |
packages/typegpu/src/tgsl/infix.ts |
Introduces the new callable InfixDispatch helper/type guard. |
packages/typegpu/src/tgsl/accessProp.ts |
Returns the new dispatch objects from property access and simplifies swizzle matching. |
packages/typegpu/src/data/index.ts |
Rewires vector/matrix infix operators onto getter-based dispatchers. |
packages/typegpu/src/data/dataTypes.ts |
Removes the old InfixDispatch class from shared data types. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Object.defineProperty(base.prototype, operator, { | ||
| get() { | ||
| return infixDispatch(this, opImpl); | ||
| }, |
There was a problem hiding this comment.
I don't think it's avoidable, and vectors are already not performant in JS anyways
Prerequisite for #2425
This PR changes the way infix dispach is handled in preparation for externals like
{ 'vec' : { 'mul': /* getter */ vec.mul } }