gpu: alias shared heap pages for translated indexed draws #2258

Merged
R0Y00 merged 4 commits from upstream-pr/2266 into main 2026-11-25 10:05:38 +00:00
R0Y00 commented 2026-11-25 08:54:15 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T08:54:15Z.


Refs #1759. Stacked on #2262.

Add an opt-in read-only existing-heap binding for unregistered index views and vertex stream zero in translated indexed indirect draws. The requested span must fit a committed 64 KiB page in a private allocation whose external heap was already opened by slot 133. Refuse an overlapping registered GPU alias, an unproven or foreign heap, an extent beyond the underlying heap, and a view crossing the page. Both inputs on one page share the exact desktop resource. The argument buffer and existing GPU validator are used as before.

Enable with X2W_TRANSLATED_INDIRECT_ADDRESS_ALIAS=1 alongside X2W_TRANSLATED_INDIRECT_DRAW=1. Keep the allocation live for the startup device's lifetime and keep input bytes and alias ownership stable through GPU execution. The binding retains at most 64 pages and applies only to the index and vertex stream zero. Ordinary registered placements and recording uploads keep their existing paths.

Windows 26200.9974, MSVC 19.51.36244.0 Release, D3D12 debug layer on WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656.

cmake --build --preset release --target startup_indirect_draw_indexed --parallel 3
ctest --preset release --no-tests=error -R '^startup_indirect_(translated_indexed(_upload|_alias(_off)?)?|translated_draw|draw_indexed|copy_provenance(_off)?|mesh(_console|_amplified)?)_(warp|hardware)$' --output-on-failure

22/22 CTests passed with zero skips. The new fixture seeds a second page through slot 133, then uses an eight-byte R16 index view and a disjoint vertex view on the first page. The R32 case changes the argument offset and uses a nonzero base. All pixels and original argument words match. Unproven heap, overlapping alias, cross-page view and opt-out controls all leave the target clear.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6600759835 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2266). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-25T08:54:15Z. --- Refs #1759. Stacked on #2262. Add an opt-in read-only existing-heap binding for unregistered index views and vertex stream zero in translated indexed indirect draws. The requested span must fit a committed 64 KiB page in a private allocation whose external heap was already opened by slot 133. Refuse an overlapping registered GPU alias, an unproven or foreign heap, an extent beyond the underlying heap, and a view crossing the page. Both inputs on one page share the exact desktop resource. The argument buffer and existing GPU validator are used as before. Enable with `X2W_TRANSLATED_INDIRECT_ADDRESS_ALIAS=1` alongside `X2W_TRANSLATED_INDIRECT_DRAW=1`. Keep the allocation live for the startup device's lifetime and keep input bytes and alias ownership stable through GPU execution. The binding retains at most 64 pages and applies only to the index and vertex stream zero. Ordinary registered placements and recording uploads keep their existing paths. Windows 26200.9974, MSVC 19.51.36244.0 Release, D3D12 debug layer on WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656. ```powershell cmake --build --preset release --target startup_indirect_draw_indexed --parallel 3 ctest --preset release --no-tests=error -R '^startup_indirect_(translated_indexed(_upload|_alias(_off)?)?|translated_draw|draw_indexed|copy_provenance(_off)?|mesh(_console|_amplified)?)_(warp|hardware)$' --output-on-failure ``` 22/22 CTests passed with zero skips. The new fixture seeds a second page through slot 133, then uses an eight-byte R16 index view and a disjoint vertex view on the first page. The R32 case changes the argument offset and uses a nonzero base. All pixels and original argument words match. Unproven heap, overlapping alias, cross-page view and opt-out controls all leave the target clear.
tedin7 commented 2026-11-25 09:01:05 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T09:01:05Z.

Review: COMMENTED


Review of head 08875b4f979c5d77b66fc40b49fb8c053e41a550 (comment only).

Scope: 6 files, +250/-26 (two stacked commits: recording-upload index, then the opt-in existing-heap alias).

Commands executed locally

  • git diff --stat origin/main...HEAD, targeted reads of d3d12_xs_device.cpp, d3d12_draw.inl, d3d12_capture.inl, the fixture and CMakeLists.txt
  • python3 tests/docs_links_check.py -> self-test passed, 18 Markdown files, 432 links OK
  • python3 tests/bidi_controls_check.py -> 1546 files, no bidirectional controls
  • git diff --check origin/main...HEAD -> clean
  • python3 x2w_pipe.py win2025 2266 --targets startup_indirect_draw_indexed --regex '^startup_indirect_translated_indexed(_upload|_alias(_off)?)?_(warp|hardware)$' -> Release: build OK, WARP 4/4 passed (translated_indexed, _upload, _alias, _alias_off). The four _hardware variants were skipped for capability on that node, so they are not counted as passes.

