runtime: capture slot 57 attachment formats for profiles #3738

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

@⁠lambirou on GitHub · 2026-12-01 13:18 UTC · original
lambirou:codex/mesh57-attachment-capture-clean → main · +116 −5 · 6 files · 6 commits · open

X2W_MESH57_CAPTURE_STATE=1 archived the slot 57 state blocks in
req_<variant>.s57, but not the render-target and depth formats bound at
that draw. tools/startup/mesh57_profile_draft.py reads those from an
adjacent .t57 sidecar, so a color capture could only be reviewed as a
depth-only profile and no color profile could be built from the title.

The capture now writes req_<variant>.t57 immediately before .s57, in
one targets <N> <fmt...> dsv <fmt> writable <0|1> samples 1 0 line with
decimal DXGI formats. It is written only when the bound attachments are
single-sample and at least one target or the DSV has a known format; an empty
or multisample bind writes no sidecar and keeps .s57 as the archive. The
fixture binds R8G8B8A8_UNORM and D32_FLOAT_S8X24_UINT, checks the exact
tuple against its own formats, and covers the depth-only, empty and
multisample controls.

Validation (Windows, Release):

  • ctest --preset release --no-tests=error -R '^(native_fixed_mesh57(_mrt)?_(warp|hardware)|startup_indirect_mesh_(warp|hardware))$'
    — 6/6 pass, including AMD Radeon RX 9060 XT.
  • python -B tests/mesh57_profile_draft_check.py — pass.
  • python -B tests/docs_links_check.py — pass.

Refs #3499
Refs #3726

**@⁠lambirou** on GitHub · 2026-12-01 13:18 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3736) `lambirou:codex/mesh57-attachment-capture-clean` → `main` · +116 −5 · 6 files · 6 commits · open `X2W_MESH57_CAPTURE_STATE=1` archived the slot 57 state blocks in `req_<variant>.s57`, but not the render-target and depth formats bound at that draw. `tools/startup/mesh57_profile_draft.py` reads those from an adjacent `.t57` sidecar, so a color capture could only be reviewed as a depth-only profile and no color profile could be built from the title. The capture now writes `req_<variant>.t57` immediately before `.s57`, in one `targets <N> <fmt...> dsv <fmt> writable <0|1> samples 1 0` line with decimal DXGI formats. It is written only when the bound attachments are single-sample and at least one target or the DSV has a known format; an empty or multisample bind writes no sidecar and keeps `.s57` as the archive. The fixture binds `R8G8B8A8_UNORM` and `D32_FLOAT_S8X24_UINT`, checks the exact tuple against its own formats, and covers the depth-only, empty and multisample controls. Validation (Windows, Release): - `ctest --preset release --no-tests=error -R '^(native_fixed_mesh57(_mrt)?_(warp|hardware)|startup_indirect_mesh_(warp|hardware))$'` — 6/6 pass, including AMD Radeon RX 9060 XT. - `python -B tests/mesh57_profile_draft_check.py` — pass. - `python -B tests/docs_links_check.py` — pass. Refs #3499 Refs #3726
The fixed slot 57 capture kept the state blocks but not the render-target and depth formats, so a color profile could not be reviewed from it. Publish a `.t57` sidecar immediately before `.s57` when the bound attachments are single-sample: one `targets <N> <fmt...> dsv <fmt> writable <0|1> samples 1 0` line that `mesh57_profile_draft.py` already reads. A bind with no attachments or a non-single-sample bind writes no sidecar, and `.s57` remains the archive. The fixture checks the tuple against the formats it bound and covers the depth-only, empty and multisample controls.

Refs #3497
Refs #3724
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 13:20:05 +00:00
Author
Owner

@⁠R0D4X on GitHub · 2026-12-01 16:59 UTC · original

Reviewed the diff of #3738 against tools/startup/mesh57_profile_draft.py and #3504 (now also unstacked onto current main in #3763).

