Commit Graph
235 Commits
Author SHA1 Message Date
Anees Iqbal 289cb3f0bd ✅ Add oracle_locks: whether Metal takes an app's locks
The bundle's app-lock tests hold @synchronized on a command buffer, a queue,
a function and the device while another thread does Metal's work on it.
oracle_locks runs the same steps on Metal, each in a child that must end
within 10 s, so the tests' expectation is Metal's answer. On the M3 Max under
macOS 27.0.1 every step finishes, except one that is the app's own deadlock:
a completed handler that takes the lock the buffer's waiter holds, where
Metal's wait never returns.
2026-11-26 17:35:58 -08:00
Anees Iqbal e4baca4322 📝 Add the queue priority oracle and its answer [ci skip]
On the Iris Xe, a guest's late frames come from the window server's writers
waiting on the GPU behind long buffers of the guest's background media-analysis
service. The guest marks that service's heavy queues setBackgroundGPUPriority: 2
and then setGPUPriority: 2, and WindowServer's setGPUPriority: 0. Our bundle
keeps the marks and answers them back, and nothing reaches the host. Before any
priority work is sized, the question was what an Intel Mac does with the marks.

oracle_prio answers first which of the four setters a queue answers and what its
getters read back. Then a second process commits a short compute buffer while
the first process's queue of 60 ms compute buffers runs, with that queue
unmarked, marked as the service marks its queues, both queues marked, and the
short buffer's queue alone marked as WindowServer marks its own.

Jobs m3-max-68129 and m3-max-68139 ran it on the MacBookPro16,1 oracle's Intel
UHD Graphics 630, and m3-max-68137 on its AMD Radeon Pro 5300M, under macOS
26.7.1. dgpu-oracle.md's Q50 records the answers:
- A new queue reads GPU priority 1 and background priority 2 on both GPUs, so
  the service's marks change only its GPU priority, to 2.
- The 630 runs queues of one GPU priority first in, first out. When the short
  buffer's queue has the lower value, it preempts the running long buffer and
  starts the short one within 0.44 ms.
- The 5300M runs the short buffer beside the long one within 0.44 ms, marked
  or not.
Our one VkQueue runs it after them all, in every case.

design.md's queue rings paragraph now says so, citing Q50. The oracle README
lists the probe, and build.sh builds it with the others.

Docs and the source of a probe built only for the oracle Mac: no check reaches
it ("docs and comments" in AGENTS.md). The probe was built with build.sh's flags
in jobs m3-max-68121 and m3-max-68136, with 0 warnings.
2026-11-22 09:40:21 -08:00
Anees Iqbal 670d9da12c 🎨 Keep the bounds case inside the oracle's 2 GiB jobs
The oracle's jobs reserve at most 2 GiB, and a job whose processes' phys
footprint passes its reservation is ended. The caller's bytes are now a
sparse file's pages, mapped shared, which the footprint does not count, so
a no-copy create that wires them stays inside the job. The buffer of bytes
at maxBufferLength, which commits its bytes where it is made, is not asked,
and the one past it runs last. Each line gives the footprint after the
create.
2026-11-22 01:29:33 -08:00
Anees Iqbal f37157e8a3 🆕 Measure the creates Metal bounds by a length, at the bound and past it
oracle_errors' bounds case asks each create whose length or size Metal
bounds for one at its bound and one past it, each step in a child process,
so a step that ends its process shows how: buffers of a length, of bytes
and over the caller's bytes at maxBufferLength, one byte and one page past
it, a no-copy length off the page, a Private heap there, a Placement heap's
buffer and texture at its end and past it, and the tiled texture SPI over
the caller's bytes. The bundle answers the no-copy form without a bound,
and nothing measured what the x86 Macs answer there.
2026-11-22 01:29:33 -08:00
Anees Iqbal 3187ecb859 🐛 Fix the oracle tools' warnings: 420v was boxed as 'v'
Built with build.sh's flags on the M3 (Xcode 27.2), the oracle tools printed
two kinds of warning, for x86_64 and arm64 alike:

- oracle_bundle.m: @('420v') boxed the multi-character constant as a char, so
  iosurf.buffer.420v asked IOSurfaceCreate for pixel format 118 ('v'), not
  '420v' (-Wconstant-conversion). It now boxes the four characters as a
  uint32_t, as probe_surface takes its fourcc.
- oracle_readonly.m: cpuShape's two texel arrays were sized by a static const
  NSUInteger, which C does not take as a constant expression, so clang folded
  each variable-length array to a constant one as an extension
  (-Wgnu-folding-constant). kSide is now an enum constant.

