Apply typed blend patches to derived graphics pipelines #1266

Merged
R0Y00 merged 3 commits from upstream-pr/1273 into main 2026-11-24 07:00:55 +00:00
R0Y00 commented 2026-11-24 06:25:19 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T06:25:19Z.


Refs #874 and #1216.

Device slot 55 previously retained only 256 bytes of its patch array. A single type-2 record needs 332 bytes, so a translated draw could use an ancestor's blend state even when the caller supplied a new one. Preserve the array at creation, use the last blend patch from the nearest derived pipeline and retain the existing shader lookup through the base. Empty patch lists are accepted. A nonempty unreadable list or more than 64 records returns E_INVALIDARG.

The source-built fixture goes through the guest device and command list, then reads back the target on a separate desktop queue. It exercises multiple type-2 records, a trailing sample-mask record and a further derivation without a blend patch. With a green shader, the parent preserves A8 at 0, the child writes 255, and R8 receives 0. A red shader writes 255 to R8. All four cases check all 32 bytes, including the untouched half.

The fixed record size and tag can be cross-checked against the XCL implementation at 64b3f35.

Windows verification

Tested aae7a50c on Windows 11 build 26200.9974 with the debug layer disabled. Adapters were NVIDIA GeForce RTX 4060 Laptop GPU (32.0.16.1656) and Microsoft Basic Render Driver (10.0.26100.9818).

cmake --build --preset release --target startup_stream_consumer
ctest --test-dir out/build/release --no-tests=error --output-on-failure -R '^startup_stream_(request_warp|draw_(hardware|warp))$'

All three tests passed in 6.71 seconds, with zero skips. The existing red/green RGBA readbacks and swapped-shader control passed on both adapters.

After merging current main into this branch, candidate 1e744970 retains the logical heap fixture added by #1255. Reran ctest --test-dir out/build/release --no-tests=error --output-on-failure -R '^startup_(stream_(request_warp|draw_(hardware|warp))|logical_view_(hardware|warp))$'. Four tests passed in 8.99 seconds and the separate WARP logical-heap test returned its capability skip. Both derived blend readbacks passed.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6576006062 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1273). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T06:25:19Z. --- Refs #874 and #1216. Device slot 55 previously retained only 256 bytes of its patch array. A single type-2 record needs 332 bytes, so a translated draw could use an ancestor's blend state even when the caller supplied a new one. Preserve the array at creation, use the last blend patch from the nearest derived pipeline and retain the existing shader lookup through the base. Empty patch lists are accepted. A nonempty unreadable list or more than 64 records returns `E_INVALIDARG`. The source-built fixture goes through the guest device and command list, then reads back the target on a separate desktop queue. It exercises multiple type-2 records, a trailing sample-mask record and a further derivation without a blend patch. With a green shader, the parent preserves A8 at 0, the child writes 255, and R8 receives 0. A red shader writes 255 to R8. All four cases check all 32 bytes, including the untouched half. The fixed record size and tag can be cross-checked against the [XCL implementation at 64b3f35](https://github.com/ivall/xcl/blob/64b3f35599bb7102f55d640e1a791e7d6dd3b175/crates/xcl/src/hle/d3d12x/device_x.rs#L501-L515). ### Windows verification Tested `aae7a50c` on Windows 11 build 26200.9974 with the debug layer disabled. Adapters were NVIDIA GeForce RTX 4060 Laptop GPU (32.0.16.1656) and Microsoft Basic Render Driver (10.0.26100.9818). ```powershell cmake --build --preset release --target startup_stream_consumer ctest --test-dir out/build/release --no-tests=error --output-on-failure -R '^startup_stream_(request_warp|draw_(hardware|warp))$' ``` All three tests passed in 6.71 seconds, with zero skips. The existing red/green RGBA readbacks and swapped-shader control passed on both adapters. After merging current main into this branch, candidate `1e744970` retains the logical heap fixture added by #1255. Reran `ctest --test-dir out/build/release --no-tests=error --output-on-failure -R '^startup_(stream_(request_warp|draw_(hardware|warp))|logical_view_(hardware|warp))$'`. Four tests passed in 8.99 seconds and the separate WARP logical-heap test returned its capability skip. Both derived blend readbacks passed.
tedin7 commented 2026-11-24 06:41:02 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T06:41:02Z.

Review: COMMENTED


Peer review at commit 1e74497020920761d8bf3f363206c5b685c7c8e7:

