d3d12 translator: a buffer's size through its own handle on AMD (carry of #2698, D3D12-AMD-SIZE-HANDLE-CARRY) #3293

Manually merged
github merged 5 commits from github-bot/gh-3293 into gh-pr/3293/base 2026-12-03 14:27:39 +00:00 AGit
Owner

@⁠OreoFR on GitHub · 2026-12-03 04:18 UTC · original
OreoFR:carry/amd-size-handle → main · +91 −16 · 9 files · 5 commits · merged 2026-12-03 14:17 UTC

Carry of #2698 by @⁠Geovannisz. Item: D3D12-AMD-SIZE-HANDLE-CARRY, claimed in #2570. The author has been inactive since 2026-11-30, and this is carried at OreoFR's request. All three commits are cherry-picked with -x, authorship kept.

Why

On RDNA4 (Radeon RX 9070 / 9070 XT), AMD's DXIL compiler can crash inside amdxc64.dll+0x861b9f (read at 0x8) while building a pipeline, before the first frame:

  • #2785 reports it;
  • an RX 9070 player hit the same address again today.

#3222 guards the crash after it happens. This change aims at its cause: a buffer's getDimensions sharing a heap handle with that buffer's loads.

What it does (unchanged from #2698)

With LEONIDA_SEPARATE_SIZE_HANDLES=1, a buffer's size query in Lower::descriptor_data gets its own heap handle to the same view, at the same index and raw twin.

  • The reuse pass keeps that handle apart from loads and stores (Tag::SizeHandle), and dead queries are still removed.
  • Off by default, as in #2698.
  • The shader cache keys on the switch (LEONIDA_SHADER_SWITCHES).
  • Changing the translator's sources means the first start after this retranslates everything.

What changed vs #2698

  • Rebase: onto main 516c9eaab, with no conflicts. Main's separate legacy_mad fix (3c2bfd429) is kept. The failing rdna_forms_give_what_the_spelled_out_ones_give on #2698's old base comes from that base, and it passes here.
  • Nothing added. Our Darner-derived prototype (Darner emit/lower/amd.rs, after DexNom/VIctory PR 62, GPL-3.0-or-later) does the same thing behind its own switch. It also leaves the size query of a waterfall loop on its per-lane handle; #2698 does not exempt that case. With the switch on, the waterfall and size tests pass here, so no gap was shown and nothing was added. A reviewer with an RDNA4 card may want to look at that path.

Tested

RTX 4070 Laptop 8 GB, driver 621.40, Windows 11; the tree is identical to #2698 merged into main 516c9eaab.

  • cargo test -q -p leonida-shader: 430 passed, 0 failed, 6 ignored. That includes the host-GPU and WARP size_tests (DXIL validated), rdna_forms_give_what_the_spelled_out_ones_give, and buffer_size_handles_are_kept_separate_when_reusing_values.
  • With LEONIDA_SEPARATE_SIZE_HANDLES=1: the size_tests, waterfall, size-handle and rdna_forms tests pass, 34 of them.
  • cargo clippy -p leonida-shader --all-targets -- -D warnings: only the 6 errors main already has in valu_tests.rs, none in the touched files.
  • scripts/check_no_game_data.py on the changed files: OK.

Needs: an in-game run on an RDNA4 card before merge. We have none here; the RX 9070 player could run a build with LEONIDA_SEPARATE_SIZE_HANDLES=1. According to #2698's docs/design.md entry, it was also confirmed by offline native pipeline compilation on an RX 9070 XT (driver 32.0.32029.2010).

AI-assisted (oreofr-agent, Claude Code).

🤖 Generated with Claude Code

**@⁠OreoFR** on GitHub · 2026-12-03 04:18 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/3293) `OreoFR:carry/amd-size-handle` → `main` · +91 −16 · 9 files · 5 commits · merged 2026-12-03 14:17 UTC Carry of #2698 by @⁠Geovannisz. Item: **D3D12-AMD-SIZE-HANDLE-CARRY**, claimed in #2570. The author has been inactive since 2026-11-30, and this is carried at OreoFR's request. All three commits are cherry-picked with `-x`, authorship kept. ## Why On RDNA4 (Radeon RX 9070 / 9070 XT), AMD's DXIL compiler can crash inside `amdxc64.dll+0x861b9f` (read at 0x8) while building a pipeline, before the first frame: - #2785 reports it; - an RX 9070 player hit the same address again today. #3222 guards the crash after it happens. This change aims at its cause: a buffer's `getDimensions` sharing a heap handle with that buffer's loads. ## What it does (unchanged from #2698) With `LEONIDA_SEPARATE_SIZE_HANDLES=1`, a buffer's size query in `Lower::descriptor_data` gets its own heap handle to the same view, at the same index and raw twin. - The reuse pass keeps that handle apart from loads and stores (`Tag::SizeHandle`), and dead queries are still removed. - **Off by default**, as in #2698. - The shader cache keys on the switch (`LEONIDA_SHADER_SWITCHES`). - Changing the translator's sources means the first start after this retranslates everything. ## What changed vs #2698 - **Rebase:** onto main `516c9eaab`, with no conflicts. Main's separate `legacy_mad` fix (3c2bfd429) is kept. The failing `rdna_forms_give_what_the_spelled_out_ones_give` on #2698's old base comes from that base, and it passes here. - **Nothing added.** Our Darner-derived prototype (Darner `emit/lower/amd.rs`, after DexNom/VIctory PR 62, GPL-3.0-or-later) does the same thing behind its own switch. It also leaves the size query of a waterfall loop on its per-lane handle; #2698 does not exempt that case. With the switch on, the waterfall and size tests pass here, so no gap was shown and nothing was added. A reviewer with an RDNA4 card may want to look at that path. ## Tested RTX 4070 Laptop 8 GB, driver 621.40, Windows 11; the tree is identical to #2698 merged into main `516c9eaab`. - `cargo test -q -p leonida-shader`: 430 passed, 0 failed, 6 ignored. That includes the host-GPU and WARP `size_tests` (DXIL validated), `rdna_forms_give_what_the_spelled_out_ones_give`, and `buffer_size_handles_are_kept_separate_when_reusing_values`. - With `LEONIDA_SEPARATE_SIZE_HANDLES=1`: the `size_tests`, waterfall, size-handle and `rdna_forms` tests pass, 34 of them. - `cargo clippy -p leonida-shader --all-targets -- -D warnings`: only the 6 errors main already has in `valu_tests.rs`, none in the touched files. - `scripts/check_no_game_data.py` on the changed files: OK. **Needs: an in-game run on an RDNA4 card before merge.** We have none here; the RX 9070 player could run a build with `LEONIDA_SEPARATE_SIZE_HANDLES=1`. According to #2698's `docs/design.md` entry, it was also confirmed by offline native pipeline compilation on an RX 9070 XT (driver 32.0.32029.2010). AI-assisted (oreofr-agent, Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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 #2570
Co-authored-by: OpenAI Codex <[email protected]>

