startup: allow MRT, depth, and depth-only targets in translated ExecuteIndirect #2417

Manually merged
github merged 3 commits from gh-pr/2417/head into gh-pr/2417/base 2026-11-27 00:50:18 +00:00
Owner

@⁠stan495 on GitHub · 2026-11-25 16:06 UTC · original
stan495:startup/translated-indirect-targets → main · +278 −11 · 5 files · 3 commits · merged 2026-11-26 02:50 UTC

Summary

Allow X2W_TRANSLATED_INDIRECT_DRAW=1 ExecuteIndirect draws to run with multiple render targets (up to 8 RTVs), colour + depth-stencil, and depth-only (0 RTVs + DSV) attachments instead of refusing them before draw_translated_indirect.

pipeline_for() in d3d12_draw.inl already builds desktop graphics PSOs matching pass.target_count, pass.target_formats[0..target_count-1], and pass.dsv_format, and list_set_render_targets already tracks pass.targets_single_sample and pass.depth_view_writable.

  • src/startup_stubs/d3d12_xs_device.cpp:
    • Unconditionally record pass.bound_targets[8] and pass.bound_depth in list_set_render_targets (cleared on each bind).
    • In list_execute_indirect, when translated is true, require pass.targets_bound, at least one colour or depth attachment (pass.target_count > 0 || pass.dsv_format != DXGI_FORMAT_UNKNOWN), pass.viewport_set && pass.scissor_set, and pass.targets_single_sample.
    • Non-translated desktop graphics pipelines keep the existing single-RTV, no-DSV, format-matching guard unchanged.
  • src/startup_stubs/d3d12_draw.inl:
    • Extend the indirect sampled-texture aliasing check from pass.target0 to all bound colour targets (pass.bound_targets[0..target_count-1]) and a writable depth target (pass.bound_depth && pass.depth_view_writable).
    • Refuse indirect translated draws that write depth or stencil against a read-only depth view (indirect_refusal_code::read_only_depth_write).
  • tests/startup_indirect_draw_indexed.cpp & CMakeLists.txt:
    • Add startup_indirect_translated_targets_{warp,hardware} covering 2-target MRT, colour + DSV, depth-only (0 RTV + DSV), refusal of zero attachments, and refusal of a sampled texture aliasing RTV 1 (sampled_texture_mismatch).
  • docs/experiments.md:
    • Update the Translated indirect triangles section with the supported target combinations, aliasing/read-only-DSV rules, and test filter.

Verification

  • Commit: cb9259a2 (based on upstream/main 7092683a)
  • Environment: Windows 11 Build 26200, MSVC 19.44.35228, AMD Radeon RX 7900 XTX (driver 32.0.32029.2010, XBOX2WINDOWS_ADAPTER=7900) and WARP (Microsoft Basic Render Driver, driver 10.0.26100.9818), D3D12 debug layer enabled (0 errors; only the expected benign warning ID 679 when reusing the colour-writing pixel shader for the 0-RTV depth-only fixture case).
  • Commands & Results:
    • ctest --preset release --no-tests=error -j 1 -R '^startup_indirect_(translated_(targets|draw|refusal_census)|draw_indexed)' -V -> 9/9 passed, 0 failed, 0 skipped:
      • startup_indirect_translated_targets_warp: PASS
      • startup_indirect_translated_targets_hardware: PASS (AMD Radeon RX 7900 XTX, debug layer enabled)
      • startup_indirect_translated_draw_{warp,hardware}: PASS
      • startup_indirect_translated_refusal_census_{warp,hardware,control_warp}: PASS
      • startup_indirect_draw_indexed_{warp,hardware}: PASS
    • python -B tests/docs_links_check.py -> PASS (19 Markdown files, 464 links)
    • python -B tests/bidi_controls_check.py -> PASS (1723 tracked files)
