gpu: bind recording upload indices for translated indirect draws #2254

Merged
R0Y00 merged 2 commits from upstream-pr/2262 into main 2026-11-25 09:06:55 +00:00
R0Y00 commented 2026-11-25 08:41:16 +00:00 (Migrated from github.com)

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


Refs #1759. Follows #2252.

The translated indexed indirect route accepts an index view fully contained in a slot 148 upload allocation of the current recording. The compute validator and input assembler use the exact same GPU range in GENERIC_READ. The upload lives through the existing recording and fence ownership. The caller completes CPU writes before submission and keeps the bytes stable through execution.

The upload view must have a DWORD-aligned offset and size so an R16 load stays within its owned range while fetching a packed word. A different recording, incomplete coverage, overlapping placed buffers and readable addresses without GPU backing are refused.

At d0b31a26 on 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)?|translated_draw|draw_indexed|copy_provenance(_off)?|mesh(_console|_amplified)?)_(warp|hardware)$' --output-on-failure

18/18 passed, zero skips. The source-built R16 case supplies an eight-byte index view at a nonzero offset, with invalid indices during recording and a final write before submission. The R32 case has different offsets and a nonzero base vertex. Both positive cases paint the expected half, with exact readback of all pixels and protected argument words. Cross-allocation, foreign-recording, half-word-aligned and unowned CPU views leave the target clear. The earlier placed-only shim refused the same eight-byte positive control on both adapters.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6600557892 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2262). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-25T08:41:16Z. --- Refs #1759. Follows #2252. The translated indexed indirect route accepts an index view fully contained in a slot 148 upload allocation of the current recording. The compute validator and input assembler use the exact same GPU range in GENERIC_READ. The upload lives through the existing recording and fence ownership. The caller completes CPU writes before submission and keeps the bytes stable through execution. The upload view must have a DWORD-aligned offset and size so an R16 load stays within its owned range while fetching a packed word. A different recording, incomplete coverage, overlapping placed buffers and readable addresses without GPU backing are refused. At `d0b31a26` on 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)?|translated_draw|draw_indexed|copy_provenance(_off)?|mesh(_console|_amplified)?)_(warp|hardware)$' --output-on-failure ``` 18/18 passed, zero skips. The source-built R16 case supplies an eight-byte index view at a nonzero offset, with invalid indices during recording and a final write before submission. The R32 case has different offsets and a nonzero base vertex. Both positive cases paint the expected half, with exact readback of all pixels and protected argument words. Cross-allocation, foreign-recording, half-word-aligned and unowned CPU views leave the target clear. The earlier placed-only shim refused the same eight-byte positive control on both adapters.
tedin7 commented 2026-11-25 08:44:55 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T08:44:55Z.

Review: COMMENTED


Review at head d0b31a2683a4fb746e43baa8bc8ee97a50f9b69f.

Scope read: git diff --stat origin/main...HEAD (5 files, +102/-20), then the src/startup_stubs/d3d12_xs_device.cpp and d3d12_draw.inl hunks, CMakeLists.txt test registration and the docs/experiments.md section.

Logic checks

  • The placed-buffer path is unchanged in behaviour. indices.reject is still refused, now with a clearer message. Placed owners without a real resource fall to the else branch, where !indices.owner makes the upload lookup return empty, so they are still refused.
  • The upload branch is gated on translated. The range must sit fully inside one allocation of the current open recording, through list_upload_range under the shared lock. Another recording or a partial cover therefore returns an empty allocation and is refused.
  • (upload.offset | view.SizeInBytes) & 3 refuses non-DWORD offsets and sizes. This matches the validator's 32-bit word loads for R16, so a packed half-word load cannot read a neighbouring allocation.
  • require_state is skipped for upload-backed indices in both places in validate_indexed_arguments. Upload-heap resources are fixed in GENERIC_READ, so a transition there would be invalid. Skipping it is correct. The indices != draw.argument comparison is unaffected.
  • The new CTest entry mirrors its sibling translated_indexed (timeout 60, skip code 77) and covers warp and hardware. The docs section matches the code.

