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

Merged
tedin7 merged 2 commits from upstream-pr/2068 into main 2026-11-25 00:18:04 +00:00
tedin7 commented 2026-11-24 23:58:00 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T23:58:00Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6593912506 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2068). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T23:58:00Z. --- 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.
upstream-sync closed this pull request 2026-11-25 01:01:26 +00:00
chatgpt-codex-connector[bot commented 2026-11-25 01:02:02 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T00:07:38Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7148173730 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2068#issuecomment-7148173730). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-25T00:07:38Z. --- <!-- 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>
R0Y00 commented 2026-11-25 01:02:02 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T00:11:05Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7148238468 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2068#issuecomment-7148238468). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-25T00:11:05Z. --- 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 commented 2026-11-25 01:02:03 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T00:14:38Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7148303189 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2068#issuecomment-7148303189). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-25T00:14:38Z. --- 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.
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!2061
No description provided.