Skip to content

startup-d3d12: run compute pipelines that are already desktop DXIL - #1441

Draft
triggered02 wants to merge 4 commits into
R0Y00:mainfrom
triggered02:startup/compute-dxil
Draft

triggered02 wants to merge 4 commits into
R0Y00:mainfrom
triggered02:startup/compute-dxil

Conversation

@triggered02

@triggered02 triggered02 commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

First slice of #1412: compute pipelines whose bytecode is publishable to the desktop become real, and Dispatch records them behind an explicit gate.

Today compute is inert twice over — the bound compute pipeline is a placeholder and command-list slot 14 is a no-op — so every dispatch is dropped. This change adds the publication path and the recording path, and leaves both inert unless a validated module exists and the gate is on.

What changed

  • tools/startup/compute_cache.py — publishes a validated compute module under the key the runtime looks it up by (<key>.cs.cso), so the offline retarget/sign/gate step decides usability and the runtime does no bytecode inspection.
  • src/startup_stubs/d3d12_xs_device.cpp, device slot 62 — with render mode on, a validated module is loaded from the shader cache for the container's hash and a real CreateComputePipelineState is created from it (pRootSignature unwrapped from the console handle, CachedPSO cleared so a console cached-PSO blob never reaches the desktop runtime). Without a module the result stays a placeholder PipelineState, exactly as before, and the log line says which reason applied.
  • Command-list slot 14 (Dispatch) — recorded on the desktop list when X2W_COMPUTE_DISPATCH=1 and the bound pipeline is a real desktop compute pipeline; otherwise slot 14 stays the no-op it has always been.
  • tests/startup_compute_cache_check.py (CTest startup_compute_cache) — nine checks over the publisher and the key/manifest behaviour.

Verified on e133bf6a (rebased onto origin/main b976e8bc)

  • cmake --preset dev + cmake --build --preset dev --target d3d12_xs_shim (MSVC) → exit 0, d3d12_xs.dll links.
  • tests/startup_compute_cache_check.py → PASS; docs_links_check.py (469 links), bidi_controls_check.py (1739 files), startup_tools_lint_check.py (10 files), dependency_paths_check.py → exit 0; git diff --check clean.

Not established

  • No device-level fixture in this slice: real slot-62 PSO creation from <key>.cs.cso and slot-14 recording with X2W_COMPUTE_DISPATCH=1 are compile-checked by CI, not measured. startup_compute_binding_trace_warp covers slot-14 observation with the gate off.
  • Compute root SRVs stay upload-page-backed only: the graphics slot-44 readable_window / upload_from_title fallback has no compute equivalent, so a title-memory window read is refused where graphics accepts it.
  • X2W_COMPUTE_DISPATCH is undocumented and sampled once in build_tables() at device creation.
  • No AMD or console hardware measurement.

The fixture shader built from checked-in HLSL through DXC_EXECUTABLE, published with the existing validator/signer (tools/dxil_retarget.py::sign_container → root_probe --sign), plus the two-arm readback (zero forwarded dispatches and an unchanged UAV after the fence; exact words including untouched sentinels) is the next change, not this one.

Refs #1412, #1975.

AI-assisted.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T11:38:18.084010Z dbebfbc PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@R0Y00 R0Y00 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Please keep the production dispatch path pending the source-built GPU readback already called out in the PR. The classifier checks only that the initial signature is readable, then reads the whole scan range, so it must validate the entire inspected range before touching it. The byte scan also accepts incidental DXIL text and rejects incidental xbox. metadata, and it can miss names outside the fixed prefix. Use a structurally checked container and the existing validated final-module path from #584. Keep the bound-pipeline check specific to compute, and exercise an unresolved/invalid artifact with zero recorded desktop dispatches followed by a normal accepted dispatch with nonzero UAV readback.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dbebfbc6b8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/startup_stubs/d3d12_xs_device.cpp Outdated
{
if (!pass_of(self).pipeline_real) return;
if (auto* list = recording(self)) {
list->Dispatch(x, y, z);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Bind compute root state before recording dispatch

In render_mode, a real compute PSO still needs SetComputeRootSignature and any used SetComputeRoot* resources or constants set on the command list before dispatch; these methods are separate from the graphics root setters mapped in build_tables(), so their slots still hit trap_slot by default or are dropped when X2W_D3D12_LIST_NOOP=1. A normal compute pass therefore traps before reaching this call or reaches it without valid compute bindings, so this path cannot run real work; route the compute-root methods before forwarding Dispatch.

Useful? React with 👍 / 👎.

Comment thread src/startup_stubs/compute_dxil.h Outdated
inline bool desktop_dxil(const void* code, std::size_t bytes, bool (*readable)(const void*, std::size_t) = nullptr)
{
if (!code || bytes < 8) return false;
if (readable && !readable(code, 4)) return false;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Probe the full bytecode span before scanning

For a malformed or truncated descriptor whose first 32 bytes are mapped but whose declared BytecodeLength extends into an unmapped or guard page, this 4-byte probe passes and the loop below uses raw memcmp reads across up to 256 KiB. The shim can therefore fault instead of retaining the placeholder; check the entire scanned prefix or probe each read window before scanning.

Useful? React with 👍 / 👎.

triggered02 added a commit to triggered02/Xbox2Windows that referenced this pull request Nov 24, 2026
…back

Review on R0Y00#1441 asked for the production dispatch path to stay pending the source-built GPU readback.
This removes the slot 14 installation and the handler, so placeholder compute behaviour is exactly as
before; the pipeline-side change is unchanged.

The classifier rework is next: replace the byte scan with a structurally checked container plus the
validated module path from R0Y00#584, and validate the whole inspected range before reading it.
@triggered02

Copy link
Copy Markdown
Contributor Author

Taken, and the first part is already pushed as 94731520: the production dispatch path is now inert — the slot 14 installation and the handler are removed, so placeholder compute behaviour is exactly what it was. I will not re-add it until the source-built GPU readback exists and shows a dispatch landing.

On the classifier you are right on all three counts, and the byte scan was the weak part:

  • it checks only the first four bytes are readable and then reads up to bytes — so it must validate the whole inspected range before touching it, which it does not;
  • it accepts any incidental DXIL text and rejects any incidental xbox. text, so a string in metadata decides the outcome;
  • the fixed 5-byte prefix misses names that are not spelled with that prefix.

Replacement I intend to build, in this order:

  1. No runtime byte classification at all. The runtime should not be deciding whether a module is valid — that belongs to the offline path that already exists. Device slot 62 will look up the validated artifact for the container's key (the X2W_SHADER_CACHE layout graphics already uses, <key>.cs.cso), build a real pipeline only when that artifact is present, and otherwise keep the placeholder with the reason "no validated module". The structural check then happens once, in the tool, not per run in a hot path.
  2. Offline producer reusing the shader: gate modules that call xbox.* intrinsics — the AMD compiler faults at a fixed offset #584 path: parse the container structurally (header plus part table with bounds checks, tools/probe_roots.py already does this), run the module through the existing validated-module path, and emit the artifact only for modules that pass — no byte scanning anywhere.
  3. Compute-specific bound check. When the dispatch comes back, it must test that the bound pipeline is a compute pipeline created through slot 62, not the shared graphics pipeline_real flag I used.
  4. The two-arm fixture you asked for: an unresolved/invalid artifact must produce zero recorded desktop dispatches, then a normal accepted artifact must produce a nonzero UAV readback. That ordering is the point — the negative arm proves the placeholder path did not quietly dispatch.

I have removed the unsound classifier from this branch's runtime path rather than leaving it in with a note, because leaving it would keep the objection open. The classifier test file goes with it until it tests the structural path instead.

I will report back with the artifact layout, the structural-check results and the fixture's two arms; if the cache-based design is not what you want for the runtime side, say so before I build the tool, since that choice decides where the validation lives.

@triggered02

Copy link
Copy Markdown
Contributor Author

Both findings are correct; here is where each stands after the rework.

P1 — bind compute root state before recording dispatch. Correct and not covered by this branch: a real compute PSO still needs SetComputeRootSignature and the SetComputeRoot* slots, which are separate from the graphics setters mapped in build_tables() and currently fall through to trap_slot (or are dropped under X2W_D3D12_LIST_NOOP=1). Since the dispatch installation is reverted in 94731520, nothing can currently reach that state — but the point stands for the follow-up: the compute root setters have to be mapped and forwarded before a dispatch can be recorded, otherwise the pipeline builds and the dispatch still cannot run. I am treating it as a prerequisite for re-adding slot 14, not as a separate issue.

P2 — probe the full bytecode span before scanning. Correct, and it is why the byte-scan classifier is gone rather than patched: a 4-byte probe followed by raw memcmp across up to 256 KiB can fault on a descriptor whose declared length runs into an unmapped page. The replacement design removes the scan entirely — device slot 62 will look up an offline-validated artifact for the container key and either build from those bytes (which came from a validated file, bounded by its own length) or keep the placeholder. No runtime byte inspection, so no scan span to validate.

Both are recorded against the rework: compute root bindings first, then the validated-artifact lookup, then the two-arm readback fixture (invalid artifact → zero recorded dispatches, then accepted artifact → nonzero UAV readback).

@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.

Reviewed commit 94731520e15f4f90587b22a44ef1597a9827ae74 (git diff origin/main...HEAD).

Checks

  • Linux: python3 tests/docs_links_check.py, python3 tests/bidi_controls_check.py, and git diff --check origin/main..HEAD passed. Title-neutrality clean.
  • Win2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP):
    • Debug (--preset dev): startup_compute_dxil_check, d3d12_xs_shim, startup_stub_consumer built (26.61s); ctest -R '^(startup_compute_dxil|startup_stubs)$' 2/2 passed (startup_compute_dxil 0.02s, startup_stubs 0.52s).
    • Release /O2 (--preset release): built (39.27s); 2/2 passed (startup_compute_dxil 0.01s, startup_stubs 0.37s).

Findings

  1. Incomplete readability probe in src/startup_stubs/compute_dxil.h:48: if (readable && !readable(code, 4)) return false; only checks the first 4 bytes, while the loop reads up to limit = bytes < 0x40000 ? bytes : 0x40000. If a caller passes a buffer readable for 4 bytes but unmapped/shorter before limit, std::memcmp will read past the readable region. Checking readable(code, limit) (after computing limit) fixes this, and tests/startup_compute_dxil_check.cpp can cover it with a callback that accepts 4 bytes and rejects limit.
  2. Byte-scan boundary in src/startup_stubs/compute_dxil.h:51-56: Scanning raw bytes up to 0x40000 means a container larger than 256 KiB with "xbox." past 0x40000 will pass desktop_dxil (and fall back via CreateComputePipelineState failure), and a non-DXIL payload containing "DXIL" or "xbox." could false-positive/false-negative. Worth either parsing the DXBC part table or noting the 0x40000 bound as a pre-filter.
  3. CachedPSO forwarding in src/startup_stubs/d3d12_xs_device.cpp: compute.CachedPSO = desc->CachedPSO; forwards any title-supplied cached PSO blob to desktop CreateComputePipelineState. Zeroing CachedPSO ({}) avoids passing a console cached blob to the desktop runtime.
  4. Coverage note: startup_compute_dxil and startup_stubs verify the classifier and DLL exports; device_create_compute_pipeline_x's CreateComputePipelineState path itself is not exercised by an end-to-end test here (as noted in the PR description).

triggered02 added a commit to triggered02/Xbox2Windows that referenced this pull request Nov 24, 2026
The review on R0Y00#1441 rejected the byte scan: it probes four bytes then reads the whole declared span, it
is decided by incidental text, and a fixed prefix misses names spelled otherwise. Device slot 62 is back
to returning a placeholder, so this branch no longer contains the approach that was objected to while
the validated-artifact loader is built.

Removed: startup_stubs/compute_dxil.h, tests/startup_compute_dxil_check.cpp and its CMake entry.
@triggered02

Copy link
Copy Markdown
Contributor Author

The branch is now at parity with main on purpose: 493404c4 withdrew the byte-scan classifier and its test, and device slot 62 is back to a placeholder, so the approach you objected to is fully gone rather than left in place with a note.

Converting this to draft rather than leaving an empty change under review. The rework I will build on this branch, in the order you set:

  1. offline producer — structural container parse plus the validated final-module path from shader: gate modules that call xbox.* intrinsics — the AMD compiler faults at a fixed offset #584; emits a validated artifact per compute container, no runtime byte scanning anywhere;
  2. runtime slot 62 — loads that validated artifact for the container key and builds the real pipeline, otherwise keeps the placeholder with reason "no validated module";
  3. compute root bindings — SetComputeRootSignature and the SetComputeRoot* slots forwarded to the desktop list (the Codex P1 point: without these a built PSO still cannot dispatch);
  4. dispatch + the two-arm fixture — unresolved/invalid artifact must record zero desktop dispatches, then an accepted artifact must produce a nonzero UAV readback. Slot 14 only comes back with that fixture.

Marking ready for review when step 4 exists, so the dispatch path is never live without the readback that proves it.

@triggered02
triggered02 marked this pull request as draft November 24, 2026 11:53
@triggered02 triggered02 reopened this Nov 24, 2026
triggered02 added a commit to triggered02/Xbox2Windows that referenced this pull request Nov 24, 2026
…op runtime

tedin7's review finding 3 on R0Y00#1441: the compute pipeline description copied desc->CachedPSO straight
through, which hands a console cached blob to desktop CreateComputePipelineState. Zero it instead; a
cached PSO is an optimisation the desktop must not be asked to interpret.

Findings 1 and 2 were about the byte-scan classifier, which is withdrawn; finding 4 (no end-to-end
coverage of the CreateComputePipelineState path) is still true and is the next step.

Builds clean; startup_compute_cache and startup_stubs pass.
@triggered02

Copy link
Copy Markdown
Contributor Author

Thanks — and apologies for the churn you reviewed against 94731520: I closed this PR by mistake at 11:54 and have reopened it. The branch has moved on since your review; here is where each finding stands.

1. Incomplete readability probe (compute_dxil.h:48) — fixed by removal. The whole byte-scan classifier and its test are withdrawn (493404c4), not patched: the runtime no longer inspects bytecode at all, so there is no partial probe to widen.

2. Byte-scan boundary / 0x40000 pre-filter — same answer. Your point that a "DXIL" or "xbox." string anywhere in the payload decides the outcome is exactly why it is gone rather than bounded.

The replacement is the design R0Y00 asked for: device slot 62 hashes the container the same way the graphics path does (fnv_bytes, 16 hex digits) and loads <key>.cs.cso from X2W_SHADER_CACHE (d2f05ba0); tools/startup/compute_cache.py produces those files by delegating retarget/gate/validate/sign to tools/dxil_retarget.py (eca9a67e), so the structural check happens once, offline. startup_compute_cache pins the key in both directions and the refusal path (9/9).

3. CachedPSO forwarding — you were right, and it was still live in the new code. Fixed in 6dcb79eb: the compute description now zeroes CachedPSO with a comment saying why. A console cached blob must not be handed to desktop CreateComputePipelineState.

4. No end-to-end coverage of the CreateComputePipelineState path — still true, and it is the remaining work rather than something I am claiming. The production dispatch path stays inert (slot 14 is not installed) until the two-arm fixture exists: an unresolved/invalid artifact must record zero desktop dispatches, then a normal accepted artifact must produce a nonzero UAV readback. Compute root bindings (SetComputeRootSignature and SetComputeRoot*) have to be forwarded first, since a built PSO still cannot dispatch without them — that is the Codex P1 on this PR and the next thing I am wiring.

One note that may matter for the review: the fnv_bytes seed in d3d12_draw.inl is 1469598103934665603, one digit short of the canonical FNV-1a 64 basis (14695981039346656037). The cache is keyed by whatever the runtime computes, so the publisher matches the runtime instead of the spec; worth a deliberate decision some time, since correcting it would invalidate existing cached translations.

@triggered02

Copy link
Copy Markdown
Contributor Author

Progress summary, and the fixture design I intend to build next — flagging it before I write it, since the two-arm shape is the condition on this PR.

Landed since your review

  • d2f05ba0 — slot 62 hashes the container with fnv_bytes (same helper and %016llx format as the graphics path) and loads <key>.cs.cso from X2W_SHADER_CACHE; a hit builds a real CreateComputePipelineState, a miss keeps the placeholder and logs no validated module. No byte inspection anywhere.
  • eca9a67e — tools/startup/compute_cache.py publishes those files by delegating retarget/gate/validate/sign to tools/dxil_retarget.py; startup_compute_cache pins the key in both directions plus the refusal path (9/9).
  • 6dcb79eb — tedin7's finding: CachedPSO is zeroed instead of forwarding a console cached blob to desktop CreateComputePipelineState.
  • c9e185a3 — compute root bindings. The slot numbers are measured, not inferred: a title run's per-frame command-list census is … 13:35 14:1 … 33:1 34:25 35:2 36:37 … 44:2 …, so the title calls Dispatch (slot 14) once per frame, and slots 33/35 sit one below the known graphics twins 34 (SetGraphicsRootSignature) and 36 (descriptor table). Slot 33 → SetComputeRootSignature and slot 43 → SetComputeRootShaderResourceView are forwarded. Slot 35 is left unwired because its graphics twin at 36 is not forwarded either — I'd rather ask than invent a convention.

Fixture design (the condition for marking this ready)

Two arms, in one test, in that order:

  1. Unresolved/invalid arm — a pending directory containing something that is not a valid module. The publisher writes <key>.fail and no .cs.cso; with X2W_SHADER_CACHE pointed at that directory the stand-in builds no compute pipeline, and the fixture asserts zero recorded desktop dispatches. This is the arm that proves the placeholder path does not quietly dispatch.
  2. Accepted arm — a trivial compute shader compiled with DXC into a container, published through compute_cache.py so the module goes through the real validated path, then bound and dispatched through the stand-in; the fixture copies the UAV to a readback buffer and asserts a nonzero result.

I would drive it the way tests/startup_stream_consumer.cpp + startup_stream_draw_check.py drive the graphics path (device via D3D12XboxCreateDevice, list through the stand-in, python-side orchestration and assertions).

Two things I want your call on before I build:

  • Is publishing through compute_cache.py the right "accepted" arm, or would you rather the fixture write <key>.cs.cso directly and keep the publisher out of the GPU test?
  • Slot 35 (SetComputeRootDescriptorTable): mirror the graphics side (which does not forward tables) or forward compute tables only? The census says the title calls it twice per frame, so silence here is a guess either way.

Dispatch itself stays uninstalled until arm 2 passes, so nothing can dispatch in production before the readback proves it.

@ChazY11

ChazY11 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

The three hard-coded keys check out against the runtime helper — and one thing worth a comment

Independent reviewer, not the author. Reviewed 14352e25; nothing pushed to the branch.

Environment: Windows 11 build 26300.9974, MSVC 14.44.35207, SDK 10.0.26100, Python from out/pe-env.

cmake --preset dev
cmake --build --preset dev
ctest --preset dev --no-tests=error -R '^(startup_compute_cache|cpu_shim_compute_(warp|hardware))$' -V

3 of 3 pass, and the two shim compute cases are unchanged (they still report the size=18446744073709551615 attr=0xa8004000
refusal path and exit 17 in that probe, as before this change).

I recomputed the three keys independently

Writing FNV-1a myself with the seed and prime taken from fnv_bytes in src/startup_stubs/d3d12_draw.inl:

seed = 1469598103934665603, prime = 1099511628211

b""     -> 14650fb0739d0383      test expects 0x14650FB0739D0383
b"a"    -> 44bd8ad473cd9906      test expects "44bd8ad473cd9906"
b"abc"  -> e16801510db89efd      test expects "e16801510db89efd"

All three match, so the fixture's hard-coded oracle is the same function the pipeline lookup uses, which is the property
that makes the file name correct rather than merely plausible.

One observation, worth one line of comment

That seed is not the canonical FNV-1a 64 offset basis. Canonical is 14695981039346656037; fnv_bytes uses
1469598103934665603, i.e. one digit shorter, and tools/startup/compute_cache.py inherits it deliberately. It works
fine as an internal key, but it is exactly the kind of constant someone later "corrects" after checking it against a
reference implementation — which would silently invalidate every .cs.cso and .fail file already on disk.

A comment on the C++ default argument saying the value is intentional and shared with the Python tool would remove that
risk. I am not asking for it in this PR; it is equally fine as a follow-up if you prefer.

Verdict

Reviewed 14352e25. Builds clean, the new case passes, the shim compute cases are unaffected, and the key constants are
verifiably the runtime's own function rather than a copy of a reference implementation. No objection from me.

triggered02 added a commit to triggered02/Xbox2Windows that referenced this pull request Nov 24, 2026
…op runtime

tedin7's review finding 3 on R0Y00#1441: the compute pipeline description copied desc->CachedPSO straight
through, which hands a console cached blob to desktop CreateComputePipelineState. Zero it instead; a
cached PSO is an optimisation the desktop must not be asked to interpret.

Findings 1 and 2 were about the byte-scan classifier, which is withdrawn; finding 4 (no end-to-end
coverage of the CreateComputePipelineState path) is still true and is the next step.

Builds clean; startup_compute_cache and startup_stubs pass.
@triggered02

Copy link
Copy Markdown
Contributor Author

Taking the readback arm you asked for. Two design points I want to pin down before I build it, because they decide what the fixture can honestly prove on this machine.

What I plan to do. A fixture that drives the shim's console-side objects (not the desktop D3D12 API directly), in two arms on WARP:

  1. Unresolved artifact arm. X2W_SHADER_CACHE points at a directory with no <key>.cs.cso for the container, so slot 62 takes the placeholder path. Bind that pipeline and dispatch, then assert zero desktop dispatches were recorded and that the UAV buffer still reads as the initial contents.
  2. Accepted artifact arm. Publish the validated module under the same key, rebuild the whole chain from origin/main, create the pipeline again (real CreateComputePipelineState), bind, dispatch, and assert nonzero UAV readback with the expected pattern.

Question 1 — how should "zero recorded desktop dispatches" be observable? I can add a small counter to the shim and export it (x2w_d3d12_dispatch_count(), incremented only where the forward to ID3D12GraphicsCommandList::Dispatch actually happens). That is direct evidence rather than inferring from the trap log. It adds one export that exists only for this check — is that acceptable, or would you rather the fixture read the existing X2W_TRAP_LOG/diagnostic counters and I infer from those?

Question 2 — the accepted arm needs a real accepted module. tools/startup/compute_cache.py publishes one by shelling out to dxil_retarget.py with retarget + intrinsic gate + validation + signing. Can the fixture call that tool at test time (it needs the dxc/validator environment the build already sets up), or should the fixture embed a fixed pre-validated .cs.cso as a checked-in test asset? The second is hermetic but means a binary blob in the tree; the first proves the published path end to end but makes the test depend on the toolchain being present.

What this will not establish. That the title's own compute shader dispatches correctly, or anything about the game's compute workload — only that this shim refuses an unrecognised artifact without dispatching, and forwards a validated one that writes a UAV. Those are the two behaviours tied to the dispatch gate.

The production dispatch path stays gated on X2W_COMPUTE_DISPATCH=1 and on the bound pipeline having come through slot 62, as it is in this branch.

triggered02 added a commit to triggered02/Xbox2Windows that referenced this pull request Nov 24, 2026
…op runtime

tedin7's review finding 3 on R0Y00#1441: the compute pipeline description copied desc->CachedPSO straight
through, which hands a console cached blob to desktop CreateComputePipelineState. Zero it instead; a
cached PSO is an optimisation the desktop must not be asked to interpret.

Findings 1 and 2 were about the byte-scan classifier, which is withdrawn; finding 4 (no end-to-end
coverage of the CreateComputePipelineState path) is still true and is the next step.

Builds clean; startup_compute_cache and startup_stubs pass.
triggered02 added a commit to triggered02/Xbox2Windows that referenced this pull request Nov 24, 2026
…op runtime

tedin7's review finding 3 on R0Y00#1441: the compute pipeline description copied desc->CachedPSO straight
through, which hands a console cached blob to desktop CreateComputePipelineState. Zero it instead; a
cached PSO is an optimisation the desktop must not be asked to interpret.

Findings 1 and 2 were about the byte-scan classifier, which is withdrawn; finding 4 (no end-to-end
coverage of the CreateComputePipelineState path) is still true and is the next step.

Builds clean; startup_compute_cache and startup_stubs pass.
triggered02 added a commit to triggered02/Xbox2Windows that referenced this pull request Nov 24, 2026
…op runtime

tedin7's review finding 3 on R0Y00#1441: the compute pipeline description copied desc->CachedPSO straight
through, which hands a console cached blob to desktop CreateComputePipelineState. Zero it instead; a
cached PSO is an optimisation the desktop must not be asked to interpret.

Findings 1 and 2 were about the byte-scan classifier, which is withdrawn; finding 4 (no end-to-end
coverage of the CreateComputePipelineState path) is still true and is the next step.

Builds clean; startup_compute_cache and startup_stubs pass.
triggered02 added a commit to triggered02/Xbox2Windows that referenced this pull request Nov 24, 2026
…op runtime

tedin7's review finding 3 on R0Y00#1441: the compute pipeline description copied desc->CachedPSO straight
through, which hands a console cached blob to desktop CreateComputePipelineState. Zero it instead; a
cached PSO is an optimisation the desktop must not be asked to interpret.

Findings 1 and 2 were about the byte-scan classifier, which is withdrawn; finding 4 (no end-to-end
coverage of the CreateComputePipelineState path) is still true and is the next step.

Builds clean; startup_compute_cache and startup_stubs pass.
@R0Y00

R0Y00 commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Please build the fixture shader from checked-in HLSL with the existing DXC dependency, then run the normal compute-cache publication path using the validator and signer. This covers the deployed artifact path and keeps the fixture source-built. Reuse the existing dispatch accounting or add a counter only in a test build of the shim if the existing diagnostic cannot distinguish a recorded call. The negative arm should assert both zero forwarded dispatches and an unchanged UAV after the fence. The positive arm should compare the exact output, including untouched sentinel words.

Keep the existing opt-in dispatch and slot 62 provenance checks. #1974/#1975 are working on the command-list state and root constants. Please link the fixture or its interface there so we can reuse the same two-arm readback instead of adding a second production slot 14 handler.

@triggered02

Copy link
Copy Markdown
Contributor Author

Understood — the fixture has to exercise the deployed artifact path, not a hand-placed .cso. Plan for the fixture, keeping your constraints:

  1. Shader from checked-in HLSL, built by the existing DXC dependency. The fixture shader source is checked in and compiled by DXC_EXECUTABLE in the build (no prebuilt blob, no game data), so ps_6_0/cs_6_0 bytecode is produced by the same toolchain the build already requires.
  2. Normal compute-cache publication, with the validator and signer. The compiled container goes through the cache's own publication path — the key/manifest/.cso write the slot 67 compute request path uses — and the container is validated and signed the way the tree already does it: tools/dxil_retarget.py::sign_container, which calls root_probe --sign (dxil.dll) after validation, instead of copying a bytecode file into the cache directory. If any part of the manifest must be hand-built for a fixture-only key, I will say so explicitly in the fixture header rather than hide it.
  3. Negative arm: assert both zero forwarded dispatches and an unchanged UAV after the fence. I will check the accounting that startup: implement command-list slot 14 Dispatch (Part of #870) #1974 landed in main first — if it distinguishes a recorded dispatch, reuse it; if it cannot, add a counter in a test build of the shim only, never in the shipping path.
  4. Positive arm: compare the exact output words, including untouched sentinel words, so a partial write cannot pass.
  5. Keep the existing opt-in dispatch and slot 62 provenance checks unchanged.

Two things about the state of this PR:

I will post the re-created sha here, then the fixture sha with the arm results. If you would rather this wait until #1975 lands the root-constant path, say so and I will hold the rebase until then.

triggered02 added a commit to triggered02/Xbox2Windows that referenced this pull request Nov 25, 2026
…op runtime

tedin7's review finding 3 on R0Y00#1441: the compute pipeline description copied desc->CachedPSO straight
through, which hands a console cached blob to desktop CreateComputePipelineState. Zero it instead; a
cached PSO is an optimisation the desktop must not be asked to interpret.

Findings 1 and 2 were about the byte-scan classifier, which is withdrawn; finding 4 (no end-to-end
coverage of the CreateComputePipelineState path) is still true and is the next step.

Builds clean; startup_compute_cache and startup_stubs pass.
@triggered02

Copy link
Copy Markdown
Contributor Author

Correction to my previous comment, and the rebase result.

My earlier reply described the wrong code. I described a compute_dxil.h classifier and a tests/startup_compute_dxil_check.cpp boundary fixture — neither exists at this branch head (bcf24db8) or in any ref in the fork. This PR's head is the earlier slice: a publisher for <key>.cs.cso, real slot-62 compute-PSO creation from that published module, and slot-14 Dispatch behind X2W_COMPUTE_DISPATCH=1; its own CTest is startup_compute_cache (tests/startup_compute_cache_check.py + tools/startup/compute_cache.py). The PR body described a revision that was never pushed; I have updated the body to describe this head instead of leaving it wrong. Sorry for the noise.

Rebased onto main b976e8bc, head is now e133bf6a (was bcf24db8), MERGEABLE. Four commits replayed:

e133bf6a startup-d3d12: add the compute dispatch path behind an explicit gate
b5a90bc9 startup-d3d12: do not forward a console cached-PSO blob to the desktop runtime
4d196f2d startup-d3d12: publish compute modules under the key the runtime looks them up by
edd1f35b startup-d3d12: load validated compute modules by key from the shader cache

One commit was dropped because main superseded it: e9ef89af ("forward the compute root signature and compute root SRV") replayed empty. main now has a richer slot 33 (deferred heap-indexed root + binding trace) and a slot 43 that binds upload-page-backed compute root SRVs after indexed-indirect validation. The PR version also read pass.root (the graphics root set at slot 34) rather than the compute root, so replaying it verbatim would have been a defect. I did not replace it.

Conflict resolutions (all in src/startup_stubs/d3d12_xs_device.cpp plus CMake): slot 62 keeps main's note_pipeline/note_compute_binding_pipeline calls and adds the cache load, wrapping real_pipeline instead of nullptr and setting own().compute_pipeline; the PR's parallel compute_pipeline_real was dropped because main's compute_pipeline covers it; slot 14 keeps main's barrier/root handlers and adds list_dispatch gated on pass.compute_pipeline; the PR's duplicate list_typed[33]/[43] registrations were removed because main already registers both. The CachedPSO = {} fix replayed cleanly. CMakeLists.txt keeps main's startup_live_view block and inserts the startup_compute_cache CTest beside it.

Verified on e133bf6a: cmake --preset dev + cmake --build --preset dev --target d3d12_xs_shim with MSVC → exit 0, d3d12_xs.dll links, so the rebased slot-62/14 code compiles against current main. tests/startup_compute_cache_check.py → PASS (9 checks), docs_links_check.py (469 links), bidi_controls_check.py (1739 files), startup_tools_lint_check.py (10 files), dependency_paths_check.py → all exit 0; git diff --check clean.

What CI can and cannot prove here. CI can compile the shim and run ctest -R '^startup_compute_cache$' (pure Python). There is no device-level fixture in this head for the runtime path — real slot-62 PSO creation from <key>.cs.cso and slot-14 recording with X2W_COMPUTE_DISPATCH=1 are unmeasured. startup_compute_binding_trace_warp still covers slot-14 observation with the gate off.

Two real gaps this head leaves, stated rather than hidden: (1) compute root SRVs are limited to upload-page pointers; the graphics slot-44 readable_window/upload_from_title fallback has no compute equivalent, so a title-memory window read would be refused where graphics accepts it; (2) X2W_COMPUTE_DISPATCH is undocumented and sampled once in build_tables() at device creation.

What I plan next, unless you want it differently: implement the DXC-built fixture shader and the two-arm readback you asked for (checked-in HLSL compiled by DXC_EXECUTABLE, published through the normal compute-cache path with tools/dxil_retarget.py::sign_container validating and signing via root_probe --sign, negative arm zero forwarded dispatches plus unchanged UAV after the fence, positive arm exact words including untouched sentinels), and expose that readback as one reusable helper for #1975. That is what turns this from compile-checked into evidenced. Say if you want the compute root SRV fallback (1) folded into the same change or handled separately.

triggered02 added a commit to triggered02/Xbox2Windows that referenced this pull request Nov 26, 2026
…op runtime

tedin7's review finding 3 on R0Y00#1441: the compute pipeline description copied desc->CachedPSO straight
through, which hands a console cached blob to desktop CreateComputePipelineState. Zero it instead; a
cached PSO is an optimisation the desktop must not be asked to interpret.

Findings 1 and 2 were about the byte-scan classifier, which is withdrawn; finding 4 (no end-to-end
coverage of the CreateComputePipelineState path) is still true and is the next step.

Builds clean; startup_compute_cache and startup_stubs pass.
@triggered02

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (e46d336); head is now c7a6ed3 (was e133bf6). Clean replay.

Verified on c7a6ed3: startup_compute_cache_check PASS; docs_links_check 523 links; startup_tools_lint_check 11 files; dependency_paths_check; git diff --check clean; diff vs main is the PR's own 4 files (+241/-9). Main's newer slot-14 Dispatch (#1974) is kept and the PR's duplicate registration stays dropped, pipeline_root interop is in place, and the .cs.cso load plus X2W_COMPUTE_DISPATCH gate survive.

CI can compile-check this head; the runtime half (real slot-62 PSO from a published module, slot-14 recording) still has no device-level fixture, which the description lists as outstanding.

@triggered02

Copy link
Copy Markdown
Contributor Author

Answering the two Codex findings and @R0Y00's change request against the current head c7a6ed3, because the reviewed revision is no longer what this branch contains.

P1 � "Bind compute root state before recording dispatch": no longer applies to this head. This branch no longer records a dispatch at all. Main landed #1974 (src/startup_stubs/list_dispatch.h, decide_dispatch) while this PR was in flight, and the rebase dropped this PR's list_dispatch and its list_typed[14] registration as a duplicate � main installs slot 14 unconditionally and its handler already forwards compute-root state. What this PR keeps is the PSO side: it builds the real compute pipeline and sets both own().compute_pipeline and own().pipeline_root, so decide_dispatch's pipeline-root match (pass.compute_pipeline_root, set from slot 33 list_compute_root) has a root to compare. Verifying: grep -n 'list_dispatch|list_compute_root|pipeline_root' src/startup_stubs/d3d12_xs_device.cpp shows one list_dispatch definition (main's), one list_typed[14], and the slot-62 pipeline_root assignment.

P2 � "Probe the full bytecode span before scanning": that file is not in this head. src/startup_stubs/compute_dxil.h does not exist on this branch � the DXIL-classifier design was never pushed here; the head is the earlier cache-publisher slice ( ools/startup/compute_cache.py, .cs.cso load at slot 62). The P2 is a real finding for that future classifier revision, and I have not marked it fixed; it simply has no code to apply to in c7a6ed3.

@R0Y00's change request � keep the production dispatch path pending the source-built GPU readback: satisfied by construction on this head. Dispatch recording is main's, not this PR's, and the only new runtime behavior is gated: without X2W_COMPUTE_DISPATCH=1 the slot-62 path keeps the placeholder pipeline and no module is loaded, so nothing can dispatch from this PR's change until the readback fixture turns it on. The description's "not established" section lists that fixture as still outstanding.

Verified on c7a6ed3: startup_compute_cache_check PASS, docs 523 links, translator/lint/dependency-path checks clean, git diff --check clean; diff vs main is the PR's 4 files (+241/-9).

… cache

Step (b) of the R0Y00#1412 rework. Device slot 62 no longer inspects bytes: it hashes the container the same
way the graphics path does (fnv_bytes over the CS bytecode) and looks for `<key>.cs.cso` in
X2W_SHADER_CACHE, which is where the offline retarget/sign/gate step publishes validated desktop
modules. A hit builds a real CreateComputePipelineState from those bytes with the unwrapped root
signature; a miss keeps the placeholder and logs "no validated module".

Nothing else changes: the dispatch path is still inert (slot 14 not installed), so no behaviour moves
until the two-arm readback proves it. Offline publication of `<key>.cs.cso`, the compute root bindings
and the readback fixture are the remaining steps.

Builds clean; startup_stubs passes.
…ks them up by

Step (a) of the R0Y00#1412 rework: tools/startup/compute_cache.py turns the containers the stand-in dumps
into the `<key>.cs.cso` files that device slot 62 loads, and records `<key>.fail` with the reason when
the existing validated path refuses a module. The retarget/gate/validate/sign decision stays in
tools/dxil_retarget.py - this tool only supplies the naming and the refusal record, so validation does
not get re-implemented at the runtime.

The key is FNV-1a 64 over the shader bytes rendered as 16 hex digits, matching the stand-in's
fnv_bytes/cache_path (d3d12_draw.inl), and tests/startup_compute_cache_check.py (ctest
startup_compute_cache) pins it in both directions plus the refusal behaviour.

Note recorded in the test and worth a maintainer's look: the seed in fnv_bytes is 1469598103934665603,
which is a digit short of the canonical FNV-1a 64 offset basis (14695981039346656037). The cache is
keyed by whatever the runtime computes, so the publisher matches the runtime rather than the spec; if
that constant was a typo it should be corrected deliberately, not as a side effect of this work.
…op runtime

tedin7's review finding 3 on R0Y00#1441: the compute pipeline description copied desc->CachedPSO straight
through, which hands a console cached blob to desktop CreateComputePipelineState. Zero it instead; a
cached PSO is an optimisation the desktop must not be asked to interpret.

Findings 1 and 2 were about the byte-scan classifier, which is withdrawn; finding 4 (no end-to-end
coverage of the CreateComputePipelineState path) is still true and is the next step.

Builds clean; startup_compute_cache and startup_stubs pass.
Step (d), first half: gate the compute-dispatch experiment behind X2W_COMPUTE_DISPATCH=1.

Rebased onto a main whose command-list slot 14 Dispatch already exists (R0Y00#1974): main installs slot 14
unconditionally and forwards only when a desktop compute pipeline and root signature are bound and the
root arguments are forwarded (`decide_dispatch` in `src/startup_stubs/list_dispatch.h`, covered by
startup_list_dispatch and startup_list_dispatch_native). That newer code fully supersedes this PR's own
slot 14 handler, so the handler and its gated `list_typed[14]` registration are dropped rather than
duplicated. The gate covers the slot 62 side instead, which is what this PR adds: with
X2W_COMPUTE_DISPATCH=1 a validated `<key>.cs.cso` is loaded and the desktop pipeline records
`own().pipeline_root`, so main's existing gate can match it against the bound compute root signature.
Without the variable nothing is loaded, so production behaviour is unchanged and nothing can dispatch
on the placeholder path.

Still outstanding, and why this is not marked ready: the source-built two-arm readback (invalid
artifact -> zero recorded dispatches, accepted artifact -> nonzero UAV readback). The gate exists so
that fixture can turn the path on explicitly; until it passes, the default is inert.
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.

4 participants