gpu: lower translated indexed indirect rectangle lists #2251

Merged
R0Y00 merged 6 commits from upstream-pr/2259 into main 2026-11-25 08:51:48 +00:00
R0Y00 commented 2026-11-25 08:27:53 +00:00 (Migrated from github.com)

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


Refs #1759 and #1999. Stacked on #2252. #2173 covers the non-indexed command.

Allow topology 0x11 for the translated single-record indexed indirect route. The existing GPU validator checks the original index and argument ranges and supplies the base vertex. A resource-free geometry shader runs after the translated vertex shader, finds the shared corner, and emits two triangles in the original winding. It reconstructs float interpolants for the fourth corner and uses the first original vertex's flat values. Desktop rasterization applies the existing clip volume and scissor.

The geometry shader accepts finite positions with a common positive clip-space w and three distinct, axis-aligned corners. Other shapes emit no geometry. It supports the startup translator's SV_Position, float PARAM and unsigned flat FPARAM linkage and refuses other signatures. Direct draws and native indirect routes retain their existing topology handling.

Head 89ff1960 on #2252 head ab83bffd. Windows build 26200.9974, Release MSVC 19.51.36244.0, debug layer enabled on WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656.

cmake --build --preset release --target startup_indirect_draw_indexed rectlist_draw_check --parallel 3
ctest --preset release --no-tests=error -R '^startup_indirect_(translated_indexed(_rect)?|translated_draw|draw_indexed|copy_provenance(_off)?|mesh(_console|_amplified)?)_(warp|hardware)$|^rectlist_(draw_(warp|hardware)|topology)$' --output-on-failure
python -B tests/docs_links_check.py

21/21 CTests passed with zero skips. The new R16 and R32 cases check permuted indices, nonzero start and base, both corner orders, decoded half-float UVs, flat values, clipped/scissored pixels and all original GPU argument words. Bad indices, a trailing incomplete rectangle, varying w and non-rectangle corners leave all pixels clear. Replacing the DLL with the #2252 base gave a topology refusal and a black first expected pixel on both adapters.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6600351545 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2259). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-25T08:27:53Z. --- Refs #1759 and #1999. Stacked on #2252. #2173 covers the non-indexed command. Allow topology 0x11 for the translated single-record indexed indirect route. The existing GPU validator checks the original index and argument ranges and supplies the base vertex. A resource-free geometry shader runs after the translated vertex shader, finds the shared corner, and emits two triangles in the original winding. It reconstructs float interpolants for the fourth corner and uses the first original vertex's flat values. Desktop rasterization applies the existing clip volume and scissor. The geometry shader accepts finite positions with a common positive clip-space w and three distinct, axis-aligned corners. Other shapes emit no geometry. It supports the startup translator's SV_Position, float PARAM and unsigned flat FPARAM linkage and refuses other signatures. Direct draws and native indirect routes retain their existing topology handling. Head `89ff1960` on #2252 head `ab83bffd`. Windows build 26200.9974, Release MSVC 19.51.36244.0, debug layer enabled on WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656. ```powershell cmake --build --preset release --target startup_indirect_draw_indexed rectlist_draw_check --parallel 3 ctest --preset release --no-tests=error -R '^startup_indirect_(translated_indexed(_rect)?|translated_draw|draw_indexed|copy_provenance(_off)?|mesh(_console|_amplified)?)_(warp|hardware)$|^rectlist_(draw_(warp|hardware)|topology)$' --output-on-failure python -B tests/docs_links_check.py ``` 21/21 CTests passed with zero skips. The new R16 and R32 cases check permuted indices, nonzero start and base, both corner orders, decoded half-float UVs, flat values, clipped/scissored pixels and all original GPU argument words. Bad indices, a trailing incomplete rectangle, varying w and non-rectangle corners leave all pixels clear. Replacing the DLL with the #2252 base gave a topology refusal and a black first expected pixel on both adapters.
tedin7 commented 2026-11-25 08:31:37 +00:00 (Migrated from github.com)

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

