The renderer makes a tessellated draw's vertex and control shaders one kernel
that takes the draw's vertices as a patch control point input, and makes its
compute pipeline under a stage input descriptor. Metal compiles that input in
no kernel (m3-max-30197): its own devices define the input's control point
function from the descriptor. The device's pipeline of the kernel was refused,
and the renderer drew the draw's vertex and control stages in software.
A kernel variant with the input now keeps its module's text, and its compute
pipeline is made of the kernel made one without the input under the
pipeline's descriptor, once per descriptor: a wrapper kernel of the same name
takes the buffers the fields read and the stage input region's origin, and
the control point function, defined in place of its declaration, fetches each
field as Metal's [[stage_in]] fetch does. The pipeline answers the variant's
reflection. GL tessellated draws run on the GPU where the renderer drew them
in software.
The fetch matches the M3 Max's own [[stage_in]] kernels bit for bit, for every
attribute format and step function (gl_tests' stage input oracle,
m3-max-30314), which measured two of its conversions: Int1010102Normalized's
10-bit components are c times the float nearest 1/511, and RG11B10Float's
NaNs are 0x7fc00000.
94b38e703 took a GL kernel's inputs through the lowering's input rules, and
said the tessellated draw's kernel had the generator's bare attribute name
in its argument 0. It does, but one level down. The kernel the renderer
makes of a tessellated draw's vertex and control shaders takes the draw's
vertices as a patch control point input, and the bare name is in that
input's field node. The field also has the key air.arg_type_name where the
type name goes. The library dumped as the device made it shows both
(measured: macOS 27.0.1 arm64, m3-max-30158). metal2vulkan reads a field
through the same attributes as any input, so it still refused the kernel's
compute pipeline ("UnknownKey" at argument 0, "attrib_0"), and the renderer
still drew the draw's vertices in software.
A patch control point input's field node k now loses the bare name. Where
its type name is the key, it gets the Metal name of member k of the control
point function's result, which is what `metal` writes: one field per
member, in order. The rule applies in vertex functions and kernels alike.
gl_tests holds the generator's shape in a kernel and in a
post-tessellation vertex function, and checks that the input as `metal`
writes it comes through byte for byte. The header and the gl_tests
comment no longer put the name in the kernel's input node itself.
For the guest: the fields of a GL tessellated draw's kernel are now what
`metal` writes. The device still refuses the kernel, now at its patch
control point role (m3-max-30171). metal2vulkan refuses that role in a
kernel as Metal does: Metal compiles no kernel with a patch control point
input (measured on the M3 by metal2vulkan, m3-max-30197, m3-max-30201 and
m3-max-30203). The renderer draws the draw's vertices in software until the
device makes the kernel one Metal compiles.
The GL lowering makes each variant's metadata what `metal` writes, but it
read only a vertex or fragment entry point's inputs. A kernel's inputs kept
the generator's bare attribute name after air.location_index and had no
buffer address space. The kernel GL's renderer makes for a tessellated draw
has such an input ("attrib_0" at its argument 0). metal2vulkan refuses that
key, so the device refused the kernel's compute pipeline. The renderer's
buildPipelineState failed, and it drew the draw's vertices in software
(measured: macOS 27.0.1 arm64, a quad patch through a tessellation control
and evaluation shader, m3-max-30129).
For the guest: a GL kernel's inputs now follow the rules a vertex
function's do. The tessellated draw's kernel was still refused with these
rules alone (m3-max-30150): the name sits in its control point input's
field, which the next commit normalizes. gl_tests holds a kernel's inputs
through the rules.
What the guest sees changes: the device answers targetDeviceArchitecture
(MTLDeviceSPI) with an MTLTargetDeviceArchitecture, Metal's own class, of
cpuType 0x01005247, subType 0, version 1.0.0 and driverVersion 0x10000. It
answered nil, the IOGPU base's answer.
Metal's loader ends the process at nil (+[MTLLoader sliceIDForDevice:
legacyDriverVersion:airntDriverVersion:]), and MTLAssetUpgraderD, which asks
Metal's archive reader about every .metallib of an app it is told of for
every device, ended with SIGABRT at each app installed in the guest: 1-2
reports in every walk since pin 70, on Iris and the 3090.
Every Mac answers an object (oracle_archtype: AMD 5300M, Intel UHD 630, M3
Max, dgpu-oracle.md Q42), so nil is outside the envelope. The values name
each GPU's own compiler target, so the device names its own: CPU_ARCH_ABI64
with its PCI device id, which no Metal slice carries, so no archive holds a
slice Metal reads as this device's; one target whatever the host GPU; and
one version for both version fields, as the M3 Max and the Intel 630 answer.
Where the guest's Metal lacks the class or its setters, nil as before.
inherited_tests now checks the answer, and the register's line says why it
changed.
MTLAssetUpgraderD ends with SIGABRT in every guest that installs an app: for
each .metallib of the app it asks Metal's archive reader about the file for
every device, and Metal's loader asserts on the device's
targetDeviceArchitecture, which the reims-graphics device answers nil.
The probe prints what a device answers there (the class, its members and
their values) and what the archive and dynamic library readers answer for
named files and for an archive and a dynamic library the device serializes
itself, each read in a child process, so a Mac's answers and the guest's can
be compared and the guest's abort is reproduced without an app install.
Its first round measured plane 0 of a surface with planes; a texture over a
later plane is the platform's other planar shape, so the probe asks it too:
plane 1 of a 128 x 32 420v surface, whose 16 rows of 128 bytes hold a 16 x 16
RGBA16Float texture.
The Vulkan platform drops a 4x BGRA8 attachment's resolve into a texture of
another format (RGBA16Float, BGR10_XR, BGR10_XR_sRGB) where the M3 Max was
measured to leave the texture untouched, but its measurements covered only a
texture over an IOSurface without planes in Shared or Managed storage. The
guest's surfaces now reach the platform as buffers, whose storage the device
picks (Private over a device cache), and the guest's own textures may lie over
a plane of a surface with planes or be Private.
oracle_surfresolve measures the rest: one case a process, the resolve
texture of its own, over a surface without planes, or over plane 0 of a 420v
surface, Shared, Managed and Private, by MultisampleResolve and
StoreAndMultisampleResolve, against a resolve of the same format.
A command buffer committed while the control ring held messages made two kext
calls: SubmitBatch posted the held, then the bundle published the buffer on
its queue's ring and rang the queue's doorbell through the kext. The second
call costs its kernel entry and return around the doorbell's write: measured
with the commit probe and the kext's stamps at 4.6 us p50 a commit on the Iris
Xe host (1.3 in, 2.0 the write, 1.2 out), and on the 780M host 4.5 us warm and
11.3 us after 2 ms idle (3.2 in, 2.7 out). Every commit the probe made behind
held messages rang it.
Where the kext answers kRgfxKextFeatureQueuePublish, SubmitBatch takes three
scalars more: the queue, its ring's new producer and the doorbell's flags. The
bundle writes the buffer on its ring and fences its stores, leaves the
producer, and hands the publish to the held (RgfxRingWriter::tryPost's `via`,
RgfxSerializer::publishVia). Once the kext has posted every held message it
stores the producer, fences, reads consumer_idle and rings the doorbell as the
bundle's own publish does (RgfxQueuePublish.hpp), so the host sees the held on
ring 0, then the buffer, as before. A commit with nothing held, or behind an
indirect command buffer's encodes or a refused destroy, goes as before; so
does every commit with a kext that lacks the bit. Where the kext leaves a held
message other than a destroy unposted it publishes nothing, and the bundle
takes the buffer off its ring unseen, its seqno the next buffer's and its
expected records dropped (RgfxReplyReader::forget), and fails it as before.
The buffer's posted time is stamped before the call.
The kext maps each queue's submission ring header at QUEUE_CREATE, while the
ring's block is pinned, only where the block is the client's own (ownsBlock),
in RgfxAcceleratorUserClient::keepQueueHeader. It lets the mapping go before
the pages can: at the queue's destroy (destroyQueueIfTracked), at Free of the
block the ring lies in, before the free, and at the context's close
(releaseContext, before the window and the blocks go). Each publish runs under
the client's list lock, which every drop takes. A device reset frees no block:
the mapping stays the process's ring until one of those. A queue past the
client's first 64 is published by the bundle.
Tests: queue_publish_test (the kext's publish against the bundle's own, every
consumer state and flag, and the headers' table through create, free, destroy
and close), shell_tests' test_commit_hands_its_publish_to_the_held (one call,
nothing held, a kext without the bit, a refused create, refused destroys
alone) and user_client_words_test (the bit).
metal2vulkan refuses a write of every two-plane YCbCr texture reached through
an argument buffer, and asked what Metal stores there before taking the slot
answers for it. oracle_twinwrites gains `argbuf`, a kernel's write() through an
argument buffer that holds the texture, made resident for writing, and 500
(YCBCR8_420_2P over a '420v' surface), whose slot writes Metal drops, so one
run compares the two routes. Written from scratch.
oracle_failways measures a command buffer the GPU fails two ways at once: a
render pass storing into bit-24 memory beside encoders made under protection
options, each encoder followed by an event signal. The Vulkan platform died at
such a commit because nothing measured which failure wins. oracle_twinwrites
records what Metal stores into a 4:4:4 surface's planes through the _sRGB twins
523 and 527, whose writes the runtime refuses for want of those bytes. Both are
written from scratch, and build.sh builds them with the other probes.
A command buffer's delivery releases what the buffer kept before it lets
its waiters go, as Metal does, and the destroys those releases hold armed
their 1 ms timer there: a dispatch_after, whose kevent wakes the dispatch
manager's thread. In a guest ktrace of Geekbench's Metal Super Resolution
on the 780M host that arm took the release 16.9 us p50 (30.2 p90) of each
delivery on the completion queue, between the app's handler and the wait's
return. The delivery now holds the arm (RgfxRingLaterArms) until its
waiters are let go: the destroys go as before, the timer from the end of
the delivery.
The completion thread pumps and arms every live queue's completion ring on
each pass, and the ring headers are uncached memory to the guest: a store
there costs about 0.3 us on an AMD host, a load 0.1 us (design.md). A ring
the last pass armed and found empty is armed still while the host publishes
nothing, as the host clears `armed` only in a post, so the pass now reads
its `producer` alone, and a pump that took nothing leaves `consumer` as it
was. The host sees the same counts and the same arm.
oracle_waits on the 5300M, the 630 and the M3 Max: a queue's statuses,
handlers and waits run in one order on its completion queue. A status changes
before its stage's handlers, waits return only after them, and a handler that
blocks holds everything of its queue after it. Our delivery keeps that order.
The probe now counts a status its polling thread never read apart.
The guest's completion delivery runs a command buffer's completed handlers
before its waiters wake, and its fast path for a buffer with no handler waits
behind every earlier record of its queue. Whether Metal orders them so is what
decides how far that path can be cut. oracle_waits measures it on a Mac:
waitUntilCompleted and waitUntilScheduled against completed and scheduled
handlers that block, and a later buffer's waits against an earlier buffer's
handler that blocks.
What Metal does with a GPU or CPU write into read-only memory (a no-copy
buffer or heap made with MTLResourceOptions bit 24, or over pages the
process maps read-only) decided where the Vulkan platform faulted, dropped
or ended the process, and only the M3 Max had been measured. oracle_readonly
asks every such write on any Mac, one shape a process against a writable
control: a render pass's stores and resolves of every action, colour, depth
and stencil, by the descriptor and late; a draw's, a kernel's and a blit's
texture writes; the CPU's replaceRegion:; and whether the queue runs on and
its second fault revokes it. oracle_readonly.sh DEVICE runs every shape.
dgpu-oracle.md Q38 holds what it found on the M3 Max, the Radeon Pro 5300M and
the UHD Graphics 630 (m3-max-29292 to m3-max-29294, m3-max-29309 to
m3-max-29311). It is written from scratch, in plain Metal.
A discrete GPU reads gameload's Shared buffers in system memory: the frame's
constants and the materials' argument buffers, which every vertex and fragment
reads, and the ICBs' argument buffers, which each encode thread reads. On the
RTX 3090 behind a Thunderbolt link, gameload's frame takes 46 ms of GPU time
against the RX 7900 XTX's 9.9 ms, and the link carries many small reads a
frame. --private frame,materials,args puts each in a Private buffer instead,
copied from its Shared one by a blit at the start of the frame (once where the
CPU writes it once), so a run with it measures what those reads cost.
newBufferWithBytesNoCopy: over Shared memory the process maps read-only took
a slab copy that the bundle merged from the memory at every commit using it.
On macOS 12.7.6's WindowServer, which wraps clients' Core Animation backing
stores (VM_MEMORY_LAYERKIT, mapped read-only, 8-30 MB each) so and draws from
them every frame, that merge was 14.10 s of the commit path's 14.25 s over a 451 s walk, 130,850 MiB
compared, and its commit-to-post wait 2-6 ms a frame where 14.8.9's is
20-60 us (appwalk14, ms01's Iris Xe).
Where the kext makes a read-only pages block (RGFX_FEATURE_READ_ONLY_PAGES),
such memory now lies over its own pages: the bundle asks the block for
reading alone and makes its BUFFER_OVER_PAGES with Metal's private bit 24,
sent to the host alone. The buffer answers the app's options, without the
bit, as Metal's does; its contents, length, allocatedSize and GPU address
(the pointer's offset in its page) answer as before. Read-only blocks join
only read-only ones. Read-only Managed memory keeps its copy: the host's two
copies would write the CPU copy back to the pages. Where the kext gives no
block (a host without the bit), the copy stays.
What changes for the guest, beside the time: the GPU's writes to such memory
follow accuracy-ledger.md's read-only-pages-written row, as Metal's do, where
the copy kept them in the slab for later command buffers to read:
- a shader's store, a blit's fill or copy and a pass's visibility results
into it complete with their writes dropped, and later command buffers see
the memory as it is;
- a pass that stores an attachment there (Store,
StoreAndMultisampleResolve) fails its command buffer with
MTLCommandBufferErrorPageFault, where the copy let it complete;
- the CPU sees its pages unchanged, as before.
On Linux the runtime makes a bit-24 buffer over a copy of the pages today,
compared with them at each commit that uses it, so the per-commit compare
moves from the guest's process to the host's commit until metal2vulkan
imports such memory in place.
The shell tests that held "read-only memory never asks for a block" now hold
the new route: the ask for reading alone, the bit on the wire and not in the
buffer's options, and the copy where no block is given. Both guest sets are
rebuilt in the 📦 commit that follows.
What changes for the guest: newFunction now answers nil with
MTLLibraryErrorDomain 3 (CompileFailure) and Metal's own lines ("error:
buffer argument b has invalid location (<0,1>) in k\n"), by any way of
making the function, where function constant values put two present
arguments of one argument table at overlapping locations through
(a) a predicate or an index computed from a half constant,
(b) an index computed through a conversion between a float and an integer,
(c) a function table (visible or intersection) or an acceleration
structure (primitive or instance) at a buffer's location.
Before, newFunction made the function in those three cases and the
pipeline's create refused it later on the host (OverlappingArgument). Metal
refuses at newFunction (oracle Q33), and the bundle already did so for
every other case its AIR reader decides.
Why the bundle missed them: the initialisers' evaluator folded no half
constant's value; the compiler writes a float-integer conversion as a call
(air.convert.u.i32.f.f16 and the like), which it took as any value; and the
reader did not count a function table's or an acceleration structure's
location, whose table and word were not measured.
Q33's probe, oracle_overlap, gains eight functions (k_halfpred, k_halfidx,
k_fidx, k_sidx, k_vft, k_ift, k_pas, k_ias), measured on the 5300M, the 630
and the M3 Max (m3-max-28663, 28662, 28659). The three oracles agree on
every newFunction answer: function tables and acceleration structures take
locations of the buffers' table, with the word `buffer`; a half constant's
predicate and index, and an index through conversions truncated toward
zero (-1.5 gives -1), count as any other. One pipeline differs: the 630
refuses k_vft's compute pipeline where the table is called, its compiler
service dying (CompilerError 1, XPC_ERROR_CONNECTION_INTERRUPTED), while
the 5300M and the M3 make it. Making it stays inside what the x86 Macs
answer, so nothing here follows the 630 there; Q33 records it.
For the overlap check alone (rgfxAirConstantGlobals) the evaluator now
folds a half constant's value, rounds each half result to the nearest half
as LLVM folds a half, and folds air.convert of scalars between floats and
integers (a float to an integer only where the truncated value is in the
integer's range); the bodies' specialisation (reflection's used arguments)
still takes those as any value. The reader counts a function table's or an
acceleration structure's location in the buffers' table, and the check
names it `buffer`. test_overlapping_arguments_refused_as_metal compares
the eight new functions with this Mac's Metal for every value and way, and
checks the x86 Macs' words.
Still left to the host, written in Q33: an initialiser operation the
evaluator does not fold (vector or array elements, conversions of two
integers or of vectors, other calls), an air.buffer with no address space
(no form built writes one), and a function of a library Metal's link made,
which keeps no bytes.
A slab being let go leaves the slabs' books before its memory is back in its
source: its heap's destroy and its block's release, which the kext answers
once the host has let go of it, run outside the lock. A buffer create that
found no room, and whose own let-go of the empty and cached slabs found
nothing left to drop, asked its source again at once and answered nil while
another thread (or the background thread) was still giving those slabs back.
The region's reclaim answered the same way for any block it was asked for.
For the guest: newBuffer of a Shared or Managed buffer, and a block of the
region (a Shared heap, a texture's CPU copy, a staging window, a command
buffer's out-of-line message), could be nil near the region's or the pages'
end while another thread freed buffers. It found the memory a moment later.
test_slab_thread caught it once on the M3 (m3-max-25197): on that
4-thread test under Rosetta, development's slabs refused a 3 MiB take in 8,
9 and 3 of 1,000 runs (m3-max-28562, 28595, 28619). Each refusal came with
15 to 52 slabs, 42 to 154 MiB, out of the books and not yet back in the
source: a starved background thread had let doomed slabs pile up, and one
thread's evict was dropping them all. This branch: 0 of 1,000 and 0 of 2,000.
A take that finds no room now waits for the drops in flight and the doomed
slabs as it asks, then asks again; so does RgfxSlabs::reclaim, which then
answers true. Those are the drops its own dropDoomed(true) would have made
had it come first, on the same locks and the same host answers, so the wait
holds the thread on nothing that call does not. None of the region's
callers that reach the reclaim holds a lock the drop path takes (the
serializer's library-key, ICB, destroy and ring locks, the region's pages
lock): the argument encoders' answer blocks, an ICB's slots (its own slot
lock), a Shared heap, an IOSurface's shadow (its making lock), the upload
and body pools (an arena's lock, a queue's post lock), a library's staging
window (the stream lock), a texture's CPU copy. stats().dooming counts the
drops in flight too.
Tests: test_slab_take_waits_for_slabs_given_back and
test_region_reclaim_waits_for_slabs_given_back hold a slab's release at a
gate while another thread asks for its room: without the waits each answers
nil at once (both fail without their halves of the fix). test_slab_thread
also checks that every byte its source gave is a slab's.
The host sees a command buffer only once a queue's thread takes it off its
ring, so the app's encode and the buffer's way to the host show as one span
with nothing pending on the host. This adds the guest's stamps that split it,
a diagnostic.
What changes for the guest:
- The device offers a new feature bit, RGFX_FEATURE_GUEST_TIMES (bit 44,
FEATURES_HI bit 12), and DRIVER_FEATURES takes it. The kext carries it.
- Where the device's word holds it, the bundle starts each command buffer's
stream with a new op, RGFX_OP_GUEST_TIMES (0x000e, 32 bytes): the guest's
clock as the buffer was made, as its commit was entered, and as its message
went on its ring. The last is written under the ring's lock, after the copy
and before producer is published; for a buffer in a block, into the block.
- After each VBLANK's reading of HOST_TIME the kext writes ring 0's new header
fields: guest_clock_offset_ns (0x18), then guest_clock_bound_ns (0x20) with
release, split out of reserved bytes. The host zeroes both as it initialises
a ring.
- The decoder walks the op as a no-op, so it changes nothing a buffer does,
and a host that did not offer the bit never sees it. Old guest sets carry
no bit, send no op and leave the fields 0.
The header is regenerated, both guest sets are rebuilt from the same sources,
and the option ROM's record takes the header's new hash; the ROM's bytes are
unchanged. The tests cover the op's and fields' layout (the header test, the
kext's vblank clock test), the bit's negotiation (the kext's features test,
the peer and memory-map tests), the stamps (the bundle's serializer and shell
tests) and the walk (a cmdbuf test, and the fuzz's streams). The host's
reading of the stamps is the next commit.
G1, the host's replay of GPU-encoded indirect command buffers, has a compute
half that gameload's icb shape (draws only) never reaches. cicb is that shape:
a kernel encodes CICB_COMMANDS concurrent dispatches into a compute indirect
command buffer, every fifth reset, and a later compute encoder sets the
pipeline and its buffers at non-zero offsets and executes it. The commands
inherit the pipeline, and the encoder's buffers unless -b, where the kernel
sets each command's three buffers itself.
The dispatches sum their input into one word for each frame in flight, which
the CPU checks against its own sum as the frame slot comes back. A replay that
drops a command, a grid or an offset then fails the run (exit 1, cicb_bad)
instead of only running slower. -c sets the command count (512 by default),
which the frame constants carry in what was their pad word. The tools' README
names the new shape.
dgpu-oracle Q37 records oracle_surftex's aliasing cases on the three Macs: a
write through one texture over a plane reaches the next encoder's read through
another, tracked or behind a fence, on all three; the bytes past the plane's
texels are the surface's own on the M3 and the GPU's own on the x86 Macs. It
says which answer each wide home gives. Decided 14 in the device's design and
the oracle tools' list name the wide home and its copies.
The x86 Macs keep the CPU's bytes past the texels in the surface after a wide
texture writes them; the aliasing cases now count, where the wide texture
reads, the runs whose read of the bytes past the texels gave the CPU's.
The x86 Macs left the surface without the wide texture's writes after the
command buffer of an aliasing case, where the M3 held them: the count of the
surface after each run now takes the plane's texels and the bytes past them
apart, and counts the runs whose bytes past the texels still hold the CPU's.
A texture over an IOSurface plane wider than the plane's texels gets a home of
its own on a host whose device cache lays the plane out at the GPU's pitch, so
the host has to know whether Metal shows one encoder's writes through one
texture to the next encoder's reads through another texture over the same
plane, in one command buffer. The aliasing cases write an L008 surface of
128-byte rows through an RG8 texture of the whole rows or an R8 texture of the
plane's texels, by a blit or a clear, and read them back through the other in
the next encoder, tracked and Untracked with a fence, 16 runs each.
The perf ledger's AAA rows (heap shadows, format views, chunk imports, heap
compression, per-draw cost) each wait on a run that makes the load an AAA
Metal port makes, and none of our walks makes it. gameload is that load, our
own code: offscreen, a fixed number of frames, each frame's CPU, wait,
frame-to-frame and GPU times printed with their p50, p90 and mean, and the
measured window's start and end on the wall clock so a host's logs of the same
span can be cut to it.
A frame holds placement-heap streaming (slots made again at their offsets and
uploaded, BC7 where the device has it, a placed vertex buffer, transient
textures from an automatic heap made aliasable), render targets placed in a
heap, a 4x MSAA scene with depth resolved, composited through an sRGB view and
with a UI pass into a BGRA view, a GPU-encoded indirect command buffer, 4000
CPU draws and 1000 shadow draws over argument buffers, compute
post-processing and a blit stream with a read-back. Each of the eight shapes
turns off by name, so a run with one off measures its share; -b makes the
indirect command buffer inherit no buffers.
make -C guest/bundle/tools/gameload builds one universal binary (arm64 and
x86_64) for an Apple-silicon Mac, the Intel oracle and both guests. It has a
Makefile of its own because guest/bundle/Makefile is a source the prebuilt
guest sets record, and a target there would mean rebuilding both sets. The
tools' README gives the command lines the measured runs used.
Metal's descriptor validation, which runs without the debug layer, ends the
process at every usage bit it names none for. The exceptions are 0x8, which
it takes and leaves out of the answer, and 0x4000, 0x8000 and 0x10000, which
it takes and answers. It names the bits in one line ("MTLTextureUsage has
unknown bits 0x1c0."). It also ends the process at ShaderAtomic on any
format but R32Uint and R32Sint, and on an Apple GPU RG32Uint; the x86 Macs
name RG32Uint in words of their own. This was measured alike on the M3 Max
(macOS 27.0.1), the AMD 5300M and the Intel UHD 630 (26.7.1), over an
IOSurface and over none, in oracle_surftex's sixth and seventh rounds:
0x40, 0x80, 0x100, 0x200 to 0x2000, 0x20000 to 0x100000, 0x1000000,
0x80000000, and BGRA8Unorm, R32Float, RGBA8Uint, R8Uint, R16Uint, RG32Sint,
RGBA32Uint and format 500 with the atomic bit.
The bundle ended the process at 0x80 alone and made the rest, so a guest
held textures no Mac makes. Now every creator ends where the Macs end, in
their words and order, on x86 and arm64 guests. An arm64 guest still makes
an atomic RG32Uint texture, as the M3 does.
An R32Uint texture over a BGRA surface made with ShaderRead, ShaderWrite and
ShaderAtomic answered usage 0x23 in the arm64 guest, where the M3 answers
0x3. The class is wider than surfaces: the M3 Max (macOS 27.0.1), the AMD
5300M and the Intel UHD 630 (26.7.1) all leave ShaderAtomic (0x20) and 0x8
out of every texture's usage answer, over an IOSurface of each kind and over
none, in Managed, Shared and Private storage, and so do the texture's views
(oracle_surftex's sixth and seventh rounds: 0x23 answers 0x3, 0x20 answers
0, 0x29 answers 0x1). Bits 0x4000, 0x8000 and 0x10000 are answered as given.
x86 and arm64 guests both answered the bits as given. The answer now masks
them, while the wire keeps the usage the descriptor gave, so the host's
texture still takes the atomic bit. isCompressed reads the usage the texture
was made with, as it did through the answer before.
The sixth round showed all three Macs end the process at usage bits 0x40
and 0x100, drop 0x8 from the answer and keep 0x4000 and 0x10000, and end
it at the atomic bit for every format but R32Uint, R32Sint and, on an
Apple GPU, RG32Uint. The seventh round asks each other bit alone, three
at once, and more formats with the atomic bit, so the bundle's rule
covers the class and not the bits seen so far.
The arm64 guest answered usage 0x23 for an R32Uint texture over a BGRA
surface asked for ShaderRead, ShaderWrite and ShaderAtomic, where the M3
answers 0x3. One case can't say which bits Metal drops, for which formats,
or whether the surface or the format decides. The sixth round asks the
atomic bit across formats, storage modes and surfaces, with and without
PixelFormatView, bits Metal has no name for, the same descriptors over no
surface, and a view of the texture over the surface.
Metal's no-copy buffers answer NonVolatile to every purgeable state they are
told, on the M3 Max, the AMD Radeon Pro 5300M and the Intel UHD 630 alike
(oracle_bundle purgeable.kinds), as views, textures over buffers and heaps'
resources already do here: the host backs none of them with a purgeable
allocation of its own. The bundle's no-copy buffers kept the state told.
A visible function table answers NonVolatile on the M3 Max and the Intel 630,
where the AMD 5300M keeps the state told; the bundle answered the AMD's (2,
then 3 when asked). It now answers the M3's and the Intel's on every guest.
What the guest sees: setPurgeableState: on a no-copy buffer or a visible
function table answers NonVolatile, whatever was set before, and isPurgeable
answers NO. Every other resource keeps the state told, as before. The oracle
doc records the measurement (Q35), and both guest sets are rebuilt.
The arm64 walk found a visible function table keeping the Volatile state it
is told on the guest, where the M3 Max's stays NonVolatile. Before the
bundle's answers change, purgeable.kinds measures the states every kind of
resource the device makes answers, buffers, views, textures over buffers and
IOSurfaces, heaps and what they hold, and indirect command buffers, so the
rule comes from measurements on each reference GPU.
The arm64 guest's device answers the x86 Macs' feature profile, 10002,
where the M3 Max answers 10. Metal reads the profile at device creation and
keys limits, families and feature queries on it; this probe prints what the
base device answers under each profile asked, so the change to 10 can be
weighed against what the device itself answers.
Q34 gains the answers arm64rules2 measured on the M3 Max under macOS 27.0.1:
the depth/stencil queries, ids and words the arm64 guest now takes, and
those the M3 gives as the x86 Macs do (a state's resourceIndex and
uniqueIdentifier, dynamic library refusals, a dylib's exported function,
texture addresses, the indirect command read-back), so they stay as they
are.
Both x86 Macs load the install names of a library read from a file alone:
a kernel whose library was made of bytes or of source refuses its pipeline
though the named file is there. An arm64 guest's device answers as an
Apple GPU, and the M3 Max makes both pipelines, bare and with the library
preloaded, and they run as the file's (oracle_fnptr Apple, macOS 27.0.1).
The arm64 guest's pipelines now load such a library's @executable_path
names; its @loader_path names, of which a library of no file has no
directory, still refuse it, as nothing measured them. An x86 guest's
pipelines refuse as before, which the test keeps beside the Apple answer.
Both x86 Macs' function handles raise an unrecognized selector at
gpuResourceID, and so did ours on every guest. An arm64 guest's device
answers as an Apple GPU, and the M3 Max's handles answer 0, for a compute
pipeline's linked functions and a render pipeline's fragment functions
alike (oracle_fnptr Apple, macOS 27.0.1).
The arm64 guest's handles now answer 0; an x86 guest's still raise, which
the test keeps beside the Apple answer.
Apple's GL renderer asks a depth/stencil state it binds whether it reads
and writes depth and stencil. Both x86 Macs' states answer YES to all four
for every descriptor, and so did ours on every guest. An arm64 guest's
device answers as an Apple GPU, and the M3 Max's states answer what the
descriptor does (oracle_bundle Apple ds.queries and ds.grid, 717
descriptors under macOS 27.0.1): writesDepth is the depth write;
readsDepth is that, or a depth compare other than Always and Never; a face
writes the stencil where its write mask is not 0 and an operation is not
Keep, and reads it where it writes it, or its read mask is not 0 and its
compare is neither Always nor Never.
The arm64 guest's states now answer that; an x86 guest's still answer YES,
which the test checks for each descriptor beside the Apple answer.
An arm64 guest's device answers as an Apple GPU, whose Metal reference is
the M3 Max. Its pipeline reflection answers a constant buffer's alignment,
and its pointer type's, as the pointee's (16 for a struct of float4x4
members, 8 and 4 for others), where both x86 Macs answer 32: measured by
tools/pipeline_reflection_check Apple under macOS 27.0.1, whose only other
differences are compiler flags in instance variables no getter reaches.
The arm64 guest's pipelines now reflect the M3's alignment; an x86 guest's
answer stays 32, which the test checks beside the Apple one.
ds.queries' 15 descriptors leave the M3 Max's rule open where a test cannot
pass or fail (Never, Always) and where masks are 0; the grid asks every
compare, operation set and mask, so the rule is read from measurements,
not guessed.
The arm64 guest's device answers as an Apple GPU, so each answer it gives
has to be measured on the M3 Max's own Metal first. These cases ask what a
depth/stencil state answers to the four queries Apple's GL renderer sends,
to resourceIndex and uniqueIdentifier, and what the device's tiled texture
SPI over bytes and a buffer's tiled SPI answer.
A locked instruction right after a store to a write-combined page waits for
the page's write-combining buffers to drain, which may cost ~90 ns on an AMD
host where the guest's write-combined mappings stay write-combined. setBytes
copies its bytes into a write-combined upload chunk, so the new case
render.setVertexBytes.16.retained follows each 16-byte setVertexBytes with a
CFRetain and a CFRelease, to set against render.setVertexBuffer.retained's
cost of the same two locked instructions after a write-back store.
dgpu-oracle.md gets Q34: what the M3 Max under macOS 27.0.1 answers, with no
validation layer, where the bundle took the x86 Macs' rules for an arm64 guest,
measured on 11-13 by oracle_surftex's fourth and fifth rounds and
oracle_bundle's new cases, its argbuf.ds.* and oracle_mesh's icb (m3-max-26136,
26149, 26152, 26237, 26239): textures over a surface, views, Shared heaps,
linear alignments, depth textures over a buffer, depth/stencil states in
argument buffers, mesh indirect command buffers, option bits 17 to 19, the
IOSurface buffer and tiled texture SPI, and the register's x86
respondsToSelector verdicts the M3 answers otherwise (50 of 67). Each row says
what an arm64 guest's device now answers. Q9 and Q20 point there; the probes'
README names the new cases, and the device's comment on rgfxAppleRules names the
rules it now covers.
Guest-visible on an arm64 guest (and wherever the device answers an Apple
family): a depth/stencil state's gpuResourceID now answers 0, and an argument
encoder's setDepthStencilState:atIndex: (and its range form) writes nothing,
where both raised an unrecognized selector, which ends the process where
nothing catches it.
The M3 Max under macOS 27.0.1, with no validation layer, answers 0 for every
state's gpuResourceID, and its encoders write nothing and raise nothing for a
state or nil: at a depth/stencil descriptor's index, beside a texture and a
pointer, on an encoder of one texture, and on one of a function's argument
buffer holding a state (oracle_bundle Apple argbuf.ds.id, .set, .mixed, .tex,
.texnil, .nil and .function, 11-13). x86 guests keep the x86 Macs' raises,
which the protocol test keeps beside the new answers. A state's resourceIndex
and uniqueIdentifier still raise on both: the M3's answers to them were not
measured.
Guest-visible on an arm64 guest (and wherever the device answers an Apple
family): a texture of a depth or stencil format over a buffer's bytes, by the
public newTextureWithDescriptor:offset:bytesPerRow: and the linear SPI, now ends
the process with the M3 Max's words ("Linear texture: cannot create
compressed, depth, or stencil textures, pixelFormat (...) disallowed",
_mtlValidateStrideTextureParameters), sending nothing, where the bundle made
it: an Apple GPU's descriptor validation takes depth and stencil textures in
Shared storage, so the x86 Macs' end at the storage never came.
Measured: the M3 Max under macOS 27.0.1 with no validation layer ends the
process there at Depth16Unorm, Depth32Float, Stencil8, Depth32Float_Stencil8
and X32_Stencil8 in Shared storage over a Shared buffer, and at Depth32Float by
the linear SPI (oracle_bundle Apple buftex.depth*, linear.depth, 11-13). x86
guests keep the x86 Macs' end at the descriptor's validation
(buffer-texture-depth).
Guest-visible on an arm64 guest (and wherever the device answers an Apple
family): minimumLinearTextureAlignmentForPixelFormat: now answers the device's
alignment for the formats the M3 Max answers and ends the process at the rest
as it does, where the bundle took the x86 Macs' set. It answers 111 more raw
values: those the x86 Macs lack but Invalid, D24S8 and X24S8 (B5G6R5, A1BGR5,
ABGR4, sRGB R8 and RG8, Unspecialized, the two-plane and XR10 formats) and
values of no name in the SDK (26, 44, 66, 116, 501, 504, 521, 524, 546 to 548,
560, 562 to 613, 615 to 629). It ends at PVRTC, EAC, ETC2 and ASTC with the
compressed formats' words, and at 651 and 652 with the depth/stencil words,
where it said Invalid.
Measured: the M3 Max under macOS 27.0.1 with no validation layer, at each raw
value from 0 to 799 and 1000, 1023, 4096 and 65535, one child process each
(oracle_bundle Apple linalign, 11-13): 175 answered (16 each), 82 compressed,
7 depth/stencil, the rest Invalid. rgfxLinearAlignmentAnswer classifies a
value for a device; test_linear_alignment_as_an_apple_gpu checks every value
against the M3's table and that the x86 Macs' 64 stay where the device
answers no Apple family.
Guest-visible on an arm64 guest (and wherever the device answers an Apple
family): newHeapWithDescriptor: with Shared storage now makes a heap over a
block of the device region (RGFX_CMD_HEAP_OVER_HOST_MEMORY), whose buffers'
contents lie there, where the bundle ended the process with the x86 Macs'
"Heap Descriptor Validation\nShared storage mode disallowed".
The M3 Max under macOS 27.0.1 makes a 4 MiB Shared heap, Shared buffers in it
whose contents the CPU reaches, and a Shared texture in it (oracle_bundle Apple
heap.shared, 11-13). The heap over host memory is the path the bundle took for
every Shared heap before 0f9108bdf moved the x86 guests to the x86 Macs' end;
it is restored for Apple GPUs alone. x86 guests keep the end
(heap-shared); test_shared_heaps_on_an_apple_gpu checks the new heap.
Guest-visible on an arm64 guest (and wherever the device answers an Apple
family): newTextureViewWithPixelFormat: and its forms in
MTLPixelFormatInvalid now answer nil, sending nothing, where the bundle ended
the process with the x86 Macs' words ("texture view pixelFormat
(MTLPixelFormatInvalid) not castable").
The M3 Max under macOS 27.0.1, with no validation layer, answers nil for that
view (oracle_bundle Apple view.noformat, 11-13), and ends the process at the
view's other rules in the x86 Macs' words: a format of another class, levels
or slices past the texture's, a type of another family and a cube of slices
not a multiple of six (view.class, view.levels, view.slices, view.type and
view.slicecount). rgfxEndAtViewMetalEnds takes the texture's device for it.
x86 guests keep the x86 Macs' end; test_views_as_an_apple_gpu checks the new
answer beside the old test, and two of the shared rules on an Apple GPU.
Guest-visible on an arm64 guest (and wherever the device answers an Apple
family): newTextureWithDescriptor:iosurface:plane: now ends the process at a
Cube or CubeArray texture over a plane of a surface with planes, and answers
nil, sending nothing, for a compressed format (BC, ASTC, ETC2, EAC, PVRTC)
over any surface once its rows and height fit, and for a two-plane format of
4:2:0 or 4:2:2 chroma of an odd width or height that is a render target or
that a shader writes. It made each of these.
These are the M3 Max's answers under macOS 27.0.1 with no validation layer
(oracle_surftex Apple, 11-13, Q20): IOGPUMetalTexture asserts
"carriesComplexTexture || numFaces == 1" at every cube over a plane, of a
one-plane BGRA surface and a 420v one's luma plane, and answers nil for the
others over a surface without planes, a one-plane surface and either plane of
a 420v one; 4:4:4 and XR10 two-plane textures and read-only ones of odd sizes
it makes. An arm64 Mac's GPU is always Apple's, so an arm64 guest's frameworks
expect these answers. x86 guests keep the x86 Macs' answers, which make BC
textures wherever their rows fit and cubes over a plane, and end the process
at every two-plane format: the new test checks every case against both.
A fifth round of 74 cases: each 4:2:0 and 4:2:2 two-plane format over a 420v
surface's luma plane at an odd height, at an odd width, as a render target, at
an odd size as a shader-written and a shader-read texture, and each 4:4:4 and
XR10 one at an odd size, shader-written. The M3 Max answered nil for a 63 x 63
render target of every subsampled format, and for 500 written by a shader:
these cases tell which side and usage decide it.
oracle_surftex gets a fourth round of 45 cases: the compressed formats only an
Apple GPU has (ASTC, ETC2, EAC, PVRTC) over a surface with planes and without,
the cube types over a plane, and two-plane textures of odd sizes, as render
targets and not, over each kind of plane. oracle_bundle gets a Shared heap
(heap.shared), buffers and textures of options holding bit 17, 18 or 19, the
tiled and linear texture SPI's answers (tiled.responds), and the depth and
stencil formats over a Shared buffer by the public form and Depth32Float by
the linear SPI. The x86 Macs answered most of these (or end the process at
them); the arm64 guest's rules need the M3 Max's.