Commands executed locally (Linux worktree)

  • python3 tests/docs_links_check.py: self-test passed, 18 Markdown files, 432 links.
  • python3 tests/bidi_controls_check.py: self-test passed, 1546 files, no bidirectional controls.
  • git diff --check origin/main...HEAD: clean.
  • gh pr checks: Linux Python checks and gfx1013 fixtures pass. Windows build and test was still pending when I looked. The /O2 job was skipping.

Not done

  • The touched code is Windows-only D3D12 C++, so I could not build or run it on Linux. I did no source mutation and no Windows WARP run. I rely on the author's reported 18/18 and on the pending Windows CI job.

Findings

  • P1: none.
  • P2: none.
  • Nit: the refusal reason at the upload branch reads "no unique placed or current recording upload buffer", which also fires for a non-translated route. This is harmless but slightly misleading. It could say that upload-backed views need the translated route.
  • Nit: a negative test for a DWORD-misaligned upload view (offset or size not a multiple of 4) is not named in the PR text. The code refuses it, so a test would lock the behaviour in. Please say whether the test covers it.

Verdict: no blocking issues found. Please wait for the Windows CI job to go green before marking this ready.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6054337063 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2262#pullrequestreview-6054337063). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T08:44:55Z. **Review:** COMMENTED --- Review at head `d0b31a2683a4fb746e43baa8bc8ee97a50f9b69f`. Scope read: `git diff --stat origin/main...HEAD` (5 files, +102/-20), then the `src/startup_stubs/d3d12_xs_device.cpp` and `d3d12_draw.inl` hunks, `CMakeLists.txt` test registration and the `docs/experiments.md` section. Logic checks - The placed-buffer path is unchanged in behaviour. `indices.reject` is still refused, now with a clearer message. Placed owners without a real resource fall to the else branch, where `!indices.owner` makes the upload lookup return empty, so they are still refused. - The upload branch is gated on `translated`. The range must sit fully inside one allocation of the current open recording, through `list_upload_range` under the shared lock. Another recording or a partial cover therefore returns an empty allocation and is refused. - `(upload.offset | view.SizeInBytes) & 3` refuses non-DWORD offsets and sizes. This matches the validator's 32-bit word loads for R16, so a packed half-word load cannot read a neighbouring allocation. - `require_state` is skipped for upload-backed indices in both places in `validate_indexed_arguments`. Upload-heap resources are fixed in GENERIC_READ, so a transition there would be invalid. Skipping it is correct. The `indices != draw.argument` comparison is unaffected. - The new CTest entry mirrors its sibling `translated_indexed` (timeout 60, skip code 77) and covers warp and hardware. The docs section matches the code. Commands executed locally (Linux worktree) - `python3 tests/docs_links_check.py`: self-test passed, 18 Markdown files, 432 links. - `python3 tests/bidi_controls_check.py`: self-test passed, 1546 files, no bidirectional controls. - `git diff --check origin/main...HEAD`: clean. - `gh pr checks`: Linux Python checks and gfx1013 fixtures pass. Windows build and test was still pending when I looked. The /O2 job was skipping. Not done - The touched code is Windows-only D3D12 C++, so I could not build or run it on Linux. I did no source mutation and no Windows WARP run. I rely on the author's reported 18/18 and on the pending Windows CI job. Findings - P1: none. - P2: none. - Nit: the refusal reason at the upload branch reads "no unique placed or current recording upload buffer", which also fires for a non-translated route. This is harmless but slightly misleading. It could say that upload-backed views need the translated route. - Nit: a negative test for a DWORD-misaligned upload view (offset or size not a multiple of 4) is not named in the PR text. The code refuses it, so a test would lock the behaviour in. Please say whether the test covers it. Verdict: no blocking issues found. Please wait for the Windows CI job to go green before marking this ready. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-25 09:04:21 +00:00 (Migrated from github.com)

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

Review: COMMENTED


Re-review at head 18323d39054d190073cbb3c5141748b3e984cb37 (previous review was at d0b31a26).

Scope read: git diff --stat origin/main...HEAD (still 5 files, +102/-20), then the PR-only hunks of d3d12_xs_device.cpp, d3d12_draw.inl, CMakeLists.txt and tests/startup_indirect_draw_indexed.cpp. The new head is a merge of main plus the PR; I looked at how the merge resolved against the rectangle path that landed on main.

