Skip to content

impr: Use Immediates in examples - #2813

Draft
reczkok wants to merge 1 commit into
feat/tgpu-immediatesfrom
feat/tgpu-immediates-examples
Draft

impr: Use Immediates in examples#2813
reczkok wants to merge 1 commit into
feat/tgpu-immediatesfrom
feat/tgpu-immediates-examples

Conversation

@reczkok

@reczkok reczkok commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@reczkok
reczkok marked this pull request as draft August 8, 2026 13:58
@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown

pkg.pr.new

packages
Ready to be installed by your favorite package manager ⬇️

https://pkg.pr.new/software-mansion/TypeGPU/eslint-plugin-typegpu@85378ac8fa40c2819756525e1e3ad6bf06ae9a29
https://pkg.pr.new/software-mansion/TypeGPU/tgpu-gen@85378ac8fa40c2819756525e1e3ad6bf06ae9a29
https://pkg.pr.new/software-mansion/TypeGPU/tinyest-for-wgsl@85378ac8fa40c2819756525e1e3ad6bf06ae9a29
https://pkg.pr.new/software-mansion/TypeGPU/typegpu@85378ac8fa40c2819756525e1e3ad6bf06ae9a29
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/cli@85378ac8fa40c2819756525e1e3ad6bf06ae9a29
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/color@85378ac8fa40c2819756525e1e3ad6bf06ae9a29
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/gl@85378ac8fa40c2819756525e1e3ad6bf06ae9a29
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/noise@85378ac8fa40c2819756525e1e3ad6bf06ae9a29
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/radiance-cascades@85378ac8fa40c2819756525e1e3ad6bf06ae9a29
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/react@85378ac8fa40c2819756525e1e3ad6bf06ae9a29
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/sdf@85378ac8fa40c2819756525e1e3ad6bf06ae9a29
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/three@85378ac8fa40c2819756525e1e3ad6bf06ae9a29
https://pkg.pr.new/software-mansion/TypeGPU/unplugin-typegpu@85378ac8fa40c2819756525e1e3ad6bf06ae9a29

benchmark
view benchmark

commit
view commit

@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown

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]
Loading
---
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]
Loading
---
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]
Loading

@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown

Bundle size comparison (import * as ... in PR vs import * as ... in target):

🟢 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 ($${\color{green}-3.4\%}$$)
tgpu_initFromDevice.ts 271.14 kB ($${\color{green}-3.6\%}$$)
tgpu_resolve.ts 168.87 kB ($${\color{green}-40.0\%}$$)
tgpu_resolveWithContext.ts 168.80 kB ($${\color{green}-40.0\%}$$)
tgpu_bindGroupLayout.ts 73.83 kB ($${\color{green}-73.8\%}$$)
tgpu_mutableAccessor.ts 68.55 kB ($${\color{green}-75.6\%}$$)
tgpu_accessor.ts 68.55 kB ($${\color{green}-75.6\%}$$)
tgpu_privateVar.ts 67.24 kB ($${\color{green}-76.1\%}$$)
tgpu_workgroupVar.ts 67.24 kB ($${\color{green}-76.1\%}$$)
tgpu_const.ts 66.66 kB ($${\color{green}-76.3\%}$$)
tgpu_lazy.ts 66.46 kB ($${\color{green}-76.4\%}$$)
tgpu_fragmentFn.ts 38.96 kB ($${\color{green}-86.2\%}$$)
tgpu_fn.ts 38.90 kB ($${\color{green}-86.2\%}$$)
tgpu_vertexFn.ts 38.78 kB ($${\color{green}-86.2\%}$$)
tgpu_computeFn.ts 38.48 kB ($${\color{green}-86.3\%}$$)
tgpu_vertexLayout.ts 27.61 kB ($${\color{green}-90.2\%}$$)
tgpu_comptime.ts 15.22 kB ($${\color{green}-94.6\%}$$)
tgpu_unroll.ts 1.75 kB ($${\color{green}-99.4\%}$$)
tgpu_slot.ts 1.70 kB ($${\color{green}-99.4\%}$$)

If you wish to run a comparison for other, slower bundlers, run the 'Tree-shake test' from the GitHub Actions menu.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No critical issues — one minor suggestion inline.

Reviewed changes

  • Lighting shaders — replaced DSL chains (.mul/.sub/.div) and tgpu.fn with 'use gpu' bodies using infix operators and direct accessor reads; depthToColor is now a plain TS 'use gpu' fn.
  • PointLight immediates — dropped the six shadow Cameras in favor of a tgpu.accessor(d.mat4x4f) fed by immediateVar + pass.setImmediates, with a per-face uniform-bind-group fallback when immediate_address_space is unsupported.
  • Render loop — moved to an explicit root['~unstable'].createCommandEncoder() with hand-rolled passes; destroyed depthTexture/msaaTexture on resize; scene._instanceBuffer now destroyed before rebuild.
  • Camera / typesCameraData struct replaced by a single d.mat4x4f viewProj uniform (dropped unused inverseViewProjectionMatrix).
  • box-geometry — model matrix built with wgpu-matrix (quat.fromEuler(…, 'zyx') + mat4.fromQuat/setTranslation/scale); verified equivalent to the old T*Rz*Ry*Rx*S chain.
  • 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.

Pullfrog  | Fix all ➔Fix 👍s ➔View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

if (this.#faceImmediate) {
pass.setImmediates(this.#faceImmediate, this.#faceMatrices[face]);
} else {
pass.setBindGroup(this.#faceBindGroups[face]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant