Keep AMD's shader compiler (RX 9060 XT) from failing: size queries through a non-uniform handle, one clean-up pass for nine programs #62

Open
github-bot wants to merge 2 commits from github-bot/gh-62 into main AGit
Owner

@⁠MrToucann on GitHub · 2026-11-26 01:50 UTC · original
MrToucann:amd-shader-fixes → main · +102 −2 · 5 files · 2 commits · open

Problem

On an AMD Radeon RX 9060 XT (driver 32.0.32029.2010, amdxc64.dll 8.18.10.0514), creating the host pipelines of 13 translated programs makes the driver's shader compiler fail:

  • access violation (null read at 0x8 inside amdxc64.dll): victory warm dies with 0xC0000005, or
  • the process exits with 0xFFFFFFFF and prints nothing.

The DXIL passes dxil.dll validation, so this is a driver compiler bug. A user on an RX 9070 XT with the same driver hit the same crash (fxceless/victory-fork#1213).

The programs were found by creating every program's pipeline in a process of its own: 2,684 compute programs, and 23,279 others each with a stand-in partner stage.

The change

Programs Change
All programs with a buffer size query: this fixes bvh_skinning:CSComputeSkinningTreeAnimVelocity, GpuParticleUpdateCS_UpdateSkinnedAttachMeshTreeParticles and both rtdirectionalshadows RT shadow traces A buffer's size (descriptor_data) is asked through a heap handle of its own, marked non-uniform, rather than the uniform handle the buffer's loads use. This is the approach of fxceless/victory-fork#1213 (IxMxAMAR). The handle isn't counted in nonuniform_handles, since its index is the same in every lane. Descriptors loaded per lane keep their handle as before.
indirect_diffuse_lighting:CS_ScreenProbes_ActivateRays The constant-folding clean-up pass (FOLD) runs for it whatever VICTORY_SHADER_OPT says (on this card the full clean-up has to stay off, since it trips the same compiler elsewhere).
Eight PS_*_PBR_MATERIAL_*GLINTS* pixel programs The same, with FACTS.

The pass list is chosen by container digest, so other programs keep their passes as they are. Neither change alters what a program computes.

Everything lives in emit/lower/amd.rs. Existing code changes by one line per hook, so it carries to forks:

  • lower.rs: mod amd;, plus the size query's handle through size_view_handle.
  • mod.rs: lower::amd::begin(c.digest); before lowering.
  • shader.rs: | super::lower::amd::passes() in the clean-up's pass set.
  • lib.rs: the new file in translation_inputs!, so the shader cache keys on it.

How the size-read crash was narrowed

Reduced with DXC built from source (dxa/dxopt) to 46 instructions:

  • a raw load at an offset computed from that same view's getDimensions;
  • a branch on the loaded value;
  • a guarded loop.

Each of the three is needed. Passing the size through waveReadLaneFirst, waveReadLaneAt, a double bfrev, or a separate handle on the same index that stays uniform still crashes. A non-uniform handle (#1213's finding) builds, and so does groupshared memory across a group barrier (this PR's first version, now replaced).

Testing (RX 9060 XT)

  • cargo test -p victory-shader: 240 passed.
  • All 13 programs: translate --validate --pipelines validates and creates the pipeline, with VICTORY_SHADER_OPT=0 and with it unset.
  • Not yet verified in-game. No frame has been rendered with these programs yet.

Side finding, not addressed here: making all compute pipelines in parallel in one process removed the device partway on this card (0x887A0005), while victory warm --jobs 1 made all 2,734.

🤖 Generated with Claude Code

https://claude.ai/code/session_01A752X7rKCzD2ViPbSWcyut

**@⁠MrToucann** on GitHub · 2026-11-26 01:50 UTC · [original](https://github.com/DexNom/VIctory/pull/62) `MrToucann:amd-shader-fixes` → `main` · +102 −2 · 5 files · 2 commits · open ## Problem On an **AMD Radeon RX 9060 XT** (driver 32.0.32029.2010, `amdxc64.dll` 8.18.10.0514), creating the host pipelines of **13 translated programs** makes the driver's shader compiler fail: - **access violation** (null read at `0x8` inside `amdxc64.dll`): `victory warm` dies with `0xC0000005`, or - **the process exits with `0xFFFFFFFF`** and prints nothing. The DXIL **passes `dxil.dll` validation**, so this is a driver compiler bug. A user on an RX 9070 XT with the same driver hit the same crash (fxceless/victory-fork#1213). The programs were found by creating every program's pipeline in **a process of its own**: 2,684 compute programs, and 23,279 others each with a stand-in partner stage. ## The change | Programs | Change | |---|---| | **All programs** with a buffer size query: this fixes `bvh_skinning:CSComputeSkinningTreeAnimVelocity`, `GpuParticleUpdateCS_UpdateSkinnedAttachMeshTreeParticles` and both `rtdirectionalshadows` RT shadow traces | A buffer's size (`descriptor_data`) is asked through a **heap handle of its own, marked non-uniform**, rather than the uniform handle the buffer's loads use. This is the approach of fxceless/victory-fork#1213 (IxMxAMAR). The handle isn't counted in `nonuniform_handles`, since its index is the same in every lane. Descriptors loaded per lane keep their handle as before. | | `indirect_diffuse_lighting:CS_ScreenProbes_ActivateRays` | The constant-folding clean-up pass (`FOLD`) runs for it whatever `VICTORY_SHADER_OPT` says (on this card the full clean-up has to stay off, since it trips the same compiler elsewhere). | | Eight `PS_*_PBR_MATERIAL_*GLINTS*` pixel programs | The same, with `FACTS`. | The pass list is chosen by container digest, so other programs keep their passes as they are. Neither change alters what a program computes. Everything lives in **`emit/lower/amd.rs`**. Existing code changes by one line per hook, so it carries to forks: - `lower.rs`: `mod amd;`, plus the size query's handle through `size_view_handle`. - `mod.rs`: `lower::amd::begin(c.digest);` before lowering. - `shader.rs`: `| super::lower::amd::passes()` in the clean-up's pass set. - `lib.rs`: the new file in `translation_inputs!`, so the shader cache keys on it. ## How the size-read crash was narrowed Reduced with DXC built from source (`dxa`/`dxopt`) to **46 instructions**: - a raw load at an offset computed from **that same view's `getDimensions`**; - a branch on the loaded value; - a guarded loop. Each of the three is needed. Passing the size through `waveReadLaneFirst`, `waveReadLaneAt`, a double `bfrev`, or a separate handle on the same index that stays *uniform* still crashes. A non-uniform handle (#1213's finding) builds, and so does groupshared memory across a group barrier (this PR's first version, now replaced). ## Testing (RX 9060 XT) - `cargo test -p victory-shader`: 240 passed. - All 13 programs: `translate --validate --pipelines` validates and creates the pipeline, with `VICTORY_SHADER_OPT=0` and with it unset. - **Not yet verified in-game.** No frame has been rendered with these programs yet. Side finding, not addressed here: making all compute pipelines **in parallel** in one process removed the device partway on this card (`0x887A0005`), while `victory warm --jobs 1` made all 2,734. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01A752X7rKCzD2ViPbSWcyut
amdxc64 8.18.10.0514 (Radeon RX 9060 XT, driver 32.0.32029.2010) dereferences
null, or ends the process, creating the pipelines of 13 programs as
translated. They were found by creating every program's pipeline (2,684
compute; 23,279 others with a stand-in partner stage) in a process of its
own.

- Four compute programs load from a raw view at an offset computed from that
  view's own size, with a branch on the loaded value guarding a loop (reduced
  to 46 instructions with DXC's dxa/dxopt). For them the size is read in the
  entry block and passed through groupshared memory across a group barrier,
  which hides where the offset came from. Every thread meets the barrier
  there.
- One compute program and the eight glints pixel programs build once one
  clean-up pass runs (constant folding, or what a taken branch says about its
  condition). It runs for them whatever VICTORY_SHADER_OPT says.

They are chosen by container digest, so every other program translates as
before, and these compute the same values. Everything lives in
emit/lower/amd.rs with a one-line hook where each change acts, so the change
carries to forks.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01A752X7rKCzD2ViPbSWcyut
The four size-read programs crash because the size query and the buffer's
loads use the same uniform heap handle. fxceless/victory-fork#1213
(IxMxAMAR) asks the size through a handle of its own, marked non-uniform and
not counted in nonuniform_handles. On the RX 9060 XT that clears all four
here too, without a digest list. It replaces the groupshared hoist and the
Module helpers it needed.

The nine programs that need one clean-up pass keep it by digest.

All 13 programs validate and create their pipelines on the RX 9060 XT;
cargo test -p victory-shader: 240 passed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01A752X7rKCzD2ViPbSWcyut
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:33:01 +00:00
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/62/head:github-bot/gh-62'
git switch 'github-bot/gh-62'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-62'
git switch 'github-bot/gh-62'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-62'
git switch 'github-bot/gh-62'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-62'
git switch 'main'
git merge --squash 'github-bot/gh-62'
git switch 'main'
git merge --ff-only 'github-bot/gh-62'
git switch 'main'
git merge 'github-bot/gh-62'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.