impr: Use Immediates in examples - #2813
Conversation
|
pkg.pr.new packages benchmark commit |
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.93, 1.93, 4.49, 6.62, 7.09, 11.45, 21.49, 23.41]
line [0.92, 1.93, 3.97, 5.94, 7.55, 11.15, 22.11, 24.71]
line [0.92, 1.89, 4.31, 6.62, 7.97, 12.35, 23.98, 24.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.31, 0.50, 0.65, 0.80, 1.06, 1.12, 1.39, 1.52]
line [0.28, 0.49, 0.66, 0.77, 1.07, 1.11, 1.32, 1.49]
line [0.30, 0.54, 0.72, 0.84, 1.16, 1.30, 1.54, 1.58]
---
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.88, 2.09, 4.01, 6.76, 12.48, 25.83, 52.39, 108.88]
line [0.93, 2.06, 4.54, 6.53, 12.06, 26.31, 52.32, 108.60]
line [1.02, 2.24, 3.70, 6.42, 13.05, 27.29, 57.75, 119.00]
|
Bundle size comparison (
|
| 🟢 Decreased | ➖ Unchanged | 🔴 Increased | ❔ Unknown |
|---|---|---|---|
| 0 | 322 | 0 | 0 |
import { ... } in PR vs import * as ... in PR (is the library tree-Shakeable?):
| Test | tsdown |
|---|---|
| tgpu_init.ts | 271.67 kB ( |
| tgpu_initFromDevice.ts | 271.14 kB ( |
| tgpu_resolve.ts | 168.87 kB ( |
| tgpu_resolveWithContext.ts | 168.80 kB ( |
| tgpu_bindGroupLayout.ts | 73.83 kB ( |
| tgpu_mutableAccessor.ts | 68.55 kB ( |
| tgpu_accessor.ts | 68.55 kB ( |
| tgpu_privateVar.ts | 67.24 kB ( |
| tgpu_workgroupVar.ts | 67.24 kB ( |
| tgpu_const.ts | 66.66 kB ( |
| tgpu_lazy.ts | 66.46 kB ( |
| tgpu_fragmentFn.ts | 38.96 kB ( |
| tgpu_fn.ts | 38.90 kB ( |
| tgpu_vertexFn.ts | 38.78 kB ( |
| tgpu_computeFn.ts | 38.48 kB ( |
| tgpu_vertexLayout.ts | 27.61 kB ( |
| tgpu_comptime.ts | 15.22 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.
There was a problem hiding this comment.
ℹ️ No critical issues — one minor suggestion inline.
Reviewed changes
- Lighting shaders — replaced DSL chains (
.mul/.sub/.div) andtgpu.fnwith'use gpu'bodies using infix operators and direct accessor reads;depthToColoris now a plain TS'use gpu'fn. - PointLight immediates — dropped the six shadow
Cameras in favor of atgpu.accessor(d.mat4x4f)fed byimmediateVar+pass.setImmediates, with a per-face uniform-bind-group fallback whenimmediate_address_spaceis unsupported. - Render loop — moved to an explicit
root['~unstable'].createCommandEncoder()with hand-rolled passes; destroyeddepthTexture/msaaTextureon resize;scene._instanceBuffernow destroyed before rebuild. - Camera / types —
CameraDatastruct replaced by a singled.mat4x4fviewProjuniform (dropped unusedinverseViewProjectionMatrix). - box-geometry — model matrix built with wgpu-matrix (
quat.fromEuler(…, 'zyx')+mat4.fromQuat/setTranslation/scale); verified equivalent to the oldT*Rz*Ry*Rx*Schain. - Snapshot test — updated WGSL inline snapshot (immediate path).
I verified the two things that looked risky: pointLight.positionUniform.$ needs no explicit bind group (TypeGPU's auto-generated catch-all bind group covers it, see resolutionCtx.ts), and the wgpu-matrix fromEuler('zyx') quaternion is exactly qz⊗qy⊗qx, i.e. the same rotation the old rotationZ().mul(rotationY()).mul(rotationX()) chain produced.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| if (this.#faceImmediate) { | ||
| pass.setImmediates(this.#faceImmediate, this.#faceMatrices[face]); | ||
| } else { | ||
| pass.setBindGroup(this.#faceBindGroups[face]); |
There was a problem hiding this comment.
The uniform fallback branch (here and #faceUniforms/#faceBindGroups) is only exercised when immediate_address_space isn't supported, but the updated snapshot test in point-light-shadow.test.ts only covers the immediate path (var<immediate> item: mat4x4f). Since this example will run on devices without the extension, the fallback is the only code path there — worth a quick manual check (or a second snapshot) that it renders, as the current test would not catch a regression in it.

No description provided.