shader: a phi read only through another phi keeps its missing incoming value #699

Closed
github-bot wants to merge 4 commits from gh-pr/699/head into gh-pr/699/base
Owner

@⁠arthercz on GitHub · 2026-11-24 07:02 UTC · original
arthercz:phi-missing-fix → main · +1884 −659 · 38 files · 4 commits · closed without merging

Closes #604.

The emitter refused a branch on a live s_memtime read but accepted the same read through two conditional joins: fill_phis substitutes zero for a missing incoming value of a phi no reader marks, and Lower::get marked only the phi a comparison reads directly. A phi whose value flows solely into another phi's arguments was never marked, so its missing timestamp value silently became zero instead of surfacing the refusal the direct read gets.

The fix follows incoming phi dependencies from the phis actual readers mark (fixpoint) before the substitution decision. A dead phi (read by nothing live) still lowers with the zero substitution, matching the issue's expectation.

The regression test is Dathinel's probe from the issue (test-only commit 4b2ea70f), applied unmodified; it compares the direct and the twice-joined read and expects the dead-timestamp variant to keep lowering.

Verified: cargo test -p victory-shader --features host a_missing_value_stays_missing_through_two_live_joins passes; cargo test --workspace 266 passed; cargo clippy --workspace --all-features clean.

**@⁠arthercz** on GitHub · 2026-11-24 07:02 UTC · [original](https://github.com/Marvisak/VIctory/pull/699) `arthercz:phi-missing-fix` → `main` · +1884 −659 · 38 files · 4 commits · closed without merging Closes #604. The emitter refused a branch on a live `s_memtime` read but accepted the same read through two conditional joins: `fill_phis` substitutes zero for a missing incoming value of a phi no reader marks, and `Lower::get` marked only the phi a comparison reads directly. A phi whose value flows solely into another phi's arguments was never marked, so its missing timestamp value silently became zero instead of surfacing the refusal the direct read gets. The fix follows incoming phi dependencies from the phis actual readers mark (fixpoint) before the substitution decision. A dead phi (read by nothing live) still lowers with the zero substitution, matching the issue's expectation. The regression test is Dathinel's probe from the issue ([test-only commit 4b2ea70f](https://github.com/Dathinel/VIctory/commit/4b2ea70f0940a4317dc934000d249dce0fce50f6)), applied unmodified; it compares the direct and the twice-joined read and expects the dead-timestamp variant to keep lowering. Verified: `cargo test -p victory-shader --features host a_missing_value_stays_missing_through_two_live_joins` passes; `cargo test --workspace` 266 passed; `cargo clippy --workspace --all-features` clean.
- cargo fmt: 168 formatting differences in 32 files
- xmem.rs: initialize PERFORMANCE_INFORMATION cb in the struct literal
  (clippy::field_reassign_with_default)
Speech streams were valid empty WAVE files, so the title's narration
(accessibility menus and the like) was silent. Route text (0x68) and
SSML (0xa8) through Windows.Media.SpeechSynthesis and hand the title the
spoken RIFF stream; when the host has no voice (no voices installed,
WinRT unavailable), keep the empty-WAVE fallback so the title still
plays the stream and goes on.

- streams become boxed handles, reclaimed by close (0x70); the
  synthesizer handle stays a fixed address
- enumerate_voices stays a no-op: no title of ours asks, and the host's
  default voice speaks
- the windows crate moves out of the diagnostics-only feature so its
  WinRT bindings link in release builds too

Verified on Windows 11: the unit test now speaks "Hello" and validates
the returned WAVE (RIFF chunk walk, PCM 16 kHz mono 16-bit, non-empty
data); cargo test --workspace 264 passed.
The diagnostics gate checked only the variable's presence, so
VICTORY_D3D12_WARP=0 still created the device on WARP; the workaround was
to remove the variable entirely (issue #610).

Treat "0" like unset, keep documented "1" and presence-means-on for
other values, and keep the diagnostics feature gate. The predicate moves
into warp_selected/warp_selected_at, covered by a table test (unset, 0,
1, empty); README documents the opt-out.

Verified: cargo test -p victory-gpu --features diagnostics --locked
warp_ passes; cargo clippy --workspace --all-features clean.
The emitter refused a branch on a live timestamp read (s_memtime result)
but accepted the same read through two conditional joins: fill_phis
substitutes zero for a missing incoming value of a phi no reader marks,
and Lower::get marked only the phi a comparison reads directly. A phi
whose value flows solely into another phi's arguments was never marked,
so its missing timestamp value became zero instead of the refusal the
direct read gets (issue #604).

Follow incoming phi dependencies from the phis actual readers mark, by
fixpoint, before the substitution decision; a dead phi (read by nothing
live) still lowers with the zero substitution.

The regression test is Dathinel's probe from the issue (test-only commit
4b2ea70f), applied unmodified.

Verified: cargo test -p victory-shader --features host
a_missing_value_stays_missing_through_two_live_joins passes; cargo test
--workspace 266 passed; cargo clippy --workspace --all-features clean.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:13:29 +00:00
github-bot closed this pull request 2026-11-26 04:13:29 +00:00
Author
Owner

@⁠iurysf on GitHub · 2026-11-24 08:16 UTC · original

Measured offline against main c2e7254 with victory translate --list --validate over the title's shaders.rpf + executable (26,096 programs), dxil.dll 1.9.2602.17, comparing outcomes program by program:

failed rejected by validator validated
main 3,734 185 21,983
main + this PR 4,067 (+333) 175 21,660 (−323)
  • No program is fixed. 323 programs that emitted and validated on main now fail, and 10 previously rejected ones now fail too. Their new refusals are mostly "a descriptor read only as data" (227), then "a scalar memory read as data" (32), "a structured buffer of unknown stride" (23), "the first half of an interpolation" (20) and "a lane mask read as data" (17).
  • So following phi dependencies to a fixpoint marks many more phis as read, and their missing incoming values (zero-substituted on main) now surface as other refusals, well beyond the s_memtime case in #604.
  • Some of those zeroes may be wrong in the same silent way as the timestamp. Still, losing 323 working programs is a large in-game cost. Could the stricter marking be limited to the value kinds where a zero is known to be wrong (timestamps), or applied only when the missing edge carries such a value?

AI-assisted.

**@⁠iurysf** on GitHub · 2026-11-24 08:16 UTC · [original](https://github.com/Marvisak/VIctory/pull/699#issuecomment-7125938926) Measured offline against main `c2e7254` with `victory translate --list --validate` over the title's `shaders.rpf` + executable (26,096 programs), dxil.dll 1.9.2602.17, comparing outcomes program by program: | | failed | rejected by validator | validated | |---|---:|---:|---:| | main | 3,734 | 185 | 21,983 | | main + this PR | **4,067 (+333)** | 175 | **21,660 (−323)** | - No program is fixed. **323 programs that emitted and validated on main now fail**, and 10 previously rejected ones now fail too. Their new refusals are mostly "a descriptor read only as data" (227), then "a scalar memory read as data" (32), "a structured buffer of unknown stride" (23), "the first half of an interpolation" (20) and "a lane mask read as data" (17). - So following phi dependencies to a fixpoint marks many more phis as read, and their missing incoming values (zero-substituted on main) now surface as other refusals, well beyond the `s_memtime` case in #604. - Some of those zeroes may be wrong in the same silent way as the timestamp. Still, losing 323 working programs is a large in-game cost. Could the stricter marking be limited to the value kinds where a zero is known to be wrong (timestamps), or applied only when the missing edge carries such a value? AI-assisted.
Author
Owner

@⁠slint6614-dev on GitHub · 2026-11-24 09:30 UTC · original

Measured on the full retail shader pack (26,503 containers) with victory translate --validate --pipelines (pipelines on an AMD RX 9070, Windows 11, dxil.dll from SDK 10.0.26100). Counts are emitted / validated / pipelines.

This PR conflicts with current main (lower.rs), so it was measured on its own base against main 1f858b0, which predates #612 (VS/PS 12272 / 12172, CS 1693 / 1670, MS 8191 / 8129).

With this PR: VS/PS 12220 / 12130, CS 1440 / 1417, MS 8163 / 8101. That is the same loss of 323 validated programs (42 VS/PS, 253 CS, 28 MS) as the merged #612 shows (see my measurement there), with the same refusal reasons. So it fixes #604 the same way, but it now duplicates #612.

**@⁠slint6614-dev** on GitHub · 2026-11-24 09:30 UTC · [original](https://github.com/Marvisak/VIctory/pull/699#issuecomment-7127511551) Measured on the full retail shader pack (26,503 containers) with `victory translate --validate --pipelines` (pipelines on an AMD RX 9070, Windows 11, dxil.dll from SDK 10.0.26100). Counts are emitted / validated / pipelines. This PR conflicts with current main (`lower.rs`), so it was measured on its own base against main 1f858b0, which predates #612 (VS/PS 12272 / 12172, CS 1693 / 1670, MS 8191 / 8129). With this PR: VS/PS 12220 / 12130, CS **1440 / 1417**, MS 8163 / 8101. That is the same loss of 323 validated programs (42 VS/PS, 253 CS, 28 MS) as the merged #612 shows (see my measurement there), with the same refusal reasons. So it fixes #604 the same way, but it now duplicates #612.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:27 UTC · original

Automated triage for the maintainers. Closing because this change is already in main, or main has since replaced the code it patches.

The fix for #604 (a phi read only through another phi is live) is already in main through #612 (commit 3dd467c), and this copy carries a workspace-wide cargo fmt.

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

**@⁠Marvisak** on GitHub · 2026-11-25 00:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/699#issuecomment-7148532965) Automated triage for the maintainers. Closing because this change is already in `main`, or `main` has since replaced the code it patches. The fix for #604 (a phi read only through another phi is live) is already in main through #612 (commit 3dd467c), and this copy carries a workspace-wide cargo fmt. If this is mistaken, reply here with what was missed (or push a change and say so) 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!699
No description provided.