Skip to content

GPU: rectangle corners in normalized vertex formats, NaN in half conversion - #1311

Closed
SamuelReeder wants to merge 1 commit into
Marvisak:mainfrom
SamuelReeder:fix/rect-normalized-corners
Closed

SamuelReeder wants to merge 1 commit into
Marvisak:mainfrom
SamuelReeder:fix/rect-normalized-corners

Conversation

@SamuelReeder

@SamuelReeder SamuelReeder commented Nov 24, 2026 •

Copy link
Copy Markdown

expand_rects computes a rectangle's fourth corner only for the vertex formats components knows; others keep the first vertex's value. This adds the remaining 8- and 16-bit normalized formats:

  • SNORM: R16G16B16A16 (13), R8G8B8A8 (31), R16G16 (37), R8G8 (51), R16 (58), R8 (63)
  • UNORM: R8G8 (49), R16 (56), R8 (61)

The lowest SNORM integer reads as -1, as in D3D. f32_to_half also turned NaN into infinity; it now stays NaN.

The NaN change covers half of #843, reported there with a fix; #1069 (closed) fixed both halves. #1220 covers the rounding half.

Half rounding of exact ties is left to #1220. #1158 and #1204 also touch expand_rects.

Tests (synthetic, CPU only), each failing before and passing after:

  • signed_normalized_corners_complete_the_rectangle
  • small_normalized_formats_get_their_fourth_corner
  • halves_keep_nan

cargo test --workspace --locked --features victory-gpu/diagnostics with VICTORY_WARP=1 VICTORY_D3D12_WARP=1: 348 passed, 0 failed, 6 ignored. Clippy on victory-gpu is clean. Not tested with a title or on a hardware adapter.

🤖 Generated with Claude Code

The fourth corner of a rectangle kept the first vertex's value for 8- and
16-bit SNORM inputs and the one- and two-component UNORM formats. A NaN
converted to a half became infinity.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@DenRakEiw DenRakEiw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested merged cleanly onto main (ffe310e) on Windows 11 x64 (Rust 1.98.1 MSVC) with NVIDIA GeForce RTX 5090 (Blackwell) and WARP (VICTORY_D3D12_WARP=1):

  • cargo test -p victory-gpu (RTX 5090): 53 passed, 0 failed, 1 ignored
  • VICTORY_D3D12_WARP=1 cargo test -p victory-gpu (WARP): 53 passed, 0 failed, 1 ignored
  • cargo clippy -p victory-gpu --all-targets: 0 warnings
  • cargo xtask policy: ok

Clean normalized vertex format and half-float NaN handling in rectangle expansion. Approving.

AI-assisted (Gemini 4 Neon).

@muhammed-aksoy

Copy link
Copy Markdown

Windows integration results for 075c4ba on ffe310e. The GPU diagnostics suite passed 56 tests with one ignored. In a separate local merge with the branch from #843, both touch primitive.rs. Keeping this PR's normalized rectangle changes and #843's payload-preserving, ties-to-even half conversion passed 56 GPU diagnostics tests with one ignored on WARP, including both regression cases. The tested merge is 8c799dc. These were synthetic fixtures. AI-assisted.

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.

3 participants