PR is mergeable, title is neutral, no CI checks are reported on the branch. No Linux-runnable code is touched (Windows-only C++), so a source mutation could not be built or killed here. I did not run a mutation.

P1: none.
P2: none.

Checks that hold up

  • The alias route needs both X2W_TRANSLATED_INDIRECT_ADDRESS_ALIAS=1 and a known slot-133 heap. The _alias_off test covers the off path.
  • Overlap with a registered alias is re-checked on every call (placed_buffer_range(..., aliases_only=true)), before the page cache is consulted.
  • Page bound, heap extent bound, device identity and MEM_PRIVATE coverage are all checked before CreatePlacedResource. The cache is capped at 64 pages and refuses when full.
  • The index and VB0 share one cached page resource. The validator does not transition upload-backed indices (draw.indices.upload).

Nits

  1. d3d12_xs_device.cpp indirect_address_alias: placed_buffer_range runs before placed_mutex is taken, so the overlap check and the cache insert are not atomic. A placed alias registered between them is missed. The PR text says the caller must not activate an overlapping alias, so this is documented, but a short comment at the check would help.
  2. The cached Page resource is never released, and pages is a function-local static. That is fine for a device-lifetime heap, but the 64-page limit is reached silently. A one-time log line on it == pages.end() would make the refusal easy to diagnose.
  3. validate_indexed_arguments now skips the final require_state(... INDEX_BUFFER) for upload indices only. The aliased resource still gets the transition, so it ends the pass in INDEX_BUFFER state. Tests with two draws on the same page are debug-layer clean, so this looks fine. A comment on why alias differs from upload would help.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6054547774 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2266#pullrequestreview-6054547774). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T09:01:05Z. **Review:** COMMENTED --- Review of head `08875b4f979c5d77b66fc40b49fb8c053e41a550` (comment only). **Scope:** 6 files, +250/-26 (two stacked commits: recording-upload index, then the opt-in existing-heap alias). **Commands executed locally** - `git diff --stat origin/main...HEAD`, targeted reads of `d3d12_xs_device.cpp`, `d3d12_draw.inl`, `d3d12_capture.inl`, the fixture and `CMakeLists.txt` - `python3 tests/docs_links_check.py` -> self-test passed, 18 Markdown files, 432 links OK - `python3 tests/bidi_controls_check.py` -> 1546 files, no bidirectional controls - `git diff --check origin/main...HEAD` -> clean - `python3 x2w_pipe.py win2025 2266 --targets startup_indirect_draw_indexed --regex '^startup_indirect_translated_indexed(_upload|_alias(_off)?)?_(warp|hardware)$'` -> Release: build OK, WARP 4/4 passed (translated_indexed, _upload, _alias, _alias_off). The four `_hardware` variants were skipped for capability on that node, so they are not counted as passes. PR is mergeable, title is neutral, no CI checks are reported on the branch. No Linux-runnable code is touched (Windows-only C++), so a source mutation could not be built or killed here. I did not run a mutation. **P1:** none. **P2:** none. **Checks that hold up** - The alias route needs both `X2W_TRANSLATED_INDIRECT_ADDRESS_ALIAS=1` and a known slot-133 heap. The `_alias_off` test covers the off path. - Overlap with a registered alias is re-checked on every call (`placed_buffer_range(..., aliases_only=true)`), before the page cache is consulted. - Page bound, heap extent bound, device identity and `MEM_PRIVATE` coverage are all checked before `CreatePlacedResource`. The cache is capped at 64 pages and refuses when full. - The index and VB0 share one cached page resource. The validator does not transition upload-backed indices (`draw.indices.upload`). **Nits** 1. `d3d12_xs_device.cpp` `indirect_address_alias`: `placed_buffer_range` runs before `placed_mutex` is taken, so the overlap check and the cache insert are not atomic. A placed alias registered between them is missed. The PR text says the caller must not activate an overlapping alias, so this is documented, but a short comment at the check would help. 2. The cached `Page` resource is never released, and `pages` is a function-local static. That is fine for a device-lifetime heap, but the 64-page limit is reached silently. A one-time log line on `it == pages.end()` would make the refusal easy to diagnose. 3. `validate_indexed_arguments` now skips the final `require_state(... INDEX_BUFFER)` for upload indices only. The aliased resource still gets the transition, so it ends the pass in INDEX_BUFFER state. Tests with two draws on the same page are debug-layer clean, so this looks fine. A comment on why alias differs from upload would help. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-25 09:15:54 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T09:15:54Z.

Review: COMMENTED


