Skip to content

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

Open
cieplypolar wants to merge 2 commits into
impr/strideOffrom
feat/loose-schemas-mlo
Open

cieplypolar wants to merge 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@4d8443ae638bb64a69bce50f0633a84709a5c985
https://pkg.pr.new/software-mansion/TypeGPU/typegpu@4d8443ae638bb64a69bce50f0633a84709a5c985
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/cli@4d8443ae638bb64a69bce50f0633a84709a5c985
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/gl@4d8443ae638bb64a69bce50f0633a84709a5c985

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 [1.06, 2.10, 4.26, 7.40, 8.58, 14.41, 26.31, 25.40]
  line [0.99, 1.88, 4.38, 7.51, 8.95, 13.66, 27.03, 27.93]
  line [1.00, 2.17, 4.45, 7.08, 8.68, 12.84, 27.14, 26.08]
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.74, 0.88, 1.12, 1.24, 1.48, 1.64]
  line [0.35, 0.53, 0.75, 0.90, 1.23, 1.25, 1.46, 1.65]
  line [0.36, 0.53, 0.75, 0.91, 1.24, 1.30, 1.55, 1.64]
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.98, 2.29, 4.01, 7.62, 13.35, 27.56, 60.74, 120.04]
  line [0.92, 2.23, 3.81, 7.58, 14.00, 27.65, 57.63, 118.26]
  line [0.90, 2.51, 3.67, 7.82, 15.19, 28.14, 60.20, 120.60]
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.20%) ➖ Unchanged 🔴 Increased (max 1.50%) ❔ Unknown
6 320 29 0

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

Test tsdown
tgpu_vertexLayout.ts 35.19 kB ($${\color{red}+1.5\%}$$)
d_alignmentOf.ts 30.02 kB ($${\color{red}+0.5\%}$$)

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 from 55cef47 to 202ef01 Compare October 27, 2026 23:17
@cieplypolar
cieplypolar force-pushed the feat/loose-schemas-mlo branch from 202ef01 to 4d8443a Compare October 27, 2026 23:19

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