The tools are not among the sources of the prebuilt kext sets, so the sets
are unchanged.
2026-11-21 22:33:42 -08:00
Anees Iqbal 96cc4a9344 🆕 Add oracle probes of a queue's depth and the GL renderer's
The guest's GPU benchmark scene keeps about 3.4 to 3.8 frames of command buffers
in flight on our device, against about 1.7 on the 5300M Mac. The question was
whether an answer of ours lets the app run further ahead than a Mac would.

oracle_depth measures how many buffers one queue keeps uncompleted in front of a
busy GPU, where -commandBuffer blocks, whether commit or
commitAndWaitUntilSubmitted blocks before that, and when each buffer is
scheduled. oracle_gldepth hooks the Metal device's queue creators and the
queues' command-buffer creators under a CGL context that draws into an FBO, so
it reads what Apple's GL renderer over Metal asks for and how many buffers it
keeps in flight.

Q49 holds what they found:
- On the 5300M, the 630 and the M3, a queue keeps its maxCommandBufferCount of
  buffers uncompleted (34 on the 630 for an ask of 32), and blocks only in
  -commandBuffer.
- Each buffer is scheduled within 0.8 ms of its commit, 32 deep. The M3 alone
  schedules at most 36 of a queue ahead.
- Apple's GL renderer asks for 32 and keeps 32 in flight when the GPU is the
  slower side, as the guest's does on our device.
- The 5300M's 1.7 frames belong to AMD's own GL driver, which is not over Metal.
2026-11-21 22:06:20 -08:00
Anees Iqbal fd1316d5ac 📝 Add the cross-process backlog oracle and its answer [ci skip]
Q16 measured another process's access to an IOSurface behind one long pass.
It left open whether a read waits out the writing process's whole queue of
work ahead of the write, whether it also waits for what that queue commits
after the write, and whether a writer committed by a plain commit is ordered
at all.

oracle_backlog asks those three, as arms 1 to 3, each against control rounds
in which the read has nothing to wait for. Job m3-max-64081 ran it on the
MacBookPro16,1 oracle's AMD Radeon Pro 5300M and Intel UHD Graphics 630
under macOS 26.7.1, and dgpu-oracle.md's Q48 records the answers. On both
GPUs the read waits out the writer's queue ahead of the write, as our surface
order makes it. The 5300M orders the read by the surface alone and lets it
pass buffers the writer committed after the write; the 630 runs both
processes' work first in, first out, as our one VkQueue does. On the 5300M a
read after a plain-commit writer ran ahead of the write in 1 of 3 rounds;
our order, which never lets it, matches the 630 and is kept.

design.md's "Surface order" and surface_order.rs's module doc cite Q48 beside
Q16, the oracle README lists the probe, and build.sh builds it with the
others.