Re-review of head e05fab9e759eda9021dc230cbb616fc16cbdb629 (merge of main on top of the previous head; the PR's own diff is still 6 files, +158/-16).

Commands executed locally:

  • git diff --stat origin/main...HEAD: CMakeLists.txt, docs/experiments.md, d3d12_capture.inl, d3d12_draw.inl, d3d12_xs_device.cpp, tests/startup_indirect_draw_indexed.cpp
  • python3 tests/docs_links_check.py: pass (18 files, 435 links)
  • python3 tests/bidi_controls_check.py: pass
  • git diff --check origin/main...HEAD: clean
  • python3 x2w_pipe.py win2025 2266 --targets startup_indirect_draw_indexed --regex startup_indirect_translated_indexed (WARP, dev + release /O2): build OK. alias_warp and alias_off_warp pass in both presets, along with the existing translated_indexed, upload and rect WARP tests. The 5 _hardware variants skip on capability (not counted as passes).

Findings:

  • P1: none in the PR's own code.
  • P2 (CI): "Run platform-independent Python checks on Linux" and "Assemble and translate gfx1013 fixtures" fail on this head (TypeError: 'NoneType' object is not an iterator, from tools/mesh_entry_aot.py and related checks). The PR touches no Python or tools, so these come in through the merged main content. Please confirm they fail the same way on main, or re-run, before Ready.
  • P2 (coverage of the guard): placed_buffer_range(..., aliases_only) in d3d12_xs_device.cpp / d3d12_capture.inl checks only Placement::aliased_buffer neighbours. A non-aliased placement overlapping the page (for example a texture placement) is not treated as a conflict. The tests cover only the aliased-buffer overlap (alias_overlaps). Either document this limit or add a case.
  • nit: the 64-entry static pages array never frees entries. A full table silently returns "refused". A counter or log line would make that visible. It is already documented as a limit.
  • nit: Windows CI "Build and test on Windows" passes but does not run the startup_indirect alias tests, so the Windows proof above is the only runtime evidence.
  • Not done: I did not run a mutation of the new logic, because the tests that exercise it need Windows and I did not queue a second Windows run. Static read: the alias_no_heap, alias_overlaps, alias_cross_page and alias_off cases each map to a distinct early-return in indirect_address_alias, so removing any of those checks should flip one of them.

Positives: the route is opt-in (X2W_TRANSLATED_INDIRECT_ADDRESS_ALIAS), requires a private committed page already in the slot-133 heap list, refuses cross-page spans, and is refused when a recording upload covers the address. Title is neutral, no clean-room concerns.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6054758884 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2266#pullrequestreview-6054758884). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T09:15:54Z. **Review:** COMMENTED --- Re-review of head `e05fab9e759eda9021dc230cbb616fc16cbdb629` (merge of main on top of the previous head; the PR's own diff is still 6 files, +158/-16). Commands executed locally: - `git diff --stat origin/main...HEAD`: CMakeLists.txt, docs/experiments.md, d3d12_capture.inl, d3d12_draw.inl, d3d12_xs_device.cpp, tests/startup_indirect_draw_indexed.cpp - `python3 tests/docs_links_check.py`: pass (18 files, 435 links) - `python3 tests/bidi_controls_check.py`: pass - `git diff --check origin/main...HEAD`: clean - `python3 x2w_pipe.py win2025 2266 --targets startup_indirect_draw_indexed --regex startup_indirect_translated_indexed` (WARP, dev + release /O2): build OK. `alias_warp` and `alias_off_warp` pass in both presets, along with the existing translated_indexed, upload and rect WARP tests. The 5 `_hardware` variants skip on capability (not counted as passes). Findings: - P1: none in the PR's own code. - P2 (CI): "Run platform-independent Python checks on Linux" and "Assemble and translate gfx1013 fixtures" fail on this head (`TypeError: 'NoneType' object is not an iterator`, from `tools/mesh_entry_aot.py` and related checks). The PR touches no Python or tools, so these come in through the merged main content. Please confirm they fail the same way on main, or re-run, before Ready. - P2 (coverage of the guard): `placed_buffer_range(..., aliases_only)` in d3d12_xs_device.cpp / d3d12_capture.inl checks only `Placement::aliased_buffer` neighbours. A non-aliased placement overlapping the page (for example a texture placement) is not treated as a conflict. The tests cover only the aliased-buffer overlap (`alias_overlaps`). Either document this limit or add a case. - nit: the 64-entry static `pages` array never frees entries. A full table silently returns "refused". A counter or log line would make that visible. It is already documented as a limit. - nit: Windows CI "Build and test on Windows" passes but does not run the startup_indirect alias tests, so the Windows proof above is the only runtime evidence. - Not done: I did not run a mutation of the new logic, because the tests that exercise it need Windows and I did not queue a second Windows run. Static read: the `alias_no_heap`, `alias_overlaps`, `alias_cross_page` and `alias_off` cases each map to a distinct early-return in `indirect_address_alias`, so removing any of those checks should flip one of them. Positives: the route is opt-in (`X2W_TRANSLATED_INDIRECT_ADDRESS_ALIAS`), requires a private committed page already in the slot-133 heap list, refuses cross-page spans, and is refused when a recording upload covers the address. Title is neutral, no clean-room concerns. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-25 09:57:50 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T09:57:50Z.

Review: COMMENTED


Re-review of head bd05823b7d904083c497bc943a4df5478b7321c1 (merge of main; the PR's own diff is still 6 files).

Commands executed locally:

  • git diff --stat origin/main...HEAD: CMakeLists.txt, docs/experiments.md, d3d12_capture.inl, d3d12_draw.inl, d3d12_xs_device.cpp, tests/startup_indirect_draw_indexed.cpp
  • python3 tests/docs_links_check.py: pass (18 files, 435 links)
  • python3 tests/bidi_controls_check.py: pass
  • git diff --check origin/main...HEAD: clean
  • python3 x2w_pipe.py win2025 2266 --targets startup_indirect_draw_indexed --regex startup_indirect_translated_indexed (WARP, dev + release /O2): build OK, exit 0. 5 of 10 tests pass in both presets (the WARP ones, including the alias and alias_off cases). The 5 _hardware variants skip on capability and are not counted as passes.

Previous P2s:

  • CI Python failure (TypeError: 'NoneType' object is not an iterator): RESOLVED. "Run platform-independent Python checks on Linux" passes on this head. "Assemble and translate gfx1013 fixtures" and "Build and test on Windows" were still pending when I checked.
  • Guard coverage (placed_buffer_range(..., aliases_only) considers only Placement::aliased_buffer neighbours): STILL OPEN, now reduced to a doc/test gap. The docs now state that a page with a registered GPU alias is refused, which matches the code. A non-aliased placement overlapping the page (for example a texture) is still neither refused nor tested. Please document that limit or add a case.

Findings on this head:

  • P1: none.
  • P2: the guard coverage item above.
  • nit: the 64-entry static pages table never frees entries. A full table silently refuses. A counter or log line would make it visible (documented as a limit).
  • Not done: no mutation run. The new logic needs Windows to execute and I did not queue extra runs. By static read, alias_no_heap, alias_overlaps, alias_cross_page and alias_off each map to a distinct early return in indirect_address_alias.

Opt-in route, neutral title, no clean-room concerns.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6055396730 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2266#pullrequestreview-6055396730). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T09:57:50Z. **Review:** COMMENTED --- Re-review of head `bd05823b7d904083c497bc943a4df5478b7321c1` (merge of main; the PR's own diff is still 6 files). Commands executed locally: - `git diff --stat origin/main...HEAD`: CMakeLists.txt, docs/experiments.md, d3d12_capture.inl, d3d12_draw.inl, d3d12_xs_device.cpp, tests/startup_indirect_draw_indexed.cpp - `python3 tests/docs_links_check.py`: pass (18 files, 435 links) - `python3 tests/bidi_controls_check.py`: pass - `git diff --check origin/main...HEAD`: clean - `python3 x2w_pipe.py win2025 2266 --targets startup_indirect_draw_indexed --regex startup_indirect_translated_indexed` (WARP, dev + release /O2): build OK, exit 0. 5 of 10 tests pass in both presets (the WARP ones, including the alias and alias_off cases). The 5 `_hardware` variants skip on capability and are not counted as passes. Previous P2s: - CI Python failure (`TypeError: 'NoneType' object is not an iterator`): RESOLVED. "Run platform-independent Python checks on Linux" passes on this head. "Assemble and translate gfx1013 fixtures" and "Build and test on Windows" were still pending when I checked. - Guard coverage (`placed_buffer_range(..., aliases_only)` considers only `Placement::aliased_buffer` neighbours): STILL OPEN, now reduced to a doc/test gap. The docs now state that a page with a registered GPU alias is refused, which matches the code. A non-aliased placement overlapping the page (for example a texture) is still neither refused nor tested. Please document that limit or add a case. Findings on this head: - P1: none. - P2: the guard coverage item above. - nit: the 64-entry static `pages` table never frees entries. A full table silently refuses. A counter or log line would make it visible (documented as a limit). - Not done: no mutation run. The new logic needs Windows to execute and I did not queue extra runs. By static read, `alias_no_heap`, `alias_overlaps`, `alias_cross_page` and `alias_off` each map to a distinct early return in `indirect_address_alias`. Opt-in route, neutral title, no clean-room concerns. AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-25 11:02:14 +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!2258
No description provided.