shader: copy compute buffer reads from a caller-bound source to the store #782

Merged
roansystemlabs merged 3 commits from upstream-pr/788 into main 2026-11-23 04:18:47 +00:00
roansystemlabs commented 2026-11-23 03:27:05 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by roansystemlabs on 2026-11-23T03:27:05Z.


Change

Step 3 of #721: vector reads. Refs #721.

It builds on the per-lane guard merged in #776: the LLVM 15 fixtures read inside a guard.

LLVM 15 compiles a read from a second raw buffer, copied to the store, as:

s_load_dwordx8 s[0:7], s[0:1], 0x0          ; u0 and the source descriptor in one load
v_lshlrev_b32_e32 v1, 2, v0                 ; byte offset gid * 4
s_waitcnt lgkmcnt(0)
buffer_load_dword v1, v1, s[4:7], 0 offen   ; read
s_waitcnt vmcnt(0)                          ; the VGPR is valid only after this
buffer_store_dword v1, v0, s[0:3], 0 idxen

compute_store_aot.lower() now lowers this to a real read from a ByteAddressBuffer. No ALU is added; the word read is only stored or copied, as you asked on #721 for small steps.

  • Binding: the caller binds the source, as for u0 and b0. --source-descriptor gives the table byte offset of its descriptor, which becomes ByteAddressBuffer inputData : register(t0). --source-stride gives the stride that indexed reads use. Slots must not overlap the u0 or b0 slots. An s_load_dwordx8 is accepted when both 16-byte halves are bound slots.
  • Read: buffer_load_dword vN, ..., s[a:a+3], 0, with a zero SGPR offset and an aligned instruction offset below 4096, from the t0 descriptor only. The address is a fixed off offset, an offen byte offset dispatch index << shift with a shift of at least 2 (smaller shifts give unaligned byte offsets), or an idxen dispatch index with --source-stride, where the instruction offset must stay inside one element.
  • Reads from u0 are rejected ("Reads from the stored UAV are not supported"): a read of the store target would have to be ordered against other invocations' stores, which this step does not model.
  • Wait: the loaded VGPR is unknown until s_waitcnt vmcnt(0), alone or combined with lgkmcnt(0). Reading, copying or overwriting it before that wait is rejected, and so is a partial count such as vmcnt(1). Before this change, vmcnt(0) was a no-op, and it still is when no load is outstanding.
  • Guard: loads follow the #776 rules. A load issued under the guard is unknown after the restore. A load issued before the guard and waited for only under it is pending again after the restore. If its register was overwritten under the guard, it is unknown.
  • Output: t0 is read-only, so the HLSL reads it where the word is used, inside the if when the store is guarded. The output for every existing program is unchanged.

shader_profile_audit.py is unchanged. It does not bind a source. Docs: new subsection "Vector reads from a second raw buffer", after "Per-lane guards around compute stores".

Verification

Commit 72c7ae5 on main (8ed77f6). Windows 11 build 26200.9974, D3D12 debug layer enabled, NVIDIA GeForce RTX 3070 (driver 32.0.16.2101) and WARP (10.0.26100.9818).

Fixtures. Both programs are unchanged LLVM 15 code generator output of original amdgpu_cs sources (source and commands below), with the #776 layout: a 32-bit table pointer and the group X ID as SGPR arguments, a group of 32, u0 at table byte 0, the source at byte 16, b0 at byte 32, and n = params[0].x.

  • read_copy: if (gid < n) out[gid] = src word gid, a raw offen read. Bindings: --table-reg 0 --descriptor-offset 0 --constant-descriptor 32 --group-reg 1 --stride 4 --source-descriptor 16.
  • read_index: if (gid < n) out[gid] = word 1 of src element gid, an idxen offset:4 read. The stride is a descriptor field, bound here with --source-stride 8.

Emitted HLSL for read_copy:

cbuffer Constants : register(b0) { uint4 params[4]; };
ByteAddressBuffer inputData : register(t0);
RWByteAddressBuffer outputData : register(u0);
[numthreads(32,1,1)]
void main(uint3 tid : SV_DispatchThreadID) {
    if (params[0].x > tid.x) {
        outputData.Store(tid.x * 4u + 0u, inputData.Load((tid.x << 2u) + 0u));
    }
}

