054f8a71d0789195841cb9c024adbb86b8600a09
124
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
65cbf3220e |
🐛 Make a pages block's view after its answer on a worker of its own
Where the guest took IMPORT_ADDRESSES_LATER, a pages block's SURFACE_PAGES was answered as soon as its runs were carried out, and its view was then mapped and imported on the same surface worker job before the block settled. The surface worker runs at most four threads, so four blocks' view makes held every thread, and the next block's SURFACE_PAGES waited for one behind them, however short its own carry-out. On the RTX 3090's gcl boot (rowb-3090, m3-max-79853) carry-outs took at most 2.1 ms, view makes 14.9 ms at the median and up to 351 ms, and 64 answers took over 50 ms, up to 133 ms: of the 225 over 20 ms, 163 waited while four or more other blocks' views were being made. The view made after the answer now runs on the views worker (reims-vgpu.graphics-views-<i>), a worker of its own under the block's key, which holds the block's settle until the view is made: the messages that name the block wait for it as before, and the surface worker's thread goes on to other blocks' SURFACE_PAGES. A job of the block's on the surface worker (its BUFFER_OVER_PAGES, or its next SURFACE_PAGES) that finds one of the block's on the views worker runs behind it there (Worker::behind, one step under the worker's lock), so the block's jobs keep their order across the two workers; a SURFACE_PAGES run there makes its view itself, so no views worker's job hands one to the views worker. The views worker runs at most POOL_THREADS (4) threads, as every worker does, and holds at most VIEWS_WAITING (256) jobs waiting (Worker::bounded): a hand-over that finds that many waits on its surface worker's thread until one is taken, counted and logged at debug. The busiest 100 ms of the same boot carried out 140 SURFACE_PAGES. No setting changes either number. The view's make takes the reset gate shared, recursively, as the surface worker's jobs do, and where the device was reset since the SURFACE_PAGES' begin it makes nothing. What the guest observes: a LATER SURFACE_PAGES is answered without waiting for other blocks' views; its own block's later messages wait for its view as before. What the host observes: raise_interrupt may come on a views worker's thread (a SURFACE_PAGES or a BUFFER_OVER_PAGES run behind a view there posts its answer or its command buffer's failure), named in reims_vgpu.h, api.md and RAISE_THREADS. QEMU's raise_interrupt callback takes a call from any of the library's threads (the irqfd's write, the WHPX request under msi_lock, or a BH), as it does from the surface workers', so its side needs no change. Nothing changes where the guest did not take IMPORT_ADDRESSES_LATER. Tests: - a_pages_block_s_answer_waits_for_no_other_block_s_view: four blocks' view imports held, a fifth block's SURFACE_PAGES is answered, no surface worker cap hit, the views worker at four threads, and a BUFFER_OVER_PAGES over a held block made only after its view. - a_reset_ends_pages_views_made_after_their_answers_cleanly: a reset waits for the view being made; the view waiting on the views worker and the buffer behind it make nothing after the reset; both blocks settle. - a_device_released_while_pages_views_are_made_after_their_answers_ends_clean: the release waits for neither view, and the device's control goes once both views' jobs end. - worker: a_bounded_worker_s_hand_over_waits_for_room, a_job_behind_a_key_runs_after_its_jobs_or_here_where_it_has_none. |
||
|
|
1e8853cd04 |
🆕 Keep the AIR of states rt refuses for unsupplied draw input
REIMS_VGPU_REFUSED_AIR_DIR kept the AIR and record of a pipeline state only where the translator refused it. A state rt refuses as reading what a draw or a dispatch does not supply yet (Gap::RenderPipeline, Gap::KernelInput, such as DrawInput) names no cause: it is one of a function table, a translation table, a long parameter block, an unfilled push field or an unnormalized constexpr sampler, which only the functions' AIR tells apart. A usdz preview in Quick Look on an x86-64 guest met one (DrawInput) that no log could explain. The switch now keeps those states' AIR and records too. It is a diagnostic, off by default: nothing the guest or host observes changes. |
||
|
|
82d7064f04 |
🐛 Release reims-graphics at a quit of a VM that was not running
vendor/qemu moves to f8a1f0c5 on the fork's steelbrain/reims-vgpu-rebase-2 (a60aa2b3 before it). A quit of a VM that QEMU was not running (paused by QMP's stop or by a full disk, never started past -S, or paused by a shutdown whose action pauses) stopped no running VM, so the device's VM state handler never tore it down. The device stayed to the exit, the library's quiesce at the end of QEMU's cleanup answered that it still held a GPU device, and QEMU ended with _exit. reims-ctl's stop of a VM paused for a full disk quits such a VM. QEMU's cleanup notifier now first tears down each device no teardown ran for, BAR 2 out of the guest's address space first, as at a stop. The release lets go of the GPU device, the quiesce answers true, and QEMU ends with exit(). Only a device a display's read kept (a GPU that stopped answering) still ends QEMU with _exit. docs/qemu.md and docs/api.md say so. What changes for the host: such a quit ends by exit(), with its exit handlers run. The guest sees nothing: it no longer runs. |
||
|
|
2a0064a9bb |
🆕 Write the degradation counts again each minute they changed
The library writes its degradation counts line at a device's reset, at the process's exit and when the host asks (reims-ctl report). A QEMU killed or crashed writes nothing at its end, so its log held counts only as of the last reset or ask, often the boot's start: a report of such a run had nothing to read its degradations from. The first device made on the process's platform (GraphicsDevice::new, as the C API makes QEMU's) now starts a thread, reims-vgpu.counts, that every COUNTS_REWRITE, a minute, folds rt's metrics in and writes the counts line where it changed since the library last wrote it, and nothing else: the repeats' line and rt's diagnostic lines stay the reset's, exit's and ask's. Each write is an entry, so the thread parks for good once the process's exit began. A killed or crashed QEMU's log now holds counts at most a minute old. A diagnostic: free under the contract. A test's platform runs no such thread. |
||
|
|
68701c61bf |
🐛 Wait at a reset for the queue walks begun before it
The device's reset waits, in the host's settle, for the GPU work the guest committed before it, so none of that work writes the guest's memory after the reset returns. A queue walk begun before the reset could still commit work after the settle looked: the control thread's reset waits for it (the reset gate), but the settle cannot take that gate, as ring 0's queue creates and destroys hold it and may wait for the BQL that QEMU holds around the reset. The walk's GPU work then ran, and wrote the guest's pages, after the reset returned. The settle now waits, within 30 s of its start, as for the decoder's locks, for the queue walks begun before the reset (walks.rs: a ticket taken in begin_command_buffer before the walk asks whether its poster is stale, so a walk that begins after the reset ends at once and is not waited for). First it cuts short every wait the control thread's reset cuts short, so no walk waits for that thread: for other queues' buffers and their events (Decoders::resetting; commit_order::Cancel now nests, as the two resets may overlap), for compiles outside the process (GpuDevice::reset_begins, whose stage-fill suspends nest) and for pipelines still compiling (Pending::resetting, which nests too). After the walks it releases the events and surface timelines again, for what the walks made or waited for meanwhile, then waits for the GPU as before, on progress: the command buffers it waits for are those committed by then, the walks' among them. Ring 0's block-lane downloads and cache copies stay out of it. A walk past 30 s ends the process at "the device's reset", naming the oldest. The settle's line now reads "the device's reset waited X ms for the W queue walks begun before it (Y ms) and the N command buffers committed to the GPU before it, Z ms at most with none of them completing". What the host observes: rvg_graphics_device_reset and a STATUS write of 0 return only once the queue walks begun before them have ended, which the header's reset doc and docs/api.md now say. Two tests held the old behaviour and change with it. a_reset_during_a_walk_comes_after_it had the reset return with the walk in flight; it now resets on a thread of its own and checks that the reset waits. reset_chain's stage-fill test had the fill go on through the settle, cancelled only by the control thread's reset, with the settle setting the writer's timeline on the CPU; now the settle cancels the fill, the walk ends with its dispatch refused and commits the writer's buffer, and the settle waits for it and the reader's on the GPU. Its compile test now moves the clock past the bound where the reset has not returned, so a red run dies there rather than hanging. Tests (tests/reset_walks.rs), each with the control thread's reset held behind a ring-0 message whose platform call is held, standing for the BQL: - a_reset_waits_for_a_walk_begun_before_it and a_reset_whose_walk_runs_past_the_bound_ends_the_process; - one per wait class a walk can sit in, each ending inside the bound: a COMMIT_ORDER wait, a begin's SURFACE_ORDER wait (whose buffer then waits on the GPU for a timeline the settle sets after the walks), a stage's fill and a pipeline still compiling. Job m3-max-79627 (homelab-um870-1) ran them on the fake platform three ways. Green: all pass, with the progress rule's and the chain's tests (88). Without the walks wait: the two walk tests, a_reset_during_a_walk_comes_after_it and the SURFACE_ORDER test, whose timeline is set only after the walks, fail. Without the settle's cut-shorts: each wait class's test and both chain tests die at the bound. fmt, the header's check and clippy on the host and the Windows target are clean (79627); the workspace's 3167 tests pass on homelab-um870-1's Radeon 780M (79647). |
||
|
|
161cf78cf4 |
🐛 Let a reset wait while the GPU work before it completes
The device's reset waits for the GPU work the guest committed before it, so
none of that work writes the guest's memory after the reset returns. It waited
a flat 30 s, and ended the process past that. A guest that is busy, with
nothing stuck, could reach it: the settle waits for every command buffer
committed before the reset, and a backlog of long ones, each well within the
drivers' watchdogs, can sum past 30 s. Nothing of ours bounds that backlog.
The wait now runs on progress. The set of command buffers it waits for is
fixed as it begins. It waits while they complete, each within 30 s of the one
before (or of its start), and 10 min at most in all: the time cap of the helper
process that runs pipeline compiles and stage fills, read from its definition
(os::compile_helper's TIME_MOST, exported as COMPILE_HELPER_TIME_MOST), not a
new constant. The decoder's locks the settle takes keep their flat 30 s. Each
settle logs the longest it waited with none of its command buffers completing.
What the host observes: rvg_graphics_device_reset and a STATUS write of 0 wait
while that work completes, past 30 s, and end the process only once 30 s pass
with none of it completing, or at 10 min. A reset still waiting 2 s on writes
one line on stderr, whatever REIMS_VGPU_LOG says ("reims-vgpu: reset waiting:
for the GPU work committed before it, N command buffers, 2 s on"), and one
once it is done ("reims-vgpu: reset waited: S s for the GPU work committed
before it"). The death's line says which bound it passed. reims-ctl's
interface reads the first line from QEMU's log, and shows the VM's state as
"reset: waits for GPU", with the line in its pane, until the second comes. The
header's reset docs, docs/api.md ("Waiting", "Deaths", the threads table and a
new "The reset's lines") and docs/known-issues.md ("A stuck GPU closes the VM
when it restarts": one command buffer running past 30 s on a driver that never
ends it is a stuck GPU to the reset) say so.
GpuDevice::settle takes SettleBounds and a waiting callback and answers
Settled; rt's Flights::settle restarts its bound on each command buffer that
completes, on the platform's clock, as the testkit's World::settle does on
virtual time.
Tests: a_reset_waits_on_while_its_gpu_work_completes (three buffers, one
completing every 20 s: the reset returns, having said both lines) and
a_reset_whose_gpu_work_completes_past_the_most_ends_the_process (one buffer
every 29 s, 22 of them: alive after 20, dead at the ceiling); rt's
a_settle_waits_while_its_command_buffers_settle_within_the_quiet_bound on a
virtual clock; reims-ctl's a_vm_whose_reset_waits_for_its_gpu_shows_it.
Red, job m3-max-79515 (homelab-um870-1, fake platform): with the settle's
ceiling set back to the flat 30 s, both reims-vgpu tests fail (the reset ended
40 s on, with its GPU work completing; it ended before the most it waits).
Green: the same tests pass (79515); fmt, the header's check and clippy on the
host and the Windows target (79539); the workspace's 3156 tests on
homelab-um870-1's Radeon 780M (79546); make check-ctl on the Mac (79521).
|
||
|
|
cbd87bd547 |
🆕 Offer a headless display the VM's resolution as its mode
A device with no window (REIMS_VGPU_WINDOW=0, or another display of QEMU's) offered every display 1920x1080, whatever QEMU's resolution property said: the property reached the library only inside a window config. A VM started for its viewer alone therefore ran at 1920x1080 whatever its settings named. The C API's RvgGraphicsDeviceConfig grows headless_mode_width and headless_mode_height (its seventh version), read only where window is NULL, and the Rust API's GraphicsConfig grows headless_mode. A display without a window offers that mode first, its width rounded down to a multiple of 16 and its height to even as a window's size is, at 60 Hz; 0 in either, or a host built before the fields, keeps 1920x1080. QEMU's reims-graphics-pci passes its resolution there (vendor/qemu 0f7f65ae). What the host's user gets: a VM started without a window now offers its guest the resolution its settings name. |
||
|
|
39da9779ea |
🐛 End a reset's settle within its bound, and none inside a raise
The reset batch hung on a_raise_may_call_the_device_at_once, past its 540 s slow mark, on every leg. Its raise resets the device, as the header lets it. On the doorbell's thread, inside mmio_write_taking, the raise comes as a CB_SUBMITTED is answered, with the decoder's contexts' lock held. The reset's new settle (Host::reset_settles) then took that same lock and waited for it for good: gdb's stacks in job m3-max-79063 show the thread blocked in release_waits_for_reset on the lock it holds. api.md section 5 lists that lock, a context's table read and the device caches' lock among those the library may hold around a raise, and said no function of the device takes them. The settle took all three. A behaviour change the host observes, in two parts: - A reset made inside the device's raise, on the raising thread, asks for no settle and waits for no GPU work, so that work may write the guest's memory after the reset returns: the one reset without the settle. That thread may hold what the settle takes, and the work it raises for began before the reset and ends only once the reset returns. The device crate counts the raises on each thread (raise_through) and skips Host::reset_settles inside one. QEMU's raise never resets the device or writes STATUS. - The 30 s bound now covers every wait of the settle. Before, it covered only the GPU wait, and the hang was a lock taken before that wait, which no timer reached. The settle now takes the contexts' lock, each context's table read and the caches' lock in 10 ms slices against the same bound, on the platform's clock. Past the bound the process ends with the bound's death, naming the lock. The raise rule widens with this: no raise_interrupt, on any thread, may wait for a lock the host holds around a reset. The settle waits for locks the library may hold around any raise, not only for the threads that run completed handlers. QEMU's raise waits for none: reims_graphics_pci_raise_interrupt_cb writes the vector's irqfd, or takes msi_lock, which the vector's mask and unmask hold under the BQL and which waits for nothing else, or schedules a bottom half. The header's raise and reset docs and docs/api.md sections 1 and 5 say so. Tests: a_raise_may_call_the_device_at_once, unchanged, hung before this change and passes now; a_reset_inside_a_raise_asks_for_no_settle (device crate); and a_reset_whose_settle_waits_past_the_bound_for_a_lock_ends_the_process. |
||
|
|
70698aef1c |
🐛 Wait at a reset for the GPU work the guest committed before it
A behaviour change the host and the guest observe. design.md says nothing begun before a reset reaches the guest after it, as a GPU's reset stops its DMA. But the reset returned while the guest's command buffers committed before it were still on the GPU: they and the completed handlers that merge copied ranges back went on writing the rebooted guest's memory. Now the reset, on the thread that resets (rvg_graphics_device_reset, which QEMU calls under its BQL, or the guest's STATUS write of 0 on the vCPU), ends with Host::reset_settles. reims-vgpu first sets every event the guest's buffers could wait for past every value, and each deferred device cache copy's event to its number, so no buffer waits for a signal nothing will send any more. Then it waits for every command buffer committed before to complete and run its completed handlers (GpuDevice::settle). It waits for no thread of the device's: a route callback on ring 0's thread or the control thread takes the BQL. It logs its time and how many it waited for. The settle is bounded at 30 s, and past it the process ends: a new death, "the device's reset". Only a GPU no driver recovered reaches it. The drivers end hung work as a lost device, whose command buffers rt then completes, failed: amdgpu at 2 s (lockup_timeout's default), and i915's last resort, its heartbeat's engine reset, at most 25 s after work hangs (a pulse at the next 2.5 s tick, raised one level a tick to the highest three ticks later, then twice the 7.5 s preempt timeout; read from intel_engine_heartbeat.c). The code is absent from the counts of the last good boots, as a new one is. The BQL's hold grows by the settle. Typically that is the time the GPU takes to finish what the guest committed before the reset: a settle over a 1 MiB fill committed just before it took 1.3 ms on an RTX 3090, and one with nothing in flight waits for none. At worst it is 30 s, only on a GPU no driver recovered. The host gains one rule: raise_interrupt on the platform's thread that runs a completed handler must not wait for a lock the host holds around a reset. QEMU's waits for none: the irqfd's write, msi_lock, which waits for nothing else, or a bottom half. The header, docs/api.md (sections 1 and 4, and 5's locks around raise_interrupt), design.md's Reset and qemu.md's BAR 0 say so. Tested by a_reset_returns_once_the_guest_s_command_buffers_before_it_have_completed, red before this change (the reset returned with the buffer on the GPU), and a_reset_whose_gpu_work_runs_past_the_bound_ends_the_process. |
||
|
|
8a470a3874 |
📝 Say the create refuses a memory map whose ranges overlap [ci skip]
The config's memory_map said only that its ranges may not overlap, and api.md's status table did not list the refusal. The create refuses, with RVG_ERR_INVALID_ARGUMENT, a map whose ranges overlap or run past the address space (core's MemoryMap::new), and one whose ranges are NULL but counted (the C API's memory_map). The field's doc, the header and the table now say so. |
||
|
|
7811962a81 |
🆕 Say when a later boot uses the guest's bundle again
The bundle line stays in QEMU's log for the whole run. After the guest restarts and RgfxGate replaces the bundle, the line would go on saying the desktop runs without Metal. The library now writes a "guest bundle used" line where a boot finds its own bundle after an earlier boot of the same run did not, so the last line says how the guest draws now. The installer and Recovery get no line: RgfxGate installs nothing there (RGFX_GATE_SKIPPED), and they draw without Metal on every host, so the line would only alarm someone installing macOS. docs/api.md gains "The guest drivers' lines", which describes all three. |
||
|
|
e8f8e88c60 |
📝 Say which destroys the release runs
The header and docs/api.md section 4 said rvg_graphics_device_release calls back never. Section 5 and the tables' own rules say otherwise: the release closes the window, which runs the window table's destroy on the calling thread unless a window callback is running then, and the handle lets go of the device table before the device, so a table with no functions, or one whose last closure the release drops, has its destroy run inside the call. The release's row, the "Calling back" list and the header now say so. The row also says that the release of the process's last device waits at most 5 s for its threads, as the "Waiting" list and the header already said. Nothing changes for the host or the guest. The header is cbindgen's output of the new doc. |
||
|
|
afd1ae46a5 |
📝 Name the release pace's and shared events' threads for raise
Two more threads the library raises on were missing from raise_interrupt's threads. The releases' pace thread (reims-vgpu.graphics-release-pace) carries out a BLOCK_RELEASE as its turn comes, and answers it there where nothing is left to copy, so its COMPLETE is posted and raised there. The shared events' thread (reims-vgpu.graphics-shared-events) tries again the EVENT_SIGNALLED to another holder whose ring had no room for it, through the ring's try_post, which raises. As with the take workers and the UI thread, the code has always raised there and QEMU's raise is safe on any thread, so the header and docs/api.md section 5 name them. The header is cbindgen's output of the new doc. |
||
|
|
f57814d61f |
📝 Name the take workers and the UI thread among raise's threads
raise_interrupt's threads left out three the library raises on. The take workers of the guest's Shared pool and of its Private blocks (reims-vgpu.graphics-pool-take and reims-vgpu.graphics-private-take) post the POOL_BLOCK and PRIVATE_BLOCK answers they give. The windows' UI thread (on macOS the process's main thread, on Linux and Windows reims-vgpu.ui) posts the POINTER_OVER, POINTER_MOTION and SCROLL it tells the guest. The code has always raised there, and QEMU's raise is safe on any thread. Handing those posts to the control thread instead would add a wake on the pointer's input. The header and docs/api.md section 5 now name them. The header is cbindgen's output of the new doc. |
||
|
|
75b42c7900 |
📝 Say the release closes the pool at its start, and waits
The header said pool_remove is not called once rvg_graphics_device_release has begun. The release now closes the pool at its start, and a call the pool's thread began before that may still be running, which the release waits for: pool_add and pool_remove say so, and so do the release's own doc and docs/api.md's sections 4 and 5. The header is cbindgen's output of the new docs. |
||
|
|
927f2c41ec |
🆕 Record an exported surface as the replay format's surface records
A recording held an exported surface's planes as two textures of the device's own (newTextureWithDescriptor: of a descriptor marked outside the guest's indices), and nothing of the surface itself: not its make, its exports or the pictures the host's video landed in it. A player could not make the surface, hand it to a stand-in for the other API, or replay its hand-overs, and the planes read as never written. The rt platform now records metal2vulkan's exported-surface family (its replay format's "Surfaces and the guest's RAM", as of metal2vulkan abf7b8f873): - m2v.newExportedSurface on the device, with the handle, the multiples and the planes, its result the surface; - m2v.surfacePlane on the surface for each plane's texture; - m2v.exportSurface at each export; - m2v.surfaceWritesDone at each picture landed, with no bytes, as the stream holds none of the picture's; - the surface's release, as its memory's last reference goes. A surface over Direct3D 11 textures keeps the old form. The recorder's FIXES list names the change (exported-surfaces), and docs/api.md lists the records. Nothing changes for a process that does not record. Replaying the records needs metal2vulkan's player at abf7b8f873 or later, which the pin does not hold yet. on_vulkan_rt_an_exported_surface_is_recorded_as_the_replay_format_s checks the records and their order on the GPU. The test that held the old form, on_vulkan_an_rt_surface_s_planes_are_named_where_they_are_used, now checks each plane's m2v.surfacePlane on the surface the make named. |
||
|
|
7fafb7f9fb |
🆕 Stamp the build's commit into reims-ctl and the library
A report could not say which builds it came from: reims-ctl's version was the package's, and the library named its commit only where `cargo xtask dist` set RVG_BUILD_COMMIT, so a QEMU or reims-ctl from another build than the install's went unseen. Each is now stamped at build time by a build script of its own, with no new dependency: `git rev-parse HEAD`, `-dirty` where a tracked file of the tree differs from it (Cargo.lock aside, which a build rewrites), and `unknown` outside a checkout, never failing the build. The library's is reims-vgpu-c's, handed to the Vulkan crate at the C API's first call, so every build of it carries it, not only dist's; xtask's RVG_BUILD_COMMIT and the recorder's own read of it go. `reims-ctl --version` shows its stamp. The ask for the counts writes the library's build line, `reims-vgpu: build <commit> on metal2vulkan <pin>`, and system.txt's head names reims-ctl's stamp, the running library's as the QEMU log names it, the install record's commit and the metal2vulkan commit, with one plain line where the commits differ. Display only. |
||
|
|
f2be18b911 |
🆕 Write a pacing line at the host's ask for the counts
A report of a slow app has said what degraded, not what held the app back: the guest's own CPU work, the host's GPU, or the library's threads. At the ask for the counts (rvg_write_counts, QEMU's x-write-counts), where the ask before it was 2 to 60 s earlier, the library now writes one line over the span between the two: each display's presents a second with the interval's p50 and p99, the GPU's time per frame (p50, p99) and busy share from the command buffers' GPU start and end times, merged where they overlap, and the CPU of QEMU's vCPU threads, of ours by role (decoder, completion, window, video, the rest by name) and of the rest of the process. The state is fixed: a ring of 4096 shows per display and a few atomics for the GPU, nothing allocated per frame. Thread times are read only at the ask: /proc/self/task on Linux (with a table of the names Linux cuts at 15 bytes), task_threads and thread_info on macOS, a ToolHelp snapshot and GetThreadTimes on Windows. rt gives no GPU times for its own command buffers (uploads, fills, staging copies), for one that ended in an error, nor for the host's video codecs; the line counts the ones without times. reims-ctl report asks twice, 10 s apart, before vulkaninfo loads the GPU, and its help, conventions.md and api.md say how to read the three verdicts beside the guest's `top -o cpu -l 2`. A diagnostic: nothing decides on it, the guest sees nothing new, and the C API gains no call, so QEMU's side is unchanged. |
||
|
|
37af90950e |
🐛 Leave the window system to SDL where the GPU presents to Wayland
|
||
|
|
09f166332e |
🐛 Open the window through a window system its GPU presents to
A laptop's NVIDIA GPU beside the Intel GPU KWin composites on presented to X11 and not to Wayland (a user's report: its Wayland surface was not presented to, its XCB and Xlib surfaces were). SDL opened the window through Wayland, the swapchain was refused, and the window never appeared: Wayland maps a window only once a frame is presented to it, so its task bar entry alone showed. Before SDL's video starts, the GPU of the first window's sink is now asked, with no window, whether it presents to the session's Wayland compositor, and where it does not, to its X server: Vulkan's per-platform presentation-support questions, over connections the window crate makes and closes. The windows open through Wayland where it presents to the compositor, else through X11 (XWayland under a Wayland compositor) where it presents to the X server, and where it presents to neither, no window opens and the guest runs headless. A named Wayland also holds where the compositor has no fifo-v1 and SDL would take XWayland on its own. Each window also tells QEMU's stderr once whether it shows: "reims-vgpu: window shown: display N" at its first frame presented, or "reims-vgpu: no window: <why>" where it stays empty, or where no window opens because the GPU presents to neither window system. reims-ctl reads them to say whether a VM's window is open. The sink is attached before the host's screens are asked for, so the first window's attach starts the UI thread with its GPU. |
||
|
|
df67517752 |
🐛 Refuse a pool of host memory at the start where the GPU refuses it
PR 178's pool blocks of host memory were found refused only at the guest's
first take, logged once by a flag of its own and counted nowhere, and the
device's start said nothing of which form its pool's blocks took.
For the host: where pool_host_memory is 1 and the device has a pool, its
start imports one 64 KiB block of host memory and gives it back. Where the
GPU refuses it (NVIDIA's driver, by rt's rule for dma-bufs, or a Linux host
without udmabuf), rvg_graphics_device_create answers RVG_ERR_HOST_RESOURCES
with one warning, and never maps the GPU's own memory, which that
hypervisor refuses. The pool's start line now ends with its blocks' form
("its blocks are the GPU's own memory", or host memory the GPU imports, or
the process's own memory), so a log shows which form ran. A take refused
later is counted (pool-host-memory-refused), the first of each cause logged
by the logger's kind. The field's doc in the header states it as the host's
fact, found by asking the hypervisor alone; its name stays, as QEMU's fork
sets it by that name. A take past one dma-buf's bytes (udmabuf's
size_limit_mb, 64 MiB stock) needs rt's dma-buf granule, now said, and
tested with a take of 64 MiB and 64 KiB: several dma-bufs at the stock
limit, one where the host raised it.
Nothing changes where pool_host_memory is 0, every host but QEMU under
Linux's KVM on arm64: the_pool_s_blocks_are_the_gpu_s_memory_unless_the_
host_s_hypervisor_maps_none holds the default. The rt tests print and
return where the GPU imports no host memory, where the unwrap panicked.
docs/api.md's INVALID_ARGUMENT row names the 1 on macOS and Windows, which
make no such blocks, and its HOST_RESOURCES row the GPU's refusal.
platform/rt.rs keeps its OS cfgs to two whole items.
|
||
|
|
d0547561a0 |
🐛 Make the Shared pool host memory where KVM maps no cached GPU memory
On an M1 Pro under Fedora Asahi Remix 45, once Honeykrisp met the runtime's floor, QEMU exited as the guest's driver took the Shared pool: Linux's KVM on arm64 takes a cacheable VM_PFNMAP mapping as a memory slot only where the CPU has stage-2 forced write-back and CACHE_DIC, every host mapping of a Honeykrisp allocation is VM_PFNMAP, and KVM_SET_USER_MEMORY_REGION2 refused the pool's first piece with EINVAL (#174). For the host: RvgGraphicsDeviceConfig's sixth version adds pool_host_memory, 0 or 1, any other value refused. A host built before it reads as 0 and keeps the pool of the GPU's own memory. QEMU sets it under KVM on an arm64 host whose VM does not answer KVM_CAP_ARM_CACHEABLE_PFNMAP_SUPPORTED (vendor/qemu c9f8890b). Each of the pool's blocks is then a memfd of the library's (RegionMemory, as the device's region is), which rt imports as a dma-buf (rt_platform::import_host_block, the no-copy buffers' dma-buf path) and the device knows as it knows rt's blocks (pool::HostMemoryBlocks, the platform's host_memory_block_source); pool_add hands QEMU the memfd's mapping, which KVM maps cached, as it maps the guest's RAM. Host, guest and GPU then reach one cached memory. A platform that makes no such blocks (macOS, Windows) refuses the 1, where its pool's blocks would be the GPU's; the guest's Private blocks keep the GPU's memory everywhere. An uncached memory type of the GPU's would also pass KVM's check, and needs no import, but the guest would reach the pages cached while the host zeroes each take through an uncached mapping, a pair of views the architecture does not keep coherent. The imports' cost on this kernel was measured first: a program that imported 16 and 32 udmabufs of 16 MiB into Honeykrisp, a GPU fill into each, then freed them and the device left Shmem as it was (7.3.4-401.asahi, Mesa 26.2.7), where kernel 6.19 had been reported keeping such imports. Tests: the C API's field (0 and a size before the field the GPU's memory, 2 refused, 1 taken on Linux and refused elsewhere); HostMemoryBlocks on the M1 Pro (Honeykrisp): a Shared block is imported host memory, zeros, at a GPU address, known from take to release, Private refused. The C harness gives the field 0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit a8ad00aca33fb895bb4dd5f11cabef677851b32b; vendor/qemu is kept at the fork's tip here, and moves to the fork's integrated commit, which carries the fork's PR 19, in a later commit.) |
||
|
|
0df657bde1 |
🆕 Scroll x86-64 guests sideways through their own mouse
An x86-64 guest scrolled only up and down: QEMU's usb-tablet, which took the host window's scrolling, has no sideways wheel. The x86-64 kext's mouse now has an AC Pan beside its wheel, which IOHIDEventDriver makes the scroll event's sideways axis, and once the mouse is up the kext names it to the host with the new SCROLL_DEVICES command. From then on the window sends its scrolling to the guest as SCROLL events instead of QEMU's wheel buttons: a wheel's notches as they are, and a touchpad's distance as one notch per 10 points, the points a line is on SDL (FINE_PER_NOTCH), the rest carried to the next event and counted afresh where the scrolling turns back. The kext posts the notches as the mouse's wheel and pan reports, at most 8 x 127 a SCROLL. For the guest: its scrolling comes from "Reims vGPU Mouse", sideways included, with macOS's own wheel acceleration, as the tablet's did. For the host: the window's wheel and scroll callbacks are not called for scrolling the guest's devices take. An arm64 guest names no devices, so its scrolling goes to the vmapple tablet as before; the arm64e kext's binary is unchanged. The wire also carries a SCROLL's distance in 1/256 points, for a guest that names a precise scroller (RGFX_SCROLL_DEVICE_PRECISE), which no kext names yet. Measured in windowed walks with a wheel mouse over the window, on macOS 26.7.2 (potluck job m3-max-76095) and 11.7.11 (m3-max-76100): notches up, down, right and left reach the guest three for three on their axes, in the tablet's directions; eight quarter-notch parts make two; a burst of ten at 16 ms ramps from 1 to 91 points, as the tablet's did; QEMU's tablet takes no wheel button. |
||
|
|
d844ae9f9f |
🎨 Say once why a device has no Shared pool
A device with no Shared pool offers the guest no POOL, and so no SURFACE_CACHE_EVERY and no MANAGED_AT_COPY. Only one of the ways to lose the pool logged a line: a GPU that answers no memory heap. A host that gave the device no guest addresses for one, which QEMU does on a machine with no room for it, and a Windows host with an arm64 guest logged nothing, so a run's log did not show why the guest went without the pool. The device now writes one warning at its start in each of those cases, saying which of them it is and what the device does not offer. The no-heap warning is folded into it. The tests pin the line of a device given no addresses, and that a device with a pool writes none. |
||
|
|
ce6fa476d4 |
🆕 Write the degradation counts when a running VM's report asks
The library wrote its counts line only at a device's reset and at the process's exit, so a reims-ctl report made while the VM ran had none of it in its qemu.log. A host now asks for them with rvg_write_counts (the Rust API's GraphicsDevice::write_counts), which writes the line before it returns, where it changed since it was last written. QEMU's reims-graphics-pci calls it when its new x-write-counts property is set to true over QMP (vendor/qemu b057a987), and reims-ctl report sets it on a running VM before it zips the logs, with a line in state.txt saying whether the library wrote them. A trigger rather than a timer: a timer would touch only the library, but write a line a minute into every log and still be up to a minute old at the report; QEMU forwards no signal the library could take, and Windows has none. For the host: a new C API function and QOM property; QEMU's log gets the counts line at each ask. api.md, conventions.md, qemu.md and the report's help say so. |
||
|
|
c897a0f78f |
⬆️ Build on metal2vulkan development efd7dbcd4d
Moves the runtime to metal2vulkan development efd7dbcd4d, which holds development db3a88526b and the Shared memory coherence form the owner chose (A-narrow, Telegram 2963). SEMANTICS moves from 2302 to 2304 and ARTIFACT from 596 to 597 (RUNTIME stays 2550), so every host translates its guests' shaders again once, and rt's stored artifacts and pipeline caches re-key. What changes for the guest at this pin: - rt's floor takes a device whose host-cached memory types are none of them host-coherent. Shared storage lives in the first host-visible, host-cached type a buffer can use, a host-coherent one first (2c4680acea, 31ca7f6779). Such a device is one where Mesa's Intel driver over i915 runs a GPU with no cache it shares with the CPU, as on a user's Intel Arc (Meteor Lake) laptop, which rt refused with rt-refused-below-floor (Missing::MemoryType). It is now made. On it, rt flushes the Shared memory a submission's command buffers reach before it submits them. Before the host can see a command buffer's progress (its status, a wait, its completed handlers, a shared event's value), rt flushes then invalidates what the command buffer may write. It also flushes around replaceRegion, getBytes and the named bytes of an upload. A range a command buffer reaches only through an address or a residency set, with no binding or declaration naming it, is neither flushed nor invalidated there (rt's known gap). The commit after this one forwards a render encoder's useHeaps, so a used heap's memory is among what rt flushes. On a device with a host-coherent host-cached type, every GPU our tests and boots run on, rt takes the same type as before, keeps no ranges and makes neither call. metal2vulkan measured what that costs there (efd7dbcd4d's message): +43.1 user-space instructions per command buffer on a Radeon RX 7900 XTX's burst_2000 (job 74045), and 1.0062 on burst_2000 and 1.0115 on frame_5cb on a Radeon 780M (job 74046). - A metallib of format 2.2, whose function entries carry no MDSZ and which has no extended header (an older toolchain's precompiled library, such as the one a game launcher's SDL2 renderer makes), is read (4bcb58dbb1, SEMANTICS 2303). rt refused it as Container(MissingTag), and every pipeline made from it was dropped. Its functions, AIR 1.8 with the pre-LLVM-4 metadata and typed-pointer records (METADATA_STRING_OLD, METADATA_KIND in the METADATA block, METADATA_OLD_NODE, INBOUNDS_GEP_OLD, LOAD and CALL without their types), now decode as LLVM 23.1.2's reader reads them (31b3470a3e, a68c6633c2, SEMANTICS 2304), where each stopped at its first such record. Lane steamfix's boot of the launcher's disk on these fixes (job m3-max-73971, um870's RTX 3090) made all 61 of its libraries, the SDL2 renderer's among them, and all 25 render pipelines made from its functions, with rt-refused-translation 0. A METADATA_KIND record with fewer than 2 operands, or with a kind id stated twice, is now malformed, as it is for LLVM's reader. - A compressed copy of whole blocks that ends past a level's edge, inside the level's last block (the one 4 x 4 block of a level of 4 x 2 texels), copies that block (9ddd0be2a4). That covers texture to texture, buffer to texture, texture to buffer, replaceRegion and getBytes, and matches what Metal does (measured on an M3 Max by metal2vulkan's probe compressed_copies_of_small_levels). rt refused those copies as Refusal::TextureRegion (rt-refused-ours), encoding nothing. A copy between two textures whose regions stop at different edges is now Gap::TextureCopy (rt-refused-gap), still encoding nothing. A size past the rounded edge stays refused as TextureRegion. - The rest of the range is metal2vulkan's validation, probes, conformance cases, censuses and docs. Its deadbind deletions (the indirect-command plumbing only its deleted runtime drove, and the Y'CbCr planes chain nothing has made since its producer went) remove 51 records from api_signatures.tsv, and this tree names none of them. For the host: rt's Metrics gain five fields, the Shared memory flushes and invalidates, their bytes and the calls that failed, all 0 on a host-coherent type. The counts line carries them from the commit after next. No other API this tree uses changed, no rt kind of refusal, gap or note is new, and no dependency changed: the lock, in its stripped form, is unchanged. Our docs that named the Shared type's flags follow (gpu/identity.rs, pool.rs, docs/api.md), and rt_platform/copied.rs says which copies rt flushes on a type that is not host-coherent. Checks the move cannot reach: QEMU, the option ROM, the guest's kexts and bundle and reims-ctl build nothing of the runtime. The video crate and its arms call nothing the move changes, so their checks do not run. The table's row owes no boot: the move changes no death the platform ends the process on, and on every GPU we run, rt's floor answers as before and takes the same Shared type, with no device info, GPU family or feature query changed. Only a device with no host-coherent host-cached type sees the floor change, and no lab GPU is one. The Windows tests on the mini run after the merge. |
||
|
|
df1eeb4e8c |
🆕 Let a VM's windows never capture input
The owner asked for a VM whose window does not grab the mouse (owner 2893, 2895, 2900): capture stays the default, and a VM's settings can turn it off. With REIMS_VGPU_WINDOW_CAPTURE=0, which reims-ctl sets for such a VM, no window captures, on macOS (AppKit's window and SDL3's) or on Linux and Windows (SDL3's): a click into the image is sent to the guest but captures nothing, so the window never takes the host's system keys, never grabs the keyboard, never holds or locks the pointer and never holds its own size. The pointer reaches the guest over the image alone, and outside it only in a drag that began there, which ends in the guest. Keys go to the guest while the window has the keyboard; on macOS that takes in ⌘ shortcuts, as while captured, since nothing else could give the guest one, and the window's menu stays in the pointer's reach. A game gets the absolute pointer alone, which stops at the image's edge, since the guest's mouse is driven only while captured. The title ends " — input capture off". Unset, or any other value, capture is on as before. features.md gets the register's "Capture off" entry and the switch, and the Capture entries say where it applies; docs/api.md lists the variable. |
||
|
|
d7fec652de |
🐛 Let a decoder's state go off rt's completion thread at a loss
At a device's loss the table walk (fault_walk) upgrades each decoder's Weak<Shared> on the thread that read the first failed command buffer, rt's completion thread among them. Where the decoder went during the walk, the walk's hold was the last one, and the decoder's objects were dropped there: a drop that waited for a command buffer's completion would hang the thread that completes it. TableWalk::each now hands a last hold to a thread of its own, reims-vgpu.graphics-tables-let-go, through the platform's threads, so a refused spawn ends the process as theirs do. The test drops the decoder in the walk's callback and checks that its state went on that thread, and that a walk of a decoder that outlives it spawns nothing. The host sees only a new library thread name; nothing the guest sees changes. |
||
|
|
b955213d27 |
📝 Keep the guest's RAM mapped until the process exits [ci skip]
The device's imports of the guest's pages into the host GPU can outlive its release: rt frees them on a thread of its own once no GPU work uses them, and the release of the last device keeps the GPU device for the process when its wait runs out. So the memory map's host memory stays mapped, and is not unmapped, mapped anew or discarded, until the process exits (the header's RvgMemoryRange and memory_map, docs/api.md, and reims-vgpu's MemoryMap). QEMU's side does not change: the machine holds its RAM backend until QEMU exits (hw/core/machine.c:1216), and the VMs reims-ctl makes discard no guest RAM: no balloon, free page reporting, virtio-mem or memory hot-unplug, and their RAM is a shared mapping, which KSM does not merge. |
||
|
|
42d93ec745 |
🎨 Rewrap the lines the runtime's rename ran past 100 columns
The rename of metal2vulkan-rt to metal2vulkan-runtime lengthened each mention
by five columns, and 43 lines of comments, docs and string literals ran past
the tree's 100 (the C API's two paragraphs were rewrapped in
|
||
|
|
11055c78d5 |
⬆️ Build on metal2vulkan development 82e7c39216
Moves both metal2vulkan revs from d83fb05624 to 82e7c39216, 65 commits on its
development branch, named green by its checks (m3-max-59311). The runtime's
crate takes its published name there (9a1c8fe6dc): metal2vulkan-rt 0.0.0 is
now metal2vulkan-runtime 0.2.0, its library metal2vulkan_runtime. The
dependency key, the crate's paths (each still `as rt`), the lock's entry and
the docs, comments, log lines and scripts that named the crate follow it. The
rename changes no API.
On rt:
- A command buffer waiting for a shared event's value whose signal is
submitted is Scheduled as it is submitted (4730af16e7): its scheduled
handlers run on the submit thread then, and its queue's later command
buffers are no longer held behind it. A wait for a value that neither the
host set nor a submitted signal promises stays held, Committed, as before
(counted in Metrics::event_holds, fb4b77048c). GPU order and completion are
unchanged. The docs that said rt's completion thread runs a held command
buffer's scheduled handlers now say its submit thread does.
- Copies over buffers are tracked by the memory a buffer lies in, never its
id (7e38a29b69): a texture over one buffer sees a draw through a texture
over another buffer over the same bytes, in one command buffer and across
a held group.
- A kernel that reads buffers through an argument buffer's pointer members,
or through a gpuAddress the CPU wrote into a constant buffer, now makes
(3cdca62567, c0403a1c98); the translator refused it (IdentityDomains).
- A refused kernel input names its kind (98895eb6d2, 1c26e1dc54):
Gap::KernelInput { kind }, so the refusal's text, in the log and in the
NSError's description, carries the kind. It is still counted as
KernelInput.
- Memory goes back sooner. The release of a texture or block that an unsent
upload holds sends the upload at once (0277c68696). A texture longer than
a 16 MiB block has its block to itself and gives it back at its release
(61949e8ba4). Every free of device memory on a normal path is made by the
block-maker thread, and counted against the submits it meets (4c808ffa6d,
09735ad792). New gauges tell texture blocks apart from the consumer's
Private takes (b3f6c859dd).
- ComputePipelineState::dispatch_variant, the key of the VkPipeline a dispatch
runs (82e7c39216), which this tree does not call yet.
- The translator's old path is deleted (0b94d919d9 to 16c831165d): its
profile comes from Vulkan queries alone, with no policy switches and no
driver-fact tables. SEMANTICS_VERSION goes from 2201 to 2203 and
RUNTIME_VERSION from 2540 to 2541, so rt's shader and pipeline caches miss
once: the first run on each host translates its pipelines again.
The rest is metal2vulkan's own: its conformance declarations and ledger, its
generated documents and the tests of each change. The NSError texts the guest
receives, and the comments of the wire header and the guest's sources that the
prebuilt kext sets and the option ROM record, keep the old name here; commits
of their own change them.
|
||
|
|
8c40add9ac |
📝 Say what the tree runs on now the old platform is gone [ci skip]
The cutdel branch deletes VulkanPlatform, metal2vulkan-runtime and the rt feature, so RtPlatform over metal2vulkan-rt is the only platform. These docs still described the old one: its answer policies, its exact switches, MoltenVK on the Mac, its in-place guest memory, its records cache, its device recovery and its Metal-answer tests. - conventions.md: the guest-memory-in-place rule is replaced by the rt rule (rt allocates GPU memory, the device maps its blocks into the guest, textures sync at the guest's events, and there is one VkDevice per process). The degradation codes are now rt-unbuilt and rt-refused, and the deleted codes are dropped. - accuracy-ledger.md: restated for rt, which has no switches. It keeps the device's own arithmetic notes (tagged as measured before rt), the 19 unbuilt pieces and rt's refusal kinds, and device loss. - api.md, README.md: REIMS_VGPU_EXACT, _CENSUS_DIR and _TRACE_DEGRADE are gone, and STRICT now covers running out of memory only. The let-go and the quiesce describe one platform. - architecture.md, development.md, testing.md, qemu.md: KosmicKrisp in place of MoltenVK; RtPlatform, rt_window and RtBlocks in place of VulkanPlatform, the old window sink and HostBlocks; no Metal-answer comparisons and no opt-in GPU-fault tests. - lessons.md: the four lessons about deleted code only (the Metal comparison after MoltenVK, the runtime's shadows, device recovery and the in-place check) are dropped. The lessons that still bind mark their deleted names. - video/vaapi.md, graphics-kext/design.md: the GPU plane copy and the compositor mirror are marked as gone. - AGENTS.md: only the Vulkan platform's "Where things are" row changes. |
||
|
|
3a550ab291 |
🐎 Let go of released device caches off the surface worker
A released block's device cache was dropped on the surface worker under its block's key, and so were the views and the SURFACE_PAGES and BUFFER_OVER_PAGES jobs, on the worker's four threads. A video session's caches go together at its end: on Windows each is a Direct3D 11 target pair whose drop flushes both immediate contexts under the plane draws' lock, 6 ms at the median and up to 100 ms under that contention. On the UHD 630 the held pass's 240 pairs kept all four threads busy, and the next session's first SURFACE_PAGES, taken 15-19 ms after its open and done in 0.02 ms, waited 512-586 ms for a thread to post its answer; the guest's first copy took 516-600 ms. The caches now go on a worker of their own, reims-vgpu.graphics-let-go-<i>, each block's in its order: at a BLOCK_RELEASE, and once a block is named again without a cache, whose drop ran inline on its ring-0 lane before. Their drops answer nothing and no job waits for them, so a pages job no longer waits behind them. The Linux arms' caches, VA-API's dma-buf imports and NVDEC's, go the same way through the same let-go. A view's drop stays on the surface worker under its block's key, as its mapping may go back to the idle pool the block's next SURFACE_PAGES takes. |
||
|
|
7c74421e0e |
🆕 Make the rt platform the library's default
The owner ordered the cutover: the library's platform is RtPlatform, over metal2vulkan-rt, from this commit on. The rt feature of reims-vgpu-vulkan, reims-vgpu and reims-vgpu-c is now on by default, so `cargo xtask dist`, `make`, the installers' builds and QEMU's link all make every handle on RtPlatform. Every test set that builds those crates with their default features now runs rt's tests where it ran the old platform's. For the guest everything the device answers and draws now comes from rt: pipelines through rt's translator, memory from rt's pool, surfaces and imports through rt's paths, on the host's Vulkan driver on Linux and Windows and on Mesa's KosmicKrisp on a Mac. The old platform, VulkanPlatform over metal2vulkan-runtime, still builds without the feature until its code is deleted, which comes next. Anything wrong on rt is fixed forward. |
||
|
|
2e40e0b52c |
🆕 Record refused pipelines' constants and descriptor fields
A refused pipeline's AIR alone does not reproduce its refusal when the guest's call adds what refuses it: a kernel that compiles with default function constants can be refused for the values or descriptor fields the guest passed. Under the same off-by-default switch, REIMS_VGPU_REFUSED_AIR_DIR, each refused compute or render state now also writes a record into records.txt next to refused.txt, once per distinct record. The record holds the creator and the refusal; for each stage, its function, whether it was made specialized, each function-constant value with its index, declared name, type and bytes, and each declared constant left undefined; the same for each linked function; and each field of the descriptor rt was given. The records are the guest's data: they are written only to that directory on the host, never to stderr or the log. The rt-diag refused-air line now also counts the records. |
||
|
|
bb34b2e0dd |
🆕 Count rt's fetched-attachment draws, refusals and border samplers
The arm64 macOS 26 boot on rt refused 5685 draws, the first of them as reading a colour attachment through its texture (FetchedAttachment), and nothing said which attachments those were: rt refuses one that is no 2D texture, renders another level or slice, has no index, shares its image with another target, or that the device reads no attachment through. The boot diagnostics now count each such draw by each colour target's class (how its texture was made, type, samples, level and slice, index, whether its image's usage reads and writes, its usages, a shared image), with a first line per pipeline state, as they do the attachment reads. They also count rt's refusals of Metal's and its limits by variant, where the counts line has one rt-refused-metal and one rt-refused-limit, and the sampler states made, with those that clamp to their border colour by the colour. And a diagnostic switch, off by default: REIMS_VGPU_REFUSED_AIR_DIR keeps the metallib of each function of a pipeline state the translator refused, once per library, with a line per refusal, in air-<pid> in the directory it names, so the refusal can be read on the host that met it. It is the guest's code: it stays on that host, and nothing commits or copies it. |
||
|
|
359ac7817e |
🐎 Complete a decode alone into caches at its decode
A command buffer that holds only a video decode whose output lies in device caches, where the VA-API arm copies the picture into the caches by its video processing on the GPU, now posts its CB_COMPLETE as the session says the decode is done and the copy is issued, instead of at its platform end after the copy. The guest's decoder hands the picture on while the copy runs: the start of a 4K stream decodes one picture at a time into new surfaces, and each picture's chain waited for its copy. What changed for the guest: - such a CB_COMPLETE comes before the copy into the output's caches ends, in its queue's order of records (a queue's turns of completion posts), and carries GPU times of 0; - the guest's writer slots, which it empties at the CB_COMPLETE, then name the decode no more, so the host keeps each such decode by its blocks until its platform end: a later command buffer of another queue that uses the output waits for that end, on the GPU, or on the CPU for a video op; a present waits for it as for a writer named; a lock's download waits on the end value as before. Counted as buffers and presents held; - the buffer's later work, its surface timeline, its caches' copy into the pages, its context's drain and its place among its queue's buffers in flight all stay at its platform end, so a reset, a close and a quiesce see the decode in flight as before. What changed for the host: raise_interrupt may now be called on a video session's picture landing thread, reims-vgpu.graphics-video-land, inside the landing's video processing run (reims_vgpu.h, docs/api.md section 5). QEMU's reims-graphics-pci raises its interrupt from any thread, and is unchanged. |
||
|
|
59e376bd05 |
🐛 Answer false to the quiesce once the platform made a GPU device
On the Vulkan platform (metal2vulkan's old runtime) rvg_quiesce_for_exit answered true once the release's let-go took the GPU devices, so QEMU called exit(). The let-go does not end the runtime's work: a pipeline making of the warm pass can stay in the driver past the device's last drop, and the runtime's exit hook, registered as the device was made, then waits for it and on Linux ends the process at once with _exit. QEMU's exit notifiers never ran: on an RTX 2080 (620.70.06) a quit 24 s into a boot, its let-go 315 ms after the quit, ended 9.6 s after it with QEMU's pidfile left (job m3-max-53092). Now the quiesce answers false once the platform asked the runtime for a device in the process, kept or let go of since: each of the platform's makes (the default device, a window's device, MTLCopyAllDevices's, the device choice's timed devices) and each adoption mark it (let_go::asked_the_runtime_for_devices). What changes for the host: on the Vulkan platform, a quit after the release that let go of the device now gets false, and QEMU runs its own exit work (its exit notifiers, the terminal's restore, the streams' flush) and ends with _exit and the cleanup's status, as it did with a device kept. The runtime's exit hook and the driver's exit handlers no longer run then, and the library writes its degradation counts in the quiesce. A process that never opened a GPU device still answers true. The platform over metal2vulkan-rt is unchanged. The let-go's child-process test now expects false after the let-go, then _exit with status 0; a new one holds true and exit() for a process that asked for no device. The C harness ends as QEMU does on the answer, and its test expects false on the Vulkan platform and true over metal2vulkan-rt. The API docs, the header, docs/api.md and docs/lessons.md say the same. |
||
|
|
bbeb3d39b3 |
🐎 Land staged downloads on threads of the caches' own
On the rt platform every cache's copies are staged, and a download's command buffer ended in a completed handler that copied the staging buffer into the pages on the host's CPU. The platform sees every queue's completions on one thread, so a large surface's copy held all of them: 144 MiB at 3 GB/s is 48 ms, and every completion of every queue behind it waited that long. The handler now hands the copy into the pages, the copy's landing and the answers that wait for it to a worker of the caches' own (reims-vgpu.graphics-into-pages-<i>), keyed by the block, so a block's copies land in the order their command buffers completed, and returns. Only what waits for the pages waits for that thread: the download's or release's answer and the threads that wait for the copy to land. For the host: raise_interrupt is now also called on those threads, which the header, docs/api.md and the raise list now name. QEMU's callback already takes any of the library's threads, so its side needs no change. The tests that check a staged download's answer now wait for the worker, and a new test shows another queue's completion going through while the copy waits. |
||
|
|
96dbe24887 |
🐛 Answer false to the quiesce while a Vulkan GPU device lives
The Vulkan platform's quiesce ahead of the exit (rvg_quiesce_for_exit) did nothing and answered true, so a quit with a GPU device kept to the exit went on through exit(). On Linux metal2vulkan's exit hook, which runs before QEMU's exit notifiers, waits 2 s for the runtime's work in progress and then ends the process with _exit itself: with a device kept to a paused VM's quit, 5 of 9 quits on an RTX 3090 and 5 of 9 on an RTX 2080 left QEMU's pidfile behind, and usb-host's return of host devices to their drivers is skipped the same way. Now it closes the exit gate ahead of the exit, waits for the library's steps in progress within its bound, and answers false while the platform keeps a GPU device (let_go::gpus_kept), as the platform over metal2vulkan-rt does. What changes for the host, where QEMU's quit finds a device kept (a paused VM, a shutdown action that pauses, a display read that kept it): QEMU's exit work runs (its exit notifiers, the terminal's restore, the streams' flush), then _exit with the cleanup's status. metal2vulkan's exit hook and the driver's exit handlers no longer run then, and the degradation counts are written in the quiesce rather than by the exit gate's handler. A quit whose release let go of the device answers true and exits as before. New tests hold both answers in a child process: false with a device kept, true once the let-go took it, then exit() with status 0. The C tests that quiesce with nothing on a GPU still answer true. The API docs, the header and docs/api.md say the same for both platforms; docs/lessons.md has the trap. |
||
|
|
c997d16fe0 |
🐛 End an exit that skips QEMU's cleanup with _exit and no quiesce
metal2vulkan-rt supports no quiesce inside an exit handler. QEMU's exit handler for an exit() that skips its cleanup (a later device's refused realize, a failed incoming migration) called rvg_quiesce_for_exit there and let the exit go on where it answered true, though no release had let go of the GPU device on that path. vendor/qemu ba447463 makes the handler call no quiesce: it runs QEMU's own exit work and ends with _exit(EXIT_FAILURE), and after the cleanup's true answer it does nothing. For the host: rvg_quiesce_for_exit's doc says it is not for an exit handler, and on that path QEMU now ends with _exit, the library writing no degradation counts. QEMU's new trace event reims_graphics_end names each end through _exit. |
||
|
|
df1172fa25 |
🐛 Answer false to the exit's quiesce while a GPU device lives
metal2vulkan-rt's exit contract (its README, "Quiesce and exit", at d48664f6d2) supports exit() with a device live on no device: a process that still holds one quiesces it and ends with _exit, whatever the quiesce answered. On an RTX 3090 (620.70.06), 3 of 9 power-offs that called exit() after the quiesce stopped every rt thread in time ended in SIGSEGV in the driver's exit handler. What changes for the host: rvg_quiesce_for_exit now answers whether the host may call exit(). On the rt platform it still parks the library's threads and quiesces a device that lives, but answers false wherever one lives: a device kept to the exit (a quit of a stopped or shutdown-paused VM, a display read that kept it) or one a let-go could not tear down. It answers true where the release of the last graphics device let go of it. On false the library writes its degradation counts then, since the host's _exit runs no exit handler. The warning on false now comes from the platform and only where a wait outlasted its bound. The Vulkan platform still answers true. QEMU (vendor/qemu e8f0178b): on false it runs its exit notifiers, the terminal's restore and the flush of stdio, then ends with _exit. Tests: the rt child test with the device live now expects false, with rt's own quiesce answering true, and ends with _exit. |
||
|
|
c000ca0981 |
🐛 Let go of rt's device at the last release
The rt platform kept the process's one rt device in a OnceLock until the
exit. On an RTX 3090 (NVIDIA 620.70.06), 3 of 9 power-offs of an x86-64 macOS
guest then ended in SIGSEGV inside exit(): the driver's exit handler waited
on a lock while a thread of the driver's own read near a null pointer, with
the VkDevice live and every rt thread already stopped by the quiesce.
metal2vulkan-rt's contract asks the consumer to drop the device's last
handle before the process exits.
What changes for the host: the release of the last graphics device
(rvg_graphics_device_release) now lets go of rt's device, as it does of the
Vulkan platform's. Once nothing beyond the platform holds it (at most 5 s),
rt's quiesce runs with what is left of the bound, then the drop of the last
handle tears the device down on the releasing thread, and the let-go waits
for rt's gauges of it to read zero. A device whose quiesce answered false is
kept to the exit. A let-go that waits out its bound logs a warning and keeps
the device, as on the Vulkan platform. A graphics device created after it
runs on a new rt device.
Tests: the let-go test runs on the default platform, so on rt too, and the
test that pinned rt keeping its device (
|
||
|
|
f7892bf0e8 |
🆕 Quiesce the library ahead of the process's exit
Where QEMU keeps the reims-graphics device to its exit (a shutdown action that pauses, a quit of a stopped VM, a display read past its 5 s), and on the rt platform even after the release of the last graphics device, rt's submit, completion and block-maker threads can still be in the GPU's driver as the driver's exit handler tears it down: on NVIDIA's driver, SIGSEGV inside that handler. rvg_quiesce_for_exit(timeout_ms) is the host's last call before its exit. It goes to a new method of core's platform, quiesce: on the rt platform it closes the exit gate ahead of the exit, so the library's threads park at their next step, waits for the steps in progress, then runs rt's Device::quiesce, all within the bound; it frees nothing, answers false where a thread may still be in the driver, and a second call gives the first answer at once. The exit gate's hook still runs at the exit and writes the counts. On the Vulkan platform and the testkit it does nothing and answers true, so their exits stay as they were. QEMU calls it at the end of its cleanup, before exit() runs any handler, and from an exit handler registered as the device is made for exits that skip the cleanup; it ends with _exit on a false answer (vendor/qemu 88337859). The C harness and a unit test call it with nothing to stop; an rt GPU test checks the device's handlers ran, a second call, the closed gate and the refusal after it; an exit-gate test checks the wait, its deadline and the counts written at the exit. |
||
|
|
2fe5515d85 |
🆕 Record each acquire of another API's writes into a buffer
metal2vulkan's replay player plays the host video recordings, whose surface caches the hardware writes outside the runtime: VA-API's decode or video processing into a dma-buf cache, NVDEC's copy through CUDA's import of an exportable one. It must refill what lies over such a cache where those writes become visible to the device: the platform's external_write_done, the runtime's acquire. The platform made that call unrecorded, so no stream held the point, and a player had to infer it. external_write_done now records m2v.externalWriteDone on the buffer, with no arguments, as the call returns, as rebindNoCopy and every other hooked call are recorded. The host's video makes the call on the session's landing thread once the picture is in the cache, right before the session's setSignaledValue: that releases the decode's command buffer past its wait, so the record lies after the hardware's writes and before every command that reads them. A refused acquire is recorded as any refusal is. The record is counted by its selector in the stats file, and the recorder_fix "external-write-done" names the change. Nothing changes for the guest or the C API's host. With REIMS_VGPU_RECORD unset the call costs one relaxed load more. |
||
|
|
c6ab041d68 |
🆕 Record a no-copy buffer's escape in the replay stream
metal2vulkan's replay player must stop, typed, where the GPU may reach a no-copy buffer through an address in memory alone. The guest says so with BUFFER_ESCAPED, but the note ended in the decoder: no stream carried it, and only the stats file's counted totals showed it. The decoder's first note for each buffer now also records it, where the process records (REIMS_VGPU_RECORD): an m2v.bufferEscaped call on the buffer's stream id, [kind], the note's RGFX_BUFFER_ESCAPED_* act (0 gpuAddress, 1 argument encoder, 2 resource id, 3 residency set), of the whole buffer. It is queued on the decoder's thread at the note, so it lies after the m2v.write records of each commit made before the note and before those of each commit made after it. A later note, a note for a refused create and a bad reference write none. Each record is counted by its selector in the stats file, and the recorder_fix "buffer-escaped" names the change. Nothing changes for the guest or the C API's host. With REIMS_VGPU_RECORD unset the note costs one more relaxed load (recorder::on). |
||
|
|
5273e0eeb9 |
🆕 Give arm64 guests' device the Shared pool's room past RAM
QEMU gave the library a pool range only on a PC machine, and an arm64 guest's device on vmapple had none. vmapple now answers the room past its RAM, from the end of RAM rounded up to 1 GiB to the end of the guest's physical addresses (the CPU's PARange, at most 40 bits), as read-only machine properties, and reims-graphics-pci gives the library that room where no PC host bridge answers one, reserving nothing where the machine has no fw_cfg. Ambrosia lists RAM alone, so the guest places nothing there; it is told of no piece yet. x86-64 guests' pool is unchanged. |
||
|
|
a39e43e99f |
🐛 Cap the pool's room at the end of the host's physical addresses
QEMU offered the library the pool's room up to three quarters of the guest's physical address space only. A guest may have more physical address bits than its host (QEMU allows it with a warning; the Windows mini's Coffee Lake has 39 against the guest's default 40), and a piece placed past the host's width makes KVM refuse its slot (x86 KVM's memslot check, read from code); WHPX gets the same cap. Under KVM and WHPX the room now ends at the host's width too, read from CPUID 0x80000008: the device file builds for every target, where target/i386's host_cpu_phys_bits is not linked. What changed for the host: where the host's addresses end before three quarters of the guest's, so does the room. Measured with the device realized paused and the 64-bit window pushed so the room starts 4 GiB below the host's end, the range the library took ends there: at 0x1000000000000 under KVM on a 48-bit Ryzen with phys-bits=52 (m3-max-49283), and at 0x8000000000 under WHPX on the mini (m3-max-49316); under TCG it runs past both. On the mini's default q35 machine the room is now 487424 MiB, its 39 bits' end less the window's; the range, the UHD 630's 31 GiB of heaps, is as it was. |
||
|
|
f4692c7179 |
🐛 Take a pool piece out of the guest before its block goes back
The pool gave an empty piece's block back to its source and left the guest's mapping to the source's unmap hook (BlockMappings::unmap), which the source called before it freed the block, on the pool's thread or its own. The metal2vulkan runtime deletes that hook, so the pool keeps the promise itself: it gives a block back only once no thread of the device holds it and the host has said its piece is out of the guest's address space, and its close gives every block back only after every hold has ended. The source may then free any block it gets back at once. HostBlocks loses its mappings field, and Pool::new takes the source itself. What changed for the host: pool_remove comes on the device's pool thread as the pool gives a block back (an empty piece past RELEASE_DELAY), never on the source's thread; and a block the source hands out again is placed and gets a new pool_add, where it used to keep its piece and mapping. QEMU's x-pool-grow boot (8 asks of 256 MiB) now shows 8 adds and 7 removals (m3-max-49284), where it showed 5 removals before (m3-max-49031). The release waits for the device's own holds before it frees the blocks. The guest sees nothing new. The tests that held "a block taken again keeps its piece" now hold that it is mapped anew. New tests hold that a piece goes back only once the host removed it and its hold ended, that one given back before the host's add answered still waits for its remove, that ready blocks past two are freed with no word to the host, and that the release gives a held piece's block back only once the hold ends and asks the host nothing. All ten fail on the code before this commit. QEMU's comment now says pool_remove comes on the pool thread. |
||
|
|
16ad40298e |
🆕 Size the guest's Shared pool's range from all the GPU's heaps
The guest's Shared pool's range of guest physical addresses, which QEMU reserves and gives the firmware as etc/reserved-memory-end, is now the sum of the host GPU's memory heaps, every heap, rounded up to 2 MiB and at most the room the host gives, where it was the heap of the GPU's host-visible, host-coherent and host-cached memory type alone. A heap's size is how the driver accounts for memory, not the most it allocates: on a 780M, RADV puts that type on a 5.52 GiB heap beside an 11.05 GiB device-local one over the same system memory, so the guest's pool stopped at about 5.5 GiB, while the runtime takes Shared blocks until the driver refuses one. A guest on a 780M now gets about 16.6 GiB of pool addresses, on an RTX 3090 about 46 to 47 GiB, on an RX 7900 XTX about 38.6 GiB; on an Iris Xe, with one heap, 23.24 GiB as before. GpuDevice::shared_heap_size becomes memory_heaps_total, which sums the heaps of VkPhysicalDeviceMemoryProperties and needs no buffer to ask which types a buffer can use. A GPU that answers no heap still gives no pool. The library's pool line now also logs the room the host gave, so a boot's log shows whether the room clamps the range. QEMU's code is unchanged: vendor/qemu moves to a commit that rewords its comments. |