GPU: interpolate normalized rectangle vertex attributes #1452

Merged
Luizbc2 merged 1 commit from upstream-pr/1453 into main 2026-11-25 00:14:15 +00:00
Luizbc2 commented 2026-11-24 18:06:30 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Luizbc2 on 2026-11-24T18:06:30Z.


Summary

The rectangle-list expansion leaves attributes in several ordinary normalized vertex formats at the first vertex’s value. Add the remaining one- and two-component UNORM8 forms, scalar UNORM16, and the one-, two-, and four-component SNORM8/SNORM16 forms so they use the existing fourth-corner interpolation. Clamp the signed minimum on decode and clamp the interpolated result to the representable range before encoding.

Reproduction and testing

The new normalized_attributes_are_interpolated_in_their_own_range test expands one synthetic rectangle. On ffe310e it finds the first vertex’s bytes at the fourth vertex. With the patch, it verifies the interpolated attributes and positive and negative clamping. All five primitive.rs tests passed on Windows with the pinned Rust toolchain.

Reference: DXGI format definitions. AI-assisted with Codex.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6588279722 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1453). Originally posted by [Luizbc2](https://github.com/Luizbc2) on 2026-11-24T18:06:30Z. --- ## Summary The rectangle-list expansion leaves attributes in several ordinary normalized vertex formats at the first vertex’s value. Add the remaining one- and two-component UNORM8 forms, scalar UNORM16, and the one-, two-, and four-component SNORM8/SNORM16 forms so they use the existing fourth-corner interpolation. Clamp the signed minimum on decode and clamp the interpolated result to the representable range before encoding. ## Reproduction and testing The new `normalized_attributes_are_interpolated_in_their_own_range` test expands one synthetic rectangle. On `ffe310e` it finds the first vertex’s bytes at the fourth vertex. With the patch, it verifies the interpolated attributes and positive and negative clamping. All five `primitive.rs` tests passed on Windows with the pinned Rust toolchain. Reference: [DXGI format definitions](https://learn.microsoft.com/en-us/windows/win32/api/dxgiformat/ne-dxgiformat-dxgi_format). AI-assisted with Codex.
acetonahard-code commented 2026-11-24 21:03:49 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by acetonahard-code on 2026-11-24T20:59:50Z.


For reference: #1311 added the same normalized/SNORM entries to components, and its author closed it today, so this looks like the one to keep.

Tested on Windows 11, RTX 4070 SUPER (driver 621.14), with the repo toolchain, merged into current main (ffe310e):

cargo test -p victory-gpu passed failed ignored
main 50 0 1
main + this PR 51 0 1
main, --all-features 53 0 -
main + this PR, --all-features 54 0 -
  • The new test passes.
  • No GPU test skipped for lack of a device.
  • cargo clippy --all-targets -- -D warnings, with and without --all-features: clean.

I didn't test with game data.


Tested locally with an AI-assisted script (Claude Code); I checked the results before posting.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7144336070 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1453#issuecomment-7144336070). Originally posted by [acetonahard-code](https://github.com/acetonahard-code) on 2026-11-24T20:59:50Z. --- For reference: #1311 added the same normalized/SNORM entries to `components`, and its author closed it today, so this looks like the one to keep. Tested on Windows 11, RTX 4070 SUPER (driver 621.14), with the repo toolchain, merged into current `main` (ffe310e): | `cargo test -p victory-gpu` | passed | failed | ignored | |---|---|---|---| | `main` | 50 | 0 | 1 | | `main` + this PR | 51 | 0 | 1 | | `main`, `--all-features` | 53 | 0 | - | | `main` + this PR, `--all-features` | 54 | 0 | - | - The new test passes. - No GPU test skipped for lack of a device. - `cargo clippy --all-targets -- -D warnings`, with and without `--all-features`: clean. I didn't test with game data. --- <sub>Tested locally with an AI-assisted script (Claude Code); I checked the results before posting.</sub>
mercuryVM commented 2026-11-24 23:04:35 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T22:49:49Z.

Review: APPROVED


Tested 6f36cdf on Windows 11, RTX 5070, MSVC: builds, cargo test --workspace --no-fail-fast 644 passed, 0 failed (on our fork main), clippy -D warnings clean with and without --all-features. normalized_attributes_are_interpolated_in_their_own_range passes.

  • The format numbers are the right DXGI formats: 56 R16_UNORM, 49 R8G8_UNORM, 61 R8_UNORM, 13/37/58 R16G16B16A16/R16G16/R16_SNORM, and 31/51/63 R8G8B8A8/R8G8/R8_SNORM.
  • The SNORM decode clamps the most negative code (-128, -32768) to -1.0, as the D3D conversion rules require. The encode clamps to [-1, 1] and rounds.
  • The test's fourth corner (v0 + v2 - v1) checks the interpolation and both clamps, positive (UNORM8 at 255) and negative (SNORM at the minimum).

Merged into our fork's main.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:review:6048627758 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1453#pullrequestreview-6048627758). Originally posted by [mercuryVM](https://github.com/mercuryVM) on 2026-11-24T22:49:49Z. **Review:** APPROVED --- Tested 6f36cdf on Windows 11, RTX 5070, MSVC: builds, `cargo test --workspace --no-fail-fast` 644 passed, 0 failed (on our fork main), clippy `-D warnings` clean with and without `--all-features`. `normalized_attributes_are_interpolated_in_their_own_range` passes. - The format numbers are the right DXGI formats: 56 R16_UNORM, 49 R8G8_UNORM, 61 R8_UNORM, 13/37/58 R16G16B16A16/R16G16/R16_SNORM, and 31/51/63 R8G8B8A8/R8G8/R8_SNORM. - The SNORM decode clamps the most negative code (-128, -32768) to -1.0, as the D3D conversion rules require. The encode clamps to [-1, 1] and rounds. - The test's fourth corner (v0 + v2 - v1) checks the interpolation and both clamps, positive (UNORM8 at 255) and negative (SNORM at the minimum). Merged into our fork's main. AI-assisted (Claude Code).
upstream-sync closed this pull request 2026-11-25 01:06:35 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Marvisak/VIctory!1452
No description provided.