Skip to content

runtime: translate slot 67 compute requests in the stand-in - #2958

Merged
MasterDomino merged 3 commits into
R0Y00:cpp-migrationfrom
Not-Saii:startup/native-compute-dispatch
Nov 27, 2026
Merged

MasterDomino merged 3 commits into
R0Y00:cpp-migrationfrom
Not-Saii:startup/native-compute-dispatch

Conversation

@Not-Saii

@Not-Saii Not-Saii commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #2934

With X2W_NATIVE_SHADERS naming the directory of dxcompiler.dll and dxil.dll, the stand-in translates a slot 67 compute request in-process on the pipeline's first Dispatch and records the Dispatch, with an empty shader cache and no Python watcher.

Two things to know first

  • The route does not use NativeRecording or NativeDispatchStates, which the issue names. The stand-in's dispatch path (record_translated_dispatch) already resolves raw table buffers, tracks their states and refuses what it cannot bind. So the new code reads the request the stand-in itself published (x2w::read_compute_request), runs x2w::translate_compute and ShaderDxilCompiler::runtime_worker, and fills the same ComputeTranslation a published <key>.txt fills. The two helpers stay unused until a binder handles textures and typed views.
  • The WARP package smoke test still passes. The package ships offscreen_check.exe, which compiles the stand-in source without the new define. tools/package-gpu-check.ps1 was run at 89a75318 (same code as a58e08f9, plus the note): the extracted package passes its WARP run with 11 tests and 68 of 68 recorded shader cases. bvh_wave64_warp reports a capability skip there (no 64-lane waves), which the script does not require.

What changed

  • src/startup_stubs/d3d12_compute_dispatch.inl: translate_compute_natively, tried once per key and before a published <key>.txt. Root signature and pipeline creation moved into a helper shared with the manifest loader.
  • Accepted: root constants, a raw table buffer loaded per lane and a raw table buffer stored to. Every other view kind (a scalar buffer load included), a sampler, an adapter without 32-lane waves and whatever the frontend refuses are logged with their reason (first 16 per process) and left to a published translation.
  • CMakeLists.txt: d3d12_xs_shim links x2w_shader_compiler and defines X2W_NATIVE_SHADERS when that target exists. Both use the static CRT.
  • tools/startup/run.ps1: -Render -NativeShaders <dir> sets the switch; tests/startup_run_ps1_check.py covers it with a mutant.
  • tests/startup_compute_dispatch_native_check.py (startup_compute_dispatch_native_{warp,hardware}) and a dispatch-records32 mode in tests/startup_stream_consumer.cpp.
  • docs/startup-runtime.md and a note, docs/experiments/startup-compute-native-dispatch.md.

The check

The program is case A of startup_gfx2hlsl_compute_check.py with its two buffer descriptors loaded from 32-byte table records (bytes 0 and 32). The C++ frontend reads a table as 32-byte records and refuses case A as written (unaligned descriptor table entry), so case A is the unsupported workload.

  1. Native, from an empty cache: all 320 output words match the CPU reference, the log names the native translation, and the cache holds only request files and the compiler's own cache.
  2. The same program over the plain table layout is refused when bound; every word keeps the sentinel.
  3. Negative control: case A is refused with the frontend's reason and no translation; every word keeps the sentinel.
  4. Fallback: gfx2hlsl.py --pending publishes both requests; case A then runs through the published translation and all 320 words match.
  5. Order: the first program runs again with a published translation in the cache; the native translation is still the one used.

Commands and results

Commit a58e08f9 on cpp-migration at e3670100, Windows 11 build 26300.9974, Debug build (dev preset), D3D12 debug layer enabled.

cmake --build --preset dev --target d3d12_xs_shim startup_stream_consumer compile_dxil native_wave_request_gpu offscreen_check
ctest --preset dev --no-tests=error -V -R '^(startup_compute_dispatch_native|startup_compute_dispatch|native_wave_request)_hardware$'
ctest --preset dev --no-tests=error -V -R '^(startup_compute_dispatch(_.*)?|startup_slot67_indirect_dispatch|startup_compute_translate_e2e)_warp$'
ctest --preset dev --no-tests=error -R '^offscreen_warp$'
.\tools\package-gpu-check.ps1
Test Adapter, driver Result
startup_compute_dispatch_native_hardware NVIDIA GeForce RTX 4090, 32.0.16.1088 PASS, all 320 words, no debug-layer error message
startup_compute_dispatch_hardware NVIDIA GeForce RTX 4090, 32.0.16.1088 PASS
native_wave_request_hardware same machine (prints no adapter line) PASS
10 WARP dispatch tests (startup_compute_dispatch_warp and the family above) Microsoft Basic Render Driver, 10.0.26100.9818 PASS
offscreen_warp WARP (run without -V, adapter line not read) PASS
tools/package-gpu-check.ps1 (Release, at 89a75318) Microsoft Basic Render Driver, 10.0.26100.9818 PASS: 11 tests, 68 of 68 shader cases; bvh_wave64_warp capability skip

