broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(p):
    p = dict(p)
    dims = [[max(1,(p["w"]+(1<<i)-1)//(1<<i)),max(1,(p["h"]+(1<<i)-1)//(1<<i))] for i in range(4)]
    texel_counts = [w*h for w,h in dims]
    layer_pitches = [t*p["b"] for t in texel_counts]
    level_spans = [q*p["layers"]+5 for q in layer_pitches]
    level_offsets = [sum(level_spans[:i]) for i in range(4)]
    selected_pitch = layer_pitches[p["level"]]
    selected_header = p["base"]+level_offsets[p["level"]]
    layer_origin = selected_header+5+p["layer"]*selected_pitch
    payload_origin = layer_origin+1
    allocation_end = p["base"]+sum(level_spans)
    return {'dims': dims, 'texel_counts': texel_counts, 'layer_pitches': layer_pitches, 'level_spans': level_spans, 'level_offsets': level_offsets, 'selected_pitch': selected_pitch, 'selected_header': selected_header, 'layer_origin': layer_origin, 'payload_origin': payload_origin, 'allocation_end': allocation_end}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'w': 6, 'h': 3, 'b': 2, 'layers': 2, 'layer': 0, 'level': 0, 'base': 13}, {'dims': [[6, 3], [3, 2], [2, 1], [1, 1]], 'texel_counts': [18, 6, 2, 1], 'layer_pitches': [37, 13, 5, 3], 'level_spans': [79, 31, 15, 11], 'level_offsets': [0, 79, 110, 125], 'selected_pitch': 37, 'selected_header': 13, 'layer_origin': 18, 'payload_origin': 19, 'allocation_end': 149}), ({'w': 7, 'h': 4, 'b': 2, 'layers': 3, 'layer': 1, 'level': 1, 'base': 13}, {'dims': [[7, 4], [4, 2], [2, 1], [1, 1]], 'texel_counts': [28, 8, 2, 1], 'layer_pitches': [57, 17, 5, 3], 'level_spans': [176, 56, 20, 14], 'level_offsets': [0, 176, 232, 252], 'selected_pitch': 17, 'selected_header': 189, 'layer_origin': 211, 'payload_origin': 212, 'allocation_end': 279}), ({'w': 8, 'h': 5, 'b': 2, 'layers': 4, 'layer': 2, 'level': 2, 'base': 13}, {'dims': [[8, 5], [4, 3], [2, 2], [1, 1]], 'texel_counts': [40, 12, 4, 1], 'layer_pitches': [81, 25, 9, 3], 'level_spans': [329, 105, 41, 17], 'level_offsets': [0, 329, 434, 475], 'selected_pitch': 9, 'selected_header': 447, 'layer_origin': 470, 'payload_origin': 471, 'allocation_end': 505}), ({'w': 9, 'h': 6, 'b': 2, 'layers': 2, 'layer': 1, 'level': 3, 'base': 13}, {'dims': [[9, 6], [5, 3], [3, 2], [2, 1]], 'texel_counts': [54, 15, 6, 2], 'layer_pitches': [109, 31, 13, 5], 'level_spans': [223, 67, 31, 15], 'level_offsets': [0, 223, 290, 321], 'selected_pitch': 5, 'selected_header': 334, 'layer_origin': 344, 'payload_origin': 345, 'allocation_end': 349}), ({'w': 10, 'h': 7, 'b': 2, 'layers': 3, 'layer': 1, 'level': 0, 'base': 13}, {'dims': [[10, 7], [5, 4], [3, 2], [2, 1]], 'texel_counts': [70, 20, 6, 2], 'layer_pitches': [141, 41, 13, 5], 'level_spans': [428, 128, 44, 20], 'level_offsets': [0, 428, 556, 600], 'selected_pitch': 141, 'selected_header': 13, 'layer_origin': 159, 'payload_origin': 160, 'allocation_end': 633}), ({'w': 11, 'h': 8, 'b': 2, 'layers': 4, 'layer': 1, 'level': 1, 'base': 13}, {'dims': [[11, 8], [6, 4], [3, 2], [2, 1]], 'texel_counts': [88, 24, 6, 2], 'layer_pitches': [177, 49, 13, 5], 'level_spans': [713, 201, 57, 25], 'level_offsets': [0, 713, 914, 971], 'selected_pitch': 49, 'selected_header': 726, 'layer_origin': 780, 'payload_origin': 781, 'allocation_end': 1009})], 2: [({'w': 7, 'h': 3, 'b': 3, 'layers': 2, 'layer': 0, 'level': 0, 'base': 26}, {'dims': [[7, 3], [4, 2], [2, 1], [1, 1]], 'texel_counts': [21, 8, 2, 1], 'layer_pitches': [64, 25, 7, 4], 'level_spans': [133, 55, 19, 13], 'level_offsets': [0, 133, 188, 207], 'selected_pitch': 64, 'selected_header': 26, 'layer_origin': 31, 'payload_origin': 32, 'allocation_end': 246}), ({'w': 8, 'h': 4, 'b': 3, 'layers': 3, 'layer': 1, 'level': 1, 'base': 26}, {'dims': [[8, 4], [4, 2], [2, 1], [1, 1]], 'texel_counts': [32, 8, 2, 1], 'layer_pitches': [97, 25, 7, 4], 'level_spans': [296, 80, 26, 17], 'level_offsets': [0, 296, 376, 402], 'selected_pitch': 25, 'selected_header': 322, 'layer_origin': 352, 'payload_origin': 353, 'allocation_end': 445}), ({'w': 9, 'h': 5, 'b': 3, 'layers': 4, 'layer': 2, 'level': 2, 'base': 26}, {'dims': [[9, 5], [5, 3], [3, 2], [2, 1]], 'texel_counts': [45, 15, 6, 2], 'layer_pitches': [136, 46, 19, 7], 'level_spans': [549, 189, 81, 33], 'level_offsets': [0, 549, 738, 819], 'selected_pitch': 19, 'selected_header': 764, 'layer_origin': 807, 'payload_origin': 808, 'allocation_end': 878}), ({'w': 10, 'h': 6, 'b': 3, 'layers': 2, 'layer': 1, 'level': 3, 'base': 26}, {'dims': [[10, 6], [5, 3], [3, 2], [2, 1]], 'texel_counts': [60, 15, 6, 2], 'layer_pitches': [181, 46, 19, 7], 'level_spans': [367, 97, 43, 19], 'level_offsets': [0, 367, 464, 507], 'selected_pitch': 7, 'selected_header': 533, 'layer_origin': 545, 'payload_origin': 546, 'allocation_end': 552}), ({'w': 11, 'h': 7, 'b': 3, 'layers': 3, 'layer': 1, 'level': 0, 'base': 26}, {'dims': [[11, 7], [6, 4], [3, 2], [2, 1]], 'texel_counts': [77, 24, 6, 2], 'layer_pitches': [232, 73, 19, 7], 'level_spans': [701, 224, 62, 26], 'level_offsets': [0, 701, 925, 987], 'selected_pitch': 232, 'selected_header': 26, 'layer_origin': 263, 'payload_origin': 264, 'allocation_end': 1039}), ({'w': 12, 'h': 8, 'b': 3, 'layers': 4, 'layer': 1, 'level': 1, 'base': 26}, {'dims': [[12, 8], [6, 4], [3, 2], [2, 1]], 'texel_counts': [96, 24, 6, 2], 'layer_pitches': [289, 73, 19, 7], 'level_spans': [1161, 297, 81, 33], 'level_offsets': [0, 1161, 1458, 1539], 'selected_pitch': 73, 'selected_header': 1187, 'layer_origin': 1265, 'payload_origin': 1266, 'allocation_end': 1598})], 3: [({'w': 8, 'h': 3, 'b': 4, 'layers': 2, 'layer': 0, 'level': 0, 'base': 39}, {'dims': [[8, 3], [4, 2], [2, 1], [1, 1]], 'texel_counts': [24, 8, 2, 1], 'layer_pitches': [97, 33, 9, 5], 'level_spans': [199, 71, 23, 15], 'level_offsets': [0, 199, 270, 293], 'selected_pitch': 97, 'selected_header': 39, 'layer_origin': 44, 'payload_origin': 45, 'allocation_end': 347}), ({'w': 9, 'h': 4, 'b': 4, 'layers': 3, 'layer': 1, 'level': 1, 'base': 39}, {'dims': [[9, 4], [5, 2], [3, 1], [2, 1]], 'texel_counts': [36, 10, 3, 2], 'layer_pitches': [145, 41, 13, 9], 'level_spans': [440, 128, 44, 32], 'level_offsets': [0, 440, 568, 612], 'selected_pitch': 41, 'selected_header': 479, 'layer_origin': 525, 'payload_origin': 526, 'allocation_end': 683}), ({'w': 10, 'h': 5, 'b': 4, 'layers': 4, 'layer': 2, 'level': 2, 'base': 39}, {'dims': [[10, 5], [5, 3], [3, 2], [2, 1]], 'texel_counts': [50, 15, 6, 2], 'layer_pitches': [201, 61, 25, 9], 'level_spans': [809, 249, 105, 41], 'level_offsets': [0, 809, 1058, 1163], 'selected_pitch': 25, 'selected_header': 1097, 'layer_origin': 1152, 'payload_origin': 1153, 'allocation_end': 1243}), ({'w': 11, 'h': 6, 'b': 4, 'layers': 2, 'layer': 1, 'level': 3, 'base': 39}, {'dims': [[11, 6], [6, 3], [3, 2], [2, 1]], 'texel_counts': [66, 18, 6, 2], 'layer_pitches': [265, 73, 25, 9], 'level_spans': [535, 151, 55, 23], 'level_offsets': [0, 535, 686, 741], 'selected_pitch': 9, 'selected_header': 780, 'layer_origin': 794, 'payload_origin': 795, 'allocation_end': 803}), ({'w': 12, 'h': 7, 'b': 4, 'layers': 3, 'layer': 1, 'level': 0, 'base': 39}, {'dims': [[12, 7], [6, 4], [3, 2], [2, 1]], 'texel_counts': [84, 24, 6, 2], 'layer_pitches': [337, 97, 25, 9], 'level_spans': [1016, 296, 80, 32], 'level_offsets': [0, 1016, 1312, 1392], 'selected_pitch': 337, 'selected_header': 39, 'layer_origin': 381, 'payload_origin': 382, 'allocation_end': 1463}), ({'w': 13, 'h': 8, 'b': 4, 'layers': 4, 'layer': 1, 'level': 1, 'base': 39}, {'dims': [[13, 8], [7, 4], [4, 2], [2, 1]], 'texel_counts': [104, 28, 8, 2], 'layer_pitches': [417, 113, 33, 9], 'level_spans': [1673, 457, 137, 41], 'level_offsets': [0, 1673, 2130, 2267], 'selected_pitch': 113, 'selected_header': 1712, 'layer_origin': 1830, 'payload_origin': 1831, 'allocation_end': 2347})], 4: [({'w': 9, 'h': 3, 'b': 5, 'layers': 2, 'layer': 0, 'level': 0, 'base': 52}, {'dims': [[9, 3], [5, 2], [3, 1], [2, 1]], 'texel_counts': [27, 10, 3, 2], 'layer_pitches': [136, 51, 16, 11], 'level_spans': [277, 107, 37, 27], 'level_offsets': [0, 277, 384, 421], 'selected_pitch': 136, 'selected_header': 52, 'layer_origin': 57, 'payload_origin': 58, 'allocation_end': 500}), ({'w': 10, 'h': 4, 'b': 5, 'layers': 3, 'layer': 1, 'level': 1, 'base': 52}, {'dims': [[10, 4], [5, 2], [3, 1], [2, 1]], 'texel_counts': [40, 10, 3, 2], 'layer_pitches': [201, 51, 16, 11], 'level_spans': [608, 158, 53, 38], 'level_offsets': [0, 608, 766, 819], 'selected_pitch': 51, 'selected_header': 660, 'layer_origin': 716, 'payload_origin': 717, 'allocation_end': 909}), ({'w': 11, 'h': 5, 'b': 5, 'layers': 4, 'layer': 2, 'level': 2, 'base': 52}, {'dims': [[11, 5], [6, 3], [3, 2], [2, 1]], 'texel_counts': [55, 18, 6, 2], 'layer_pitches': [276, 91, 31, 11], 'level_spans': [1109, 369, 129, 49], 'level_offsets': [0, 1109, 1478, 1607], 'selected_pitch': 31, 'selected_header': 1530, 'layer_origin': 1597, 'payload_origin': 1598, 'allocation_end': 1708}), ({'w': 12, 'h': 6, 'b': 5, 'layers': 2, 'layer': 1, 'level': 3, 'base': 52}, {'dims': [[12, 6], [6, 3], [3, 2], [2, 1]], 'texel_counts': [72, 18, 6, 2], 'layer_pitches': [361, 91, 31, 11], 'level_spans': [727, 187, 67, 27], 'level_offsets': [0, 727, 914, 981], 'selected_pitch': 11, 'selected_header': 1033, 'layer_origin': 1049, 'payload_origin': 1050, 'allocation_end': 1060}), ({'w': 13, 'h': 7, 'b': 5, 'layers': 3, 'layer': 1, 'level': 0, 'base': 52}, {'dims': [[13, 7], [7, 4], [4, 2], [2, 1]], 'texel_counts': [91, 28, 8, 2], 'layer_pitches': [456, 141, 41, 11], 'level_spans': [1373, 428, 128, 38], 'level_offsets': [0, 1373, 1801, 1929], 'selected_pitch': 456, 'selected_header': 52, 'layer_origin': 513, 'payload_origin': 514, 'allocation_end': 2019}), ({'w': 14, 'h': 8, 'b': 5, 'layers': 4, 'layer': 1, 'level': 1, 'base': 52}, {'dims': [[14, 8], [7, 4], [4, 2], [2, 1]], 'texel_counts': [112, 28, 8, 2], 'layer_pitches': [561, 141, 41, 11], 'level_spans': [2249, 569, 169, 49], 'level_offsets': [0, 2249, 2818, 2987], 'selected_pitch': 141, 'selected_header': 2301, 'layer_origin': 2447, 'payload_origin': 2448, 'allocation_end': 3088})], 5: [({'w': 10, 'h': 3, 'b': 6, 'layers': 2, 'layer': 0, 'level': 0, 'base': 65}, {'dims': [[10, 3], [5, 2], [3, 1], [2, 1]], 'texel_counts': [30, 10, 3, 2], 'layer_pitches': [181, 61, 19, 13], 'level_spans': [367, 127, 43, 31], 'level_offsets': [0, 367, 494, 537], 'selected_pitch': 181, 'selected_header': 65, 'layer_origin': 70, 'payload_origin': 71, 'allocation_end': 633}), ({'w': 11, 'h': 4, 'b': 6, 'layers': 3, 'layer': 1, 'level': 1, 'base': 65}, {'dims': [[11, 4], [6, 2], [3, 1], [2, 1]], 'texel_counts': [44, 12, 3, 2], 'layer_pitches': [265, 73, 19, 13], 'level_spans': [800, 224, 62, 44], 'level_offsets': [0, 800, 1024, 1086], 'selected_pitch': 73, 'selected_header': 865, 'layer_origin': 943, 'payload_origin': 944, 'allocation_end': 1195}), ({'w': 12, 'h': 5, 'b': 6, 'layers': 4, 'layer': 2, 'level': 2, 'base': 65}, {'dims': [[12, 5], [6, 3], [3, 2], [2, 1]], 'texel_counts': [60, 18, 6, 2], 'layer_pitches': [361, 109, 37, 13], 'level_spans': [1449, 441, 153, 57], 'level_offsets': [0, 1449, 1890, 2043], 'selected_pitch': 37, 'selected_header': 1955, 'layer_origin': 2034, 'payload_origin': 2035, 'allocation_end': 2165}), ({'w': 13, 'h': 6, 'b': 6, 'layers': 2, 'layer': 1, 'level': 3, 'base': 65}, {'dims': [[13, 6], [7, 3], [4, 2], [2, 1]], 'texel_counts': [78, 21, 8, 2], 'layer_pitches': [469, 127, 49, 13], 'level_spans': [943, 259, 103, 31], 'level_offsets': [0, 943, 1202, 1305], 'selected_pitch': 13, 'selected_header': 1370, 'layer_origin': 1388, 'payload_origin': 1389, 'allocation_end': 1401}), ({'w': 14, 'h': 7, 'b': 6, 'layers': 3, 'layer': 1, 'level': 0, 'base': 65}, {'dims': [[14, 7], [7, 4], [4, 2], [2, 1]], 'texel_counts': [98, 28, 8, 2], 'layer_pitches': [589, 169, 49, 13], 'level_spans': [1772, 512, 152, 44], 'level_offsets': [0, 1772, 2284, 2436], 'selected_pitch': 589, 'selected_header': 65, 'layer_origin': 659, 'payload_origin': 660, 'allocation_end': 2545}), ({'w': 15, 'h': 8, 'b': 6, 'layers': 4, 'layer': 1, 'level': 1, 'base': 65}, {'dims': [[15, 8], [8, 4], [4, 2], [2, 1]], 'texel_counts': [120, 32, 8, 2], 'layer_pitches': [721, 193, 49, 13], 'level_spans': [2889, 777, 201, 57], 'level_offsets': [0, 2889, 3666, 3867], 'selected_pitch': 193, 'selected_header': 2954, 'layer_origin': 3152, 'payload_origin': 3153, 'allocation_end': 3989})]}