(cherry picked from commit 950fea2243)
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 <[email protected]>
(cherry picked from commit d93d4d888f)
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 <[email protected]>
(cherry picked from commit 1f188c4f7a)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-03 04:25:22 +00:00
test_d3d12_switches failed in CI on both jobs: the carried switch was not in
the tracked page. Regenerated with tools/d3d12_switches.py --out; --check
and tests/test_d3d12_switches.py pass.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Owner

@⁠fiestorra on GitHub · 2026-12-03 04:33 UTC · original

VERIFY-3293 — el carry de #2698, verificado otra vez sobre la base actual: 430/0/6

Es el mismo cambio, reabierto por OreoFR para que no dependa de una rama de ocho días:

head fae5bd4b5 · diff vs main: 8 files changed, 90 insertions(+), 16 deletions(-)
cargo test -p leonida-shader --lib
  430 passed; 0 failed; 6 ignored   (450 s)

Los mismos números que medí en #2698 con el cherry-pick (430/0/6) y en la rama que rebasé (2acb803ff, 430/0/6). Tres caminos, un resultado — y eso es lo que hace que valga la pena decirlo: la corrección de mi comentario anterior no era un artefacto de cómo rebasé yo.

Lo que este carry resuelve de verdad: #2698 estaba abierto contra una base de hace ocho días, y el rojo de su propia rama (rdna_forms_give_what_the_spelled_out_ones_give) hacía que pareciera roto. Reabrir sobre main elimina la pregunta entera — el rojo no aparece, y nadie tiene que leer tres comentarios míos para descubrir que era la rama.

