Skip to content

feat: Stabilize command encoders - #3300

Open
iwoplaza wants to merge 1 commit into
mainfrom
feat/stable-command-encoders
Open

iwoplaza wants to merge 1 commit into
mainfrom
feat/stable-command-encoders

Conversation

@iwoplaza

Copy link
Copy Markdown
Collaborator

Moves createCommandEncoder and createRenderBundleEncoder from root['~unstable'] to root.

  • root['~unstable'].createCommandEncoder / .createRenderBundleEncoder still work, but are marked @deprecated.
  • Updated examples, tests, and docs to use the stable API, and removed the "Experimental" note from the pipelines docs.

@github-actions

Copy link
Copy Markdown

pkg.pr.new

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

https://pkg.pr.new/software-mansion/TypeGPU/tgpu-gen@297bc470d46fa563a84f04354a2dc30d1ebf738d
https://pkg.pr.new/software-mansion/TypeGPU/typegpu@297bc470d46fa563a84f04354a2dc30d1ebf738d
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/cli@297bc470d46fa563a84f04354a2dc30d1ebf738d
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/color@297bc470d46fa563a84f04354a2dc30d1ebf738d
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/gl@297bc470d46fa563a84f04354a2dc30d1ebf738d
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/radiance-cascades@297bc470d46fa563a84f04354a2dc30d1ebf738d

benchmark
view benchmark

commit
view commit

@iwoplaza
iwoplaza marked this pull request as ready for review October 30, 2026 16:36
@iwoplaza
iwoplaza requested review from aleksanderkatan, cieplypolar, reczkok and vende11s and a balanced review from Copilot October 30, 2026 16:36
@github-actions

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.90, 1.85, 4.18, 6.09, 7.73, 12.29, 22.86, 24.02]
  line [0.94, 1.97, 4.53, 6.57, 7.77, 12.73, 24.79, 24.63]
  line [0.90, 1.87, 4.05, 6.33, 7.43, 11.69, 22.10, 24.52]
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.33, 0.54, 0.70, 0.87, 1.12, 1.16, 1.35, 1.52]
  line [0.35, 0.57, 0.76, 0.88, 1.13, 1.25, 1.42, 1.55]
  line [0.34, 0.53, 0.72, 0.84, 1.11, 1.15, 1.30, 1.47]
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.95, 2.29, 3.78, 6.94, 13.15, 26.80, 55.89, 108.04]
  line [0.95, 2.08, 4.04, 6.82, 13.58, 25.04, 53.72, 110.87]
  line [0.86, 2.13, 3.62, 6.83, 12.33, 24.48, 51.81, 108.12]
Loading

@github-actions

Copy link
Copy Markdown

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

🟢 Decreased (max -0.00%) ➖ Unchanged 🔴 Increased ❔ Unknown
4 351 0 0

No notable changes.

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

Copilot AI 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.

🟡 Changes recommended

The deprecated ~unstable command and render bundle encoder entry points no longer have tests, leaving their compatibility unverified.

1 open issue
What changed in this PR

This PR promotes TypeGPU’s command-encoder and render-bundle-encoder factories to the stable root API while retaining deprecated ~unstable entry points for compatibility.

Changes:

  • Adds stable factory declarations and deprecates the experimental declarations.
  • Migrates package consumers, examples, and tests to the stable API.
  • Updates documentation and warning text, including removing the experimental notice.
