Skip to content

fix: preserve signed float intdiv operands - #2945

Open
oxura wants to merge 2 commits into
software-mansion:mainfrom
oxura:fix/2892-signed-float-intdiv
Open

fix: preserve signed float intdiv operands#2945
oxura wants to merge 2 commits into
software-mansion:mainfrom
oxura:fix/2892-signed-float-intdiv

Conversation

@oxura

@oxura oxura commented Aug 29, 2026

Copy link
Copy Markdown

Summary

  • prefer i32 when std.intdiv must choose between equally ranked signed and unsigned targets
  • keep explicitly unsigned operands on the existing u32 path
  • cover negative runtime f32 operands across the CPU implementation and generated WGSL

Closes #2892

Verification

  • vitest run --config vitest.config.mts from packages/typegpu — 2,370 tests passed
  • pnpm --filter typegpu test:types
  • oxlint on the changed source and test files
  • oxfmt --check on the changed source and test files

Copilot AI lite review requested due to automatic review settings August 29, 2026 11:05
@pullfrog

pullfrog Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Run failed. View the logs →

Pullfrog  | Rerun failed job ➔View workflow run | via Pullfrog | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

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

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 choose i32 over u32 in signed/unsigned tie cases.
  • Add a regression test ensuring negative runtime f32 operands 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.

Comment thread packages/typegpu/src/std/numeric.ts Outdated
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.

std.intdiv with two runtime f32 operands emits unsigned division, so negative inputs silently return 0 on GPU

2 participants