"""The pipeline state lists (gpu/vk/vk_draw.cpp: triforce_pipeline_states.bin, written as the game is played): show one, or merge several into the list a release ships (work/pipeline_states.bin, copied by nx2/make_game.py beside the game as triforce_pipeline_states_shipped.bin, whose pipelines the first start's shader preparation builds before the title). python -I nx2/pipeline_states.py ... what they hold python -I nx2/pipeline_states.py --out work/pipeline_states.bin ... merged, each pipeline once A list holds no game code: each record is a pipeline's stage code keys (hashes of the game's shaders, which the player's own triforce_shaders.bin turns back into the shaders), the program variant's hash, and the formats and draw state baked into the pipeline. : "HKSTATE1", u32 record size (528), then the records: u64 code[4] (vertex or mesh, fragment, task, the header-only stage), u64 variant, u32 mesh, topology, targets, samples, depth format, has depth, u32 color formats[8], u8 color types[8], u64 blend[8], u32 vertex attributes[16], u32 attribute count, u32 strides[16], u32 divisors[16], u32 blend enables, channel mask, polygon mode, depth clamp, alpha to coverage, pad, u32 answers, u32 questions, u32 answers[24] (stage, descriptor, image, type), u8 questions[32] (each answer as asked) """ import argparse import collections import struct import sys MAGIC = b"HKSTATE1" SIZE = 528 def read(path): with open(path, "rb") as f: data = f.read() if data[:8] != MAGIC or struct.unpack_from("