Shaders: descriptors set in a region s_cbranch_execz can skip are traced after it #2324
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!2324
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2324/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?
@chippy01 on GitHub · 2026-11-25 10:41 UTC · original
chippy01:shaders/descriptor-neither-loaded-nor-built→main· +324 −6 · 2 files · 1 commits · closed without mergingProblem
On
main(940d32f) three compute programs are refused at translation withresources: a descriptor neither loaded nor built. They are the last three of that class (#320 brings it from 298 to 3;mainis at 3):shadowmask:CS_TraceShadowRays_ScreenSpaceOnlyCheckerboarde6ac855a4cddb16d0x6dc8alphaResolve:CS_AlphTransmissionPrefilterMip2da4beb386509b770x4d0indirect_light_probes:CS_Alpha_Scheduleaab1b3c7248ee5de0x140All three set a descriptor (a table load in two of them, an immediate sampler in the third) inside a region that
s_and_saveexec+s_cbranch_execzskips when no lane would run it, and read it after the region ends (s_mov exec, saved). The phi where the region ends joins the region's words with what the skip leaves in the registers (an EXEC save, a lane mask), and tracking refuses the read.CS_Alpha_Schedulealso clears the high half of its table address only inside such a region, so after the first refusal it stops atan address into a descriptor heap with an untracked high half.Why the read is the region's
The structuriser turns
s_cbranch_execzinto a per-lane branch, which holds for vector work but not for scalar writes: those are the whole wave's. A lane that reaches the region's end without running the region itself reads what another lane's run set. Only a wave none of whose lanes runs the region reads what the skip leaves, and compiled code does not read an EXEC save as a descriptor.The change (
crates/victory-shader/src/resource.rs)phi(): when some predecessor edges fail to trace,past_skiptakes the source of the others if every failing edge is the taken edge of ans_cbranch_execzinto the join, and the other edges agree on one source whose handle can be made at the join. That means a constant, or a load or built descriptor whose address only reads values that dominate the join. Lowering makes the handle at the access from the load's base and offset registers, so those are what is checked.high_half(): a phi at such a join whose non-skip edges are the expected high half (0 for a table) counts as that high half. A table's heap index only uses the low dword, which is unaffected.Phi(test below).Tests
Five new unit tests in
resource::tests, on synthetic code:a_descriptor_loaded_in_a_skippable_region_is_read_after_ita_sampler_set_in_a_skippable_region_is_the_constant_after_ita_table_address_a_skippable_region_completes_is_traced_after_ita_descriptor_a_skippable_region_reloads_is_still_joined(unchanged behaviour)a_descriptor_read_after_a_skip_otherwise_still_fails: an offset computed inside the region, and a skip on a uniforms_cbranch_scc1, are still refused.The three positive tests fail without the change.
Measurements
Offline
victory translate --validate --listover the shader pack, the executable and its DLLs: 25,982 programs. Windows 11,dxil.dllfrom SDK 10.0.26100. Per #1945 that one prints 1.8 but behaves like 1.7; both runs used it, so the comparison holds.main940d32fa descriptor neither loaded nor builtThe only outcomes that change, across all 25,982 programs:
mainCS_TraceShadowRays_ScreenSpaceOnlyCheckerboard0x6dc8CS_AlphTransmissionPrefilterMip0x4d0CS_Alpha_Schedule0x140Entry function performs some operation that is incompatible with the shader stage), the class #2027 addressesChecks:
cargo clippy -p victory-shader --all-targets --locked -- -D warnings, with and without--all-features: clean.cargo test -p victory-shader --locked: 249 passed, 3 failed. The same three fail onmainon this GPU (RTX 3070 Ti):a_heap_buffer_read_by_element_takes_the_views_strideanda_heap_buffer_read_where_no_buffer_view_is_reads_zeros(the 1,000,000 view-heap cap, #1835) andgathers_at_a_level_match_the_hardware.In-game check
On an RTX 3070 Ti (32-lane waves, Windows 11), one run per row, each into the prologue's world from about 1.5 min:
main+ #1775 (to get past #1753's boot removal), as a diagnostics build;VICTORY_SKIP_PIPELINES);VICTORY_POKE=71b6331:1andVICTORY_D3D12_DRED=1are set;2da4beb386509b77aab1b3c7248ee5demain+ #1775+0x5149aecafter 11 min (#1232)0x887A0006) at 7.5 min indraw [vertex cb47fdb3b37b7880, pixel b335d5633b1ed53f]aab1b3c7248ee5deskippedWith
aab1b3c7248ee5deskipped, the GPU runs exactly the workmaindoes. The same draw then hangs, so the removal is the known hang in that draw (#1968, #452), not something this change makes run. Themainrun ended on the title's breakpoint before getting there. The third program,e6ac855a4cddb16d, was not requested in these runs.Not covered
AI-assisted; measured on my own machine.
Compiled code sets a descriptor, or the high half of the table address it loads one through, inside a region that `s_cbranch_execz` skips when no lane would run it, and reads it after the region. The phi where the region ends joins the region's words with what the skip leaves in the registers (an EXEC save, a lane mask), and tracking refused the read ("a descriptor neither loaded nor built", then "an address into a descriptor heap with an untracked high half"). Scalar writes are the whole wave's: a lane that reaches the end without running the region reads what another lane's run set, so the per-lane branch structurisation makes of the skip does not hold for them. Where every edge that fails to trace is such a skip and the other edges agree, the read is of the region's source, provided its handle can be made where the region ends: a constant, or a load or built descriptor whose address only reads values that dominate that point. A table address's high half set in such a region counts as set. Reads that trace today are unchanged. The rule is in the module notes and docs/architecture.md; a skip's edge holding a descriptor tracking cannot follow is a shortcut. Offline `translate --validate` over the title's 25,982 programs: the three "a descriptor neither loaded nor built" refusals are gone; two of them validate, the third now reaches the validator's compute-derivative check (the class #2027 addresses). No other program's outcome changes.@Marvisak on GitHub · 2026-11-25 15:19 UTC · original
Automated triage for the maintainers.
Merge candidate (worth a look). In
crates/victory-shader/src/resource.rs,Tracer::phinow goes through the newpast_skipbefore it gives up: if the only predecessor edges that fail to trace are the taken edges of ans_cbranch_execzinto the join, and the other edges agree on one source whose handle can be built at the join, the read takes that source;high_halfdoes the same throughpast_skip_is. This matches GFX10 behaviour (scalar writes apply to the whole wave, ands_cbranch_execzskips only when EXEC is zero, so the skip edge carries a value the compiled code never reads as a descriptor), and the new paths run only where tracking used to refuse. The negative tests (an offset computed inside the region, a skip on a uniforms_cbranch_scc1) still refuse; the evidence covers the affected programs, an offline validation diff and an in-game run. CI: passing.Generated by Claude Code
@chippy01 on GitHub · 2026-11-25 15:47 UTC · original
Superseded by
ff47463and58b5255on main, which handle the same three programs by proving that no lane takes the skip edge. Onda82e44the shader census gives what this PR aimed for: CS_AlphTransmissionPrefilterMip and CS_TraceShadowRays_ScreenSpaceOnlyCheckerboard validate, CS_Alpha_Schedule stops at the compute-derivative check (#2027), and no 'a descriptor neither loaded nor built' refusal is left.Pull request closed