Conversation
|
pkg.pr.new packages benchmark commit |
📊 Bundle Size Comparison📈 Summary
📋 Bundle Size Comparison
|
Contributor
Author
|
Comments in the code resemble comments in the og code, so it's easier to understand where something came from. |
reczkok
requested changes
Jan 23, 2026
Contributor
reczkok
left a comment
There was a problem hiding this comment.
I have a couple of problems with this PR:
- The TGSL functions wouldn’t want to make me use TypeGPU - please move to normal operators and go through the logic to eliminate useless casts, etc.
- Take advantage of TypeGPU mechanics (like slots) to make the logic nicer. computeHeightBtoA and computeHeightAtoB are basically the same, so you could halve the code using slots (I’m pretty sure).
- Separating gpuHelpers into a separate file makes no sense to me if you need to create them using a function. I would either figure out a way to make the helpers top‑level (which I’m pretty sure is possible using accessors/slots) or not do it at all.
Comment on lines
+12
to
+29
| const getNeighborIndices = (index: number) => { | ||
| 'use gpu'; | ||
| const width = d.u32(WIDTH); | ||
| const x = d.i32(std.mod(index, WIDTH)); | ||
| const y = d.i32(std.div(index, WIDTH)); | ||
|
|
||
| const leftX = std.max(0, std.sub(x, 1)); | ||
| const rightX = std.min(std.add(x, 1), std.sub(d.i32(width), 1)); | ||
| const bottomY = std.max(0, std.sub(y, 1)); | ||
| const topY = std.min(std.add(y, 1), std.sub(d.i32(width), 1)); | ||
|
|
||
| const westIndex = d.u32(std.add(std.mul(y, d.i32(width)), leftX)); | ||
| const eastIndex = d.u32(std.add(std.mul(y, d.i32(width)), rightX)); | ||
| const southIndex = d.u32(std.add(std.mul(bottomY, d.i32(width)), x)); | ||
| const northIndex = d.u32(std.add(std.mul(topY, d.i32(width)), x)); | ||
|
|
||
| return NeighborIndices({ northIndex, southIndex, eastIndex, westIndex }); | ||
| }; |
Contributor
There was a problem hiding this comment.
🤔
Suggested change
| const getNeighborIndices = (index: number) => { | |
| 'use gpu'; | |
| const width = d.u32(WIDTH); | |
| const x = d.i32(std.mod(index, WIDTH)); | |
| const y = d.i32(std.div(index, WIDTH)); | |
| const leftX = std.max(0, std.sub(x, 1)); | |
| const rightX = std.min(std.add(x, 1), std.sub(d.i32(width), 1)); | |
| const bottomY = std.max(0, std.sub(y, 1)); | |
| const topY = std.min(std.add(y, 1), std.sub(d.i32(width), 1)); | |
| const westIndex = d.u32(std.add(std.mul(y, d.i32(width)), leftX)); | |
| const eastIndex = d.u32(std.add(std.mul(y, d.i32(width)), rightX)); | |
| const southIndex = d.u32(std.add(std.mul(bottomY, d.i32(width)), x)); | |
| const northIndex = d.u32(std.add(std.mul(topY, d.i32(width)), x)); | |
| return NeighborIndices({ northIndex, southIndex, eastIndex, westIndex }); | |
| }; | |
| const getNeighborIndices = (index: number) => { | |
| 'use gpu'; | |
| const width = d.u32(WIDTH); | |
| const x = index % WIDTH; | |
| const y = d.u32(index / WIDTH); | |
| const leftX = std.max(0, x - 1); | |
| const rightX = std.min(x + 1, width - 1); | |
| const bottomY = std.max(0, y - 1); | |
| const topY = std.min(y + 1, width - 1); | |
| const westIndex = y * width + leftX; | |
| const eastIndex = y * width + rightX; | |
| const southIndex = bottomY * width + x; | |
| const northIndex = topY * width + x; | |
| return NeighborIndices({ northIndex, southIndex, eastIndex, westIndex }); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
New example, ported from threejs