Shaders: a table's address is not checked for a high half #2546

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

@⁠Halfect on GitHub · 2026-11-25 15:34 UTC · original
Halfect:fix/table-address-high-half → main · +27 −6 · 1 files · 1 commits · closed without merging

What

In traced_address, an address whose base is a table (Table / ResourceHeap / SamplerHeap) had its high half checked anyway: it had to be the constant 0 or a provable carry, otherwise the tracer failed with an address into a descriptor heap with an untracked high half. A table's base is a 32-bit address whose high half is zero, and an offset added to it stays inside the same 4 GiB, so the high half of such an address carries no information — programs whose high half the tracer could not follow were rejected for no reason. The check now runs only for a root descriptor, the one case with its own 64-bit address in two dwords.

This is the table half of the correction #2268 measured on the corpus (an address in an SGPR that is no root parameter, 195 programs on 940d32f): the geometry-placement part of that class is #2284, which deliberately left this out. The two changes touch different decisions in the same file and merge cleanly either way.

Test

a_tables_address_is_not_checked_for_a_high_half: a load whose base is a one-SGPR table parameter with the address's high half taken from an unrelated system SGPR. It fails on main with the untracked-high-half error and resolves to the table with this change.

Validation (Windows, CPU-only; no GPU, no game data)

  • cargo test --locked -p victory-shader --lib: 245 passed, 3 failed — the three failures are the D3D12-device dispatch tests (stride_tests pair and gathers_at_a_level_match_the_hardware) that fail identically on unmodified 940d32f on this machine (dispatch failed: 内存资源不足); all 34 resource:: tests pass, including the new one.
  • cargo clippy --locked -p victory-shader --all-targets -- -D warnings: clean.
  • cargo xtask policy: 182 files ok. git diff --check: clean.

The corpus measurement behind the correction is #2268's; I cannot re-run the title's programs here, so a fresh corpus A/B on this head would be welcome.

AI-assisted (Kimi). The correction itself is @⁠bittertea0323's from #2268 (co-author on the commit); this PR packages it with a regression test.

