Skip to content

fix(emit): avoid division by zero in point sprite NDC offset - #5

Merged
odvcencio merged 1 commit into
mainfrom
fix/viewport-div-guard
Jul 27, 2026
Merged

fix(emit): avoid division by zero in point sprite NDC offset#5
odvcencio merged 1 commit into
mainfrom
fix/viewport-div-guard

Conversation

@odvcencio

Copy link
Copy Markdown
Contributor

Summary

Prevents a division-by-zero crash when calculating NDC offsets for point sprites. Previously, the vertex shader divided directly by the viewport width and height, which can occasionally be zero. The fix clamps these dimensions to at least 1.0 before the division.

Changes

  • Modified Metal and WGSL vertex shader generators to compute NDC offsets safely.
  • Clamping viewport width/height to a minimum of 1.0 prevents zero-division runtime errors.
  • Refreshed conformance golden files to reflect the updated shader math.

Testing

  • Run go test ./... to verify conformance tests pass and golden files are up to date.

- Clamp viewport dimensions to 1.0 minimum to prevent division by zero during point sprite NDC offset calculation
- Prevent NaN/undefined behavior when viewport width or height is zero
- Update Metal and WGSL emitters and golden test files
@odvcencio
odvcencio force-pushed the fix/viewport-div-guard branch from 5d1b829 to c03b7d7 Compare July 27, 2026 05:00
@odvcencio
odvcencio merged commit 3d459d5 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