File Description
packages/​typegpu/​tests/​renderPipeline.test.ts Uses the stable render-bundle factory.
packages/​typegpu/​tests/​immediates.test.ts Uses stable render-bundle creation in immediate-value tests.
packages/​typegpu/​tests/​guardedComputePipeline.test.ts Uses stable command-encoder creation.
packages/​typegpu/​tests/​computePipeline.test.ts Migrates factory calls and warning expectations.
packages/​typegpu/​src/​core/​root/​rootTypes.ts Exposes stable factories and deprecates experimental declarations.
packages/​typegpu/​src/​core/​pipeline/​drawState.ts Recommends the stable factory in warnings.
packages/​typegpu/​src/​core/​commandEncoder/​commandEncoder.ts Updates the documentation example.
packages/​typegpu-radiance-cascades/​src/​runner.ts Creates fallback encoders through the stable API.
packages/​typegpu-radiance-cascades/​src/​holographic/​index.ts Uses stable encoder creation when needed.
packages/​typegpu-algorithm/​README.md Updates the batching example.
apps/​typegpu-docs/​src/​examples/​rendering/​triplanar-mapping/​index.ts Migrates frame encoder creation.
apps/​typegpu-docs/​src/​examples/​rendering/​simple-shadow/​index.ts Migrates shadow-rendering encoder creation.
apps/​typegpu-docs/​src/​examples/​rendering/​render-bundles/​index.ts Migrates both encoder factories.
apps/​typegpu-docs/​src/​examples/​rendering/​render-bundles-with/​index.ts Migrates frame encoder creation.
apps/​typegpu-docs/​src/​examples/​rendering/​radiance-cascades-drawing/​index.ts Migrates lighting-frame encoder creation.
apps/​typegpu-docs/​src/​examples/​rendering/​global-illumination/​index.ts Migrates illumination-frame encoder creation.
apps/​typegpu-docs/​src/​examples/​rendering/​area-light/​index.ts Migrates rendering encoder creation.
apps/​typegpu-docs/​src/​examples/​image-processing/​monocular-light-injection/​renderer.ts Migrates relighting encoder creation.
apps/​typegpu-docs/​src/​examples/​algorithms/​sort/​index.ts Migrates initialization, sorting, and benchmark encoders.
apps/​typegpu-docs/​src/​examples/​algorithms/​genetic-racing/​index.ts Migrates simulation and reduction encoders.
apps/​typegpu-docs/​src/​examples/​advanced/​appjs-venue/​index.ts Migrates scene encoder creation.
apps/​typegpu-docs/​src/​content/​docs/​ecosystem/​typegpu-radiance-cascades.mdx Updates the shared compute-pass example.
apps/​typegpu-docs/​src/​content/​docs/​apis/​pipelines.mdx Removes the experimental notice and updates examples.
apps/​typegpu-docs/​src/​content/​docs/​apis/​buffers.mdx Updates the buffer-operation encoder example.

Review effort: Balanced

const pipeline = root.createComputePipeline({ compute: entryFn });

const encoder = root['~unstable'].createCommandEncoder();
const encoder = root.createCommandEncoder();

@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 new issues found.

Reviewed changes

This PR stabilizes the command encoder API by moving createCommandEncoder and createRenderBundleEncoder from root['~unstable'] to the stable TgpuRoot interface, with mechanical call-site updates.

  • Interface relocation — both method declarations and their JSDoc move from ExperimentalTgpuRoot to TgpuRoot in packages/typegpu/src/core/root/rootTypes.ts. ExperimentalTgpuRoot keeps a one-line @deprecated redeclaration of each, so root['~unstable'].* still type-checks and now emits a deprecation hint. This mirrors the existing createGuardedComputePipeline / pipe stabilization pattern.
  • No runtime change — the implementation in core/root/init.ts (TgpuRootImpl) already defined both methods, so this is a type-surface change only.
  • Docs and examples — removed the "Experimental" caution from apis/pipelines.mdx; updated buffers.mdx, the radiance-cascades doc, the algorithm README, and all example/test call sites.
  • Warning copy — core/pipeline/drawState.ts and its assertion in computePipeline.test.ts now reference root.createCommandEncoder().

Verification

  • npx tsc -p packages/typegpu/tsconfig.json --noEmit passes.
  • computePipeline.test.ts (30 tests) and immediates.test.ts (40 tests) pass.
  • The only remaining root['~unstable'].createCommandEncoder references are in the historical migrations/0-12.mdx guide and the 0.12 blog post, which correctly document the old API and should stay as-is.
  • typegpu-gl's TgpuRootWebGL stubs are unaffected — initWithGL casts through unknown as TgpuRoot, and the fallback methods still throw WebGLFallbackUnsupportedError as before.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@aleksanderkatan aleksanderkatan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

@cieplypolar cieplypolar left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM! Left 1 nit.

* encoder.submit();
* ```
*/
/** @deprecated This feature is now stable, use `root.createCommandEncoder`. */

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/** @deprecated This feature is now stable, use `root.createCommandEncoder`. */
/** @deprecated This feature is now stable, use {@link TgpuRoot.createCommandEncoder | root.createCommandEncoder}. */

* const bundle = bundleEncoder.finish();
* ```
*/
/** @deprecated This feature is now stable, use `root.createRenderBundleEncoder`. */

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

same as above

This branch has not been deployed

No deployments
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.

4 participants