compute: accept raw buffer loads without offen or with a scalar offset #3172

Merged
Leyukaka merged 1 commit from upstream-pr/3172 into main 2026-11-27 21:49:26 +00:00
Leyukaka commented 2026-11-27 20:17:57 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-27T20:17:57Z.


Fixes #3143. Part of #2935. Target branch main. #3143 was claimed by @JB2WIN; I took it over after two hours without activity, with credit to them. Their plan also accepted m0 as soffset; this PR keeps m0 refused, and that can follow.

Change (src/gfx1013_compute_native.cpp): direct compute accepts raw buffer loads (buffer_load_dword, _dwordx2, _dwordx3, _dwordx4) with offen clear, and with a scalar offset that is a numeric SGPR or an inline integer.

  • The shared decoder refused anything but offen with an inline-0 soffset, because the legacy HLSL emitter assumes offen and ignores soffset.
  • The direct emitter (DirectCompute::memory) already adds the optional VGPR offset, the 12-bit immediate offset and soffset, then aligns to a dword. It reads soffset through operand32, which refuses a non-numeric SGPR.
  • Still refused: idxen, glc, dlc, slc, tfe, lds, inline float constants and literals as soffset.
  • The HLSL and graphics paths keep the strict rule unchanged.

Tests. The setup was Windows 11 with an NVIDIA GeForce RTX 5080 and DXC from the Windows SDK 10.0.26100, on main a5dad843 plus this commit.

  • native_global_srv_heap_replay_hardware adds wave32 requests, each compared over all 72 output words with a CPU reference:
    • off with an SGPR soffset, at all four widths;
    • an SGPR soffset plus an immediate offset;
    • offen plus an SGPR soffset;
    • zero and nonzero inline offsets.
  • native_global_srv_heap_replay.cpp takes an optional reference file for those cases.
  • Refusal controls:
    • glc, slc and idxen;
    • a descriptor SGPR as soffset;
    • a literal soffset.
  • native_global_srv_heap_replay_warp skips (77) on this machine. The native_direct_container and startup_compute_dispatch* tests pass, 25 tests in all, two of them WARP skips.
  • Mutation checks, run by hand, each failing native_global_srv_heap_replay_hardware:
    • accepting glc;
    • dropping soffset from the emitted address.

Measured on a local capture (counts and instruction shape only) with compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests on main a5dad843.

Requests Compiled before Compiled after Stopped first at this refusal
Capture, 2,689 403 409 59
One start-up run, 2,718 416 422 66
  • 6 of them now compile. 3 of those 6 are dispatched in the start-up run, 462 dispatches in all.
  • No request that compiled before stops compiling.
  • The others stop later. In the run, 14 of the 66 stop at the new message ("raw buffer load needs a linear byte offset and no modifiers"); the 8 of them I could decode all carry glc and dlc. Of the rest:
    • 11 stop at "non-contiguous resource descriptor";
    • 9 at "unbound numeric SGPR";
    • the remaining 26 at several other refusals.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5532588740 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3172). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-27T20:17:57Z. --- Fixes #3143. Part of #2935. Target branch `main`. #3143 was claimed by @JB2WIN; I took it over after two hours without activity, with credit to them. Their plan also accepted `m0` as `soffset`; this PR keeps `m0` refused, and that can follow. **Change** (`src/gfx1013_compute_native.cpp`): direct compute accepts raw buffer loads (`buffer_load_dword`, `_dwordx2`, `_dwordx3`, `_dwordx4`) with `offen` clear, and with a scalar offset that is a numeric SGPR or an inline integer. - The shared decoder refused anything but `offen` with an inline-0 `soffset`, because the legacy HLSL emitter assumes `offen` and ignores `soffset`. - The direct emitter (`DirectCompute::memory`) already adds the optional VGPR offset, the 12-bit immediate offset and `soffset`, then aligns to a dword. It reads `soffset` through `operand32`, which refuses a non-numeric SGPR. - Still refused: `idxen`, `glc`, `dlc`, `slc`, `tfe`, `lds`, inline float constants and literals as `soffset`. - The HLSL and graphics paths keep the strict rule unchanged. **Tests.** The setup was Windows 11 with an NVIDIA GeForce RTX 5080 and DXC from the Windows SDK 10.0.26100, on `main` `a5dad843` plus this commit. - `native_global_srv_heap_replay_hardware` adds wave32 requests, each compared over all 72 output words with a CPU reference: - `off` with an SGPR `soffset`, at all four widths; - an SGPR `soffset` plus an immediate offset; - `offen` plus an SGPR `soffset`; - zero and nonzero inline offsets. - `native_global_srv_heap_replay.cpp` takes an optional reference file for those cases. - Refusal controls: - `glc`, `slc` and `idxen`; - a descriptor SGPR as `soffset`; - a literal `soffset`. - `native_global_srv_heap_replay_warp` skips (77) on this machine. The `native_direct_container` and `startup_compute_dispatch*` tests pass, 25 tests in all, two of them WARP skips. - Mutation checks, run by hand, each failing `native_global_srv_heap_replay_hardware`: - accepting `glc`; - dropping `soffset` from the emitted address. **Measured on a local capture** (counts and instruction shape only) with `compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests` on `main` `a5dad843`. | Requests | Compiled before | Compiled after | Stopped first at this refusal | |---|---|---|---| | Capture, 2,689 | 403 | 409 | 59 | | One start-up run, 2,718 | 416 | 422 | 66 | - 6 of them now compile. 3 of those 6 are dispatched in the start-up run, 462 dispatches in all. - No request that compiled before stops compiling. - The others stop later. In the run, 14 of the 66 stop at the new message ("raw buffer load needs a linear byte offset and no modifiers"); the 8 of them I could decode all carry `glc` and `dlc`. Of the rest: - 11 stop at "non-contiguous resource descriptor"; - 9 at "unbound numeric SGPR"; - the remaining 26 at several other refusals. AI-assisted.
pigalot commented 2026-11-27 21:49:00 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-27T21:49:00Z.

Review: APPROVED


I reviewed 7189ffc7 merged over current main 2b7ebf18. The merge is clean (tree c6c196d2) and git diff --cached --check is clean.

What I traced.

  • Decoder masks: in the direct compute branch, a & 0x0203e000 refuses idxen, glc, dlc, lds, bit 17 and opcode bit 7, and b & 0x00e00000 refuses slc, tfe and bit 21. offen (bit 12) is now free. That is the same rule the direct raw store already uses (0x3e000 / 0xe00000), so loads and stores now accept the same addressing.
  • soffset: the guard admits SGPRs 0 to 105 and inline integers 128 to 208, and refuses vcc, ttmp, m0, null, exec, the float constants and 255. MUBUF has no literal word, so refusing 255 is right. An SGPR that is not numeric is refused later by operand32 (unbound numeric SGPR), as the descriptor-SGPR control shows.
  • Emitter: DirectCompute::memory reads vaddr only when offen is set, then adds the 12-bit immediate offset and operand32(soffset), and aligns to a dword. With offen clear, vaddr is not read, so the new off cases do not depend on v1.
  • Other paths: the HLSL path (direct == false) and the graphics path keep the strict rule.

What I ran.

  • dev: full build, then

    ctest --test-dir out/build/dev --no-tests=error -j 4 -R '^(native_global_srv_heap_replay_warp|native_direct_container|startup_compute_dispatch.*)$' -E '_hardware$'
    ctest --test-dir out/build/dev --no-tests=error -j 1 -V -R '^native_global_srv_heap_replay_hardware$'
    

    12/12 pass, with two capability skips (77): native_global_srv_heap_replay_warp and startup_compute_dispatch_native_warp. The hardware test passes, and all eight new address forms match the 72-word CPU reference.

  • release /O2: built compile_dxil and native_global_srv_heap_replay, then ran ctest --test-dir out/build/release --no-tests=error -j 1 -V -R '^native_global_srv_heap_replay_(hardware|warp)$'. The hardware test passes; the WARP test is a capability skip (77) here too.

Mutants, each rebuilt in dev and run against native_global_srv_heap_replay_hardware:

Mutant Result
direct branch off (main's decoder rule; negative control) killed
slc / tfe accepted (b & 0x00e00000 dropped) killed
glc accepted killed
idxen accepted killed
literal soffset guard removed killed
emitter drops soffset from the address (existing code) killed
emitter reads vaddr even with offen clear (existing code) killed
dlc accepted survives
lds accepted survives
negative inline soffset (193 to 208) refused survives

Restored and rebuilt afterwards; git diff --quiet is clean. The negative control is main's rule, so the new cases fail on main.

Non-blocking.

  1. dlc and lds refusals are not pinned. The description lists both as still refused, and the code refuses them, but no control covers them. lds matters most: an LDS-direct load writes LDS instead of vdata, so accepting it would be a silent miscompile. Two more entries in the refusal loop (flags: 1 << 15 and flags: 1 << 16) would pin them.
  2. Negative inline soffset is accepted but not exercised. 193 to 208 pass the guard, and the emitter adds them as a 32-bit value, so offset + soffset wraps inside the view. My reading of the RDNA buffer addressing is that soffset is unsigned, so the hardware would address past the buffer instead. That is a hypothesis I have not checked on hardware. Compilers are unlikely to emit it, so refusing 193 to 208 until a case needs them would be the cautious choice.

Verdict: approve on 7189ffc7.

Environment: NVIDIA GeForce RTX 5090 driver 32.0.16.1088; Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; DXC 1.9.2602.17; Python 3.12.10; wave32; debug layer off.
CI: Build and test on Windows, Assemble and translate gfx1013 fixtures and Run platform-independent Python checks on Linux pass on 7189ffc7.

This reply was AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6093640299 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3172#pullrequestreview-6093640299). Originally posted by [pigalot](https://github.com/pigalot) on 2026-11-27T21:49:00Z. **Review:** APPROVED --- I reviewed `7189ffc7` merged over current `main` `2b7ebf18`. The merge is clean (tree `c6c196d2`) and `git diff --cached --check` is clean. **What I traced.** - **Decoder masks:** in the direct compute branch, `a & 0x0203e000` refuses `idxen`, `glc`, `dlc`, `lds`, bit 17 and opcode bit 7, and `b & 0x00e00000` refuses `slc`, `tfe` and bit 21. `offen` (bit 12) is now free. That is the same rule the direct raw store already uses (`0x3e000` / `0xe00000`), so loads and stores now accept the same addressing. - **`soffset`:** the guard admits SGPRs 0 to 105 and inline integers 128 to 208, and refuses `vcc`, `ttmp`, `m0`, `null`, `exec`, the float constants and 255. MUBUF has no literal word, so refusing 255 is right. An SGPR that is not numeric is refused later by `operand32` (`unbound numeric SGPR`), as the descriptor-SGPR control shows. - **Emitter:** `DirectCompute::memory` reads `vaddr` only when `offen` is set, then adds the 12-bit immediate offset and `operand32(soffset)`, and aligns to a dword. With `offen` clear, `vaddr` is not read, so the new `off` cases do not depend on `v1`. - **Other paths:** the HLSL path (`direct == false`) and the graphics path keep the strict rule. **What I ran.** - **`dev`:** full build, then ```powershell ctest --test-dir out/build/dev --no-tests=error -j 4 -R '^(native_global_srv_heap_replay_warp|native_direct_container|startup_compute_dispatch.*)$' -E '_hardware$' ctest --test-dir out/build/dev --no-tests=error -j 1 -V -R '^native_global_srv_heap_replay_hardware$' ``` 12/12 pass, with two capability skips (77): `native_global_srv_heap_replay_warp` and `startup_compute_dispatch_native_warp`. The hardware test passes, and all eight new address forms match the 72-word CPU reference. - **`release` `/O2`:** built `compile_dxil` and `native_global_srv_heap_replay`, then ran `ctest --test-dir out/build/release --no-tests=error -j 1 -V -R '^native_global_srv_heap_replay_(hardware|warp)$'`. The hardware test passes; the WARP test is a capability skip (77) here too. **Mutants**, each rebuilt in `dev` and run against `native_global_srv_heap_replay_hardware`: | Mutant | Result | |---|---| | direct branch off (main's decoder rule; negative control) | killed | | `slc` / `tfe` accepted (`b & 0x00e00000` dropped) | killed | | `glc` accepted | killed | | `idxen` accepted | killed | | literal `soffset` guard removed | killed | | emitter drops `soffset` from the address (existing code) | killed | | emitter reads `vaddr` even with `offen` clear (existing code) | killed | | `dlc` accepted | **survives** | | `lds` accepted | **survives** | | negative inline `soffset` (193 to 208) refused | **survives** | Restored and rebuilt afterwards; `git diff --quiet` is clean. The negative control is main's rule, so the new cases fail on `main`. **Non-blocking.** 1. **`dlc` and `lds` refusals are not pinned.** The description lists both as still refused, and the code refuses them, but no control covers them. `lds` matters most: an LDS-direct load writes LDS instead of `vdata`, so accepting it would be a silent miscompile. Two more entries in the refusal loop (`flags: 1 << 15` and `flags: 1 << 16`) would pin them. 2. **Negative inline `soffset` is accepted but not exercised.** 193 to 208 pass the guard, and the emitter adds them as a 32-bit value, so `offset + soffset` wraps inside the view. My reading of the RDNA buffer addressing is that `soffset` is unsigned, so the hardware would address past the buffer instead. That is a hypothesis I have not checked on hardware. Compilers are unlikely to emit it, so refusing 193 to 208 until a case needs them would be the cautious choice. **Verdict:** approve on `7189ffc7`. Environment: NVIDIA GeForce RTX 5090 driver 32.0.16.1088; Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; DXC 1.9.2602.17; Python 3.12.10; wave32; debug layer off. CI: `Build and test on Windows`, `Assemble and translate gfx1013 fixtures` and `Run platform-independent Python checks on Linux` pass on `7189ffc7`. This reply was AI-assisted.
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
R0Y00/Xbox2Windows!3172
No description provided.