Skip to content

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

Draft
Leyukaka wants to merge 6 commits into
R0Y00:mainfrom
Leyukaka:diag-mesh57-bound-targets
Draft

Leyukaka wants to merge 6 commits into
R0Y00:mainfrom
Leyukaka:diag-mesh57-bound-targets

Conversation

@Leyukaka

Copy link
Copy Markdown
Collaborator

Refs #3416

Stacked on #3493: until it merges, this PR also shows its commits. Only the last commit (4991e86) 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 lukaslw-lab left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority: P0 Highest project priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants