Conversation
📊 Bundle Size Comparison
👀 Notable resultsStatic test results:No major changes. Dynamic test results:No major changes. 📋 All resultsClick to reveal the results table (337 entries).
If you wish to run a comparison for other, slower bundlers, run the 'Tree-shake test' from the GitHub Actions menu. |
|
pkg.pr.new packages benchmark commit |
There was a problem hiding this comment.
Pull request overview
This PR extends TGSL → WGSL codegen to support block-scoped externals (similar to existing function externals), and uses that mechanism to generate for ... of ... loops more cleanly by injecting the loop variable into the generated block.
Changes:
- Add per-block external bindings via a new
externalsmap on block scope stack layers. - Update
wgslGenerator.block(...)to accept an optional external map and push externals for identifier resolution within that block. - Refactor
for ... of ...generation to pass the loop variable through block externals, and add tests covering non-overriding + correct injection.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/typegpu/tests/tgsl/wgslGenerator.test.ts | Adds coverage for block externals behavior (non-overriding + injection). |
| packages/typegpu/src/types.ts | Extends block scope stack layer shape and stack interface with block externals operations. |
| packages/typegpu/src/tgsl/wgslGenerator.ts | Adds optional block externals support and uses it for for...of loop variable handling. |
| packages/typegpu/src/tgsl/shaderGenerator.ts | Updates generator interface to allow passing block externals. |
| packages/typegpu/src/tgsl/generationHelpers.ts | Extends GenerationCtx with block externals push/pop methods. |
| packages/typegpu/src/resolutionCtx.ts | Implements block externals storage + lookup in the stack and exposes it via ResolutionCtxImpl. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Changes: