Repository navigation
startup: publish translation requests for device slot 67 compute pipelines - #2195
Conversation
…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
left a comment
There was a problem hiding this comment.
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 failedpython3 tests/docs_links_check.py-> pass (18 files, 406 links)python3 tests/bidi_controls_check.py-> passgit diff --check origin/main...HEAD-> cleantests/startup_compute_request_check.pyneeds 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_keyin order and framing. - All parts are copied once with the fault-safe copy before hashing and writing. Pointer words are zeroed before they reach
.descor the key. The.c67marker 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 -- .):
- Changed the compute marker pattern in
request_keysfrom.c67to.c68.startup_triage_run_check.pystill passed (survived on Linux). - Swapped the order of
cs_codeanddataincompute_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:2709and:2953): the Linux-side compute logic (compute_key,request_keys(compute=True),compute_refusals_report, the.c67pattern inpending_keys) has no Linux test, as the two mutations show. A small fixture check (a literal key vector forcompute_key, plus a cache dir with areq_*.c67file run through--refusalsand--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>
|
Thanks. Added Both mutations now fail it locally:
AI-assisted (Claude Code). |
tedin7
left a comment
There was a problem hiding this comment.
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, +72python3 -B tests/startup_compute_request_offline_check.py-> passpython3 -B tests/startup_triage_run_check.py->0 failedpython3 tests/docs_links_check.py-> pass (18 files, 406 links)python3 tests/bidi_controls_check.py-> passgit diff --check origin/main...HEAD-> clean
Mutations tried (each reverted with git checkout -- .):
.c67->.c68intools/startup/gfx2hlsl.py: the new test fails (AssertionError). Killed. Before this commit it survived.- Swapped
cs_codeanddatain thecompute_keyloop (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
KEYis produced by the same Python function it checks. That is fine as a drift guard, and the independentframed_key()covers the framing rule. Nothing to change. - Nit (unchanged):
pointer_like_qwordscan count a hash-like value as a pointer. It is only a counter.
AI-assisted; commands listed were executed locally.
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_requestwriter, the same write-once-per-key rule and the same--pending/--watchscan. The producer comes first because no translator can be built or measured againstreal 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) withX2W_SHADER_CACHEset, 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 alwayszero, 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 theblock 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.
written, so a later write by the title cannot leave a file that does not match its key.
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.
Key. A length-framed FNV-1a chain over
x2w-startup-shader-8cs(the graphics revision followed bycs).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.
.descor the key.those targets are decoded later, every key changes and each request is published once more.
.data,.saand.sbthat name committed memory are counted, not refused: oneVirtualQueryper candidate, so no fault is taken. Hash-like values can name memory by chance. The code isnot scanned.
Dedupe and cost.
.c67yet) are kept, and the next creation completes the request.draw_lock.x2w-render totalsline ends withcompute 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/--watchtake.c67as a ready marker and recordcompute stage not supportedin<key>.fail. The request waits in the cache, and a later--pendingretries it.
--refusalsreports compute requests in their own section, so the graphics statistics do notmove.
triage_run.pycounts their.failreasons under acompute: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. Computepipelines 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 (
.aand.c67).Overlap:
req_<key>.cs(slot 62 desktop DXIL) with<key>.cs.srcas its ready marker. That is why thisPR uses
.c67, so the two coexist.<key>.cs.cso.d3d12_xs_device.cpp.gfx2hlsl.py.Refs #1412.
Verification
Head
607a96a7onorigin/maina116c379. Windows 11 build 26300, MSVC x64, WARP (Microsoft Basic RenderDriver 10.0.26100.10068).
Result: 11 of 11 passed, with no skips.
startup_compute_request_disabled_controlprintedFAIL: no compute request. Also passed:docs_links_check.py,bidi_controls_check.py,startup_triage_run_check.pyandstartup_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 anaddress: each is below 0x10000 or at or above 2^47. It checks that:
and 10 pointing into the consumer;
gfx2hlsl.compute_key, and thatmoving bytes between parts changes it;
PAGE_NOACCESSpage;--pendingand--refusalsrecordcompute 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):
98.8 MB of it
.c67. It counted 729 pointer-like blob qwords.changed no modification times.
and 8. State block A is 28 bytes and state block B 20 bytes.
Limits.
at least 4 KiB.
Follow-up: translation with the compute stage of #2182 (next PR), then runtime loading and binding.
Checklist
AI-assisted (Claude Code); the commands above were run locally.
🤖 Generated with Claude Code