**@⁠stan495** on GitHub · 2026-11-25 16:06 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2417) `stan495:startup/translated-indirect-targets` → `main` · +278 −11 · 5 files · 3 commits · merged 2026-11-26 02:50 UTC ## Summary Allow `X2W_TRANSLATED_INDIRECT_DRAW=1` `ExecuteIndirect` draws to run with multiple render targets (up to 8 RTVs), colour + depth-stencil, and depth-only (`0` RTVs + DSV) attachments instead of refusing them before `draw_translated_indirect`. `pipeline_for()` in `d3d12_draw.inl` already builds desktop graphics PSOs matching `pass.target_count`, `pass.target_formats[0..target_count-1]`, and `pass.dsv_format`, and `list_set_render_targets` already tracks `pass.targets_single_sample` and `pass.depth_view_writable`. - **`src/startup_stubs/d3d12_xs_device.cpp`**: - Unconditionally record `pass.bound_targets[8]` and `pass.bound_depth` in `list_set_render_targets` (cleared on each bind). - In `list_execute_indirect`, when `translated` is true, require `pass.targets_bound`, at least one colour or depth attachment (`pass.target_count > 0 || pass.dsv_format != DXGI_FORMAT_UNKNOWN`), `pass.viewport_set && pass.scissor_set`, and `pass.targets_single_sample`. - Non-translated desktop graphics pipelines keep the existing single-RTV, no-DSV, format-matching guard unchanged. - **`src/startup_stubs/d3d12_draw.inl`**: - Extend the indirect sampled-texture aliasing check from `pass.target0` to all bound colour targets (`pass.bound_targets[0..target_count-1]`) and a writable depth target (`pass.bound_depth && pass.depth_view_writable`). - Refuse indirect translated draws that write depth or stencil against a read-only depth view (`indirect_refusal_code::read_only_depth_write`). - **`tests/startup_indirect_draw_indexed.cpp` & `CMakeLists.txt`**: - Add `startup_indirect_translated_targets_{warp,hardware}` covering 2-target MRT, colour + DSV, depth-only (`0` RTV + DSV), refusal of zero attachments, and refusal of a sampled texture aliasing RTV 1 (`sampled_texture_mismatch`). - **`docs/experiments.md`**: - Update the `Translated indirect triangles` section with the supported target combinations, aliasing/read-only-DSV rules, and test filter. ## Verification - **Commit**: `cb9259a2` (based on `upstream/main` `7092683a`) - **Environment**: Windows 11 Build 26200, MSVC 19.44.35228, `AMD Radeon RX 7900 XTX` (driver `32.0.32029.2010`, `XBOX2WINDOWS_ADAPTER=7900`) and WARP (`Microsoft Basic Render Driver`, driver `10.0.26100.9818`), D3D12 debug layer enabled (0 errors; only the expected benign warning ID 679 when reusing the colour-writing pixel shader for the 0-RTV depth-only fixture case). - **Commands & Results**: - `ctest --preset release --no-tests=error -j 1 -R '^startup_indirect_(translated_(targets|draw|refusal_census)|draw_indexed)' -V` -> **9/9 passed, 0 failed, 0 skipped**: - `startup_indirect_translated_targets_warp`: PASS - `startup_indirect_translated_targets_hardware`: PASS (`AMD Radeon RX 7900 XTX`, debug layer enabled) - `startup_indirect_translated_draw_{warp,hardware}`: PASS - `startup_indirect_translated_refusal_census_{warp,hardware,control_warp}`: PASS - `startup_indirect_draw_indexed_{warp,hardware}`: PASS - `python -B tests/docs_links_check.py` -> PASS (19 Markdown files, 464 links) - `python -B tests/bidi_controls_check.py` -> PASS (1723 tracked files)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 00:50:16 +00:00
github manually merged commit b23768ed8d into gh-pr/2417/base 2026-11-27 00:50:18 +00:00
Author
Owner

@⁠KelboLive on GitHub · 2026-11-25 16:08 UTC · original

APPROVED. Allows MRT, depth, and depth-only targets in translated ExecuteIndirect. Useful extension.

**@⁠KelboLive** on GitHub · 2026-11-25 16:08 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2417#issuecomment-7167629072) APPROVED. Allows MRT, depth, and depth-only targets in translated ExecuteIndirect. Useful extension.
Author
Owner

@⁠tedin7 on GitHub · 2026-11-25 18:22 UTC · original · reviewed

Review of head cb9259a2 (Linux checks and code reading only; I did not build or run the C++ fixture, and I found no author-posted Windows results for this SHA).

What I checked

  • Scope: 5 files (d3d12_draw.inl, d3d12_xs_device.cpp, tests/startup_indirect_draw_indexed.cpp, CMakeLists.txt, docs/experiments.md). Additive, limited to the translated ExecuteIndirect path. Non-translated indirect graphics keep the old one-target, no-depth check.
  • list_execute_indirect (d3d12_xs_device.cpp ~2663): the translated branch now accepts MRT, colour plus depth, and depth-only. It still needs viewport, scissor, bound targets and single-sample. pass.targets_single_sample (set in list_targets, ~3172) covers every colour target and the depth resource, so skipping the old target0 sample check for translated draws is safe (and avoids a null target0 in the depth-only case).
  • list_targets: bound_targets[8] and bound_depth are cleared at the top and filled only after the early returns, so a failed bind leaves no stale pointers.
  • draw_translated (d3d12_draw.inl ~1891, ~2017): the new read_only_depth_write refusal triggers only when the pipeline writes depth or stencil and the view is not DEPTH_WRITE. The sampled-texture alias check now covers all bound colour targets and a writable depth view. Sampling a read-only depth view is still allowed, which is correct.
  • Sibling census: the new refusal code sits next to the other indirect_refusal_code entries. The new CTest startup_indirect_translated_targets_{warp,hardware} is added in the existing backend loop with the same TIMEOUT and SKIP_RETURN_CODE as its siblings, and docs/experiments.md is updated, including the -R regex.
  • Test: the new translated-targets mode renders on the device, then does a fenced readback of the colour targets and compares each pixel to the expected colour. It covers two-target MRT, colour plus depth, depth-only, zero attachments (refused) and an RTV 1 alias (refused with sampled_texture_mismatch). It is a real GPU readback, not a string check.
  • Duplicates: searched ExecuteIndirect. #2232 and #2333 are merged and cover the base translated path and the census. Open #2411 (census for other refusals) and #2470 (translated compute) touch the same area, so a rebase or CMake/test-file conflict is possible but there is no overlap in behavior.

Commands run in a clean worktree of the PR head

  • python3 tests/docs_links_check.py -> OK
  • python3 tests/bidi_controls_check.py -> OK
  • git diff --check origin/main...HEAD -> clean

Minor notes (not blocking)

  • The read-only-depth refusal and the depth-only success path have no mutation I could run on Linux. The Windows WARP and hardware runs of startup_indirect_translated_(draw|targets)_ for the final head are needed before a merge.
  • The branch is 27 commits behind main. Please keep any Windows results tied to the final head SHA.