Docs, a doc comment and the source of a probe built only for the oracle Mac:
no check reaches it ("docs and comments" in AGENTS.md), and nothing was built
or run for this commit.
2026-11-21 09:32:44 -08:00
Anees Iqbal 7b842ef6fc 🆕 Time gameload's heap size query alone after its window
An Automatic heap's make asks the device for its texture's size first, a
call to the host, then makes the texture. To split the bloom chain's makes
into that query and the rest, the tool now asks the device's
heapTextureSizeAndAlignWithDescriptor: alone after its measured window, as
many times as the window's bloom makes, and adds their count, p50, p90 and
worst to the GAMELOAD calls line. Nothing in the window changes.
2026-11-20 23:25:26 -08:00
Anees Iqbal c2c9bbb713 🆕 Time gameload's heap object makes, and with -r their releases
The heap shape makes 10 objects a frame (two stream slots and the 1 MiB
vertex buffer placed in the placement heap, the 7 bloom textures in the
frame's automatic heap) and lets 10 go. To tell whether the calls themselves
hold the frame's extra time or what they cause later does, the tool now
times each make in the measured frames, and prints a GAMELOAD calls line:
their count, p50, p90, the worst and their time a frame.

Releases happen where the last reference goes, most of them as a command
buffer that holds them completes, off the encoding thread. -r holds each
frame's heap objects until the frame FRAMES_IN_FLIGHT + 1 frames later
starts, after its command buffers completed, and releases them there one at
a time, each timed; the line then gives the same numbers for them, and how
many another reference still held. Without -r every object goes where it
went before, and every other output line is unchanged.
2026-11-20 23:25:26 -08:00
Anees Iqbal 929b59c1c0 🐛 Make gameload's ICB passes' objects only when their shape is on
gameload made the ICB pass's pipeline (supportIndirectCommandBuffers on the
scene's variant 0) and its encode kernel's pipeline, and the compute ICB's
encode kernel and its supportIndirectCommandBuffers pipeline, whatever --off
said. So `--off icb,cicb` still made pipelines for indirect command buffers,
and a device that builds no ICBs refused the first one and the run ended.

Now each of those is made only when its shape is on, beside the ICB, its
argument buffer and the compute ICB's buffers, which already were. With both
on, the tool makes the same objects in the same order as before, and every
other shape's work and output lines are unchanged. The header says what --off
now leaves out.
2026-11-20 21:00:15 -08:00
Anees Iqbal 78231d010b 🐛 Read page info through the SDK's own header
The bundle and the sole-holder probe named mach/vm_page_info.h, which the
macOS SDK does not ship: VM_PAGE_INFO_BASIC and its struct come from
mach/vm_region.h, which both files already include.
2026-11-20 14:02:42 -08:00
Anees Iqbal 83c4898877 🆕 Name a sole holder's anonymous memory unchanging
The bundle now names read-only anonymous memory unchanging where its maximum
protection has no write, the kernel answers it SM_PRIVATE at a shadow depth of
0, and mach_vm_page_info's VM_PAGE_INFO_BASIC answers its object's count as 1
at depth 0 with the region's object id (kRgfxAnonymousPrivate). The kext takes
such a block (kRgfxPagesSoleHolder, 1 << 3, where it sets
kRgfxKextFeatureSoleHolderPages, 1 << 20) and marks its SURFACE_PAGES
RGFX_SURFACE_PAGES_UNCHANGING without COPY_ON_WRITE, so the host reads its
pages once, as the view is imported. On P2's guest (macOS 26.7.2, the Windows
mini) the 4K block over such memory was copied whole at each commit that used
it.

A wire holds no reference, so the count leaves out wires for writing taken
while the memory was writable. The kext knows its own: it refuses the block
(kIOReturnNotPermitted) where, once its pages are wired, a writable block of
its own in the table or an in-place surface block covers a page of them, or a
block of writable memory is being made (writableMakes), and the bundle then
asks a read-only block, why RGFX_PAGES_WHY_REFUSED. The check sorts the
block's runs and walks every writable wire's segments under contextLock, once
per such make. What is left is a write another driver started before the app
removed write for good, still landing after the make.

