GPU: expand packed rectangle colors from the selected corner #3646

Open
andrewpozdnakov7-jpg wants to merge 1 commit from upstream-pr/3646 into main
andrewpozdnakov7-jpg commented 2026-11-28 01:50:58 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T01:50:58Z.


The CPU rectangle fallback leaves R10G10B10A2_UNORM at the copied corner’s value. Reconstruct the fourth color from the two adjacent vertices and the right-angle vertex already selected from the position. Clamp RGB to 10 bits and alpha to 2 bits.

This replaces the closed #2243. Its review identified that the packed calculation assumed the second vertex was the right angle. The new regression supplies a float2 position and packed color in the same vertex and exercises all six orders. The fourth position and all four color channels match the expected values for every order.

The same regression fails on 63bcca43. All ten primitive tests passed with the fix when compiling the exact module and its unchanged right-angle helper with rustc --test. The local test exercises CPU expansion. DXGI input-assembler format support.

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5535535304 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3646). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T01:50:58Z. --- The CPU rectangle fallback leaves `R10G10B10A2_UNORM` at the copied corner’s value. Reconstruct the fourth color from the two adjacent vertices and the right-angle vertex already selected from the position. Clamp RGB to 10 bits and alpha to 2 bits. This replaces the closed #2243. Its review identified that the packed calculation assumed the second vertex was the right angle. The new regression supplies a `float2` position and packed color in the same vertex and exercises all six orders. The fourth position and all four color channels match the expected values for every order. The same regression fails on `63bcca43`. All ten primitive tests passed with the fix when compiling the exact module and its unchanged right-angle helper with `rustc --test`. The local test exercises CPU expansion. [DXGI input-assembler format support](https://learn.microsoft.com/en-us/windows/win32/direct3ddxgi/hardware-support-for-direct3d-12-0-formats). AI-assisted with OpenAI Codex.
andrewpozdnakov7-jpg commented 2026-11-28 01:51:19 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T01:51:19Z.


Verified 187d1c29a5789d923f028312fb37904927dccf56 against 63bcca43c6a00a758510398fa43096ce7e4f7df0. The new rectangle test fails on main and passes for all six orders with the fix. The fourth vertex has position (2, 1) and packed color (1023, 270, 0, 3), including saturation in the red, blue, and alpha channels.

All ten primitive tests passed using the exact source and unchanged right-angle helper. Git merged this head cleanly with #2729 at 857f394ebe5a7f8d1b4100979cd801eb4ac4deb8. The same ten tests passed from the merged primitive source. Asset policy passed for 191 files. These runs used generated CPU vertex data.

Please preserve the Git author if cherry-picking or rebasing, or include this trailer if folding the change into another commit.

Co-authored-by: andrewpozdnakov7-jpg <[email protected]>

<!-- greyfinch-sync:Marvisak/VIctory:comment:7231962184 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3646#issuecomment-7231962184). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T01:51:19Z. --- Verified `187d1c29a5789d923f028312fb37904927dccf56` against `63bcca43c6a00a758510398fa43096ce7e4f7df0`. The new rectangle test fails on main and passes for all six orders with the fix. The fourth vertex has position `(2, 1)` and packed color `(1023, 270, 0, 3)`, including saturation in the red, blue, and alpha channels. All ten primitive tests passed using the exact source and unchanged right-angle helper. Git merged this head cleanly with #2729 at `857f394ebe5a7f8d1b4100979cd801eb4ac4deb8`. The same ten tests passed from the merged primitive source. Asset policy passed for 191 files. These runs used generated CPU vertex data. Please preserve the Git author if cherry-picking or rebasing, or include this trailer if folding the change into another commit. `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>`
Dukestar69 commented 2026-11-28 02:45:57 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-28T02:45:57Z.

Review: APPROVED


LGTM — verified on Windows:

  • cargo test -p victory-gpu --lib primitive:: passed (10/10, including packed_unorm_uses_the_position_corner_in_each_vertex_order)
  • cargo clippy -p victory-gpu --all-targets -- -D warnings passed with 0 warnings
  • cargo xtask policy passed (191 files ok)

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6095250236 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3646#pullrequestreview-6095250236). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-28T02:45:57Z. **Review:** APPROVED --- LGTM — verified on Windows: - `cargo test -p victory-gpu --lib primitive::` passed (10/10, including `packed_unorm_uses_the_position_corner_in_each_vertex_order`) - `cargo clippy -p victory-gpu --all-targets -- -D warnings` passed with 0 warnings - `cargo xtask policy` passed (`191 files ok`) Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
andrewpozdnakov7-jpg commented 2026-11-28 03:18:02 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T03:18:02Z.


