"""The shared pipeline list: graphics pipelines players met, for an install to build before play. A game folder records every graphics pipeline a run builds in pipeline-keys.bin (runtime/vk_pipeline.c "pipeline keys": the pipeline state with its shaders named by input id) and every shader variant in shader-answers.bin (runtime/gfx_shader.c "answers met in play": stage, code hash, input id, translator answers). The next start of that folder builds its recorded pipelines ahead of play; another install, or the same one after its caches were removed, meets each of them in play first. A mesh pipeline met that way is compiled then, 0.2 to 1.1 s with its draws left out of the picture: all of it where mesh pipelines have no stage libraries, and otherwise the library of its task and mesh stages, which is most of it and which only a pipeline record names (runtime/vk_pipeline.c "mesh pipelines' stage libraries ahead of their draws"). This tool folds the two files of any number of game folders into one list file; a list file made before can stand in for a folder, so a list grows by the folders played since. Beside the shader variants the pipelines name, the list takes the compute variants each folder dispatched: no pipeline record names a compute shader, and a variant with other answers than the shader list's default one was translated in the middle of play, 30 to 40 ms on the frame that first dispatched it. tools/prepare_shaders.py reads the list beside the shared shader list: the shader variants it names go into the seed, so the preparation translates them, and its pipeline records go next to the game as seed-pipeline-keys.bin, which every start of the game counts as recorded pipelines beside its own (runtime/vk_pipeline.c keys_open_seed), so a new install builds them before play, and which `nx2navi.exe --prepare-shaders` (and `--prepare-pipelines` on a folder that is prepared already) builds once into the pipeline cache and the graphics driver's own. What a record depends on. Its shaders are named by input id, a hash of the game's shader code and the answers, which no translator, GPU or driver changes: a record made on one machine names the same shaders on another with the same game version. Its state is the game's (formats, blend, depth and stencil, topology, sample count) and a few choices of the runtime's settings (a culled foliage shadow pass, the depth range); everything that depends on the GPU is derived from it when the pipeline is built. A record whose state this install never reaches costs one pipeline in the caches, and one whose shader this game version lacks is left out by the preparation. The record layout belongs to the runtime that wrote it (KEYS_VERSION and the record size, in the file's header): a list is made again for a runtime that changes either, and the runtime ignores one that does not match. The list is derived from game data: it stays out of the repository (tools/check_content.py refuses it) and travels with the installer archive as data/pipeline_list.bin, as the shader list does. python tools/pipeline_list.py merge OUT.bin GAME_DIR_OR_LIST [GAME_DIR_OR_LIST ...] [--mesh-only] python tools/pipeline_list.py info FILE_OR_GAME_DIR [...] File: "NX2NPLST", version u32, answers bytes u32, keys bytes u32, then a shader-answers.bin image (header, the records the keys name and the compute variants', input id kept) and a pipeline-keys.bin image (header and records). """ import argparse import struct import sys from pathlib import Path MAGIC = b'NX2NPLST' VERSION = 1 ANS_MAGIC, ANS_REC = b'NX2NSANS', 4 + 32 + 32 + 147 + 1 # gfx_shader.c: stage, code hash, input id, answers, pad KEYS_MAGIC = b'NX2NPKEY' ID = 32 STAGE_NAMES = {0: 'vertex', 4: 'fragment', 5: 'compute', 6: 'task', 7: 'mesh'} # runtime/gfx.h GFX_STAGE_* STAGE_COMPUTE, STAGE_MESH = 5, 7 def read_answers(data): """shader-answers.bin image -> its records (bytes each); [] for another magic or record size.""" if len(data) < 16 or data[:8] != ANS_MAGIC: return [] _, rec = struct.unpack_from(' (magic, version, record size, records); records [] for a file too short.""" if len(data) < 16: return b'', 0, 0, [] magic = data[:8] version, rec = struct.unpack_from(' (answers records, pipeline-keys.bin image); None when it is not one.""" if len(data) < 20 or data[:8] != MAGIC: return None version, na, nk = struct.unpack_from('