The clause is on for every guest kernel, with no release gate. The facts it
rests on, read in xnu's published source at each tag from macOS 11.0.1 to
26.5, osfmk/vm/ lines:
xnu-               cnt   pid   rid  fake  prot   upl clamp  iopl  walk     id
7195.50.7.100.1  19154 19264 14459 19126  6172  6459 17037  9030 14915   1209
7195.60.75       19074 19184 14406 19046  6156  6459 16984  9030 14862   1209
7195.81.3        19074 19184 14413 19046  6157  6459 16984  9030 14869   1209
7195.101.1       19119 19229 14290 19091  5915  6457 17020  9010 14749   1190
7195.121.3       19158 19268 14329 19130  5916  6457 17059  9010 14788   1190
7195.141.2       19158 19268 14329 19130  5916  6517 17059  9070 14788   1190
8019.41.5        19330 19440 14493 19302  6007  6551 17227  9137 14952   1190
8019.61.5        19330 19440 14493 19302  6007  6551 17227  9137 14952   1190
8019.80.24       19330 19440 14493 19302  6007  6551 17227  9137 14952   1190
8020.101.4       19330 19440 14501 19302  6003  6543 17247  9143 14960   1188
8020.121.3       18885 18995 14245 18857  5918  6541 16960  9131 14704   1168
8020.140.41      18945 19055 14305 18917  5909  6542 17019  9135 14771   1168
8792.41.9        19527 19637 14780 19499  5939  6701 17519  9294 15246   1166
8792.61.2        19538 19648 14791 19510  5939  6753 17530  9346 15257   1167
8792.81.2        19538 19648 14791 19510  5939  6753 17530  9346 15257   1167
8796.101.5       19669 19779 14872 19641  5926  6750 17650  9273 15338   1164
8796.121.2       19669 19779 14872 19641  5926  6750 17650  9273 15338   1164
8796.141.3       19738 19848 14911 19710  5940  6774 17695  9297 15377   1164
10002.1.13       19897 20007 15074 19869  6032  6791 17854  9316 15540   1163
10002.41.9       19910 20020 15087 19882  6032  6771 17867  9296 15553   1165
10002.61.3       19910 20020 15087 19882  6032  6771 17867  9296 15553   1167
10002.81.5       20023 20133 15121 19995  6041  6771 17980  9296 15587   1167
10063.101.15     20254 20364 15180 20226  6098  6774 18210  9299 15646   1355
10063.121.3      20357 20467 15247 20329  6123  6774 18308  9299 15714   1355
10063.141.1      20359 20469 15249 20331  6125  6774 18310  9299 15716   1355
11215.1.10       20139 20249 14984 20111  5692  6843 18096  8188 15442   771i
11215.41.3       20139 20249 14984 20111  5692  6843 18096  8188 15442   771i
11215.61.5       20501 20611 15230 20472  5759  6817 18384  8162 15693   765i
11215.81.4       20507 20617 15236 20478  5765  6817 18390  8162 15699   765i
11417.101.15     20646 20756 15393 20617  5804  6766 18487  8111 15856   765i
11417.121.6      20694 20804 15441 20665  5843  6781 18535  8129 15904   766i
11417.140.69     20703 20813 15449 20674  5841  6777 18546  8124 15913   766i
12377.1.9        20960 21070 15518 20931  5974  6988 18734  8331 16004   776i
12377.41.6       22004 22114 16433 21975  6174  7198 19709  8562 16933   807i
12377.61.12      22037 22147 16463 22008  6204  7203 19742  8567 16963   808i
12377.81.4       22109 22219 16534 22080  6275  7209 19813  8573 17034   808i
12377.101.15     18688 18805 13571 18677  5743  7659 16128  8765 14068   824i
12377.121.6      18686 18803 13569 18675  5722  7659 16126  8765 14066   824i
 cnt   vm_map.c, vm_map_page_range_info_internal: the top object's count,
       less the query's own reference to 12377.81.4, read before it after
 pid   there: the id, VM_KERNEL_ADDRPERM to 10063.101.15, ADDRHASH after
 rid   vm_map.c, vm_map_region_recurse_64: the region's id, VM_OBJECT_ID
 id    vm_object.h (i: vm_object_internal.h): VM_OBJECT_ID, the low 32 bits
       of pid's macro in each tag
 fake  vm_map_page_range_info_internal: a footprint query's count of 1 and
       an id of no object (task_self_region_footprint)
 prot  vm_map.c, vm_map_protect (its preflight from 12377.101.15): no
       protection the maximum lacks
 upl   vm_pageout.c, vm_map_create_upl: no write UPL where the entry's
       protection lacks write; from 12377.1.9 through vme_allows_upl_write,
       whose test is at 6786, 6986, 6991, 6997, 7413 and 7413
 clamp vm_map.c, vm_map_remap_extract: a share's maximum is the source's at
       most, which memory entries take through vm_map_copy_extract
 iopl  vm_pageout.c, vm_object_iopl_request: the UPL keeps the object with
       no reference of its own
 walk  vm_map.c, vm_map_region_walk: the count less one while paging, so
       the share mode alone leaves it in doubt

Later releases are checked by test: guest/bundle/tools/sole_holder_probe.c,
which the lane gate's info phase (item sole-holder) and Ambrosia's
check-boot.sh (check sole-holder) run on each guest they boot, reads the count
as 2 with a memory entry or a second mapping holding the memory and 1 once it
goes, sees a footprint query answered otherwise, the kext's writable wire of
memory whose maximum lacks write refused, a sole holder's block made, and
refused while a writable block of the kext's covers it. A release where it
fails is a red leg. The kext's tests cover the wiring and the runs' sort and
search, and the bundle's a sole holder's block named and refused.
2026-11-20 14:02:42 -08:00
Anees Iqbal 82a8d1b00d 🐛 Zero each new region block before a process's window maps it
A region block's offset goes to any process once the device answers its
release or its holder's close, and the region keeps its bytes across the
device's reset and the guest's reboot. A new block held whatever its last
holder left: another app's command buffers' bodies, its shader library's
staging chunks, its buffers, or a surface copy of its window's pixels.

The kext now writes zeros over every span a window maps of a new block
before the window maps it, each through a kernel mapping of the cache mode
the window maps it with (write-combined from the region's write-combined
descriptor, write-back from its own), and allocBlock maps from the same
spans, so what is zeroed is what is mapped (RgfxBlockZero.hpp). A surface's
new block is zeroed over the part its holders map: the whole copy for a copy
block, the header for one in place. A span the kernel will not map fails the
grant. A block held again (a shared or revived surface block) and a pages
block, never in a window, are left.

