startup: bind translated resources for indirect draws #2232

Manually merged
github merged 1 commit from gh-pr/2232/head into gh-pr/2232/base 2026-11-27 00:08:05 +00:00
Owner

@⁠R0Y00 on GitHub · 2026-11-25 06:43 UTC · original
R0Y00:codex/translated-indirect-draw → main · +302 −14 · 5 files · 1 commits · merged 2026-11-25 07:04 UTC

Refs #870.

Enable one translated, non-indexed slot 61 Draw with X2W_TRANSLATED_INDIRECT_DRAW=1. After validating the signature, root, target and placed argument span, the translator binds its existing graphics PSO and sampled texture resources. Desktop ExecuteIndirect reads the argument at its recorded GPU offset. The caller supplies legal draw arguments.

This scope covers a triangle list with one single-sample colour target, a matching slot 57 root, explicit viewport and scissor, and the existing texture-table bindings. Compiled shader reflection checks actual use of entry constants. Draw-dependent start vertex or instance, vertex streams, buffer SRVs, dynamic samplers, unknown bindings and unreflectable shaders are refused.

Local MSVC Release, Windows 11 build 26200.9974. WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656, D3D12 debug layer enabled. The fixture compiles its own shaders. A GPU producer writes one Draw command at byte 4 in a separate desktop resource. Red and green texture bindings both match all eight pixels, guard words and GPU argument words. The omitted producer, wrong root, short argument range, missing texture and shader that reads start vertex all leave the clear colour. The CPU argument backing stays zero.

cmake --build --preset release --target startup_indirect_draw_indexed startup_indirect_dispatch startup_stream_consumer
ctest --preset release -j1 --no-tests=error -R '^startup_(indirect_(translated_draw|draw|draw_indexed|mesh|requests|dispatch|root_constants|count|counts_control)|stream_draw|1d_srv)_' -V

21/21 passed, no skips. After adding the shader key to the success diagnostic, the two translated draw tests passed again. AI-assisted. Commands executed locally.

**@⁠R0Y00** on GitHub · 2026-11-25 06:43 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2232) `R0Y00:codex/translated-indirect-draw` → `main` · +302 −14 · 5 files · 1 commits · merged 2026-11-25 07:04 UTC Refs #870. Enable one translated, non-indexed slot 61 Draw with `X2W_TRANSLATED_INDIRECT_DRAW=1`. After validating the signature, root, target and placed argument span, the translator binds its existing graphics PSO and sampled texture resources. Desktop ExecuteIndirect reads the argument at its recorded GPU offset. The caller supplies legal draw arguments. This scope covers a triangle list with one single-sample colour target, a matching slot 57 root, explicit viewport and scissor, and the existing texture-table bindings. Compiled shader reflection checks actual use of entry constants. Draw-dependent start vertex or instance, vertex streams, buffer SRVs, dynamic samplers, unknown bindings and unreflectable shaders are refused. Local MSVC Release, Windows 11 build 26200.9974. WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656, D3D12 debug layer enabled. The fixture compiles its own shaders. A GPU producer writes one Draw command at byte 4 in a separate desktop resource. Red and green texture bindings both match all eight pixels, guard words and GPU argument words. The omitted producer, wrong root, short argument range, missing texture and shader that reads start vertex all leave the clear colour. The CPU argument backing stays zero. ```powershell cmake --build --preset release --target startup_indirect_draw_indexed startup_indirect_dispatch startup_stream_consumer ctest --preset release -j1 --no-tests=error -R '^startup_(indirect_(translated_draw|draw|draw_indexed|mesh|requests|dispatch|root_constants|count|counts_control)|stream_draw|1d_srv)_' -V ``` 21/21 passed, no skips. After adding the shader key to the success diagnostic, the two translated draw tests passed again. AI-assisted. Commands executed locally.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 00:08:04 +00:00
github manually merged commit 38971e07f5 into gh-pr/2232/base 2026-11-27 00:08:05 +00:00
Author
Owner

@⁠tedin7 on GitHub · 2026-11-25 06:46 UTC · original · reviewed

Review of head 38971e07f5347922ec716f02772a45c3aab94f8b (static review plus Linux checks; the Windows-only C++ was not built or run locally).

Commands executed locally

  • git diff --stat origin/main...HEAD: 5 files, +302/-14
  • python3 tests/docs_links_check.py: self-test passed, 18 Markdown files and 412 links OK
  • python3 tests/bidi_controls_check.py: 1507 files, no bidirectional controls
  • git diff --check origin/main...HEAD: clean
  • gh pr checks: Linux Python checks, Windows build and test, and gfx1013 fixtures pass. The /O2 job and the chart job are skipped.
  • PR is mergeable and the title is neutral. No clean-room concerns seen.