Findings

  • src/startup_stubs/d3d12_xs_device.cpp & src/startup_stubs/derived_blend.h: device_create_derived_pipeline now retains count * 0x14c bytes (x2w_derived_blend::record_size) instead of truncating to 256 bytes, validates count <= 64 and readability of non-empty desc (E_INVALIDARG), and x2w_derived_blend::last_blend scans backwards so the last tag-2 blend patch wins.
  • src/startup_stubs/d3d12_draw.inl: translation_for walks up to 8 derived ancestors and picks the blend patch from the nearest derived pipeline before falling back to stream/state-block blend state. (Existing depth < 8 bound is unchanged.)
  • tests/startup_stream_consumer.cpp, tests/startup_stream_draw.cpp, tests/startup_stream_draw_check.py: Good negative/positive coverage—nullptr patch pointer with count = 1 returning E_INVALIDARG, multiple tag-2 records, trailing tag-3 sample-mask record, grandchild inheritance, and exact 32-pixel A8/R8 readbacks with red/green shader controls.

Verification

  • Linux:
    • git diff --check origin/main...HEAD: clean
    • /root/.local/share/x2w-rev-venv/bin/python -B tests/docs_links_check.py: passed (Checked 16 Markdown files and 284 links)
    • /root/.local/share/x2w-rev-venv/bin/python -B tests/bidi_controls_check.py: passed (Checked 1070 tracked source, script and build/CI files: no bidirectional controls)
  • Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP):
    • Debug (--preset dev):
      • cmake --build --preset dev --target startup_stream_consumer -- -j 6 (23.11s)
      • ctest --preset dev -R '^startup_stream_(request_warp|draw_warp)$' --parallel 4 --no-tests=error --output-on-failure: 2/2 passed (1.62s: startup_stream_request_warp 1.25s, startup_stream_draw_warp 1.56s)
    • Release /O2 (--preset release):
      • cmake --build --preset release --target startup_stream_consumer -- -j 6 (35.20s)
      • ctest --preset release -R '^startup_stream_(request_warp|draw_warp)$' --parallel 4 --no-tests=error --output-on-failure: 2/2 passed (1.69s: startup_stream_request_warp 1.24s, startup_stream_draw_warp 1.62s)
<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6034779006 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1273#pullrequestreview-6034779006). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T06:41:02Z. **Review:** COMMENTED --- Peer review at commit `1e74497020920761d8bf3f363206c5b685c7c8e7`: ### Findings - `src/startup_stubs/d3d12_xs_device.cpp` & `src/startup_stubs/derived_blend.h`: `device_create_derived_pipeline` now retains `count * 0x14c` bytes (`x2w_derived_blend::record_size`) instead of truncating to 256 bytes, validates `count <= 64` and readability of non-empty `desc` (`E_INVALIDARG`), and `x2w_derived_blend::last_blend` scans backwards so the last tag-2 blend patch wins. - `src/startup_stubs/d3d12_draw.inl`: `translation_for` walks up to 8 derived ancestors and picks the blend patch from the nearest derived pipeline before falling back to stream/state-block blend state. (Existing `depth < 8` bound is unchanged.) - `tests/startup_stream_consumer.cpp`, `tests/startup_stream_draw.cpp`, `tests/startup_stream_draw_check.py`: Good negative/positive coverage—`nullptr` patch pointer with `count = 1` returning `E_INVALIDARG`, multiple tag-2 records, trailing tag-3 sample-mask record, grandchild inheritance, and exact 32-pixel A8/R8 readbacks with red/green shader controls. ### Verification - **Linux**: - `git diff --check origin/main...HEAD`: clean - `/root/.local/share/x2w-rev-venv/bin/python -B tests/docs_links_check.py`: passed (`Checked 16 Markdown files and 284 links`) - `/root/.local/share/x2w-rev-venv/bin/python -B tests/bidi_controls_check.py`: passed (`Checked 1070 tracked source, script and build/CI files: no bidirectional controls`) - **Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP)**: - Debug (`--preset dev`): - `cmake --build --preset dev --target startup_stream_consumer -- -j 6` (`23.11s`) - `ctest --preset dev -R '^startup_stream_(request_warp|draw_warp)$' --parallel 4 --no-tests=error --output-on-failure`: **2/2 passed** (`1.62s`: `startup_stream_request_warp` `1.25s`, `startup_stream_draw_warp` `1.56s`) - Release `/O2` (`--preset release`): - `cmake --build --preset release --target startup_stream_consumer -- -j 6` (`35.20s`) - `ctest --preset release -R '^startup_stream_(request_warp|draw_warp)$' --parallel 4 --no-tests=error --output-on-failure`: **2/2 passed** (`1.69s`: `startup_stream_request_warp` `1.24s`, `startup_stream_draw_warp` `1.62s`)
upstream-sync closed this pull request 2026-11-24 07:07:37 +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!1266
No description provided.