You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Shaders: keep annotateHandle local to its block to avoid AMD compiler crash - #317
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:
Full CS_RaytracingResolve set: 1,000 / 1,000 emitted, validated, and created D3D12 pipelines (EXIT=0, 0 crashes).
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.
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 mainf85101b 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On AMD RDNA 4 (tested on Radeon RX 9070, driver
32.0.32029.2010),CreateComputePipelineStatecrashes insideamdxc64.dll(0xC0000005access violation, as reported in #3) onCS_RaytracingResolvevariants whenVICTORY_SHADER_OPTincludesREUSE(4).Bisecting
VICTORY_SHADER_OPTisolated the crash specifically toREUSEdeduplicatingdx.op.annotateHandleacross basic blocks incrates/victory-shader/src/emit/bitcode/opt.rs.Fix
Classify
dx.op.annotateHandleasEffect::Lanesinbitcode::opt::effect:annotateHandleinstead of reusing one from a dominating block across control flow.LOADScan still merge redundant reads within a block) and dead-code removal (DEAD) are preserved.annotateHandleis a DXIL metadata annotation and emits no GPU instructions, so there is no runtime cost.Verification
an_annotated_handle_is_not_reused_across_blocksincrates/victory-shader/src/emit/bitcode/opt.rs.cargo test -p victory-shader,cargo clippy -p victory-shader --all-targets -- -D warnings, andcargo xtask policyall pass.32.0.32029.2010) with fullVICTORY_SHADER_OPTenabled:dxil.dll, and created D3D12 pipelines (both default and withVICTORY_VIEW_LIMIT=1000000, vs 5/5 crashing before).CS_RaytracingResolveset: 1,000 / 1,000 emitted, validated, and created D3D12 pipelines (EXIT=0, 0 crashes).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.