Repository navigation
fix(d3d12): Isolate AMD buffer size query handles - #2698
Geovannisz wants to merge 3 commits into
Conversation
Add an opt-in DXIL workaround for an AMD shader compiler crash during pipeline creation. Keep the size query's heap handle separate when reusing values and allow the writer to discard unused queries. Adapt the approach from imjustprism's Marvisak/VIctory#2122 to Mandy's descriptor and raw-view paths. Refs ProjectLeonida#2570 Co-authored-by: OpenAI Codex <noreply@openai.com>
Keep the opt-in size-handle setting in one resolver and include its conservatively non-uniform temporary handle in pre-cleanup counters. GPU readback and wave-operation assertions remain in place. Co-authored-by: OpenAI Codex <noreply@openai.com>
Count dedicated size-query handles separately in test metadata so waterfall assertions continue checking the per-lane resource handles. This covers programs that emit several unused size queries before dead-code cleanup. Co-authored-by: OpenAI Codex <noreply@openai.com>
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
|
Cross-vendor check on Windows of
So on this driver the opt-in changes no result, and leaving it off changes nothing either. That fits it being a workaround for the AMD compiler only. The 8 WARP-only failures in the description don't appear on hardware here in either mode. I can't reproduce the AMD fault itself, nor the standalone structured-buffer readback case. AI-assisted: yes |
|
Independent size-handle and cache-key check under Wine. MEASURED. One fresh process per mode per GPU compiled the synthetic structured-buffer count plus indexed-load fixture. DXC disassembly shows that unset and All six hardware runs returned The focused size, waterfall, and optimizer selection on each GPU was 15 passed / 1 failed on Synthetic translation and Wine readback coverage. A second agent checked the raw results. AI-assisted. |
KelboLive
left a comment
There was a problem hiding this comment.
Verified 1f188c4f with an own target dir: cargo test -p leonida-shader with LEONIDA_SEPARATE_SIZE_HANDLES=1 gives 371 passed / 0 failed / 4 ignored, and the waterfall (22) and descriptor (21) subsets pass with the switch both on and unset. The separation is genuinely tested: deleting the Tag::SizeHandle guard in opt.rs:919 makes the new regression fail with the size query merged into the memory-access handle ([[Inst(0), Inst(0)]] vs [[Inst(0), Inst(1)]]), and the dead-query case still drops (body == 3 after REUSE | DEAD).
The mechanism is right: the buffer getDimensions path takes a fresh handle only for buffers with separate_size_handles() (lower.rs:8296-8306, :1662-1667), built from the same index and props as the access handle, and the tag is attached to createHandleFromHeap (shader.rs:682-684) and preserved in bitcode.rs:397-402 even with the census off, so it can neither be reused nor absorb a later access. The fingerprint claim checks out too: the build script's switch list contains the name and translation_fingerprint() hashes its value.
git merge-tree against current main is clean, and on the merged tree the regression plus the waterfall/descriptor subsets pass. The branch is now 1027 commits behind and main has gained #2687's hoist_handles; that pass only hoists uniform createHandleFromHeap calls, and these handles are emitted non-uniform, so the contract still holds — worth a sentence in the body so the interaction is on record.
One nit: tag == Tag::SizeHandle || census::enabled() in bitcode.rs:399 would read better as a Tag::needed_without_census() predicate, so the next optimisation tag does not have to edit that condition. The AMD amdxc64.dll fault and the 22-pipeline result cannot be reproduced here (no RX 9070 XT, no game data); the DXIL-level evidence above is what this machine can check.
|
Thanks @KelboLive for the independent verification and for checking the regression by removing its guard. I added the interaction with #2687's hoist_handles pass to the PR description after checking the current main source. The dedicated handles carry the non-uniform flag, which excludes them from its uniform-handle eligibility check. Your Tag::needed_without_census() suggestion is noted as a readability improvement. The RX 9070 XT measurements remain scoped to the pinned offline A/B and the earlier warm run described in the PR. AI-assisted: OpenAI Codex. |
Claimed in the coordination issue as D3D12-RDNA4-BUFFER-SIZE-HANDLE.
What and why
On my RX 9070 XT, AMD's DXIL compiler faults during compute pipeline creation. LEONIDA_SEPARATE_SIZE_HANDLES=1 makes the native translator emit a dedicated heap handle for buffer-size queries. The reuse pass keeps it separate from memory-access handles. Dead-code removal can still discard unused queries. Both handles address the same view.
The setting is opt-in and participates in the translation-cache fingerprint. The README explains activation and retrying keys recorded as bad by an earlier warm run. The native translator contract is documented in docs/design.md.
This adapts imjustprism's approach in Marvisak/VIctory#2122 to Mandy's lowering and optimiser. It is independent of #2694, which serializes concurrent driver calls. My reproducer uses one pipeline per fresh process.
Compatibility with #2687's handle hoisting was checked in the current main source. The hoist_handles eligibility check accepts only uniform createHandleFromHeap calls. This workaround emits dedicated size-query handles with the non-uniform flag set, so they are excluded from that pass. KelboLive independently tested the merged tree and reported passing regression and waterfall/descriptor subsets.
Tested
MEASURED locally. Profile M, Radeon RX 9070 XT 16 GB desktop, driver 32.0.32029.2010, Windows 11 build 26300, Rust 1.98.1, MSVC x64.
GPUs tested: AMD Radeon RX 9070 XT, driver 32.0.32029.2010, Windows 11 build 26300. WARP used for synthetic readback tests.
AI-assisted: OpenAI Codex. The hardware and crash report are mine. The commit author is Geovanni (@Geovannisz), with Codex assistance recorded and prior VIctory work credited.
Checklist