Commit Graph
47 Commits
Author SHA1 Message Date
Anees Iqbal 4e1f847978 🐛 Answer nil for a device texture of more bytes than maxBufferLength
The device's newTextureWithDescriptor: sent every texture its validation
passed to the host, posted, and answered a texture, however many bytes it took.
Metal answers nil for one too large to make: the Intel 630 past its
maxBufferLength, the AMD 5300M past 16 GiB (the previous commit's
measurement). A texture whose create the host's platform refused for its size
was then one the app held, and the draws of every command buffer naming it
were dropped (refused.rs), where Metal's app would have seen nil and taken
another path.

What the guest sees: the device's creator answers nil, sending nothing, for a
texture whose bytes, every level of every slice and sample in its format's
blocks (its allocatedSize), are more than the device's maxBufferLength, as the
Intel does and as the bundle answers a buffer and a heap past it. It is inside
both x86 GPUs' answers, and keeps a texture within three quarters of the host
GPU's working set, which our maxBufferLength is. A heap's, a buffer's and an
IOSurface's creators place a texture in memory of their own size, and are
unchanged. test_textures_past_max_buffer_length_are_nil expects it.

guest/prebuilt is rebuilt from the tree (make -C guest prebuilt, the macOS
26.7.1 KDK): RgfxGate, which carries the bundle, and the record.
2026-11-07 11:07:32 -08:00
Anees Iqbal 8b59610c48 ✅ Measure where Metal answers nil for a large texture
The bundle sends a texture create to the host posted and answers a texture
whatever the host's platform then does with it, so a texture Metal answers nil
for by its descriptor alone has to be answered nil in the bundle. The
descriptor's rules were copied on 11-05 (Q24); what Metal answers for a texture
too large to make had not been measured.

oracle_texdesc's 13 new cases are RGBA32Float textures within every rule, of
2 GiB to 8 TiB, at the device's creator; each prints the size
heapTextureSizeAndAlignWithDescriptor: answers, and a made one its
allocatedSize and the process's footprint. On macOS 26.7.1 the Intel 630 makes
2 GiB, its maxBufferLength, and answers nil a row taller; the AMD 5300M makes
16 GiB and answers nil from 20 GiB, its maxBufferLength 3.2 GB. A texture that
is made commits no memory. The M3 Max answers nil for the 128 GiB and 8 TiB
ones. dgpu-oracle.md, Q24, records the table.
2026-11-07 11:07:32 -08:00
Anees Iqbal 1c77a6d25a ✅ Measure a long command buffer's GPU times on x86 Macs
A command buffer the host commits in parts answers GPU times from its first
part's start to its last part's end, which hold the host's walk between parts:
game_6000's gpu_p50 went from under 1 ms to 5.4-8.5 ms with car 12's split.
What a Mac answers for one long buffer had not been measured.

oracle_cmdbuf's new gputimes case commits K encoders of about 0.5 ms each (K
= 1, 8, 32; compute and render passes) in one buffer, and the same encoders
one buffer each, back to back. On both x86 Macs (macOS 26.7.1, the AMD Radeon
Pro 5300M and the Intel UHD Graphics 630) one buffer spans its encoders' GPU
time summed, as the back-to-back buffers do, within the GPUs' clock ramp; the
CPU's encoding time never counts; GPUStartTime comes 0.08 to 0.40 ms after
the commit. dgpu-oracle.md, Q7, records the table.
2026-11-07 11:01:27 -08:00
Anees Iqbal 450661e889 🐛 Answer nil for a texture buffer past its buffer's bytes
Both x86 Macs make a texture buffer by the public form even when its texels
lie past the buffer's bytes (measured: macOS 26.7.1, 4 RGBA32Float texels at
offset 4064 of a 4096-byte buffer). metal2vulkan refuses such a texture
(TexelsPastLength), and the Vulkan host ends its process at a refusal by this
creator. So the bundle answers nil, logged once, and sends nothing, as it does
for the other textures over a buffer the host does not carry.
2026-11-07 09:11:16 -08:00
Anees Iqbal 55bbbd0f82 🆕 Make texture buffers over a buffer by the public form
A buffer's newTextureWithDescriptor:offset:bytesPerRow: answered nil for a
texture buffer, logged as a type the host does not carry. The GL renderer
makes each GL texture buffer this way: gl_cases' texbuffer case got nil, and
the renderer drew it in software (RTX 5080 host, m3-max-3947).

