Repository navigation
Conversation
7bae0f0 to
760f627
Compare
760f627 to
68a1dc3
Compare
…cally, with --join and --check The script reads nvn_mtl.m as top-level blocks (functions, data, types, preprocessor groups, with the comments above them), assigns each to a part by name (split_nvn_mtl_plan.tsv, a new block goes with the one before it), writes the 14 nvn_mtl_<part>.inc files and the include lines, and refuses what it cannot read safely. --check proves the round trip byte for byte, --join puts the parts back for merging. A part whose res_add sites would share a __LINE__ with another file's gets a padding comment line, so the residency statistics keep their sites apart. dm/gfx/README.md lists the parts. Three tools read nvn_mtl.m and must follow it into the parts. impact_map.tsv matches nvn_mtl.m and its parts. usage.py treats the parts as one file for the call graph, because the statics are shared. The ABI literal test reads the parts with nvn_mtl.m. lint_c.py analyzes the parts put back together, because clang's static analyzer skips functions defined in included files. It keeps the baseline of the unsplit file and moves findings that tests report in a part to their line in the put-back text. All of them work on the unsplit and the split file. This commit adds the tool and what it needs. The cut is the next commit.
… change) Generated by dm/tools/split_nvn_mtl.py on upstream/main 2aae9f8. nvn_mtl.m (11,944 lines) keeps its includes, the residency set, deferred release, mtl_init, the memory pools and the capture hooks (633 lines). The rest moved, in whole top-level blocks and in the original order, into 14 files nvn_mtl_<part>.inc that nvn_mtl.m #includes where each part stood. Re-running the script on the unsplit file gives this commit again. Checked against the same tree unsplit. The parts put back give nvn_mtl.m byte for byte. clang -E -P with the host's flags (Mac) and with arm64-apple-ios26.0 / apple-a18 differ only in the line argument of res_add_at (43 changed lines on the Mac and on iOS, the sites stay distinct). otool -tvV of the object has the same instruction count (125,397 on the Mac, 123,597 on iOS) at the same addresses and differs only in the matching mov w1 immediates (54 on the Mac and on iOS). Same compiler warnings on the Mac (52 on each).
68a1dc3 to
1be184a
Compare
|
@seedds a note on how to land this. I suggest you take only the first commit,
If you prefer, I can drop the second and third commit from this PR so it only holds the script. Tell me which way you want it. |
|
Thanks for designing the reversible split tooling and byte-for-byte verification approach, @v0lumehi. We're closing this PR because |
What and why
Roadmap #313, the first step of "Extract, one module at a time": a mechanical split of
dm/gfx/nvn/nvn_mtl.m, an updated #133.shlibfirst) with their own interfaces, each checked with replayed frames (Capture one NVN frame and replay it against new code (DM_NVN_CAPTURE, nvn_replay), step 1 of #402 #473).Three commits, so the split can be checked by re-running it:
dm/tools/split_nvn_mtl.pywith its plan,split_nvn_mtl_plan.tsv(which top-level block goes into which part), a test, and a parts table indm/gfx/README.md. It also adapts four tools that readnvn_mtl.m, so they work on the unsplit and the split file (see below).--checkproves that putting the parts back gives the original byte for byte, and--joinputs them back.#if, a part that would come out in two pieces.dm/tools/impact_map.tsvrules fornvn_mtl.mnow match its parts.usage.pyand the ABI literal test read the parts as part ofnvn_mtl.m.lint_c.pyruns clang-tidy on the parts put back together, because the analyzer skips functions that are defined in included files. The baseline is unchanged, and the report is identical to the one for the unsplit file (274 findings).main'snvn_mtl.mat 2aae9f8 (with Capture one NVN frame and replay it against new code (DM_NVN_CAPTURE, nvn_replay), step 1 of #402 #473's capture hooks, which stay innvn_mtl.m, and dmsh_abi.h: one definition of the shader library ABI for the build and the host #391'sdmsh_abi.h).nvn_mtl.mkeeps 633 lines: the includes, the residency set, deferred release,mtl_initand the memory pools.submit456,ubuf542,tex1,193,pass823,shader1,014,state964,pso1,092,args603,lookahead796,merge855,indirect405,draw1,467,shot342,present815 (line counts of the files, with their three header lines)..git-blame-ignore-revswith the split commit, so GitHub's blame shows the real authors. Locally:git config blame.ignoreRevsFile .git-blame-ignore-revs.You can cut it yourself. If you'd rather land it at a moment of your choosing, or after more changes to
nvn_mtl.m, take only the first commit and runpython3 dm/tools/split_nvn_mtl.pyon yourmain. Then update the SHA in.git-blame-ignore-revs. After a conflict in a part:--join, resolve in the whole file, and run the script again.Re-cutting needs no plan change, with one exception: a function renamed in
mainis treated as a new block (it goes with its neighbour) until--write-planrecords it. The cut on 2aae9f8 listed 115 new blocks and the neighbour rule placed all of them, so the plan is the one from the first version.Checked
--checkgives today'snvn_mtl.mbyte for byte. Fed Split nvn_mtl.m into topic parts (mechanical, identical machine code) #133's old file, the script reproduces Split nvn_mtl.m into topic parts (mechanical, identical machine code) #133's 14 parts and itsnvn_mtl.mexactly.clang -E -Pofnvn_mtl.mbefore and after, withdm/host/Makefile's flags, and for iOS with the iPhoneOS 27.1 SDK. The only differences are the line-number arguments ofres_add_at(43 changed lines, as__LINE__now counts from each part's top). They stay distinct: no two sites in different files share a line number, and the script adds a padding comment line where they would, as in Split nvn_mtl.m into topic parts (mechanical, identical machine code) #133. This cut needed none.otool -tvVof thenvn_mtlobject for Mac and iOS has the same instruction count (125,397 on the Mac, 123,597 on iOS) and addresses. The only differences are 54mov w1, #imm, the immediates of thoseres_add_atcalls. The compiler warnings on the Mac are the same as before (52).make -C dm/host/tests GAME=010015100B514000 runandmake -C dm/gfx/tests GAME=010015100B514000 run(the GPU tests);t_perf_order --cpu(165 checks),perf-order-tsan,check_t_thermal,thermal-tsanandgl-imports;dmhostfor the three CI profiles anddm/ios/tools/compile_check.py(184 files);test_romfs_read, which needs a .NET SDK here and fails the same way onmain;main's, whose one finding above the baseline is indm/host/tests/t_pollwait.c) and the Python lint ratchet (0 new findings, as onmain).res_add_atline numbers.Docs
dm/gfx/README.md