startup: write translation requests for console pipelines used only by ExecuteIndirect #2178

Merged
NiiRoZz merged 6 commits from upstream-pr/2186 into main 2026-11-25 03:40:59 +00:00
NiiRoZz commented 2026-11-25 03:18:13 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by NiiRoZz on 2026-11-25T03:18:13Z.


Change

Translation requests (req_<key>.{a,b,root}) for console graphics pipelines were written only on the direct-draw path (draw_translated → translation_for). A pipeline used only through ExecuteIndirect (command-list slot 61) was never requested, so its translator gap never showed up in the shader cache.

Slot 61 can refuse a graphics call because no desktop pipeline and root match; the x2w-render indirect line (#2180) counts that refusal as graphics-pipeline. When it does and the bound pipeline is a console pipeline (no desktop pipeline, own().real null), the stand-in now takes draw_lock and calls translation_for through a request_translation helper next to it. That is the direct-draw request writer: same key, same files, and once per pipeline through its per-pipeline map.

Each recording remembers the last pipeline it asked for, so repeated refused calls skip draw_lock. Each lookup is logged (first 16). The x2w-render totals line now ends with pipelines requested by ExecuteIndirect N. That count is per pipeline, not per call, so it goes on the totals line beside pipelines translated / missing, not on the per-call x2w-render indirect line.

Nothing is drawn. What is forwarded and refused is unchanged.

Not a duplicate:

  • #2120 (merged) translates requests that already exist; it writes none.
  • #1750 (open) writes requests offline from the shader archive, so it overlaps in part. It writes each adjacent pixel/vertex pair once per root already in the cache (req_*.root from earlier runs). It covers an indirect-only pipeline only when another pipeline recorded the same root and its programs are adjacent in the archive. It cannot cover non-adjacent pairs or programs embedded in the executable. This change writes the exact key that the runtime pairing uses.

Refs #1759 (ExecuteIndirect), #870.

Verification

Head 561af3a8 (origin/main a2010c91 merged in, including #2180), branch startup/indirect-pipeline-requests. Windows 11 build 26300, release preset. Adapters: WARP (Microsoft Basic Render Driver, 10.0.26100.10068) and NVIDIA GeForce RTX 5090 (driver 32.0.16.2135). The startup_indirect_* C++ tests ran with the debug layer enabled. The consumer-based checks (startup_indirect_requests, startup_slot57_blend_draw, startup_stream_draw) ran without it (X2W_D3D12_DEBUG=0, no X2W_TEST_DEBUG_LAYER).

cmake --build --preset release --target startup_stream_consumer startup_indirect_dispatch startup_indirect_draw_indexed
ctest --preset release --no-tests=error -R '^startup_(indirect_(requests|dispatch|root_constants|draw_indexed|draw|mesh|counts_control)|slot57_blend_draw|stream_draw)_(warp|hardware)$'
# 100% tests passed, 0 tests failed out of 17 (no capability skips)
git diff --check origin/main...HEAD
# no output
python -B tests/docs_links_check.py
# Checked 18 Markdown files and 404 links.

How the fixture works: startup_indirect_requests_{warp,hardware} uses startup_stream_consumer, which gains two modes.

  • It builds the stream pipeline (slot 86, with an input layout so its key differs) and a device slot-57 pipeline from the same synthetic gfx1013 shaders and root.
  • slot57-draw binds the slot-57 pipeline and records three refused Draw calls. The cache must then hold exactly one extra request, carrying the slot-57 shaders and root, and each process must log exactly one lookup. Two processes into one cache must still give one extra request.
  • slot57-bound (negative control) binds the pipeline and records nothing. Only the stream pipeline's request may exist, and no lookup.
  • slot57-dispatch binds the same pipeline and records one Dispatch call, which is a compute-state refusal. It must write no request.
  • desktop-draw binds a slot-86 pipeline with desktop shaders and records one refused Draw call. The log must show that a real desktop pipeline was built, and there must be no lookup.

Mutants, each built and run with startup_indirect_requests_warp (all fail):

Mutant Failure
The memo is bypassed 3 lookups for 3 calls, expected 1
A request on the compute-state refusal slot57-dispatch: 1 extra requests
A request even with a desktop pipeline desktop-draw: a desktop pipeline was looked up
The request call removed (earlier revision) 0 indirect-only requests, expected 1

Evidence and follow-up

  • The shaders are the synthetic gfx1013 programs from tests/startup_stream_draw_check.py. No title data is used.
  • The request is written whatever the target, viewport and topology state; only the pipeline decides it. The direct-draw path also checks targets and topology before writing.
  • Side effects:
    • Each refused graphics slot-61 call with a console pipeline now takes draw_lock for one map lookup, as a direct draw does.
    • The first call per pipeline also logs the x2w-draw pipeline ... blend from line, within its existing 24-line limit.
    • Only direct draws poll for a manifest (translation_for_targets). An indirect-only pipeline therefore stays in "missing" for the whole run. In a later run, once its manifest exists, it counts as "translated" even though it is never drawn. The pipelines requested by ExecuteIndirect N counter shows these pipelines separately.
  • CI reach: the check sits under if(EXISTS INTAKE_PYTHON) beside startup_slot57_blend_draw. It runs in the full non-hardware suites, not in the pr preset.
  • origin/main a2010c91 is merged in. The request stays on the refusal that #2180 labels graphics-pipeline, and that refusal keeps its reason index. The X2W_SHADER_CACHE docs row keeps #2120's run.ps1 -Translate sentence.
  • Overlap search (read-only):
    • #1803 (open) touches list_execute_indirect context.
    • #2067 (open) touches d3d12_draw.inl elsewhere.
    • #2181 (draft, GPU-counted indirect Dispatch records) and #2173 (draft, rectangle-list indirect Draw arguments) both change list_execute_indirect. I test-merged each PR head with this branch and with origin/main. Each already conflicts with origin/main (2 and 1 hunks in d3d12_xs_device.cpp). Merging this branch first adds no conflict hunk, and none of their conflict hunks touch this change's lines. No textual conflict with this change is expected beyond what they already have with main.
    • No open PR writes requests from slot 61.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed (X2W_SHADER_CACHE row in docs/startup-runtime.md: request, polling and the totals counter).
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted (Claude Code).

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6596400446 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2186). Originally posted by [NiiRoZz](https://github.com/NiiRoZz) on 2026-11-25T03:18:13Z. --- ## Change Translation requests (`req_<key>.{a,b,root}`) for console graphics pipelines were written only on the direct-draw path (`draw_translated` → `translation_for`). A pipeline used only through `ExecuteIndirect` (command-list slot 61) was never requested, so its translator gap never showed up in the shader cache. Slot 61 can refuse a graphics call because no desktop pipeline and root match; the `x2w-render indirect` line (#2180) counts that refusal as `graphics-pipeline`. When it does and the bound pipeline is a console pipeline (no desktop pipeline, `own().real` null), the stand-in now takes `draw_lock` and calls `translation_for` through a `request_translation` helper next to it. That is the direct-draw request writer: same key, same files, and once per pipeline through its per-pipeline map. Each recording remembers the last pipeline it asked for, so repeated refused calls skip `draw_lock`. Each lookup is logged (first 16). The `x2w-render totals` line now ends with `pipelines requested by ExecuteIndirect N`. That count is per pipeline, not per call, so it goes on the totals line beside `pipelines translated / missing`, not on the per-call `x2w-render indirect` line. Nothing is drawn. What is forwarded and refused is unchanged. Not a duplicate: - #2120 (merged) translates requests that already exist; it writes none. - #1750 (open) writes requests offline from the shader archive, so it overlaps in part. It writes each adjacent pixel/vertex pair once per root already in the cache (`req_*.root` from earlier runs). It covers an indirect-only pipeline only when another pipeline recorded the same root and its programs are adjacent in the archive. It cannot cover non-adjacent pairs or programs embedded in the executable. This change writes the exact key that the runtime pairing uses. Refs #1759 (ExecuteIndirect), #870. ## Verification Head `561af3a8` (`origin/main` `a2010c91` merged in, including #2180), branch `startup/indirect-pipeline-requests`. Windows 11 build 26300, release preset. Adapters: WARP (Microsoft Basic Render Driver, 10.0.26100.10068) and NVIDIA GeForce RTX 5090 (driver 32.0.16.2135). The `startup_indirect_*` C++ tests ran with the debug layer enabled. The consumer-based checks (`startup_indirect_requests`, `startup_slot57_blend_draw`, `startup_stream_draw`) ran without it (`X2W_D3D12_DEBUG=0`, no `X2W_TEST_DEBUG_LAYER`). ```powershell cmake --build --preset release --target startup_stream_consumer startup_indirect_dispatch startup_indirect_draw_indexed ctest --preset release --no-tests=error -R '^startup_(indirect_(requests|dispatch|root_constants|draw_indexed|draw|mesh|counts_control)|slot57_blend_draw|stream_draw)_(warp|hardware)$' # 100% tests passed, 0 tests failed out of 17 (no capability skips) git diff --check origin/main...HEAD # no output python -B tests/docs_links_check.py # Checked 18 Markdown files and 404 links. ``` How the fixture works: `startup_indirect_requests_{warp,hardware}` uses `startup_stream_consumer`, which gains two modes. - It builds the stream pipeline (slot 86, with an input layout so its key differs) and a device slot-57 pipeline from the same synthetic gfx1013 shaders and root. - `slot57-draw` binds the slot-57 pipeline and records three refused Draw calls. The cache must then hold exactly one extra request, carrying the slot-57 shaders and root, and each process must log exactly one lookup. Two processes into one cache must still give one extra request. - `slot57-bound` (negative control) binds the pipeline and records nothing. Only the stream pipeline's request may exist, and no lookup. - `slot57-dispatch` binds the same pipeline and records one Dispatch call, which is a compute-state refusal. It must write no request. - `desktop-draw` binds a slot-86 pipeline with desktop shaders and records one refused Draw call. The log must show that a real desktop pipeline was built, and there must be no lookup. Mutants, each built and run with `startup_indirect_requests_warp` (all fail): | Mutant | Failure | |---|---| | The memo is bypassed | `3 lookups for 3 calls, expected 1` | | A request on the compute-state refusal | `slot57-dispatch: 1 extra requests` | | A request even with a desktop pipeline | `desktop-draw: a desktop pipeline was looked up` | | The request call removed (earlier revision) | `0 indirect-only requests, expected 1` | ## Evidence and follow-up - The shaders are the synthetic gfx1013 programs from `tests/startup_stream_draw_check.py`. No title data is used. - The request is written whatever the target, viewport and topology state; only the pipeline decides it. The direct-draw path also checks targets and topology before writing. - Side effects: - Each refused graphics slot-61 call with a console pipeline now takes `draw_lock` for one map lookup, as a direct draw does. - The first call per pipeline also logs the `x2w-draw pipeline ... blend from` line, within its existing 24-line limit. - Only direct draws poll for a manifest (`translation_for_targets`). An indirect-only pipeline therefore stays in "missing" for the whole run. In a later run, once its manifest exists, it counts as "translated" even though it is never drawn. The `pipelines requested by ExecuteIndirect N` counter shows these pipelines separately. - CI reach: the check sits under `if(EXISTS INTAKE_PYTHON)` beside `startup_slot57_blend_draw`. It runs in the full non-hardware suites, not in the `pr` preset. - `origin/main` `a2010c91` is merged in. The request stays on the refusal that #2180 labels `graphics-pipeline`, and that refusal keeps its reason index. The `X2W_SHADER_CACHE` docs row keeps #2120's `run.ps1 -Translate` sentence. - Overlap search (read-only): - #1803 (open) touches `list_execute_indirect` context. - #2067 (open) touches `d3d12_draw.inl` elsewhere. - #2181 (draft, GPU-counted indirect Dispatch records) and #2173 (draft, rectangle-list indirect Draw arguments) both change `list_execute_indirect`. I test-merged each PR head with this branch and with `origin/main`. Each already conflicts with `origin/main` (2 and 1 hunks in `d3d12_xs_device.cpp`). Merging this branch first adds no conflict hunk, and none of their conflict hunks touch this change's lines. No textual conflict with this change is expected beyond what they already have with `main`. - No open PR writes requests from slot 61. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed (`X2W_SHADER_CACHE` row in `docs/startup-runtime.md`: request, polling and the totals counter). - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
upstream-sync closed this pull request 2026-11-25 04:04:11 +00:00
tedin7 commented 2026-11-25 04:04:12 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T03:21:35Z.

Review: COMMENTED


Review of head 561af3a806c8266f6f547138d3fdf3221183f677 (comment only).

Summary: the change is small and consistent. It reuses translation_for (same key, same files, once per pipeline via translation_by_pipeline()), takes draw_lock correctly, and resets requested_pipeline with the pass (pass = Pass{} at src/startup_stubs/d3d12_xs_device.cpp:1951). Title is neutral, no clean-room concerns seen. Mergeable: yes.

Commands executed locally in a worktree of this head:

  • git diff --stat origin/main...HEAD: 6 files, +200/-5.
  • python3 tests/docs_links_check.py: self-test passed, 18 Markdown files, 404 links OK.
  • python3 tests/bidi_controls_check.py: 1466 files, no bidirectional controls.
  • git diff --check origin/main...HEAD: clean.
  • python3 -I -m py_compile tests/startup_indirect_requests_check.py: OK.
  • gh pr checks 2186: Linux Python checks pass; Windows build/test and gfx1013 fixtures were still pending when I looked.

Not executed: the new startup_indirect_requests_* CTest and the C++ consumer need a Windows build, so I did not run them and did not do a logic mutation (the production logic is in the Windows-only D3D12 stand-in). The Windows run reported in the PR body is the evidence for those; please make sure the pending Windows CI job passes before merging.

Findings:

  • P1: none.
  • P2: none.
  • nit: request_translation logs "already known" only when another path (direct draw) created the entry first. The test covers the "new" case and the two-process case; a case where a direct draw and an indirect refusal share one pipeline would exercise the "already known" counter branch (indirect_requested not incremented). Optional.
  • nit: only the !root / root mismatch / mesh mismatch / non-direct list refusal branch (d3d12_xs_device.cpp:2157-2166) writes the request. Other slot-61 refusals (later checks) for a console pipeline do not. This matches the PR text ("no desktop pipeline and root match"), so just worth keeping in mind when reading the counter.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6051375202 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2186#pullrequestreview-6051375202). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T03:21:35Z. **Review:** COMMENTED --- Review of head `561af3a806c8266f6f547138d3fdf3221183f677` (comment only). Summary: the change is small and consistent. It reuses `translation_for` (same key, same files, once per pipeline via `translation_by_pipeline()`), takes `draw_lock` correctly, and resets `requested_pipeline` with the pass (`pass = Pass{}` at `src/startup_stubs/d3d12_xs_device.cpp:1951`). Title is neutral, no clean-room concerns seen. Mergeable: yes. Commands executed locally in a worktree of this head: - `git diff --stat origin/main...HEAD`: 6 files, +200/-5. - `python3 tests/docs_links_check.py`: self-test passed, 18 Markdown files, 404 links OK. - `python3 tests/bidi_controls_check.py`: 1466 files, no bidirectional controls. - `git diff --check origin/main...HEAD`: clean. - `python3 -I -m py_compile tests/startup_indirect_requests_check.py`: OK. - `gh pr checks 2186`: Linux Python checks pass; Windows build/test and gfx1013 fixtures were still pending when I looked. Not executed: the new `startup_indirect_requests_*` CTest and the C++ consumer need a Windows build, so I did not run them and did not do a logic mutation (the production logic is in the Windows-only D3D12 stand-in). The Windows run reported in the PR body is the evidence for those; please make sure the pending Windows CI job passes before merging. Findings: - P1: none. - P2: none. - nit: `request_translation` logs "already known" only when another path (direct draw) created the entry first. The test covers the "new" case and the two-process case; a case where a direct draw and an indirect refusal share one pipeline would exercise the "already known" counter branch (`indirect_requested` not incremented). Optional. - nit: only the `!root / root mismatch / mesh mismatch / non-direct list` refusal branch (`d3d12_xs_device.cpp:2157-2166`) writes the request. Other slot-61 refusals (later checks) for a console pipeline do not. This matches the PR text ("no desktop pipeline and root match"), so just worth keeping in mind when reading the counter. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-25 04:04:12 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T03:41:18Z.

Review: COMMENTED


Re-review of head 3efc640a0aa8b41e24ca5cb438a1fecfc8f17b4e (previous review covered 561af3a8; one new commit: "Distinguish indirect pipeline lookups from complete shader requests").

Result: no P1, no P2.

What I checked

  • The new commit only renames the counter and log to "first looked up by ExecuteIndirect" and adds the note to docs/startup-runtime.md that req_<key>.a is the ready marker. This matches the code: request_translation (src/startup_stubs/d3d12_draw.inl) counts a pipeline only when it was not in translation_by_pipeline(), so the counter is a lookup count, not a count of published files. The test now asserts the same wording.
  • Refusal path (d3d12_xs_device.cpp ~2157-2166): the request is made only for console pipelines (!own().real) with a bound pipeline. requested_pipeline is reset with pass = Pass{} at list reset (line 1951), so repeats within a list skip draw_lock. Nothing is drawn.
  • The doc sentence that only direct draws poll for the manifest, so such a pipeline stays in missing, is consistent with the diff.
  • CI on this head: Linux checks pass, Windows build and test pass, gfx1013 fixtures pass.
  • PR is not Draft, mergeable, title is neutral, no clean-room concerns seen.

Commands executed locally (Linux, in a worktree of this head)

  • git diff --stat origin/main...HEAD: 6 files, +200/-5
  • python3 tests/docs_links_check.py: self-test passed, 18 Markdown files, 404 links
  • python3 tests/bidi_controls_check.py: no bidirectional controls in 1466 files
  • git diff --check origin/main...HEAD: clean
  • python3 -I -m py_compile tests/startup_indirect_requests_check.py: ok

Not done

  • No source mutation run: the new test needs the Windows-only startup_stream_consumer (D3D12), so it cannot be built on Linux. I relied on the passing Windows CI job and did not queue the Windows VM.

Nits

  • nit: requested_pipeline is a raw pointer compared per list, so a pipeline freed and reallocated at the same address inside one list would be skipped. The window is one command list, so the impact is negligible.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6051527691 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2186#pullrequestreview-6051527691). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T03:41:18Z. **Review:** COMMENTED --- Re-review of head `3efc640a0aa8b41e24ca5cb438a1fecfc8f17b4e` (previous review covered `561af3a8`; one new commit: "Distinguish indirect pipeline lookups from complete shader requests"). **Result: no P1, no P2.** What I checked - The new commit only renames the counter and log to "first looked up by ExecuteIndirect" and adds the note to `docs/startup-runtime.md` that `req_<key>.a` is the ready marker. This matches the code: `request_translation` (`src/startup_stubs/d3d12_draw.inl`) counts a pipeline only when it was not in `translation_by_pipeline()`, so the counter is a lookup count, not a count of published files. The test now asserts the same wording. - Refusal path (`d3d12_xs_device.cpp` ~2157-2166): the request is made only for console pipelines (`!own().real`) with a bound pipeline. `requested_pipeline` is reset with `pass = Pass{}` at list reset (line 1951), so repeats within a list skip `draw_lock`. Nothing is drawn. - The doc sentence that only direct draws poll for the manifest, so such a pipeline stays in `missing`, is consistent with the diff. - CI on this head: Linux checks pass, Windows build and test pass, gfx1013 fixtures pass. - PR is not Draft, mergeable, title is neutral, no clean-room concerns seen. Commands executed locally (Linux, in a worktree of this head) - `git diff --stat origin/main...HEAD`: 6 files, +200/-5 - `python3 tests/docs_links_check.py`: self-test passed, 18 Markdown files, 404 links - `python3 tests/bidi_controls_check.py`: no bidirectional controls in 1466 files - `git diff --check origin/main...HEAD`: clean - `python3 -I -m py_compile tests/startup_indirect_requests_check.py`: ok Not done - No source mutation run: the new test needs the Windows-only `startup_stream_consumer` (D3D12), so it cannot be built on Linux. I relied on the passing Windows CI job and did not queue the Windows VM. Nits - nit: `requested_pipeline` is a raw pointer compared per list, so a pipeline freed and reallocated at the same address inside one list would be skipped. The window is one command list, so the impact is negligible. AI-assisted; commands listed were executed locally.
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!2178
No description provided.