Y una cosa que ahora se puede decir con el carry delante: #3294 — "Test RDNA legacy MAD lowering without a GPU" — aparece a la vez, y su test nuevo se llama rdna_legacy_mad_uses_distinct_dxil. Es exactamente la pregunta que dejé abierta en #2698 («¿debe mad_legacy emitirse con su forma o plegarse a la canónica?»): la respuesta es un test que compara el DXIL de las dos formas y exige que difieran. Así que los dos PRs son el mismo trabajo, uno con el cambio y otro con la prueba.

Si los dos entran juntos, #2698 puede cerrarse el mismo día — y lo digo porque su contenido está aquí, no porque lo haya decidido yo.

**@⁠fiestorra** on GitHub · 2026-12-03 04:33 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/3293#issuecomment-7367773835) ## VERIFY-3293 — el *carry* de `#2698`, verificado otra vez sobre la base actual: 430/0/6 **Es el mismo cambio, reabierto por OreoFR para que no dependa de una rama de ocho días**: ``` head fae5bd4b5 · diff vs main: 8 files changed, 90 insertions(+), 16 deletions(-) cargo test -p leonida-shader --lib 430 passed; 0 failed; 6 ignored (450 s) ``` **Los mismos números que medí en `#2698` con el cherry-pick (430/0/6) y en la rama que rebasé (`2acb803ff`, 430/0/6).** **Tres caminos, un resultado** — **y eso es lo que hace que valga la pena decirlo: la corrección de mi comentario anterior no era un artefacto de cómo rebasé yo.** **Lo que este *carry* resuelve de verdad**: **`#2698` estaba abierto contra una base de hace ocho días**, **y el rojo de su propia rama (`rdna_forms_give_what_the_spelled_out_ones_give`) hacía que pareciera roto.** **Reabrir sobre `main` elimina la pregunta entera** — **el rojo no aparece, y nadie tiene que leer tres comentarios míos para descubrir que era la rama.** **Y una cosa que ahora se puede decir con el *carry* delante**: **`#3294` — *"Test RDNA legacy MAD lowering without a GPU"* — aparece a la vez**, **y su test nuevo se llama `rdna_legacy_mad_uses_distinct_dxil`.** **Es exactamente la pregunta que dejé abierta en `#2698`** (*«¿debe `mad_legacy` emitirse con su forma o plegarse a la canónica?»*): **la respuesta es un test que compara el DXIL de las dos formas y exige que difieran.** **Así que los dos PRs son el mismo trabajo, uno con el cambio y otro con la prueba.** **Si los dos entran juntos, `#2698` puede cerrarse el mismo día** — **y lo digo porque su contenido está aquí, no porque lo haya decidido yo.**
Author
Owner

@⁠merzleckeier on GitHub · 2026-12-03 04:38 UTC · original · reviewed

Verified the switch catalog follow-up at 2abd0c4c. The old head fae5bd4b fails with missing from the page: LEONIDA_SEPARATE_SIZE_HANDLES. The new head passes all 20 catalog tests and --check. With #3270 applied, all 21 tests pass, including the header count check. #3294 also merges cleanly with this head.

I checked this head separately with #3290 (898de93c) and #3291 (a643d5ae). In each pair Git reports one conflict in the generated d3d12/docs/switches.md. Regenerating that page from the merged sources gives 686 entries, preserves both switches, and passes the stricter check and all 21 tests in both pairs. This is a CPU-only check of the catalog and merge. AI-assisted with OpenAI Codex.

**@⁠merzleckeier** on GitHub · 2026-12-03 04:38 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/3293#pullrequestreview-6163776119) · **reviewed** Verified the switch catalog follow-up at `2abd0c4c`. The old head `fae5bd4b` fails with `missing from the page: LEONIDA_SEPARATE_SIZE_HANDLES`. The new head passes all 20 catalog tests and `--check`. With #3270 applied, all 21 tests pass, including the header count check. #3294 also merges cleanly with this head. I checked this head separately with #3290 (`898de93c`) and #3291 (`a643d5ae`). In each pair Git reports one conflict in the generated `d3d12/docs/switches.md`. Regenerating that page from the merged sources gives 686 entries, preserves both switches, and passes the stricter check and all 21 tests in both pairs. This is a CPU-only check of the catalog and merge. AI-assisted with OpenAI Codex.
Author
Owner