No bugs found.

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-25 18:22 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2417#pullrequestreview-6062817175) · **reviewed** Review of head cb9259a2 (Linux checks and code reading only; I did not build or run the C++ fixture, and I found no author-posted Windows results for this SHA). What I checked - Scope: 5 files (d3d12_draw.inl, d3d12_xs_device.cpp, tests/startup_indirect_draw_indexed.cpp, CMakeLists.txt, docs/experiments.md). Additive, limited to the translated ExecuteIndirect path. Non-translated indirect graphics keep the old one-target, no-depth check. - `list_execute_indirect` (d3d12_xs_device.cpp ~2663): the translated branch now accepts MRT, colour plus depth, and depth-only. It still needs viewport, scissor, bound targets and single-sample. `pass.targets_single_sample` (set in `list_targets`, ~3172) covers every colour target and the depth resource, so skipping the old `target0` sample check for translated draws is safe (and avoids a null `target0` in the depth-only case). - `list_targets`: `bound_targets[8]` and `bound_depth` are cleared at the top and filled only after the early returns, so a failed bind leaves no stale pointers. - `draw_translated` (d3d12_draw.inl ~1891, ~2017): the new `read_only_depth_write` refusal triggers only when the pipeline writes depth or stencil and the view is not DEPTH_WRITE. The sampled-texture alias check now covers all bound colour targets and a writable depth view. Sampling a read-only depth view is still allowed, which is correct. - Sibling census: the new refusal code sits next to the other `indirect_refusal_code` entries. The new CTest `startup_indirect_translated_targets_{warp,hardware}` is added in the existing backend loop with the same TIMEOUT and SKIP_RETURN_CODE as its siblings, and docs/experiments.md is updated, including the `-R` regex. - Test: the new `translated-targets` mode renders on the device, then does a fenced readback of the colour targets and compares each pixel to the expected colour. It covers two-target MRT, colour plus depth, depth-only, zero attachments (refused) and an RTV 1 alias (refused with `sampled_texture_mismatch`). It is a real GPU readback, not a string check. - Duplicates: searched `ExecuteIndirect`. #2232 and #2333 are merged and cover the base translated path and the census. Open #2411 (census for other refusals) and #2470 (translated compute) touch the same area, so a rebase or CMake/test-file conflict is possible but there is no overlap in behavior. Commands run in a clean worktree of the PR head - `python3 tests/docs_links_check.py` -> OK - `python3 tests/bidi_controls_check.py` -> OK - `git diff --check origin/main...HEAD` -> clean Minor notes (not blocking) - The read-only-depth refusal and the depth-only success path have no mutation I could run on Linux. The Windows WARP and hardware runs of `startup_indirect_translated_(draw|targets)_` for the final head are needed before a merge. - The branch is 27 commits behind main. Please keep any Windows results tied to the final head SHA. No bugs found. AI-assisted; commands listed were executed locally.
Author
Owner

@⁠RonLogic on GitHub · 2026-11-25 19:25 UTC · original

Independent Release run at cb9259a2: all 9 selected tests passed on WARP and RTX 4070, no skips. I found a gap in the depth-only fixture. It reads an unbound color target and expects black, so skipping slot 61 dispatch for Mode::depth_only still passed both target tests.

I added an occlusion query around ExecuteIndirect in the test-only commit 09ef4cf9. The existing fence protects the query readback. Both adapters reported the expected 8 rasterized samples and the full 9-test selection passed. With the depth-only call omitted, both adapters returned 0 and the tests failed. Restoring the call made both pass again. This verifies the draw rasterizes in the depth-only configuration; the fixture uses its existing depth state. Feel free to cherry-pick the test commit into this PR.

cmake --build --preset release --target startup_indirect_draw_indexed xmem_shim --parallel 4
ctest --preset release --no-tests=error -j 1 -R '^startup_indirect_(translated_(targets|draw|refusal_census)|draw_indexed)' --output-on-failure

Windows 11 x64 26300.10075, MSVC 19.52.37029, RTX 4070 driver 32.0.16.2124, in-box WARP 10.0.26100.10068. D3D12 debug layer enabled on both adapters.

