a3fb1283e621f9eb97e8bfcb48cafffbfcb771ae
95
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
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
|
||
|
|
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) |
||
|
|
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)
|
||
|
|
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) |
||
|
|
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) |
||
|
|
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) |
||
|
|
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) |
||
|
|
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) |
||
|
|
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)
|
||
|
|
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) |
||
|
|
b6c025c12b |
Free a moved shadow's image once the command buffer that took the move completed
A texture over host pages made before its in-place verdict is a shadow, and moves in place at a
commit once its class's verdicts pass (`texture/storage_form.rs`). The shadow's image then stayed
with the texture until it went, so a long-lived surface kept an unused texel-sized image and its
merges' scratch buffers for the session.
The switch's last part now writes the shadow's image (a tracked transfer write of every level and
layer), so hazard tracking orders the committing command buffer after every use of the shadow
committed before it, on any queue, and that command buffer holds a ShadowAfterMove. Once it
completed, where the texture moved in and only the texture's storage and this hold the shadow's
image, the image's VkImage, views and memory go (`Image::let_go_unused`, the release a drop runs,
at most once), and its merges' kept scratch buffers. Nothing names the shadow by then: every later
command presents the image in place. A view of the texture made before the move, a shadow made
over the shadow's image (which holds it as its truth, `shadow::ImageTruth`), and an untracked
texture keep it until those and the texture go. The in-place counts are unchanged.
New WorkCounts field: host_texture_shadows_freed_after_move. FAST-PATHS (the in-place row) and
HOWTO say when the shadow goes.
Verified:
- runtime_lane::in_place_textures::a_texture_made_before_its_verdict_moves_in_place_once_it_passes
now requires as many shadows freed as moved (polled up to its wait): "moved 1, in place 1,
shadows freed 1" on lavapipe (gem10 m3-max-7070, at this base; msi m3-max-7019 at
|
||
|
|
2b7ebd8c38 |
ANV: blits through two imports of the same host pages are unordered by a barrier in one command buffer
On ms01's Iris Xe (Raptor Lake-P, Mesa 26.2.6) two host_ram_device tests failed (5425): a write through a buffer bound in a run's import and a read through one bound in the chunk's import of the same pages, in one blit encoder. A probe of each way (5482, scratch branch steelbrain/amdperf-iris-probe, two runs) showed the shape MoltenVK's AliasedImportBlitsUnordered names: in one command buffer, in one encoder or two, a fill through one import, a global memory barrier and a copy through the other read none of the fill (0 of 4096 bytes) in either direction, where two command buffers of one queue, a wait first, and two queues each read all of it, and every way through one import read all of it. Vulkan counts imports of the same pages as aliases of one memory, which a global barrier orders, so this is the driver's. ANV now has the defect in the Affected table, so an object over a chunk not yet imported binds in the chunk's import (waiting for it), never in an import of its own run, as on MoltenVK. The table test lists it for ANV; host_ram.rs, the host_ram_device tests' docs and HOWTO name ANV beside MoltenVK. Verified: cargo fmt only here; the Iris rerun of the 42 tests is a potluck job. (cherry picked from commit 589815be2cd36191673b6aae36e2f50a2afcd1cd) |
||
|
|
78e58c370f |
Guest RAM: listed chunks stop at 512 MiB, not 256
On a device whose held imports add to the cost of every submission (RADV), a guest RAM's chunks now run up to 512 MiB. reims's 16 GiB guest on the Radeon 780M (their job 5584, two boots of each setting) had less of QEMU's RAM resident with 512 MiB chunks than with 256 MiB ones: 0.45 GiB more than without the source at its desktop against 0.94 GiB, and 0.15 against 0.25 GiB at the end of its run, with at most 11 to 12 chunks live against 15 to 18. The probe's per-submission cost falls too: an 8 GiB RAM's submission median was 32 to 33 us in 32 chunks of 256 MiB and 24 us in 16 of 512 MiB (job 5411). LONGEST_LISTED_CHUNK, the module and use_host_ram docs, HOWTO, the FAST-PATHS row and the chunk-length probe (now up to 512 MiB) say 512 MiB. (cherry picked from commit 003382bdc921fa8e7901fa00c7896f29439d7907) |
||
|
|
f9bc470d7c |
Move a shadow made before its pages' in-place verdict in place once it passes
A texture over host pages made before its class's in-place verdicts were known is a shadow (CheckPending): an unknown, not a lack. Under the owner's 11-07 ruling a shadow is only for accesses that cannot be done in place, so such a shadow must not stay one for life because it was made early. Each such shadow now waits for its class's verdicts (StorageForms::moves). The check's thread, at each verdict, decides from facts stored with the wait (class, usage, texel bytes) and takes no handle of a program's texture. Where the verdicts take an image in place, the texture waits for the storage-form switch. At the commit of the device's only uncommitted command buffer, the switch makes the image in place exactly as the texture's making makes it: the declared plan, with feedback loop and storage usage where the device makes them so, and noted for a rebind and its first move. Where every encoder ran, the texture presents it from then on (TextureShared::moved; every storage read goes through Texture::storage). It is counted in host_textures_in_place and in the new WorkCounts::host_textures_moved_in_place, and its slots are written again. No texel is copied: between encoders the shadow holds nothing the buffer lacks, and the image in place is the buffer's bytes, whose uses hazard tracking orders after earlier copies back and merges. A view made before the move keeps the shadow. A shadow with a usage or render shadow, over detached or copied bytes, or whose image the device refuses stays a shadow. The shadow's image is kept with the texture until it goes. Test: runtime_lane::in_place_textures::a_texture_made_before_its_verdict_moves_in_place_once_it_passes (under the validation layer). Docs: storage_form.rs and in_place.rs module docs, FAST-PATHS in-place row, HOWTO, API.md. (cherry picked from commit 605d0444de1ad1a9b93e02649db7e1b2fda18e93) |
||
|
|
6aff9aaa3c |
Stop a listed guest RAM's chunks at 256 MiB: a chunk's import pins every page of it
Where each listed import costs every submission (RADV with a source of dma-bufs), a guest RAM was imported in chunks as long as the source's dma-bufs and the device's limits took: about 2.5 GiB on a consumer's 16 GiB guest on the Radeon 780M. A chunk's import pins every page of the chunk, and udmabuf allocates the pages of the memfd the guest never touched, which stay allocated once the chunk is freed. So each chunk an object lies in made all its bytes resident: the consumer measured QEMU's Pss_Shmem at 7.86 GiB without the source and 12.31 GiB with it. listed_chunk_bytes now stops at LONGEST_LISTED_CHUNK, 256 MiB, on every device and kernel. It is a structural bound, not tied to udmabuf's size_limit_mb, which stays an upper bound through HostRam::with_largest_dma_buf. The trade is speed against memory, with no accuracy change and so no switch. Each live chunk costs every submission about half a microsecond (an 8 GiB RAM on the 780M: 128 chunks of 64 MiB took a submission's median from 14 us to 60-88 us; 3 chunks of 2730 MiB, to 16 us). At 256 MiB, a 16 GiB RAM lists at most 64 chunks. The kept-chunk rule (releases_idle_chunks) is unchanged, so the first-gather win of kept chunks stays. The docs (the host_ram module, Device::use_host_ram, HOWTO section 6, and the FAST-PATHS "Idle dma-buf imports are released" entry, edited in place) say where the chunks stop and why. The lane probe submit_per_ram_chunk_length now measures only the lengths the plan can make (64, 128 and 256 MiB). Its run before the cap measured 64 MiB to 1 GiB. Verified: the unit test listed_chunks_are_as_long_as_every_limit_takes_in_whole_64_mib fails without the cap (a 2.5 GiB source gave 2560 MiB chunks) and passes with it (job ids in the tip). (cherry picked from commit 9a158941e94173b4e0dc53b89f3b15c9b59f60c2) |
||
|
|
442dcd08c9 |
Copied host memory: a copy that drops the GPU's writes takes its guest RAM's log, and a draw that only reads through loaded addresses leaves unnamed copies uncompared
A copy of memory of Metal's private option bit 24 (on a system that maps no read-only view of the pages) skipped the routing of its guest RAM runs, so it kept no log: every commit compared every byte of it, and every completion of a command buffer with a root table compared every copy. In consumer boots that is about 29.5 MiB per commit and per completion over 37-44 objects. - Commit (copy in): a no-copy buffer, heap or rebind whose GPU writes are dropped has its runs asked as a writable one's are (routes_runs), so its copy takes the RAM's log and copies in only the pages the log reports written. It is still never bound in the RAM's chunk: the in-chunk binding is filtered on drops_writes. macOS keeps its read-only view and asks no runs. - Completion (merge back): State::writes_unnamed narrows reaches_unnamed to commands whose functions may write memory. A draw's root table writes only where the vertex or fragment function may store or update memory (GraphicsState::vertex_writes_memory, fragment_writes_memory) or the pipeline has another stage; kernels, tile functions, replay tables and records resolved by host steps stay as they were (every copy compared). The compare itself stays: in a dropping copy it is what restores the dropped bytes, so later command buffers read the pages' bytes. Tests: host_ram_copy_device a_private_bit_copy_over_the_pages_copies_in_only_the_pages_the_log_reports (one page written: length - page bytes not compared, the GPU's fill dropped) and copied_device a_merge_back_skips_a_copy_when_a_draw_only_reads_through_loaded_addresses (root table noted, merge back compared 0). Docs: copied.rs, FAST-PATHS known gap, HOWTO section on copies. (cherry picked from commit 61a9a4f4603a4c080ba5a4f2e204668ae621cf41) |
||
|
|
78a98addc1 |
Guest RAM: a listed chunk stays imported where the whole RAM fits the memory its imports count against
On RADV the first kernel submission that lists a guest-RAM chunk just imported waits while amdgpu writes the chunk's page tables, one entry per host page, through SDMA jobs that wait for room in the IB suballocator (amdgpu_cs_ioctl > amdgpu_vm_bo_update > amdgpu_vm_sdma_update > drm_suballoc). It holds the VM's reservation lock throughout, so every other submission of the device waits too, and so did the guest-RAM thread's next PRIME_FD_TO_HANDLE (218 ms in amdgpu_gem_object_open). Seen with a root /proc stack sampler on the Radeon 780M (gem10 job 4750): 231 to 275 ms of a gather's submission per 3.94 GiB chunk imported again. Every re-import after the idle release paid it again. A listed chunk, once imported, now stays imported while the device uses the RAM, where the whole RAM fits in half the device's memory heaps with unified memory (RADV reports an APU's GTT and carve-out together, split across two heaps), else in three quarters of the heaps that are not device-local (a discrete GPU's GTT). Chunks kept past their objects must fit in the kernel's GTT: RADV lists every import in every submission, which fails once they pass it. Where the RAM does not fit, chunks are released while idle as before. Each kept chunk costs every submission about half a microsecond (3 chunks for 8 GiB: 16 us against 14 us). Plan::releases says which; Device::count_host_ram_imports_against is the device tests' seam (cfg(test)): the release test makes the RAM too long, and a new test sees chunks kept past their objects and the idle window, with the next objects bound in them and no import made. The lane probe's gathers say how many chunks are live and were released. FAST-PATHS and HOWTO say what is true now. (cherry picked from commit 75f17258ddd0dc03e2f89a85819091cfa22c345a) |
||
|
|
3312a0ad84 |
Make a texture over host pages before its verdict without waiting for the in-place check
A texture over host pages made while its class's in-place verdict was pending started the check
and waited for that verdict as it was made, up to in_place::VERDICT_WAIT (5 s). The check's
rounds take seconds on some devices and builds: on um870's Radeon 780M (RADV, Mesa 26.2.6), in a
debug build, the first of the consumer's odd-width surfaces (3662x16, rows of 14656 bytes,
ShaderRead | RenderTarget) took 1.75 s and 1.86 s to make (job m3-max-5168), past the ~2 s the
consumer's guest waits for the COMPLETE of its next message. reims-vgpu's
on_vulkan_a_presented_surface_at_an_odd_width_reads_row_for_row failed there ("a COMPLETE") from
the wait's landing on; every command buffer of the same shape completed in under 2 ms.
A texture made before its verdict is a shadow again (ShadowCause::CheckPending, counted in
host_texture_shadows_check_pending), and its making starts the check and waits for none of it.
A program that makes such textures as it starts, and wants them in place on a driver's first
run, starts the check earlier with Device::settle_in_place_checks and a zero timeout; a device
whose record holds the verdicts knows them as it is made, as before. VERDICT_WAIT,
InPlaceChecks::wait_for and WorkCounts::in_place_verdicts_waited go (api_signatures.tsv).
Test: tests::first_host_texture, the consumer's shape: six surfaces over no-copy buffers at widths
3662, 1831 and 1001 (rows padded to 64 bytes), ShaderRead | RenderTarget then ShaderRead, each
copied out by a blit and read at its own pixels by a draw. The first is a shadow made before its
verdict; before this change it waited and was counted 0 there (m3-max-5168), so the assertion
fails without the fix. fresh_pages's in-place test settles the check before its texture, as a
texture made before its verdict is a shadow now. The waiter's unit test goes with wait_for.
Docs: in_place.rs, docs/API.md, docs/HOWTO.md, the FAST-PATHS in-place row.
(cherry picked from commit eca12ad708a8f1ad53521c967d4340a9b2635a22)
|
||
|
|
6276d55b25 |
Textures a shader writes over host pages in place, where the device's check passes for their writes
A texture over host pages whose usage writes it through a shader (`ShaderWrite` or `ShaderAtomic`) was a shadow on every device: its texels copied in before each use and merged back after each write. The owner's ruling of 11-07 (confirmed for discrete GPUs) has CPU-visible memory worked on in place wherever the device can, slower or not, with a shadow only where in place is impossible, announced and counted. This takes such a texture in place on the same terms as one that renders, from the parked branch park/shaderwrite-in-place, onto the per-class, per-access check, with no device-type rule: a discrete GPU takes it in place too. - `in_place.rs`: a third access, `Access::Writes`, which a texture of `ShaderWrite` or `ShaderAtomic` usage takes; a texture is tried in place where its class's check passed for each access it takes (`Access::takes`: renders, writes, or reads where it does neither), asked in that order until one did not pass. A texture a shader writes of texels of 1 or 2 bytes, which the check's kernel stores none of, is a shadow (`ShadowCause::StoreWidth`); `ShadowCause:: ShaderWrite` is gone. Nine verdicts a record (CHECK_VERSION 3). - `in_place_check.rs`: the storage rounds, per class: a texture of `ShaderWrite` usage over the pattern, every texel stored by the crate-owned copy-in kernel through an unsigned-integer view (`Texture::store_in_place`, from a buffer outside the Metal address space), its first move first, while the writer writes the bytes between rows and after the image; every texel must read the kernel's bytes, every other byte the writer's or the pattern. `STORE_SHAPES`: 4, 8 and 16-byte texels, packed, padded at 512 bytes (widths no multiple of 4, odd heights) and at a tight 16-byte pitch, and 1920x1080. - `WorkCounts`: `host_textures_in_place_written` (of `host_textures_in_place`, those a shader writes) and `host_texture_shadows_store_width` are new; `host_texture_shadows_shader_write` is now the subtotal of the shadows a shader writes, as `host_texture_shadows_render_target` is of those that render. The rebind of a texture in fresh pages asks every access its image's usage takes. Tests: the decision test covers every usage, texel width and combination of the three accesses' verdicts, and the order in which they are asked; the cause words and the record of nine verdicts. Lanes: in_place_textures gains `written_textures_over_host_pages_take_the_path_their_checks_answered` (64x64 `RGBA16Float` at 1024 and 512 bytes, 61x64 at 496, signaling-NaN halves beside the texels: in place exactly where `Pointer writes` passed, a kernel's writes reaching the pages, every other byte kept), and `textures_that_render_or_write_take_the_path_their_checks_answered` replaces the test that counted every written texture a shadow; no_copy_textures and pitched_surfaces take a written texture in place where its texels are 4, 8 or 16 bytes. Docs: in_place.rs, in_place_check.rs, the policy's docs, API.md (the in-place paragraph, the shadow paragraph, the `shadowed-texture` notice), HOWTO.md, the runtime README and FAST-PATHS.md's in-place row and host-pages bullet. (cherry picked from commit c3ffb08376251b87e16b7b417b39f1458e271085) |
||
|
|
158f7220ff |
Pages the process maps read-only are a copy whose GPU writes are dropped, on every device
On Linux, a no-copy buffer, heap or rebind over pages the process maps read-only went to the caller's dma-buf source wherever it gave one, and so did pages an import alignment above the host page left with no pointer import (by_pointer false), which skip the gate. A dma-buf of the pages takes the GPU's writes, which Metal drops (an M3 Max under macOS 27.0.1: the CPU reads read-only pages as they were). The runtime announced that as read-only-pages-written. Without a source the pages were refused, where Metal makes the buffer. The owner's rule (10-23) is to drop such writes on every device, never refuse them. Such pages are now a copy whose GPU writes are dropped (copied.rs), with or without a source, which is never called for them. The gate is still asked first where the pointer would be imported, and its refusal is still counted as a refusal. Counted: WorkCounts::copied_unwritable_pages (new, public), announced as copied-host-pages with its own cause. Degradation::ReadOnlyPagesWritten is removed (public: api_signatures, docs/API.md's catalogue, the lane's notice registry), and so are HostWindow::unwritable and degrade_read_only_pages. Tests: the dma_buf_imports lane test is now read_only_pages_are_a_copy_whose_gpu_writes_are_ dropped. It fails at the base, where the sourced buffer's fill reaches the file's pages and the unsourced one is refused. The host_memory lane test a_read_only_page_is_a_copy_on_linux_and_ read_elsewhere replaces the refusal test. The runtime's copied_device tests cover a new buffer and a rebind over read-only pages whose gate admits them: a copy, the source unasked. The keep-alive order test uses writable memfd pages, which RADV imports as dma-bufs all the same. (cherry picked from commit 68805d8a5742590e157b089f336c17e8e1dc4ef4) |
||
|
|
23ffb2f64f |
Name the in-place check's record by the driver and the check alone; wait for the verdict
The record of the device's in-place check was named by RUNTIME_VERSION too, which moves at almost every pin: every reims boot after a pin move ran the check again, and the textures made before it answered (WindowServer's framebuffers, made at its start) were shadows for that boot's life. - in_place.rs: the record's name and body hold the check's tag, kind and version and the driver's identity (vendor, device, driver version, driver ID, name, info, device UUID), not the runtime version; the body loses its runtime field. CHECK_VERSION is the version of what decides the answer: the check, and the images over host pages it checks as the product makes them. Asked by main for the owner's 11-07 ruling. - A texture made while its class's verdict for its access is pending starts the check and waits for that verdict as it is made, up to in_place::VERDICT_WAIT (5 s), instead of taking a shadow for its life (InPlaceChecks::wait_for, woken by each verdict set and by the settle; counted WorkCounts::in_place_verdicts_waited). Past the wait it is a shadow, counted check_pending. - self_reads prints the check's time (SELF-READ-CHECK ... took). Tests: tests::in_place pins the record name to the identity and check alone (a hash computed in the test), drops the runtime field from the frame tests, and checks a waiter wakes on its own verdict and on the settle. Docs: in_place.rs, in_place_check.rs, docs/API.md, docs/HOWTO.md, docs/FAST-PATHS.md's row; api_signatures.tsv gains WorkCounts.in_place_verdicts_waited. Verified: build, clippy and the touched tests in the follow-up jobs named in the tip's report. (cherry picked from commit 841a92b0020f1d43e943c9bc04245cffb7fcf503) |
||
|
|
6a31655071 |
Guest RAM on a listed device: no making or copy waits for a long chunk's import
On a device where each listed import costs every submission (RADV with a dma-buf source), a guest RAM's chunks are a few long dma-bufs (2.7 GiB on the Radeon 780M and RX 7900 XTX), and the first object over a chunk not imported imported it on its own thread: 660 to 692 ms, at the first object over each chunk and again at a released chunk's next use. A copy over such a chunk (copy_from_host_ram, copy_to_host_ram) did the same on the encoding thread. Now the chunk's import is off the caller's path: - On a listed device the device's thread (listed_chunks, in place of release_idle) imports each chunk an object or copy asked for (ChunkSlot::asked, RamOnDevice::next_asked), and still releases idle chunks. The object, and every object over the chunk until the import is done, is bound in an import of its own run alone (RamOnDevice::run_alone), as on a device that imports ahead; those after lie in the chunk. - A buffer's (not a heap's) run import is releasable as a no-copy buffer's own import is (host_residency.rs, AgainFrom::RamRun): released while idle, its address never handed out, and at its next blit bound in the chunk's import where that is made and lays the bytes as the run's did, else in its run's own import again; never the chunk's import nor a wait for one. This holds on every device whose objects take run imports. - A copy over a chunk not imported imports each of its ranges of that chunk alone (ranges less than 2 MiB apart joined, at most copy::MOST_ALONE = 16), held by its command buffer, while the device's thread imports the chunk (RamOnDevice::for_copy); more ranges than that, or where an object's run would not be imported alone, the chunk as before. Tests: the listed device test now checks the first object's run import, the thread's import of the asked chunk, the holders in the chunk, the runs' release while idle and the rebind in the chunk at the next blit, the chunks' release, and a copy over a released chunk taking its run alone. The AHEAD copy window test expects the copy past the window to import its page alone. Unit tests: next_asked's choice, alone_ranges' joins. Docs: host_ram.rs, host_residency.rs, host_ram/copy.rs module docs, use_host_ram, HostMemory::with_runs, WorkCounts::run_imports_live, FAST-PATHS.md, HOWTO.md. (cherry picked from commit f80468eb4afac1e30f14fd99e1af06b67622a1a1) |
||
|
|
48ba1d9856 |
Guest RAM on a device that pays per listed import: few long chunks, none ahead, idle ones released
Where the device imports dma-bufs, the RAM has a source and the device's held imports add to the cost of every submission (RADV), each listed import costs every submission: an 8 GiB RAM as 128 dma-bufs of 64 MiB raised a submission's median from 14 us to 60-88 us on the 780M (probe submit_per_ram_dma_buf, job 3904), as 3 of 2730 MiB to 16 us. There (Plan::listed) a chunk is as long as one dma-buf of the source holds (HostRam::with_largest_dma_buf, new: udmabuf's size_limit_mb) and maxMemoryAllocationSize, maxBufferSize and maxStorageBufferRange take, in whole 64 MiB (listed_chunk_bytes). No thread imports ahead and no run is imported alone; the device's thread instead releases a chunk only its slot holds once it stayed so for its window (2 s, doubled per release up to 64 s, as a no-copy buffer's idle import), counted by the new WorkCounts::host_ram_chunks_released. Tests: listed_chunk_bytes and long chunk_spans unit tests; a device test (where_each_listed_import_costs_a_submission_...) of one long chunk, none ahead, kept while held, released once idle and imported again; the probe submit_per_ram_chunk (8 GiB memfd RAM, an object over each 64 MiB). Docs: host_ram.rs, with_runs, HOWTO section 6, FAST-PATHS idle-release row, api_signatures. Not built yet: the next commits fix forward what the build finds. (cherry picked from commit e313ddd4201e87a76490a36eb394281d6961dbc9) |
||
|
|
3eb84d76c6 |
Off macOS, drop the GPU's writes to bit-24 no-copy memory through a copy
Metal drops what a shader or the blit engine writes into no-copy memory made with its private option bit 24: the write completes with no error, a later command of the same command buffer may read it back, and neither a later command buffer nor the CPU sees it (probes/readonly_gpu_writes.m, an M3 Max under macOS 27.0.1; the owner's ruling of 10-23: drop, never refuse, on every driver). macOS imports the pages through a read-only view of them. Elsewhere the import was of the caller's own pages, so the GPU's writes reached the pages, the CPU and later command buffers (host-page-writes-kernel-store-read-only and host-page-writes-visibility-read-only diverged on llvmpipe and the RTX 5080), announced as private-resource-option. No import can keep the writes out there: Linux drivers pin imported pages for writing, and ANV lost the device and RADV failed every submission over read-only imported pages. So off macOS such a buffer, heap or rebind is made over a copy of the pages whose GPU writes are dropped, the mechanism copied.rs already has for pages the process maps read-only: each commit copies in what the CPU changed, later commands of the batch read the GPU's writes, and the batch's completion puts every byte the GPU changed back, writing nothing to the pages. The gate is not asked (nothing is imported), the copy joins no other buffer over the bytes, and a rebind whose bytes moved in their page is now a copy laid out at the old offset rather than refused. - buffer_descriptor.rs: buffer_over_host_memory makes the copy (CopiedFor::ReadOnly) where drops_writes and the system maps no read-only view; the rebind path copies the same way (read_only_copy); copied_buffer takes why it copies, and passes read_only to CopiedBuffers::add and drops_writes to the buffer's HostCell. no_copy_options moves here from degradation.rs and no longer announces private-resource-option off macOS (that notice stays for a heap of the runtime's memory and an indirect command buffer). - copied.rs: add() takes read_only, which drops the copy's GPU writes whatever the pages' protection. - buffer.rs: BufferParts carries drops_writes into host_lie. - New: CopiedBecause::ReadOnly, WorkCounts::copied_read_only_memory. - Docs: read_only_view.rs, copied.rs, capabilities.rs (the answer stays no off macOS), values.rs, host_backing.rs, interop.rs, host_aliases.rs, error.rs (RebindTextures is macOS-only now), degradation.rs, docs/API.md (private-resource-option, copied-host-pages), docs/HOWTO.md and the docs/FAST-PATHS.md known gap: off macOS a command buffer committed while the writer is in flight still reads its writes, and a render pass's store-out into the copy completes where Metal's faults. - Tests: degrade_notices' bit-24 lane tests assert the writes are dropped on every driver and count the copies (3 and 1 off macOS, 0 on it) and the kinds (copied-host-pages off macOS, none on it); copied_surfaces' dropping buffer is a copy of its own off macOS. - host-page-writes read-only rows declare copied-host-pages in place of private-resource-option; their 8 ledger rows are removed. - api_signatures.tsv blessed for the new field. Verified: see the replay and lane-test jobs named in the branch report (lavapipe, the RTX 5080 through b5080, MoltenVK on the M3). (cherry picked from commit 1f24b1f035d61f093ecf2c76fae4b9c2e4b541d9) |
||
|
|
924f46aac7 |
use_host_ram and HOWTO: the no-source case and the dma-buf route in one statement
flakes's landing (
|
||
|
|
718f6543b4 |
HostRam: chunks imported as dma-bufs where held pointer imports tax every submission
reims measured raw Vulkan on the Radeon 780M: each live host-pointer import adds about 0.75 us plus 0.33 us per MiB to every vkQueueSubmit (amdgpu gets every page of a userptr again in each CS), each dma-buf about 0.44 us with no per-page cost. A guest RAM imported in 64 MiB pointer chunks would cost RADV about 24 us per chunk per submission, and RADV refuses the pointer of any shared mapping (a memfd's) anyway, so the consumer imports 13-135 region blocks and its IOSurfaces one dma-buf each there. - `HostRam::with_dma_buf(source)` (new public method) gives the RAM a DmaBufSource. Each import of the RAM, a chunk or an object's run imported alone, is then one dma-buf of its pages where the device's submission checks found a held pointer import taxing every submission (the ImportTax verdict; the pointer where that import fails), and elsewhere the pointer first, the dma-buf where the pointer is refused. The decision reads the device's measured verdict or the driver's refusal, never its identity: NVIDIA, ANV and MoltenVK (untaxed) keep the pointer path unchanged. `use_host_ram` waits (at most 10 s) for the checks first when the RAM has a source. - A buffer bound in a dma-buf chunk is made for DMA_BUF_EXT memory (VUID-vkBindBufferMemory-memory-02985; `host_buffer` takes the handle type). Its placement lends the chunk's imports, so textures over it take the dma-buf image route (an image over a dma-buf of their own pages from the RAM's source), asked at the RAM's addresses (`Placement::dma_buf_address`: the caller's view may differ from the RAM's). A rebind into such a chunk makes the heap's and in-place images again as a rebind onto the caller's dma-bufs does. `host_backing` reports such a buffer InHostRam; its deallocator goes at once (it frees no memory of its own); the chunk's RAM keep-alive goes after the chunk's dma-buf import is freed. - Counted: WorkCounts::host_ram_dma_buf_imports (new field). Also in this commit, for the submission checks of 363fa41176: the docs that named the removed DriverFact rows (PointerImportsFollowTheirAddress, SubmissionsWithoutSignalsMerge) name the device checks (FAST-PATHS grouping row and known gaps, HOWTO, fresh_pages.rs, buffer.rs, buffer_descriptor.rs, host_memory.rs, work_counts.rs); fresh_pages.rs and FAST-PATHS give the measured reason for the tax gate (one 64 MiB fresh-page buffer: a commit's p50 10.7 -> 36.6 us on the 780M, 14.7 -> 164.7 us on the RX 550, submit_per_fresh_page_buffer at 27b9b13bcd); the checks' 10 s answer wait is one constant (submit_check::ANSWER_WAIT) shared with the in-place check; and the recall test's failure names the record, where it lies, the cache's rejected/failed reads and both identities (it failed on lavapipe, msi-laptop, m3-max-3160: no device recalled the record in 60 s; the cause is not known yet). Verified: cargo fmt only; compiled and tested in the following jobs. (cherry picked from commit fa8c27f1549fe09d769847ef63f8e34d51f2c6af) |
||
|
|
bc13149480 |
HostRam tests: fresh RAM a device imports; shared RAM a device refuses imports no chunk
On RADV (a Radeon 780M, Mesa 26.2.6) 8 of the 19 host_ram_device tests failed every run: every
test over fresh_ram, a memfd mapped shared as QEMU's memory-backend-memfd,share=on RAM is. RADV
imports a pointer through amdgpu's userptr, which takes private anonymous pages alone, so it
refuses those pages (Device::imports_shared_host_pointers answers false there): the device's
thread imported no chunk ("one chunk from the RAM's start", left 0), and a no-copy buffer over
the RAM was refused, Unsupported(HostMemory, NotRepresentable) (diagnosed on homelab-um870-1,
potluck jobs m3-max-2986, 3083 and 3119). The runtime's answer is the right one with no dma-buf
source; the tests asked RADV for RAM it cannot import.
fresh_ram now takes the device and maps the memory it imports: the memfd mapped shared where
imports_shared_host_pointers answers true (NVIDIA, lavapipe, MoltenVK), else private anonymous
memory, as QEMU's memory-backend-ram RAM is, both never touched and advised for huge pages.
ahead_device asks the probe once up front, so no test's counts or allocation limit meet its
one-page import. A new test pins the no-source case where the device refuses shared pointers:
a_ram_of_shared_memory_a_device_refuses_imports_no_chunk_and_refuses_its_objects makes the
memfd RAM, uses it, and expects the buffer over it refused (Unsupported, HostMemory), no chunk
imported or live, and the RAM's keep-alive dropped after the use; elsewhere it says so and
passes. use_host_ram's docs and HOWTO state that no-source case.
(cherry picked from commit 48202da5ba0c0cb7f49d0a630e59efd11c5918f7)
|
||
|
|
a2b99ee4f6 |
Report each write to a log of host pages in one batched call
The consumer measured DirtyCommit::report_host_writes at 77.7% of its present path on the RTX 5080: PagesLog::wrote_but called the source's hook once per run of the object's window in a guest RAM's log, about 9,000 calls a report for a 3840x2400 BGRA8 surface over scattered 4 KiB pages. PagesLog::wrote, wrote_as and a shadow's report did the same. DirtyPages gains wrote_runs(&[Range<u64>]) and wrote_runs_as(&[Range<u64>], writer), whose defaults call wrote or wrote_as once a run, in order, so existing sources keep working. Every write the runtime reports now comes to each log as one call carrying all its runs there: each range of a command buffer's writes in place (the bytes no shadow wrote, the gaps between the shadows' writes, in order), each shadow's write to the other logs, a copied host buffer's merge back (all its blocks, one call per log and copy, where it was one call per run of each block), a CPU write, and a shadow's copy back or merge (one run). For each source, the runs, their order and their writers are what the per-run calls carried. The runs gather in a thread-local buffer kept for the thread's next report, so a warm report allocates nothing (wrote_but also no longer builds a Vec per range to cut out the shadows' writes: one sorted list, swept). The internal DirtyHook calls the batched forms alone; its per-run methods went. The read side needs no batching: changed and changed_except already hand back every run of a query in one call. watch stays per run: a copied host buffer watches its runs once, at its making, not per report. Docs: the trait's contract for the runs (never empty, each non-empty, in the order of the object's bytes, apart in the object, not sorted by offset over scattered pages), its Batches paragraph, HostMemory::with_dirty_pages, the runtime README and HOWTO's guest RAM log; the api_signatures table blessed (two trait items). Tests: dirty_runs checks, over a memory log and a guest RAM log of 24 scattered pages, that a command buffer's report, a write with a shadow's merge inside it, a copy's merge back of three blocks and a CPU write each reach each log in one call per range carrying exactly the runs worked out from the window, and that a log keeping only wrote/wrote_as hears every run in the same order with the same writers. The bench gains a batched trivial log. (cherry picked from commit b69d6b70c49af0b0ab08db5fe2f8b78cd61ed2fe) |
||
|
|
d3f2bf185a |
HostRam: test a run-bound buffer against copies of its pages; copies' take wording
On gate/stack27b the HostRam copies (copy_from_host_ram, copy_to_host_ram) and the run imports compose: a copy reads and writes a chunk's pages through the chunk's import, and an object over a chunk not imported yet is bound in an import of its own run, two imports of the same pages ordered only by their host bytes (host_aliases.rs). New device test a_run_bound_buffer_and_a_copy_of_its_pages_order_by_their_host_bytes: four pages over a chunk not imported are bound in their run's import, and then, both ways: - a fill through the buffer before a gather of its second page; - a scatter into that page before a copy out of the buffer. Each way runs in one blit encoder (a barrier recorded between them), in two encoders of one command buffer, and across two queues in commit order (the writer behind 2 GiB of private fills). The six copies import nothing, and the run's import stays live. On a device with RuntimeDriverDefect::AliasedImportBlitsUnordered (MoltenVK) the test asserts the fallback: no run import, the buffer imports the chunk and lies in the copies' import. Docs: copy.rs's module docs and HOWTO said a copy takes a chunk "as an object does", importing it or waiting for its import; objects no longer wait, so both now say that a copy makes no run import of its own and waits. host_ram.rs and HOWTO add the copies to what a run-bound object's uses order against, and the test module's docs add the composition. Verification is pending in this commit: M3 and RTX 5080 device runs. (cherry picked from commit be6d43fbf2c0a5921a2468038740ef3604a2da9f) |
||
|
|
c074aa490e |
Document the HostRam window's direction, the runs' imports and their fallback
docs/HOWTO.md's "One run inside one chunk" bullet now says what the branch's runtime does: the window opens in the takes' direction, up or down the RAM; an object over a chunk not imported yet is bound in an import of its own run (run_bound_buffers_made, run_imports_live) and never waits for the chunk's fault-in; the price is up to one more allocation and pin per such object; and where the object falls back to the chunk's import (thread stopped, chunk failed or given back, allocations within the margin, a whole-chunk run, or RuntimeDriverDefect::AliasedImportBlitsUnordered on MoltenVK). It adds the measured result from tests/host_ram_window_bench.rs on the RTX 5080 laptop (NVIDIA 615.71.09), at 2b2419c67c: 256 2 MiB heaps upward, downward and scattered had no making of 5 ms or more (slowest 1.4, 1.5, 3.7 ms), against 2, 8 and 15 makings importing a chunk (slowest 8.2 to 8.7 ms) without the change; 128, about 76 and 20 heaps were bound in their own runs' imports. Docs only; verified by reading the text against host_ram.rs's for_object and after_take. (cherry picked from commit 25572e5af997da7009960fa31bf94c5d478e2370) |
||
|
|
a0bebe78f1 |
runtime: copy runs of a guest RAM to and from a buffer on the GPU, from the chunk imports
`BlitCommandEncoder::copy_from_host_ram(ram, runs, destination, destination_offset)` gathers runs
of a `HostRam` the device uses into consecutive bytes of a buffer, and
`copy_to_host_ram(source, source_offset, ram, runs)` scatters them back (a runtime extension:
Metal has none). A surface that is a scatter of guest pages is copied straight from the RAM's
64 MiB chunk imports, with no view mapped per surface (one mmap per run) and no import made per
surface.
How: adjacent ascending runs merge, descending neighbours stay apart; runs are cut at chunk ends;
the 4 KiB pages become a table in the command buffer's upload arena, and each chunk the runs touch
takes one dispatch of the new `bind::pages_copy_module` (more only past the storage-buffer range
or the workgroup count). A chunk not imported yet is imported, or its pending import waited for,
as an object over it does.
Ordering: each chunk a copy uses gets a resource key placed over the chunk's host bytes in the
host-alias placements, the way no-copy buffers and heaps are placed, so the copy's chunk uses
(joined to at most 16 ranges per chunk) order against other copies and against every no-copy
object over the RAM's own addresses, in one encoder and across encoders; the buffer side is
tracked like any blit. A scatter's writes reach the RAM's dirty log as the GPU's in place, so a
copied backing over those pages takes them in at its next commit. Objects made over another
mapping of the pages (a view resolved through `with_runs`) are not ordered against the copies.
Refused with `Problem::HostRam`: an empty run, one off 4 KiB, one outside the RAM, a RAM the
device does not use, buffer bytes off a 4-byte word; no host import is `Unsupported`; bytes past
the buffer are `RangeOutOfBounds`. Replayed at rebinds (`BlitCall::HostRamCopy`). New counters
`host_ram_copies`, `host_ram_copy_bytes`, `host_ram_copy_dispatches`. README, HOWTO, the
API signature rows and docs/REFUSALS.md updated.
Verified:
- On this M3 Max (MoltenVK), --cfg m2v_gpu under nextest: the five new device tests
(`tests::host_ram_copy_device`: round trips byte for byte over ascending, descending, adjacent,
repeated and chunk-crossing runs into Shared and Private buffers; CPU writes before the commit
gathered and a scatter's bytes in the pages after completion; the two hazard cases in one
encoder and across encoders; a copied backing over the pages taking a scatter at the next
commit; the refusals) and the ten `tests::host_ram_device` tests: 15 passed.
- Negative controls, each a saved build: merging descending neighbours fails
`adjacent_ascending_runs_merge_and_descending_ones_stay_apart` and
`a_gather_and_a_scatter_move_every_runs_bytes_in_order` ("the gathered bytes"); not placing the
chunk keys over the host bytes fails
`copies_are_ordered_against_a_no_copy_buffer_over_the_same_pages` ("a later reader sees the
scatter"). The first control found the test pattern repeating every 1 KiB, so a page swap
went unseen; the pattern now differs per page.
- The `host_ram::copy` unit tests (merge, refusals, chunk cuts, the plan, the joined uses) and
`consumer_auto_traits`; clippy --workspace --all-targets --all-features -D warnings, plain and
--cfg m2v_gpu; rustdoc -D warnings; `signatures.py --check` after the bless; the refusal
surface `--check`.
- The ignored release bench `tests::host_ram_copy_bench` on the M3, a 3840x2054 BGRA8 surface
(31,549,440 bytes, 31,551,488 in whole pages) scattered over 1 GiB of shared RAM: 7703 4 KiB
runs (5490 descending neighbours, 7279 runs after the merge) take 16 dispatches, 0.35 ms of CPU in the call, 0.59 ms of GPU and 0.64 ms from commit to completion
for a gather (scatter 0.37 / 0.58 / 0.64). The view path at the host's 16 KiB page (1926 runs:
a view mapped run by run, a buffer `with_runs`, a buffer-to-buffer copy, the release) takes
1.58 ms to map, 2.36 ms to make the buffer, 0.99 ms commit to completion and 0.78 ms to
release; the gather of the same 1926 runs takes 0.14 ms CPU and 0.60 ms commit to completion.
Ported onto gate/stack27, where the device's thread imports a window of chunks ahead of the
objects (paced, with the memory lock released, short of maxMemoryAllocationCount and giving back
what no object took). The conflict was `RamOnDevice`'s fields alone: the copies' `ChunkKeys` sit
beside the window and its wake, and the old cursor is gone. The copy still takes each chunk
through `RamOnDevice::chunk(.., By::Object)`, the objects' own path, which now moves the window
past it, wakes the thread and clears the chunk's untaken mark; there is no second import path. The
copy module docs and HOWTO say so. The ignored release bench waited for every chunk imported
ahead, which the window never does; its warm-up copy now imports the chunks the runs touch.
The verification above was on the old base; this tree's is in the commit that follows.
(cherry picked from commit 923718777c198bef526dd07f701fc71a71e07b00)
(cherry picked from commit fa00224f7b29ab0359c8305a47da9c9273fc5d37)
|
||
|
|
6c4b409fb0 |
Lay a no-copy buffer over a live copied host buffer's bytes in its copy
What: a copied host buffer (the caller's gate refused the import, or an admitted import failed) now joins its memory and is placed as an import is (`HostAliases::join` with `Kind::Copy`, `HostAliases::place`). A later no-copy buffer over exactly the same first byte and length, of either storage mode, finds it (`HostAliases::import`: an import of its class, else the live copy), lies in it through `Device::buffer_in_import`, is named to it (`copied_as`) and joins its key, with the gate not asked. A rebind onto such bytes lies in the copy too where its textures were planned at the copy's offset (its first byte) and no image in place rides on it; an import keeps the old `!moved` rule. A heap's own copy is placed but joins nothing; a buffer whose writes are dropped keeps its read-only view. New counter `WorkCounts::copied_host_buffers_shared`. Why: two copies of one memory agreed only through the pages (merge back at the writer's completion, copy in at the reader's commit). reims-vgpu measured on the M3 (MoltenVK) two textures over one 64x64 BGRA8 surface, each over its own refused no-copy buffer: a blit write then a blit read in one command buffer, and a reader committed first on a second queue waiting on the writer's event, both read all 16384 bytes stale, where Metal and the runtime in place read the write. The consumer also made a full copy of the surface per texture per present. The remaining GPU-to-GPU gap, between a copy and another copy or import of overlapping but different bytes, is recorded in copied.rs, docs/API.md, docs/HOWTO.md and docs/FAST-PATHS.md's known gaps. Verified: cargo check of the runtime with tests; the lane in the next commit, run on the M3 (see its message). (cherry picked from commit 69feb791dc6ec3bc2405dbf5b6ae5d0b27d936aa) |
||
|
|
968ccc4af0 |
host_ram: import a window of chunks ahead of the objects, not the whole RAM
What:
- The thread Device::use_host_ram starts now keeps a window of chunks past the one an object
last took imported (host_ram.rs, Window): one chunk after a take outside the window (and the
RAM's first chunk before any take), AHEAD_CHUNKS = 4 once a take lands inside it. It never
imports past the window, never goes back to the RAM's start, and so faults in at most 4
chunks (256 MiB) that no object took for one take, and at most 1 for a take that starts no
run. While its window is imported it waits (Wake: a mutex and a condition variable), woken
when an object takes another chunk or the use ends, holding the device and the RAM only
weakly, as between chunks before.
- Unchanged: the pacing (SCHED_BATCH, yields, MADV_POPULATE_WRITE in 2 MiB steps), imports with
the memory lock released, the stop a quarter short of maxMemoryAllocationCount and the
give-back of untaken chunks.
- Docs: host_ram.rs, Device::use_host_ram, WorkCounts::host_ram_chunks_imported(_ahead),
docs/HOWTO.md ("One run inside one chunk"), with the numbers below and the burst caveat.
Why: reims-vgpu's time to first present on the RTX 5080 laptop went from 11-12 s to 13.9-86.1 s
with the whole-RAM ahead import, worst at low MemFree, the normal state of a Linux desktop
whose page cache fills memory. Reproduced without a VM (release probe, public API: 16 GiB of
fresh memfd RAM under MADV_HUGEPAGE through use_host_ram, an mmap+munmap sampler, CPU-bound and
bandwidth-bound workers, a toucher faulting its own THP memory, vmstat and PSI):
- The whole-RAM import took 40.4 s at 35.4 GB free with only 21 free 2 MiB blocks, and 57.4 s
at 17.1 GB free: pgmigrate 4.1-9.1 M pages, PSI memory "full" 6.6-9.6 s, another thread's
mmap up to 0.96-1.19 s, another thread's 2 MiB faults up to 0.8 s at p99 0.48 s, a CPU-bound
worker up to 51% slower at p50 and a bandwidth-bound one up to 128%.
- 99% of it is the fault-in of fresh huge pages (direct compaction and reclaim, holding the
process's memory map lock): per chunk p50 39-123 ms, worst 1.46 s. The import itself (pin and
vkAllocateMemory) of a resident chunk took 1.7-3.2 ms at p50 (0.56 s for 248 chunks).
- So the thread now faults in only what the objects are about to reach.
Measured on the same laptop (NVIDIA 615.71.09, Linux 7.2), release, one run each, MemFree
1.7-3.0 GB with 82-88 GB of page cache. Pattern: 40 2 MiB heaps at use_host_ram, then 8 bursts
of 128 consecutive heaps (4 chunks) 1 s apart, 2.08 GiB in all, with a toucher writing 1024
2 MiB pages spread over the same RAM (the guest's own faults):
ahead own imports making max (after the first 40) PSI full
adaptive (this) 36 2 26.9 ms 0.97 s
fixed 4 36 2 6.6 / 171 ms (2 runs) 0.48 / 0.97 s
fixed 1 9 26 372 / 614 ms (2 runs) 2.1 / 2.9 s
none (no thread) 0 34 544 ms 1.14 s
whole RAM (cut at 40 s) 138 2 194 ms 14.6 s
The 2 own imports are heaps 0 and 32, made as use_host_ram starts. 16 heaps over scattered
chunks, 300 ms apart: chunks faulted ahead adaptive 16, fixed 1 16, fixed 4 38, fixed 16 46;
making p50 adaptive 99 ms, fixed 1 51-60 ms, fixed 4 61-135 ms, fixed 16 160 ms, none 28 ms
(states vary run to run). A window of 8 or 16 bought nothing more for consecutive heaps and
cost more (16: PSI full 1.5 s, guest-fault p99 134 ms). A burst that runs more than 4 chunks
past the last take waits at each chunk past the window, one fault-in each (45-70 ms at p50 in
that state, at worst 0.34 s).
No DevicePolicy switch: this trades speed for speed, and no measurement favoured the whole-RAM
form.
Tests:
- host_ram::tests::a_take_inside_the_window_opens_it_and_one_outside_gives_one_chunk (the rule)
and ::the_devices_thread_imports_the_window_past_the_last_take_and_no_more (the order: the
start's one chunk, the window past a take, a held chunk passed, nothing past the window or the
RAM's end, nothing back after a jump).
- tests::host_ram_device::the_window_ahead_moves_with_the_objects_and_imports_no_more: fresh
THP RAM of 16 chunks; the first chunk alone before any take; a full window once a heap takes
it; a run of heaps over the window imports nothing on its own thread; one chunk past a jump;
a full window again once the run goes on; nothing past the RAM's end; the skipped chunk never
imported. 14 chunks ahead, 1 by an object, over 259 heap makings, on both devices.
- chunks_are_imported_ahead_so_no_making_waits_for_one and
the_ahead_thread_leaves_the_allocation_limit_to_the_objects now open the window with a heap
over the first chunk; the limit test gives back the 3 chunks no object took.
Negative controls (a temporary build with one defect switched on at a time, M3, release,
--cfg m2v_gpu); each test failed as follows:
- whole-RAM order (next_ahead wrapping as before): the order unit test ("none past the start's
one chunk", Some(1)); the window device test ("the device's thread went on past the window",
16 chunks).
- a fixed window of 4 for every take: the rule unit test (Window { from: 10, chunks: 4 } after a
jump); the window device test (13 chunks ahead after the jump).
- the window one slot off: the window device test ("no chunk past it", 6 live).
- no wake when an object takes another chunk: the window device test ("a full window past the
take", 1).
- no thread: chunks_are_imported_ahead_so_no_making_waits_for_one ("the device's thread
imported the RAM's first chunk", 0).
- no give-back: the_ahead_thread_leaves_the_allocation_limit_to_the_objects ("the untaken
chunks went back", 0).
- with no switch, the same binary passes the window device test.
Verified:
- RTX 5080 laptop, release, --cfg m2v_gpu: the host_ram and allocations tests, 30 passed,
0 failed.
- M3 Max (MoltenVK 1.4.2, macOS 27.0.1), release, --cfg m2v_gpu, under maclock: 28 passed,
0 failed (the two dma-buf tests are Linux-only).
- cargo clippy --workspace --all-targets --all-features -D warnings, plain and with
--cfg m2v_gpu; cargo doc -p metal2vulkan-runtime with -D warnings.
(cherry picked from commit 6d72e50ebb7d52e195fea5062bfed989af2877d4)
|
||
|
|
cf7eae4420 |
Hold each device to maxMemoryAllocationCount; the ahead import stops short of it and gives back
What: - allocations.rs (new) counts each device's live VkDeviceMemory allocations, by its handle, at the runtime's two doors: - creation::allocate_memory, where every allocation goes; - release::object for vkFreeMemory, where every free goes. tests/exit_guard.rs already holds every allocation and free to those doors. So the count covers pooled and dedicated blocks, every host-pointer import (no-copy objects' own, guest RAM chunks, fresh pages) and every dma-buf import, with no caller passing it. A device is registered once its priming, which frees all it allocates, is done. Its registration goes with it. - At the limit, creation::allocate_memory refuses with ERROR_TOO_MANY_OBJECTS and does not call the driver. The refusal is counted in WorkCounts::memory_allocations_refused_at_limit. Callers handle it as they handle the driver's own refusal (memory.rs frees kept empty blocks and tries again). - The ahead-import thread stops where one more import would leave the device fewer than a quarter of its limit (Allocations::room_ahead). The remaining chunks are left to the objects over them, imported on demand as before. - Once an allocation leaves the device fewer than that quarter, a thread is spawned (Device::give_back_ahead_near_the_limit). It runs with no lock of the allocating caller held, and frees every chunk the ahead thread imported that no object took and only its slot holds. Counted in WorkCounts::host_ram_chunks_given_back. An object over such a chunk later imports it as it is made. - Scope: the ahead thread is started only in Device::use_host_ram (host_ram.rs, the one exit_guard::spawn of import_ahead). That call refuses a device without VK_EXT_external_memory_host, and its chunks are host-pointer imports (import_chunk -> memory::import_host). A no-copy object's own imports, by pointer or of the caller's dma-bufs (dma_buf.rs), never touch the RAM source and never start the thread. So RADV's per-object dma-buf imports are unchanged and never put all of RAM in GTT. That holds as long as the consumer calls use_host_ram only on devices that refuse dma-buf views, which reims-vgpu does: its os/linux/host_ram.rs hands the RAM only to devices that need imported pages mapped from their files. Why: - VUID-vkAllocateMemory-maxMemoryAllocationCount-04101: "There must be less than VkPhysicalDeviceLimits::maxMemoryAllocationCount device memory allocations currently allocated on the device". Nothing counted allocations before. - Importing ahead makes one allocation per 64 MiB of guest RAM whether or not an object ever uses the chunk. So the thread must leave the limit to the objects and never be the reason an allocation is refused. - The spec's minimum limit is 4096, so the margin is at least 1024 allocations. - The give-back runs on its own thread because the door may be called under the device's memory lock, which a chunk's free takes. A free of device-address memory can also wait for batches in flight (freed_memory.rs). Limits: - RTX 5080 laptop (NVIDIA 615.71.09): maxMemoryAllocationCount 4294967295, read by the device test. - M3 Max (MoltenVK 1.4.2, macOS 27.0.1): 1073741824, read by the same test. - At those limits, the margin and the refusal never come into play in practice. They hold for a device with a small limit. Verified on the RTX 5080 laptop, release, --cfg m2v_gpu: all 25 host_ram and allocations tests pass. Among them, the new device test the_ahead_thread_leaves_the_allocation_limit_to_the_objects: - It holds the device to a small limit (Allocations::limit_to, test-only). With 0 live, the limit is 5 and the margin 1. - The thread imports 4 chunks of a 12-chunk fresh RAM and stops. - An object over the 5th chunk imports it on demand. That allocation brings the device within the margin, and the 4 untaken chunks are given back (host_ram_chunks_given_back 4, host_ram_chunks_live +1). - Buffers of blocks of their own are then made until the device holds its limit. The next is refused at the door (Vulkan(VkResultCode(-10)), memory_allocations_refused_at_limit +1), with none of the thread's chunks live. On the M3 Max, release, --cfg m2v_gpu, the same test passes, the same way: limit 5, 4 chunks ahead, given back, then 2 buffers made and the next refused at the door. The runtime's whole host-side suite passes (1218 tests). The unit tests allocations::tests cover the refusal and room, the margin and the single give-back, and a registration's life. Not verified: a real device with a small limit (none of ours has one). The case where more than a quarter of the limit's allocations land before the give-back thread frees the chunks. That case is a race, bounded by the margin. (cherry picked from commit 15543aa261afa12b13bcda954fc5cb51063a6b0f) (cherry picked from commit 3766b1338e9b92367712cc4e9cf8f9a19dbe85e8) |
||
|
|
f739bea1eb |
host_ram: pace the ahead import, and import host pointers with the memory lock released
What:
- The thread that imports a used RAM's chunks ahead now runs as the system's batch work:
SCHED_BATCH on Linux, with its nice value kept, and the utility QoS class on Apple's systems.
- It yields between chunks.
- On Linux, before each chunk's import, it faults the chunk's pages in 2 MiB at a time with
MADV_POPULATE_WRITE, yielding between steps. That changes no byte. A kernel that refuses
the advice leaves the faults to the import, as before.
- memory::import_host (it was Memory::import_host) makes the vkAllocateMemory import with
the device's memory lock released, as import_own_pages and new blocks already do. It
re-locks only to record the block. Its callers are the chunk import (host_ram.rs) and a
no-copy object's own import (buffer_descriptor.rs).
- No CPU pinning, and no kernel, boot or module parameter.
Why: a reviewer accepted pinning all of guest RAM ahead on condition that the thread does
not stall the host while a VM starts.
- The pin of a 64 MiB chunk holds the VMM process's mmap lock while it faults in fresh pages.
Every mmap, munmap, and every page fault queued behind one, waits on that lock.
- The chunk import used to run under the device's memory lock, so every other placement on
the device waited for it too.
- A low-weight thread that holds those locks is worse, not better. On the RTX 5080 laptop
(24 threads, kernel 7.2), a thread faulting in 64 MiB pieces of a fresh THP memfd ran
against 24 or 48 spinning threads at nice 0. Another thread's mmap+munmap waited:
policy 24 busy: p99 / max 48 busy: p99 / max chunks faulted in 6 s
default 0.23 / 12.4 ms 3.6 / 26.9 ms 883 / 276
SCHED_BATCH 1.4 / 12.4 ms 11.2 / 13.9 ms 850 / 581
nice 19 131 / 511 ms 164 / 1012 ms 4 / 2
SCHED_IDLE 0.004 / 1039 ms 0.005 / 1419 ms 1 / 1
So the thread keeps the default weight (SCHED_BATCH only marks it as batch work) and paces
itself by yielding and by faulting in small steps.
Measured on the same laptop, release build, 16 GiB of fresh THP memfd RAM imported ahead
whole. "Unpaced" is the parent commit (df5beeecaa, in stack19 as 97a69f70ab). A sampler
thread timed mmap+munmap of one page every millisecond:
run time mmap p99 / max >10 ms compact_stall / fail / allocstall_normal
unpaced, idle, first run of a hold 5088 ms 57.8 / 98.8 ms 76 2411 / 183 / 67
paced, idle, right after it 8374 ms 7.5 / 45.9 ms 32 930 / 209 / 0
unpaced, idle, calm memory (x3) 1515-1824 ms 5.2-6.4 / 6.7-6.8 0 none
paced, idle, calm memory (x3) 1552-1600 ms 4.9-5.0 / 5.3-6.6 0 none
unpaced, 24 threads busy (x3) 2212-5649 ms 9.7-19.2 / 12.3-24.9 7-238 none
paced, 24 threads busy (x3) 3720-6693 ms 0.27-1.6 / 1.9-7.7 0 none
- The earlier unpaced measurement (batch at df5beeecaa) was 3.47 s, with compact_stall 1152
and allocstall_normal 54.
- Compaction follows the host's memory state, not the pace. Only the first run of each hold
met page cache to reclaim and fragmented free memory, and the hold that had it ran unpaced
first. So the compaction rows are not a like-for-like comparison.
- The pace costs time only when the CPUs are busy, where the thread now shares them. In
return, the process's other threads wait at most a few ms for the memory map lock.
- In calm memory, the remaining ~5 ms p99 is the import's pin of 64 MiB of resident pages.
Verified at the tip of this branch (this commit and the next), on the RTX 5080 laptop with
--cfg m2v_gpu, release: the host_ram device tests pass, including
chunks_are_imported_ahead_so_no_making_waits_for_one (4 chunks ahead in 31.6 ms, the slowest
of 40 heap makings 52 us). Clippy is clean with all targets and features, plain and with
--cfg m2v_gpu.
(cherry picked from commit aff66f6a5dc424d97854c0908dee022475e8dc01)
(cherry picked from commit 9bbe4518ceff598e5fa0172d5624f6af7a75b6a2)
|
||
|
|
9b60da4bee |
host_ram: import a used RAM's chunks ahead, on a thread of the device's
What: Device::use_host_ram now starts a thread ("m2v-host-ram", through exit_guard::spawn)
that imports the RAM's 64 MiB chunks one after another, ahead of the objects over them. It
goes on from the chunk past the one an object last took, then from the RAM's start. It
skips a chunk whose lock is held (an object is importing it) and one it failed to import
(left to the first object over it, as before). It stops once every chunk is imported, the
use ends, the device goes or is lost, or the process exits (each import inside an
exit_guard section). It holds the device and the RAM weakly between chunks. An object over
a chunk the thread has not reached imports it on its own thread, as before. One over the
chunk being imported waits for that one import. New counter:
WorkCounts::host_ram_chunks_imported_ahead.
Why: a consumer makes 2 MiB heaps over consecutive fresh guest RAM (memfd). Each 32nd heap
was the first object over a chunk. Its making waited for the chunk's import, which faults
in and pins 64 MiB of fresh pages. That took ~7.5 ms exclusive on the RTX 5080 laptop, and
0.4-4.0 s in a shared boot with compaction (compact_stall +10,889). Keeping chunks imported
for the RAM's life already held at the start of this branch (a chunk stays in its slot
while the use lasts). Measured here: a heap made again after every heap was dropped
imported 0 chunks.
The trade-off: the whole RAM is resident and pinned from soon after use_host_ram, not only
the chunks objects touch. 16 GiB of fresh THP memfd RAM took 3.47 s on the thread, with
compact_stall 1152, compact_fail 56, pgmigrate_success 935291 and allocstall_normal 54,
all off the making threads. No kernel, boot or module parameter is needed. Recorded in
docs/HOWTO.md ("One run inside one chunk").
Vulkan rules relied on (checked against the 1.4.366 spec): the import itself is
Device::import_chunk, unchanged, under VUID-VkImportMemoryHostPointerInfoEXT-pHostPointer-01749
"pHostPointer must be a pointer aligned to an integer multiple of
VkPhysicalDeviceExternalMemoryHostPropertiesEXT::minImportedHostPointerAlignment",
VUID-VkImportMemoryHostPointerInfoEXT-handleType-01750 "pHostPointer must be a pointer to
allocationSize number of bytes of host memory", VUID-VkMemoryAllocateInfo-allocationSize-01745
"allocationSize must be an integer multiple of ...minImportedHostPointerAlignment", and
VUID-VkMemoryAllocateInfo-memoryTypeIndex-01744 "the value of memoryTypeIndex must be one of
those returned by vkGetMemoryHostPointerPropertiesEXT". The spec's "Externally Synchronized
Parameters" list names no parameter of vkAllocateMemory, so the thread's imports may run
while other threads use the device. Each chunk's import is made once, under the chunk's own
lock. A chunk is freed only on the existing path (vkFreeMemory's memory parameter is
externally synchronized: one owner frees it).
Verified on the RTX 5080 laptop (NVIDIA 615.71.09), release, --cfg m2v_gpu:
- All 21 host_ram tests pass, among them the new device test
chunks_are_imported_ahead_so_no_making_waits_for_one. It covers 4 chunks of fresh memfd
RAM under MADV_HUGEPAGE, imported ahead in 32.5 ms. Then 40 heaps of 2 MiB over
consecutive runs: 0 chunk imports, 0 host-pointer imports and 40 chunk-bound buffers
during the makings, the slowest making 78 us. Heap 33 passes a CPU write -> GPU read ->
GPU write -> CPU read round trip. A heap made again after all were dropped imports
nothing. The other device tests hold the thread back (Device::hold_host_ram_imports,
test-only), so they still see each chunk imported by its first object.
- Negative control: with the spawn disabled, the new test fails ("the device's thread
imported 0 of 4 chunks").
- On the M3 Max (MoltenVK, macOS 27.0.1), release, --cfg m2v_gpu: all 19 host_ram tests
pass (the two dma-buf tests are Linux-only). In the new test, 4 chunks were imported ahead
in 7.2 ms; across the 40 makings the slowest took 35 us.
- Unit test the_devices_thread_goes_on_past_the_chunk_an_object_took_then_from_the_start
covers the order, the skip of a held or failed chunk, and the end.
Heap makings, 128 heaps of 2 MiB over fresh THP memfd RAM (wall time per
new_heap_with_bytes_no_copy):
case p50 p90 max makings > 5 ms
before, 1 GiB RAM 0.001 ms 0.002 ms 7.39 ms heaps 0, 32, 64, 96
after, made at once 0.001 ms 0.003 ms 7.54 ms heaps 0, 32, 64, 96
after, made once the thread is done (122 ms) 0.001 ms 0.002 ms 0.05 ms none
before, 16 GiB RAM 0.001 ms 0.002 ms 7.54 ms heaps 0, 32, 64, 96
after, 16 GiB, made once done (3468 ms) 0.001 ms 0.002 ms 0.03 ms none
Made at once, the makings outran the thread: 5 chunks were imported during them, 4 of
them by the thread. Once the thread is done, no making waits for an import.
(cherry picked from commit 7baa553a75515909f2ce9701c1e1bea4c408845a)
(cherry picked from commit 97a69f70ab96d37dcdf269192a6935f8c4126749)
|
||
|
|
d07650b362 |
Warm passes: judge the byte budget on every device, and say what pipeline_bytes counts
What: tests::warm::a_byte_budget_stops_the_pass no longer skips its 1-byte leg when the pass counted no driver bytes. That leg runs over a directory of its own, which holds none of the records' driver data, so it now asserts that the pass wrote records' data (driver_saves > 0), counted it (pipeline_bytes > 0), and stopped after the first record, on every device. A new test, a_pass_over_its_records_own_directory_counts_only_what_it_writes, warms records over the directory whose creations made them and asserts that the pass counts driver bytes exactly where its makings wrote data. Where it wrote none, it asserts that a 1-byte budget stopped nothing. WarmStatistics::pipeline_bytes, Device::warm, the runtime README and docs/HOWTO.md now say that a making whose data the directory holds already adds nothing. Over that directory the budget binds only where a making writes new data. Why: the consumer read pipeline_bytes 0 on every boot of the RTX 5080, though the warm pass made 248 pipelines, and asked whether the counter is broken there (a making's keep on a thread without the pass, or a path that never keeps). Measured with a scratch diagnostic at 1bb0b87a5a, not committed: - RTX 5080, a fresh directory: 23,800 bytes counted, 3 records' data written. - The 5080 over the records' own directory: 0 bytes, 0 written, 2 unchanged, 2 found. - M3 Max on MoltenVK 1.4.2: 13,362 bytes and 3 found respectively. So keep() runs on the pass's thread and counts on NVIDIA too, and the consumer's 0 is the true value. Their records come from the boot before, over the same directory, whose creations wrote every making's data. The old test's skip branch could have hidden a broken counter; now a pass that writes data and counts none fails. Verified: tests::warm on the M3 (MoltenVK 1.4.2), 6 passed. The 1-byte pass over a fresh directory counted 8,003 bytes with 1 record's data written; the pass over its own directory counted 0 bytes, wrote 0 and found 3. cargo clippy -p metal2vulkan-runtime --all-targets --all-features -D warnings with --cfg m2v_gpu; public rustdoc clean. The RTX 5080 run is in the hand-over. (cherry picked from commit 83cc2dbe6fb610c6ad59a741a7170812611cf703) (cherry picked from commit 1d43003372f23275ceb7fcc463a34abedbeff9a7) |
||
|
|
763965c854 |
Record a texture write's NaN encoding only where its stored NaN is not measured to be Metal's
reims-vgpu treats precision notes as fatal on Apple GPUs. A kernel's write of halves into a
32-bit float or RG11B10Float texture died with DeviceNanEncoding, and through NativeNanEncoding,
on the M3 Max where the stored bytes are Metal's; a write of a constant texel with no NaN died
the same way on every device.
What:
- A new DriverDeviation::MetalSmallFloatNans (VkProperty::MetalSmallFloatNans), taken by the
APPLE9 MoltenVK row alone: the device stores a float's or a half's NaN written to a
B10G11R11_UFLOAT_PACK32 storage image as Metal does.
- half_write_nans (a half texel's write) classifies the slot's storage choice: a 16-bit float
format takes MetalHalfTexelWrites as before, a 32-bit float one MetalNanMoves (the widened
half's bits are Metal's 0x7fc00000), the packed small float one MetalSmallFloatNans; a taken
deviation drops the note and requires its property. A slot declared without a format (every
float storage choice on MoltenVK and lavapipe) records the note under the bound format's class
(a SpecializedNote of BoundTexelFormat), one clause per class the profile does not cover, so
the runtime announces it only when such a texture is bound.
- half_storage_facts (a float texel's write) drops the small-float note the same way.
- A texture write of a constant texel none of whose lanes is a NaN records neither note.
- A new module side table, stored_texels, records each texture-family write's texel (kept
through edit.rs's retain and the roll pass's check). narrow::moves_unfolded no longer counts a
widened half's store as such a texel as an escape: the write's own DeviceNanEncoding accounts
for its stored NaN under the format it stores.
Verified on this M3 Max, byte for byte against plain Metal (an MSL probe): a float4 write of
33,792 words (16,446 NaNs) and a half4 write of all 65,536 halves (2,046 NaNs) into RG11B10Float,
RGBA32Float, RG32Float and R32Float store Metal's bytes; into R16Float and RGBA16Float a half
NaN's payload differs (the device stores 0x7e00), so those keep the note.
- runtime_lane::half_write_nans on MoltenVK: half writes into rgba32f, r32f and rg11b10f announce
nothing and 0 texels differ; rgba16f announces device-nan-encoding (2,045 NaNs differ). Without
note_stored_texel the lane fails ("write r32f: ... native-nan-encoding true").
- New core tests: a_half_texel_write_s_nan_into_wide_and_small_float_images_is_metal_s_where_
measured (declared and formatless choices on moltenvk-m3 with and without each deviation, and
lavapipe; the bound-class clauses evaluated per format) and a_constant_texel_without_a_nan_
records_no_nan_encoding (zero and 0x7e00 constants, every committed profile); the existing
device-nan-encoding and half-storage-notes tests follow the deviations. Each fails with its
change disabled (the NaN test forced true; the stored-texel exemption removed).
- Notes of every public fixture on moltenvk-m3, lavapipe and nvidia-rtx5080-laptop before and
after: DeviceNanEncoding leaves 65 moltenvk-m3 rows and 6 rows on each other profile (constant
texels), 17 formatless rows per profile go from unconditional to specialized by bound format,
58 moltenvk-m3 rows lose their small-float clause, NativeNanEncoding leaves 11 moltenvk-m3 rows,
and no row gains a note. Consumer AIR on moltenvk-m3: DeviceNanEncoding 33 entries to 21,
NativeNanEncoding 9 to 5.
Docs: API.md (device-nan-encoding and native-nan-encoding exemptions), HOWTO.md, the
PrecisionNote, VkProperty and deviation rustdoc, the driver-facts measurement record.
api_signatures gains the two variants. The versions bumped in the previous commit cover this one.
(cherry picked from commit 05d96c61107989813c186961087ee70d573cf876)
|