compute: lower sub-DWORD scalar global loads in the direct path #3517

Manually merged
github merged 4 commits from github-bot/gh-3515 into gh-pr/3515/base 2026-11-30 02:40:20 +00:00 AGit
Owner

@⁠Ammmae0x on GitHub · 2026-11-29 20:16 UTC · original
Ammmae0x:compute/global-subdword-loads → main · +948 −16 · 12 files · 4 commits · merged 2026-11-30 02:37 UTC

Lower sub-DWORD scalar-base global loads (global_load_ubyte, global_load_sbyte, global_load_ushort, global_load_sshort) in the direct C++ compute path.

Refs #3226, #2935

Change

  • src/gfx1013_compute_native.cpp: admit subdword_load = (i.op >= 8 && i.op <= 11) alongside DWORD loads/stores. The refusal substring for _d16 loads/stores, global_store_byte/global_store_short and atomics is unchanged, as are the lds, segment != 2, saddr == 125 and saddr == 127 refusals.
  • src/gfx1013_direct_compute.inl: global_root now takes the byte transfer size and a sub-DWORD flag. Sub-DWORD loads allow any signed 12-bit byte immediate offset (-2048..2047); the DWORD/wider offset % 4 refusal is unchanged. Binding span covers the aligned DWORD(s) touched: ((max(offset, 0) + width + 3) & ~3). The 32-bit wrap guard covers the last byte (offset + width - 1). Byte extraction shifts by ((addr & 3) * 8) and masks 0xff, with sign extension for sbyte; halfwords handle the in-word case and the cross-DWORD case (addr & 3 == 3), where the second DWORD is loaded only on a cross-DWORD lane (the result is still selected to 0 when the wrap guard fails). Root SRV and root UAV saddr and glc/slc/dlc are accepted as for global_load_dword.
  • Tests: new tests/native_global_subdword_load_check.py (encodings and hardware modes), tests/cmake/native_global_subdword_load.cmake, wired into tests/checks/python-linux/native-global-subdword-load.txt. The dispatch checks 29 cases per lane: all four opcodes, all four intra-DWORD byte alignments, cross-DWORD halfwords, boundary bytes (0x00, 0x7f, 0x80, 0xff) and halfwords (0x0000, 0x7fff, 0x8000, 0xffff), signed/unsigned odd negative and positive offsets, root SRV and root UAV, glc slc dlc, both 32-bit wrap guards, and a vdst == vaddr alias program. The module check counts 50 raw buffer loads (29 sub-DWORD loads, 19 cross-DWORD second loads, plus 2 scalar size loads), 52 upper-bound wrap guards (24 sub-DWORD loads plus 28 nonzero-offset output stores) and 4 lower-bound wrap guards, and pins the ushort wrap bound at -18.
  • Docs: new docs/experiments/native-direct-global-subdword-load.md, linked from docs/experiments.md; the global-load note now points to it for sub-DWORD opcodes.

Linux verification (this host cannot run compile_dxil, DXC or hardware)

  • /tmp/pe-env/bin/python -B tests/native_global_subdword_load_check.py encodings — pass (four sub-DWORD opcodes, all four byte alignments, cross-DWORD, odd and extreme offsets, policy bits, pattern stores, alias-free dispatch program)
  • /tmp/pe-env/bin/python -B tools/run_checks_parallel.py --from-dir tests/checks/python-linux — all 59 checks passed
  • tests/form_coverage_check.py — passed; tests/docs_links_check.py — 178 Markdown files, 718 links; tests/bidi_controls_check.py — 2680 tracked files, no bidirectional controls
  • git diff --check — clean; git merge-tree --write-tree origin/main HEAD — exit 0

Mutation audit

28/28 enumerated mutants killed (no survivors). Killed by hardware readback: decode-gate bounds, alignment refusal, byte/halfword shift and mask, sign extension, cross-DWORD predicate/shift/mask, width mapping, upper wrap guard. Killed by the module dumpbin checks: lower wrap guard (readback-equivalent, guard count 4 -> 0) and the last-offset formula (widening/narrowing moves the pinned -18 bound). Killed by the extent checks: the span +3 and & ~3u terms (ubyte at offset 1 sizes a view to 4 bytes, ushort at offset 3 to 8 bytes; ubyte at offset 2047 to 2048, ushort to 2052).

Windows verification

Pending: compile_dxil and hardware readback on Windows (not runnable on this Linux host).

WIN-VERIFY fix (f6a3d606)

Windows verification of d5993681 failed native_global_subdword_load_hardware at compile_dxil with
inconsistent DXIL declaration: the dispatch loads both a root SRV (nounwind readonly) and a root UAV
(nounwind) through the same @dx.op.rawBufferLoad.i32 intrinsic, and DxilModule::invoke() threw on
the second declaration. The fix merges the two forms into a single nounwind declaration in either
order (dxc accepts one shared declaration for ByteAddressBuffer and RWByteAddressBuffer loads;
dropping readonly preserves UAV store-load ordering); any other attribute or signature mismatch
still throws. Coverage: new tests/dxil_module_invoke_check.py (host C++ probe, 10 cases: both orders,
readonly-only/plain-only unchanged, mismatch controls) with an 8/8 mutation audit of the widening
logic, plus a UAV-then-SRV compile-only program in the sub-DWORD check alongside the SRV-then-UAV
dispatch. The probe against the pre-fix header aborts with the same inconsistent DXIL declaration,
reproducing the Windows failure on Linux.

Linux re-verification on f6a3d606: encodings pass, tests/dxil_module_invoke_check.py pass (10 cases,
8/8 mutants killed), tools/run_checks_parallel.py --from-dir tests/checks/python-linux — all 60 checks
passed, form/docs/bidi pass, git diff --check clean, merge-tree exit 0.

Windows verification

Pending: compile_dxil and hardware readback on Windows (not runnable on this Linux host).

WIN-VERIFY fix (12793ffb)

Windows verification of f6a3d606 failed native_global_subdword_load_hardware at compile_dxil with
global store base is an advanced or mismatched root address: prologue() and alias_program() wrote
the group*32 temporary to s9, clobbering the high half of s[8:9] (root UAV u1). The fix uses free
SGPR s12 for the temporary (s_lshl_b32 s12, s10, 5 / v_add_nc_u32 v9, s12, v0) in both programs
and pins both instructions in encodings().

Linux re-verification on 12793ffb: encodings pass, tools/run_checks_parallel.py --from-dir tests/checks/python-linux — all 60 checks passed, form/docs/bidi pass, git diff --check clean,
merge-tree exit 0.

Windows verification

Pending: compile_dxil and hardware readback on Windows (not runnable on this Linux host).

WIN-VERIFY fix (d02f73e3)

Windows verification of 12793ffb left one assertion: module counts (50, 52, 4) where the check
expected (50, 24, 4). The dumpbin count is module-wide: upper is 24 sub-DWORD load guards plus
28 upper guards from the 28 output global_store_dword instructions at offsets 4..112 (slots 1..28);
the slot-0 store has offset 0 and emits no guard. The expected count is now (50, 52, 4) in the
check, its print message, and the docs note, with a comment pinning the composition. Local verification
in a throwaway copy confirmed that both dev and release pass all 29 cases per lane (64 lanes + pattern UAV

  • alias + reverse programs + the -18 wrap bound) with zero diffs once the count is corrected.

Linux re-verification on d02f73e3: encodings pass, tools/run_checks_parallel.py --from-dir tests/checks/python-linux — all 60 checks passed, form/docs/bidi pass, git diff --check clean.

Windows Verification (d02f73e3)

Commit: d02f73e3f398188de48d21d2e8fe6151553afd91
Adapter: NVIDIA GeForce RTX 4050 Laptop GPU (driver 32.0.15.9186)
dev: cmake --build out/build/dev --target compile_dxil native_store_replay
dev: ctest --preset dev --no-tests=error -R '^(native_global_subdword_load_.*|native_global_load_.*|native_global_store_.*)$' --output-on-failure -> 5 passed, 0 skipped (7.85s)
release: cmake --build out/build/release --target compile_dxil native_store_replay
release: ctest --preset release --no-tests=error -E 'cpu_native_archive_' -R '^(native_global_subdword_load_.*|native_global_load_.*|native_global_store_.*)$' --output-on-failure -> 5 passed, 0 skipped (7.30s)
Checks: native_global_subdword_load_check.py encodings, form_coverage_check.py, docs_links_check.py (178 files, 718 links), bidi_controls_check.py (2682 files) -> passed

AI-assisted.

**@⁠Ammmae0x** on GitHub · 2026-11-29 20:16 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3515) `Ammmae0x:compute/global-subdword-loads` → `main` · +948 −16 · 12 files · 4 commits · merged 2026-11-30 02:37 UTC Lower sub-DWORD scalar-base global loads (`global_load_ubyte`, `global_load_sbyte`, `global_load_ushort`, `global_load_sshort`) in the direct C++ compute path. Refs #3226, #2935 ## Change - `src/gfx1013_compute_native.cpp`: admit `subdword_load = (i.op >= 8 && i.op <= 11)` alongside DWORD loads/stores. The refusal substring for _d16 loads/stores, `global_store_byte`/`global_store_short` and atomics is unchanged, as are the `lds`, `segment != 2`, `saddr == 125` and `saddr == 127` refusals. - `src/gfx1013_direct_compute.inl`: `global_root` now takes the byte transfer size and a sub-DWORD flag. Sub-DWORD loads allow any signed 12-bit byte immediate offset (-2048..2047); the DWORD/wider `offset % 4` refusal is unchanged. Binding span covers the aligned DWORD(s) touched: `((max(offset, 0) + width + 3) & ~3)`. The 32-bit wrap guard covers the last byte (`offset + width - 1`). Byte extraction shifts by `((addr & 3) * 8)` and masks `0xff`, with sign extension for `sbyte`; halfwords handle the in-word case and the cross-DWORD case (`addr & 3 == 3`), where the second DWORD is loaded only on a cross-DWORD lane (the result is still selected to 0 when the wrap guard fails). Root SRV and root UAV `saddr` and `glc`/`slc`/`dlc` are accepted as for `global_load_dword`. - Tests: new `tests/native_global_subdword_load_check.py` (`encodings` and hardware modes), `tests/cmake/native_global_subdword_load.cmake`, wired into `tests/checks/python-linux/native-global-subdword-load.txt`. The dispatch checks 29 cases per lane: all four opcodes, all four intra-DWORD byte alignments, cross-DWORD halfwords, boundary bytes (0x00, 0x7f, 0x80, 0xff) and halfwords (0x0000, 0x7fff, 0x8000, 0xffff), signed/unsigned odd negative and positive offsets, root SRV and root UAV, `glc slc dlc`, both 32-bit wrap guards, and a `vdst == vaddr` alias program. The module check counts 50 raw buffer loads (29 sub-DWORD loads, 19 cross-DWORD second loads, plus 2 scalar size loads), 52 upper-bound wrap guards (24 sub-DWORD loads plus 28 nonzero-offset output stores) and 4 lower-bound wrap guards, and pins the ushort wrap bound at -18. - Docs: new `docs/experiments/native-direct-global-subdword-load.md`, linked from `docs/experiments.md`; the global-load note now points to it for sub-DWORD opcodes. ## Linux verification (this host cannot run compile_dxil, DXC or hardware) - `/tmp/pe-env/bin/python -B tests/native_global_subdword_load_check.py encodings` — pass (four sub-DWORD opcodes, all four byte alignments, cross-DWORD, odd and extreme offsets, policy bits, pattern stores, alias-free dispatch program) - `/tmp/pe-env/bin/python -B tools/run_checks_parallel.py --from-dir tests/checks/python-linux` — all 59 checks passed - `tests/form_coverage_check.py` — passed; `tests/docs_links_check.py` — 178 Markdown files, 718 links; `tests/bidi_controls_check.py` — 2680 tracked files, no bidirectional controls - `git diff --check` — clean; `git merge-tree --write-tree origin/main HEAD` — exit 0 ## Mutation audit 28/28 enumerated mutants killed (no survivors). Killed by hardware readback: decode-gate bounds, alignment refusal, byte/halfword shift and mask, sign extension, cross-DWORD predicate/shift/mask, width mapping, upper wrap guard. Killed by the module dumpbin checks: lower wrap guard (readback-equivalent, guard count 4 -> 0) and the last-offset formula (widening/narrowing moves the pinned -18 bound). Killed by the extent checks: the span `+3` and `& ~3u` terms (ubyte at offset 1 sizes a view to 4 bytes, ushort at offset 3 to 8 bytes; ubyte at offset 2047 to 2048, ushort to 2052). ## Windows verification Pending: compile_dxil and hardware readback on Windows (not runnable on this Linux host). ## WIN-VERIFY fix (f6a3d606) Windows verification of `d5993681` failed `native_global_subdword_load_hardware` at `compile_dxil` with `inconsistent DXIL declaration`: the dispatch loads both a root SRV (`nounwind readonly`) and a root UAV (`nounwind`) through the same `@dx.op.rawBufferLoad.i32` intrinsic, and `DxilModule::invoke()` threw on the second declaration. The fix merges the two forms into a single `nounwind` declaration in either order (dxc accepts one shared declaration for `ByteAddressBuffer` and `RWByteAddressBuffer` loads; dropping `readonly` preserves UAV store-load ordering); any other attribute or signature mismatch still throws. Coverage: new `tests/dxil_module_invoke_check.py` (host C++ probe, 10 cases: both orders, readonly-only/plain-only unchanged, mismatch controls) with an 8/8 mutation audit of the widening logic, plus a UAV-then-SRV compile-only program in the sub-DWORD check alongside the SRV-then-UAV dispatch. The probe against the pre-fix header aborts with the same `inconsistent DXIL declaration`, reproducing the Windows failure on Linux. Linux re-verification on `f6a3d606`: encodings pass, `tests/dxil_module_invoke_check.py` pass (10 cases, 8/8 mutants killed), `tools/run_checks_parallel.py --from-dir tests/checks/python-linux` — all 60 checks passed, form/docs/bidi pass, `git diff --check` clean, merge-tree exit 0. ## Windows verification Pending: compile_dxil and hardware readback on Windows (not runnable on this Linux host). ## WIN-VERIFY fix (12793ffb) Windows verification of `f6a3d606` failed `native_global_subdword_load_hardware` at `compile_dxil` with `global store base is an advanced or mismatched root address`: `prologue()` and `alias_program()` wrote the group*32 temporary to `s9`, clobbering the high half of `s[8:9]` (root UAV `u1`). The fix uses free SGPR `s12` for the temporary (`s_lshl_b32 s12, s10, 5` / `v_add_nc_u32 v9, s12, v0`) in both programs and pins both instructions in `encodings()`. Linux re-verification on `12793ffb`: encodings pass, `tools/run_checks_parallel.py --from-dir tests/checks/python-linux` — all 60 checks passed, form/docs/bidi pass, `git diff --check` clean, merge-tree exit 0. ## Windows verification Pending: compile_dxil and hardware readback on Windows (not runnable on this Linux host). ## WIN-VERIFY fix (d02f73e3) Windows verification of `12793ffb` left one assertion: module counts `(50, 52, 4)` where the check expected `(50, 24, 4)`. The dumpbin count is module-wide: `upper` is 24 sub-DWORD load guards plus 28 upper guards from the 28 output `global_store_dword` instructions at offsets 4..112 (slots 1..28); the slot-0 store has offset 0 and emits no guard. The expected count is now `(50, 52, 4)` in the check, its print message, and the docs note, with a comment pinning the composition. Local verification in a throwaway copy confirmed that both `dev` and `release` pass all 29 cases per lane (64 lanes + pattern UAV + alias + reverse programs + the -18 wrap bound) with zero diffs once the count is corrected. Linux re-verification on `d02f73e3`: encodings pass, `tools/run_checks_parallel.py --from-dir tests/checks/python-linux` — all 60 checks passed, form/docs/bidi pass, `git diff --check` clean. ### Windows Verification (d02f73e3) ```text Commit: d02f73e3f398188de48d21d2e8fe6151553afd91 Adapter: NVIDIA GeForce RTX 4050 Laptop GPU (driver 32.0.15.9186) dev: cmake --build out/build/dev --target compile_dxil native_store_replay dev: ctest --preset dev --no-tests=error -R '^(native_global_subdword_load_.*|native_global_load_.*|native_global_store_.*)$' --output-on-failure -> 5 passed, 0 skipped (7.85s) release: cmake --build out/build/release --target compile_dxil native_store_replay release: ctest --preset release --no-tests=error -E 'cpu_native_archive_' -R '^(native_global_subdword_load_.*|native_global_load_.*|native_global_store_.*)$' --output-on-failure -> 5 passed, 0 skipped (7.30s) Checks: native_global_subdword_load_check.py encodings, form_coverage_check.py, docs_links_check.py (178 files, 718 links), bidi_controls_check.py (2682 files) -> passed ``` AI-assisted. <!-- WIN-VERIFY: passed | sha=d02f73e3f398188de48d21d2e8fe6151553afd91 -->
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 20:21:07 +00:00
WIN-VERIFY fix for PR #3515: a module reading both a root SRV and a root
UAV threw 'inconsistent DXIL declaration' at compile_dxil because
load_buffer declares rawBufferLoad 'nounwind readonly' for the SRV and
'nounwind' for the UAV. DxilModule::invoke() now merges the two forms
into one 'nounwind' declaration in either order; any other mismatch
still throws.
WIN-VERIFY fix for PR #3515: prologue() and alias_program() wrote the
group*32 temporary to s9, clobbering the high half of s[8:9] (root UAV
u1), so the output stores failed with 'global store base is an
advanced or mismatched root address'. Use free SGPR s12 instead, and
pin both new instructions in encodings().
WIN-VERIFY fix for PR #3515: the dumpbin count is module-wide, so the
upper-bound count is 24 sub-DWORD load guards plus 28 upper guards
from the output global_store_dword instructions at offsets 4..112
(slots 1..28); the slot-0 store has offset 0 and emits no guard. The
previous 24 counted the loads only.
Author
Owner

@⁠Leyukaka on GitHub · 2026-11-29 21:09 UTC · original · approved these changes

Approving at d02f73e3. Read the full diff: the decode gate admits only FLAT ops 8..11 (src/gfx1013_compute_native.cpp:282,291), global_root gives the same span and wrap bound as before for the DWORD loads and stores, and the byte/halfword extraction with the cross-DWORD second load and phi (src/gfx1013_direct_compute.inl:666-711) is correct.

Independent run in an isolated environment (network off, PR tree read-only, dev preset, -DX2W_WITH_OPUS=OFF): ctest --preset dev --no-tests=error -R '^(native_global_subdword_load_.*|native_global_load_.*|native_global_store_.*)$' → 5/5 passed, no skips, including native_global_subdword_load_hardware (29 cases per lane, alias and reverse programs). The test log does not identify the adapter. CI does not run these tests.

Finding (not blocking): the two paths assume different alignment modes. The DWORD path drops the low two address bits and says so (src/gfx1013_direct_compute.inl:599-600, "DWORD alignment mode"); tools/startup/gfx2hlsl.py:7382 records the existing assumption: DWORD rounds down, UNALIGNED gathers across neighbouring DWORDs, the console's setting is unmeasured. The new halfword path reads an odd address byte-granular and gathers across two DWORDs at addr & 3 == 3 (src/gfx1013_direct_compute.inl:688-705), which is the UNALIGNED behaviour; under DWORD mode that halfword would round down. Bytes and even-address halfwords are the same in both modes. docs/experiments/native-direct-global-subdword-load.md should state which mode it assumes for odd-address halfwords.

