Recompiler: flat heap reads outside the windows take the null view #3486

Open
KDenKC wants to merge 2 commits from upstream-pr/3486 into main
KDenKC commented 2026-11-30 01:21:30 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by KDenKC on 2026-11-30T01:21:30Z.


With XCL_HEAP_FLAT=1 (heap windows on), the direct DXIL translator reads a compute program's heap memory windows without a branch (2f523330). The access runs for every lane, and a lane outside the windows or under a false guard (a buffer index past num_records, a lane EXEC leaves out) had its value set to zero afterwards. But its access went to window 0's descriptor, at the address it was given. So it read window 0's memory at an address the program never reaches: the guarded form branches around that access, and the HLSL accessors (409cf071) send it to the null view MEM_NULL_LOAD. Now the direct form selects MEM_NULL_LOAD for it too, so it touches no window's memory.

Stacked on #3349: the branch is main 1c8b5514 + #3349's commit unchanged (42bd1090, Kalmarv) + this PR's commit 87c10e69; only the top commit belongs here.

It needs #3349 for the null view to be a buffer: on main, console_heap::shared_heap runs fill_nulls after null_window_views and writes a Texture2D null SRV over MEM_NULL_LOAD, which the HLSL accessors already select today. #3349 writes the raw-UAV null views after fill_nulls. Kalmarv's #2428 (flat heap windows by default on NVIDIA) still has the window-0 select.

Related: #2626 (a compute dispatch's GPU VA 0 fault on the first world frame), #2403, #2088.

