runtime: check that adjacent title ranges pack for the shader lookup #1533

Merged
Asimmimx merged 1 commit from upstream-pr/1540 into main 2026-11-24 14:38:17 +00:00
Asimmimx commented 2026-11-24 13:47:38 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Asimmimx on 2026-11-24T13:47:38Z.


Change

era_title_va::shader_ranges (src/era_title_va.{h,cpp}) packs a Table's ranges into the words the shader-side title lookup reads. It refuses ranges that are unsorted or overlap. Adjacent ranges are valid: Table::add accepts them, and era_title_gpu::shader_view packs table.ranges().

No device-free test packs two adjacent ranges. A mutant that turns the overlap check ranges[i - 1].title_end > range.title_begin into >= left all four era_title_va_* tests passing; that mutant also rejects adjacent ranges. Only gpu_alias_lookup_warp, gpu_alias_lookup_writes_warp and gpu_alias_registry_warp failed, and only because Windows placed their allocations next to each other. docs/experiments.md notes that placement varies, and those tests skip (77) without existing-heap support.

This adds a hand-worked case to the existing era_title_va_shader scenario. Two adjacent ranges, [0xffff'f000, 0x1'0000'0000) and [0x1'0000'0000, 0x1'0000'1000), which also meet on the 4 GiB line, must pack to {0xfffff000, 0, 0, 1, slot 0, reserved 0} and {0, 1, 0x1000, 1, slot 1, reserved 0}.

Only tests/era_title_va_check.cpp and one sentence in the era_title_va_shader row of docs/experiments.md change. There is no new CTest.

Verification

Commit 309cfede (main) plus this change, dev preset (Debug), Windows 11 Pro build 26300.9974, MSVC 19.51.36260, Windows SDK 10.0.26100.0, WARP 10.0.26100.9818.

ctest --preset dev --no-tests=error -R '^era_title_va_' -V
#   4/4 passed; with the >= mutant re-applied, era_title_va_shader fails with "FAIL: adjacent ranges packed"

These 12 tests passed with no skips, at baseline and after the change:

  • era_title_va_{translate,bounds,registry,shader}
  • era_title_gpu_alloc
  • gpu_alias_warp, gpu_alias_window_warp, gpu_alias_lookup_warp, gpu_alias_lookup_writes_warp and gpu_alias_registry_warp
  • dxr_address_ranges_warp and dxr_placed_build_warp

tests/docs_links_check.py, tests/bidi_controls_check.py and git diff --check passed.

Mutation probe

I applied each mutation to src/era_title_va.{h,cpp} alone, rebuilt, ran the 12 tests, then reverted. None of this is committed.

Mutant Existing With the new case
control: translate drops the offset killed n/a
pack: adjacent ranges rejected (> → >=) killed only by 3 WARP tests, placement-dependent killed
pack: start alignment & 3 → & 7 survived survived (not pinned)
pack: overlap checked against ranges[0] survived survived (not pinned)
pack: reserved set to the slot index survived killed
add: next->first < title_end → <= killed n/a
translate: last >= title_end → > killed n/a
translate: wrap check removed killed n/a
pack: 4 GiB limit >= → > killed n/a

Two survivors are left alone on purpose. The ranges that reach shader_ranges come from Table::ranges(), which are always page-aligned, sorted and disjoint, so no real caller can observe the 8-byte-alignment or the first-range overlap fault. If you want the documented 4-byte start rule pinned anyway, for example a start of 0x10004 being accepted, I can add that case.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6583237243 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1540). Originally posted by [Asimmimx](https://github.com/Asimmimx) on 2026-11-24T13:47:38Z. --- ## Change `era_title_va::shader_ranges` (`src/era_title_va.{h,cpp}`) packs a `Table`'s ranges into the words the shader-side title lookup reads. It refuses ranges that are unsorted or overlap. Adjacent ranges are valid: `Table::add` accepts them, and `era_title_gpu::shader_view` packs `table.ranges()`. No device-free test packs two adjacent ranges. A mutant that turns the overlap check `ranges[i - 1].title_end > range.title_begin` into `>=` left all four `era_title_va_*` tests passing; that mutant also rejects adjacent ranges. Only `gpu_alias_lookup_warp`, `gpu_alias_lookup_writes_warp` and `gpu_alias_registry_warp` failed, and only because Windows placed their allocations next to each other. `docs/experiments.md` notes that placement varies, and those tests skip (77) without existing-heap support. This adds a hand-worked case to the existing `era_title_va_shader` scenario. Two adjacent ranges, `[0xffff'f000, 0x1'0000'0000)` and `[0x1'0000'0000, 0x1'0000'1000)`, which also meet on the 4 GiB line, must pack to `{0xfffff000, 0, 0, 1, slot 0, reserved 0}` and `{0, 1, 0x1000, 1, slot 1, reserved 0}`. Only `tests/era_title_va_check.cpp` and one sentence in the `era_title_va_shader` row of `docs/experiments.md` change. There is no new CTest. ## Verification Commit `309cfede` (`main`) plus this change, `dev` preset (Debug), Windows 11 Pro build 26300.9974, MSVC 19.51.36260, Windows SDK 10.0.26100.0, WARP 10.0.26100.9818. ```powershell ctest --preset dev --no-tests=error -R '^era_title_va_' -V # 4/4 passed; with the >= mutant re-applied, era_title_va_shader fails with "FAIL: adjacent ranges packed" ``` These 12 tests passed with no skips, at baseline and after the change: - `era_title_va_{translate,bounds,registry,shader}` - `era_title_gpu_alloc` - `gpu_alias_warp`, `gpu_alias_window_warp`, `gpu_alias_lookup_warp`, `gpu_alias_lookup_writes_warp` and `gpu_alias_registry_warp` - `dxr_address_ranges_warp` and `dxr_placed_build_warp` `tests/docs_links_check.py`, `tests/bidi_controls_check.py` and `git diff --check` passed. ## Mutation probe I applied each mutation to `src/era_title_va.{h,cpp}` alone, rebuilt, ran the 12 tests, then reverted. None of this is committed. | Mutant | Existing | With the new case | |---|---|---| | control: `translate` drops the offset | killed | n/a | | pack: adjacent ranges rejected (`>` → `>=`) | killed only by 3 WARP tests, placement-dependent | killed | | pack: start alignment `& 3` → `& 7` | survived | survived (not pinned) | | pack: overlap checked against `ranges[0]` | survived | survived (not pinned) | | pack: `reserved` set to the slot index | survived | killed | | add: `next->first < title_end` → `<=` | killed | n/a | | translate: `last >= title_end` → `>` | killed | n/a | | translate: wrap check removed | killed | n/a | | pack: 4 GiB limit `>=` → `>` | killed | n/a | Two survivors are left alone on purpose. The ranges that reach `shader_ranges` come from `Table::ranges()`, which are always page-aligned, sorted and disjoint, so no real caller can observe the 8-byte-alignment or the first-range overlap fault. If you want the documented 4-byte start rule pinned anyway, for example a start of `0x10004` being accepted, I can add that case. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted (Claude Code).
upstream-sync closed this pull request 2026-11-24 15:01:56 +00:00
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!1533
No description provided.