Minor: src/gfx1013_compute_native.cpp:586 calls clear_spills(256 + dst) for global_load_dword only, so a sub-DWORD load over a VGPR holding spill lanes leaves stale entries. global_load_dwordx2/x3/x4 already have this gap on main; a follow-up is enough.

Minor: line 66 of the new doc still says the hardware readback is pending Windows verification.

Revert check, by reading: with the src/ changes reverted, native_global_subdword_load_hardware fails at compile_words(program()), before any replay. native_global_subdword_load_encodings checks only the Python-built words against the disassembler and does not depend on src/, so it would still pass.

**@⁠Leyukaka** on GitHub · 2026-11-29 21:09 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3515#pullrequestreview-6104816234) · **approved these changes** Approving at d02f73e3. Read the full diff: the decode gate admits only FLAT ops 8..11 (`src/gfx1013_compute_native.cpp:282,291`), `global_root` gives the same span and wrap bound as before for the DWORD loads and stores, and the byte/halfword extraction with the cross-DWORD second load and phi (`src/gfx1013_direct_compute.inl:666-711`) is correct. Independent run in an isolated environment (network off, PR tree read-only, dev preset, `-DX2W_WITH_OPUS=OFF`): `ctest --preset dev --no-tests=error -R '^(native_global_subdword_load_.*|native_global_load_.*|native_global_store_.*)$'` → 5/5 passed, no skips, including `native_global_subdword_load_hardware` (29 cases per lane, alias and reverse programs). The test log does not identify the adapter. CI does not run these tests. Finding (not blocking): the two paths assume different alignment modes. The DWORD path drops the low two address bits and says so (`src/gfx1013_direct_compute.inl:599-600`, "DWORD alignment mode"); `tools/startup/gfx2hlsl.py:7382` records the existing assumption: DWORD rounds down, UNALIGNED gathers across neighbouring DWORDs, the console's setting is unmeasured. The new halfword path reads an odd address byte-granular and gathers across two DWORDs at `addr & 3 == 3` (`src/gfx1013_direct_compute.inl:688-705`), which is the UNALIGNED behaviour; under DWORD mode that halfword would round down. Bytes and even-address halfwords are the same in both modes. `docs/experiments/native-direct-global-subdword-load.md` should state which mode it assumes for odd-address halfwords. Minor: `src/gfx1013_compute_native.cpp:586` calls `clear_spills(256 + dst)` for `global_load_dword` only, so a sub-DWORD load over a VGPR holding spill lanes leaves stale entries. `global_load_dwordx2/x3/x4` already have this gap on main; a follow-up is enough. Minor: line 66 of the new doc still says the hardware readback is pending Windows verification. Revert check, by reading: with the `src/` changes reverted, `native_global_subdword_load_hardware` fails at `compile_words(program())`, before any replay. `native_global_subdword_load_encodings` checks only the Python-built words against the disassembler and does not depend on `src/`, so it would still pass.
Author
Owner

@⁠Not-Saii on GitHub · 2026-11-29 22:10 UTC · original · approved these changes

Approving at d02f73e3. I read the full diff and the code it touches, and ran the PR's tests in an isolated environment (results below). I agree with the earlier review's three points: the alignment mode for odd-address halfwords, the missing clear_spills for the new opcodes, and the stale "pending" line in the new doc. I don't repeat them here, except where I have new evidence.

Findings

None of these block the merge.

SHOULD 1: the Windows report is missing two required fields. AGENTS.md asks GPU reports to identify the adapter, driver, Windows build, commit and debug-layer status. The "Windows Verification (d02f73e3)" block in the PR body gives the commit, adapter and driver. It does not give the Windows build or the debug-layer status.

SHOULD 2: the comment this PR edited still names one alignment mode for every caller. This adds evidence to the earlier alignment point. At src/gfx1013_direct_compute.inl:596-602 the PR extends the global_root comment, which says the low two address bits are dropped ("DWORD alignment mode"). The sub-DWORD path (:679-705) keeps those bits, reads an odd-address halfword one byte at a time, and gathers across two DWORDs at addr & 3 == 3. The fixture depends on that reading in 9 of the 29 slots per lane (slots 5, 6, 7, 8, 10, 13, 24, 25 and 26) and in slot 1 of the alias program. If the assumption changes later, those slots and the reference model change with it. The comment and the doc should both name the mode the halfword path assumes.

NIT 3: the declaration merge applies to every intrinsic. The merge in DxilModule::invoke() (src/dxil_module.h:106-125) applies to any intrinsic whose two declarations differ only by a trailing readonly, not only to rawBufferLoad/bufferLoad. It reaches both the direct compute path and src/gfx1013_rect_geometry.cpp.

  • Dropping readonly is conservative.
  • The merge only takes effect where main would have thrown, so modules that compiled before produce the same text.
  • No existing control expects that throw (searched at the head).

Either limit the merge to the two buffer-load names or say in the comment that it is general.

NIT 4: the 28/28 mutation audit cannot be reproduced. The PR body lists the 28 mutants by category but gives no script or command. The 8/8 audit for the header lives in tests/dxil_module_invoke_check.py, where anyone can run it again.

NIT 5: two sentences in docs/experiments/native-direct-global-subdword-load.md need rewording.

  • Lines 20-21 begin with a byte at VADDR 0xffffffff and then say the halfword wraps. The example should use either a byte or a halfword throughout.
  • Line 15 says the second DWORD is loaded only on a cross-DWORD lane, then says in the same sentence that a lane whose wrap guard fails still loads it. Splitting it into two sentences would make clear that the second clause means a cross-DWORD lane.

NIT 6 (optional): the module-wide guard counts are fragile. tests/native_global_subdword_load_check.py:439 checks exact icmp counts across the whole module, and those counts already needed one correction in d02f73e3. Counting only the sub-DWORD load guards would make the check independent of the output stores.

These look correct on reading:

  • the decode gate admits FLAT ops 8..11 only (src/gfx1013_compute_native.cpp:282,291), after the segment, lds, saddr 125 and saddr 127 refusals;
  • DWORD loads and stores keep the same span and last-offset bound (transfer_bytes = count * 4);
  • the sub-DWORD span is (max(offset,0) + width + 3) & ~3;
  • the last-byte wrap bound is right;
  • the cross-DWORD second load is branched on cross only and merged with a phi, and the in-range select then discards any value from a lane whose guard failed;
  • sign extension is applied after the cross select.

What each test proves

  • native_global_subdword_load_encodings checks the Python-built words against tools/disasm_rdna2.py, plus asserts on the reference model. It does not depend on src/.

  • native_global_subdword_load_hardware proves the lowering on one adapter. It covers:

    • 14 refusal controls;
    • glc/slc/dlc accepted;
    • four extent/min_size checks;
    • module counts and the -18 ushort bound;
    • a readback of 29 cases × 64 lanes against the reference model;
    • the vdst == vaddr alias program;
    • a compile-only UAV-then-SRV program.

    On Windows, this test is also the only coverage of the dxil_module.h merge.

  • tests/dxil_module_invoke_check.py runs 10 cases and 8 mutants against the header. It is listed only in tests/checks/python-linux/. Its compiler search does not include cl, so on a Windows host without a gcc-style compiler it skips (77).

  • native_global_load_hardware and native_global_store_{encodings,hardware} are regression checks for the shared global_root change.

CI

The pull_request run at d02f73e3 passed.

  • Linux: ran native_global_subdword_load_check.py encodings and dxil_module_invoke_check.py: 10 cases, 8/8 mutants killed.
  • Windows: the job ran 82 tests, none of them native_global_*, because the PR check skips native_*. CI did not run the hardware readback.
  • /O2: the job was skipped.

Independent run

