Skip to content

fix(ir): parenthesize CellUV base in Swizzle expressions - #9

Merged
odvcencio merged 1 commit into
mainfrom
fix/celluv-swizzle-parens
Jul 27, 2026
Merged

odvcencio merged 1 commit into
mainfrom
fix/celluv-swizzle-parens

Conversation

@odvcencio

@odvcencio odvcencio commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This fixes a precedence bug where inline cell.uv.x expressions in WGSL and Metal backends produced incorrect output. Both dialects render CellUV as an unparenthesized division expression, so appending .field without parentheses bound the swizzle to the denominator instead of the entire UV, e.g. a / b.x instead of (a / b).x. GLSL and GLES render CellUV as the bare varying vUV, so they were not affected.

Changes

  • Parenthesize CellUV specifically in ir.Print's Swizzle case so inline swizzled access renders as (a / b).x
  • Added regression unit test covering the Swizzle-with-CellUV case and a guard test ensuring bare CellUV output is unchanged
  • Conformance test water-sim-inline-cell-uv with golden outputs for all backends (GLES, GLSL, Metal, WGSL)

Testing

  • go test ./...

- Print's Swizzle case appended ".field" to CellUV without parentheses, causing swizzles to bind to the division denominator in WGSL/Metal (e.g. `a / b.x` instead of `(a / b).x`)
- Add targeted parenthesization in Print's Swizzle case for CellUV to ensure correct precedence without affecting bare CellUV usage
- Add regression tests for swizzled and bare CellUV print output
- Add conformance test material and goldens exercising inline `cell.uv` swizzles
@odvcencio
odvcencio merged commit f5ec361 into main Jul 27, 2026
1 check passed
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.

1 participant