For read_index the read is inputData.Load(tid.x * 8u + 4u).

Binary checks (LLVM 15). tests/compute_store_check.py binary assembles both fixtures, extracts them from a container, and checks that the decoded listing and the CLI (with --source-descriptor and --source-stride) give the hand-listed result. As for #776, I ran it locally with the official LLVM 15.0.7 Windows build: clang 15.0.7 as the assembler behind an llvm-mc-style wrapper, llvm-objcopy 15.0.7, and its LLVM-C.dll for disassembly:

python -B tests/compute_store_check.py binary <llvm-mc wrapper> llvm-objcopy.exe LLVM-C.dll
exit 0

The Ubuntu pixel-binary job runs the same command with llvm-mc-15.

CPU controls (run before every mode). Exact output for both programs, then these are accepted with the same HLSL:

  • the two descriptors loaded with two s_load_dwordx4, as the full -O2 IR pipeline emits it;
  • a combined vmcnt(0) lgkmcnt(0) wait, and a v_mov_b32 copy of the word read before the store;
  • a read issued before the guard, waited for under it, then waited for again after the restore.

A fixed off read is also accepted, as inputData.Load(8u).

Rejected, each with its named diagnostic:

  • Wait: no vmcnt(0) wait (both programs), only an lgkmcnt(0) wait, a partial vmcnt(1) wait, the word read copied or overwritten before its wait, and a read from before the guard used after the restore without a new wait.
  • Descriptor: a read from the u0 descriptor or from the b0 descriptor, a source bound at another slot or not bound at all, and a read issued while the descriptor load is still pending.
  • Index: a byte offset that is not the dispatch index (missing, or a constant), a byte offset shifted by 1, idxen on the raw read, offen on the indexed read, an indexed read without a stride, and an index from an unknown VGPR.
  • Offset: an unaligned instruction offset, offset 4096, and an offset that leaves the source element.
  • Guard: a word read under the guard and stored after the restore, and a word overwritten under the guard after its wait.
  • Binding: an overlapping or unaligned source slot, an unaligned stride, and a stride without a source.

Mutation check (local, LLVM 15.0.7 tools as above). Each single-site mutant of compute_store_aot.py ran the full compute_store_check.py binary in a copy of tools/ and tests/. All 49 were killed: 24 new ones for the reads and the 25 guard mutants from #776, rerun. rejects() now reports any exception other than the expected ValueError as a failed rejection, so a mutant that crashes inside a rejection control fails its assertion instead of escaping as an unrelated error. Every mutant is killed by a control with its diagnostic or by the exact-output check of a fixture: no vmcnt tracking, lgkmcnt completing vector loads, a loaded word known at once, u0 reads allowed, any descriptor read, a pending descriptor, unaligned or 12-bit offsets unchecked, a read leaving its element, an offen shift below 2, an offen address from any vector or an idxen read without a stride, idxen/offen swapped, the shift, offset or source stride dropped or taken from u0, guard loads kept or not pending after the restore, an overlapping slot, the second x8 slot unchecked or tagged as the first, no t0 declaration, and the CLI dropping either new option.

Windows tests (72c7ae5, rebuilt):

ctest --preset dev --no-tests=error -R "^(compute_store_aot_|compute_mesh_texture_|compute_to_pixel_|offscreen_warp|compute_|shader_metadata_census|pixel_aot_)" -V
100% tests passed, 0 tests failed out of 54

compute_store_aot_hardware and compute_store_aot_warp each passed 42 full 320-word readbacks, 36 existing and 6 new, all with mismatches=0 and debug_errors=0 debug_warnings=0. The harness binds t0 to 320 known words, 0x8b02a7f1 + i * 0x413b1, followed by 320 sentinel words, and u0 starts at the sentinel 0xc5c5c5c5. The expected words come from an independent per-lane model. Each read program runs three dispatches:

Groups n Covers
1 0 no lane reads, so the branch is taken
1 17 split wave
5 150 the largest dispatch the harness takes, four full waves and the fifth split; every lane reads a known word

On 5 groups with n = 150, each of these must fail, and all failed on both adapters:

  • a reference with one copied word off by one bit, or with lane 150 also copying (first mismatch at that word);
  • recompiled HLSL that ignores the read index, reads the next source word, or reads u0 instead of t0 ("Compute readback differs").

compute_store_aot_hardware took 30.5 s and _warp 6.0 s, against a 45 s timeout (the guard alone, before this change, took 28.4 s). The hardware test is sensitive to machine load: before the rebase, with other jobs keeping the CPU at about 75 %, the same test timed out while still in the guard dispatches, and passed in 39.2 to 39.6 s at about 25 to 40 %. If a later step adds dispatches to this test, it may need to be split or given a longer timeout. Ten runs elsewhere report debug_warnings=1 (compute_to_pixel_*, pixel_aot_buffer_color_*, pixel_aot_attribute_*), the same tests and count as for #776; this PR does not touch them.

Pure-Python checks from AGENTS.md (22): all exit 0.

Load during the Windows run: GPU 9 % before and 3 % after (nvidia-smi), with 4.8 to 5.6 GB of 8 GB in use by other processes; CPU 21 % before and 13 % after. The tests are short dispatches.

Overlap. No open PR touches tools/compute_store_aot.py or tests/compute_store_check.py. Against the 50 open PRs that touch these files or docs/experiments.md, git merge-tree shows no conflict that main does not already have. The branch also merges cleanly with current main.

Kernel source and commands
declare i32 @llvm.amdgcn.s.buffer.load.i32(<4 x i32>, i32, i32)
declare i32 @llvm.amdgcn.raw.buffer.load.i32(<4 x i32>, i32, i32, i32)
declare i32 @llvm.amdgcn.struct.buffer.load.i32(<4 x i32>, i32, i32, i32, i32)
declare void @llvm.amdgcn.struct.buffer.store.i32(i32, <4 x i32>, i32, i32, i32, i32)

define amdgpu_cs void @read_copy(i32 inreg %table, i32 inreg %group, <3 x i32> %lid3) #0 {
entry:
  %t64 = zext i32 %table to i64
  %tp = inttoptr i64 %t64 to ptr addrspace(4)
  %uav = load <4 x i32>, ptr addrspace(4) %tp, align 16, !invariant.load !0
  %sp = getelementptr inbounds i8, ptr addrspace(4) %tp, i32 16
  %src = load <4 x i32>, ptr addrspace(4) %sp, align 16, !invariant.load !0
  %cp = getelementptr inbounds i8, ptr addrspace(4) %tp, i32 32
  %cbv = load <4 x i32>, ptr addrspace(4) %cp, align 16, !invariant.load !0
  %n = call i32 @llvm.amdgcn.s.buffer.load.i32(<4 x i32> %cbv, i32 0, i32 0)
  %lid = extractelement <3 x i32> %lid3, i32 0
  %base = shl i32 %group, 5
  %gid = add i32 %base, %lid
  %in = icmp ult i32 %gid, %n
  br i1 %in, label %body, label %end
body:
  %off = shl i32 %gid, 2
  %v = call i32 @llvm.amdgcn.raw.buffer.load.i32(<4 x i32> %src, i32 %off, i32 0, i32 0)
  call void @llvm.amdgcn.struct.buffer.store.i32(i32 %v, <4 x i32> %uav, i32 %gid, i32 0, i32 0, i32 0)
  br label %end
end:
  ret void
}
attributes #0 = { "amdgpu-flat-work-group-size"="32,32" }
!0 = !{}

read_index is the same function with the read replaced by struct.buffer.load.i32(<4 x i32> %src, i32 %gid, i32 4, i32 0, i32 0), that is byte 4 of element gid.

The listing comes from the LLVM 15.0.7 code generator, through clang because the Windows release has no llc:

clang -S --target=amdgcn--amdpal -mcpu=gfx1013 -O2 -x ir -Xclang -disable-llvm-passes reads.ll -o reads.s

This skips the IR optimization pipeline and runs only the code generator, as llc-15 -mtriple=amdgcn--amdpal -mcpu=gfx1013 -O2 does. Both fixtures match the listing line for line. Without -disable-llvm-passes, read_index is identical, and read_copy loads the two descriptors with two s_load_dwordx4 instead of one s_load_dwordx8. That variant is a CPU control above.

Evidence and follow-up

  • Fixtures: original sources written for this test, compiled with LLVM 15 and kept as gfx1013 assembly. MIT. No game files.
  • Assumptions: the caller binds the source as a separate read-only raw buffer that does not alias u0. That binding, like the u0 and b0 bindings, needs separate evidence for a real program. The tests bind in-range buffers, with no swizzle, format conversion or out-of-range reads.
  • Not covered: reads from u0, multi-dword and typed loads, non-zero SGPR offsets, glc/slc/dlc, and partial vmcnt counts. A program with one of these still stops at its first unsupported instruction.
  • Next on #721: the small ALU subset, then the first read–compute–write kernel. Once an ALU instruction that writes vcc is accepted, the guard compare tracking from #776 will have to be invalidated on that write.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted: yes. Code, tests and this description were prepared with an AI coding agent and checked by running the commands above.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6551634918 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/788). Originally posted by [roansystemlabs](https://github.com/roansystemlabs) on 2026-11-23T03:27:05Z. --- ## Change Step 3 of #721: vector reads. Refs #721. It builds on the per-lane guard merged in #776: the LLVM 15 fixtures read inside a guard. LLVM 15 compiles a read from a second raw buffer, copied to the store, as: ``` s_load_dwordx8 s[0:7], s[0:1], 0x0 ; u0 and the source descriptor in one load v_lshlrev_b32_e32 v1, 2, v0 ; byte offset gid * 4 s_waitcnt lgkmcnt(0) buffer_load_dword v1, v1, s[4:7], 0 offen ; read s_waitcnt vmcnt(0) ; the VGPR is valid only after this buffer_store_dword v1, v0, s[0:3], 0 idxen ``` `compute_store_aot.lower()` now lowers this to a real read from a `ByteAddressBuffer`. No ALU is added; the word read is only stored or copied, as you asked on #721 for small steps. - **Binding:** the caller binds the source, as for u0 and b0. `--source-descriptor` gives the table byte offset of its descriptor, which becomes `ByteAddressBuffer inputData : register(t0)`. `--source-stride` gives the stride that indexed reads use. Slots must not overlap the u0 or b0 slots. An `s_load_dwordx8` is accepted when both 16-byte halves are bound slots. - **Read:** `buffer_load_dword vN, ..., s[a:a+3], 0`, with a zero SGPR offset and an aligned instruction offset below 4096, from the t0 descriptor only. The address is a fixed `off` offset, an `offen` byte offset `dispatch index << shift` with a shift of at least 2 (smaller shifts give unaligned byte offsets), or an `idxen` dispatch index with `--source-stride`, where the instruction offset must stay inside one element. - **Reads from u0 are rejected** ("Reads from the stored UAV are not supported"): a read of the store target would have to be ordered against other invocations' stores, which this step does not model. - **Wait:** the loaded VGPR is unknown until `s_waitcnt vmcnt(0)`, alone or combined with `lgkmcnt(0)`. Reading, copying or overwriting it before that wait is rejected, and so is a partial count such as `vmcnt(1)`. Before this change, `vmcnt(0)` was a no-op, and it still is when no load is outstanding. - **Guard:** loads follow the #776 rules. A load issued under the guard is unknown after the restore. A load issued before the guard and waited for only under it is pending again after the restore. If its register was overwritten under the guard, it is unknown. - **Output:** t0 is read-only, so the HLSL reads it where the word is used, inside the `if` when the store is guarded. The output for every existing program is unchanged. `shader_profile_audit.py` is unchanged. It does not bind a source. Docs: new subsection "Vector reads from a second raw buffer", after "Per-lane guards around compute stores". ## Verification Commit `72c7ae5` on `main` (`8ed77f6`). Windows 11 build 26200.9974, D3D12 debug layer enabled, NVIDIA GeForce RTX 3070 (driver 32.0.16.2101) and WARP (10.0.26100.9818). **Fixtures.** Both programs are unchanged LLVM 15 code generator output of original `amdgpu_cs` sources (source and commands below), with the #776 layout: a 32-bit table pointer and the group X ID as SGPR arguments, a group of 32, u0 at table byte 0, the source at byte 16, b0 at byte 32, and `n = params[0].x`. - `read_copy`: `if (gid < n) out[gid] = src word gid`, a raw `offen` read. Bindings: `--table-reg 0 --descriptor-offset 0 --constant-descriptor 32 --group-reg 1 --stride 4 --source-descriptor 16`. - `read_index`: `if (gid < n) out[gid] = word 1 of src element gid`, an `idxen offset:4` read. The stride is a descriptor field, bound here with `--source-stride 8`. Emitted HLSL for `read_copy`: ```hlsl cbuffer Constants : register(b0) { uint4 params[4]; }; ByteAddressBuffer inputData : register(t0); RWByteAddressBuffer outputData : register(u0); [numthreads(32,1,1)] void main(uint3 tid : SV_DispatchThreadID) { if (params[0].x > tid.x) { outputData.Store(tid.x * 4u + 0u, inputData.Load((tid.x << 2u) + 0u)); } } ``` For `read_index` the read is `inputData.Load(tid.x * 8u + 4u)`. **Binary checks (LLVM 15).** `tests/compute_store_check.py binary` assembles both fixtures, extracts them from a container, and checks that the decoded listing and the CLI (with `--source-descriptor` and `--source-stride`) give the hand-listed result. As for #776, I ran it locally with the official LLVM 15.0.7 Windows build: `clang` 15.0.7 as the assembler behind an `llvm-mc`-style wrapper, `llvm-objcopy` 15.0.7, and its `LLVM-C.dll` for disassembly: ``` python -B tests/compute_store_check.py binary <llvm-mc wrapper> llvm-objcopy.exe LLVM-C.dll exit 0 ``` The Ubuntu `pixel-binary` job runs the same command with `llvm-mc-15`. **CPU controls** (run before every mode). Exact output for both programs, then these are accepted with the same HLSL: - the two descriptors loaded with two `s_load_dwordx4`, as the full `-O2` IR pipeline emits it; - a combined `vmcnt(0) lgkmcnt(0)` wait, and a `v_mov_b32` copy of the word read before the store; - a read issued before the guard, waited for under it, then waited for again after the restore. A fixed `off` read is also accepted, as `inputData.Load(8u)`. Rejected, each with its named diagnostic: - **Wait:** no `vmcnt(0)` wait (both programs), only an `lgkmcnt(0)` wait, a partial `vmcnt(1)` wait, the word read copied or overwritten before its wait, and a read from before the guard used after the restore without a new wait. - **Descriptor:** a read from the u0 descriptor or from the b0 descriptor, a source bound at another slot or not bound at all, and a read issued while the descriptor load is still pending. - **Index:** a byte offset that is not the dispatch index (missing, or a constant), a byte offset shifted by 1, `idxen` on the raw read, `offen` on the indexed read, an indexed read without a stride, and an index from an unknown VGPR. - **Offset:** an unaligned instruction offset, offset 4096, and an offset that leaves the source element. - **Guard:** a word read under the guard and stored after the restore, and a word overwritten under the guard after its wait. - **Binding:** an overlapping or unaligned source slot, an unaligned stride, and a stride without a source. **Mutation check** (local, LLVM 15.0.7 tools as above). Each single-site mutant of `compute_store_aot.py` ran the full `compute_store_check.py binary` in a copy of `tools/` and `tests/`. All 49 were killed: 24 new ones for the reads and the 25 guard mutants from #776, rerun. `rejects()` now reports any exception other than the expected `ValueError` as a failed rejection, so a mutant that crashes inside a rejection control fails its assertion instead of escaping as an unrelated error. Every mutant is killed by a control with its diagnostic or by the exact-output check of a fixture: no vmcnt tracking, `lgkmcnt` completing vector loads, a loaded word known at once, u0 reads allowed, any descriptor read, a pending descriptor, unaligned or 12-bit offsets unchecked, a read leaving its element, an `offen` shift below 2, an `offen` address from any vector or an `idxen` read without a stride, `idxen`/`offen` swapped, the shift, offset or source stride dropped or taken from u0, guard loads kept or not pending after the restore, an overlapping slot, the second x8 slot unchecked or tagged as the first, no t0 declaration, and the CLI dropping either new option. **Windows tests** (`72c7ae5`, rebuilt): ``` ctest --preset dev --no-tests=error -R "^(compute_store_aot_|compute_mesh_texture_|compute_to_pixel_|offscreen_warp|compute_|shader_metadata_census|pixel_aot_)" -V 100% tests passed, 0 tests failed out of 54 ``` `compute_store_aot_hardware` and `compute_store_aot_warp` each passed 42 full 320-word readbacks, 36 existing and 6 new, all with `mismatches=0` and `debug_errors=0 debug_warnings=0`. The harness binds t0 to 320 known words, `0x8b02a7f1 + i * 0x413b1`, followed by 320 sentinel words, and u0 starts at the sentinel `0xc5c5c5c5`. The expected words come from an independent per-lane model. Each read program runs three dispatches: | Groups | n | Covers | |---|---|---| | 1 | 0 | no lane reads, so the branch is taken | | 1 | 17 | split wave | | 5 | 150 | the largest dispatch the harness takes, four full waves and the fifth split; every lane reads a known word | On 5 groups with `n = 150`, each of these must fail, and all failed on both adapters: - a reference with one copied word off by one bit, or with lane 150 also copying (first mismatch at that word); - recompiled HLSL that ignores the read index, reads the next source word, or reads u0 instead of t0 ("Compute readback differs"). `compute_store_aot_hardware` took 30.5 s and `_warp` 6.0 s, against a 45 s timeout (the guard alone, before this change, took 28.4 s). The hardware test is sensitive to machine load: before the rebase, with other jobs keeping the CPU at about 75 %, the same test timed out while still in the guard dispatches, and passed in 39.2 to 39.6 s at about 25 to 40 %. If a later step adds dispatches to this test, it may need to be split or given a longer timeout. Ten runs elsewhere report `debug_warnings=1` (`compute_to_pixel_*`, `pixel_aot_buffer_color_*`, `pixel_aot_attribute_*`), the same tests and count as for #776; this PR does not touch them. Pure-Python checks from `AGENTS.md` (22): all exit 0. Load during the Windows run: GPU 9 % before and 3 % after (`nvidia-smi`), with 4.8 to 5.6 GB of 8 GB in use by other processes; CPU 21 % before and 13 % after. The tests are short dispatches. **Overlap.** No open PR touches `tools/compute_store_aot.py` or `tests/compute_store_check.py`. Against the 50 open PRs that touch these files or `docs/experiments.md`, `git merge-tree` shows no conflict that `main` does not already have. The branch also merges cleanly with current `main`. <details> <summary>Kernel source and commands</summary> ```llvm declare i32 @llvm.amdgcn.s.buffer.load.i32(<4 x i32>, i32, i32) declare i32 @llvm.amdgcn.raw.buffer.load.i32(<4 x i32>, i32, i32, i32) declare i32 @llvm.amdgcn.struct.buffer.load.i32(<4 x i32>, i32, i32, i32, i32) declare void @llvm.amdgcn.struct.buffer.store.i32(i32, <4 x i32>, i32, i32, i32, i32) define amdgpu_cs void @read_copy(i32 inreg %table, i32 inreg %group, <3 x i32> %lid3) #0 { entry: %t64 = zext i32 %table to i64 %tp = inttoptr i64 %t64 to ptr addrspace(4) %uav = load <4 x i32>, ptr addrspace(4) %tp, align 16, !invariant.load !0 %sp = getelementptr inbounds i8, ptr addrspace(4) %tp, i32 16 %src = load <4 x i32>, ptr addrspace(4) %sp, align 16, !invariant.load !0 %cp = getelementptr inbounds i8, ptr addrspace(4) %tp, i32 32 %cbv = load <4 x i32>, ptr addrspace(4) %cp, align 16, !invariant.load !0 %n = call i32 @llvm.amdgcn.s.buffer.load.i32(<4 x i32> %cbv, i32 0, i32 0) %lid = extractelement <3 x i32> %lid3, i32 0 %base = shl i32 %group, 5 %gid = add i32 %base, %lid %in = icmp ult i32 %gid, %n br i1 %in, label %body, label %end body: %off = shl i32 %gid, 2 %v = call i32 @llvm.amdgcn.raw.buffer.load.i32(<4 x i32> %src, i32 %off, i32 0, i32 0) call void @llvm.amdgcn.struct.buffer.store.i32(i32 %v, <4 x i32> %uav, i32 %gid, i32 0, i32 0, i32 0) br label %end end: ret void } attributes #0 = { "amdgpu-flat-work-group-size"="32,32" } !0 = !{} ``` `read_index` is the same function with the read replaced by `struct.buffer.load.i32(<4 x i32> %src, i32 %gid, i32 4, i32 0, i32 0)`, that is byte 4 of element `gid`. The listing comes from the LLVM 15.0.7 code generator, through `clang` because the Windows release has no `llc`: ```sh clang -S --target=amdgcn--amdpal -mcpu=gfx1013 -O2 -x ir -Xclang -disable-llvm-passes reads.ll -o reads.s ``` This skips the IR optimization pipeline and runs only the code generator, as `llc-15 -mtriple=amdgcn--amdpal -mcpu=gfx1013 -O2` does. Both fixtures match the listing line for line. Without `-disable-llvm-passes`, `read_index` is identical, and `read_copy` loads the two descriptors with two `s_load_dwordx4` instead of one `s_load_dwordx8`. That variant is a CPU control above. </details> ## Evidence and follow-up - **Fixtures:** original sources written for this test, compiled with LLVM 15 and kept as gfx1013 assembly. MIT. No game files. - **Assumptions:** the caller binds the source as a separate read-only raw buffer that does not alias u0. That binding, like the u0 and b0 bindings, needs separate evidence for a real program. The tests bind in-range buffers, with no swizzle, format conversion or out-of-range reads. - **Not covered:** reads from u0, multi-dword and typed loads, non-zero SGPR offsets, `glc`/`slc`/`dlc`, and partial `vmcnt` counts. A program with one of these still stops at its first unsupported instruction. - **Next on #721:** the small ALU subset, then the first read–compute–write kernel. Once an ALU instruction that writes `vcc` is accepted, the guard compare tracking from #776 will have to be invalidated on that write. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted: yes. Code, tests and this description were prepared with an AI coding agent and checked by running the commands above.
