gpu: preserve live upload reservations #2815

Merged
chadhyatt merged 1 commit from upstream-pr/2823 into main 2026-11-26 11:58:10 +00:00
chadhyatt commented 2026-11-26 11:51:33 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chadhyatt on 2026-11-26T11:51:33Z.


AI-assisted backport patch from x2w-microlift.

Refs #2775. Keep upload reservation offsets and backing stable for their lifetime. Grow on demand as before and use remaining unused tails; refuse exhaustion at the existing 256 MiB cap rather than recycle a reservation without a completion contract. This is a bounded correctness change, not a recycling implementation. A long-running workload can exhaust the ring; fence-aware retirement needs a separate change.

The authored portable fixture checks unchanged existing bytes, cursor and return values after growth and exhaustion. The existing Windows gate-ring fixture now expects retained payload 0, null view on later refused draws, and an explicit refusal log. Windows D3D12 gate behavior has not been run on this host.

Verified 59a79a4db3 on arm64 macOS:

  • c++ -std=c++17 -Wall -Wextra -fsanitize=address,undefined -Isrc tests/upload_reservation_check.cpp -o out/upload_reservation_check && out/upload_reservation_check: pass.
  • Python compile on tests/startup_address_console_check.py: pass.
  • git diff --check: pass.

Suggested Windows verification: ctest --preset dev --no-tests=error -R "^(upload_reservation|startup_address_console_gate_ring_warp|startup_address_console_gate_warp)$". No Windows or physical GPU result claimed.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6626045225 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2823). Originally posted by [chadhyatt](https://github.com/chadhyatt) on 2026-11-26T11:51:33Z. --- AI-assisted backport patch from x2w-microlift. Refs #2775. Keep upload reservation offsets and backing stable for their lifetime. Grow on demand as before and use remaining unused tails; refuse exhaustion at the existing 256 MiB cap rather than recycle a reservation without a completion contract. This is a bounded correctness change, not a recycling implementation. A long-running workload can exhaust the ring; fence-aware retirement needs a separate change. The authored portable fixture checks unchanged existing bytes, cursor and return values after growth and exhaustion. The existing Windows gate-ring fixture now expects retained payload 0, null view on later refused draws, and an explicit refusal log. Windows D3D12 gate behavior has not been run on this host. Verified 59a79a4db3d43af0e42b2f3173811b2a03f8924a on arm64 macOS: - `c++ -std=c++17 -Wall -Wextra -fsanitize=address,undefined -Isrc tests/upload_reservation_check.cpp -o out/upload_reservation_check && out/upload_reservation_check`: pass. - Python `compile` on `tests/startup_address_console_check.py`: pass. - `git diff --check`: pass. Suggested Windows verification: `ctest --preset dev --no-tests=error -R "^(upload_reservation|startup_address_console_gate_ring_warp|startup_address_console_gate_warp)$"`. No Windows or physical GPU result claimed.
upstream-sync closed this pull request 2026-11-26 12:04:52 +00:00
tedin7 commented 2026-11-26 12:04:53 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T11:56:12Z.

Review: COMMENTED


Review of head 59a79a4d (comment only).

Result: sound. The change keeps upload reservation offsets and backing stable and refuses at the cap instead of recycling. It makes no game or startup claim, so the game rule does not apply.

What I checked:

  • reserve_upload_chunk (src/startup_stubs/upload_reservation.h): overflow-safe bounds test, cursor only moves on success.
  • reserve_upload_ring in d3d12_xs_device.cpp: new chunks start at used=0 and reserve through the same helper; the old "wrap to offset 0 of another chunk" loop is gone; fallback scans unused tails of existing chunks; refusal is logged (first 8 only). The old (ptr, offset, resource) wrapper is kept, so callsites are unchanged.
  • Test wiring: upload_reservation is registered in CMake; the gate-ring Python and C++ fixtures updated to expect retained payload 0 and a null view after refusal.
  • No other open or merged PR covers this slice (searched "upload reservation").

Commands run (Linux):

  • c++ -std=c++17 -Wall -Wextra -Isrc tests/upload_reservation_check.cpp -> all checks passed
  • python3 tests/docs_links_check.py -> ok; python3 tests/bidi_controls_check.py -> ok
  • git diff --check origin/main...HEAD -> clean
  • Mutation 1 (reset used to 0 on exhaustion): upload_reservation_check fails ("insufficient tail refuses the reservation").
  • Mutation 2 (always start at offset 0): fails ("exact remaining active tail").

Not covered here: Windows D3D12 gate behavior (Win2025 run follows in a receipt).

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6073715759 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2823#pullrequestreview-6073715759). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T11:56:12Z. **Review:** COMMENTED --- Review of head 59a79a4d (comment only). Result: sound. The change keeps upload reservation offsets and backing stable and refuses at the cap instead of recycling. It makes no game or startup claim, so the game rule does not apply. What I checked: - `reserve_upload_chunk` (src/startup_stubs/upload_reservation.h): overflow-safe bounds test, cursor only moves on success. - `reserve_upload_ring` in d3d12_xs_device.cpp: new chunks start at `used=0` and reserve through the same helper; the old "wrap to offset 0 of another chunk" loop is gone; fallback scans unused tails of existing chunks; refusal is logged (first 8 only). The old `(ptr, offset, resource)` wrapper is kept, so callsites are unchanged. - Test wiring: `upload_reservation` is registered in CMake; the gate-ring Python and C++ fixtures updated to expect retained payload 0 and a null view after refusal. - No other open or merged PR covers this slice (searched "upload reservation"). Commands run (Linux): - `c++ -std=c++17 -Wall -Wextra -Isrc tests/upload_reservation_check.cpp` -> all checks passed - `python3 tests/docs_links_check.py` -> ok; `python3 tests/bidi_controls_check.py` -> ok - `git diff --check origin/main...HEAD` -> clean - Mutation 1 (reset `used` to 0 on exhaustion): `upload_reservation_check` fails ("insufficient tail refuses the reservation"). - Mutation 2 (always start at offset 0): fails ("exact remaining active tail"). Not covered here: Windows D3D12 gate behavior (Win2025 run follows in a receipt). AI-assisted; commands listed were executed locally.
chadhyatt commented 2026-11-26 12:04:58 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chadhyatt on 2026-11-26T11:56:35Z.


Thanks for reviewing the exact head and running the independent portable checks. The Windows build-and-test and Linux checks are green. The 256 MiB exhaustion refusal remains intentionally bounded; fence-aware retirement is separate. I will keep the D3D12 gate behavior unclaimed until the Windows receipt.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7191363595 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2823#issuecomment-7191363595). Originally posted by [chadhyatt](https://github.com/chadhyatt) on 2026-11-26T11:56:35Z. --- Thanks for reviewing the exact head and running the independent portable checks. The Windows build-and-test and Linux checks are green. The 256 MiB exhaustion refusal remains intentionally bounded; fence-aware retirement is separate. I will keep the D3D12 gate behavior unclaimed until the Windows receipt.
tedin7 commented 2026-11-26 12:04:58 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T11:58:01Z.


Win2025 WARP receipt for head 59a79a4d.

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

  • Debug (--preset dev):
    • Build (cmake --build --preset dev --target d3d12_xs_device_obj d3d12_xs_shim startup_stream_consumer unified_buffer_paths_check upload_reservation_check -- -j 2): 25.45s (configure 1.88s)
    • Test (ctest --preset dev -R '^(upload_reservation|startup_address_console_gate_ring_warp|startup_address_console_gate_warp|unified_buffer_paths.*|startup_stream_draw.*)$' --parallel 6 --no-tests=error --output-on-failure): 10/10 passed (3.82s: unified_buffer_paths_skip_refresh_control 1.35s, unified_buffer_paths_hardware 1.37s, unified_buffer_paths_skip_copy_back_control 1.20s, unified_buffer_paths_warp 1.20s, upload_reservation 0.02s, startup_stream_draw_warp 2.86s, startup_stream_draw_hardware 3.04s, startup_address_console_gate_ring_warp 3.31s, startup_address_console_gate_warp 3.63s, unified_buffer_paths_reuse_early_control 1.09s)
  • Release /O2 (--preset release):
    • Build (cmake --build --preset release --target d3d12_xs_device_obj d3d12_xs_shim startup_stream_consumer unified_buffer_paths_check upload_reservation_check -- -j 2): 54.96s (configure 1.87s)
    • Test (ctest --preset release -R '^(upload_reservation|startup_address_console_gate_ring_warp|startup_address_console_gate_warp|unified_buffer_paths.*|startup_stream_draw.*)$' --parallel 6 --no-tests=error --output-on-failure): 10/10 passed (3.68s: upload_reservation 0.02s, unified_buffer_paths_hardware 1.43s, unified_buffer_paths_skip_copy_back_control 1.44s, unified_buffer_paths_warp 1.47s, unified_buffer_paths_skip_refresh_control 1.51s, unified_buffer_paths_reuse_early_control 1.12s, startup_stream_draw_warp 2.75s, startup_stream_draw_hardware 2.75s, startup_address_console_gate_ring_warp 1.96s, startup_address_console_gate_warp 2.07s)
  • sccache: 0/16 hits; wall 93.0s

Tests covered (10/10 dev, 10/10 release): upload_reservation, startup_address_console_gate_warp, startup_address_console_gate_ring_warp, unified_buffer_paths and stream-draw tests. Real-GPU run not available (RunPod stopped).

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7191393771 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2823#issuecomment-7191393771). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T11:58:01Z. --- Win2025 WARP receipt for head 59a79a4d. Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit `59a79a4db3d43af0e42b2f3173811b2a03f8924a`: - **Debug (`--preset dev`)**: - Build (`cmake --build --preset dev --target d3d12_xs_device_obj d3d12_xs_shim startup_stream_consumer unified_buffer_paths_check upload_reservation_check -- -j 2`): `25.45s` (configure `1.88s`) - Test (`ctest --preset dev -R '^(upload_reservation|startup_address_console_gate_ring_warp|startup_address_console_gate_warp|unified_buffer_paths.*|startup_stream_draw.*)$' --parallel 6 --no-tests=error --output-on-failure`): **10/10 passed** (`3.82s`: `unified_buffer_paths_skip_refresh_control` `1.35s`, `unified_buffer_paths_hardware` `1.37s`, `unified_buffer_paths_skip_copy_back_control` `1.20s`, `unified_buffer_paths_warp` `1.20s`, `upload_reservation` `0.02s`, `startup_stream_draw_warp` `2.86s`, `startup_stream_draw_hardware` `3.04s`, `startup_address_console_gate_ring_warp` `3.31s`, `startup_address_console_gate_warp` `3.63s`, `unified_buffer_paths_reuse_early_control` `1.09s`) - **Release `/O2` (`--preset release`)**: - Build (`cmake --build --preset release --target d3d12_xs_device_obj d3d12_xs_shim startup_stream_consumer unified_buffer_paths_check upload_reservation_check -- -j 2`): `54.96s` (configure `1.87s`) - Test (`ctest --preset release -R '^(upload_reservation|startup_address_console_gate_ring_warp|startup_address_console_gate_warp|unified_buffer_paths.*|startup_stream_draw.*)$' --parallel 6 --no-tests=error --output-on-failure`): **10/10 passed** (`3.68s`: `upload_reservation` `0.02s`, `unified_buffer_paths_hardware` `1.43s`, `unified_buffer_paths_skip_copy_back_control` `1.44s`, `unified_buffer_paths_warp` `1.47s`, `unified_buffer_paths_skip_refresh_control` `1.51s`, `unified_buffer_paths_reuse_early_control` `1.12s`, `startup_stream_draw_warp` `2.75s`, `startup_stream_draw_hardware` `2.75s`, `startup_address_console_gate_ring_warp` `1.96s`, `startup_address_console_gate_warp` `2.07s`) - `sccache`: 0/16 hits; wall `93.0s` Tests covered (10/10 dev, 10/10 release): upload_reservation, startup_address_console_gate_warp, startup_address_console_gate_ring_warp, unified_buffer_paths and stream-draw tests. Real-GPU run not available (RunPod stopped). AI-assisted; commands listed were executed 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!2815
No description provided.