feat: Expose schema read-write APIs#2411
Conversation
|
pkg.pr.new packages benchmark commit |
📊 Bundle Size Comparison
👀 Notable resultsStatic test results:No major changes. Dynamic test results:
📋 All resultsClick to reveal the results table (353 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.91, 1.77, 3.77, 5.18, 6.72, 9.69, 20.15, 22.17]
line [0.86, 1.71, 3.44, 5.18, 6.48, 9.36, 18.55, 20.09]
line [0.79, 1.62, 3.72, 5.21, 6.31, 7.98, 19.82, 21.64]
---
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.33, 0.51, 0.64, 0.81, 1.03, 1.08, 1.32, 1.47]
line [0.28, 0.46, 0.65, 0.81, 1.10, 1.13, 1.34, 1.43]
line [0.29, 0.50, 0.66, 0.80, 1.02, 1.12, 1.32, 1.36]
---
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.71, 1.74, 3.24, 5.35, 10.63, 23.12, 50.66, 99.50]
line [0.75, 1.99, 4.32, 6.03, 10.51, 21.92, 49.16, 98.77]
line [0.79, 1.74, 3.37, 5.22, 10.25, 22.85, 49.04, 97.64]
|
There was a problem hiding this comment.
Pull request overview
Exposes schema-driven ArrayBuffer read/write/patch utilities as public APIs and refactors buffer internals to reuse them.
Changes:
- Added
writeToArrayBuffer,readFromArrayBuffer, andpatchArrayBufferas public exports. - Refactored
TgpuBuffer’s read/write/patch paths to delegate to the new ArrayBuffer IO helpers. - Added tests and documentation for the new ArrayBuffer IO APIs.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/typegpu/src/data/dataIO.ts | Introduces writeToArrayBuffer / readFromArrayBuffer helpers. |
| packages/typegpu/src/data/partialIO.ts | Introduces patchArrayBuffer helper built on patch-instruction generation. |
| packages/typegpu/src/indexNamedExports.ts | Re-exports the new public ArrayBuffer IO functions. |
| packages/typegpu/src/core/buffer/buffer.ts | Refactors buffer read/write/patch to use the new helpers. |
| packages/typegpu/tests/arrayBufferIO.test.ts | Adds tests covering arrayBuffer IO read/write/patch behavior. |
| packages/typegpu/tests/buffer.test.ts | Adds coverage for patching a mapped buffer. |
| apps/typegpu-docs/src/content/docs/fundamentals/buffers.mdx | Documents the new ArrayBuffer IO APIs and examples. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| </ListItem> | ||
| ::: | ||
|
|
||
| ## ArrayBuffer IO |
There was a problem hiding this comment.
I would move this documentation to the Schemas guide, and refer to it here as in "This is what we do under the hood, if you'd like to do this yourself, you can split it up into two API calls"
There was a problem hiding this comment.
I worded it differently, see if it's okay
Changes:
write,patchandreadfunctions for ArrayBuffers,