The kext logs what the zeroing took by kind (bodies, split, write-back,
surface copies, surface headers), and offers it as feature bit 1 << 14
ZeroedBlocks, after which the bundle takes the region's slabs as clean
rather than zero them again. block_zero_test checks the spans and the
cross-process cases natively; guest/bundle/tools/block_zero_probe.c checks
them in a guest, a block filled by one process and read by the next.
2026-11-18 20:48:32 -08:00
Anees Iqbal d5ae31b6ef 🆕 Probe when a Managed texture's replaceRegion: reaches a committed read
oracle_storage mtexcap [full|part] measures whether a command buffer committed
before a Managed texture's replaceRegion: reads the new texels, on a two-copy
GPU and a one-copy one. The buffer waits on a shared event the CPU signals
after the replace, so the replace lands between the commit and the GPU's read;
where the times leave the point open, it is written again after the buffer is
scheduled, then while a spinning kernel holds the GPU. The new runtime's
planner needs the answer to choose when it takes a Managed texture's bytes.
2026-11-18 00:41:13 -08:00
Anees Iqbal 6536decf91 🆕 Probe a Managed buffer's capture at any size and after the commit
oracle_storage's capture case measured, on a 4096-byte buffer, that a
discrete Mac takes a Managed buffer's CPU bytes by the commit, not at
didModifyRange:. It never wrote B between the commit's return and the
buffer's scheduling, where taking the bytes at the commit and at the
submission differ, nor called didModifyRange: again while a committed
buffer waits or runs, and its size was fixed.

capture now takes a size (capture [BYTES], 4096 by default) for the
Managed buffer and its output, and three steps follow the five, which
stay as they were: 5 writes B at once after the commit returns, with the
spin held; 6 is step 3 with a second didModifyRange: before the spin is
let go; 7 is step 5 with a second didModifyRange: right after B. The new
steps print when B was written, when the commit returned, when the
buffer was scheduled and started on the GPU, and when it completed.
2026-11-17 23:37:52 -08:00
Anees Iqbal 1b532d111f 🆕 Read every CPU's PAT through the accelerator's user client
The kext sets the guest PAT's entry 2 to write-back on every CPU, and
nothing the guest could run showed whether every CPU holds it. CpuPats,
selector 15 on the 'RGFX' client (the next number every WebKit sandbox
allows), reads each online CPU's PAT on that CPU in an mp_rendezvous_no_intrs
action, into a record sized to the kernel's CPU count (real_ncpus), by CPU
number: a CPU whose number lies past it is counted, never written past the
record or shifted past a mask's width. It answers an administrator's process
alone, as the read stops every CPU for a moment; arm64, with no PAT, answers
kIOReturnUnsupported. The x86-64 kext sets kext feature bit 13, CpuPats.

guest/bundle/tools/pat_probe.c checks every online CPU holds entry 2
write-back and entry 6 write-combining, and times stores and loads over a
write-back block of the region beside process memory, on any kext.
pat_test holds the record's rules; user_client_words_test the number and
the bit; design.md's registry gives both out.
2026-11-17 08:56:29 -08:00
Anees Iqbal 6436c97b94 🆕 Add oracle_binfn, what a device answers for binary functions
macOS 12 and 13's iconservicesagent and com.apple.dock.extra send the
device's private compile of a visible function, which the bundle answers
unsupported while supportsFunctionPointers answers YES. The probe records
what an x86 Mac's Metal does there: the three forms of the compile, what
Metal's library sends it for MTLFunctionOptionCompileToBinary, pipelines
linking binary functions, and newComputePipelineStateWithAdditional-
BinaryFunctions:error:.
2026-11-16 12:56:26 -08:00
Anees Iqbal 5afdd60765 🐛 Answer stage input attributes from Metal's own function
A function specialised by constant values answered as active an attribute that
Metal's compiler leaves inactive once it folds the values: the bundle read the
AIR itself, and its reading keeps reads that are dead only after folding.
RealityKit's vsRealityPbr, under its usdz preview's constants, answered color
active where the AMD 5300M answers it inactive; unspecialised, it answered the
15 attributes its metadata declares where Metal answers none.

