runtime: make the coherent placed buffer refresh opt-in #3914

Merged
Leyukaka merged 1 commit from upstream-pr/3914 into main 2026-12-03 08:06:09 +00:00
Leyukaka commented 2026-12-03 07:54:23 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-12-03T07:54:23Z.


Problem

Since #3776, a translated draw input or a compute root SRV in a placed buffer that does not alias guest memory is refreshed from guest memory through refresh_range. Two things changed with it.

Full-length application runs stall. Since #3776, every full run stalls when it reaches a later, heavier scene: the presenter reports x2w-present fence wait exceeded 2 seconds, and the process is ended about 30 s later. Bisection shows the stall needs the refreshed bytes themselves:

Variant Result
refresh as merged stalls
same ranges copied to a scratch buffer instead of the placed buffer no stall
same ranges written as zeros no stall
refresh disabled no stall

So the copy cost and the fence handling are not the cause. The buffers involved are consumed as constant buffers. The likely cause is a translated shader doing unbounded work once it reads real constants. That is not confirmed and is still under investigation.

Refusal controls fail on main. These tests expect a refusal for an input that is now refreshed:

  • 8 compute tests reported by @JB2WIN in https://github.com/R0Y00/Xbox2Windows/pull/3776#issuecomment-7358431627: startup_compute_dispatch_input_{warp,hardware}, startup_compute_input_view_token_{warp,hardware}, startup_compute_root_srv_dispatch_{warp,hardware}, startup_compute_snapshot_order_{warp,hardware}
  • 5 indirect tests: startup_indirect_translated_draw_{warp,hardware}, startup_indirect_translated_refusal_census_{warp,hardware}, startup_indirect_translated_refusal_census_control_warp. #3890 addresses these in a different way.

Change

This is a temporary gate, not a revert. All of #3776 stays in the tree and can be enabled per run.

  • X2W_COHERENT_PLACED_REFRESH=1 turns the refresh on. The switch is read once per process. With it on, behaviour is the same as current main.
  • With the switch unset, indirect_table_buffer and compute_root_srv_buffer do not call the refresh. They refuse these inputs with the same refusal text as before #3776. The two refusal reasons that #3776 added appear only with the switch on.
  • Nothing from #3776 is removed: page tracking, before_submit / commit_lists, mark_gpu_written on copies and the triage reasons are unchanged.
  • startup_coherent_placed_srv_{warp,hardware} now set the switch. A new test, startup_coherent_placed_srv_switch_off, runs with the switch off and checks that the gate reads off.
  • docs/startup-runtime.md has a new row in the switch table.

Once the stall is understood, the default can go back to on and the switch can be removed.

Validation

Windows, MSVC, on WARP and on a hardware adapter.

Targeted tests: 29/29 passed.

  • startup_coherent_placed_srv_{warp,hardware} with the switch on
  • startup_coherent_placed_srv_switch_off, the new control
  • the 5 indirect tests listed above, which fail on current main
  • the 8 compute tests listed above, which fail on current main
  • startup_mesh86_material_backing*
  • standin_exports, compat_report, triage_run

Independent read of the diff. With the switch unset, every path that #3776 touched behaves as it did before #3776, with identical refusal text. With X2W_COHERENT_PLACED_REFRESH=1, behaviour is the current one.

Full-length application runs.

Build Result
current main stalls at the later scene (fence wait over 2 s, process ended about 30 s later)
this branch, switch unset completes the full 360 s window with no stall