for i, (p, expected) in enumerate(cases[N]):
    check("layout fixture " + str(i + 1), solve(p), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(p):
    p = dict(p)
    dims = [[max(1,(p["w"]+(1<<i)-1)//(1<<i)),max(1,(p["h"]+(1<<i)-1)//(1<<i))] for i in range(4)]
    texel_counts = [w*h for w,h in dims]
    layer_pitches = [(t+1)*p["b"] for t in texel_counts]
    level_spans = [q*p["layers"]+5 for q in layer_pitches]
    level_offsets = [sum(level_spans[:i]) for i in range(4)]
    selected_pitch = layer_pitches[p["level"]]
    selected_header = p["base"]+level_offsets[p["level"]]
    layer_origin = selected_header+5+p["layer"]*selected_pitch
    payload_origin = layer_origin+1
    allocation_end = p["base"]+sum(level_spans)
    return {'dims': dims, 'texel_counts': texel_counts, 'layer_pitches': layer_pitches, 'level_spans': level_spans, 'level_offsets': level_offsets, 'selected_pitch': selected_pitch, 'selected_header': selected_header, 'layer_origin': layer_origin, 'payload_origin': payload_origin, 'allocation_end': allocation_end}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'w': 6, 'h': 3, 'b': 2, 'layers': 2, 'layer': 0, 'level': 0, 'base': 13}, {'dims': [[6, 3], [3, 2], [2, 1], [1, 1]], 'texel_counts': [18, 6, 2, 1], 'layer_pitches': [37, 13, 5, 3], 'level_spans': [79, 31, 15, 11], 'level_offsets': [0, 79, 110, 125], 'selected_pitch': 37, 'selected_header': 13, 'layer_origin': 18, 'payload_origin': 19, 'allocation_end': 149}), ({'w': 7, 'h': 4, 'b': 2, 'layers': 3, 'layer': 1, 'level': 1, 'base': 13}, {'dims': [[7, 4], [4, 2], [2, 1], [1, 1]], 'texel_counts': [28, 8, 2, 1], 'layer_pitches': [57, 17, 5, 3], 'level_spans': [176, 56, 20, 14], 'level_offsets': [0, 176, 232, 252], 'selected_pitch': 17, 'selected_header': 189, 'layer_origin': 211, 'payload_origin': 212, 'allocation_end': 279}), ({'w': 8, 'h': 5, 'b': 2, 'layers': 4, 'layer': 2, 'level': 2, 'base': 13}, {'dims': [[8, 5], [4, 3], [2, 2], [1, 1]], 'texel_counts': [40, 12, 4, 1], 'layer_pitches': [81, 25, 9, 3], 'level_spans': [329, 105, 41, 17], 'level_offsets': [0, 329, 434, 475], 'selected_pitch': 9, 'selected_header': 447, 'layer_origin': 470, 'payload_origin': 471, 'allocation_end': 505}), ({'w': 9, 'h': 6, 'b': 2, 'layers': 2, 'layer': 1, 'level': 3, 'base': 13}, {'dims': [[9, 6], [5, 3], [3, 2], [2, 1]], 'texel_counts': [54, 15, 6, 2], 'layer_pitches': [109, 31, 13, 5], 'level_spans': [223, 67, 31, 15], 'level_offsets': [0, 223, 290, 321], 'selected_pitch': 5, 'selected_header': 334, 'layer_origin': 344, 'payload_origin': 345, 'allocation_end': 349}), ({'w': 10, 'h': 7, 'b': 2, 'layers': 3, 'layer': 1, 'level': 0, 'base': 13}, {'dims': [[10, 7], [5, 4], [3, 2], [2, 1]], 'texel_counts': [70, 20, 6, 2], 'layer_pitches': [141, 41, 13, 5], 'level_spans': [428, 128, 44, 20], 'level_offsets': [0, 428, 556, 600], 'selected_pitch': 141, 'selected_header': 13, 'layer_origin': 159, 'payload_origin': 160, 'allocation_end': 633}), ({'w': 11, 'h': 8, 'b': 2, 'layers': 4, 'layer': 1, 'level': 1, 'base': 13}, {'dims': [[11, 8], [6, 4], [3, 2], [2, 1]], 'texel_counts': [88, 24, 6, 2], 'layer_pitches': [177, 49, 13, 5], 'level_spans': [713, 201, 57, 25], 'level_offsets': [0, 713, 914, 971], 'selected_pitch': 49, 'selected_header': 726, 'layer_origin': 780, 'payload_origin': 781, 'allocation_end': 1009})], 2: [({'w': 7, 'h': 3, 'b': 3, 'layers': 2, 'layer': 0, 'level': 0, 'base': 26}, {'dims': [[7, 3], [4, 2], [2, 1], [1, 1]], 'texel_counts': [21, 8, 2, 1], 'layer_pitches': [64, 25, 7, 4], 'level_spans': [133, 55, 19, 13], 'level_offsets': [0, 133, 188, 207], 'selected_pitch': 64, 'selected_header': 26, 'layer_origin': 31, 'payload_origin': 32, 'allocation_end': 246}), ({'w': 8, 'h': 4, 'b': 3, 'layers': 3, 'layer': 1, 'level': 1, 'base': 26}, {'dims': [[8, 4], [4, 2], [2, 1], [1, 1]], 'texel_counts': [32, 8, 2, 1], 'layer_pitches': [97, 25, 7, 4], 'level_spans': [296, 80, 26, 17], 'level_offsets': [0, 296, 376, 402], 'selected_pitch': 25, 'selected_header': 322, 'layer_origin': 352, 'payload_origin': 353, 'allocation_end': 445}), ({'w': 9, 'h': 5, 'b': 3, 'layers': 4, 'layer': 2, 'level': 2, 'base': 26}, {'dims': [[9, 5], [5, 3], [3, 2], [2, 1]], 'texel_counts': [45, 15, 6, 2], 'layer_pitches': [136, 46, 19, 7], 'level_spans': [549, 189, 81, 33], 'level_offsets': [0, 549, 738, 819], 'selected_pitch': 19, 'selected_header': 764, 'layer_origin': 807, 'payload_origin': 808, 'allocation_end': 878}), ({'w': 10, 'h': 6, 'b': 3, 'layers': 2, 'layer': 1, 'level': 3, 'base': 26}, {'dims': [[10, 6], [5, 3], [3, 2], [2, 1]], 'texel_counts': [60, 15, 6, 2], 'layer_pitches': [181, 46, 19, 7], 'level_spans': [367, 97, 43, 19], 'level_offsets': [0, 367, 464, 507], 'selected_pitch': 7, 'selected_header': 533, 'layer_origin': 545, 'payload_origin': 546, 'allocation_end': 552}), ({'w': 11, 'h': 7, 'b': 3, 'layers': 3, 'layer': 1, 'level': 0, 'base': 26}, {'dims': [[11, 7], [6, 4], [3, 2], [2, 1]], 'texel_counts': [77, 24, 6, 2], 'layer_pitches': [232, 73, 19, 7], 'level_spans': [701, 224, 62, 26], 'level_offsets': [0, 701, 925, 987], 'selected_pitch': 232, 'selected_header': 26, 'layer_origin': 263, 'payload_origin': 264, 'allocation_end': 1039}), ({'w': 12, 'h': 8, 'b': 3, 'layers': 4, 'layer': 1, 'level': 1, 'base': 26}, {'dims': [[12, 8], [6, 4], [3, 2], [2, 1]], 'texel_counts': [96, 24, 6, 2], 'layer_pitches': [289, 73, 19, 7], 'level_spans': [1161, 297, 81, 33], 'level_offsets': [0, 1161, 1458, 1539], 'selected_pitch': 73, 'selected_header': 1187, 'layer_origin': 1265, 'payload_origin': 1266, 'allocation_end': 1598})], 3: [({'w': 8, 'h': 3, 'b': 4, 'layers': 2, 'layer': 0, 'level': 0, 'base': 39}, {'dims': [[8, 3], [4, 2], [2, 1], [1, 1]], 'texel_counts': [24, 8, 2, 1], 'layer_pitches': [97, 33, 9, 5], 'level_spans': [199, 71, 23, 15], 'level_offsets': [0, 199, 270, 293], 'selected_pitch': 97, 'selected_header': 39, 'layer_origin': 44, 'payload_origin': 45, 'allocation_end': 347}), ({'w': 9, 'h': 4, 'b': 4, 'layers': 3, 'layer': 1, 'level': 1, 'base': 39}, {'dims': [[9, 4], [5, 2], [3, 1], [2, 1]], 'texel_counts': [36, 10, 3, 2], 'layer_pitches': [145, 41, 13, 9], 'level_spans': [440, 128, 44, 32], 'level_offsets': [0, 440, 568, 612], 'selected_pitch': 41, 'selected_header': 479, 'layer_origin': 525, 'payload_origin': 526, 'allocation_end': 683}), ({'w': 10, 'h': 5, 'b': 4, 'layers': 4, 'layer': 2, 'level': 2, 'base': 39}, {'dims': [[10, 5], [5, 3], [3, 2], [2, 1]], 'texel_counts': [50, 15, 6, 2], 'layer_pitches': [201, 61, 25, 9], 'level_spans': [809, 249, 105, 41], 'level_offsets': [0, 809, 1058, 1163], 'selected_pitch': 25, 'selected_header': 1097, 'layer_origin': 1152, 'payload_origin': 1153, 'allocation_end': 1243}), ({'w': 11, 'h': 6, 'b': 4, 'layers': 2, 'layer': 1, 'level': 3, 'base': 39}, {'dims': [[11, 6], [6, 3], [3, 2], [2, 1]], 'texel_counts': [66, 18, 6, 2], 'layer_pitches': [265, 73, 25, 9], 'level_spans': [535, 151, 55, 23], 'level_offsets': [0, 535, 686, 741], 'selected_pitch': 9, 'selected_header': 780, 'layer_origin': 794, 'payload_origin': 795, 'allocation_end': 803}), ({'w': 12, 'h': 7, 'b': 4, 'layers': 3, 'layer': 1, 'level': 0, 'base': 39}, {'dims': [[12, 7], [6, 4], [3, 2], [2, 1]], 'texel_counts': [84, 24, 6, 2], 'layer_pitches': [337, 97, 25, 9], 'level_spans': [1016, 296, 80, 32], 'level_offsets': [0, 1016, 1312, 1392], 'selected_pitch': 337, 'selected_header': 39, 'layer_origin': 381, 'payload_origin': 382, 'allocation_end': 1463}), ({'w': 13, 'h': 8, 'b': 4, 'layers': 4, 'layer': 1, 'level': 1, 'base': 39}, {'dims': [[13, 8], [7, 4], [4, 2], [2, 1]], 'texel_counts': [104, 28, 8, 2], 'layer_pitches': [417, 113, 33, 9], 'level_spans': [1673, 457, 137, 41], 'level_offsets': [0, 1673, 2130, 2267], 'selected_pitch': 113, 'selected_header': 1712, 'layer_origin': 1830, 'payload_origin': 1831, 'allocation_end': 2347})], 4: [({'w': 9, 'h': 3, 'b': 5, 'layers': 2, 'layer': 0, 'level': 0, 'base': 52}, {'dims': [[9, 3], [5, 2], [3, 1], [2, 1]], 'texel_counts': [27, 10, 3, 2], 'layer_pitches': [136, 51, 16, 11], 'level_spans': [277, 107, 37, 27], 'level_offsets': [0, 277, 384, 421], 'selected_pitch': 136, 'selected_header': 52, 'layer_origin': 57, 'payload_origin': 58, 'allocation_end': 500}), ({'w': 10, 'h': 4, 'b': 5, 'layers': 3, 'layer': 1, 'level': 1, 'base': 52}, {'dims': [[10, 4], [5, 2], [3, 1], [2, 1]], 'texel_counts': [40, 10, 3, 2], 'layer_pitches': [201, 51, 16, 11], 'level_spans': [608, 158, 53, 38], 'level_offsets': [0, 608, 766, 819], 'selected_pitch': 51, 'selected_header': 660, 'layer_origin': 716, 'payload_origin': 717, 'allocation_end': 909}), ({'w': 11, 'h': 5, 'b': 5, 'layers': 4, 'layer': 2, 'level': 2, 'base': 52}, {'dims': [[11, 5], [6, 3], [3, 2], [2, 1]], 'texel_counts': [55, 18, 6, 2], 'layer_pitches': [276, 91, 31, 11], 'level_spans': [1109, 369, 129, 49], 'level_offsets': [0, 1109, 1478, 1607], 'selected_pitch': 31, 'selected_header': 1530, 'layer_origin': 1597, 'payload_origin': 1598, 'allocation_end': 1708}), ({'w': 12, 'h': 6, 'b': 5, 'layers': 2, 'layer': 1, 'level': 3, 'base': 52}, {'dims': [[12, 6], [6, 3], [3, 2], [2, 1]], 'texel_counts': [72, 18, 6, 2], 'layer_pitches': [361, 91, 31, 11], 'level_spans': [727, 187, 67, 27], 'level_offsets': [0, 727, 914, 981], 'selected_pitch': 11, 'selected_header': 1033, 'layer_origin': 1049, 'payload_origin': 1050, 'allocation_end': 1060}), ({'w': 13, 'h': 7, 'b': 5, 'layers': 3, 'layer': 1, 'level': 0, 'base': 52}, {'dims': [[13, 7], [7, 4], [4, 2], [2, 1]], 'texel_counts': [91, 28, 8, 2], 'layer_pitches': [456, 141, 41, 11], 'level_spans': [1373, 428, 128, 38], 'level_offsets': [0, 1373, 1801, 1929], 'selected_pitch': 456, 'selected_header': 52, 'layer_origin': 513, 'payload_origin': 514, 'allocation_end': 2019}), ({'w': 14, 'h': 8, 'b': 5, 'layers': 4, 'layer': 1, 'level': 1, 'base': 52}, {'dims': [[14, 8], [7, 4], [4, 2], [2, 1]], 'texel_counts': [112, 28, 8, 2], 'layer_pitches': [561, 141, 41, 11], 'level_spans': [2249, 569, 169, 49], 'level_offsets': [0, 2249, 2818, 2987], 'selected_pitch': 141, 'selected_header': 2301, 'layer_origin': 2447, 'payload_origin': 2448, 'allocation_end': 3088})], 5: [({'w': 10, 'h': 3, 'b': 6, 'layers': 2, 'layer': 0, 'level': 0, 'base': 65}, {'dims': [[10, 3], [5, 2], [3, 1], [2, 1]], 'texel_counts': [30, 10, 3, 2], 'layer_pitches': [181, 61, 19, 13], 'level_spans': [367, 127, 43, 31], 'level_offsets': [0, 367, 494, 537], 'selected_pitch': 181, 'selected_header': 65, 'layer_origin': 70, 'payload_origin': 71, 'allocation_end': 633}), ({'w': 11, 'h': 4, 'b': 6, 'layers': 3, 'layer': 1, 'level': 1, 'base': 65}, {'dims': [[11, 4], [6, 2], [3, 1], [2, 1]], 'texel_counts': [44, 12, 3, 2], 'layer_pitches': [265, 73, 19, 13], 'level_spans': [800, 224, 62, 44], 'level_offsets': [0, 800, 1024, 1086], 'selected_pitch': 73, 'selected_header': 865, 'layer_origin': 943, 'payload_origin': 944, 'allocation_end': 1195}), ({'w': 12, 'h': 5, 'b': 6, 'layers': 4, 'layer': 2, 'level': 2, 'base': 65}, {'dims': [[12, 5], [6, 3], [3, 2], [2, 1]], 'texel_counts': [60, 18, 6, 2], 'layer_pitches': [361, 109, 37, 13], 'level_spans': [1449, 441, 153, 57], 'level_offsets': [0, 1449, 1890, 2043], 'selected_pitch': 37, 'selected_header': 1955, 'layer_origin': 2034, 'payload_origin': 2035, 'allocation_end': 2165}), ({'w': 13, 'h': 6, 'b': 6, 'layers': 2, 'layer': 1, 'level': 3, 'base': 65}, {'dims': [[13, 6], [7, 3], [4, 2], [2, 1]], 'texel_counts': [78, 21, 8, 2], 'layer_pitches': [469, 127, 49, 13], 'level_spans': [943, 259, 103, 31], 'level_offsets': [0, 943, 1202, 1305], 'selected_pitch': 13, 'selected_header': 1370, 'layer_origin': 1388, 'payload_origin': 1389, 'allocation_end': 1401}), ({'w': 14, 'h': 7, 'b': 6, 'layers': 3, 'layer': 1, 'level': 0, 'base': 65}, {'dims': [[14, 7], [7, 4], [4, 2], [2, 1]], 'texel_counts': [98, 28, 8, 2], 'layer_pitches': [589, 169, 49, 13], 'level_spans': [1772, 512, 152, 44], 'level_offsets': [0, 1772, 2284, 2436], 'selected_pitch': 589, 'selected_header': 65, 'layer_origin': 659, 'payload_origin': 660, 'allocation_end': 2545}), ({'w': 15, 'h': 8, 'b': 6, 'layers': 4, 'layer': 1, 'level': 1, 'base': 65}, {'dims': [[15, 8], [8, 4], [4, 2], [2, 1]], 'texel_counts': [120, 32, 8, 2], 'layer_pitches': [721, 193, 49, 13], 'level_spans': [2889, 777, 201, 57], 'level_offsets': [0, 2889, 3666, 3867], 'selected_pitch': 193, 'selected_header': 2954, 'layer_origin': 3152, 'payload_origin': 3153, 'allocation_end': 3989})]}
