GPU: reconstruct packed UNORM rectangle vertex colors #2241

Closed
andrewpozdnakov7-jpg wants to merge 1 commit from upstream-pr/2243 into main
andrewpozdnakov7-jpg commented 2026-11-25 08:36:13 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-25T08:36:13Z.


Rectangle expansion handles several unpacked vertex formats. For R10G10B10A2_UNORM, the generated fourth vertex currently keeps the color of the first vertex. This format is supported by the D3D12 input assembler. Format support.

Reconstruct each packed channel with the same fourth-corner formula used by the existing expansion, then clamp to its bit width. A packed element that crosses the vertex stride retains the first vertex's bytes.

The same synthetic vertex-buffer test failed before the change and passed after it. It checks all four channels and a packed element whose word crosses the stride.

  • Windows/WARP GPU library suite with the regression went from 145 passed, 2 failed, 2 ignored to 146 passed, 1 failed, 2 ignored. The placed-view texture-format test failed in both builds.

  • Clippy passed for victory-gpu all targets with warnings denied, with and without diagnostics.

  • Native D3D12 WARP control with the same synthetic vertex data on 940d32f and c53275b. It fed the expanded fourth vertex through the packed input assembler format, drew one point, and copied the float render target back. The pixel was [0.9384164, 0.21505377, 0.015640274, 0.33333334] before and [1.0, 0.2639296, 0.0, 1.0] after, matching the reconstructed channels.

Coordination claim in #1633.

