fix(shader): reject modified v_add_co_ci_u32 in address carry tracing #3362

Open
reeledMarek wants to merge 1 commit from upstream-pr/3362 into main
reeledMarek commented 2026-11-26 20:25:50 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by reeledMarek on 2026-11-26T20:25:50Z.


Summary

  • Tracer::carried matched v_add_co_ci_u32 without checking VALU input/output modifiers (abs, neg, opsel, clamp, omod, sdwa, dpp).
  • A saturating (clamp), SDWA sub-dword, or DPP lane-permuted v_add_co_ci_u32 was therefore accepted as a plain 64-bit address high-half carry, misclassifying the resulting global memory address as belonging to a root descriptor parameter instead of falling back to MEMORY.
  • Guards Tracer::carried to require unmodified v_add_co_ci_u32 (abs == 0 && neg == 0 && opsel == 0 && !clamp && omod == 0 && sdwa.is_none() && dpp.is_none()).
  • Adds regression test modified_v_add_co_ci_u32_is_not_treated_as_plain_address_carry covering plain vs clamped, SDWA, and DPP16 encodings.

Verification

  • Executed all 4 machine-code cases directly against victory-shader on Linux
  • cargo clippy -p victory-shader --all-targets --target x86_64-pc-windows-msvc --locked -- -D warnings
  • cargo test -p xtask --locked