upstream-sync closed this pull request 2026-11-24 06:44:47 +00:00
rwZephyr commented 2026-11-24 06:48:59 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by rwZephyr on 2026-11-23T03:51:51Z.


Independent Windows 10 22H2 (19045.6466) run on 72c7ae596f05c3d18137c7ab38ceb59c1517a62a.

ctest --preset dev --no-tests=error -V -R '^compute_store_aot_(hardware|warp)$'

The two new fixtures should copy the selected source DWORDs below the bound and preserve 0xc5c5c5c5 elsewhere. Both backends matched all 320 DWORDs in each of 42 positive readbacks, including the six new dispatches. The negative controls detected the intended mismatches.

  • Hardware: RTX 3060 Ti (10de:2414), DXGI driver 32.0.16.2124, passed in 30.37 s.
  • Software: in-box Microsoft WARP (1414:008c, 10.0.19041.5794), passed in 4.55 s.
  • Zero skips. D3D12 debug layer unavailable on both backends.

AI-assisted. All tests ran locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7091085658 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/788#issuecomment-7091085658). Originally posted by [rwZephyr](https://github.com/rwZephyr) on 2026-11-23T03:51:51Z. --- Independent Windows 10 22H2 (19045.6466) run on `72c7ae596f05c3d18137c7ab38ceb59c1517a62a`. `ctest --preset dev --no-tests=error -V -R '^compute_store_aot_(hardware|warp)$'` The two new fixtures should copy the selected source DWORDs below the bound and preserve `0xc5c5c5c5` elsewhere. Both backends matched all 320 DWORDs in each of 42 positive readbacks, including the six new dispatches. The negative controls detected the intended mismatches. - Hardware: RTX 3060 Ti (`10de:2414`), DXGI driver `32.0.16.2124`, passed in 30.37 s. - Software: in-box Microsoft WARP (`1414:008c`, `10.0.19041.5794`), passed in 4.55 s. - Zero skips. D3D12 debug layer unavailable on both backends. AI-assisted. All tests ran locally.
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!782
No description provided.