gpu: store through two raw UAV address windows #1018

Merged
zohaiblazuli merged 3 commits from upstream-pr/1025 into main 2026-11-24 08:06:49 +00:00
zohaiblazuli commented 2026-11-23 21:58:32 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by zohaiblazuli on 2026-11-23T21:58:32Z.


Change

Refs #874. This is the open slice "a raw UAV store through two distinct logical address windows", which I claimed in #874. It builds on #1017, which must land first: the first commit here is #1017's, rebased onto current main, with a docs conflict resolved by keeping both entries. Review only the second commit, d9c3609.

  • src/raw_buffer_uav.h adds resolve_raw_uav_store, next to make_raw_buffer_srv. It maps a logical address to the window that contains it and returns a raw R32_TYPELESS UAV covering exactly that window, plus the store's byte offset inside it.
    • Declared alignment: 4 bytes for a scalar DWORD store and 16 bytes for a four-DWORD store. Other widths are refused.
    • Fit: the whole store must lie inside one window.
    • Window validity: each window must sit inside its resource, start 16-byte aligned (D3D12_RAW_UAV_SRV_BYTE_ALIGNMENT), and be a whole number of DWORDs.
    • Anything else returns E_INVALIDARG before a descriptor is created.
  • vm_copy_queue_check raw_uav_{warp,hardware} and the CTests vm_raw_uav_warp and vm_raw_uav_hardware:
    • Two 4 KiB default-heap buffers hold distinct sentinel words. Window 0 maps 2040 bytes starting 256 bytes into buffer 0, and window 1 maps 2040 bytes starting 512 bytes into buffer 1. The views therefore have different first elements, and a 16-byte-aligned vector can't fit in a window's last 8 bytes.
    • Seven refusals, checked before any GPU work: a 16-byte-aligned vector running 8 bytes past its window, the first byte after a window, a 4-byte-aligned vector, a misaligned scalar, an address between the windows, an address just before a window, and an undeclared 8-byte width.
    • Bound pass: a scalar Store goes into the last DWORD of window 0 and a Store4 lands 24 bytes before the end of window 1, through descriptor-table bindings. Readback of both full buffers must differ from the sentinels in exactly those five words.
    • Swapped pass (negative control): the sentinels are reloaded and the two window bindings swapped. The same stores must land at the matching offsets of the other buffer, and all five intended words must keep their sentinels.
  • docs/experiments.md has a reproduction entry after the raw SRV entry.

No existing behavior changes. The other vm_copy_queue_check modes are untouched.

Verification

Branch head d9c3609 on main at 6a09e87. Windows 11 build 26300.10075, MSVC 19.50.35728 x64, Windows SDK DXC. Debug layer off, as in #1017 (the harness doesn't enable it).

cmake --build --preset dev --target vm_copy_queue_check
ctest --preset dev --no-tests=error -R '^(vm_raw_uav_|vm_raw_srv_|vm_copy_queue_|vm_page_provenance_|docs_links)'

9/9 passed with dev, and again with release (/O2). Direct runs from the build directory:

Adapter Driver raw_uav_* raw_srv_hardware
NVIDIA GeForce RTX 3060 (10de:2504) 32.0.16.1742 bound mismatches 0, changed 5/2048; swapped mismatches 0, changed 5, intended kept 5/5; refused 7 mismatches 0, shifted 0, negative 1024/1024
Intel UHD Graphics 770 (8086:a780), selected with XBOX2WINDOWS_ADAPTER=Intel 32.0.101.7092 same as RTX 3060 mismatches 0, shifted 0, negative 1024/1024
In-box WARP — same (raw_srv_warp) same

The Intel raw_srv_hardware row is also the independent Intel result requested for #1017 in #874.

Mutation check: forcing FirstElement = 0 in the resolver, so the window offset is ignored, failed raw_uav_warp with 10 mismatching words in each pass. Restoring it passed again.

Evidence and follow-up

The shader (tests/vm_raw_uav.hlsl), resolver and test are original, under the MIT license, and use only synthetic sentinel data. The windows are explicit test inputs and don't come from any title data.

Assumptions that need separate evidence:

  • The 16-byte declared alignment for the four-DWORD store is this fixture's contract. DXIL Store4 itself only requires 4-byte alignment.
  • Mapping a logical window to one raw UAV per window, rather than one view per store, is a fixture choice.