Review: COMMENTED


Review of head 89ff1960ea1cb7e40ab408d53bf30db626d1d100 (comment only, no approval).

Scope check

  • Diff vs origin/main also carries the stacked base (#2252: GPU validator + translated indexed route). Rectangle-list part is indexed_rect_geometry.h, the indexed_rect PSO key/GS in d3d12_draw.inl, and the topology 0x11 gate in d3d12_xs_device.cpp.
  • Title is neutral. Mergeable. No CI checks are reported on the branch.

Logic read-through

  • Geometry shader: the corner is the vertex sharing x with one neighbour and y with the other. The fourth corner is a + b - corner. Winding is kept: (v0,v1,v2) is the cycle (corner,a,b), and (a,fourth,b) has the same orientation. OK.
  • Common positive w is required, so linear reconstruction of the PARAM interpolants is exact. Non-finite or non-axis-aligned input emits nothing.
  • Signature handling refuses anything outside SV_Position / PARAM float / FPARAM uint, and checks that the PS inputs are covered by the VS outputs. OK.
  • The guard requires args.x % 3 == 0, so each triangle is one rect. Index range, base vertex overflow and start_instance are checked on the GPU. Scratch buffers are held on the allocator and cleared on reset. OK.

Findings

  • P1: none.
  • P2: none.
  • nit (indexed_rect_geometry.h, flat += lines): flat values come from v[0], the first emitted vertex. This matches the PR text, but a test that makes flat values differ per vertex (not only per draw) would pin the rule. Please check that translated-indexed-rect does this.
  • nit (d3d12_draw.inl, geometry compile failure path): the log is emitted once per translation, and later draws return nullptr silently. That is fine, but the refusal reason shown to the guest-side counters is generic.

Commands executed locally (Linux)

  • git diff --stat origin/main...HEAD: 7 files, +619/-61.
  • python3 tests/docs_links_check.py: Checked 18 Markdown files and 428 links.
  • python3 tests/bidi_controls_check.py: no bidirectional controls.
  • git diff --check origin/main...HEAD: clean.

Windows verification

  • python3 x2w_pipe.py win2025 2259 --targets startup_indirect_draw_indexed --regex '^startup_indirect_(translated_indexed(_rect)?|draw_indexed)_warp$' --skip-release
  • Result: dev build OK. 3/3 WARP tests passed (startup_indirect_translated_indexed_warp, startup_indirect_translated_indexed_rect_warp, startup_indirect_draw_indexed_warp).
  • Not run: the release preset and the hardware GPU variants (the PR body reports them).

Mutation

  • No mutation was run. The test needs the Windows build, which I did not edit remotely. I judged the logic by reading it. A useful mutation for the author: swap a/b in the second triangle. The test should then fail on winding or coverage.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6054170925 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2259#pullrequestreview-6054170925). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T08:31:37Z. **Review:** COMMENTED --- Review of head `89ff1960ea1cb7e40ab408d53bf30db626d1d100` (comment only, no approval). **Scope check** - Diff vs `origin/main` also carries the stacked base (#2252: GPU validator + translated indexed route). Rectangle-list part is `indexed_rect_geometry.h`, the `indexed_rect` PSO key/GS in `d3d12_draw.inl`, and the topology 0x11 gate in `d3d12_xs_device.cpp`. - Title is neutral. Mergeable. No CI checks are reported on the branch. **Logic read-through** - Geometry shader: the corner is the vertex sharing x with one neighbour and y with the other. The fourth corner is `a + b - corner`. Winding is kept: `(v0,v1,v2)` is the cycle `(corner,a,b)`, and `(a,fourth,b)` has the same orientation. OK. - Common positive `w` is required, so linear reconstruction of the `PARAM` interpolants is exact. Non-finite or non-axis-aligned input emits nothing. - Signature handling refuses anything outside `SV_Position` / `PARAM` float / `FPARAM` uint, and checks that the PS inputs are covered by the VS outputs. OK. - The guard requires `args.x % 3 == 0`, so each triangle is one rect. Index range, base vertex overflow and `start_instance` are checked on the GPU. Scratch buffers are held on the allocator and cleared on reset. OK. **Findings** - P1: none. - P2: none. - nit (`indexed_rect_geometry.h`, `flat +=` lines): flat values come from `v[0]`, the first emitted vertex. This matches the PR text, but a test that makes flat values differ per vertex (not only per draw) would pin the rule. Please check that `translated-indexed-rect` does this. - nit (`d3d12_draw.inl`, geometry compile failure path): the log is emitted once per translation, and later draws return `nullptr` silently. That is fine, but the refusal reason shown to the guest-side counters is generic. **Commands executed locally (Linux)** - `git diff --stat origin/main...HEAD`: 7 files, +619/-61. - `python3 tests/docs_links_check.py`: `Checked 18 Markdown files and 428 links.` - `python3 tests/bidi_controls_check.py`: `no bidirectional controls.` - `git diff --check origin/main...HEAD`: clean. **Windows verification** - `python3 x2w_pipe.py win2025 2259 --targets startup_indirect_draw_indexed --regex '^startup_indirect_(translated_indexed(_rect)?|draw_indexed)_warp$' --skip-release` - Result: dev build OK. 3/3 WARP tests passed (`startup_indirect_translated_indexed_warp`, `startup_indirect_translated_indexed_rect_warp`, `startup_indirect_draw_indexed_warp`). - Not run: the release preset and the hardware GPU variants (the PR body reports them). **Mutation** - No mutation was run. The test needs the Windows build, which I did not edit remotely. I judged the logic by reading it. A useful mutation for the author: swap `a`/`b` in the second triangle. The test should then fail on winding or coverage. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-25 08:46:36 +00:00 (Migrated from github.com)

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

Review: COMMENTED


Re-review of head 7faa82ccaf1d48e835c5bf14359befc2f39bfb61 (previous review was at 89ff1960).

What changed: the new head merges main and drops the already-merged prerequisites. git diff --stat origin/main...HEAD is now 6 files, +245/-24: CMakeLists.txt, docs/experiments.md, d3d12_draw.inl, d3d12_xs_device.cpp, new indexed_rect_geometry.h, tests/startup_indirect_draw_indexed.cpp. The rectangle-list slice is isolated. No logic change in the geometry shader or the draw path beyond the rebase.

Re-checked in the new diff

  • indexed_rect = rect && indexed && indirect: only the GPU-written indexed indirect path opens the rectangle topology. Direct indexed rectangle draws are still refused.
  • The pipeline cache key now includes indexed_rect, so the GS and non-GS PSOs cannot collide.
  • A failed GS compile is cached through indexed_rect_geometry_attempted, gives a refusal string, and does not retry per draw.
  • The rect user-data is 0 on this path, as intended. The VS keeps the original index and base vertex.
  • GS corner detection and the fourth vertex a + b - corner are correct. Triangle (a, fourth, b) keeps the winding of (corner, a, b). Flat FPARAM comes from vertex 0. Non-finite positions, a non-common w, or a non-axis-aligned shape emit nothing, and the tests cover these (rect_bad_w, rect_bad_shape, rect_bad_index, rect_bad_count).
  • The test is a real D3D12 GPU readback with expected pixel values computed from the geometry. A scissor at x=1 covers the clipped-rectangle and scissor interaction.

Commands run locally

  • git diff --check origin/main...HEAD: clean
  • python3 tests/docs_links_check.py: pass (18 files, 432 links)
  • python3 tests/bidi_controls_check.py: pass
  • Windows Server 2025 (MSVC 14.44, D3D12 WARP) at 7faa82cc: python3 x2w_pipe.py win2025 2259 --targets startup_indirect_draw_indexed --regex '^startup_indirect_(translated_indexed(_rect)?|mesh|draw)'
    • dev and release: all WARP tests pass, including startup_indirect_translated_indexed_rect_warp and startup_indirect_translated_indexed_warp. The *_hardware variants skip on this VM (capability skip, not a pass).
  • GitHub shows no CI checks on this branch. Mergeable: yes. Title and body are neutral.

Mutation: not run. The change is D3D12/C++ only, so I can't build it on Linux, and I did not rebuild a mutated GS on Windows. Please note that the rect_bad_* cases give negative-control coverage for the shape and w guards, but I have not shown that they fail when the guards are removed.

Findings

  • P1: none
  • P2: none
  • nit: compile_indexed_rect_geometry returns E_INVALIDARG for every unsupported signature, and the log line only prints the HRESULT. A short reason string (which semantic or mask was rejected) would make field diagnosis easier.
  • nit: the PR is Ready, and GitHub shows no CI checks to back the Windows result above.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6054357240 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2259#pullrequestreview-6054357240). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T08:46:36Z. **Review:** COMMENTED --- Re-review of head `7faa82ccaf1d48e835c5bf14359befc2f39bfb61` (previous review was at `89ff1960`). **What changed:** the new head merges main and drops the already-merged prerequisites. `git diff --stat origin/main...HEAD` is now 6 files, +245/-24: CMakeLists.txt, docs/experiments.md, `d3d12_draw.inl`, `d3d12_xs_device.cpp`, new `indexed_rect_geometry.h`, `tests/startup_indirect_draw_indexed.cpp`. The rectangle-list slice is isolated. No logic change in the geometry shader or the draw path beyond the rebase. **Re-checked in the new diff** - `indexed_rect = rect && indexed && indirect`: only the GPU-written indexed indirect path opens the rectangle topology. Direct indexed rectangle draws are still refused. - The pipeline cache key now includes `indexed_rect`, so the GS and non-GS PSOs cannot collide. - A failed GS compile is cached through `indexed_rect_geometry_attempted`, gives a refusal string, and does not retry per draw. - The `rect` user-data is 0 on this path, as intended. The VS keeps the original index and base vertex. - GS corner detection and the fourth vertex `a + b - corner` are correct. Triangle `(a, fourth, b)` keeps the winding of `(corner, a, b)`. Flat `FPARAM` comes from vertex 0. Non-finite positions, a non-common `w`, or a non-axis-aligned shape emit nothing, and the tests cover these (`rect_bad_w`, `rect_bad_shape`, `rect_bad_index`, `rect_bad_count`). - The test is a real D3D12 GPU readback with expected pixel values computed from the geometry. A scissor at x=1 covers the clipped-rectangle and scissor interaction. **Commands run locally** - `git diff --check origin/main...HEAD`: clean - `python3 tests/docs_links_check.py`: pass (18 files, 432 links) - `python3 tests/bidi_controls_check.py`: pass - Windows Server 2025 (MSVC 14.44, D3D12 WARP) at `7faa82cc`: `python3 x2w_pipe.py win2025 2259 --targets startup_indirect_draw_indexed --regex '^startup_indirect_(translated_indexed(_rect)?|mesh|draw)'` - dev and release: all WARP tests pass, including `startup_indirect_translated_indexed_rect_warp` and `startup_indirect_translated_indexed_warp`. The `*_hardware` variants skip on this VM (capability skip, not a pass). - GitHub shows no CI checks on this branch. Mergeable: yes. Title and body are neutral. **Mutation:** not run. The change is D3D12/C++ only, so I can't build it on Linux, and I did not rebuild a mutated GS on Windows. Please note that the `rect_bad_*` cases give negative-control coverage for the shape and `w` guards, but I have not shown that they fail when the guards are removed. **Findings** - P1: none - P2: none - nit: `compile_indexed_rect_geometry` returns `E_INVALIDARG` for every unsupported signature, and the log line only prints the HRESULT. A short reason string (which semantic or mask was rejected) would make field diagnosis easier. - nit: the PR is Ready, and GitHub shows no CI checks to back the Windows result above. AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-25 09:04:05 +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!2251
No description provided.