gpu: read live aliased indices in direct translated draws #2716

Merged
R0Y00 merged 3 commits from upstream-pr/2724 into main 2026-11-26 04:12:25 +00:00
R0Y00 commented 2026-11-26 03:49:44 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-26T03:49:44Z.


Refs #2714. Uses the source-built reproduction published in that issue.

On the same Windows build and adapters, the current direct draw matched the two unchanged controls but missed all 32 pixels in each late-write case. If the index range fits one live placed alias and the translation has no vertex-stream SRV that needs slicing, keep the desktop index resource with the recording and use its GPU view. The existing snapshot remains paired with any vertex range derived from it, so command lists cannot read a newer index against an older sliced vertex stream.

Windows Release passed 10/10 related CTests on WARP and RTX 4060 Laptop (32.0.16.1656) without skips. The new test covers visible and clipped controls, both directions of the pre-submit rewrite, and a 32-bit view with a leading decoy index. All 32 pixels match in each case with the debug layer enabled. Copied descriptors, stream fetch, translated indirect targets and pixel UAVs passed in the same tree.

cmake --build --preset release --target startup_stream_consumer startup_indirect_draw_indexed d3d12_xs_device_obj
ctest --preset release --no-tests=error -R '^startup_(direct_index_late_write|copied_vertex_srv|stream_fetch|indirect_translated_targets|pixel_uav)_(warp|hardware)$' -V

This covers the live-alias slice of the source-built report. The recorded executable trace does not establish that its clipped draw used this sequence.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6619090467 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2724). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-26T03:49:44Z. --- Refs #2714. Uses the source-built reproduction published in that issue. On the same Windows build and adapters, the current direct draw matched the two unchanged controls but missed all 32 pixels in each late-write case. If the index range fits one live placed alias and the translation has no vertex-stream SRV that needs slicing, keep the desktop index resource with the recording and use its GPU view. The existing snapshot remains paired with any vertex range derived from it, so command lists cannot read a newer index against an older sliced vertex stream. Windows Release passed 10/10 related CTests on WARP and RTX 4060 Laptop (32.0.16.1656) without skips. The new test covers visible and clipped controls, both directions of the pre-submit rewrite, and a 32-bit view with a leading decoy index. All 32 pixels match in each case with the debug layer enabled. Copied descriptors, stream fetch, translated indirect targets and pixel UAVs passed in the same tree. ```powershell cmake --build --preset release --target startup_stream_consumer startup_indirect_draw_indexed d3d12_xs_device_obj ctest --preset release --no-tests=error -R '^startup_(direct_index_late_write|copied_vertex_srv|stream_fetch|indirect_translated_targets|pixel_uav)_(warp|hardware)$' -V ``` This covers the live-alias slice of the source-built report. The recorded executable trace does not establish that its clipped draw used this sequence.
tedin7 commented 2026-11-26 04:12:07 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T04:12:07Z.

Review: COMMENTED


Win2025 WARP receipt for head 602e9189 after updating with main (3 commits).