What changed and how it checks out

  • Merge resolution: the topology gate in list_execute_indirect keeps main's translated && indexed && topology == 0x11 rectangle allowance. The PR's upload branch sits only in the index-view lookup, so the two do not interfere. translated-indexed and translated-indexed-rect tests from main are intact, and the new translated-indexed-upload test is registered next to them (timeout 60, skip 77, warp and hardware).
  • Earlier nit about a DWORD-misaligned upload view is now covered: the test has index_upload_unaligned (R16 view starting at a half-word offset), plus index_upload_cross and index_upload_foreign (view from a different recording). All three are expected refusals.
  • require_state skips for upload-backed indices (!draw.indices.upload) are unchanged and still correct for GENERIC_READ upload heaps.
  • No P1 or P2 in the new merge content.

Commands executed locally (Linux worktree at this head)

  • python3 tests/docs_links_check.py: self-test passed, 18 Markdown files, 433 links.
  • python3 tests/bidi_controls_check.py: self-test passed, 1562 files, no bidirectional controls.
  • git diff --check origin/main...HEAD: clean.
  • git merge-tree --write-tree origin/main HEAD: merges cleanly.
  • gh pr checks 2262: Linux Python checks pass. gfx1013 fixtures and Windows build/test were still pending when I looked. The /O2 job was skipping.

Not done

  • The touched code is Windows-only D3D12 C++. I could not build it on Linux, so I did no source mutation and no Windows WARP run. I rely on the pending Windows CI job and the author's Win2025 results.

Findings

  • P1: none.
  • P2: none.
  • Nit (carried over): the refusal text "index view has no unique placed or current recording upload buffer" also fires on the non-translated route. Saying that upload-backed views need the translated route would be clearer.

Verdict: no blocking issues at this head. Please wait for the Windows CI job to go green before marking ready.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6054593022 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2262#pullrequestreview-6054593022). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T09:04:21Z. **Review:** COMMENTED --- Re-review at head `18323d39054d190073cbb3c5141748b3e984cb37` (previous review was at `d0b31a26`). Scope read: `git diff --stat origin/main...HEAD` (still 5 files, +102/-20), then the PR-only hunks of `d3d12_xs_device.cpp`, `d3d12_draw.inl`, `CMakeLists.txt` and `tests/startup_indirect_draw_indexed.cpp`. The new head is a merge of main plus the PR; I looked at how the merge resolved against the rectangle path that landed on main. What changed and how it checks out - Merge resolution: the topology gate in `list_execute_indirect` keeps main's `translated && indexed && topology == 0x11` rectangle allowance. The PR's upload branch sits only in the index-view lookup, so the two do not interfere. `translated-indexed` and `translated-indexed-rect` tests from main are intact, and the new `translated-indexed-upload` test is registered next to them (timeout 60, skip 77, warp and hardware). - Earlier nit about a DWORD-misaligned upload view is now covered: the test has `index_upload_unaligned` (R16 view starting at a half-word offset), plus `index_upload_cross` and `index_upload_foreign` (view from a different recording). All three are expected refusals. - `require_state` skips for upload-backed indices (`!draw.indices.upload`) are unchanged and still correct for GENERIC_READ upload heaps. - No P1 or P2 in the new merge content. Commands executed locally (Linux worktree at this head) - `python3 tests/docs_links_check.py`: self-test passed, 18 Markdown files, 433 links. - `python3 tests/bidi_controls_check.py`: self-test passed, 1562 files, no bidirectional controls. - `git diff --check origin/main...HEAD`: clean. - `git merge-tree --write-tree origin/main HEAD`: merges cleanly. - `gh pr checks 2262`: Linux Python checks pass. gfx1013 fixtures and Windows build/test were still pending when I looked. The /O2 job was skipping. Not done - The touched code is Windows-only D3D12 C++. I could not build it on Linux, so I did no source mutation and no Windows WARP run. I rely on the pending Windows CI job and the author's Win2025 results. Findings - P1: none. - P2: none. - Nit (carried over): the refusal text "index view has no unique placed or current recording upload buffer" also fires on the non-translated route. Saying that upload-backed views need the translated route would be clearer. Verdict: no blocking issues at this head. Please wait for the Windows CI job to go green before marking ready. AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-25 10:05:20 +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!2254
No description provided.