Both x86 Macs make one by this form (measured: macOS 26.7.1, RGBA32Float and
RGBA8Unorm):
- over a Shared or a Managed buffer, at any offset (0, 4, 16, 64, 100, 256);
- with rows of at least its texels' bytes (64 and 4096);
- and their kernels read the buffer's bytes from the offset.

The host's platform makes one by the same form, at any offset, so the create
now goes to the host as TEXTURE_FROM_BUFFER with its type. For rows of 0 bytes
both Macs end the process with the same words, and the bundle does too. For
fewer bytes than the texels need, the AMD answers nil where the Intel ends
the process; the bundle answers nil, as the AMD does.
2026-11-07 09:11:16 -08:00
Anees Iqbal 892a0eefb0 🐛 Make BC textures over a surface where they answered nil
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.
2026-11-05 21:59:37 -08:00
Anees Iqbal 9beab79d22 📝 Number texture-nil's oracle sections Q24 and Q25 after shared events
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.
2026-11-05 21:59:37 -08:00
Anees Iqbal 9e226f2f98 📝 Record what a command buffer does with nil objects [ci skip]
oracle_nilbind measured what the AMD 5300M and the Intel 630 do with nil where a
command buffer names an object: Q25 records it and what the decoder now does with
a refused one. Q24 adds the block-compressed and texture-buffer answers over a
buffer, and where the bundle answers nil beside them.

Car 14's stack: Q25 and Q24 were the lane's Q24 and Q23; c14-shared-events
holds Q23 on the car.
2026-11-05 21:59:37 -08:00
Anees Iqbal 5a208f8829 📝 Record which texture descriptors each creator refuses [ci skip]
oracle_texdesc measured the descriptor validation every texture creator runs on
the AMD 5300M and the Intel 630, rule by rule and in order, which the bundle now
copies. Q24 records it, and Q12 says whose words the bundle now gives.

