Skip to content

feat: Add buffer type aliases - #2787

Open
vende11s wants to merge 3 commits into
mainfrom
feat/buffer-type-aliases
Open

feat: Add buffer type aliases#2787
vende11s wants to merge 3 commits into
mainfrom
feat/buffer-type-aliases

Conversation

@vende11s

@vende11s vende11s commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Closes #2689

  • Add TgpuUniformBuffer, TgpuStorageBuffer, TgpuVertexBuffer, and TgpuIndexBuffer as named aliases for TgpuBuffer intersected with usage flags
  • Export TgpuBufferBinding alongside existing buffer binding types
  • Document the aliases in the docs
  • Ignore local .pnpm-store regularly created by the Cursor sandbox

Copilot AI review requested due to automatic review settings August 5, 2026 09:57
@github-actions

github-actions Bot commented Aug 5, 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@d4591b0e79f56be207017364c74b9079bb603002
https://pkg.pr.new/software-mansion/TypeGPU/tgpu-gen@d4591b0e79f56be207017364c74b9079bb603002
https://pkg.pr.new/software-mansion/TypeGPU/tinyest-for-wgsl@d4591b0e79f56be207017364c74b9079bb603002
https://pkg.pr.new/software-mansion/TypeGPU/typegpu@d4591b0e79f56be207017364c74b9079bb603002
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/cli@d4591b0e79f56be207017364c74b9079bb603002
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/color@d4591b0e79f56be207017364c74b9079bb603002
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/gl@d4591b0e79f56be207017364c74b9079bb603002
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/noise@d4591b0e79f56be207017364c74b9079bb603002
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/radiance-cascades@d4591b0e79f56be207017364c74b9079bb603002
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/react@d4591b0e79f56be207017364c74b9079bb603002
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/sdf@d4591b0e79f56be207017364c74b9079bb603002
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/three@d4591b0e79f56be207017364c74b9079bb603002
https://pkg.pr.new/software-mansion/TypeGPU/unplugin-typegpu@d4591b0e79f56be207017364c74b9079bb603002

benchmark
view benchmark

commit
view commit

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds explicit buffer type aliases that capture common usage-flag intersections, making user type annotations and API surface clearer while keeping the underlying TgpuBuffer behavior unchanged.

Changes:

  • Introduces TgpuUniformBuffer, TgpuStorageBuffer, TgpuVertexBuffer, and TgpuIndexBuffer as named aliases for TgpuBuffer<T> & <UsageFlag>.
  • Exports TgpuBufferBinding alongside existing buffer binding types.
  • Updates docs and adds a type-level test to ensure .$usage(...) results are compatible with the new aliases; ignores local .pnpm-store.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/typegpu/src/core/buffer/buffer.ts Adds the new Tgpu*Buffer type aliases.
packages/typegpu/src/indexNamedExports.ts Re-exports the new aliases and TgpuBufferBinding from the public entry points.
packages/typegpu/tests/buffer.test.ts Adds a type-level regression test asserting .$usage(...) buffers extend the new aliases.
apps/typegpu-docs/src/content/docs/apis/buffers.mdx Documents the new aliases with a concrete annotation example.
.gitignore Ignores .pnpm-store created by local tooling.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions

github-actions Bot commented Aug 5, 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 260.04 kB ($${\color{green}-3.2\%}$$)
tgpu_initFromDevice.ts 259.51 kB ($${\color{green}-3.4\%}$$)
tgpu_resolve.ts 165.41 kB ($${\color{green}-38.4\%}$$)
tgpu_resolveWithContext.ts 165.35 kB ($${\color{green}-38.4\%}$$)
tgpu_bindGroupLayout.ts 69.27 kB ($${\color{green}-74.2\%}$$)
tgpu_mutableAccessor.ts 66.27 kB ($${\color{green}-75.3\%}$$)
tgpu_accessor.ts 66.26 kB ($${\color{green}-75.3\%}$$)
tgpu_privateVar.ts 65.61 kB ($${\color{green}-75.6\%}$$)
tgpu_workgroupVar.ts 65.60 kB ($${\color{green}-75.6\%}$$)
tgpu_const.ts 64.85 kB ($${\color{green}-75.9\%}$$)
tgpu_fn.ts 38.45 kB ($${\color{green}-85.7\%}$$)
tgpu_fragmentFn.ts 38.45 kB ($${\color{green}-85.7\%}$$)
tgpu_vertexFn.ts 38.27 kB ($${\color{green}-85.8\%}$$)
tgpu_computeFn.ts 37.97 kB ($${\color{green}-85.9\%}$$)
tgpu_vertexLayout.ts 27.08 kB ($${\color{green}-89.9\%}$$)
tgpu_comptime.ts 14.77 kB ($${\color{green}-94.5\%}$$)
tgpu_unroll.ts 1.66 kB ($${\color{green}-99.4\%}$$)
tgpu_slot.ts 1.54 kB ($${\color{green}-99.4\%}$$)
tgpu_lazy.ts 1.19 kB ($${\color{green}-99.6\%}$$)

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

@github-actions

github-actions Bot commented Aug 5, 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.91, 1.77, 4.26, 6.54, 7.40, 10.94, 22.40, 24.65]
  line [0.88, 1.87, 3.75, 6.72, 7.26, 11.26, 21.30, 22.58]
  line [0.89, 1.86, 4.15, 6.47, 8.29, 11.14, 21.41, 25.42]
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.32, 0.51, 0.67, 0.79, 1.06, 1.15, 1.35, 1.51]
  line [0.28, 0.45, 0.64, 0.77, 1.02, 1.11, 1.26, 1.45]
  line [0.34, 0.49, 0.67, 0.80, 1.06, 1.14, 1.40, 1.52]
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.84, 1.96, 3.55, 6.80, 12.80, 25.73, 53.91, 108.42]
  line [0.96, 2.05, 3.98, 7.07, 12.46, 25.86, 54.74, 108.75]
  line [0.86, 2.07, 4.06, 6.32, 12.85, 26.13, 55.47, 111.45]
Loading

@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

Reviewed PR #2787 "feat: Add buffer type aliases" at d4591b0.

  • Added four named public type aliases for usage-flagged buffers in packages/typegpu/src/core/buffer/buffer.ts.
  • Exported the new aliases and TgpuBufferBinding from packages/typegpu/src/indexNamedExports.ts.
  • Added a type-level test asserting .$usage(...) results are assignable to the corresponding aliases.
  • Documented the aliases in the buffers API docs.
  • Added .pnpm-store to .gitignore.

The new aliases correctly mirror the existing TgpuBuffer<T> & UsageFlag patterns used throughout the codebase, the tests would fail if the aliases drifted from the actual $usage return types, and the public exports are wired through the named-export barrel. No runtime behavior changes.

Pullfrog  | View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏

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.

feat: Type alises for buffers with flags

2 participants