for i, (p, expected) in enumerate(cases[N]):
    check("layout fixture " + str(i + 1), solve(p), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The returned physical layout descriptor disagrees with the declared buffer mapping at layer_pitches.

Four ceil-halved mip levels each contain all array layers. Each layer owns a one-byte tag and tightly packed texels; level records add a five-byte header. Return the allocation directory and selected layer origin. Return the named intermediate layout descriptor and final address fields; all quantities are integer byte offsets unless explicitly stated.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(p):
    p = dict(p)
    dims = [[max(1,(p["w"]+(1<<i)-1)//(1<<i)),max(1,(p["h"]+(1<<i)-1)//(1<<i))] for i in range(4)]
    texel_counts = [w*h for w,h in dims]
    layer_pitches = [t*p["b"]+1 for t in texel_counts]
    level_spans = [q+5 for q in layer_pitches]
    level_offsets = [sum(level_spans[:i]) for i in range(4)]
    selected_pitch = layer_pitches[p["level"]]
    selected_header = p["base"]+level_offsets[p["level"]]
    layer_origin = selected_header+5+p["layer"]*selected_pitch
    payload_origin = layer_origin+1
    allocation_end = p["base"]+sum(level_spans)
    return {'dims': dims, 'texel_counts': texel_counts, 'layer_pitches': layer_pitches, 'level_spans': level_spans, 'level_offsets': level_offsets, 'selected_pitch': selected_pitch, 'selected_header': selected_header, 'layer_origin': layer_origin, 'payload_origin': payload_origin, 'allocation_end': allocation_end}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'w': 6, 'h': 3, 'b': 2, 'layers': 2, 'layer': 0, 'level': 0, 'base': 13}, {'dims': [[6, 3], [3, 2], [2, 1], [1, 1]], 'texel_counts': [18, 6, 2, 1], 'layer_pitches': [37, 13, 5, 3], 'level_spans': [79, 31, 15, 11], 'level_offsets': [0, 79, 110, 125], 'selected_pitch': 37, 'selected_header': 13, 'layer_origin': 18, 'payload_origin': 19, 'allocation_end': 149}), ({'w': 7, 'h': 4, 'b': 2, 'layers': 3, 'layer': 1, 'level': 1, 'base': 13}, {'dims': [[7, 4], [4, 2], [2, 1], [1, 1]], 'texel_counts': [28, 8, 2, 1], 'layer_pitches': [57, 17, 5, 3], 'level_spans': [176, 56, 20, 14], 'level_offsets': [0, 176, 232, 252], 'selected_pitch': 17, 'selected_header': 189, 'layer_origin': 211, 'payload_origin': 212, 'allocation_end': 279}), ({'w': 8, 'h': 5, 'b': 2, 'layers': 4, 'layer': 2, 'level': 2, 'base': 13}, {'dims': [[8, 5], [4, 3], [2, 2], [1, 1]], 'texel_counts': [40, 12, 4, 1], 'layer_pitches': [81, 25, 9, 3], 'level_spans': [329, 105, 41, 17], 'level_offsets': [0, 329, 434, 475], 'selected_pitch': 9, 'selected_header': 447, 'layer_origin': 470, 'payload_origin': 471, 'allocation_end': 505}), ({'w': 9, 'h': 6, 'b': 2, 'layers': 2, 'layer': 1, 'level': 3, 'base': 13}, {'dims': [[9, 6], [5, 3], [3, 2], [2, 1]], 'texel_counts': [54, 15, 6, 2], 'layer_pitches': [109, 31, 13, 5], 'level_spans': [223, 67, 31, 15], 'level_offsets': [0, 223, 290, 321], 'selected_pitch': 5, 'selected_header': 334, 'layer_origin': 344, 'payload_origin': 345, 'allocation_end': 349}), ({'w': 10, 'h': 7, 'b': 2, 'layers': 3, 'layer': 1, 'level': 0, 'base': 13}, {'dims': [[10, 7], [5, 4], [3, 2], [2, 1]], 'texel_counts': [70, 20, 6, 2], 'layer_pitches': [141, 41, 13, 5], 'level_spans': [428, 128, 44, 20], 'level_offsets': [0, 428, 556, 600], 'selected_pitch': 141, 'selected_header': 13, 'layer_origin': 159, 'payload_origin': 160, 'allocation_end': 633}), ({'w': 11, 'h': 8, 'b': 2, 'layers': 4, 'layer': 1, 'level': 1, 'base': 13}, {'dims': [[11, 8], [6, 4], [3, 2], [2, 1]], 'texel_counts': [88, 24, 6, 2], 'layer_pitches': [177, 49, 13, 5], 'level_spans': [713, 201, 57, 25], 'level_offsets': [0, 713, 914, 971], 'selected_pitch': 49, 'selected_header': 726, 'layer_origin': 780, 'payload_origin': 781, 'allocation_end': 1009})], 2: [({'w': 7, 'h': 3, 'b': 3, 'layers': 2, 'layer': 0, 'level': 0, 'base': 26}, {'dims': [[7, 3], [4, 2], [2, 1], [1, 1]], 'texel_counts': [21, 8, 2, 1], 'layer_pitches': [64, 25, 7, 4], 'level_spans': [133, 55, 19, 13], 'level_offsets': [0, 133, 188, 207], 'selected_pitch': 64, 'selected_header': 26, 'layer_origin': 31, 'payload_origin': 32, 'allocation_end': 246}), ({'w': 8, 'h': 4, 'b': 3, 'layers': 3, 'layer': 1, 'level': 1, 'base': 26}, {'dims': [[8, 4], [4, 2], [2, 1], [1, 1]], 'texel_counts': [32, 8, 2, 1], 'layer_pitches': [97, 25, 7, 4], 'level_spans': [296, 80, 26, 17], 'level_offsets': [0, 296, 376, 402], 'selected_pitch': 25, 'selected_header': 322, 'layer_origin': 352, 'payload_origin': 353, 'allocation_end': 445}), ({'w': 9, 'h': 5, 'b': 3, 'layers': 4, 'layer': 2, 'level': 2, 'base': 26}, {'dims': [[9, 5], [5, 3], [3, 2], [2, 1]], 'texel_counts': [45, 15, 6, 2], 'layer_pitches': [136, 46, 19, 7], 'level_spans': [549, 189, 81, 33], 'level_offsets': [0, 549, 738, 819], 'selected_pitch': 19, 'selected_header': 764, 'layer_origin': 807, 'payload_origin': 808, 'allocation_end': 878}), ({'w': 10, 'h': 6, 'b': 3, 'layers': 2, 'layer': 1, 'level': 3, 'base': 26}, {'dims': [[10, 6], [5, 3], [3, 2], [2, 1]], 'texel_counts': [60, 15, 6, 2], 'layer_pitches': [181, 46, 19, 7], 'level_spans': [367, 97, 43, 19], 'level_offsets': [0, 367, 464, 507], 'selected_pitch': 7, 'selected_header': 533, 'layer_origin': 545, 'payload_origin': 546, 'allocation_end': 552}), ({'w': 11, 'h': 7, 'b': 3, 'layers': 3, 'layer': 1, 'level': 0, 'base': 26}, {'dims': [[11, 7], [6, 4], [3, 2], [2, 1]], 'texel_counts': [77, 24, 6, 2], 'layer_pitches': [232, 73, 19, 7], 'level_spans': [701, 224, 62, 26], 'level_offsets': [0, 701, 925, 987], 'selected_pitch': 232, 'selected_header': 26, 'layer_origin': 263, 'payload_origin': 264, 'allocation_end': 1039}), ({'w': 12, 'h': 8, 'b': 3, 'layers': 4, 'layer': 1, 'level': 1, 'base': 26}, {'dims': [[12, 8], [6, 4], [3, 2], [2, 1]], 'texel_counts': [96, 24, 6, 2], 'layer_pitches': [289, 73, 19, 7], 'level_spans': [1161, 297, 81, 33], 'level_offsets': [0, 1161, 1458, 1539], 'selected_pitch': 73, 'selected_header': 1187, 'layer_origin': 1265, 'payload_origin': 1266, 'allocation_end': 1598})], 3: [({'w': 8, 'h': 3, 'b': 4, 'layers': 2, 'layer': 0, 'level': 0, 'base': 39}, {'dims': [[8, 3], [4, 2], [2, 1], [1, 1]], 'texel_counts': [24, 8, 2, 1], 'layer_pitches': [97, 33, 9, 5], 'level_spans': [199, 71, 23, 15], 'level_offsets': [0, 199, 270, 293], 'selected_pitch': 97, 'selected_header': 39, 'layer_origin': 44, 'payload_origin': 45, 'allocation_end': 347}), ({'w': 9, 'h': 4, 'b': 4, 'layers': 3, 'layer': 1, 'level': 1, 'base': 39}, {'dims': [[9, 4], [5, 2], [3, 1], [2, 1]], 'texel_counts': [36, 10, 3, 2], 'layer_pitches': [145, 41, 13, 9], 'level_spans': [440, 128, 44, 32], 'level_offsets': [0, 440, 568, 612], 'selected_pitch': 41, 'selected_header': 479, 'layer_origin': 525, 'payload_origin': 526, 'allocation_end': 683}), ({'w': 10, 'h': 5, 'b': 4, 'layers': 4, 'layer': 2, 'level': 2, 'base': 39}, {'dims': [[10, 5], [5, 3], [3, 2], [2, 1]], 'texel_counts': [50, 15, 6, 2], 'layer_pitches': [201, 61, 25, 9], 'level_spans': [809, 249, 105, 41], 'level_offsets': [0, 809, 1058, 1163], 'selected_pitch': 25, 'selected_header': 1097, 'layer_origin': 1152, 'payload_origin': 1153, 'allocation_end': 1243}), ({'w': 11, 'h': 6, 'b': 4, 'layers': 2, 'layer': 1, 'level': 3, 'base': 39}, {'dims': [[11, 6], [6, 3], [3, 2], [2, 1]], 'texel_counts': [66, 18, 6, 2], 'layer_pitches': [265, 73, 25, 9], 'level_spans': [535, 151, 55, 23], 'level_offsets': [0, 535, 686, 741], 'selected_pitch': 9, 'selected_header': 780, 'layer_origin': 794, 'payload_origin': 795, 'allocation_end': 803}), ({'w': 12, 'h': 7, 'b': 4, 'layers': 3, 'layer': 1, 'level': 0, 'base': 39}, {'dims': [[12, 7], [6, 4], [3, 2], [2, 1]], 'texel_counts': [84, 24, 6, 2], 'layer_pitches': [337, 97, 25, 9], 'level_spans': [1016, 296, 80, 32], 'level_offsets': [0, 1016, 1312, 1392], 'selected_pitch': 337, 'selected_header': 39, 'layer_origin': 381, 'payload_origin': 382, 'allocation_end': 1463}), ({'w': 13, 'h': 8, 'b': 4, 'layers': 4, 'layer': 1, 'level': 1, 'base': 39}, {'dims': [[13, 8], [7, 4], [4, 2], [2, 1]], 'texel_counts': [104, 28, 8, 2], 'layer_pitches': [417, 113, 33, 9], 'level_spans': [1673, 457, 137, 41], 'level_offsets': [0, 1673, 2130, 2267], 'selected_pitch': 113, 'selected_header': 1712, 'layer_origin': 1830, 'payload_origin': 1831, 'allocation_end': 2347})], 4: [({'w': 9, 'h': 3, 'b': 5, 'layers': 2, 'layer': 0, 'level': 0, 'base': 52}, {'dims': [[9, 3], [5, 2], [3, 1], [2, 1]], 'texel_counts': [27, 10, 3, 2], 'layer_pitches': [136, 51, 16, 11], 'level_spans': [277, 107, 37, 27], 'level_offsets': [0, 277, 384, 421], 'selected_pitch': 136, 'selected_header': 52, 'layer_origin': 57, 'payload_origin': 58, 'allocation_end': 500}), ({'w': 10, 'h': 4, 'b': 5, 'layers': 3, 'layer': 1, 'level': 1, 'base': 52}, {'dims': [[10, 4], [5, 2], [3, 1], [2, 1]], 'texel_counts': [40, 10, 3, 2], 'layer_pitches': [201, 51, 16, 11], 'level_spans': [608, 158, 53, 38], 'level_offsets': [0, 608, 766, 819], 'selected_pitch': 51, 'selected_header': 660, 'layer_origin': 716, 'payload_origin': 717, 'allocation_end': 909}), ({'w': 11, 'h': 5, 'b': 5, 'layers': 4, 'layer': 2, 'level': 2, 'base': 52}, {'dims': [[11, 5], [6, 3], [3, 2], [2, 1]], 'texel_counts': [55, 18, 6, 2], 'layer_pitches': [276, 91, 31, 11], 'level_spans': [1109, 369, 129, 49], 'level_offsets': [0, 1109, 1478, 1607], 'selected_pitch': 31, 'selected_header': 1530, 'layer_origin': 1597, 'payload_origin': 1598, 'allocation_end': 1708}), ({'w': 12, 'h': 6, 'b': 5, 'layers': 2, 'layer': 1, 'level': 3, 'base': 52}, {'dims': [[12, 6], [6, 3], [3, 2], [2, 1]], 'texel_counts': [72, 18, 6, 2], 'layer_pitches': [361, 91, 31, 11], 'level_spans': [727, 187, 67, 27], 'level_offsets': [0, 727, 914, 981], 'selected_pitch': 11, 'selected_header': 1033, 'layer_origin': 1049, 'payload_origin': 1050, 'allocation_end': 1060}), ({'w': 13, 'h': 7, 'b': 5, 'layers': 3, 'layer': 1, 'level': 0, 'base': 52}, {'dims': [[13, 7], [7, 4], [4, 2], [2, 1]], 'texel_counts': [91, 28, 8, 2], 'layer_pitches': [456, 141, 41, 11], 'level_spans': [1373, 428, 128, 38], 'level_offsets': [0, 1373, 1801, 1929], 'selected_pitch': 456, 'selected_header': 52, 'layer_origin': 513, 'payload_origin': 514, 'allocation_end': 2019}), ({'w': 14, 'h': 8, 'b': 5, 'layers': 4, 'layer': 1, 'level': 1, 'base': 52}, {'dims': [[14, 8], [7, 4], [4, 2], [2, 1]], 'texel_counts': [112, 28, 8, 2], 'layer_pitches': [561, 141, 41, 11], 'level_spans': [2249, 569, 169, 49], 'level_offsets': [0, 2249, 2818, 2987], 'selected_pitch': 141, 'selected_header': 2301, 'layer_origin': 2447, 'payload_origin': 2448, 'allocation_end': 3088})], 5: [({'w': 10, 'h': 3, 'b': 6, 'layers': 2, 'layer': 0, 'level': 0, 'base': 65}, {'dims': [[10, 3], [5, 2], [3, 1], [2, 1]], 'texel_counts': [30, 10, 3, 2], 'layer_pitches': [181, 61, 19, 13], 'level_spans': [367, 127, 43, 31], 'level_offsets': [0, 367, 494, 537], 'selected_pitch': 181, 'selected_header': 65, 'layer_origin': 70, 'payload_origin': 71, 'allocation_end': 633}), ({'w': 11, 'h': 4, 'b': 6, 'layers': 3, 'layer': 1, 'level': 1, 'base': 65}, {'dims': [[11, 4], [6, 2], [3, 1], [2, 1]], 'texel_counts': [44, 12, 3, 2], 'layer_pitches': [265, 73, 19, 13], 'level_spans': [800, 224, 62, 44], 'level_offsets': [0, 800, 1024, 1086], 'selected_pitch': 73, 'selected_header': 865, 'layer_origin': 943, 'payload_origin': 944, 'allocation_end': 1195}), ({'w': 12, 'h': 5, 'b': 6, 'layers': 4, 'layer': 2, 'level': 2, 'base': 65}, {'dims': [[12, 5], [6, 3], [3, 2], [2, 1]], 'texel_counts': [60, 18, 6, 2], 'layer_pitches': [361, 109, 37, 13], 'level_spans': [1449, 441, 153, 57], 'level_offsets': [0, 1449, 1890, 2043], 'selected_pitch': 37, 'selected_header': 1955, 'layer_origin': 2034, 'payload_origin': 2035, 'allocation_end': 2165}), ({'w': 13, 'h': 6, 'b': 6, 'layers': 2, 'layer': 1, 'level': 3, 'base': 65}, {'dims': [[13, 6], [7, 3], [4, 2], [2, 1]], 'texel_counts': [78, 21, 8, 2], 'layer_pitches': [469, 127, 49, 13], 'level_spans': [943, 259, 103, 31], 'level_offsets': [0, 943, 1202, 1305], 'selected_pitch': 13, 'selected_header': 1370, 'layer_origin': 1388, 'payload_origin': 1389, 'allocation_end': 1401}), ({'w': 14, 'h': 7, 'b': 6, 'layers': 3, 'layer': 1, 'level': 0, 'base': 65}, {'dims': [[14, 7], [7, 4], [4, 2], [2, 1]], 'texel_counts': [98, 28, 8, 2], 'layer_pitches': [589, 169, 49, 13], 'level_spans': [1772, 512, 152, 44], 'level_offsets': [0, 1772, 2284, 2436], 'selected_pitch': 589, 'selected_header': 65, 'layer_origin': 659, 'payload_origin': 660, 'allocation_end': 2545}), ({'w': 15, 'h': 8, 'b': 6, 'layers': 4, 'layer': 1, 'level': 1, 'base': 65}, {'dims': [[15, 8], [8, 4], [4, 2], [2, 1]], 'texel_counts': [120, 32, 8, 2], 'layer_pitches': [721, 193, 49, 13], 'level_spans': [2889, 777, 201, 57], 'level_offsets': [0, 2889, 3666, 3867], 'selected_pitch': 193, 'selected_header': 2954, 'layer_origin': 3152, 'payload_origin': 3153, 'allocation_end': 3989})]}
for i, (p, expected) in enumerate(cases[N]):
    check("layout fixture " + str(i + 1), solve(p), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(p):
    p = dict(p)
    dims = [[max(1,(p["w"]+(1<<i)-1)//(1<<i)),max(1,(p["h"]+(1<<i)-1)//(1<<i))] for i in range(4)]
    texel_counts = [w*h for w,h in dims]
    layer_pitches = [t*p["b"]+1 for t in texel_counts]
    level_spans = [(q+5)*p["layers"] for q in layer_pitches]
    level_offsets = [sum(level_spans[:i]) for i in range(4)]
    selected_pitch = layer_pitches[p["level"]]
    selected_header = p["base"]+level_offsets[p["level"]]
    layer_origin = selected_header+5+p["layer"]*selected_pitch
    payload_origin = layer_origin+1
    allocation_end = p["base"]+sum(level_spans)
    return {'dims': dims, 'texel_counts': texel_counts, 'layer_pitches': layer_pitches, 'level_spans': level_spans, 'level_offsets': level_offsets, 'selected_pitch': selected_pitch, 'selected_header': selected_header, 'layer_origin': layer_origin, 'payload_origin': payload_origin, 'allocation_end': allocation_end}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'w': 6, 'h': 3, 'b': 2, 'layers': 2, 'layer': 0, 'level': 0, 'base': 13}, {'dims': [[6, 3], [3, 2], [2, 1], [1, 1]], 'texel_counts': [18, 6, 2, 1], 'layer_pitches': [37, 13, 5, 3], 'level_spans': [79, 31, 15, 11], 'level_offsets': [0, 79, 110, 125], 'selected_pitch': 37, 'selected_header': 13, 'layer_origin': 18, 'payload_origin': 19, 'allocation_end': 149}), ({'w': 7, 'h': 4, 'b': 2, 'layers': 3, 'layer': 1, 'level': 1, 'base': 13}, {'dims': [[7, 4], [4, 2], [2, 1], [1, 1]], 'texel_counts': [28, 8, 2, 1], 'layer_pitches': [57, 17, 5, 3], 'level_spans': [176, 56, 20, 14], 'level_offsets': [0, 176, 232, 252], 'selected_pitch': 17, 'selected_header': 189, 'layer_origin': 211, 'payload_origin': 212, 'allocation_end': 279}), ({'w': 8, 'h': 5, 'b': 2, 'layers': 4, 'layer': 2, 'level': 2, 'base': 13}, {'dims': [[8, 5], [4, 3], [2, 2], [1, 1]], 'texel_counts': [40, 12, 4, 1], 'layer_pitches': [81, 25, 9, 3], 'level_spans': [329, 105, 41, 17], 'level_offsets': [0, 329, 434, 475], 'selected_pitch': 9, 'selected_header': 447, 'layer_origin': 470, 'payload_origin': 471, 'allocation_end': 505}), ({'w': 9, 'h': 6, 'b': 2, 'layers': 2, 'layer': 1, 'level': 3, 'base': 13}, {'dims': [[9, 6], [5, 3], [3, 2], [2, 1]], 'texel_counts': [54, 15, 6, 2], 'layer_pitches': [109, 31, 13, 5], 'level_spans': [223, 67, 31, 15], 'level_offsets': [0, 223, 290, 321], 'selected_pitch': 5, 'selected_header': 334, 'layer_origin': 344, 'payload_origin': 345, 'allocation_end': 349}), ({'w': 10, 'h': 7, 'b': 2, 'layers': 3, 'layer': 1, 'level': 0, 'base': 13}, {'dims': [[10, 7], [5, 4], [3, 2], [2, 1]], 'texel_counts': [70, 20, 6, 2], 'layer_pitches': [141, 41, 13, 5], 'level_spans': [428, 128, 44, 20], 'level_offsets': [0, 428, 556, 600], 'selected_pitch': 141, 'selected_header': 13, 'layer_origin': 159, 'payload_origin': 160, 'allocation_end': 633}), ({'w': 11, 'h': 8, 'b': 2, 'layers': 4, 'layer': 1, 'level': 1, 'base': 13}, {'dims': [[11, 8], [6, 4], [3, 2], [2, 1]], 'texel_counts': [88, 24, 6, 2], 'layer_pitches': [177, 49, 13, 5], 'level_spans': [713, 201, 57, 25], 'level_offsets': [0, 713, 914, 971], 'selected_pitch': 49, 'selected_header': 726, 'layer_origin': 780, 'payload_origin': 781, 'allocation_end': 1009})], 2: [({'w': 7, 'h': 3, 'b': 3, 'layers': 2, 'layer': 0, 'level': 0, 'base': 26}, {'dims': [[7, 3], [4, 2], [2, 1], [1, 1]], 'texel_counts': [21, 8, 2, 1], 'layer_pitches': [64, 25, 7, 4], 'level_spans': [133, 55, 19, 13], 'level_offsets': [0, 133, 188, 207], 'selected_pitch': 64, 'selected_header': 26, 'layer_origin': 31, 'payload_origin': 32, 'allocation_end': 246}), ({'w': 8, 'h': 4, 'b': 3, 'layers': 3, 'layer': 1, 'level': 1, 'base': 26}, {'dims': [[8, 4], [4, 2], [2, 1], [1, 1]], 'texel_counts': [32, 8, 2, 1], 'layer_pitches': [97, 25, 7, 4], 'level_spans': [296, 80, 26, 17], 'level_offsets': [0, 296, 376, 402], 'selected_pitch': 25, 'selected_header': 322, 'layer_origin': 352, 'payload_origin': 353, 'allocation_end': 445}), ({'w': 9, 'h': 5, 'b': 3, 'layers': 4, 'layer': 2, 'level': 2, 'base': 26}, {'dims': [[9, 5], [5, 3], [3, 2], [2, 1]], 'texel_counts': [45, 15, 6, 2], 'layer_pitches': [136, 46, 19, 7], 'level_spans': [549, 189, 81, 33], 'level_offsets': [0, 549, 738, 819], 'selected_pitch': 19, 'selected_header': 764, 'layer_origin': 807, 'payload_origin': 808, 'allocation_end': 878}), ({'w': 10, 'h': 6, 'b': 3, 'layers': 2, 'layer': 1, 'level': 3, 'base': 26}, {'dims': [[10, 6], [5, 3], [3, 2], [2, 1]], 'texel_counts': [60, 15, 6, 2], 'layer_pitches': [181, 46, 19, 7], 'level_spans': [367, 97, 43, 19], 'level_offsets': [0, 367, 464, 507], 'selected_pitch': 7, 'selected_header': 533, 'layer_origin': 545, 'payload_origin': 546, 'allocation_end': 552}), ({'w': 11, 'h': 7, 'b': 3, 'layers': 3, 'layer': 1, 'level': 0, 'base': 26}, {'dims': [[11, 7], [6, 4], [3, 2], [2, 1]], 'texel_counts': [77, 24, 6, 2], 'layer_pitches': [232, 73, 19, 7], 'level_spans': [701, 224, 62, 26], 'level_offsets': [0, 701, 925, 987], 'selected_pitch': 232, 'selected_header': 26, 'layer_origin': 263, 'payload_origin': 264, 'allocation_end': 1039}), ({'w': 12, 'h': 8, 'b': 3, 'layers': 4, 'layer': 1, 'level': 1, 'base': 26}, {'dims': [[12, 8], [6, 4], [3, 2], [2, 1]], 'texel_counts': [96, 24, 6, 2], 'layer_pitches': [289, 73, 19, 7], 'level_spans': [1161, 297, 81, 33], 'level_offsets': [0, 1161, 1458, 1539], 'selected_pitch': 73, 'selected_header': 1187, 'layer_origin': 1265, 'payload_origin': 1266, 'allocation_end': 1598})], 3: [({'w': 8, 'h': 3, 'b': 4, 'layers': 2, 'layer': 0, 'level': 0, 'base': 39}, {'dims': [[8, 3], [4, 2], [2, 1], [1, 1]], 'texel_counts': [24, 8, 2, 1], 'layer_pitches': [97, 33, 9, 5], 'level_spans': [199, 71, 23, 15], 'level_offsets': [0, 199, 270, 293], 'selected_pitch': 97, 'selected_header': 39, 'layer_origin': 44, 'payload_origin': 45, 'allocation_end': 347}), ({'w': 9, 'h': 4, 'b': 4, 'layers': 3, 'layer': 1, 'level': 1, 'base': 39}, {'dims': [[9, 4], [5, 2], [3, 1], [2, 1]], 'texel_counts': [36, 10, 3, 2], 'layer_pitches': [145, 41, 13, 9], 'level_spans': [440, 128, 44, 32], 'level_offsets': [0, 440, 568, 612], 'selected_pitch': 41, 'selected_header': 479, 'layer_origin': 525, 'payload_origin': 526, 'allocation_end': 683}), ({'w': 10, 'h': 5, 'b': 4, 'layers': 4, 'layer': 2, 'level': 2, 'base': 39}, {'dims': [[10, 5], [5, 3], [3, 2], [2, 1]], 'texel_counts': [50, 15, 6, 2], 'layer_pitches': [201, 61, 25, 9], 'level_spans': [809, 249, 105, 41], 'level_offsets': [0, 809, 1058, 1163], 'selected_pitch': 25, 'selected_header': 1097, 'layer_origin': 1152, 'payload_origin': 1153, 'allocation_end': 1243}), ({'w': 11, 'h': 6, 'b': 4, 'layers': 2, 'layer': 1, 'level': 3, 'base': 39}, {'dims': [[11, 6], [6, 3], [3, 2], [2, 1]], 'texel_counts': [66, 18, 6, 2], 'layer_pitches': [265, 73, 25, 9], 'level_spans': [535, 151, 55, 23], 'level_offsets': [0, 535, 686, 741], 'selected_pitch': 9, 'selected_header': 780, 'layer_origin': 794, 'payload_origin': 795, 'allocation_end': 803}), ({'w': 12, 'h': 7, 'b': 4, 'layers': 3, 'layer': 1, 'level': 0, 'base': 39}, {'dims': [[12, 7], [6, 4], [3, 2], [2, 1]], 'texel_counts': [84, 24, 6, 2], 'layer_pitches': [337, 97, 25, 9], 'level_spans': [1016, 296, 80, 32], 'level_offsets': [0, 1016, 1312, 1392], 'selected_pitch': 337, 'selected_header': 39, 'layer_origin': 381, 'payload_origin': 382, 'allocation_end': 1463}), ({'w': 13, 'h': 8, 'b': 4, 'layers': 4, 'layer': 1, 'level': 1, 'base': 39}, {'dims': [[13, 8], [7, 4], [4, 2], [2, 1]], 'texel_counts': [104, 28, 8, 2], 'layer_pitches': [417, 113, 33, 9], 'level_spans': [1673, 457, 137, 41], 'level_offsets': [0, 1673, 2130, 2267], 'selected_pitch': 113, 'selected_header': 1712, 'layer_origin': 1830, 'payload_origin': 1831, 'allocation_end': 2347})], 4: [({'w': 9, 'h': 3, 'b': 5, 'layers': 2, 'layer': 0, 'level': 0, 'base': 52}, {'dims': [[9, 3], [5, 2], [3, 1], [2, 1]], 'texel_counts': [27, 10, 3, 2], 'layer_pitches': [136, 51, 16, 11], 'level_spans': [277, 107, 37, 27], 'level_offsets': [0, 277, 384, 421], 'selected_pitch': 136, 'selected_header': 52, 'layer_origin': 57, 'payload_origin': 58, 'allocation_end': 500}), ({'w': 10, 'h': 4, 'b': 5, 'layers': 3, 'layer': 1, 'level': 1, 'base': 52}, {'dims': [[10, 4], [5, 2], [3, 1], [2, 1]], 'texel_counts': [40, 10, 3, 2], 'layer_pitches': [201, 51, 16, 11], 'level_spans': [608, 158, 53, 38], 'level_offsets': [0, 608, 766, 819], 'selected_pitch': 51, 'selected_header': 660, 'layer_origin': 716, 'payload_origin': 717, 'allocation_end': 909}), ({'w': 11, 'h': 5, 'b': 5, 'layers': 4, 'layer': 2, 'level': 2, 'base': 52}, {'dims': [[11, 5], [6, 3], [3, 2], [2, 1]], 'texel_counts': [55, 18, 6, 2], 'layer_pitches': [276, 91, 31, 11], 'level_spans': [1109, 369, 129, 49], 'level_offsets': [0, 1109, 1478, 1607], 'selected_pitch': 31, 'selected_header': 1530, 'layer_origin': 1597, 'payload_origin': 1598, 'allocation_end': 1708}), ({'w': 12, 'h': 6, 'b': 5, 'layers': 2, 'layer': 1, 'level': 3, 'base': 52}, {'dims': [[12, 6], [6, 3], [3, 2], [2, 1]], 'texel_counts': [72, 18, 6, 2], 'layer_pitches': [361, 91, 31, 11], 'level_spans': [727, 187, 67, 27], 'level_offsets': [0, 727, 914, 981], 'selected_pitch': 11, 'selected_header': 1033, 'layer_origin': 1049, 'payload_origin': 1050, 'allocation_end': 1060}), ({'w': 13, 'h': 7, 'b': 5, 'layers': 3, 'layer': 1, 'level': 0, 'base': 52}, {'dims': [[13, 7], [7, 4], [4, 2], [2, 1]], 'texel_counts': [91, 28, 8, 2], 'layer_pitches': [456, 141, 41, 11], 'level_spans': [1373, 428, 128, 38], 'level_offsets': [0, 1373, 1801, 1929], 'selected_pitch': 456, 'selected_header': 52, 'layer_origin': 513, 'payload_origin': 514, 'allocation_end': 2019}), ({'w': 14, 'h': 8, 'b': 5, 'layers': 4, 'layer': 1, 'level': 1, 'base': 52}, {'dims': [[14, 8], [7, 4], [4, 2], [2, 1]], 'texel_counts': [112, 28, 8, 2], 'layer_pitches': [561, 141, 41, 11], 'level_spans': [2249, 569, 169, 49], 'level_offsets': [0, 2249, 2818, 2987], 'selected_pitch': 141, 'selected_header': 2301, 'layer_origin': 2447, 'payload_origin': 2448, 'allocation_end': 3088})], 5: [({'w': 10, 'h': 3, 'b': 6, 'layers': 2, 'layer': 0, 'level': 0, 'base': 65}, {'dims': [[10, 3], [5, 2], [3, 1], [2, 1]], 'texel_counts': [30, 10, 3, 2], 'layer_pitches': [181, 61, 19, 13], 'level_spans': [367, 127, 43, 31], 'level_offsets': [0, 367, 494, 537], 'selected_pitch': 181, 'selected_header': 65, 'layer_origin': 70, 'payload_origin': 71, 'allocation_end': 633}), ({'w': 11, 'h': 4, 'b': 6, 'layers': 3, 'layer': 1, 'level': 1, 'base': 65}, {'dims': [[11, 4], [6, 2], [3, 1], [2, 1]], 'texel_counts': [44, 12, 3, 2], 'layer_pitches': [265, 73, 19, 13], 'level_spans': [800, 224, 62, 44], 'level_offsets': [0, 800, 1024, 1086], 'selected_pitch': 73, 'selected_header': 865, 'layer_origin': 943, 'payload_origin': 944, 'allocation_end': 1195}), ({'w': 12, 'h': 5, 'b': 6, 'layers': 4, 'layer': 2, 'level': 2, 'base': 65}, {'dims': [[12, 5], [6, 3], [3, 2], [2, 1]], 'texel_counts': [60, 18, 6, 2], 'layer_pitches': [361, 109, 37, 13], 'level_spans': [1449, 441, 153, 57], 'level_offsets': [0, 1449, 1890, 2043], 'selected_pitch': 37, 'selected_header': 1955, 'layer_origin': 2034, 'payload_origin': 2035, 'allocation_end': 2165}), ({'w': 13, 'h': 6, 'b': 6, 'layers': 2, 'layer': 1, 'level': 3, 'base': 65}, {'dims': [[13, 6], [7, 3], [4, 2], [2, 1]], 'texel_counts': [78, 21, 8, 2], 'layer_pitches': [469, 127, 49, 13], 'level_spans': [943, 259, 103, 31], 'level_offsets': [0, 943, 1202, 1305], 'selected_pitch': 13, 'selected_header': 1370, 'layer_origin': 1388, 'payload_origin': 1389, 'allocation_end': 1401}), ({'w': 14, 'h': 7, 'b': 6, 'layers': 3, 'layer': 1, 'level': 0, 'base': 65}, {'dims': [[14, 7], [7, 4], [4, 2], [2, 1]], 'texel_counts': [98, 28, 8, 2], 'layer_pitches': [589, 169, 49, 13], 'level_spans': [1772, 512, 152, 44], 'level_offsets': [0, 1772, 2284, 2436], 'selected_pitch': 589, 'selected_header': 65, 'layer_origin': 659, 'payload_origin': 660, 'allocation_end': 2545}), ({'w': 15, 'h': 8, 'b': 6, 'layers': 4, 'layer': 1, 'level': 1, 'base': 65}, {'dims': [[15, 8], [8, 4], [4, 2], [2, 1]], 'texel_counts': [120, 32, 8, 2], 'layer_pitches': [721, 193, 49, 13], 'level_spans': [2889, 777, 201, 57], 'level_offsets': [0, 2889, 3666, 3867], 'selected_pitch': 193, 'selected_header': 2954, 'layer_origin': 3152, 'payload_origin': 3153, 'allocation_end': 3989})]}
for i, (p, expected) in enumerate(cases[N]):
    check("layout fixture " + str(i + 1), solve(p), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The returned physical layout descriptor disagrees with the declared buffer mapping at level_spans.

Four ceil-halved mip levels each contain all array layers. Each layer owns a one-byte tag and tightly packed texels; level records add a five-byte header. Return the allocation directory and selected layer origin. Return the named intermediate layout descriptor and final address fields; all quantities are integer byte offsets unless explicitly stated.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(p):
    p = dict(p)
    dims = [[max(1,(p["w"]+(1<<i)-1)//(1<<i)),max(1,(p["h"]+(1<<i)-1)//(1<<i))] for i in range(4)]
    texel_counts = [w*h for w,h in dims]
    layer_pitches = [t*p["b"]+1 for t in texel_counts]
    level_spans = [q*p["layers"]+5 for q in layer_pitches]
    level_offsets = [sum(layer_pitches[:i]) for i in range(4)]
    selected_pitch = layer_pitches[p["level"]]
    selected_header = p["base"]+level_offsets[p["level"]]
    layer_origin = selected_header+5+p["layer"]*selected_pitch
    payload_origin = layer_origin+1
    allocation_end = p["base"]+sum(level_spans)
    return {'dims': dims, 'texel_counts': texel_counts, 'layer_pitches': layer_pitches, 'level_spans': level_spans, 'level_offsets': level_offsets, 'selected_pitch': selected_pitch, 'selected_header': selected_header, 'layer_origin': layer_origin, 'payload_origin': payload_origin, 'allocation_end': allocation_end}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'w': 6, 'h': 3, 'b': 2, 'layers': 2, 'layer': 0, 'level': 0, 'base': 13}, {'dims': [[6, 3], [3, 2], [2, 1], [1, 1]], 'texel_counts': [18, 6, 2, 1], 'layer_pitches': [37, 13, 5, 3], 'level_spans': [79, 31, 15, 11], 'level_offsets': [0, 79, 110, 125], 'selected_pitch': 37, 'selected_header': 13, 'layer_origin': 18, 'payload_origin': 19, 'allocation_end': 149}), ({'w': 7, 'h': 4, 'b': 2, 'layers': 3, 'layer': 1, 'level': 1, 'base': 13}, {'dims': [[7, 4], [4, 2], [2, 1], [1, 1]], 'texel_counts': [28, 8, 2, 1], 'layer_pitches': [57, 17, 5, 3], 'level_spans': [176, 56, 20, 14], 'level_offsets': [0, 176, 232, 252], 'selected_pitch': 17, 'selected_header': 189, 'layer_origin': 211, 'payload_origin': 212, 'allocation_end': 279}), ({'w': 8, 'h': 5, 'b': 2, 'layers': 4, 'layer': 2, 'level': 2, 'base': 13}, {'dims': [[8, 5], [4, 3], [2, 2], [1, 1]], 'texel_counts': [40, 12, 4, 1], 'layer_pitches': [81, 25, 9, 3], 'level_spans': [329, 105, 41, 17], 'level_offsets': [0, 329, 434, 475], 'selected_pitch': 9, 'selected_header': 447, 'layer_origin': 470, 'payload_origin': 471, 'allocation_end': 505}), ({'w': 9, 'h': 6, 'b': 2, 'layers': 2, 'layer': 1, 'level': 3, 'base': 13}, {'dims': [[9, 6], [5, 3], [3, 2], [2, 1]], 'texel_counts': [54, 15, 6, 2], 'layer_pitches': [109, 31, 13, 5], 'level_spans': [223, 67, 31, 15], 'level_offsets': [0, 223, 290, 321], 'selected_pitch': 5, 'selected_header': 334, 'layer_origin': 344, 'payload_origin': 345, 'allocation_end': 349}), ({'w': 10, 'h': 7, 'b': 2, 'layers': 3, 'layer': 1, 'level': 0, 'base': 13}, {'dims': [[10, 7], [5, 4], [3, 2], [2, 1]], 'texel_counts': [70, 20, 6, 2], 'layer_pitches': [141, 41, 13, 5], 'level_spans': [428, 128, 44, 20], 'level_offsets': [0, 428, 556, 600], 'selected_pitch': 141, 'selected_header': 13, 'layer_origin': 159, 'payload_origin': 160, 'allocation_end': 633}), ({'w': 11, 'h': 8, 'b': 2, 'layers': 4, 'layer': 1, 'level': 1, 'base': 13}, {'dims': [[11, 8], [6, 4], [3, 2], [2, 1]], 'texel_counts': [88, 24, 6, 2], 'layer_pitches': [177, 49, 13, 5], 'level_spans': [713, 201, 57, 25], 'level_offsets': [0, 713, 914, 971], 'selected_pitch': 49, 'selected_header': 726, 'layer_origin': 780, 'payload_origin': 781, 'allocation_end': 1009})], 2: [({'w': 7, 'h': 3, 'b': 3, 'layers': 2, 'layer': 0, 'level': 0, 'base': 26}, {'dims': [[7, 3], [4, 2], [2, 1], [1, 1]], 'texel_counts': [21, 8, 2, 1], 'layer_pitches': [64, 25, 7, 4], 'level_spans': [133, 55, 19, 13], 'level_offsets': [0, 133, 188, 207], 'selected_pitch': 64, 'selected_header': 26, 'layer_origin': 31, 'payload_origin': 32, 'allocation_end': 246}), ({'w': 8, 'h': 4, 'b': 3, 'layers': 3, 'layer': 1, 'level': 1, 'base': 26}, {'dims': [[8, 4], [4, 2], [2, 1], [1, 1]], 'texel_counts': [32, 8, 2, 1], 'layer_pitches': [97, 25, 7, 4], 'level_spans': [296, 80, 26, 17], 'level_offsets': [0, 296, 376, 402], 'selected_pitch': 25, 'selected_header': 322, 'layer_origin': 352, 'payload_origin': 353, 'allocation_end': 445}), ({'w': 9, 'h': 5, 'b': 3, 'layers': 4, 'layer': 2, 'level': 2, 'base': 26}, {'dims': [[9, 5], [5, 3], [3, 2], [2, 1]], 'texel_counts': [45, 15, 6, 2], 'layer_pitches': [136, 46, 19, 7], 'level_spans': [549, 189, 81, 33], 'level_offsets': [0, 549, 738, 819], 'selected_pitch': 19, 'selected_header': 764, 'layer_origin': 807, 'payload_origin': 808, 'allocation_end': 878}), ({'w': 10, 'h': 6, 'b': 3, 'layers': 2, 'layer': 1, 'level': 3, 'base': 26}, {'dims': [[10, 6], [5, 3], [3, 2], [2, 1]], 'texel_counts': [60, 15, 6, 2], 'layer_pitches': [181, 46, 19, 7], 'level_spans': [367, 97, 43, 19], 'level_offsets': [0, 367, 464, 507], 'selected_pitch': 7, 'selected_header': 533, 'layer_origin': 545, 'payload_origin': 546, 'allocation_end': 552}), ({'w': 11, 'h': 7, 'b': 3, 'layers': 3, 'layer': 1, 'level': 0, 'base': 26}, {'dims': [[11, 7], [6, 4], [3, 2], [2, 1]], 'texel_counts': [77, 24, 6, 2], 'layer_pitches': [232, 73, 19, 7], 'level_spans': [701, 224, 62, 26], 'level_offsets': [0, 701, 925, 987], 'selected_pitch': 232, 'selected_header': 26, 'layer_origin': 263, 'payload_origin': 264, 'allocation_end': 1039}), ({'w': 12, 'h': 8, 'b': 3, 'layers': 4, 'layer': 1, 'level': 1, 'base': 26}, {'dims': [[12, 8], [6, 4], [3, 2], [2, 1]], 'texel_counts': [96, 24, 6, 2], 'layer_pitches': [289, 73, 19, 7], 'level_spans': [1161, 297, 81, 33], 'level_offsets': [0, 1161, 1458, 1539], 'selected_pitch': 73, 'selected_header': 1187, 'layer_origin': 1265, 'payload_origin': 1266, 'allocation_end': 1598})], 3: [({'w': 8, 'h': 3, 'b': 4, 'layers': 2, 'layer': 0, 'level': 0, 'base': 39}, {'dims': [[8, 3], [4, 2], [2, 1], [1, 1]], 'texel_counts': [24, 8, 2, 1], 'layer_pitches': [97, 33, 9, 5], 'level_spans': [199, 71, 23, 15], 'level_offsets': [0, 199, 270, 293], 'selected_pitch': 97, 'selected_header': 39, 'layer_origin': 44, 'payload_origin': 45, 'allocation_end': 347}), ({'w': 9, 'h': 4, 'b': 4, 'layers': 3, 'layer': 1, 'level': 1, 'base': 39}, {'dims': [[9, 4], [5, 2], [3, 1], [2, 1]], 'texel_counts': [36, 10, 3, 2], 'layer_pitches': [145, 41, 13, 9], 'level_spans': [440, 128, 44, 32], 'level_offsets': [0, 440, 568, 612], 'selected_pitch': 41, 'selected_header': 479, 'layer_origin': 525, 'payload_origin': 526, 'allocation_end': 683}), ({'w': 10, 'h': 5, 'b': 4, 'layers': 4, 'layer': 2, 'level': 2, 'base': 39}, {'dims': [[10, 5], [5, 3], [3, 2], [2, 1]], 'texel_counts': [50, 15, 6, 2], 'layer_pitches': [201, 61, 25, 9], 'level_spans': [809, 249, 105, 41], 'level_offsets': [0, 809, 1058, 1163], 'selected_pitch': 25, 'selected_header': 1097, 'layer_origin': 1152, 'payload_origin': 1153, 'allocation_end': 1243}), ({'w': 11, 'h': 6, 'b': 4, 'layers': 2, 'layer': 1, 'level': 3, 'base': 39}, {'dims': [[11, 6], [6, 3], [3, 2], [2, 1]], 'texel_counts': [66, 18, 6, 2], 'layer_pitches': [265, 73, 25, 9], 'level_spans': [535, 151, 55, 23], 'level_offsets': [0, 535, 686, 741], 'selected_pitch': 9, 'selected_header': 780, 'layer_origin': 794, 'payload_origin': 795, 'allocation_end': 803}), ({'w': 12, 'h': 7, 'b': 4, 'layers': 3, 'layer': 1, 'level': 0, 'base': 39}, {'dims': [[12, 7], [6, 4], [3, 2], [2, 1]], 'texel_counts': [84, 24, 6, 2], 'layer_pitches': [337, 97, 25, 9], 'level_spans': [1016, 296, 80, 32], 'level_offsets': [0, 1016, 1312, 1392], 'selected_pitch': 337, 'selected_header': 39, 'layer_origin': 381, 'payload_origin': 382, 'allocation_end': 1463}), ({'w': 13, 'h': 8, 'b': 4, 'layers': 4, 'layer': 1, 'level': 1, 'base': 39}, {'dims': [[13, 8], [7, 4], [4, 2], [2, 1]], 'texel_counts': [104, 28, 8, 2], 'layer_pitches': [417, 113, 33, 9], 'level_spans': [1673, 457, 137, 41], 'level_offsets': [0, 1673, 2130, 2267], 'selected_pitch': 113, 'selected_header': 1712, 'layer_origin': 1830, 'payload_origin': 1831, 'allocation_end': 2347})], 4: [({'w': 9, 'h': 3, 'b': 5, 'layers': 2, 'layer': 0, 'level': 0, 'base': 52}, {'dims': [[9, 3], [5, 2], [3, 1], [2, 1]], 'texel_counts': [27, 10, 3, 2], 'layer_pitches': [136, 51, 16, 11], 'level_spans': [277, 107, 37, 27], 'level_offsets': [0, 277, 384, 421], 'selected_pitch': 136, 'selected_header': 52, 'layer_origin': 57, 'payload_origin': 58, 'allocation_end': 500}), ({'w': 10, 'h': 4, 'b': 5, 'layers': 3, 'layer': 1, 'level': 1, 'base': 52}, {'dims': [[10, 4], [5, 2], [3, 1], [2, 1]], 'texel_counts': [40, 10, 3, 2], 'layer_pitches': [201, 51, 16, 11], 'level_spans': [608, 158, 53, 38], 'level_offsets': [0, 608, 766, 819], 'selected_pitch': 51, 'selected_header': 660, 'layer_origin': 716, 'payload_origin': 717, 'allocation_end': 909}), ({'w': 11, 'h': 5, 'b': 5, 'layers': 4, 'layer': 2, 'level': 2, 'base': 52}, {'dims': [[11, 5], [6, 3], [3, 2], [2, 1]], 'texel_counts': [55, 18, 6, 2], 'layer_pitches': [276, 91, 31, 11], 'level_spans': [1109, 369, 129, 49], 'level_offsets': [0, 1109, 1478, 1607], 'selected_pitch': 31, 'selected_header': 1530, 'layer_origin': 1597, 'payload_origin': 1598, 'allocation_end': 1708}), ({'w': 12, 'h': 6, 'b': 5, 'layers': 2, 'layer': 1, 'level': 3, 'base': 52}, {'dims': [[12, 6], [6, 3], [3, 2], [2, 1]], 'texel_counts': [72, 18, 6, 2], 'layer_pitches': [361, 91, 31, 11], 'level_spans': [727, 187, 67, 27], 'level_offsets': [0, 727, 914, 981], 'selected_pitch': 11, 'selected_header': 1033, 'layer_origin': 1049, 'payload_origin': 1050, 'allocation_end': 1060}), ({'w': 13, 'h': 7, 'b': 5, 'layers': 3, 'layer': 1, 'level': 0, 'base': 52}, {'dims': [[13, 7], [7, 4], [4, 2], [2, 1]], 'texel_counts': [91, 28, 8, 2], 'layer_pitches': [456, 141, 41, 11], 'level_spans': [1373, 428, 128, 38], 'level_offsets': [0, 1373, 1801, 1929], 'selected_pitch': 456, 'selected_header': 52, 'layer_origin': 513, 'payload_origin': 514, 'allocation_end': 2019}), ({'w': 14, 'h': 8, 'b': 5, 'layers': 4, 'layer': 1, 'level': 1, 'base': 52}, {'dims': [[14, 8], [7, 4], [4, 2], [2, 1]], 'texel_counts': [112, 28, 8, 2], 'layer_pitches': [561, 141, 41, 11], 'level_spans': [2249, 569, 169, 49], 'level_offsets': [0, 2249, 2818, 2987], 'selected_pitch': 141, 'selected_header': 2301, 'layer_origin': 2447, 'payload_origin': 2448, 'allocation_end': 3088})], 5: [({'w': 10, 'h': 3, 'b': 6, 'layers': 2, 'layer': 0, 'level': 0, 'base': 65}, {'dims': [[10, 3], [5, 2], [3, 1], [2, 1]], 'texel_counts': [30, 10, 3, 2], 'layer_pitches': [181, 61, 19, 13], 'level_spans': [367, 127, 43, 31], 'level_offsets': [0, 367, 494, 537], 'selected_pitch': 181, 'selected_header': 65, 'layer_origin': 70, 'payload_origin': 71, 'allocation_end': 633}), ({'w': 11, 'h': 4, 'b': 6, 'layers': 3, 'layer': 1, 'level': 1, 'base': 65}, {'dims': [[11, 4], [6, 2], [3, 1], [2, 1]], 'texel_counts': [44, 12, 3, 2], 'layer_pitches': [265, 73, 19, 13], 'level_spans': [800, 224, 62, 44], 'level_offsets': [0, 800, 1024, 1086], 'selected_pitch': 73, 'selected_header': 865, 'layer_origin': 943, 'payload_origin': 944, 'allocation_end': 1195}), ({'w': 12, 'h': 5, 'b': 6, 'layers': 4, 'layer': 2, 'level': 2, 'base': 65}, {'dims': [[12, 5], [6, 3], [3, 2], [2, 1]], 'texel_counts': [60, 18, 6, 2], 'layer_pitches': [361, 109, 37, 13], 'level_spans': [1449, 441, 153, 57], 'level_offsets': [0, 1449, 1890, 2043], 'selected_pitch': 37, 'selected_header': 1955, 'layer_origin': 2034, 'payload_origin': 2035, 'allocation_end': 2165}), ({'w': 13, 'h': 6, 'b': 6, 'layers': 2, 'layer': 1, 'level': 3, 'base': 65}, {'dims': [[13, 6], [7, 3], [4, 2], [2, 1]], 'texel_counts': [78, 21, 8, 2], 'layer_pitches': [469, 127, 49, 13], 'level_spans': [943, 259, 103, 31], 'level_offsets': [0, 943, 1202, 1305], 'selected_pitch': 13, 'selected_header': 1370, 'layer_origin': 1388, 'payload_origin': 1389, 'allocation_end': 1401}), ({'w': 14, 'h': 7, 'b': 6, 'layers': 3, 'layer': 1, 'level': 0, 'base': 65}, {'dims': [[14, 7], [7, 4], [4, 2], [2, 1]], 'texel_counts': [98, 28, 8, 2], 'layer_pitches': [589, 169, 49, 13], 'level_spans': [1772, 512, 152, 44], 'level_offsets': [0, 1772, 2284, 2436], 'selected_pitch': 589, 'selected_header': 65, 'layer_origin': 659, 'payload_origin': 660, 'allocation_end': 2545}), ({'w': 15, 'h': 8, 'b': 6, 'layers': 4, 'layer': 1, 'level': 1, 'base': 65}, {'dims': [[15, 8], [8, 4], [4, 2], [2, 1]], 'texel_counts': [120, 32, 8, 2], 'layer_pitches': [721, 193, 49, 13], 'level_spans': [2889, 777, 201, 57], 'level_offsets': [0, 2889, 3666, 3867], 'selected_pitch': 193, 'selected_header': 2954, 'layer_origin': 3152, 'payload_origin': 3153, 'allocation_end': 3989})]}