While the native_fixed_mesh_fixture check on the real desktop pipeline path is a nice touch, this implementation has a few correctness gaps compared to #3504 / #3763:

  1. First-draw-wins hides conflicting attachment tuples: publish_shader_request(..., L".t57", ...) uses MoveFileExW(..., 0) (fail-if-exists) and request_slot57_mesh runs only once per (pipeline, root) before releasing fixed_ms/fixed_ps. If the same slot 57 variant is later drawn with different RTV/DSV formats or DSV writability, later tuples are silently dropped instead of recorded. mesh57_profile_draft.py relies on multiple tuples / overflow in .t57 to refuse ambiguous variants rather than drafting a wrong profile.
  2. Derived slot-55 pipelines can write .t57 for the base slot-57 variant: request_slot57_mesh walks info->path == 55 up to its base slot-57 PipelineInfo and publishes .t57 under the base variant key using the derived pipeline's bound attachments.
  3. Unresolved depth handle records bogus dsv 0 writable 0: In list_targets, when a non-null depth handle maps to no desktop descriptor (!resolved), pass.targets_bound is still set to true with pass.dsv_format == DXGI_FORMAT_UNKNOWN (the same SHOULD lukaslw-lab flagged on #3504).
  4. Typeless formats are not rejected: mesh57_attachment_tuple checks != DXGI_FORMAT_UNKNOWN, but does not check !x2w_view_dimension::typeless(...) on the RTVs or DSV.
  5. Synchronous disk I/O & hardcoded samples 1 0: Writes .t57 synchronously under request_lock on the draw thread and drops multisample binds instead of recording samples <count> <quality>.

#3763 unstacks #3504 (4991e866, keeping Leyukaka's authorship) onto current main, preserves the cache-index tracking in publish_shader_request, fixes depth_unresolved, and covers multi-RTV order, sample-count mismatch, unresolved depth, and derived slot-55 refusals on WARP and hardware.

**@⁠R0D4X** on GitHub · 2026-12-01 16:59 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3736#issuecomment-7318570018) Reviewed the diff of #3738 against `tools/startup/mesh57_profile_draft.py` and #3504 (now also unstacked onto current `main` in #3763). While the `native_fixed_mesh_fixture` check on the `real` desktop pipeline path is a nice touch, this implementation has a few correctness gaps compared to #3504 / #3763: 1. **First-draw-wins hides conflicting attachment tuples:** `publish_shader_request(..., L".t57", ...)` uses `MoveFileExW(..., 0)` (fail-if-exists) and `request_slot57_mesh` runs only once per `(pipeline, root)` before releasing `fixed_ms`/`fixed_ps`. If the same slot 57 variant is later drawn with different RTV/DSV formats or DSV writability, later tuples are silently dropped instead of recorded. `mesh57_profile_draft.py` relies on multiple tuples / `overflow` in `.t57` to refuse ambiguous variants rather than drafting a wrong profile. 2. **Derived slot-55 pipelines can write `.t57` for the base slot-57 variant:** `request_slot57_mesh` walks `info->path == 55` up to its base slot-57 `PipelineInfo` and publishes `.t57` under the base variant key using the derived pipeline's bound attachments. 3. **Unresolved depth handle records bogus `dsv 0 writable 0`:** In `list_targets`, when a non-null depth handle maps to no desktop descriptor (`!resolved`), `pass.targets_bound` is still set to `true` with `pass.dsv_format == DXGI_FORMAT_UNKNOWN` (the same SHOULD `lukaslw-lab` flagged on #3504). 4. **Typeless formats are not rejected:** `mesh57_attachment_tuple` checks `!= DXGI_FORMAT_UNKNOWN`, but does not check `!x2w_view_dimension::typeless(...)` on the RTVs or DSV. 5. **Synchronous disk I/O & hardcoded `samples 1 0`:** Writes `.t57` synchronously under `request_lock` on the draw thread and drops multisample binds instead of recording `samples <count> <quality>`. #3763 unstacks #3504 (`4991e866`, keeping Leyukaka's authorship) onto current `main`, preserves the cache-index tracking in `publish_shader_request`, fixes `depth_unresolved`, and covers multi-RTV order, sample-count mismatch, unresolved depth, and derived slot-55 refusals on WARP and hardware.
Author
Owner

@⁠R0Y00 on GitHub · 2026-12-01 17:06 UTC · original

Please add a capture case where the first request for a pipeline/root has no attachments, then the same pipeline/root draws with valid single-sample attachments. The current request cache compares only the pipeline and root, and the sidecar key excludes the attachments. That can keep the later tuple from being published. The case should also show how the reader handles two attachment tuples for the same variant.

**@⁠R0Y00** on GitHub · 2026-12-01 17:06 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3736#issuecomment-7318776709) Please add a capture case where the first request for a pipeline/root has no attachments, then the same pipeline/root draws with valid single-sample attachments. The current request cache compares only the pipeline and root, and the sidecar key excludes the attachments. That can keep the later tuple from being published. The case should also show how the reader handles two attachment tuples for the same variant.
Author
Owner

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

Windows test at ef67e5e9, 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 '^(native_fixed_mesh57(_mrt)?_(warp|hardware)|startup_indirect_mesh_(warp|hardware))$' -E 'startup_audio_(output|pacing|provider)' --output-on-failure

6/6 passed, 0 failed, 0 skipped: startup_indirect_mesh_warp, startup_indirect_mesh_hardware, native_fixed_mesh57_warp, native_fixed_mesh57_mrt_warp, native_fixed_mesh57_hardware, native_fixed_mesh57_mrt_hardware.

python -B tests/mesh57_profile_draft_check.py
python -B tests/docs_links_check.py

Both passed.

On the requested capture case (a first request for a pipeline/root with no attachments, then the same pipeline/root with valid single-sample attachments): this head does not include that sequence. The fixture checks the .t57 tuple against the formats it bound, and it unit-tests mesh57_attachment_tuple() for a depth-only bind, an empty bind (no sidecar line), and a multisample bind (no sidecar line). It does not run a first-empty-then-valid capture on one pipeline/root, and it does not show how the reader handles two attachment tuples for the same variant.

AI-Assisted

**@⁠SimSalabimse** on GitHub · 2026-12-02 11:51 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3736#issuecomment-7344511410) Windows test at ef67e5e9, 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 '^(native_fixed_mesh57(_mrt)?_(warp|hardware)|startup_indirect_mesh_(warp|hardware))$' -E 'startup_audio_(output|pacing|provider)' --output-on-failure ``` 6/6 passed, 0 failed, 0 skipped: `startup_indirect_mesh_warp`, `startup_indirect_mesh_hardware`, `native_fixed_mesh57_warp`, `native_fixed_mesh57_mrt_warp`, `native_fixed_mesh57_hardware`, `native_fixed_mesh57_mrt_hardware`. ``` python -B tests/mesh57_profile_draft_check.py python -B tests/docs_links_check.py ``` Both passed. On the requested capture case (a first request for a pipeline/root with no attachments, then the same pipeline/root with valid single-sample attachments): this head does not include that sequence. The fixture checks the `.t57` tuple against the formats it bound, and it unit-tests `mesh57_attachment_tuple()` for a depth-only bind, an empty bind (no sidecar line), and a multisample bind (no sidecar line). It does not run a first-empty-then-valid capture on one pipeline/root, and it does not show how the reader handles two attachment tuples for the same variant. AI-Assisted
Author
Owner

@⁠lambirou on GitHub · 2026-12-02 14:45 UTC · original · reviewed

Reviewed ef67e5e9; read the capture helper and the slot 57 publication path, not built here.

Verdict: approve. The attachment tuple is captured only for single-sample binds, is written before the .s57 archive, and returns an empty tuple rather than inventing an unknown format. The fixture checks the exact sidecar text and the MRT/DSV case.

  • NIT writable is encoded as capture.writable && dsv ? 1 : 0. That is correct today because an unknown DSV cannot be writable, but the truth table is implicit. A one-line comment or an explicit dsv != DXGI_FORMAT_UNKNOWN && capture.writable would make the invariant clear.
  • NIT The sidecar is published before the archive, so a failed .s57 write can leave an orphan .t57. The reader keys on .s57, so this is harmless; a cleanup on failure would keep the cache tidy.
  • Checked, no finding: target_count > 8 is rejected; a target or DSV with DXGI_FORMAT_UNKNOWN produces no tuple; the samples 1 0 fields match the single-sample contract; request_slot57_mesh skips the archive when the tuple write fails, so a reader never sees a mismatched pair.

The PR is independent of the Mesh86 stack.

**@⁠lambirou** on GitHub · 2026-12-02 14:45 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3736#pullrequestreview-6153064274) · **reviewed** Reviewed `ef67e5e9`; read the capture helper and the slot 57 publication path, not built here. **Verdict: approve.** The attachment tuple is captured only for single-sample binds, is written before the `.s57` archive, and returns an empty tuple rather than inventing an unknown format. The fixture checks the exact sidecar text and the MRT/DSV case. - **NIT** `writable` is encoded as `capture.writable && dsv ? 1 : 0`. That is correct today because an unknown DSV cannot be writable, but the truth table is implicit. A one-line comment or an explicit `dsv != DXGI_FORMAT_UNKNOWN && capture.writable` would make the invariant clear. - **NIT** The sidecar is published before the archive, so a failed `.s57` write can leave an orphan `.t57`. The reader keys on `.s57`, so this is harmless; a cleanup on failure would keep the cache tidy. - Checked, no finding: `target_count > 8` is rejected; a target or DSV with `DXGI_FORMAT_UNKNOWN` produces no tuple; the `samples 1 0` fields match the single-sample contract; `request_slot57_mesh` skips the archive when the tuple write fails, so a reader never sees a mismatched pair. The PR is independent of the Mesh86 stack.
github-bot force-pushed github-bot/gh-3736 from ef67e5e99b to 6f04c589b8 2026-12-02 14:52:21 +00:00 Compare
Author
Owner

@⁠R0Y00 on GitHub · 2026-12-02 14:55 UTC · original · requested changes

The asynchronous path drops the archive when an attachment tuple is present. request_slot57_mesh submits .t57 and .s57 in separate publish_mesh_request calls with the same variant. RequestPublisher deduplicates by key rather than extension, so the second call returns success without enqueuing .s57. I reproduced this with MSVC and the publisher header from 6f04c589: two enqueues produced one write (.t57) and one repeat. A single enqueue containing both ordered parts produced both writes. Please enqueue both parts together and verify the fixture with the default asynchronous publisher. The earlier no-attachments-to-valid-attachments case also remains uncovered, since the request cache still compares only pipeline and root.

**@⁠R0Y00** on GitHub · 2026-12-02 14:55 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3736#pullrequestreview-6153251758) · **requested changes** The asynchronous path drops the archive when an attachment tuple is present. `request_slot57_mesh` submits `.t57` and `.s57` in separate `publish_mesh_request` calls with the same variant. `RequestPublisher` deduplicates by key rather than extension, so the second call returns success without enqueuing `.s57`. I reproduced this with MSVC and the publisher header from `6f04c589`: two enqueues produced one write (`.t57`) and one repeat. A single enqueue containing both ordered parts produced both writes. Please enqueue both parts together and verify the fixture with the default asynchronous publisher. The earlier no-attachments-to-valid-attachments case also remains uncovered, since the request cache still compares only pipeline and root.
Author
Owner

@⁠R0Y00 on GitHub · 2026-12-02 15:26 UTC · original · reviewed

I checked ce71cda0. The new test setting forces X2W_SYNC_MESH_REQUESTS=1, which exercises the synchronous negative control. With the default async setting, the two publish_mesh_request calls still use the same deduplication key. The independently reproduced result is split: 1 writes, repeats=1; paired: 2 writes, repeats=0. Please enqueue .t57 and .s57 as one request (in that order) and keep a regression on the default async path. The attachment-change coverage requested in the earlier review still applies.

**@⁠R0Y00** on GitHub · 2026-12-02 15:26 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3736#pullrequestreview-6153831640) · **reviewed** I checked ce71cda0. The new test setting forces `X2W_SYNC_MESH_REQUESTS=1`, which exercises the synchronous negative control. With the default async setting, the two `publish_mesh_request` calls still use the same deduplication key. The independently reproduced result is `split: 1 writes, repeats=1; paired: 2 writes, repeats=0`. Please enqueue `.t57` and `.s57` as one request (in that order) and keep a regression on the default async path. The attachment-change coverage requested in the earlier review still applies.
This pull request has changes conflicting with the target branch.
  • src/startup_stubs/d3d12_draw.inl
  • src/startup_stubs/d3d12_xs_device.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/3738/head:github-bot/gh-3736'
git switch 'github-bot/gh-3736'

Merge

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