Review of this head (code and fixture tests only; no executable or game results claimed):

  • src/startup_stubs/d3d12_draw.inl: the live alias is used only when the index range is aligned, inside the view, fits one placed alias, the owner is still alive, and no vertex-stream SRV needs the recording-time scan. All other draws keep the snapshot path, so a sliced vertex range is never paired with a newer index read.
  • tests/startup_direct_index_late_write_check.py + startup_stream_draw.cpp: unchanged controls, both directions of a pre-submit rewrite, and a 32-bit view with a leading decoy index. All 32 pixels are compared after the fence.
  • Linux: git diff --check origin/main...HEAD clean, tests/docs_links_check.py and tests/bidi_controls_check.py pass. PR CI is green on this head.
  • Not run by me: a source mutation of the live-alias branch (needs a Windows build). The PR body states the late-write cases fail without the change.
  • This is a fixture-level review. The merge of anything claiming executable behavior stays with the maintainers.

Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP):

  • Debug (--preset dev): ctest --preset dev -R '^startup_(direct_index_late_write|copied_vertex_srv|stream_fetch|indirect_translated_targets|pixel_uav|address_buffer_srv|frame_copy)_(warp)$' --no-tests=error --output-on-failure: 7/7 passed.
  • Release /O2 (--preset release): same regex: 7/7 passed.
  • Build targets: d3d12_xs_device_obj d3d12_xs_shim startup_stream_consumer startup_indirect_draw_indexed.
  • A first run without startup_indirect_draw_indexed in the targets failed startup_indirect_translated_targets_warp (fixture not built); with the target it passes.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6068447522 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2724#pullrequestreview-6068447522). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T04:12:07Z. **Review:** COMMENTED --- Win2025 WARP receipt for head 602e9189 after updating with main (3 commits). Review of this head (code and fixture tests only; no executable or game results claimed): - `src/startup_stubs/d3d12_draw.inl`: the live alias is used only when the index range is aligned, inside the view, fits one placed alias, the owner is still alive, and no vertex-stream SRV needs the recording-time scan. All other draws keep the snapshot path, so a sliced vertex range is never paired with a newer index read. - `tests/startup_direct_index_late_write_check.py` + `startup_stream_draw.cpp`: unchanged controls, both directions of a pre-submit rewrite, and a 32-bit view with a leading decoy index. All 32 pixels are compared after the fence. - Linux: `git diff --check origin/main...HEAD` clean, `tests/docs_links_check.py` and `tests/bidi_controls_check.py` pass. PR CI is green on this head. - Not run by me: a source mutation of the live-alias branch (needs a Windows build). The PR body states the late-write cases fail without the change. - This is a fixture-level review. The merge of anything claiming executable behavior stays with the maintainers. Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP): - Debug (`--preset dev`): `ctest --preset dev -R '^startup_(direct_index_late_write|copied_vertex_srv|stream_fetch|indirect_translated_targets|pixel_uav|address_buffer_srv|frame_copy)_(warp)$' --no-tests=error --output-on-failure`: 7/7 passed. - Release /O2 (`--preset release`): same regex: 7/7 passed. - Build targets: `d3d12_xs_device_obj d3d12_xs_shim startup_stream_consumer startup_indirect_draw_indexed`. - A first run without `startup_indirect_draw_indexed` in the targets failed `startup_indirect_translated_targets_warp` (fixture not built); with the target it passes. AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-26 05:02:17 +00:00
tedin7 commented 2026-11-26 05:02:24 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T04:12:08Z.


Win2025 WARP receipt for head 602e9189 after updating with main (3 commits).

Review of this head (code and fixture tests only; no executable or game results claimed):

  • src/startup_stubs/d3d12_draw.inl: the live alias is used only when the index range is aligned, inside the view, fits one placed alias, the owner is still alive, and no vertex-stream SRV needs the recording-time scan. All other draws keep the snapshot path, so a sliced vertex range is never paired with a newer index read.
  • tests/startup_direct_index_late_write_check.py + startup_stream_draw.cpp: unchanged controls, both directions of a pre-submit rewrite, and a 32-bit view with a leading decoy index. All 32 pixels are compared after the fence.
  • Linux: git diff --check origin/main...HEAD clean, tests/docs_links_check.py and tests/bidi_controls_check.py pass. PR CI is green on this head.
  • Not run by me: a source mutation of the live-alias branch (needs a Windows build). The PR body states the late-write cases fail without the change.
  • This is a fixture-level review. The merge of anything claiming executable behavior stays with the maintainers.

Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP):

  • Debug (--preset dev): ctest --preset dev -R '^startup_(direct_index_late_write|copied_vertex_srv|stream_fetch|indirect_translated_targets|pixel_uav|address_buffer_srv|frame_copy)_(warp)$' --no-tests=error --output-on-failure: 7/7 passed.
  • Release /O2 (--preset release): same regex: 7/7 passed.
  • Build targets: d3d12_xs_device_obj d3d12_xs_shim startup_stream_consumer startup_indirect_draw_indexed.
  • A first run without startup_indirect_draw_indexed in the targets failed startup_indirect_translated_targets_warp (fixture not built); with the target it passes.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7182385309 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2724#issuecomment-7182385309). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T04:12:08Z. --- Win2025 WARP receipt for head 602e9189 after updating with main (3 commits). Review of this head (code and fixture tests only; no executable or game results claimed): - `src/startup_stubs/d3d12_draw.inl`: the live alias is used only when the index range is aligned, inside the view, fits one placed alias, the owner is still alive, and no vertex-stream SRV needs the recording-time scan. All other draws keep the snapshot path, so a sliced vertex range is never paired with a newer index read. - `tests/startup_direct_index_late_write_check.py` + `startup_stream_draw.cpp`: unchanged controls, both directions of a pre-submit rewrite, and a 32-bit view with a leading decoy index. All 32 pixels are compared after the fence. - Linux: `git diff --check origin/main...HEAD` clean, `tests/docs_links_check.py` and `tests/bidi_controls_check.py` pass. PR CI is green on this head. - Not run by me: a source mutation of the live-alias branch (needs a Windows build). The PR body states the late-write cases fail without the change. - This is a fixture-level review. The merge of anything claiming executable behavior stays with the maintainers. Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP): - Debug (`--preset dev`): `ctest --preset dev -R '^startup_(direct_index_late_write|copied_vertex_srv|stream_fetch|indirect_translated_targets|pixel_uav|address_buffer_srv|frame_copy)_(warp)$' --no-tests=error --output-on-failure`: 7/7 passed. - Release /O2 (`--preset release`): same regex: 7/7 passed. - Build targets: `d3d12_xs_device_obj d3d12_xs_shim startup_stream_consumer startup_indirect_draw_indexed`. - A first run without `startup_indirect_draw_indexed` in the targets failed `startup_indirect_translated_targets_warp` (fixture not built); with the target it passes. AI-assisted; commands listed were executed locally.