Car 14's stack: c14-shared-events holds Q23 on the car, so the lane's Q23 and
Q24 are Q24 and Q25 here, in these commits' bodies and in car 14's doc fix after
the lane's commits, which renumbers the doc's headings and references; the doc
keeps both sections, shared events' first.
2026-11-05 21:59:36 -08:00
Anees Iqbal 023663e5ad 📝 Describe shared events across processes [ci skip]
design.md's new section says how a shared event crosses processes: the port
is a connection of the kext's, which the bundle checks before it calls on it,
one host event per name, its values posted to every holder, and the port's
hold of the event, which outlives a maker killed with SIGKILL; and the residual
of a value read across processes. The user client table lists the 'RGSE'
selectors and kext feature 1 << 6. dgpu-oracle.md's Q23 records what the 5300M
and the 630 answered.
2026-11-05 21:59:36 -08:00
Anees Iqbal 2a2415f400 🐎 Post an asking buffer's CB_SCHEDULED with its CB_SUBMITTED
A command buffer that asks for its CB_SUBMITTED and waits for nothing got
that record at its take, or on its doorbell's thread, but its CB_SCHEDULED
only once the platform had taken its work: from the submission handler, on
the runtime's thread. On the RTX 5080 host that put a tiny buffer's
scheduled handler 0.34-0.39 ms after commitAndWaitUntilSubmitted on an idle
queue (car 12 and car 13, submit_probe's submitted.tiny.idle), against
0.20 ms on an AMD 5300M Mac and 0.05 ms on Apple's paravirtualized device.

Such a buffer now gets its CB_SCHEDULED right after its CB_SUBMITTED, at
the take or on the doorbell's thread, as long as no buffer begun before it
on its queue still owes its own record. Each queue counts the begun buffers
that owe one (Line's owed), so its records stay in commit order. A buffer
with nothing left to post runs no submission handler. Its ticket in its
process's commit order is issued at the take, as the CB_SUBMITTED there
already needed.

A buffer that does not ask keeps its CB_SCHEDULED to its scheduling.
Posting it at the take would need its ticket there too. A walk held on one
of a process's queues would then hold up the commits of its other queues
(a_walk_held_in_a_draw_holds_up_no_other_queue).

What the guest sees: an asking buffer that waits for nothing turns
Scheduled, and its scheduled handlers and waitUntilScheduled run, with its
commitAndWaitUntilSubmitted, before the platform has its work. Metal makes
it Scheduled within a fraction of a millisecond of its commit. Nothing the
guest orders depends on the difference (design.md, "Loose"). Such a buffer
whose walk then faults is now scheduled before its failure.
2026-11-05 21:59:36 -08:00
Anees Iqbal a43ef6e5e3 🐛 Answer the display's gamma as the AMD Mac's display does
Request 2 of AGDC attribute 0x711 answered one gamma entry naming no plane
and tables of 0 entries. CoreDisplay then found no gamma on plane 0
("Attempting to get capabilities from plane with no gamma", 76 times on car
13's boot) and drew CGDisplayFade into WindowServer's own frames instead of
sending the display pipe's gamma selectors a table each step. The frames
stopped early, so B4's held black read 34% and the fade in stayed at 71%.

The entry is now the first one macOS 26.7.1's AMDRadeonX6000Framebuffer
answers (getFbCapabilityForGamma, read): flags 0x88005, plane 0, table type
0x10, values 0.0 to 1.0, 256 entries. Its fields stay field_xx, each with the
IOPresentment key it fills. The AMD's optional second entry, a configuration
that IOPresentment sends through selector 11, is not answered, so selectors
10 and 11 stay refused.

For the guest: CoreDisplay sees plane gamma and sends fades and calibration
tables through selectors 5 to 7, which the kext already carries to the host.
2026-11-05 21:59:35 -08:00
Anees Iqbal 3a127e823d 📝 Record Macs' mesh pipeline answers and the mesh wire [ci skip]
dgpu-oracle.md Q22 holds oracle_mesh's and base_answers_probe's measurements
on the 5300M, the Intel 630 and the M3 Max, each classified, and what the lane
answers. design.md names FEATURES_LO bit 25 and the mesh create in the wire's
table, and the oracle README lists oracle_mesh.
2026-11-05 21:59:35 -08:00
Anees Iqbal 320b9e5314 🐛 Answer pipelines' reflection as an x86 Mac's Metal
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.
2026-11-05 21:59:34 -08:00
Anees Iqbal 9a9077389c 🐛 End the process at every two-plane texture over a surface
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.
2026-11-05 21:59:34 -08:00
Anees Iqbal 2cfd44fb18 🐎 Lay a one-level Managed 2D array over its CPU copy
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.
2026-11-05 21:59:34 -08:00
Anees Iqbal 814c527080 🐛 End the linear alignment query at every format x86 Metal ends it
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.
2026-11-05 21:59:33 -08:00
Anees Iqbal e828db91bc 🐎 Lay no-copy Managed buffers over the app's pages in place
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.
2026-11-05 21:59:33 -08:00
Anees Iqbal b4c0e4d67d 📝 Record what Metal does with textures over an IOSurface [ci skip]
Q20 holds oracle_surftex's answers on the AMD 5300M, the Intel 630 and the
M3 Max: the three steps where Metal ends the process, what a plane of a planar
surface takes, where the M3 answers nil, and which of the textures the x86
Macs make the host still refuses.
2026-11-05 21:59:33 -08:00
Anees Iqbal 5b7c979bb3 🐛 Publish no framebuffer memory size after a mode change
The framebuffer published IOFBMemorySize, 134217728 (the scanout's room),
once WindowServer had set a new mode, and none before: IOFramebuffer's
setup for each new mode (setupForCurrentConfig, the only caller of its full
setup in macOS 26.7.1's IOGraphicsFamily, read) runs on the thread of the
task that set it, WindowServer's, which holds the server connection, so the
VRAM range went to it and IOFramebuffer published the range's size.

The framebuffer now marks the thread that runs that setup while it runs, and
gives it no VRAM range, as it gives the kernel's and the open's setups none.
What changes for the guest: IOFBMemorySize never appears in the
framebuffer's registry entry, as the Intel 630's and the stock paravirtual
framebuffer publish none (oracle Q19); before, it appeared after the first
mode change. IOFramebuffer's VRAM map offset stays 0, as before: our aperture
and VRAM range start at the same address. WindowServer's map of the VRAM
range through its connection is unchanged.

The setupForCurrentConfig override, a trace build's only, is now always
built.
2026-11-05 21:59:33 -08:00
Anees Iqbal 029cc3b229 📝 Record which types each form makes over a buffer [ci skip]
dgpu-oracle.md's Q11 now has the lintypes and linarray probes' answers on the
AMD 5300M, the Intel 630 and the M3 Max: the types each of the three forms
makes over a buffer, the words Metal ends the process with at the others, and
where the M3 lays a linear 2D array's slices, and what the bundle does with
each. The slice pitch's comment cited metal2vulkan's measurement and now cites
the M3's probe: slices of 48 bytes of rows lie 128 bytes apart and of 768
bytes 768 apart, whatever the bytesPerImage.
2026-11-05 21:59:32 -08:00
Anees Iqbal aafe9ba7ef 📝 Record when Metal's CPU sees a mid-buffer signal (oracle Q18) [ci skip]
oracle_cmdbuf events on the 5300M, the 630 and the M3: the CPU's value,
waits and listeners see a shared event's signal from the middle of a buffer
before the buffer ends, and the wait-then-set pattern completes on all three;
the AMD and the M3 see it within a few milliseconds of the GPU reaching it, the
630 about 100 ms after the commit. A trailing signal's listener runs within
0.3 ms of the completed handler.
2026-11-05 21:59:31 -08:00
Anees Iqbal b42ec184cf 📝 Record two refusals' words and IOFBMemorySize (oracle Q19) [ci skip]
oracle_names on the 5300M, the 630 and the M3: a function constant given a
value of another type is refused with the same type names on all three, in a
sentence each OS words its own; a mesh pipeline's binary archive add is refused
on x86 with or without its functions, where the M3 asserts on a descriptor
with no mesh function and records one with it; all three make the pipeline
itself, which ours refuses. The AMD's framebuffer publishes IOFBMemorySize and
the 630's does not, so ours publishing it after a mode change is inside the
envelope.
2026-11-05 21:59:31 -08:00
Anees Iqbal b5846b36f7 🐛 Read a two-copy Managed texture's GPU copy on unified memory
On a GPU that shares the CPU's memory the host lays a Managed texture over its
CPU copy only where a texture over a buffer has its shape: one level, one
sample, 2D, of a linear format. Every other shape (mipmapped, an array, a cube
or a 3D texture, a block-compressed format) keeps two copies there too, and the
bundle's getBytes: read the CPU copy, which shows the GPU's writes only after a
synchronizeTexture:. On such a GPU Metal shows them with no synchronize (the
Intel UHD 630 and the M3, oracle_storage mtex), and the guest's device answers
hasUnifiedMemory as the host's platform does: yes on Apple silicon and on an
integrated GPU (or lavapipe) of the Vulkan platform, no on a discrete one.

For the guest: where the device answers hasUnifiedMemory yes, getBytes: of a
Managed texture of a two-copy shape now reads the GPU's copy through a device
copy (rgfxCopyRegion:), as a Shared texture's does, so it sees the GPU's writes
and every region replaceRegion: posted before it, and it waits for that copy's
command buffer. replaceRegion: is unchanged, and so is every texture on a
discrete GPU and every texture the host lays over its CPU copy.

The bundle knows the shape alone (rgfxManagedLiesOverCopy, the host's
in_place_shape), so a texture of the in-place shape whose texture over its
buffer the platform refuses still reads its CPU copy; the module doc says so.
2026-11-05 21:59:31 -08:00
Anees Iqbal 5077bda1a6 📝 Record what the CPU's uploads into textures cost [ci skip]
The upload probe's numbers on the AMD, the Intel 630, the M3 and the lane,
so the next change to the Managed and Shared upload paths has its target:
Managed calls are on par with the Macs, the host's per-texture upload is
twice the AMD's, and a Shared replaceRegion: waits a staging blit.
2026-11-05 21:59:30 -08:00
Anees Iqbal a5ccb712b9 📝 Record what textures over Managed buffers do on the oracles [ci skip]
Q3 gains the 11-03 rows behind the bundle's last three fixes:
- where a texture over a buffer may lie (linalign);
- replaceRegion: and didModifyData of a linear texture over a Managed buffer
  (lintex and didmodify), with the CoreAnimation trace that shows it calling
  didModifyData;
- no-copy Managed buffers (nocopy);
- argument encoders writing Managed argument buffers (argenc).
2026-11-05 21:59:30 -08:00
Anees Iqbal 17d65be9c2 🐎 Post surface-ordered buffers' records at their commit
The guest sees a command buffer that waits on the GPU for another queue's
buffer (SURFACE_ORDER) as submitted and scheduled when the host commits it,
instead of when that other buffer finishes. The order itself is unchanged: the
buffer still waits on the GPU and completes after the buffer it names.

The host counted such a buffer as one that waits for an event: its CB_SUBMITTED
and CB_SCHEDULED went at the platform's scheduling, and every later buffer of
its queue waited behind it. On the Vulkan platform a shared-event wait is held
on the host until its value is reached, so the records came only after the other
queue's buffer completed. WindowServer waits for submission three times a
frame, so the glass drag composited at about 59 a second on msi since the
surface order landed, against 117 before it.

A Mac holds back no record for such an order (dgpu-oracle.md, Q16): the blit
behind another queue's or process's 210 ms pass returns from
commitAndWaitUntilSubmitted and is scheduled within a millisecond on the 5300M
and the M3, and within 5 ms on the 630, and completes after the pass. So a
queue's records now go at commit, in its commit order, while one of its ordered
buffers is not yet taken by the platform (cmdbuf.rs, Line). Buffers that wait
for an event or a device cache's fill keep their records at their scheduling,
as before.

With such a buffer no longer holding its queue, a buffer behind it that ends
in its ask may be answered at the doorbell (answer_at_doorbell): its
CB_SUBMITTED is the answer's, and its CB_SCHEDULED goes at its commit through
the queue's Line, after the ordered buffer's. Submitted and Scheduled each post
once, whoever posts them first.

The fake platform can now hold submissions (World::hold_submissions), so the
tests pin both: an ordered buffer's records at commit, with completions in
order, and an explicit event wait that still holds its queue. A third pins a
doorbell answer between an ordered buffer's take and its commit: each record
once, in the queue's order. A test on each real platform pins the records at
commit and B's copy of what A wrote.
2026-11-05 21:59:28 -08:00
Anees Iqbal 7ebabe0806 📝 Narrow the released-buffer skip to ICBs resident for writing [ci skip]
The Vulkan arm runs a command naming a released buffer, reading zero there,
in an ICB made resident for reading; only its host replay, of an ICB an
encoder made resident for writing, skips the command.
2026-11-05 21:59:26 -08:00
Anees Iqbal 0d278a58c0 📝 Record what ICBs keep after a reset and run after a release [ci skip]
Q15 of the dGPU oracle doc: oracle_icb's resets and freed cases on the AMD
5300M, the Intel 630 and the M3 Max, each answer read in its class. What a
reset keeps of a command's state is divergent, so the lane's range reset in
one call, which leaves every command fresh, is inside the envelope. A command
naming a released buffer runs with no error on all three; what it reads
there is divergent; the Vulkan arm's skip of the command is outside the
envelope and handed to metal2vulkan.
2026-11-05 21:59:26 -08:00
Anees Iqbal 6c1cb77ce9 🆕 Measure sampler lodBias and reductionMode on the oracle
wire 2 carries neither property, and the next wire change needs to know what
a dGPU Mac does with them before the host realizes them. oracle_sampler
samples a mip chain whose level i holds i under each bias, from level(),
gradient2d() and a fragment's implicit LOD, and a 2x2 texture under each
reduction mode, and prints the device's SPI answers.

The AMD 5300M and the UHD 630 apply the bias to every LOD source and reduce
per channel, also with a nearest mip filter, where the header says the mode
is ignored; the M3 answers 0 and samples as unbiased and averaged. Q14 reads
the answers by the envelope classes: the documented rule on nearest filters is
kept, and the guest's reduction answer follows what the host can realize.
2026-11-05 21:59:23 -08:00
Anees Iqbal b6c42bf1e5 🆕 Probe how CoreAnimation and VideoToolbox pick a Y'CbCr matrix
The x86 guest's aerial wallpaper, an x420 frame tagged ITU_R_709_2, shows by
BT.709 on our lane and by BT.601 on the stock lane. oracle_ca_ycbcr asks what
a Mac's frameworks do with that tag: a CARenderer draws x420 and 420v surfaces,
tagged 709, 601 or untagged, into a texture of the device, and a
VTPixelTransferSession converts them to 32BGRA.

On the AMD 5300M, the Intel 630 and the M3, both convert by the tag, and an
untagged surface by BT.601, except that the x86 Macs' VideoToolbox converts an
untagged x420 surface by BT.709. A 709-tagged frame converts by BT.709 on all
three, as our lane shows it, so the stock lane's BT.601 is its own and the
oracle report records the colour as a decided divergence, beside the display
curve's.
2026-11-05 21:59:21 -08:00
Anees Iqbal 5f24cdbdce 🆕 Probe two-plane Y'CbCr textures on the oracle
The x86 guest's desktop shows its aerial wallpaper by BT.709 where the stock
lane shows it by BT.601. oracle_ycbcr asks whether that comes from Metal's
two-plane Y'CbCr textures, which our stack makes as the M3 does, converting by
the surface's matrix. On the AMD 5300M and the Intel 630 Metal refuses the
format outright: creating one ends the process. A traced boot shows the guest
never asks for it: VideoToolbox and WindowServer read the aerial's x420 planes
through R16 and RG16 textures, and convert by its ITU_R_709_2 tag in their own
shaders.

The oracle report gains Q13 with both answers; what an x86 Mac's frameworks
make of the tag is left as not measured, for the next probe.
2026-11-05 21:59:21 -08:00
Anees Iqbal 8e1bf61303 📝 Record the display colour's divergence from the stock lane [ci skip]
The x86 guest's desktop on the host differs from the stock lane's by up to
about 7 levels in dark tones. Measured from both lanes' captures: our EDID
declares sRGB, so macOS builds an sRGB profile and the host shows the frame as
WindowServer renders it; the stock framebuffer's EDID declares gamma 2.2, and
its display pipe has the host re-encode the same sRGB frame for it through a
gamma table and a colour matrix.

Each lane is consistent with what it declares, real Macs differ by panel, and
ours is the faithful one on the usual sRGB host monitor. Matching stock would
cost a kext, wire and host change for less faithful pixels, so the lane keeps
its own; the oracle report records the numbers and the decision.
2026-11-05 21:59:21 -08:00
Anees Iqbal 0e853caa6d 🐎 Post CB_SUBMITTED when the host takes the buffer
WindowServer's compositor commits each composite with
commitAndWaitUntilSubmitted, and CompositeLayersToDestination waits on it. The
host answered after its commit, so the call waited for the whole walk of the
buffer's ops on the platform: on the RTX 5080 boot about 650 us of the 1.27 ms
the guest spends in CLTD, against 0.43 ms on stock.

A buffer that asks and waits for nothing is now answered as the host takes it,
before the walk. The rule is the approved one, read at the take: no WAIT_EVENT
op (named or not), no fill of a device cache it uses (decided by before() from
the SURFACE_USE ops the bundle puts first; a fill not yet done counts), and no
buffer before it on its queue holding it. Any other buffer is answered at its
scheduling, as before. take() reads SURFACE_USE, WAIT_EVENT and SUBMITTED in one
pass; SUBMITTED ends the stream, as the bundle appends it at the commit.

Why nothing reorders: the post runs on the buffer's lane inside its decode,
under the device's one decoder lock. Every ring's decode takes that lock, and
so does every host call that reads or changes what the walk and commit use
(close_context, release_block, download_surface, surface_pages,
present_surface). A message the guest sends after the answer, on any queue, is
carried out after the buffer's after() and commit, as before:
- the device caches' users: after() records the queue's end value under the
  lock, so a later fill, download or present still waits for the buffer;
- the device-write watch: taken in before(), at the take, ahead of the post;
- uses_detached: a release the guest causes takes the lock, so it lands after
  the commit; block shares go to Region, which only object creation reads;
- the IOSurface hold from commit to completion: the commit still comes before
  the guest's next locked message; the bundle leaves use counts alone;
- seqno and present order: CB_SUBMITTED is still the buffer's first record,
  and a present waits for its writers by each queue's highest finished seqno,
  which a failure posts too;
- a revived dormant block: its cache is made again with no generation, so its
  first use fills, and that buffer is answered at scheduling;
- records: the walk posts none, and pending compiles are waited for before the
  take.

Classes:
- contract: the call returns at submission; event waits hold (a buffer that
  waits, or is behind one that does, is answered at its scheduling); tracked
  order across queues holds, since later work is carried out after the commit;
- loose: what "submitted" means on the host side. Metal answers once it has
  submitted the buffer; ours answers once the host owns the message, which the
  guest cannot tell apart;
- the fault case is inside the envelope: a buffer whose walk faults after the
  answer gets CB_SUBMITTED and then its failure at CB_COMPLETE, as Metal
  reports command-buffer errors at completion, not at commit. A buffer the host
  cannot take, for example on a queue it does not hold, gets none.

Tests: a plain buffer is answered before its first encoder and its commit; one
that waits for an event is answered after its commit, at its scheduling; one
behind a fill of a device cache is answered at its scheduling, and the next one
of that generation at its take; a buffer whose walk faults is answered and then
fails. The Metal test of a later commit on another queue passes unchanged. The
wire docs, the header, design.md and the oracle notes say "as the host takes
it" in place of "at its commit". ops.rs said the bundle puts SUBMITTED first; it
puts it last.
2026-11-05 21:59:21 -08:00
Anees Iqbal 10a2b89f5f 🐎 Return from commitAndWaitUntilSubmitted at the host's commit
SkyLight's compositor and VideoToolbox commit with commitAndWaitUntilSubmitted
and wait there. The bundle returned at the buffer's CB_SCHEDULED, which the
host posts once the buffer's work is scheduled on its GPU, later than Metal's
return on the M3, the 5300M and the 630, about 0.1 to 0.4 ms behind a long
buffer even where it waits for nothing (docs/graphics-kext/dgpu-oracle.md,
Q7).

Where the device info's features_lo has CB_SUBMITTED, a buffer that call
commits now carries an RGFX_OP_SUBMITTED, and the call returns at the host's
RGFX_EVT_CB_SUBMITTED: at its commit, or at the signal the buffer or one
before it on its queue waits for. The buffer stays Committed there and its
scheduled handlers wait for its CB_SCHEDULED, as Metal's may. The first of
CB_SUBMITTED, CB_SCHEDULED and CB_COMPLETE ends the wait, so a host that
answers no CB_SUBMITTED for a buffer leaves it at its scheduling, as before;
the reader drops the buffer's registration at either of the later two. A
buffer committed otherwise asks nothing, as nothing waits for its submission,
and a bundle on a host without the bit asks nothing. The kext is unchanged:
the op and the event pass through the queue's rings, which it does not read.
2026-11-05 21:59:20 -08:00
Anees Iqbal c22ea42112 📝 Tag the submission and two-queue answers by class [ci skip]
The oracle's answers on when commitAndWaitUntilSubmitted returns and on
ordering across two queues now say which class each is read in, and Q7 says
what the host's CB_SUBMITTED answers.
2026-11-05 21:59:20 -08:00
Anees Iqbal b97c0ee08f ✅ Measure commitAndWaitUntilSubmitted behind a buffer that waits
Through the decoder, a buffer committed on another queue right after an
earlier one's commit ran before it on Metal, where the earlier one sat behind
a buffer of its queue waiting for a shared event: Metal does not order a
tracked resource behind work it has not submitted. Whether the call returns
early there decides whether the host may.

On the 5300M, the 630 and the M3 the call returns at the signal for a buffer
behind one of its queue that waits on an event, as for one that waits
itself; and a tracked resource is ordered across two queues as soon as the
first buffer's plain commit returns.
2026-11-05 21:59:20 -08:00
Anees Iqbal 91c12b5ab5 ✅ Measure when commitAndWaitUntilSubmitted returns on the oracles
The host is to answer commitAndWaitUntilSubmitted at submission rather than at
scheduling. What a buffer reads right after the call, and whether a later
commit on another queue sees its writes, decide what the early answer may
leave out: oracle_cmdbuf gains a submitted case (behind a long buffer, on an
idle queue, waiting on a shared event) and two two-queue orderings.

On the 5300M, the 630 and the M3 the call returns at submission, at the
signal for a buffer waiting on an event; the status then is Committed or
Scheduled by a race, and always Committed on an idle queue. A tracked
resource is ordered across two queues by commit on all three; an untracked
one races on the M3 alone.
2026-11-05 21:59:20 -08:00
Anees Iqbal 0064af053c ⬆️ Build on metal2vulkan 7da81ee3d8's runtime
The runtime now answers supports32BitMSAA (32-bit integer MSAA textures and
32-bit float resolves, from the device's own formats) and
supportsPullModelInterpolation (interpolant inputs and Metal's
interpolate_at_* functions, lowered to the GLSL.std.450 interpolation
instructions). The Vulkan platform passes both through, where it answered
neither before: the AMD, Intel and M3 Macs all answer yes to both, so a no
was outside every measured Mac. The runtime also draws fill-Lines triangles'
wide edges as bands, and at the nearest width where it refuses a band.

metal2vulkan commits: 7a1dae2b87 be2d725fdb 06f08298fd 130513884f f18cf358da
2376157b3b 70e01b4bd6 e9f45f7c85 2dcbbf39b6 313d45dc1c a27c863842 7da81ee3d8.

Two degradation kinds are new, and both die in strict mode (DIES):
WideEdgeDepthBias (a wide triangle edge under a depth bias, which each band
triangle takes by its own slope) and DeviceInterpolationOffset (a read at an
offset, on the device's offset grid). Draws of either kind died before this
runtime, so placing them there ends no run that went on. The accuracy ledger's
wide-line row now says the band draws triangles' edges too.
2026-11-05 21:59:20 -08:00
Anees Iqbal 0b60cd1c9f 🐛 End the process at texture descriptors Metal's validation ends it at
The device's and the heaps' newTextureWithDescriptor: sent the host every
descriptor, and the host refused those Metal's validation ends the process at:
a three-channel format (45 to 48, 95 to 100, 120 to 122), which the guest's
macOS 26.6 setter takes and Metal describes no format for, and a multisample
texture of a compressed or 4:2:2 format or of Unspecialized. The AMD, the Intel
and the M3 GPU end the process at each, at the device and at a heap. The
bundle now ends it there too, with the words of the M3's create, each rule
broken a line, and sends nothing; a heap ends it before it asks the host the
texture's size.

dgpu-oracle.md Q12 records the measurements. Each case's death is checked in a
child of the shell tests.
2026-11-05 21:59:20 -08:00
Anees Iqbal 0b798d10f7 🐎 Take no dirty source on the graphics device
This reverts 71d7ba107 (Give the graphics device the host's dirty source),
8f1b8b02e (Resolve an import's pages once per range for the dirty log) and
67edfb6ee (its test's fix), and points vendor/qemu at 926401c49, which
reverts reims-graphics-pci's dirty source on its branch.

With the source, the runtime asked the guest pages behind each IOSurface's
import at each command buffer's reports and watches, and the graphics
device's thread resolved them through the backing table and the registry,
under locks the runtime's queue threads also took. On the msi's RTX 5080,
the same guest under window-drag load, the host with the source against the
host without it, back to back:

- the decode and commit of a command buffer took 5.2-7.3 ms, against
  0.33-0.51 ms;
- WindowServer composited 27-30 times a second, against 40-45, and its
  CompositeLayersToDestination averaged 9.65 ms, against 3.24 ms;
- QEMU used 122% of a core, against 89%.

The copies the source saved, an IOSurface's shadow copied in whole at each
use on a discrete GPU, are what the device cache of IOSurfaces replaces.
RvgGraphicsDeviceConfig is at its second version again; the third was never
in development.
2026-11-05 21:59:20 -08:00
Anees Iqbal dd05521d6e 🐛 End the process at a mipmapped texture over a buffer, as Metal does
newTextureWithDescriptor:offset:bytesPerRow: with more than one mipmap level
ends the process on the AMD, the Intel and the M3 GPU, at Metal's failed
assertion "Linear texture: cannot be mipmapped". The bundle sent the create
to the host instead, which refused it, and every later command buffer that
named the texture failed: WindowServer's composition stopped in boot ro1-p2.
The bundle now ends the process with Metal's words and sends nothing.

The buffer's tiled SPI, which x86 Macs answer with levels 1 and up in the
GPU's own memory, answers nil for more than one level, logged once, until the
host carries those levels; it no longer reaches the public form's death.

The shell tests run the death in a child of their own, whose SIGABRT handler
exits, so the check writes no crash report.
2026-11-05 21:59:20 -08:00
Anees Iqbal c28a0ebed0 📝 Reword Q11's reason for the M3's feature profile [ci skip] 2026-11-05 21:59:20 -08:00
Anees Iqbal 7aeb14dd4a 📝 Record why the lane keeps the M3's feature profile [ci skip]
Answering featureProfile 10002, an x86 Mac's, made WindowServer ask the
lane for a 7-level texture over a buffer. The host refused it, and every
later command buffer faulted. On AMD and Intel, the tiled SPI forms make
such textures with levels 1 and up in the GPU's own memory. The public
form asserts on every Mac, and the M3 has no tiled form. A Q11 section
records this, and Q9 and Q10 now say the lane keeps 10.
2026-11-05 21:59:20 -08:00
Anees Iqbal 60a9dfbbc6 📝 Record what the oracle measured of runtime source compile [ci skip]
A Q10 section gives oracle_source's answers on the three Macs, how the base
device class compiles, which device answers it reads, and what the lane does
now. A featureProfile row is added to the limits table.
2026-11-05 21:59:20 -08:00
Anees Iqbal e61033bfa0 📝 Read the dGPU oracle's answers by class [ci skip]
The oracle report said what each Mac does but not what the lane makes of
it. A new section, Reading the oracles, gives the four classes:
documented, divergent (the cheapest answer inside the envelope), agreed
(contract) and outside the envelope (fix). A boot overrides all four.
Each answer is now tagged with its class.

The report also catches up with the lane: the device answers, the
linear alignments, return at submission, GPU times and the async
creators' queue now say what the lane does. Relaxation 4 is withdrawn,
and the stencil's DontCare result is added.
2026-11-05 21:59:20 -08:00
Anees Iqbal 3edaba0dfb 📝 Record what the dGPU oracle measured [ci skip]
The AMD 5300M and Intel 630 of a 2019 MacBook Pro (macOS 26.7.1) against
the M3 Max and our stack, question by question, with the relaxations
ranked. The biggest: on x86 an IOSurface's GPU copy is a device cache,
refreshed from the pages only after a CPU read-write unlock and written
back only at a CPU lock after a GPU write, so the host need not shadow a
render-target surface in and out on every composite. Also where x86 is
stricter than the M3 rules the lane copied (DontCare stores keep color,
untracked work is ordered across command buffers, timeout errors).
2026-11-05 21:59:19 -08:00