Shaders: include HEAP_FLAT in offline precompile runtime_windows #2704

Open
github-bot wants to merge 2 commits from github-bot/gh-2704 into amd-dev AGit
Owner

@⁠Saksukella on GitHub · 2026-11-26 07:21 UTC · original
Saksukella:fix/precompile-heap-flat → amd-dev · +25 −8 · 1 files · 2 commits · open

What is in it

  • crates/xcl/src/shaders.rs: extract runtime_windows_flags(windows, heap_windows, heap_flat) so offline xcl shaders --precompile / --export-hlsl / --measure-pso include recomp::HEAP_FLAT whenever windows > 1 && heap_windows && heap_flat, matching runtime recomp::pso::mem_windows().
  • Mask both recomp::HEAP_WINDOWS | recomp::HEAP_FLAT when printing the memory window count in export_hlsl and precompile (previously printing 536870916 memory windows if HEAP_FLAT were set), and append (flat) only in precompile (not --export-hlsl, since pso::console_hlsl / recomp::translate strips HEAP_FLAT as direct-DXIL-only).
  • Add unit test shaders::tests::offline_runtime_windows_includes_heap_flat_when_enabled.
  • Target branch: amd-dev (where recomp::HEAP_FLAT and recomp::pso::heap_flat() live).

Tested

  • Hardware: AMD Radeon RX 9070 XT (driver 32.0.32029.2010), 24-thread x86_64 CPU, 32 GB RAM, Windows; rustc 1.100.0 (0ef1bc386 2026-11-09); debug (tests) and release (xcl.exe).
  • cargo test -p xcl --lib offline_runtime_windows_includes_heap_flat_when_enabled: 1 passed, 0 failed (0.00s).
  • cargo test -p xcl --test shaders_e2e -- --test-threads=4: 8 passed, 0 failed (0.26s).
  • End-to-end offline compute precompile against existing runtime .plib (gen-00000036.plib):
    • Before fix: pipeline library (.plib): 1 loaded, 576 stored (key mismatch because offline omitted HEAP_FLAT).
    • After fix (xcl shaders shaders.rpf --precompile --only cs --pipelines --used-only): 4 memory windows from the descriptor heap (flat), pipelines made on the GPU 578, refused 0, pipeline library (.plib): 548 loaded, 30 stored -> gen-0000003e.plib (94.8% instant hit rate; also cached 2.67 MB 56c0cd3b82a00c6e with the matching runtime key).

Regression run

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: AMD Radeon RX 9070 XT
title: b8db18c2
seconds: 60
exit: 0x0
frames shown: 1624 (PresentX 1624)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 19700 MB
xcl-smoke v1
commit: 9b6811395e231ecbdb243aff99e81eaa21fa0178
gpu: AMD Radeon RX 9070 XT
title: b8db18c2
seconds: 60
exit: 0x0
frames shown: 1674 (PresentX 1674)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15689 MB

Not tested

  • --export-hlsl and --measure-pso with Windows Developer Mode enabled (Developer Mode is off on this machine).
  • NVIDIA and Intel GPU adapters (tested on AMD Radeon RX 9070 XT only).

AI use

  • Antigravity (Google Gemini frontier model): assisted with root-cause analysis comparing shaders.rs and pso.rs, code edit, unit test authoring, and running offline precompile / smoke checks. All diffs and measurements were verified locally on hardware.
