-
-
Notifications
You must be signed in to change notification settings - Fork 35.8k
TSL: Ensure memory alignment for struct()
#31151
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
struct()
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
I can still see one edge case with wrong alignment:
Because each mat3 occupies 12 byte in wgpu memory, this struct would need 16 bytes, but with the code from this PR only 12 bytes would be allocated. Also to be pedantic, line 116 of StructTypeNode.js: |
New approach looks good to me! :) |
Ran a few more tests and found one other small discrepancy. Turns out mat2 alignment is not 16 but 8 bytes (as per https://webgpufundamentals.org/webgpu/lessons/webgpu-memory-layout.html) |
* improve alignToBoundary * cleanup * adds more robust verification * add `getMemoryLengthFromType()` * new approach * remove `DataUtils.alignToBoundary()` * cleanup * updates
* improve alignToBoundary * cleanup * adds more robust verification * add `getMemoryLengthFromType()` * new approach * remove `DataUtils.alignToBoundary()` * cleanup * updates
Related issue: #31146, #30983 (comment)
Description
Ensure memory alignment for
struct()
. adds more robust verification./cc @holtsetio