Repository navigation
startup-d3d12: run compute pipelines that are already desktop DXIL - #1441
triggered02 wants to merge 4 commits into
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
R0Y00
left a comment
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
💡 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".
| { | ||
| if (!pass_of(self).pipeline_real) return; | ||
| if (auto* list = recording(self)) { | ||
| list->Dispatch(x, y, z); |
There was a problem hiding this comment.
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 👍 / 👎.
| 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; |
There was a problem hiding this comment.
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 👍 / 👎.
…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.
|
Taken, and the first part is already pushed as On the classifier you are right on all three counts, and the byte scan was the weak part:
Replacement I intend to build, in this order:
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. |
|
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 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 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
left a comment
There was a problem hiding this comment.
Reviewed commit 94731520e15f4f90587b22a44ef1597a9827ae74 (git diff origin/main...HEAD).
Checks
- Linux:
python3 tests/docs_links_check.py,python3 tests/bidi_controls_check.py, andgit diff --check origin/main..HEADpassed. Title-neutrality clean. - Win2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP):
- Debug (
--preset dev):startup_compute_dxil_check,d3d12_xs_shim,startup_stub_consumerbuilt (26.61s);ctest -R '^(startup_compute_dxil|startup_stubs)$'2/2 passed (startup_compute_dxil0.02s,startup_stubs0.52s). - Release
/O2(--preset release): built (39.27s); 2/2 passed (startup_compute_dxil0.01s,startup_stubs0.37s).
- Debug (
Findings
- 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 tolimit = bytes < 0x40000 ? bytes : 0x40000. If a caller passes a buffer readable for 4 bytes but unmapped/shorter beforelimit,std::memcmpwill read past the readable region. Checkingreadable(code, limit)(after computinglimit) fixes this, andtests/startup_compute_dxil_check.cppcan cover it with a callback that accepts4bytes and rejectslimit. - Byte-scan boundary in
src/startup_stubs/compute_dxil.h:51-56: Scanning raw bytes up to0x40000means a container larger than 256 KiB with"xbox."past0x40000will passdesktop_dxil(and fall back viaCreateComputePipelineStatefailure), and a non-DXIL payload containing"DXIL"or"xbox."could false-positive/false-negative. Worth either parsing the DXBC part table or noting the0x40000bound as a pre-filter. CachedPSOforwarding insrc/startup_stubs/d3d12_xs_device.cpp:compute.CachedPSO = desc->CachedPSO;forwards any title-supplied cached PSO blob to desktopCreateComputePipelineState. ZeroingCachedPSO({}) avoids passing a console cached blob to the desktop runtime.- Coverage note:
startup_compute_dxilandstartup_stubsverify the classifier and DLL exports;device_create_compute_pipeline_x'sCreateComputePipelineStatepath itself is not exercised by an end-to-end test here (as noted in the PR description).
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.
|
The branch is now at parity with 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:
Marking ready for review when step 4 exists, so the dispatch path is never live without the readback that proves it. |
e48569d to
bb6c9a0
Compare
…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.
|
Thanks — and apologies for the churn you reviewed against 1. Incomplete readability probe (compute_dxil.h:48) — fixed by removal. The whole byte-scan classifier and its test are withdrawn ( 2. Byte-scan boundary / 0x40000 pre-filter — same answer. Your point that a The replacement is the design R0Y00 asked for: device slot 62 hashes the container the same way the graphics path does ( 3. 4. No end-to-end coverage of the One note that may matter for the review: the |
|
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
Fixture design (the condition for marking this ready)Two arms, in one test, in that order:
I would drive it the way Two things I want your call on before I build:
|
The three hard-coded keys check out against the runtime helper — and one thing worth a commentIndependent reviewer, not the author. Reviewed Environment: Windows 11 build 26300.9974, MSVC 14.44.35207, SDK 10.0.26100, Python from cmake --preset dev
cmake --build --preset dev
ctest --preset dev --no-tests=error -R '^(startup_compute_cache|cpu_shim_compute_(warp|hardware))$' -V3 of 3 pass, and the two shim compute cases are unchanged (they still report the I recomputed the three keys independentlyWriting FNV-1a myself with the seed and prime taken from All three match, so the fixture's hard-coded oracle is the same function the pipeline lookup uses, which is the property One observation, worth one line of commentThat seed is not the canonical FNV-1a 64 offset basis. Canonical is A comment on the C++ default argument saying the value is intentional and shared with the Python tool would remove that VerdictReviewed |
…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.
14352e2 to
6d416e2
Compare
|
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:
Question 1 — how should "zero recorded desktop dispatches" be observable? I can add a small counter to the shim and export it ( Question 2 — the accepted arm needs a real accepted module. 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 |
…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.
6d416e2 to
41abddf
Compare
…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.
41abddf to
4801051
Compare
…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.
4801051 to
b98624d
Compare
…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.
b98624d to
bcf24db
Compare
|
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. |
|
Understood — the fixture has to exercise the deployed artifact path, not a hand-placed
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. |
…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.
bcf24db to
e133bf6
Compare
|
Correction to my previous comment, and the rebase result. My earlier reply described the wrong code. I described a Rebased onto One commit was dropped because Conflict resolutions (all in Verified on What CI can and cannot prove here. CI can compile the shim and run Two real gaps this head leaves, stated rather than hidden: (1) compute root SRVs are limited to upload-page pointers; the graphics slot-44 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 |
…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.
e133bf6 to
c7a6ed3
Compare
|
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. |
|
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.
c7a6ed3 to
361b6e3
Compare
First slice of #1412: compute pipelines whose bytecode is publishable to the desktop become real, and
Dispatchrecords 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 realCreateComputePipelineStateis created from it (pRootSignatureunwrapped from the console handle,CachedPSOcleared so a console cached-PSO blob never reaches the desktop runtime). Without a module the result stays a placeholderPipelineState, exactly as before, and the log line says which reason applied.Dispatch) — recorded on the desktop list whenX2W_COMPUTE_DISPATCH=1and 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(CTeststartup_compute_cache) — nine checks over the publisher and the key/manifest behaviour.Verified on
e133bf6a(rebased ontoorigin/mainb976e8bc)cmake --preset dev+cmake --build --preset dev --target d3d12_xs_shim(MSVC) → exit 0,d3d12_xs.dlllinks.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 --checkclean.Not established
<key>.cs.csoand slot-14 recording withX2W_COMPUTE_DISPATCH=1are compile-checked by CI, not measured.startup_compute_binding_trace_warpcovers slot-14 observation with the gate off.readable_window/upload_from_titlefallback has no compute equivalent, so a title-memory window read is refused where graphics accepts it.X2W_COMPUTE_DISPATCHis undocumented and sampled once inbuild_tables()at device creation.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.