Skip to content

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
MrToucann wants to merge 2 commits into
DexNom:mainfrom
MrToucann:amd-shader-fixes
Open

MrToucann wants to merge 2 commits into
DexNom:mainfrom
MrToucann:amd-shader-fixes

Conversation

@MrToucann

@MrToucann MrToucann commented Nov 26, 2026 •

Copy link
Copy Markdown

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 (Marvisak#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

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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01A752X7rKCzD2ViPbSWcyut
…ess/victory-fork#1213 does

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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01A752X7rKCzD2ViPbSWcyut
@MrToucann MrToucann changed the title Keep AMD's shader compiler (RX 9060 XT) from failing on 13 translated programs Keep AMD's shader compiler (RX 9060 XT) from failing: size queries through a non-uniform handle, one clean-up pass for nine programs Nov 26, 2026
@BackseatDrivers-Unbound

Copy link
Copy Markdown

Independent test of this PR on an RX 9070 XT, compared with #7, #56, #45 and #2. Results of the offline evaluation (driver 32.0.32029.2010). Each PR head is merged onto main 64bd58f. All 25,985 shader containers the game ships are translated and validated, each batch in its own process, and the targeted ones also go through D3D12 pipeline creation. A shader counts as a crasher only when it kills a process on its own (module and offset from the Windows crash event).

Unfixed main has 72 crashers, all at amdxc64.dll+0x861b9f:

  • 68 ped CS_RaytracingResolve programs;
  • three tree-animation programs (CSComputeSkinningTreeAnimVelocity, CSComputeSkinningTreeAnim, CSComputeTreeAnim);
  • one particle program (CS_UpdateSkinnedAttachMeshTreeParticles).

Upstream Marvisak has 0.

PR (head) crashers left of the 72 new crashers translated / validated (whole game) DXIL outputs changed
main 64bd58f 72 - 25,748 / 25,632 -
#62 2152e55 (MrToucann) 0 0 25,748 / 25,632 22,463
#7 3ac8713 (manoel0810) 4 (the 3 tree + the particle) 0 25,748 / 25,632 20,862
#56 b03da94 (ExMoha, closed) 4 (the same) 0 25,748 / 25,632 12,975
#45 35ef1c3 (PasElias) 72 offline (its guard only acts in game) 0 25,748 / 25,632 0
#2 13bad93 (jmal423) guard only, nothing to measure offline 0

Prior work: #62's own commit message already reports every pipeline made, each in its own process, on an RX 9060 XT (13 failing there, 0 with the PR). This repeats that on a 9070 XT and compares it with #7, #45 and #56. The same idea exists in fxceless/victory-fork#1213 and fxceless/victory-fork#452, Marvisak#2122 and avatarmanz/VIctory-7900XTX#357. Belobug/VIctory-Belobug-AMD#339 has a related variant.

Recommendation: merge #62, and add a guard as a separate safety net (GitHub PR 2 is the smaller one). That covers programs a census can't build offline, for example with the game's real partner stages.

Limits:

  • Offline pipelines use stub partner stages and a test root signature, not the game's pipeline states. All 72 crashers are compute programs, which are close to what the game makes.
  • One card and one driver.
  • In game, one run so far (main + 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, --rt --console series-x, open-world save, cold shader cache): no crash in about 5.5 minutes. That covers about 4 minutes in play, until the test runner closed the game, with every pipeline the scene asked for made ("0 being made" at the end). Unfixed main crashed in the same test after about 2.5 minutes at amdxc64.dll+0x861b9f. The character stood still in that run; a longer run with movement comes next.

RDNA 3 or RX 9060 XT owners: if you run the same census on your card, please post your count of crashers.

Full report and method: pr-evaluation-rdna4-compiler-crash.md; whole-game census of main: rdna4-shader-census-dexnom.md. AI-assisted (Claude); measured on my card.

@eazyves

eazyves commented Nov 27, 2026

Copy link
Copy Markdown

Independent test on an RX 9070 XT (RDNA 4), driver 32.0.32029.2010, Ryzen 7 5800X3D, 32 GB RAM, Windows 11 build 26200.

Builds: DexNom/VIctory main 8114ff7 and this PR merged onto it (9c7fe1d, clean merge), release with --features diagnostics, rustc 1.98.1. The PR build had its own install folder and started from an empty shader cache.

Shader warming (victory-warm.exe)

main 8114ff7 main + #62
Result 0xc0000005 in amdxc64.dll+0x861b9f after about 1 min completed in 715 s
Compute pipelines crashed before finishing 2,734 made, 0 refused
Shaders (incomplete) 25,748 translated, 10 refused (the same 10 refusals as main)

The same fault, at the same offset, happened again in two more warm runs on main: one with GromX0/victory-fork 1465c1f cherry-picked, and one with that commit and VICTORY_SHADER_OPT=59.

Game runs (main + #62), FSR Quality 4K profile (--rt --console series-x --local-gpu-memory --sparse-textures --no-upload-ahead --capture-readbacks --rt-write-stats --fsr-quality, FidelityFX 4.1.2), warm cache:

  • "CHAPTER 1 - Boat Scene" save from the server: reached the world without a crash or a watchdog stop and exited cleanly (exit 0).
  • "CHAPTER 1 - Jason's House" save: reached control with the HUD; the picture looked right (lit interior, floor reflections, slightly overexposed windows). Measured with the camera still, no input, below.

On main without this PR, the same profile with a cold cache ended at the title's 30 s watchdog on the first world frame (victory-image+0x23cf683), as reported on the server for another 9070 XT.

Jason's House, 121 s with the camera still, 22 frame-line intervals (median/p95 are of those interval means, not of single frames):

Median p95
Frame time 1,424 ms (0.7 fps) 1,844 ms
Preparing (CPU) 781 ms 992 ms
Waiting for the GPU 624 ms 716 ms
Copying back 603 ms, 76 MB 657 ms, 95 MB
Uploads (copies / textures) 502 MB / 21 MB 587 MB / 179 MB
Draws per frame 5,859 5,942
Dropped draws / pipelines being made 0 / 0 0 / 0

Memory in the same window, sampled every 2-3 s from Windows counters (median, max):

Median Max
victory.exe private commit 32.8 GB 34.9 GB
victory.exe working set 22.1 GB 25.6 GB
GPU dedicated / shared (process) 13.2 / 9.0 GB 13.7 / 9.4 GB
System commit / commit limit 54.1 / 57.0 GB 56.2 / 57.0 GB
Available RAM 3.75 GB min 0.46 GB

With 32 GB of RAM the system ran at its commit limit and Windows kept growing the page file. The working set swung between about 20 and 26 GB in a cycle of roughly 10 s (Task Manager showed RAM filling, being trimmed and filling again); local video memory sat about 1 GB under its 14.5 GB budget with 9 GB spilled to shared memory.

Limits: one PC, one measured run, no pixel comparison against another card.

VanviroDev pushed a commit to VanviroDev/VIctory that referenced this pull request Nov 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants