Refresh CPU-backed shader inputs between fenced submissions #1103

Merged
R0Y00 merged 2 commits from upstream-pr/1110 into main 2026-11-24 12:37:11 +00:00
R0Y00 commented 2026-11-24 01:10:10 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T01:10:10Z.


Refs #874, #870.

cpu_srv::refresh updates an existing upload range for a stable shader-resource view. The caller serializes updates and submits, holds the CPU input stable during the copy, and supplies the fence point covering prior GPU readers. Unreadable input and an unfinished fence preserve the live data. The fixture uses the same R16_UINT view for both compute dispatches.

On Windows build 26200, RTX 4060 Laptop driver 32.0.16.1656 and WARP 10.0.26100.9818 passed all four Release tests with the D3D12 debug layer enabled, zero warnings, zero errors and zero skips. The second readback changes from 1398 2467 to 8765 fe01 after refresh. Skipping the refresh preserves the original pair. Rejections include an incomplete fence, a write extending beyond the endpoint, an overflowing offset and an unreadable source.

cmake --build --preset release --target offscreen_check
ctest --preset release --no-tests=error -R '^cpu_srv_' -V

This PR covers the source-built shader input and its CPU/GPU handoff. Diagnostic runtime integration is tracked in #870.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6572294332 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1110). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T01:10:10Z. --- Refs #874, #870. `cpu_srv::refresh` updates an existing upload range for a stable shader-resource view. The caller serializes updates and submits, holds the CPU input stable during the copy, and supplies the fence point covering prior GPU readers. Unreadable input and an unfinished fence preserve the live data. The fixture uses the same `R16_UINT` view for both compute dispatches. On Windows build 26200, RTX 4060 Laptop driver 32.0.16.1656 and WARP 10.0.26100.9818 passed all four Release tests with the D3D12 debug layer enabled, zero warnings, zero errors and zero skips. The second readback changes from `1398 2467` to `8765 fe01` after refresh. Skipping the refresh preserves the original pair. Rejections include an incomplete fence, a write extending beyond the endpoint, an overflowing offset and an unreadable source. ``` cmake --build --preset release --target offscreen_check ctest --preset release --no-tests=error -R '^cpu_srv_' -V ``` This PR covers the source-built shader input and its CPU/GPU handoff. Diagnostic runtime integration is tracked in #870.
tedin7 commented 2026-11-24 02:15:43 +00:00 (Migrated from github.com)

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

Review: COMMENTED


Reviewed at 9f23be2b232f96c9e48edb90c4cb9b97fb47bcdf.

  • Code & structure: cpu_srv::refresh in src/cpu_srv_upload.h validates inputs, buffer dimension, overflow-safe bounds (bytes > desc.Width - destination_offset), D3D12_HEAP_TYPE_UPLOAD, and fence completion (UINT64_MAX -> DXGI_ERROR_DEVICE_REMOVED, done < previous_value -> DXGI_ERROR_WAS_STILL_DRAWING). Staging via ReadProcessMemory before Map/memcpy/Unmap ensures an unreadable source page fails without altering the upload buffer (minor note: per-call heap allocation + ReadProcessMemory is great for safety here, though worth keeping in mind if ever used on a hot path). check_cpu_srv_refresh in tests/descriptor_window_submissions.cpp covers both refresh and --cpu-srv-stale plus the negative cases.
  • Linux checks run: python3 -B tests/docs_links_check.py (15 files, 246 links), python3 -B tests/bidi_controls_check.py (929 files), python3 -B tests/gpu_report_format_check.py (10 tests), and python3 -B tests/xgameruntime_table_check.py — all passed.
  • CI / Windows: gh pr checks 1110 shows all 4 Windows/Linux checks passed (publish skipped); Windows MSVC/WARP/hardware execution is covered by CI.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6032633724 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1110#pullrequestreview-6032633724). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T02:15:43Z. **Review:** COMMENTED --- Reviewed at `9f23be2b232f96c9e48edb90c4cb9b97fb47bcdf`. - **Code & structure**: `cpu_srv::refresh` in `src/cpu_srv_upload.h` validates inputs, buffer dimension, overflow-safe bounds (`bytes > desc.Width - destination_offset`), `D3D12_HEAP_TYPE_UPLOAD`, and fence completion (`UINT64_MAX` -> `DXGI_ERROR_DEVICE_REMOVED`, `done < previous_value` -> `DXGI_ERROR_WAS_STILL_DRAWING`). Staging via `ReadProcessMemory` before `Map`/`memcpy`/`Unmap` ensures an unreadable source page fails without altering the upload buffer (minor note: per-call heap allocation + `ReadProcessMemory` is great for safety here, though worth keeping in mind if ever used on a hot path). `check_cpu_srv_refresh` in `tests/descriptor_window_submissions.cpp` covers both refresh and `--cpu-srv-stale` plus the negative cases. - **Linux checks run**: `python3 -B tests/docs_links_check.py` (15 files, 246 links), `python3 -B tests/bidi_controls_check.py` (929 files), `python3 -B tests/gpu_report_format_check.py` (10 tests), and `python3 -B tests/xgameruntime_table_check.py` — all passed. - **CI / Windows**: `gh pr checks 1110` shows all 4 Windows/Linux checks passed (publish skipped); Windows MSVC/WARP/hardware execution is covered by CI.
Toons29 commented 2026-11-24 06:50:07 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Toons29 on 2026-11-24T02:02:55Z.


Tested 9f23be2b on an AMD Radeon RX 9070 (RDNA 4, 1002:7550), driver 32.0.32029.2010, Windows 11 build 26300, dev preset, debug layer unavailable: pass

ctest --preset dev --no-tests=error -R '^cpu_srv_' -V

All 4 pass with no skips. cpu_srv_refresh reads 00001398,00002467 after fence 1 and 00008765,0000fe01 after fence 2 on both the RX 9070 and in-box WARP. cpu_srv_stale keeps 00001398,00002467 after fence 2 on both, as expected.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7119702847 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1110#issuecomment-7119702847). Originally posted by [Toons29](https://github.com/Toons29) on 2026-11-24T02:02:55Z. --- Tested 9f23be2b on an AMD Radeon RX 9070 (RDNA 4, `1002:7550`), driver `32.0.32029.2010`, Windows 11 build 26300, `dev` preset, debug layer unavailable: pass ```powershell ctest --preset dev --no-tests=error -R '^cpu_srv_' -V ``` All 4 pass with no skips. `cpu_srv_refresh` reads `00001398,00002467` after fence 1 and `00008765,0000fe01` after fence 2 on both the RX 9070 and in-box WARP. `cpu_srv_stale` keeps `00001398,00002467` after fence 2 on both, as expected.
upstream-sync closed this pull request 2026-11-24 13:00:19 +00:00
R0Y00 commented 2026-11-24 13:00:53 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T12:28:58Z.


Resolved the CMake conflict at 4ca3c951 by retaining the CPU SRV and startup sampler shader registrations. Windows Release: 12/12 CPU SRV refresh/stale, descriptor-window, and startup sampler cases passed on RTX and WARP, with no skips.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7131501314 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1110#issuecomment-7131501314). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T12:28:58Z. --- Resolved the CMake conflict at 4ca3c951 by retaining the CPU SRV and startup sampler shader registrations. Windows Release: 12/12 CPU SRV refresh/stale, descriptor-window, and startup sampler cases passed on RTX and WARP, with no skips.
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!1103
No description provided.