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

Merged
OreoFR merged 5 commits from upstream-pr/3293 into main 2026-12-03 14:17:12 +00:00
OreoFR commented 2026-12-03 04:18:55 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-12-03T04:18:55Z.


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

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5619870581 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3293). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-12-03T04:18:55Z. --- 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)
fiestorra commented 2026-12-03 04:33:07 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-03T04:33:07Z.


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7367773835 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3293#issuecomment-7367773835). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-12-03T04:33:07Z. --- ## 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.**
merzleckeier commented 2026-12-03 04:38:30 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-03T04:38:30Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6163776119 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3293#pullrequestreview-6163776119). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-03T04:38:30Z. **Review:** COMMENTED --- 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.
MoonEyes commented 2026-12-03 05:01:12 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-03T05:01:12Z.


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).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7368287313 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3293#issuecomment-7368287313). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-03T05:01:12Z. --- 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).
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
ProjectLeonida/mandy!3293
No description provided.