Skip to content

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

Merged
ivall merged 1 commit into
xcl-dev:mainfrom
gefydev:recomp-window-carry
Nov 23, 2026
Merged

ivall merged 1 commit into
xcl-dev:mainfrom
gefydev:recomp-window-carry

Conversation

@gefydev

@gefydev gefydev commented Nov 23, 2026

Copy link
Copy Markdown
Member

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

…low dword)

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.
@ivall
ivall merged commit 778e329 into xcl-dev:main Nov 23, 2026
ivall added a commit that referenced this pull request Nov 23, 2026
This reverts commit 778e329, reversing
changes made to 5231403.
@ivall

ivall commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

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.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants