Repository navigation
Shaders: a phi that only another read phi consumes is live too (#604) - #612
Conversation
(cherry picked from commit 4b2ea70)
fill_phis treats a phi no one read directly as dead and fills a value with no DXIL form (an unsupported s_memtime result, say) with zero. When that value reaches a read through two joins, the first phi is only read by the second, so it was never marked read: the read lowered with a zero where the same value read directly is refused with "a scalar memory read as data". Mark the incoming phis of every read phi as read, transitively, before the phis are filled. The reproducer from Marvisak#604 now agrees for the direct and the joined read, and the dead control (the timestamp replaced by a group id) still lowers.
LAKSHYA-cmd-tech
left a comment
There was a problem hiding this comment.
Verified and tested on Windows 11 x64 (D3D12).
- Confirmed transitive liveness propagation for phi nodes in ill_phis: incoming phis feeding read phis across multi-join chains are properly marked read instead of being dropped and silently filled with zero.
- Unit test �_missing_value_stays_missing_through_two_live_joins passes and reproduces the expected refusal behaviour consistently.
- cargo test -p victory-shader: 70 passed, 0 failed.
- cargo clippy -p victory-shader --lib -- -D warnings: 0 warnings.
- cargo xtask policy: 151 files clean.
|
Thanks for carrying over the #604 regression. I checked one additional case on Windows: a loop where the header's On the test-only parent To reproduce, apply the cyclic test only to either revision and run |
On main at 8d23f07 the test target of victory-shader does not compile: Marvisak#612 gave the test helper `lowers` a second argument (rsrc2) and Marvisak#117's `scalar_bit_tests_lower`, merged beside it, still calls it with one. The call passes 0, as the helper's other callers without group ids do. Not part of the scratch-memory change; it is here so this branch's tests can run. Drop it when main has the same fix. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
On main the test target of victory-shader does not compile (upstream issue Marvisak#719): Marvisak#612 gave the test helper `lowers` a second argument (rsrc2) and Marvisak#117's `scalar_bit_tests_lower`, merged beside it, still calls it with one. The call passes 0, as the helper's other callers without group ids do. Not part of the image sampling change; it is here so this branch's tests can run. Drop it when main has the same fix. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Heads-up: on the title's full shader corpus, this change stops 323 programs that emitted and validated before it from translating. Reverting only this merge on main |
|
As asked in the description, the effect on the real corpus: full retail shader pack (26,503 containers),
So 323 programs that validated before are now refused: 42 VS/PS, 253 compute (15 % of the emitted compute programs) and 28 mesh. The main refusal reasons that changed (without → with):
The largest jump is in descriptors read as data. That may mean the transitive walk also marks phis that only carry descriptors or lane masks (which resource tracking or the mask pass resolve without a DXIL value) as read data, not only the zero-filled data values from #604. I can't tell from the counts alone whether these 323 were all silently wrong before. Given the size (a sixth of the compute programs), it may be worth checking a few before the next measurements build on it. |
The Marvisak#604 fix (f1fa9d5) marked every phi a read phi takes a value from as read, so any missing incoming value of such a join refused the program. Upstream merged the same change as Marvisak#612 and measured it (Marvisak#736): 323 programs that translated and validated before stopped, mostly on descriptor dwords, lane masks and interpolation halves that only joins carry after their last use, where the zero never reaches a reader. Phis read only through other joins are now kept apart from the ones an instruction reads. A missing incoming value refuses such a phi only when zero would silently misrepresent it: an s_memtime or s_memrealtime timestamp, the Marvisak#604 case. Every other value becomes zero on that edge, as before the fix. The test keeps the timestamp case and adds an s_getpc_b64 carried through the same two joins: refused when read directly, translated when only joins carry it. Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
…y without its transitive phi liveness is lowered so, joins zero-filled Upstream Marvisak#612 (3dd467c) makes a phi that only another read phi consumes live, so a value with no DXIL form reaching a read through two joins refuses the program instead of being zero-filled at the first join. On the title's corpus that refuses 222 programs linux-bringup translated (108 'a lane mask read as data': ped skinning and pre-skin mesh programs; 74 'a structured buffer of unknown stride': prop_2lyr_procedural_batch compute; 20 'the first half of an interpolation': vehicle livery pixel programs; 18 'a descriptor read only as data': alpha prepass meshes), whose draws would now be dropped. Until those values get a DXIL form, a form that Marvisak#612 refuses is lowered again without the transitive liveness; when that succeeds the result is used and marked (HostShader::zero_filled_phis, kept in the shader cache), and victory-gpu logs 'Marvisak#612 fallback: zero-filled live phi' once per shader with its hash. The zero-filled values are probably wrong data on those paths. VICTORY_STRICT_PHIS=1 keeps Marvisak#612's refusal (and keys the shader cache). Marvisak#612's own test checks both.
|
Corpus effect reproduced independently, and what the 333 are Full-corpus
That is 333 programs that emitted before and are refused now, and 63 the other way. The 10-program gap to @slint6614-dev's 323 is the counting rule: they count programs that validated before, and 10 VS/PS programs in my set emitted but already failed validation at Bisect: 23 first-parent commits between What the set is. 245 of the 253 compute programs are On whether they were silently wrong before: I cannot tell that from the counts either. The 227 AI-assisted (Claude Code). |
|
Update on the "were they silently wrong before?" question: reverting #612 restores the programs offline, but on an RTX 4080 the title loses the device in those programs I cherry-picked the exact revert (
That is direct hardware evidence that the pre-#612 values were not benign for the running title: a subset of the restored programs stalls on null descriptors. It supports keeping #612 as a correctness fix rather than reverting it for program count. I have not tried a narrowed version that marks only data phis read, which was the other option I raised earlier. AI-assisted (Claude Code). |
Shaders: a phi that only another read phi consumes is live too (#604)
Shaders: a phi that only another read phi consumes is live too (Marvisak#604)
|
Correction and disclosure for my two comments above (13:58Z, 16:21Z) Both end with "AI-assisted (Claude Code)". That is wrong. My Claude Code session hit its usage limit at 13:26Z, and OpenCode continued the session on its free models:
I have now rechecked both with Claude Code against the original files. 13:58Z (what the 333 are): confirmed.
16:21Z (in-game revert): its conclusion is not supported. Please disregard it.
So "direct hardware evidence that the pre-#612 values were not benign" and "supports keeping #612" are withdrawn. Whether the 333 restored programs behave correctly in the title is still untested here, and I have not tried a narrowed rule that treats only data phis as read. This correction: Claude Code (Claude Opus 5.5); every figure was recomputed from the original files on my machine. |
Fixes #604.
fill_phisdecides which phis are live fromread_phis, which only holds a phi thatLower::getread directly. A value with no DXIL form (the issue's unsupporteds_memtimeresult) that reaches a read through two joins goes through a first phi that only the second phi consumes. That first phi is never inread_phis, so its missing incoming value is filled with zero, and the final read lowers instead of being refused the way the direct read is (a scalar memory read as data).Change (
crates/victory-shader/src/emit/lower.rs, +14 lines): at the start offill_phis, mark the incoming phis of every read phi as read, transitively. The existingRetrymechanism then refuses the chain exactly as it refuses a direct read.Reproducer: the first commit is Dathinel's test probe from #604, cherry-picked with its authorship (
a_missing_value_stays_missing_through_two_live_joins). It checks that the direct and joined reads agree and that the dead control (the timestamp replaced by a group-id read) still lowers.Tested on Linux (Ryzen 7 5700, rustc 1.98.1, the repo's pinned toolchain):
main(d2a4bae) withleft: None,right: Some("a scalar memory read as data"), as the issue says, and passes with the change.cargo test -p victory-shader: 57 passed, 0 failed. The issue's exact command (--features host) passes.cargo xwin check --workspace --target x86_64-pc-windows-msvc: ok.main(none added by this change).Not measured: the effect on the real shader corpus (no game data here). Shaders that used to be accepted only because a missing value was silently zeroed through a phi chain will now be refused, which is the point of the change, but someone with the corpus may want to compare the translated counts before and after. No game data is in this PR.