Shaders: trace a geometry program's signature memory #3220

Open
kotekompotek wants to merge 1 commit from upstream-pr/3222 into main
kotekompotek commented 2026-11-26 13:37:52 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-26T13:37:52Z.


Grand Theft Auto VI's GS_VoxelizeGeneric programs (all 195 of them - the single biggest refusal bucket in victory translate --list shaders.rpf) keep the pointer to their root signature memory in user data 0-1 - their first user SGPRs, s[8:9] - and load through it like a compute program does through s[0:1]:

s_mov_b32 s0, s8                ; pointer low
s_and_b32 s1, s9, 0xff          ; high masked to 40 bits
s_load_dword s0, s[0:1], 0xb8   ; the load at 0x44

spill_loads was gated on HwStage::Cs, so the base address wasn't recognized as USER_DATA memory and the program was refused with "an address in an SGPR that is no root parameter".

Now spill_loads and param_word's spilled path admit HwStage::Gs, reading the pointer from stage.user_sgpr(0..1) instead of hardcoding s[0:1]. A geometry program's signature memory is there whenever user data 0-1 holds no parameter (it doesn't need the >16-dwords overflow condition compute has).

Verified on six real GS_VoxelizeGeneric programs extracted from shaders.rpf (v1.0.2.1) - all six now trace to USER_DATA addresses instead of failing. Regression test synthesizes the prologue + load.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5511046839 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3222). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-26T13:37:52Z. --- Grand Theft Auto VI's `GS_VoxelizeGeneric` programs (all 195 of them - the single biggest refusal bucket in `victory translate --list shaders.rpf`) keep the pointer to their root signature memory in user data 0-1 - their first user SGPRs, s[8:9] - and load through it like a compute program does through s[0:1]: ``` s_mov_b32 s0, s8 ; pointer low s_and_b32 s1, s9, 0xff ; high masked to 40 bits s_load_dword s0, s[0:1], 0xb8 ; the load at 0x44 ``` `spill_loads` was gated on `HwStage::Cs`, so the base address wasn't recognized as `USER_DATA` memory and the program was refused with "an address in an SGPR that is no root parameter". Now `spill_loads` and `param_word`'s spilled path admit `HwStage::Gs`, reading the pointer from `stage.user_sgpr(0..1)` instead of hardcoding s[0:1]. A geometry program's signature memory is there whenever user data 0-1 holds no parameter (it doesn't need the >16-dwords overflow condition compute has). Verified on six real `GS_VoxelizeGeneric` programs extracted from `shaders.rpf` (v1.0.2.1) - all six now trace to `USER_DATA` addresses instead of failing. Regression test synthesizes the prologue + load.
Dukestar69 commented 2026-11-26 13:50:41 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T13:50:41Z.

Review: APPROVED


Verified against origin/main (63bcca4):

  • cargo test -p victory-shader --lib resource::tests:: -- --test-threads=1: 36/36 passed (including a_geometry_programs_signature_memory_loads_through_its_pointer).
  • cargo clippy -p victory-shader --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Cleanly traces a geometry program's signature memory loads through its pointer.

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

<!-- greyfinch-sync:Marvisak/VIctory:review:6075265744 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3222#pullrequestreview-6075265744). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T13:50:41Z. **Review:** APPROVED --- Verified against `origin/main` (`63bcca4`): - `cargo test -p victory-shader --lib resource::tests:: -- --test-threads=1`: 36/36 passed (including `a_geometry_programs_signature_memory_loads_through_its_pointer`). - `cargo clippy -p victory-shader --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Cleanly traces a geometry program's signature memory loads through its pointer. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Venom2054 commented 2026-11-26 14:01:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Venom2054 on 2026-11-26T13:45:35Z.


I repeated the resource-tracking test on all 195 distinct GS_VoxelizeGeneric geometry shader containers in my local index, using the same inputs on the parent 63bcca43 and PR head 879f2126.

  • On the parent, resource::track refused all 195 at instruction 0x44 because it could not identify the address in the scalar register pair.
  • On the PR head, resource::track succeeded for all 195. In each case it identified one load from USER_DATA at that instruction.
  • At the full emit::translate entry point, both revisions still refused all 195 at stage selection, before producing DXIL. A separate compute control emitted 2,160 bytes of DXIL and passed the Windows SDK validator on both revisions.

This confirms the signature-memory fix across the whole family. It leaves geometry-stage translation and in-game rendering as separate checks. Codex assisted with the offline comparison.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7193797473 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3222#issuecomment-7193797473). Originally posted by [Venom2054](https://github.com/Venom2054) on 2026-11-26T13:45:35Z. --- I repeated the resource-tracking test on all 195 distinct `GS_VoxelizeGeneric` geometry shader containers in my local index, using the same inputs on the parent `63bcca43` and PR head `879f2126`. - On the parent, `resource::track` refused all 195 at instruction `0x44` because it could not identify the address in the scalar register pair. - On the PR head, `resource::track` succeeded for all 195. In each case it identified one load from `USER_DATA` at that instruction. - At the full `emit::translate` entry point, both revisions still refused all 195 at stage selection, before producing DXIL. A separate compute control emitted 2,160 bytes of DXIL and passed the Windows SDK validator on both revisions. This confirms the signature-memory fix across the whole family. It leaves geometry-stage translation and in-game rendering as separate checks. Codex assisted with the offline comparison.
kotekompotek commented 2026-11-26 18:15:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-26T18:15:56Z.


Full-pack verification, victory translate --list on the shipped shaders.rpf (v1.0.2.1, 26 503 containers, 26 084 programs):

main this change
resources tracked 25 889 / 26 084 26 084 / 26 084
SGPR-no-root-parameter refusals 195 (all GS_VoxelizeGeneric) 0

The 195 programs do not just track now — they emit: mesh programs stay 8 765 / 8 765 emitted. Every remaining refusal in the pack is a different, already-accounted bucket (13 lane-mask join — FIND-6; 5 v_cvt_f32_f64 — #1262; 4 lane mask read as data — FIND-6; 1 descriptor read only as data — #329; 1 barycentrics; 1 v_permlanex16_b32).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7200249600 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3222#issuecomment-7200249600). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-26T18:15:56Z. --- Full-pack verification, `victory translate --list` on the shipped shaders.rpf (v1.0.2.1, 26 503 containers, 26 084 programs): | | main | this change | |---|---|---| | resources tracked | 25 889 / 26 084 | **26 084 / 26 084** | | SGPR-no-root-parameter refusals | 195 (all GS_VoxelizeGeneric) | **0** | The 195 programs do not just track now — they emit: mesh programs stay 8 765 / 8 765 emitted. Every remaining refusal in the pack is a different, already-accounted bucket (13 lane-mask join — FIND-6; 5 v_cvt_f32_f64 — #1262; 4 lane mask read as data — FIND-6; 1 descriptor read only as data — #329; 1 barycentrics; 1 v_permlanex16_b32).
futurepro62 commented 2026-11-26 22:43:15 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by futurepro62 on 2026-11-26T22:43:15Z.


NVIDIA full-suite run, to go with the reports above by Dukestar69, since none of them names a GPU run. Tested exact head 879f212 (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: a_geometry_programs_signature_memory_loads_through_its_pointer.
  • --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:7204926882 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3222#issuecomment-7204926882). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-26T22:43:15Z. --- NVIDIA full-suite run, to go with the reports above by Dukestar69, since none of them names a GPU run. Tested exact head `879f212` (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: `a_geometry_programs_signature_memory_loads_through_its_pointer`. - `--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.
fuzeofficlal commented 2026-11-26 23:35:45 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T23:35:45Z.

Review: CHANGES_REQUESTED


Thanks for extending signature memory tracking to HwStage::Gs! One regression against main came up in param_word:

  • GS register-backed root descriptors at user_data >= 16 lose their high half (crates/victory-shader/src/resource.rs:488, 546, 641, 941-943):
    Line 546 now routes all user_data >= 16 lookups on HwStage::Cs | HwStage::Gs exclusively to self.first_spilled. However, spill_loads() explicitly skips spill scanning whenever self.layout.iter().any(|p| p.user_data < 2 && p.sgprs > 0) (line 488), leaving self.first_spilled empty. Because merged GS stages have up to 32 user SGPRs (s[8 + user_data]), if a GS layout occupies user_data < 2 and also passes a RootType::Descriptor in entry SGPRs at user_data >= 16, param_of (line 641) matches the incoming SGPR, but param_word(param, 1) now returns None instead of reading the incoming high SGPR (as main did), causing line 943 to fail with "a root descriptor without its high half".

Gating line 546 on whether signature memory is active for GS (e.g. if self.stage == HwStage::Cs || !self.layout.iter().any(|p| p.user_data < 2 && p.sgprs > 0), or falling back to entry SGPRs when self.first_spilled is empty on HwStage::Gs) preserves register-backed GS descriptors cleanly.

<!-- greyfinch-sync:Marvisak/VIctory:review:6081518522 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3222#pullrequestreview-6081518522). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T23:35:45Z. **Review:** CHANGES_REQUESTED --- Thanks for extending signature memory tracking to `HwStage::Gs`! One regression against `main` came up in `param_word`: - **GS register-backed root descriptors at `user_data >= 16` lose their high half (`crates/victory-shader/src/resource.rs:488, 546, 641, 941-943`)**: Line 546 now routes all `user_data >= 16` lookups on `HwStage::Cs | HwStage::Gs` exclusively to `self.first_spilled`. However, `spill_loads()` explicitly skips spill scanning whenever `self.layout.iter().any(|p| p.user_data < 2 && p.sgprs > 0)` (line 488), leaving `self.first_spilled` empty. Because merged GS stages have up to 32 user SGPRs (`s[8 + user_data]`), if a GS layout occupies `user_data < 2` and also passes a `RootType::Descriptor` in entry SGPRs at `user_data >= 16`, `param_of` (line 641) matches the incoming SGPR, but `param_word(param, 1)` now returns `None` instead of reading the incoming high SGPR (as `main` did), causing line 943 to fail with `"a root descriptor without its high half"`. Gating line 546 on whether signature memory is active for GS (e.g. `if self.stage == HwStage::Cs || !self.layout.iter().any(|p| p.user_data < 2 && p.sgprs > 0)`, or falling back to entry SGPRs when `self.first_spilled` is empty on `HwStage::Gs`) preserves register-backed GS descriptors cleanly.
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/3222:upstream-pr/3222'
git switch 'upstream-pr/3222'

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