Where a function's library has Metal's own library (the one Metal compiled,
linked or stitched, or one Metal makes over the bytes of a library of a file,
of data or of a bundle), its attributes are now those of Metal's own function
of the same name and constant values. The metadata and the AIR's
specialisation remain where there is no such library. oracle_fnreflect gains
v_deadfold, whose attributes' reads are dead only after folding, and the
shadow test checks that every function asks Metal's own.
2026-11-16 11:41:25 -08:00
Anees Iqbal 67fb29d1ab ✅ Measure the built-ins of amplification and dispatch groups
RealityKit's usdz Quick Look preview asks the reflection of a vertex function of
air.amplification_id, a built-in whose answer the bundle never measured, and
gets nil. pipeline_reflection_check gains r_amplification, a vertex and a
fragment function of amplification_id and amplification_count, and
c_dispatch_groups, a kernel of dispatch_simdgroups_per_threadgroup,
dispatch_quadgroups_per_threadgroup and thread_execution_width: the built-ins of
their stages no case measured.
2026-11-16 09:41:07 -08:00
Anees Iqbal c3db1b640d 🆕 Add oracle_fnreflect, what functions and pipelines reflect of themselves
A probe of our own for the reflection answers a guest app reads off a
library, a function and a pipeline state, on a real Mac and in a guest
alike: a vertex function's vertexAttributes, a kernel's
stageInputAttributes, the constants a function declares, the library's
reflectionForFunctionWithName:, and every property of the pipeline
states' protocols, allocatedSize among them.
2026-11-16 09:10:29 -08:00
Anees Iqbal 9030c4d0fc 🆕 Add oracle_allocsize, what a Mac's currentAllocatedSize counts
A probe of what the device's currentAllocatedSize counts on a real Mac: each
step makes one object (buffers of each storage mode, no-copy buffers,
textures, views, heaps and what is made in them, indirect command buffers, a
visible function table, samplers, states, events, queues, pipelines), reads
the count, frees the object and reads it again. The guest bundle answers 0
there today; this is the reference its count follows.
2026-11-15 18:11:13 -08:00
Anees Iqbal 30ae24eba1 🆕 Add oracle_pastlen, texels past a buffer's length
Two ledger rows ask what Metal does with a texture's texels past its
buffer's length: whether the CPU's copies and the GPU's paths agree there,
and which such textures an Apple GPU makes. The probe answers both on each
oracle: `paths` runs every read and write path of each shape in a process
of its own, against neighbour buffers whose words name their bytes, and
`limits` bisects each creator's bound by buffer kind, length and form.
2026-11-15 08:01:12 -08:00
Anees Iqbal a3165753d9 ✅ Let oracle_texdesc cap its texture-buffer heaps and buffers
ORACLE_TB_CAP caps the bytes of the heap and the buffer the texture-buffer
cases make below the device's maxBufferLength. A guest answers 4 GiB, and its
cases past 2^28 elements made heaps that large before the descriptor's
validation ended them, which took a walk on ms01 past its memory.
2026-11-14 23:35:46 -08:00
Anees Iqbal 54a9119729 ✅ Let oracle_texdesc's texture-buffer sweep take one format
--texbuf fixed|max|all F runs format F alone, so a guest run can keep to
the formats whose widest textures its host's memory holds.
2026-11-14 23:35:46 -08:00
Anees Iqbal ced0b4a24b ✅ Measure texture buffers' widths at each texture creator
oracle_texdesc --texbuf asks the device's, a Private heap's and a Shared
buffer's creators for texture buffers (MTLTextureTypeTextureBuffer) of 1- to
16-byte formats at fixed widths, from 16384 to past 2^32, over a buffer that
holds them and one of 4096 bytes, then bisects the largest width each makes
and the largest that does not end the process. --tbread fills one and reads
elements back by kernels. A guest's MoltenVK makes texel buffer views as
texture buffers 46626 wide, which the bundle ends the process at past 16384;
this measures what Metal answers there. [ci skip]
2026-11-14 23:35:46 -08:00
Anees Iqbal c749b28a16 🐛 Read a texture in a raster order group for pipelines' reflection
The AIR reader refused a texture argument that sits in a raster order
group (`[[texture(n), raster_order_group(g)]]`). Its function's pipelines
answered no reflection. QuartzCore's inplace_copy_lpf and inplace_copy_lph
fragments, the last two entry points the sweep of macOS 27's metallibs found
refused, take one.

The reader now takes the group after a texture's access. The reflection
answers the texture as it answers one in no group: the AMD 5300M and the
Intel 630 make r_rog_texture's pipeline and list the texture that way
(m3-max-31210, 31211), and MTLTextureBindingInternal has no field for a
group.

What changed for the guest: on either guest, pipelines of such fragments
now answer a reflection that lists the texture. Before, they answered none.
2026-11-14 20:50:59 -08:00
Anees Iqbal 662040dac0 🐛 Answer imageblocks in pipelines' reflection as Metal does
The AIR reader refused the nodes of an explicit imageblock, of a fragment
function's imageblock data and of a view of a master struct. Pipelines of
those functions answered no reflection, and the device logged "its nodes
were not read". A sweep of macOS 27's metallibs found about 270 such
entry points: QuartzCore's blur kernels, CoreComposite's and VectorKit's
tile views, among others.

