Shaders: descriptors set in a region s_cbranch_execz can skip are traced after it #2324

Closed
github-bot wants to merge 1 commit from gh-pr/2324/head into gh-pr/2324/base
Owner

@⁠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 merging

Problem

On main (940d32f) three compute programs are refused at translation with resources: a descriptor neither loaded nor built. They are the last three of that class (#320 brings it from 298 to 3; main is at 3):

program hash refused at
shadowmask:CS_TraceShadowRays_ScreenSpaceOnlyCheckerboard e6ac855a4cddb16d 0x6dc8
alphaResolve:CS_AlphTransmissionPrefilterMip 2da4beb386509b77 0x4d0
indirect_light_probes:CS_Alpha_Schedule aab1b3c7248ee5de 0x140

All 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_execz skips 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_Schedule also clears the high half of its table address only inside such a region, so after the first refusal it stops at an address into a descriptor heap with an untracked high half.

Why the read is the region's

The structuriser turns s_cbranch_execz into 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_skip takes the source of the others if every failing edge is the taken edge of an s_cbranch_execz into 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.
  • Reads that trace today are unchanged: the new paths only run where tracking would otherwise refuse. A region that reloads a descriptor the skip also leaves stays a Phi (test below).

Tests

Five new unit tests in resource::tests, on synthetic code:

  • a_descriptor_loaded_in_a_skippable_region_is_read_after_it
  • a_sampler_set_in_a_skippable_region_is_the_constant_after_it
  • a_table_address_a_skippable_region_completes_is_traced_after_it
  • a_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 uniform s_cbranch_scc1, are still refused.

The three positive tests fail without the change.

Measurements

Offline victory translate --validate --list over the shader pack, the executable and its DLLs: 25,982 programs. Windows 11, dxil.dll from SDK 10.0.26100. Per #1945 that one prints 1.8 but behaves like 1.7; both runs used it, so the comparison holds.

main 940d32f this PR
programs validated 24,005 24,007
a descriptor neither loaded nor built 3 0

The only outcomes that change, across all 25,982 programs:

program main this PR
CS_TraceShadowRays_ScreenSpaceOnlyCheckerboard refused at 0x6dc8 validated
CS_AlphTransmissionPrefilterMip refused at 0x4d0 validated
CS_Alpha_Schedule refused at 0x140 emitted; the validator's compute-derivative check (Entry function performs some operation that is incompatible with the shader stage), the class #2027 addresses

Checks:

  • 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 on main on this GPU (RTX 3070 Ti): a_heap_buffer_read_by_element_takes_the_views_stride and a_heap_buffer_read_where_no_buffer_view_is_reads_zeros (the 1,000,000 view-heap cap, #1835) and gathers_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:

  • every run is main + #1775 (to get past #1753's boot removal), as a diagnostics build;
  • the W, A and C programs of #1968 are skipped (VICTORY_SKIP_PIPELINES);
  • VICTORY_POKE=71b6331:1 and VICTORY_D3D12_DRED=1 are set;
  • each run starts from a cold shader cache of its own.
run 2da4beb386509b77 aab1b3c7248ee5de end
main + #1775 does not translate; 2 dispatches a frame dropped does not translate; 1 a frame dropped the title's own breakpoint at +0x5149aec after 11 min (#1232)
+ this PR translates; the driver refuses the pipeline (a wave64 program on a 32-lane host), so still dropped translates; pipeline made, runs every frame (writes its 32x16 target) device hung (0x887A0006) at 7.5 min in draw [vertex cb47fdb3b37b7880, pixel b335d5633b1ed53f]
+ this PR, aab1b3c7248ee5de skipped as above skipped the same draw hangs at 7.3 min

With aab1b3c7248ee5de skipped, the GPU runs exactly the work main does. The same draw then hangs, so the removal is the known hang in that draw (#1968, #452), not something this change makes run. The main run ended on the title's breakpoint before getting there. The third program, e6ac855a4cddb16d, was not requested in these runs.

Not covered

  • Other scalar values such a region sets and the code reads after it (a count read as data, say) still take the per-lane phi in lowering. That is a separate structuriser question.
  • A region source whose address the region computes is still refused: its handle could not be made where the region ends.

AI-assisted; measured on my own machine.

**@⁠chippy01** on GitHub · 2026-11-25 10:41 UTC · [original](https://github.com/Marvisak/VIctory/pull/2324) `chippy01:shaders/descriptor-neither-loaded-nor-built` → `main` · +324 −6 · 2 files · 1 commits · closed without merging ## Problem On `main` (`940d32f`) three compute programs are refused at translation with `resources: a descriptor neither loaded nor built`. They are the last three of that class (#320 brings it from 298 to 3; `main` is at 3): | program | hash | refused at | |---|---|---| | `shadowmask:CS_TraceShadowRays_ScreenSpaceOnlyCheckerboard` | `e6ac855a4cddb16d` | `0x6dc8` | | `alphaResolve:CS_AlphTransmissionPrefilterMip` | `2da4beb386509b77` | `0x4d0` | | `indirect_light_probes:CS_Alpha_Schedule` | `aab1b3c7248ee5de` | `0x140` | All 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_execz` skips 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_Schedule` also clears the high half of its table address only inside such a region, so after the first refusal it stops at `an address into a descriptor heap with an untracked high half`. ## Why the read is the region's The structuriser turns `s_cbranch_execz` into 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_skip` takes the source of the others if every failing edge is the taken edge of an `s_cbranch_execz` into 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. - Reads that trace today are unchanged: the new paths only run where tracking would otherwise refuse. A region that reloads a descriptor the skip also leaves stays a `Phi` (test below). ## Tests Five new unit tests in `resource::tests`, on synthetic code: - `a_descriptor_loaded_in_a_skippable_region_is_read_after_it` - `a_sampler_set_in_a_skippable_region_is_the_constant_after_it` - `a_table_address_a_skippable_region_completes_is_traced_after_it` - `a_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 uniform `s_cbranch_scc1`, are still refused. The three positive tests fail without the change. ## Measurements Offline `victory translate --validate --list` over the shader pack, the executable and its DLLs: 25,982 programs. Windows 11, `dxil.dll` from SDK 10.0.26100. Per #1945 that one prints 1.8 but behaves like 1.7; both runs used it, so the comparison holds. | | `main` `940d32f` | this PR | |---|---|---| | programs validated | 24,005 | 24,007 | | `a descriptor neither loaded nor built` | 3 | 0 | The only outcomes that change, across all 25,982 programs: | program | `main` | this PR | |---|---|---| | `CS_TraceShadowRays_ScreenSpaceOnlyCheckerboard` | refused at `0x6dc8` | validated | | `CS_AlphTransmissionPrefilterMip` | refused at `0x4d0` | validated | | `CS_Alpha_Schedule` | refused at `0x140` | emitted; the validator's compute-derivative check (`Entry function performs some operation that is incompatible with the shader stage`), the class #2027 addresses | Checks: - `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 on `main` on this GPU (RTX 3070 Ti): `a_heap_buffer_read_by_element_takes_the_views_stride` and `a_heap_buffer_read_where_no_buffer_view_is_reads_zeros` (the 1,000,000 view-heap cap, #1835) and `gathers_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: - every run is `main` + #1775 (to get past #1753's boot removal), as a diagnostics build; - the W, A and C programs of #1968 are skipped (`VICTORY_SKIP_PIPELINES`); - `VICTORY_POKE=71b6331:1` and `VICTORY_D3D12_DRED=1` are set; - each run starts from a cold shader cache of its own. | run | `2da4beb386509b77` | `aab1b3c7248ee5de` | end | |---|---|---|---| | `main` + #1775 | does not translate; 2 dispatches a frame dropped | does not translate; 1 a frame dropped | the title's own breakpoint at `+0x5149aec` after 11 min (#1232) | | + this PR | translates; the driver refuses the pipeline (a wave64 program on a 32-lane host), so still dropped | translates; pipeline made, runs every frame (writes its 32x16 target) | device hung (`0x887A0006`) at 7.5 min in `draw [vertex cb47fdb3b37b7880, pixel b335d5633b1ed53f]` | | + this PR, `aab1b3c7248ee5de` skipped | as above | skipped | the same draw hangs at 7.3 min | With `aab1b3c7248ee5de` skipped, the GPU runs exactly the work `main` does. The same draw then hangs, so the removal is the known hang in that draw (#1968, #452), not something this change makes run. The `main` run ended on the title's breakpoint before getting there. The third program, `e6ac855a4cddb16d`, was not requested in these runs. ## Not covered - Other scalar values such a region sets and the code reads after it (a count read as data, say) still take the per-lane phi in lowering. That is a separate structuriser question. - A region source whose address the region computes is still refused: its handle could not be made where the region ends. 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:02:19 +00:00
github-bot closed this pull request 2026-11-26 05:02:19 +00:00
Author
Owner

@⁠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::phi now goes through the new past_skip before it gives up: if the only predecessor edges that fail to trace are the taken edges of an s_cbranch_execz into the join, and the other edges agree on one source whose handle can be built at the join, the read takes that source; high_half does the same through past_skip_is. This matches GFX10 behaviour (scalar writes apply to the whole wave, and s_cbranch_execz skips 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 uniform s_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

**@⁠Marvisak** on GitHub · 2026-11-25 15:19 UTC · [original](https://github.com/Marvisak/VIctory/pull/2324#issuecomment-7166674874) <!-- victory-triage v1 head=bcb3268c010ae875fe8d73fcc3ee29f58674ff9c verdict=merge-candidate at=2026-11-25T15:25:00Z --> Automated triage for the maintainers. **Merge candidate (worth a look).** In `crates/victory-shader/src/resource.rs`, `Tracer::phi` now goes through the new `past_skip` before it gives up: if the only predecessor edges that fail to trace are the taken edges of an `s_cbranch_execz` into the join, and the other edges agree on one source whose handle can be built at the join, the read takes that source; `high_half` does the same through `past_skip_is`. This matches GFX10 behaviour (scalar writes apply to the whole wave, and `s_cbranch_execz` skips 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 uniform `s_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](https://claude.ai/code)_
Author
Owner

@⁠chippy01 on GitHub · 2026-11-25 15:47 UTC · original

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.

**@⁠chippy01** on GitHub · 2026-11-25 15:47 UTC · [original](https://github.com/Marvisak/VIctory/pull/2324#issuecomment-7167317549) 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.

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!2324
No description provided.