febd0da9727a9ba11eb561b89e7ebd09abbe268f
5873
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
febd0da972 |
🎨 Make the read-only resolve tests' late setters eager
Clippy's unnecessary_lazy_evaluations: the late resolve setters the tests build are plain values, so then_some takes them. |
||
|
|
3ba94c6eb5 |
📝 Record what each write into read-only memory answers [ci skip]
dgpu-oracle.md Q38 records oracle_readonly's runs on the M3 Max (macOS 27.0.1) and the dGPU oracle's Radeon Pro 5300M and UHD Graphics 630 (macOS 26.7.1), each shape with its class: agreed, divergent or outside the envelope, and the x86 finding that bit 24 does nothing there. The accuracy ledger's read-only-pages-written row, the writes module's docs, the command module's note on read-only store faults and design.md's no-copy buffers say what the platform now answers: a store-out faults as the M3 Max's does, every other GPU write completes with its write dropped, a CPU write lands where the pages are writable, and a depth StoreAndMultisampleResolve into such memory still ends the process until metal2vulkan completes it. |
||
|
|
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. |
||
|
|
36e52d8da0 |
✅ Test what a death names of an undetermined slot
The words a death gives where a pipeline state's slot writes leave a slot undetermined (gap_named, through Whether::through) had no test. No committed function leaves a slot undetermined, so the test reads the naming of each gap the runtime names: a slot only a function constant states, a payload argument of an unmeasured stage, an argument buffer member's role. |
||
|
|
657054c90d |
🐛 Write the pages for a CPU write of a texture over bit-24 memory
replaceRegion: of a texture over the guest's read-only memory (a buffer or heap made with bit 24, or over pages mapped read-only, which the runtime copies on Linux) ended the process, as Metal's write through a read-only mapping does. oracle_readonly measured it (dgpu-oracle.md Q38). Agreed (class 3): on the M3 Max (macOS 27.0.1) and the Radeon Pro 5300M and UHD Graphics 630 (macOS 26.7.1), a write of a texture over a bit-24 buffer of writable pages lands in the pages, which the GPU then reads, and on the M3 Max one in a Shared heap of bit 24 lands in the texture; a write over pages the process maps read-only ends the process with SIGBUS, with the bit or without (m3-max-29292 to m3-max-29294). The backing now records whether its pages are mapped read-only, apart from bit 24 (Backing::pages_read_only). A CPU write over bit-24 memory of writable pages is sent: the runtime writes the caller's pages, and its copy takes them at the next commit, so later command buffers read them. One over pages mapped read-only dies, naming Metal's bus error. The last writes into memory the runtime copies that kept_write ended the process at are gone with it, so kept_write's words now name only the surface twin and the depth StoreAndMultisampleResolve. What the guest sees: the CPU write takes, as on Metal, instead of the process ending; the test a_cpu_write_of_a_texture_over_read_only_memory_takes_its_texels_on_linux replaces the one that held the death. No boot: the guest bundle writes a buffer's texels itself, and no walk reaches this path. |
||
|
|
6a48464ba7 |
🐛 Complete a blit's texture writes into read-only memory, dropped
A blit that writes a texture over the guest's read-only memory (bit 24, or pages mapped read-only, which the runtime copies on Linux) other than by a copy (a colour or bytes fill, mipmaps, an invalidation) ended the process where it was encoded, as nothing had measured Metal there. oracle_readonly did (dgpu-oracle.md Q38). Divergent (class 2): the M3 Max (macOS 27.0.1) completes each and drops the write (m3-max-29292; m3-max-29309 for mipmaps, level 1 of a heap's texture staying zeros where it is written without bit 24), the Radeon Pro 5300M and UHD Graphics 630 (macOS 26.7.1) complete mipmaps and write them, bit 24 doing nothing there, and end the process at the fill and invalidation SPI with the bit or without, which their drivers lack (m3-max-29293, m3-max-29294). Each is now sent and completes, its write dropped by the runtime's copy, as the M3 Max's is and as a blit's copy already was; only a write that would land in a surface's writable twin (Kept::lands) still dies. What the guest sees: such blits complete with no error, and the memory keeps its bytes, instead of the process ending, as the test blit_writes_of_a_texture_in_read_only_memory_are_dropped holds. No boot: no walk reaches these paths. |
||
|
|
536f4e8ea7 |
🐛 Complete a draw's texture writes into read-only memory, dropped
A draw that may write a texture over the guest's read-only memory (bit 24, or pages mapped read-only, which the runtime copies on Linux), through a function's write() at a bound slot or by making it resident for writing, ended the process where it was encoded, as nothing had measured Metal there. oracle_readonly did (dgpu-oracle.md Q38): - Divergent (class 2): a fragment or vertex function's write() of such a texture fails the command buffer with PageFault on the M3 Max (macOS 27.0.1) every run, and completes on the Radeon Pro 5300M and UHD Graphics 630 (macOS 26.7.1), which write the pages, bit 24 doing nothing there, and leave pages the process maps read-only unchanged (m3-max-29292, 29309; m3-max-29293/29294, 29310/29311). The draw is now sent and completes, its writes dropped by the runtime's copy: the cheaper answer, as faulting it would keep every such bind in the draws' reach and ask it at each draw. - Agreed (class 3): a texture made resident for writing that no function writes completes on all three, and is now sent. Kept::lands names what still dies where it is encoded: a write that would land in a surface's read-only memory through the runtime's writable twin. A texture over read-only memory the runtime copies no longer decides anything a draw asks (texture_bind). What the guest sees: such draws complete with no error, and the memory keeps its bytes, instead of the process ending, as the test a_draws_write_into_read_only_memory_is_dropped holds. No boot: no walk reaches these paths. |
||
|
|
caf1c7bef8 |
🐛 Answer every render pass store-out into read-only memory
A render pass that resolved into, or kept an attachment in, the guest's read-only memory (a no-copy buffer or heap made with MTLResourceOptions bit 24, which the runtime makes over a copy of its pages on Linux) ended the process at every shape no probe had measured. oracle_readonly measured each on the M3 Max (macOS 27.0.1) and on the dGPU oracle's Radeon Pro 5300M and UHD Graphics 630 (macOS 26.7.1), dgpu-oracle.md Q38, and each now gets an answer inside that envelope: - Divergent (class 2): a colour StoreAndMultisampleResolve, a stencil MultisampleResolve or StoreAndMultisampleResolve and a depth MultisampleResolve into such memory, the descriptor's action or a late one, into the descriptor's resolve texture or a late setter's. The M3 Max faults the command buffer every run, and the x86 Macs, on which bit 24 does nothing, complete them and write the pages. The pass now fails its command buffer with PageFault, as the M3 Max's does and as the runtime faults it itself, at no cost (m3-max-29292, m3-max-29309; m3-max-29293/29294, 29310/29311), as a Store and a colour MultisampleResolve did already. - Agreed (class 3): a colour or stencil CustomSampleDepthStore set late completes on all three, writing nothing, and the runtime stores it as DontCare: it is sent. One the descriptor names ends the process in Metal's validation on all three, over any memory: it now dies at the runtime's refusal, as for any memory, not as a read-only write. - Outside the envelope (class 4): a depth attachment's StoreAndMultisampleResolve into such memory completes on all three Macs (the M3 Max leaving the texture unchanged), where the runtime (metal2vulkan 20f7e82bbe) faults it. It still ends the process, where the pass is made, or at the late store action or resolve texture, and the message now names the runtime's gap; metal2vulkan takes on completing it. What the guest sees: these passes fail their command buffer with MTLCommandBufferErrorPageFault, counted against the queue as Metal's are, instead of ending the process. The tests change with them: the resolve and depth tests cover StoreAndMultisampleResolve, stencil and the late setter, and the depth SMSR deaths. No boot: no walk reaches these paths. |
||
|
|
15f99157b6 |
✅ Make the read-only depth test's heap texture relaxed
a_depth_store_into_read_only_memory_faults_its_command_buffer died on ms01's Iris Xe (ANV) as it made its Depth32Float texture in the bit-24 heap: on Linux that texture's image is a shadow of the heap's bytes, and on a device without VK_EXT_depth_range_unrestricted the runtime announces restricted-depth-upload as it makes it (degrade_shadowed_depth), which dies in strict mode. The test checks the pass's fault, not that degradation, so the texture is made under the default, as the heap is. Only the test changes; nothing changes for the guest or the host. No boot: no walk reaches the path. |
||
|
|
f264ac73b8 |
🐛 Drop kernel and blit-copy texture writes into read-only memory
A kernel's write() of a texture over memory the process maps read-only (Metal's private option bit 24, a no-copy buffer or heap the runtime makes over a copy of the pages on Linux), and a blit's copy into such a texture, ended the process where they were encoded (kept_write), as what Metal does there was read as unmeasured. metal2vulkan measured both on the M3 Max, macOS 27.0.1, plain Metal (probes/readonly_gpu_writes.m; the runtime's read_only_view.rs): a texture over such memory takes a kernel's write() and a blit's copy into it, out of a buffer or a texture, nowhere; each completes with no error and leaves the pages as they were. The runtime's copy drops those writes too: a texture over a copy lies in the copy's memory, or is a shadow of its bytes, and each batch's completion writes back over every byte the GPU changed in a copy that drops writes (copied.rs), so a later command buffer reads the pages' bytes. What changes for the guest: such a dispatch and such a blit copy complete with no error, their writes dropped, where they used to end the process. predication.rs's kept_write_through asks texture_twinned instead of texture_kept for a texture a kernel writes, bound or made resident for writing, so only a surface's read-only memory the runtime twins still dies there. encode_blit.rs sends a copy into a texture over memory the runtime copies (copy_dropped: CopyBufferToTexture, CopyTextureRegion, CopyTextureSlices and their options forms). What stays a death, as nothing measured it: a draw's write of such a texture, another blit's write of one (a fill, mipmaps, an invalidation), and a CPU write of one. Tests: texture_writes_into_read_only_memory_are_dropped runs a kernel's write, a copy out of a buffer and a copy out of a texture into a texture over a bit-24 buffer and one in a bit-24 heap over pages: each completes with no error, the pages stay zeros, and a later command buffer reads zeros. a_blit_into_a_read_only_buffer_is_dropped's copy into a texture over the buffer now completes where it died. gpu/writes.rs's docs and the accuracy ledger's read-only row say the same. No boot: no walk has reached this path (no app in our walks writes a texture over read-only memory). |
||
|
|
68a94da601 |
🐛 Fault measured resolves and depth stores into read-only memory
A pass that resolved a multisample colour attachment into a texture over memory the process maps read-only (Metal's private option bit 24), or kept a depth attachment there by CustomSampleDepthStore, ended the process where it was encoded, as what Metal does there was unmeasured. metal2vulkan has since measured both on the M3 Max, macOS 27.0.1, plain Metal (m3-max-28796, m3-max-28797): a colour MultisampleResolve into a texture over a buffer of bit 24, and a depth attachment in a heap of bit 24 kept by CustomSampleDepthStore, each by the descriptor's action or one the encoder set, fail the command buffer with PageFault, as a Store there does. RUNTIME 2280 (pin 89) faults both itself (store_out.rs), and counts the fault toward its queue's revocation. What changes for the guest: those two shapes now fail their command buffer with PageFault (3), the pass and the encoders after it running nothing, every event signal firing, the pages unchanged, and the queue serving on until its second fault, where they used to end the process. kept_attachment and late_store let them through, and read_only_stores and late_store tell the command buffer of the fault (faults_at_read_only_store), as a Store there is told, so a command buffer that fails another way too still dies at its commit. faults_over and faults_into name the store actions that fault. A colour attachment's resolve texture over such memory, the descriptor's, is marked Unsent::Copied while its store action is Unknown, so a late MultisampleResolve into it faults. The store-out shapes 2280 did not measure stay deaths where they are encoded: StoreAndMultisampleResolve into such a texture (at the pass's creation, or at its late store action), a depth or stencil resolve into one, a resolve into a texture a late resolve setter named, a colour or stencil attachment kept there by CustomSampleDepthStore, and a colour resolve into such a texture that this platform drops because plain Metal leaves a texture of that format untouched (now dying in read_only_stores, at the same selector, where it died in kept_attachment before). Tests: a_resolve_into_read_only_memory_dies becomes a_resolve_into_read_only_memory_faults_its_command_buffer: MultisampleResolve given at once or late faults and the queue runs on, while StoreAndMultisampleResolve dies at renderCommandEncoderWithDescriptor: and at setColorStoreAction:atIndex:. In a_depth_store_into_read_only_memory_faults_its_command_buffer, CustomSampleDepthStore at once or late, and Store, in a heap of bit 24 over pages fault, the queue running on, and DontCare completes. The read-only pass helper takes any pass (pass_line_on). The module docs, gpu/writes.rs's and the accuracy ledger's read-only row say the same. No boot: no walk has reached this path (no app in our walks stores into read-only memory). |
||
|
|
67e65365e5 |
🐛 Let a read-only store's fault revoke its queue, not end the process
A render pass that stores an attachment into memory the process maps read-only (Metal's private option bit 24) faults its command buffer with PageFault. This platform then made the commit of every later command buffer of the process die (READ_ONLY_FAULTED), as Metal was read to fail them all. Measured on the M3 Max, macOS 27.0.1, plain Metal, that reading was of the probe's runs sharing one queue: one fault a process leaves the next command buffer of the same queue Completed (m3-max-29110, twice, a process each), and so do one on the same queue 100 ms on and one on a new queue (m3-max-28796, m3-max-28797); four faulting runs on one queue fail every command buffer of that queue after its second fault. That is the queue revocation the runtime models in command_buffer/revocation.rs, measured on the same Mac: the queue's second page fault or hang revokes it, every later commit on it failing with AccessRevoked (4); other queues, and a new one, serve on. What changes for the guest: a command buffer committed after such a fault runs, where the commit used to end the process; the queue's second fault revokes that queue, every later command buffer of it completing with AccessRevoked, running nothing and signalling nothing; other queues run. Since RUNTIME 2280 (pin 89) the runtime faults such a store-out itself, with the same code, from the same pass on, every event signal firing (store_out.rs), and counts it toward its queue's revocation. This platform no longer commits the fault as failed (commit_failed of code 3): the command buffer commits as any other, and the runtime faults it. The pass is still told to the command buffer, now as a failure the runtime makes (the field type_9 becomes by_runtime, holding type-9 draws' failures and these), so a command buffer that fails another way too still dies at its commit as a combination nothing measured, and is never cut into parts. The executions of indirect command buffers in the encoders such a failure runs nothing of stay unchecked at the commit, as they were while this platform committed the failure. The same now holds for a type-9 draw's failure, whose later encoders' executions were checked, and could die there, though Metal runs nothing of them. Tests: a_store_into_read_only_memory_fails_its_command_buffer and its late store variant now see the next command buffer of the queue and of a new queue run, the faulted one's blit after the pass not run and its signal fired; read_only_faults_revoke_queues_as_metals holds the revocation at the second fault, while a new queue runs and takes a first fault of its own without revocation; a_command_buffer_failing_two_ways_dies_at_its_commit gains the read-only cases and the first encoder that runs nothing. The module docs, gpu/writes.rs's and the accuracy ledger's read-only row say the same. No boot: no walk has reached this path (no app in our walks stores into read-only memory). |
||
|
|
c3ed478a70 |
⬆️ Build on metal2vulkan 20f7e82bbe's runtime
Pin 89 moves metal2vulkan from bc12f6d95a (RUNTIME_VERSION 2266,
SEMANTICS_VERSION 2107, ARTIFACT_FORMAT_VERSION 522) to 20f7e82bbe (2290,
2109, 522). Pins 87 and 88 were never cut: 87's lavapipe suite hung in the
read twins (fixed by RUNTIME 2278), and 88 (afba68e6e4) kept a buffer's
unobserved padding in an exportable image that starts UNDEFINED, a shadow
where in place passed (fixed by RUNTIME 2288). It carries:
- consecutive compute encoders of a command buffer recorded into one
Vulkan command buffer (RUNTIME 2268), an encoder's open looking only at
the encoders ended since the open before (2270), and a failure inside a
group of folded encoders failing only the encoders it names (2272,
2273);
- copies from a no-copy buffer made with Metal's read-only option, and
slots that only read such a buffer, reading its pages in place through
a read twin (2269, 2276; fixed forward by 2274 and 2278);
- the unshared-isolation hold's budget at 2 ms only while an unshared
queue on that VkQueue committed within the last 50 ms, else 16 ms
(2275): a guest's single-batch command buffers are no longer held for
2 ms each while the window's queue is idle;
- a render pass's store-out into memory whose GPU writes are dropped
(Metal's private bit 24) faulting its command buffer with PageFault off
macOS too, as Metal's does (2280);
- a kernel's unaliased, never-written buffer arguments NonWritable
(SEMANTICS 2108, RUNTIME 2283), and an 8-byte leaf at a proven 8-aligned
offset moving as one uvec2 (SEMANTICS 2109, RUNTIME 2287): on the 780M
Geekbench's convolution loops now load as the native driver's do;
- cheaper bookkeeping per dispatch and per command buffer: a part's first
command ordered lazily (2281), recycled encoder state (2282), live-buffer
tables rebuilt only where a chunk changed and compared in place (2284,
2286), a compute encoder's memory barrier recording the least barrier
(2285), a one-dispatch encoder keeping its instantiated commands (2289),
bind memos (2277), a used heap's buffers listed once (2271) and an
encoder carrying every kept draw (2267);
- buffers whose padding is unobserved laid in blocks of their own,
exportable as dma-bufs, with the padding of a block never exported held
in place (2279, 2288);
- pieces of one shared dma-buf file bound in one import of the file
(2290).
Here:
- gpu/command.rs gains the test
protection_options_fail_compute_encoders_from_the_one_made_under_them:
two compute encoders that the runtime records together, the second made
under protection options, where the first one's work runs and the second
one's runs nothing. It failed at metal2vulkan 09068993d6, before RUNTIME
2272. failure()'s doc says the encoders it fails are From the first that
runs nothing, and that this encoder can directly follow compute
encoders the runtime records with it, the ones before it running all
the same.
- RUNTIME 2290 changes the runtime's DmaBufChunk to { file:
Arc<OwnedFd>, offset, length }. os/linux/dma_buf.rs and host_ram.rs hand
each chunk a file of its own at offset 0, which is the runtime's
behaviour before 2290, and their tests read through chunk.file.
No Degradation kind or RuntimeGap changes (247 and 80, the same names).
WorkCounts drops kept_draws_carry_capped, which nothing here reads, and
adds counters for the changes above. SEMANTICS moves, so every host's
shader caches and records go cold once, at the first run of each
pipeline; ARTIFACT_FORMAT stays.
What the guest sees changes in timing, and in one case of the contract:
on Linux and macOS hosts alike a render pass that stores an attachment
into memory the process maps read-only now faults its command buffer in
the runtime as Metal's does, where this platform already failed it so.
Under protection options the encoders before a failed one still run, as
they did at pin 86, which had no fold; the test above holds that.
The checks it reaches are the library's on the Mac and on each Linux
GPU class, rustdoc, and, since the runtime's GPU results change for
guest frameworks, a cold boot of the x86 guest on each GPU class and the
arm64 gate. The video crate, the window crate's register, the guest
sets, the option ROM and QEMU link nothing of the runtime's changes and
cannot move.
20f7e82bbe is metal2vulkan's GREEN.
Cargo.lock keeps its lines.
|
||
|
|
887b8f94a4 |
🐛 Name parts_cut in plain backticks, as rustdoc never sees it
note_part_cut's doc linked Self::parts_cut, which exists only under cfg(test), so rustdoc -D warnings failed on an unresolved link (batch 69, m3-max-29067 and 29068). The doc now names the counter without a link. |
||
|
|
e5b4e2fa35 |
📝 Say why a buffer's parts out are not limited [ci skip]
Batch 64 doubled the walk a dispatch of Fluid Simulation's big command buffers on a Radeon 780M, 17.2 to 33.6 us, cutting each into about 75 parts. The question was whether fewer parts, committed only while few are out, would keep the GPU's early start for less walk. Measured with dispatch_cost's fluid shape and its heavy one (the decoder alone, release, median of 5 runs), at most 2 or 16 parts out against no limit: metal2vulkan afba68e6e4 (pin 88), latency in ms, walk us a dispatch: 780M heavy none 166.2 / 7.3 16: 167.0 / 7.0 2: 166.8 / 6.6 Iris heavy none 253.0 / 7.6 16: 252.2 / 7.3 2: 252.4 / 7.3 M3 fluid none 33.8 / 7.9 16: 35.7 / 7.9 2: 44.3 / 7.5 M3 heavy none 121.9 / 8.1 16: 127.2 / 8.0 2: 132.2 / 7.9 (fluid on the 780M and the Iris: the GPU keeps up, no limit is reached) So a limit is neutral on the hosts the library ships on, and loses on MoltenVK, where completions come late and the GPU waits for the cut. The walk's doubling was the runtime's at bc12f6d95a (pin 86): on the 780M the heavy shape's walk took 55.8k cycles a dispatch against fluid's 34.5k for the same instructions; at afba68e6e4, 30.2k against 33.3k. The rule stays batch 64's. Runs: m3-max-28834, 28846 (M3, Iris, pin 86); 28855 (780M, pin 86); 28900, 28904, 28858 (M3, Iris, 780M, pin 88); 29014 (M3, parts that grow). |
||
|
|
b9f9310405 |
✅ Add a dispatch_cost shape whose GPU work outlasts its walk
dispatch_cost's fluid shape dispatches one threadgroup at a time, so its GPU keeps up with the walk and each part completes about as soon as it is cut. Geekbench 7's Fluid Simulation on a Radeon 780M runs about 200 us of GPU work a dispatch against a walk of 12 to 20 us (perfscout4's gbr-780m), and with batch 64 its buffers had up to 47 parts out. The heavy shape is fluid's ops with 32,768 threadgroups a dispatch, so the GPU falls behind the walk on any host. Both benches now also print how many parts the walk committed a command buffer (a frame for composite_cost), from a counter only the tests' builds keep. Tested by the_fluid_shape_holds_an_encoder_a_dispatch. |
||
|
|
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. |
||
|
|
18310e5539 |
📦 Rebuild both guest sets with read-only pages blocks
The kext takes RGFX_FEATURE_READ_ONLY_PAGES and makes read-only pages blocks, and the bundle lays read-only no-copy memory over them (the two commits before this one). The x86 set (with the KDK) and the arm64e set are rebuilt from the tree on the M3, with their sources records; make -C guest prebuilt-check and make -C firmware prebuilt-check pass on it. |
||
|
|
320ad08811 |
🐎 Lay read-only no-copy memory over its pages, not a copy
newBufferWithBytesNoCopy: over Shared memory the process maps read-only took
a slab copy that the bundle merged from the memory at every commit using it.
On macOS 12.7.6's WindowServer, which wraps clients' Core Animation backing
stores (VM_MEMORY_LAYERKIT, mapped read-only, 8-30 MB each) so and draws from
them every frame, that merge was 14.10 s of the commit path's 14.25 s over a 451 s walk, 130,850 MiB
compared, and its commit-to-post wait 2-6 ms a frame where 14.8.9's is
20-60 us (appwalk14, ms01's Iris Xe).
Where the kext makes a read-only pages block (RGFX_FEATURE_READ_ONLY_PAGES),
such memory now lies over its own pages: the bundle asks the block for
reading alone and makes its BUFFER_OVER_PAGES with Metal's private bit 24,
sent to the host alone. The buffer answers the app's options, without the
bit, as Metal's does; its contents, length, allocatedSize and GPU address
(the pointer's offset in its page) answer as before. Read-only blocks join
only read-only ones. Read-only Managed memory keeps its copy: the host's two
copies would write the CPU copy back to the pages. Where the kext gives no
block (a host without the bit), the copy stays.
What changes for the guest, beside the time: the GPU's writes to such memory
follow accuracy-ledger.md's read-only-pages-written row, as Metal's do, where
the copy kept them in the slab for later command buffers to read:
- a shader's store, a blit's fill or copy and a pass's visibility results
into it complete with their writes dropped, and later command buffers see
the memory as it is;
- a pass that stores an attachment there (Store,
StoreAndMultisampleResolve) fails its command buffer with
MTLCommandBufferErrorPageFault, where the copy let it complete;
- the CPU sees its pages unchanged, as before.
On Linux the runtime makes a bit-24 buffer over a copy of the pages today,
compared with them at each commit that uses it, so the per-commit compare
moves from the guest's process to the host's commit until metal2vulkan
imports such memory in place.
The shell tests that held "read-only memory never asks for a block" now hold
the new route: the ask for reading alone, the bit on the wire and not in the
buffer's options, and the copy where no block is given. Both guest sets are
rebuilt in the 📦 commit that follows.
|
||
|
|
ccbcdabd6d |
🆕 Make pages blocks of memory a process maps read-only
A no-copy buffer over memory its process maps read-only cannot lie over its
own pages today: the kext refuses the pages block, and the host would lay a
buffer over it that takes the GPU's writes. So the bundle syncs a slab copy
of it at every commit that uses it. macOS 12's WindowServer wraps clients'
Core Animation backing stores, mapped read-only into it (8-30 MB each), that
way, and spent 14.1 s of a 451 s walk syncing them (appwalk14, 12.7.6 on the
Iris Xe). This makes the device and the kext ready to keep them in place; the
bundle takes the route in the next commit.
What changes on the wire:
- A new feature bit, RGFX_FEATURE_READ_ONLY_PAGES (bit 45, FEATURES_HI bit
13), offered wherever PAGES_BUFFERS is, and taken by the kext.
- A new SURFACE_PAGES flag, RGFX_SURFACE_PAGES_READ_ONLY (1 << 5), meaningful
with RGFX_SURFACE_PAGES_PRIVATE alone (else INVALID_ARGUMENT): the pages
block holds pages its process maps read-only.
- BUFFER_OVER_PAGES needs no new field: its options already carry
MTLResourceOptions bit 24 to the host, which hands it to the runtime as
memory whose GPU writes it drops (accuracy-ledger.md,
read-only-pages-written).
The host keeps every object over a read-only block from writing its pages: a
BUFFER_OVER_PAGES without bit 24, a HEAP_OVER_PAGES, an ICB_SLOTS_IN_PAGES
and a MANAGED_BUFFER_CREATE or MANAGED_TEXTURE_CREATE whose CPU copy lies over
one are refused, each logged as the guest error it is. The block's view stays
the writable mapping of guest RAM.
Where the kext took the bit, PagesBlock makes a block of read-only memory too:
it wires the pages with kIODirectionOut, which asks the VM system only for
read access, completes them for that direction at the unwire, and marks the
block read-only (rgfxPagesWiring). Without the bit it refuses read-only
memory as before.
Why a feature bit, though reims-ctl ships the host and the x86 set together:
the mark is where the host holds the line, not a hint. A process can post any
message on its rings, so a forged BUFFER_OVER_PAGES without bit 24 over a
read-only block would let the GPU write pages the process maps read-only, a
file's page cache among them. A host older than the mark ignores it, so the
kext makes such a block only where the host took the bit. The arm64e set also
reaches VMs through Ambrosia's config bundle, apart from the host. Old guest
sets never ask, and change nothing; a new set on an older host gets no block
and keeps its copy.
The header is regenerated, and the option ROM's record takes the header's
new hash (the ROM's bytes are unchanged); both guest sets are rebuilt with
the bundle's change, in the 📦 commit after it. Tests: the
header test, the peer and offer tests, a decoder test of what a read-only
block admits and refuses
(a_read_only_pages_block_holds_only_buffers_that_drop_their_writes), and the
kext's features and pages-block tests.
|
||
|
|
c2dbffc7bb |
📝 Name the unshared queues and their log line as they are [ci skip]
GpuDevice::new_command_queue_unshared's doc listed the device's blit and
exec queues and the process's frame queue, which no code makes since the
paravirt lane went, and left out the decoder's release queue and the window
mirror's queue, which do exist. It now names the queues made unshared today,
each with the reason its own doc gives: the window sink's and its mirror's
(on a present's path), the IOSurface device caches' transfer queue (presents
and cache-drawn frames wait for its fills) and the decoder's release queue
(no guest command buffer may hold up the signal of a closed context's
events).
design.md said the host logs each unshared queue at info on
reims_vgpu::graphics; since
|
||
|
|
89d2e8efd6 |
🐎 Index the spans the live objects lie over
A block's release is refused where an object of the decoder's lies in it (Context::span_in), which looked at the span of every live entry of every context, each in a box of its own: a cache miss an object. Particle Physics spent 2.31 us a dispatch there on gbp-iris (perfscout4), about 0.5 ms for each of its 106 releases on ring 0's thread, and Video Filter 11.33 us a dispatch. Each context's table now keeps the spans its live entries lie over, each counted as entries come and go, and the longest it counted: a release looks only at the spans that start no further before its block than that, a few keys, and answers as before. The index is counted where an entry goes into the live ones and taken out where it leaves, through the one function every removal goes through, under the table's write lock with the change itself, and an entry's span never changes while it is in the table, so it cannot go stale. span_in_answers_as_a_look_at_every_live_entry holds both, through random makes, makes over an id again, removes and closes with views open: each step the index against the live entries' spans recounted, and the answer against a look at every live entry. Per run of gbp-iris (from perfscout4's profile and trace): Particle Physics made 106 BLOCK_RELEASEs and spent about 50 ms on ring 0's thread in the check, 0.47 ms a release; Video Filter 93 and about 19 ms, 0.2 ms each. The index's check is a few BTreeMap steps under the read lock, about 1 us a release (read from the cost test's 284 cycles over 8,192 objects; the real tables' boxed entries cost cache misses the index never takes), so those 50 and 19 ms go to under 0.2 ms a run. Ring 0 carries out the guest's other messages behind a release, so that is time the guest waits. a_block_release_s_check_costs (homelab-ms01-1, release, user space: a check over 8,192 objects of 6,144 blocks, median of 9 runs), before -> after: a check: 88,412 -> 589 instructions, 51,523 -> 284 cycles (job m3-max-28671; a second pair of runs gave the same within 3%) |
||
|
|
ddc2f9a450 |
✅ Test and time the check that no object lies in a block
A block's release is refused where an object of the decoder's lies in it (Context::span_in), which looks at the span of every live entry of every context, each in a box of its own. Particle Physics spent 2.31 us a dispatch there on gbp-iris (perfscout4), about 0.5 ms for each of its 106 releases, and Video Filter 11.33 us a dispatch. A test sets span_in's answers beside a look at every live entry through random makes, removes and closes with views open; a cost test prints its user-space instructions and cycles a check over 8,192 objects. |
||
|
|
abdc3a5d19 |
🐎 Keep the binding of a buffer bound again at its index
Each buffer a compute encoder's setBuffers names was cloned into the encoder's bindings (predication's Bindings::bind_buffer), and the one it replaced dropped, even where it was the same buffer bound again: an upload chunk at its next offset before each dispatch, or a kernel's buffers set again before each of its dispatches. Each such bind took the buffer's reference count up and down, two locked writes, and a BTreeMap insert. Super Resolution spends 1.30 us a dispatch there on gbp-iris (perfscout4). The index's binding now keeps its reference where it holds the same object already, and only its offset and stride change; another buffer is cloned in, before the one it replaces drops, as before. The object's lifetime is unchanged: the bindings hold it as long as before. set_buffers_cost (homelab-ms01-1, Iris Xe, release, user space, a buffer bound by a setBuffers of 8, median of 5 encoders of 4,096 sends), before -> after: a buffer bound again where it is bound (same: an upload chunk at index 0 at a moving offset, then 7 buffers set again): 166 -> 118 cycles (-29%), 438 -> 444 instructions a buffer replacing another (fresh: from a pool of 64): 242 -> 224 cycles, 507 -> 518 instructions (job m3-max-28673; two pairs of runs, the same within 4%) The two locked writes are the gain: the instructions stay within 2%, and the 48 cycles a rebind saves are those two writes, about 24 cycles each where the test's one thread keeps the count's line in its own cache. A line another thread took last costs a locked write more. decodeperf's dispatch_cost, one shape (2,600 dispatches in one encoder, each after its bindings, Iris Xe, job m3-max-28744, two pairs of runs): 14,736 and 14,355 -> 14,146 and 14,457 cycles a dispatch, 33,263 -> 33,209 instructions, within its spread; its fluid and small shapes, an encoder a dispatch, bind no buffer again (job m3-max-28732: the same within 1%). |
||
|
|
014b746caa |
✅ Add a cost test of a compute encoder's setBuffers
Super Resolution spends 1.30 us a dispatch in predication's Bindings::bind_buffer on gbp-iris (perfscout4): each buffer a setBuffers names is cloned into the bindings, and the one it replaces dropped, even where it is the same buffer bound again, as an upload chunk is at its next offset before each dispatch. The test sends setBuffers of 8 buffers to a compute encoder, the same 7 after a moving upload chunk, or 8 fresh ones each time, and prints the user-space instructions and cycles a buffer bound. |
||
|
|
69499af6ac |
🐎 Look a view's names up with one hash, in a map sized for them
Super Resolution spends 4.19 us a dispatch in tables::View::get on gbp-iris (perfscout4), over 6,847 command buffers of about 6 dispatches; gbl-iris's call graphs put 43% of View's samples in compute setBuffers' binds and 18% in the views' drops. Each command buffer takes a view of its table, and each object it names is looked up in the view's map, then in the table under its lock, then put in the map: the map hashed the id twice on a first lookup, and grew from nothing through four sizes as a command buffer named its first 32 objects, moving every name at each growth. A view's drop swept the gone list though nothing was on it. The first lookup now hashes the id once (the map's entry, where the table's answer goes in), the map starts with room for 32 names, and a drop with nothing gone sweeps nothing. What a view finds is unchanged: the table's tests of what a view sees hold it. a_command_buffer_s_view_costs (homelab-ms01-1, release, user space: a view over 4,096 objects naming 64 of them 4 times, median of 9 runs), before -> after: a command buffer: 30,523 -> 25,144 instructions (-17.6%), 9,878 -> 8,161 cycles (-17.4%); a name: 119.2 -> 98.2 instructions, 38.6 -> 31.9 cycles (job m3-max-28671; a second pair of runs gave the same) decodeperf's dispatch_cost, small shape (64 command buffers of 5 encoders, Iris Xe, job m3-max-28732, two pairs of runs), does not tell it from its spread: 74,250 and 74,113 -> 73,910 and 74,131 instructions a dispatch, 51,220 and 52,154 -> 50,554 and 49,858 cycles. |
||
|
|
4fe5f13849 |
✅ Add a cost test of a command buffer's view of its table
Super Resolution's 6,847 command buffers of about 6 dispatches each spend 4.19 us a dispatch in tables::View::get on gbp-iris (perfscout4), and the call graphs of gbl-iris put 43% of View's samples in the binds of compute encoders' setBuffers, 18% in the views' drops. The test times what a command buffer's view costs over a table of 4,096 objects: its take, its first lookup of each object it names, the lookups the decoder's cache of recent entries misses, and its drop. It prints the thread's user-space instructions and cycles a command buffer and a name, the figures View's changes are measured by. |
||
|
|
da5ecdcc3e |
🐎 Walk the backing table's runs in one search a range
Each step of a scattered view's life looked its pages up in the backing table one at a time: a page of the guest's RAM, a source of the view, took two searches of the runs' BTreeMap (the run holding it, and the next run after it), and each of the view's own runs one search in every write check (the import's and the gate's), in the runs of the guest's RAM the runtime asks for, and in the protect check; the teardown's forget searched again for every run it dropped, and three times more for the joins beside it, and a fresh view's record looked each piece's neighbour up again. On a device that imports views mapped from their files (Iris Xe's ANV), with hundreds of thousands of one-page runs of other views in the table, that is what perfscout4's profile of gbp-iris names: about 14 us a dispatch over Feature Matching, and 6 to 8% of Photo Filter's, Video Filter's, Path Tracer's and Horizon Detection's graphics threads. A range is now walked with one search: the last run that starts before its end tells whether any run reaches into it (none, for the guest's RAM), and the runs in it are then taken in order, the registrations filling the bytes between them, the stretches the same as the lookups one at a time gave. A forget drops the runs of its range in one pass, with the joins they take part in counted as removing them one at a time uncounts them, and a fresh record counts its pieces' joins from the pieces themselves. What every call answers is unchanged: walks_and_joins_match_a_page_by_page_table sets the walk's stretches, the counted joins and holds_none beside a lookup of each page alone and a recount from scratch, through random records, forgets and protects of runs over and beside a registration. a_scattered_views_life_costs (homelab-ms01-1, release, user space, a page of a 16,384-page scattered view beside 200,000 other runs, median of 8 views), instructions / cycles, before -> after: step instructions cycles resolve (view_pieces) 611.5 -> 289.5 144.4 -> 78.8 record (record_pieces) 1390.0 -> 831.6 517.8 -> 354.9 import's writable 402.6 -> 43.3 203.0 -> 12.4 import's through_pieces 33.3 -> 33.3 10.5 -> 10.3 gate's writable 402.6 -> 43.3 201.2 -> 12.2 guest_ram_runs 456.0 -> 134.6 210.9 -> 27.2 forget (teardown) 2128.6 -> 407.5 620.5 -> 144.8 the view's life 5424.5 -> 1783.2 1913.2 -> 638.8 (-67%) (job m3-max-28671; a second pair of runs gave the same instructions and cycles within 1%) The kernel's maps, a mapping a page from the memfd, are what is left of a view's cost on ANV; the table's share no longer grows with the runs. |
||
|
|
76875deabd |
✅ Add a cost test of a scattered view's life in the table
Feature Matching's no-copy buffers are views of up to 140,000 scattered guest pages each. On a device that imports views mapped from their files (Iris Xe's ANV), every page goes through the backing table's BTreeMap many times over the view's life: on gbp-iris, perfscout4's profile puts the table's searches at about 14 us a dispatch over that pass, and 6 to 8% of Photo Filter's, Video Filter's, Path Tracer's and Horizon Detection's. The test runs a view's life against the table alone, beside 200,000 runs of other views: the resolve of its sources, the record of its pieces, the import's and the gate's write checks, the runs of the guest's RAM the runtime asks for, and the teardown's forget. It prints each step's user-space instructions and cycles a page, read from the thread's own perf counters (os/linux/thread_counts.rs), the figures the table's fixes are measured by. |
||
|
|
6beda4878b |
📦 Rebuild both guest sets for the slabs' wait and the overlaps
Both sets built afresh from this tree on the M3 Max (Xcode 27.2, job m3-max-28669: make -C guest test, make -C guest prebuilt, make -C guest prebuilt-arm64e and make -C guest prebuilt-check, each exit 0), for the Metal bundle's sources the two commits before this changed: RgfxSlabs.cpp, RgfxSlabs.hpp and RgfxRegion.hpp (a take and a reclaim wait for the slabs on their way back), RgfxAirArguments.cpp and RgfxPipelineReflection.mm (the overlap refusals at newFunction). Only RgfxGate, which carries the bundle, and the records change. |
||
|
|
d5c67a65f4 |
📦 Rebuild the 14 metallibs an older Xcode wrote
cargo xtask metallibs on the M3 Max rewrote the bytes of 14 of the Vulkan crate's committed metallibs while their record, metallibs.toml, stayed the same: the record holds the hashes of their commands and sources, which did not change, and those 14 were written by an older Metal compiler (metalfe-32023.921.6: AIR 2.8 for macOS 26.0, or AIR 2.9 for macOS 27.0). Every later run on the M3 left them as uncommitted changes. This commit takes cargo xtask metallibs' output on Xcode 27.2 (27B52, metalfe-32023.922.4, job m3-max-28640) for barycentric, five_samplers, icb_color1, icb_encode, numbered_samplers, predication, refused, rgbx, simd_stages, slice_write_repro, spin, unrasterized, vertex_ids and ycbcr_probe. All 28 are now AIR 2.9 for macOS 27.2 from one compiler, as the other 14 already were. The sources and the record are unchanged. Thirteen are the tests' shaders. predication.metallib, command predication's step kernel, ships in the library (the Linux build copies it from here): the same source compiled by the newer compiler, which the predication tests run, so nothing the guest sees is meant to change. |
||
|
|
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.
|
||
|
|
4b06fb8eb8 |
🐛 Wait for the slabs on their way back before refusing a buffer
A slab being let go leaves the slabs' books before its memory is back in its source: its heap's destroy and its block's release, which the kext answers once the host has let go of it, run outside the lock. A buffer create that found no room, and whose own let-go of the empty and cached slabs found nothing left to drop, asked its source again at once and answered nil while another thread (or the background thread) was still giving those slabs back. The region's reclaim answered the same way for any block it was asked for. For the guest: newBuffer of a Shared or Managed buffer, and a block of the region (a Shared heap, a texture's CPU copy, a staging window, a command buffer's out-of-line message), could be nil near the region's or the pages' end while another thread freed buffers. It found the memory a moment later. test_slab_thread caught it once on the M3 (m3-max-25197): on that 4-thread test under Rosetta, development's slabs refused a 3 MiB take in 8, 9 and 3 of 1,000 runs (m3-max-28562, 28595, 28619). Each refusal came with 15 to 52 slabs, 42 to 154 MiB, out of the books and not yet back in the source: a starved background thread had let doomed slabs pile up, and one thread's evict was dropping them all. This branch: 0 of 1,000 and 0 of 2,000. A take that finds no room now waits for the drops in flight and the doomed slabs as it asks, then asks again; so does RgfxSlabs::reclaim, which then answers true. Those are the drops its own dropDoomed(true) would have made had it come first, on the same locks and the same host answers, so the wait holds the thread on nothing that call does not. None of the region's callers that reach the reclaim holds a lock the drop path takes (the serializer's library-key, ICB, destroy and ring locks, the region's pages lock): the argument encoders' answer blocks, an ICB's slots (its own slot lock), a Shared heap, an IOSurface's shadow (its making lock), the upload and body pools (an arena's lock, a queue's post lock), a library's staging window (the stream lock), a texture's CPU copy. stats().dooming counts the drops in flight too. Tests: test_slab_take_waits_for_slabs_given_back and test_region_reclaim_waits_for_slabs_given_back hold a slab's release at a gate while another thread asks for its room: without the waits each answers nil at once (both fail without their halves of the fix). test_slab_thread also checks that every byte its source gave is a slab's. |
||
|
|
b1723ebdcb |
🎨 Format dispatch_cost as rustfmt lays it out
cargo fmt --all -- --check flagged three spots of the cost test's file. |
||
|
|
d8ad27f09c |
🐎 Cut a command buffer of compute encoders into parts
The Vulkan platform refused a split while a unit of command predication was open, and every compute encoder opens one, so a buffer of compute encoders alone was never cut: Geekbench 7's Fluid Simulation commits 2,600 one-dispatch encoders in one buffer, and its GPU work waited for the whole walk. A split now needs only no block open, no loop body being laid down again and no unit an unbalanced record emptied (Predication::cuttable). A unit open at the cut goes on in the next part (Predication::go_on): its first dispatch type, work, indirect dispatch and numbering carry over, so what Metal decides by the unit (an unbalanced encodeEndIf after its work, a first indirect dispatch of another type) dies where it would in the whole buffer. With no block open the GPU's skip counter is 0, so the next part's counter, reset at its first step, stands for the cut part's. For the guest only timing changes, and where a walk faults after a part was committed, that part's work has run, as for a buffer of render passes (only invalid input reaches that). dispatch_cost's fluid shape (1 buffer of 2,600 encoders of one dispatch, M3 Max, MoltenVK, release, median of 5 runs of 6), through the decoder: first take to completion 87.0 ms -> 34.8 ms; the walk's CPU 14.7 -> 8.8 us a dispatch (164.2k -> 110.6k instructions), as the runtime's work for an encoder grows with the encoders before it in its buffer. The small (64 x 5 encoders) and one-encoder shapes are not cut, and stay as they were. Tested by a_unit_goes_on_in_the_next_part, a_block_open_keeps_a_command_buffer_whole and the encode_compute dies and goes_on cases across a split. |
||
|
|
b339c98596 |
✅ Time a compute command buffer's completion in dispatch_cost
A guest that commits each command buffer after the last one completed, as Geekbench 7's Fluid Simulation does, waits for its walk and its GPU work in series unless the walk commits it in parts. dispatch_cost now also prints each path's latency, a repetition's first begin to its last completion, and walks the decoder's messages in a context, as a queue's ring hands them, so its walk commits parts where the platform lets it; DISPATCH_COST_SPLIT_US sets how long a part is walked (one longer than the walk keeps it whole), as composite_cost's COMPOSITE_SPLIT_US does. |
||
|
|
e3a17c7b39 |
🐎 Read compute ops' records in place
Each array-tailed compute op copied its element records into a Vec, then built a Vec of the objects they name and one for each other list it hands the encoder: three allocations for every setBuffer:, setBytes: and setTexture: the bundle sends as a list of one, two for every setSamplerState:. The records are now read where they lie in the op's body, after the same check of their span, and the lists sit on the stack up to 16 entries (a Vec past that). The objects are resolved in the same order, so the same reference faults first, and the encoder gets the same slices. dispatch_cost on the M3 Max (MoltenVK, release), the decoder's cost above the platform's a dispatch: 3,754 -> 2,049 instructions in the fluid shape (an encoder a dispatch, five binds each), 3,566 -> 1,740 in the shape of one encoder. |
||
|
|
4ad13220e5 |
🐎 Box the runtime's compute encoder
The runtime's compute encoder is 4,104 bytes, and the platform kept it by value: each move between its making and its end (out of the runtime call, through the answer layer's closure, into the predicated encoder, into its lock's cell, into the object's allocation, out again at endEncoding) copied it whole. In a command buffer of an encoder a dispatch, as Geekbench 7's Fluid Simulation sends 2,600 of them, those copies were 9% of the decoding thread's busy time on the M3 Max (sample(1) of dispatch_cost). It is boxed as it is made, as the blit encoder already is, so it moves as a pointer. Nothing it encodes changes. dispatch_cost on the M3 Max (MoltenVK, release), fluid shape, the platform's cost above the runtime's a dispatch: 17,757 -> 6,738 instructions and 6,144 -> 2,153 cycles (about 1 us of the 12 us a dispatch takes there). The shape of one encoder, which makes no encoder a dispatch, is unchanged (3,662 -> 3,600). |
||
|
|
c594123e01 |
✅ Add a cost test of a compute dispatch
Geekbench 7's Fluid Simulation commits command buffers of 2,600 compute encoders of one dispatch each, one after another's completion, so the host's walk of each is on the run's critical path: 20-25 us a dispatch on a Radeon 780M (perfscout4's gbr-780m trace), where Metal encodes one in 1-2 us. dispatch_cost sends that shape through the decoder, through the platform's core traits and through the runtime alone, as draw_cost does for draws, and prints the thread's CPU time, instructions and cycles a dispatch of each, so the gaps show the decoder's share, the platform's and the runtime's. The shapes `one` (the same dispatches in one encoder) and `small` (64 command buffers of 5 encoders) split what an encoder costs from what a dispatch does. The runtime's path commits with commit_and_submit, as the platform does. A measurement run by hand, holding the GPU; the shape's own unit test runs in the suite. |
||
|
|
e080c5568f |
📝 Record what GL's Apple settings need of the device [ci skip]
The design said the GL renderer's Apple settings need Apple7 and the vendor "Apple". Its five settings records (macOS 27.0.1, arm64e) show Apple5's and Apple7's are the same in every setting the renderer reads but the largest point it draws, 16 pixels against 64, so Apple5 with a vendor none of AMD, ATI, NVIDIA and Intel is the narrowest pair. The section now lists the other settings the Apple records hold (the texture upload and mipmap path, the seams on cube maps, the point clamp) and why the device claims neither: Apple4's and Apple5's rows hold tile shaders, imageblocks and nonsquare tile dispatch, which the device does not carry and the runtime refuses on every device (its audit on an Iris Xe at metal2vulkan c796a88d6a: 26 of Apple5's rows block), and the Apple settings send GL_POINT polygon mode as setTriangleFillMode: 2, on which the platform dies. |
||
|
|
fb50368276 |
⬆️ Build on metal2vulkan bc12f6d95a's runtime
Pin 86 moves metal2vulkan from c796a88d6a (RUNTIME_VERSION 2263,
SEMANTICS_VERSION 2107, ARTIFACT_FORMAT_VERSION 522) to bc12f6d95a (2266,
2107, 522). It carries:
- a kept draw that reads its own attachment through the copy, carried
into a pass whose every step snapshots, asking every step's form again
(RUNTIME 2266). It was rebound with the copy form and, in release, read
stale texels: the draw_again.rs 780M device test's panic at pin 84;
- the staging queue's command-buffer ring growing to 128 instead of
waiting on the host for its oldest buffer past 8 (RUNTIME 2265; new
WorkCounts staging_buffers_grown and staging_buffer_waits): the likely
end of the 23.6 and 323 ms submissions held under the scheduler's lock;
- on NVIDIA, draws reading a texture after a barrier, where the texture
has no feedback-loop usage, take leading snapshots weighed by area and
learned coverage instead of a split and a scissored copy (RUNTIME 2264;
new WorkCounts reading_draws_snapshotted_leading and
reading_draws_leading_covered_{within,to_half,over_half});
- the leading_snapshots test's expectation fixed to coverage measured
after a pass that saw both readers.
No degradation kind or runtime gap changes (247 and 80), and SEMANTICS
and ARTIFACT_FORMAT stay, so every host's caches and records stay warm.
What the guest sees changes where a kept draw read its own attachment in
an all-snapshot pass (right texels now) and in timing.
The checks it reaches are the library's on the Mac and on each Linux
GPU class, rustdoc, and, since the runtime's GPU results change for
guest frameworks, a cold boot of the x86 guest on each GPU class and the
arm64 gate. The video crate, the window crate's register, the guest
sets, the option ROM and QEMU link nothing of the runtime's changes and
cannot move.
bc12f6d95a is metal2vulkan's GREEN.
Cargo.lock keeps its lines.
|
||
|
|
7b01419033 |
⬆️ Build on metal2vulkan c796a88d6a's runtime
Pin 85 moves metal2vulkan from f6a19accbe (RUNTIME_VERSION 2261, SEMANTICS_VERSION 2107, ARTIFACT_FORMAT_VERSION 522) to c796a88d6a (2263, 2107, 522). It carries: - distinct textures sharing one resource key at bytes apart share no memory (RUNTIME 2262). With it, a grouped pass's resolve into a target over bytes apart from what it read is no longer refused (NotImplemented(ColorAttachmentGroups)), textures carved from one buffer at bytes apart take no needless attached read, and a sampled texture's copy no longer clears to another texture's clear value; - an indirect command buffer's compute commands ordered by their records' barriers alone, as Metal documents (RUNTIME 2263): about 410 fewer barriers a frame in a game-shaped frame's host step; - a default-off diagnostic naming each batch submission that holds its thread 5 ms or longer, phase by phase (METAL2VULKAN_QUEUE_TIMES). No degradation kind or runtime gap changes (247 and 80), and SEMANTICS and ARTIFACT_FORMAT stay, so every host's caches and records stay warm. What the guest sees changes where it made textures at bytes apart over one buffer (a resolve that was refused now runs; a sampled copy's clear value is its own texture's) and in timing. The checks it reaches are the library's on the Mac and on each Linux GPU class, rustdoc, and, since the runtime's refusals and GPU results change for guest frameworks, a cold boot of the x86 guest on each GPU class and the arm64 gate. The video crate, the window crate's register, the guest sets, the option ROM and QEMU link nothing of the runtime's changes and cannot move. c796a88d6a is metal2vulkan's GREEN. Cargo.lock keeps its lines. |
||
|
|
0abbaa7c34 |
⬆️ Build on metal2vulkan f6a19accbe's runtime
Pin 84 moves metal2vulkan from 1eaeb7079a (RUNTIME_VERSION 2258, SEMANTICS_VERSION 2106, ARTIFACT_FORMAT_VERSION 522) to f6a19accbe (2261, 2107, 522). It carries: - a kernel's staticThreadgroupMemoryLength reported rounded up to 16 bytes, as Metal reports it (SEMANTICS 2107). The display's displayMirrorTile, whose threadgroup variables take 1028 bytes, now answers Metal's 1040, so the compute state test expects every kernel here to answer as Metal does again, and its pin of that one difference goes; - a use's range kept at 32 bytes, an image's place in its heap counted in 64-byte granules (RUNTIME 2259), for the per-draw cost RUNTIME 2257 added on the XTX; - every rate-mapped pass's pieces timed, one piece included (RUNTIME 2260), a work count only; - a commit that returns while its batch waits for a VkQueue someone else holds, where it waited as long as the queue was held; and kept draws carried only into passes of the same sample positions and the same renderTargetArrayLength, where a draw kept from a pass at custom positions or another layer count drew wrong pixels on AMD and lavapipe (RUNTIME 2261). No degradation kind or runtime gap changes (247 and 80). What the guest sees changes in staticThreadgroupMemoryLength's answer for kernels whose threadgroup memory is not a multiple of 16, in the pixels of passes that had carried a kept draw across sample positions or layer counts, and in timing. SEMANTICS 2107 misses every host's cached keys, so each host's caches start fresh once. The checks it reaches are the library's on the Mac and on each Linux GPU class, rustdoc, and, since the threadgroup length answer and SEMANTICS 2107 change what guest frameworks choose and what guest shaders compile to, a cold boot of the x86 guest on the Iris, the 780M, the XTX and the RTX 2080 and the arm64 gate: the video crate, the window crate's register, the guest sets, the option ROM and QEMU link nothing of the runtime's changes and cannot move. f6a19accbe is metal2vulkan's GREEN: e30c91de8a with its authored compile census re-blessed, which only metal2vulkan's own tests read. Cargo.lock keeps its lines. |
||
|
|
5353c7cba9 |
📝 Record the mirror's sync waited for on the compositor's GPU [ci skip]
Route 1's design notes described the CPU ordering the two GPUs and named the sync-file export as the step still to take. The draw now waits for the mirror's sync on the compositor's GPU, so the notes say how, and where the window's thread still waits. They record the walk pair on pin 83 that measured it, warm against warm, on um870's RTX 3090 beside its 780M compositor and on um790's 780M beside its XTX compositor: the render thread's wait a sync fell from 4.63 to 0.45 ms and from 4.25 to 0.99 ms. Every sync went to the compositor as a sync file, none after host copies, and rates and latencies held. They also explain Mission Control's take-to-show median rising from 2.2 to 14.4 ms under route 1: its presents fall in two groups, those finished by their take and those whose writers still run, and route 1 made the second group faster (39.1 to 15.2 ms) and larger, so the median moved between them while the mean fell from 18.2 to 10.0 ms. The GPU wait leaves both groups as they were. |
||
|
|
995c9fa8f7 |
✅ Mark the Vulkan mirror test once as a test
The mirror's GPU wait gave the test's doc a second #[test] attribute, which rustc refuses as duplicated. |
||
|
|
9b3ad186dc |
🐎 Wait for the window's mirror on the compositor's GPU
The window's thread waited for each mirror sync, the runtime's GPU's copy of the changed tiles over its link, before it encoded the draw on the compositor's GPU: 1.6 ms a present in Mission Control, 7.3 ms in an autoscroll and 10.8 ms in GL 3D on a 3090 beside a 780M. A sync now asks for its completion as a sync file, and the draw that reads the mirror waits for it on the compositor's GPU, so the window's thread waits for no GPU work of the sync's. The next sync waits for the last draw, as before, and for the sync before it, whose count of tiles it then reads. Where the runtime exports no sync file (MoltenVK), the sync finished before the export looked, or the compositor's device cannot import one (logged once), the window's thread waits for the sync as before. The mirror's debug log counts the syncs waited for on the GPU. The Vulkan mirror test checks that each sync asks for a sync file exactly where the runtime exports one, and that one of its syncs at least went to the draw as a file there, besides the pixels it checked. |
||
|
|
3e6c5c2124 |
🆕 Export and wait for a command buffer's completion as a sync file
The window's mirror orders the runtime's GPU and the compositor's on the CPU: the window's thread waits for each sync before it encodes the draw that reads the mirror. metal2vulkan exports a command buffer's completion as a sync file from pin 82 on, which a device of any driver imports, so the draw can wait for the sync on its own GPU instead. The platform's command buffer gains the three steps, each refusable: ask for the completion as a sync file before the commit, export it after, and wait for one before a command buffer's work. The wait imports the file into a binary semaphore made for it (a temporary import), which the command buffer's completed handler destroys. A device that exports none (MoltenVK, RuntimeGap::SyncFileExport) or imports none refuses, and the caller waits on the host. The test fills a buffer on one queue and copies it on another that waits for the fill's sync file, or takes the refusal where the runtime exports none. |
||
|
|
c11dee753a |
✅ Take the fuzz's known op tags from the wire's own constants
The command buffer fuzz counts a tag past a fixed table's last as unknown and checks that a buffer holding one is never carried out. The table was stale. Framing stopped at 0x0009 (ENCODER_BEGIN_VIDEO), though the walk takes SURFACE_ORDER (0x000c) and COMMIT_ORDER (0x000d) and steps past GUEST_TIMES (0x000e). Render stopped at 0x104f with ops up to 0x105e, and video at 0x4000 with ops up to 0x4003. A seed that drew one of those tags from past the table could fail the test on a buffer carried out as it should be. Each group's last tag is now read from reims-vgpu-graphics's op modules, their `pub const RGFX_OP_...: u16` lines, so an op added to a group is in its range as it is written; a tag in a new group fails the fuzz until it has a slot. A test checks the bounds: every group holds tags, the tag past each last is unknown, and the three framing ops above are known. The generator now also leaves out SURFACE_ORDER and COMMIT_ORDER, which wait for other buffers as the event and surface ops it already left out do, and draws framing tags from 1 to its last (it drew one past it). The GUEST_TIMES case in the unknown check goes, as the bounds now hold it. |
||
|
|
db058169b4 |
🆕 Split the time before a command buffer's take by its stamps
Where the guest took GUEST_TIMES, a queue's thread notes the host's clock as it takes each buffer, before the gate, and as it comes back to the ring after the buffer before it. With ring 0's clock offset (its bound read with acquire, then the offset) it splits the buffer's time before the take: encode (committed - made), post_wait (posted - committed), queued (behind the queue's buffer before it, on the host) and transport (the doorbell, the thread's wake and the ring), posted mapped to the host's clock. With no offset held only encode and post_wait are given. Each buffer's spans go to the host's trace as a cbguest event: queue, seqno, the spans, the offset's bound, and held, the time from the take to the event, so a reader places the take. Once a second a debug line of target reims_vgpu_graphics::guest_times gives the buffers' count, each span's sum and median, and the longest transport. Both are diagnostics: the device does nothing else differently, and reads nothing of a guest that did not take the bit. The device's tests: a stamped buffer's spans reach the trace, alone and queued behind a buffer the host holds; a buffer without the op, or a guest without the bit, gives no event; with bound 0 there is no transport. The module's own tests cover the spans' clamps and the line's window. |
||
|
|
14c2c18e8c |
🆕 Stamp each command buffer with the guest's clock (GUEST_TIMES)
The host sees a command buffer only once a queue's thread takes it off its ring, so the app's encode and the buffer's way to the host show as one span with nothing pending on the host. This adds the guest's stamps that split it, a diagnostic. What changes for the guest: - The device offers a new feature bit, RGFX_FEATURE_GUEST_TIMES (bit 44, FEATURES_HI bit 12), and DRIVER_FEATURES takes it. The kext carries it. - Where the device's word holds it, the bundle starts each command buffer's stream with a new op, RGFX_OP_GUEST_TIMES (0x000e, 32 bytes): the guest's clock as the buffer was made, as its commit was entered, and as its message went on its ring. The last is written under the ring's lock, after the copy and before producer is published; for a buffer in a block, into the block. - After each VBLANK's reading of HOST_TIME the kext writes ring 0's new header fields: guest_clock_offset_ns (0x18), then guest_clock_bound_ns (0x20) with release, split out of reserved bytes. The host zeroes both as it initialises a ring. - The decoder walks the op as a no-op, so it changes nothing a buffer does, and a host that did not offer the bit never sees it. Old guest sets carry no bit, send no op and leave the fields 0. The header is regenerated, both guest sets are rebuilt from the same sources, and the option ROM's record takes the header's new hash; the ROM's bytes are unchanged. The tests cover the op's and fields' layout (the header test, the kext's vblank clock test), the bit's negotiation (the kext's features test, the peer and memory-map tests), the stamps (the bundle's serializer and shell tests) and the walk (a cmdbuf test, and the fuzz's streams). The host's reading of the stamps is the next commit. |