Commit Graph
24 Commits
Author SHA1 Message Date
Anees Iqbal d13d23593b 🐎 Read a function's AIR without its bodies until asked
A new function's first read of its AIR module decoded the bodies of every
function of a module that declares function constants, which only a
pipeline's reflection, an OpenCL-mode function and constants set by name with
no function list to resolve them use. That decode is most of the read:
MPSNeuralNetwork's cnnConvArray took 391 us with it and 40 us without,
Espresso's dequantizeGeneric 54 and 17 (M3 Max, macOS 27), and Vision's first
newFunctionWithName: of an MPS kernel took 0.16 ms in the 26.7.2 guest where
the AMD 5300M takes 0.01 ms.

The module cache now keeps two reads of a module: its arguments and visible
functions alone, made at the first ask without the entry points and costing
its bytes, and the read with them, made at the first ask with them and costing
its code. A library's entry point that a pipeline's reflection asks for is so
read twice, once for each kind. Nothing the guest observes changes: the
arguments and visible functions are the readers' own answers either way, and
every library over equal bytes still shares one read of each kind.
2026-11-12 13:28:15 -08:00
Anees Iqbal d96a612b55 🐛 Check compute pipelines' threadgroup fields as Metal does
The bundle kept requiredThreadsPerThreadgroup guest-side and sent the host
none of it, so a compute pipeline whose required size is past its kernel's
[[max_total_threads_per_threadgroup(n)]] was made, where Metal's compile
refuses it. maxTotalThreadsPerThreadgroup against the kernel's attribute and
the device's limit went unchecked guest-side too, and macOS 27's
forwardProgressUsage and contentionRelief were taken whatever their value.

oracle_threads measured each case on the AMD 5300M, the Intel 630 and the
M3 Max (m3-max-22216, 22217, 22214; dgpu-oracle.md Q32). The AIR reader now
reads a kernel's attribute (air.max_work_group_size), and the bundle checks
the fields before it posts the create, in the x86 guest the AMD GPU's way
and in the arm64 guest the M3's, as its validation and compiler do.

What the guest observes: a required size with an axis of 0, past the
device's limit or past the descriptor's maximum ends the process at Metal's
failed assertion; a required size past the kernel's attribute, a descriptor
maximum other than the kernel's or past the device's limit, and a forward
progress usage or contention relief Metal does not name are refused with
the device's error, and nothing is posted; a pipeline of a required size
answers its threads as maxTotalThreadsPerThreadgroup; and forwardProgressUsage
Automatic answers Weak. The tests that held the old answers change with it.
2026-11-12 12:45:37 -08:00
Anees Iqbal 7ff8cfb02e 🐛 Reflect post-tessellation vertex functions' control points
A post-tessellation vertex function's control point input
(air.patch_control_point_input) takes two nodes the AIR reader did not
follow, its control point function's and its attributes', so the reader
gave up on the whole entry point and its pipelines got no reflection: a
creator asked for reflection answered nil where Metal answers one.

The reader now follows them, keeping each attribute of the control point,
and reads the entry's patch type (air.patch). The reflection answers what
the AMD 5300M, the Intel 630 and the M3 Max agree on, measured with
pipeline_reflection_check's patch cases (m3-max-22312, 22313, 22314): the
control points and the patch's attributes are no bindings, the vertex
descriptor's buffers are unused though the function reads them,
position_in_patch and patch_id are built-ins 14 and 13, and the dump stride
adds the patch's position, 12 bytes for a triangle and 8 for a quad, taken
or not. Two new probe functions (a triangle patch that takes no position,
and a quad that takes one it never reads) pin the last rule.

What the guest observes: those pipelines' reflection, where it got nil.
2026-11-12 12:45:37 -08:00
Anees Iqbal b64ad9b556 🐛 Read each entry point's nodes and visible function on its own
The bundle's AIR reader answered no entry point of a module, for a pipeline's
reflection and for OpenCL mode's bindings, where one entry point had a node it
does not follow (an argument's, a layout's, an output's or its work group
size's), and no visible function's signature where one visible function's node
was not of its form. A function constant whose node did not read did the same
to every entry point, and to every entry point's specialisation by its
constants. This is F10's class: 72503e9c5 fixed rgfxReadAirFunctions per
function.

Now each is its own answer. An entry point a node of which does not read is
listed with nodesRead false beside the others, and the library answers no
reflection for it alone ("a node of it is not one the reader follows"). A
visible function's node not of its form answers an unknown signature, so
Metal's own function answers that function's reflection, and the others keep
theirs. A function constant whose node does not read is left out of the
module's constants, so only a predicate that names it has no value, and in the
specialisation its global reads as any value while the others' values stand.
A layout that did not read from one entry point (past the depth the reader
follows) is no longer kept as unread for another that reaches it nearer.

What the guest sees: in a module of several entry points (an OpenCL C program,
Metal source compiled at run time) the other pipelines keep their reflection
and OpenCL-mode bindings where one entry point has a node the reader does not
follow. A post-tessellation vertex function is one: its control point input
(air.patch_control_point_input) takes two nodes no key the reader follows
takes, so tests/air_arguments.metal's whole module answered no entry point's
nodes, and now answers every one but reads_patch's. A .metallib of Apple's
tools holds one entry point a module, so its libraries answer as before.

The tests read the compiler's module of every entry point of
tests/air_arguments.metal, whole and with the key of each argument under a
function constant spoilt, a module the test writes (LLVM's bitstream,
unabbreviated records) of malformed nodes beside well-formed ones, and the
committed metallibs' entry points, the three of an explicit imageblock listed
with their nodes unread.
2026-11-12 05:35:38 -08:00
Anees Iqbal 72503e9c5d 🐛 Read OpenCL kernels' by-value arguments, each function on its own
The bundle's AIR argument reader did not know `air.constant`, the node Metal's
compiler writes for an OpenCL C kernel's argument passed by value (a scalar, a
vector, a struct or a union), bound at an `air.location_index` among the
buffers. It took the unknown binding as one that may be a texture, so the
kernel's arguments did not read, and functionsOf() then dropped every entry
point of the module. Nearly every OpenCL kernel takes a value, so the guest
logged "no arguments read (its module did not read)" for each of them, and
every texture with ShaderWrite usage it bound was taken as written: a cost in
surface writes, never a wrong result.

Now a by-value argument is read as a buffer at its index, of the access its
node names (none): every kernel of the audit's clprobe reads, k_buffers and
k_struct among them. And an entry point whose arguments do not read is listed
with `argumentsRead` false beside the module's other entry points, which keep
their own answers; the library logs "an argument of it is not one the reader
follows" for it alone.

Read from this Mac's compile of OpenCL C programs of our own (macOS 27.0.1,
the M3 Max), as LLVM's text form prints the modules. The tests read every
kernel of the CL mode tests' programs and of a new one of every value kind,
and a module of every entry point of tests/air_arguments.metal (the
compiler's .air) with one entry point spoilt.
2026-11-12 03:43:38 -08:00
Anees Iqbal 8c61d99be4 🐛 Read a buffer's address space from its parameter before macOS 13
The Metal compiler of macOS 11 and 12 writes no air.address_space on a
buffer argument, and neither does this Mac's compiler for a macOS 11 or 12
target (measured: 11.7.11's and 12.7.6's compiler in a guest, and Xcode
27.2's for macos-metal2.3 and 2.4). The reader then left every buffer of
such a module without an address space, and a pipeline's reflection of any
function with a buffer answered nil ("a buffer of no address space or
pointee"), so Metal apps that ask for reflection got none on 11 and 12.

An entry point's buffer node that names no address space now takes its
parameter's: the address space of the pointer at the node's position in
the function's type. Modules that name it are read as before.

The AIR test reads a library built at test time for macOS 11
(tests/air_arguments_11.metal): its device, constant and threadgroup
buffers each take their parameter's space, and its textures, samplers and
built-ins take none.
2026-11-11 06:32:24 -08:00
Anees Iqbal 57e2bcce59 🐎 Find a library's function and its bitcode by name in O(1)
After the AIR read cache (104f648f8), a library's lookup of a function's
module was mostly a walk of its .metallib's function list to the name:
1.39M instructions (73 us) a lookup on the M3, on average over macOS 27's
framework libraries, all of them cache hits (m3-max-2221). Libraries of many
functions (MPSImage's 1,837) pay O(n) per lookup, and finding a function's
table entry walked the table by name too.

The shared function table now indexes both when it is read, once per content
key: each function's entry by name, and its bitcode as rgfxMetallibBitcode
finds it (RgfxMetallibBitcodeIndex: the first function of a name answers, and
none past a group that does not read, as the walk). Bytes of another length
or header than those the index walked are walked as before.

Lookups find what they found before: the AIR test checks that the index
answers what rgfxMetallibBitcode answers for every name of its libraries, of
the committed metallibs and of 2,000 libraries with spoilt function lists.
Only when the list is walked changes, never what a lookup finds.
2026-11-05 21:59:36 -08:00
Anees Iqbal e4d8932355 🐛 Count a module's decoded code against the AIR cache's budget
Since 81618ace7 a cached module also holds its decoded code
(RgfxAirEntries::code) where it declares function constants. The cache
counted only the module's bytes against its 16 MiB, so its memory was no
longer bounded as the header said: decoded code grows with the function
bodies, not the metadata. Each kept module now costs its bytes plus what
its code's containers hold (rgfxAirModuleCost), and the budget bounds that
sum. Only which modules the cache keeps changes, never a read's answers.

The AIR test's whole-value comparison of one read with each reader did not
cover the fields 81618ace7 and 19ef218a6 added: a node's globals and render
target, an entry's function, and the code. It now compares them, the code by
what rgfxAirSpecialise answers for each entry point. The cache test budgets
by cost, and checks that every_access, which declares a constant, costs more
than its bytes.
2026-11-05 21:59:36 -08:00
Anees Iqbal fadd0bbb10 ✅ List only the imageblock entry points as unread in the AIR test
c14-air-cache's test of every committed metallib (1cb31349f) lists the entry
points whose nodes do not read, among them rounding.metallib's and
rounding_safe.metallib's three framebuffer-fetch fragments, whose `[[color(0)]]`
input (`air.render_target`) the node reader did not follow. c14-reflection
(19ef218a6) taught the reader that input, so on car 14 those six read, and the
test failed at the first (m3-max-2483: "rounding.metallib: fetch_half_fragment:
its nodes do not read"). The three explicit-imageblock kernels still do not
read, as c14-reflection's message says.

Car 14's stack: a test fix where c14-air-cache meets c14-reflection.
2026-11-05 21:59:36 -08:00
Anees Iqbal bf214206db ✅ Check specialised reflections against Metal's answers
The shell tests now make k_specialised and v_specialised under two sets
of constant values and expect what the 5300M and the 630 answer: an
index kIndex + 1 computes, an argument under kOn || kOff kept or left
out, and which arguments a switch, a select and an optional constant
leave used. air_arguments_test checks rgfxAirSpecialise directly (the
arguments used, the globals the initialisers leave, no values given),
and specialises 4000 spoilt copies of k_specialised's module without a
crash or a hang.
2026-11-05 21:59:36 -08:00
Anees Iqbal 0932f1cd0c 🐛 Reflect nested argument buffers, tables and colour reads
A pipeline's reflection answered nil where a function had an argument
buffer of a struct of members, a C array of members, an array of
samplers or a pointer to an argument buffer of its own, a function table
or an acceleration structure, a texture of 64-bit atomics, or a fragment
function that reads its colour attachments: the AIR reader refused the
fragment node, and the reflection had no answer measured for the others.

Each now answers what Metal answers on the x86 Macs (measured on the
5300M and the 630 with tools/pipeline_reflection_check, every getter and
instance variable alike):
- a struct of members is a struct of its own argument buffer members,
  at ids from its first, a C array of them an argument buffer array of
  the ids an element takes as its index stride;
- a C array of a member is an argument buffer array whose details are
  the element's binding, of a constant's size's stride;
- a metal::array of samplers is an array of index stride 1, as textures';
- a pointer to an argument buffer is a pointer member of its binding;
- function tables and acceleration structures are bindings of their
  own types, read only, as kernel and fragment arguments and as an
  argument buffer's members;
- a texture of ulong is of MTLDataTypeULong (the 630's answer; the 5300M
  makes no pipeline of one, nor of a fragment table);
- a fragment function's colour attachment reads are listed nowhere.

For the guest: those pipelines now answer a reflection where they
answered nil. An imageblock still answers nil: neither x86 Mac makes a
pipeline of one.
2026-11-05 21:59:36 -08:00
Anees Iqbal dff5d2d43a 🐎 Read each AIR module once a process, for every library
A library read a function's AIR module once for each kind it asked for (the
arguments, a visible function's signature, the nodes a pipeline's reflection
reads), and every library object over the same bytes read it again. The
c13-answers probe measured 20.6 us a read on average over macOS 27's
frameworks (m3-max-1379).

Now one read of a module gives all three answers (rgfxReadAirModule), and
the process keeps its reads by the module's bytes (RgfxAirModuleCache), so a
second library over equal bytes, or another kind of lookup, reads nothing
again. The cache's key is a copy of the bytes, compared whole, so equal
reads always come from equal bytes. It keeps the most recently looked-up
modules while their bytes total 16 MiB, and reads one it let go again.

A function's answers are a function of its module's bytes alone, so the
cache changes when a library's answers are produced, never the answers
themselves: the AIR test checks that one read answers what each reader
answers, for every module of its libraries. Libraries over equal bytes now
share one object per function's arguments and signature (the shell test).
2026-11-05 21:59:36 -08:00
Anees Iqbal b840c3f7f3 ✅ Read every function of the committed metallibs in the AIR test
The ledger listed 8 committed metallibs whose functions the AIR argument
reader did not read. At b4aff9c7f it reads them all: Core Image's kernels
(TYPE 5) get no read at all, the linked, stitchable and stitched libraries'
visible functions are read by the signature reader, and kernel_trunc.metallib
is cut to 1000 bytes on purpose, so its function has no bitcode. The AIR test
now runs the readers over every committed metallib (the suite's fixtures and
the Vulkan platform's), and checks that each function is found by the read
the device makes for its kind.

Nine entry points' nodes do not read. Each has a framebuffer-fetch input or
an explicit imageblock, and their pipelines answer no reflection. The test
lists them, so a new miss, or a fix for these, shows up.
2026-11-05 21:59:36 -08:00
Anees Iqbal b978f7b6f7 🆕 Read an entry point's AIR nodes whole
The pipelines' reflection needs more of each entry point than its argument
list: every node's kind, index, access, type, size and alignment, a struct's
members with their offsets, arrays and argument buffer details, the function
constant a node is gated on, a vertex or mesh function's outputs and a mesh's
vertex and primitive data. rgfxReadAirEntries reads them, and refuses a
module it does not follow. air_arguments_test checks it over the oracle
probe's library (build/oracle_reflection.metallib, which `make test` now
builds), and spoils its bytes 4000 times to check it fails cleanly.

Car 13's stack: resolved against c13-answers' function-constant reader
(69d1cd068, f59eeb440): RgfxAirArguments.cpp keeps both readers, the constants
(constantType, readConstants) and this commit's whole nodes, which take a
function_constant predicate's name from the constant's node at operand 2 as
readConstants does; the Makefile builds both test libraries (AIR_OLD_LIB,
ORACLE_REFLECTION_LIB) and links the AIR test with RgfxFunctionConstants.o;
air_arguments_test's header names both.
2026-11-05 21:59:34 -08:00
Anees Iqbal c5f268c638 🐎 Read macOS 10.12's AIR modules, of LLVM 3.5's metadata nodes
A .metallib built for macOS 10.12 (-std=macos-metal1.2, the language its
function constants came with) holds AIR modules in LLVM 3.5's metadata form:
each node a METADATA_NODE of code 8 whose operands are pairs of a type and a
value, a metadata's number where the type is metadata and a value in place of
a METADATA_VALUE otherwise, and each string a record of its own. The reader
took code 8 for a record of no node, so not one entry point of such a module
read (measured: Apple metal 32023.922, every entry point of a library built
from our sources for 10.12, and none of one built for 10.13), and each took
every texture whose usage has ShaderWrite as written.

The reader now reads the module's type table for its metadata and void types
and takes those nodes so, the values held beside the numbered metadata. Its
test reads a library built for 10.12 from tests/air_arguments_old.metal: each
entry point's arguments, and its constants as its CNST tag lists them.

The guest sees no other answer: textures such modules' functions only read or
sample are no longer taken as written.
2026-11-05 21:59:34 -08:00
Anees Iqbal df0a868146 🐎 Read binding counts constants set, and patch inputs, from AIR
Of the 29,273 entry points of macOS 27's frameworks' .metallibs on the M3 Max,
the AIR reader followed all but 710, and a function it does not follow takes
every texture whose usage has ShaderWrite as written. 709 bind an array_ref
of textures or buffers whose length is an expression of function constants (a
global variable in place of the count's integer, as for an index; Metal
Performance Shaders' kernels among them), and one is a post-tessellation
vertex function with a patch input (air.patch_input), a stage input of no
texture.

Such a count now reads as an argument of every index from its first
(anyCount), and a patch input as a binding of no texture: the reader follows
all 29,273. The guest sees no other answer: textures those kernels only read
or sample are no longer taken as written, which spares their surfaces'
write-backs.
2026-11-05 21:59:34 -08:00
Anees Iqbal 29dd60bfb9 🆕 Read each module's function constants from its AIR
A .metallib names a function's constants in its public metadata (the CNST
tag), and the bundle had nothing else to read them from: a function whose
metadata names none took every value set for it as set for nothing.

Each module lists its constants in the named metadata air.function_constants:
the global the value is read from, the type's name, the constant's name and
its index. The AIR reader now reads them beside the arguments and signatures,
into RgfxAirFunction and RgfxAirVisible. A constant is required where its
global is unnamed_addr; one the function tests with
is_function_constant_defined has its address taken and is not. Measured over
the 46,563 functions of macOS 27's frameworks' .metallibs on the M3 Max: each
of the 6,615 with constants lists the same names, indices and types in its
module as in its CNST tag, the 25,275 unnamed_addr ones required and none of
the 7,108 others, and no function without a CNST tag declares any.

The reader's test compares every function of its library with its CNST tag,
over a new kernel of five constants (vectors, and one tested for) and a
visible function of one.
2026-11-05 21:59:34 -08:00
Anees Iqbal 0270c31aea 🐛 Read every type kind a stitchable signature can carry
Core Image's CIKL general kernels take their sampler as a struct with a
reference field, a type kind the AIR reader did not know: such a kernel's
signature read as unknown, and its reflection fell back to Metal's own
function, which has none on our device, so Core Image made no kernel.

The reader now knows every kind Metal compiles into a stitchable signature:
lvalue and rvalue references (read as pointers), void pointees, bfloat and
its vectors, enums, visible and intersection function tables, acceleration
structures, atomics whose struct has no fields, each type's address space,
and unnamed arguments. The builder answers them as Metal's own compiler
does, measured on our own stitchable functions (tests/air_arguments.metal)
on an M3 Max on macOS 27 and an AMD Radeon Pro 5300M on macOS 26.7.1:
enums and tables are of no data type, a pointer is sized by its innermost
pointee and not at all for opaque ones, a pointed-to texture takes its
address space as its access, and a field's pointer to a pointer is
described by its pointee's pointee. A signature that holds an acceleration
structure gets no reflection: Metal's own ends the process on it, and
Metal's own function on our device answers nil.

reflection_check compares a refused signature with Metal's own answer,
asked in a process of its own; it reports 0 differences on both devices
over the test library and Core Image's own libraries.
2026-11-05 21:59:21 -08:00
Anees Iqbal d742ad11d2 🆕 Read stitchable functions' signatures from their AIR
A stitchable function's reflection (its -returnType, -arguments and
-bindings) is what Core Image reads to make a kernel of it. Metal makes it
with the device's compiler, which our device does not have, so on our device
it is nil and Core Image's CIKL kernels fail to build (the sweep's
ci.kernel.color and ci.kernel.warp).

The function's AIR module carries the signature: `air.visible` lists each
visible function, and a stitchable one's node ends in `air.stitching_info`,
the return's type and each argument's type and name. rgfxReadAirVisible reads
it into a tree of types: scalars, vectors (packed ones too), matrices, arrays
of C's and metal::arrays, structs with their fields' names and offsets,
pointers, textures of each shape and access, and samplers. A type node of a
kind it does not know makes that function's signature unknown, beside the
rest of the module, so its answer is left to Metal. The module reading is
shared with rgfxReadAirFunctions.

tests/air_arguments.metal gains stitchable functions of every kind of type,
and air_arguments_test checks each signature type by type, an unknown one,
and 4000 spoilt modules. Its library grows from 55 KB to 136 KB, so the shell
test that streams it gets a ring it fits.

Checks: make -C guest/bundle test (serializer, AIR reader 184 checks, shell
tests, base-class check) on the M3 Max.
2026-11-05 21:59:21 -08:00
Anees Iqbal 75dd9638ce 🎨 Keep threadgroup memory out of the AIR reader's buffer arguments
Threadgroup memory ([[threadgroup(n)]]) is an air.buffer of address space 3
in AIR, at an index of its own that no buffer is bound to. The reader took it
for a read-write buffer at that index, beside any device buffer bound there.
Nothing consults a buffer argument's access today (every bound buffer over
app memory is taken as written), so this changes no write-back; the reader's
answer is now true for any later use of it.

The reader test's new kernel holds threadgroup memory at 0 beside a device
buffer at 0 it only reads: one buffer argument at 0, read.
2026-11-05 21:59:21 -08:00
Anees Iqbal f5586a1223 🐛 Read binding indices set by function constants, and stage inputs
Since bfc3eaaef the AIR reader gives up on a whole module where it cannot
follow an argument, which is right, but two shapes our own compiler makes
stopped it:
- a binding index that is an expression of function constants
  ([[texture(kPlane)]]): AIR names a global variable, which the module's
  initialiser sets, in place of the integer index. ImageIO's HEIC decode
  converts its planes with kernels that bind textures so;
- a compute kernel's [[stage_in]] (air.stage_in), an attribute of the stage
  input descriptor, which no list of the reader's named.

For the user: the decode's pixels were right, as an unread function takes
every bound texture whose usage has ShaderWrite for written, but those
kernels' modules did not read, and the bundle logged "no arguments read"
once per library. The decode makes a library for nearly every dispatch: 332
lines in one decode of three desktop pictures (msi, RTX 5080), and lines from
Spotlight, the Dock, Notification Center and others.

Now an argument whose index constants set is read as one at any index: a
texture there that the function may write makes each bound texture whose
usage has ShaderWrite or is unknown written, as for unread arguments, but for
that function alone; one it only reads adds nothing. A kernel's stage input
binds no texture. The line is logged once a function name per process.

Our own kernels for both shapes in tests/air_arguments.metal; the shell tests
check the usage rule for a write at any index, and that two libraries of one
unread module log once.
2026-11-05 21:59:21 -08:00
Anees Iqbal d8cb9ac0a0 🐛 Take a surface for written wherever its writes cannot be ruled out
The AIR argument reader skipped every argument declared under a function
constant: Apple's compiler puts air.function_constant and the constant's node
ahead of such an argument's kind, and the reader took that for a built-in. A
function's conditional textures were then missing from its arguments, so a
draw or dispatch writing one never named its surface written, and the
surface's copy was not written back nor its CPU locks made to wait. A
GPU-written surface could stay stale in its pages. ImageIO's HEIC decode came
out black: with a Metal device, a decode kernel declaring its textures under
function constants converts the picture's planes into a surface the decoder
then reads on the CPU, and its pages kept their zeros.

Narrowing the writes may only drop one the function cannot make, so every
gap now falls back to written:
- an argument under a function constant is the function's whatever the
  constant's value;
- a binding of a kind the reader does not know makes the function's
  arguments unknown, rather than being skipped. Stage input attributes,
  function tables and acceleration structures are named, as bindings of no
  texture;
- where the arguments are unknown, a bound texture of unknown usage counts as
  written, as one with ShaderWrite usage did;
- a surface used without Write usage counts as written at a draw or dispatch
  whose function's arguments are unknown or whose argument buffer may write a
  texture, and a buffer over app memory used so at one with any argument
  buffer. Metal's docs make useResource's usage the app's promise, but a
  discrete Mac's driver lands the write whatever was declared, so an app that
  writes through an argument buffer with Read usage works on real Macs: the
  conservative pick of a loose rule.
Heaps hold no IOSurface texture, so useHeap names none.

The reader's test reads a kernel of the decode's shape from our own shader:
four read buffers, two read textures and a written one and a buffer under
function constants. The shell tests cover unknown usage, residency under
argument buffers by stage, and a resident buffer over app memory.
2026-11-05 21:59:21 -08:00
Anees Iqbal 9341d8e075 🐛 Read a universal library's arguments from its AIR slice
The device makes a library from a universal .metallib's AIR slice, but the
library keeps the whole file for its shadow, and the argument reader looked
for a .metallib's header there. Every function of such a library, QuartzCore's
default.metallib among them, read no arguments, so WindowServer's textures
went by their ShaderWrite usage again (boot C3: 13 functions).

The slice selection moves to RgfxAirArguments (rgfxMetallibAirSlice), which
the device's library maker and the reader now share, and the log line says
why a function's arguments did not read.
2026-11-05 21:59:20 -08:00
Anees Iqbal 3133714a17 🆕 Read each entry point's binding arguments from its AIR module
The host gives the guest's device no binding reflection, so the bundle
cannot tell which texture bindings a function writes: it takes ShaderWrite
usage for a write, and a CPU lock of a surface a kernel only reads then
waits for that read, which no x86 Mac's Metal does.

A .metallib carries each function's AIR module, whose metadata lists every
entry point's binding arguments with their kind, index, count and access.
RgfxAirArguments reads them: a small LLVM bitstream reader over the blocks
that hold them (globals, string table, constants, metadata), skipping every
other block whole, and answering nothing for what it cannot follow. Its
test reads a .metallib Apple's compiler builds at test time from our own
tests/air_arguments.metal, nothing committed, and spoils the module 4000
ways without a crash.
2026-11-05 21:59:20 -08:00