The bundle sends a texture create to the host posted and answers a texture
whatever the host's platform then does with it, so a texture Metal answers nil
for by its descriptor alone has to be answered nil in the bundle. The
descriptor's rules were copied on 11-05 (Q24); what Metal answers for a texture
too large to make had not been measured.
oracle_texdesc's 13 new cases are RGBA32Float textures within every rule, of
2 GiB to 8 TiB, at the device's creator; each prints the size
heapTextureSizeAndAlignWithDescriptor: answers, and a made one its
allocatedSize and the process's footprint. On macOS 26.7.1 the Intel 630 makes
2 GiB, its maxBufferLength, and answers nil a row taller; the AMD 5300M makes
16 GiB and answers nil from 20 GiB, its maxBufferLength 3.2 GB. A texture that
is made commits no memory. The M3 Max answers nil for the 128 GiB and 8 TiB
ones. dgpu-oracle.md, Q24, records the table.
A command buffer the host commits in parts answers GPU times from its first
part's start to its last part's end, which hold the host's walk between parts:
game_6000's gpu_p50 went from under 1 ms to 5.4-8.5 ms with car 12's split.
What a Mac answers for one long buffer had not been measured.
oracle_cmdbuf's new gputimes case commits K encoders of about 0.5 ms each (K
= 1, 8, 32; compute and render passes) in one buffer, and the same encoders
one buffer each, back to back. On both x86 Macs (macOS 26.7.1, the AMD Radeon
Pro 5300M and the Intel UHD Graphics 630) one buffer spans its encoders' GPU
time summed, as the back-to-back buffers do, within the GPUs' clock ramp; the
CPU's encoding time never counts; GPUStartTime comes 0.08 to 0.40 ms after
the commit. dgpu-oracle.md, Q7, records the table.
On the RTX 5080 guest, ten of gl_cases' texture cases sample zeros on our
device (m3-max-3831) while the same lowered shaders pass over the Intel 630's
textures on the oracle. GL_INJECT_TEXTURES=1 writes the first calls of each kind
that make, fill, view, copy into and bind the device's textures and samplers,
with their arguments and each object's number, so a guest run shows which step
loses the texels.
cl_probe lists every OpenCL device of every platform. On each one it
builds and runs c = a + b over 1024 floats and checks what it reads back.
It exits 0 when every run passes.
The GL renderer that an accelerator's IOGLBundleName names has compute
entry points of its own, so naming it on our accelerator may change what
OpenCL finds. The guest checks run cl_probe before and after that change.
On the x86 oracle it finds the CPU, the Intel 630 and the AMD 5300M, and
all three runs pass (macOS 26.7.1).
With GL_INJECT_DUMP=DIR, gl_inject already writes every library the class
makes from bytes. It now also writes each render pipeline to
DIR/pipeline-N.txt: whether it was made, the numbers of the libraries its
two functions came from, and its descriptor's state. That state is the
vertex attributes and layouts, color attachments, depth and stencil
formats, sample count, alpha to coverage, rasterization and topology.
These dumps let the GL renderer's own pipelines be compiled off the guest,
against the Vulkan host's runtime, without a boot. That is how the
lowering's module rules were found.
The system's GL renderer picks its per-vendor settings by the Metal device's
vendorName, and ends the process on a name it does not know. With
GL_INJECT_VENDOR=NAME, gl_inject makes the device class answer NAME, so each
vendor's settings can be tried on the reims-graphics device in a guest.
gl_cases draws 29 GL features apps use into a framebuffer object and checks
each centre pixel against the GL spec. It runs in a 4.1 core context, and the
legacy cases in a legacy one. The same cases on Metal's own GL path and
through the bundle's lowering (gl_inject) must give the same pixels. That is
how the lowering's two link and reflection failures were found.
gl_inject now logs each render pipeline the device makes, with its functions
and its error, when GL_INJECT_LOG=1 is set. It writes each library made from
bytes to a directory when GL_INJECT_DUMP is set. gld_lower's new dis mode
prints a .metallib's bitcode as the system's LLVM reads it.
The renderer sets its features from the device's vendor and support
queries as it makes its own device, so the probe prints each device's
answers to compare a guest's device with an x86 Mac's.
It draws gl_probe's triangle into an NSOpenGLView for N frames, through
the window's surface or a layer-backed view, and checks the back
buffer's pixels: what the renderer needs of the device for on-screen
contexts shows on a guest.
A library inserted into one process gives the device installed in a
guest the GL members of this tree's sources, so the GL renderer can be
tried on it before the kext carries them, and on another Mac's Metal
device (GL_INJECT_CLASS) to check the lowering against Metal's own.
The system's LLVM writes bitcode for an Apple triple inside the same
wrapper a .metallib's bitcode section carries, so the section was
wrapped twice and Metal's compiler service aborted reading the module
(an interrupted connection to the caller). gld_lower now unwraps the
writer's output first. With that, both GL shaders of gl_probe's triangle
make a render pipeline, and a draw with it gives the expected pixels.
It also reads the bitcode back and runs the verifier, assembles IR text
(the writer's check apart from the GL code generator), edits the module
text through GLD_REPLACE, sets a vertex descriptor (GLD_VERTEX) and the
descriptor's openGLModeEnabled (GLD_GL_MODE), and draws (GLD_DRAW).
gld_lower lowers the GL IR AppleMetalOpenGLRenderer hands a Metal device to
AIR through the GL code generator the system ships beside the renderer, and
wraps it in a .metallib of one function, as the layout metal writes for a
macOS 11 target. gl_redirect, inserted into one process, makes that process's
OpenGL see an IOGLBundleName on an accelerator, so the renderer can be tried on
a device before a kext names it. gl_probe -x now also traces the plugin data,
the pipelines and their reflection the renderer asks for.
The OpenGL lane needs to see what a guest's GL apps get from our device:
which renderers CGL lists, which one an accelerated context lands on, and
whether a clear, a shaded triangle and an IOSurface-backed framebuffer draw.
-x and -X dump the GL IR AppleMetalOpenGLRenderer hands the device, which
the lane's design reads to decide where GL shaders are lowered.
The probe ran its stitched function through a visible function table, which
the bundle does not support (function pointers), so its run step failed
whatever the stitch did. MPS links its stitched functions by declaration
(MTLLinkedFunctions), as its reduce_stitched kernel does, so the probe's
kernel now declares `fused` and links it the same way.
MPS stitches its uber shaders' visible functions after making them with
constant values and a specialized name (MPSLibrary::CreateUberShaderKey). Our
stitch runs over each function's shadow, Metal's own function over the same
bytes, and a function made with constant values had none, so the stitch was
refused ("link: function constant_0000000000000000_f has no function of Metal's
own library"), MPS inserted the nil it got into an array and threw: Geekbench
7's GPU benchmark aborted at its first MPSGraph convolution.
A function now keeps the constant values it was made with, and its shadow is
Metal's own function of a descriptor of the entry point, those values and its
specialized name. Metal's own library on this device makes such functions and
stitches them (measured in a macOS 26.6.1 guest on the RTX 5080 host,
tools/stitch_probe --metal). The same covers a function given a specialized
name alone, whose shadow answered the entry point's name, which a graph's node
naming the specialized one does not find.
The shell tests stitch functions specialised each way over Metal's own shadows
(tests/stitch_constants.metal); tools/stitch_probe runs the stitched function
on a guest's device.
A command buffer naming an object whose posted create the host refused stands
the object in as nil. What Metal does with nil there (a draw or dispatch
reading or writing a texture, sampler or buffer bound nil, a pass with a nil
attachment, a nil pipeline state, a blit from or to nil) is measured here on
the x86 Macs and the M3. [ci skip]
What the device's, a Private heap's and a Shared buffer's texture creators
make, answer nil for, or end the process at, by the descriptor alone. The
bundle's creators copy the x86 Macs' answers, and oracle_surftex measured
them only over an IOSurface. [ci skip]
The connect case's calls each run on a thread of their own, and a call that
never returns keeps its detail text: it is on the heap, not in a block's
captures, which clang refuses for an array. The probe links IOKit for them, and
IOConnectAddClient, which takes the port as its argument, never its
destination, now runs first, so a port the next calls kill the process on is
still answered.
The third round of the probe: an event made from a port whose exporter was
killed, before and after the kill, and what IOKit's object and connection calls
answer for a connection, a task port and a port the caller receives, which the
bundle's own port checks have to match.
The second round of the probe: a handle made by initWithSharedEvent: over an
object of the probe's own, which logs what the handle asks of it, sent across
XPC as a real handle is, and the refs a port held by handles and events made
from them takes, freed as the probe's events are, by the ownership the
selectors' names give.
What a Mac's Metal answers for a shared event used by two processes: its
eventPort and handle, the events made back from either, their coding, and
the value, listeners and GPU waits two holders share. It runs unchanged on
the guest's device, so it is the guest's check of the same.
submitted.tiny.behind's rounds took twice as long on car 13's tip as on car
12's (n 8059-8955 against 14742-20172 per 5 s), while its ret, the tiny
buffer's commitAndWaitUntilSubmitted, is at most about 70 us of a round.
The case now also prints the busy buffer's commit to its GPUStartTime, its
GPUStartTime to its GPUEndTime and the whole round. Those split the extra
time between the host's submission, the GPU's fills and the completions.
pipeline_reflection_check now also makes c_nested_more, an argument buffer
of C arrays of samplers and of pointers to argument buffers, a struct of
members that holds one and a C array, and a C array of those structs, and
c_ab_tables, function tables and acceleration structures as an argument
buffer's members, so that Metal's answers for them are measured on the
x86 Macs alongside the kinds c_nested and c_tables measure.
A pipeline's reflection is built in the guest from its functions' AIR,
and answered nil where a binding index, a count or a predicate was an
expression of function constants, and isUsed came from the AIR alone,
which marks used an argument read only in code a constant removes.
Metal reflects the specialised function (measured on the 5300M, the 630
and the M3: an argument read only under a false constant is unused, and
[[buffer(kIndex)]] is at the index kIndex gives).
The AIR reader now decodes the function bodies of a module that declares
function constants. Under the function's constant values it runs the
module's initialisers (the stores that set the globals a computed index,
count or predicate is read from), propagates the values through the
entry point's branches, switches, selects and phis, and marks used the
arguments a live instruction of a reachable block reads.
For the guest: such a pipeline now answers a reflection, its arguments
at the indices and counts its constants compute, and an argument read
only in code its constants remove answers isUsed and isActive 0. Where
the reader does not follow the module's code, the answers are as before.
Car 14's stack: resolved over c14-air-cache's one read of a module (104f648f8).
The specialisation code sits before visibleOf in the anonymous namespace,
rgfxAirSpecialise after rgfxReadAirEntries outside it, and finishCode takes a
const Module. rgfxReadAirEntries and rgfxReadAirModule read with wantCode;
where the cache's read with code fails, the module is read again without it for
its functions and visible functions, so only its entry points go unread, as on
this lane. rgfxAirEntryNamed copies the module's code pointer beside its
constants. The header keeps both includes and both sections.
pipeline_reflection_check gains the cases the bundle's pipeline reflection
answers nil for: nested argument buffers and their arrays, function and
intersection tables, acceleration structures, further texture types, an
imageblock, a 64-bit atomic texture, framebuffer fetch and tables in a
fragment function, and functions whose binding index, predicates and
reads function constants decide. With -v a case ours does not make
prints Metal's instance variables too, and a case Metal makes no
pipeline of prints its error without counting as a difference.
dgpu-oracle.md Q22 holds oracle_mesh's and base_answers_probe's measurements
on the 5300M, the Intel 630 and the M3 Max, each classified, and what the lane
answers. design.md names FEATURES_LO bit 25 and the mesh create in the wire's
table, and the oracle README lists oracle_mesh.
oracle_mesh makes mesh render pipelines of each descriptor shape an app sets
(object functions, the maxima, the payload, required sizes, no fragment or no
mesh function, functions of another stage, archive misses, indirect command
buffer support), and prints the state's answers. It draws each mesh draw form
into a target and prints which threadgroups of what grid ran, and makes
indirect command buffers of the mesh command types and executes a mesh draw
from one. The mesh lane matches the x86 Macs' answers it measures
(docs/graphics-kext/dgpu-oracle.md, Q22).
Every pipeline creator answered a nil reflection, whatever its options. An
app that asks for MTLPipelineOptionBindingInfo or BufferTypeInfo to find its
buffers' indices, sizes or struct layouts found none.
What changes for the guest: a render, mesh or compute pipeline made with
either option now answers Metal's own reflection (its private reflection
classes), in the synchronous creators and in the completion handlers alike.
It is built in the guest from the AIR of the pipeline's functions and its
vertex or stage input descriptor: each stage's bindings, built-in arguments,
types and struct members, and the private postVertexDumpStride. Options of
neither still answer nil. A pipeline the bundle cannot answer exactly (an
index function constants compute, a kind no x86 Mac was measured for, a
function of no library of ours) still answers nil, logged once per reason.
An argument read only in code its function constants remove is answered
used, where Metal answers it unused; Intel's postVertexDumpStride is 4 less
than ours, which is AMD's. Nothing changes on the wire.
The values are an x86 Mac's (macOS 26.7.1, AMD Radeon Pro 5300M and Intel
UHD Graphics 630), measured with the oracle_reflection probe and recorded in
docs/graphics-kext/dgpu-oracle.md, Q20. tools/pipeline_reflection_check.mm
makes the same pipelines on a device and compares its reflection with ours,
getter by getter and instance variable by instance variable: over 80 cases it
finds no difference on the AMD GPU, and on the Intel GPU only that stride.
The shell test checks ours over the probe's library. RgfxMeshPipelineReflectionOf is the
mesh creators' to answer once they make mesh pipelines.
Car 13's stack: resolved docs/graphics-kext/dgpu-oracle.md, where c13-contract
added Q20 (textures over an IOSurface) first: this commit's section is Q21, and
the probe list names oracle_surftex and oracle_reflection;
guest/bundle/Makefile's shell tests take both RGFX_AIR_REFLECTED
(c13-wire-gaps) and RGFX_ORACLE_REFLECTION.
oracle_reflection makes render, mesh and compute pipelines of
oracle_reflection.metal's functions on a device, with each pipeline option,
and prints the reflection each creator answers: every getter of every
object, recursively, and with ORACLE_IVARS set every instance variable. Its
walker is oracle_walk.h, which the bundle's pipeline_reflection_check shares.
The functions cover buffers of each value type, structs and arrays of them,
argument buffers, threadgroup memory, textures of each type and access,
samplers, arguments the function never reads or a function constant gates,
stage inputs, built-ins, outputs and payloads. It measured the x86 Macs'
answers the bundle's pipelines' reflection is to equal.
Car 13's stack: resolved guest/bundle/tools/oracle's README.md and build.sh
against c13-contract's oracle_surftex and the oracle_bundle cases of
c13-answers and c13-wire-gaps: kept every probe's row and build.
oracle_surftex's third round asks for a texture of each two-plane format,
the Y'CbCr ones of 4:2:0, 4:2:2 and 4:4:4 chroma and the extended-range one,
over a 420v surface's luma plane, and of format 500 over its chroma plane and
over a one-plane surface: what the x86 Macs answer for the formats the bundle
had measured only at 500.
oracle_bundle's second round for the bundle's remaining divergences: what
copyIOSurfaceSharedTextureProperties: answers across formats, sizes, levels and
slices, an encoder at a function's plain buffer and at an index it has no
buffer at, setting a depth/stencil state or nil into an argument buffer, and
what a function array's library answers.
oracle_bundle gains the cases the bundle's remaining divergences need Metal's
answer for on the x86 Macs: a depth/stencil state in an argument buffer, an
encoder made from a buffer binding or with its reflection, the device's
copyIOSurfaceSharedTextureProperties: and newBufferWithIOSurface:, a shared
event's port and NSCoding, which slices of a binary archive Metal reads, and
more forms of a function array's and a package's library.
Car 13's stack: resolved guest/bundle/tools/oracle (README.md, build.sh,
oracle_bundle.m) against c13-answers' probes (texaddr, texmem, nocopy,
linalign): kept both lanes' cases, their comments, helpers and dispatch arms
(no name in common), the includes of both, and both lanes' metallibs and the
IOSurface framework in build.sh.
Every Mac measured makes a no-copy buffer over read-only memory and drops
its GPU writes, a file under it included, where the host's buffer over a
pages block takes them: in place they would reach the process's read-only
pages. The shadow never writes back to read-only memory, so it drops them
as Metal does. The oracle README names oracle_bundle's new cases.
nocopy.copies asks whether a GPU read of a no-copy Managed buffer sees a CPU
write made with no didModifyRange:, and whether the CPU sees a blit's write
with no synchronize, the two questions that tell one copy from two.
oracle_bundle gains four groups of cases for the guest bundle's answers that
differ from Metal's: texaddr (the SPI gpuAddress, virtualAddress, resourceSize
and allocationID of textures of each storage mode and shape, in heaps, over
buffers, as views and over IOSurfaces), texmem (where a Shared or Managed
texture's texels lie at its virtualAddress, and what CPU and GPU writes there
show), nocopy.ro (a no-copy buffer over read-only anonymous and file memory,
and what GPU reads and writes do with it), and linalign (the linear texture
alignment of every raw format to 799 and a few past it, one child each).
Safari's requestAnimationFrame runs at 60 on the kext lane's 120 Hz display and at
120 on some pages of the paravirt lane. WebKit takes the rate from the main display's
CVDisplayLink nominal period, once per UI process, and with its "Prefer Page Rendering
Updates near 60fps" default asks for nominal / (nominal / 60) frames a second. This
probe prints every answer a Mac gives about the display's rate (CGDisplayMode,
NSScreen, CVDisplayLink nominal samples and callbacks, NSScreen's CADisplayLink), the
installed WebKit's default for that feature, the rate WebKit's rules predict, and,
with -w, the rate a WKWebView measures with the feature on and off.
oracle_surftex asks newTextureWithDescriptor:iosurface:plane: for a texture
over a plane of six 64 x 64 surfaces ('BGRA' with and without planes, 'BGRA'
without planes of 512-byte rows, 'RGhA', 'L008', a CVPixelBuffer's '420v'),
one case a child process, changing one thing of the surface's own shape a
case: the plane, the size, the type, depth, array length, levels and samples,
the pixel format against the plane's elements, compressed formats at the
rows' edge, the usage, storage, CPU cache and hazard tracking modes and the
swizzle. Each case prints the texture made, nil, or Metal's words and the
signal where it ends the process. The bundle answered a texture for every
one of them the host did not refuse later; this measures what Metal answers
at the call.
The bundle is to end the process where the x86 Macs' texture descriptor
validation does at a depth or stencil texture the CPU reaches. oracle_bundle
measured that at a texture over a Shared buffer (buftex.depth); devtex.* asks
the same of the device's own newTextureWithDescriptor:, in Shared, Managed and
Private storage, so the bundle's device creator follows a measurement too.
The first run on the AMD and Intel Macs ended four cases early at Metal's own
assertions (a Shared heap, an empty function array, a dynamic library's
exported function) or at a crash in the archive case on AMD. The cases now
skip what ends the process, and failmiss2 measures newFunctionWithDescriptor:
failing on an archive miss for each stage, by the options the function was
added with and by the kernel's constant values.
The bundle answers nil for a texture view of levels, slices, a type or a format
class its texture does not take, where the M3 Max's Metal ends the process, and
for a texture over a buffer whose rows are shorter than the texture's. The new
cases measure what the AMD and Intel Macs do there, and what the public
texture-over-buffer form does with formats whose linear alignment query may end
the process.
The guest bundle's device answers some calls otherwise than Metal: buffers'
allocatedSize, event creators with options, binary archives over fat files,
newFunctionWithDescriptor: on an archive miss, the type of functions of other
stages, a dynamic library's type, and more. oracle_bundle measures what an AMD
or Intel Mac answers for each, one case a child process, so the bundle can
answer the same where every Mac agrees.
oracle_storage's lintypes case makes a texture of one MTLTextureType over a
Shared buffer by the public form, the linear SPI or the tiled SPI, and
prints whether it is made or nil, or Metal's words where its assertion ends
the process. The linarray case found that all three Macs end the process at
a 2D array by the public form, which the bundle sends to the host.
oracle_storage's linarray case makes a 2D array of three BGRA8 slices over a
Shared buffer, by the linear SPI with three bytesPerImage values and by the
public form, and prints where replaceRegion: of each slice lands, what the
GPU reads of each, and what getBytes: reads after the CPU writes the buffer.
The bundle's CPU copies of a texture over a buffer refuse slices past 0, and
fixing them needs Metal's slice pitch on the AMD, the Intel and the M3.
oracle_cmdbuf events on the 5300M, the 630 and the M3: the CPU's value,
waits and listeners see a shared event's signal from the middle of a buffer
before the buffer ends, and the wait-then-set pattern completes on all three;
the AMD and the M3 see it within a few milliseconds of the GPU reaching it, the
630 about 100 ms after the commit. A trailing signal's listener runs within
0.3 ms of the completed handler.
oracle_cmdbuf's new events case times a shared event's signal encoded
between two kernels of one command buffer as a listener, a poller and a
waiter see it, against the buffer's GPU times and completed handler; runs
the pattern where the CPU waits for a mid-buffer signal before it sets the
value the same buffer waits for next; and times a trailing signal's listener
against the completed handler. The host posts a buffer's signals only at its
end, and these answers say when Metal's reach the CPU.
The lone submit was measured with a scratch probe that was never committed.
The submit probe now has the call's cases: an empty and a tiny buffer after
an idle gap, with the call's time and its start to the scheduled handler,
and a tiny buffer behind a buffer of a few milliseconds on its queue.
oracle_names' archive case added mesh pipelines with no mesh function only,
which Metal's own descriptor validation refuses on the M3 before the archive
sees them. Its new step adds the pipeline an app adds, a mesh function and a
fragment function, and makes that pipeline on the device, so the bundle's
answer for it is measured too.
The bundle answers a function made with a constant value of another type, and a
binary archive's mesh-pipeline add with no mesh function, with words of its own
where Metal's are unmeasured: a type outside the constant types it names prints
as MTLDataType(N), and the mesh add's refusal is ours. oracle_names measures
Metal's, on any Mac GPU picked by name, each step in a child of its own, so a
step Metal's validation ends is reported and the rest go on. It also checks a
bfloat constant, a type the bundle's constant table does not hold. [ci skip]
A busy desktop runs short of the region where each Managed texture's CPU copy or
read-only no-copy buffer's GPU copy takes a block of its own. The keep cases make
Managed textures, read-only Shared no-copy buffers and Managed no-copy buffers
until Metal answers nil or a limit, and -check reads each one's bytes back, so a
guest run shows how much one process holds and that the copies read right.
WindowServer makes a Managed texture where a device refuses its linear
texture over a buffer, so what a make costs is part of that fallback's
price. upload_probe's mk.SHAPE times newTextureWithDescriptor: and the
release of a Managed texture at WindowServer's shapes, and a new texture
filled by replaceRegion: and read by a blit, against the same blit of a
texture made before.