shader: report xbox.* intrinsics as declarations, calls and metadata names #602
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/608"
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 MoonYueya on 2026-11-22T15:36:28Z.
Change
Refs #584. Adds a read-only inventory of the
xbox.*intrinsic names in a DXIL module, reported in three groups so a gate can later rely on calls alone. It advances S1 of #584 ("report the intrinsic set fromdxil_retarget.py, no behaviour change") and lands no gate and no submission behaviour.tools/probe_roots.pypreviously derivedxbox_call_sitesfrom call instructions only, so a name that a module merely declares, or one that appears in metadata alone, was indistinguishable from a real call. The newxbox_intrinsic_inventory()classifies the same disassembly text into:calls— symbols referenced by call instructions, with a site count;declarations—declarefunction-table entries;metadata_only— names carried by a metadata string value (!"xbox.…") that are neither declared nor called.An unused declaration and a metadata-only name therefore never appear under
calls. A named-metadata key is a node name, not an intrinsic:!xbox.compiler.options = !{!1}and!xbox.module = !{!0}contribute nothing, so the option node that Xbox modules carry does not surface as an intrinsic name, and neither does an attachment reference such as!xbox.md !3.Wire-up, all additive:
validate_shader()reports the inventory asir.xbox_intrinsicsand takes the unchangedxbox_call_sitesvalue fromxbox_intrinsic_inventory()["calls"]; the call-site regular expression is now one module constant shared by both, so the two views cannot drift. On the synthetic shapes below the newcallsmapping equals the previousxbox_call_sitesmapping exactly.tools/dxil_retarget.pyaddsxbox_intrinsicsto each container entry of the--pereport, taken from the module as submitted (before). In the container mode,--probe root_probe.exealready serialisesvalidation.ir, so the inventory appears there without a new option.docs/experiments.mddocuments the three groups and the key rule.Verification
Commit
1edd6bd, Windows x64. Toolchain from thedevpreset: Visual Studio 2026 BuildTools 18.11.0 (MSVC 19.51.36260.0), CMake and Ninja fromvcvars64.bat, Windows SDK 10.0.26100.0 (dxc.exeanddxil.dll1.8.2502.11), Python 3.15.0.CMakeLists.txtandCMakePresets.jsoncontain noFetchContent,ExternalProject,vcpkgorfile(DOWNLOAD), so the configure and build steps fetch nothing.-DINTAKE_PYTHONonly points the Python-driven tests at the host interpreter: the defaultout/pe-env/Scripts/python.exeis not created unless a contributor makes it, and without itshader_metadata_*anddxil_retarget_*are not registered at all. No package was installed.The same inventory was also exercised outside this test suite on the 52 console-compiled compute modules of the DLL that
docs/experiments.mdalready pins by SHA-256 (99f803ac…23707e); no bytes, shader names or derived files are included here, and no test depends on these numbers. That entry already records the split — 9 of the 52 make no directxbox.*call — and the classifier reproduces it while adding the two columns it does not have:xbox.*call (the 43 indocs/experiments.md)metadata_onlynon-empty, which would mean a named-metadata false positive (!xbox.compiler.optionsis present in every module)declarationsdiffering fromcallsCross-checked against an earlier extraction of the same disassembly that matched
@xbox\.(\w+)\(: it agrees on every name it found and misses 19 names across 11 containers, all of them dotted —MakeUniform.i32,MakeUniform.i64,ReadLane.i32,LaneSwizzle.i32,TypedLoad.i32. They are real calls in the text, so a\w+-style pattern silently under-reports these names;CALL_SITEaccepts[\w.$-]+, so the inventory has no such gap. Worth knowing for anyone re-deriving that nine-module list.Evidence and follow-up
The fixtures are original IR text written for this test in
tests/dxil_retarget_check.py, in the shaperoot_probe --disassembleprints, and are contributed under the repository's MIT license; there are no game files, dumps or derived binaries. They verify the classification logic only — the 52-module numbers above are local data, and no CI job depends on them. Each case is a positive control and, for the other two groups, a negative control forcalls:declare i32 @xbox.V_ALIGNBYTE_B32(...)plus a call to it, plus!0 = !{!"xbox.V_ALIGNBYTE_B32"}callshas one site;declarationslists it;metadata_onlystays empty, so a metadata mention cannot relabel a callcallsempty;declarationslists it;metadata_onlyempty!xbox.module = !{!0}with!0 = !{!"xbox.V_ALIGNBYTE_B32", i32 332}, no declaration or callmetadata_only == ["xbox.V_ALIGNBYTE_B32"]; the keyxbox.moduleis not reported;callsanddeclarationsemptydx.op.unary.f32and quoted@"dx.op.threadId.i32", withllvm.module.flagsmetadata!xbox.compiler.options = !{!1}with!1 = !{!"__XBOX_ENABLE_WAVE32=1"}, the shape every Xbox module carriesAssumptions a reviewer should check:
xbox.*call site, rather than decoding function bodies from bitcode. A module therefore needsroot_probe.exe(ordxil.dllthrough it) to be inventoried, exactly asxbox_call_sitesdoes today.callmnemonic is treated as a call, matching the existing analysis; DXIL has noinvoke.xbox.prefix itself to be reported.call void bitcast (void (i32)* @xbox.foo to void (i64)*)(i64 5)— is not matched, because the pattern requires(immediately after the symbol. The existingxbox_call_sites, and therefore--only-without-xbox-calls, share that gap; it is inherited, not introduced here.call … @xbox.…(would be counted as a call site. No such string occurs in these modules; skipping lines that begin with!would close it.;cuts the line before quoted strings are read, so a metadata string containing;is cut there and the name inside it is lost rather than shortened. Also inherited from the existing analysis.Follow-ups in #584 stay separate: S2 gates submission at the adapter with a recording submission stub (
callsis the only group that should refuse), S3 replaces the gate with the lowering path. This PR deliberately reports and changes nothing else.Checklist
callsstays empty, and e asserts that a named-metadata key is not a name).docs/experiments.md).Drafted with AI assistance; the commands above were run on the author's Windows x64 host and the numbers are pasted from that run.
Imported from R0Y00/Xbox2Windows. Originally posted by descent81 on 2026-11-22T15:41:38Z.
Independent verification of
1edd6bdfb6on Windows x64.Built root_probe, root_device_probe and offscreen_check and ran:
All six passed (including the WARP and hardware retarget checks), with no skips. The docs links and bidi checks passed as well.
I also exercised the real PE report/filter and retargeting code using a source-built compute container converted to synthetic xb2, with PE enumeration and the probe responses mocked. On both the PR and its parent, declaration-only and ordinary metadata-only cases were processed, and two direct calls to a quoted Xbox symbol caused one container to be skipped. On the PR, the quoted symbol's static count was exactly 2. The processed containers had identical output bytes on both revisions and with or without --report (SHA-256 0c4cc4e989f21c3510838edcdce7e64026934b7882534dc4d3bfc0e0edb6b535).
One inherited edge case is worth recording for S2. With this synthetic disassembly line:
the inventory reports calls={"xbox.text": 1} and metadata_only=[] even though the line contains no call instruction. In the mocked PE path, --only-without-xbox-calls skips that container on both the parent and this head. This is existing scanner behavior. A future submission gate should distinguish instruction tokens from metadata string contents before treating this result as a reason to refuse a submission.
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by MoonYueya on 2026-11-22T16:11:55Z.
Thanks for the independent run and for the mocked PE path. The
!0 = !{!"call void @xbox.text()"}case is the second inherited edge listed under Assumptions; we'll treat it as a requirement for S2. Call sites should come only from instruction lines, which means skipping lines that start with!before matchingCALL_SITE. S2 will include your line as a negative control.Drafted with AI assistance.