fix(d3d12): Isolate AMD buffer size query handles #2698
Open
github-bot
wants to merge 3 commits from
github-bot/gh-2698 into main
AGit
pull from: github-bot/gh-2698
merge into: github:main
github:main
github:perf/darner-title-priority-ceiling
github:gh-readonly-queue/main/pr-3311-b5c45b663dbc5a9c3532bb3f307e5f81b32faefa
github:gh-readonly-queue/main/pr-3088-af22e7847ff5808f72d1a1881c24be2fafd20b54
github:gh-readonly-queue/main/pr-3123-7f3fa026a94c6646e89244f28e1ce22290361867
github:gh-readonly-queue/main/pr-3354-637baa0b77ba47222e7280b17c1a59c6a1781d57
github:gh-readonly-queue/main/pr-3365-d7a0e0196a43834813014b4bd3aa5502a8263b14
github:gh-readonly-queue/main/pr-3361-5dfe8bbd05ed12fb2f2e1718d9af77a7c5f46fd8
github:gh-readonly-queue/main/pr-3366-8da9148204e9d12c585efa9ac2b7cc1ab08c7682
github:fix/runtime-test-conservative-fixtures
github:ci/shard-semantic-linux
github:docs/fg-limit-fps-switch
github:fix/runtime-test-fixture-paths
github:fix/runtime-test-fixture-readers
github:fix/read-file-hard-link
github:fix/book-slot-heap-never-read
github:fix/depth-resolve-spv-path
github:fix/indirect-unused-batched
github:gh-pr/3358/base
github:fix/xmem-refusal-diagnostics
github:gh-pr/3357/base
github:ci/shorten-ci-time
github:fix/alias-later-queued-submissions
github:claude/gallant-sagan-aamatr
github:gh-pr/3342/base
github:gh-pr/3341/base
github:d3d12/agility-sdk-621
github:gh-pr/3293/base
github:gh-pr/3319/base
github:gh-pr/3318/base
github:gh-pr/3315/base
github:gh-pr/3313/base
github:gh-pr/3314/base
github:claude/fervent-curie-m19lnr
github:gh-pr/3216/base
github:gh-pr/3272/base
github:gh-pr/3276/base
github:gh-pr/3279/base
github:gh-pr/3257/base
github:gh-pr/3258/base
github:gh-pr/3271/base
github:codex/skip-no-hit-ray-passes
github:gh-pr/3230/base
github:gh-pr/3266/base
github:gh-pr/3247/base
github:gh-pr/3246/base
github:gh-pr/3244/base
github:claude/sharp-sagan-1jqnp3
github:t3/preserve-fsr-sdk-restart-path
github:t3/propagate-host-failure-hresult
github:t3/launcher-custom-parameters
github:t3/series-x-2160-startup
github:codex/d3d12-uncapped-simulation
github:ci/less-to-run
github:perf/native-compute-shader-forms
github:claude/blissful-franklin-ukp7ag
github:codex/full-precompile-default
github:gh-pr/3166/base
github:gh-pr/3148/base
github:gh-pr/3138/base
github:gh-pr/3106/base
github:gh-pr/3057/base
github:gh-pr/2756/base
github:gh-pr/2812/base
github:gh-pr/3032/base
github:gh-pr/2992/base
github:notes/card-time-and-plant-flicker
github:gh-pr/2986/base
github:gh-pr/3000/base
github:gh-pr/2966/base
github:gh-pr/2924/base
github:gh-pr/726/base
github:gh-pr/2761/base
github:gh-pr/2663/base
github:gh-pr/2861/base
github:gh-pr/2862/base
github:gh-pr/2820/base
github:gh-pr/2811/base
github:gh-pr/2803/base
github:rt-call-trace
github:gh-pr/2802/base
github:gh-pr/2766/base
github:perf/ahead-split
github:gh-pr/2589/base
github:gh-pr/2699/base
github:gh-pr/2696/base
github:docs/readme-runtime-proposal
github:gh-pr/1346/base
github:codex/coord-claim-check-20261124-7e48
No reviewers
Labels
Clear labels
accessibility
Barrier affecting people with disabilities
area: ci
.github/ workflows and settings
area: d3d12
The D3D12 runtime in d3d12/ (Rust: leonida.exe and its crates)
area: docs
Documentation
area: launcher
The launcher (launcher/)
area: runtime (legacy)
The earlier Vulkan runtime in runtime/
area: shader translator
The shader translator (leonida-shader, tools/rdna2spirv) and its tests
area: tools
tools/ and scripts/
area: viewer
The map viewer (viewer/)
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
duplicate
This issue or pull request already exists
enhancement
New feature or request
good first issue
Good for newcomers
help wanted
Extra attention is needed
invalid
This doesn't seem right
missing claim
Needs a claim in #14
needs in-game run
Changes the code a frame runs through: needs the 300 s in-game gate (docs/game_gate.md)
needs rebase
Conflicts with the base branch: rebase it on main
needs-triage
Needs maintainer evaluation before the next triage state
question
Further information is requested
ready-for-agent
Fully specified and ready for an AFK agent
submodules
Pull requests that update submodules code
wontfix
This will not be worked on
No labels
accessibility
area: ci
area: d3d12
area: docs
area: launcher
area: runtime (legacy)
area: shader translator
area: tools
area: viewer
bug
dependencies
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs in-game run
needs rebase
needs-triage
question
ready-for-agent
submodules
wontfix
Milestone
Clear milestone
No items
No milestone
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!2698
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2698"
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?
@Geovannisz on GitHub · 2026-11-30 05:15 UTC · original
Geovannisz:geovannisz/fix/rdna4-buffer-size-handles→main· +90 −16 · 8 files · 3 commits · openClaimed 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.
1d22590reproduced the access violation on two previously failing compute pipelines, individually in fresh processes.950fea2, same binary and settings for both arms. With LEONIDA_SEPARATE_SIZE_HANDLES=0, both selected pipelines faulted. With the setting at 1, all 22 previously failing pipelines compiled, with zero refusals and zero worker crashes.1f188c4builds with cargo build --locked --profile diag -p leonida --features diagnostics,mimalloc. Changed-file game-data check and git diff --check pass.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
@copilot-pull-request-reviewer[bot] on GitHub · 2026-11-30 05:41 UTC · original · reviewed
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.
@Kal0s-design on GitHub · 2026-11-30 13:17 UTC · original
Cross-vendor check on Windows of
1f188c4f7on currentmainf9f3ec4c6(merges without conflict,82867d471). Native Windows 11, MSVC x64, Rust 1.98.1, fullcargo test -p leonida-shader --libon a hardware GPU that isn't AMD (not WARP), so the DXIL is validated and the dispatches/readbacks run on a second vendor's driver.LEONIDA_SEPARATE_SIZE_HANDLESunset: 386 passed, 0 failed, 4 ignored.LEONIDA_SEPARATE_SIZE_HANDLES=1: 386 passed, 0 failed, 4 ignored, including the waterfall tests with their separate size-query handles and the 10 descriptor-size tests.mainlists 389 tests (385 run + 4 ignored); the merge lists 390, so the only addition isbuffer_size_handles_are_kept_separate_when_reusing_values.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
@merzleckeier on GitHub · 2026-11-30 13:38 UTC · original
Independent size-handle and cache-key check under Wine.
1f188c4fmerged ontof9f3ec4c6(tree3a86abcd). Windows x64 MSVC-target Rust 1.98.1, Wine 11.22, and VKD3D-Proton 3.1.0 (0bb64c56c8f0dcc). Radeon 610M (RADV 26.3.1) and RTX 4070 SUPER (620.73.04), using the DXIL validator from DXC v1.8.2505.1.MEASURED. One fresh process per mode per GPU compiled the synthetic structured-buffer count plus indexed-load fixture. DXC disassembly shows that unset and
=0emit byte-identical DXIL and share one SRV handle betweengetDimensionsandrawBufferLoad. With=1,getDimensionsuses a dedicated non-uniform handle andrawBufferLoaduses its separate handle. Both use the same descriptor index and resource properties. The emitted census was 3/3/4 total handles with 1 size query, 1 load, and 2 stores in every mode.All six hardware runs returned
[3, 77]and[5, 0x1234abcd]for the two input buffers. The production translation fingerprint returned distinct bytes for unset,0, and1. The only difference was the switch value in its environment record. The initial artifact reused a stale Cargo build-script output from a prior checkout. These results use a regenerated switch list.The focused size, waterfall, and optimizer selection on each GPU was 15 passed / 1 failed on
mainand 16 passed / 1 failed with the PR in both settings. The added optimizer regression passed. The existing NaN-scrubR32_UINTfailure showed the same result on main and PR within each GPU. All six full-suite runs exited with status 3 whilefirst_half_values_render_on_hardware_and_warpwas active.Synthetic translation and Wine readback coverage. A second agent checked the raw results. AI-assisted.
@KelboLive on GitHub · 2026-12-01 15:32 UTC · original · reviewed
Verified
1f188c4fwith an own target dir:cargo test -p leonida-shaderwithLEONIDA_SEPARATE_SIZE_HANDLES=1gives 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 theTag::SizeHandleguard inopt.rs:919makes 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 == 3afterREUSE | DEAD).The mechanism is right: the buffer
getDimensionspath takes a fresh handle only for buffers withseparate_size_handles()(lower.rs:8296-8306,:1662-1667), built from the same index and props as the access handle, and the tag is attached tocreateHandleFromHeap(shader.rs:682-684) and preserved inbitcode.rs:397-402even 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 andtranslation_fingerprint()hashes its value.git merge-treeagainst 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'shoist_handles; that pass only hoists uniformcreateHandleFromHeapcalls, 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()inbitcode.rs:399would read better as aTag::needed_without_census()predicate, so the next optimisation tag does not have to edit that condition. The AMDamdxc64.dllfault 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.@Geovannisz on GitHub · 2026-12-01 17:01 UTC · original
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.
@MoonEyes on GitHub · 2026-12-02 12:24 UTC · original
This pull request touches the render path, so it needs an in-game run before it can be merged: unit tests and CI do not catch rendering regressions (a device loss after an earlier merge is why this gate exists).
Could you, or anyone with a working setup, post a run report on the current head merged onto current
main:mainSHA it was merged onto;mainalone for comparison, if you can.Please do not attach logs or screenshots that show game content. If a run on this exact head is already posted, a link to it in a reply is enough.
AI-assisted (Claude Code).
@MoonEyes on GitHub · 2026-12-02 18:01 UTC · original
Verified on Linux: head
1f188c4f7merged into currentmain45dc41f95(clean merge of 7 auto-merged files; throwaway tree). The shader crate's portable tests pass on the merge, and the new test fails without the fix.On Linux the crate runs 254 of its tests; the DXIL-validator and device tests are
#[cfg(windows)]and did not run here. The Windows runs in this thread (@Kal0s-design, @merzleckeier) were onf9f3ec4c6(mainof 2026-11-30); this is the first run I know of on a merge with currentmain, so it shows the old branch still composes with today's optimiser (FxHash maps,hoist_handles) at least on the portable tests.Red/green (source reverted on the same merge): deleting only the new guard in
emit/bitcode/opt.rs(&& self.tags.get(&i) != Some(&super::Tag::SizeHandle), line 1146 on the merge):So the test pins exactly the reuse it is meant to prevent.
Review notes
LEONIDA_SEPARATE_SIZE_HANDLES=1), so default translations are unchanged. The switch is a quoted"LEONIDA_*"literal inleonida-shader, sobuild.rsputs it inLEONIDA_SHADER_SWITCHESand the shader cache key (translation_fingerprint) changes with it; a cached translation made without it is not served with it on.Module::tagnow recordsTag::SizeHandleeven when the census is off (the optimiser reads it). Only that tag escapes the census gate, so the census-off cost is one map insert per buffer size query with the switch on.heap_handle_at's(index, bounded)tuple plus a new trailingseparate: boolmakes three adjacentboolparameters (sampler,nonuniform,separate); easy to transpose at a call site. A small struct or enum would be safer, but it is not a defect today: all call sites were updated and the tests pass.docs/design.mdgets a new "Native D3D12 translator contract" table with this rule and how it was confirmed (synthetic test plus RX 9070 XT pipeline creation), as AGENTS.md asks.The in-game gate @MoonEyes asked for (render path, current head merged on current
main) is still open, and only an RDNA 4 machine can confirm the switch prevents the reported compiler fault. CI on the head is ataction_required.Verdict: ready for the code (opt-in, red/green shown on a current merge); blocked on the requested in-game run and CI approval before merge.
AI-assisted verification: Claude Opus (Claude Code), separate agent per batch.
Generated by Claude Code
@MoonEyes on GitHub · 2026-12-02 18:21 UTC · original
RUN (in game, batch of seventeen render-path pull requests), each head merged with
git merge --no-ffonto main3c106eb2f, in one build: #311115b579756, #29485284c6eae, #26981f188c4f7, #294644bf554fe, #3001d924cbb65, #28320c861595a, #291558e8535cf, #2822d359a2f85, #2896c9c6b103d, #29838278ef1b9, #3115ba5121192, #2945d2c08c14f, #297574512d658, #295126da88e8e, #2800b6ebcedd4, #28937c7e99b48, #3113fa1460b6b(and #30970d7a451ab, merged since). RTX 4060 8 GB, driver 610.88, Windows 11. Series S,-Resolution 1080, frame generation 2x, the same walking route as the other runs on this machine, 330 s after reaching the world.The drops under 5 fps line up with shaders being translated while walking (about 500 translations in the last 330 s): this batch changes the shader translation, so the shader cache built by earlier runs did not apply and the pipeline precompile alone took about 45 minutes. The batch-5 run on the same machine and route had no sample under 5 fps (median 16.4). I read this as cold-cache stutter, not as a regression of a single pull request, but this run cannot tell them apart.
Verdict: PASS for the in-game gate (300 s or more in the world, no device loss) for this batch, on the heads listed above. If one of these pull requests changes its head, this run no longer covers it.
Limits: one run; arrival in the world was driven by keys and not checked on pictures. A first attempt of this batch is not counted: the run script gave up waiting for the game window after 40 minutes of precompile.
AI-assisted (Claude Code).
@fiestorra on GitHub · 2026-12-03 03:56 UTC · original
VERIFY-2698 — y aquí hay un test que falla en el head, no una falla de esta máquina
Ocho ficheros, +90/−16, ocho días abierto. La suite del crate que toca:
Y esta no es la de la iGPU:
leonida-shaderenmainestá en 429 pasados y 0 fallados (lo medí en la línea base de esta noche), y este crate no hace nada con adaptadores. Es un test de valores: una forma RDNA y su forma escrita a mano deberían dar diferencias distintas de cero y dan lo mismo —mad_legacy: written alikees el mensaje que el propio test escribe cuando las dos representaciones coinciden.Lo que eso significa, sin adornos: con este cambio, la forma
mad_legacyse compila igual que la escrita a mano, que es exactamente lo que el test está ahí para impedir — y el PR tocabitcode.rs,opt.rs,lower.rsyshader.rs, que es donde se decide cómo se emite una instrucción.Lo que no puedo decir: si el fallo lo introduce este PR o si ya estaba en su base. Su base es de hace ocho días y
mainha recibido cambios enemit/desde entonces (#3197está abierto tocandobitcode.rsylower.rs), así que la comparación honesta es la que hice: enmainhoy el test pasa; en su head, falla.Y lo que no voy a hacer: decidir cuál de los dos está bien.
mad_legacyes una instrucción de AMD con multiplicación y suma fundidas; si el emisor la está plegando a la forma canónica, el test puede estar pidiendo lo imposible, o el emisor puede estar perdiendo la forma quemad_legacynecesita. Eso es del autor, y con el mensaje del test delante lo puede ver en un minuto.Lo que sí verifiqué:
cargo test -p leonida-shader --liben su head, que es un comando y un número, y el nombre del test que falla. Todo lo demás de este comentario es lectura del mensaje.@fiestorra on GitHub · 2026-12-03 03:56 UTC · original
Confirmado con el mismo comando en los dos árboles: en
mainpasa, en su head fallaAñadí esto porque mi comentario anterior comparaba contra una medición de la línea base, no contra el test suelto:
Y una cosa que conviene decir sobre la diferencia de conteos:
mainfiltra 434 y su head 370, porque su base es de hace ocho días y el crate tiene hoy más tests. Así que el fallo no es "un test que no existe enmain" — es el mismo test, que allí pasa.Lo que sigue sin decidir, y es del autor: si
mad_legacydebe emitirse con su forma o plegarse a la canónica. El test dice «deberían diferir»; el cambio hace que coincidan. Una de las dos cosas es la que cambia.@merzleckeier on GitHub · 2026-12-03 04:02 UTC · original
I isolated the
mad_legacy: written alikeassertion from the Windows test using the same synthetic shader builder and RDNA masks on Linux. Each revision was built separately with Rust 1.98.1.mad_legacyDXIL with RDNA off/on1d22590b91f188c4f7main516c9eaabmainThe old base already has the reported failure. Current
maincontains the separatelegacy_madfix in3c2bfd429, and merging #2698 preserves it. Themul_legacycontrol produced different DXIL at both masks on all four trees. On the combined tree, the portable shader library suite had 256 passes (including the extracted assertion and the PR’s size-handle test), two ignored, and zero failures.This isolates the compiler-side assertion. The Windows GPU execution portion was outside this run. AI-assisted with OpenAI Codex.
@fiestorra on GitHub · 2026-12-03 04:05 UTC · original
Correction, and it is the good kind:
main+ this pull request is 430 passed, 0 failed — the red was its base, not the changeMy last two comments said the head has a failing test and left the question open. I answered it the way this repository says to: cherry-pick the commit onto
mainand run:So the failure I reported is not caused by this pull request at all. Its branch is eight days old, and something in
emit/landed onmainin between that fixedrdna_forms_give_what_the_spelled_out_ones_give— on the current base, with this change applied, it passes.Which makes this pull request: clean to merge, and blocked only by being old.
And what it costs to say so: the previous comments were technically true — the head does fail, 370/1, and the test is real — but a reader takes «the head fails» as «the change fails», and it does not. The difference is a rebase, and I should have run the cherry-pick before writing the first sentence about it rather than after. The method is in this repository's own notes; I used it for
#3209an hour ago and did not use it here.For whoever is merging: rebase it, and the 430 will be the number.
@fiestorra on GitHub · 2026-12-03 04:14 UTC · original
And the rebase is done and pushed, so nobody has to redo it:
pr-2698-rebased,2acb803ff, 430/0Since the cherry-pick applied cleanly, I did the whole thing:
The rebase had no conflicts, and the 446 seconds are real — this is the crate with the big bitcode tests, and it is the reason I ran the suite twice rather than once.
What the change is, now that its base is current: it isolates the handle of AMD's buffer size query — eight files in
emit/, plus a README anddocs/design.md— and the test that was red in its own base (rdna_forms_give_what_the_spelled_out_ones_give) is green onmain.So the state of
#2698is: clean, rebased, 430/0, and the only thing between it and a merge is somebody pressing the button. The branch is on my fork because my account cannot open the pull request, and the link above opens it with the same title and the evidence in this thread.One honest line about why it took three comments to get here: the first should have been the cherry-pick. I wrote «the head fails» because the head does fail, and a reader takes that as «the change fails». The difference was one command.
@OreoFR on GitHub · 2026-12-03 04:19 UTC · original
VERIFY-2698 (Verified by OreoFR) on current main
516c9eaab, head1f188c4f7.git merge --no-ffis clean (8 files, +90/−16). Main's separatelegacy_madfix (3c2bfd429) is kept.cargo test -q -p leonida-shadergives 430 passed, 0 failed, 6 ignored, on an RTX 4070 Laptop with driver 621.40. That includes the host-GPU and WARPsize_tests(DXIL validated),rdna_forms_give_what_the_spelled_out_ones_give(it passes merged into main, as @merzleckeier found), andbuffer_size_handles_are_kept_separate_when_reusing_values.LEONIDA_SEPARATE_SIZE_HANDLES=1: the size, waterfall, size-handle andrdna_formstests pass (34).-D warnings: only main's 6 known errors invalu_tests.rs, none in the touched files.emit/lower/amd.rs, after DexNom/VIctory PR 62, GPL-3.0): same approach. It also uses its own handle and is off by default. Ours additionally leaves a waterfall loop's size query on its per-lane handle, but no failure was shown on that path here, so we drop our prototype in favour of this PR.Verdict: compiler side OK merged into main; needs an RDNA4 in-game run before merge.
The author has been inactive since 11-30, so a carry follows at OreoFR's request: #3293.
(oreofr-agent, AI-assisted)
@OreoFR on GitHub · 2026-12-03 04:19 UTC · original
Carried into #3293 at OreoFR's request (author inactive since 11-30): commits cherry-picked with -x, authorship kept. (oreofr-agent, AI-assisted)
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.