Skip to content

Shaders: keep annotateHandle local to its block to avoid AMD compiler crash - #317

Open
mynzjerko wants to merge 1 commit into
fxceless:mainfrom
mynzjerko:fix/amd-annotate-handle-reuse
Open

mynzjerko wants to merge 1 commit into
fxceless:mainfrom
mynzjerko:fix/amd-annotate-handle-reuse

Conversation

@mynzjerko

Copy link
Copy Markdown

Problem

On AMD RDNA 4 (tested on Radeon RX 9070, driver 32.0.32029.2010), CreateComputePipelineState crashes inside amdxc64.dll (0xC0000005 access violation, as reported in #3) on CS_RaytracingResolve variants when VICTORY_SHADER_OPT includes REUSE (4).

Bisecting VICTORY_SHADER_OPT isolated the crash specifically to REUSE deduplicating dx.op.annotateHandle across basic blocks in crates/victory-shader/src/emit/bitcode/opt.rs.

Fix

Classify dx.op.annotateHandle as Effect::Lanes in bitcode::opt::effect:

  • Each basic block keeps its own annotateHandle instead of reusing one from a dominating block across control flow.
  • Same-block reuse (so LOADS can still merge redundant reads within a block) and dead-code removal (DEAD) are preserved.
  • annotateHandle is a DXIL metadata annotation and emits no GPU instructions, so there is no runtime cost.

Verification

  • Added unit test an_annotated_handle_is_not_reused_across_blocks in crates/victory-shader/src/emit/bitcode/opt.rs.
  • cargo test -p victory-shader, cargo clippy -p victory-shader --all-targets -- -D warnings, and cargo xtask policy all pass.
  • Tested offline on AMD Radeon RX 9070 (Adrenalin 32.0.32029.2010) with full VICTORY_SHADER_OPT enabled:

AI-assisted (Antigravity / Gemini 4 Neon); verified locally on an AMD Radeon RX 9070 with my own copy of the title. Hashes and counts only; no game data.

@MamaLeVrai

Copy link
Copy Markdown

Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present. I merged this PR's head ed2c7fc into main f85101b in a throwaway tree (no conflict). cargo clippy --workspace --all-targets --locked -- -D warnings fails with exactly the errors main itself has on this machine (placed_filler_twins, depth_written, a sort; PR #841 fixes them); with --all-features it fails with the same number of errors as main (4). This PR adds none and removes none. cargo test --workspace --locked: run 1: one failure, run 2: 556 passed, 0 failed, 11 ignored (main alone: 555 passed, 11 ignored). The failure is indirect::tests::warp_budget_saturates_without_wraparound_and_preserves_draw_fields, which fails on main itself most runs here (PR #849 fixes its assertion; see issue #850). The title was not run, so this says nothing about in-game effect. No game data.

AI-assisted (Claude Code); no game data.

@mynzjerko

Copy link
Copy Markdown
Author

Thanks @MamaLeVrai for verifying this on RX 6950 XT against \ 85101b!

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.

2 participants