Repository navigation
runtime: compile a supported graphics pair on first use in the stand-in - #2981
Conversation
Validation of
|
|
I claimed #2978 shortly before this PR opened and have a branch for it too. I am not opening a second PR. This is what the branch does differently, in case any of it is useful here or as a follow-up. Branch: Differences from this PR
Costs
Regression runs on the branch (full I can rebase any of points 1 to 4 onto this PR once it merges, open the branch as an alternative PR, or drop it. Tell me which is useful. AI-assisted (Claude Code). |
KelboLive
left a comment
There was a problem hiding this comment.
Strong milestone — the first native graphics draw through the stand-in. The try_native_graphics() path cleanly sits between load_translation() fallback and the manifest-based path, and the test exercises cold/warm cache behavior plus refusal of unsupported stages.
Findings
✅ What works well
- Placement in
cached_translation(): The newtry_native_graphics()call happens afterpublish_shader_requestbut beforeload_translation(). This is correct — if the request file exists, native compilation is attempted; if it fails,load_translation()falls back to the published manifest path. No regression for existing workflows. try_native_graphics()structure: Reads the request →prepare_direct_graphics()→format_graphics_runtime_manifest()→ compiles both stages throughShaderDxilCompiler::runtime_worker()→ passes manifest toload_translation(). The lambdastage()abstracts the compile+blob creation loop. Clean.- Manifest passthrough to
load_translation(): Theprovidedflag preventsload_translation()from re-reading.txtand.csofiles when a native manifest is already available. The two.csoreads are guarded by!provided, and the manifest string is used directly. This avoids a double-load. x2w-draw native graphicslogging: Theready=%u cache(frontend,vs,ps)=%u,%u,%umessage gives exact cache hit counts. The refusal path also logs with the error reason. Useful for debugging.- Test fixture: Triangle VS + patched PS, checking all 32 pixels for cold/warm draw, and a third process with an unsupported stage verifying untouched clear color. Good separation of concerns.
⚠️ Issues / observations
-
prepare_direct_graphics()refusal: If the request has an unsupported binding layout,format_graphics_runtime_manifestreturnsstd::nulloptand the exception message is"unsupported graphics binding layout". This is caught by the catch block and logged as"refused: unsupported graphics binding layout". However, the test expects the string"refused:"in stderr — the actual log would be"x2w-draw native graphics %016llx refused: unsupported graphics binding layout". The assertionreturncode == 0 and "refused:" in run.stderrworks because the fallbackload_translation()path still runs after the native attempt fails. Verify that the test's unsupported stage scenario exercises the right code path (native refusal vs. manifest rejection). -
Shader model: Both stages compile with
"vs_6_6"and"ps_6_6". This is the minimum shader model for SM6.6 wave32 features. If the target adapter doesn't support SM 6.6,compile()will fail and the pipeline creation will refuse. Consider whether to detect the adapter's SM support and fall back gracefully, or if this is intentionally restricted (consistent with the compute path requiring SM 6.6 + wave32). -
direct_compute_cache.hinclude ind3d12_xs_device.cpp: The include brings indirect_compute_cache.hwhich definesprepare_direct_graphics()andformat_graphics_runtime_manifest(). Since this file isd3d12_xs_device.cpp(the device initialization), it should be correct, but note that this couples the device init to the direct compute cache machinery. If this header includes heavy dependencies, consider a forward declaration or a lighter header. -
cache_pathfor native request file:cache_path(path, L"req_", tr.key, L".a")constructsreq_<key>.ain the cache directory. The manifest reader (load_translation()) readscache_path(path, L"", tr.key, L".txt")— the published request. These are two different paths, so native compilation reads from the request file while manifest loading reads from the .txt output. Correct.
Recommendation
Ready to land with the one question about the test's refusal path (item 1). The feature is well-placed, well-tested, and follows the pattern established by the compute path.
🏷 Future: if prepare_direct_graphics() or the compilation path gains more refusal reasons, consider adding a classification layer (e.g., refused_invalid_request vs refused_unsupported_binding vs refused_compile_failure) for more precise logging and potential retry logic.
R0Y00
left a comment
There was a problem hiding this comment.
Follow-up on exact head 671b9ac8188919499fa05ebd94269a33e76fbf76. I ran ctest --preset {dev,release} --no-tests=error --output-on-failure -R '^startup_(native_graphics_draw|compute_dispatch_native|stream_draw)_(warp|hardware)$' on Windows 11 26200.9974. Both builds gave five passes and one native-compute WARP capability skip. Cold/hot graphics both read back 16 red and 16 clear pixels on WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656; the unsupported stage left all 32 clear. Debug used embedded /Z7; Release was /O2.
I reproduced the late fallback failure with local Release fault injection on WARP. I first published an ordinary disk <key>.txt, .vs.cso, and .ps.cso via the offline CLI and verified that it drew 16 red/16 clear with native disabled. Independently forcing an unsupported native manifest version or E_FAIL at native root creation gives ready=0, no draw and 32 clear pixels at this head, despite that valid cache. In a separate same-process control using X2W_TEST_PUBLISH_MANIFEST, both faults also prevent drawing after the manifest appears and the retry window elapses. The disk cache files are byte-identical throughout.
I tested a local fix that parses and builds the root in a temporary Translation, commits it only on state == 1, and otherwise falls through to the original disk loader. Both injected faults then drew 16 red/16 clear with a pre-existing manifest and on the later draw after publication. Please carry these two negative controls into the PR. This fix addresses late manifest/root failures and preserves the existing retry. The agreed compile-on-first-draw timing and existing-cache precedence remain separate acceptance points, and this test does not inject a later PSO failure.
KelboLive
left a comment
There was a problem hiding this comment.
What works
try_native_graphics()fills a missing gap: the stand-in now
accepts X2W_NATIVE_SHADERS and compiles a VS/PS pair inline from the
published request, with a first-use compile path and subsequent cache
hit path (--180s timeout is reasonable).load_translation()signature change is safe: the default
argumentmanifest = {}is backwards-compatible. When an empty
string is provided externally, the existing cache-path read still
runs. Good.- The fixture tests the cold/warm transition and the unsupported
stage refusal in the same test, checking pixel counts in each case.
No debug layer warnings expected (good quality gate). - The CMakeLists.txt test harness uses both warp and hardware
adaptives, with skip=77 for hardware-only features.
Issues
x2w::read_graphics_request()path: thecache_path(path, L"req_", tr.key, L".a")call uses the translation's key directly. If the
request file isn't found, the function returns false without logging
a reason. This is correct for the graceful fallback, but the log at
the end of this PR saysrefused: no graphics requestfor an
unsupported -- consider if that should become a debug-level event or
a specific refusal with the missing key.- The
try_native_graphics()function returns false if the runtime
doesn't know the path to DXC or the request file. The fallback to
the published translation is correct, but the transition between
compiled and cached paths should be observable in logs for
diagnosing first-use vs subsequent issues.
Recommendations
- Consider adding a debug log entry when
try_native_graphics()
returns false so developers can distinguish the reason from the
overall pipeline path taken. - The
prepare_direct_graphics()call should verify it handles the
request's pixel/vertex roots and binding layout correctly before the
pipeline creation.
Overall
Solid step for native graphics through the stand-in. The first-use
compile + cache hit path looks correct. Approvable.
|
Retargeted to main. For the draw-loader conflict, keep the supplied-manifest path together with main's ManifestRetry handling. I tested the temporary Translation fix on main e04217f. Keep the VS/PS in local COM owners and commit the candidate only when state == 1. With this fix, forcing an unsupported native manifest or E_FAIL at native root creation preserved the valid disk cache and allowed a same-process draw after delayed manifest publication. Both faults produced the expected 16 red / 16 clear pixels after fallback in Debug and Release /O2 on WARP and RTX 4060 Laptop, with the D3D12 debug layer enabled and published files byte-identical. The ordinary draw, stream draw and slot-67 regressions gave five passes and one native-compute WARP capability skip per preset. Please carry the fallback fix and two fault controls into the rebased PR. |
|
I reapplied the complete PR and the transactional manifest-load fix onto current main I also reran the two fault controls on WARP and RTX. Both an unsupported native manifest and a native root-creation |
|
The broader runtime integration is now in #3094, stacked on #3091. This PR remains the record of the original first-use draw and the fallback review. I linked the manifest, root-signature and PSO findings there so they can be verified against the runtime head. The #2978 claim is unchanged. Please preserve the original commit and review history when reconciling the two PRs, and keep this one open until the overlap and the full disk fallback have been verified. |
|
At f76a6cf, Debug and Release /O2 each passed five tests and had one capability skip (77, WARP native wave32 compute). Hardware native Dispatch passed with the merged cache-stamp test correction from #3231. The WARP and RTX graphics fixtures each read back 16 red and 16 clear pixels on cold and hot runs, used the already published disk pair unchanged when present, and recovered the same pixels on a later draw in the same process after a native refusal and publication. The unsupported stage retained all 32 clear pixels. Windows 11 26200.9974, WARP 10.0.26100.9818, RTX 4060 Laptop 32.0.16.1656. D3D12 debug layer enabled for the graphics fixture. cmake --build --preset dev --target startup_stream_consumer d3d12_xs_shim compile_dxil
ctest --preset dev --no-tests=error --output-on-failure -j 1 -R '^startup_(native_graphics_draw|compute_dispatch_native|stream_draw)_(warp|hardware)$'Repeat with the release preset. Please review the first-draw timing, published-disk precedence and transactional candidate state on this head. |
|
The refreshed first-draw head 850aba8 (tree e3ae37972ded055bb93f729762b3348321d6ebe9) incorporates the slot-67 baseline and preserves both sets of CMake controls. On Windows 11 26200.9974 with RTX 4060 Laptop and inbox WARP, Debug and Release /O2 each gave five passes and one capability skip. Both MRT late-manifest checks recovered on the later draw, both first-draw fixtures passed, and hardware native Dispatch passed. Inbox WARP native Dispatch reported 77. ctest --preset dev --no-tests=error --output-on-failure -j 1 -R '^startup_(native_graphics_draw|mrt_dxc|compute_dispatch_native)_(warp|hardware)$' |
|
@lambirou, could you independently review first-draw head 850aba8? Please focus on publication of the native VS/PS candidate, precedence for an already-published disk pair, and a later draw after a late refusal. The commands and Windows results are in the current-head receipt. The required Windows CI has passed. |
lambirou
left a comment
There was a problem hiding this comment.
Independent review of 850aba86c088c2198e2baa09698d8223589aaecb.
I rebuilt the head in a clean worktree and ran the focused suite on Windows 11 26300, WARP 10.0.26100.10068 and RX 9060 XT 32.0.32029.2010. Debug and Release each gave 7 passed and 1 capability skip (startup_compute_dispatch_native_warp, 32-lane waves). The new startup_native_graphics_draw_{warp,hardware} passed in both presets: cold cache=0,0,0, hot 1,1,1, 16 red and 16 clear pixels; the published disk pair drew with no native attempt and its .txt/.vs.cso/.ps.cso files stayed byte-identical; the failed native attempt left the first target clear and the later draw after publication recovered 16 red and 16 clear; the unsupported pixel stage kept all 32 clear.
Focus points:
- Candidate publication is transactional.
try_native_graphicsbuilds a localTranslation, attaches both blobs, callsload_translation(candidate, {}, manifest), and assignstr = std::move(candidate)only afterstate == 1; the blobs are detached only then. A manifest or root failure discards the candidate and leaves the live entry'smanifest_retryintact. - Published disk precedence holds. When
<key>.txtexists atcached_translation,load_translationclears the retry andtry_native_graphicsis not called. The no-native graphicsassertion and unchanged cache files in the fixture confirm it. - A later draw after a late refusal recovers. The shipped control uses a missing SDK, which fails before the candidate is built. I additionally injected
E_FAILatcreate_translated_rootafter the candidate and blobs were constructed (local patch, reverted). The first draw stayed all clear; the later draw after publishing the disk manifest drew 16 red and 16 clear on WARP and the RX 9060 XT, withnative graphics ... ready=0. This confirms the candidate discard preserves the retry.
One coverage request: please commit a permanent late-failure control (the root-creation E_FAIL or an unsupported provided manifest). The current failed native attempt case exits before the candidate exists, so it would not catch a regression that mutates the live translation before state == 1.
The D3D12 debug layer is unavailable on this machine (0x887a002d), so I could not repeat the debug-layer assertions; the normal draw path and both adapters passed. PSO-failure fallback is out of scope here and tracked by #3139/#3094.
|
@lambirou, the permanent late rejection control is on 3440edf. Both native stages compile, then the fixture supplies an unsupported manifest version to the local candidate. It requires the manifest diagnostic and ready=0, verifies the first 32 pixels are still clear, publishes the original disk manifest, and checks 16 red plus 16 clear pixels on the later draw in the same process. The three disk files stay byte-identical. The missing-DXC early control remains separate. Debug and Release /O2 each had 5 passes and 1 capability skip (inbox WARP native wave32 Compute). Both late graphics cases passed on RTX 4060 Laptop (32.0.16.1656) and WARP 10.0.26100.9818, Windows 11 26200.9974, debug layer enabled. Please recheck the new control on this head. Mutation check in the Debug WARP fixture: locally clearing the live manifest retry when the native candidate fails leaves the cold/hot draws, disk precedence and missing-DXC negative passing. The new late-manifest case fails at the second-draw pixel assertion (CTest exit 8). With that local mutation removed and the shim rebuilt, the same test passes (CTest exit 0). The published head contains only the test control. |
lambirou
left a comment
There was a problem hiding this comment.
Re-checked 3440edff857bbda116ad2949c8a2d4487cc15c8f.
The new control is the one I asked for. It compiles both stages, attaches both blobs to the local candidate, replaces the provided manifest with x2w-manifest 0, and requires unsupported manifest version for <key> plus native graphics <key> ready=0. The first draw stays all clear, the original disk manifest is published, and the later draw in the same process gives 16 red and 16 clear on both adapters; the three disk files stay byte-identical. The missing-DXC early control remains separate.
On Windows 11 26300, WARP 10.0.26100.10068 and RX 9060 XT 32.0.32029.2010:
- Debug: 5 passed, 1 capability skip (
startup_compute_dispatch_native_warp). - Release: 5 passed, 1 capability skip.
startup_native_graphics_draw_{warp,hardware}: 2/2 in each preset; both retry cases pass.- No regressions in
startup_mrt_dxc_{warp,hardware}or hardware native Dispatch.
Hosted CI is green on this head: Windows build/test, Linux Python checks, and gfx1013 assembly/translation passed; /O2 and the coverage chart are skipped as usual. The D3D12 debug layer is still unavailable here (0x887a002d), so I could not repeat those assertions; your run covers them.
Candidate publication, published-disk precedence, and the later draw after a late refusal now all have committed coverage. Approved.
Refs #2978
With
X2W_NATIVE_SHADERSset, the graphics runtime links a supported VS/PS pair, compiles both stages in process and uses the native binding manifest to create the pipeline. The fixture starts with an empty cache and uses a fresh process for the second draw.Tested locally on Windows 11 build 26200.9974, Release, NVIDIA GeForce RTX 4060 Laptop driver 32.0.16.1656 and WARP, with the D3D12 debug layer enabled.
Both tests passed. Cold and warm draws each produced exactly 16 red and 16 clear RGBA8 pixels. Frontend, VS and PS cache hits changed from
0,0,0to1,1,1. An unsupported pixel stage left all 32 pixels clear. The hardware slot 67 regression also matched all 320 words. Scope is a source-built draw on one fixed target format. Independent review and CI are pending.