runtime: compile a supported graphics pair on first use in the stand-in #2981
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2981"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-27T02:06:27Z.
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.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-27T02:11:23Z.
Validation of
671b9ac8188919499fa05ebd94269a33e76fbf76I rebuilt and ran the source-built fixtures in a separate checkout on Windows 11 26200.9974, MSVC 19.51.36231, Release
/O2, and Windows SDK 10.0.26100 DXC. WARP used Microsoft Basic Render Driver 10.0.26100.9818. Hardware used RTX 4060 Laptop driver 32.0.16.1656. The native graphics fixture enabled the D3D12 debug layer on both adapters and reported no error messages.Five passed and one capability skip. Both native graphics draws produced 16 red and 16 clear pixels after the fence. Fresh processes showed frontend/VS/PS cache hits
0,0,0then1,1,1. An additional cold-cache run of the invalid PS kept all 32 pixels clear, logged the decoder refusal, and left only.a,.b, and.rootrequest inputs. Both legacy stream draw fixtures passed, including late manifest publication. I also reran the WARP legacy fixture withX2W_NATIVE_SHADERSset and observed the native decoder refusal followed by successful manifest-based draws. Slot 67 matched 320 words on hardware. WARP checked refusal and fallback, then reported a capability skip for the native path because it lacks 32-lane waves.Review finding
try_native_graphicsinsrc/startup_stubs/d3d12_draw.inldetaches both blobs into the live translation and returnstrueeven whenload_translationleavesstate == 2.cached_translationthen bypasses the existing on-disk manifest, and the native parse clears the manifest retry deadline. This differs from the tested early decoder refusal, which returnsfalseand reaches the legacy loader. Please stage the native parse and root signature in a temporary translation and publish it only on success. Add a late-failure control with a valid legacy entry already present and verify that it still draws. This finding is from the control flow, and the fixture did not inject a root-signature failure. A later graphics PSO rejection also caches a null PSO for the pass, so theready=1diagnostic currently means the root and stages are ready for PSO creation.Hosted CI passed Windows build/test, Linux Python checks, and gfx1013 assembly/translation. The hosted
/O2job was skipped. The local Release run above used synthetic inputs.Imported from R0Y00/Xbox2Windows. Originally posted by Not-Saii on 2026-11-27T02:28:20Z.
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:
Not-Saii:native/first-graphics-draw-2978, three commits on05438d65. Tested locally at5639d957on Windows 11 build 26300.9974, Debug, D3D12 debug layer enabled with no error message, NVIDIA GeForce RTX 4090 driver 32.0.16.1088 and WARP (Microsoft Basic Render Driver 10.0.26100.9818).startup_draw_native_hardwareandstartup_draw_native_warppass. The note isdocs/experiments/startup-graphics-native-draw.mdon the branch.Differences from this PR
translation_for_targets, andcached_translationis untouched. A pipeline that is created and never drawn compiles nothing. Control: with the draw skipped, the cache holds request files only.<key>.vs.cso,<key>.ps.csoand then<key>.txtwith the jobcompile_dxil gfx1013-container-pair --requestsruns, moved tosrc/graphics_request_job.cppso the tool and the stand-in share it. A second process loads the entry at pipeline creation and compiles nothing. The check compares names, sizes and modification times of every cache file across that run.<key>.txtwins. The in-process compile runs only when the manifest is absent, and the first draw looks for it again first. Control: a manifest moved into place between pipeline creation and the first draw is loaded and not replaced. On the review finding above: with this order a valid on-disk entry is loaded before any native work, so a late native failure cannot bypass it. That is from the control flow and this control. I did not inject a root-signature failure either.<key>.*file:(pixel stage): native compute +0x0: unsupported pixel entry VGPR 0(vertex stage): native compute +0x8: vertex fetch call outside the entry(pair stage): native compute +0x0: graphics stages disagree on TEXCOORD0Costs
X2W_TEST_NO_DRAW,X2W_TEST_PUBLISH_BEFORE_DRAW).Regression runs on the branch (full
devbuild, same machine): 31 of 31 stream draw, pixel-history and native graphics tests pass, WARP and hardware.native_rectangle_pso_warppasses (the tool's rectangle mode goes through the moved job). Theprpreset has 36 passes. Capability skips, not passes:startup_compute_dispatch_native_warp,native_comparison_pso_warpand the fourspirv_minlod_*_warptests.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).
Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-27T04:16:47Z.
Review: COMMENTED
Strong milestone — the first native graphics draw through the stand-in. The
try_native_graphics()path cleanly sits betweenload_translation()fallback and the manifest-based path, and the test exercises cold/warm cache behavior plus refusal of unsupported stages.Findings
✅ What works well
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.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.⚠️ 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_requestvsrefused_unsupported_bindingvsrefused_compile_failure) for more precise logging and potential retry logic.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-27T05:16:10Z.
Review: COMMENTED
Follow-up on exact head
671b9ac8188919499fa05ebd94269a33e76fbf76. I ranctest --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.csovia the offline CLI and verified that it drew 16 red/16 clear with native disabled. Independently forcing an unsupported native manifest version orE_FAILat native root creation givesready=0, no draw and 32 clear pixels at this head, despite that valid cache. In a separate same-process control usingX2W_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 onstate == 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.Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-27T05:40:48Z.
Review: COMMENTED
What works
try_native_graphics()fills a missing gap: the stand-in nowaccepts 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 defaultargument
manifest = {}is backwards-compatible. When an emptystring is provided externally, the existing cache-path read still
runs. Good.
stage refusal in the same test, checking pixel counts in each case.
No debug layer warnings expected (good quality gate).
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 therequest 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 says
refused: no graphics requestfor anunsupported -- consider if that should become a debug-level event or
a specific refusal with the missing key.
try_native_graphics()function returns false if the runtimedoesn'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
try_native_graphics()returns false so developers can distinguish the reason from the
overall pipeline path taken.
prepare_direct_graphics()call should verify it handles therequest'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.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-27T11:19:06Z.
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
e04217f4. 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.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-27T14:55:53Z.
I reapplied the complete PR and the transactional manifest-load fix onto current main
ca659396, with the Opus-only #3084 candidate in the local base. The isolated integration (3712c974, treea62b28610efd46a847cdce191081abd9616369a4) retains original671b9ac8as a merge parent. Nothing was pushed. Debug and Release/O2each gave six passes and one native-compute WARP 77 skip withctest --test-dir <build> --no-tests=error -j 1 -V -R '^(startup_(native_graphics_draw|stream_draw|compute_dispatch_native)_(warp|hardware)|startup_manifest_retry)$'.I also reran the two fault controls on WARP and RTX. Both an unsupported native manifest and a native root-creation
E_FAILpreserved the working disk translation and allowed same-process retry after a missing manifest was published. A third control found a later failure: with a valid disk entry already present, forcingE_FAILonly for the nativeCreateGraphicsPipelineStateleft all 32 pixels clear in both presets on both adapters. The baseline disk entry drew 16 red / 16 clear, and its files stayed byte-identical. The native candidate logsready=1beforepipeline_forattempts PSO creation, and that function caches the null PSO. Please keep the original commits in the integration and extend fallback through this native-only PSO failure, preserving the disk path for the same render-target key. The remote head still has the draw-loader conflict.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-27T15:04:27Z.
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.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-28T00:31:32Z.
At
f76a6cf4b7, 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.Repeat with the release preset. Please review the first-draw timing, published-disk precedence and transactional candidate state on this head.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-28T01:09:48Z.
The refreshed first-draw head
850aba86c0(treee3ae37972d) 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.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-28T02:02:29Z.
@lambirou, could you independently review first-draw head
850aba86c0? 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.Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-11-28T02:27:36Z.
Review: COMMENTED
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 newstartup_native_graphics_draw_{warp,hardware}passed in both presets: coldcache=0,0,0, hot1,1,1, 16 red and 16 clear pixels; the published disk pair drew with no native attempt and its.txt/.vs.cso/.ps.csofiles 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:
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.<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.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_FAILor an unsupported provided manifest). The currentfailed native attemptcase exits before the candidate exists, so it would not catch a regression that mutates the live translation beforestate == 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.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-28T02:36:25Z.
@lambirou, the permanent late rejection control is on
3440edff85. 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.
Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-11-28T02:42:41Z.
Review: APPROVED
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 requiresunsupported manifest version for <key>plusnative 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:
startup_compute_dispatch_native_warp).startup_native_graphics_draw_{warp,hardware}: 2/2 in each preset; both retry cases pass.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;
/O2and 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.