feat: switch in 'use gpu' functions - #2912
Open
aleksanderkatan wants to merge 20 commits into
Open
Conversation
|
pkg.pr.new packages benchmark commit |
Bundle size comparison (
|
| 🟢 Decreased | ➖ Unchanged | 🔴 Increased (max 0.78%) | ❔ Unknown |
|---|---|---|---|
| 0 | 304 | 21 | 0 |
import * as ... in PR vs import * as ... in target (did bundle size increase?):
| Test | tsdown |
|---|---|
| STATIC_tgpu.ts | 274.75 kB ( |
| tgpu_fn.ts | 274.76 kB ( |
| tgpu_init.ts | 274.76 kB ( |
| tgpu_lazy.ts | 274.76 kB ( |
| tgpu_slot.ts | 274.76 kB ( |
| tgpu_const.ts | 274.76 kB ( |
| tgpu_unroll.ts | 274.76 kB ( |
| tgpu_resolve.ts | 274.76 kB ( |
| tgpu_accessor.ts | 274.76 kB ( |
| tgpu_comptime.ts | 274.76 kB ( |
| tgpu_vertexFn.ts | 274.76 kB ( |
| tgpu_computeFn.ts | 274.76 kB ( |
| tgpu_fragmentFn.ts | 274.76 kB ( |
| tgpu_privateVar.ts | 274.76 kB ( |
| tgpu_vertexLayout.ts | 274.77 kB ( |
| tgpu_workgroupVar.ts | 274.77 kB ( |
| tgpu_initFromDevice.ts | 274.77 kB ( |
| tgpu_bindGroupLayout.ts | 274.77 kB ( |
| tgpu_mutableAccessor.ts | 274.77 kB ( |
| tgpu_resolveWithContext.ts | 274.77 kB ( |
| STATIC_allImports.ts | 301.01 kB ( |
import { ... } in PR vs import * as ... in PR (is the library tree-Shakeable?):
| Test | tsdown |
|---|---|
| tgpu_init.ts | 265.23 kB ( |
| tgpu_initFromDevice.ts | 264.68 kB ( |
| tgpu_resolve.ts | 163.87 kB ( |
| tgpu_resolveWithContext.ts | 163.81 kB ( |
| tgpu_bindGroupLayout.ts | 62.32 kB ( |
| tgpu_mutableAccessor.ts | 57.04 kB ( |
| tgpu_accessor.ts | 57.04 kB ( |
| tgpu_privateVar.ts | 55.73 kB ( |
| tgpu_workgroupVar.ts | 55.73 kB ( |
| tgpu_const.ts | 55.15 kB ( |
| tgpu_lazy.ts | 54.95 kB ( |
| tgpu_fragmentFn.ts | 39.68 kB ( |
| tgpu_fn.ts | 39.62 kB ( |
| tgpu_vertexFn.ts | 39.50 kB ( |
| tgpu_computeFn.ts | 39.20 kB ( |
| tgpu_vertexLayout.ts | 28.33 kB ( |
| tgpu_comptime.ts | 15.93 kB ( |
| tgpu_unroll.ts | 1.75 kB ( |
| tgpu_slot.ts | 1.70 kB ( |
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.84, 1.72, 3.38, 5.76, 6.79, 10.76, 20.28, 21.53]
line [0.94, 1.81, 3.82, 5.82, 6.69, 11.27, 21.49, 20.84]
line [0.87, 1.76, 3.42, 5.41, 7.17, 9.45, 22.01, 23.48]
---
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.44, 0.70, 0.78, 0.99, 1.07, 1.23, 1.40]
line [0.34, 0.54, 0.67, 0.76, 1.03, 1.06, 1.26, 1.47]
line [0.32, 0.49, 0.60, 0.73, 1.00, 1.04, 1.28, 1.45]
---
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.76, 2.11, 3.40, 6.14, 10.65, 23.35, 49.83, 99.10]
line [0.82, 1.99, 3.05, 6.94, 10.74, 23.68, 50.49, 103.44]
line [0.80, 1.96, 2.99, 6.09, 10.90, 23.57, 51.32, 102.07]
|
Member
Author
|
@pullfrog review |
aleksanderkatan
force-pushed
the
feat/switch-in-use-gpu
branch
from
August 25, 2026 09:48
0f7dbe9 to
b1b2a97
Compare
aleksanderkatan
marked this pull request as ready for review
August 25, 2026 11:16
aleksanderkatan
requested review from
cieplypolar,
iwoplaza,
reczkok and
vende11s
August 25, 2026 11:22
Contributor
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — one commit (118097f8 Fix break pruning) re-reviewed against feat/null-legal-at-comptime:
- Fixed WGSL switch break pruning in
WgslGenerator._emitSwitchStatement: the oldfilterremoved every statement whose resolved code was a barebreak;(caseendsWithControlFlow === 'break'), which corrupted cases where an intermediatebreaksplit reachable from unreachable statements. It now pops only a single trailing barebreak— the switch's genuinely redundant terminal break (WGSL switch clauses don't fall through, so it's safe to drop). - Added the
does not prune wrong breakstest, which fails under the old logic and pins the corrected emission (intermediate breaks kept, terminal break pruned, auto-added default). - Confirmed the pruning is WGSL-only:
GlslGenerator._emitSwitchStatementoverrides and re-emits without pruning, so C-style fall-throughbreaks are retained for GLSL.
I verified the change end-to-end: the new test and the full switch.test.ts suite (21 tests) pass.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
aleksanderkatan
force-pushed
the
feat/switch-in-use-gpu
branch
from
August 26, 2026 10:17
118097f to
5ab12f7
Compare
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:
switch,switch.More than half of this PR is tests.