AI-assisted using Codex. Synthetic vertex data only.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6600481377 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2243). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-25T08:36:13Z. --- Rectangle expansion handles several unpacked vertex formats. For R10G10B10A2_UNORM, the generated fourth vertex currently keeps the color of the first vertex. This format is supported by the D3D12 input assembler. [Format support](https://learn.microsoft.com/en-us/windows/win32/direct3ddxgi/hardware-support-for-direct3d-12-0-formats). Reconstruct each packed channel with the same fourth-corner formula used by the existing expansion, then clamp to its bit width. A packed element that crosses the vertex stride retains the first vertex's bytes. The same synthetic vertex-buffer test failed before the change and passed after it. It checks all four channels and a packed element whose word crosses the stride. - Windows/WARP GPU library suite with the regression went from 145 passed, 2 failed, 2 ignored to 146 passed, 1 failed, 2 ignored. The placed-view texture-format test failed in both builds. - Clippy passed for victory-gpu all targets with warnings denied, with and without diagnostics. - Native D3D12 WARP control with the same synthetic vertex data on 940d32f and c53275b. It fed the expanded fourth vertex through the packed input assembler format, drew one point, and copied the float render target back. The pixel was [0.9384164, 0.21505377, 0.015640274, 0.33333334] before and [1.0, 0.2639296, 0.0, 1.0] after, matching the reconstructed channels. [Coordination claim in #1633](https://github.com/Marvisak/VIctory/issues/1633#issuecomment-7157127975). AI-assisted using Codex. Synthetic vertex data only.
DenRakEiw commented 2026-11-25 09:06:00 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T08:42:29Z.

Review: APPROVED


Verified locally merged onto origin/main (940d32f, Windows 11 x64, Rust 1.98.1 MSVC):

  • cargo test -p victory-gpu --lib primitive:: — 9 passed, 0 failed (including a_packed_unorm_color_is_reconstructed_at_the_missing_corner)
  • cargo clippy -p victory-gpu --all-targets — 0 warnings
  • cargo xtask policy — ok (183 files ok)

Clean per-channel reconstruction of packed UNORM rectangle vertex colors at the missing fourth corner. Looks good.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6054307532 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2243#pullrequestreview-6054307532). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-25T08:42:29Z. **Review:** APPROVED --- Verified locally merged onto `origin/main` (`940d32f`, Windows 11 x64, Rust 1.98.1 MSVC): - `cargo test -p victory-gpu --lib primitive::` — **9 passed, 0 failed** (including `a_packed_unorm_color_is_reconstructed_at_the_missing_corner`) - `cargo clippy -p victory-gpu --all-targets` — 0 warnings - `cargo xtask policy` — ok (`183 files ok`) Clean per-channel reconstruction of packed UNORM rectangle vertex colors at the missing fourth corner. Looks good. AI-assisted (Gemini 4 Neon).
catminou4 commented 2026-11-25 09:06:00 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T08:48:37Z.

Review: COMMENTED


Reconstruct packed UNORM (R10G10B10A2) rectangle vertex colors for the fourth vertex instead of reusing v0. Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1.

<!-- greyfinch-sync:Marvisak/VIctory:review:6054381992 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2243#pullrequestreview-6054381992). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T08:48:37Z. **Review:** COMMENTED --- Reconstruct packed UNORM (R10G10B10A2) rectangle vertex colors for the fourth vertex instead of reusing v0. Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1.
MamaLeVrai commented 2026-11-25 10:07:32 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by MamaLeVrai on 2026-11-25T09:13:29Z.


Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present, so the hardware-only shader checks run. I merged this PR's head c53275b7 into main 940d32f in a throwaway tree (no conflict). cargo clippy --workspace --all-targets --locked -- -D warnings: clean; the same with --all-features: clean. cargo test --workspace --locked: 702 passed, 0 failed, 10 ignored, two runs (main alone on the same machine: 701 passed, 0 failed, 10 ignored). The title was not run, so this says nothing about in-game effect. No game data.

AI-assisted (Claude Code); no game data.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7158041722 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2243#issuecomment-7158041722). Originally posted by [MamaLeVrai](https://github.com/MamaLeVrai) on 2026-11-25T09:13:29Z. --- Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present, so the hardware-only shader checks run. I merged this PR's head `c53275b7` into `main` `940d32f` in a throwaway tree (no conflict). `cargo clippy --workspace --all-targets --locked -- -D warnings`: clean; the same with `--all-features`: clean. `cargo test --workspace --locked`: 702 passed, 0 failed, 10 ignored, two runs (`main` alone on the same machine: 701 passed, 0 failed, 10 ignored). The title was not run, so this says nothing about in-game effect. No game data. AI-assisted (Claude Code); no game data.
Marvisak commented 2026-11-25 14:07:23 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T13:31:52Z.


Automated triage for the maintainers.

Merge candidate (worth a look). expand_rects in crates/victory-gpu/src/primitive.rs now computes the fourth rectangle corner for R10G10B10A2_UNORM elements per channel (packed_unorm_corner: v0 + v2 - v1 in integer units, clamped to each field's range), where before such an element, unknown to components, kept the first vertex's value; it requires the whole 4-byte word inside the vertex, like the existing per-component bound. I checked the corner formula and clamping against the float path used for the other UNORM kinds (Kind::write) and the test's expected values; CI (check) passes, and a tester reports the workspace tests passing on RDNA2. Minor: the rest of the file matches formats by number, so the windows import could be the literal 24 for consistency.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7163910242 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2243#issuecomment-7163910242). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T13:31:52Z. --- <!-- victory-triage v1 head=c53275b7597eb9c7f372ebc040077c46abef193b verdict=merge-candidate at=2026-11-25T13:47:00Z --> Automated triage for the maintainers. **Merge candidate (worth a look).** `expand_rects` in `crates/victory-gpu/src/primitive.rs` now computes the fourth rectangle corner for `R10G10B10A2_UNORM` elements per channel (`packed_unorm_corner`: v0 + v2 - v1 in integer units, clamped to each field's range), where before such an element, unknown to `components`, kept the first vertex's value; it requires the whole 4-byte word inside the vertex, like the existing per-component bound. I checked the corner formula and clamping against the float path used for the other UNORM kinds (`Kind::write`) and the test's expected values; CI (`check`) passes, and a tester reports the workspace tests passing on RDNA2. Minor: the rest of the file matches formats by number, so the `windows` import could be the literal `24` for consistency. --- _Generated by [Claude Code](https://claude.ai/code)_
upstream-sync closed this pull request 2026-11-25 23:04:07 +00:00
Marvisak commented 2026-11-25 23:05:58 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T22:07:15Z.


Automated triage for the maintainers, second look (a review against current main, with builds and tests where they could change the verdict).

Closing because it is inconsistent with 8ff79135, which it predates. Every other element now computes get(a) + get(b) - get(right) with the right angle found from the position, while the packed path here always takes the right angle at v1, so rectangles with it at v0 or v2 would get the wrong colour. The test has no position element, so it does not see this. The function is also the CPU fallback, which practically never runs now that rectangle lists get a geometry shader.

If this is mistaken, reply here with what was missed and it will be looked at again. Thank you for the contribution.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7175961297 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2243#issuecomment-7175961297). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T22:07:15Z. --- Automated triage for the maintainers, second look (a review against current `main`, with builds and tests where they could change the verdict). Closing because it is inconsistent with 8ff79135, which it predates. Every other element now computes `get(a) + get(b) - get(right)` with the right angle found from the position, while the packed path here always takes the right angle at v1, so rectangles with it at v0 or v2 would get the wrong colour. The test has no position element, so it does not see this. The function is also the CPU fallback, which practically never runs now that rectangle lists get a geometry shader. If this is mistaken, reply here with what was missed and it will be looked at again. Thank you for the contribution.

Pull request closed

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!2241
No description provided.