What is in it (one commit, 87c10e69: the fixes and their tests)

  • gpu/dxil/lower_mem.rs with_mem_i32s: the flat form selects descriptor MEM_NULL_LOAD instead of window 0 for an access outside the windows or under a false guard. Its callers only load (memory loads and the BVH node loads), so the null load view is the one.
  • gpu/dxil/lower_mem.rs scalar_flat_read (the flat s_buffer_load path from #3500) and gpu/dxil/lower_window.rs high_one_slot (the carry case's slot for a high dword of one): an address outside the windows takes MEM_NULL_LOAD too, not window 0 (bmjask's review). The scalar read's dwords stay masked as before.
  • Tests:
    • gpu/dxil/core_tests.rs raw_loads_in_root_windows_are_branchless: the flat form selects the null-load view, and a program of one s_buffer_load alone does too (that part fails without the scalar_flat_read change).
    • gpu/dxil/module/opt.rs the_flat_read_carry_rewrite_keeps_the_null_select: the optimizer's FlatRead carry rewrite turns the read's bounds test and slot into carry selects and leaves its null select in place (Foniass's review).
  • Rebased onto main 1c8b5514, stacked on #3349. Before that, on main d52ff48c: #3500 (b5973e3e) touched the same lines but did not change this: its flat read still selects window 0 (sel(ok, w, 0)) for an access outside the windows. Its FlatRead record keeps pointing at the descriptor-index add, which its carry rewrite changes; the null select is after that add, and ok is inside (also rewritten), so the carry form keeps the null view too.

Tested

  • NVIDIA GeForce RTX 3090 24 GB (VM), driver 621.24, Intel i7-10700T, Windows 11 build 26300.9974, Rust 1.99.1, debug, at this head 87c10e69 (main 1c8b5514 + #3349's commit + this commit):
    • cargo test --workspace --no-fail-fast -- --test-threads=4: 2903 passed, 5 failed, 51 ignored. The 5 fail on main 1c8b5514 too: title_textures::tests::placed_title_textures_share_vram_and_preserve_pixels, the 3 stream_recheck_* tests, and e2e test_title_runs_and_game_folder_is_untouched. SKIPPED: 28 (22 no wave64, 2 no heap windows, 3 no debug layer, 1 driver cache cannot be disabled). The run leaves out the 3 uma_driver tests, as every run on this VM.
    • The scalar test, red without the scalar_flat_read change (the test commit alone on main 1c8b5514): scalar flat heap reads must select the null-load view (descriptor 20), test result: FAILED. 0 passed; 1 failed; green with it: test result: ok. 1 passed; 0 failed.
    • -- the_flat_read_carry_rewrite_keeps_the_null_select: 1 passed, 0 failed.
  • Earlier head 2d3e3fe1 (main d52ff48c + the first fix), same machine:
    • Red, at 63fbc611 (main d52ff48c + the test only): cargo test -p xcl --lib -- raw_loads_in_root_windows_are_branchless --nocapture --test-threads=1:
      thread 'gpu::dxil::core_tests::raw_loads_in_root_windows_are_branchless' (1360) panicked at crates\xcl\src\gpu\dxil\core_tests.rs:1463:9:
      flat heap reads must select the null-load view (descriptor 20):
      test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 2764 filtered out; finished in 0.24s
      
    • Green, at 2d3e3fe1, the same command:
      test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 2764 filtered out; finished in 0.12s
      
    • cargo test --workspace --no-fail-fast -- --test-threads=4 (leaving out the 3 uma_driver tests that need a GPU upload segment this VM has not): 2868 passed, 6 failed, 51 ignored. SKIPPED: 28 (22 no wave64, 2 no heap windows, 3 no debug layer, 1 driver cache cannot be disabled). The 6 failures: gpu::dxil::msaa_tests::gpu_direct_image_get_resinfo_d16, title_textures::tests::placed_title_textures_share_vram_and_preserve_pixels, the 3 stream_recheck_* tests, and test_title_runs_and_game_folder_is_untouched.
    • Main d52ff48c on the same machine fails the same tests: gpu_direct_image_get_resinfo_d16, the 3 stream_recheck_* and test_title_runs_and_game_folder_is_untouched. Its parallel run lost the lib binary, so its lib tests come from a one-thread rerun that left out all of uma_driver::tests (2721 passed, 5 failed, 31 ignored); its counts are not comparable to the line above, the failing names are.
  • (the earlier head, before the rebase) RTX 5090 32 GB, driver 621.24, Ryzen 7 9800X3D, the retail title, XCL_HEAP_FLAT=1 with heap windows, the debug layer and DRED on, XCL_PREPARE=0, 200 s. The change is in our integration build of open PRs (93d11d74: the same commit on top of it); the build under it alone (1b108007) is the "before":
    • before (1b108007), the device is removed on the first world frame:
      [   75.235][11864][INFO ] D3D12.X: split command list (type 2) around mid-list Wait after Write64 (#2)
      [   75.654][37400][ERROR] D3D12 device removed: 0x887a0006 The GPU will not respond to more commands, most likely because of an invalid command passed by the calling application.
      [   75.655][37400][ERROR] DRED device state: 7
      [   75.655][37400][ERROR] DRED page fault at GPU VA 0x0 = window 10 + 0x0; allocations there: []; recently freed: []
      
    • with this change (93d11d74), the frame is drawn and the run ends at its timer:
      [   77.993][41660][INFO ] D3D12.X: split command list (type 2) around mid-list Wait after Write64 (#1)
      [   78.554][39156][INFO ] activity (2 s): 1 presents, 34 submits, 4995 draws, 7278 dispatches, 2 frame-event waits (0 timed out), 1 frame statistics (0 not flipped)
      [  201.010][41788][INFO ] process ends (thread 41788)
      19:12:29 pid 28360 exit code 0 (0x00000000)
      device removed lines: 0; DRED lines (past the 'DRED on' start line): 0
      
      The debug layer's other errors in that run: ids 1422, 527, 538 and 1047, 8 each (uninitialized placed targets, barrier states and the sparse queue race, seen before this change too); none of them a device removal.

Regression run
RTX 5090, 600 s each, JIT (XCL_PREPARE=0), seeded profile and held Enter. The main block is reused from the earlier gate-batch-t pair and was validated against the full main SHA and network line. Heap windows were on, but XCL_HEAP_FLAT was unset, so this smoke checks the default path rather than the opt-in path changed here. Head frames are 114% of main and peak commit is 102.2% of main; both are within the smoke limits.

main 1c8b5514 (reused block):

xcl-smoke v1
commit: 1c8b551475e1e7bfe48f94448492a4c3544a2e0f
gpu: NVIDIA GeForce RTX 5090
title: 9cc6a39e
seconds: 600
exit: 0x0
frames shown: 1724 (PresentX 1725)
presents per 2 s (last 3): 2 1 2
device removals: 0
crashes: 0
peak commit: 47581 MB

#3486 head 87c10e69:

xcl-smoke v1
commit: 87c10e692424c5f212cadb99b88df0fb6b3f5e14
gpu: NVIDIA GeForce RTX 5090
title: 9cc6a39e
seconds: 600
exit: 0x0
frames shown: 1962 (PresentX 1963)
presents per 2 s (last 3): 2 2 2
device removals: 0
crashes: 0
peak commit: 48639 MB

Not tested

  • The run above is on our integration build, not on main + this commit alone; the title's first world frame is the only place it was seen.
  • A GPU run that shows the old access fault: the test runner's window buffers return zero out of range, so the difference is only in which descriptor is read (checked in the DXIL).
  • AMD and Intel.
  • A smoke pair with XCL_HEAP_FLAT=1 at this head.

AI use

  • Claude Code (Claude Opus 5.5, Claude Sonnet 5.5), Codex (GPT-6.2-Sol), Antigravity (Gemini 4 Neon, Gemini 4 Hydrogen): an agent swarm wrote, tested, reviewed and described this change.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:issue:5557297972 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3486). Originally posted by [KDenKC](https://github.com/KDenKC) on 2026-11-30T01:21:30Z. --- With `XCL_HEAP_FLAT=1` (heap windows on), the direct DXIL translator reads a compute program's heap memory windows without a branch (2f523330). The access runs for every lane, and a lane outside the windows or under a false guard (a buffer index past `num_records`, a lane EXEC leaves out) had its value set to zero afterwards. But its access went to window 0's descriptor, at the address it was given. So it read window 0's memory at an address the program never reaches: the guarded form branches around that access, and the HLSL accessors (409cf071) send it to the null view `MEM_NULL_LOAD`. Now the direct form selects `MEM_NULL_LOAD` for it too, so it touches no window's memory. Stacked on #3349: the branch is `main` `1c8b5514` + #3349's commit unchanged (`42bd1090`, Kalmarv) + this PR's commit `87c10e69`; only the top commit belongs here. It needs #3349 for the null view to be a buffer: on main, `console_heap::shared_heap` runs `fill_nulls` after `null_window_views` and writes a Texture2D null SRV over `MEM_NULL_LOAD`, which the HLSL accessors already select today. #3349 writes the raw-UAV null views after `fill_nulls`. Kalmarv's #2428 (flat heap windows by default on NVIDIA) still has the window-0 select. Related: #2626 (a compute dispatch's GPU VA 0 fault on the first world frame), #2403, #2088. **What is in it** (one commit, `87c10e69`: the fixes and their tests) - `gpu/dxil/lower_mem.rs` `with_mem_i32s`: the flat form selects descriptor `MEM_NULL_LOAD` instead of window 0 for an access outside the windows or under a false guard. Its callers only load (memory loads and the BVH node loads), so the null load view is the one. - `gpu/dxil/lower_mem.rs` `scalar_flat_read` (the flat `s_buffer_load` path from #3500) and `gpu/dxil/lower_window.rs` `high_one_slot` (the carry case's slot for a high dword of one): an address outside the windows takes `MEM_NULL_LOAD` too, not window 0 (bmjask's review). The scalar read's dwords stay masked as before. - Tests: - `gpu/dxil/core_tests.rs` `raw_loads_in_root_windows_are_branchless`: the flat form selects the null-load view, and a program of one `s_buffer_load` alone does too (that part fails without the `scalar_flat_read` change). - `gpu/dxil/module/opt.rs` `the_flat_read_carry_rewrite_keeps_the_null_select`: the optimizer's `FlatRead` carry rewrite turns the read's bounds test and slot into carry selects and leaves its null select in place (Foniass's review). - Rebased onto `main` 1c8b5514, stacked on #3349. Before that, on `main` d52ff48c: #3500 (b5973e3e) touched the same lines but did not change this: its flat read still selects window 0 (`sel(ok, w, 0)`) for an access outside the windows. Its `FlatRead` record keeps pointing at the descriptor-index add, which its carry rewrite changes; the null select is after that add, and `ok` is `inside` (also rewritten), so the carry form keeps the null view too. **Tested** - NVIDIA GeForce RTX 3090 24 GB (VM), driver 621.24, Intel i7-10700T, Windows 11 build 26300.9974, Rust 1.99.1, debug, at this head `87c10e69` (`main` `1c8b5514` + #3349's commit + this commit): - `cargo test --workspace --no-fail-fast -- --test-threads=4`: 2903 passed, 5 failed, 51 ignored. The 5 fail on `main` `1c8b5514` too: `title_textures::tests::placed_title_textures_share_vram_and_preserve_pixels`, the 3 `stream_recheck_*` tests, and e2e `test_title_runs_and_game_folder_is_untouched`. SKIPPED: 28 (22 no wave64, 2 no heap windows, 3 no debug layer, 1 driver cache cannot be disabled). The run leaves out the 3 `uma_driver` tests, as every run on this VM. - The scalar test, red without the `scalar_flat_read` change (the test commit alone on `main` `1c8b5514`): `scalar flat heap reads must select the null-load view (descriptor 20)`, `test result: FAILED. 0 passed; 1 failed`; green with it: `test result: ok. 1 passed; 0 failed`. - `-- the_flat_read_carry_rewrite_keeps_the_null_select`: 1 passed, 0 failed. - Earlier head `2d3e3fe1` (main `d52ff48c` + the first fix), same machine: - Red, at 63fbc611 (main `d52ff48c` + the test only): `cargo test -p xcl --lib -- raw_loads_in_root_windows_are_branchless --nocapture --test-threads=1`: ``` thread 'gpu::dxil::core_tests::raw_loads_in_root_windows_are_branchless' (1360) panicked at crates\xcl\src\gpu\dxil\core_tests.rs:1463:9: flat heap reads must select the null-load view (descriptor 20): test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 2764 filtered out; finished in 0.24s ``` - Green, at `2d3e3fe1`, the same command: ``` test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 2764 filtered out; finished in 0.12s ``` - `cargo test --workspace --no-fail-fast -- --test-threads=4` (leaving out the 3 `uma_driver` tests that need a GPU upload segment this VM has not): 2868 passed, 6 failed, 51 ignored. SKIPPED: 28 (22 no wave64, 2 no heap windows, 3 no debug layer, 1 driver cache cannot be disabled). The 6 failures: `gpu::dxil::msaa_tests::gpu_direct_image_get_resinfo_d16`, `title_textures::tests::placed_title_textures_share_vram_and_preserve_pixels`, the 3 `stream_recheck_*` tests, and `test_title_runs_and_game_folder_is_untouched`. - Main `d52ff48c` on the same machine fails the same tests: `gpu_direct_image_get_resinfo_d16`, the 3 `stream_recheck_*` and `test_title_runs_and_game_folder_is_untouched`. Its parallel run lost the lib binary, so its lib tests come from a one-thread rerun that left out all of `uma_driver::tests` (2721 passed, 5 failed, 31 ignored); its counts are not comparable to the line above, the failing names are. - (the earlier head, before the rebase) RTX 5090 32 GB, driver 621.24, Ryzen 7 9800X3D, the retail title, `XCL_HEAP_FLAT=1` with heap windows, the debug layer and DRED on, `XCL_PREPARE=0`, 200 s. The change is in our integration build of open PRs (`93d11d74`: the same commit on top of it); the build under it alone (`1b108007`) is the "before": - before (`1b108007`), the device is removed on the first world frame: ``` [ 75.235][11864][INFO ] D3D12.X: split command list (type 2) around mid-list Wait after Write64 (#2) [ 75.654][37400][ERROR] D3D12 device removed: 0x887a0006 The GPU will not respond to more commands, most likely because of an invalid command passed by the calling application. [ 75.655][37400][ERROR] DRED device state: 7 [ 75.655][37400][ERROR] DRED page fault at GPU VA 0x0 = window 10 + 0x0; allocations there: []; recently freed: [] ``` - with this change (`93d11d74`), the frame is drawn and the run ends at its timer: ``` [ 77.993][41660][INFO ] D3D12.X: split command list (type 2) around mid-list Wait after Write64 (#1) [ 78.554][39156][INFO ] activity (2 s): 1 presents, 34 submits, 4995 draws, 7278 dispatches, 2 frame-event waits (0 timed out), 1 frame statistics (0 not flipped) [ 201.010][41788][INFO ] process ends (thread 41788) 19:12:29 pid 28360 exit code 0 (0x00000000) device removed lines: 0; DRED lines (past the 'DRED on' start line): 0 ``` The debug layer's other errors in that run: ids 1422, 527, 538 and 1047, 8 each (uninitialized placed targets, barrier states and the sparse queue race, seen before this change too); none of them a device removal. **Regression run** RTX 5090, 600 s each, JIT (`XCL_PREPARE=0`), seeded profile and held Enter. The main block is reused from the earlier gate-batch-t pair and was validated against the full main SHA and network line. Heap windows were on, but `XCL_HEAP_FLAT` was unset, so this smoke checks the default path rather than the opt-in path changed here. Head frames are 114% of main and peak commit is 102.2% of main; both are within the smoke limits. main `1c8b5514` (reused block): ``` xcl-smoke v1 commit: 1c8b551475e1e7bfe48f94448492a4c3544a2e0f gpu: NVIDIA GeForce RTX 5090 title: 9cc6a39e seconds: 600 exit: 0x0 frames shown: 1724 (PresentX 1725) presents per 2 s (last 3): 2 1 2 device removals: 0 crashes: 0 peak commit: 47581 MB ``` #3486 head `87c10e69`: ``` xcl-smoke v1 commit: 87c10e692424c5f212cadb99b88df0fb6b3f5e14 gpu: NVIDIA GeForce RTX 5090 title: 9cc6a39e seconds: 600 exit: 0x0 frames shown: 1962 (PresentX 1963) presents per 2 s (last 3): 2 2 2 device removals: 0 crashes: 0 peak commit: 48639 MB ``` **Not tested** - The run above is on our integration build, not on `main` + this commit alone; the title's first world frame is the only place it was seen. - A GPU run that shows the old access fault: the test runner's window buffers return zero out of range, so the difference is only in which descriptor is read (checked in the DXIL). - AMD and Intel. - A smoke pair with `XCL_HEAP_FLAT=1` at this head. **AI use** - Claude Code (Claude Opus 5.5, Claude Sonnet 5.5), Codex (GPT-6.2-Sol), Antigravity (Gemini 4 Neon, Gemini 4 Hydrogen): an agent swarm wrote, tested, reviewed and described this change. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Foniass commented 2026-12-01 09:11:22 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T09:11:22Z.


merge-check
base: 7d86c5d2b7
head: 2d3e3fe111
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2896 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: read the whole diff (lower_mem.rs +6/-2, core_tests.rs +3). Nothing changes by default (XCL_HEAP_FLAT is opt-in) and there's no added cost (the select moves after the add). A lane outside the windows, or under a false guard, now reads descriptor MEM_NULL_LOAD instead of window 0's view at its own address; values are still zeroed (sel(ok, v, z), ~431) and every caller only loads. Findings: (1) on main, descriptor 20 isn't a raw UAV yet: shared_heap writes it in null_window_views (console_heap.rs ~503), then fill_nulls (~511) replaces it with a null Texture2D SRV, and set_window_views only rewrites 4..19. Until #3349 is merged, these lanes access a descriptor of the wrong type (undefined; the HLSL accessors already do this today). The PR says it needs #3349 but isn't stacked on it, so it should merge after #3349. (2) The new assertion (core_tests.rs ~1463) only checks that some select ... i32 20 exists; the carry-rewrite form (opt.rs ~1424-1441) is argued, not tested. No smoke run: flat reads are off by default. Fine: in the carry case ok is the rewritten inside and slot is the add it replaces, so the null select still applies, and the test failed before the fix.
performance: no smoke run (the default path doesn't reach this change); not measured.
verdict: safe to merge after #3349 (on its own, the lanes it redirects read a descriptor that isn't a raw UAV yet; that's undefined, but it is opt-in and no worse than the HLSL accessors today)
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5

AI-written and posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7306340527 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3486#issuecomment-7306340527). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T09:11:22Z. --- merge-check base: 7d86c5d2b7845695031eeea1327aa81b6c439323 head: 2d3e3fe111598096165b7ec2a41e1fcc788cc91d merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2896 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none review: read the whole diff (lower_mem.rs +6/-2, core_tests.rs +3). Nothing changes by default (`XCL_HEAP_FLAT` is opt-in) and there's no added cost (the select moves after the add). A lane outside the windows, or under a false guard, now reads descriptor `MEM_NULL_LOAD` instead of window 0's view at its own address; values are still zeroed (`sel(ok, v, z)`, ~431) and every caller only loads. Findings: (1) on main, descriptor 20 isn't a raw UAV yet: `shared_heap` writes it in `null_window_views` (`console_heap.rs` ~503), then `fill_nulls` (~511) replaces it with a null Texture2D SRV, and `set_window_views` only rewrites 4..19. Until #3349 is merged, these lanes access a descriptor of the wrong type (undefined; the HLSL accessors already do this today). The PR says it needs #3349 but isn't stacked on it, so it should merge after #3349. (2) The new assertion (core_tests.rs ~1463) only checks that some `select ... i32 20` exists; the carry-rewrite form (`opt.rs` ~1424-1441) is argued, not tested. No smoke run: flat reads are off by default. Fine: in the carry case `ok` is the rewritten `inside` and `slot` is the add it replaces, so the null select still applies, and the test failed before the fix. performance: no smoke run (the default path doesn't reach this change); not measured. verdict: safe to merge after #3349 (on its own, the lanes it redirects read a descriptor that isn't a raw UAV yet; that's undefined, but it is opt-in and no worse than the HLSL accessors today) hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5 AI-written and posted by Foniass without a human check of each point.
Aniseto commented 2026-12-01 09:20:53 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Aniseto on 2026-12-01T09:20:53Z.


Ran the named raw_loads_in_root_windows_are_branchless test at 2d3e3fe1 on an NVIDIA Blackwell desktop part with 16 GB of VRAM.

Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB, mesh shaders) driver 32.0.16.2140 (621.40), Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09), MSVC 14.44.35207, DXC 1.9.2609.5, debug build, XCL_ADAPTER=NVIDIA, detached worktree at the exact PR head, no local patches.

XCL_ADAPTER=NVIDIA cargo test -q -p xcl --lib gpu::dxil::core_tests::raw_loads_in_root_windows_are_branchless -- --test-threads=1
1 passed; 0 failed; 0 ignored; 2764 filtered out      (exit 0)

The new test passes at this head; the author's red run without the fix is not repeated here. This adapter is NVIDIA, where the flat heap windows are relevant.

Not tested: the full workspace suite, a GPU run showing the original fault, a title run, XCL_HEAP_FLAT=1 in the world, the dependency on #3349, AMD adapters, Wine, wave64 hosts, release profile, game data.

AI-assisted (OpenCode), model: MiMo-V2.6-Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the test, wrote this report; the worktree was not modified; no game data was used.

<!-- greyfinch-sync:ivall/xcl:comment:7306568963 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3486#issuecomment-7306568963). Originally posted by [Aniseto](https://github.com/Aniseto) on 2026-12-01T09:20:53Z. --- Ran the named `raw_loads_in_root_windows_are_branchless` test at `2d3e3fe1` on an NVIDIA Blackwell desktop part with 16 GB of VRAM. Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB, mesh shaders) driver 32.0.16.2140 (621.40), Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09), MSVC 14.44.35207, DXC 1.9.2609.5, debug build, `XCL_ADAPTER=NVIDIA`, detached worktree at the exact PR head, no local patches. ``` XCL_ADAPTER=NVIDIA cargo test -q -p xcl --lib gpu::dxil::core_tests::raw_loads_in_root_windows_are_branchless -- --test-threads=1 1 passed; 0 failed; 0 ignored; 2764 filtered out (exit 0) ``` The new test passes at this head; the author's red run without the fix is not repeated here. This adapter is NVIDIA, where the flat heap windows are relevant. Not tested: the full workspace suite, a GPU run showing the original fault, a title run, `XCL_HEAP_FLAT=1` in the world, the dependency on #3349, AMD adapters, Wine, wave64 hosts, release profile, game data. AI-assisted (OpenCode), model: **MiMo-V2.6-Flash Free** - checked out the PR's head commit in a detached worktree, built it, ran the test, wrote this report; the worktree was not modified; no game data was used.
Foniass commented 2026-12-01 10:03:35 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T10:03:35Z.


Triage (#1607) – head 2d3e3fe

No open or merged PR makes the same change. Main (after #3500) still has sel(ok, w, 0) in with_mem_i32s, and #2428 keeps the window-0 select.
The null select comes after the descriptor-index add that FlatRead records, so the optimizer's carry rewrite of test/slot still feeds sel(ok, slot, MEM_NULL_LOAD). That looks right.
This depends on #3349 (open): until then main's shared_heap writes a Texture2D null SRV over MEM_NULL_LOAD, and this path would bind that descriptor as a raw buffer UAV. It should merge after #3349, or say so at the top of the description.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7307606328 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3486#issuecomment-7307606328). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T10:03:35Z. --- **Triage (#1607)** – head 2d3e3fe No open or merged PR makes the same change. Main (after #3500) still has `sel(ok, w, 0)` in `with_mem_i32s`, and #2428 keeps the window-0 select. The null select comes after the descriptor-index add that `FlatRead` records, so the optimizer's carry rewrite of `test`/`slot` still feeds `sel(ok, slot, MEM_NULL_LOAD)`. That looks right. This depends on #3349 (open): until then main's `shared_heap` writes a Texture2D null SRV over `MEM_NULL_LOAD`, and this path would bind that descriptor as a raw buffer UAV. It should merge after #3349, or say so at the top of the description. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
brainhay5 commented 2026-12-01 10:40:15 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by brainhay5 on 2026-12-01T10:40:15Z.


merge-check claim
head: 2d3e3fe111

<!-- greyfinch-sync:ivall/xcl:comment:7308533666 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3486#issuecomment-7308533666). Originally posted by [brainhay5](https://github.com/brainhay5) on 2026-12-01T10:40:15Z. --- merge-check claim head: 2d3e3fe111598096165b7ec2a41e1fcc788cc91d
brainhay5 commented 2026-12-01 10:46:17 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by brainhay5 on 2026-12-01T10:46:17Z.


merge-check claim
head: 2d3e3fe111

<!-- greyfinch-sync:ivall/xcl:comment:7308692038 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3486#issuecomment-7308692038). Originally posted by [brainhay5](https://github.com/brainhay5) on 2026-12-01T10:46:17Z. --- merge-check claim head: 2d3e3fe111598096165b7ec2a41e1fcc788cc91d
brainhay5 commented 2026-12-01 10:59:20 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by brainhay5 on 2026-12-01T10:59:20Z.


merge-check
base: 493dbd3dd0
head: 2d3e3fe111
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2899 passed, 1 failed, 51 ignored; 29 SKIPPED lines
failing: test_title_runs_and_game_folder_is_untouched
review: automated overnight check — diff inspected for safety only (no build/CI/toolchain/script changes, no process/network/runtime-loading code); no duplicate search performed; no line-by-line code review.
performance: not assessed beyond the suite.
verdict: safe to merge
hardware / tool and model: RTX 5070 Ti 16 GB, driver 610.88 (32.0.16.1088); Ryzen 7 5800X3D, 64 GB; Windows 11 22631; OpenCode agent, DeepSeek V4.1 Flash 1017

<!-- greyfinch-sync:ivall/xcl:comment:7309009359 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3486#issuecomment-7309009359). Originally posted by [brainhay5](https://github.com/brainhay5) on 2026-12-01T10:59:20Z. --- merge-check base: 493dbd3dd0cd50b4c3e8d28f73ab9b504fcd8158 head: 2d3e3fe111598096165b7ec2a41e1fcc788cc91d merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2899 passed, 1 failed, 51 ignored; 29 SKIPPED lines failing: test_title_runs_and_game_folder_is_untouched review: automated overnight check — diff inspected for safety only (no build/CI/toolchain/script changes, no process/network/runtime-loading code); no duplicate search performed; no line-by-line code review. performance: not assessed beyond the suite. verdict: safe to merge hardware / tool and model: RTX 5070 Ti 16 GB, driver 610.88 (32.0.16.1088); Ryzen 7 5800X3D, 64 GB; Windows 11 22631; OpenCode agent, DeepSeek V4.1 Flash 1017
bmjask commented 2026-12-02 08:48:14 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T08:48:14Z.

Code review location: crates/xcl/src/gpu/dxil/lower_mem.rs; line 426

@@ -416,11 +416,15 @@ impl Lw {
             let carry_case = high.filter(|&(_, hi)| matches!(hi, Value::Inst(_))).map(|(_, hi)| (hi, self.high_one_slot()));
             let inside = self.cmpc(Pred::ULt, w, self.mems.len() as u32);
             let ok = if let Some(g) = guard { self.and(g, inside) } else { inside };
-            let safe = self.sel(ok, w, z);
-            let i = self.addc(safe, crate::gpu::recomp::MEM_HEAP_BASE);
+            // (an access outside the windows or under a false guard still runs here, without a
+            // branch: it reads the null view, as the HLSL accessors do, never a window's memory.
+            // The optimizer's carry rewrite of `inside` and of this add keeps that: `FlatRead`)
+            let i = self.addc(w, crate::gpu::recomp::MEM_HEAP_BASE);
             if let (Some((hi, (valid1, slot1))), Value::Inst(test), Value::Inst(slot)) = (carry_case, inside, i) {
                 self.s.m.flat_reads.push(super::module::FlatRead { hi, test, slot, valid1, slot1 });
             }
+            let null = self.c(crate::gpu::recomp::MEM_NULL_LOAD);

Flat reads now index MEM_NULL_LOAD (descriptor 20) as a RWByteAddressBuffer, but on main that slot holds a Texture2D null SRV. console_heap::shared_heap runs null_window_views (line 503) before fill_nulls(MEM_HEAP_BASE..cap) (line 511), which copies an even-index Texture2D SRV over slot 20. That ordering is fixed in #3349, which is still open, and this branch isn't stacked on it. If this merges first, with XCL_HEAP_FLAT=1 and heap windows on, any lane with VAR_WIN >= mems.len() or a false EXEC/num_records guard creates a raw-buffer UAV handle from a Texture2D SRV descriptor. That descriptor-type mismatch is undefined: garbage reads, a GBV error, or device removal. The regression run at 2d3e3fe1 had XCL_HEAP_FLAT unset, so this path wasn't exercised. Stacking on #3349, or including its 3-line reorder here, would make it safe to merge alone.

<!-- greyfinch-sync:ivall/xcl:review-comment:4766881276 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3486#discussion_r4766881276). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T08:48:14Z. **Code review location:** `crates/xcl/src/gpu/dxil/lower_mem.rs`; line 426 ~~~~diff @@ -416,11 +416,15 @@ impl Lw { let carry_case = high.filter(|&(_, hi)| matches!(hi, Value::Inst(_))).map(|(_, hi)| (hi, self.high_one_slot())); let inside = self.cmpc(Pred::ULt, w, self.mems.len() as u32); let ok = if let Some(g) = guard { self.and(g, inside) } else { inside }; - let safe = self.sel(ok, w, z); - let i = self.addc(safe, crate::gpu::recomp::MEM_HEAP_BASE); + // (an access outside the windows or under a false guard still runs here, without a + // branch: it reads the null view, as the HLSL accessors do, never a window's memory. + // The optimizer's carry rewrite of `inside` and of this add keeps that: `FlatRead`) + let i = self.addc(w, crate::gpu::recomp::MEM_HEAP_BASE); if let (Some((hi, (valid1, slot1))), Value::Inst(test), Value::Inst(slot)) = (carry_case, inside, i) { self.s.m.flat_reads.push(super::module::FlatRead { hi, test, slot, valid1, slot1 }); } + let null = self.c(crate::gpu::recomp::MEM_NULL_LOAD); ~~~~ --- Flat reads now index MEM_NULL_LOAD (descriptor 20) as a RWByteAddressBuffer, but on main that slot holds a Texture2D null SRV. `console_heap::shared_heap` runs `null_window_views` (line 503) before `fill_nulls(MEM_HEAP_BASE..cap)` (line 511), which copies an even-index Texture2D SRV over slot 20. That ordering is fixed in #3349, which is still open, and this branch isn't stacked on it. If this merges first, with XCL_HEAP_FLAT=1 and heap windows on, any lane with VAR_WIN >= mems.len() or a false EXEC/num_records guard creates a raw-buffer UAV handle from a Texture2D SRV descriptor. That descriptor-type mismatch is undefined: garbage reads, a GBV error, or device removal. The regression run at 2d3e3fe1 had XCL_HEAP_FLAT unset, so this path wasn't exercised. Stacking on #3349, or including its 3-line reorder here, would make it safe to merge alone.
bmjask commented 2026-12-02 08:48:14 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T08:48:14Z.

Review: COMMENTED


Review of 2d3e3fe1: 2 finding(s). 1 are inline. These are on lines outside the diff:

crates/xcl/src/gpu/dxil/lower_mem.rs:1191: scalar_flat_read, the flat s_buffer_load path from #3500, still computes slot = sel(valid, w, 0) + MEM_HEAP_BASE, so an out-of-window access still reads window 0's descriptor, the root cause this PR fixes in with_mem_i32s. Under XCL_HEAP_FLAT=1, an s_buffer_load whose V# high word is outside the windows still runs rawBufferLoad on window 0 (only masked afterwards by lim = 0). raw_loads_in_root_windows_are_branchless includes S_BUFFER_LOAD_DWORDX4 and still passes because it only checks that some select uses , i32 20. high_one_slot (lower_window.rs:170) has the same window-0 fallback, so a shared heap_load_slot(ok, w) returning sel(ok, w + MEM_HEAP_BASE, MEM_NULL_LOAD) used at all three sites would fix them together.


These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.

<!-- greyfinch-sync:ivall/xcl:review:6147399243 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3486#pullrequestreview-6147399243). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T08:48:14Z. **Review:** COMMENTED --- Review of `2d3e3fe1`: 2 finding(s). 1 are inline. These are on lines outside the diff: **`crates/xcl/src/gpu/dxil/lower_mem.rs:1191`**: `scalar_flat_read`, the flat s_buffer_load path from #3500, still computes `slot = sel(valid, w, 0) + MEM_HEAP_BASE`, so an out-of-window access still reads window 0's descriptor, the root cause this PR fixes in `with_mem_i32s`. Under XCL_HEAP_FLAT=1, an s_buffer_load whose V# high word is outside the windows still runs rawBufferLoad on window 0 (only masked afterwards by lim = 0). `raw_loads_in_root_windows_are_branchless` includes S_BUFFER_LOAD_DWORDX4 and still passes because it only checks that some select uses `, i32 20`. `high_one_slot` (lower_window.rs:170) has the same window-0 fallback, so a shared `heap_load_slot(ok, w)` returning `sel(ok, w + MEM_HEAP_BASE, MEM_NULL_LOAD)` used at all three sites would fix them together. --- _These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it._
Foniass commented 2026-12-02 09:59:28 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T09:59:28Z.


Follow-up review (head df2d4d0f, since 2d3e3fe, diff read, not a merge-check; checks red):

  • MEM_NULL_LOAD is not a raw UAV on main until #3349 lands: partly fixed. The description and commit now say it depends on #3349, but #3349 is still open and this PR is not stacked on it; it builds on main alone, where shared_heap still writes the null window views first (console_heap.rs ~503) and fill_nulls (~511) then puts a Texture2D null SRV over MEM_NULL_LOAD. Merged first, the redirected lanes (now including the scalar path, lower_mem.rs ~1193-1197) would bind that descriptor as a raw buffer UAV with XCL_HEAP_FLAT=1, so it has to merge after #3349.
  • The FlatRead carry rewrite is argued, not tested: still open; the new block (core_tests.rs ~1535-1549) covers scalar_flat_read, and nothing checks the rewrite in opt.rs ~1424-1441 next to the null select.
  • Triage (keep open, merge after #3349): still applies.

New:

  • The smoke block is stale. The PR's xcl-smoke block names 2d3e3fe1, not the head df2d4d0f (the reason PR description is red).
  • The description does not cover the scalar change. df2d4d0f also changes scalar_flat_read (lower_mem.rs ~1191-1198) and adds a scalar test, but What is in it lists only with_mem_i32s and every Tested result is at 2d3e3fe1, before it.

Fine: the null select comes after the descriptor-index add, so after the carry rewrite a lane with no valid window still gets MEM_NULL_LOAD and the window-0 fallback in high_one_slot can no longer be reached; values are still masked; opt-in (XCL_HEAP_FLAT); the scalar test reaches scalar_flat_read.

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7341791156 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3486#issuecomment-7341791156). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-02T09:59:28Z. --- Follow-up review (head df2d4d0f, since 2d3e3fe, diff read, not a merge-check; checks red): - **`MEM_NULL_LOAD` is not a raw UAV on `main` until #3349 lands:** partly fixed. The description and commit now say it depends on #3349, but #3349 is still open and this PR is not stacked on it; it builds on `main` alone, where `shared_heap` still writes the null window views first (`console_heap.rs` ~503) and `fill_nulls` (~511) then puts a Texture2D null SRV over `MEM_NULL_LOAD`. Merged first, the redirected lanes (now including the scalar path, `lower_mem.rs` ~1193-1197) would bind that descriptor as a raw buffer UAV with `XCL_HEAP_FLAT=1`, so it has to merge after #3349. - **The `FlatRead` carry rewrite is argued, not tested:** still open; the new block (`core_tests.rs` ~1535-1549) covers `scalar_flat_read`, and nothing checks the rewrite in `opt.rs` ~1424-1441 next to the null select. - **Triage (keep open, merge after #3349):** still applies. New: - **The smoke block is stale.** The PR's `xcl-smoke` block names `2d3e3fe1`, not the head `df2d4d0f` (the reason `PR description` is red). - **The description does not cover the scalar change.** `df2d4d0f` also changes `scalar_flat_read` (`lower_mem.rs` ~1191-1198) and adds a scalar test, but **What is in it** lists only `with_mem_i32s` and every **Tested** result is at `2d3e3fe1`, before it. Fine: the null select comes after the descriptor-index add, so after the carry rewrite a lane with no valid window still gets `MEM_NULL_LOAD` and the window-0 fallback in `high_one_slot` can no longer be reached; values are still masked; opt-in (`XCL_HEAP_FLAT`); the scalar test reaches `scalar_flat_read`. AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
Pipodi commented 2026-12-02 10:27:56 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Pipodi on 2026-12-02T10:27:56Z.


merge-check
base: 1c8b551475
head: df2d4d0f1a
merge: clean (merge commit d5e88baec8118dc557a45f3145ca87b438075968)
build: cargo build --workspace -> ok (and cargo build --release -p xcl -> ok)
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2909 passed, 0 failed, 51 ignored; failing: none. 25 SKIPPED lines (22 no wave64, 2 no heap windows, 1 cannot disable the driver cache). raw_loads_in_root_windows_are_branchless runs and passes; with the base's lower_mem.rs it fails at core_tests.rs:1503 (vector flat read), and with only the scalar_flat_read hunk reverted it fails at core_tests.rs:1549 (scalar flat read), so both new assertions catch their half of the change.
review:

  • Merge order (blocking): on this base MEM_NULL_LOAD (descriptor 20) is not a raw buffer UAV. console_heap::shared_heap writes null_window_views (console_heap.rs:503) and then fill_nulls(MEM_HEAP_BASE..cap) (:511) copies the null block over it; 20 is even, so it ends up a Texture2D null SRV (null_views_in, :555-562). With XCL_HEAP_FLAT=1, every lane outside the windows or under a false guard now binds that descriptor as a raw UAV, where before it read window 0 at a bounds-checked address and the value was masked to 0 anyway. The description says it depends on #3349 (still open), but the PR is not stacked on it and merges into main alone. It has to land after #3349.
  • Correct otherwise: only loads take this path (with_mem_i32s callers: buffer loads in lower_mem.rs:337, image/BVH loads in lower_image.rs:176/285); stores and atomics keep the guarded with_mem_many_tys form. The null select sits after the descriptor-index add, so opt.rs 1424-1441 can rewrite test/slot for the high-dword carry and a lane with no valid window still gets MEM_NULL_LOAD; ok is inside there (the carry case requires no guard). high_one_slot's window-0 fallback is no longer reachable. Values stay masked to 0.
  • Test gap (minor): the test checks only that a select ... i32 20 exists in the disassembly, not that the carry-rewritten form (FlatRead) keeps it.
  • Scope: 34 lines, one commit, opt-in path only. The PR description still lists only with_mem_i32s and has test results and a smoke block from 2d3e3fe1, not from this head (PR description check is red).
    performance: XCL_HEAP_FLAT is off by default, so the default path is unchanged. The flat path gains one select per read. Smoke pair on the retail title, 60 s, same scripted presses on both sides, one untimed warm-up run before each: main 1611 frames, peak commit 19846 MB; merge 1600 frames (99.3 %), 20310 MB (102.3 %); 0 device removals and 0 crashes on both. The smoke runs do not set XCL_HEAP_FLAT, so they do not reach the changed code.

main (base):

xcl-smoke v1
commit: 1c8b551475e1e7bfe48f94448492a4c3544a2e0f
gpu: NVIDIA GeForce RTX 4090
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1611 (PresentX 1611)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 19846 MB

this PR merged into base:

xcl-smoke v1
commit: d5e88baec8118dc557a45f3145ca87b438075968
gpu: NVIDIA GeForce RTX 4090
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1600 (PresentX 1600)
presents per 2 s (last 3): 60 61 60
device removals: 0
crashes: 0
peak commit: 20310 MB

verdict: not yet: merge after #3349 (on main today MEM_NULL_LOAD is a Texture2D null SRV, so the flat path would bind it as a raw UAV); rebase or stack on it and the rest holds
hardware / tool and model: NVIDIA GeForce RTX 4090 24 GB, driver 621.40; Intel Core i9-13900K, 32 GB; Windows 11 build 26300; rustc 1.100.0; debug suite, release smoke. Claude Code, Claude Opus 5.5 (ran the merge, build, suite, revert test and smoke pair, and wrote this check).

<!-- greyfinch-sync:ivall/xcl:comment:7342508976 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3486#issuecomment-7342508976). Originally posted by [Pipodi](https://github.com/Pipodi) on 2026-12-02T10:27:56Z. --- merge-check base: 1c8b551475e1e7bfe48f94448492a4c3544a2e0f head: df2d4d0f1ad1da1d4adbfcf025ae2781507f9c94 merge: clean (merge commit d5e88baec8118dc557a45f3145ca87b438075968) build: cargo build --workspace -> ok (and cargo build --release -p xcl -> ok) tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2909 passed, 0 failed, 51 ignored; failing: none. 25 SKIPPED lines (22 no wave64, 2 no heap windows, 1 cannot disable the driver cache). `raw_loads_in_root_windows_are_branchless` runs and passes; with the base's `lower_mem.rs` it fails at core_tests.rs:1503 (vector flat read), and with only the `scalar_flat_read` hunk reverted it fails at core_tests.rs:1549 (scalar flat read), so both new assertions catch their half of the change. review: - Merge order (blocking): on this base `MEM_NULL_LOAD` (descriptor 20) is not a raw buffer UAV. `console_heap::shared_heap` writes `null_window_views` (console_heap.rs:503) and then `fill_nulls(MEM_HEAP_BASE..cap)` (:511) copies the null block over it; 20 is even, so it ends up a Texture2D null SRV (`null_views_in`, :555-562). With `XCL_HEAP_FLAT=1`, every lane outside the windows or under a false guard now binds that descriptor as a raw UAV, where before it read window 0 at a bounds-checked address and the value was masked to 0 anyway. The description says it depends on #3349 (still open), but the PR is not stacked on it and merges into main alone. It has to land after #3349. - Correct otherwise: only loads take this path (`with_mem_i32s` callers: buffer loads in lower_mem.rs:337, image/BVH loads in lower_image.rs:176/285); stores and atomics keep the guarded `with_mem_many_tys` form. The null select sits after the descriptor-index add, so `opt.rs` 1424-1441 can rewrite `test`/`slot` for the high-dword carry and a lane with no valid window still gets `MEM_NULL_LOAD`; `ok` is `inside` there (the carry case requires no guard). `high_one_slot`'s window-0 fallback is no longer reachable. Values stay masked to 0. - Test gap (minor): the test checks only that a `select ... i32 20` exists in the disassembly, not that the carry-rewritten form (`FlatRead`) keeps it. - Scope: 34 lines, one commit, opt-in path only. The PR description still lists only `with_mem_i32s` and has test results and a smoke block from `2d3e3fe1`, not from this head (`PR description` check is red). performance: XCL_HEAP_FLAT is off by default, so the default path is unchanged. The flat path gains one select per read. Smoke pair on the retail title, 60 s, same scripted presses on both sides, one untimed warm-up run before each: main 1611 frames, peak commit 19846 MB; merge 1600 frames (99.3 %), 20310 MB (102.3 %); 0 device removals and 0 crashes on both. The smoke runs do not set XCL_HEAP_FLAT, so they do not reach the changed code. main (base): ``` xcl-smoke v1 commit: 1c8b551475e1e7bfe48f94448492a4c3544a2e0f gpu: NVIDIA GeForce RTX 4090 title: 21222967 seconds: 60 exit: 0x0 frames shown: 1611 (PresentX 1611) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 19846 MB ``` this PR merged into base: ``` xcl-smoke v1 commit: d5e88baec8118dc557a45f3145ca87b438075968 gpu: NVIDIA GeForce RTX 4090 title: 21222967 seconds: 60 exit: 0x0 frames shown: 1600 (PresentX 1600) presents per 2 s (last 3): 60 61 60 device removals: 0 crashes: 0 peak commit: 20310 MB ``` verdict: not yet: merge after #3349 (on main today `MEM_NULL_LOAD` is a Texture2D null SRV, so the flat path would bind it as a raw UAV); rebase or stack on it and the rest holds hardware / tool and model: NVIDIA GeForce RTX 4090 24 GB, driver 621.40; Intel Core i9-13900K, 32 GB; Windows 11 build 26300; rustc 1.100.0; debug suite, release smoke. Claude Code, Claude Opus 5.5 (ran the merge, build, suite, revert test and smoke pair, and wrote this check).
KDenKC commented 2026-12-02 10:29:05 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by KDenKC on 2026-12-02T10:29:05Z.


@Pipodi thanks for picking this up; a heads-up so your merge-check isn't wasted: a new head is coming shortly. It adds bmjask's last point (high_one_slot also takes the null view), a test for the FlatRead carry rewrite that Foniass asked for, and it will be stacked on #3349 (which provides the raw-UAV null view this PR relies on). I'll post here the moment it's pushed.

AI use: an agent swarm: Claude Opus 5.5, Claude Sonnet 5.5, GPT-6.2-Sol, Gemini 4 Neon and Gemini 4 Hydrogen.

<!-- greyfinch-sync:ivall/xcl:comment:7342536592 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3486#issuecomment-7342536592). Originally posted by [KDenKC](https://github.com/KDenKC) on 2026-12-02T10:29:05Z. --- @Pipodi thanks for picking this up; a heads-up so your merge-check isn't wasted: a new head is coming shortly. It adds bmjask's last point (`high_one_slot` also takes the null view), a test for the FlatRead carry rewrite that Foniass asked for, and it will be stacked on #3349 (which provides the raw-UAV null view this PR relies on). I'll post here the moment it's pushed. AI use: an agent swarm: Claude Opus 5.5, Claude Sonnet 5.5, GPT-6.2-Sol, Gemini 4 Neon and Gemini 4 Hydrogen.
KDenKC commented 2026-12-02 10:52:06 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by KDenKC on 2026-12-02T10:52:06Z.


@Pipodi the new head is pushed: 87c10e69, stacked on #3349 (main 1c8b5514 + #3349's commit unchanged + this PR's one commit). Since df2d4d0f: high_one_slot also takes the null view, and a test for the FlatRead carry rewrite (the_flat_read_carry_rewrite_keeps_the_null_select). Whole suite at 87c10e69 on an RTX 3090: 2903 passed, 5 failed (the same 5 as main), 51 ignored, 28 SKIPPED. The description and a new smoke pair follow.

AI use: an agent swarm: Claude Opus 5.5, Claude Sonnet 5.5, GPT-6.2-Sol, Gemini 4 Neon and Gemini 4 Hydrogen.

<!-- greyfinch-sync:ivall/xcl:comment:7343094960 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3486#issuecomment-7343094960). Originally posted by [KDenKC](https://github.com/KDenKC) on 2026-12-02T10:52:06Z. --- @Pipodi the new head is pushed: `87c10e69`, stacked on #3349 (`main` `1c8b5514` + #3349's commit unchanged + this PR's one commit). Since `df2d4d0f`: `high_one_slot` also takes the null view, and a test for the FlatRead carry rewrite (`the_flat_read_carry_rewrite_keeps_the_null_select`). Whole suite at `87c10e69` on an RTX 3090: 2903 passed, 5 failed (the same 5 as `main`), 51 ignored, 28 SKIPPED. The description and a new smoke pair follow. AI use: an agent swarm: Claude Opus 5.5, Claude Sonnet 5.5, GPT-6.2-Sol, Gemini 4 Neon and Gemini 4 Hydrogen.
Foniass commented 2026-12-02 10:54:12 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T10:54:12Z.


Follow-up review (head 87c10e69, since df2d4d0f, diff read, not a merge-check; checks red):

  • MEM_NULL_LOAD is not a raw UAV on main until #3349 lands: fixed in the branch; it now carries #3349's commit (42bd1090, the same patch as 5dc64ea7), so it is stacked on #3349 and no longer sends lanes to a Texture2D null SRV whichever order they merge in. A Stacked on #3349 line at the top would make that explicit.
  • The FlatRead carry rewrite is argued, not tested: fixed; the_flat_read_carry_rewrite_keeps_the_null_select (module/opt.rs ~1983) checks that the null select stays on top of the rewritten slot.
  • The smoke block is stale: still open; it still names 2d3e3fe1, not 87c10e69.
  • The description does not cover the whole change: still open. What is in it still says "one commit" and lists only with_mem_i32s; it does not mention the scalar scalar_flat_read change, the new lower_window.rs change (~166-171: the window choice for a lane outside the windows now selects MEM_NULL_LOAD instead of window 0) or the carried #3349 commit, and every Tested result is from 2d3e3fe1.

New: none.

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7343144472 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3486#issuecomment-7343144472). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-02T10:54:12Z. --- Follow-up review (head 87c10e69, since df2d4d0f, diff read, not a merge-check; checks red): - **`MEM_NULL_LOAD` is not a raw UAV on `main` until #3349 lands:** fixed in the branch; it now carries #3349's commit (`42bd1090`, the same patch as `5dc64ea7`), so it is stacked on #3349 and no longer sends lanes to a Texture2D null SRV whichever order they merge in. A `Stacked on #3349` line at the top would make that explicit. - **The `FlatRead` carry rewrite is argued, not tested:** fixed; `the_flat_read_carry_rewrite_keeps_the_null_select` (`module/opt.rs` ~1983) checks that the null select stays on top of the rewritten slot. - **The smoke block is stale:** still open; it still names `2d3e3fe1`, not `87c10e69`. - **The description does not cover the whole change:** still open. **What is in it** still says "one commit" and lists only `with_mem_i32s`; it does not mention the scalar `scalar_flat_read` change, the new `lower_window.rs` change (~166-171: the window choice for a lane outside the windows now selects `MEM_NULL_LOAD` instead of window 0) or the carried #3349 commit, and every **Tested** result is from `2d3e3fe1`. New: none. AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
KDenKC commented 2026-12-02 11:18:10 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by KDenKC on 2026-12-02T11:18:10Z.


@Pipodi @Foniass New head 87c10e69 (stacked on #3349) has its regression pair: 600 s smoke on an RTX 5090, main 1c8b5514 1724 frames, 0 removals, 47581 MB peak commit; 87c10e69 1962 frames, 0 removals, 48639 MB. Both blocks are in the description's Regression run, and the whole suite at 87c10e69 on an RTX 3090 is 2903 passed, 5 failed (the same 5 as main), 51 ignored.

AI use: an agent swarm: Claude Opus 5.5, Claude Sonnet 5.5, GPT-6.2-Sol, Gemini 4 Neon and Gemini 4 Hydrogen.

<!-- greyfinch-sync:ivall/xcl:comment:7343719919 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3486#issuecomment-7343719919). Originally posted by [KDenKC](https://github.com/KDenKC) on 2026-12-02T11:18:10Z. --- @Pipodi @Foniass New head `87c10e69` (stacked on #3349) has its regression pair: 600 s smoke on an RTX 5090, `main` `1c8b5514` 1724 frames, 0 removals, 47581 MB peak commit; `87c10e69` 1962 frames, 0 removals, 48639 MB. Both blocks are in the description's Regression run, and the whole suite at `87c10e69` on an RTX 3090 is 2903 passed, 5 failed (the same 5 as `main`), 51 ignored. AI use: an agent swarm: Claude Opus 5.5, Claude Sonnet 5.5, GPT-6.2-Sol, Gemini 4 Neon and Gemini 4 Hydrogen.
Pipodi commented 2026-12-02 11:23:29 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Pipodi on 2026-12-02T11:23:29Z.


merge-check
base: 1c8b551475
head: 87c10e6924
merge: clean (merge commit be998edb2b43389df9d7c753461e62c7fa913dd1). The PR is stacked on #3349 (still open), so this merge brings #3349's commit too: 42bd1090 here has the same git patch-id --stable as #3349's head 5dc64ea7. Merging #3349 first and then this PR is also clean and gives the identical tree (0-line diff against be998edb).
build: cargo build --workspace -> ok (and cargo build --release -p xcl -> ok)
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2908 passed, 3 failed, 51 ignored; failing: title_textures::tests::placed_title_textures_share_vram_and_preserve_pixels (title_textures.rs:6368, "superseded unaligned extra_pages must be reclaimed immediately"), and stream_recheck_partial_upload_without_an_entry_queues_a_whole_upload and stream_recheck_schedule_catches_late_writes_and_resets_milestones (PoisonError after the first one). They are flaky and fail on the base too: cargo test -p xcl --lib title_textures, run 3 times on each side: the merge passed 3/3 (65 passed); the base 1c8b5514 failed run 1 (the same placed_... and stream_recheck_schedule_...) and passed runs 2 and 3. This PR touches none of that code. 25 SKIPPED lines (22 no wave64, 2 no heap windows, 1 cannot disable the driver cache). raw_loads_in_root_windows_are_branchless, the_flat_read_carry_rewrite_keeps_the_null_select and #3349's shared_heap_preserves_null_window_raw_uavs run and pass.
Reverting fixes, with the tests kept: base lower_mem.rs -> raw_loads_... fails at core_tests.rs:1503 (vector flat read); only the scalar_flat_read hunk reverted -> fails at :1549 (scalar flat read). Both earlier results hold. The new the_flat_read_carry_rewrite_keeps_the_null_select still passes with the base lower_mem.rs and lower_window.rs together (no recompiler change at all): it builds its IR by hand and checks the unchanged opt.rs rewrite, so it locks that behaviour in rather than failing without this PR. Reverting only the lower_window.rs hunk (high_one_slot) passes every test.
review:

  • The merge-order point from my check on df2d4d0f is resolved: the merge result now has #3349's fix, so MEM_NULL_LOAD is a raw buffer UAV when the flat path binds it. Whoever merges should either merge #3349 first (then this PR adds only its own commit, see merge:) or close #3349 as included here; both give the same tree.
  • New since df2d4d0f: high_one_slot (lower_window.rs) falls back to MEM_NULL_LOAD instead of window 0. This is correct but no test catches it, and on the flat-read path it cannot be reached. Its only user is the FlatRead carry rewrite: the slot becomes carry ? slot1 : window 0 and the read's test carry ? valid1 : true, and the null select on top already picks MEM_NULL_LOAD whenever valid1 is false. That makes it consistency only, which is how the commit message presents it.
  • Test (minor): see tests:. The new carry test is a guard on the optimizer and does not fail without the change. The vector and scalar assertions in raw_loads_... are the ones that fail without it.
  • The rest of the diff is unchanged from df2d4d0f and still holds: only loads take the flat path, stores and atomics keep the guarded form, and values stay masked to 0. I read the whole diff (lower_mem.rs, lower_window.rs, core_tests.rs, module/opt.rs, and #3349's console_heap.rs change and test).
    performance: no cost by default: XCL_HEAP_FLAT (and XCL_HEAP_WINDOWS) are off, so the default path is unchanged. The flat path gains one select per read. Smoke pair on the retail title, 60 s, same scripted presses on both sides, one untimed warm-up run before each: main 1611 frames, peak commit 19846 MB; merge 1598 frames (99.2 %), 19965 MB (100.6 %); 0 device removals and 0 crashes on both. Those runs do not reach the changed code.
    Extra, not a regression pair: one more run of the merge with XCL_HEAP_WINDOWS=1 XCL_HEAP_FLAT=1 (same 60 s and presses, warm-up first). The log confirms heap windows were on ("memory windows from the shared descriptor heap"); XCL_HEAP_FLAT came from the same environment but the log does not print it. It showed 1347 frames, peak commit 21980 MB, 0 device removals, 0 crashes. It is not comparable to the default runs: a different shader key set.

main (base):

xcl-smoke v1
commit: 1c8b551475e1e7bfe48f94448492a4c3544a2e0f
gpu: NVIDIA GeForce RTX 4090
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1611 (PresentX 1611)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 19846 MB

this PR merged into base:

xcl-smoke v1
commit: be998edb2b43389df9d7c753461e62c7fa913dd1
gpu: NVIDIA GeForce RTX 4090
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1598 (PresentX 1598)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 19965 MB

extra, this PR merged into base with XCL_HEAP_WINDOWS=1 XCL_HEAP_FLAT=1:

xcl-smoke v1
commit: be998edb2b43389df9d7c753461e62c7fa913dd1
gpu: NVIDIA GeForce RTX 4090
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1347 (PresentX 1347)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 21980 MB

verdict: safe to merge (it lands #3349's commit too: merge #3349 first or close it as included)
hardware / tool and model: NVIDIA GeForce RTX 4090 24 GB, driver 621.40; Intel Core i9-13900K, 32 GB; Windows 11 build 26300; rustc 1.100.0; debug suite, release smoke. Claude Code, Claude Opus 5.5 (ran the merge, build, suite, reruns, revert tests and smoke runs, and wrote this check).

<!-- greyfinch-sync:ivall/xcl:comment:7343853667 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3486#issuecomment-7343853667). Originally posted by [Pipodi](https://github.com/Pipodi) on 2026-12-02T11:23:29Z. --- merge-check base: 1c8b551475e1e7bfe48f94448492a4c3544a2e0f head: 87c10e692424c5f212cadb99b88df0fb6b3f5e14 merge: clean (merge commit be998edb2b43389df9d7c753461e62c7fa913dd1). The PR is stacked on #3349 (still open), so this merge brings #3349's commit too: 42bd1090 here has the same `git patch-id --stable` as #3349's head 5dc64ea7. Merging #3349 first and then this PR is also clean and gives the identical tree (0-line diff against be998edb). build: cargo build --workspace -> ok (and cargo build --release -p xcl -> ok) tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2908 passed, 3 failed, 51 ignored; failing: `title_textures::tests::placed_title_textures_share_vram_and_preserve_pixels` (title_textures.rs:6368, "superseded unaligned extra_pages must be reclaimed immediately"), and `stream_recheck_partial_upload_without_an_entry_queues_a_whole_upload` and `stream_recheck_schedule_catches_late_writes_and_resets_milestones` (PoisonError after the first one). They are flaky and fail on the base too: `cargo test -p xcl --lib title_textures`, run 3 times on each side: the merge passed 3/3 (65 passed); the base 1c8b5514 failed run 1 (the same `placed_...` and `stream_recheck_schedule_...`) and passed runs 2 and 3. This PR touches none of that code. 25 SKIPPED lines (22 no wave64, 2 no heap windows, 1 cannot disable the driver cache). `raw_loads_in_root_windows_are_branchless`, `the_flat_read_carry_rewrite_keeps_the_null_select` and #3349's `shared_heap_preserves_null_window_raw_uavs` run and pass. Reverting fixes, with the tests kept: base `lower_mem.rs` -> `raw_loads_...` fails at core_tests.rs:1503 (vector flat read); only the `scalar_flat_read` hunk reverted -> fails at :1549 (scalar flat read). Both earlier results hold. The new `the_flat_read_carry_rewrite_keeps_the_null_select` still passes with the base `lower_mem.rs` and `lower_window.rs` together (no recompiler change at all): it builds its IR by hand and checks the unchanged `opt.rs` rewrite, so it locks that behaviour in rather than failing without this PR. Reverting only the `lower_window.rs` hunk (`high_one_slot`) passes every test. review: - The merge-order point from my check on df2d4d0f is resolved: the merge result now has #3349's fix, so `MEM_NULL_LOAD` is a raw buffer UAV when the flat path binds it. Whoever merges should either merge #3349 first (then this PR adds only its own commit, see `merge:`) or close #3349 as included here; both give the same tree. - New since df2d4d0f: `high_one_slot` (lower_window.rs) falls back to `MEM_NULL_LOAD` instead of window 0. This is correct but no test catches it, and on the flat-read path it cannot be reached. Its only user is the `FlatRead` carry rewrite: the slot becomes `carry ? slot1 : window 0` and the read's test `carry ? valid1 : true`, and the null select on top already picks `MEM_NULL_LOAD` whenever `valid1` is false. That makes it consistency only, which is how the commit message presents it. - Test (minor): see `tests:`. The new carry test is a guard on the optimizer and does not fail without the change. The vector and scalar assertions in `raw_loads_...` are the ones that fail without it. - The rest of the diff is unchanged from df2d4d0f and still holds: only loads take the flat path, stores and atomics keep the guarded form, and values stay masked to 0. I read the whole diff (lower_mem.rs, lower_window.rs, core_tests.rs, module/opt.rs, and #3349's console_heap.rs change and test). performance: no cost by default: XCL_HEAP_FLAT (and XCL_HEAP_WINDOWS) are off, so the default path is unchanged. The flat path gains one select per read. Smoke pair on the retail title, 60 s, same scripted presses on both sides, one untimed warm-up run before each: main 1611 frames, peak commit 19846 MB; merge 1598 frames (99.2 %), 19965 MB (100.6 %); 0 device removals and 0 crashes on both. Those runs do not reach the changed code. Extra, not a regression pair: one more run of the merge with XCL_HEAP_WINDOWS=1 XCL_HEAP_FLAT=1 (same 60 s and presses, warm-up first). The log confirms heap windows were on ("memory windows from the shared descriptor heap"); XCL_HEAP_FLAT came from the same environment but the log does not print it. It showed 1347 frames, peak commit 21980 MB, 0 device removals, 0 crashes. It is not comparable to the default runs: a different shader key set. main (base): ``` xcl-smoke v1 commit: 1c8b551475e1e7bfe48f94448492a4c3544a2e0f gpu: NVIDIA GeForce RTX 4090 title: 21222967 seconds: 60 exit: 0x0 frames shown: 1611 (PresentX 1611) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 19846 MB ``` this PR merged into base: ``` xcl-smoke v1 commit: be998edb2b43389df9d7c753461e62c7fa913dd1 gpu: NVIDIA GeForce RTX 4090 title: 21222967 seconds: 60 exit: 0x0 frames shown: 1598 (PresentX 1598) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 19965 MB ``` extra, this PR merged into base with XCL_HEAP_WINDOWS=1 XCL_HEAP_FLAT=1: ``` xcl-smoke v1 commit: be998edb2b43389df9d7c753461e62c7fa913dd1 gpu: NVIDIA GeForce RTX 4090 title: 21222967 seconds: 60 exit: 0x0 frames shown: 1347 (PresentX 1347) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 21980 MB ``` verdict: safe to merge (it lands #3349's commit too: merge #3349 first or close it as included) hardware / tool and model: NVIDIA GeForce RTX 4090 24 GB, driver 621.40; Intel Core i9-13900K, 32 GB; Windows 11 build 26300; rustc 1.100.0; debug suite, release smoke. Claude Code, Claude Opus 5.5 (ran the merge, build, suite, reruns, revert tests and smoke runs, and wrote this check).
bmjask commented 2026-12-02 14:12:49 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T14:12:49Z.


@Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any.

<!-- greyfinch-sync:ivall/xcl:comment:7348173056 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3486#issuecomment-7348173056). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T14:12:49Z. --- @Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3486:upstream-pr/3486'
git switch 'upstream-pr/3486'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3486'
git switch 'upstream-pr/3486'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3486'
git switch 'upstream-pr/3486'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3486'
git switch 'main'
git merge --squash 'upstream-pr/3486'
git switch 'main'
git merge --ff-only 'upstream-pr/3486'
git switch 'main'
git merge 'upstream-pr/3486'
git push origin 'main'
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
xcl-dev/xcl!3486
No description provided.