**@⁠Halfect** on GitHub · 2026-11-25 15:34 UTC · [original](https://github.com/Marvisak/VIctory/pull/2546) `Halfect:fix/table-address-high-half` → `main` · +27 −6 · 1 files · 1 commits · closed without merging ## What In `traced_address`, an address whose base is a table (`Table` / `ResourceHeap` / `SamplerHeap`) had its high half checked anyway: it had to be the constant 0 or a provable carry, otherwise the tracer failed with `an address into a descriptor heap with an untracked high half`. A table's base is a 32-bit address whose high half is zero, and an offset added to it stays inside the same 4 GiB, so the high half of such an address carries no information — programs whose high half the tracer could not follow were rejected for no reason. The check now runs only for a root descriptor, the one case with its own 64-bit address in two dwords. This is the table half of the correction #2268 measured on the corpus (`an address in an SGPR that is no root parameter`, 195 programs on `940d32f`): the geometry-placement part of that class is #2284, which deliberately left this out. The two changes touch different decisions in the same file and merge cleanly either way. ## Test `a_tables_address_is_not_checked_for_a_high_half`: a load whose base is a one-SGPR table parameter with the address's high half taken from an unrelated system SGPR. It fails on `main` with the untracked-high-half error and resolves to the table with this change. ## Validation (Windows, CPU-only; no GPU, no game data) - `cargo test --locked -p victory-shader --lib`: 245 passed, 3 failed — the three failures are the D3D12-device dispatch tests (`stride_tests` pair and `gathers_at_a_level_match_the_hardware`) that fail identically on unmodified `940d32f` on this machine (`dispatch failed: 内存资源不足`); all 34 `resource::` tests pass, including the new one. - `cargo clippy --locked -p victory-shader --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 182 files ok. `git diff --check`: clean. The corpus measurement behind the correction is #2268's; I cannot re-run the title's programs here, so a fresh corpus A/B on this head would be welcome. AI-assisted (Kimi). The correction itself is @⁠bittertea0323's from #2268 (co-author on the commit); this PR packages it with a regression test.
A table's base is a 32-bit address whose high half is zero, and an
offset added to it stays inside the same 4 GiB, so requiring the
address's high half to be zero (or a provable carry) rejected addresses
that were fine: the tracer errored 'an address into a descriptor heap
with an untracked high half' on loads whose high half it simply could
not follow. Only a descriptor's own 64-bit address has a high half to
match, so the check now runs only then.

This is the table half of the correction #2268 measured on the corpus
('an address in an SGPR that is no root parameter': 195 -> 167 with the
geometry placement split, the rest needing this); it was deliberately
left out of #2284, which covers the placement. A synthetic test pins it:
a load whose base is a table parameter resolves even when the address's
high half is a system SGPR of unknown value.

Co-authored-by: bittertea0323 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:08:51 +00:00
github-bot closed this pull request 2026-11-26 05:08:51 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 15:56 UTC · original · edited 2026-11-25 16:49 UTC

Automated triage for the maintainers.

Merge candidate.

Tracer::traced_address in crates/victory-shader/src/resource.rs no longer checks the high half of an address based on a descriptor table or heap. Root descriptors, whose high half comes from the parameter, are still checked.

Changed since the last review (new head af4abca, rebased onto 67e8ae1): CI passes now. The earlier failure in heap_direct_texture_reads_mark_their_heap_index was a test-harness issue that main fixed in 67e8ae1.

On your reply: your argument holds when checked against the code.

  • Table and heap parameters are a single dword in the layout; only RootType::Descriptor has a param_word(param, 1).
  • Address carries only param, offset and dynamic, so the high half never affects which table or offset is resolved.
  • For a program main already accepted, the result is identical; the change only lifts a refusal.

There is still no title run or corpus A/B showing which values these high halves hold, so the maintainer should weigh that. The new test pins the case of an unknown system scalar as the high half.

CI: check passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 15:56 UTC · [original](https://github.com/Marvisak/VIctory/pull/2546#issuecomment-7167449049) · edited 2026-11-25 16:49 UTC <!-- victory-triage v1 head=af4abcafae7bf34934eba371e5382e8f8136d50e verdict=merge-candidate at=2026-11-25T16:44:54Z --> Automated triage for the maintainers. **Merge candidate.** `Tracer::traced_address` in `crates/victory-shader/src/resource.rs` no longer checks the high half of an address based on a descriptor table or heap. Root descriptors, whose high half comes from the parameter, are still checked. Changed since the last review (new head `af4abca`, rebased onto `67e8ae1`): CI passes now. The earlier failure in `heap_direct_texture_reads_mark_their_heap_index` was a test-harness issue that main fixed in `67e8ae1`. On your reply: your argument holds when checked against the code. - Table and heap parameters are a single dword in the layout; only `RootType::Descriptor` has a `param_word(param, 1)`. - `Address` carries only `param`, `offset` and `dynamic`, so the high half never affects which table or offset is resolved. - For a program main already accepted, the result is identical; the change only lifts a refusal. There is still no title run or corpus A/B showing which values these high halves hold, so the maintainer should weigh that. The new test pins the case of an unknown system scalar as the high half. CI: `check` passing. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠Halfect on GitHub · 2026-11-25 16:10 UTC · original

Thanks — both points addressed in af4abca (rebased onto current main 67e8ae1, no conflicts).

The CI failure is unrelated to this change and already fixed on main. The head's CI ran before 67e8ae1 ("Shader tests: the compute harness zeroes its UAVs"), whose message describes exactly this failure: on the CI's WARP the 512 KiB mark buffer of heap_direct_texture_reads_mark_their_heap_index came back holding the page table an earlier test had uploaded and freed, so the test saw thousands of bits besides the one the shader set ("the slot read"). The failing run was on the pre-fix harness. Checked as asked: on this machine the test fails identically without my change — it aborts with STATUS_ACCESS_VIOLATION on unmodified 67e8ae1 as well as on this head (this machine's D3D12 environment also fails the three known device dispatch tests on an unmodified base). The change itself cannot reach that test's outcome either way: its program's heap-address high half is the constant 0 (s_mov_b32 s5, 0 before the load), which the old check already accepted, so tracing resolves it exactly as before.

On runtime evidence for the loosened check. The change is reject-only: for any program the old tracer accepted, the resolved address is bit-identical (the check only returned an error; removing it changes nothing else), so no previously working program can change behavior. For a newly accepted address the skipped check is vacuous by construction: a table/heap base is a 32-bit user-data value (high half zero), and the offset is added with 32-bit wraparound, so the address's high half is never dereferenced — it carries no information whether the tracer follows it or not. I have no title data or corpus access here, so I cannot produce the title-run note; a corpus A/B on this head would still be welcome.

Validation on af4abca (Windows, CPU-only; no GPU, no game data):

  • cargo test --locked -p victory-shader --lib resource::: 34 passed / 0 failed, including a_tables_address_is_not_checked_for_a_high_half.
  • Full library suite with the one device test skipped: 267 passed, 3 failed — the same three D3D12-device tests (stride_tests pair, gathers_at_a_level_match_the_hardware) that fail identically on unmodified 67e8ae1 on this machine; heap_direct_texture_reads_mark_their_heap_index aborts the harness process with an access violation on both trees here, so it was run separately (same result on both).
  • cargo clippy --locked -p victory-shader --all-targets -- -D warnings: clean. cargo xtask policy: 184 files ok. git diff --check: clean.

AI-assisted (Kimi).

**@⁠Halfect** on GitHub · 2026-11-25 16:10 UTC · [original](https://github.com/Marvisak/VIctory/pull/2546#issuecomment-7167654995) Thanks — both points addressed in `af4abca` (rebased onto current main `67e8ae1`, no conflicts). **The CI failure is unrelated to this change and already fixed on main.** The head's CI ran before `67e8ae1` ("Shader tests: the compute harness zeroes its UAVs"), whose message describes exactly this failure: on the CI's WARP the 512 KiB mark buffer of `heap_direct_texture_reads_mark_their_heap_index` came back holding the page table an earlier test had uploaded and freed, so the test saw thousands of bits besides the one the shader set ("the slot read"). The failing run was on the pre-fix harness. Checked as asked: on this machine the test fails identically without my change — it aborts with `STATUS_ACCESS_VIOLATION` on unmodified `67e8ae1` as well as on this head (this machine's D3D12 environment also fails the three known device dispatch tests on an unmodified base). The change itself cannot reach that test's outcome either way: its program's heap-address high half is the constant 0 (`s_mov_b32 s5, 0` before the load), which the old check already accepted, so tracing resolves it exactly as before. **On runtime evidence for the loosened check.** The change is reject-only: for any program the old tracer accepted, the resolved address is bit-identical (the check only returned an error; removing it changes nothing else), so no previously working program can change behavior. For a newly accepted address the skipped check is vacuous by construction: a table/heap base is a 32-bit user-data value (high half zero), and the offset is added with 32-bit wraparound, so the address's high half is never dereferenced — it carries no information whether the tracer follows it or not. I have no title data or corpus access here, so I cannot produce the title-run note; a corpus A/B on this head would still be welcome. Validation on `af4abca` (Windows, CPU-only; no GPU, no game data): - `cargo test --locked -p victory-shader --lib resource::`: 34 passed / 0 failed, including `a_tables_address_is_not_checked_for_a_high_half`. - Full library suite with the one device test skipped: 267 passed, 3 failed — the same three D3D12-device tests (`stride_tests` pair, `gathers_at_a_level_match_the_hardware`) that fail identically on unmodified `67e8ae1` on this machine; `heap_direct_texture_reads_mark_their_heap_index` aborts the harness process with an access violation on both trees here, so it was run separately (same result on both). - `cargo clippy --locked -p victory-shader --all-targets -- -D warnings`: clean. `cargo xtask policy`: 184 files ok. `git diff --check`: clean. AI-assisted (Kimi).
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 22:10 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 lifting the check changes no program today and weakens a soundness check. No title program is refused with "untracked high half" on main; the 195 GS_VoxelizeGeneric programs of #2268 stop earlier, and geometry stages are not lowered at all. The console reads the full 64-bit address, so a high half that is real data points somewhere other than the table, and the new test pins exactly that case as acceptable. Worth reconsidering together with merged-GS translation (#2284), with the high halves those programs actually hold.

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:10 UTC · [original](https://github.com/Marvisak/VIctory/pull/2546#issuecomment-7176039870) Automated triage for the maintainers, second look (a review against current `main`, with builds and tests where they could change the verdict). Closing because lifting the check changes no program today and weakens a soundness check. No title program is refused with "untracked high half" on `main`; the 195 `GS_VoxelizeGeneric` programs of #2268 stop earlier, and geometry stages are not lowered at all. The console reads the full 64-bit address, so a high half that is real data points somewhere other than the table, and the new test pins exactly that case as acceptable. Worth reconsidering together with merged-GS translation (#2284), with the high halves those programs actually hold. 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!2546
No description provided.