**@⁠RonLogic** on GitHub · 2026-11-25 19:25 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2417#issuecomment-7172266997) Independent Release run at `cb9259a2`: all 9 selected tests passed on WARP and RTX 4070, no skips. I found a gap in the depth-only fixture. It reads an unbound color target and expects black, so skipping slot 61 dispatch for `Mode::depth_only` still passed both target tests. I added an occlusion query around `ExecuteIndirect` in the [test-only commit `09ef4cf9`](https://github.com/RonLogic/Xbox2Windows/commit/09ef4cf922704ac7afde4f42cfd46aeb0ca3a433). The existing fence protects the query readback. Both adapters reported the expected 8 rasterized samples and the full 9-test selection passed. With the depth-only call omitted, both adapters returned 0 and the tests failed. Restoring the call made both pass again. This verifies the draw rasterizes in the depth-only configuration; the fixture uses its existing depth state. Feel free to cherry-pick the test commit into this PR. ```powershell cmake --build --preset release --target startup_indirect_draw_indexed xmem_shim --parallel 4 ctest --preset release --no-tests=error -j 1 -R '^startup_indirect_(translated_(targets|draw|refusal_census)|draw_indexed)' --output-on-failure ``` Windows 11 x64 26300.10075, MSVC 19.52.37029, RTX 4070 driver 32.0.16.2124, in-box WARP 10.0.26100.10068. D3D12 debug layer enabled on both adapters.
Author
Owner

@⁠tedin7 on GitHub · 2026-11-26 00:51 UTC · original · reviewed

Review of head 12283d42 against current origin/main. Code review plus Linux checks only; no Windows run from me on this head. No game or executable result is claimed or verified here.

Code (looks correct)

  • d3d12_xs_device.cpp list_targets: bound_targets[8] and bound_depth are cleared on each bind and filled after the early return, so they match target_count and dsv_format.
  • list_execute_indirect: the new translated branch only widens the translated path. Non-translated pipelines keep the old single-RTV, no-DSV guard. Skipping the target0 multisample read for translated draws is safe, because targets_single_sample is checked just above.
  • d3d12_draw.inl: the remaining target0 uses (around lines 1396 and 2280) are null-guarded, so the 0-RTV depth-only case does not crash.
  • The alias check over all bound colour targets and a writable depth target is a sound extension of the old target0 check.

Test gaps (please address before merge)

  1. The depth-only fixture does not prove the draw happens. It reads an unbound colour target and expects black, so dropping the ExecuteIndirect call in Mode::depth_only still passes. @⁠RonLogic reported this on cb9259a2 and offered a test-only commit (09ef4cf9, occlusion query around ExecuteIndirect) that fails when the call is removed. It is not in this head. Please cherry-pick it or add an equivalent check.
  2. The new read_only_depth_write refusal (d3d12_draw.inl, around line 1943) has no test: rg read_only_depth tests/ finds nothing. A fixture that binds a read-only DSV with depth write enabled and expects the refusal would guard it. Removing the new if block would currently pass every test.

Linux checks run

  • python3 tests/docs_links_check.py -> 19 files, 507 links, ok
  • python3 tests/bidi_controls_check.py -> 1887 files, ok
  • git diff --check origin/main...HEAD -> clean
  • Mutation runs of the new test need a Windows build and were not done by me.

CI on this head was still running at review time. The earlier review on cb9259a2 does not cover this head.

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-26 00:51 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2417#pullrequestreview-6067071629) · **reviewed** Review of head `12283d42` against current `origin/main`. Code review plus Linux checks only; no Windows run from me on this head. No game or executable result is claimed or verified here. **Code (looks correct)** - `d3d12_xs_device.cpp` `list_targets`: `bound_targets[8]` and `bound_depth` are cleared on each bind and filled after the early return, so they match `target_count` and `dsv_format`. - `list_execute_indirect`: the new `translated` branch only widens the translated path. Non-translated pipelines keep the old single-RTV, no-DSV guard. Skipping the `target0` multisample read for translated draws is safe, because `targets_single_sample` is checked just above. - `d3d12_draw.inl`: the remaining `target0` uses (around lines 1396 and 2280) are null-guarded, so the 0-RTV depth-only case does not crash. - The alias check over all bound colour targets and a writable depth target is a sound extension of the old `target0` check. **Test gaps (please address before merge)** 1. The depth-only fixture does not prove the draw happens. It reads an unbound colour target and expects black, so dropping the `ExecuteIndirect` call in `Mode::depth_only` still passes. @⁠RonLogic reported this on `cb9259a2` and offered a test-only commit (`09ef4cf9`, occlusion query around `ExecuteIndirect`) that fails when the call is removed. It is not in this head. Please cherry-pick it or add an equivalent check. 2. The new `read_only_depth_write` refusal (`d3d12_draw.inl`, around line 1943) has no test: `rg read_only_depth tests/` finds nothing. A fixture that binds a read-only DSV with depth write enabled and expects the refusal would guard it. Removing the new `if` block would currently pass every test. **Linux checks run** - `python3 tests/docs_links_check.py` -> 19 files, 507 links, ok - `python3 tests/bidi_controls_check.py` -> 1887 files, ok - `git diff --check origin/main...HEAD` -> clean - Mutation runs of the new test need a Windows build and were not done by me. CI on this head was still running at review time. The earlier review on `cb9259a2` does not cover this head. AI-assisted; commands listed were executed locally.
Author
Owner

