startup: record bound slot 57 targets with the creation capture #3502

Open
Leyukaka wants to merge 6 commits from upstream-pr/3502 into main
Leyukaka commented 2026-11-29 18:34:11 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-29T18:34:11Z.


Refs #3416

Stacked on #3493: until it merges, this PR also shows its commits. Only the last commit (4991e866) is new.

Why

A reviewed slot 57 profile needs the desktop render target formats, the DSV format and the sample count and quality. The creation capture written under X2W_MESH57_CAPTURE_STATE does not contain them. The views bound when the indirect mesh call executes do.

What

Under X2W_MESH57_CAPTURE_STATE only, a matching-root slot 57 indirect mesh call (placeholders included) records the bound attachments in req_<16-digit-variant-hex>.t57, next to the .s57 archive and with the same stem.

One LF-terminated line per distinct tuple:

targets <rtv-count> <ordered-rtv-formats...> dsv <format> writable <0-or-1> samples <count> <quality>

Example: targets 1 29 dsv 55 writable 1 samples 1 0.

  • DXGI formats are decimal and come from the typed view, not the resource.
  • DSV format 0 with writable 0 means no depth view is bound.
  • Tuples are deduplicated. The first 8 distinct tuples are kept, followed by an optional overflow <observations> line that counts observations outside the retained set, repeats of an unretained tuple included.
  • The writer merges with a prior complete sidecar in the same cache. A malformed or oversized (>= 2048 B) existing file is left untouched.
  • A fresh bind on the same recording is observed again. The archived variant is reused after the creation request releases its shader copies.
  • Unknown or typeless formats and inconsistent attachment sample descriptions are not recorded.
  • A derived slot 55 pipeline supplies no base-variant tuple.

Switch off: no work, allocation, file I/O or new lock. One environment lookup per indirect mesh call with a placeholder pipeline remains.

Switch on: the draw path adds no lock and does not wait for disk. It queues a value copy (variant, formats, samples, paths) to a background writer, capped at 256 outstanding items. A declined submit is retried on a later draw. The file is replaced atomically. Writes are best effort: a saturated queue or process exit can leave observations unpublished.

docs/startup-runtime.md documents the switch and the sidecar.

Tests

Two new CTests per backend, startup_indirect_mesh57_targets_<backend> and startup_indirect_mesh57_targets_off_<backend>, reuse the existing fixture binary. They cover duplicate binds, a format change on one recording, typeless color and depth resources with typed views, DSV writability, capture across recordings, overflow and the switch-off case.

ctest --preset dev -R '^(startup_indirect_mesh57_targets(_off)?|startup_indirect_mesh_request|native_fixed_mesh57(_mrt|_depth_only)?)_(warp|hardware)$|^native_mesh57_'

14/14 passed, no skips, on WARP and on hardware.

Mutations, each built and run against the two new WARP tests, all killed:

Mutation Detected by
tuple limit 8 -> 9 9th tuple instead of overflow 1
dedupe check removed duplicate first line
RTV format taken from the resource instead of the view 27 instead of 28
capture switch bypassed in the indirect path off fixture finds capture files
rebind mark dropped second tuple missing
writable forced to false writable 0 instead of 1
empty variant after the creation request is released later recording missing

Not covered

The profile tool does not read .t57 yet. That is a follow-up.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5553801917 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3502). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-29T18:34:11Z. --- Refs #3416 Stacked on #3493: until it merges, this PR also shows its commits. Only the last commit (4991e866) is new. ## Why A reviewed slot 57 profile needs the desktop render target formats, the DSV format and the sample count and quality. The creation capture written under `X2W_MESH57_CAPTURE_STATE` does not contain them. The views bound when the indirect mesh call executes do. ## What Under `X2W_MESH57_CAPTURE_STATE` only, a matching-root slot 57 indirect mesh call (placeholders included) records the bound attachments in `req_<16-digit-variant-hex>.t57`, next to the `.s57` archive and with the same stem. One LF-terminated line per distinct tuple: ``` targets <rtv-count> <ordered-rtv-formats...> dsv <format> writable <0-or-1> samples <count> <quality> ``` Example: `targets 1 29 dsv 55 writable 1 samples 1 0`. - DXGI formats are decimal and come from the typed view, not the resource. - DSV format `0` with writable `0` means no depth view is bound. - Tuples are deduplicated. The first 8 distinct tuples are kept, followed by an optional `overflow <observations>` line that counts observations outside the retained set, repeats of an unretained tuple included. - The writer merges with a prior complete sidecar in the same cache. A malformed or oversized (>= 2048 B) existing file is left untouched. - A fresh bind on the same recording is observed again. The archived variant is reused after the creation request releases its shader copies. - Unknown or typeless formats and inconsistent attachment sample descriptions are not recorded. - A derived slot 55 pipeline supplies no base-variant tuple. Switch off: no work, allocation, file I/O or new lock. One environment lookup per indirect mesh call with a placeholder pipeline remains. Switch on: the draw path adds no lock and does not wait for disk. It queues a value copy (variant, formats, samples, paths) to a background writer, capped at 256 outstanding items. A declined submit is retried on a later draw. The file is replaced atomically. Writes are best effort: a saturated queue or process exit can leave observations unpublished. `docs/startup-runtime.md` documents the switch and the sidecar. ## Tests Two new CTests per backend, `startup_indirect_mesh57_targets_<backend>` and `startup_indirect_mesh57_targets_off_<backend>`, reuse the existing fixture binary. They cover duplicate binds, a format change on one recording, typeless color and depth resources with typed views, DSV writability, capture across recordings, overflow and the switch-off case. ``` ctest --preset dev -R '^(startup_indirect_mesh57_targets(_off)?|startup_indirect_mesh_request|native_fixed_mesh57(_mrt|_depth_only)?)_(warp|hardware)$|^native_mesh57_' ``` 14/14 passed, no skips, on WARP and on hardware. Mutations, each built and run against the two new WARP tests, all killed: | Mutation | Detected by | |---|---| | tuple limit 8 -> 9 | 9th tuple instead of `overflow 1` | | dedupe check removed | duplicate first line | | RTV format taken from the resource instead of the view | 27 instead of 28 | | capture switch bypassed in the indirect path | off fixture finds capture files | | rebind mark dropped | second tuple missing | | writable forced to false | `writable 0` instead of `1` | | empty variant after the creation request is released | later recording missing | ## Not covered The profile tool does not read `.t57` yet. That is a follow-up.
lukaslw-lab commented 2026-11-30 07:00:23 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-11-30T07:00:23Z.

Review: APPROVED