Follow-ups:

  • A window that is unmapped at dispatch time rather than at resolve time (for example a released backing range) isn't covered.
  • Cross-window stores are refused, never split.

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.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6569668774 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1025). Originally posted by [zohaiblazuli](https://github.com/zohaiblazuli) on 2026-11-23T21:58:32Z. --- ## Change Refs #874. This is the open slice "a raw UAV store through two distinct logical address windows", which I claimed in #874. It builds on #1017, which must land first: the first commit here is #1017's, rebased onto current `main`, with a docs conflict resolved by keeping both entries. Review only the second commit, `d9c3609`. - `src/raw_buffer_uav.h` adds `resolve_raw_uav_store`, next to `make_raw_buffer_srv`. It maps a logical address to the window that contains it and returns a raw `R32_TYPELESS` UAV covering exactly that window, plus the store's byte offset inside it. - **Declared alignment:** 4 bytes for a scalar DWORD store and 16 bytes for a four-DWORD store. Other widths are refused. - **Fit:** the whole store must lie inside one window. - **Window validity:** each window must sit inside its resource, start 16-byte aligned (`D3D12_RAW_UAV_SRV_BYTE_ALIGNMENT`), and be a whole number of DWORDs. - Anything else returns `E_INVALIDARG` before a descriptor is created. - `vm_copy_queue_check raw_uav_{warp,hardware}` and the CTests `vm_raw_uav_warp` and `vm_raw_uav_hardware`: - Two 4 KiB default-heap buffers hold distinct sentinel words. Window 0 maps 2040 bytes starting 256 bytes into buffer 0, and window 1 maps 2040 bytes starting 512 bytes into buffer 1. The views therefore have different first elements, and a 16-byte-aligned vector can't fit in a window's last 8 bytes. - **Seven refusals, checked before any GPU work:** a 16-byte-aligned vector running 8 bytes past its window, the first byte after a window, a 4-byte-aligned vector, a misaligned scalar, an address between the windows, an address just before a window, and an undeclared 8-byte width. - **Bound pass:** a scalar `Store` goes into the last DWORD of window 0 and a `Store4` lands 24 bytes before the end of window 1, through descriptor-table bindings. Readback of both full buffers must differ from the sentinels in exactly those five words. - **Swapped pass (negative control):** the sentinels are reloaded and the two window bindings swapped. The same stores must land at the matching offsets of the other buffer, and all five intended words must keep their sentinels. - `docs/experiments.md` has a reproduction entry after the raw SRV entry. No existing behavior changes. The other `vm_copy_queue_check` modes are untouched. ## Verification Branch head `d9c3609` on `main` at `6a09e87`. Windows 11 build 26300.10075, MSVC 19.50.35728 x64, Windows SDK DXC. Debug layer off, as in #1017 (the harness doesn't enable it). ```powershell cmake --build --preset dev --target vm_copy_queue_check ctest --preset dev --no-tests=error -R '^(vm_raw_uav_|vm_raw_srv_|vm_copy_queue_|vm_page_provenance_|docs_links)' ``` 9/9 passed with `dev`, and again with `release` (/O2). Direct runs from the build directory: | Adapter | Driver | `raw_uav_*` | `raw_srv_hardware` | |---|---|---|---| | NVIDIA GeForce RTX 3060 (`10de:2504`) | 32.0.16.1742 | bound mismatches 0, changed 5/2048; swapped mismatches 0, changed 5, intended kept 5/5; refused 7 | mismatches 0, shifted 0, negative 1024/1024 | | Intel UHD Graphics 770 (`8086:a780`), selected with `XBOX2WINDOWS_ADAPTER=Intel` | 32.0.101.7092 | same as RTX 3060 | mismatches 0, shifted 0, negative 1024/1024 | | In-box WARP | — | same | (`raw_srv_warp`) same | The Intel `raw_srv_hardware` row is also the independent Intel result requested for #1017 in #874. **Mutation check:** forcing `FirstElement = 0` in the resolver, so the window offset is ignored, failed `raw_uav_warp` with 10 mismatching words in each pass. Restoring it passed again. ## Evidence and follow-up The shader (`tests/vm_raw_uav.hlsl`), resolver and test are original, under the MIT license, and use only synthetic sentinel data. The windows are explicit test inputs and don't come from any title data. **Assumptions that need separate evidence:** - The 16-byte declared alignment for the four-DWORD store is this fixture's contract. DXIL `Store4` itself only requires 4-byte alignment. - Mapping a logical window to one raw UAV per window, rather than one view per store, is a fixture choice. **Follow-ups:** - A window that is unmapped at dispatch time rather than at resolve time (for example a released backing range) isn't covered. - Cross-window stores are refused, never split. ## 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.
tedin7 commented 2026-11-24 06:45:54 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T03:15:37Z.

Review: COMMENTED


Audited diff (a6399891, stacked on #1017) and ran platform-independent checks on Linux (Windows D3D12/DXC build and vm_raw_uav_warp / vm_raw_uav_hardware were not executed locally).

Linux checks run on a6399891:

  • python3 -B tests/docs_links_check.py: passed (Checked 13 Markdown files and 221 links.)
  • python3 -B tests/bidi_controls_check.py: passed (Checked 871 tracked source, script and build/CI files: no bidirectional controls.)
  • python3 -B tests/rdna2_tools_check.py: passed (Ran 90 tests in 2.107s, OK (skipped=5))
  • python3 -B tests/resource_root_check.py: passed (Ran 4 tests in 0.255s, OK)
  • python3 -B tests/resource_ranges_check.py: passed (Ran 20 tests in 2.120s, OK)

Code audit (src/raw_buffer_uav.h, tests/vm_copy_queue_check.cpp, tests/vm_raw_uav.hlsl):

  • resolve_raw_uav_store validates every window in the array (alignment of logical_base and resource_offset to D3D12_RAW_UAV_SRV_BYTE_ALIGNMENT, DWORD-multiple non-zero bytes fitting in UINT elements and within resource_width, no 64-bit wrap), rejects partial overlap below logical_base, rejects ambiguous/overlapping matches across windows, enforces offset <= UINT_MAX and store_bytes containment, and leaves result untouched on E_INVALIDARG.
  • raw_uav in tests/vm_copy_queue_check.cpp covers 7 request refusals, 4 window-control refusals, independent full-buffer sentinel verification for bound stores, and a swapped-bindings negative control.
  • Minor coverage note: as also noted in an earlier comment, the three resource_offset / resource_width error branches in resolve_raw_uav_store (resource_offset % 16, resource_offset > resource_width, bytes > resource_width - resource_offset) do not have negative test cases in raw_uav, and no GPU dispatch exercises an out-of-window offset at window_bytes to verify NumElements clipping on the GPU descriptor.
  • AGENTS.md compliance: title-neutral wording, docs/experiments.md updated.

Windows D3D12/WARP/hardware execution remains unverified locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6033139809 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1025#pullrequestreview-6033139809). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T03:15:37Z. **Review:** COMMENTED --- Audited diff (`a6399891`, stacked on `#1017`) and ran platform-independent checks on Linux (Windows D3D12/DXC build and `vm_raw_uav_warp` / `vm_raw_uav_hardware` were not executed locally). **Linux checks run on `a6399891`:** - `python3 -B tests/docs_links_check.py`: passed (`Checked 13 Markdown files and 221 links.`) - `python3 -B tests/bidi_controls_check.py`: passed (`Checked 871 tracked source, script and build/CI files: no bidirectional controls.`) - `python3 -B tests/rdna2_tools_check.py`: passed (`Ran 90 tests in 2.107s`, `OK (skipped=5)`) - `python3 -B tests/resource_root_check.py`: passed (`Ran 4 tests in 0.255s`, `OK`) - `python3 -B tests/resource_ranges_check.py`: passed (`Ran 20 tests in 2.120s`, `OK`) **Code audit (`src/raw_buffer_uav.h`, `tests/vm_copy_queue_check.cpp`, `tests/vm_raw_uav.hlsl`):** - `resolve_raw_uav_store` validates every window in the array (alignment of `logical_base` and `resource_offset` to `D3D12_RAW_UAV_SRV_BYTE_ALIGNMENT`, DWORD-multiple non-zero `bytes` fitting in `UINT` elements and within `resource_width`, no 64-bit wrap), rejects partial overlap below `logical_base`, rejects ambiguous/overlapping matches across windows, enforces `offset <= UINT_MAX` and `store_bytes` containment, and leaves `result` untouched on `E_INVALIDARG`. - `raw_uav` in `tests/vm_copy_queue_check.cpp` covers 7 request refusals, 4 window-control refusals, independent full-buffer sentinel verification for bound stores, and a swapped-bindings negative control. - Minor coverage note: as also noted in an earlier comment, the three `resource_offset` / `resource_width` error branches in `resolve_raw_uav_store` (`resource_offset % 16`, `resource_offset > resource_width`, `bytes > resource_width - resource_offset`) do not have negative test cases in `raw_uav`, and no GPU dispatch exercises an out-of-window offset at `window_bytes` to verify `NumElements` clipping on the GPU descriptor. - `AGENTS.md` compliance: title-neutral wording, `docs/experiments.md` updated. Windows D3D12/WARP/hardware execution remains unverified locally.
R0Y00 commented 2026-11-24 06:49:46 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T22:09:13Z.


I pushed a6399891. The resolver now refuses a too-wide shader offset, a misaligned logical base, a wrapping range and an ambiguous window without changing its output. The full-buffer expectation uses positions fixed by the request fixture rather than the resolver's offset. Forcing the dispatch 16 bytes early gave ten wrong words in each pass, then the restored Windows Release run passed 8/8 across the raw UAV/SRV, COPY and provenance checks. Both raw UAV backends reported eleven refusals and exactly five changed words in each pass. This PR still follows #1017.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7115392368 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1025#issuecomment-7115392368). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T22:09:13Z. --- I pushed `a6399891`. The resolver now refuses a too-wide shader offset, a misaligned logical base, a wrapping range and an ambiguous window without changing its output. The full-buffer expectation uses positions fixed by the request fixture rather than the resolver's offset. Forcing the dispatch 16 bytes early gave ten wrong words in each pass, then the restored Windows Release run passed 8/8 across the raw UAV/SRV, COPY and provenance checks. Both raw UAV backends reported eleven refusals and exactly five changed words in each pass. This PR still follows #1017.
thepatrickworld commented 2026-11-24 06:49:55 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by thepatrickworld on 2026-11-24T00:22:50Z.


Merged the stack onto current main and ran the two entries on an RX 9070 XT, since the _hardware ones never run in CI (-E '_hardware$' on both Windows jobs).

Merge. a639989 onto d33845b: no conflict (CMakeLists.txt and docs/experiments.md auto-merged). The merged tree is 3d9e0982, two parents, so any clean merge of those two should reproduce it. Note the API reports mergeable_state as unknown for #1017 right now; that state is about #1017 alone, not about this stack.

Result: 4/4 passed, three consecutive runs, build dev, same numbers each time.

vm_raw_srv_warp ....... Passed 0.10 s      vm_raw_srv_hardware ... Passed 0.22 s
vm_raw_uav_warp ....... Passed 0.04 s      vm_raw_uav_hardware ... Passed 0.16 s

On the hardware entry (device adapter 1002:7550 AMD Radeon RX 9070 XT, driver 32.0.32029.2010, DXC 1.9.2602.17, Windows 11 26200, MSVC 19.44.35230.0):

UAV windows: bound mismatches=0 changed=5/2048; swapped mismatches=0 changed=5, intended words kept=5/5; refused=11
SRV: cross-page mismatches=0 shifted mismatches=0 negative=1024/1024

refused=11 is 7 request refusals (d9c3609) plus 4 window controls (a639989), and both are E_INVALIDARG returns on the CPU side, before any descriptor exists — they are not GPU measurements. The seven in the d9c3609 message is accurate for that commit, which did not yet contain the four controls.

What this does not cover. No dispatch uses an offset at or beyond 2040, so nothing here documents the descriptor's upper bound. NumElements is bytes / 4 (510), so a store at 2040 is out of the descriptor and dropped — but the test would not notice if that number were too large: the same store would land in the buffer tail that is left at its sentinel (1800 bytes past the window in buffer 0, 1544 in buffer 1), and a wider NumElements would be accepted just as well. One extra dispatch at offset 2040, or a CPU assertion on FirstElement/NumElements, closes that. Three validity branches in resolve_raw_uav_store also have no case at all: resource_offset % 4, resource_offset > resource_width, and bytes > resource_width - resource_offset.

Scope notes. One physical GPU: _warp is the WARP software adapter, not a wave-width variation. No production caller yet — both headers are included only by tests/vm_copy_queue_check.cpp. And the PR body says to review only d9c3609, but a639989 rewrote resolve_raw_uav_store (base alignment, ambiguity, overflow, 32-bit offset) and 45 lines of the test, so what I measured is the final tree; anyone reading the body alone would validate code the PR no longer contains.

Revision scope: the harness and resolve_raw_uav_store were read; the rest of the suite and the device code were not. 604 entries in ctest --preset dev -N, the four vm_raw_* are 597, 598, 601, 602; git status --porcelain shows only the run logs.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7118007315 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1025#issuecomment-7118007315). Originally posted by [thepatrickworld](https://github.com/thepatrickworld) on 2026-11-24T00:22:50Z. --- Merged the stack onto current `main` and ran the two entries on an RX 9070 XT, since the `_hardware` ones never run in CI (`-E '_hardware$'` on both Windows jobs). **Merge.** `a639989` onto `d33845b`: no conflict (`CMakeLists.txt` and `docs/experiments.md` auto-merged). The merged tree is `3d9e0982`, two parents, so any clean merge of those two should reproduce it. Note the API reports `mergeable_state` as `unknown` for #1017 right now; that state is about #1017 alone, not about this stack. **Result: 4/4 passed, three consecutive runs**, build `dev`, same numbers each time. ``` vm_raw_srv_warp ....... Passed 0.10 s vm_raw_srv_hardware ... Passed 0.22 s vm_raw_uav_warp ....... Passed 0.04 s vm_raw_uav_hardware ... Passed 0.16 s ``` On the hardware entry (`device adapter 1002:7550 AMD Radeon RX 9070 XT`, driver `32.0.32029.2010`, DXC `1.9.2602.17`, Windows 11 26200, MSVC 19.44.35230.0): ``` UAV windows: bound mismatches=0 changed=5/2048; swapped mismatches=0 changed=5, intended words kept=5/5; refused=11 SRV: cross-page mismatches=0 shifted mismatches=0 negative=1024/1024 ``` `refused=11` is 7 request refusals (`d9c3609`) plus 4 window controls (`a639989`), and both are `E_INVALIDARG` returns on the CPU side, before any descriptor exists — they are not GPU measurements. The `seven` in the `d9c3609` message is accurate for that commit, which did not yet contain the four controls. **What this does not cover.** No dispatch uses an offset at or beyond 2040, so nothing here documents the descriptor's upper bound. `NumElements` is `bytes / 4` (510), so a store at 2040 is out of the descriptor and dropped — but the test would not notice if that number were too large: the same store would land in the buffer tail that is left at its sentinel (1800 bytes past the window in buffer 0, 1544 in buffer 1), and a wider `NumElements` would be accepted just as well. One extra dispatch at offset 2040, or a CPU assertion on `FirstElement`/`NumElements`, closes that. Three validity branches in `resolve_raw_uav_store` also have no case at all: `resource_offset % 4`, `resource_offset > resource_width`, and `bytes > resource_width - resource_offset`. **Scope notes.** One physical GPU: `_warp` is the WARP software adapter, not a wave-width variation. No production caller yet — both headers are included only by `tests/vm_copy_queue_check.cpp`. And the PR body says to review only `d9c3609`, but `a639989` rewrote `resolve_raw_uav_store` (base alignment, ambiguity, overflow, 32-bit offset) and 45 lines of the test, so what I measured is the final tree; anyone reading the body alone would validate code the PR no longer contains. Revision scope: the harness and `resolve_raw_uav_store` were read; the rest of the suite and the device code were not. 604 entries in `ctest --preset dev -N`, the four `vm_raw_*` are 597, 598, 601, 602; `git status --porcelain` shows only the run logs. _AI-assisted._
upstream-sync closed this pull request 2026-11-24 09:04:19 +00:00
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!1018
No description provided.