Notes

  • #3776: the refresh that this switch gates. Its code is unchanged.
  • #3890: marks UAV writes as GPU writes before the refresh. It only has an effect with the switch on, and it is still needed for that case. With the switch unset, the 5 indirect tests pass without it.
  • https://github.com/R0Y00/Xbox2Windows/pull/3776#issuecomment-7358431627: the report of the 8 compute failures. With the switch unset these controls pass with their original expectations. They will need new expectations when the default goes back to on.
  • The root cause of the stall is not identified yet. Work on it continues separately.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5622327078 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3914). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-12-03T07:54:23Z. --- ## Problem Since #3776, a translated draw input or a compute root SRV in a placed buffer that does not alias guest memory is refreshed from guest memory through `refresh_range`. Two things changed with it. **Full-length application runs stall.** Since #3776, every full run stalls when it reaches a later, heavier scene: the presenter reports `x2w-present fence wait exceeded 2 seconds`, and the process is ended about 30 s later. Bisection shows the stall needs the refreshed bytes themselves: | Variant | Result | |---|---| | refresh as merged | stalls | | same ranges copied to a scratch buffer instead of the placed buffer | no stall | | same ranges written as zeros | no stall | | refresh disabled | no stall | So the copy cost and the fence handling are not the cause. The buffers involved are consumed as constant buffers. The likely cause is a translated shader doing unbounded work once it reads real constants. That is not confirmed and is still under investigation. **Refusal controls fail on `main`.** These tests expect a refusal for an input that is now refreshed: - 8 compute tests reported by @JB2WIN in https://github.com/R0Y00/Xbox2Windows/pull/3776#issuecomment-7358431627: `startup_compute_dispatch_input_{warp,hardware}`, `startup_compute_input_view_token_{warp,hardware}`, `startup_compute_root_srv_dispatch_{warp,hardware}`, `startup_compute_snapshot_order_{warp,hardware}` - 5 indirect tests: `startup_indirect_translated_draw_{warp,hardware}`, `startup_indirect_translated_refusal_census_{warp,hardware}`, `startup_indirect_translated_refusal_census_control_warp`. #3890 addresses these in a different way. ## Change This is a temporary gate, not a revert. All of #3776 stays in the tree and can be enabled per run. - `X2W_COHERENT_PLACED_REFRESH=1` turns the refresh on. The switch is read once per process. With it on, behaviour is the same as current `main`. - With the switch unset, `indirect_table_buffer` and `compute_root_srv_buffer` do not call the refresh. They refuse these inputs with the same refusal text as before #3776. The two refusal reasons that #3776 added appear only with the switch on. - Nothing from #3776 is removed: page tracking, `before_submit` / `commit_lists`, `mark_gpu_written` on copies and the triage reasons are unchanged. - `startup_coherent_placed_srv_{warp,hardware}` now set the switch. A new test, `startup_coherent_placed_srv_switch_off`, runs with the switch off and checks that the gate reads off. - `docs/startup-runtime.md` has a new row in the switch table. Once the stall is understood, the default can go back to on and the switch can be removed. ## Validation Windows, MSVC, on WARP and on a hardware adapter. **Targeted tests: 29/29 passed.** - `startup_coherent_placed_srv_{warp,hardware}` with the switch on - `startup_coherent_placed_srv_switch_off`, the new control - the 5 indirect tests listed above, which fail on current `main` - the 8 compute tests listed above, which fail on current `main` - `startup_mesh86_material_backing*` - `standin_exports`, `compat_report`, `triage_run` **Independent read of the diff.** With the switch unset, every path that #3776 touched behaves as it did before #3776, with identical refusal text. With `X2W_COHERENT_PLACED_REFRESH=1`, behaviour is the current one. **Full-length application runs.** | Build | Result | |---|---| | current `main` | stalls at the later scene (fence wait over 2 s, process ended about 30 s later) | | this branch, switch unset | completes the full 360 s window with no stall | ## Notes - #3776: the refresh that this switch gates. Its code is unchanged. - #3890: marks UAV writes as GPU writes before the refresh. It only has an effect with the switch on, and it is still needed for that case. With the switch unset, the 5 indirect tests pass without it. - https://github.com/R0Y00/Xbox2Windows/pull/3776#issuecomment-7358431627: the report of the 8 compute failures. With the switch unset these controls pass with their original expectations. They will need new expectations when the default goes back to on. - The root cause of the stall is not identified yet. Work on it continues separately.
R0Y00 commented 2026-12-03 08:05:26 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-03T08:05:26Z.

Review: APPROVED


Independently reviewed 9af44a3f. Both production refresh_range callers are gated and the alias and copy-backed cases are preserved. Windows 11 build 26300, MSVC Debug: all 16 source-built cases passed, including 13 affected indirect and compute tests with the flag unset, both enabled refresh fixtures, and the explicit switch-off control. No skips, using WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656. With identical binaries and X2W_COHERENT_PLACED_REFRESH=1, both refusal-census cases reproduced the key3 mismatch: pixel (0,0) got 0xff00ff00, expected 0xff000000. #3890 tracks the opt-in case. The original executable comparison remains the author's work.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6165800374 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3914#pullrequestreview-6165800374). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-03T08:05:26Z. **Review:** APPROVED --- Independently reviewed 9af44a3f. Both production refresh_range callers are gated and the alias and copy-backed cases are preserved. Windows 11 build 26300, MSVC Debug: all 16 source-built cases passed, including 13 affected indirect and compute tests with the flag unset, both enabled refresh fixtures, and the explicit switch-off control. No skips, using WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656. With identical binaries and X2W_COHERENT_PLACED_REFRESH=1, both refusal-census cases reproduced the key3 mismatch: pixel (0,0) got 0xff00ff00, expected 0xff000000. #3890 tracks the opt-in case. The original executable comparison remains the author's work.
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!3914
No description provided.