Skip to content

Recompiler: direct DXIL reads heap memory windows without a branch - #2427

Open
Kalmarv wants to merge 1 commit into
xcl-dev:mainfrom
Kalmarv:heap-flat-loads
Open

Kalmarv wants to merge 1 commit into
xcl-dev:mainfrom
Kalmarv:heap-flat-loads

Conversation

@Kalmarv

@Kalmarv Kalmarv commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Part of #2088.

With heap memory windows (XCL_HEAP_WINDOWS=1), every read in a direct-DXIL compute program is a branch on w < windows (and the lane guard) around the heap lookup, with a phi per value where the paths join. NVIDIA's compile time follows the block count, not the byte count, and the reads in a large compute program make thousands of blocks.

This PR adds a one-path form behind XCL_HEAP_FLAT=1. It applies only with heap windows on:

  • The read: each lane reads from window w's heap view. It uses window 0 instead when w is outside the windows or the lane is inactive, and those lanes then take 0. The guarded form and the switch over root UAVs give the same results.
  • Credit: the one-path idea (a clamped index instead of a branch) is the one @brothernog brings to the HLSL heap form in Recompiler: heap memory windows without a guard (min + null view), and the 64-bit atomics check #1695. Reading through a select instead of a branch is the same direction as @coolpersonnn's Recompiler: flatten direct DXIL root-UAV loads for compute #2368 for root UAVs. This PR applies it to the direct translator's heap form.
  • Cache keys: the new HEAP_FLAT flag is in the windows count, so the caches keep the forms apart.
  • Scope: compute programs only (kernel and CS entries, kernel::reads_heap_flat). Vertex, pixel, mesh and GS programs keep the guarded form, and the HLSL path is unchanged. Before, mesh and GS programs read flat too (@pvfreis's review). Only reads change: raw, SMEM, unaligned, format and BVH node loads (all the with_mem_i32s callers). Stores and atomics keep their branch.

Result, on native Windows and NVIDIA: this form builds these five large programs 34–64 % faster than the guarded heap form. Its native code is 2.4 % smaller than the guarded form's in total (1.5–4.8 % per program).

The table was measured on 0f04514, this PR before its rebase onto 6d12f58. Its switch column is the form from before #2368; main now reads compute memory through #2368's select instead.

Cold pipeline builds on an RTX 5070 Ti (NVIDIA 610.74), shader cache disabled (ShaderCacheControl), 4 windows, split wave64:

  • Programs: five large compute programs from title: ea3b5e4d.
  • One job: all three forms come from the same translator build: the switch over root UAVs (before Recompiler: flatten direct DXIL root-UAV loads for compute #2368), the guarded heap form, and this PR's flat heap form.
  • Order: each program is built in the order switch, guarded, flat, flat, guarded, switch.
  • Cells: both runs, then their mean, in seconds.
program switch (before #2368) heap, guarded heap, flat (this PR) native code: switch / guarded / flat
RT resolve A 36.4 / 29.7 → 33.1 29.4 / 12.6 → 21.0 12.0 / 12.4 → 12.2 1242 / 955 / 941 KB
RT resolve B 31.5 / 31.6 → 31.5 14.2 / 14.2 → 14.2 8.9 / 8.5 → 8.7 1365 / 1051 / 1027 KB
local lights 6.4 / 6.3 → 6.3 2.9 / 2.8 → 2.9 1.9 / 1.9 → 1.9 460 / 374 / 356 KB
cascade shadows A 51.5 / 53.8 → 52.7 101.1 / 82.8 → 92.0 29.0 / 37.8 → 33.4 2408 / 2153 / 2092 KB
cascade shadows B 13.8 / 11.5 → 12.7 14.3 / 14.2 → 14.2 8.2 / 8.2 → 8.2 1252 / 1138 / 1117 KB

Against main's form (#2368), measured on this PR rebased onto 6d12f58 (its compute translation is this head's) in one timing job, same card, driver and settings as above. Each program is built in the order switch (before #2368), #2368's select, guarded, flat, then the reverse. The switch column comes from the earlier export, so it is not from the 6d12f58 build.

program switch (before #2368) #2368's select (main) heap, guarded heap, flat (this PR) native code: switch / #2368 / guarded / flat
RT resolve A 30.2 / 30.7 → 30.4 14.3 / 14.1 → 14.2 11.9 / 11.6 → 11.7 7.7 / 7.6 → 7.6 1243 / 1119 / 956 / 941 KB
RT resolve B 31.4 / 36.2 → 33.8 15.5 / 17.2 → 16.4 14.2 / 14.8 → 14.5 8.5 / 8.5 → 8.5 1365 / 1226 / 1047 / 1030 KB
local lights 6.3 / 6.3 → 6.3 3.4 / 3.4 → 3.4 2.9 / 2.8 → 2.9 1.8 / 1.8 → 1.8 460 / 460 / 373 / 353 KB
cascade shadows A 43.4 / 45.1 → 44.3 40.1 / 40.2 → 40.1 68.8 / 67.2 → 68.0 26.5 / 27.5 → 27.0 2408 / 2293 / 2149 / 2094 KB
cascade shadows B 11.6 / 11.3 → 11.4 10.4 / 10.8 → 10.6 14.9 / 15.0 → 14.9 8.4 / 8.2 → 8.3 1252 / 1216 / 1138 / 1117 KB
  • Against Recompiler: flatten direct DXIL root-UAV loads for compute #2368's select: flat builds 22–48 % faster on all five programs (geomean 7.67 vs 12.72 s, a ratio of 0.603). Its native code is 0.877 times the size in total (0.77–0.92 per program).
  • Against the guarded form in this job: 0.557 by geomean (13.76 s guarded).
  • Same limits as above: five large compute programs, one card, native Windows.

What is in it

  • gpu/dxil/lower_mem.rs: the one-path read in with_mem_i32s.
  • gpu/dxil/kernel.rs, gpu/dxil/lower.rs: heap_flat in Lw. kernel::reads_heap_flat sets it for kernel and CS entries with HEAP_FLAT and heap windows. Test: only_compute_programs_read_heap_windows_flat.
  • gpu/recomp/mod.rs, gpu/recomp/pso.rs: the HEAP_FLAT flag and XCL_HEAP_FLAT=1. The HLSL path strips the flag the way it strips HEAP_WINDOWS. pso::windows_for gives the windows of n for this run; mem_windows takes it.
  • shaders.rs: xcl shaders (--precompile, --export-hlsl, --measure-pso) takes its windows from pso::windows_for too, instead of its own copy of the rule, which had no HEAP_FLAT. With XCL_HEAP_FLAT=1, the precompile made the guarded form's entries, not the ones the runtime looks up (found by @bielfreedom). Test: precompile_windows_are_the_runtimes runs with XCL_HEAP_WINDOWS=1 and XCL_HEAP_FLAT=1 or 0 in a new process and compares the windows with the runtime's. It fails with the old copy (260 against 772).
  • gpu/recomp/tests.rs: gpu_heap_flat_reads_match_the_switch_form.
    • It runs one program in all three forms (switch, guarded heap, flat heap) over a 4-window arena and compares SGPRs and VGPRs.
    • The program has SMEM loads into window 2 and outside the UMA, an s_buffer_load_dwordx4 from window 3, a buffer_load from window 1, and per-lane global_loads spread over all four windows.
    • Every eighth lane reads outside the UMA, lanes 0–32 are inactive (v_cmpx), and there is a SADDR global_load_dwordx2.

Tested

  • Ryzen 9 9950X, RTX 5070 Ti (NVIDIA 610.74), Windows 11 build 26200, rustc 1.99.0, DXC 1.9.2609, debug.
  • cargo test --workspace --no-fail-fast -- --test-threads=4 on this head, c8c2b7a (on main 6d12f58): 1426 passed, 0 failed, 46 ignored.
    • 25 SKIPPED notices: 21 for no wave64, 3 for wave32 per-lane forms refused by the gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 list (V_MUL_F16, V_PK_MUL_F16, V_CVT_F16_F32), and 1 for no heap windows (the switch-form fallback test, since heap windows are opt-in here).
    • gpu_heap_flat_reads_match_the_switch_form, only_compute_programs_read_heap_windows_flat and precompile_windows_are_the_runtimes pass.
  • Title run with the form on, this head, XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_HEAP_FLAT=1, 60 s, release, one run beside other jobs on the same machine. There was no device removal and no crash. It showed 1474 frames and was still presenting at the end (52, 38 and 50 frames per 2 s), with a peak commit of 17993 MB. Its log shows the memory windows coming from the shared descriptor heap. There is no main run of the same length to compare with.

Tested by others

Regression run

  • Setup: scripts/smoke.ps1 through our run script, 120 s, release builds, XCL_DIRECT_DXIL=1, in one queue job: main b49be18, then this head. Both sides use the same data root and XCL cache, warmed by earlier runs, and start from the same learned coherent-window state.
  • Beside it: it ran beside a CPU-bound precompile on the same machine (an offline xcl shaders --precompile count, through both sides), and another agent's GPU test suite ran beside the main side only (about 60 of its 120 s).
  • Result: no device removal and no crash. This PR showed 87.6 % of main's frames (1522 against 1738) and 101.7 % of its peak commit (28999 against 28514 MB). The run uses this PR's defaults, where the flat form is off.

main b49be18:

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 120
exit: 0x0
frames shown: 1738 (PresentX 1738)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 28514 MB

This PR (c8c2b7a):

xcl-smoke v1
commit: c8c2b7a6b19d86aa3774dc62dfc2bb13b6aafac7
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 120
exit: 0x0
frames shown: 1522 (PresentX 1522)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 28999 MB

Not tested

  • A title run with the form on that is longer than 60 s, or compared with main over the same time.
  • Compile time for programs other than the five large ones, and on other cards natively.
  • Intel and Linux. AMD: only @bielfreedom's precompile timing, no title run.
  • Graphics stages: they keep the guarded form. Recompiler: flatten direct DXIL root-UAV loads for compute #2368 measured a select-flattened form as slower for NVIDIA pixel shaders, so extending this form to them needs its own timing.

AI use

  • Claude Code (Claude Opus 5.5) wrote the change, the test and this description, made the measurements and ran the tests.

🤖 Generated with Claude Code

@FIJI1299

Copy link
Copy Markdown

Tested commit 717fec5 on Windows:

Environment

  • OS: Windows 11 (Build 26100)
  • CPU: AMD Ryzen 5 9600X 6-Core Processor
  • RAM: 32 GB
  • GPU: NVIDIA GeForce RTX 5070 (12 GB VRAM, driver 621.40, wave32)
  • DXC: 1.8.2502.11 (Windows SDK 10.0.26100.0)

Results

@ivall ivall added the goal:world-load Bears on the retail title getting past world loading label Nov 25, 2026
raylitebull added a commit that referenced this pull request Nov 25, 2026
Port #2427 (XCL_HEAP_FLAT=1, HEAP_FLAT=0x200) for compute stages using
XCL_HEAP_WINDOWS=1 so every heap-window read in Lw::with_mem_i32s() lowers
to a single clamped ResourceDescriptorHeap[NonUniformResourceIndex(4 + w)]
load and select instead of a per-read branch, merge block, and PHI set.

Large compute shaders (including 95cc13288a27a96e with 1,316 heap-window
reads and a74706fb8f96ade9 with 1,012 reads) eliminate thousands of basic
blocks and PHIs on AMD RDNA4 as well as NVIDIA; heap_raw_buffer_uav already
sets NonUniformResourceIndex=true and out-of-range/inactive lanes read
harmlessly from window 0 and select 0.

Includes gpu_heap_flat_reads_match_the_switch_form regression test.

Assisted-by: Antigravity (Gemini 4 Neon High)
@SlopTart

Copy link
Copy Markdown

Tested: current PR head merged onto current origin/main (clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo target x86_64-pc-windows-gnu run under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29).

gpu_ suite, cold cache: 161 passed / 4 failed. Three are the known baseline trio on this lane; the fourth is the new gpu_promoted_uav_clear_values_pass_create_committed_resource failure that current main carries (reported here), not caused by this PR. Everything else is green.

Not tested: retail titles (no title data on this lane, counts only).

AI use: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

Thanks!

@bmjask bmjask left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No concrete source-level defect found. Flat path clamping/select behavior, cache identity, and GPU parity coverage look sound. This draft is not merge-ready: merge state is unstable, required main/head regression pair is pending, and there is no XCL_HEAP_FLAT title run or AMD/Intel validation. The documented precompiled-cache misses are acceptable only while opt-in measurement remains the scope; rebase and provide current evidence before merge.

@pvfreis

pvfreis commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

By reading only, at d356a74 and #2428 ab2855f:

  1. Baseline. The table (last edited 18:40 UTC, on 68a284a) predates Recompiler: flatten direct DXIL root-UAV loads for compute #2368 (merged 19:59, now in both heads' base). Recompiler: flatten direct DXIL root-UAV loads for compute #2368 replaced the switch on compute raw loads with selects and reports builds up to 3.5 times as fast for that form. So the switch column, and Recompiler: NVIDIA compute programs take flat heap windows by default #2428's 1.1–3.8 times (body and heap_windows comment) and 11–25 %, are not against the form Recompiler: NVIDIA compute programs take flat heap windows by default #2428's default replaces now. Rerunning the five programs on the current base would settle it.
  2. Scope. "Mesh and GS programs … are unchanged" does not hold: heap_flat is off only for Entry::Vertex | Entry::Pixel, so with XCL_HEAP_WINDOWS=1 and direct DXIL the mesh and GS compute passes read flat too (by default after Recompiler: NVIDIA compute programs take flat heap windows by default #2428). The new test runs a kernel program only.

AI use: Claude Code (Claude Opus 5.5) found this; a second Claude Opus 5.5 re-derived it; Claude Fable 5.2 reviewed the text; checked by a person before posting.

@bielfreedom

Copy link
Copy Markdown

AMD Windows driver timing for #2427: on an RX 9070 XT with heap windows, XCL_HEAP_FLAT=1 makes AMD's CreateComputePipelineState about 11 % faster over 26 large retail compute programs and lowers peak memory. One catch first: xcl shaders --precompile never sets HEAP_FLAT, so offline the switch does nothing.

The offline tool: pso::mem_windows adds HEAP_FLAT, but shaders.rs's runtime_windows builds its own count (windows | HEAP_WINDOWS). With this PR as is, XCL_HEAP_WINDOWS=1 XCL_HEAP_FLAT=1 xcl shaders --precompile gives the same bytes as without the switch for all 2,689 programs. So with the switch on, what the offline precompile caches would not be what the runtime looks for. For the numbers below I added | if recomp::pso::heap_flat() { recomp::HEAP_FLAT } else { 0 } to runtime_windows locally.

Setup

  • GPU: RX 9070 XT 16 GB (RDNA4, native wave64), AMD driver 32.0.32029.2010.
  • CPU and memory: Ryzen 7 7700 (16 threads), 32 GB RAM, Windows 11, release.
  • Build: this PR merged onto main 08db802, plus the one-line hookup above and a local timing patch that writes each program's DXIL size and each CreateComputePipelineState time to a file. Measured at d356a74 and again at the current head f8b3191; the numbers below are from f8b3191 (d356a74 gave the same sizes and a 10.5 % driver gain). One binary for both arms; only the switch differs.
  • Offline: xcl shaders <retail shaders.rpf> --precompile --only cs --pipelines with XCL_DIRECT_DXIL=1, XCL_HEAP_WINDOWS=1, XCL_PSO_DISK_CACHE=0, one driver thread, a fresh translation cache and a fresh executable name for every run (the AMD driver keys its own cache on the exe name, so every build is cold).

DXIL size, all 2,689 compute programs, heap windows (translation only)

switch off XCL_HEAP_FLAT=1
total direct DXIL 728.9 MB (same bytes as main) 702.1 MB (−3.7 %)
programs changed 2,639

Driver time, 26 large programs, 2 interleaved rounds (off, on, then on, off)

arm pipelines (incl. split pieces) driver time r1 / r2 peak memory r1 / r2
off 66 73.1 / 73.9 s 1.62 / 1.63 GB
XCL_HEAP_FLAT=1 65 64.8 / 65.5 s 1.24 / 1.36 GB

Mean 73.5 → 65.2 s (−11 %), and no pipeline failed. The gain is much larger than the 3.7 % size cut, which fits the description: AMD also seems to pay for the blocks, not the bytes. Largest programs:

program DXIL off → on driver ms off driver ms on
620491641aa9bad6 317 → 307 KB 11,277 / 11,625 9,215 / 9,277
6d1e4583f8129771 558 → 545 KB 6,698 / 6,823 6,044 / 6,348
7c08ec6429245b8e 478 → 467 KB 5,694 / 5,729 4,898 / 4,926
6f3a2502a8d6b129 322 → 316 KB 3,449 / 3,456 2,670 / 2,712
83a3df882bebfdab 260 → 255 KB 2,419 / 2,451 1,903 / 1,963

Not measured: 95cc13288a27a96e (ActivateRays, 17.6 GB with heap windows on #2375), GPU output, and a title run.

AI use: Claude Code (Claude Opus 5.5) built the binaries, ran the measurements and wrote this report; I posted it.

@Kalmarv

Kalmarv commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor Author

@bmjask thanks for the review.

Rebased. This PR is now c8c2b7a, on main 6d12f58, so #2368 is in its base. The suite on that head: 1426 passed, 0 failed, 46 ignored.

The table. It was measured before the rebase, and its switch column is the form from before #2368. The body now says so and states the claim against the guarded heap form, which this opt-in flag replaces. Against that form, the flat form built the five large programs 34–64 % faster, and its native code was 2.4 % smaller in total. On @pvfreis's RTX 3060 it was 0.974 times the guarded form's size over 60 records, with 12 of them larger. Those five programs are all the compile-time evidence there is, and the body says the gain is shown only for them. A same-job rerun on the new base, with #2368's form as a fourth column, is queued.

Scope. Flat reads are now for compute programs only (kernel and CS entries, kernel::reads_heap_flat). Mesh and GS passes read flat before with XCL_HEAP_WINDOWS=1; now they keep the guarded form. only_compute_programs_read_heap_windows_flat covers it (@pvfreis's point).

Regression pair (in the body), on c8c2b7a against main b49be18, 120 s, XCL_DIRECT_DXIL=1: no removal or crash, 87.6 % of main's frames (1522 against 1738) and 101.7 % of its peak commit.

XCL_HEAP_FLAT title run: this head with XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_HEAP_FLAT=1, 60 s, one run. There was no device removal and no crash, 1474 frames, still presenting at the end, and a peak commit of 17993 MB. @Eterst ran a title with this PR and #2496 together on an RTX 4070 SUPER (#2496, comment 7176075746): no device removal up to 395 s, where main 06055a7 lost the device at 261–303 s in four runs. That run is not separated from #2496, and it is one run.

AMD / Intel. I have neither. @bielfreedom timed the form on an RX 9070 XT (comment 7180279957), and found and confirmed a precompile-key fix (comment 7181043742): xcl shaders --precompile now keys this form as the runtime does.

AI use: Claude Code (Claude Opus 5.5) made the changes and measurements and wrote this reply.

@Kalmarv

Kalmarv commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

@pvfreis thank you for both: the reading on #2427 and the RTX 3060 run on #2428.

1. Baseline. You're right: the table predated #2368. A same-job rerun of the five programs on main 6d12f58 is queued: RTX 5070 Ti (610.74), cold, A B B A, in four forms (the old switch, #2368's select form, the guarded heap form and the flat heap form). Until it lands, the bodies state each claim against the form it was measured against:

2. Scope. Also right: with XCL_HEAP_WINDOWS=1, the mesh and GS compute passes read flat too, and that form was never timed or GPU-tested. I narrowed the code rather than the claim. Flat reads are now for kernel and CS entries only (kernel::reads_heap_flat), and mesh, GS, VS and PS keep the guarded form. A test, only_compute_programs_read_heap_windows_flat, covers it. It is in #2427's commit, now f8b3191.

Your other results. Your suite (1429 passed, 1 failed, 46 ignored; only e2e presents fails, and it fails on main too) and the native sizes are in the bodies under Tested by others, with a link to your comment. On the repeat check: I haven't looked into why blob contents differ between runs either. The sizes were equal 60/60, and the size claims use only sizes.

AI use: Claude Code (Claude Opus 5.5) made the changes and the measurements and wrote this reply.

With heap windows (XCL_HEAP_WINDOWS=1), every read of the direct DXIL
translator was a branch on `w < windows` (and the lane guard) around the
heap lookup, and a phi per value at the join. On NVIDIA the driver's
compile time follows the block count, and the reads of a large compute
program make thousands of blocks.

XCL_HEAP_FLAT=1 (with heap windows; new flag HEAP_FLAT in the windows
count, so the caches keep the forms apart) reads in one path: the lane
loads from window `w`, or window 0 when `w` is outside the windows or
the lane is not active, and those lanes take 0, as the guarded form and
root UAVs give. All with_mem_i32s callers only load (raw, SMEM,
unaligned, format and BVH node reads). Stores and atomics keep their
branch. Compute programs only (kernel and CS entries,
kernel::reads_heap_flat): mesh, GS, vertex and pixel programs keep the
guarded form. The HLSL path ignores the flag. The one-path form is the
idea xcl-dev#1695 brings to the HLSL heap form.

xcl shaders (--precompile, --export-hlsl, --measure-pso) takes its
windows from pso::windows_for, as pso::mem_windows does, instead of its
own copy of the rule, which had no HEAP_FLAT: with XCL_HEAP_FLAT=1 the
precompile made the guarded form's entries, not the ones the runtime
looks up (found by bielfreedom).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Kalmarv

Kalmarv commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

@bielfreedom thank you, that is a real bug, and the AMD timing is very useful.

The fix, in this PR's commit, now c8c2b7a:

  • xcl shaders (--precompile, --export-hlsl, --measure-pso) no longer has its own copy of the window rule. It takes its windows from pso::windows_for, the same function pso::mem_windows uses at run time. With XCL_HEAP_WINDOWS=1 XCL_HEAP_FLAT=1, the precompile now makes the entries the runtime looks up.
  • The precompile's printed window count also leaves out the new flag.
  • A test, shaders::tests::precompile_windows_are_the_runtimes, runs with XCL_HEAP_WINDOWS=1 and XCL_HEAP_FLAT=1 or 0 in a new process, since both switches are read once. It checks that the precompile's windows are the runtime's. With the old copy it fails: 260 (no HEAP_FLAT) against 772.
  • Recompiler: NVIDIA compute programs take flat heap windows by default #2428 had its own version of this, which already carried HEAP_FLAT. It is rebased onto the fix and keeps one shared function (pso::compute_windows) for the precompile and the runtime. The same test runs there.

This corrects what I wrote to @bmjask above: precompiled entries for this form are found with the flag on.

Your setup and numbers are in the description under Tested by others, credited to you: 3.7 % less DXIL over 2,689 programs, and 11 % less AMD CreateComputePipelineState time over 26 large programs, with lower peak memory and no failures.

AI use: Claude Code (Claude Opus 5.5) made the fix and the test and wrote this reply.

@DavidM1911

Copy link
Copy Markdown
Contributor

Re-verification on RTX 3060 Ti (Windows 11), new head merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.

Thanks!

— Devin

@bielfreedom

Copy link
Copy Markdown

@Kalmarv confirmed on the RX 9070 XT: at c8c2b7a, with no local change, XCL_HEAP_WINDOWS=1 XCL_HEAP_FLAT=1 xcl shaders --precompile now makes the flat form.

  • DXIL, all 2,689 compute programs: 728.9 → 702.1 MB (−3.7 %, 2,639 changed). These are the same bytes, program for program, as my earlier run with the hand-added hookup.
  • Driver, the same 26 large programs, 2 interleaved rounds (off, on, then on, off):
    • Flag off: 66 pipelines, 91.6 / 100.2 s, peak 1.62 GB.
    • Flag on: 65 pipelines, 85.8 / 86.9 s, peak 1.34 / 1.27 GB.
    • No failures. Mean −10 %, in line with the −11 % before.
    • Both arms are slower than last night because the machine was busier; the comparison inside the run is what counts.
  • Setup is as in my comment above. This PR is merged onto main b49be18. Only my timing patch is added: it writes each CreateComputePipelineState time to a file.

AI use: Claude Code (Claude Opus 5.5) built the binary, ran the measurements and wrote this; I posted it.

@pvfreis

pvfreis commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Follow-up, by reading only, not run, at c8c2b7a6 and #2428 970823e4. Both points are addressed.

  1. Baseline: the 1.1–3.8 times and 11–25 % are gone from both bodies, both commit messages and the heap_windows comment. Each remaining build-time figure names the form it was measured against (the guarded heap form, or the switch from before Recompiler: flatten direct DXIL root-UAV loads for compute #2368). Still open, as both bodies say: build time against Recompiler: flatten direct DXIL root-UAV loads for compute #2368's form.
  2. Scope: fixed. heap_flat is set in one place (kernel.rs:537), from reads_heap_flat, which is true only for kernel and CS entries, and with_mem_i32s is its only reader. Mesh and GS passes are translated as Entry::Mesh / Entry::Geometry, so they keep the guarded form with XCL_HEAP_WINDOWS=1 XCL_HEAP_FLAT=1. In Recompiler: NVIDIA compute programs take flat heap windows by default #2428 they take heap windows only with XCL_HEAP_WINDOWS=1 (pso::mem_windows).

AI use: Claude Code (Claude Opus 5.5) checked this; Claude Fable 5.2 reviewed it; checked by a person before posting.

@Kalmarv

Kalmarv commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

@pvfreis thank you for reading both heads again.

On point 2: the scope is stated under Scope in this PR's description (compute programs only, kernel::reads_heap_flat), and only_compute_programs_read_heap_windows_flat tests it. #2428's description says so under How it decides: graphics, mesh and GS take heap windows only with XCL_HEAP_WINDOWS=1, through pso::mem_windows. On the open item, build time against #2368's form, the same-job rerun of the five programs is still queued.

AI use: Claude Code (Claude Opus 5.5) wrote this reply.

@Kalmarv
Kalmarv marked this pull request as ready for review November 26, 2026 04:36
bmjask pushed a commit to bmjask/xcl that referenced this pull request Nov 26, 2026
Heap-window reads in the direct DXIL compute path placed a branch and PHI set around every access. Add an opt-in one-path form whose cache identity is shared by runtime and offline precompile, while the HLSL path strips the flag and stays byte-identical. Graphics stages remain guarded because their performance has not been established across vendors.

Adapted from xcl-dev#2427 by Kalmarv and Claude Code (Claude Opus 5.5).

Assisted-by: Codex (GPT-5.6-sol)
@Prime1997 Prime1997 mentioned this pull request Nov 26, 2026
bmjask pushed a commit to bmjask/xcl that referenced this pull request Nov 26, 2026
Heap-window reads in the direct DXIL compute path placed a branch and PHI set around every access. Add an opt-in one-path form whose cache identity is shared by runtime and offline precompile, while the HLSL path strips the flag and stays byte-identical. Graphics stages remain guarded because their performance has not been established across vendors.

Adapted from xcl-dev#2427 by Kalmarv and Claude Code (Claude Opus 5.5).

Assisted-by: Codex (GPT-5.6-sol)
@upipibi

upipibi commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

8 GB NVIDIA run on the current head c8c2b7a6 (base main 6d12f58, merge-base 6d12f58): RTX 3070 8 GB (Ampere, wave32, driver 616.56), Windows 11 26100, rustc 1.100.0, debug. Ryzen 9 5950X, 32 GB RAM.

  • XCL_HEAP_FLAT=1 (XCL_HEAP_WINDOWS unset), 3 of 3 runs: gpu_heap_flat_reads_match_the_switch_form and only_compute_programs_read_heap_windows_flat passed, none skipped.
  • XCL_HEAP_FLAT=1 cargo test -p xcl --lib -- --skip hle::xaudio2 --test-threads=4: 1292 passed, 0 failed, 26 ignored, 9 filtered out. 25 SKIPPED: 21 no wave64, 3 wave32 per-lane f16 forms, 1 needs Developer Mode to disable the driver cache.
  • 0 DXGI_ERROR_DEVICE_REMOVED, 0 nvlddmkm resets.

Tests only: no title run, no compile timing (driver cache cannot be disabled here).
AI-assisted (Claude Code, Claude Sonnet 5.5 ran the tests; Claude Opus 5.5 checked and posted).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

goal:world-load Bears on the retail title getting past world loading

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants