Repository navigation
startup: add a read-only --refusals census of gfx2hlsl refusal sites - #1978
Conversation
…raw encoding names AI-assisted.
AI-assisted.
Ran it, broke the normaliser five ways: four caught, the hex redaction is unpinnedWindows 11 build 26300.9974, device-free: out/pe-env/Scripts/python.exe -B tests/startup_gfx2hlsl_refusals_check.py
exit 0
What the surviving line does, and why its loss mattersCalling So the operand-position rule at 2132–2133 covers Suggested case, one line in the existing shape: assert normalize_refusal('v_mov_b32 with literal 0x3f800000') == 'v_mov_b32 with literal N'
assert normalize_refusal('unexpected value 0x7fc00000 in source') == 'unexpected value N in source'One process note, not a finding about the PRTwo neighbouring checks ( What I like about the design
What this does not establishNothing about a full cache: the fixture builds its own requests. The undercount behind the first refusal (#1723's motivation) is a VerdictReviewed. The normaliser is well covered except its hex-redaction line, which the fixture never exercises. Notes
|
Refs #1723.
Change
tools/startup/gfx2hlsl.pystops a pipeline at its first refused instruction. A cache of refused requests therefore shows one layer of gaps at a time: fixing a refusal reveals the next one behind it, and the census in #1723 notes that the gaps behind the first refusal are undercounted.This adds a read-only diagnostic:
It loads every request in the directory through the same loader as
--pending, including RTV variants and requests that already have a.txtor.fail. Each request is translated in memory with a collector:.fail, after normalisation; file errors are reported asunreadable shader requestbecause their text holds the path and key;translator crash in <op>: <type>when nothing was recorded before it, a translator bug, or asinternal error in <op>: <type>after an earlier refusal or crash, a possible follow-on effect.The report has two views:
decode,vs,ps,pipeline), the requests that contain it, that reach it first, and that have it as their only distinct reason, plus a histogram of refusal sites per request and the count with no refusal recorded (not compiled);.aand.bbytes, excluding RTV variants, with each reason counted under every observed root signature or under some roots only.Register numbers and immediates are normalised (
sN,s[N:N],vN), as are raw instruction words. Numbers that are the cause, such as a format, a width or a shader model, are kept. No request key or path is printed; refusal text is printed only after this normalisation. Counts after the first refusal are approximate, because a skipped instruction leaves later state unmodelled; the report and the docs say so.The mode writes nothing:
refusals_mainnever reachestranslate_to, opens no file for writing, never starts fxc, and exits beforemain()'sos.makedirs. It is selected by--refusals DIRor--refusals=DIRanywhere on the command line. With the collector unset, the default path is unchanged. Thedecode()encoding checks, #1932's NEG rewrite included, move verbatim intocheck_encoding(). Request loading is split out oftranslate_request()intoload_request(). The end ofmain()(the pending loop that #1749 rewrites) is untouched. On a translator without this change,--refusals DIRis treated as--pending DIRand writes into the directory; the docs say so.Registered as CTest
startup_gfx2hlsl_refusals, in thepython-linuxCI list and inAGENTS.md. There is a section indocs/experiments.mdand a short note indocs/startup-runtime.md.Verification
On
425cd53b(based onmainat889cd3f4), Windows 11 build 26300, Python 3.14.10:47 checks pass, without game data or LLVM, and with
X2W_FXCempty so fxc is never started. The disassembler is stubbed with synthetic words, except the NEG check, which decodes one hand-assembledv_cndmask_b32_e64word with the in-tree decoder. They cover:.failtext;only;word_0x…;--refusals=DIR, and a missing directory that is never created;translate_topatched to raise aBaseExceptionsubclass.A control stops at the first refusal and requires the second reason to disappear from the report. On
mainthe script ends at its first collector call with an uncaughtgfx2hlsl.Unsupported: unsupported_first.Local data, not in the repository. On a local cache of 575 recorded requests (the synthetic check above covers the same properties without it: unchanged default output, an unchanged directory, no key in the report):
X2W_FXC= python -B tools/startup/gfx2hlsl.py --pending <copy>with this branch and withmainat889cd3f4gives byte-identical directories (897 files) and identical logs;--refusals <copy>leaves every file byte-identical and prints no 16-hex-digit key or rawword_0xname.Also run on this branch, each
python -B tests/<name>exiting 0:startup_translator_check.py,startup_gfx2hlsl_capture_check.py,startup_ngg_slice_check.py,startup_gfx2hlsl_f32_lg_check.py,startup_gfx2hlsl_f32_nan_check.py;startup_gfx2hlsl_cndmask_neg_check.py,startup_gfx2hlsl_op_refusals_check.py,startup_uniform_lane_check.py,startup_gfx2hlsl_scalar_m0_check.py,startup_gfx2hlsl_sop2_complement_check.py,startup_gfx2hlsl_smem_offset_check.py;docs_links_check.py,bidi_controls_check.py.CTest was not run: no build tree was configured for this change. The registration is one
add_testbeside its neighbours, and CI runs the script directly.Evidence and follow-up
tools/startup/gfx2hlsl.py: none textual with startup: translate shader requests in parallel and during a run #1749 (it rewrites the end ofmain()) or startup: prove lane-pure v_readfirstlane_b32 sources uniform in straight-line code #1931 (translate()hunks separated by unchanged lines). startup: prove lane-pure v_readfirstlane_b32 sources uniform in straight-line code #1931 and this change both add anadd_testafterstartup_gfx2hlsl_smem_offsetinCMakeLists.txt; whichever lands second needs a one-line rebase. startup: structure simple loops in gfx2hlsl #1631 edits the same lines ofPipeline.__init__,Stage.__init__and the top ofStage.translate(), so the second to land needs a manual rebase; its newStageargument is positional and this change passes its own by keyword, so the two compose.Checklist
AI-assisted.