startup: add upload buffer lifetime coverage and guard (Part of #1758) #2068

Manually merged
github merged 2 commits from gh-pr/2068/head into gh-pr/2068/base 2026-11-26 23:53:50 +00:00
Owner

@⁠tedin7 on GitHub · 2026-11-24 23:58 UTC · original
tedin7:x2w-1758-next-slice → main · +215 −0 · 3 files · 2 commits · merged 2026-11-25 00:18 UTC

Part of #1758

What this unblocks: the ABI and lifetime control that #1758 asks for before command-list slot 148 (the builder's upload allocation) is wired into production.

What it adds

startup_upload_lifetime reuses the #1774 upload arena. With the queue blocked on a fence:

  1. Allocate A (640 bytes, 16-byte alignment), write a payload and submit a copy to a readback buffer.
  2. Reset the arena, allocate a distinct B on a new page, write another payload and submit its copy.
  3. Open the gate, wait for both copies, and compare the exact A and B bytes.

Also checked: CPU pointer and GPU address are both 16-byte aligned, the GPU address equals the page base plus the offset, a retired A range no longer translates, and no copy ran before the gate opened.

The overwrite control writes B into A's live range before the gate opens. A's readback must then show B, which proves the harness sees late GPU reads.

The arena reset drops the arena's own page reference, so the fixture holds A's page until the queue drains. This stands in for the retirement a production caller owes.

Not covered: refusal after a normal Close, and any command-buffer interaction (still a separate hypothesis per the thread).

Verification

Executed locally (Linux):

  • git diff --check: clean.
  • x86_64-w64-mingw32-g++ -std=c++17 -fsyntax-only -Isrc tests/startup_upload_lifetime.cpp: no errors.

Win2025 commands not yet executed (this host has no Windows build):

  • cmake --build --preset release --target startup_upload_lifetime
  • ctest --preset release --no-tests=error -R '^startup_upload_lifetime_' -V

Please run the two ctest cases (WARP and hardware) before merge.

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-24 23:58 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2068) `tedin7:x2w-1758-next-slice` → `main` · +215 −0 · 3 files · 2 commits · merged 2026-11-25 00:18 UTC Part of #1758 What this unblocks: the ABI and lifetime control that #1758 asks for before command-list slot 148 (the builder's upload allocation) is wired into production. ## What it adds `startup_upload_lifetime` reuses the #1774 upload arena. With the queue blocked on a fence: 1. Allocate A (640 bytes, 16-byte alignment), write a payload and submit a copy to a readback buffer. 2. Reset the arena, allocate a distinct B on a new page, write another payload and submit its copy. 3. Open the gate, wait for both copies, and compare the exact A and B bytes. Also checked: CPU pointer and GPU address are both 16-byte aligned, the GPU address equals the page base plus the offset, a retired A range no longer translates, and no copy ran before the gate opened. The overwrite control writes B into A's live range before the gate opens. A's readback must then show B, which proves the harness sees late GPU reads. The arena reset drops the arena's own page reference, so the fixture holds A's page until the queue drains. This stands in for the retirement a production caller owes. Not covered: refusal after a normal Close, and any command-buffer interaction (still a separate hypothesis per the thread). ## Verification Executed locally (Linux): - `git diff --check`: clean. - `x86_64-w64-mingw32-g++ -std=c++17 -fsyntax-only -Isrc tests/startup_upload_lifetime.cpp`: no errors. Win2025 commands not yet executed (this host has no Windows build): - `cmake --build --preset release --target startup_upload_lifetime` - `ctest --preset release --no-tests=error -R '^startup_upload_lifetime_' -V` Please run the two ctest cases (WARP and hardware) before merge. AI-assisted; commands listed were executed locally.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 23:53:48 +00:00
github manually merged commit f34f42e9fc into gh-pr/2068/base 2026-11-26 23:53:50 +00:00
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-25 00:07 UTC · original · edited 2026-11-25 00:10 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-25T00:10:39.132518Z 3a2310f 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-25 00:07 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2068#issuecomment-7148173730) · edited 2026-11-25 00:10 UTC <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"3a2310f343bd4cd87d756a97e0972788567fd2d6","has_any_findings":false,"has_unresolved_findings":false,"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-25T00:10:39.132518Z">2026-11-25T00:10:39.132518Z</relative-time> | `3a2310f` | 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

@⁠R0Y00 on GitHub · 2026-11-25 00:11 UTC · original

Windows Release at 3a2310f3: startup_upload_lifetime_warp and startup_upload_lifetime_hardware were 2/2 on WARP and RTX 4060 Laptop, debug layer enabled, no skips. Both read back A and B after the gate, and the overwrite control read B in A's copy. Command: ctest --preset release --no-tests=error -R '^startup_upload_lifetime_' -V.

Before marking it ready, check the HRESULTs from queue Wait and CPU gate Signal. The cleanup currently waits for fence value 2 even if the code never submitted B's completion signal. Track a successfully signaled completion (or enqueue a drain after opening the gate), and never report the normal lifetime result if the gate setup or completion failed. The standalone result still uses a page reference kept by the fixture. Keep the production Close/Reset check under #1758.

**@⁠R0Y00** on GitHub · 2026-11-25 00:11 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2068#issuecomment-7148238468) Windows Release at 3a2310f3: `startup_upload_lifetime_warp` and `startup_upload_lifetime_hardware` were 2/2 on WARP and RTX 4060 Laptop, debug layer enabled, no skips. Both read back A and B after the gate, and the overwrite control read B in A's copy. Command: `ctest --preset release --no-tests=error -R '^startup_upload_lifetime_' -V`. Before marking it ready, check the HRESULTs from queue Wait and CPU gate Signal. The cleanup currently waits for fence value 2 even if the code never submitted B's completion signal. Track a successfully signaled completion (or enqueue a drain after opening the gate), and never report the normal lifetime result if the gate setup or completion failed. The standalone result still uses a page reference kept by the fixture. Keep the production Close/Reset check under #1758.
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-25 00:14 UTC · original

I pushed the gate and drain fix. A failed queue wait now stops before recording, a failed gate signal is reported, and the fixture waits only on an enqueued completion signal, including when B is never submitted. Windows Release passed both WARP and RTX 4060 Laptop again, debug layer enabled, no skips. The fixture still holds its old page explicitly, as expected for the standalone test.

**@⁠R0Y00** on GitHub · 2026-11-25 00:14 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2068#issuecomment-7148303189) I pushed the gate and drain fix. A failed queue wait now stops before recording, a failed gate signal is reported, and the fixture waits only on an enqueued completion signal, including when B is never submitted. Windows Release passed both WARP and RTX 4060 Laptop again, debug layer enabled, no skips. The fixture still holds its old page explicitly, as expected for the standalone test.
This discussion has been locked. Commenting is limited to contributors.
No description provided.