Windows Sandbox with networking disabled. The PR tree was exported at the head and mapped read-only, with one writable output folder.

  • Commit: d02f73e3f3
  • Toolchain: MSVC 14.44.35207, CMake 3.31.6, Windows SDK 10.0.26100 DXC (dxcompiler 1.9.2602.17), dev preset (Debug)
  • Adapter: the replay creates its device on the default adapter, and the test log does not print which adapter that was. The sandbox lists NVIDIA GeForce RTX 4090 (Windows Sandbox vGPU, driver reported as 10.0.26100.1150) and the Microsoft Remote Display Adapter. The dispatch passed the replay's SM 6.6 wave32 gate.
  • Windows build: Windows 11 Enterprise 10.0.26100, build 26100
  • Debug layer: off. The sandbox image has no d3d12SDKLayers.dll, and the test tools do not enable it.
  • Commands:
    cmake --preset dev -DX2W_WITH_OPUS=OFF -DINTAKE_PYTHON=<venv python with requirements-dev.txt>
    cmake --build --preset dev --target compile_dxil native_store_replay
    ctest --preset dev --no-tests=error -R '^(native_global_subdword_load_.*|native_global_load_.*|native_global_store_.*)$' --output-on-failure -V
    
  • Passed (5):
    • native_global_load_hardware
    • native_global_store_encodings
    • native_global_store_hardware
    • native_global_subdword_load_encodings
    • native_global_subdword_load_hardware: 29 cases per lane, module counts (50, 52, 4), and the alias and reverse programs.
  • Failed: none.
  • Skipped (77): none.

Revert check

Each mutation was applied to a scratch copy, then compile_dxil was rebuilt (no compile errors) and the two subdword tests were run.

  • A: revert the decode gate. Remove the subdword_load declaration and the || subdword_load term in src/gfx1013_compute_native.cpp.
    • _encodings passed.
    • _hardware failed at the non-root-base refusal control: it expected "global load base is not a root buffer address" and got the generic DWORD-only decode refusal.
  • B: drop the byte-lane shift. Change mul byte_lane, 8 to mul byte_lane, 0 at src/gfx1013_direct_compute.inl:680.
    • _encodings passed.
    • _hardware passed the module checks and failed the readback, starting at lane 0 slot 1 (the sbyte at offset 2). The first diff is 0x0 against 0xffffffaa.
  • Restored tree: file hashes matched the head again, and both tests passed.
