diff --git a/docs/experiments/native-fixed-mesh57.md b/docs/experiments/native-fixed-mesh57.md index c5f456dfc1..582d4e3c02 100644 --- a/docs/experiments/native-fixed-mesh57.md +++ b/docs/experiments/native-fixed-mesh57.md @@ -91,6 +91,8 @@ Set `X2W_SHADER_CACHE` to the request cache and `X2W_MESH57_CAPTURE_STATE=1` to Native preparation reads a separately reviewed `.mesh57-state` profile from the cache. The stand-in lists the cache's top-level file names once per process, at the first profile lookup (`src/startup_stubs/cache_index.h`), and opens a profile only when that listing has its name. A profile written while the process runs is read by the next process. Its versioned Windows x64 header is defined by `Mesh57Profile` in `src/startup_stubs/mesh57_profile.h`. The header supplies the MS entry layout and desktop fixed-function state. The file ends with the normalized descriptor, register blocks, serialized root and both guest programs. The stand-in compares every byte before building a PSO. The fixture authors this profile from its own known inputs. A captured register block alone does not establish the desktop rasterizer state or MS entry layout. +The `.mesh57-state` name uses a stable profile key. `stable_mesh57_profile_descriptor` first recognizes the same 0x300 layout as `normalize_mesh57_descriptor`: the `0x04010000` markers at `0x11c` and `0x27c`, the zero and non-zero length words, and the ten required record pointers near the section pointer at `0x38`. Any other 0x300 descriptor is returned byte-for-byte, so its unclassified bytes still distinguish profiles. In a recognized layout the optional pointers `0x198`, `0x1b8`, `0x1d8` and `0x2f8` are made relative when near the section. The four 32-bit values at `0x188`, `0x1a8`, `0x1c8` and `0x2e8` keep only their distance from the first valid value, so a common base shift keeps the key and a changed spacing does not; small values such as `0x40`/`0x80` remain metadata. Finally the qwords at `0x38`, `0x78`, `0x120`, `0x128`, `0x160`, `0x168`, `0x178`, `0x198`, `0x1b8`, `0x1d8`, `0x280`, `0x288`, `0x2c0`, `0x2c8`, `0x2d8` and `0x2f8` and the dwords at `0x110`, `0x270` and `0x1f4` are cleared; `0x188`/`0x1a8`/`0x1c8`/`0x2e8` are never cleared. The `.s57` archive keeps its stream-key variant name and the full normalized descriptor; the profile name, lookup and byte comparison use this stable form. `normalize_mesh57_descriptor` and its stream-key test are unchanged. The fixture covers a common second-base shift, a spacing change, unclassified bytes under an unknown marker, metadata in a second-base slot and idempotence. + To serialize reviewed desktop and entry state, run `python -B tools/startup/mesh57_profile.py ARCHIVE REVIEWED.json OUTPUT_DIR`. Keep the three request companions beside the archive. The diff --git a/docs/startup-runtime.md b/docs/startup-runtime.md index 976e2f80ee..879c8d4b91 100644 --- a/docs/startup-runtime.md +++ b/docs/startup-runtime.md @@ -1865,6 +1865,7 @@ ctest --preset dev --no-tests=error -R '^startup_hook_(window|overlap)$' -V | `X2W_D3D12_RELEASE_RETIRED=1` | opt-in, effective with `X2W_D3D12_RENDER=1` only (the list handlers that record holds exist only there): frees the desktop object of a released committed 2D texture of one narrow class once no recorded list, submission or release-time fence refers to it ([details](#d3d12-resource-budget)). Unset, nothing changes | | `X2W_D3D12_INLINE_DESCRIPTORS=1` | opt-in: leaves byte +0x18 of the guest device at 0, so the title writes constant buffer views and copies CBV/SRV/UAV descriptors itself instead of calling device slots 17 and 24 (sampler copies still arrive through slot 24); with `X2W_D3D12_RELEASE_RETIRED=1`, a retired resource is then freed once its release fences pass ([details](#d3d12-inline-descriptors)). Unset, nothing changes | | `X2W_D3D12_NO_VISIBLE_HEAP_MIRROR=1` | negative control only: title view and sampler heaps created shader-visible get no CPU-only mirror. By default every view, sampler and copy the stand-in writes into a shader-visible range goes to the mirror first and is copied from there, and copies and `ClearUnorderedAccessView*` read a visible descriptor from the mirror, because desktop D3D12 reads those only from CPU-only heaps (debug layer message 654; a driver fault on a GTX 1060, #3558). The switch restores the direct read | +| `X2W_MESH57_CAPTURE_STATE=1` | opt-in: archives each slot 57 fixed mesh variant as `req_.s57`; a published `.mesh57-state` uses the stable profile key for a recognized 0x300 layout (optional record pointers relative, the common `+0x188`-base values shifted, remaining relocations cleared; an unknown layout keeps every byte), so its name can differ from the `.s57` stream-key variant | | `X2W_D3D12_RELEASE_RETIRED_VIEWS=1` | legacy diagnostic. Logs that clearing live slots is disabled and enables the existing retirement breakdown when base retirement and budgets are on ([details](#d3d12-resource-budget)) | | `X2W_D3D12_AGILITY=` | opt-in: the stand-ins select the Agility SDK `D3D12Core.dll` in `` before the first D3D12 device of the process (Windows Developer Mode only; `` on the executable's drive). Unset, the in-box runtime stays and nothing is read ([details](#d3d12-agility-sdk-runtime)) | | `X2W_D3D12_RETIRE_REASONS=1` | diagnostic only, effective with `X2W_D3D12_RELEASE_RETIRED=1` and `X2W_D3D12_BUDGET=1`: adds one `x2w-retire held:` line to the heartbeat that counts final-released resources whose desktop object is still alive, by reason ([details](#d3d12-resource-budget)). Unset, nothing is recorded | diff --git a/src/startup_stubs/mesh57_profile.h b/src/startup_stubs/mesh57_profile.h index 84844db93b..9ee15302f2 100644 --- a/src/startup_stubs/mesh57_profile.h +++ b/src/startup_stubs/mesh57_profile.h @@ -61,6 +61,68 @@ inline std::vector normalize_mesh57_descriptor(std::vector stable_mesh57_profile_descriptor(std::vector desc) +{ + if (desc.size() != 0x300) + return desc; + const auto word = [&](std::size_t offset) { + std::uint32_t value; + std::memcpy(&value, desc.data() + offset, sizeof(value)); + return value; + }; + const auto address = [&](std::size_t offset) { + std::uint64_t value; + std::memcpy(&value, desc.data() + offset, sizeof(value)); + return value; + }; + const auto put = [&](std::size_t offset, std::uint64_t value) { + std::memcpy(desc.data() + offset, &value, sizeof(value)); + }; + const auto is_pointer = [](std::uint64_t value) { + return value >= 0x10000 && value < 0x800000000000ull; + }; + const auto section = address(0x38); + if (address(0x48) || address(0x50) || !address(0x30) || !address(0x70) || + word(0x11c) != 0x04010000 || word(0x27c) != 0x04010000 || !is_pointer(section)) + return desc; + const auto near_section = [&](std::uint64_t value) { + return is_pointer(value) && (value >= section ? value - section : section - value) <= INT32_MAX; + }; + constexpr std::size_t required_pointers[]{ + 0x38, 0x78, 0x120, 0x128, 0x168, 0x178, 0x280, 0x288, 0x2c8, 0x2d8 + }; + for (const auto offset : required_pointers) + if (!near_section(address(offset))) + return desc; + constexpr std::size_t optional_pointers[]{0x198, 0x1b8, 0x1d8, 0x2f8}; + for (const auto offset : optional_pointers) + if (near_section(address(offset))) + put(offset, address(offset) - section); + std::uint64_t second_base = 0; + for (const auto offset : {0x188, 0x1a8, 0x1c8, 0x2e8}) { + const auto value = address(offset); + if (value < 0x10000 || value >> 32) + continue; + if (!second_base) second_base = value; + put(offset, value - second_base); + } + constexpr std::size_t qwords[]{ + 0x00, 0x08, 0x18, 0x28, 0x38, 0x68, 0x78, 0x120, 0x128, 0x160, + 0x168, 0x178, 0x198, 0x1b8, 0x1d8, 0x280, 0x288, 0x2c0, 0x2c8, 0x2d8, 0x2f8 + }; + constexpr std::size_t dwords[]{0x110, 0x270, 0x1f4}; + for (const auto offset : qwords) + std::memset(desc.data() + offset, 0, sizeof(std::uint64_t)); + for (const auto offset : dwords) + std::memset(desc.data() + offset, 0, sizeof(std::uint32_t)); + return desc; +} // A reviewed fixed-state/entry record. The header is followed by the exact normalized fixed // descriptor, the two register blocks, creation root blob, guest MS and guest PS, in this order. // Descriptor normalization removes the relocations recognized in each fixed layout. diff --git a/src/startup_stubs/native_mesh57.inl b/src/startup_stubs/native_mesh57.inl index 3cb399a6e7..99982132b5 100644 --- a/src/startup_stubs/native_mesh57.inl +++ b/src/startup_stubs/native_mesh57.inl @@ -433,7 +433,8 @@ void prepare_native_mesh57(Wrapper* pipeline) constexpr char revision[] = "x2w-startup-mesh-57-4"; const u64 key = fnv_part(root_blob, fnv_part(ps_bytes, fnv_part(ms_bytes, fnv_bytes(revision, sizeof(revision) - 1)))); const auto normalized = x2w_startup::normalize_mesh57_descriptor(info->desc); - const auto variant = fnv_part(info->state_b, fnv_part(info->state_a, fnv_part(normalized, key))); + const auto stable = x2w_startup::stable_mesh57_profile_descriptor(normalized); + const auto variant = fnv_part(info->state_b, fnv_part(info->state_a, fnv_part(stable, key))); if (!cache_path(path, L"", variant, L".mesh57-state")) return note_mesh57_outcome(Mesh57Outcome::profile_absent); InterlockedIncrement(&mesh57_profile_lookups); @@ -496,8 +497,17 @@ void prepare_native_mesh57(Wrapper* pipeline) if (!size) return; std::string copy(size, 0); - if (!file.read(copy.data(), size) || std::memcmp(copy.data(), bytes, size)) + if (!file.read(copy.data(), size)) throw profile_error(Mesh57Outcome::profile_input_content, std::string("profile input bytes differ: ") + name + " content"); + if (part == 0) { + std::vector stored(copy.begin(), copy.end()); + if (x2w_startup::stable_mesh57_profile_descriptor(stored) != stable) + throw profile_error(Mesh57Outcome::profile_input_content, + std::string("profile input bytes differ: ") + name + " content"); + } else if (std::memcmp(copy.data(), bytes, size)) { + throw profile_error(Mesh57Outcome::profile_input_content, + std::string("profile input bytes differ: ") + name + " content"); + } }; match(0, "normalized descriptor", normalized.data(), normalized.size()); match(1, "state_a", info->state_a.data(), info->state_a.size()); diff --git a/tests/mesh57_profile_draft_check.py b/tests/mesh57_profile_draft_check.py index 80ddcc69bb..6218a03022 100644 --- a/tests/mesh57_profile_draft_check.py +++ b/tests/mesh57_profile_draft_check.py @@ -417,6 +417,7 @@ def check_census(folder): def main(): compiler = Path(sys.argv[1]) if len(sys.argv) > 1 else None dxc = Path(sys.argv[2]) if len(sys.argv) > 2 else None + stable_key_checks() check_classification() check_depth_decode() check_blend_words() @@ -431,5 +432,63 @@ def main(): print("slot 57 profile draft, review, depth-only and refusal checks passed") +def stable_key_checks(): + def build(section, allocation): + desc = bytearray(0x300) + offsets = (0x38, 0x78, 0x120, 0x128, 0x168, 0x178, 0x198, 0x1d8, + 0x280, 0x288, 0x2c8, 0x2d8, 0x2f8) + for index, offset in enumerate(offsets): + struct.pack_into("; + const auto put = [](Bytes& bytes, size_t offset, auto value) { + std::memcpy(bytes.data() + offset, &value, sizeof(value)); + }; + const auto build = [&](uint64_t section, uint64_t allocation) { + Bytes bytes(0x300); + constexpr size_t offsets[]{ + 0x38, 0x78, 0x120, 0x128, 0x168, 0x178, 0x198, 0x1d8, + 0x280, 0x288, 0x2c8, 0x2d8, 0x2f8 + }; + for (size_t i = 0; i < std::size(offsets); ++i) + put(bytes, offsets[i], section + i * 16); + put(bytes, 0x78, section - 16); + put(bytes, 0x110, static_cast(section + 8 * 16)); + put(bytes, 0x270, static_cast(section + 16)); + put(bytes, 0x30, uint64_t{512}); + put(bytes, 0x70, uint64_t{1024}); + put(bytes, 0x11c, uint32_t{0x04010000}); + put(bytes, 0x27c, uint32_t{0x04010000}); + put(bytes, 0x160, allocation); + put(bytes, 0x2c0, allocation); + return bytes; + }; + const auto stable = [](const Bytes& bytes) { + return x2w_startup::stable_mesh57_profile_descriptor(bytes); + }; + const auto fold = [](uint64_t key, const void* data, size_t n) { + const auto* p = static_cast(data); + for (size_t i = 0; i < n; ++i) + key = (key ^ p[i]) * 1099511628211ull; + return key; + }; + const auto extend = [&](uint64_t base, const Bytes& part) { + const uint64_t n = part.size(); + return fold(fold(base, &n, sizeof(n)), part.data(), part.size()); + }; + const auto profile_key = [&](const Bytes& desc) { + uint64_t key = 0x12345678ull; + key = extend(key, stable(desc)); + key = extend(key, Bytes{1, 2, 3, 4}); + key = extend(key, Bytes{5, 6}); + return key; + }; + + constexpr uint64_t first_section = 0x10020000; + const auto original = build(first_section, 0x30030000); + const auto relocated = build(0x140050000, 0x260070000); + const auto normalized = stable(original); + if (normalized == original || normalized != stable(relocated) || normalized != stable(normalized) || + profile_key(original) != profile_key(relocated)) + return false; + + auto different_metadata = original; + different_metadata[0x207] = 1; + // 0x30 is a stable scalar: changing it must change the profile key. + auto different_scalar = original; + put(different_scalar, 0x30, uint64_t{768}); + // 0x1d8 is a section relocation: the stable form clears it, so the key must not change. + auto different_relocation = original; + put(different_relocation, 0x1d8, first_section + 0x400); + if (profile_key(original) == profile_key(different_metadata) || + profile_key(original) == profile_key(different_scalar) || + profile_key(original) != profile_key(different_relocation)) + return false; + + // An unknown layout must keep every unclassified byte: +0x1b8 0x40 and 0x80 cannot share a key. + auto unknown_layout = original; + put(unknown_layout, 0x11c, uint32_t{0x04020000}); + auto unknown_40 = unknown_layout; + put(unknown_40, 0x1b8, uint64_t{0x40}); + auto unknown_80 = unknown_layout; + put(unknown_80, 0x1b8, uint64_t{0x80}); + if (stable(unknown_40) != unknown_40 || stable(unknown_80) != unknown_80 || + stable(unknown_40) == stable(unknown_80) || profile_key(unknown_40) == profile_key(unknown_80)) + return false; + + // The four second-base values keep their spacing, not their absolute base. + const auto with_second_base = [&](uint64_t section, uint32_t base, uint32_t spacing) { + auto bytes = build(section, 0x30030000); + put(bytes, 0x188, uint64_t{base}); + put(bytes, 0x1a8, uint64_t{base + 0x400}); + put(bytes, 0x1c8, uint64_t{base + 0x700}); + put(bytes, 0x2e8, uint64_t{base + spacing}); + return bytes; + }; + const auto shifted = with_second_base(first_section, 0x86abaf00, 0x2f100); + const auto shifted_again = with_second_base(0x140050000, 0x1a0baf00, 0x2f100); + const auto respaced = with_second_base(first_section, 0x86abaf00, 0x2f200); + if (profile_key(shifted) != profile_key(shifted_again) || profile_key(shifted) == profile_key(respaced)) + return false; + + // A small value in a second-base slot is metadata and must still distinguish profiles. + auto metadata_40 = original; + put(metadata_40, 0x188, uint64_t{0x40}); + auto metadata_80 = original; + put(metadata_80, 0x188, uint64_t{0x80}); + if (profile_key(metadata_40) == profile_key(metadata_80)) + return false; + std::puts("mesh57 profile key: layout-gated, common second-base shift, spacing/metadata differ, idempotent"); + return true; +} + bool fixed_mesh_create_contract(ID3D12Device* guest) { - if (!mesh57_descriptor_relocations()) return false; + if (!mesh57_descriptor_relocations() || !mesh57_profile_stable_key()) return false; const D3D12_ROOT_SIGNATURE_DESC root_desc{}; const auto root = create_root(guest, root_desc); const std::array ms{0xbfa00003, 0xbf900009, 0xf80008cf, 0x03020100, 0xf8000941, 0, 0xbf810000}; @@ -2657,6 +2761,9 @@ static int native_fixed_mesh_fixture(ID3D12Device* device, ID3D12Device* guest, auto state_a = expected_a; auto state_b = expected_b; UINT64 fields[0x300 / sizeof(UINT64)]{}; + const auto set_marker = [&](UINT64 value) { + reinterpret_cast(fields)[0x207] = static_cast(value); + }; fields[2] = sizeof(state_a); fields[4] = sizeof(state_b); fields[6] = ps_size; @@ -2688,7 +2795,11 @@ static int native_fixed_mesh_fixture(ID3D12Device* device, ID3D12Device* guest, } char name[64]; const auto variant = [&] { - return extend(extend(extend(key,fields,sizeof(fields)),state_a.data(),sizeof(state_a)),state_b.data(),sizeof(state_b)); + std::vector profile_fields( + reinterpret_cast(fields), + reinterpret_cast(fields) + sizeof(fields)); + profile_fields = x2w_startup::stable_mesh57_profile_descriptor(profile_fields); + return extend(extend(extend(key,profile_fields.data(),profile_fields.size()),state_a.data(),sizeof(state_a)),state_b.data(),sizeof(state_b)); }; std::snprintf(name, sizeof(name), "%016llx.mesh57-state", variant()); x2w_startup::Mesh57Profile profile{}; @@ -2767,11 +2878,11 @@ static int native_fixed_mesh_fixture(ID3D12Device* device, ID3D12Device* guest, if (!out) return 1; } - fields[15]=1; + set_marker(1); char other_name[64]; std::snprintf(other_name,sizeof(other_name),"%016llx.mesh57-state",variant()); std::filesystem::copy_file(cache/name,cache/other_name,std::filesystem::copy_options::overwrite_existing); - fields[15]=0; + set_marker(0); fields[0] = reinterpret_cast(root.Get()); fields[1] = reinterpret_cast(state_a.data()); fields[3] = reinterpret_cast(state_b.data()); @@ -2823,7 +2934,7 @@ static int native_fixed_mesh_fixture(ID3D12Device* device, ID3D12Device* guest, } if (compare_vcc) std::printf("native fixed mesh compare mask: reviewed stage pair linked and created a color PSO\n"); - fields[15] = 1; // Same stages and root, unreviewed fixed pipeline state. + set_marker(1); // Same stages and root, unreviewed fixed pipeline state. const auto mismatched = create(); { char expected[128]; @@ -2840,9 +2951,10 @@ static int native_fixed_mesh_fixture(ID3D12Device* device, ID3D12Device* guest, } // 64 more fixed states without a profile. Only the two profiles above may be opened. for (UINT64 extra = 2; extra < 66; ++extra) { - fields[15] = extra; + set_marker(extra); create(); } + set_marker(0); if (outcomes) { const char* prefix = "x2w-render native slot57 preparation:"; const auto line = render_totals_line(guest, log_path, prefix); @@ -2859,14 +2971,14 @@ static int native_fixed_mesh_fixture(ID3D12Device* device, ID3D12Device* guest, return 1; } } - fields[15] = 1; + set_marker(1); LONG lookups = -1, opens = -1; x2w_d3d12_mesh57_profile_stats(&lookups, &opens); std::printf("native fixed mesh profile lookups %ld, opens %ld (2 profiles, 2000 other cache files)\n", lookups, opens); if (lookups != 66 || opens != 2) return 1; // Reuse the indexed profile filename with the original descriptor after checking lookup counts. - fields[15] = 0; + set_marker(0); const auto profile_path = cache / name; std::vector original_profile(std::filesystem::file_size(profile_path)); { @@ -2976,7 +3088,7 @@ static int native_fixed_mesh_fixture(ID3D12Device* device, ID3D12Device* guest, create(); if (!expect_profile_refusal("trailing bytes after the pixel shader")) return 1; - fields[15] = 1; + set_marker(1); state_a.fill(0); state_b.fill(0); check(SetEnvironmentVariableA("X2W_MESH57_CAPTURE_STATE", "1") ? S_OK : E_FAIL, "enable fixed-state archive"); @@ -3047,6 +3159,7 @@ static int native_fixed_mesh_fixture(ID3D12Device* device, ID3D12Device* guest, append(expected_b.data(), sizeof(expected_b)); auto valid = expected; std::fill_n(valid.begin() + sizeof(key) + sizeof(sizes) + 15 * sizeof(UINT64), sizeof(UINT64), 0); + valid[sizeof(key) + sizeof(sizes) + 0x207] = 0; bool saw_valid = false, saw_other = false; for (const auto& f : std::filesystem::directory_iterator(cache)) if (f.path().extension() == ".s57") { diff --git a/tools/startup/mesh57_pixel_entry.py b/tools/startup/mesh57_pixel_entry.py index 3663b162d9..bb1ecc30dd 100644 --- a/tools/startup/mesh57_pixel_entry.py +++ b/tools/startup/mesh57_pixel_entry.py @@ -4,11 +4,12 @@ import struct import sys -from mesh57_profile import read_creation +from mesh57_profile import profile_variant, read_creation, stable_mesh57_profile_descriptor def pixel_entry(request, archive, profile): - variant, parts = read_creation(archive, request) + parts = read_creation(archive, request)[1] + variant = profile_variant(archive, request) if profile.name != f"{variant:016x}.mesh57-state": raise ValueError("fixed-state variant disagrees with profile name") data = profile.read_bytes() @@ -34,8 +35,11 @@ def pixel_entry(request, archive, profile): offset += 4 + 12 * count if version >= 5: offset += 4 # MS resource heap SGPR - for part in parts: - if data[offset:offset + len(part)] != part: + for index, part in enumerate(parts): + stored = data[offset:offset + len(part)] + compared = stable_mesh57_profile_descriptor(stored) if index == 0 else stored + expected = stable_mesh57_profile_descriptor(part) if index == 0 else part + if compared != expected: raise ValueError("profile creation or shader bytes differ") offset += len(part) if offset != len(data): diff --git a/tools/startup/mesh57_profile.py b/tools/startup/mesh57_profile.py index cdb4d17f4f..125cf449b3 100644 --- a/tools/startup/mesh57_profile.py +++ b/tools/startup/mesh57_profile.py @@ -14,6 +14,11 @@ stay null. ``--check ARCHIVE REVIEWED_JSON`` lists every field that still needs review and every field whose reviewed value disagrees with the capture, without writing a profile. + +The published `.mesh57-state` name uses the stable profile key +(only a recognized 0x300 layout; optional record pointers, a common second base +and the remaining relocations are removed while their spacing remains); the +`.s57` archive keeps the stream-key variant name. """ import argparse import json @@ -87,6 +92,65 @@ def read_creation(archive, request=None): return variant, (desc, a, b, root, ms, ps) +def stable_mesh57_profile_descriptor(desc): + """The descriptor form used for the profile name, or the input when its layout is unknown.""" + out = bytearray(desc) + if len(out) != 0x300: + return bytes(out) + + def word(offset): + return struct.unpack_from("> 32: + continue + if second_base is None: + second_base = value + put(offset, value - second_base) + for offset in (0x00, 0x08, 0x18, 0x28, 0x38, 0x68, 0x78, 0x120, 0x128, 0x160, + 0x168, 0x178, 0x198, 0x1b8, 0x1d8, 0x280, 0x288, 0x2c0, 0x2c8, 0x2d8, 0x2f8): + out[offset:offset + 8] = bytes(8) + for offset in (0x110, 0x270, 0x1f4): + out[offset:offset + 4] = bytes(4) + return bytes(out) + + +def profile_variant(archive, request=None): + """The stable naming a .mesh57-state profile.""" + data = archive.read_bytes() + key = struct.unpack_from(" 1 << 20 or len(ms) % 4 or len(ps) % 4: raise ValueError("invalid creation root or shader lengths") @@ -480,7 +544,7 @@ def build_profile(archive, state): sections = "version mesh blend rasterizer depth_stencil rt_formats depth_format samples" extra_sections = "pixel constant views heap_sgpr".split()[:version - 1] require_fields(state, " ".join([sections, *extra_sections]), "profile") - variant, parts = read_creation(archive) + _, parts = read_creation(archive) root, ms, ps = parts[3:] validate_stage_lengths(root, ms, ps) captured, _, observations = read_captured_state(archive.with_suffix(".t57"), parts[1], ps) @@ -496,7 +560,7 @@ def build_profile(archive, state): header = PROFILE_PREFIX.pack(f"X2WM57{version}".encode("ascii"), *map(len, parts)) header += fixed_state(state, depth_only) assert len(header) == 532 # Mesh57Profile in src/startup_stubs/mesh57_profile.h - return (f"{variant:016x}.mesh57-state", + return (f"{profile_variant(archive):016x}.mesh57-state", header + extensions(state, version, root, depth_only) + b"".join(parts))