<!-- greyfinch-sync:Marvisak/VIctory:issue:5516696984 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3362). Originally posted by [reeledMarek](https://github.com/reeledMarek) on 2026-11-26T20:25:50Z. --- ### Summary - `Tracer::carried` matched `v_add_co_ci_u32` without checking VALU input/output modifiers (`abs`, `neg`, `opsel`, `clamp`, `omod`, `sdwa`, `dpp`). - A saturating (`clamp`), SDWA sub-dword, or DPP lane-permuted `v_add_co_ci_u32` was therefore accepted as a plain 64-bit address high-half carry, misclassifying the resulting global memory address as belonging to a root descriptor parameter instead of falling back to `MEMORY`. - Guards `Tracer::carried` to require unmodified `v_add_co_ci_u32` (`abs == 0 && neg == 0 && opsel == 0 && !clamp && omod == 0 && sdwa.is_none() && dpp.is_none()`). - Adds regression test `modified_v_add_co_ci_u32_is_not_treated_as_plain_address_carry` covering plain vs clamped, SDWA, and DPP16 encodings. ### Verification - Executed all 4 machine-code cases directly against `victory-shader` on Linux - `cargo clippy -p victory-shader --all-targets --target x86_64-pc-windows-msvc --locked -- -D warnings` - `cargo test -p xtask --locked`
Dukestar69 commented 2026-11-26 20:27:05 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T20:27:05Z.

Review: APPROVED


LGTM — verified on Windows against origin/main (63bcca4).

  • Rejecting v_add_co_ci_u32 instructions with VALU modifiers (abs, neg, opsel, clamp, omod, sdwa, dpp) during address carry tracing avoids misclassifying saturating/SDWA/DPP operations as plain 64-bit address high-half carries.
  • cargo test -p victory-shader --lib resource:: -- --test-threads=1: 36 passed, 0 failed (including modified_v_add_co_ci_u32_is_not_treated_as_plain_address_carry).
  • cargo clippy -p victory-shader --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

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

<!-- greyfinch-sync:Marvisak/VIctory:review:6080148252 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3362#pullrequestreview-6080148252). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T20:27:05Z. **Review:** APPROVED --- LGTM — verified on Windows against `origin/main` (`63bcca4`). - Rejecting `v_add_co_ci_u32` instructions with VALU modifiers (`abs`, `neg`, `opsel`, `clamp`, `omod`, `sdwa`, `dpp`) during address carry tracing avoids misclassifying saturating/SDWA/DPP operations as plain 64-bit address high-half carries. - `cargo test -p victory-shader --lib resource:: -- --test-threads=1`: 36 passed, 0 failed (including `modified_v_add_co_ci_u32_is_not_treated_as_plain_address_carry`). - `cargo clippy -p victory-shader --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
fuzeofficlal commented 2026-11-26 20:48:25 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T20:48:25Z.

Review: APPROVED


LGTM — adding the VALU modifier guards (abs, neg, opsel, clamp, omod, sdwa, dpp) to Tracer::carried prevents modified v_add_co_ci_u32 instructions from being misclassified as plain 64-bit address high-half carries.

Verified

  • cargo clippy --locked -p victory-shader --all-targets -- -D warnings (default & --all-features): clean.
  • rustfmt --edition 2024: clean on all PR-touched hunks in crates/victory-shader/src/resource.rs.
  • cargo test --locked -p victory-shader --lib resource::tests:: -- --test-threads=1: 36 passed, 0 failed (including modified_v_add_co_ci_u32_is_not_treated_as_plain_address_carry).
  • cargo test --locked -p victory-shader --lib -- --test-threads=1 ir:: structure:: io:: emit::lower::: 59 passed, 0 failed, 1 ignored.

Non-blocking follow-up notes

  • Pre-existing siblings in resource.rs (vadd at 731-753, vorigin at 764-777, and reaches_pc at 863) have similar gaps (missing clamp/omod guards on v_mov_b32/v_add_*, and carried not yet validating the other addend or carry-in provenance).
  • Note on the SDWA case (resource.rs:3937): since 48-bit global addresses drop the upper 16 bits, dst_sel:WORD_0 with zero-pad still produces the same effective address and exercises conservative fallback to MEMORY.
<!-- greyfinch-sync:Marvisak/VIctory:review:6080339614 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3362#pullrequestreview-6080339614). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T20:48:25Z. **Review:** APPROVED --- LGTM — adding the VALU modifier guards (`abs`, `neg`, `opsel`, `clamp`, `omod`, `sdwa`, `dpp`) to `Tracer::carried` prevents modified `v_add_co_ci_u32` instructions from being misclassified as plain 64-bit address high-half carries. ### Verified - `cargo clippy --locked -p victory-shader --all-targets -- -D warnings` (default & `--all-features`): clean. - `rustfmt --edition 2024`: clean on all PR-touched hunks in `crates/victory-shader/src/resource.rs`. - `cargo test --locked -p victory-shader --lib resource::tests:: -- --test-threads=1`: **36 passed, 0 failed** (including `modified_v_add_co_ci_u32_is_not_treated_as_plain_address_carry`). - `cargo test --locked -p victory-shader --lib -- --test-threads=1 ir:: structure:: io:: emit::lower::`: **59 passed, 0 failed, 1 ignored**. ### Non-blocking follow-up notes - Pre-existing siblings in `resource.rs` (`vadd` at `731-753`, `vorigin` at `764-777`, and `reaches_pc` at `863`) have similar gaps (missing `clamp`/`omod` guards on `v_mov_b32`/`v_add_*`, and `carried` not yet validating the other addend or carry-in provenance). - Note on the SDWA case (`resource.rs:3937`): since 48-bit global addresses drop the upper 16 bits, `dst_sel:WORD_0` with zero-pad still produces the same effective address and exercises conservative fallback to `MEMORY`.
Jackster commented 2026-11-26 22:29:06 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Jackster on 2026-11-26T22:29:06Z.


Windows 11, 63bcca4 + this PR:

  • resource::tests::modified_v_add_co_ci_u32_is_not_treated_as_plain_address_carry by name: 1 passed.
  • cargo test -p victory-shader --lib resource::: green.
  • cargo clippy -p victory-shader --all-targets -- -D warnings: clean.

The guard now requires abs/neg/opsel clear, no clamp, omod 0 and no SDWA/DPP before a v_add_co_ci_u32 is read as the plain carry-add of an address; the test's plain VOP3B case still traces as a parameter and the clamped case stops doing so. Synthetic only. AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7204719300 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3362#issuecomment-7204719300). Originally posted by [Jackster](https://github.com/Jackster) on 2026-11-26T22:29:06Z. --- Windows 11, `63bcca4` + this PR: - `resource::tests::modified_v_add_co_ci_u32_is_not_treated_as_plain_address_carry` by name: 1 passed. - `cargo test -p victory-shader --lib resource::`: green. - `cargo clippy -p victory-shader --all-targets -- -D warnings`: clean. The guard now requires abs/neg/opsel clear, no clamp, omod 0 and no SDWA/DPP before a `v_add_co_ci_u32` is read as the plain carry-add of an address; the test's plain VOP3B case still traces as a parameter and the clamped case stops doing so. Synthetic only. AI-assisted.
futurepro62 commented 2026-11-27 07:17:04 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by futurepro62 on 2026-11-27T07:17:04Z.


NVIDIA full-suite run, to go with the reports above by Dukestar69, Jackster, fuzeofficlal, since none of them names a GPU run. Tested exact head dd8cf5f (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: modified_v_add_co_ci_u32_is_not_treated_as_plain_address_carry.
  • --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:7212322588 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3362#issuecomment-7212322588). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-27T07:17:04Z. --- NVIDIA full-suite run, to go with the reports above by Dukestar69, Jackster, fuzeofficlal, since none of them names a GPU run. Tested exact head `dd8cf5f` (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: `modified_v_add_co_ci_u32_is_not_treated_as_plain_address_carry`. - `--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/3362:upstream-pr/3362'
git switch 'upstream-pr/3362'

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