@⁠tedin7 on GitHub · 2026-11-26 00:51 UTC · original

Correction to my review above: it was written against 12283d42, but the PR head moved to b23768ed ("verify depth-only indirect draw rasterization with occlusion query") while I was posting. That commit appears to address point 1 (depth-only draw not guarded). I have not re-reviewed or tested b23768ed. Point 2 (no test for the read_only_depth_write refusal) still stands unless the new commit covers it. Merge stays open until the head is re-reviewed and tested on Windows.

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-26 00:51 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2417#issuecomment-7179184771) Correction to my review above: it was written against `12283d42`, but the PR head moved to `b23768ed` ("verify depth-only indirect draw rasterization with occlusion query") while I was posting. That commit appears to address point 1 (depth-only draw not guarded). I have not re-reviewed or tested `b23768ed`. Point 2 (no test for the `read_only_depth_write` refusal) still stands unless the new commit covers it. Merge stays open until the head is re-reviewed and tested on Windows. AI-assisted; commands listed were executed locally.
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-26 02:48 UTC · original · approved these changes

Independent Windows Release run on this head passed 4/4 with debug layer enabled on WARP and RTX 4060 Laptop. Verified both color attachments, color plus DSV, depth-only rasterization via the occlusion query, refusal of no attachments, and refusal when a sampled texture aliases RTV 1. Existing indexed indirect tests also passed on both adapters. This covers the source-built translated draw path.

**@⁠R0Y00** on GitHub · 2026-11-26 02:48 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2417#pullrequestreview-6067888077) · **approved these changes** Independent Windows Release run on this head passed 4/4 with debug layer enabled on WARP and RTX 4060 Laptop. Verified both color attachments, color plus DSV, depth-only rasterization via the occlusion query, refusal of no attachments, and refusal when a sampled texture aliases RTV 1. Existing indexed indirect tests also passed on both adapters. This covers the source-built translated draw path.
Author
Owner

@⁠RavenCurseBurg on GitHub · 2026-11-26 02:54 UTC · original

Windows CI on merged main now reports C2086 for both Pass::bound_targets and Pass::bound_depth. #2417 and #2448 added the same declarations and commit the same pair in the successful bind path. I will submit the small integration fix on current main, keeping the common target state for both consumers and the separate trace state. Failing build

**@⁠RavenCurseBurg** on GitHub · 2026-11-26 02:54 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2417#issuecomment-7181227657) Windows CI on merged main now reports C2086 for both `Pass::bound_targets` and `Pass::bound_depth`. #2417 and #2448 added the same declarations and commit the same pair in the successful bind path. I will submit the small integration fix on current main, keeping the common target state for both consumers and the separate trace state. [Failing build](https://github.com/R0Y00/Xbox2Windows/actions/runs/45745104983/job/139659120059)
This discussion has been locked. Commenting is limited to contributors.
No description provided.