Repository navigation
Conversation
…ced after it
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 Marvisak#2027 addresses). No other program's outcome changes.
catminou4
left a comment
There was a problem hiding this comment.
Tested locally: merged into main 940d32f, cargo test -p victory-shader --locked on macOS arm64 — 149 passed, 0 failed, 2 ignored (Windows-gated hardware execution tests not run here). Approving — descriptors set in a region s_cbranch_execz can skip, +5 tests and docs.
|
Automated triage for the maintainers. Merge candidate (worth a look). In Generated by Claude Code |
|
Superseded by ff47463 and 58b5255 on main, which handle the same three programs by proving that no lane takes the skip edge. On da82e44 the 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. |
Problem
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, NVIDIA D3D12 (70564ae): stride_tests & synthetic_tests fail due to HEAP_VIEWS (2M > 1M NVIDIA limit) and Stride::Structured with rawBufferLoad #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+ GPU: unordered views only in formats the host can store (#1753) #1775 (to get past NVIDIA: main at 70564ae removes the device ~6 s after start (typed UAV on B5G5R5A1_UNORM, DXGI_ERROR_INVALID_CALL) #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.