**@⁠Not-Saii** on GitHub · 2026-11-29 22:10 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3515#pullrequestreview-6105064016) · **approved these changes** Approving at d02f73e3. I read the full diff and the code it touches, and ran the PR's tests in an isolated environment (results below). I agree with the earlier review's three points: the alignment mode for odd-address halfwords, the missing `clear_spills` for the new opcodes, and the stale "pending" line in the new doc. I don't repeat them here, except where I have new evidence. ### Findings None of these block the merge. **SHOULD 1: the Windows report is missing two required fields.** AGENTS.md asks GPU reports to identify the adapter, driver, Windows build, commit and debug-layer status. The "Windows Verification (d02f73e3)" block in the PR body gives the commit, adapter and driver. It does not give the Windows build or the debug-layer status. **SHOULD 2: the comment this PR edited still names one alignment mode for every caller.** This adds evidence to the earlier alignment point. At `src/gfx1013_direct_compute.inl:596-602` the PR extends the `global_root` comment, which says the low two address bits are dropped ("DWORD alignment mode"). The sub-DWORD path (`:679-705`) keeps those bits, reads an odd-address halfword one byte at a time, and gathers across two DWORDs at `addr & 3 == 3`. The fixture depends on that reading in 9 of the 29 slots per lane (slots 5, 6, 7, 8, 10, 13, 24, 25 and 26) and in slot 1 of the alias program. If the assumption changes later, those slots and the reference model change with it. The comment and the doc should both name the mode the halfword path assumes. **NIT 3: the declaration merge applies to every intrinsic.** The merge in `DxilModule::invoke()` (`src/dxil_module.h:106-125`) applies to any intrinsic whose two declarations differ only by a trailing ` readonly`, not only to `rawBufferLoad`/`bufferLoad`. It reaches both the direct compute path and `src/gfx1013_rect_geometry.cpp`. - Dropping `readonly` is conservative. - The merge only takes effect where main would have thrown, so modules that compiled before produce the same text. - No existing control expects that throw (searched at the head). Either limit the merge to the two buffer-load names or say in the comment that it is general. **NIT 4: the 28/28 mutation audit cannot be reproduced.** The PR body lists the 28 mutants by category but gives no script or command. The 8/8 audit for the header lives in `tests/dxil_module_invoke_check.py`, where anyone can run it again. **NIT 5: two sentences in `docs/experiments/native-direct-global-subdword-load.md` need rewording.** - Lines 20-21 begin with a byte at VADDR 0xffffffff and then say the halfword wraps. The example should use either a byte or a halfword throughout. - Line 15 says the second DWORD is loaded only on a cross-DWORD lane, then says in the same sentence that a lane whose wrap guard fails still loads it. Splitting it into two sentences would make clear that the second clause means a cross-DWORD lane. **NIT 6 (optional): the module-wide guard counts are fragile.** `tests/native_global_subdword_load_check.py:439` checks exact `icmp` counts across the whole module, and those counts already needed one correction in d02f73e3. Counting only the sub-DWORD load guards would make the check independent of the output stores. These look correct on reading: - the decode gate admits FLAT ops 8..11 only (`src/gfx1013_compute_native.cpp:282,291`), after the segment, `lds`, saddr 125 and saddr 127 refusals; - DWORD loads and stores keep the same span and last-offset bound (`transfer_bytes = count * 4`); - the sub-DWORD span is `(max(offset,0) + width + 3) & ~3`; - the last-byte wrap bound is right; - the cross-DWORD second load is branched on `cross` only and merged with a phi, and the in-range select then discards any value from a lane whose guard failed; - sign extension is applied after the cross select. ### What each test proves - **`native_global_subdword_load_encodings`** checks the Python-built words against `tools/disasm_rdna2.py`, plus asserts on the reference model. It does not depend on `src/`. - **`native_global_subdword_load_hardware`** proves the lowering on one adapter. It covers: - 14 refusal controls; - glc/slc/dlc accepted; - four extent/min_size checks; - module counts and the -18 ushort bound; - a readback of 29 cases × 64 lanes against the reference model; - the `vdst == vaddr` alias program; - a compile-only UAV-then-SRV program. On Windows, this test is also the only coverage of the `dxil_module.h` merge. - **`tests/dxil_module_invoke_check.py`** runs 10 cases and 8 mutants against the header. It is listed only in `tests/checks/python-linux/`. Its compiler search does not include `cl`, so on a Windows host without a gcc-style compiler it skips (77). - **`native_global_load_hardware` and `native_global_store_{encodings,hardware}`** are regression checks for the shared `global_root` change. ### CI The pull_request run at d02f73e3 passed. - **Linux:** ran `native_global_subdword_load_check.py encodings` and `dxil_module_invoke_check.py`: 10 cases, 8/8 mutants killed. - **Windows:** the job ran 82 tests, none of them `native_global_*`, because the PR check skips `native_*`. CI did not run the hardware readback. - **/O2:** the job was skipped. ### Independent run Windows Sandbox with networking disabled. The PR tree was exported at the head and mapped read-only, with one writable output folder. - **Commit:** d02f73e3f398188de48d21d2e8fe6151553afd91 - **Toolchain:** MSVC 14.44.35207, CMake 3.31.6, Windows SDK 10.0.26100 DXC (dxcompiler 1.9.2602.17), dev preset (Debug) - **Adapter:** the replay creates its device on the default adapter, and the test log does not print which adapter that was. The sandbox lists NVIDIA GeForce RTX 4090 (Windows Sandbox vGPU, driver reported as 10.0.26100.1150) and the Microsoft Remote Display Adapter. The dispatch passed the replay's SM 6.6 wave32 gate. - **Windows build:** Windows 11 Enterprise 10.0.26100, build 26100 - **Debug layer:** off. The sandbox image has no `d3d12SDKLayers.dll`, and the test tools do not enable it. - **Commands:** ``` cmake --preset dev -DX2W_WITH_OPUS=OFF -DINTAKE_PYTHON=<venv python with requirements-dev.txt> cmake --build --preset dev --target compile_dxil native_store_replay ctest --preset dev --no-tests=error -R '^(native_global_subdword_load_.*|native_global_load_.*|native_global_store_.*)$' --output-on-failure -V ``` - **Passed (5):** - `native_global_load_hardware` - `native_global_store_encodings` - `native_global_store_hardware` - `native_global_subdword_load_encodings` - `native_global_subdword_load_hardware`: 29 cases per lane, module counts (50, 52, 4), and the alias and reverse programs. - **Failed:** none. - **Skipped (77):** none. ### Revert check Each mutation was applied to a scratch copy, then `compile_dxil` was rebuilt (no compile errors) and the two subdword tests were run. - **A: revert the decode gate.** Remove the `subdword_load` declaration and the `|| subdword_load` term in `src/gfx1013_compute_native.cpp`. - `_encodings` passed. - `_hardware` failed at the non-root-base refusal control: it expected "global load base is not a root buffer address" and got the generic DWORD-only decode refusal. - **B: drop the byte-lane shift.** Change `mul byte_lane, 8` to `mul byte_lane, 0` at `src/gfx1013_direct_compute.inl:680`. - `_encodings` passed. - `_hardware` passed the module checks and failed the readback, starting at lane 0 slot 1 (the sbyte at offset 2). The first diff is 0x0 against 0xffffffaa. - **Restored tree:** file hashes matched the head again, and both tests passed.
github-bot changed target branch from main to gh-pr/3515/base 2026-11-30 02:40:19 +00:00
github manually merged commit d02f73e3f3 into gh-pr/3515/base 2026-11-30 02:40:20 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.