Shaders: path-sensitive reachability for missing values across phi joins (#736) #1230
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!1230
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1230/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Ctrl-Alt-Haze on GitHub · 2026-11-24 16:35 UTC · original
Ctrl-Alt-Haze:fix/shader-736-reachability→main· +2703 −306 · 3 files · 2 commits · closed without mergingSummary
Fixes #736 (
#612regression on phi reachability) while preserving #604 soundness and passing the two-join live descriptor word soundness control.Changes
crates/victory-shader/src/structure.rs:BoolSet<'a>, a non-mutating ROBDD overlay over&'a Bools(and,or,not,forgetfor loop back-edges,edgeforreach[q] & exits[q],sat, bounded atMAX_OVERLAY_NODES = 65536with conservativeBool::TRUEfallback on overflow).crates/victory-shader/src/emit/lower.rs:read_phistransitive closure + globalbad/Stop::Retrypoisoning with single-pass path-sensitive missing-value taint tracking (ReadDep,ValueDeps,SinkRead,check_missing_reach) solved to a bounded fixpoint (MAX_TAINT_ROUNDS = 256with conservativeBool::TRUEwidening) infill_phis.Lower::get(get_inner) somask_dword(mask_ok && is_mask) does not falsely treatEXECphis/predecessors as data reads.oldfallbacks inold_i32_ofwith lane-conditionedOldDep/direct_missingtracking (!guardforwrite_placedanddsatomicoutsidewhen guarded with a destination register; active lanes forplace_bits,write_16(keep), andlow_halfwhile exempting onlyv_interp_p1lv_f16accumulator reads), and routedfloat_src/v_fmac_f32/self.floatscache hits throughrecord_readso live missing values never silently drop.lower::tests: preserveda_missing_value_stays_missing_through_two_live_joins(#604), added the two-join live structured-buffer descriptor-word control (a_live_descriptor_word_stays_missing_through_two_joins),old_register_missing_values_and_cached_floats_stay_refused,unknown_stride_load_stays_missing_when_live_and_lowers_when_overwritten,first_half_of_interpolation_stays_missing_when_live_and_lowers_when_overwritten,guarded_write_and_exec_mask_phi_lower_soundly, andloop_missing_value_refuses_on_back_edge_and_lowers_when_infeasible.crates/victory-shader/src/emit/valu_tests.rs:reachability_overwritten_missing_phis_match_on_host_and_warpexecuting correlated-overwrite descriptor-word, unknown-stridebuffer_load_dword, and loop-invariants_memtimeshaders withdxil.dllvalidation on RTX 5070 Ti + WARP.Verification
32.0.16.2135), WARP (VICTORY_WARP=1), Windows SDK10.0.26100.0dxil.dll, Rust1.98.1, baseffe310eb.cargo xtask policy:154 files okcargo clippy --workspace --all-targets --locked -- -D warnings(default &--all-features): passedcargo test --workspace --locked:349 passed, 0 failed, 6 ignored(victory-shader127/1 ign)cargo test -p victory-shader --features host --locked(RTX 5070 Ti + WARP):127 passed, 0 failed, 1 ignoredVICTORY_WARP=1 cargo test -p victory-shader --features host --locked(WARP):127 passed, 0 failed, 1 ignoredcargo test -p victory-gpu --features diagnostics --locked&VICTORY_D3D12_WARP=1:53 passed, 0 failed, 1 ignoredeachrustfmt --edition 2024 --checkon modified files: zero diffs on added/modified lines (valu_tests.rscompletely clean).AI use: Written and verified locally with an AI coding swarm (
gemini-4-hydrogen-high), then independently audited and tested on RTX 5070 Ti + WARP.@pablogonz12 on GitHub · 2026-11-24 17:16 UTC · original
Setup: Linux, RX 9070 XT, RADV (Mesa 26.3.1), dxil-spirv master, spirv-val 1.3. Your head folded onto a base of origin/main
ffe310eplus #1017 (main's host build fails without it:E0425 host_resource), then the four-stage offline check over 768 programs (751-program world dump + 52-program BVH capture, 35 duplicate containers skipped).One program that translated on the base no longer does: a pixel program that now stops at "barycentrics read directly" (2 -> 3 pixel programs). Nothing else moves; worth a look whether your reachability change is meant to reach a barycentric read that the base folded away.
Not tested: in-game.
@Zipettte on GitHub · 2026-11-24 17:59 UTC · original
Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 3a00856:
cargo test -p victory-shaderpasses, 127 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).Tested with AI assistance (Claude).
@Ctrl-Alt-Haze on GitHub · 2026-11-24 18:21 UTC · original
@pablogonz12 Thank you for catching that pixel regression on the 768-program RADV check!
Root cause: Pixel shaders begin with
Input::Barycentric(Val::Missing("barycentrics read directly")) inv0/v1. When a 16-bit or sub-dword op reusesv0/v1(low_half,write_half, or SDWAUNUSED_PRESERVEinplace_bits), the prior commit recordedOldDep/DirectMissingon the whole 32-bitValuewithout tracking bitmasks (0x0000_FFFFvs0xFFFF_0000), so reading only the newly writtenlo16or overwritinghi16afterward falsely tripped"barycentrics read directly".Fix (
6f77efd):BitMaskCond, bitmask-awareReadDep/OldDep/DirectMissing,Transfer::{Broadcast, Shift}) through partial writes (low_half,write_half,place_bits,v_fma_mix*,write_placed) and sub-dword reads (half_src,sdwa_src,v_and_b32/s_and_b32constants, shifts,v_bfe_*/s_bfe_*,v_pack_b32_f16,v_pk_*,v_perm_b32,v_cvt_f32_ubyte*,v_mul_*24/v_mad_*24,export,imagea16,bufferd16 store).emit::lower::tests::pixel_barycentric_reuse_tracks_exact_bitmasks(6 positive lo16 / full-overwrite cases + 6 negative cases confirming untouched halves still refuse"barycentrics read directly") andemit::valu_tests::pixel_barycentric_reuse_16bit_and_sdwa_match_on_host_and_warp(live RTX 5070 Ti + WARP pixel shader readback).Re-verified on
6f77efd:cargo xtask policy:154 files okcargo clippy --workspace --all-targets --locked -- -D warnings(default &--all-features): passcargo test --workspace --locked:351 passed, 0 failed, 6 ignored(victory-shader129/1 ign)cargo test -p victory-shader --features host --locked(RTX 5070 Ti &VICTORY_WARP=1):129 passed, 0 failed, 1 ignoredeachcargo test -p victory-gpu --features diagnostics --locked(RTX 5070 Ti &VICTORY_D3D12_WARP=1):53 passed, 0 failed, 1 ignoredeachAI-assisted fix (
gemini-4-hydrogen-high), independently audited and tested on RTX 5070 Ti + WARP; no game data.@Ctrl-Alt-Haze on GitHub · 2026-11-24 22:24 UTC · original
Rebased onto upstream
main(70564ae) at6bd5dd9(commit 1 at7c2f3ed, commit 2 at6bd5dd9):desc_word_shaderstill fails on cleanupstream/main70564ae(Unsupported { offset: 76, what: "a descriptor's address or format read as data" }), so path-sensitivecheck_missing_reachremains necessary beyonda7fc47a/dead_on_edge.dead_on_edge/never_takenedge pruning alongsidecheck_missing_reach, keptbuffer_guardon descriptor loads, preservednarrow16,fmac_half, andextra-offset packed image addressing from70564ae, removed supersededlow16, and added the newHostShaderfields invalu_tests.rs.Verified locally on Windows 11 x64 / NVIDIA GeForce RTX 5070 Ti + WARP:
cargo xtask policy: passed (174 files ok)cargo clippy --workspace --all-targets --locked -- -D warnings(default &--all-features): passedreachability_overwritten_missing_phis_match_on_host_and_warppassed,a_missing_value_stays_missing_through_two_live_joinspassed,a_missing_value_on_a_path_no_lane_takes_is_deadpassed,a_value_no_lane_from_its_edge_reads_needs_no_formpassed,pixel_barycentric_reuse_16bit_and_sdwa_match_on_host_and_warppassed--locked -- --test-threads=1):victory1 passed,victory-core11 passed,victory-formats23 passed / 4 ignored,victory-game15 passed,victory-hle99 passed (97 unit + 1fidelityfx+ 1no_dll_planting),victory-loader25 passed (22 unit + 2load_probe+ 1title_dlls),victory-pe7 passed,victory-pipeline4 passed,xtask4 passedcargo test -p victory-gpu --locked -- --test-threads=1:76 passed; 2 failed; 1 ignored(pre-existing on clean70564ae:dynamic_slots_are_held_until_released,lists_share_a_table_and_copies_keep_their_views)cargo test -p victory-shader --features host --locked(hardware):215 passed; 3 failed; 2 ignored(pre-existing on clean70564aeon RTX 5070 Ti:stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride,stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros,synthetic_tests::gathers_at_a_level_match_the_hardware)VICTORY_WARP=1 cargo test -p victory-shader --features host --locked:216 passed; 2 failed; 2 ignored(pre-existinggathers_at_a_level_match_the_hardware+permutes_read_the_lane_named_and_zero_from_lanes_left_outwhich skips underVICTORY_WARP=1and passed on RTX hardware)@Dathinel on GitHub · 2026-11-25 00:16 UTC · original
Retested the cyclic regression fixture from #604/#612 on the rebased head
6bd5dd9(Windows/MSVC). The two mutually dependent phis still preserve the live timestamp: lowering refuses it with the same diagnostic as the direct read. Making the timestamp dead or replacing it with a constant still lowers successfully. All four outcomes match #612.To reproduce, add the test function to the existing tests in
emit/lower.rsand runcargo test --locked -p victory-shader --features host --lib emit::lower::tests::timestamp_phi_cycle -- --exact --nocapture. One test ran and passed. This checks the emitter before GPU dispatch; game behavior is untested here. AI-assisted.@Marvisak on GitHub · 2026-11-25 00:35 UTC · original
Automated triage for the maintainers. Closing because this change is already in
main, ormainhas since replaced the code it patches.now rebased, it replaces main's #736 fix (live_edges with never_taken/dead_on_edge in fill_phis,
a7fc47af) with a 2.2k-line taint fixpoint and removes the never_taken/dead_on_edge use that main's emitted programs rely on; no measurement on the title's list.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