GPU: reconstruct packed UNORM rectangle vertex colors #2243

Closed
github-bot wants to merge 1 commit from gh-pr/2243/head into gh-pr/2243/base
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-25 08:36 UTC · original
andrewpozdnakov7-jpg:codex2/packed-rect-vertex → main · +52 −6 · 1 files · 1 commits · closed without merging

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.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-25 08:36 UTC · [original](https://github.com/Marvisak/VIctory/pull/2243) `andrewpozdnakov7-jpg:codex2/packed-rect-vertex` → `main` · +52 −6 · 1 files · 1 commits · closed without merging 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://git.gtahub.st/github/Marvisak--VIctory/issues/1633). AI-assisted using Codex. Synthetic vertex data only.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:59:43 +00:00
github-bot closed this pull request 2026-11-26 04:59:43 +00:00
Author
Owner

@⁠MamaLeVrai on GitHub · 2026-11-25 09:13 UTC · original

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.

**@⁠MamaLeVrai** on GitHub · 2026-11-25 09:13 UTC · [original](https://github.com/Marvisak/VIctory/pull/2243#issuecomment-7158041722) 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.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 13:31 UTC · original

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

**@⁠Marvisak** on GitHub · 2026-11-25 13:31 UTC · [original](https://github.com/Marvisak/VIctory/pull/2243#issuecomment-7163910242) <!-- 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)_
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 22:07 UTC · original

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.

**@⁠Marvisak** on GitHub · 2026-11-25 22:07 UTC · [original](https://github.com/Marvisak/VIctory/pull/2243#issuecomment-7175961297) 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

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2243
No description provided.