Since c13-contract (ae37ce1c2) the bundle answered nil for a BC1 to BC7
texture over an IOSurface or one of its planes, before it took a view of the
surface. Metal on the x86 Macs makes these wherever the rows fit, over a
surface with planes or without, in Managed or Private storage
(oracle_surftex, Q20). The nil was the host's limit: pin 14's runtime made
no texture of one over a surface's rows (NotLinear). metal2vulkan's stack
34, at this branch's pin, makes them in the x86 Macs' form, row j of blocks
at the plane's row j (on MoltenVK as a shadow image), and the bundle's own
CPU access takes the same rows since 187d1ee33. Runtime gaps are
metal2vulkan's, and ours go at the pin that fixes them.
What changes for the guest: newTextureWithDescriptor:iosurface:plane: of a
BC format answers a texture and posts its create, where it answered nil and
logged "no texture (descriptor)". The shapes stack 34 still refuses (a BC
texture over a plane at an offset or rows off 16 bytes, or wider than the
plane's rows) are posted and refused as the host's other refused shapes are
(decode/refused.rs). On the Metal platform, whose buffer creator answers nil
for BC as Metal's IOSurface creator does (87b24e27e), the texture is a
refused create too.
Test: test_iosurface_block_compressed_textures_are_made fails at the base,
where the bundle answers nil.
A texture over an IOSurface read and wrote its rows on the CPU (getBytes,
replaceRegion) in the surface's elements, not the texture's texels. A
texture of a narrower format than the surface's element wrote past the
caller's rows: an R8Unorm texture over a 'BGRA' surface copied four bytes a
texel into a buffer of one a texel. A wider format copied too few bytes, and
a surface whose elements are not single pixels (a 4:2:2 one) gave none.
Metal reads and writes the texture's own texels, row j of them at the
plane's row j.
What changes for the guest: getBytes and replaceRegion of a texture over a
surface read and write the blocks of the texture's own format
(rgfxPixelFormatBlock) at the plane's rows, over a 4:2:2 surface too. A
texture of a format with no block there (depth or stencil, Private over a
surface) reads and writes nothing.
It is also the ground for block-compressed textures over a surface, whose
rows of blocks lie at the plane's rows.
Test: test_iosurface_cpu_access_in_the_texture_s_format fails at the base,
where the R8Unorm read writes past the caller's 256 bytes.
c14-shared-events and c14-texture-nil each added a Q23 to dgpu-oracle.md. The
car keeps shared events' Q23 and numbers texture-nil's two sections after it:
the texture descriptors each creator refuses are Q24, and what a command buffer
does with nil objects is Q25. The references in dgpu-oracle.md, design.md, the
decoder's refused.rs and the shell tests follow, and the report's probe list
names oracle_events, which shared events added to the oracle's README and
build.sh.
The bundle posted a BC1 to BC7 texture over a buffer's bytes, which the host's
platform makes none of (Metal's over a buffer, and metal2vulkan's linear
images), so the host refused it and every draw that named the texture was
dropped. The AMD 5300M answers nil for one over a Shared buffer, 64 x 64 and
62 x 64 (oracle_texdesc buffer bc1.*), where the Intel 630 makes it: the
envelope holds nil, and the bundle answers it, sending nothing.
For the guest: newTextureWithDescriptor:offset:bytesPerRow: of a
block-compressed format is nil. Both x86 Macs make a single block's (2 x 2),
which is now nil too.
A texture create is posted, not waited for, so a descriptor the host refused
left the app holding a texture whose every draw was dropped, where Metal on the
x86 Macs ends the process at its descriptor validation. The bundle copied a few
of its rules (three-channel formats, multisample compressed formats, depth in
CPU storage), and the IOSurface creator a subset of its own.
Every texture creator now runs one copy of
-[MTLTextureDescriptorInternal validateWithDevice:]: the device's, both of a
heap's, a buffer's public form and its linear and tiled SPI, and the creator
over an IOSurface. It follows the AMD 5300M and the Intel 630 under macOS
26.7.1 at the device, a Private heap and a Shared buffer (oracle_texdesc, 107
descriptors): every rule broken a line, in their order, in one assertion; the
sample counts the device makes; Depth24Unorm_Stencil8 and X24_Stencil8 lacked,
as on the Intel. A heap's creators then end the process at a descriptor of
another storage mode than the heap's, and a texture type past TextureBuffer
ends it with no words, as there.
For the guest: a process that sent the host a texture create Metal does not
make now ends at the create with Metal's words, and the host is sent nothing.
eventPort, newSharedEventHandle, newSharedEventWithHandle: and
newSharedEventWithMachPort: answered nil or raised unrecognized selectors. They
now answer as the AMD 5300M and the Intel 630 do under macOS 26.7.1
(oracle_events, identical on both), where the kext and the host carry ports:
- eventPort is the kext's port for the event, asked once and the same name at
each ask, which the event holds one send reference of;
- the handle is Metal's own MTLSharedEventHandle over it, which takes its own
reference, keeps the label, and crosses NSXPC as Metal's does;
- an event made of a port or a handle is the same host event at its value,
holds one more reference, and is labelled as the handle (nil from a port);
made of this process's own port it is the event's alias, which reads the
other's sets at once, as Metal's two events do;
- MACH_PORT_NULL, a dead name, a port the process receives, a port that names
no shared event, and a nil handle answer nil, the references as they were;
the bundle asks its own connection whether a port is the kext's
(IOConnectAddClient) before it calls on it, so another process's own port is
answered nil, where an IOKit call on it would kill the process;
- the event adopts NSSecureCoding and codes only through an NSXPCCoder, raising
NSInvalidArgumentException with Metal's words otherwise.
The values other processes give the event come on a queue of the device's own,
its listen queue. A value set in another process reaches this one as the host
posts it, where Metal's shared page is read at once: a read right after the
other's set may see the value before it.
The car 12 probe put a lone buffer's commit-to-scheduled-handler at about
390 us p50 on the RTX 5080 host, against 198 on an AMD Mac. Part of that is the
guest's own hops: the completion thread's wake, then the queue's completion
queue for each record. shell_tests --queue-timing [rounds] times them on the
bundle's real queue, reader and completion thread, with the kext's wait stood
in for: how long after the host's post of a CB_SCHEDULED, then a CB_COMPLETE,
the handlers run and waitUntilScheduled and waitUntilCompleted return, for a
buffer with both handlers, one with a completed handler alone and one with
none. It is a measurement, run by hand, never in make test.
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.
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.
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.
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).
For the guest: where the device takes MESH_PIPELINES, every
newRenderPipelineStateWithMeshDescriptor: form makes a mesh render pipeline. It
used to answer nil and an unsupported error. The render encoders send the object
and mesh stages' bindings and drawMeshThreadgroups:, drawMeshThreads: and the
indirect form, and the SPI's supportsMeshShaders answers YES. Without the
feature they answer as before. The state answers its object and mesh limits as
the host's platform answers them (maxTotalThreadgroupsPerMeshGrid NSUIntegerMax
past 32 bits) and the threadgroup sizes its descriptor required.
Measured with guest/bundle/tools/oracle/oracle_mesh, plain Metal, on the AMD
Radeon Pro 5300M and the Intel UHD Graphics 630 (macOS 26.7.1, 25G241) and the
M3 Max (macOS 27.0.1, 26A434), the creators now end the process where the x86
Macs' Metal does, with their words:
- supportIndirectCommandBuffers YES, on the 5300M and the 630 (the M3 Max makes
it): "validateWithDevice:1884: failed assertion `Mesh Render Pipeline
Descriptor Validation\nUse of mesh shader pipelines in indirect command
buffers is not supported by this device.\n'"
- no mesh function, on all three: "...\nmeshFunction must not be nil.\n'"
- no fragment function while rasterizing, on all three: "...\nfragmentFunction
must not be nil.\n'"
So no mesh pipeline supports indirect command buffers, and indirect commands
carry no mesh draw. This matches the families: supportsFamily: answers no for
Apple7 to Apple9 on the x86 Macs and on the device, and the SPI's
supportsMeshShadersInICB answers NO on the x86 Macs and the device (YES on the
M3 Max).
They refuse before the host is asked, in the x86 Macs' compiler's domain
(CompilerError):
- a payload past 16384 bytes, code 2, "payloadMemoryLength property of
MTLMeshRenderPipelineDescriptor (16385 bytes) exceeds maximum supported by
this device (16384 bytes)";
- a stage maximum past the device's 1024 threads, code 2, the 5300M's
"maxThreadsPerThreadgroup pipeline descriptor value (2048) exceeds maximum
supported (1024)\n" (the 630 makes it, the M3 Max refuses it);
- a vertex function as the mesh function, code 2, "RasterizationEnabled is
false but the vertex shader's return type is not void";
- any other function of another stage, code 1. The x86 Macs answer the
crashed compiler's XPC words; ours are the validation layer's;
- a mesh function as the object function, code 1, which the x86 Macs make
and the M3 Max refuses;
- an archive miss under MTLPipelineOptionFailOnBinaryArchiveMiss, code 2,
"Unable to find function \"f_col\" in binary archives. \n ". It names the
fragment function, else the mesh function. An x86 archive holds no mesh
pipeline, so every create naming an archive misses.
The creators with a reflection answer RgfxMeshPipelineReflectionOf's, the
reflection of the pipeline's functions, as the render pipeline creators answer
theirs.
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.
The bundle made two-plane Y'CbCr textures over a surface as the M3 Max does
(dgpu-oracle.md Q13, read as class 2). The lane imitates the x86 dGPU Macs,
and both end the process there: oracle_surftex's third round measured
"MTLTextureDescriptor has invalid pixelFormat (N)." on the AMD 5300M and the
Intel 630 under macOS 26.7.1 at every two-plane Y'CbCr format (500, 502, 503,
505 to 510, 520, 522, 523, 525 to 530, 540 to 545) and at the extended-range
RGB10A8_2P_XR10 and its sRGB twin (550, 551), over either plane of a 420v
surface, a one-plane surface and a surface without planes. Where both agree,
their answer is the lane's contract; the M3, which makes them all, is outside
its envelope. Q13 records the reversal.
What changes for the guest: newTextureWithDescriptor:iosurface:plane: ends
the process at a texture of any of these formats, at any size, with the x86
Macs' words, sending the host nothing. The odd-extent render target rule
folds into it. No code of the bundle makes such a texture: the video decoder
lands pictures through R8, RG8, R16 and RG16 textures over the planes. The
one-plane 4:2:2 formats (GBGR422, BGRG422) are made as before.
Test: test_invalid_surface_textures_end_the_process holds a death per format
over the luma plane, 500 over the chroma plane and over a surface without
planes, and passes for the planes' own formats and the 4:2:2 ones; it fails
at surface-ycbcr-flat with the rule stubbed out.
On a GPU that shares the CPU's memory the host laid a Managed texture over
its CPU copy only where it was a one-level 2D texture: every 2D array kept two
copies there, the guest's CPU copy and the platform's own texture, so it took
its size twice in memory, each replaceRegion: was copied again on the host,
and the guest's getBytes: of it waited for a device copy. The platform makes a
one-level 2D array over a buffer too, by the linear SPI, which lays each slice
at its rows' bytes rounded up to 128 (measured on the M3 Max; the Vulkan
platform's runtime alike, array_over_host_memory_is_metals), and a CPU copy's
rows are multiples of 256 bytes, so its slices lie where the copy's layout
puts them.
For the host: on unified memory MANAGED_TEXTURE_CREATE of a one-level 2D
array of a linear format is newLinearTextureWithDescriptor: over the CPU
copy's buffer, its rows and slices the layout's, in place of a
newTextureWithDescriptor: beside it; TEXTURE_REPLACE_REGION and
synchronizeTexture: of it copy nothing. A texture of the one-copy shape whose
texture over its buffer the platform refuses is logged once. On a GPU of its
own memory nothing changes but where it has no memory for the GPU's copy,
where such an array now takes the one-copy form too.
For the guest: where the device answers hasUnifiedMemory yes, getBytes: of such
an array reads its CPU copy, as a one-level 2D texture's does, with no device
copy (rgfxManagedLiesOverCopy). A mipmapped texture, a cube, a 3D texture and a
block-compressed one stay two copies: no texture over a buffer has their shape,
and without the CPU copy an upload would be a staging blit the call waits for,
340 to 420 us a call where a Managed one's is 2 to 4 (dgpu-oracle.md Q17).
An older bundle on this host reads such an array through a device copy, which
reads the one copy: correct. This bundle on an older host would read a CPU
copy the host keeps apart: the two ship together.
Car 13's stack: resolved a comment in shell_tests.mm over
test_managed_texture_reads_on_unified_memory against c13-answers (16c2a86ad):
kept this commit's 2D-array wording and c13-answers' virtualAddress sentence.
newArgumentEncoderWithBufferIndex: asked the host's layout at every index. Both
x86 Macs (AMD 5300M and Intel 630, macOS 26.7.1, oracle_bundle argbuf.index.1
and .5) make an encoder of no arguments, 0 bytes long, at a plain buffer's
index, and end the process at an index of no buffer, with "bufferIndex N does
not identify an argument buffer".
The guest's function now reads its AIR arguments for the index: a plain
buffer answers an encoder of no arguments (length 0, alignment 1, the AMD
5300M's) with nothing sent to the host; no buffer ends the process with
Metal's words; an argument buffer, or a function whose AIR was not read or
whose buffer index is a function constant's, asks the host as before.
newLibraryWithFunctionArray:error: went through Metal's own library of the
functions' shadows (46b5a4d66), but Metal's function-array library holds no
bytes to make ours over, so the guest got nil. Both x86 Macs (AMD 5300M and
Intel 630, macOS 26.7.1, oracle_bundle libforms2 and libforms3) make a library
that holds the given functions themselves, which a guest now gets:
- each function by its name, the very object given, whatever constants or
descriptor ask for it; nil, or MTLLibraryErrorDomain 5 "Function NAME was
not found in the library", for a name it lacks;
- its functionNames in the reverse of the order given;
- type Executable, no install name, label, reflection or extern functions,
and serializeToURL:error: refused with "MTLLibrary is not formatted as a
MetalLib file.";
- two functions of one name: nil and code 1 "function names must be unique";
- an empty array ends the process with Metal's assertion words.
Nothing goes to the host. The test of the old route is replaced by one of
these answers, with the empty array's death.
Guest-visible: an app's newLibraryWithFunctionArray:error: now answers a
library of the visible and stitchable functions given, where the bundle
answered nil and MTLLibraryErrorUnsupported. Both x86 Macs make one (AMD 5300M
and Intel 630, macOS 26.7.1: oracle_bundle libforms). It is Metal's own library
over the functions' shadows, made ours over its bytes, as the bundle's links
and stitches are.
newLibraryWithMetalPackageURL:error: and newLibraryWithMPSGraphPackageURL:
name:error: now run Metal's own reading of the package, the base class's, and
make a library it answers ours over its bytes, as a source compile is. So a
refusal is Metal's own: both x86 Macs answer MTLLibraryErrorDomain 1 "Invalid
metal package" for a missing path and a .metallib, where the bundle answered
code 1 in its own words, and MTLLibraryErrorDomain 6 "failed to open MPSGraph
package", logging "Error: did not find file at url", where the bundle
answered code 1.
Each surface's shared block holds four writer slots and four reader slots,
shared by every process's queues. A queue that found none free left its
access unnamed (logged once): a later write of another queue did not wait
for its reads, nor a later read or a present for its writes.
Where a record has no slot left for a queue, the bundle now gives it a slot
of its own process's that names a buffer of another of its queues which the
buffer runs after on the GPU, its post's SURFACE_ORDER having named that
buffer at the slot's seqno or later: whatever names the slot from then on
runs after both, as it ran after each. A read that finds no reader slot is
named among the writers instead (its queue's writer slot, a free one, or
one taken so), which every later buffer that uses the surface names. Only a
slot of this process's is written, and one raised past what the post named
is kept.
What the guest observes: an access to a surface whose record is full of
slots of this process's other queues is ordered against later accesses of
other queues as one with a slot is, where it was not ordered before; a read
named among the writers is also waited for by a later read of another queue
and by a present of the surface, which is later than a Mac would and never
sooner. An access whose records hold every slot for other processes' queues
is still not named.
Tests: test_iosurface_full_records_take_this_process_s_slots fails before;
test_iosurface_slots_free_at_completion's fifth queue's read is now named
among the writers until it finishes.
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.
A function of a library whose function list reads, but whose metadata names
no constants (no CNST tag, or one that does not read), resolved the values a
process set against no constants: every value set by name or by index was
dropped, and the host specialised the function with none, where Metal
resolves them against the constants the function's module declares.
What the guest sees now, for such a function: functionConstantsDictionary
answers the constants its AIR module declares (name, type, index, required),
values set by name and by index reach them, and a value of another type than
its constant's fails with MTLLibraryErrorCompileFailure, as for a function
with the tag. A function whose module declares none is unchanged, and so is
every function with a CNST tag. Apple's compiler writes the tag for every
function with constants (measured, previous commit), so this reaches only
metadata of other writers. The module is the one the library already reads
for the function's arguments, so no function costs a second read.
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.
A Managed texture in no heap answered virtualAddress NULL. Both x86 Macs'
Managed and Shared textures answer a CPU address, the memory getBytes: reads, in
their GPU's tiled layout: a CPU write there is what getBytes: answers next
(oracle_bundle texmem: AMD 5300M and Intel 630, macOS 26.7.1).
What the guest sees now: a Managed texture answers its CPU copy's address, laid
out as RgfxManagedLayout lays it, where replaceRegion: writes and getBytes:
reads, so a CPU write there is what getBytes: answers next, as on both x86
Macs. Such a write reaches the GPU's copy only where the host's texture lies
over the copy itself (a one-level 2D texture of a linear format on a GPU that
shares the CPU's memory: one copy, the Intel's rule); elsewhere it does not, as
nothing tells the host (the AMD's two copies), and the GPU sees it at no later
call but a replaceRegion: of those texels, which overwrites them. A Managed
texture the host keeps in two copies on a GPU that shares the CPU's memory reads
getBytes: from its GPU copy, so it still answers NULL, as do Shared textures,
whose memory the device keeps nowhere the CPU reaches.
minimumLinearTextureAlignmentForPixelFormat: answered 256 for every raw format
but the 105 of the SDK's that 3274b39d1 ended the process at. Both x86 Macs'
Metal (AMD 5300M and Intel 630, macOS 26.7.1, no validation layer; oracle_bundle
linalign over every raw value from 0 to 799 and 1000, 1023, 4096 and 65535)
answer 256 for 64 values alike, the SDK's 46 and 18 it has no name for (84, 85,
300 to 304, 313 to 315, 323 to 325, 556, 586, 587, 628, 629), and end the
process at all the others, with the compressed or depth words for those
formats and MTLPixelFormatInvalid for the rest.
What the guest sees now: the query answers 256 for those 64 values only, and
ends the process with Metal's words at every other: MTLPixelFormatInvalid (0),
the Y'CbCr formats, and values no format has among them, which answered 256
before. The bundle's own callers still ask the internal query, which ends
nothing.
Car 13's stack: resolved RgfxTexture.mm's rgfxEndAtUnalignableLinearFormat,
where c13-contract had moved the same lacked-format list into rgfxDeviceLacks
(kept for its other use): took this commit's answered-format list, which ends
at every lacked format too.
A no-copy Managed buffer over writable app memory took a shadow: a range of
a slab as its CPU copy, synced with the app's memory at every commit that used
it and written back at every completion that might write it, and on a discrete
host a third copy, the platform's own Managed buffer, beside it.
Where the region has pages blocks it now lies over the app's own pages, as a
writable Shared one has since 2c09b2196: a BUFFER_OVER_PAGES whose buffer the
host makes Shared, so the memory is one copy on every host, as the Intel 630's
no-copy Managed buffer is (dgpu-oracle.md Q3; the AMD 5300M keeps two, and
Metal's contract for the mode allows either). The buffer still answers the
Managed options it was asked. Its didModifyRange:, and a blit's
synchronizeResource: or synchronizeTexture: of it or of a texture over it,
send the host nothing, as one copy has nothing to bring over.
What the guest sees: a GPU write to such a buffer shows in the app's memory as
the GPU makes it, not at its command buffer's completion, and a CPU write is
seen by the GPU's next read with no didModifyRange:, as on the Intel 630.
Read-only memory, and memory the kext or host makes no pages block of, keep
the shadow.
A block-compressed format over a surface was sent to the host and answered
a texture. The host's runtime makes no texture of one over a surface's rows
(metal2vulkan's NotLinear), so every command buffer naming it failed.
The AMD 5300M and the Intel 630 make BC1 and BC7 textures there wherever
the rows fit, over a surface with planes or without, in Managed or Private
storage (oracle_surftex). The nil is the host's limit, not Metal's, and is
outside the x86 envelope; it is the better answer while the host makes
none, since the guest's frameworks can take a nil and go another way, where
a refused texture fails their work later. The host's gap is on the ledger.
What changes for the guest: the bundle answers nil at the call, before it
takes a view of the surface, and logs it once ("no texture (descriptor)").
Test: test_iosurface_nil_is_logged fails at the base, where nothing is logged
for the descriptor.
newTextureWithDescriptor:iosurface:plane: sent every descriptor to the host,
posted and not waited for, and answered a texture. The host's runtime refuses
most of what Metal's validation stops, so the guest held a texture whose every
command buffer failed later.
oracle_surftex measured what Metal does instead on the AMD 5300M and the
Intel 630 under macOS 26.7.1: it ends the process, alike on both, in three
steps. The descriptor's validation, over every surface, stops a zero width or
height, a format the device lacks, a depth, array length or sample count
above 1 that the type does not allow, a multisample texture of one sample or
in Shared or Managed storage, Memoryless storage, and a 4:2:2 format of an
odd width. Over a surface without planes it then stops a type other than 2D
or TextureBuffer, a depth other than 1, more than one level, rows of a format
of one texel a block wider than the surface's, and depth or stencil formats;
then a plane past 0, a compressed format's rows in blocks wider than the
surface's, and more rows than the surface has. A plane of a planar surface
takes everything past the first step.
The x86 Macs also end at every two-plane Y'CbCr texture ("invalid
pixelFormat (500)."), which the lane makes as the M3 Max does (Q13). A render
target of one of 4:2:0 or 4:2:2 chroma at an odd width or height is the
exception: neither the M3 (which answers nil) nor the host makes it, so it
takes the x86 Macs' answer.
What changes for the guest: the device's creator now ends the process at
each of these with the x86 Macs' words, sending nothing, as the bundle's
other texture creators do. A plane past a planar surface's planes stays nil,
as on both.
Test: test_invalid_surface_textures_end_the_process (65 cases, each death in
a process of its own) fails at the base, where surface-width-0 goes on.
Guest-visible: an app's newHeapWithDescriptor: with Shared storage now ends
the process with Metal's words ("Heap Descriptor Validation\nShared storage
mode disallowed"), where the bundle made a heap over host memory; and a depth,
stencil or depth-stencil texture in Shared or Managed storage, from the
device's, a heap's or a buffer's texture creators, ends it with Metal's
"Depth, Stencil, DepthStencil textures cannot be allocated with
MTLStorageModeShared or MTLStorageModeManaged on this device.", where the
bundle made one. Neither sends the host anything.
The x86 lane imitates an x86 Mac's GPU, and both oracles, the AMD 5300M and
the Intel 630 under macOS 26.7.1, end the process there: at a Shared heap
(oracle_bundle heapbuffers), at a Depth32Float texture in Shared storage over
a buffer (buftex.depth), and at the device's Depth32Float in Shared or Managed
storage and Stencil8 in Managed (devtex.*), making the Private one. The M3 Max
makes the heap and the texture over a buffer, but is no oracle of this lane.
The heap's region argument is now unused.
test_library_type_and_install_name posts five libraries, two of the stitchable
test library's 12 KiB and three of the compiled dynamic library, through the
fixture's default 32 KiB control ring, which nothing drains in the test: the
last create answered nil. Its fixture now takes a 256 KiB ring.
The exported-function death test compiled a dynamic library on the Mac and
named its first function, which needs the bundle's reader to read that
library's function list. It now makes its library in metallibOf's layout,
one function of TYPE 3, so the death it checks does not hang on what the Mac's
compiler writes. The type and install-name checks keep the compiled library.
test_unread_function_list_answers_from_shadow posts the AIR test library
(228 KiB) and test_function_patch_answers the patch library, 44 KiB since
74e5868b8 added a mesh, an object and an intersection function, through a
control ring of the fixture's default 32 KiB, which a library create must fit:
each create answered nil. Their fixtures now take rings their libraries fit.
test_linked_function_specialised_on_the_wire wrote its visible function's
metallib entry as TYPE 3, which the bundle read as Visible until 47a241699. TYPE
3 is a dynamic library's exported function, which the bundle now ends the
process at as both x86 Macs do; Apple's compiler writes a visible function as
TYPE 4 (oracle_bundle functypes).
test_event_routing let each event made with options go before the next was
made, so its destroy came between the creates the test reads. The register now
lists newEventWithOptions: and newSharedEventWithOptions: as implemented, as
83b9a8031 answers every options value Metal's x86 Macs answer, and
protocol_members_tests fails a 'partial' member with no RGFX_UNSUPPORTED.
A guest app that makes a function of a dynamic library's exported function
(TYPE 3 in the metallib's function list, which no MTLFunctionType names) now
dies there with Metal's words, "validateMTLFunctionType: failed assertion
`type is not a valid MTLFunctionType.'", where the bundle answered a function
of type Visible. Both x86 Macs' Metal ends the process at newFunctionWithName:
for it (AMD 5300M and Intel 630, macOS 26.7.1; oracle_bundle functypes.dyn).
A guest app's newFunctionWithDescriptor: with
MTLFunctionOptionFailOnBinaryArchiveMiss and binary archives named now answers
nil and Metal's error where both x86 Macs do (AMD 5300M and Intel 630, macOS
26.7.1; oracle_bundle failmiss and failmiss2), where the bundle made every
function before:
- a kernel no named archive holds by its name and constants' values, added
either way: MTLLibraryErrorFunctionNotFound, "Failed to find specialized
function "NAME" in binary archive";
- a visible function asked with MTLFunctionOptionCompileToBinary too that was
not added with it: MTLLibraryErrorCompileFailure, "Compilation failed:
\n\nFailed to find compiled function in binary archives.".
Every other function is made, as on both Macs: one asked without failing on a
miss or naming no archive, a visible function asked without
CompileToBinary, and vertex and fragment functions.
An archive keeps a visible function added with CompileToBinary under a key of
its own, so a function added either way keeps its earlier key, and the add
makes the function without looking it up in the archives its descriptor names.
A guest app now sees a dynamic library's metallib (header file type 2),
loaded as a plain library from a URL or from data, answer MTLLibraryType
Dynamic and the install name its bytes hold, where the bundle answered
Executable and nil for every library. An executable library now answers the
last part of the URL it was made from as its install name, or
default.metallib for one made from data or source, where it answered nil.
Both x86 Macs answer so (AMD 5300M and Intel 630, macOS 26.7.1; oracle_bundle
libtype and functypes). The dynamic library's install name comes from its
shadow, Metal's own library over the same bytes.
A guest app now sees allocatedSize in whole 4 KiB pages for a Private buffer
(its length rounded up, 4096 for 1 byte) and for a no-copy buffer (the pages
its bytes meet, 0x15000 for 0x14000 bytes 0x123 into a page), where the
bundle answered their length before. Both x86 Macs answer so (AMD 5300M and
Intel 630, macOS 26.7.1; oracle_bundle buffers in every storage mode, and
nocopy.* with 8192 for 4096 bytes 16 into a page), as the bundle's Shared and
Managed device buffers already did through their slab ranges.
A guest app now dies, with Metal's words, at a texture view Metal's own
validation ends the process at on both x86 Macs (AMD 5300M and Intel 630,
macOS 26.7.1, no validation layer; oracle_bundle view.*), where the bundle
answered nil before: a view in no format (MTLPixelFormatInvalid), in a format
of one texel a block of other bytes than the texture's (RGBA16Float in
RGBA8Unorm), at levels or slices past the texture's, of a type of another
family (a 2D texture as 3D), and as a cube of a slice count not a multiple of
six. The words are _mtlValidateArgumentsForTextureViewOnDevice's "Texture
Creation" lines, measured alike on both GPUs.
The M3 Max under macOS 27.0.1 ends the process at the same views but answers
nil for one in no format; the x86 lane follows the x86 Macs. Views no oracle
measured (empty ranges, a 2D view of two slices, compressed formats) keep their
nil answer. The type rule follows rgfxViewFamily's families, measured on the
M3, so a 3D texture viewed as 2D dies as the 2D texture viewed as 3D does.
minimumLinearTextureAlignmentForPixelFormat: answered 256 for every format.
On the AMD 5300M and the Intel 630 under macOS 26.7.1, with no validation
layer (oracle_caps formats), Metal answers 256 for 46 of the SDK's formats and
ends the process at the other 105, alike on both: _MTLDevice's assertion that
"Linear textures do not support compressed pixel formats" (BC and 4:2:2),
"... depth/stencil pixel formats", or that MTLPixelFormatInvalid "is not
supported on this device" for a format the device lacks (sRGB R8 and RG8, the
three-channel formats, PVRTC, EAC, ETC2, ASTC, D24S8 as the lane answers no
Depth24Stencil8, Unspecialized, XR10). The M3 Max ends it at 95.
What the guest sees now: that query ends the process with Metal's words at
those 105 formats and answers 256 for the rest, those no oracle measured
among them. The bundle's own callers (the linear-alignment check of a texture
over a buffer, the video planes' alignment) ask an internal query that ends
nothing, as Metal's own texture creators over a buffer do not end the process
there (oracle_bundle buftex.bc1: AMD nil, Intel made).
newEventWithOptions: and newSharedEventWithOptions: (SPI) refused every
options value but 0, logged as unsupported. The AMD 5300M and Intel 630 under
macOS 26.7.1 (oracle_bundle events) answer the event of the form without
options for every value from 0 to 16, and the shared event for 0 and 1, nil for
any other.
What the guest sees now: newEventWithOptions: answers an event for any options,
and newSharedEventWithOptions: a shared event for 0 and 1 and nil, unlogged,
for any other.
A .metallib function list's TYPE tag of 6, 7 or 8 answered Visible. Apple's
compiler writes 6 for an intersection function, 7 for a mesh function and 8 for
an object function, and Metal answers MTLFunctionTypeIntersection, Mesh and
Object for them (measured on the AMD 5300M and Intel 630 under macOS 26.7.1,
oracle_bundle functypes, and on the M3 Max by the shell test).
What the guest sees now: such a function's functionType is its stage's. A
[[visible]] or [[stitchable]] function (tag 4) still answers Visible, and the
test library gains one function of each of these stages.
A library whose .metallib function list the bundle does not read (bytes the
host and Metal take but this reader does not follow) vended a function for any
name, of the placeholder stage Vertex, and dropped constant values set by
name. Metal answers such a library from its own reading of the same bytes.
What the guest sees now, for such a library: its functionNames are its
shadow's (Metal's own library over the same bytes), a name the shadow lacks is
nil (FunctionNotFound with values), each function has the shadow's type and
patch, its functionConstantsDictionary is the shadow's, and values set by
name resolve against those constants as they do for a table that read, a
value of another type failing with MTLLibraryErrorCompileFailure. A library
with no shadow answers as before. Libraries whose list reads are unchanged.
newTextureWithDescriptor:offset:bytesPerRow: of any type but 2D, and the
linear SPI of any but 2D, 2D array and texture buffer, now end the guest
process with Metal's words, where the bundle used to send them to the host,
whose Vulkan platform ends the host's process at a texture over a buffer it
does not make (resource.rs, new_texture). Measured with oracle_storage
DEVICE lintypes FORM:TYPE: the AMD 5300M, the Intel 630 and the M3 Max say
the same at a 1D, 1D array, cube or cube array type, and at a 2D array by
the public form; at a 3D one the M3 and the AMD add a depth line and the
Intel GPU says other words; at a multisample one the M3 names the type and
the x86 GPUs stop earlier at its Shared storage. The bundle says the M3's
words where they differ. A texture buffer by the public form, not measured,
answers nil, logged once. The tiled SPI answers nil for any type but 2D,
logged once: the AMD and the Intel GPU make each type there, the M3 has no
such selector, and the host does not carry them.
A view of more than one slice of a linear 2D array over a buffer, a view
in a format alone of such an array among them, is now nil, logged once,
and the host is sent nothing. The bundle used to send it, and the host's
Vulkan platform ends the host's process there (resource.rs, BufferSlices),
as Metal asserts at it (sliceRange.length == 1, measured by metal2vulkan
on the M3 Max and an M4: read from its REFUSALS.md). Nil follows the
bundle's rule for the other views Metal asserts at. A view of one slice is
made as before; the slices test now views one slice, and checks that two
and all three answer nil.
replaceRegion: and getBytes: of a texture over a buffer reached only slice 0:
slices 1 and up of a linear 2D array (newLinearTextureWithDescriptor:offset:
bytesPerRow:bytesPerImage:) were dropped, with a log line, so the app's bytes
never reached them and its reads came back untouched.
What changes for the guest: a CPU copy of slice s of such a texture reads and
writes the buffer's bytes at s times the slice pitch past the first slice,
the pitch the host's linear form lays the array out by: its rows' bytes
rounded up to 128, whatever bytesPerImage the texture was made with, as
Metal's (measured on the M3 Max and an M4 by metal2vulkan, whose runtime lays
the array out the same). Over a Managed buffer the host is told that slice's
span. A view of later slices reaches them through its texture, as before. A
slice past the array copies nothing, logged, as any copy the texture cannot
reach.
test_buffer_texture_slices writes and reads each slice of a 4 x 3 BGRA8 array
rows 32 bytes apart, whose slices take 128 bytes each, and through a view.
A command buffer the host answers on its doorbell's vCPU has its
CB_SUBMITTED on the queue's completion ring before the doorbell write
returns. The committing thread still slept until the vector's interrupt
woke the framebuffer's work loop, which woke the completion thread, which
took the record and woke the committing thread: three guest thread wakes,
each a vCPU that may be halted, for a record already in place.
For the guest: a buffer that asks for its submission now looks for its
record on the ring as its post returns, after the bookkeeping a submitted
buffer is held to, and where it is there, commitAndWaitUntilSubmitted
returns at once, the buffer submitted and still Committed. The look reads
at most 64 records and takes none, so the completion thread still takes
each record in ring order and runs its handlers. A buffer not answered at
its doorbell waits as before. Nothing changes for the host.
Metal submits a command buffer that waits on an event below its value only
once the wait is met, and every buffer behind it on its queue with it. Until
then it orders no other queue's or process's access to an IOSurface after
the buffer: on the oracle's 5300M and 630 (macOS 26.7.1), another process's
blit of the surface, and its read-only CPU lock, went on at once while the
write waited on its event, the blit reading the surface as it was.
The bundle named every buffer's accesses at its post: its writer or reader
slots, which other queues' posts name in SURFACE_ORDER, and its writes to the
kext, which CPU locks wait for. So a read posted while such a write waited
was held behind it on the host's GPU, and a lock in the kext, for as long as
the event stayed below its value: a hang where a Mac has none, wherever the
event's signal waited on that read.
A buffer is now held at its post where it waits on an event below its value
as its process knows it (a shared event's value as the host posted it and
the CPU set it; a plain event's as the host finished the process's buffers
that signalled it), or is posted behind a held buffer of its queue. A held
buffer names its accesses at its CB_SCHEDULED, which the host posts once its
platform has scheduled the buffer, past its waits, or at its completion where
none came. A delivered buffer names nothing, so no write reaches the kext
after its retire.
What the guest observes: a read, CPU lock or present of a surface by another
queue or process, posted while a write of the surface waits on an event below
its value, goes on at once and sees the surface as it was, as on a Mac; it
waited for the write before. A wait already met holds nothing, and such a
buffer's accesses are named at its post as before.
test_iosurface_held_buffer_names_at_scheduling holds a write that waits on a
plain event nothing signalled, and the write behind it, until each is
scheduled, and names at the post a write whose plain or shared event is met.
A surface's shared block holds four writer slots and four reader slots,
shared by every process's queues. A buffer's post names, from them, the
buffers of other queues it runs after (SURFACE_ORDER), and a present waits
for the writers. A queue kept its slot until the queue itself went, though
the buffer it named had long finished. So once four queues had used a
surface, WindowServer's and other long-lived processes' among them, a fifth
found no slot: its reads were named to no later write by another queue, and
its writes to no present or read. Per-process commit-order tickets take away
the last thing that ordered such a write after an answered read of another
process, its wait for the read's ticket.
A buffer's slots are now emptied once the host has finished it and its post
has named it, whichever comes second, where no later buffer of its queue has
raised them. A slot names a buffer only while it runs, and a buffer that
named a finished one would wait for nothing. The readers lie past the writers
in every block, as they did: the bundle laid out no block without room for
them, and two static checks of the layout now hold that.
What the guest observes: accesses to a surface by more than four queues
over time, with at most four of them in flight in each record, are each
ordered after the others' where one of two writes, as on a Mac; before,
every queue past the fourth went unordered. Waits for buffers that are
running are unchanged. test_iosurface_slots_free_at_completion reads a copy
another process writes, checks the slots a write of another queue reads
while the read runs and after it finishes, and gives a fifth queue the slot
a finished read left.
Where the host orders command buffers of different queues over the IOSurfaces
they share (SURFACE_ORDER), the bundle names, for each buffer, the buffers of
other queues it runs after, from the surfaces' writer and reader slots. It
read the slots at the commit. A buffer committed behind one enqueued before
it and not yet committed goes on its ring only once that one is, so another
queue's access to the surface could be posted in between: the held buffer
named the access before it, and the access, which found the held buffer not
yet in the slots, named nothing of it. The two ran unordered, where Metal
submits the held buffer after the access, and so runs it after (read from
Metal's enqueue order; no oracle has measured a held buffer's surface order).
The slots are now read at the post, just before the buffer goes on its ring,
where the commit order's names are read too. The device-cache uses
(SURFACE_USE), with the CPU's generation as of the commit, are still named
at the commit. Each buffer named was still posted before the post that names
it, so the waits run from later posts to earlier ones and cannot meet in a
cycle.
What the host observes: a held buffer's SURFACE_ORDER names the accesses of
other queues posted up to its own post. A buffer posted at its commit names
what it named before. test_iosurface_order's new case posts another queue's
write while a reading buffer is held: the held buffer names it.
fx-managed's test_managed_texture_reads_on_unified_memory called
managedTextureWithDescriptor:region:device:serializer:, which fx-capacity's
f36db2486 replaced with a form that takes slabs:. It now passes nullptr, as
f36db2486 did for every other region-block caller, so the test still makes
its CPU copy over a region block and checks what it checked before.