fix: preserve signed float intdiv operands - #2945
Open
oxura wants to merge 2 commits into
Open
Conversation
Contributor
|
Run failed. View the logs →
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a backend mismatch in std.intdiv where two runtime f32 operands could unify to u32, causing negative values to saturate to 0 in generated WGSL and produce incorrect GPU results compared to the CPU implementation.
Changes:
- Adjust
std.intdiv’s type unification preference to choosei32overu32in signed/unsigned tie cases. - Add a regression test ensuring negative runtime
f32operands produce signed integer division in both CPU execution and emitted WGSL.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/typegpu/src/std/numeric.ts | Reorders the unify candidate list for intdiv to prefer i32 over u32. |
| packages/typegpu/tests/std/numeric/intdiv.test.ts | Adds coverage for negative runtime f32 operands and validates the emitted WGSL uses i32 division. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
i32whenstd.intdivmust choose between equally ranked signed and unsigned targetsu32pathf32operands across the CPU implementation and generated WGSLCloses #2892
Verification
vitest run --config vitest.config.mtsfrompackages/typegpu— 2,370 tests passedpnpm --filter typegpu test:typesoxlinton the changed source and test filesoxfmt --checkon the changed source and test files