runtime: probe an unreadable memory SRV range once per refusal #3466

Merged
Leyukaka merged 2 commits from upstream-pr/3466 into main 2026-11-30 19:58:25 +00:00
Leyukaka commented 2026-11-29 15:29:32 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-29T15:29:32Z.


Fixes #3462.

What changes

publish_tiled_texture now reports through a bool& unreadable whether its readability probe failed. texture_unavailable_reason uses that result and no longer calls x2w_local::readable on the same range (it also loses its address parameter). All three publish_tiled_texture call sites in device_memory_srv pass the same flag.

Faults on an unreadable range, per slot-70 refusal:

main (5de0b114) this PR
logged refusal (first 8, then the first of each new shape) 3 2
repeated refusal 2 1

The 1-byte probe in log_refused_memory_srv is unchanged; it is the second fault of a logged refusal.

Refusal decisions and census names are the same: texture_no_resource, texture_over_64mib, texture_unreadable, texture_unavailable. The size check still comes before the probe. The census class now follows the probe that made the decision, not a later one.

Why

Each failed probe is a first-chance access violation, and under the debugger each one stops the whole process. See #3462.

Tests

tests/startup_memory_srv_diag.cpp reserves one page without committing it, sends the same one-texel view to slot 70 twice, and counts read access violations at that address with a vectored handler. It expects 2 faults for the first call (logged) and 1 for the repeat, and texture_unreadable 2, in the census. tests/startup_memory_srv_diag_check.py expects the new shape's texture_unreadable line after the nine existing slot-70 lines.

ctest --preset dev -R '^startup_memory_srv_': 23/23 passed, twice (WARP and hardware diag included).

Mutations, each restored afterwards:

  • d3d12_memory_srv.inl back to the 5de0b114 version: diag_warp and diag_hardware fail with Expected 2 logged and 1 repeat reserved texel probe faults, observed 3 and 2.
  • Log probe removed (address_readable forced to false in log_refused_memory_srv): both fail with observed 1 and 1.
  • "texture_unreadable" renamed in texture_unavailable_cause (run on the first commit, 62e0a3c1): startup_memory_srv_census fails.

Not covered

  • No cache of unreadable ranges across calls: a repeated refusal still faults once. That is #2245.
  • The effect on a full run of the application has not been measured yet.
  • #2245 edits the same line of publish_tiled_texture, so whichever merges second gets a textual conflict there. There is no semantic overlap: #2245 does not touch texture_unavailable_reason.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5552198037 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3466). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-29T15:29:32Z. --- Fixes #3462. ## What changes `publish_tiled_texture` now reports through a `bool& unreadable` whether its readability probe failed. `texture_unavailable_reason` uses that result and no longer calls `x2w_local::readable` on the same range (it also loses its `address` parameter). All three `publish_tiled_texture` call sites in `device_memory_srv` pass the same flag. Faults on an unreadable range, per slot-70 refusal: | | `main` (`5de0b114`) | this PR | |---|---|---| | logged refusal (first 8, then the first of each new shape) | 3 | 2 | | repeated refusal | 2 | 1 | The 1-byte probe in `log_refused_memory_srv` is unchanged; it is the second fault of a logged refusal. Refusal decisions and census names are the same: `texture_no_resource`, `texture_over_64mib`, `texture_unreadable`, `texture_unavailable`. The size check still comes before the probe. The census class now follows the probe that made the decision, not a later one. ## Why Each failed probe is a first-chance access violation, and under the debugger each one stops the whole process. See #3462. ## Tests `tests/startup_memory_srv_diag.cpp` reserves one page without committing it, sends the same one-texel view to slot 70 twice, and counts read access violations at that address with a vectored handler. It expects 2 faults for the first call (logged) and 1 for the repeat, and `texture_unreadable 2,` in the census. `tests/startup_memory_srv_diag_check.py` expects the new shape's `texture_unreadable` line after the nine existing slot-70 lines. `ctest --preset dev -R '^startup_memory_srv_'`: 23/23 passed, twice (WARP and hardware `diag` included). Mutations, each restored afterwards: - `d3d12_memory_srv.inl` back to the `5de0b114` version: `diag_warp` and `diag_hardware` fail with `Expected 2 logged and 1 repeat reserved texel probe faults, observed 3 and 2`. - Log probe removed (`address_readable` forced to `false` in `log_refused_memory_srv`): both fail with `observed 1 and 1`. - `"texture_unreadable"` renamed in `texture_unavailable_cause` (run on the first commit, `62e0a3c1`): `startup_memory_srv_census` fails. ## Not covered - No cache of unreadable ranges across calls: a repeated refusal still faults once. That is #2245. - The effect on a full run of the application has not been measured yet. - #2245 edits the same line of `publish_tiled_texture`, so whichever merges second gets a textual conflict there. There is no semantic overlap: #2245 does not touch `texture_unavailable_reason`.
lukaslw-lab commented 2026-11-30 08:56:47 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-11-30T08:56:47Z.

Review: APPROVED


Reviewed 5ca1d954 by reading the diff; not built or run.

Verdict: approve. One fault fewer per refusal, and the census class is unchanged on every path. No MUST.

  • Census on the shared path (d3d12_memory_srv.inl:768-792): with published true, texture_unavailable_reason runs only when there is no texture and nothing is held. On the BC / bc64 path, publish_tiled_texture has just run. On the console-layout path, the only way through without held is the else if (!texture) branch, which also calls publish_tiled_texture. So unreadable is always the result of a probe on the same call, never the stale false default. A view with both a BC and a console layout probes twice, and the second result wins, which is the correct one.
  • Order is kept: the 64 MiB check still returns before the probe with unreadable = false, so texture_over_64mib is unchanged. A nullptr after a successful probe still gives texture_unavailable.
  • The fixture holds on current main (2e30cc59). readable goes through probe_readable → mapped_prefix, which skips only MEM_FREE. A MEM_RESERVE page is still touched with the pre-check on or off (X2W_PROBE_PRECHECK, #3313), so the expected 2 / 1 faults do not depend on the debugger or the environment. Neither file has changed on main since this head.

Tests: the vectored-handler count at the exact address shows the probe count per call, and the 5de0b114 mutation (3 / 2) shows it catches the double probe. The diag_check.py change follows the new tenth slot-70 line. CI did not run startup_memory_srv_diag_*: they are not in the pr preset's list, and /O2 was skipped on the PR.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6109235163 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3466#pullrequestreview-6109235163). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-11-30T08:56:47Z. **Review:** APPROVED --- Reviewed `5ca1d954` by reading the diff; not built or run. **Verdict: approve.** One fault fewer per refusal, and the census class is unchanged on every path. No MUST. - Census on the shared path (`d3d12_memory_srv.inl:768`-`792`): with `published` true, `texture_unavailable_reason` runs only when there is no texture and nothing is `held`. On the BC / bc64 path, `publish_tiled_texture` has just run. On the console-layout path, the only way through without `held` is the `else if (!texture)` branch, which also calls `publish_tiled_texture`. So `unreadable` is always the result of a probe on the same call, never the stale `false` default. A view with both a BC and a console layout probes twice, and the second result wins, which is the correct one. - Order is kept: the 64 MiB check still returns before the probe with `unreadable = false`, so `texture_over_64mib` is unchanged. A `nullptr` after a successful probe still gives `texture_unavailable`. - The fixture holds on current main (`2e30cc59`). `readable` goes through `probe_readable` → `mapped_prefix`, which skips only `MEM_FREE`. A `MEM_RESERVE` page is still touched with the pre-check on or off (`X2W_PROBE_PRECHECK`, #3313), so the expected 2 / 1 faults do not depend on the debugger or the environment. Neither file has changed on main since this head. Tests: the vectored-handler count at the exact address shows the probe count per call, and the `5de0b114` mutation (3 / 2) shows it catches the double probe. The `diag_check.py` change follows the new tenth slot-70 line. CI did not run `startup_memory_srv_diag_*`: they are not in the `pr` preset's list, and `/O2` was skipped on the PR.
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!3466
No description provided.