I checked #3653 with the current 187d1c29 head. Combined commit 89e04d8 preserves both PR heads.

All ten existing rectangle tests, including the packed-color test for every vertex order, passed on both revisions. I also expanded 4,096 generated rectangles with float positions and packed R10G10B10A2, UNORM8, SNORM8 and UNORM16 in one vertex. The full output buffers matched byte for byte. A second fixture compared 51,511,296 reconstructed normalized codes. These checks ran the exact rectangle expansion source on CPU and the asset policy passed.

Please retain the Git authors on cherry-pick or rebase, or add Co-authored-by: andrewpozdnakov7-jpg <[email protected]> if folding the normalized arithmetic into another commit.

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7232960995 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3646#issuecomment-7232960995). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T03:18:02Z. --- I checked #3653 with the current `187d1c29` head. [Combined commit `89e04d8`](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/89e04d827226fe086daf71e550f16765d8bd8526) preserves both PR heads. All ten existing rectangle tests, including the packed-color test for every vertex order, passed on both revisions. I also expanded 4,096 generated rectangles with float positions and packed R10G10B10A2, UNORM8, SNORM8 and UNORM16 in one vertex. The full output buffers matched byte for byte. A second fixture compared 51,511,296 reconstructed normalized codes. These checks ran the exact rectangle expansion source on CPU and the asset policy passed. Please retain the Git authors on cherry-pick or rebase, or add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>` if folding the normalized arithmetic into another commit. AI-assisted with OpenAI Codex.
futurepro62 commented 2026-11-29 21:53:46 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by futurepro62 on 2026-11-29T21:53:46Z.


Full-suite run on NVIDIA, since this PR has no test report yet. Tested exact head 187d1c2 (on its base 63bcca4).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), dxil.dll from Windows SDK 10.0.26100 (the loader's default), debug.
  • cargo build --workspace --locked, then cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 867 passed, 0 failed, 10 ignored.
  • The new tests ran and passed: packed_unorm_uses_the_position_corner_in_each_vertex_order.
  • --skip leaves out tests that fail on main 63bcca4 on this card too, not because of this PR: heap_direct_texture_reads_mark_their_heap_index ends the victory-shader test process with 0xc0000005 (#2571), so without the skip the rest of that crate never reports; dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views and the two stride_tests hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); gathers_at_a_level_match_the_hardware fails on lane 0 (#1744).

Not tested

  • AMD (the tests take the default adapter), a release build, the title (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7263237800 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3646#issuecomment-7263237800). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-29T21:53:46Z. --- Full-suite run on NVIDIA, since this PR has no test report yet. Tested exact head `187d1c2` (on its base `63bcca4`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), `dxil.dll` from Windows SDK 10.0.26100 (the loader's default), debug. - `cargo build --workspace --locked`, then `cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware`: **867 passed, 0 failed, 10 ignored**. - The new tests ran and passed: `packed_unorm_uses_the_position_corner_in_each_vertex_order`. - `--skip` leaves out tests that fail on main `63bcca4` on this card too, not because of this PR: `heap_direct_texture_reads_mark_their_heap_index` ends the `victory-shader` test process with `0xc0000005` (#2571), so without the skip the rest of that crate never reports; `dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views` and the two `stride_tests` hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); `gathers_at_a_level_match_the_hardware` fails on lane 0 (#1744). **Not tested** - AMD (the tests take the default adapter), a release build, the title (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3646:upstream-pr/3646'
git switch 'upstream-pr/3646'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3646'
git switch 'upstream-pr/3646'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3646'
git switch 'upstream-pr/3646'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3646'
git switch 'main'
git merge --squash 'upstream-pr/3646'
git switch 'main'
git merge --ff-only 'upstream-pr/3646'
git switch 'main'
git merge 'upstream-pr/3646'
git push origin 'main'
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!3646
No description provided.