The reader now takes the imageblock's layout, its data size and the
master struct. The reflection builder makes them from Metal's own classes,
as the oracles answer them (tools/pipeline_reflection_check's new cases):
- on an Apple GPU, a kernel's explicit imageblock is an
  MTLImageBlockArgument of binding type 17 and kind 1, at index 0, of its
  data's size and its struct; a false function constant leaves it out.
  Neither x86 Mac makes a pipeline of one, so an x86 guest's still answers
  none;
- a fragment function's imageblock data is an MTLImageBlockDataArgument of
  binding type 16, its master struct in imageBlockMasterStructMembers when
  it views one, on either guest: the M3 Max and the Intel 630 make those
  pipelines, and the AMD 5300M makes the master view's.

What changed for the guest: these pipelines now answer a reflection that
lists their imageblock. Before, they answered none. The x86 checks match
the AMD GPU in every value, and the Intel GPU in every value but its known
postVertexDumpStride (m3-max-31210, 31211). Of the entry points the sweep
found refused, 2 are left: QuartzCore's textures in a raster order group,
which the next commit reads.
2026-11-14 20:50:59 -08:00
Anees Iqbal 26c6fd2573 🐛 Read colour attachment inputs at computed indices or in raster groups
A fragment function's input of a colour attachment's value ([[color(n)]])
did not read where function constants compute n, or where the input is in a
raster order group, and pipelines of such a function answered no reflection:
41 of macOS 27's framework fragments (RenderBox's 35, PencilKit's, CoreRE's)
take an index function constants compute and 9 (CoreRE's) a raster order
group (the reflection sweep, m3-max-31057 and 31073). Metal's compiler writes
the index as the global its initialiser sets, as for a binding's index, and
the group as air.raster_order_group n after it (read: f_fetch_at and
f_fetch_group, macOS 27.0.1). The reader now takes both, the group only on a
colour attachment's input, where Metal lists the input nowhere (measured:
f_fetch); a binding in a raster order group still does not read.

What the guest sees: a render pipeline made with reflection options of such
a fragment function answers its reflection, the colour attachment's input
listed nowhere, where it answered nil; and its functions made with constants
are checked for overlapping arguments, as Metal checks them. oracle_reflection's
f_fetch_group and f_fetch_at hold it in the AIR test and the shell test, and
pipeline_reflection_check compares them with Metal's (r_fetch_group,
r_fetch_at).
2026-11-14 20:50:59 -08:00
Anees Iqbal e2870344f1 🐛 Follow argument buffers nested 32 deep for pipelines' reflection
The AIR reader stopped at 8 levels of layouts and argument buffers' members,
and a pipeline of an entry point nested deeper answered no reflection: 39 of
macOS 27's framework entry points (VFX 30, CoreUSDEdit 9; the reflection
sweep over every system .metallib on the M3 Max, m3-max-31057 and 31073),
which all read at 12. The limit only bounds the recursion, so it is now 32,
named kRgfxAirNesting, in the reader, in the count of a struct of members'
ids and in whether an argument buffer's members write a texture.

What the guest sees: a render, compute or mesh pipeline made with reflection
options of such an entry point answers its reflection, built as for the
shallower argument buffers, where it answered nil; textures in those
argument buffers that the function only reads are no longer taken as
written. oracle_reflection's k_deep_ab, a chain of seven argument buffers,
holds both in the AIR test and the shell test, and pipeline_reflection_check
compares it with Metal's (c_deep_ab).
2026-11-14 20:50:59 -08:00
Anees Iqbal d268bb7819 ✅ Probe a function array's name order over many orders
The bundle answers a function array's functionNames in the reverse of the
order given, from two arrays the x86 Macs and the M3 Max answered that way
(libforms3). Two arrays do not tell a reversal from an order of the names
alone, a hash's: libforms.order asks each of the six orders of three
functions and four orders of five, each made twice, so the rule is read
from measurements on each reference GPU.
2026-11-14 20:50:45 -08:00
Anees Iqbal 4daf23dd26 🆕 Ask the oracle of a scheduled signal behind a held buffer
Whether a scheduled signal waits for an earlier buffer of its queue that waits
on an event: the case that tells a signal at the buffer's commit from one at
the queue's submission of it.
2026-11-14 17:58:32 -08:00
Anees Iqbal c24fab988b 🐛 Ask the oracle of a plain event's scheduled signal in a child
A plain event's scheduled signal ends the process on the M3 Max ("MTLEvent
passed to API expecting MTLSharedEvent"), which ended the schedsig case at
its fifth step. The plain event's call, and a nil event's on a buffer that
retains nothing, run each in a child process of its own.
2026-11-14 17:58:32 -08:00
Anees Iqbal 62c9425b3a 🆕 Ask the oracle when a scheduled signal reaches its event
The command-buffer SPI encodeSignalEventScheduled:value:, which Apple GPUs'
command buffers answer and the x86 Macs' do not, is to be carried in arm64
guests. oracle_cmdbuf's schedsig case measures what it does on a Mac: when
the event reads the value against the buffer's scheduled handler and GPU
times, idle and behind a long buffer of its queue, for a shared and a plain
event; the value it leaves; its order against the buffer's GPU signals and
its waits, on another event and on the same one; the listener's queue; and,
each in a child process, the call with an encoder open, after the commit and
with a nil event.
2026-11-14 17:58:32 -08:00
Anees Iqbal 43074ddf74 🆕 Ask the oracle of released states and bit-24 command buffers
Two answers of Metal that the runtime's exact forms of ReleasedCommandState
and PrivateResourceOption wait on had no Mac's answer here.

