runtime: capture slot 57 attachment formats for profiles #3736

Open
lambirou wants to merge 6 commits from upstream-pr/3736 into main
lambirou commented 2026-12-01 13:18:14 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-12-01T13:18:14Z.


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 #3497
Refs #3724

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5586497283 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3736). Originally posted by [lambirou](https://github.com/lambirou) on 2026-12-01T13:18:14Z. --- `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 #3497 Refs #3724
R0D4X commented 2026-12-01 16:59:27 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0D4X on 2026-12-01T16:59:27Z.


Reviewed the diff of #3736 against tools/startup/mesh57_profile_draft.py and #3502 (now also unstacked onto current main in #3761).

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 #3502 / #3761:

  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 #3502).
  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>.

#3761 unstacks #3502 (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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7318570018 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3736#issuecomment-7318570018). Originally posted by [R0D4X](https://github.com/R0D4X) on 2026-12-01T16:59:27Z. --- Reviewed the diff of #3736 against `tools/startup/mesh57_profile_draft.py` and #3502 (now also unstacked onto current `main` in #3761). 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 #3502 / #3761: 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 #3502). 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>`. #3761 unstacks #3502 (`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.
R0Y00 commented 2026-12-01 17:06:55 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-01T17:06:55Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7318776709 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3736#issuecomment-7318776709). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-01T17:06:55Z. --- 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.
SimSalabimse commented 2026-12-02 11:51:51 +00:00 (Migrated from github.com)

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


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

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7344511410 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3736#issuecomment-7344511410). Originally posted by [SimSalabimse](https://github.com/SimSalabimse) on 2026-12-02T11:51:51Z. --- 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
lambirou commented 2026-12-02 14:45:23 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-12-02T14:45:23Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6153064274 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3736#pullrequestreview-6153064274). Originally posted by [lambirou](https://github.com/lambirou) on 2026-12-02T14:45:23Z. **Review:** COMMENTED --- 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.
R0Y00 commented 2026-12-02 14:55:16 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-02T14:55:16Z.

Review: CHANGES_REQUESTED


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6153251758 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3736#pullrequestreview-6153251758). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-02T14:55:16Z. **Review:** CHANGES_REQUESTED --- 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 commented 2026-12-02 15:26:08 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-02T15:26:08Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6153831640 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3736#pullrequestreview-6153831640). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-02T15:26:08Z. **Review:** COMMENTED --- 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 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/3736:upstream-pr/3736'
git switch 'upstream-pr/3736'

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