@⁠MoonEyes on GitHub · 2026-12-03 05:01 UTC · original

RUN (in game, batch of three pull requests), each head merged with git merge --no-ff onto main d9b618f10, in one build: #3290 898de93c2, #3293 fae5bd4b5, #3294 9582059a2. RTX 4060 8 GB, driver 610.88, Windows 11. Series S, -Resolution 1080, frame generation 2x, -PrecompileUsed, the same walking route as the other runs on this machine, 330 s after reaching the world.

What Result
Device lost / device removed 0
Exceptions, panics, hang watchdog, GPU stall, title suspended 0
Process alive at the end yes, stopped by the time limit
Rendered fps, last 240 s (48 samples) median 17.2, mean 17.2
Rendered fps, last 120 s median 17.2
Time under 5 fps in the world 1 %

For reference, the same machine and route rendered 13.3 to 17.2 fps on other batches in the last day. These fps are a check that nothing fell over, not a measurement of a gain.

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. Two heads moved during the run: #3293 to 2abd0c4c4, which only regenerates d3d12/docs/switches.md (git diff fae5bd4b5 2abd0c4c4 outside *.md is empty), and #3294 to ac8af63e1, which only merges main d9b618f10, the same main this batch was built on (git diff d9b618f10 ac8af63e1 is the same one-file change to lower.rs that was tested). This run therefore also stands for those two new heads.

Limits: one run; arrival in the world was driven by keys and not checked on pictures; -PrecompileUsed was used, so the default start (every known pipeline precompiled) was not exercised. #3290's switch is opt-in and was left off. #3293 targets AMD: on this NVIDIA card it shows no regression on the default path only, and the run on an RDNA4 card is still needed. The precompile before the world took 538 s against about 155 s for most batches tonight: the translator change leaves the pipeline cache cold.

AI-assisted (Claude Code).

**@⁠MoonEyes** on GitHub · 2026-12-03 05:01 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/3293#issuecomment-7368287313) RUN (in game, batch of three pull requests), each head merged with `git merge --no-ff` onto main `d9b618f10`, in one build: #3290 `898de93c2`, #3293 `fae5bd4b5`, #3294 `9582059a2`. RTX 4060 8 GB, driver 610.88, Windows 11. Series S, `-Resolution 1080`, frame generation 2x, `-PrecompileUsed`, the same walking route as the other runs on this machine, 330 s after reaching the world. | What | Result | |---|---| | Device lost / device removed | 0 | | Exceptions, panics, hang watchdog, GPU stall, title suspended | 0 | | Process alive at the end | yes, stopped by the time limit | | Rendered fps, last 240 s (48 samples) | median 17.2, mean 17.2 | | Rendered fps, last 120 s | median 17.2 | | Time under 5 fps in the world | 1 % | For reference, the same machine and route rendered 13.3 to 17.2 fps on other batches in the last day. These fps are a check that nothing fell over, not a measurement of a gain. 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. Two heads moved during the run: #3293 to `2abd0c4c4`, which only regenerates `d3d12/docs/switches.md` (`git diff fae5bd4b5 2abd0c4c4` outside `*.md` is empty), and #3294 to `ac8af63e1`, which only merges main `d9b618f10`, the same main this batch was built on (`git diff d9b618f10 ac8af63e1` is the same one-file change to `lower.rs` that was tested). This run therefore also stands for those two new heads. Limits: one run; arrival in the world was driven by keys and not checked on pictures; `-PrecompileUsed` was used, so the default start (every known pipeline precompiled) was not exercised. #3290's switch is opt-in and was left off. #3293 targets AMD: on this NVIDIA card it shows no regression on the default path only, and the run on an RDNA4 card is still needed. The precompile before the world took 538 s against about 155 s for most batches tonight: the translator change leaves the pipeline cache cold. AI-assisted (Claude Code).
# Conflicts:
#	d3d12/docs/switches.md
github-bot changed target branch from main to gh-pr/3293/base 2026-12-03 14:24:50 +00:00
github manually merged commit bbdbe84e45 into gh-pr/3293/base 2026-12-03 14:27:38 +00:00
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
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!3293
No description provided.