thepatrickworld commented 2026-11-26 05:02:25 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by thepatrickworld on 2026-11-26T04:17:20Z.


Post-merge receipt on 602e9189 (#2724), independent AMD RDNA 4 result: the neighbourhood passes on hardware, and reverting only d3d12_draw.inl makes late-visible fail. Not a code change; measurements only.

Environment

  • Windows build 10.0.26200.9974, UBR 0x26f6, DisplayVersion 25H2; the registry ProductName on this install still reads Windows 10 Pro.
  • MSVC 19.44.35230 (VCToolsVersion=14.44.35207); the DXC and FXC used are the ones under Windows Kits\10\bin\10.0.26100.0\x64\.
  • Adapter AMD Radeon RX 9070 XT, driver 32.0.32029.2010. The warp backend selects an adapter reported as Microsoft Basic Render Driver, driver 10.0.26100.9818.
  • Preset dev (CMAKE_BUILD_TYPE=Debug in CMakePresets.json). Every mode line reports debug layer unavailable, and with X2W_D3D12_DEBUG=1 the shim prints x2w-d3d12 debug layer: 0x887a002d (not installed?) — no API validation is involved below.
  • Measured head 602e9189 (Merge branch 'main' into codex/live-index-alias); the API reports base 562f7ddb on main for this PR. The PR was merged as feec219e while these runs were in progress, and 602e9189 is the head that was merged, so this is a receipt on what main now carries.

Commands

cmake --preset dev "-DINTAKE_PYTHON=<shared pe-env>/Scripts/python.exe"
cmake --build --preset dev --target startup_stream_consumer startup_indirect_draw_indexed d3d12_xs_device_obj
set "XBOX2WINDOWS_ADAPTER=AMD Radeon RX 9070 XT"
ctest --preset dev --no-tests=error -R "^startup_(direct_index_late_write|copied_vertex_srv|stream_fetch|indirect_translated_targets|pixel_uav|address_buffer_srv|frame_copy)_(warp|hardware)$" -V

The regex takes the five prefixes listed in the description plus address_buffer_srv and frame_copy, on both backends.

Observed

100% tests passed out of 14, 14 Passed lines and no ***Skipped or ***Failed line, Total Test time (real) = 24.88 sec. The same regex reduced to the five prefixes of the description gives 100% tests passed out of 10 in 20.79 sec. The hardware entry prints one line per mode:

1274: visible: 32 exact pixels, adapter=AMD Radeon RX 9070 XT driver=32.0.32029.2010, debug layer unavailable
1274: clipped: 32 exact pixels, adapter=AMD Radeon RX 9070 XT driver=32.0.32029.2010, debug layer unavailable
1274: late-visible: 32 exact pixels, adapter=AMD Radeon RX 9070 XT driver=32.0.32029.2010, debug layer unavailable
1274: late-clipped: 32 exact pixels, adapter=AMD Radeon RX 9070 XT driver=32.0.32029.2010, debug layer unavailable
1274: late-visible-r32: 32 exact pixels, adapter=AMD Radeon RX 9070 XT driver=32.0.32029.2010, debug layer unavailable

The warp entry prints the same five lines with adapter=Microsoft Basic Render Driver driver=10.0.26100.9818. In the hardware block one adapter= line before the modes also names Microsoft Basic Render Driver; the five lines that report each mode are the ones that name the AMD adapter. Three further runs of startup_direct_index_late_write_hardware each reported 100% tests passed out of 1.

Reverting only d3d12_draw.inl

The PR's test file and its tests/startup_stream_draw.cpp were kept; only src/startup_stubs/d3d12_draw.inl was restored to the base 562f7ddb (the file then differs from the head by 7 insertions(+), 32 deletions(-), and a findstr for live_index_resource on it returns nothing), then rebuilt. The shim banner in those logs reads build=602e9189-dirty, against build=602e9189 for the restored rebuild. Two lines of the resulting log, the second from its final summary:

AssertionError: late-visible: got 0000ffff0000ffff...0000ffff, expected 32 pixels of ff0000ff
0% tests passed, 2 tests failed out of 2

That assertion appears once per backend; both entries (1/2 for warp, 2/2 for hardware) are ***Failed. The message prints 32 four-byte groups, all 0000ffff, abbreviated above. That is the fixture's CLIPPED constant, the value the clipped control reads back, and the clear colour the record-time indices (3, 4, 5) leave behind. Both controls printed 32 exact pixels first.

The traceback stops in check() at line 47, after the guards at lines 41-44 (the slot133 ... aliased gpuva= line and the indexed(3, 1, start 0, base 0) ... -> drawn line). The pixel assertion does not print the child's stderr, so the line number only shows that those two guards were satisfied on the old path, not what they matched. Restoring the file and rebuilding returns 2/2 passed.

On this adapter, then, with the PR's fixture and the base draw file, late-visible reads back the record-time indices. That is the source mutation the receipt above lists as not run.

Binaries on the restored tree: startup_stream_consumer.exe 36B3F967DDB78B195D6372DBF51A8007F13C5030805D526C71BB3792F986E055, d3d12_xs.dll 8A94B7FFCB433C4CD432C306596F9242B4A9912663A811D4C37DCB4100A8A87E. The reverted run used a different d3d12_xs.dll, identified by its build=602e9189-dirty banner rather than by a separate hash.

Limits

  • The fixture raises on the first failing mode and each mode runs in its own process: in the reverted run only visible, clipped and late-visible executed, so late-clipped and late-visible-r32 were not compared against the old path. The causal statement above covers late-visible.
  • One machine, one adapter, Debug preset only; the release preset is not measured here.
  • No debug layer, so resource states and the require_state call on the live view are not validated.
  • The vertex-stream SRV guard (srv.source == 1) is not exercised: none of the five modes records a vertex-stream SRV (the vertex shader uses only SV_VertexID), so the new path is only seen on the branch where that guard is absent.
  • Draw shape is fixed: count=3, start in {0, 1}, base vertex 0, one index buffer, no indirect, R16_UINT in four modes and R32_UINT in one.
  • The fixture returns 77 when D3D12_FEATURE_EXISTING_HEAPS is unsupported; it is supported here, so no mode skipped.
  • No game or console trace is involved; each case is a 32-pixel readback of one render target.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7182462798 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2724#issuecomment-7182462798). Originally posted by [thepatrickworld](https://github.com/thepatrickworld) on 2026-11-26T04:17:20Z. --- **Post-merge receipt on `602e9189` (#2724), independent AMD RDNA 4 result: the neighbourhood passes on hardware, and reverting only `d3d12_draw.inl` makes `late-visible` fail.** Not a code change; measurements only. ### Environment - Windows build `10.0.26200.9974`, UBR `0x26f6`, `DisplayVersion` `25H2`; the registry `ProductName` on this install still reads `Windows 10 Pro`. - MSVC `19.44.35230` (`VCToolsVersion=14.44.35207`); the DXC and FXC used are the ones under `Windows Kits\10\bin\10.0.26100.0\x64\`. - Adapter `AMD Radeon RX 9070 XT`, driver `32.0.32029.2010`. The `warp` backend selects an adapter reported as `Microsoft Basic Render Driver`, driver `10.0.26100.9818`. - Preset `dev` (`CMAKE_BUILD_TYPE=Debug` in `CMakePresets.json`). Every mode line reports `debug layer unavailable`, and with `X2W_D3D12_DEBUG=1` the shim prints `x2w-d3d12 debug layer: 0x887a002d (not installed?)` — no API validation is involved below. - Measured head `602e9189` (`Merge branch 'main' into codex/live-index-alias`); the API reports base `562f7ddb` on `main` for this PR. The PR was merged as `feec219e` while these runs were in progress, and `602e9189` is the head that was merged, so this is a receipt on what `main` now carries. ### Commands ``` cmake --preset dev "-DINTAKE_PYTHON=<shared pe-env>/Scripts/python.exe" cmake --build --preset dev --target startup_stream_consumer startup_indirect_draw_indexed d3d12_xs_device_obj set "XBOX2WINDOWS_ADAPTER=AMD Radeon RX 9070 XT" ctest --preset dev --no-tests=error -R "^startup_(direct_index_late_write|copied_vertex_srv|stream_fetch|indirect_translated_targets|pixel_uav|address_buffer_srv|frame_copy)_(warp|hardware)$" -V ``` The regex takes the five prefixes listed in the description plus `address_buffer_srv` and `frame_copy`, on both backends. ### Observed `100% tests passed out of 14`, 14 `Passed` lines and no `***Skipped` or `***Failed` line, `Total Test time (real) = 24.88 sec`. The same regex reduced to the five prefixes of the description gives `100% tests passed out of 10` in `20.79 sec`. The hardware entry prints one line per mode: ``` 1274: visible: 32 exact pixels, adapter=AMD Radeon RX 9070 XT driver=32.0.32029.2010, debug layer unavailable 1274: clipped: 32 exact pixels, adapter=AMD Radeon RX 9070 XT driver=32.0.32029.2010, debug layer unavailable 1274: late-visible: 32 exact pixels, adapter=AMD Radeon RX 9070 XT driver=32.0.32029.2010, debug layer unavailable 1274: late-clipped: 32 exact pixels, adapter=AMD Radeon RX 9070 XT driver=32.0.32029.2010, debug layer unavailable 1274: late-visible-r32: 32 exact pixels, adapter=AMD Radeon RX 9070 XT driver=32.0.32029.2010, debug layer unavailable ``` The warp entry prints the same five lines with `adapter=Microsoft Basic Render Driver driver=10.0.26100.9818`. In the hardware block one `adapter=` line before the modes also names `Microsoft Basic Render Driver`; the five lines that report each mode are the ones that name the AMD adapter. Three further runs of `startup_direct_index_late_write_hardware` each reported `100% tests passed out of 1`. ### Reverting only `d3d12_draw.inl` The PR's test file and its `tests/startup_stream_draw.cpp` were kept; only `src/startup_stubs/d3d12_draw.inl` was restored to the base `562f7ddb` (the file then differs from the head by `7 insertions(+), 32 deletions(-)`, and a `findstr` for `live_index_resource` on it returns nothing), then rebuilt. The shim banner in those logs reads `build=602e9189-dirty`, against `build=602e9189` for the restored rebuild. Two lines of the resulting log, the second from its final summary: ``` AssertionError: late-visible: got 0000ffff0000ffff...0000ffff, expected 32 pixels of ff0000ff 0% tests passed, 2 tests failed out of 2 ``` That assertion appears once per backend; both entries (`1/2` for warp, `2/2` for hardware) are `***Failed`. The message prints 32 four-byte groups, all `0000ffff`, abbreviated above. That is the fixture's `CLIPPED` constant, the value the `clipped` control reads back, and the clear colour the record-time indices (3, 4, 5) leave behind. Both controls printed `32 exact pixels` first. The traceback stops in `check()` at line 47, after the guards at lines 41-44 (the `slot133 ... aliased gpuva=` line and the `indexed(3, 1, start 0, base 0) ... -> drawn` line). The pixel assertion does not print the child's stderr, so the line number only shows that those two guards were satisfied on the old path, not what they matched. Restoring the file and rebuilding returns 2/2 passed. On this adapter, then, with the PR's fixture and the base draw file, `late-visible` reads back the record-time indices. That is the source mutation the receipt above lists as not run. Binaries on the restored tree: `startup_stream_consumer.exe` `36B3F967DDB78B195D6372DBF51A8007F13C5030805D526C71BB3792F986E055`, `d3d12_xs.dll` `8A94B7FFCB433C4CD432C306596F9242B4A9912663A811D4C37DCB4100A8A87E`. The reverted run used a different `d3d12_xs.dll`, identified by its `build=602e9189-dirty` banner rather than by a separate hash. ### Limits - The fixture raises on the first failing mode and each mode runs in its own process: in the reverted run only `visible`, `clipped` and `late-visible` executed, so `late-clipped` and `late-visible-r32` were not compared against the old path. The causal statement above covers `late-visible`. - One machine, one adapter, Debug preset only; the `release` preset is not measured here. - No debug layer, so resource states and the `require_state` call on the live view are not validated. - The vertex-stream SRV guard (`srv.source == 1`) is not exercised: none of the five modes records a vertex-stream SRV (the vertex shader uses only `SV_VertexID`), so the new path is only seen on the branch where that guard is absent. - Draw shape is fixed: `count=3`, `start` in `{0, 1}`, base vertex 0, one index buffer, no indirect, `R16_UINT` in four modes and `R32_UINT` in one. - The fixture returns 77 when `D3D12_FEATURE_EXISTING_HEAPS` is unsupported; it is supported here, so no mode skipped. - No game or console trace is involved; each case is a 32-pixel readback of one render target. _AI-assisted._
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!2716
No description provided.