a3fb1283e621f9eb97e8bfcb48cafffbfcb771ae
802
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
a3fb1283e6 |
FAST-PATHS: the first clip's allocations stay open, with their cause and why no block is made ahead
(cherry picked from commit 4d2833ae3d662006101e3be98bfba4c7da58603e) |
||
|
|
186d327fe7 |
Memory: kept blocks past their quiet period go within a second at the next creation call; FAST-PATHS records the kept memory
A kept empty block was looked at only when a release came in its own pool, so a pool whose resources stopped coming and going kept its blocks, up to its heap's budget, until its next release. The device's creation calls (keep_room) now also free every pool's kept blocks past KEPT_EMPTY_FOR, at most once every KEPT_SWEEP_EVERY (1 s): the memory is held at most about 11 s past a working set's dip wherever the program still makes resources. docs/FAST-PATHS.md, known gaps: the NVIDIA memory block row, with the bound (an eighth of a heap, at most 2 GiB, 10 s), what it holds per device, why it has no switch (no answer of Metal's changes), and the RTX 5080 measurement of tests::clip_bursts (poolwait-burst, NVIDIA 615.71.09, two runs each): clips 2 and 3 took 41 and 40 allocations and 89 to 102 ms with 2 to 5 commits held 1 ms or more (longest 8.8 to 9.4 ms) before, none and 64 to 71 ms with no commit held (longest 0.39 to 0.67 ms) after; a first clip 44 allocations before, 16 after. Not yet built: the sweep builds and runs next on lavapipe. (cherry picked from commit b31e221ee4cfba1861320e8c674a01ea83614013) |
||
|
|
1c14b4b44a |
Staged gathers take their staging at their host step, not on the calling thread
A gather staged through the CPU (
|
||
|
|
0d65ab5579 |
Staged scatters: a first scatter into guest RAM makes no import or memory on the calling thread
A copy_to_host_ram over a chunk not yet imported used to import on the
encoding thread. With 16 ranges or fewer it imported those ranges alone
(each import about 2.3 ms on NVIDIA, its pages pinned). With more, it
imported the whole chunk or waited for its import. A clip switch's
block release (a device cache scattered to fresh guest pages) paid this
on the guest's command thread.
Such a scatter is now staged through the CPU, on devices whose thread
imports ahead (plans other than Plan::listed), as gathers are since
|
||
|
|
6f702cb76a |
docs/API.md: an exit mid-making, the difference left
What: the accepted differences' "Process exit" names what the exit hook's registrar leaves: a making on the program's own thread, which the exit does not wait for, and destructors the driver's compiler registered in the last 2 ms before the exit (or past the registrar's 16384 registrations), which can run beside the compile, where Metal compiles in another process. Why: the registrar (RUNTIME_VERSION 1899) closed the rest of exit_guard's hole for makings on the runtime's threads; what is still open is a consumer-visible difference, and one such exit (a consumer's making thread left running) ended its process with SIGSEGV inside NVIDIA's SPIR-V compiler on the RTX 5080. How verified: docs only; the figures are exit_guard's MAKING_INTERVAL and MAKING_REGISTRATIONS. (cherry picked from commit 5f1846a295017a2244fde27cdd2ed3db97bdb9cb) |
||
|
|
48cfac5cb3 |
HostRam lists kept: the docs say the lists outlive their copies, with same-host numbers
HOWTO, the runtime README and FAST-PATHS still said a copy's lists were freed with its command buffer and that every copy pays its lists' imports. They now say each list is kept past its copy for the copies of the same pages after it (at most 64 MiB and 16 lists, released once no copy took one for 2 s), and they give the numbers. The numbers come from tests/host_ram_listed_bench.rs on the Radeon 780M of one host (um790, RADV, kernel 7.3.1). The kept tip was run with a timing probe that never lands, then again with the bound sabotaged to (0, 0), which keeps nothing, back to back. Medians are commit to completion, then encode: - A 5 MiB device cache filled again: 0.37 to 0.43 ms and 0.2 to 0.4 ms, against 3.0 to 3.2 ms and 0.7 to 1.0 ms with no list kept. Over an imported chunk it takes 0.37 to 0.40 ms and 0.12 to 0.14 ms. - A surface-shaped tile's download after its fill: 0.53 to 0.60 ms, against 4.0 to 4.2 ms. - A scattered tile's download: 0.46 to 0.50 ms, against 0.98 to 1.04 ms. - A copy that imports pays the lookup through the kept lists: 48 to 63 us for a surface tile, 250 to 290 us for 1,800 scattered runs against 16 lists. - The scroll's 24 visible tiles pass the 64 MiB bound (about nine tiles), so a third to a half of their repeated fills took a kept list. - Residency is the same with and without kept lists: 4028 of 8192 MiB, and 8300 of 16384 MiB. (cherry picked from commit ee030ba7ed497aeb4bf0c92653cc33078e987379) |
||
|
|
7d4d9346df |
HostRam gathers over a chunk the device's thread imports go through the CPU, never importing on the encoding thread
copy_take answered Now for a gather over a chunk not imported yet whenever its ranges, joined where under 2 MiB apart, were at most 16 and none was the whole chunk. The copy then imported those ranges alone on the encoding thread. With runs scattered over a chunk, the joined ranges cover nearly all of it. On the RTX 5080 Laptop GPU a 24 MiB cache of 2,477 runs over five chunks, its runs joined where under 1 MiB apart, pinned 317 MiB in 61 ms (irisperf's first-fill bench), where the CPU copied the same runs in 2.8 ms. The bench's first call took 105 to 107 ms with import waits of 0, so the staged path (RT 1893) never ran: it covered only gathers that would otherwise wait. The consumer's mid-playback fills of new 4K surfaces took 3.4 to 327 ms with one clip and 1.4 to 2.1 s with three. Now, on a plan that is not listed and with the device's thread running, a gather over such a chunk is ThroughCpu however few its ranges. It is staged through the command buffer's arena, filled by the CPU at its batch's host step, and the chunk is asked of the thread. A gather the CPU path cannot take (its bytes possibly written by another use, no staging memory) still takes the imports' path. So do scatters and listed plans, as before. Docs: copy_take, the copy module's first-touch bullet, the staging check, and HOWTO's copy section. Test: host_ram_copy_device::a_first_gather_of_few_ranges_imports_nothing_on_the_encoding_thread. It gathers three pages within 2 MiB in one chunk and one in another, which before this change was an import of the ranges alone. It asserts no run import is live once the gather is encoded, the gather is staged, it waits for no import, and it reads the pages. The negative control is the old match order; it should fail on any device without AliasedImportBlitsUnordered. Not run yet. (cherry picked from commit 3dbab04a5849524c694c74aaea52b776cbef6dd2) |
||
|
|
ecddb49936 |
FAST-PATHS: the NVIDIA pool block gap with its sizes, its frees and making ahead
The RTX 5080's measurement of its own (an exclusive window, 12 blocks a size): vkAllocateMemory of a pool block's memory takes about 0.16 ms a MiB, idle or beside another process's GPU work (medians 5.5, 11.0, 20.4 and 40.6 ms for 32, 64, 128 and 254.7 MiB), vkFreeMemory about 0.035 ms a MiB, and every vkQueueSubmit another thread calls during either returns once it does. Frames every 16.7 ms met a 254.7 MiB making 28.6 to 48.6 ms late on their own thread (23 of 23 over 1 ms), and up to 67.5 ms with the making on another thread, spread over the frame or right after a submission (11 of 23 either way). So no block is made ahead on a thread of the device's own: it would not keep frames from the hold. A smaller block would shorten it in proportion, at the cost of each command buffer's pool capacity, which is the orchestrator's call. Verified: docs only; the numbers are entry poolwait-poolwait-sizes-063031-063031 (7eb0aab5e5's allocation_holds). (cherry picked from commit f3e209f7ea255d79ef6b524bd1dcd176e9792589) |
||
|
|
0d66b9de2b |
with_vk_queue: the closure gets the VkDevice its VkQueue belongs to
`CommandQueue::with_vk_queue` now calls `f(&ash::Device, vk::Queue, u32)`. The device is the serving generation's, read under the queue's lock with the VkQueue. After a recovery the queue lends the new VkDevice's VkQueue. Until now a caller could get the device only from `Device::raw` handles it had cached, and after a recovery those name the lost VkDevice. The consumer's copier did exactly that: it submitted command buffers from a pool made on the lost device to the new device's queue, and the process died inside RADV (a segfault at null+0x50 in libvulkan_radeon.so, right after our "VkDevice was lost and made again" log). No call let it see the change atomically. Every call site in the runtime, its examples and the validation lanes takes the new argument. The runtime README's interop and "A lost device" sections, `Device::raw`'s docs and docs/API.md's device-recovered entry say what the closure gets. api_signatures.tsv is re-blessed (one signature changed). Test: device_recovery::a_lent_queue_names_the_vk_device_it_belongs_to_across_a_recovery. It reads the lent queue's device before and after recover_for_test. The two differ, and the second equals what Device::raw answers after the recovery. The test also asserts the old route is wrong: the raw handle cached before the recovery differs from the lent queue's device after it. That cached handle was the only source of the device under the old signature. (cherry picked from commit b4bf228df9db98a451c997f350c6014b027f7e31) |
||
|
|
97ba27de2d |
Regenerate docs/REFUSALS.md for the version-1 symbol table's refusal site
The module-level symbol table reader (bitcode/module.rs, Names::read) refuses a summary-index entry (VST_COMBINED_ENTRY) as Unsupported(BitcodeRecord), a new construction site of that variant. Generated with python3 scripts/refusal-surface/refusal_surface.py. (cherry picked from commit b500dc8717a4dd60f84eb775fa0a70446db44cd6) |
||
|
|
bfcd71e5d6 |
Record the short last row's shadow among the known gaps
A texture over host pages whose buffer ends inside its last row's pitch is a shadow (Refused(Placement)): a linear image's last row takes the whole pitch, so the image's memory requirements reach past the buffer's bytes, over an import of the caller's pages and over a copied host buffer's copy alike, whose placement is the buffer's length. Metal reads such a texture in place, so it is a runtime cost above the driver's: docs/FAST-PATHS.md's known gaps now say so, and InPlaceRefusal::Placement's doc names the case. Seen on the Iris Xe (ANV) and the 780M and RX 550 (RADV) by a probe at the guest's shape, which stays on a branch of its own. Verified: cargo fmt; scripts/api-signatures --check (signatures unchanged; a doc change). (cherry picked from commit 9493894b26cee3b1a525d9a0916a83f3fc6a594f) |
||
|
|
da896c5a1f |
Textures over a device-allocated copy: the caller's pages' verdicts, the pooled check only for the pitched image
On RADV (the RX 550, job 8832) every texture over a copied host buffer whose copy lies in memory the device allocates stayed a shadow: the route asked the runtime's pooled class's verdicts, which the check leaves unchecked there, though the image over such a copy is mostly the driver's own linear image, which starts PREINITIALIZED and so keeps the copy's bytes at its first move. The pooled class judges only the DRM_FORMAT_MOD_LINEAR image made UNDEFINED at Metal's pitch where the driver lays its rows otherwise. So the route asks the caller's pages' class (Pointer) for texels as they lie in the copy and as they lie in the pages (a rebind may import them), and fresh pages' where the copy lies in them; copy_unplaced refuses the pitched image for its pitch where the pooled check did not pass for its accesses. The wider plans of a texture over a copy (the usages its descriptor lacks) take the caller's pages' verdicts too, as the route does. Texels::over_caller_pages answers only over a copied buffer. The device test now asserts an image over the copy where both checks passed and none where the pages' did not. Verified: cargo fmt; builds and tests run as potluck jobs after this commit. (cherry picked from commit 7911bb167b88661f3d4b8b6a4431145ff22a143c) |
||
|
|
1cf4730839 |
Textures over a copied host buffer: an image over the copy where the check passed, not a shadow
Every texture made over a copied host buffer (a no-copy buffer whose import the caller's gate
refused, or that failed) was a shadow, refused as `Refused(Placement)` ("a copy of the caller's
pages in memory of the device's own"), whatever its usage: each command buffer copied the copy's
texels into the shadow's image, and merged writes back, on top of the copy's own copy-in and merge.
A consumer whose views of guest memory pass the host's mapping budget gets copies of its large
window surfaces (reims's Iris census: 112 gate copies, 1.9 GB), and every texture over them is
such a double copy: the boots' 491 refused-placement shadows.
The GPU uses the copy in the pages' stead, so a texture's image can lie there, as a rebind onto a
copy already makes one (`in_place_over_copy`):
- route.rs: a copied buffer's class is its copy's memory's (Fresh in fresh pages the runtime
imported, else Pooled); the in-place decision asks that class's verdicts and the caller's pages'
(Pointer: a rebind may import them), each for texels that lie in lines as they lie there
(`Texels::line_start` reads the copy's offset in its memory; `over_caller_pages` the pages').
- in_place_image.rs: `unplaced` over a copy makes the image in the copy's memory: in fresh pages
the host-allocation one, as over the pages; in memory the device allocates `own_unbound`, the
driver's linear image (PREINITIALIZED) where it lays the rows at the pitch, else the
DRM_FORMAT_MOD_LINEAR one of no external memory (`unbound_in` serves both, and
`in_place_unbound`). The image is watched for rebinds and its first move holds the pages, for any
no-copy buffer's pages (the class no longer decides it). A rebind onto a device-allocated copy
takes the DRM_FORMAT_MOD_LINEAR image too where the pooled class passed for its accesses
(`class_takes`, from `fresh_pages_take`).
- The image's identity is the buffer's, so its uses name the copy: commits copy the CPU's writes
in, completions merge the GPU's back, as for the buffer.
- Counted: `WorkCounts::copied_textures_in_place` (also in `host_textures_in_place`); a shadow's
notice names the copy.
Tests (copied_device.rs): a sampled and a rendered texture over a gate-refused copy take an image
over the copy exactly where the verdicts of the copy's memory and the pages pass (before this,
every one was a shadow, so on a device whose check passes the test fails), read the caller's
texels and a CPU write before a commit, and their blit and clear reach the texels' bytes in the
pages alone; such a texture follows rebinds to another copy and back to an import.
Docs: copied.rs, in_place.rs, in_place_image.rs, route.rs, HOWTO (copied host buffers),
FAST-PATHS (the in-place row), TexturePlacement::InPlace; api_signatures blessed.
(cherry picked from commit e6573e3f1b942d11bda3063f5477745018cf9239)
|
||
|
|
15c72b1690 |
GPU pools: a block a queue lets go is the device's spare for the next queue
A queue's pool block that went (its queue went, or no lease held it for QUIET) was released, and the next queue to need a block of that kind made one again: on the RTX 5080 a 254.7 MiB vkAllocateMemory of 4.9 to 189.5 ms beside other GPU work, during which the driver holds every vkQueueSubmit of the process (docs/FAST-PATHS.md, known gaps). Now the block becomes the device's spare of its kind where the device holds none (else it is released, as before), a made-meanwhile block too, and a queue holding no block takes the spare at its first lease before it makes one. A device so makes no more blocks of a kind than the most queues that held one at once, and none as queues come and go or rest. The cost is one block of each kind beyond the queues' own until a queue takes it or the device goes: 254.7 MiB of device memory on the RTX 5080 Laptop GPU, 1 GiB of host memory kept wired on the M3 Max. The spare is safe to hand on: no lease holds a block that goes, so no command uses it, and nothing reads a pool's bytes before its own command buffer wrote them. QueueBlocks::drain pops the slots instead of taking the map. Tests: the pool CPU tests cover the spare from both releases, the made-meanwhile block, the teardown and queue churn (eight queues one after another make one block); the device tests see a later queue and a rested one take the spare without a making, and the handler test makes each round's block after a holder queue took the spare. Verified: cargo fmt only, here; the runtime and validation suites, clippy and the device runs follow as potluck jobs. (cherry picked from commit dcc2bc0cb49f391b7d14c135d7aae97f1a93795b) |
||
|
|
9024d9ee5f |
index_pools: count a completed handler's lag from its submission's return too
runtime_lane::index_pools::a_completed_handler_waits_for_no_pool_block_made_meanwhile
failed on the RTX 5080 (round
|
||
|
|
384ce01a32 |
HostRam lists: HOWTO, runtime README and FAST-PATHS with the 780M's numbers
HOWTO section 6 gains HostRam::with_dma_buf_of_runs: what the source answers, where copies take lists, what they differ from (a chunk's import pins every page of it, for good, and later copies import nothing; lists pin the copy's pages while it runs, and every copy pays its imports), and the Radeon 780M's numbers from tests/host_ram_listed_bench.rs at 4f30c38a77 (before the rebase onto development; the list path is unchanged by it): 4028 MiB of an 8 GiB guest's file held where whole chunks would make 8192 MiB resident, 8300 of 16384 for 16 GiB; a surface-shaped tile 4.1 to 4.5 ms from the commit to the completion, a scattered one 0.9 to 1.25 ms, against 0.39 to 0.48 ms over an imported chunk. The copy paragraph says where lists replace the staged and alone paths. The runtime README names the call; FAST-PATHS's row on idle dma-buf imports gains the trade (memory for per-copy time, the consumer's choice, no accuracy). (cherry picked from commit c6f08a396cc2e4713dedfae06ad0648019e9e22d) |
||
|
|
27eea49ec5 |
HostRam: a copy over a listed chunk not imported takes lists of its own pages, of an opt-in source
HostRam::with_dma_buf_of_runs(source, most_runs) gives a RAM a DmaBufRunsSource: one dma-buf of a list of runs of its pages, their pages one after another (udmabuf's UDMABUF_CREATE_LIST on Linux, at most list_limit runs a list). Only copies by runs call it, and only where the plan is Plan::listed (each held import costs every submission and the RAM's chunks are the device's dma-bufs of its source: RADV) and the device's barriers order blits through two imports of the same pages. There RamOnDevice::for_copy, for a chunk not imported, takes RamOnDevice::run_lists: the copy's ranges of the chunk by address, widened to whole host pages and joined where those share or touch a page (copy::page_runs), split into lists of at most most_runs runs and one dma-buf's bytes (copy::run_lists), each imported as one dma-buf of the source (Device::ram_runs_as_dma_buf, Imported::Runs), held by the command buffer until it completed and freed then. The chunk is neither imported nor asked for, so copies pin their own pages while they run and never a chunk's untouched pages, which udmabuf allocates for good. Without the source, a source that fails or answers a dma-buf of another length, the margin of the allocation limit, a run that is the whole chunk or passes one dma-buf, the copy takes the chunk as before. A list's VkBuffer holds each run from where the runs before it end: RamChunk keeps the runs and their offsets (RamChunk::offset_of, RamChunk::bytes), and the copy maps each piece through it; regions take their host bytes from the pieces, not the import's span. alone_ranges takes one chunk's sorted ranges (chunk_ranges with no cap) and joins them as before, so every other plan (ANV, NVIDIA, lavapipe, MoltenVK, RADV without the source) copies as before. Counted: WorkCounts::host_ram_run_list_imports (new), live in run_imports_live. Tests: copy.rs units for page_runs and run_lists; host_ram_dma_buf's tile tests over a RAM with a udmabuf list source (lists of at most 1,024 runs, no chunk, nothing asked, no untouched page resident) and, without it, the chunk; elsewhere the list source never asked. The bench takes the list source and prints first and repeated copies, sorted runs and lists per copy, over surface-shaped and scattered tiles. api_signatures blessed (three added: DmaBufRunsSource, with_dma_buf_of_runs, the counter; nothing removed); docs/REFUSALS.md regenerated (a DmaBuf site). Verified: cargo fmt and the signature and refusal scripts only; the 780M runs follow. (cherry picked from commit f2e5c143dd314835fd58cd6f8430c5c7c620e52a) |
||
|
|
bdeed7eaa6 |
HOWTO, signatures: copies over a chunk not imported, staged gathers and their counts
docs/HOWTO.md's host RAM copy paragraph said a copy over a chunk not imported waits for its import; it now says what each takes: ranges alone (at most 16, not on MoltenVK or ANV), a staged gather through the CPU on devices whose thread imports ahead, and the wait otherwise, with the counts that show each. api_signatures.tsv blessed for the six new WorkCounts fields (signatures.py --bless: six records added, none moved). (cherry picked from commit 9332df0676eea0a5336ee95ffc25deb2b5d0b05f) |
||
|
|
748465a50e |
Host RAM copies of runs each at a byte of the buffer: one call for a laid-out surface
BlitCommandEncoder::copy_runs_from_host_ram(ram, runs, destination) and copy_runs_to_host_ram(source, ram, runs) take (buffer byte, host run) pairs, so a device cache that keeps a surface's layout (row r at base + r * pitch, the padding between rows the guest's and untouched) copies every row in one call instead of a call a row (the Iris measured 2054 calls at 3.9 ms GPU and 8.1 ms CPU against 0.83 ms and 1.5 ms for one call of the same runs, m3-max-8523). The call now holds runs at their buffer bytes (Run); copy_from_host_ram and copy_to_host_ram lay theirs one after another from their offset (one_after_another), so their behaviour and refusals are as before. Runs join where they touch in the RAM and in the buffer (merged). pieces() places each piece at its buffer byte; the record path takes the span from the lowest run's first byte to the highest's last for the bindings, windows and hazard tracking, and the kernel's entries already carry their buffer word, so only the table's filling changes. Runs that all end on a word and lie at words of the buffer's memory take the dispatches; others, and copies that write a destination byte twice (a scatter's host bytes, a gather's buffer bytes), take regions, in rounds where a byte is named twice so the later run's bytes stay. For the runs calls, a run past the buffer is RangeOutOfBounds (the first such run's), and a run at a buffer byte off a word takes regions instead of being refused. Tests: a laid-out surface (rows at a pitch over scattered pages, two side by side, one in each chunk) both ways in one call with sentinels in the buffer's padding and the whole RAM compared, 4-byte rows by a dispatch per chunk, 2-byte rows and rows at a buffer byte off a word by regions; a gather naming one buffer byte twice keeps the later run's bytes; the runs calls' refusals; unit tests for merging pairs, in_words off a buffer word and pieces at their buffer bytes. The bench's laid-out one-call form now uses copy_runs_to_host_ram from the laid-out cache. Docs: both calls' API docs, the module docs, Problem::HostRam, HOWTO section 6 and the runtime README; signatures re-blessed (REFUSALS.md regenerated, unchanged). (cherry picked from commit 8292ae5075d07cbcd6eada94cf8dc99060792722) |
||
|
|
1c33448daa |
dma-buf lane: a view of single pages takes the route its device answers; ANV's dma-buf limits documented
What: the reversed-view test now asserts each measured driver's route for a no-copy Shared buffer over 64 and list_limit + 1 single pages of a memfd in reverse, mapped from the file and through udmabufs (VM_PFNMAP), placed outside the guest's range, with a dma-buf source: - RADV: through dma-bufs, one chunk, or two in a sparse buffer; - ANV: by pointer from the file; through udmabufs, one dma-buf where one udmabuf holds the view, else refused (Unsupported, HostMemory) after one request for a single dma-buf of the whole view; - lavapipe: by pointer. No route is a copy. It prints the mappings the view and the import took. with_dma_buf's docs and HOWTO now say what ANV does. It imports a dma-buf for a plain buffer but reports none for a sparse one, so its source is asked for one chunk of the whole length, which one udmabuf must hold. It refuses the pointer of a mapping of dma-bufs. Why: a consumer's probe found ANV refusing a view of list_limit + 1 pages mapped through udmabufs. The runtime's route there was not a copy, nor a skipped source: - the pointer import of the udmabuf mapping was refused: vkGetMemoryHostPointerPropertiesEXT answered memoryTypeBits 0x7f, then vkAllocateMemory with VkImportMemoryHostPointerInfoEXT returned VK_ERROR_INVALID_EXTERNAL_HANDLE on memory types 2 and 1; - the source was then asked; - vkGetPhysicalDeviceExternalBufferProperties for DMA_BUF reports import for flags 0 but not for SPARSE_BINDING, so the request's granule was the whole 4,198,400 bytes, and one udmabuf of 1,025 items is past list_limit 1024. No buffer of Vulkan binds more than one imported memory without sparse binding, so the runtime has no documented path for such a view on ANV. Verified: diagnostics on a scratch branch (never merged), on the Iris Xe (ms01, job m3-max-8433, Linux 7.3.1, i915), the 780M (job m3-max-8454) and lavapipe (gem10, job m3-max-8477). The runs of this test follow. (cherry picked from commit 32ba8392a0aa8d16b4fceb9b6ed052e5d618b1a0) |
||
|
|
ded385b661 |
YCbCr textures: announce the device's conversion at the first conversion; the lanes read in-place samples as Metal's
On the Radeon 780M, which converts the 4:2:0 formats itself and reads their planes in place, the ycbcr lanes failed 9 of 48 at this branch (um870 m3-max-8383) and 17 of 48 at development's tip (gem10 m3-max-8421), the same 9 among them. Two causes: - A texture whose conversion is the device's announced ycbcr-filter-not-exact as it was made, though a texture whose planes every function reads in place never converts and so never reads the device's conversion (a_ycbcr_texture_sampled_and_gathered_by_one_function_reads_its_planes_in_place, a_ycbcr_sample_through_an_unmeasured_filter_is_announced). Converts::new now announces it at the texture's first conversion. WorkCounts::ycbcr_device_conversions still counts the texture as it is made, so a lane can tell before a read that the texture's image holds the device's conversion. The lanes' notice predicates now take a conversion that ran, WorkCounts::ycbcr_device_samples (device_samples), in place of the textures made. - The lanes held the samples of a texture whose planes are read in place to its image's texels, the device's conversion on such a device, where a function reading the planes converts the codes itself: Metal's conversion and filter under the lane's exact_answers (YCbCrInPlacePolicy::Exact), as ycbcr.rs states. Texels::sampled takes Metal's steps of the codes (modelled) for a texture read in place and the image's texels elsewhere, in a_linear_sample_of_a_ycbcr_texture_is_metals, a_linear_sample_is_metals_through_each_sampler_and_result and its fragment twin, a_ycbcr_slot_takes_the_devices_filter_in_the_pipeline_its_creation_made and ycbcr_textures_read_the_texels_metal_converts; a_draw_samples_the_planes_as_written_before_it holds a draw read in place to Metal's conversion of the uniform codes. four_two_two_and_four_four_four_codes_read_what_metal_reads also held a code twin over a surface whose chroma plane it does not fit in to Metal's codes where the device reconstructs them itself: it now takes the device's codes there, as the test's other surfaces do. Docs: the ycbcr.rs and ycbcr_device.rs module docs, Degradation::YCbCrFilterNotExact and its docs/API.md catalogue entry say the notice comes at the first conversion. Verified: cargo fmt; the 780M runs on um870 and gem10 follow. (cherry picked from commit c498f9383a3f4a2ef3f267a135ea5494aa8fb5e4) |
||
|
|
5640e17560 |
Document the model's linear sample of planes read in place
FAST-PATHS.md gets the ledger row for ycbcr_in_place_reads (Model default, Exact switch, the 780M's exact-form cost measured at development's tip), the device-gaps row and the in-place section name the choice; API.md's policy list and the half/float filter and ycbcr-filter-not-exact catalogue entries name the model; PrecisionNote::HalfSampleFilter/FloatSampleFilter and Degradation::YCbCrFilterNotExact docs say the model records and announces them. (cherry picked from commit 5f83699d296386c3b0b357f2baa63cfefc086096) |
||
|
|
b30da69b50 |
Host RAM copies of runs of words take the pages copy's dispatches, not regions
The pages copy's table entries become three words: the run's first word in the scattered binding, its first word in the consecutive one (from the shape's first_word) and its words, at most a page's 1024. Each invocation copies its strided words below the run's count. Whole pages are entries of 1024 words, one a page as before, so their tables' entries, dispatches and windows are unchanged. In the runtime, a copy whose runs all end on a word (they already start on one, and the buffer's bytes too) takes the dispatches: plan() cuts each piece into runs of at most a page from its start and where a window of the buffer ends. Only runs that end off a word (rows of 1- or 2-byte texels), or a scatter whose runs write a byte twice (share_a_byte, so the later run's bytes stay as with regions), keep vkCmdCopyBuffer regions. The Iris measured regions at about 1.6 us of GPU and 1 us of CPU each (m3-max-8389: 8853 regions of a 31.5 MB surface, 14.0 ms GPU, against 0.99 ms for the page kernel over the same pages). Tests: the kernel's interpreter test of word runs (a word, 128, 129, a run across a page, a page less a word) with no word around them changed; the plan's cuts at a page and at a window's end; a device test of rows of 2044 bytes at a 2048 pitch from 16 bytes into a page, a run ending a word before a page's end, three pages and more from inside a page, one across the chunks' end and a word, with sentinels over every touched page, a dispatch per chunk and no region both ways, and a twice-named scatter of word runs by regions, the later run kept. The regions refusal case now ends off a word. The bench measures rows of 4-byte texels (dispatches), of 2-byte texels (regions) and 2046 bytes at a 2048 pitch. Docs: the kernel's module and entry docs, the copy module, both calls' API docs, HOWTO and the runtime README; signatures re-blessed (entry() takes the run's words and returns 12 bytes; ENTRY_WORDS). (cherry picked from commit 562fc5fc526cce2b31db280c4bbffb29314f8ac4) |
||
|
|
6ba9ac779f |
BufferDescriptor::aligned_byte: lay a buffer's byte on a multiple of 256 bytes of its memory
A consumer that lands decoded frames in a buffer of the runtime's own memory makes plane textures at CoreVideo's offsets: the first plane 32 bytes into the surface, the second 32 bytes past a multiple of 256 after the first's rows. A linear image aliasing the buffer binds at the buffer's memory offset plus the texture's, which must meet the device's linear-image alignment (256 on RADV, 128 on NVIDIA, 64 on lavapipe), and the runtime starts each buffer on a multiple of 256, so those planes are shadows there (the 780M probe, um870 m3-max-8351: Shared and Private buffers, in place at 0 and 256, shadows at 32, 64 and 128). BufferDescriptor::aligned_byte (with_aligned_byte), a runtime extension for the runtime's own memory, names the byte to lay on a multiple of 256 (LINEAR_IMAGE_ALIGNMENT). placed_new_buffer then makes the VkBuffer that byte's shortfall longer, binds it where its placement starts, and starts the buffer's bytes that many bytes into both (BufferParts offset and base, the mechanism host imports use), so the byte lands on the multiple and textures there alias the memory. Such a buffer is never parked nor taken from the parked, and lies in no fresh pages. Its length and gpuAddress (the runtime's address space's) are unchanged; a Shared one's contents start the byte's remainder short of a multiple of 256, which the field's docs name against Metal's page-aligned contents. Refused with NoCopy contents (Problem::AlignedByteNoCopy). tests::aligned_byte: over Shared and Private buffers laying byte 0x20, the 8-bit and 10-bit frames' planes (R8/RG8 at rows 3840, R16/RG16 at rows 7680; the second plane at 0x20 + 0x7E9000 or 0xFD2000), sampled, written and rendered into, alias wherever the same texture at offset 0 of a plain buffer does, and are shadows at 0x20 of a plain buffer wherever the device's linear alignment is past 32; a blit of each sampled plane reads the bytes at its offset; length, gpuAddress and contents as above; the refusal over NoCopy. Docs: the field, HOWTO, API.md's shadowed-texture entry, the runtime README; api_signatures blessed and REFUSALS.md regenerated. New public items: BufferDescriptor::aligned_byte, BufferDescriptor::with_aligned_byte, Problem::AlignedByteNoCopy. Verified: cargo fmt; the 780M, lavapipe and Iris runs follow. (cherry picked from commit bef28766eee658ef30dfcc5d0492a1493171b34d) |
||
|
|
fe5f08a4b1 |
Host RAM copies take runs at word starts and any end, copied by regions
reims's laid-out device cache downloads hand copy_to_host_ram each texel row's bytes (encode_out): runs that start on the device's linear texture alignment, always a 4-byte word, and end at any byte, short of the row's padding, which the guest's CPU owns. merged() refused every such run (Problem::HostRam) and the consumer fell back to a view of the surface's pages: on ANV one mapping per 4 KiB page, 278 of 294 device caches in boot 8267. Now a run starts on a 4-byte word and ends at any byte past it. Copies whose runs are all whole 4 KiB pages keep the pages copy's one dispatch per chunk, unchanged. Any other copy records each run's bytes in a chunk as a region of vkCmdCopyBuffer between the import that holds them (whole pages, imported as before) and the buffer: byte offsets and sizes, so no other byte of the runs' pages is read or written. The regions of one import are one command, at most 1024 each (MOST_REGIONS). A scatter whose runs name a byte twice takes a round of commands per overlap, so no byte is written by two regions of one command (VUID-vkCmdCopyBuffer-pRegions-12482), the later run's bytes left; a buffer over host pages the runs overlap is refused (VUID-vkCmdCopyBuffer-pRegions-00117). Counted in the new WorkCounts::host_ram_copy_regions. Tests: copy.rs's unit tests (word starts, any ends, rows that touch merge, whole_pages, rounds); host_ram_copy_device's runs_inside_pages_move_their_bytes_alone_and_leave_the_rest_of_their_pages (2046-byte rows at a 2048 pitch from 16 bytes into a page, a run ending 2 bytes before a page's end, one across the first chunk's end, one of 3 bytes; pattern sentinels around them; gather into Shared and Private, scatter back; 10 regions, no dispatch; twice-named bytes; the overlapping buffer refused); the whole-page test now also asserts no regions; the refusal test's cases off a word. host_ram_copy_bench gains the laid-out download: a call a row, one call, and the view with a blit a row. Docs: copy.rs module and both calls' API docs, Problem::HostRam, docs/HOWTO.md, the runtime README; docs/REFUSALS.md regenerated and the API signatures re-blessed (the new WorkCounts field). (cherry picked from commit 1ba8aba84076208a1eccaf65dd4993058ed53431) |
||
|
|
016c09572a |
Pooled moves: docs and API signatures
TexturePlacement::Pending: over the device's own memory, a texture made while the pooled check is pending now moves to its image at Metal's pitch the same way (it no longer stays a shadow for good). Texture::vk_image, docs/FAST-PATHS.md (row 41), docs/API.md (the shadow reasons over the device's own memory) and docs/HOWTO.md (the padding-unobserved paragraph) say so, naming WorkCounts::pooled_textures_moved_in_place and pooled_texture_shadows_freed_after_move. API signatures: the two new WorkCounts fields (scripts/api-signatures/signatures.py --bless, two lines added). (cherry picked from commit 4c1beda492dcc4af16923df09724b7fbf0e7387a) |
||
|
|
535f50063f |
Pooled bound over tracked Private buffers alone: CPU-visible caches lie in place at any size
The owner's 2026-11-07 ruling: over CPU-visible memory the GPU works in place wherever the device's check passed, however much slower; a shadow there is a correctness fallback, never a speed choice. The 48 KiB pooled bound (LinearCost) chooses between two speeds where both forms give the same answer, which holds only over bytes only the runtime's commands write. So it now applies to tracked textures over Private buffers alone (Texels::only_commands_write), for every access; over a Shared or Managed buffer, and for an untracked texture, a texture that samples, renders or is written takes the DRM_FORMAT_MOD_LINEAR image at its pitch at any size wherever its check passed. This widens the previous commit's sample-only exception. reims's histogram (boot 8203) shows no rendered cache past 48 KiB, so the render and write side changes nothing measured today. The bound's doc comment, LinearCost's (internal and public) and docs/API.md and docs/HOWTO.md now say so. Test: a_texture_past_the_pooled_bound_is_a_shadow_of_its_linear_cost_over_private_memory_alone replaces the rendered bound test and the previous commit's sampled one: 164x82 at 704-byte rows, past the bound, rendering and sample-only, over a tracked Private buffer Shadow(LinearCost) and no pitched image where the device makes such images, over a Shared buffer never LinearCost and the pitched image where the pooled check of its access passed. (cherry picked from commit cd89debcd731885e8045dc998252a08edc3dc60f) |
||
|
|
f8caa83975 |
Pooled bound: a texture that only samples bytes the CPU writes lies in place at any size
The 48 KiB bound weighs a DRM_FORMAT_MOD_LINEAR image at Metal's pitch against a shadow that renders into its own optimal image, or samples it copied in once. A texture that only samples a Shared or Managed buffer's bytes (or an untracked texture that only samples) has no such shadow: its shadow is copied in whole at every command buffer that samples it, as the CPU may have written the bytes. The guest's large device caches are WebKit's tiles, about 5 MiB each, CPU-painted and only sampled; past the bound each was a shadow re-copied in every command buffer. Measured on the Iris Xe (ANV, Mesa 26.2.6; job m3-max-8243, runtime_lane::pooled_draw_costs::pooled_sample_costs), a frame that samples four such textures whole after the CPU wrote a texel of each, GPU microseconds as shadows at the padded pitch against linear images at the tight one: over Shared buffers 1308x512 (2.7 MB) 327.8/215.9, 1324x940 (5.0 MB) 802.2/380.1, 3648x2038 (30 MB) 5789.3/2601.6; over Private buffers, whose shadows stand copied in once, 237.7/216.2, 404.4/409.4, 2028.1/2433.2. So the bound keeps covering textures that render or are written, and those that only sample bytes only the runtime's commands write (Texels::only_commands_write, the predicate a shadow's standing uses). Test: a_sampled_texture_past_the_pooled_bound_lies_in_place_over_bytes_the_cpu_writes (164x82 at 704-byte rows, past the bound, sampled: over a Shared buffer a pitched image where the pooled reads check passed and never Shadow(LinearCost); over a Private buffer Shadow(LinearCost) where the device makes such images). (cherry picked from commit d99c9c507b00e7b1537257a7a2fddd18d9563e2f) |
||
|
|
48caeeb155 |
DegradeNotice::command_buffer: the command buffer whose work announced a notice
A consumer that makes some notices fatal (reims-vgpu's ReleasedCommandState, PrivateResourceOption, HostDeallocatorDelayed) could not tell which command buffer a notice was about: a ReleasedCommandState announced at a host step on the scheduler's steps thread ended its whole VM. Now every notice carries the ID of the command buffer whose work the runtime was doing on the announcing thread, so the consumer can fail that one command buffer. What changed: - CommandBuffer::object_id: an ObjectId, minted at the command buffer's making from the process-wide count buffers, textures and heaps use. - DegradeNotice::command_buffer: Option<ObjectId>, read at the notice's making from a thread-local scope (degradation::NoticesFor), as `call` reads the call being lowered. The scope is set where the runtime holds the command buffer and does its work: the compute and blit encoders' logged funnels and their other recording calls and ends, the render lowering's at-call funnel, its unit calls, its batches' lowering (on the lowering thread or a drain) and its end, the resource state encoder's calls, encoder openings, the commit (at the call or queued behind a render end), a batch's submission and the storage-form settle that rides on it, host steps, a rebind's encoding again, and GPU-time reads. Nested scopes name the innermost. - None, explicitly, for a recovery of the device (device-recovered), for grouped-completion (several command buffers' batches), and inside the program's code the runtime calls (exit_guard::program, indirect command checks, executed-commands handlers). - A bind's memoized notices, announced again at each later bind under announce_each, are named as that bind's: its command buffer and the call being lowered (the call was the first bind's before; same mechanism). - ObjectId docs, docs/API.md section 9, docs/RUNTIME-PORTING.md; API signatures re-blessed (two records: the field and the method). Tests (runtime crate, device tests): - notice_command_buffers: an ICB execution recorded at a host step announces released-command-state on the steps thread naming the executing command buffer; its commit's host-replayed-indirect-commands, on the program's thread, names it too; private-resource-option of an ICB made between the encoder's calls names none. - deferred_calls: the call-naming test also checks the command buffer under both lowering policies; a new test waits for the lowering thread to announce unsized-points after end_encoding and checks the thread, call and command buffer, and that a device notice between the encoder's calls names none. - vertex_conversion_notices: a memoized bind notice (device-nan-encoding) announced at a second command buffer's draw names that command buffer and its own call index, with bound_notices_made proving the memo was reused. (cherry picked from commit b4c2ba83ea726229f129a405ce6f432b0bdb0127) |
||
|
|
df2d326289 |
A device's teardown leaves the device to the process's end at its next step once the exit began
runtime_lane::exits::exits_right_after_learning_of_completion_are_clean failed on the RTX 5080 in lane 10 of development's round at |
||
|
|
f5da0934bf |
exit_guard: past half its bound, the hook names where the sections it waits for began
An exit that waited for the runtime's work said nothing about what it waited for until its bound
ran out, and then only that the driver still ran it (the at-once notice). An exits-lane exit
that took 2.08 s on the RTX 5080 (runtime_lane::exits, handler_learns_exit, development
|
||
|
|
7e5821d9d1 |
In place: renders over padding a buffer declares unobserved take a verdict that lets that padding change (Access::UnobservedRenders)
What: a new check access, UnobservedRenders, that the renders rounds answer beside Renders, as the
storage-write rounds answer BufferWrites beside Writes. Where a shape's rows' padding is free
(Shape::padding), a renders round that changed no byte but of that padding (after a row's last
texel, before its pitch, the last row's included) fails Renders for its row ends and keeps
UnobservedRenders. A byte past the last row's pitch, or a texel, fails both. A new Padding variant,
Unobserved (Free padding over a buffer that declares padding_unobserved, Texels::padding), makes
in_place() ask UnobservedRenders in the stead of Renders (Access::rendered); the wider render-target
plan of an image in place asks the same. The check's SHAPES gain 172x67 BGRA8 at a 704-byte pitch,
whose last row's pitch ends 64 bytes past a multiple of 128 and 256, so a device that writes back
more than a line around a row's last texels changes a byte past the image and fails both.
VERDICTS 48 -> 56 (7 accesses), the record 56 bytes; CHECK_VERSION stays 11 (unlanded).
Why: on the Iris Xe (job 7965 at c4eeeba7e8), the pooled class's Renders verdict failed for rows
ending mid-line (the clear and store, and draws, write back the 64-byte line holding a row's last
texels whole), so none of the 93 device caches went in place (93 shadows, frame 4145 us declared
and undeclared alike), and the item's case (a padding-unobserved texture at a 64-aligned pitch, rows
ending mid-line, rendered) stayed a shadow (CheckFailed{Renders, InLines}). The declaration already
lets a render pass's load and store write those bytes; no byte past the last row's pitch may change,
and Padding::of guarantees the last row's pitch ends on a line.
Also: a padding-unobserved buffer in fresh pages takes the same rule; BufferDescriptor's doc says so.
Tests: unit cases for the compare (the line write-back of each row's padding is Padded; a 128-byte
write-back past the last row's pitch, a byte past it or a texel is Changed), Padding::declared, the
tally (Renders answers two), the decision test over Unobserved padding, the shadow-cause words; the
device test asks the UnobservedRenders verdict and asserts the texels' padding is Unobserved. Device
evidence follows on the Iris.
(cherry picked from commit 990d744ec71269663e292c7f2f3e4148d166bacb)
|
||
|
|
6717cac4ea |
Pooled class: a bound in bytes past which a texture over pooled memory stays a shadow (TextureShadowReason::LinearCost)
Measured on the Iris Xe (probe 7933): a small cache's shadow costs a fixed 3.5-4.3 us a
command buffer that writes it, which a linear image at Metal's pitch saves, while caches of
1.4 MB and more render and sample 8-18% slower as linear images than as shadows with their
copies. Over Private memory both forms give the same answer (no CPU reads the bytes, the check
judges the first move), so this chooses between two speeds and takes no FAST-PATHS row or
switch. in_place::POOLED_PITCHED_BYTES bounds a texture's rows to their pitch, the same on every
device; past it the cause is ShadowCause::LinearCost, which the placement query answers as the
new public TextureShadowReason::LinearCost { bytes } through the shared route. docs/API.md (the
padding-unobserved reason) and HOWTO say why.
The bound's value here (256 KiB) is provisional: the size sweep on the Iris and the 780M places
it at the measured crossover in a following commit.
Verified: cargo fmt; api signatures re-blessed (one variant added); REFUSALS.md regenerates
unchanged; builds follow.
(cherry picked from commit 366e098c15c7227006ba7633ecda574da224690e)
|
||
|
|
703eca0dba |
Pooled class: tests and docs
The padding-unobserved device test settles the check and holds the answer to the making's (NotHostPages exactly where the texture aliases, else the shadow's cause); a new device test renders textures of the guests' cache shapes (64-aligned pitches, rows ending inside a 64-byte line) over declared buffers and checks that a pitched image appears only where the pooled class passed for reads and renders, that the CPU's texels read back through the texture, that a clear reaches the buffer's rows, and that the bytes after the last row keep the CPU's. The validation lane reads 48 verdicts. Docs: in_place.rs and in_place_check.rs module docs, FAST-PATHS row 41, API.md (placement answers, the shadow reasons), HOWTO's padding-unobserved paragraph, the runtime README, BufferDescriptor::padding_unobserved, TexturePlacement's NotHostPages and Pending (a pooled texture made before its verdicts stays a shadow). Verified: cargo fmt only; builds and the device runs follow. (cherry picked from commit ae31d0fd3841b136c692897cbdf425633e9344c3) |
||
|
|
3feb4b3a55 |
Keep a tiled texture's own image through a detach, its first level the bytes' last texels
A tiled texture of more than one level (Buffer::new_tiled_texture) over a no-copy buffer presented the shared zero stand-in at every level while the bytes were detached, and refused CPU access at every level (DetachedTexelAccess). On a Mac its later levels are the texture's own memory, which a detach leaves, and its first level the pages it took, whose last bytes its CPU access reaches. The texture's image is its own, so it now keeps presenting it: noted with keeps (NotedTexture::keeps), it takes no stand-in at the detach (TexturesOver::images leaves it out, and so do the stale-reach notes) nor at its making over detached bytes. Before anything is detached, the detach loads its first level with the bytes' texels as they are then (keep_first_levels, Texture::keep_first_level: a get_bytes of the pages, then a write into the image), so an unnamed read and get_bytes read the last texels, those the CPU wrote after the last copy in included; a replace_region of that level stays refused. The later levels are read and written in the image as before. Once the bytes lie in pages again the first level copies them in at its next use. The load reads the level's texels once on the host (11.7 KB for WindowServer's 54x54) and stages one copy for the next submission, at a detach only. Docs: the item's rustdoc says the difference (its first level reads its last bytes while detached, where a texture over the pages alone reads zeros), with its other levels' rule and the copies of item 1 and 2; detach.rs, stand_in.rs, DetachedTexelAccess's doc and docs/API.md. REFUSALS regenerated (unchanged), api signatures checked (no change). Verified by the device tests: see the tip's evidence. (cherry picked from commit 87435362577424f2e7757ff69bcb292b401dc9ed) |
||
|
|
aadc115900 |
In-place check: a store failure fails every class's pass; compares read in wide loads
With the dma-buf class's pages imported on the Iris Xe (the commit before), two things showed, both from one cause: ANV maps its exported memory uncached for the CPU, whatever the memory type (job 7706: types 1 and 2 alike), so each byte the check reads there is a bus read of about 80 ns. 1. A flaky pass. The check's writer reads each byte before it rewrites it, sweep after sweep, while the GPU stores; a sweep of a 101x51@512 window there takes about 2.7 ms, against a store step of 0.1 to 0.8 ms, so it revisits a row's last line about 40 us apart instead of under a microsecond, and rarely lands a write between the GPU's read of the line and its write-back. The storage-write rounds of rows that end inside lines saw the padding change in 3 of 18 dma-buf rounds against 10 and 14 of 18 of the pointer and fresh-pages classes (job 7706), and the dma-buf class passed storage writes inside lines in one fresh check of three (job 7688), where its pass would have put a kernel's writes in place over kept padding on a guest's pages. In that run every round agreed (none saw a change). carried_store_failures: a class's failure of an access whose rounds store (renders: the pass's clear and store, and the draw; storage writes and buffer writes: the kernel's stores), where that class's reads of those row ends passed (so the failure is the stores', not the first move's), fails the other classes' passes of that access and row ends. The line write-back belongs to the store path every class's images share; how often a class's rounds see it does not. A reads failure (whether the GPU sees the CPU's bytes depends on the class's mapping and import), an unchecked verdict and a class whose pages could not be made carry nowhere. Each carried failure is noted. To change no verdict a texture already took, the check now gives its verdicts together once every class is done, not per class. 2. A 19 s check. Bytes::matches compared the window byte by byte: 2.7 s for each round of the 3840x2160 surface over the dma-buf pages (the fill took 4 ms). It now compares each period whole first (slice equality, in wide loads) and looks for the byte only where one differs; a cleared row's texels likewise, a chunk of zeros at a time. CHECK_VERSION stays 9 (the commit before, not yet released). Docs: the module's verdicts paragraph and run's, API.md's in-place check paragraph. Test: a_store_failure_fails_the_other_classes_passes_and_nothing_else_carries (tests/in_place.rs), the Iris's verdicts of the flaky run: the dma-buf class's pass of storage writes inside lines alone fails, as the pointer class's failure; a failure of the dma-buf class's own carries to the others; reads failures, an unchecked verdict and a store failure of a class whose reads failed carry nowhere. Verified: pending (the unit test with and without the rule, the Iris check time and verdicts in release, the device test repeated, the 780M and lavapipe verdicts against development's). (cherry picked from commit f2f0e284c2b62980bbc3f1e1881e01b2c8ce9227) |
||
|
|
20360b6038 |
In-place check: the narrow rounds' large surface is 1024x64, not 1024x1024
The last of the narrow store shapes was a 1024x1024 R8Uint surface at a 1024-byte pitch. On the M3 (release, job 7745's probe) its three rounds took 7.5-8.4 ms of each class's 14-16 ms of narrow rounds, and the narrow rounds put the whole check 30 ms past the base's (0.33 s to 0.36 s; the base's spread is about 7 ms). A sixteenth of its rows keeps its 1024-byte rows, the row width of the largest such guest texture, and the many workgroups of its dispatch, and cuts its fill, word-per-texel source and compare by sixteen. Verified: cargo fmt; the shape tests read NARROW_STORE_SHAPES and name no size. The check's time is measured again on the M3 in the next jobs. (cherry picked from commit 3927363fbd5883c78cf2835255ae145e2f1541f3) |
||
|
|
b1e2f06e9e |
Docs: a written texture over host pages is a shadow by width only outside 1, 2, 4, 8 and 16 bytes
Two passages still said a shader's writes of 1- or 2-byte texels keep a texture over host pages a shadow: the shadowed-texture entry of docs/API.md's degrade-notice catalogue and the host-pages bullet of docs/FAST-PATHS.md's costs. The device's check now stores those widths too; a texture is a shadow by its width only for a width outside the ones it stores. Verified: docs only; grep finds no other passage that names 1- or 2-byte written texels as a shadow's cause. (cherry picked from commit 90bd51d7a55257a40e115c55da2a53c7bb0b4f80) |
||
|
|
6575c031f5 |
In place: 1- and 2-byte texels a shader writes, checked apart by the device's check
In every guest session reims measured (Iris Xe and Radeon 780M, macOS 26.7.2 guests), host_texture_shadows_store_width was 114, from 23 distinct R8Unorm, A8Unorm and R16 textures a shader writes (32x32 at 256-byte rows among them). They were shadows because the in-place check's write kernel stored only 4-, 8- and 16-byte texels (STORED_TEXEL_BYTES, ShadowCause::StoreWidth), so no check covered a driver's writes of narrower ones. What changes: - in_place.rs (from selfread's parked 0c587bcad5): Access gains NarrowWrites and NarrowBufferWrites, with 36 verdicts instead of 24. Access::written picks the writes check of a texel width and padding. STORED_TEXEL_BYTES holds 1, 2, 4, 8 and 16; NARROW_TEXEL_BYTES holds 1 and 2. in_place asks the written check in place of Writes. The report names "narrow writes" and "narrow buffer writes". CHECK_VERSION goes to 9 (development's dma-buf import fix took 8). - in_place_check.rs: NARROW_STORE_SHAPES, rounds of their own for the narrow accesses, through the copy-in kernel's R8_UINT and R16_UINT views (a801dac7d7). The shapes are packed R8 256x16 and R16 128x16 at 256; R8 61x37 and R16 45x29 at 256, whose rows end inside a word and whose heights are odd; the 16- and 64-byte tight pitches; and an R8 1024x1024. The source buffer holds a word per texel, the texel's bytes low and zeros above, since CopyIn takes 4*words() bytes a texel. A narrow round's change fails only the narrow verdicts, never a 4/8/16-byte texture's. A device whose kernel or image is not made (no shaderStorageImageExtendedFormats) leaves them unchecked. - in_place::storable: one helper for a render target's storage usage, used by route.rs and storage_form.rs. It asks Access::written(texel, Padding::Kept) instead of Writes, so a narrow render target never takes the 4-byte verdict. writes_reach (the storage usage an image that does not render takes beyond its usage) and fresh_pages_take ask the written check of the texels' width; InPlaceWatch carries the width. - InPlaceAccess::Writes covers the narrow accesses. Docs (in_place, the check, API.md, HOWTO, FAST-PATHS row, runtime README, WorkCounts, HostPageTexturePolicy, TextureShadowReason) say 1, 2, 4, 8 and 16 bytes, with narrow writes checked apart. The lane's VERDICTS goes to 36. Tests: - The decision test runs every width, 3 bytes for StoreWidth among them, against narrow answers that differ from their wide twins'. It also checks storable. - Shape tests cover the narrow set: tight pitches, row ends at 16/64/128/256, free padding. - New: each_check_of_storage_writes_stores_its_texels_width. A narrow tally case. - New device test narrow_writes_device: the guest's 32x32 R8Unorm and A8Unorm (and RG8Unorm and R16Unorm) at 256-byte rows over a no-copy buffer. Each takes its narrow verdict's path, its placement query agrees, a kernel's writes reach the bytes, and the padding and the bytes past the last row are kept. - in_place_storage adds an R8Unorm render target. Verified: not yet built; the build, clippy, unit and device runs follow as jobs. (cherry picked from commit dbb985df199b1c46bb783aafbd50efd40bcab187) |
||
|
|
c73e4b36a8 |
Document learned coverage's measured costs and the spare pools' effect
FAST-PATHS' attachment-read paragraph and render/snapshot.rs now state what learned coverage does where the device measures readers, and the measured results against the build before the area rule (pre) and the spare-pool scratch (q4): - Iris Xe (job 7575, pre from 7439): crossover rows at most 1.03 times pre, except 320x180 readers covering 1.5% or 12.5% (both builds snapshot) at 1.05-1.07, the query's own cost; readers that learned a dense coverage now split (area lane 0.99-1.01 of the split). - RX 7900 XTX (7578, pre from 7481): 0.68-1.05 of pre after the control's drift between runs; per-round spread up to 1.4x. - Radeon 780M (um870, 7628): dense readers 1.00 of pre; readers over 12.5% of a scissor their pass filled whole 1.15-1.26 of pre, as the area-rule control takes too. The spare-pool doc states the Iris measurement: from pools made a pass, the measured readers took 1.07-1.19 times the same forms unmeasured, and from spare pools 1.00-1.06. (cherry picked from commit 1978c9008cf2ee9a7d90033e940a93ba24680fbe) |
||
|
|
26d00a396c |
Weigh a reader of its pass's color by what it covered in its last measured pass
The area rule weighs a reader through no scissor at the share least favourable to each form, since a draw's recording cannot know what it covers. A 1280x720 or 1080p reader covering the whole target therefore took the snapshot, 1.97-2.34x the split's GPU time on the Radeon 780M, while the consumer's readers over 3% of a 3662x2039 target need the snapshot (Iris 12.8 -> 1.7 ms a frame). Both shapes weigh the same at recording, so no static rule serves both. Now, on a device with occlusionQueryPrecise that resets queries on the host, each reader the rule would weigh records its drawing commands inside a precise occlusion query of its pass's own pool (render/coverage.rs). As the command buffer completes, the count is kept on the reader's first color's texture, keyed by the pipeline state and the reader's place among that state's readers of the texture in the pass. Later passes weigh that reader at its count: the snapshot where SNAPSHOT_PIXEL_COST per covered pixel per color costs no more than the split's copy. A device without precise queries or host reset, a reader inside an app's visibility query (already refused the snapshot), a pending pipeline's draw and a replay record no query and keep the area rule. Instances recorded inline after a split keep the query's begin and end with their draws. Both forms are exact; a stale count costs the form it chose until a pass after the change completes. Counted: WorkCounts::coverage_queries and reading_draws_by_coverage. The crossover lane runs each cell once untimed so its timed frame is weighed by the learned count. Tests: tests::learned_coverage (forms and bytes across a sparse -> whole -> sparse change; an app's Counting visibility query keeps its count with a reader inside), coverage unit tests. (cherry picked from commit 1108cd1bdebfb15f9da91b39ed80d91d8624bc28) |
||
|
|
b136c2531a |
Buffers: a declaration that the bytes between a texture's rows are unobserved
A consumer's cache buffer of the runtime's own memory (the 780M guest's 3662x2038 desktop
surface, more guest-page pieces than udmabuf takes) holds textures whose rows lie 14848 bytes
apart, 14648 bytes of texels each. linear_plan::holding shadows every such texture, since an image
at that pitch holds the bytes between rows and Vulkan lets its layout moves and a render pass's
load and store write them; the consumer's download copies each row's texels alone, so it never
reads those bytes, and the shadow's copies cost it about 1 G texels/s in a Finder drag.
BufferDescriptor::padding_unobserved (with_padding_unobserved) is the maker's declaration that
nothing reads the bytes between a texture's rows over the buffer (each row's bytes after its
texels to its pitch, the last row's included) nor between its slices. A runtime extension with
no Metal counterpart, only for the runtime's own memory: refused, Invalid
(PaddingUnobservedNoCopy), with NoCopy contents. The buffer keeps it (Buffer::padding_unobserved).
- The route (texture/route.rs) decides it for a buffer of the device's own memory:
Route::Device { holds } carries linear_plan::holding's answer, which with the declaration
holds rows and slices that lie apart (rows that share bytes stay refused). The making and the
placement query share it: the query answers NotHostPages where an image may hold the texels,
and the new TextureShadowReason::BytesBetweenRows where it may not (it answered NotHostPages
for both before).
- aliases takes the declaration: the image's subresources may then hold the padding
(linear_plan::within_padding: each subresource ends at its slice's last row's pitch or before,
slices at Metal's stride), never a byte past the last row's pitch, nor memory past the
buffer's. A byte of the image's memory past every subresource is reached by no operation on
it, the reading texels_alone already rests on, so no new check class is needed.
- WorkCounts::unobserved_padding_aliases counts the aliasing images that hold such bytes.
- A buffer the runtime lays in fresh pages (a long one where pointer imports cost submissions
nothing) keeps the in-place check's route: the declaration lets nothing more there (documented).
Docs: the field and builder, NotHostPages and BytesBetweenRows, HOWTO's paragraph on textures
over the runtime's own memory, API.md's shadow reasons and placement answers, the runtime
README; REFUSALS.md and api_signatures.tsv regenerated.
Tests: linear_plan's unit tests of the declared holding and aliasing (padding to the last row's
pitch held, past it or past the buffer refused, slices at Metal's stride alone, shared rows
refused); the route's placement test of both Route::Device answers; a device test
(tests/padding_unobserved.rs): a 101x48 BGRA8Unorm texture at 416, 448 and 512 bytes a row over
an undeclared buffer answers Shadow(BytesBetweenRows) and is a shadow, over a declared one answers
NotHostPages and is an aliasing image wherever the device lays one at the pitch (counted), at
least one pitch aliasing, its texels read back by a blit; and the declaration refused over the
caller's memory. The in-place lane's unobserved_padding_costs times a frame reading the
consumer's surface shape over a declared and an undeclared buffer.
Verified: pending (lavapipe and MoltenVK device tests, the 780M lane run next).
(cherry picked from commit 430523ce0e4dbd8433eb2b514f837d44ce1c5a9a)
|
||
|
|
11a1901a23 |
In place: the shadow notice names in-place images; the lane counts image-to-image copies
Follows the commit before, whose "WIP" line this commit's verification replaces: an in-place image of a texture that does not render takes the usages its descriptor lacks where the device's check passed for what they reach (the storage usage where the writes check passed, the one that lets free padding change; the attachment usage where the renders check passed; the sampled usage always), the first set the device makes the image with, most usages first, each at the texels' pitch in their memory or not made. A texture that renders keeps the route's `storable` (`texture/route.rs`), the strict writes check, as before; renders stay strict. - The `undeclared-usage-shadow` notice's declaration and docs/API.md's entry name the in-place case: a shadow or stand-in where the device's check failed for what the usage lets reach the pages, none where it passed. - `fresh_pages_take`'s docs point at the route's `storable`. - The lane counts a shadow's copies from an image too (`shadow_texels_copied_in_images`), which is how the usage shadow of an image in place copies, and prints the count on either path. - The module docs split the declared usage, the lacking usages and a render target's usages into their own entries. Verified: pending (clippy, rustdoc, the runtime's unit tests, lavapipe and Iris lanes run next). (cherry picked from commit 11d16a1b92cfdca3c409ff2f0501a67f0c1b607c) |
||
|
|
7205978cfa |
Make a tiled texture of more than one level over a buffer's bytes
The x86 macOS guests' WindowServer asks for a texture over a buffer with several mipmap levels through Metal's private newTiledTextureWithDescriptor:offset: bytesPerRow: (BGRA8Unorm 54x54 of 6 levels, 64x60 of 7, ShaderRead, over a new 16384-byte Shared buffer at 256 bytes a row). The runtime had no such entry, so the guest's bundle answered nil and the x86 featureProfile could not be turned on. Buffer::new_tiled_texture makes what new_texture makes, and a 2D texture of more levels (BufferTextureCall::Tiled lets linear_plan take them; a texture buffer of more levels stays MipmapLevelCount, and its offset keeps the validated 16-byte rule as the linear SPI's does). No Vulkan image lays level 0 over the buffer's rows and the other levels elsewhere, so the shared route sends it to a shadow over any buffer (Route::Levels, answered TextureShadowReason::Mipmapped): one image of every level, made zero in a Shared or Managed texture, whose existing shadow copies move level 0's texels alone (their range was already level 0), so the bytes reach level 0 before the GPU reads it and level 0's writes reach the bytes by the end of the encoder. Announced as shadowed-texture, naming the levels; counted in shadowed_textures and shadows_zeroed. The paths that assumed every texture over a buffer has one level: - blits: such a texture is an image to a blit, as a heap shadow is (Texture::blit_texels; BlitCommandEncoder::see notes it), so every level is a blit source and destination, generate_mipmaps included; - get_bytes and replace_region reach level 0 in the bytes and the other levels in the image; - a reinterpreting view shadow and a usage shadow, whose truth would be the bytes alone, are refused for it. Buffer::tiled_texture_placement answers the placement for the new call. Docs: the item's rustdoc (Metal's selector and what differs), docs/API.md, the degrade catalogue, RUNTIME-PORTING, the runtime README; api_signatures blessed (three additions, no breakage), REFUSALS regenerated (MipmapLevelCount's text). Verified: api-signatures, refusal-surface and metal-coverage checks locally; the builds, lint and device runs are the potluck jobs that follow. (cherry picked from commit b040d815059b99a20426234239aa756b282b25b9) |
||
|
|
e038e8b5fa |
Tell a loss refusal apart by lost_refusal's own answer, and regenerate the refusal surface
Device::lost_under named RuntimeGap::MadeBeforeRecovery in a match, which the refusal surface script counts as a refusal site of the gap (a third one, lost_under, which refuses nothing). It now compares the answer with DeviceLost and with lost_refusal's own answer for the generation, which is MadeBeforeRecovery wherever the line recovers past it, as the check already requires: the same calls go to the serving generation. docs/REFUSALS.md regenerated: the gap keeps its two sites; five refusal sites read their _now function's name now that the public forwarders run through Device::at_serving (the refusals are unchanged). (cherry picked from commit 0eea4c413fdcddf56a39f7f12b89c8ca23f9ff01) |
||
|
|
ab8651ae38 |
Run a device call again on the serving generation where its own was lost under it
tests::device_recovery::each_recovery_announces_its_own_wait failed on the M3
in 10 of 30 runs at
|
||
|
|
d60e8b5b60 |
Answer a texture's placement through the image in place's making up to its bind
On the Radeon 780M (RADV) a guest surface whose pitch is no multiple of 256 bytes (3664 px BGRA8 at 14656 bytes a row) is refused Refusal::Pitch where the image in place is made: the driver lays its linear image's rows out at another pitch, and refuses the DRM_FORMAT_MOD_LINEAR image at that one. The query stopped at the route and answered InPlace, so the consumer sent such a surface in place and got a shadow copied in for every command buffer, the case the query exists to prevent. Now the image in place's making is two steps, shared: Device::unplaced makes and checks the image of a plan before any memory is bound (over pages imported by their pointer, in_place_unbound's linear or DRM_FORMAT_MOD_LINEAR image and its requirements against the bytes' place and memory type; over dma-buf pages, dma_buf_image_unbound's image checked against the pages, before the caller's source is asked), and Device::place binds it. in_place_image runs the rows check, then the wider plans and the declared plan through both steps as before. The query's placement_over_buffer, where the route is the image in place, calls Device::in_place_image_made: the same rows check and the same unbound step for the declared plan first and then the wider plans, releasing each image unbound, answering Shadow(Refused(kind)) with the declared plan's refusal where none is made. Its cost: one or two VkImages where the declared plan is made in place, a pair more per wider plan where it is refused; nothing bound or submitted. What only the bind shows stays unknown: over dma-buf pages the caller's source and the driver's import of its dma-buf. The new device test a_pitch_the_device_lays_no_image_at_answers_its_shadow asks and makes BGRA8Unorm textures at pitches past their rows (61 texels at 256..1024 bytes, 3664 texels at 14656, 14672 and 14848, a render target), each answer equal to what the making counted, and at least one Shadow(Refused(Pitch)). (cherry picked from commit fb619a2a4f6fa9bfa524cd7ae88c6e76a10d12ed) |
||
|
|
3f8b07c044 |
In-place check: a kernel's writes of a texture over a buffer may change its rows' padding
What: a second verdict for a kernel's writes, Access::BufferWrites, taken by a texture over a
buffer's rows (no IOSurface plane's) whose buffer holds its last row to its pitch and whose rows,
each to its pitch, start and end on a line of the device's memory (in_place::Padding::Free). The
same Writes rounds give it: the writer and the compare tell a change of a byte of the shape's
rows' padding (after a row's last texel, before its pitch, the last row's included) apart from
any other change. A round that changed only such bytes (Round::Padded) fails Writes for its row
ends, as before, and counts as kept for BufferWrites, and the rounds go on through every shape;
any other change (a texel, a byte past the last row's pitch) fails both and ends the class's
rounds. in_place() asks BufferWrites in the stead of Writes for such a texture; renders, an
IOSurface plane's rows and a render target's storage usage (storable) keep the strict verdict.
The rebind's choice of fresh pages carries whether the padding is the buffer's own. 24 verdicts,
CHECK_VERSION 7; the report adds `{class} buffer writes` lines.
Why: real Macs disagree on those bytes, so Metal leaves them to the GPU. The probe
(row_padding_writes.m) found an Intel UHD Graphics 630 under macOS 26.7.1 writing older values
back over the CPU's writes to the padding of textures over a buffer under a kernel's writes
(10,197 and 28,162 bytes in 100 rounds of 3662x64 and 61x64 BGRA8, 304 and 307 in the last row;
m3-max-7240, m3-max-7269), keeping them over IOSurfaces and under clears, stores and draws; an M3
Max under 27.0.1 (arm64 and x86_64, m3-max-7241) and a Radeon Pro 5300M (static check, 7269) kept
every byte. The owner's ruling: follow the x86 Macs' envelope and remove the shadow copy where
possible. On the Iris Xe, whose writes write back the 64-byte line holding a row's last texels,
written textures over a buffer whose rows end inside a line now take the image in place.
Docs: in_place.rs and in_place_check.rs module docs, docs/API.md (the in-place paragraph, the
shadowed-texture notice, section 10 Kernels with the three probe results), FAST-PATHS row 41, the
runtime README. Lanes: in_place_textures' VERDICTS 24 and its written-texture checks ask the
buffer writes verdict where the padding is free (in_place_rows::padding_free/writes), the
padding bytes of a texture in place with free padding no longer held to the pattern.
Tests: tests::in_place's decision test over both paddings; Padding::of cases (the guest's
3662x2039 surface at a 14656-byte pitch is free, 416x51 at 64-byte lines kept, slices apart);
Bytes::compare telling a change of each row's padding (the last row's last byte included) apart
from one past the last row's pitch or of a texel, and from padding that is not free; Tally's
verdicts for the Iris's walk and the others.
Verified: pending.
(cherry picked from commit 200f2a9e2b26eeaff45c1cc5ec71decf42d8437e)
|
||
|
|
95a5f1ad37 |
Point HOWTO's integrators at the texture placement query
docs/HOWTO.md's passage on textures over host pages told a program to start the in-place check early with Device::settle_in_place_checks; it now also says that a zero timeout later answers whether the verdicts are known, and that a program routing each surface to its pages or to a copy of its own asks Buffer::texture_placement (or texture_placement_with_iosurface_plane), whose answer is the making's own decision. Docs only. (cherry picked from commit 17bbae52a0330a75a5d1cd522407f2888dc7bcff) |
||
|
|
1aeff532b6 |
Answer where a texture over a buffer's bytes lies before it is made
A consumer that routes each surface either to textures over its pages in place or to a cache of its own had to parse the doc-hidden in_place_check_report() strings and re-derive row ends to learn the runtime's verdict. Now it asks: - Buffer::texture_placement(descriptor, offset, bytes_per_row) and Buffer::texture_placement_with_iosurface_plane(descriptor, plane) answer a TexturePlacement: InPlace, Pending (a shadow made before its verdict, which moves in place where it passes), Shadow(TextureShadowReason) (policy, store width, check failed or unchecked with its InPlaceAccess and InPlaceRowEnds, Refused(InPlaceRefusal), texels past the length, a device copy), NotHostPages, or OtherShape. - The answer is the making's own decision: the route a texture over a buffer takes (past its length, no host pages, a device copy, bytes detached or copied, and the in-place decision against the verdicts) moves out of storage_over_buffer into Device::route_over_buffer (texture/route.rs), which the making and the query both call. make_texture_over takes a goal, make or ask, so the query runs every check the making runs before it makes anything and refuses the same arguments with the same errors; the IOSurface client direction refusal is one function both use. - Device::settle_in_place_checks is public, documented: it starts the check, says when the verdicts are known (a zero timeout waits for nothing), and how a recovery's new VkDevice reads them again or checks anew. Tests: tests/texture_placement.rs maps every route and shadow cause to its answer; tests/texture_placement_device.rs (m2v_gpu, m2v_cpu_icd) asks and makes over host pages: pending then known after the settle, the pending texture moving to the answer at the next quiet commit, a store width, a render target, an IOSurface plane, a long buffer, texels past the length, no host pages, a texture buffer, detached bytes, the Shadow policy and a forced failed check, comparing each answer with the counts the making moved, and the errors of refused arguments. docs/API.md and the runtime README describe the query; api_signatures re-blessed; docs/REFUSALS.md regenerated. (cherry picked from commit bef6ce09f56d8a7c1ad5ee7ef934a06a39b58c7a) |