for i, (p, expected) in enumerate(cases[N]):
    check("layout fixture " + str(i + 1), solve(p), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(p):
    p = dict(p)
    dims = [[max(1,(p["w"]+(1<<i)-1)//(1<<i)),max(1,(p["h"]+(1<<i)-1)//(1<<i))] for i in range(4)]
    texel_counts = [w*h for w,h in dims]
    layer_pitches = [t*p["b"]+1 for t in texel_counts]
    level_spans = [q*p["layers"]+5 for q in layer_pitches]
    level_offsets = [sum(level_spans[:i+1]) for i in range(4)]
    selected_pitch = layer_pitches[p["level"]]
    selected_header = p["base"]+level_offsets[p["level"]]
    layer_origin = selected_header+5+p["layer"]*selected_pitch
    payload_origin = layer_origin+1
    allocation_end = p["base"]+sum(level_spans)
    return {'dims': dims, 'texel_counts': texel_counts, 'layer_pitches': layer_pitches, 'level_spans': level_spans, 'level_offsets': level_offsets, 'selected_pitch': selected_pitch, 'selected_header': selected_header, 'layer_origin': layer_origin, 'payload_origin': payload_origin, 'allocation_end': allocation_end}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {1: [({'w': 6, 'h': 3, 'b': 2, 'layers': 2, 'layer': 0, 'level': 0, 'base': 13}, {'dims': [[6, 3], [3, 2], [2, 1], [1, 1]], 'texel_counts': [18, 6, 2, 1], 'layer_pitches': [37, 13, 5, 3], 'level_spans': [79, 31, 15, 11], 'level_offsets': [0, 79, 110, 125], 'selected_pitch': 37, 'selected_header': 13, 'layer_origin': 18, 'payload_origin': 19, 'allocation_end': 149}), ({'w': 7, 'h': 4, 'b': 2, 'layers': 3, 'layer': 1, 'level': 1, 'base': 13}, {'dims': [[7, 4], [4, 2], [2, 1], [1, 1]], 'texel_counts': [28, 8, 2, 1], 'layer_pitches': [57, 17, 5, 3], 'level_spans': [176, 56, 20, 14], 'level_offsets': [0, 176, 232, 252], 'selected_pitch': 17, 'selected_header': 189, 'layer_origin': 211, 'payload_origin': 212, 'allocation_end': 279}), ({'w': 8, 'h': 5, 'b': 2, 'layers': 4, 'layer': 2, 'level': 2, 'base': 13}, {'dims': [[8, 5], [4, 3], [2, 2], [1, 1]], 'texel_counts': [40, 12, 4, 1], 'layer_pitches': [81, 25, 9, 3], 'level_spans': [329, 105, 41, 17], 'level_offsets': [0, 329, 434, 475], 'selected_pitch': 9, 'selected_header': 447, 'layer_origin': 470, 'payload_origin': 471, 'allocation_end': 505}), ({'w': 9, 'h': 6, 'b': 2, 'layers': 2, 'layer': 1, 'level': 3, 'base': 13}, {'dims': [[9, 6], [5, 3], [3, 2], [2, 1]], 'texel_counts': [54, 15, 6, 2], 'layer_pitches': [109, 31, 13, 5], 'level_spans': [223, 67, 31, 15], 'level_offsets': [0, 223, 290, 321], 'selected_pitch': 5, 'selected_header': 334, 'layer_origin': 344, 'payload_origin': 345, 'allocation_end': 349}), ({'w': 10, 'h': 7, 'b': 2, 'layers': 3, 'layer': 1, 'level': 0, 'base': 13}, {'dims': [[10, 7], [5, 4], [3, 2], [2, 1]], 'texel_counts': [70, 20, 6, 2], 'layer_pitches': [141, 41, 13, 5], 'level_spans': [428, 128, 44, 20], 'level_offsets': [0, 428, 556, 600], 'selected_pitch': 141, 'selected_header': 13, 'layer_origin': 159, 'payload_origin': 160, 'allocation_end': 633}), ({'w': 11, 'h': 8, 'b': 2, 'layers': 4, 'layer': 1, 'level': 1, 'base': 13}, {'dims': [[11, 8], [6, 4], [3, 2], [2, 1]], 'texel_counts': [88, 24, 6, 2], 'layer_pitches': [177, 49, 13, 5], 'level_spans': [713, 201, 57, 25], 'level_offsets': [0, 713, 914, 971], 'selected_pitch': 49, 'selected_header': 726, 'layer_origin': 780, 'payload_origin': 781, 'allocation_end': 1009})], 2: [({'w': 7, 'h': 3, 'b': 3, 'layers': 2, 'layer': 0, 'level': 0, 'base': 26}, {'dims': [[7, 3], [4, 2], [2, 1], [1, 1]], 'texel_counts': [21, 8, 2, 1], 'layer_pitches': [64, 25, 7, 4], 'level_spans': [133, 55, 19, 13], 'level_offsets': [0, 133, 188, 207], 'selected_pitch': 64, 'selected_header': 26, 'layer_origin': 31, 'payload_origin': 32, 'allocation_end': 246}), ({'w': 8, 'h': 4, 'b': 3, 'layers': 3, 'layer': 1, 'level': 1, 'base': 26}, {'dims': [[8, 4], [4, 2], [2, 1], [1, 1]], 'texel_counts': [32, 8, 2, 1], 'layer_pitches': [97, 25, 7, 4], 'level_spans': [296, 80, 26, 17], 'level_offsets': [0, 296, 376, 402], 'selected_pitch': 25, 'selected_header': 322, 'layer_origin': 352, 'payload_origin': 353, 'allocation_end': 445}), ({'w': 9, 'h': 5, 'b': 3, 'layers': 4, 'layer': 2, 'level': 2, 'base': 26}, {'dims': [[9, 5], [5, 3], [3, 2], [2, 1]], 'texel_counts': [45, 15, 6, 2], 'layer_pitches': [136, 46, 19, 7], 'level_spans': [549, 189, 81, 33], 'level_offsets': [0, 549, 738, 819], 'selected_pitch': 19, 'selected_header': 764, 'layer_origin': 807, 'payload_origin': 808, 'allocation_end': 878}), ({'w': 10, 'h': 6, 'b': 3, 'layers': 2, 'layer': 1, 'level': 3, 'base': 26}, {'dims': [[10, 6], [5, 3], [3, 2], [2, 1]], 'texel_counts': [60, 15, 6, 2], 'layer_pitches': [181, 46, 19, 7], 'level_spans': [367, 97, 43, 19], 'level_offsets': [0, 367, 464, 507], 'selected_pitch': 7, 'selected_header': 533, 'layer_origin': 545, 'payload_origin': 546, 'allocation_end': 552}), ({'w': 11, 'h': 7, 'b': 3, 'layers': 3, 'layer': 1, 'level': 0, 'base': 26}, {'dims': [[11, 7], [6, 4], [3, 2], [2, 1]], 'texel_counts': [77, 24, 6, 2], 'layer_pitches': [232, 73, 19, 7], 'level_spans': [701, 224, 62, 26], 'level_offsets': [0, 701, 925, 987], 'selected_pitch': 232, 'selected_header': 26, 'layer_origin': 263, 'payload_origin': 264, 'allocation_end': 1039}), ({'w': 12, 'h': 8, 'b': 3, 'layers': 4, 'layer': 1, 'level': 1, 'base': 26}, {'dims': [[12, 8], [6, 4], [3, 2], [2, 1]], 'texel_counts': [96, 24, 6, 2], 'layer_pitches': [289, 73, 19, 7], 'level_spans': [1161, 297, 81, 33], 'level_offsets': [0, 1161, 1458, 1539], 'selected_pitch': 73, 'selected_header': 1187, 'layer_origin': 1265, 'payload_origin': 1266, 'allocation_end': 1598})], 3: [({'w': 8, 'h': 3, 'b': 4, 'layers': 2, 'layer': 0, 'level': 0, 'base': 39}, {'dims': [[8, 3], [4, 2], [2, 1], [1, 1]], 'texel_counts': [24, 8, 2, 1], 'layer_pitches': [97, 33, 9, 5], 'level_spans': [199, 71, 23, 15], 'level_offsets': [0, 199, 270, 293], 'selected_pitch': 97, 'selected_header': 39, 'layer_origin': 44, 'payload_origin': 45, 'allocation_end': 347}), ({'w': 9, 'h': 4, 'b': 4, 'layers': 3, 'layer': 1, 'level': 1, 'base': 39}, {'dims': [[9, 4], [5, 2], [3, 1], [2, 1]], 'texel_counts': [36, 10, 3, 2], 'layer_pitches': [145, 41, 13, 9], 'level_spans': [440, 128, 44, 32], 'level_offsets': [0, 440, 568, 612], 'selected_pitch': 41, 'selected_header': 479, 'layer_origin': 525, 'payload_origin': 526, 'allocation_end': 683}), ({'w': 10, 'h': 5, 'b': 4, 'layers': 4, 'layer': 2, 'level': 2, 'base': 39}, {'dims': [[10, 5], [5, 3], [3, 2], [2, 1]], 'texel_counts': [50, 15, 6, 2], 'layer_pitches': [201, 61, 25, 9], 'level_spans': [809, 249, 105, 41], 'level_offsets': [0, 809, 1058, 1163], 'selected_pitch': 25, 'selected_header': 1097, 'layer_origin': 1152, 'payload_origin': 1153, 'allocation_end': 1243}), ({'w': 11, 'h': 6, 'b': 4, 'layers': 2, 'layer': 1, 'level': 3, 'base': 39}, {'dims': [[11, 6], [6, 3], [3, 2], [2, 1]], 'texel_counts': [66, 18, 6, 2], 'layer_pitches': [265, 73, 25, 9], 'level_spans': [535, 151, 55, 23], 'level_offsets': [0, 535, 686, 741], 'selected_pitch': 9, 'selected_header': 780, 'layer_origin': 794, 'payload_origin': 795, 'allocation_end': 803}), ({'w': 12, 'h': 7, 'b': 4, 'layers': 3, 'layer': 1, 'level': 0, 'base': 39}, {'dims': [[12, 7], [6, 4], [3, 2], [2, 1]], 'texel_counts': [84, 24, 6, 2], 'layer_pitches': [337, 97, 25, 9], 'level_spans': [1016, 296, 80, 32], 'level_offsets': [0, 1016, 1312, 1392], 'selected_pitch': 337, 'selected_header': 39, 'layer_origin': 381, 'payload_origin': 382, 'allocation_end': 1463}), ({'w': 13, 'h': 8, 'b': 4, 'layers': 4, 'layer': 1, 'level': 1, 'base': 39}, {'dims': [[13, 8], [7, 4], [4, 2], [2, 1]], 'texel_counts': [104, 28, 8, 2], 'layer_pitches': [417, 113, 33, 9], 'level_spans': [1673, 457, 137, 41], 'level_offsets': [0, 1673, 2130, 2267], 'selected_pitch': 113, 'selected_header': 1712, 'layer_origin': 1830, 'payload_origin': 1831, 'allocation_end': 2347})], 4: [({'w': 9, 'h': 3, 'b': 5, 'layers': 2, 'layer': 0, 'level': 0, 'base': 52}, {'dims': [[9, 3], [5, 2], [3, 1], [2, 1]], 'texel_counts': [27, 10, 3, 2], 'layer_pitches': [136, 51, 16, 11], 'level_spans': [277, 107, 37, 27], 'level_offsets': [0, 277, 384, 421], 'selected_pitch': 136, 'selected_header': 52, 'layer_origin': 57, 'payload_origin': 58, 'allocation_end': 500}), ({'w': 10, 'h': 4, 'b': 5, 'layers': 3, 'layer': 1, 'level': 1, 'base': 52}, {'dims': [[10, 4], [5, 2], [3, 1], [2, 1]], 'texel_counts': [40, 10, 3, 2], 'layer_pitches': [201, 51, 16, 11], 'level_spans': [608, 158, 53, 38], 'level_offsets': [0, 608, 766, 819], 'selected_pitch': 51, 'selected_header': 660, 'layer_origin': 716, 'payload_origin': 717, 'allocation_end': 909}), ({'w': 11, 'h': 5, 'b': 5, 'layers': 4, 'layer': 2, 'level': 2, 'base': 52}, {'dims': [[11, 5], [6, 3], [3, 2], [2, 1]], 'texel_counts': [55, 18, 6, 2], 'layer_pitches': [276, 91, 31, 11], 'level_spans': [1109, 369, 129, 49], 'level_offsets': [0, 1109, 1478, 1607], 'selected_pitch': 31, 'selected_header': 1530, 'layer_origin': 1597, 'payload_origin': 1598, 'allocation_end': 1708}), ({'w': 12, 'h': 6, 'b': 5, 'layers': 2, 'layer': 1, 'level': 3, 'base': 52}, {'dims': [[12, 6], [6, 3], [3, 2], [2, 1]], 'texel_counts': [72, 18, 6, 2], 'layer_pitches': [361, 91, 31, 11], 'level_spans': [727, 187, 67, 27], 'level_offsets': [0, 727, 914, 981], 'selected_pitch': 11, 'selected_header': 1033, 'layer_origin': 1049, 'payload_origin': 1050, 'allocation_end': 1060}), ({'w': 13, 'h': 7, 'b': 5, 'layers': 3, 'layer': 1, 'level': 0, 'base': 52}, {'dims': [[13, 7], [7, 4], [4, 2], [2, 1]], 'texel_counts': [91, 28, 8, 2], 'layer_pitches': [456, 141, 41, 11], 'level_spans': [1373, 428, 128, 38], 'level_offsets': [0, 1373, 1801, 1929], 'selected_pitch': 456, 'selected_header': 52, 'layer_origin': 513, 'payload_origin': 514, 'allocation_end': 2019}), ({'w': 14, 'h': 8, 'b': 5, 'layers': 4, 'layer': 1, 'level': 1, 'base': 52}, {'dims': [[14, 8], [7, 4], [4, 2], [2, 1]], 'texel_counts': [112, 28, 8, 2], 'layer_pitches': [561, 141, 41, 11], 'level_spans': [2249, 569, 169, 49], 'level_offsets': [0, 2249, 2818, 2987], 'selected_pitch': 141, 'selected_header': 2301, 'layer_origin': 2447, 'payload_origin': 2448, 'allocation_end': 3088})], 5: [({'w': 10, 'h': 3, 'b': 6, 'layers': 2, 'layer': 0, 'level': 0, 'base': 65}, {'dims': [[10, 3], [5, 2], [3, 1], [2, 1]], 'texel_counts': [30, 10, 3, 2], 'layer_pitches': [181, 61, 19, 13], 'level_spans': [367, 127, 43, 31], 'level_offsets': [0, 367, 494, 537], 'selected_pitch': 181, 'selected_header': 65, 'layer_origin': 70, 'payload_origin': 71, 'allocation_end': 633}), ({'w': 11, 'h': 4, 'b': 6, 'layers': 3, 'layer': 1, 'level': 1, 'base': 65}, {'dims': [[11, 4], [6, 2], [3, 1], [2, 1]], 'texel_counts': [44, 12, 3, 2], 'layer_pitches': [265, 73, 19, 13], 'level_spans': [800, 224, 62, 44], 'level_offsets': [0, 800, 1024, 1086], 'selected_pitch': 73, 'selected_header': 865, 'layer_origin': 943, 'payload_origin': 944, 'allocation_end': 1195}), ({'w': 12, 'h': 5, 'b': 6, 'layers': 4, 'layer': 2, 'level': 2, 'base': 65}, {'dims': [[12, 5], [6, 3], [3, 2], [2, 1]], 'texel_counts': [60, 18, 6, 2], 'layer_pitches': [361, 109, 37, 13], 'level_spans': [1449, 441, 153, 57], 'level_offsets': [0, 1449, 1890, 2043], 'selected_pitch': 37, 'selected_header': 1955, 'layer_origin': 2034, 'payload_origin': 2035, 'allocation_end': 2165}), ({'w': 13, 'h': 6, 'b': 6, 'layers': 2, 'layer': 1, 'level': 3, 'base': 65}, {'dims': [[13, 6], [7, 3], [4, 2], [2, 1]], 'texel_counts': [78, 21, 8, 2], 'layer_pitches': [469, 127, 49, 13], 'level_spans': [943, 259, 103, 31], 'level_offsets': [0, 943, 1202, 1305], 'selected_pitch': 13, 'selected_header': 1370, 'layer_origin': 1388, 'payload_origin': 1389, 'allocation_end': 1401}), ({'w': 14, 'h': 7, 'b': 6, 'layers': 3, 'layer': 1, 'level': 0, 'base': 65}, {'dims': [[14, 7], [7, 4], [4, 2], [2, 1]], 'texel_counts': [98, 28, 8, 2], 'layer_pitches': [589, 169, 49, 13], 'level_spans': [1772, 512, 152, 44], 'level_offsets': [0, 1772, 2284, 2436], 'selected_pitch': 589, 'selected_header': 65, 'layer_origin': 659, 'payload_origin': 660, 'allocation_end': 2545}), ({'w': 15, 'h': 8, 'b': 6, 'layers': 4, 'layer': 1, 'level': 1, 'base': 65}, {'dims': [[15, 8], [8, 4], [4, 2], [2, 1]], 'texel_counts': [120, 32, 8, 2], 'layer_pitches': [721, 193, 49, 13], 'level_spans': [2889, 777, 201, 57], 'level_offsets': [0, 2889, 3666, 3867], 'selected_pitch': 193, 'selected_header': 2954, 'layer_origin': 3152, 'payload_origin': 3153, 'allocation_end': 3989})]}
for i, (p, expected) in enumerate(cases[N]):
    check("layout fixture " + str(i + 1), solve(p), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The returned physical layout descriptor disagrees with the declared buffer mapping at level_offsets.

Four ceil-halved mip levels each contain all array layers. Each layer owns a one-byte tag and tightly packed texels; level records add a five-byte header. Return the allocation directory and selected layer origin. Return the named intermediate layout descriptor and final address fields; all quantities are integer byte offsets unless explicitly stated.

split: open-access