**@⁠Saksukella** on GitHub · 2026-11-26 07:21 UTC · [original](https://github.com/xcl-dev/xcl/pull/2704) `Saksukella:fix/precompile-heap-flat` → `amd-dev` · +25 −8 · 1 files · 2 commits · open **What is in it** - `crates/xcl/src/shaders.rs`: extract `runtime_windows_flags(windows, heap_windows, heap_flat)` so offline `xcl shaders --precompile` / `--export-hlsl` / `--measure-pso` include `recomp::HEAP_FLAT` whenever `windows > 1 && heap_windows && heap_flat`, matching runtime `recomp::pso::mem_windows()`. - Mask both `recomp::HEAP_WINDOWS | recomp::HEAP_FLAT` when printing the memory window count in `export_hlsl` and `precompile` (previously printing `536870916 memory windows` if `HEAP_FLAT` were set), and append ` (flat)` only in `precompile` (not `--export-hlsl`, since `pso::console_hlsl` / `recomp::translate` strips `HEAP_FLAT` as direct-DXIL-only). - Add unit test `shaders::tests::offline_runtime_windows_includes_heap_flat_when_enabled`. - Target branch: `amd-dev` (where `recomp::HEAP_FLAT` and `recomp::pso::heap_flat()` live). **Tested** - Hardware: AMD Radeon RX 9070 XT (driver `32.0.32029.2010`), 24-thread x86_64 CPU, 32 GB RAM, Windows; `rustc 1.100.0 (0ef1bc386 2026-11-09)`; debug (tests) and release (`xcl.exe`). - `cargo test -p xcl --lib offline_runtime_windows_includes_heap_flat_when_enabled`: 1 passed, 0 failed (`0.00s`). - `cargo test -p xcl --test shaders_e2e -- --test-threads=4`: 8 passed, 0 failed (`0.26s`). - End-to-end offline compute precompile against existing runtime `.plib` (`gen-00000036.plib`): - Before fix: `pipeline library (.plib): 1 loaded, 576 stored` (key mismatch because offline omitted `HEAP_FLAT`). - After fix (`xcl shaders shaders.rpf --precompile --only cs --pipelines --used-only`): `4 memory windows from the descriptor heap (flat)`, `pipelines made on the GPU 578, refused 0`, `pipeline library (.plib): 548 loaded, 30 stored -> gen-0000003e.plib` (94.8% instant hit rate; also cached 2.67 MB `56c0cd3b82a00c6e` with the matching runtime key). **Regression run** ``` xcl-smoke v1 commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7 gpu: AMD Radeon RX 9070 XT title: b8db18c2 seconds: 60 exit: 0x0 frames shown: 1624 (PresentX 1624) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 19700 MB ``` ``` xcl-smoke v1 commit: 9b6811395e231ecbdb243aff99e81eaa21fa0178 gpu: AMD Radeon RX 9070 XT title: b8db18c2 seconds: 60 exit: 0x0 frames shown: 1674 (PresentX 1674) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15689 MB ``` **Not tested** - `--export-hlsl` and `--measure-pso` with Windows Developer Mode enabled (Developer Mode is off on this machine). - NVIDIA and Intel GPU adapters (tested on AMD Radeon RX 9070 XT only). **AI use** - Antigravity (Google Gemini frontier model): assisted with root-cause analysis comparing `shaders.rs` and `pso.rs`, code edit, unit test authoring, and running offline precompile / smoke checks. All diffs and measurements were verified locally on hardware.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 07:30:04 +00:00
Author
Owner

@⁠luckyteagirl on GitHub · 2026-11-26 07:29 UTC · original · reviewed

shaders.rs:1097–1103: the new --export-hlsl summary can say from the descriptor heap (flat) when HEAP_FLAT is set, but this path writes HLSL through pso::console_hlsl (line 1067), and recomp::translate explicitly removes HEAP_FLAT before HLSL translation (gpu/recomp/mod.rs:1631–1633). pso.rs:116–117 also documents flat access as direct-DXIL-only. With the now-default flat runtime flag, this makes the exported HLSL summary describe a layout the exported code does not use. The corrected numeric window count should stay; could the flat suffix be omitted or qualified for --export-hlsl? Source review only at exact head 09b6d29d0172a25f52878cd352e78f11dda38405, no export run. AI-assisted review with Codex.

**@⁠luckyteagirl** on GitHub · 2026-11-26 07:29 UTC · [original](https://github.com/xcl-dev/xcl/pull/2704#pullrequestreview-6070054448) · **reviewed** `shaders.rs:1097–1103`: the new `--export-hlsl` summary can say `from the descriptor heap (flat)` when `HEAP_FLAT` is set, but this path writes HLSL through `pso::console_hlsl` (line 1067), and `recomp::translate` explicitly removes `HEAP_FLAT` before HLSL translation (`gpu/recomp/mod.rs:1631–1633`). `pso.rs:116–117` also documents flat access as direct-DXIL-only. With the now-default flat runtime flag, this makes the exported HLSL summary describe a layout the exported code does not use. The corrected numeric window count should stay; could the `flat` suffix be omitted or qualified for `--export-hlsl`? Source review only at exact head `09b6d29d0172a25f52878cd352e78f11dda38405`, no export run. AI-assisted review with Codex.
Author
Owner

@⁠Saksukella on GitHub · 2026-11-26 08:59 UTC · original

Good catch @⁠luckyteagirl — updated in 9b681139 so --export-hlsl keeps the masked numeric window count (windows & !(recomp::HEAP_WINDOWS | recomp::HEAP_FLAT)) and omits (flat) since pso::console_hlsl / recomp::translate strips HEAP_FLAT. Re-ran offline_runtime_windows_includes_heap_flat_when_enabled (1/1), shaders_e2e (8/8), and a 60s RX 9070 XT smoke run (1674 frames, 0 removals, 0 crashes).

**@⁠Saksukella** on GitHub · 2026-11-26 08:59 UTC · [original](https://github.com/xcl-dev/xcl/pull/2704#issuecomment-7187265249) Good catch @⁠luckyteagirl — updated in `9b681139` so `--export-hlsl` keeps the masked numeric window count (`windows & !(recomp::HEAP_WINDOWS | recomp::HEAP_FLAT)`) and omits ` (flat)` since `pso::console_hlsl` / `recomp::translate` strips `HEAP_FLAT`. Re-ran `offline_runtime_windows_includes_heap_flat_when_enabled` (1/1), `shaders_e2e` (8/8), and a 60s RX 9070 XT smoke run (1674 frames, 0 removals, 0 crashes).
This pull request has changes conflicting with the target branch.
  • crates/xcl/src/shaders.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2704/head:github-bot/gh-2704'
git switch 'github-bot/gh-2704'

Merge

Merge the changes and update on Forgejo.
git switch 'amd-dev'
git merge --no-ff 'github-bot/gh-2704'
git switch 'github-bot/gh-2704'
git rebase 'amd-dev'
git switch 'amd-dev'
git merge --ff-only 'github-bot/gh-2704'
git switch 'github-bot/gh-2704'
git rebase 'amd-dev'
git switch 'amd-dev'
git merge --no-ff 'github-bot/gh-2704'
git switch 'amd-dev'
git merge --squash 'github-bot/gh-2704'
git switch 'amd-dev'
git merge --ff-only 'github-bot/gh-2704'
git switch 'amd-dev'
git merge 'github-bot/gh-2704'
git push origin 'amd-dev'
This discussion has been locked. Commenting is limited to contributors.
No description provided.