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

Merged
gefydev merged 1 commit from upstream-pr/123 into main 2026-11-23 14:13:38 +00:00
gefydev commented 2026-11-23 13:29:07 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by gefydev on 2026-11-23T13:29:07Z.


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

<!-- greyfinch-sync:ivall/xcl:issue:6560405574 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/123). Originally posted by [gefydev](https://github.com/gefydev) on 2026-11-23T13:29:07Z. --- #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.
upstream-sync closed this pull request 2026-11-24 06:57:15 +00:00
ivall commented 2026-11-24 07:00:31 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ivall on 2026-11-23T14:14:14Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7103689532 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/123#issuecomment-7103689532). Originally posted by [ivall](https://github.com/ivall) on 2026-11-23T14:14:14Z. --- 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 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!122
No description provided.