Skip to content

startup: translate device slot 67 compute requests with the gfx2hlsl compute stage - #2223

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

R0Y00 merged 3 commits into
R0Y00:mainfrom
NiiRoZz:compute/slot67-translate

Conversation

@NiiRoZz

@NiiRoZz NiiRoZz commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Change

Based on main. Both pieces it connects are merged: the gfx2hlsl compute stage (#2182) and slot 67 request
publishing (#2195). This PR is the consumer between them, in one commit.

gfx2hlsl.py --pending and --watch now translate a req_<key>.c67 request instead of recording
compute stage not supported. The stand-in is unchanged and still creates a placeholder. Loading and
binding the result at run time is the next PR.

Request checks. A request is refused into <key>.fail, with no manifest, when:

  • a part is missing;
  • .desc is not 96 bytes;
  • a part's length disagrees with its size word in .desc (code word 6, data word 8, state blocks words 2
    and 4);
  • the files do not hash to the key in their name;
  • the code is empty, is not whole dwords, or has no s_endpgm.

No cache path reaches the .fail text: file errors become unreadable shader request, and DXC's file prefix
is stripped.

Translation. ComputePipeline(code, .root, rsrc2, group):

  • rsrc2 is state block A dword 6;
  • group is (dword 3 bits 15:0, dword 3 bits 31:16, dword 4 bits 15:0);
  • state block A must be 28 bytes.

This mapping is a hypothesis supported only by a local observation (below). The stand-in does not decode
these values.

Outputs.

  • <key>.cs.hlsl, then <key>.cs.cso (DXC cs_6_0 -Gis), then the stage cs manifest <key>.txt last.
    A stage refusal goes to <key>.fail with the stage's own reason.
  • pending_keys treats a compute request as done once <key>.txt and <key>.cs.cso exist.
  • X2W_FXC= (empty) publishes the manifest alone, as for graphics.
  • <key>.cs.cso has the same form as the slot 62 results of startup-d3d12: run compute pipelines that are already desktop DXIL #1441 in the same directory. The keys come from
    different hashes, so the names clash only on a 64-bit collision.

Refs #1412. Overlap:

Verification

Head ae0bcb9a, one commit on origin/main 2e4f44cb (which includes #2182, #2195, the compute D16 load guard and
#2139). Windows 11 build 26300, MSVC x64, DXC from Windows SDK 10.0.26100.0. Adapters, as printed by
offscreen_check:

  • Microsoft Basic Render Driver vendor=1414 device=008c;
  • NVIDIA GeForce RTX 5090 vendor=10de device=2b85, driver 32.0.16.2135.

Debug layer on, with debug_errors=0 debug_warnings=0.

cmake --build --preset dev --target startup_stream_consumer offscreen_check
ctest --preset dev --no-tests=error -R "^(startup_compute_(request|translate)_.*|startup_gfx2hlsl_compute_.*|startup_stream_request_warp|startup_indirect_requests_warp|startup_gfx2hlsl_watch|startup_gfx2hlsl_refusals|startup_translator|startup_tools_lint|startup_triage_run)$"

Result: 26 of 26 passed, with no skips. The selection includes all of #2182's controls on both adapters.

  • startup_compute_translate_e2e_warp and _hardware: all 320 words match.
  • startup_compute_translate_e2e_wrong_group_warp and _hardware: both
    rejected at word=5 expected=f5c0f122 actual=c5c5c5c5.

Also passed:

  • python -B tests/startup_compute_translate_check.py, pure Python, added to the CI list and AGENTS.md;
  • startup_compute_request_offline_check.py, which now expects the stage's refusal of its synthetic 24-byte
    state block A;
  • startup_gfx2hlsl_compute_check.py, startup_triage_run_check.py, docs_links_check.py and
    bidi_controls_check.py.

Evidence and follow-up

startup_compute_translate_requests (pure Python) writes requests with gfx2hlsl.compute_key:

  • case A of startup: add a compute stage to gfx2hlsl with the offen buffer store #2182's fixture, with a matching 28-byte state block, translates to a stage cs manifest with
    numthreads(2, 3, 4);
  • seven malformed requests are refused with no manifest: code of 0 bytes, code of 6 bytes, code without
    s_endpgm, a data size word that disagrees, a 24-byte state block, files renamed to another key, and a
    missing .root (whose .fail has no path);
  • the pending scan treats the translated request as done.

startup_compute_translate_e2e_<adapter> goes end to end:

  1. the stand-in publishes case A, with its program and root blob;
  2. --pending translates it and DXC compiles it;
  3. offscreen_check dispatches the published <key>.cs.cso and compares all 320 words with startup: add a compute stage to gfx2hlsl with the offen buffer store #2182's
    expectation.

The control swaps the group size in the state block and must mismatch.

What the e2e test proves: the request files, translation, compiled bytecode and dispatch fit together. It
does not prove the state-block mapping, because the fixture builds the block at the offsets the translator
reads.

Local observation (one title, local files only, counts only):

  • From an earlier local build of the request change, 2,689 requests: the group sizes read from state block A
    dwords 3 and 4 are within numthreads limits in all 2,689, with 43 distinct sizes.
  • Dword 6 has the RSRC2 layout. Bits 31:24 are zero, and the thread-ID count never exceeds the group's need;
    it covers Y > 1 in 2,671 of 2,689. TG_SIZE_EN is set in 91, which the stage refuses.
  • A local build of the request change, ported to an older base, published 2,689 requests. They were re-keyed
    offline with this branch's compute_key, which leaves the files unchanged and renames them. This PR's gfx2hlsl.py --pending
    (head ae0bcb9a, on current main) then translated and compiled 8 of 2,689 in 11 s, with no translator error.
    No request was refused by the request checks, and DXC rejected none of the 8.
  • First refusal per request (2,681 .fail files):
    • buffer_load_format_* requires descriptor FORMAT and DST_SEL: 1,280 (1,266 of them _x);
    • ... inside a block s_cbranch_execz skips per lane, for any instruction: 541;
    • s_load with a register offset through the resource heap: 158;
    • image_store: 110;
    • TG_SIZE_EN: 91.

Limits:

Follow-up:

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

…compute stage

gfx2hlsl.py --pending and --watch translate a req_<key>.c67 request with
ComputePipeline: COMPUTE_PGM_RSRC2 and the group size come from state
block A (dword 3 = X | Y << 16, dword 4 = Z, dword 6 = RSRC2), a
hypothesis from a local observation. The request is refused into
<key>.fail first when a part is missing, a length disagrees with its size
word in .desc, the files do not hash to the key in their name, or the code
is empty, not whole dwords or has no s_endpgm; no cache path reaches the
.fail text. Output: <key>.cs.hlsl, <key>.cs.cso (DXC cs_6_0), then the
stage cs manifest <key>.txt; pending_keys treats .txt plus .cs.cso as done.

startup_compute_translate_requests checks the refusals and the case A
manifest (pure Python, added to the CI list). startup_compute_translate_e2e
publishes case A through the stand-in, translates and compiles it and
dispatches all 320 words; its wrong-group control must mismatch. This
proves the plumbing, not the state-block reading. The offline request
check now expects the stage's refusal of its 24-byte state block A.

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 ae0bcb9a1f81ecf513e41a11b51172d58ba4ab20 (comment only).

Scope read: tools/startup/gfx2hlsl.py (compute_entry, load_compute_request, compute_refusals, translate_compute, pending_keys), the three tests, docs, CMake and workflow wiring. Mergeable. Title is neutral. No clean-room concerns seen.

Commands run locally (Linux):

  • python3 tests/startup_compute_translate_check.py -> pass (case A manifest, 5 malformed requests refused, renamed and incomplete refused)
  • python3 tests/startup_compute_request_check.py -> ran (usage text only; the negative control needs the Windows render path)
  • python3 tests/startup_compute_request_offline_check.py -> pass
  • python3 tests/docs_links_check.py -> pass (18 files, 410 links)
  • python3 tests/bidi_controls_check.py -> pass
  • git diff --check origin/main...HEAD -> clean

Mutations (both reverted with git checkout -- .):

  1. Swapped X and Y in compute_entry (dword 3 halves): the translate check fails (group 2 3 4 expected). Killed.
  2. Disabled the per-part size check in load_compute_request: the translate check fails (data size word returned ok). Killed.

Findings

  • P1: none.
  • P2: none.
  • nit tools/startup/gfx2hlsl.py translate_compute: if DXC fails after an older <key>.txt exists, that manifest stays in place next to the new .fail. pending_keys still treats it as done only when .cs.cso is valid, so this is harmless today, but removing the stale .txt on the failure paths would match the success path.
  • nit: the group-size and RSRC2 layout is documented as a hypothesis. That is honest and fine; keep the follow-up PR from relying on it without a second source.
  • Windows proof: not run here. CI "Build and test on Windows" and the gfx1013 fixtures job were still pending at review time. The change adds a DXC cs_6_0 compile, so a Win2025 pass is worth waiting for before Ready.

AI-assisted; commands listed were executed locally.

translate_compute removes <key>.txt on a failed compile, as the success path
does before publishing new bytecode, so no manifest is left next to
<key>.fail. startup_compute_translate_check: a pre-existing manifest and a
forced compile failure leave only the .fail, and pending_keys retries the
request. The docs census matches the PR body (541 s_cbranch_execz first
refusals, 11 s).

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

NiiRoZz commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

Thanks. Fixed in 04894d4a: a failed DXC compile now withdraws <key>.txt as the success path does. startup_compute_translate_check.py covers it with a manifest from an earlier pass plus a forced compile failure: only <key>.fail is left and pending_keys retries the request. The check fails without the fix.

The same commit brings the docs census in line with the PR body (541, 11 s). 26/26 of the ctest selection and the pure-Python checks pass.

On the second nit: agreed, the state-block layout stays a hypothesis here; the runtime loading step will not rely on it without a second source.

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 04894d4adf4c80b1dfc0200c6e5f584c91570437 (delta since ae0bcb9: withdraw a stale manifest when DXC fails).

Result: no P1. The new fix is correct and tested. Two P2 items, one nit.

Commands run locally on the PR worktree:

  • python3 tests/startup_compute_translate_check.py -> pass (includes the new "failed compile withdraws the manifest" case)
  • python3 tests/startup_compute_request_check.py -> pass (usage text only, no FAIL)
  • python3 tests/startup_compute_request_offline_check.py -> pass
  • python3 tests/docs_links_check.py -> 410 links OK
  • python3 tests/bidi_controls_check.py -> OK
  • git diff --check origin/main...HEAD -> clean
  • CI: Linux checks, gfx1013 fixtures and Windows build/test all pass. PR is mergeable. Title is neutral.

Mutations:

  1. Replace the os.remove(name + '.txt') in the DXC-failure path (tools/startup/gfx2hlsl.py:3205) with pass. The new test fails with "a manifest was left next to the failure". Killed.
  2. In pending_keys, change the compute stage list from ('.cs.cso',) to ('.vs.cso',). The test still passes. Survived.

Findings:

  • P2 tools/startup/gfx2hlsl.py (pending_keys, the stages = ... line): no test covers the non-manifest-only branch for c67. A request with a .txt but no .cs.cso should stay pending when X2W_FXC is not empty. Mutation 2 shows nothing guards it. Add one assertion with X2W_FXC unset: a .txt alone is pending, and .txt plus a real .cs.cso is done.
  • P2 translate_compute: the stale-manifest withdraw runs only when DXC runs and fails. The "dxc not found" path (around line 3190) writes .fail but leaves an older .txt in place. The Unsupported path from load_compute_request does the same. The key is a content hash, so this needs a manual cache edit or a toolchain change to hit. Still, the invariant "no manifest next to a .fail" is only partly kept. Remove .txt once in a shared spot before any .fail write.
  • nit: the .cs.hlsl file is always rewritten, even when DXC is missing. That is harmless, but it is another file that can go stale next to a .fail.

No Windows run was needed for this delta. It is Python cache handling only and has no shader or C++ change. CI already ran the Windows job.

AI-assisted; commands listed were executed locally.

@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 9c8457c0fe20b85935d8de9322a0e599cb0ed03d (delta since 04894d4: one commit, "Withdraw compute manifests before retrying slot 67 requests"; comment only).

Result: no P1. Previous P2 #2 is resolved. Previous P2 #1 is still open.

Previous findings

  • P2 #2 (stale .txt next to a .fail on the "dxc not found" and Unsupported paths): RESOLVED. translate_compute now removes <key>.txt once at the top (tools/startup/gfx2hlsl.py:3181-3182), before any .fail write, and the duplicate removals were dropped. The new test deletes req_<key>.root after a published run and checks the refusal and that no manifest remains.
  • P2 #1 (no test for the non-manifest-only branch of pending_keys for c67): STILL OPEN. The commit touches only the test lines above; no assertion was added with X2W_FXC unset.

Commands run locally (Linux, PR worktree at 9c8457c):

  • python3 tests/startup_compute_translate_check.py -> pass (includes the new "refused request withdraws the manifest" case)
  • python3 tests/startup_compute_request_offline_check.py -> pass
  • python3 tests/startup_compute_request_check.py -> usage text only (needs the Windows render path), no FAIL
  • python3 tests/docs_links_check.py -> 410 links OK
  • python3 tests/bidi_controls_check.py -> OK
  • git diff --check origin/main...HEAD -> clean
  • CI at this head: Linux checks, gfx1013 fixtures and Windows build/test pass; /O2 and chart jobs skipped. PR is mergeable, not draft, title neutral.

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

  1. Replace the new os.remove(name + '.txt') at line 3182 with pass: translate check fails with "a manifest was left next to a refused request". Killed.
  2. In pending_keys (line 3719) change the c67 stage tuple ('.cs.cso',) to ('.vs.cso',): translate check and offline check both still pass. SURVIVED (same as last round).

Findings

  • P2 tests/startup_compute_translate_check.py / tools/startup/gfx2hlsl.py:3719: the c67 .cs.cso stage rule in pending_keys is unguarded. The existing "done" assertion runs with X2W_FXC="" (manifest-only), where the stage list is not consulted. Add, with X2W_FXC unset: a .txt alone keeps the key pending; .txt plus a non-empty .cs.cso makes it done. That kills mutation 2.
  • No new P1 or other P2.

Windows proof: not run here. The delta is Python-only manifest handling, and CI Windows build/test passes at this head.

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