Capability skip, not a pass: startup_compute_dispatch_native_warp exits 77. A direct compute module declares wave size 32 and this WARP reports no 32-lane waves. Before exiting, the check confirms that the native translation is refused by that name with every word untouched, and it runs steps 3 and 4 and the first program through its published translation.

Pure-Python checks run: startup_run_ps1_check.py, docs_links_check.py, bidi_controls_check.py.

Limits

  • Compute only. A scalar buffer load, a texture, a sampler and the typed, half and indexed views are refused.
  • One descriptor shape was dispatched (stride 4, 320 records). An indirect Dispatch of a natively translated program was not run.
  • The route passes entry 0. A captured request's 36-byte v_nop prefix was only checked with compile_dxil, not dispatched.
  • One physical GPU and WARP, Debug build only. No start-up run used the switch; the launcher switch was checked with stubs.
  • The result is not published, so each process translates a key again (the compiler's DXIL cache under <shader cache>\native is reused).
  • shader: consume startup requests and publish runtime cache entries in compile_dxil #2955 landed format_compute_runtime_manifest while this was being tested. This PR keeps its own narrower mapping (the two view kinds its fixture runs); moving to the shared formatter would widen what is accepted and is left for a follow-up.

🤖 Generated with Claude Code

Not-Saii and others added 3 commits November 27, 2026 01:25
…00#2934)

With X2W_NATIVE_SHADERS naming the directory of dxcompiler.dll and
dxil.dll, the first Dispatch of a slot 67 pipeline reads the request the
stand-in published, runs the C++ compute frontend and the DXIL compiler
in-process, and fills the ComputeTranslation that a published <key>.txt
fills. The existing dispatch path then binds the table buffers.

Accepted: root constants, a raw table buffer loaded per lane and a raw
table buffer stored to. Every other view kind, a sampler, an adapter
without 32-lane waves and whatever the frontend refuses are logged by
reason and left to a published translation.

run.ps1 -Render -NativeShaders <dir> sets the switch.
startup_compute_dispatch_native_{warp,hardware} dispatches a source-built
program from an empty cache and compares all 320 output words with the
CPU reference; an unsupported program is refused with the output
untouched.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
Route, program and controls, commands, the results on the RTX 4090 and
on WARP (capability skip: no 32-lane waves) for a58e08f, and the
limits of what was run.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
…(Refs R0Y00#2934)

tools/package-gpu-check.ps1 at 89a7531: the extracted package passes its
WARP run, 11 tests and 68 of 68 recorded shader cases; bvh_wave64_warp
reports a capability skip (no 64-lane waves).

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

Copy link
Copy Markdown
Contributor

Tested f06d1d43 on the test PC (Windows 11 25H2 26200, MSVC 19.44, NVIDIA GeForce RTX 4070 Ti driver 32.0.16.2135, Debug/dev preset, D3D12 debug layer enabled).

cmake --preset dev
cmake --build --preset dev

Both exited 0.

PR tests, twice, serially, with -j 1 --no-tests=error:

ctest --preset dev --no-tests=error -j 1 -V -R '^(startup_compute_dispatch_native_(warp|hardware))$' -E 'startup_audio_output|startup_audio_pacing|startup_audio_provider'
ctest --preset dev --no-tests=error -j 1 -V -R '^startup_run_ps1$' -E 'startup_audio_output|startup_audio_pacing|startup_audio_provider'
Test Run 1 Run 2
startup_compute_dispatch_native_hardware PASS, 3.41s, all 320 words, debug layer enabled, no error message PASS, 3.46s, same
startup_compute_dispatch_native_warp skip (77), 1.98s skip (77), 1.71s
startup_run_ps1 PASS, 16.84s PASS, 16.68s
ctest exit 0 0

The WARP skip is a capability skip, not a failure: Microsoft Basic Render Driver 10.0.26100.8521 has no 32-lane waves. Before exiting 77 the check confirmed the native translation is refused by that name with every word untouched, that case A is refused the same way, and that the first program then matches all 320 words through its published translation.

Related family once, including docs_links and bidi_controls:

ctest --preset dev --no-tests=error -j 1 -V -R '^(startup_compute_dispatch(_.*)?|startup_slot67_indirect_dispatch|startup_compute_translate_e2e|native_wave_request)_(warp|hardware)$|^offscreen_warp$' -E 'startup_compute_dispatch_native|startup_audio_output|startup_audio_pacing|startup_audio_provider'
ctest --preset dev --no-tests=error -j 1 -V -R '^(docs_links|bidi_controls)$' -E 'startup_audio_output|startup_audio_pacing|startup_audio_provider'

All 24 passed, both ctest exits 0: native_wave_request_hardware, offscreen_warp, startup_compute_translate_e2e_{warp,hardware}, startup_compute_dispatch_{warp,hardware}, startup_compute_dispatch_{texture,heap,heap_word,input,entry,array,array_d16}_{warp,hardware}, startup_slot67_indirect_dispatch_{warp,hardware}, docs_links, bidi_controls.

Control: on merge-base e3670100 (cpp-migration), tests/cmake/startup_compute_dispatch_native.cmake and tests/startup_compute_dispatch_native_check.py are absent, so the new tests are not registered without this PR.

Not a duplicate of another open or merged PR; this is the only PR for #2934. Related but distinct: #2955 (merged; compile_dxil publish path) and #2912 (open; native DXIL heap-slot probe).

The author's RTX 4090 result holds on a second NVIDIA GPU and a newer driver. Still unrun, as the PR already notes: a non-NVIDIA GPU, a Release//O2 build, a start-up run with -NativeShaders, and an indirect Dispatch of a natively translated program. The choice not to use NativeRecording / NativeDispatchStates is documented and matches the two raw-buffer view kinds this path accepts. Leaving the #2955 shared manifest formatter as a follow-up also looks right, so this change does not silently widen what the stand-in will bind.

AI-Assisted

@MasterDomino MasterDomino 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 f06d1d43, tested merged onto cpp-migration f934df52. It merges cleanly, and CI on the head is green. This changes d3d12_xs.dll, so it also got start-up runs. Approving and merging.

Code read:

  • Without X2W_NATIVE_SHADERS in the environment, translate_compute_natively returns false at once and the manifest path runs as before. DXC is only loaded on the first native attempt.
  • Accepted are root constants, raw_vector_srv and raw_buffer_uav with array_count == 1 in register order. Anything else is refused with a logged reason and left to the published translation.

Fixtures (Windows 11 26300.9974, AMD Radeon RX 9070 XT, driver 32.0.32029.2010, release): the startup_compute_dispatch*, startup_slot67_indirect_dispatch_warp, startup_compute_translate_e2e_warp, startup_run_ps1, offscreen_warp and native_* families, 67 tests: 65 passed and 2 skipped (77: native_comparison_pso_warp, and startup_compute_dispatch_native_warp because WARP has no 32-lane waves). startup_compute_dispatch_native_hardware passes.

Negative control: with the native path forced off (translate_compute_natively returns false before reading the switch), startup_compute_dispatch_native_hardware fails with word=0 got=c5c5c5c5 … (288 words differ). With it restored, it passes.

Start-up runs, 300 s each, back to back, lazy memory off, the same input script, each from a fresh copy of the same shader cache, counts only:

base f934df52 this PR, no switch this PR, -NativeShaders <SDK bin>
end timeout, no second-chance exception timeout timeout
frames 8,049 8,362 8,185
storage requests done 10,511 10,582 10,778
textures uploaded 1,392 1,431 1,390
graphics pipelines over time 14 at ≈198 s, 18 at ≈278 s, 46 at ≈288 s 14 / 18 / 46 at ≈195 / 275 / 290 s 14 / 18 at ≈205 / 285 s (last sample before the late step)
  • Without the switch the run matches the base, so the default path is unchanged.
  • With the switch the run is stable and follows the same scene timing. No program translated natively in this run: all 16 logged attempts (the log cap) were refused, as the narrow scope intends. The reasons were view kind … is not bound for a natively translated program (6), raw buffer load needs offen with zero scalar offset and no modifiers (3), unsupported DPP lane selection (2), non-contiguous resource descriptor (2), and one each of SDWA, an unbound numeric SGPR and image modifiers. Every refused program fell back to its published translation.

Follow-up, not blocking: the native attempt is not quite "once per key". When it fails and no <key>.txt exists yet, record_translated_dispatch retries when retry_manifest_at comes round, about once a second, and each retry runs translate_compute_natively again, reading the request and running the frontend and possibly DXC. Remembering a refusal on the ComputeTranslation, for example a native_refused flag set in the catch, would make it once per key as the description says, and keep the CPU cost of a refused program out of the draw lock.

I will close #2934 by hand.

AI-assisted; the commands above were run locally.

@MasterDomino
MasterDomino merged commit b260984 into R0Y00:cpp-migration Nov 27, 2026
5 checks passed
JB2WIN added a commit to JB2WIN/Xbox2Windows that referenced this pull request Nov 27, 2026
Resolves the conflicts with R0Y00#2932-R0Y00#2971 (keeps both sides: HeapViewContract next
to the MODE tracking and lane-shape checks; .views handling inside the new
compile_one). The check follows the new --requests output name <key>.cs.cso
from R0Y00#2955, and the notes mention the stand-in's native slot 67 path (R0Y00#2958),
which translates without a heap view contract.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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