Skip to content

impr: Warn when property source order differs from schema declaration order - #2954

Open
cieplypolar wants to merge 5 commits into
fix/tseynit-quotes-around-non-identifiersfrom
impr/warn-schema-order
Open

impr: Warn when property source order differs from schema declaration order#2954
cieplypolar wants to merge 5 commits into
fix/tseynit-quotes-around-non-identifiersfrom
impr/warn-schema-order

Conversation

@cieplypolar

Copy link
Copy Markdown
Collaborator

No description provided.

@github-actions

github-actions Bot commented Sep 1, 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@3d4ea98ea1347253e4e95dc9754a8b4aad0f5d70
https://pkg.pr.new/software-mansion/TypeGPU/tinyest@3d4ea98ea1347253e4e95dc9754a8b4aad0f5d70
https://pkg.pr.new/software-mansion/TypeGPU/tinyest-for-wgsl@3d4ea98ea1347253e4e95dc9754a8b4aad0f5d70
https://pkg.pr.new/software-mansion/TypeGPU/typegpu@3d4ea98ea1347253e4e95dc9754a8b4aad0f5d70
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/gl@3d4ea98ea1347253e4e95dc9754a8b4aad0f5d70
https://pkg.pr.new/software-mansion/TypeGPU/unplugin-typegpu@3d4ea98ea1347253e4e95dc9754a8b4aad0f5d70

benchmark
view benchmark

commit
view commit

@github-actions

github-actions Bot commented Sep 1, 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.08, 6.92, 8.50, 10.90, 24.05, 28.96]
  line [0.97, 1.96, 4.36, 6.91, 8.09, 12.47, 24.22, 25.95]
  line [0.96, 1.90, 4.44, 6.96, 8.14, 11.74, 23.79, 24.00]
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.28, 0.47, 0.67, 0.80, 1.12, 1.15, 1.33, 1.53]
  line [0.30, 0.49, 0.68, 0.82, 1.05, 1.14, 1.32, 1.55]
  line [0.26, 0.47, 0.67, 0.80, 1.08, 1.13, 1.32, 1.54]
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.97, 2.29, 3.51, 7.58, 12.85, 26.22, 57.09, 113.60]
  line [0.90, 2.11, 3.50, 7.12, 12.67, 26.83, 56.79, 114.82]
  line [0.72, 2.23, 3.39, 7.29, 12.51, 27.45, 55.83, 113.58]
Loading

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

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

🟢 Decreased ➖ Unchanged 🔴 Increased (max 1.04%) ❔ Unknown
0 319 6 0

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

Test tsdown
tgpu_resolveWithContext.ts 163.59 kB ($${\color{red}+1.0\%}$$)
tgpu_resolve.ts 163.65 kB ($${\color{red}+1.0\%}$$)
tgpu_initFromDevice.ts 264.49 kB ($${\color{red}+0.6\%}$$)
tgpu_init.ts 265.04 kB ($${\color{red}+0.6\%}$$)
STATIC_tgpu.ts 274.56 kB ($${\color{red}+0.6\%}$$)
STATIC_allImports.ts 300.82 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.

@cieplypolar
cieplypolar force-pushed the impr/warn-schema-order branch from 8735add to f5e02ed Compare September 1, 2026 13:37
Copilot AI lite review requested due to automatic review settings September 1, 2026 13:37

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.

Pull request overview

Adds diagnostics to help developers catch situations where object-literal evaluation order and struct schema order diverge, potentially changing observable side effects (or omitting them entirely) during shader generation.

Changes:

  • Added warnings in WgslGenerator when (a) side-effectful extra struct fields are omitted and (b) side-effectful fields are reordered relative to struct declaration order.
  • Added WGSL and GLSL test coverage for the new warning scenarios (including a “no warn when pure” case).
  • Added a GLSL entry-point warning when an extra return-field is not part of the expected output struct.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
packages/typegpu/tests/tgsl/wgslGenerator.test.ts Adds WGSL tests verifying warnings for omitted/reordered side-effectful struct fields and no warning for pure reordering.
packages/typegpu/src/tgsl/wgslGenerator.ts Implements side-effect-aware warnings for extra struct fields and for schema-vs-source reordering.
packages/typegpu-gl/tests/glslGenerator.test.ts Adds GLSL tests mirroring WGSL warnings plus entry-point return warning coverage.
packages/typegpu-gl/src/glslGenerator.ts Emits a warning when entry-point return contains an extra property not in the expected output struct.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread packages/typegpu-gl/src/glslGenerator.ts
@cieplypolar
cieplypolar force-pushed the impr/warn-schema-order branch 2 times, most recently from e210e51 to c91116f Compare September 2, 2026 10:44
@cieplypolar
cieplypolar force-pushed the impr/warn-schema-order branch from 4a05e2a to 1437dea Compare September 2, 2026 12:00
@cieplypolar
cieplypolar force-pushed the impr/warn-schema-order branch from 1437dea to 78a5223 Compare September 4, 2026 15:37
@cieplypolar
cieplypolar force-pushed the impr/warn-schema-order branch from 78a5223 to 3d4ea98 Compare September 4, 2026 15:41
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.

2 participants