Skip to content

startup: publish translation requests for device slot 67 compute pipelines - #2195

Merged
R0Y00 merged 2 commits into
R0Y00:mainfrom
NiiRoZz:compute/slot67-requests
Nov 25, 2026
Merged

R0Y00 merged 2 commits into
R0Y00:mainfrom
NiiRoZz:compute/slot67-requests

Conversation

@NiiRoZz

@NiiRoZz NiiRoZz commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Change

Device slot 67 creates pipelines from console gfx1013 compute programs. Today the stand-in returns a
placeholder and writes nothing, so no offline tool can see these programs. This PR adds the producer side:
the stand-in writes a translation request through the existing shader request/cache protocol. It uses the same
cache directory, the same publish_shader_request writer, the same write-once-per-key rule and the same
--pending/--watch scan. The producer comes first because no translator can be built or measured against
real compute programs until they reach the cache. The consumer (translation with the compute stage of #2182)
is the next PR and already works locally against these requests. Nothing drawn or dispatched changes:
every slot 67 pipeline stays a placeholder.

Format. In render mode (X2W_D3D12_RENDER=1) with X2W_SHADER_CACHE set, a slot 67 creation writes:

  • req_<key>.desc: the 12 description words. The seven pointer words (0, 1, 3, 5, 7, 9 and 10) are always
    zero, so no process address reaches a file or the key.
  • req_<key>.sa, .sb: the two state blocks (words 1-2 and 3-4), at most 4 KiB each. A size of 0 means the
    block is absent.
  • req_<key>.data: the words 7-8 blob, at most 1 MiB, required.
  • req_<key>.root: the serialized root signature.
  • req_<key>.c67: the code (words 5-6), at most 1 MiB, written last as the ready marker.

Reading rules.

  • Each part is checked, then copied once with a fault-safe copy. The copy is what gets hashed, scanned and
    written, so a later write by the title cannot leave a file that does not match its key.
  • If any declared part cannot be taken, the request is refused before a file is written and counts as failed.
    That covers a size of 0 or over its limit, a part unreadable to its declared end, an unreadable description,
    and a root signature without a recorded blob.
  • The logged reason names the part and the cause.
  • A cache directory that is set but missing makes every creation fail.

Key. A length-framed FNV-1a chain over x2w-startup-shader-8cs (the graphics revision followed by cs).
Each part is preceded by its u64 length, so moving bytes between parts changes the key. A compute key and a
graphics key share one hash, so they can still coincide through a 64-bit collision, or through a graphics
program crafted to start with the compute framing.

Pointer rules.

  • Pointer words never reach .desc or the key.
  • Words 9 and 10 are not followed. Two descriptions that differ only in what they point to share a key. If
    those targets are decoded later, every key changes and each request is published once more.
  • Aligned qwords in .data, .sa and .sb that name committed memory are counted, not refused: one
    VirtualQuery per candidate, so no fault is taken. Hash-like values can name memory by chance. The code is
    not scanned.
  • Such qwords would make their key run-dependent, which is why the totals line reports them.

Dedupe and cost.

  • Each key is written once per cache.
  • Parts left by an interrupted write (no .c67 yet) are kept, and the next creation completes the request.
  • A key already seen in the process costs no file access.
  • Writes take their own lock, not draw_lock.
  • The x2w-render totals line ends with
    compute requests published N (already present N, failed N, pointer-like blob qwords N).
    This comes after the existing pipelines first looked up by ExecuteIndirect N.

Offline handling. gfx2hlsl.py --pending/--watch take .c67 as a ready marker and record
compute stage not supported in <key>.fail. The request waits in the cache, and a later --pending
retries it. --refusals reports compute requests in their own section, so the graphics statistics do not
move. triage_run.py counts their .fail reasons under a compute: class.

Relation to the ExecuteIndirect requests (#2186). That path writes graphics requests at the point of use:
when slot 61 refuses a console pipeline, it calls the direct-draw request writer translation_for. Compute
pipelines are requested at creation instead, as slot 86 streams are, because slot 67 creation already has
every part the request needs and no translated compute pipeline is looked up yet. Both paths share the cache
directory, the writer and the totals line, and use different ready markers (.a and .c67).

Overlap:

Refs #1412.

Verification

Head 607a96a7 on origin/main a116c379. Windows 11 build 26300, MSVC x64, WARP (Microsoft Basic Render
Driver 10.0.26100.10068).

cmake --build --preset dev --target startup_stream_consumer
ctest --preset dev --no-tests=error -R "^(startup_compute_request_.*|startup_stream_request_warp|startup_slot57_blend_draw_warp|startup_stream_draw_warp|startup_indirect_requests_warp|startup_gfx2hlsl_watch|startup_gfx2hlsl_refusals|startup_translator|startup_tools_lint|startup_triage_run)$"

Result: 11 of 11 passed, with no skips. startup_compute_request_disabled_control printed
FAIL: no compute request. Also passed: docs_links_check.py, bidi_controls_check.py,
startup_triage_run_check.py and startup_gfx2hlsl_export_mask_check.py.

Evidence and follow-up

The fixture (tests/startup_compute_request_check.py) is source-built and synthetic. None of its qwords is an
address: each is below 0x10000 or at or above 2^47. It checks that:

  • the six files hold the exact bytes, including a 20-byte state block B and zeroed pointer words, with words 9
    and 10 pointing into the consumer;
  • the key equals the test's own length-framed FNV of the runtime literal and gfx2hlsl.compute_key, and that
    moving bytes between parts changes it;
  • two creations in each of two processes write the files once;
  • each of 13 refusals writes no file, and the expected reason is logged:
    • zero code or data size;
    • no root;
    • code, data, state A or state B one byte over its limit;
    • code, data, state A, state B or the description on a PAGE_NOACCESS page;
    • code ending one byte before a guard page;
  • code, data and both state blocks at exactly their limits publish;
  • valid, refused, valid publishes the two valid keys;
  • a missing cache directory fails every creation;
  • an interrupted earlier write is completed without rewriting its parts;
  • a data qword naming committed memory is counted;
  • --pending and --refusals record compute stage not supported.

The negative control turns render mode off.

Local observation (a local build of this change ported to an older base; one title, local files only; counts
only):

  • One run published 2,689 requests with 0 failed. That is 2,689 files of each of the six kinds, 120.3 MB new,
    98.8 MB of it .c67. It counted 729 pointer-like blob qwords.
  • A second run with the same cache published 0 (2,689 already present, 0 failed), wrote no new files and
    changed no modification times.
  • An earlier build with the same layout found that in every request the code and blob lengths equal words 6
    and 8. State block A is 28 bytes and state block B 20 bytes.

Limits.

  • The slot 67 word meanings beyond sizes and pointers are not decoded.
  • What words 9 and 10 point to is not in the key. The first 40 descriptions point there at a readable block of
    at least 4 KiB.
  • Pointer-like blob qwords are counted, not removed.

Follow-up: translation with the compute stage of #2182 (next PR), then runtime loading and binding.

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.
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted (Claude Code); the commands above were run locally.

🤖 Generated with Claude Code

…lines

In render mode with X2W_SHADER_CACHE set, a slot 67 creation writes
req_<key>.desc (12 description words, the seven pointer words zeroed),
.sa, .sb (state blocks), .data (words 7-8 blob), .root, then .c67 (the
gfx1013 code) last as the ready marker. Each part is checked, then copied
once with a fault-safe copy and hashed, scanned and written from the copy.
Any declared part that cannot be taken (zero or oversize size, unreadable
to its end, no root blob) refuses the request before a file is written.
The key is a length-framed FNV chain after the graphics revision plus
"cs". Seen keys are kept in memory and written under their own lock;
parts left by an interrupted write are completed. Qwords in the blobs
that name committed memory (VirtualQuery) are counted. The pipeline stays
a placeholder; nothing drawn or dispatched changes.

gfx2hlsl.py takes .c67 as a ready marker and records "compute stage not
supported" in <key>.fail, so requests wait for a compute stage; --refusals
and triage_run report compute requests in their own section.

Tests: startup_compute_request_warp (files, key, dedupe, refusals and
limits with guard pages, interrupted write) and the disabled control.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

@tedin7 tedin7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of head 607a96a78f9b76cf24d14188f57ed5941589bef6 (comment only).

State: MERGEABLE. CI on this head: Linux Python checks pass, gfx1013 fixtures pass, Windows build and test pass (the /O2 job and the chart job were skipped). Title is neutral. No clean-room concern seen in the diff.

Commands executed locally (Linux):

  • git diff --stat origin/main...HEAD: 9 files, +591/-10.
  • python3 tests/startup_triage_run_check.py -> 0 failed
  • python3 tests/docs_links_check.py -> pass (18 files, 406 links)
  • python3 tests/bidi_controls_check.py -> pass
  • git diff --check origin/main...HEAD -> clean
  • tests/startup_compute_request_check.py needs the Windows consumer binary, so it was not run locally. I relied on the Windows CI job. I did not queue a Windows VM run.

Read-through (d3d12_draw.inl publish_compute_request, gfx2hlsl.py compute_key):

  • The C++ key chain (revision literal, then code, data, root, fields, state A, state B, each length-framed) matches compute_key in order and framing.
  • All parts are copied once with the fault-safe copy before hashing and writing. Pointer words are zeroed before they reach .desc or the key. The .c67 marker is written last. This looks correct.
  • Refusals happen before any file is written, and the state blocks are optional while code and data are required. Correct.

Mutations tried (each reverted with git checkout -- .):

  1. Changed the compute marker pattern in request_keys from .c67 to .c68. startup_triage_run_check.py still passed (survived on Linux).
  2. Swapped the order of cs_code and data in compute_key. No Linux test failed (survived on Linux). Only the Windows WARP check compares it with the C++ key.

Findings:

  • P1: none.
  • P2: none.
  • Nit (tests/startup_triage_run_check.py, tools/startup/gfx2hlsl.py:2709 and :2953): the Linux-side compute logic (compute_key, request_keys(compute=True), compute_refusals_report, the .c67 pattern in pending_keys) has no Linux test, as the two mutations show. A small fixture check (a literal key vector for compute_key, plus a cache dir with a req_*.c67 file run through --refusals and --pending) would let the Linux job catch drift.
  • Nit (d3d12_draw.inl, pointer_like_qwords): the author already notes the hash-like false positive as a shortcut. It is only a counter, so there is no correctness impact.
  • Nit: the PR is not marked Draft. Only the head SHA above was reviewed.

AI-assisted; commands listed were executed locally.

A literal key vector for compute_key (also computed in the test from the
framing rule) and a cache directory with one synthetic req_<key>.c67
request run through request_keys, pending_keys, --pending and --refusals,
so the Linux job catches drift in the marker pattern, the key order and the
compute section. Both review mutations (.c67 -> .c68 in request_keys,
swapped code and data in compute_key) now fail it.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@NiiRoZz

NiiRoZz commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

Thanks. Added bd07e41f: a pure-Python tests/startup_compute_request_offline_check.py (in the Linux list, AGENTS.md and ctest startup_compute_request_offline). It pins compute_key to a literal vector, also recomputed in the test from the framing rule, and runs one synthetic req_<key>.c67 request through request_keys, pending_keys, --pending and --refusals --json.

Both mutations now fail it locally: .c67 → .c68 in request_keys, and swapped code and data in compute_key (1d1c50f3243e8088 != 29c6e5148934abc8).

ctest --preset dev --no-tests=error -R "^(startup_compute_request_(offline|warp|disabled_control)|startup_gfx2hlsl_refusals|startup_triage_run|startup_tools_lint)$": 6/6 passed on Windows. The new check needs no Windows or D3D12.

AI-assisted (Claude Code).

@tedin7 tedin7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review of head bd07e41f801537bac743a4ff6a45b724a9dc8054 (comment only). Previous review was on 607a96a7.

State: MERGEABLE. CI on this head: Linux Python checks pass, gfx1013 fixtures pass, Windows build and test pass (the /O2 job and the chart job were skipped). Title is neutral. No clean-room concern seen.

What changed since 607a96a7: one commit, 4 files, +72. It adds tests/startup_compute_request_offline_check.py and registers it in CMakeLists.txt, .github/workflows/windows.yml and AGENTS.md. No production code changed. This answers my earlier nit about missing Linux coverage.

Commands executed locally (Linux):

  • git diff --stat 607a96a7 HEAD -> 4 files, +72
  • python3 -B tests/startup_compute_request_offline_check.py -> pass
  • python3 -B tests/startup_triage_run_check.py -> 0 failed
  • python3 tests/docs_links_check.py -> pass (18 files, 406 links)
  • python3 tests/bidi_controls_check.py -> pass
  • git diff --check origin/main...HEAD -> clean

Mutations tried (each reverted with git checkout -- .):

  1. .c67 -> .c68 in tools/startup/gfx2hlsl.py: the new test fails (AssertionError). Killed. Before this commit it survived.
  2. Swapped cs_code and data in the compute_key loop (gfx2hlsl.py:2715): the new test fails (1d1c50f3243e8088 != 29c6e5148934abc8). Killed. Before this commit it survived.

Read-through of the new test: it checks the key against an independent framing implementation and against a literal vector, then runs a synthetic cache directory through request_keys, pending_keys, --pending and --refusals --json. It asserts caller-visible output (the .fail file, the report, no manifest). It is registered in all three places the sibling checks use. The C++ side is still checked by the Windows job only, which passed in CI. I did not queue a Windows VM run, since this commit touches no C++ or shader code.

Findings:

  • P1: none.
  • P2: none.
  • Nit: the literal KEY is produced by the same Python function it checks. That is fine as a drift guard, and the independent framed_key() covers the framing rule. Nothing to change.
  • Nit (unchanged): pointer_like_qwords can count a hash-like value as a pointer. It is only a counter.

AI-assisted; commands listed were executed locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants