fix(shader): keep size queries, index clamps, and buffer size handles distinct on RDNA4 (#163) #258
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/TaynanGT--Vice-Tay!258
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-258"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Vladimir-Human on GitHub · 2026-11-27 12:40 UTC · original
Vladimir-Human:fix/rdna4-size-query-compiler-crash-163→main· +672 −11 · 7 files · 7 commits · merged 2026-11-27 16:19 UTCSummary
Fixes the three DXIL lowering and optimisation patterns in
victory-shaderthat triggeramdxc64.dll+0x861b9f(null read duringCreateComputePipelineStateon AMD RDNA4, driver32.0.32029.2010, #163):dx.op.getDimensions(crates/victory-shader/src/emit/bitcode/opt.rs):Module::key()now returnsNoneforgetDimensionscalls, so neitherREUSEnorLOADSmerges one size query into an earlier dominating one (and futureLICM+REUSEpasses cannot coalesce them either).Effect::Pureis preserved soDEADstill eliminates unused size queries. Adapted fromBelobug/VIctory-Belobug-AMD#324(4eb6cfd).crates/victory-shader/src/emit/bitcode.rs,opt.rs):Module::tag()now recordsTag::Clampunconditionally (not only whencensusis enabled), andModule::key()returnsNoneforTag::Clampinstructions. This keepsVICTORY_VIEW_LIMITandraw_twinUMinclamps one per handle soREUSEcannot share a single clamped index across handles of different kinds (explaining why settingVICTORY_VIEW_LIMIT=2097152reproduces #163 offline and why porting a separate size handle alone without clamp separation still failed). Adapted fromfxceless/victory-fork#984.crates/victory-shader/src/emit/shader.rs,lower.rs):descriptor_datanow asks a buffer's size (image.is_none() && !waterfall.loads.contains(&site)) throughShader::size_handle_at, emittingcreateHandleFromHeap(..., false, true)afterraw_twinlookup and bypassing the per-blockself.handlescache so buffer loads keep their uniform handle. It does not incrementnonuniform_handlesand emits nowaveReadLaneFirst/WAVE_OPS, keeping pixel shaders helper-lane safe and waterfall loops unchanged. Adapted fromfxceless/victory-fork#1213(#452) forVice-Tay'sraw_twin/heap_handle_atpath.crates/victory-shader/src/lib.rs): rebased onto877a40eand bumpedTRANSLATOR_VERSIONfrom9to10so cached shaders rebuild cleanly without colliding withmain's9.Attribution
dx.op.getDimensionsnon-reuse: adapted fromBelobug/VIctory-Belobug-AMD#324(4eb6cfd).Tag::Clamppreservation acrossREUSE: adapted fromfxceless/victory-fork#984.size_handle_at) and branched buffer-size reproducer: adapted fromfxceless/victory-fork#1213(#452) forVice-Tay'sraw_twinpath.Verification
emit::bitcode::opt::tests):a_size_query_is_not_reusedandclamped_indices_are_not_reusedverify both in-block and cross-block non-reuse acrossopt = 0,REUSE,REUSE | LOADS, andALL, while verifyingDEADstill removes unusedgetDimensionsandTag::Clampinstructions.dxil.dll+dxc -dumpbin+ D3D12 HW/WARP tests (emit::size_tests):a_buffer_size_query_uses_its_own_nonuniform_handle_and_clamps: testsopt = 0/DEFAULT/ALL,VIEW_LIMIT = 0/2_097_152,raw_views = 0/4, compute and pixel stages; verifies distinct%dx.types.Handlevalues (nonUniform = truevsfalse), distinctUMinclamp indices underVIEW_LIMIT,wave_ops == falseandnonuniform_handles == 0,dxil.dllvalidation, and exact execution results on D3D12 hardware and WARP.branched_buffer_size_read_as_number_compiles_with_view_clamp: validates and compiles the branched buffer-size compute shader underVIEW_LIMIT = 2_097_152on D3D12 hardware and WARP.two_image_resinfo_queries_stay_distinct_with_and_without_opt: verifies twoimage_get_resinfocalls across a branch remain 2 distinct@dx.op.getDimensionscalls afterDEFAULT/ALLoptimisation and return[10, 6]on D3D12 hardware and WARP.c788768(VICTORY_D3D12_DEBUG=1,--test-threads=1, Windows SDK10.0.26100.0dxil.dll+dxc.exe, D3D12 hardware + WARP):cargo clippy -p victory-shader --all-targets --locked -- -D warnings(default and--all-features): 0 warningsemit::size_tests,emit::bitcode::opt::tests,emit::bitcode::tests,emit::waterfall_tests,emit::lower::tests): 58 passed; 0 failed; 2 ignored (0D3D12 debug errors)VICTORY_WARP=1, CI mode withoutVICTORY_D3D12_DEBUG):emit::size_tests12 passed; 0 failedcargo run -p xtask --locked -- policy: asset policy: 313 files ok;cargo test -p xtask --locked: 11 passed; 0 faileddxil.dll/dxc.exe). Ready for RDNA4 confirmation on #163 (translate --validate --pipelines --jobs 1withVICTORY_VIEW_LIMIT=2097152and in-game boot).Refs #163
@TaynanGT on GitHub · 2026-11-27 12:47 UTC · original
@Vladimir-Human The three paths need independent coverage: repeated dimension queries, clamps attached to each handle and the dedicated size handle. Please keep the current cache-version change tied to the emitted code. The existing RDNA4 result gives us the driver context, while the synthetic DXIL checks can establish the intended lowering.
@Vladimir-Human on GitHub · 2026-11-27 12:59 UTC · original
@TaynanGT Thanks — here is the line-by-line mapping for the three independent paths and their synthetic DXIL tests:
dx.op.getDimensionsnon-reuse:crates/victory-shader/src/emit/bitcode/opt.rs:758-766(Module::keyreturnsNonewhile keepingEffect::PureforDEAD), covered byemit::bitcode::opt::tests::a_size_query_is_not_reused(opt.rs:1528, same-block + diamond cross-block + DCE under0/REUSE/REUSE | LOADS/ALL) andemit::size_tests::two_image_resinfo_queries_stay_distinct_with_and_without_opt(size_tests.rs:823,dxc -dumpbinconfirming 2 distinct@dx.op.getDimensionscalls afterDEFAULT/ALL+ HW/WARP[10, 6]).Tag::Clampseparation:crates/victory-shader/src/emit/bitcode.rs:383-388(unconditionalTag::Clamprecording) +crates/victory-shader/src/emit/bitcode/opt.rs:732-734(Module::keyreturnsNone), covered byemit::bitcode::opt::tests::clamped_indices_are_not_reused(opt.rs:1577, same-block + cross-block + DCE) anddxc -dumpbindistinctUMinclamp-index checks underVIEW_LIMIT=2_097_152insize_tests.rs:647-663.crates/victory-shader/src/emit/shader.rs:538-546(Shader::size_handle_at) +crates/victory-shader/src/emit/lower.rs:7394-7400(descriptor_data, preservingraw_twinwithoutwave_opsornonuniform_handlesincrement), covered byemit::size_tests::a_buffer_size_query_uses_its_own_nonuniform_handle_and_clamps(size_tests.rs:556, CS + PS,opt=0/DEFAULT/ALL,VIEW_LIMIT=0/2_097_152,raw_views=0/4,dxc -dumpbin+ HW/WARP) andemit::size_tests::branched_buffer_size_read_as_number_compiles_with_view_clamp(size_tests.rs:700).Confirmed:
TRANSLATOR_VERSION = 9(crates/victory-shader/src/lib.rs:29) stays strictly tied to the emitted code on this commit (a4788df).@TaynanGT on GitHub · 2026-11-27 13:08 UTC · original
@Vladimir-Human The distinct size calls and per-handle clamp checks cover the emitted-code differences. The CS and PS synthetic tests also verify that the size handle remains separate from the load handle. I’ll keep that result tied to this exact translator revision and cache.
a4788dfb9atoc788768efc@Vladimir-Human on GitHub · 2026-11-27 14:02 UTC · original
@TaynanGT Rebased onto latest
main(877a40e) asc788768and bumpedTRANSLATOR_VERSIONfrom9to10(crates/victory-shader/src/lib.rs) so shader caches rebuild cleanly without colliding withmain's9.All 4 GitHub CI checks (
Clippy,Default tests,Diagnostics tests,check) are green and the branch isMERGEABLE/CLEAN.@KingKaom on GitHub · 2026-11-27 14:08 UTC · original
RDNA4 verdict from the crash machine: this fix clears the fault at the previously-named pipeline — the clamped combined scan now runs past it (RX 9070 XT, driver 32.0.32029.2010, measured)
We ran PR head
a4788dfthrough the exact offline scan that reproduced the crash in our two #163 reports — same clamped host settings (VICTORY_HOST_RDNA=1,VICTORY_HOST_WAVE=32,VICTORY_VIEW_LIMIT=2097152),translate --validate --pipelines --jobs 1, cold store, diagnostics executable rebuilt from this head with the fingerprint wipe and executable identity proven by size/mtime.Against the
6b3a266baseline:Baseline: the program stream ended at 21,397 pipeline creations; the last line emitted was
creating offline D3D12 pipeline shader_hash=878933b499cfa14d stage=Cs, and WER recorded0xc0000005atamdxc64.dll+0x861b9f(same offset as ona51fb9d).This head: the same
878933b499cfa14dcompute pipeline is created and the very next program's container is read ~0.19 s later; zero exceptions, and the scan continues through the remaining census.This head then completed the entire census without crashing: 26,180/26,180 programs translated, and every emitted program got both a DXIL validation and a pipeline creation — 14,262 vertex/pixel, 2,759 compute, 8,694 mesh — zero
amdxc64.dllfaults and zero Windows error-reporting events for the run. (The 71 vertex-output-size and 2 shared-memory validator complaints are the same tail validator reports our two completed tip scans produced on #163 — reports, not crashes.)On this machine, this is the first head that clears the pipeline-creation crash end to end.
Scope note: this validates the offline pipeline-creation path under the clamped settings that reproduce #163. The in-game boot on this head has not been run on this machine yet (the pre-fix tip reproduced the identical fault signature in boot, per #163).
AI-assisted (Hermes Agent)
@TaynanGT on GitHub · 2026-11-27 14:11 UTC · original
@Vladimir-Human
c788768has four green checks. Use a cache directory unique to that commit for the RDNA4 confirmation, since #287 and #289 also declare translator version 10. I’ll tie the hardware result back to #163 before changing the default.@TaynanGT on GitHub · 2026-11-27 14:25 UTC · original
@KingKaom The completed 26,180-program scan confirms the offline fix on
a4788df. The laterc788768rebase adds loop-latch lowering from main, so I’m keeping the hardware result tied to the tested revision. A normal launch on the newer candidate through the first world load would close the remaining check.@KingKaom on GitHub · 2026-11-27 15:28 UTC · original
RDNA4 boot result from the crash machine: a normal launch through first world load passes on
c788768(RX 9070 XT, RDNA4, measured)Closing the check you asked for on this thread's newest candidate. Ran
c788768(the877a40erebase head, translator version 10) as a normal launch through first world load on the RDNA4 box that reproduced #163 at boot:17,166,848bytes).VICTORY_HOST_RDNA=1,VICTORY_HOST_WAVE=32,VICTORY_VIEW_LIMIT=2097152— the game's own host lines read wave lanes min=32 max=64 and 2,097,152 views, same as the crashing runs).0xc0000005, zero breakpad crash files, no Windows error-reporting events for the run. For contrast, the pre-fix tip boot on this machine died ~6 minutes in (see #163).Happy to post the in-game screenshot if useful.
Combined with the completed 26,180-program offline scan we reported earlier on this PR, both the offline pipeline-creation leg and now the in-game first world load pass on
c788768on this box.AI-assisted (Hermes Agent)
@TaynanGT on GitHub · 2026-11-27 15:32 UTC · original
@KingKaom The 9.5-minute run through the first world load confirms the normal launch on
c788768. The render and output counts are useful context for that exact build. I’m bringing the compiler fix onto current main and assigning a fresh cache version so the combined build regenerates its translations.@KingKaom on GitHub · 2026-11-27 16:10 UTC · original
RDNA4 result for the combined build:
ff27527(this PR's head on main16edfec, fresh cache version) boots clean through first world load — RX 9070 XT, measuredFollowing the note about bringing the fix onto current main: the current head here is exactly that combination (0 behind / 4 ahead of main, including the fresh-shader-cache commit), and this box just ran it as a normal launch with the same recipe used for the
c788768run above, so the numbers are comparable.ff27527with the fingerprint wipe, identity proven by size/mtime before and after (17,166,848at 07:46 ->17,331,712at 08:52, a real 47 s recompile). The fresh cache version took effect: the store was empty for this head and the game translated 4,753 shader programs during the run itself.0xc0000005, zero breakpad/panic lines in the whole run log, and no new Windows Error Reporting events for the game between just before launch and after exit.So the compiler fix and current main coexist on this machine: clean first-world-load behavior on today's main with regenerated translations, no recurrence of the fault this PR fixes. Happy to re-run if the head moves again before merge.
Tested on RX 9070 XT (RDNA4), measured. AI-assisted (Hermes Agent).
@TaynanGT on GitHub · 2026-11-27 16:17 UTC · original
@KingKaom Thanks for putting 16 minutes into the first-world-load check on
ff27527. That confirms the fix on the16edfecbase. The current head is17da1d0with translator version 14, and all four Windows checks passed there. Please repeat the first world load on that head with a fresh shader cache so the hardware result matches the revision we’d merge.@KingKaom on GitHub · 2026-11-27 16:49 UTC · original
Main
e7bfd07(with #258 squashed in) boots clean on the crash machine — RX 9070 XT, fresh v14 shader cacheRepeating the first-world-load on the merged revision as asked, with a fresh cache. Setup: diag build at
e7bfd07(fingerprint-wiped rebuild, exe SHA-256578B9EA0…), the shader store was purged and warmed offline withvictory translate(same host settings the title runs with: wave 32–64, view heaps 2,097,152) before boot.15-minute scripted run (two Enters, a ~4-minute walk route): the world rendered at both overlay reads — t+9 min: 17.4 render fps / 57.3 ms / 8,709 draws / 332 dropped, VRAM 9.9/11.5 GiB + 5.2 shared; t+15 min: 19.2 fps / 52.0 ms / 8,756 draws / 314 dropped, VRAM 10.6/12.8. Zero
c0000005/ breakpad / panic lines and no new WER entries; the bench timer ended the session.One data point from our side: after a full offline warm (14,262 VS/PS + 2,761 CS + 8,765 mesh programs written to the store before boot), the title still logged 3,629
shader translatedlines in-run. Is that line printed on cache hits too, or are those entries outside what the offline translate writes? (One sample here; the pre-warm boot offf27527logged 4,753.)Tested on RX 9070 XT (RDNA4), measured. AI-assisted (Hermes Agent)
@TaynanGT on GitHub · 2026-11-27 16:58 UTC · original
@KingKaom Yes,
shader translatedone7bfd07also counts disk-cache hits.Shader::translated()logs that line the first time each shader is prepared in the process, afterhost_shader()returns successfully. The cache’s hit and miss counters are the ones to use for warm-up coverage. Your 15-minute first-world-load run also confirms the merged v14 fix on the RX 9070 XT. Pretranslation freshness is tracked in #325.@KingKaom on GitHub · 2026-11-27 17:26 UTC · original
RDNA4 confirmation for
f386fc9(main head, incl. the pretranslation freshness merge): clean 15m10s through first world load — RX 9070 XT, measuredRepeating the first-world-load recipe on the current head with a fresh shader store warmed offline before boot (same host settings: wave 32–64, view heaps 2,097,152; fingerprint-wiped diagnostics build).
hits=3596 misses=38. The 3,636 in-runshader translatedlines match cache-hit preparations, so warm coverage on the used shader set is ~99% — the freshness change did not regress warm behavior on this machine.AI-assisted (Hermes Agent)
@TaynanGT on GitHub · 2026-11-27 17:29 UTC · original
@KingKaom The 3,596 hits and 38 misses put the cache-hit share at about 99% for the shaders used in this run. That’s the coverage number to use.
f386fc9confirms the RDNA4 world load with #325’s pretranslation check in place.