oracle_icb's new case, freedstate, executes a compute command a kernel
encodes naming, by the ID its argument buffer holds, a state of indirect
command buffer support the program released: before the write, after it,
with another state made since (which may take the ID), and over a state
the CPU set, the kernel writing the state or the buffers alone. Each line
says which program ran, the command buffer's status and error, and the
IDs.

oracle_readonly's new shapes, icb-cpu, icb-gpu and icb-gpu-over-cpu, make
an indirect command buffer with MTLResourceOptions bit 24 (against the
plain control), encode its command on the CPU, in a kernel, or in a kernel
over the CPU's, and execute it twice: whether the buffer is made, the
options it reports, which command ran, and each command buffer's status
and error.

Both are written from scratch, in plain Metal.
2026-11-14 16:35:04 -08:00
Anees Iqbal fffc41b341 🆕 Add oracle_archtype, the probe of a device's compiler target
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.
2026-11-14 13:39:38 -08:00
Anees Iqbal 8366731632 🆕 Let oracle_surfresolve resolve into plane 1 of a 420v surface
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.
2026-11-14 10:04:24 -08:00
Anees Iqbal 740f167a5b 🆕 Add the oracle probe of resolves into surface textures
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.
2026-11-14 10:04:24 -08:00
Anees Iqbal e2ef6ac2bf 🆕 Let oracle_twinwrites write through an argument buffer and into 500
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.
2026-11-14 09:23:15 -08:00
Anees Iqbal 265065139c 🆕 Add the oracle probes of two-way failures and twin writes
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.
2026-11-14 09:15:10 -08:00
Anees Iqbal 788561ff8f 📝 Record Metal's order of waits against handlers that block [ci skip]
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.
2026-11-14 07:50:59 -08:00
Anees Iqbal d89f0bdb7f 🆕 Add an oracle probe of waits against handlers that block
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.
2026-11-14 07:50:59 -08:00
Anees Iqbal a1da511c2a 🆕 Add oracle_readonly, the probe of writes into read-only memory
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.
2026-11-14 07:25:13 -08:00
Anees Iqbal 7c6149b53f 🆕 Add gameload's --private, its GPU-read Shared buffers made Private
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.
2026-11-14 05:03:33 -08:00
Anees Iqbal 9e942f2447 🐛 Refuse overlaps of half constants and function tables at newFunction
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.
2026-11-14 01:59:32 -08:00
Anees Iqbal a28ecb8955 🆕 Add gameload's cicb, a compute ICB of concurrent dispatches
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.
2026-11-13 18:30:24 -08:00
Anees Iqbal 7809cef902 📝 Record what aliased surface textures see in one command buffer [ci skip]
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.
2026-11-13 17:49:41 -08:00
Anees Iqbal 33cc8eff6e ✅ Ask what a wide reader reads past the plane's texels
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.
2026-11-13 17:49:41 -08:00
Anees Iqbal 4679e24068 ✅ Count the texels and the bytes past them apart after an alias
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.
2026-11-13 17:49:41 -08:00
Anees Iqbal 45cd68878c ✅ Ask oracle_surftex what aliased surface textures see in one CB
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.
2026-11-13 17:49:41 -08:00
Anees Iqbal f2d3443a05 🆕 Add gameload, a game-shaped Metal load beside the oracles
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.
2026-11-13 17:47:40 -08:00