Skip to content

Recompiler: compile HLSL-path pixel shaders without DXC's GVN (AMD compiler crash) - #3733

Draft
RodrigoTorreao wants to merge 1 commit into
xcl-dev:mainfrom
RodrigoTorreao:fix/ps-no-gvn-amd
Draft

RodrigoTorreao wants to merge 1 commit into
xcl-dev:mainfrom
RodrigoTorreao:fix/ps-no-gvn-amd

Conversation

@RodrigoTorreao

Copy link
Copy Markdown
Contributor

Fixes #3732.

DXC 1.9's GVN turns one retail pixel shader, a 1.66 MB HLSL fallback, into 509 KB of DXIL. AMD's shader compiler then crashes the process in CreatePipelineState (amdxc64.dll+0x790849, RX 6750 XT, Adrenalin 32.0.21045). With GVN off, the same source gives 696 KB of DXIL that builds. The details and the bisection are in the issue.

Pixel shaders reach DXC only on the HLSL fallback path, so the cost is a few larger fallbacks. Unlike #1398, which retries a refused compute PSO, nothing can be retried here: the driver crashes instead of returning an error.

What is in it

  • crates/xcl/src/gpu/recomp/dxc.rs: ps_* profiles get -opt-disable gvn (no_gvn, profile_args). Their DXIL cache keys use their own toolchain identity (profile_toolchain), so an entry made with GVN is not reused.
  • crates/xcl/src/gpu/recomp/pso.rs: translated pixel entries get a _nogvn name, for the same reason. Without this, the old crashing DXIL came back from translated/v2 after the change.
  • New tests:
    • pixel_shaders_compile_without_gvn_under_their_own_keys (dxc.rs): the flags, the keys, and that DXC accepts the flag;
    • translated_pixel_entries_have_the_no_gvn_name (pso.rs).

Tested

Regression run

main:

xcl-smoke v1
commit: 5ad98adbc360225ac8a57ad9661e16fe8df9d8dd
gpu: AMD Radeon RX 6750 XT
title: 2a4aef2e
seconds: 900
exit: 0x887a0020
frames shown: none logged (the run did not reach its end)
presents per 2 s (last 3): 0
device removals: 1
crashes: 2
peak commit: 5260 MB

PR:

xcl-smoke v1
commit: 9ec5bca702c4b26e0ca650b36824d228683603fe
gpu: AMD Radeon RX 6750 XT
title: 2a4aef2e
seconds: 900
exit: 0x887a0020
frames shown: none logged (the run did not reach its end)
presents per 2 s (last 3): 0
device removals: 1
crashes: 2
peak commit: 4955 MB

On this GPU both runs stop about 2 s after start, before the title draws: the driver refuses split-wave64 compute PSOs (0x887a0005) and then removes the device (0x887a0020). That is #3694, from #3655, and this PR does not touch it. The title runs that do reach this PR's code are under Tested (main 817eb1f without #3655, plus #3455).

Not tested

AI use

  • Claude Code (Claude Opus 5.5): the investigation (offline replay, bisection of the DXC flags), the code, the tests and this description. I ran every test and run listed here on the hardware above.

🤖 Generated with Claude Code

DXC 1.9's GVN turns a retail title's 1.66 MB pixel shader (an HLSL-path
fallback for a v_writelane spill) into 509 KB of DXIL that crashes AMD's
shader compiler in CreatePipelineState (amdxc64.dll+0x790849, null read,
RX 6750 XT, Adrenalin 32.0.21045), every time, on that one pipeline.
With GVN off the same source gives 696 KB that builds; DXC 1.7 makes
689 KB, also fine; -O0 builds but doubles the DXIL. Turning off licm,
sink, structurize-returns, lifetime-intrinsics or
structurize-loop-exits-for-unroll instead does not help.

ps_ profiles now get -opt-disable gvn. Their DXIL cache keys carry their
own toolchain identity and translated pixel entries get a _nogvn name,
so DXIL cached with GVN is not reused (the translated cache brought the
crashing DXIL back without the new name).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added area:recompiler RDNA2 decoder, HLSL/direct-DXIL recompiler, wave64/wave32 gpu:amd Code is specific to AMD / RDNA / wave64 GPUs (scope tag; see needs:amd-test) needs-pr-check Failing the PR description check (CONTRIBUTING.md) labels Dec 2, 2026
@Foniass

Foniass commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

Review of 9ec5bca7 (code reading only, not a merge-check; draft, PR description red) · 2 medium, 1 nit

In short: The PR compiles every ps_* HLSL program with -opt-disable gvn, gives those programs their own DXIL cache keys, and renames translated pixel entries with a _nogvn suffix, so DXIL built with GVN is never reused. The flag, the key split and the rename are right, and nothing breaks the default path. But the startup pack receipt still treats the old DXIL as current, and the rename throws away the direct translator's pixel entries too.

Medium

  1. The startup pack receipt still covers the old pixel DXIL.

    • warm_pack::Stages::open (shaders/warm_pack.rs ~51-53) keys its receipt on warm_replay::native_key. That key comes from translation_cache_identity(), which uses the plain toolchain_identity() (warm_replay.rs ~117-120). This PR changes neither.
    • After the update the old receipt stays valid, because the GVN-built .dxil files it lists are still on disk. precompile then skips those graphics records (shaders.rs ~4236), so no pixel DXIL without GVN is made at launch. The first run compiles those shaders at draw time, including the 1.66 MB one.

    Fix: make the receipt key change with this PR, for example rename pack-stages-v1 to v2, or put profile_toolchain("ps_6_6") into the digest.

  2. The _nogvn rename also discards the direct translator's pixel entries.

    • translated::file_for (gpu/recomp/pso.rs ~409) adds the suffix to every Stage::Pixel entry.
    • With XCL_DIRECT_DXIL unset, pixel shaders go to direct_graphics, which never touches DXC, and are stored under the same name (cached_rerouted_for, ~767).
    • After the update, every cached pixel shader misses once and is translated again, not only the HLSL fallbacks the description talks about.

    Fix: limit the new name to entries from the HLSL path, or state and measure the one-time cost.

Nit

  1. No test covers passing the flag to DXC. If args.extend(profile_args(profile)...) in compile_with (dxc.rs ~1109) were removed, both new tests would still pass. Build the argument list in a small function and assert it contains -opt-disable gvn for ps_6_6.
Checked and fine
  • compile_with adds profile_args only for ps_*, after the -O0 / -O1 choice. Only cs_ programs take the linked path, so pixel shaders always go through compile_whole.
  • cache_key and generated_cache_key both use profile_toolchain, so the legacy promotion cannot bring back a GVN-built pixel entry, and the .err cache and pack_proof use the same keys.
  • Compute, vertex, mesh and amplification keys are unchanged, as the new test checks.
  • The new file_for names keep the _rt32_ suffix after _nogvn.
  • skip_test is called when DXC is missing.
  • Not a duplicate: D3D12.X: retry driver-rejected compute PSOs without DXC GVN (#756) #1398 retries refused compute PSOs without GVN through separate keys. Both touch the key functions in dxc.rs, so whichever merges second may need a rebase.
  • 63+/3- in 2 files.

Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:recompiler RDNA2 decoder, HLSL/direct-DXIL recompiler, wave64/wave32 gpu:amd Code is specific to AMD / RDNA / wave64 GPUs (scope tag; see needs:amd-test) needs-pr-check Failing the PR description check (CONTRIBUTING.md)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Recompiler: DXC 1.9's GVN makes a pixel shader that crashes AMD's compiler (amdxc64.dll+0x790849, RX 6750 XT)

2 participants