startup: slot 70 structured buffer views at sub-allocated addresses take an exact-start upload copy #2841

Manually merged
github merged 5 commits from github-bot/gh-2841 into gh-pr/2841/base 2026-11-27 22:30:48 +00:00 AGit
Owner

@⁠tedin7 on GitHub · 2026-11-26 13:01 UTC · original
tedin7:x2w-slot70-structured-offset → main · +133 −22 · 9 files · 5 commits · merged 2026-11-27 22:27 UTC

Part of #870
Fixes #2839

What this unblocks: slot 70 buffer memory SRVs for structured views at sub-allocated addresses (an address that is not a whole number of elements past its 64 KiB page) publish instead of ending in buffer_unavailable.

What changed

  • unplaced_view_needs_exact_start in src/startup_stubs/memory_srv_buffer.h.
  • unplaced_memory_buffer in src/startup_stubs/d3d12_memory_srv.inl takes the element size. When the 64 KiB page start cannot name the address as a whole number of elements, it backs the view with an upload copy that starts at the address (span = the view span), in its own cache entries, with no existing-heap wrap. The page-coverage and nearby-owner checks still run on the page.
  • Tests: startup_memory_srv_buffer_check (new shapes, --mutate exact-start registered in the CMake mutant list) and startup_address_buffer_srv (an unplaced structured view with stride 12 at page offset 0x104 is read through slot 70).

Why it is correct

A buffer SRV addresses whole elements from its base: (address - base) must be a multiple of the element size to become FirstElement (D3D12 D3D12_BUFFER_SRV, FirstElement / StructureByteStride). With the page start as base that fails for most sub-allocated addresses. Starting the copy at the address makes the offset 0.
Source: Microsoft D3D12 documentation, D3D12_BUFFER_SRV (FirstElement, StructureByteStride).

What stays refused

Overlap with a known resource, pages the title does not own, views above the 256 MiB span limit, raw views not 16-byte aligned (unchanged).

Notes

The exact-start copy is a snapshot refreshed on every hit, like the existing upload fallback.

Verification

  • x86_64-w64-mingw32-g++ -std=c++17 -Isrc tests/startup_memory_srv_buffer_check.cpp then run under wine: pass; --mutate exact-start: fails (rc 1).
  • mingw syntax check of tests/startup_address_srv.cpp: ok.
  • Win2025 (independent gate, proxmox, regex startup_memory_srv|slot70|address_buffer_srv|startup_address_srv): dev 28/28 and release 28/28. startup_address_buffer_srv and startup_address_srv (warp and hardware) pass; startup_memory_srv_buffer and all 7 --mutate controls (including exact-start) pass.
  • Runtime mutant (exact = false, the fix reverted): startup_address_buffer_srv warp and hardware both fail, so the stride-12 page-offset 0x104 case exercises the fix.

Real-hardware testing: @⁠Makto94 - thanks for the help.

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-26 13:01 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2841) `tedin7:x2w-slot70-structured-offset` → `main` · +133 −22 · 9 files · 5 commits · merged 2026-11-27 22:27 UTC Part of #870 Fixes #2839 What this unblocks: slot 70 buffer memory SRVs for structured views at sub-allocated addresses (an address that is not a whole number of elements past its 64 KiB page) publish instead of ending in `buffer_unavailable`. ## What changed - `unplaced_view_needs_exact_start` in `src/startup_stubs/memory_srv_buffer.h`. - `unplaced_memory_buffer` in `src/startup_stubs/d3d12_memory_srv.inl` takes the element size. When the 64 KiB page start cannot name the address as a whole number of elements, it backs the view with an upload copy that starts at the address (span = the view span), in its own cache entries, with no existing-heap wrap. The page-coverage and nearby-owner checks still run on the page. - Tests: `startup_memory_srv_buffer_check` (new shapes, `--mutate exact-start` registered in the CMake mutant list) and `startup_address_buffer_srv` (an unplaced structured view with stride 12 at page offset 0x104 is read through slot 70). ## Why it is correct A buffer SRV addresses whole elements from its base: `(address - base)` must be a multiple of the element size to become `FirstElement` (D3D12 `D3D12_BUFFER_SRV`, FirstElement / StructureByteStride). With the page start as base that fails for most sub-allocated addresses. Starting the copy at the address makes the offset 0. Source: Microsoft D3D12 documentation, `D3D12_BUFFER_SRV` (FirstElement, StructureByteStride). ## What stays refused Overlap with a known resource, pages the title does not own, views above the 256 MiB span limit, raw views not 16-byte aligned (unchanged). ## Notes The exact-start copy is a snapshot refreshed on every hit, like the existing upload fallback. ## Verification - `x86_64-w64-mingw32-g++ -std=c++17 -Isrc tests/startup_memory_srv_buffer_check.cpp` then run under wine: pass; `--mutate exact-start`: fails (rc 1). - mingw syntax check of `tests/startup_address_srv.cpp`: ok. - Win2025 (independent gate, proxmox, regex startup_memory_srv|slot70|address_buffer_srv|startup_address_srv): dev 28/28 and release 28/28. startup_address_buffer_srv and startup_address_srv (warp and hardware) pass; startup_memory_srv_buffer and all 7 --mutate controls (including exact-start) pass. - Runtime mutant (exact = false, the fix reverted): startup_address_buffer_srv warp and hardware both fail, so the stride-12 page-offset 0x104 case exercises the fix. Real-hardware testing: @⁠Makto94 - thanks for the help. AI-assisted; commands listed were executed locally.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 01:26:10 +00:00
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-26 13:11 UTC · original · edited 2026-11-26 13:22 UTC

Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-26T13:22:28.809996Z 14edff2 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@⁠codex review" or "@⁠codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-26 13:11 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2841#issuecomment-7193004646) · edited 2026-11-26 13:22 UTC <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"14edff2aa2b3ddb0616f4ad657a836224090c4eb","has_any_findings":true,"has_unresolved_findings":true,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-26T13:22:28.809996Z">2026-11-26T13:22:28.809996Z</relative-time> | `14edff2` | Draft marked ready | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@⁠codex review" or "@⁠codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-26 13:22 UTC · original · reviewed

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 14edff2aa2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@⁠codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@⁠codex address that feedback".

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-26 13:22 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2841#pullrequestreview-6074865162) · **reviewed** <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `14edff2aa2` <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@⁠codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@⁠codex address that feedback". </details>
@ -311,0 +317,4 @@
const bool exact = x2w_startup::unplaced_view_needs_exact_start(address, page_start, elem_bytes, raw);
if (exact) {
page_start = address;
page_span = span_bytes;
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-26 13:22 UTC · original

P2 Badge Keep exact-start copies from blocking overlapping views

For successive views into the same unplaced page, the shortened backing becomes an exclusive owner through note_resource. For example, publish one stride-12 element at page + 0x104, then request a 16-byte raw view at page + 0x100: existing_memory_buffer cannot cover the latter with the 12-byte copy, and address_resource_overlap rejects allocating another backing, leaving the previous descriptor in place. The previous page-sized backing allowed that raw view. Distinguish these synthetic copies from guest-owned resources in the overlap checks so overlapping or enlarged views can obtain compatible backings.

Useful? React with 👍 / 👎.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-26 13:22 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2841#discussion_r4708959293) **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Keep exact-start copies from blocking overlapping views** For successive views into the same unplaced page, the shortened backing becomes an exclusive owner through `note_resource`. For example, publish one stride-12 element at `page + 0x104`, then request a 16-byte raw view at `page + 0x100`: `existing_memory_buffer` cannot cover the latter with the 12-byte copy, and `address_resource_overlap` rejects allocating another backing, leaving the previous descriptor in place. The previous page-sized backing allowed that raw view. Distinguish these synthetic copies from guest-owned resources in the overlap checks so overlapping or enlarged views can obtain compatible backings. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-26 13:22 UTC · original

P2 Badge Preserve raw-view alignment checks before rebasing

For an unplaced raw view at page + 1 with FirstElement == 0, elem_bytes is 4, so this enables the exact-start copy. resolve_buffer_srv_desc then sees offset zero and passes its raw 16-byte-alignment check, publishing a view that the previous page-based path rejected and overwriting the destination instead of leaving it unchanged. The existing unaligned fixture uses a placed buffer and does not exercise this path. Restrict rebasing to structured/typed views, or enforce the original raw alignment before changing the base.

Useful? React with 👍 / 👎.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-26 13:22 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2841#discussion_r4708959306) **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Preserve raw-view alignment checks before rebasing** For an unplaced raw view at `page + 1` with `FirstElement == 0`, `elem_bytes` is 4, so this enables the exact-start copy. `resolve_buffer_srv_desc` then sees offset zero and passes its raw 16-byte-alignment check, publishing a view that the previous page-based path rejected and overwriting the destination instead of leaving it unchanged. The existing unaligned fixture uses a placed buffer and does not exercise this path. Restrict rebasing to structured/typed views, or enforce the original raw alignment before changing the base. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
Author
Owner

@⁠tedin7 on GitHub · 2026-11-26 13:40 UTC · original

Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit da2a38f5788e8f0f9fd3351dfbf336a977a1cdd9:

  • Debug (--preset dev):
    • Build (cmake --build --preset dev --target d3d12_xs_device_obj d3d12_xs_shim startup_memory_srv_buffer_check startup_stream_consumer -- -j 2): 42.77s (configure 3.42s)
    • Test (ctest --preset dev -R 'startup_memory_srv_buffer|startup_address_buffer_srv|startup_address_srv' --parallel 3 --no-tests=error --output-on-failure): 13/13 passed (2.26s: startup_address_buffer_srv_warp 1.02s, startup_address_buffer_srv_hardware 1.02s, startup_memory_srv_buffer 0.02s, startup_address_srv_warp 1.06s, startup_memory_srv_buffer_height_control 0.02s, startup_memory_srv_buffer_unplaced-heap-limit_control 0.02s, startup_memory_srv_buffer_first-32_control 0.02s, startup_memory_srv_buffer_unplaced-extent_control 0.02s, startup_memory_srv_buffer_unplaced-covers_control 0.02s, startup_memory_srv_buffer_exact-fit_control 0.02s, startup_memory_srv_buffer_exact-start_control 0.02s, startup_memory_srv_buffer_raw-exact_control 0.02s, startup_address_srv_hardware 0.98s)
  • Release /O2 (--preset release):
    • Build (cmake --build --preset release --target d3d12_xs_device_obj d3d12_xs_shim startup_memory_srv_buffer_check startup_stream_consumer -- -j 2): 89.22s (configure 2.76s)
    • Test (ctest --preset release -R 'startup_memory_srv_buffer|startup_address_buffer_srv|startup_address_srv' --parallel 3 --no-tests=error --output-on-failure): 13/13 passed (1.76s: startup_address_buffer_srv_warp 0.83s, startup_address_buffer_srv_hardware 0.83s, startup_memory_srv_buffer_height_control 0.01s, startup_memory_srv_buffer 0.01s, startup_memory_srv_buffer_exact-fit_control 0.01s, startup_memory_srv_buffer_first-32_control 0.01s, startup_memory_srv_buffer_unplaced-covers_control 0.02s, startup_memory_srv_buffer_unplaced-heap-limit_control 0.01s, startup_memory_srv_buffer_unplaced-extent_control 0.01s, startup_memory_srv_buffer_exact-start_control 0.01s, startup_address_srv_warp 0.97s, startup_memory_srv_buffer_raw-exact_control 0.01s, startup_address_srv_hardware 0.75s)
  • sccache: 148/171 hits; wall 146.8s

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-26 13:40 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2841#issuecomment-7193685807) Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit `da2a38f5788e8f0f9fd3351dfbf336a977a1cdd9`: - **Debug (`--preset dev`)**: - Build (`cmake --build --preset dev --target d3d12_xs_device_obj d3d12_xs_shim startup_memory_srv_buffer_check startup_stream_consumer -- -j 2`): `42.77s` (configure `3.42s`) - Test (`ctest --preset dev -R 'startup_memory_srv_buffer|startup_address_buffer_srv|startup_address_srv' --parallel 3 --no-tests=error --output-on-failure`): **13/13 passed** (`2.26s`: `startup_address_buffer_srv_warp` `1.02s`, `startup_address_buffer_srv_hardware` `1.02s`, `startup_memory_srv_buffer` `0.02s`, `startup_address_srv_warp` `1.06s`, `startup_memory_srv_buffer_height_control` `0.02s`, `startup_memory_srv_buffer_unplaced-heap-limit_control` `0.02s`, `startup_memory_srv_buffer_first-32_control` `0.02s`, `startup_memory_srv_buffer_unplaced-extent_control` `0.02s`, `startup_memory_srv_buffer_unplaced-covers_control` `0.02s`, `startup_memory_srv_buffer_exact-fit_control` `0.02s`, `startup_memory_srv_buffer_exact-start_control` `0.02s`, `startup_memory_srv_buffer_raw-exact_control` `0.02s`, `startup_address_srv_hardware` `0.98s`) - **Release `/O2` (`--preset release`)**: - Build (`cmake --build --preset release --target d3d12_xs_device_obj d3d12_xs_shim startup_memory_srv_buffer_check startup_stream_consumer -- -j 2`): `89.22s` (configure `2.76s`) - Test (`ctest --preset release -R 'startup_memory_srv_buffer|startup_address_buffer_srv|startup_address_srv' --parallel 3 --no-tests=error --output-on-failure`): **13/13 passed** (`1.76s`: `startup_address_buffer_srv_warp` `0.83s`, `startup_address_buffer_srv_hardware` `0.83s`, `startup_memory_srv_buffer_height_control` `0.01s`, `startup_memory_srv_buffer` `0.01s`, `startup_memory_srv_buffer_exact-fit_control` `0.01s`, `startup_memory_srv_buffer_first-32_control` `0.01s`, `startup_memory_srv_buffer_unplaced-covers_control` `0.02s`, `startup_memory_srv_buffer_unplaced-heap-limit_control` `0.01s`, `startup_memory_srv_buffer_unplaced-extent_control` `0.01s`, `startup_memory_srv_buffer_exact-start_control` `0.01s`, `startup_address_srv_warp` `0.97s`, `startup_memory_srv_buffer_raw-exact_control` `0.01s`, `startup_address_srv_hardware` `0.75s`) - `sccache`: 148/171 hits; wall `146.8s` AI-assisted; commands listed were executed locally.
Author
Owner

@⁠tedin7 on GitHub · 2026-11-26 13:40 UTC · original

Fixed in da2a38f57. The exact-start copy is now limited to structured and typed views: a raw view keeps the page base, so its 16-byte alignment check still applies and a raw view at page + 1 is refused and keeps the previous descriptor. Test: startup_address_buffer_srv_warp has a new column for an unplaced raw view at page + 1 (expects 201 kept), plus a unit check raw view keeps the page base with the raw-exact mutation control in startup_memory_srv_buffer. Win2025 dev+release: 13/13 each (receipt comment on this PR).

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-26 13:40 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2841#discussion_r4709176868) Fixed in da2a38f57. The exact-start copy is now limited to structured and typed views: a raw view keeps the page base, so its 16-byte alignment check still applies and a raw view at `page + 1` is refused and keeps the previous descriptor. Test: `startup_address_buffer_srv_warp` has a new column for an unplaced raw view at page + 1 (expects 201 kept), plus a unit check `raw view keeps the page base` with the `raw-exact` mutation control in `startup_memory_srv_buffer`. Win2025 dev+release: 13/13 each (receipt comment on this PR). AI-assisted; commands listed were executed locally.
@ -311,0 +317,4 @@
const bool exact = x2w_startup::unplaced_view_needs_exact_start(address, page_start, elem_bytes, raw);
if (exact) {
page_start = address;
page_span = span_bytes;
Author
Owner

@⁠tedin7 on GitHub · 2026-11-26 13:41 UTC · original

Fixed in da2a38f57. The upload copy made for an exact-start view is now marked as a synthetic backing: address_resource_overlap and existing_memory_buffer skip it, so a later overlapping or larger view (for example a raw 16-byte view at page + 0x100 after a stride-12 view at page + 0x104) gets its own compatible backing instead of being refused. Test: startup_address_buffer_srv_warp publishes that pair on a second page and expects the shader to read 55 (before the change the raw view was refused and the previous descriptor stayed). Win2025 dev+release: 13/13 each (receipt comment on this PR).

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-26 13:41 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2841#discussion_r4709178094) Fixed in da2a38f57. The upload copy made for an exact-start view is now marked as a synthetic backing: `address_resource_overlap` and `existing_memory_buffer` skip it, so a later overlapping or larger view (for example a raw 16-byte view at `page + 0x100` after a stride-12 view at `page + 0x104`) gets its own compatible backing instead of being refused. Test: `startup_address_buffer_srv_warp` publishes that pair on a second page and expects the shader to read 55 (before the change the raw view was refused and the previous descriptor stayed). Win2025 dev+release: 13/13 each (receipt comment on this PR). AI-assisted; commands listed were executed locally.
Author
Owner

@⁠SimSalabimse on GitHub · 2026-11-26 16:07 UTC · original

Hardware and WARP result for head da2a38f5788e8f0f9fd3351dfbf336a977a1cdd9: all pass. Part of #870.

Environment: Windows 11 25H2 (26200), MSVC 19.42, dev preset, NVIDIA GeForce RTX 4070 Ti, driver 621.35 (32.0.16.2135). Tests run serially, one ctest process.

Command

ctest --preset dev --no-tests=error -R "startup_memory_srv|slot70|address_buffer_srv|startup_address_srv|address_volume_srv|startup_stream_draw|startup_placed_buffer_range"

Result (measured): 36/36 passed, exit code 0.

  • startup_memory_srv_buffer and its 8 controls, including the new exact-start and raw-exact.
  • startup_address_buffer_srv_warp and startup_address_buffer_srv_hardware (the stride-12 view at page offset 0x104 that the PR adds).
  • startup_stream_draw_warp and startup_stream_draw_hardware (the PR edits tests/startup_stream_draw.cpp).
  • The other slot-70 tests: startup_address_srv, startup_memory_srv_diag and startup_address_volume_srv (WARP and hardware), dxr_slot70_as (WARP and hardware), startup_memory_srv_{census,report,as,volume} with controls, startup_placed_buffer_range with controls.

What this shows: the new stride-12 case and the changed stream-draw test pass on an NVIDIA adapter as well as WARP, and nothing else in the slot-70 group regressed.

What this does not show: I did not revert the fix to check that the hardware test fails without it. The description reports that mutant on WARP and hardware. I did not run a game or title.

AI-Assisted

**@⁠SimSalabimse** on GitHub · 2026-11-26 16:07 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2841#issuecomment-7197202879) Hardware and WARP result for head `da2a38f5788e8f0f9fd3351dfbf336a977a1cdd9`: all pass. Part of #870. **Environment:** Windows 11 25H2 (26200), MSVC 19.42, `dev` preset, NVIDIA GeForce RTX 4070 Ti, driver 621.35 (32.0.16.2135). Tests run serially, one ctest process. **Command** ``` ctest --preset dev --no-tests=error -R "startup_memory_srv|slot70|address_buffer_srv|startup_address_srv|address_volume_srv|startup_stream_draw|startup_placed_buffer_range" ``` **Result (measured):** 36/36 passed, exit code 0. - `startup_memory_srv_buffer` and its 8 controls, including the new `exact-start` and `raw-exact`. - `startup_address_buffer_srv_warp` and `startup_address_buffer_srv_hardware` (the stride-12 view at page offset 0x104 that the PR adds). - `startup_stream_draw_warp` and `startup_stream_draw_hardware` (the PR edits `tests/startup_stream_draw.cpp`). - The other slot-70 tests: `startup_address_srv`, `startup_memory_srv_diag` and `startup_address_volume_srv` (WARP and hardware), `dxr_slot70_as` (WARP and hardware), `startup_memory_srv_{census,report,as,volume}` with controls, `startup_placed_buffer_range` with controls. **What this shows:** the new stride-12 case and the changed stream-draw test pass on an NVIDIA adapter as well as WARP, and nothing else in the slot-70 group regressed. **What this does not show:** I did not revert the fix to check that the hardware test fails without it. The description reports that mutant on WARP and hardware. I did not run a game or title. AI-Assisted
Author
Owner

@⁠pigalot on GitHub · 2026-11-27 19:40 UTC · original · requested changes

Independently reviewed da2a38f5 integrated over main 0f3e8248 (tree 2b7779b9, clean merge).

The PR's own suite passes. I built startup_stream_consumer, d3d12_xs_shim and startup_memory_srv_buffer_check in dev, then ran:
ctest --test-dir out/build/dev --no-tests=error -j 1 -R '^(startup_memory_srv_buffer.*|startup_address_buffer_srv_(warp|hardware)|startup_address_srv_(warp|hardware))$'
13/13 passed. That includes the new exact-start and raw-exact controls, on WARP and hardware. Both earlier Codex threads are resolved, and their two cases behave as described.

Finding: the exact-start copy is only used when it comes first on its page. The fixture publishes the structured view at page + 0x104 first and the raw view at page + 0x100 after it. With the two calls the other way round, the structured view is refused.

  • Repro: in draw_address_buffer_srvs, add one line just before the existing structured.view.Buffer.FirstElement = 0; of the page-offset case:
    raw.view.Buffer.FirstElement = 0; raw.address = ptr(reinterpret_cast<unsigned char*>(odd) - 4); invoke(guest, 70, ptr(&desc), ptr(&raw), cpu);
    
    Then run ctest --test-dir out/build/dev --no-tests=error -j 1 --output-on-failure -R '^startup_address_buffer_srv_warp$'.
  • Expected: column 6 reads 201 (0xc9). That is the stride-12 element at page + 0x104, as without the added line.
  • Observed: columns 6–8 read 55 (0x37). The structured view was refused, and the raw view's descriptor stayed.

As I read it:

  1. The raw view leaves a page-base upload copy that is not marked exact_copy.
  2. For the structured view, existing_memory_buffer returns that copy.
  3. resolve_buffer_srv_desc then fails on 0x104 % 12, so the view is refused before unplaced_memory_buffer runs. If it did run, address_resource_overlap would also count the page copy as an owner.

The same happens after a raw view that is itself refused. I tested a raw view at page + 1 followed by a stride-16 view at page + 0x10C: the stride-16 view is refused. Without the raw view before it, it publishes from its own exact copy and reads the expected value.

This is not a regression against main, where these views are refused in either order. But the outcome now depends on call order within a page. A title that touches a page through a raw or aligned view first gets the old refusal.

Suggested direction (unconfirmed):

  • Treat the page-base upload copies like the exact ones: synthetic backings, not guest-owned resources.
  • When resolve_buffer_srv_desc fails on such a copy, fall through to unplaced_memory_buffer, so the exact path can still run.
  • A fixture column with the raw view first would pin this down.

Verdict: changes requested on da2a38f5, for the order dependence only.

Environment: NVIDIA GeForce RTX 5090, driver 32.0.16.1088; WARP 10.0.26100.9818; Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; debug layer on.
CI: Build and test on Windows passes on da2a38f5. Both review threads are resolved.

This reply was AI-assisted.

**@⁠pigalot** on GitHub · 2026-11-27 19:40 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2841#pullrequestreview-6092706017) · **requested changes** Independently reviewed `da2a38f5` integrated over `main` `0f3e8248` (tree `2b7779b9`, clean merge). The PR's own suite passes. I built `startup_stream_consumer`, `d3d12_xs_shim` and `startup_memory_srv_buffer_check` in `dev`, then ran: `ctest --test-dir out/build/dev --no-tests=error -j 1 -R '^(startup_memory_srv_buffer.*|startup_address_buffer_srv_(warp|hardware)|startup_address_srv_(warp|hardware))$'` 13/13 passed. That includes the new `exact-start` and `raw-exact` controls, on WARP and hardware. Both earlier Codex threads are resolved, and their two cases behave as described. **Finding: the exact-start copy is only used when it comes first on its page.** The fixture publishes the structured view at page + 0x104 first and the raw view at page + 0x100 after it. With the two calls the other way round, the structured view is refused. - **Repro:** in `draw_address_buffer_srvs`, add one line just before the existing `structured.view.Buffer.FirstElement = 0;` of the page-offset case: ```cpp raw.view.Buffer.FirstElement = 0; raw.address = ptr(reinterpret_cast<unsigned char*>(odd) - 4); invoke(guest, 70, ptr(&desc), ptr(&raw), cpu); ``` Then run `ctest --test-dir out/build/dev --no-tests=error -j 1 --output-on-failure -R '^startup_address_buffer_srv_warp$'`. - **Expected:** column 6 reads 201 (0xc9). That is the stride-12 element at page + 0x104, as without the added line. - **Observed:** columns 6–8 read 55 (0x37). The structured view was refused, and the raw view's descriptor stayed. As I read it: 1. The raw view leaves a page-base upload copy that is not marked `exact_copy`. 2. For the structured view, `existing_memory_buffer` returns that copy. 3. `resolve_buffer_srv_desc` then fails on `0x104 % 12`, so the view is refused before `unplaced_memory_buffer` runs. If it did run, `address_resource_overlap` would also count the page copy as an owner. The same happens after a raw view that is itself refused. I tested a raw view at page + 1 followed by a stride-16 view at page + 0x10C: the stride-16 view is refused. Without the raw view before it, it publishes from its own exact copy and reads the expected value. This is not a regression against `main`, where these views are refused in either order. But the outcome now depends on call order within a page. A title that touches a page through a raw or aligned view first gets the old refusal. **Suggested direction (unconfirmed):** - Treat the page-base upload copies like the exact ones: synthetic backings, not guest-owned resources. - When `resolve_buffer_srv_desc` fails on such a copy, fall through to `unplaced_memory_buffer`, so the exact path can still run. - A fixture column with the raw view first would pin this down. **Verdict:** changes requested on `da2a38f5`, for the order dependence only. Environment: NVIDIA GeForce RTX 5090, driver 32.0.16.1088; WARP 10.0.26100.9818; Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; debug layer on. CI: `Build and test on Windows` passes on `da2a38f5`. Both review threads are resolved. This reply was AI-assisted.
Author
Owner

@⁠tedin7 on GitHub · 2026-11-27 21:28 UTC · original

Thanks for the repro. Pushed c02f9dd45: when a cached page-base copy cannot resolve a slot 70 view, the path now retries with an exact-start copy, so the result no longer depends on which view came first on the page. Guest-owned resource checks still apply. The fixture gains the raw-view-first order (stride 12 reads 201) and the raw page+1 then stride-16 order (reads the same as without the raw view).

Not yet run on Windows: startup_address_buffer_srv_warp, startup_address_buffer_srv_hardware, startup_memory_srv_buffer*.

Commands run locally: git diff --check, python3 -B tests/docs_links_check.py, cmake -S . -B <tmp> -DDXC_EXECUTABLE=/bin/true, public_guard.py.

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-27 21:28 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2841#issuecomment-7228472608) Thanks for the repro. Pushed `c02f9dd45`: when a cached page-base copy cannot resolve a slot 70 view, the path now retries with an exact-start copy, so the result no longer depends on which view came first on the page. Guest-owned resource checks still apply. The fixture gains the raw-view-first order (stride 12 reads 201) and the raw page+1 then stride-16 order (reads the same as without the raw view). Not yet run on Windows: `startup_address_buffer_srv_warp`, `startup_address_buffer_srv_hardware`, `startup_memory_srv_buffer*`. Commands run locally: `git diff --check`, `python3 -B tests/docs_links_check.py`, `cmake -S . -B <tmp> -DDXC_EXECUTABLE=/bin/true`, `public_guard.py`. AI-assisted; commands listed were executed locally.
Author
Owner

@⁠tedin7 on GitHub · 2026-11-27 21:47 UTC · original

Verification: head c02f9dd45 after the main merge and the latest fixes.

Environment: Windows Server 2025 (build 26100), MSVC 14.44, D3D12 WARP and the hardware adapter, dev and release legs in parallel.

Commands (the same selection in both legs):

x2w_pipe.py win2025 2841 --force --regex '^(startup_address_buffer_srv_(warp|hardware)|startup_memory_srv_buffer.*)$'
  dev:     cmake --build --preset dev --target d3d12_xs_device_obj d3d12_xs_shim startup_memory_srv_buffer_check startup_stream_consumer
           ctest --preset dev -R '^(startup_address_buffer_srv_(warp|hardware)|startup_memory_srv_buffer.*)$' --no-tests=error --output-on-failure
  release: cmake --build --preset release --target d3d12_xs_device_obj d3d12_xs_shim startup_memory_srv_buffer_check startup_stream_consumer
           ctest --preset release -R '^(startup_address_buffer_srv_(warp|hardware)|startup_memory_srv_buffer.*)$' --no-tests=error --output-on-failure

Result: 11/11 passed in both legs.

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-27 21:47 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2841#issuecomment-7228754745) Verification: head `c02f9dd45` after the main merge and the latest fixes. Environment: Windows Server 2025 (build 26100), MSVC 14.44, D3D12 WARP and the hardware adapter, dev and release legs in parallel. Commands (the same selection in both legs): ``` x2w_pipe.py win2025 2841 --force --regex '^(startup_address_buffer_srv_(warp|hardware)|startup_memory_srv_buffer.*)$' dev: cmake --build --preset dev --target d3d12_xs_device_obj d3d12_xs_shim startup_memory_srv_buffer_check startup_stream_consumer ctest --preset dev -R '^(startup_address_buffer_srv_(warp|hardware)|startup_memory_srv_buffer.*)$' --no-tests=error --output-on-failure release: cmake --build --preset release --target d3d12_xs_device_obj d3d12_xs_shim startup_memory_srv_buffer_check startup_stream_consumer ctest --preset release -R '^(startup_address_buffer_srv_(warp|hardware)|startup_memory_srv_buffer.*)$' --no-tests=error --output-on-failure ``` Result: 11/11 passed in both legs. AI-assisted; commands listed were executed locally.
github-bot changed target branch from main to gh-pr/2841/base 2026-11-27 22:30:44 +00:00
github manually merged commit c02f9dd450 into gh-pr/2841/base 2026-11-27 22:30:48 +00:00
Author
Owner

@⁠pigalot on GitHub · 2026-11-27 22:27 UTC · original · approved these changes

Re-reviewed c02f9dd4 merged over current main f6206217. The merge is clean and git diff --cached --check is clean.

The finding from my review of da2a38f5 is fixed. The exact-start copy no longer depends on which view comes first on its page. Two changes do this:

  • Fallback: when existing_memory_buffer returns a synthetic backing (unplaced_srv_backing) that resolve_buffer_srv_desc can't use, device_memory_srv now asks unplaced_memory_buffer for an exact-start copy.
  • Owner check: address_resource_overlap now skips every synthetic backing, not only the exact ones. A page-base copy no longer counts as a guest-owned owner.

The fixture has both orders I reported, on fresh pages:

  • Column 11: a raw view at page + 0x100, then the stride-12 view at page + 0x104, which reads 201.
  • Columns 13 and 14: a refused raw view at page + 1, then a stride-16 view at page + 0x10C. It reads 173, the same as on a page with no raw call before it.

What I ran. I built d3d12_xs_device_obj, d3d12_xs_shim, startup_memory_srv_buffer_check and startup_stream_consumer in dev and release, then ran

ctest --test-dir out/build/<preset> --no-tests=error -j 4 -R '^(startup_address_buffer_srv_warp|startup_memory_srv_buffer.*|startup_stream_draw_warp|startup_address_srv_warp)$'
# with X2W_TEST_DEBUG_LAYER=1, one at a time
ctest --test-dir out/build/<preset> --no-tests=error -j 1 -R '^(startup_address_buffer_srv|startup_stream_draw|startup_address_srv)_hardware$'

12/12 and 3/3 pass in both presets, with no skips. The 12 include startup_memory_srv_buffer with all eight _controls.

Mutants in src/startup_stubs/d3d12_memory_srv.inl. For each, I rebuilt in dev and ran the 12 non-hardware tests:

Mutant Result
no exact-start fallback (if (!buffer), the da2a38f5 behaviour) killed (startup_address_buffer_srv_warp)
address_resource_overlap skips only exact_copy again killed (startup_address_buffer_srv_warp)
unplaced_srv_backing set only on exact copies killed (startup_address_buffer_srv_warp)
fallback also taken for a guest-owned buffer (!buffer || !resolved) survives; see below

Restored and rebuilt afterwards; git diff --quiet is clean.

Non-blocking. The surviving mutant looks equivalent for guest-owned resources. unplaced_memory_buffer begins with address_resource_overlap, which counts such a resource and returns nullptr, so the view is still refused. The unplaced_srv_backing guard is a second layer that no test reaches on its own. That's fine to keep; a one-line comment saying so would help the next reader.

Verdict: approve on c02f9dd4.

Environment: NVIDIA GeForce RTX 5090, driver 32.0.16.1088; D3D12 WARP; Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; Python 3.12.10; debug layer on for the hardware runs.
CI: Build and test on Windows, Assemble and translate gfx1013 fixtures and Run platform-independent Python checks on Linux pass on c02f9dd4.

This reply was AI-assisted.

**@⁠pigalot** on GitHub · 2026-11-27 22:27 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2841#pullrequestreview-6093949287) · **approved these changes** Re-reviewed `c02f9dd4` merged over current `main` `f6206217`. The merge is clean and `git diff --cached --check` is clean. **The finding from my review of `da2a38f5` is fixed.** The exact-start copy no longer depends on which view comes first on its page. Two changes do this: - **Fallback:** when `existing_memory_buffer` returns a synthetic backing (`unplaced_srv_backing`) that `resolve_buffer_srv_desc` can't use, `device_memory_srv` now asks `unplaced_memory_buffer` for an exact-start copy. - **Owner check:** `address_resource_overlap` now skips every synthetic backing, not only the exact ones. A page-base copy no longer counts as a guest-owned owner. The fixture has both orders I reported, on fresh pages: - **Column 11:** a raw view at page + 0x100, then the stride-12 view at page + 0x104, which reads 201. - **Columns 13 and 14:** a refused raw view at page + 1, then a stride-16 view at page + 0x10C. It reads 173, the same as on a page with no raw call before it. **What I ran.** I built `d3d12_xs_device_obj`, `d3d12_xs_shim`, `startup_memory_srv_buffer_check` and `startup_stream_consumer` in `dev` and `release`, then ran ```powershell ctest --test-dir out/build/<preset> --no-tests=error -j 4 -R '^(startup_address_buffer_srv_warp|startup_memory_srv_buffer.*|startup_stream_draw_warp|startup_address_srv_warp)$' # with X2W_TEST_DEBUG_LAYER=1, one at a time ctest --test-dir out/build/<preset> --no-tests=error -j 1 -R '^(startup_address_buffer_srv|startup_stream_draw|startup_address_srv)_hardware$' ``` 12/12 and 3/3 pass in both presets, with no skips. The 12 include `startup_memory_srv_buffer` with all eight `_control`s. **Mutants** in `src/startup_stubs/d3d12_memory_srv.inl`. For each, I rebuilt in `dev` and ran the 12 non-hardware tests: | Mutant | Result | |---|---| | no exact-start fallback (`if (!buffer)`, the `da2a38f5` behaviour) | killed (`startup_address_buffer_srv_warp`) | | `address_resource_overlap` skips only `exact_copy` again | killed (`startup_address_buffer_srv_warp`) | | `unplaced_srv_backing` set only on exact copies | killed (`startup_address_buffer_srv_warp`) | | fallback also taken for a guest-owned buffer (`!buffer \|\| !resolved`) | survives; see below | Restored and rebuilt afterwards; `git diff --quiet` is clean. **Non-blocking.** The surviving mutant looks equivalent for guest-owned resources. `unplaced_memory_buffer` begins with `address_resource_overlap`, which counts such a resource and returns `nullptr`, so the view is still refused. The `unplaced_srv_backing` guard is a second layer that no test reaches on its own. That's fine to keep; a one-line comment saying so would help the next reader. **Verdict:** approve on `c02f9dd4`. Environment: NVIDIA GeForce RTX 5090, driver 32.0.16.1088; D3D12 WARP; Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; Python 3.12.10; debug layer on for the hardware runs. CI: `Build and test on Windows`, `Assemble and translate gfx1013 fixtures` and `Run platform-independent Python checks on Linux` pass on `c02f9dd4`. This reply was AI-assisted.
This discussion has been locked. Commenting is limited to contributors.
No description provided.