Reviewed 4991e866 (own commit over #3493 196adf8c) by reading the diff; not built or run. Draft PR.

Verdict: approve. The switch-off path is inert and the sidecar writer is careful. One SHOULD can follow before the profile tool reads .t57. No MUST.

  • SHOULD skip the capture when the title's depth handle did not resolve. list_targets binds no depth for a handle that maps to no descriptor (d3d12_xs_device.cpp:4480-4484) but still sets targets_bound (:4532), so capture_slot57_targets records dsv 0 writable 0, a tuple the title never bound. A reviewed profile built from it would drop the depth attachment. A depth_unresolved flag on Pass, checked next to d3d12_draw.inl:1013, would keep runtime misses out.
  • NIT the fixture binds one RTV with one sample only. Multi-RTV order (rtvs[i] copy), a sample-count mismatch refusal and the derived slot 55 "no tuple" rule are untested. A two-RTV observe would catch an order bug cheaply.
  • Checked, no finding:
    • Switch off: requested_mesh_variant stays empty, so neither list_targets:4533 nor the capture does any work. The env lookup moved before the real check, as the PR body says.
    • fixed_mesh_capture_variant is written and read under request_lock. The return value is built before the guard is released.
    • bound_targets[i] cannot be null once targets_bound is set (:4464-4470). Pass{} resets the new fields per recording.
    • Writer: the per-variant mutex serialises read-modify-replace across processes, and FreeLibraryWhenCallbackReturns pins the DLL. The 2048 B read limit is well above 8 tuples plus overflow. A malformed file is left untouched.
    • The publish_request_file refactor keeps publish_shader_request's old result for move_flags == 0.

Tests: startup_indirect_mesh57_targets_<backend> proves view formats (28/29/30 from typeless resources), dedupe, rebind, DSV writability, reuse across recordings after the request is released, and overflow counting. _off_ proves no .s57/.t57 is written. CI's pr filter (CMakePresets.json) does not include either name, so CI did not run them. Only the author's local 14/14 (WARP + hardware) covers this head.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6108024222 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3502#pullrequestreview-6108024222). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-11-30T07:00:23Z. **Review:** APPROVED --- Reviewed `4991e866` (own commit over #3493 `196adf8c`) by reading the diff; not built or run. Draft PR. **Verdict: approve.** The switch-off path is inert and the sidecar writer is careful. One SHOULD can follow before the profile tool reads `.t57`. No MUST. - **SHOULD** skip the capture when the title's depth handle did not resolve. `list_targets` binds no depth for a handle that maps to no descriptor (`d3d12_xs_device.cpp:4480-4484`) but still sets `targets_bound` (`:4532`), so `capture_slot57_targets` records `dsv 0 writable 0`, a tuple the title never bound. A reviewed profile built from it would drop the depth attachment. A `depth_unresolved` flag on `Pass`, checked next to `d3d12_draw.inl:1013`, would keep runtime misses out. - **NIT** the fixture binds one RTV with one sample only. Multi-RTV order (`rtvs[i]` copy), a sample-count mismatch refusal and the derived slot 55 "no tuple" rule are untested. A two-RTV observe would catch an order bug cheaply. - Checked, no finding: - Switch off: `requested_mesh_variant` stays empty, so neither `list_targets:4533` nor the capture does any work. The env lookup moved before the `real` check, as the PR body says. - `fixed_mesh_capture_variant` is written and read under `request_lock`. The return value is built before the guard is released. - `bound_targets[i]` cannot be null once `targets_bound` is set (`:4464-4470`). `Pass{}` resets the new fields per recording. - Writer: the per-variant mutex serialises read-modify-replace across processes, and `FreeLibraryWhenCallbackReturns` pins the DLL. The 2048 B read limit is well above 8 tuples plus `overflow`. A malformed file is left untouched. - The `publish_request_file` refactor keeps `publish_shader_request`'s old result for `move_flags == 0`. Tests: `startup_indirect_mesh57_targets_<backend>` proves view formats (28/29/30 from typeless resources), dedupe, rebind, DSV writability, reuse across recordings after the request is released, and `overflow` counting. `_off_` proves no `.s57`/`.t57` is written. CI's `pr` filter (`CMakePresets.json`) does not include either name, so CI did not run them. Only the author's local 14/14 (WARP + hardware) covers this head.
SimSalabimse commented 2026-12-02 11:51:53 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by SimSalabimse on 2026-12-02T11:51:53Z.


Windows test at 4991e866, tested at this head without merging main.

Windows 11 Pro (10.0.26200), NVIDIA GeForce RTX 4070 Ti, driver 621.35, MSVC 19.44.35230, --preset dev, -j 1.

ctest --preset dev --no-tests=error -j 1 -R '^(startup_indirect_mesh57_targets(_off)?|startup_indirect_mesh_request|native_fixed_mesh57(_mrt|_depth_only)?)_(warp|hardware)$|^native_mesh57_' -E 'startup_audio_(output|pacing|provider)' --output-on-failure

14/14 passed, 0 failed, 0 skipped: startup_indirect_mesh_request_warp, startup_indirect_mesh57_targets_warp, startup_indirect_mesh57_targets_off_warp, startup_indirect_mesh_request_hardware, startup_indirect_mesh57_targets_hardware, startup_indirect_mesh57_targets_off_hardware, native_fixed_mesh57_warp, native_fixed_mesh57_mrt_warp, native_fixed_mesh57_hardware, native_fixed_mesh57_mrt_hardware, native_fixed_mesh57_depth_only_warp, native_fixed_mesh57_depth_only_hardware, native_mesh57_outcomes_warp, native_mesh57_outcomes_hardware.

AI-Assisted

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7344512049 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3502#issuecomment-7344512049). Originally posted by [SimSalabimse](https://github.com/SimSalabimse) on 2026-12-02T11:51:53Z. --- Windows test at 4991e866, tested at this head without merging main. Windows 11 Pro (10.0.26200), NVIDIA GeForce RTX 4070 Ti, driver 621.35, MSVC 19.44.35230, `--preset dev`, `-j 1`. ``` ctest --preset dev --no-tests=error -j 1 -R '^(startup_indirect_mesh57_targets(_off)?|startup_indirect_mesh_request|native_fixed_mesh57(_mrt|_depth_only)?)_(warp|hardware)$|^native_mesh57_' -E 'startup_audio_(output|pacing|provider)' --output-on-failure ``` 14/14 passed, 0 failed, 0 skipped: `startup_indirect_mesh_request_warp`, `startup_indirect_mesh57_targets_warp`, `startup_indirect_mesh57_targets_off_warp`, `startup_indirect_mesh_request_hardware`, `startup_indirect_mesh57_targets_hardware`, `startup_indirect_mesh57_targets_off_hardware`, `native_fixed_mesh57_warp`, `native_fixed_mesh57_mrt_warp`, `native_fixed_mesh57_hardware`, `native_fixed_mesh57_mrt_hardware`, `native_fixed_mesh57_depth_only_warp`, `native_fixed_mesh57_depth_only_hardware`, `native_mesh57_outcomes_warp`, `native_mesh57_outcomes_hardware`. AI-Assisted
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3502:upstream-pr/3502'
git switch 'upstream-pr/3502'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3502'
git switch 'upstream-pr/3502'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3502'
git switch 'upstream-pr/3502'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3502'
git switch 'main'
git merge --squash 'upstream-pr/3502'
git switch 'main'
git merge --ff-only 'upstream-pr/3502'
git switch 'main'
git merge 'upstream-pr/3502'
git push origin 'main'
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!3502
No description provided.