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

Open
github-bot wants to merge 6 commits from github-bot/gh-3502 into main AGit
Owner

@⁠Leyukaka on GitHub · 2026-11-29 18:34 UTC · original
Leyukaka:diag-mesh57-bound-targets → main · +672 −124 · 11 files · 6 commits · draft

Refs #3418

Stacked on #3495: 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.

**@⁠Leyukaka** on GitHub · 2026-11-29 18:34 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3502) `Leyukaka:diag-mesh57-bound-targets` → `main` · +672 −124 · 11 files · 6 commits · draft Refs #3418 Stacked on #3495: 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 18:39:37 +00:00
Author
Owner

@⁠lukaslw-lab on GitHub · 2026-11-30 07:00 UTC · original · approved these changes

Reviewed 4991e866 (own commit over #3495 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.

**@⁠lukaslw-lab** on GitHub · 2026-11-30 07:00 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3502#pullrequestreview-6108024222) · **approved these changes** Reviewed `4991e866` (own commit over #3495 `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.
Author
Owner

@⁠SimSalabimse on GitHub · 2026-12-02 11:51 UTC · original

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

**@⁠SimSalabimse** on GitHub · 2026-12-02 11:51 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3502#issuecomment-7344512049) 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 has changes conflicting with the target branch.
  • docs/experiments/native-fixed-mesh57.md
  • docs/startup-runtime.md
  • src/startup_stubs/d3d12_draw.inl
  • src/startup_stubs/d3d12_xs_device.cpp
  • src/startup_stubs/mesh86_cache.inl
  • src/startup_stubs/native_mesh57.inl
  • tests/startup_indirect_draw_indexed.cpp
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/3504/head:github-bot/gh-3502'
git switch 'github-bot/gh-3502'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3502'
git switch 'github-bot/gh-3502'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3502'
git switch 'github-bot/gh-3502'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3502'
git switch 'main'
git merge --squash 'github-bot/gh-3502'
git switch 'main'
git merge --ff-only 'github-bot/gh-3502'
git switch 'main'
git merge 'github-bot/gh-3502'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.