Findings

  • P1: none.
  • P2: none.
  • Nit (d3d12_xs_device.cpp, list_execute_indirect): the commit subject says "bounded indirect draws" but the PR title says "indirect draws". Align them before merge.
  • Nit (d3d12_draw.inl, draw_translated): refusals inside the SRV loop happen after earlier SRV slots may already have called require_state/upload_texture. This only adds barriers and uploads that the next draw would add anyway, so it is harmless, but a short comment would help the next reader.
  • Nit (d3d12_draw.inl, indirect_shader_entry): Translation::independent_indirect_entry is cached per translation. That is correct today because the shaders and uds are fixed per translation. Please note that invariant next to the member.
  • Nit: the indirect path skips draw_dump_after and the per-draw log. That is fine, but it makes diagnostics weaker than direct draws.

What looks right

  • Env-gated opt-in (X2W_TRANSLATED_INDIRECT_DRAW). The default path is unchanged: the old condition is only relaxed when translated is true.
  • The translated path requires the guest pipeline's root to equal pass.root, and refuses dynamic samplers, non-zero SRV sources, and any used entry constant that is not a root constant, rect or d16 constant. This covers start vertex and start instance.
  • After ExecuteIndirect, the code restores the guest root and resets srv_bound, so later draws re-bind.
  • The sampled texture must be present, in slot 18, and distinct from the target. This avoids a read/write hazard.
  • The tests cover red and green texture bindings, guard words and argument words. The negative controls are the omitted producer, wrong root, short range, missing texture, and a start-vertex shader. Both WARP and hardware are registered, with SKIP_RETURN_CODE 77 only for backend unavailability.

Not done

  • No mutation run on the new logic. It is Windows/D3D12-only C++ that cannot be built on this Linux host.
  • No win2025 run. The PR reports local WARP and hardware results, and Windows CI is green.

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-25 06:46 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2232#pullrequestreview-6053041988) · **reviewed** Review of head `38971e07f5347922ec716f02772a45c3aab94f8b` (static review plus Linux checks; the Windows-only C++ was not built or run locally). **Commands executed locally** - `git diff --stat origin/main...HEAD`: 5 files, +302/-14 - `python3 tests/docs_links_check.py`: self-test passed, 18 Markdown files and 412 links OK - `python3 tests/bidi_controls_check.py`: 1507 files, no bidirectional controls - `git diff --check origin/main...HEAD`: clean - `gh pr checks`: Linux Python checks, Windows build and test, and gfx1013 fixtures pass. The /O2 job and the chart job are skipped. - PR is mergeable and the title is neutral. No clean-room concerns seen. **Findings** - P1: none. - P2: none. - Nit (`d3d12_xs_device.cpp`, `list_execute_indirect`): the commit subject says "bounded indirect draws" but the PR title says "indirect draws". Align them before merge. - Nit (`d3d12_draw.inl`, `draw_translated`): refusals inside the SRV loop happen after earlier SRV slots may already have called `require_state`/`upload_texture`. This only adds barriers and uploads that the next draw would add anyway, so it is harmless, but a short comment would help the next reader. - Nit (`d3d12_draw.inl`, `indirect_shader_entry`): `Translation::independent_indirect_entry` is cached per translation. That is correct today because the shaders and `uds` are fixed per translation. Please note that invariant next to the member. - Nit: the indirect path skips `draw_dump_after` and the per-draw log. That is fine, but it makes diagnostics weaker than direct draws. **What looks right** - Env-gated opt-in (`X2W_TRANSLATED_INDIRECT_DRAW`). The default path is unchanged: the old condition is only relaxed when `translated` is true. - The translated path requires the guest pipeline's root to equal `pass.root`, and refuses dynamic samplers, non-zero SRV sources, and any used entry constant that is not a root constant, rect or d16 constant. This covers start vertex and start instance. - After `ExecuteIndirect`, the code restores the guest root and resets `srv_bound`, so later draws re-bind. - The sampled texture must be present, in slot 18, and distinct from the target. This avoids a read/write hazard. - The tests cover red and green texture bindings, guard words and argument words. The negative controls are the omitted producer, wrong root, short range, missing texture, and a start-vertex shader. Both WARP and hardware are registered, with `SKIP_RETURN_CODE 77` only for backend unavailability. **Not done** - No mutation run on the new logic. It is Windows/D3D12-only C++ that cannot be built on this Linux host. - No `win2025` run. The PR reports local WARP and hardware results, and Windows CI is green. AI-assisted; commands listed were executed locally.
This discussion has been locked. Commenting is limited to contributors.
No description provided.