Skip to content

feat: Accept loose schemas in d.memoryLayoutOf - #3278

Merged
cieplypolar merged 2 commits into
impr/strideOffrom
feat/loose-schemas-mlo
Oct 30, 2026
Merged

cieplypolar merged 2 commits into
impr/strideOffrom
feat/loose-schemas-mlo

Conversation

@cieplypolar

Copy link
Copy Markdown
Collaborator

No description provided.

@cieplypolar
cieplypolar added this pull request to stack #3262 October 26, 2026 12:44
Copilot AI balanced review requested due to automatic review settings October 26, 2026 12:44

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@github-actions

github-actions Bot commented Oct 26, 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/tgpu-gen@dc0f2e23ce4c963fcc736fc7c9d18502e5955d54
https://pkg.pr.new/software-mansion/TypeGPU/typegpu@dc0f2e23ce4c963fcc736fc7c9d18502e5955d54
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/cli@dc0f2e23ce4c963fcc736fc7c9d18502e5955d54
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/color@dc0f2e23ce4c963fcc736fc7c9d18502e5955d54
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/gl@dc0f2e23ce4c963fcc736fc7c9d18502e5955d54

benchmark
view benchmark

commit
view commit

@cieplypolar
cieplypolar force-pushed the feat/loose-schemas-mlo branch from b435a5f to 677f88e Compare October 26, 2026 12:46
@github-actions

github-actions Bot commented Oct 26, 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.83, 3.73, 5.92, 7.55, 11.80, 23.05, 23.29]
  line [0.85, 1.88, 3.98, 6.30, 7.40, 11.52, 21.86, 24.33]
  line [0.97, 1.91, 3.96, 5.68, 6.33, 11.16, 18.34, 23.06]
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.27, 0.50, 0.64, 0.80, 1.08, 1.13, 1.33, 1.56]
  line [0.24, 0.45, 0.64, 0.80, 1.03, 1.05, 1.39, 1.52]
  line [0.32, 0.56, 0.73, 0.78, 1.09, 1.14, 1.44, 1.53]
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.96, 2.33, 4.57, 7.29, 12.78, 25.06, 52.31, 110.71]
  line [0.99, 2.26, 4.18, 7.88, 12.30, 24.55, 52.77, 109.24]
  line [0.88, 2.41, 4.52, 7.16, 11.58, 23.11, 52.43, 100.98]
Loading

@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

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

🟢 Decreased (max -0.01%) ➖ Unchanged 🔴 Increased (max 0.65%) ❔ Unknown
1 321 33 0

import * as ... in PR vs import * as ... in target (did bundle size increase?):

Test tsdown
d_memoryLayoutOf.ts 36.50 kB ($${\color{red}+0.6\%}$$)

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

Reviewed changes

This PR extends d.memoryLayoutOf to accept loose schemas (unstruct, disarray) and packed vertex formats, removing the throwIfLoose guard and teaching the offset proxy to descend into them.

  • Loose struct/array support — makeProxy now accepts BaseData and dispatches Unstruct/Disarray to the existing struct/array proxies; makeStructProxy/makeArrayProxy accept the loose variants. makeArrayProxy sizes elements via sizeOf(undecorate(elementType)), so custom-size decoration is treated as padding rather than data (only affects Disarray; arrayOf rejects decorated elements).
  • Packed formats — a new makePackedProxy returns the format's offset/contiguous markers while rejecting component/index access (s.pos.x, s.pos[1]) with a clear error, since packed byte layouts (e.g. unorm10-10-10-2) don't match the mapped WGSL vector.
  • Tests — the old "throws for loose schemas" cases are replaced with coverage of unstruct/disarray/packed offsets, custom sizes, alignment padding, nested continuation, and the packed component-access errors.

I verified the changed tests plus the related schema suites pass (offsetUtils, disarray, compiledIO, getLongestContiguousPrefix, isContiguous, size), tsc --noEmit is clean, and oxlint/oxfmt report no issues.

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

@cieplypolar
cieplypolar force-pushed the feat/loose-schemas-mlo branch from f9a8c97 to 55cef47 Compare October 27, 2026 18:08
@cieplypolar
cieplypolar force-pushed the feat/loose-schemas-mlo branch 4 times, most recently from 248e44a to 82b6075 Compare October 30, 2026 12:59
@cieplypolar
cieplypolar force-pushed the feat/loose-schemas-mlo branch from 82b6075 to dc0f2e2 Compare October 30, 2026 13:25
@cieplypolar
cieplypolar enabled stacked auto-merge (squash) October 30, 2026 13:26
@cieplypolar
cieplypolar merged commit 56b4312 into main Oct 30, 2026
9 checks passed
@cieplypolar
cieplypolar deleted the feat/loose-schemas-mlo branch October 30, 2026 13:33
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