recomp: memory window from the full 64-bit address (carry out of the low dword) #123

Manually merged
github merged 1 commit from gh-pr/123/head into gh-pr/123/base 2026-11-26 04:11:18 +00:00
Owner

@⁠gefydev on GitHub · 2026-11-23 13:29 UTC · original
gefydev:recomp-window-carry → main · +93 −13 · 2 files · 1 commits · merged 2026-11-23 14:13 UTC

#105 item 3.

With more than one memory window, several access kinds picked the window from the base's high dword before the offsets were added:

  • smem (s_load_*, s_buffer_load_*);
  • MUBUF (load / store / atomic / d16);
  • FLAT / global (plain and atomic).

If an offset carried out of the low dword, the access went to the base's window at the wrapped low address. A negative global offset that borrowed had the same problem. image_bvh*_intersect_ray already did this right.

The new window_at adds the low dword and the offsets in 64 bits and moves the window by the carry. The V# stride * index product is 64-bit too, and the signed SMEM / global offsets are sign-extended. With one window it emits nothing, so the single-window HLSL and its DXIL cache are unchanged. gpu_memory_windows_above_4_gib still checks that and still passes. With several windows the xcl_w = line now comes after the address computation instead of before it.

Not changed: the GS vertex input (xcl_vin) is still a 32-bit offset in window 0. It is XCL's own staging, not a title address.

Test gpu_memory_window_carry, run in a 2-window UMA arena: the base sits at 0xFFFF_F000 of window 0, and s_load, s_buffer_load, buffer load / store, global load with SADDR and a global atomic each reach window 1 through their offset. Without the change it fails (the s_load reads 0 from window 0). With it, it passes on a GTX 1650 under Wine, and so do the other lib tests that run there. I did not test the borrow case: in this arena, window 0 maps only its first MiB, so a borrow has nothing valid to land on.

**@⁠gefydev** on GitHub · 2026-11-23 13:29 UTC · [original](https://github.com/xcl-dev/xcl/pull/123) `gefydev:recomp-window-carry` → `main` · +93 −13 · 2 files · 1 commits · merged 2026-11-23 14:13 UTC #105 item 3. With more than one memory window, several access kinds picked the window from the base's high dword before the offsets were added: - smem (`s_load_*`, `s_buffer_load_*`); - MUBUF (load / store / atomic / d16); - FLAT / global (plain and atomic). If an offset carried out of the low dword, the access went to the base's window at the wrapped low address. A negative global offset that borrowed had the same problem. `image_bvh*_intersect_ray` already did this right. The new `window_at` adds the low dword and the offsets in 64 bits and moves the window by the carry. The V# `stride * index` product is 64-bit too, and the signed SMEM / global offsets are sign-extended. With one window it emits nothing, so the single-window HLSL and its DXIL cache are unchanged. `gpu_memory_windows_above_4_gib` still checks that and still passes. With several windows the `xcl_w =` line now comes after the address computation instead of before it. Not changed: the GS vertex input (`xcl_vin`) is still a 32-bit offset in window 0. It is XCL's own staging, not a title address. Test `gpu_memory_window_carry`, run in a 2-window UMA arena: the base sits at `0xFFFF_F000` of window 0, and s_load, s_buffer_load, buffer load / store, global load with SADDR and a global atomic each reach window 1 through their offset. Without the change it fails (the s_load reads 0 from window 0). With it, it passes on a GTX 1650 under Wine, and so do the other lib tests that run there. I did not test the borrow case: in this arena, window 0 maps only its first MiB, so a borrow has nothing valid to land on.
With several memory windows, smem, MUBUF (load / store / atomic / d16) and
FLAT / global (plain and atomic) picked the window from the high dword of
the base before the offsets were added. An offset that carried out of the
low dword (or a negative global offset that borrowed) read and wrote the
base's window at the wrapped low address. image_bvh*_intersect_ray already
did it right.

window_at adds the low dword and the offsets in 64 bits and moves the
window by the carry (V# stride · index in 64 bits too). With one window it
emits nothing, so the single-window HLSL (and its DXIL cache) is unchanged.

Test gpu_memory_window_carry: the base at 0xFFFF_F000 of window 0 and
every access kind reaching window 1 through its offset.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:11:17 +00:00
github manually merged commit a787c521bd into gh-pr/123/base 2026-11-26 04:11:18 +00:00
Author
Owner

@⁠ivall on GitHub · 2026-11-23 14:14 UTC · original

This one had to come out again (merged with the batch, then reverted in 70f8dc4 – sorry for the noise, GitHub will show it as merged). With it, XDefiant crashes ~10 s in inside AMD's shader compiler: unhandled exception 0xc0000005 in amdxc64.dll+0xe8f875 (write at address 0x2000000c), while creating the pipeline of a compute shader (8e4af296b9d7fd9c, 2 552 RDNA2 instructions, 4 memory windows). Deterministic; reverting only #123 runs. So the HLSL is valid but its shape (likely the 64-bit address arithmetic before the window switch at every access) trips the AMD driver. If you want to retry: emitting the carry only where an offset can actually cross the dword (immediate/SGPR offsets that are not provably small), or computing it in 32 bits with an explicit carry compare instead of uint64_t, might avoid it – please open a new PR; I can run the XDefiant check on the RX 9070.

**@⁠ivall** on GitHub · 2026-11-23 14:14 UTC · [original](https://github.com/xcl-dev/xcl/pull/123#issuecomment-7103689532) This one had to come out again (merged with the batch, then reverted in 70f8dc4 – sorry for the noise, GitHub will show it as merged). With it, XDefiant crashes ~10 s in inside AMD's shader compiler: `unhandled exception 0xc0000005 in amdxc64.dll+0xe8f875 (write at address 0x2000000c)`, while creating the pipeline of a compute shader (`8e4af296b9d7fd9c`, 2 552 RDNA2 instructions, 4 memory windows). Deterministic; reverting only #123 runs. So the HLSL is valid but its shape (likely the 64-bit address arithmetic before the window switch at every access) trips the AMD driver. If you want to retry: emitting the carry only where an offset can actually cross the dword (immediate/SGPR offsets that are not provably small), or computing it in 32 bits with an explicit carry compare instead of `uint64_t`, might avoid it – please open a new PR; I can run the XDefiant check on the RX 9070.
This discussion has been locked. Commenting is limited to contributors.
No description provided.