One commit of the 247 on development-fast (720ef1ce9a..9f46fdf80d), squashed at the user's request. Translator: - Tessellation on a device without tessellationShader: Metal's tessellator emitted as SPIR-V, a one-workgroup scan placing each patch's triangles in Metal's order, and the post-tessellation function as a plain vertex stage (EmulatedTessellationDraws; SEMANTICS 1739, ARTIFACT_FORMAT 419). - [[primitive_id]] on a device without geometry or tessellation shaders, as a flat varying the vertex function writes; indexed lists, lines and points drawn de-indexed (RuntimeGap::PrimitiveIdIndices). - Fragment functions of more colors than the device draws at once, compiled in color groups (PrecisionNote::ColorAttachmentGroups). - Object functions' threadgroup memory from the render encoder; a kernel's mesh draws from an indirect command buffer; mesh payload sizing. - The Vulkan 1.2 floor profile (vk12-floor) and the gates it needs; Metal 27.0.1 answers as the M3 Max. - Overflow tests in the runtime-built modules by the product's high word (NVIDIA's compiler fails the division form), guarded crate-wide by tests::owned_divisions. Runtime: - Color-group passes replayed per group over twin depth/stencil; snapshot and copy-back cost cuts. - Command buffers finish on the queue waiter that saw them; the waiter holds no device handle, so a program's drop after its wait is the device's last. - Every object an encoder was handed held until its command buffer completes; deallocator order and announcements. - Driver defects recorded and announced: ANV counts a visibility sample once per color output (visibility-count-per-color); MoltenVK fails pending work when memory that held a device-address buffer is freed, so freed memory waits for the work in flight (host-deallocator-delayed). - RenderCommandEncoder::set_object_threadgroup_memory_length; Visibility::counting(). Validation: mesh tooling (object, mesh and ICB-mesh cases on both executors), the authoring census closed, the queue storm judged in Metal's unit, load-robust exits and indirect-census bounds, and the golden hashes, printouts, fixture inventory and authored compile census blessed. Docs: FAST-PATHS.md trimmed to a ledger of what is true now; API.md's catalogue and accepted differences, REFUSALS.md and METAL-COVERAGE.md current. Verified on development-fast before the squash: the full suites on the RTX 5080, RTX 3090, RX 7900 XTX, Radeon 780M, Iris Xe, lavapipe and the M3 (MoltenVK and the Metal oracle), lint in every configuration, rustdoc, doc tests, packaging and public case qualification; the timing and teardown lanes x5 on every venue; the authoring-capability census 16656/16656 with 0 unresolved, the vk12-floor translation census at 6139 translated with the slowest row 794 ms and peak 126 MiB. The tree is development-fast's at 9f46fdf80d.
253 lines
11 KiB
Python
253 lines
11 KiB
Python
#!/usr/bin/env python3
|
|
"""Write docs/METAL-COVERAGE.md from coverage.tsv, the Metal API coverage map.
|
|
|
|
coverage.tsv has one row per public item of the macOS SDK's Metal headers (names only, as
|
|
`sdk_items.py` lists them): its header, container, kind, name, whether macOS deprecates it, and
|
|
our classification:
|
|
|
|
- status `I` (implemented): `crate` (runtime or translator) and `counterpart` name the item that
|
|
answers it, `Type::method` or `Type.field` (or a type);
|
|
- status `M` (missing): `note` says what it would take, `size` is S, M, L or XL, and `group`
|
|
gathers items built together;
|
|
- status `O` (out of scope): `note` says why (ray tracing, macOS-only services, IOSurface
|
|
and presentation, which are the consumer's).
|
|
|
|
Usage:
|
|
coverage.py write docs/METAL-COVERAGE.md
|
|
coverage.py --check fail if docs/METAL-COVERAGE.md is not what the table writes
|
|
coverage.py --sdk (Mac only) fail if the SDK's names differ from the table's
|
|
"""
|
|
import subprocess
|
|
import sys
|
|
from collections import Counter, OrderedDict, defaultdict
|
|
from pathlib import Path
|
|
|
|
HERE = Path(__file__).resolve().parent
|
|
ROOT = HERE.parent.parent
|
|
TABLE = HERE / "coverage.tsv"
|
|
DOC = ROOT / "docs" / "METAL-COVERAGE.md"
|
|
SDK = "macOS 27.0 SDK (Xcode 27.0, 27A266a)"
|
|
|
|
STATUS = OrderedDict([("I", "implemented"), ("M", "missing"), ("O", "out of scope")])
|
|
SIZES = ["S", "M", "L", "XL"]
|
|
|
|
# Missing groups in the order we would build them: cheap items plain apps call first, then the
|
|
# medium pieces by how often a plain app reaches them, then the large API families. A missing
|
|
# call cannot answer wrongly (it does not exist); calls that exist and refuse are in
|
|
# REFUSALS.md.
|
|
ORDER = [
|
|
"labels", "cmdbuf", "queue", "passdesc", "library", "queries", "barriers", "reflection",
|
|
"function-handles", "functions", "archive", "events", "visibility", "mesh-descriptor", "sparse",
|
|
"parallel", "icb-depth-stencil", "lod-bias", "depthbounds", "min-lod", "specialization",
|
|
"sparsebuf", "counters", "residency", "colormap", "viewpool", "logging", "notifications",
|
|
"compression", "capture", "persistent", "shadervalidation", "stitching", "io", "tensor",
|
|
"mtl4", "ml", "access-counters",
|
|
]
|
|
|
|
GROUP_NAMES = {
|
|
"labels": "labels, debug groups and signposts",
|
|
"cmdbuf": "command buffer options (descriptor, unretained references, `enqueue`, encoder error status)",
|
|
"queue": "command queue descriptor",
|
|
"passdesc": "compute, blit and resource-state pass descriptors",
|
|
"library": "libraries from a file path or URL",
|
|
"queries": "device, state and resource queries",
|
|
"barriers": "`textureBarrier` and queue-stage barriers",
|
|
"reflection": "a pipeline state's reflection after creation",
|
|
"function-handles": "function handles by name, and a handle's type and ID",
|
|
"functions": "a specialized function's name",
|
|
"archive": "more binary archive entries",
|
|
"events": "the shared event listener",
|
|
"visibility": "accumulated visibility results",
|
|
"mesh-descriptor": "mesh pipeline descriptor fields",
|
|
"sparse": "placement sparse page sizes",
|
|
"parallel": "parallel render encoding",
|
|
"icb-depth-stencil": "depth/stencil states in argument buffers",
|
|
"lod-bias": "a sampler's LOD bias",
|
|
"depthbounds": "depth bounds",
|
|
"min-lod": "a texture's minimum LOD (macOS 27)",
|
|
"specialization": "pipeline specialization (macOS 26)",
|
|
"sparsebuf": "placement sparse buffers",
|
|
"counters": "counter sample buffers",
|
|
"residency": "residency sets",
|
|
"colormap": "color attachment mapping",
|
|
"viewpool": "texture view pools",
|
|
"logging": "shader logging",
|
|
"notifications": "device hot-plug notifications",
|
|
"compression": "lossy texture compression",
|
|
"capture": "GPU capture",
|
|
"persistent": "persistent kernels (macOS 27)",
|
|
"shadervalidation": "shader validation",
|
|
"stitching": "function stitching",
|
|
"io": "fast resource loading (`MTLIOCommandQueue`)",
|
|
"tensor": "tensors",
|
|
"mtl4": "Metal 4's command model",
|
|
"ml": "machine learning encoding",
|
|
"access-counters": "texture access counters (not scheduled)",
|
|
}
|
|
|
|
|
|
def rows():
|
|
lines = TABLE.read_text().splitlines()
|
|
head = lines[0].split("\t")
|
|
out = []
|
|
for line in lines[1:]:
|
|
f = line.split("\t")
|
|
if len(f) != len(head):
|
|
sys.exit(f"coverage.tsv: {len(f)} fields, not {len(head)}: {line[:80]}")
|
|
out.append(dict(zip(head, f)))
|
|
return out
|
|
|
|
|
|
def check_rows(table):
|
|
bad = []
|
|
for r in table:
|
|
what = f"{r['container']} {r['name']}"
|
|
if r["status"] not in STATUS:
|
|
bad.append(f"{what}: status {r['status']!r}")
|
|
elif r["status"] == "I" and not (r["crate"] in ("runtime", "translator") and r["counterpart"]):
|
|
bad.append(f"{what}: implemented without a crate and counterpart")
|
|
elif r["status"] == "M" and r["size"] not in SIZES:
|
|
bad.append(f"{what}: missing without a size")
|
|
elif r["status"] in "MO" and not r["note"]:
|
|
bad.append(f"{what}: no note")
|
|
if r["status"] == "M" and r["group"] not in GROUP_NAMES:
|
|
bad.append(f"{what}: group {r['group']!r} has no name")
|
|
if bad:
|
|
sys.exit("coverage.tsv:\n " + "\n ".join(bad))
|
|
|
|
|
|
def label(r):
|
|
"""An item's name, a member's with its container."""
|
|
if r["kind"] in ("protocol", "class", "category", "function"):
|
|
return r["name"]
|
|
return f"{r['container']}.{r['name']}"
|
|
|
|
|
|
def cell(s):
|
|
return s.replace("|", "\\|")
|
|
|
|
|
|
def render(table):
|
|
out = []
|
|
w = out.append
|
|
total = Counter(r["status"] for r in table)
|
|
crates = Counter(r["crate"] for r in table if r["status"] == "I")
|
|
sizes = Counter(r["size"] for r in table if r["status"] == "M")
|
|
w("# Metal API coverage")
|
|
w("")
|
|
w(
|
|
f"Every public item of the {SDK}'s Metal headers, by name, and what answers it: the "
|
|
"runtime (`metal2vulkan-runtime`, the Metal API on Vulkan) or the translator's plain values "
|
|
"(`metal2vulkan`: pipeline descriptors, reflection, function constants), or nothing yet. "
|
|
"Generated by `scripts/metal-coverage/coverage.py` from `scripts/metal-coverage/coverage.tsv` "
|
|
"(edit the table, never this file); `coverage.py --sdk` checks the table's names against "
|
|
"the SDK on a Mac, and `crates/metal2vulkan-validation/tests/integration/metal_coverage.rs` checks that every counterpart "
|
|
"the table names exists in the sources."
|
|
)
|
|
w("")
|
|
w("- **implemented**: the counterpart answers it. A call can still refuse some inputs, which "
|
|
"[`REFUSALS.md`](REFUSALS.md) lists with the device conditions; the counterpart's Rustdoc says "
|
|
"what differs.")
|
|
w("- **missing**: no counterpart yet; the size is the work to build it (S: a day or less, M: "
|
|
"days, L: a week or more, XL: a new subsystem). A missing call cannot answer wrongly: a "
|
|
"program that needs it does not build.")
|
|
w("- **out of scope**: ray tracing, multi-GPU and macOS-only services, IOSurface, drawables "
|
|
"and source compiles, which the consumer owns, and items macOS does not offer.")
|
|
w("")
|
|
w("## Totals")
|
|
w("")
|
|
w("| Status | Items | Of which deprecated |")
|
|
w("|---|---|---|")
|
|
for s, name in STATUS.items():
|
|
dep = sum(1 for r in table if r["status"] == s and r["deprecated"])
|
|
w(f"| {name} | {total[s]} | {dep} |")
|
|
w(f"| all | {len(table)} | {sum(1 for r in table if r['deprecated'])} |")
|
|
w("")
|
|
w(f"Implemented by the runtime: {crates['runtime']}; by the translator's values: "
|
|
f"{crates['translator']}. Missing by size: " +
|
|
", ".join(f"{s} {sizes[s]}" for s in SIZES if sizes[s]) + ".")
|
|
w("")
|
|
w("## Missing, in build order")
|
|
w("")
|
|
w("Cheap items a plain app calls first, then medium pieces by how often a plain app reaches "
|
|
"them, then the large API families.")
|
|
w("")
|
|
w("| Group | Size | Items | Examples |")
|
|
w("|---|---|---|---|")
|
|
groups = defaultdict(list)
|
|
for r in table:
|
|
if r["status"] == "M":
|
|
groups[r["group"]].append(r)
|
|
for g in sorted(groups, key=lambda g: (ORDER.index(g) if g in ORDER else len(ORDER), g)):
|
|
items = groups[g]
|
|
size = "/".join(s for s in SIZES if any(r["size"] == s for r in items))
|
|
ex = ", ".join(f"`{label(r)}`" for r in items[:3])
|
|
if len(items) > 3:
|
|
ex += ", ..."
|
|
w(f"| {cell(GROUP_NAMES[g])} | {size} | {len(items)} | {cell(ex)} |")
|
|
w("")
|
|
w("## By header")
|
|
w("")
|
|
by_header = OrderedDict()
|
|
for r in table:
|
|
by_header.setdefault(r["header"], OrderedDict()).setdefault(r["container"], []).append(r)
|
|
for header, containers in by_header.items():
|
|
w(f"### {header}")
|
|
w("")
|
|
w("| Item | Kind | Status | Counterpart or note |")
|
|
w("|---|---|---|---|")
|
|
for container, items in containers.items():
|
|
for r in items:
|
|
name = label(r)
|
|
dep = " (deprecated)" if r["deprecated"] else ""
|
|
if r["status"] == "I":
|
|
crate = "runtime" if r["crate"] == "runtime" else "translator"
|
|
what = f"`{r['counterpart']}` ({crate})"
|
|
if r["note"]:
|
|
what += f": {r['note']}"
|
|
elif r["status"] == "M":
|
|
what = f"{r['size']}: {r['note']}"
|
|
else:
|
|
what = r["note"]
|
|
w(f"| `{cell(name)}`{dep} | {r['kind']} | {STATUS[r['status']]} | {cell(what)} |")
|
|
w("")
|
|
return "\n".join(out)
|
|
|
|
|
|
def sdk_check(table):
|
|
sys.path.insert(0, str(HERE))
|
|
import sdk_items
|
|
|
|
sdk = {(it[1], it[2], it[3]) for it in sdk_items.items()}
|
|
have = {(r["container"], r["kind"], r["name"]) for r in table}
|
|
new = sorted(sdk - have)
|
|
gone = sorted(have - sdk)
|
|
for c, k, n in new:
|
|
print(f"in the SDK, not the table: {c} {k} {n}")
|
|
for c, k, n in gone:
|
|
print(f"in the table, not the SDK: {c} {k} {n}")
|
|
if new or gone:
|
|
sys.exit(f"coverage.tsv differs from the SDK: {len(new)} new, {len(gone)} gone")
|
|
print(f"coverage.tsv names every SDK item ({len(sdk)})")
|
|
|
|
|
|
def main():
|
|
table = rows()
|
|
check_rows(table)
|
|
if "--sdk" in sys.argv:
|
|
sdk_check(table)
|
|
return
|
|
text = render(table) + "\n"
|
|
if "--check" in sys.argv:
|
|
if DOC.read_text() != text:
|
|
sys.exit("docs/METAL-COVERAGE.md is not what coverage.tsv writes: run coverage.py")
|
|
print("docs/METAL-COVERAGE.md is current")
|
|
return
|
|
DOC.write_text(text)
|
|
t = Counter(r["status"] for r in table)
|
|
print(f"wrote {DOC.relative_to(ROOT)}: " + ", ".join(f"{STATUS[s]} {t[s]}" for s in STATUS))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|