0b1dd0fc361da50aa1e4e284d80c3d6141b35a17
829
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
0b1dd0fc36 |
An image over a dma-buf block names a type the block is exported as, with no image-side compatibility test
On the 780M (m3-max-10304 at 07d9fcac79) the image naming an opaque file descriptor over a block exported as DMA_BUF | OPAQUE_FD was refused only by the image-side compatibility test this branch added: RADV's format query lists compatibleHandleTypes 0x1 (the opaque type alone) for its opaque linear images. That test was stricter than Vulkan: - VUID-VkExportMemoryAllocateInfo-handleTypes-09860: the export set's bits must be compatible "as reported by ... VkExternalImageFormatProperties, or VkExternalBufferProperties"; the buffer query answers them so (FdExport::new). - VUID-VkImageCreateInfo-pNext-00990: an image's handleTypes lie in its own compatibleHandleTypes; the image names one type. - VUID-vkBindImageMemory-memory-02728: the memory's export set includes one of the image's types. So the test goes (LinearRefusal::Incompatible and ModifierMemory::shared_with with it). What stays, per handle type the image names: the format query reports it EXPORTABLE, not DEDICATED_ONLY; the image made requires no dedicated allocation (VkMemoryDedicatedRequirements); its memoryTypeBits take the block's type and its alignment is met at the texels' offset (alias_unbound_in's aliases check); and the in-place check measures that exact image, under the layer, before a texture takes it. The VUIDs are cited where the export set (FdExport::new) and the image's handle type (alias_unbound) are decided. Docs follow: API.md's shadow rule, HOWTO section 7, the in_place.rs module doc. Verification: the 780M, the RX 550, lavapipe and the Iris Xe next, then the 5080 through an entry. (cherry picked from commit 239d8ff9bbd4477d784f4ccc815ebf8af53dcad0) |
||
|
|
6d5c7b8e92 |
A dma-buf block's images name an opaque file descriptor where the device takes no dma-buf image in a shared block
On the 780M (RADV PHOENIX) the runtime's memory exported as dma-bufs kept every texture a shadow: the device's image format query refuses the dma-buf handle type to a plain linear image and takes it for a DRM_FORMAT_MOD_LINEAR image only in a dedicated allocation, so the in-place check of that memory made no image and its verdicts stayed Unchecked (m3-max-10261). RADV takes an opaque file descriptor for the same images in a shared block (the opaque-descriptor planes are in place there, alignment 256). The remedy, decided from documented queries alone: - exported_memory.rs: FdExport::new asks vkGetPhysicalDeviceExternalBufferProperties for the dma-buf and the opaque handle types with the runtime's buffer usage. Where the dma-buf's compatible types hold the opaque one, and the opaque one is exportable, not DEDICATED_ONLY, and compatible with both, a shared block of dma-bufs is allocated exportable as DMA_BUF | OPAQUE_FD (Memory::export_dma_bufs_as). Elsewhere, and for a buffer's dedicated allocation, it stays the dma-buf alone. The buffer still names the dma-buf type (VUID-vkBindBufferMemory-memory-02726 needs one in common) and export_memory_dma_buf is unchanged: vkGetMemoryFdKHR of the dma-buf type, a dma-buf of the same memory. - memory.rs: Exported carries the export set beside the handle type; bound_memory answers the set. - texture.rs: alias_unbound tries the image naming the dma-buf type, then, where the block exports both, the one naming the opaque type, each through the same linear-then-DRM_FORMAT_MOD_LINEAR route (alias_unbound_in). An image takes a handle type only where vkGetPhysicalDeviceImageFormatProperties2 with that type reports it exportable, not DEDICATED_ONLY, and lists every type the block is exported as among its compatible types (external_image_limits, modifier_image_limits; LinearRefusal::Incompatible). Where neither takes it, the shadow and its notice name both refusals. - in_place.rs: the class follows the memory (ExportedDmaBuf for any block of dma-bufs); the check's own textures go through the same route, so its verdicts are of the image a texture names. CHECK_VERSION 13 -> 14: 13's records kept ExportedDmaBuf Unchecked as a cause that lasts. - WorkCounts::exported_dma_buf_images_named_opaque_fd counts the images that name the opaque type over a dma-buf block (api_signatures.tsv). Test: exported_textures' a_dma_buf_block_s_planes_name_an_opaque_fd_where_its_images_take_no_dma_buf_in_a_shared_block asks the buffer and image queries itself, apart from the runtime: it asserts the block's export set matches the buffer queries, the buffer's export is a dma-buf (fdinfo exp_name), and, where the block exports both and the dma-buf type takes no image of the plane's format in a shared block, each plane is in place naming the opaque type (counted) or a shadow of a byte the check found changed, never Unchecked; no VUID under the layer. Without the change it fails on RADV: the block exports the dma-buf alone where the buffer queries answer both. Docs: API.md's shadow rule, HOWTO section 7, the runtime README and the module docs. Verification: to run on the 780M, the RX 550 and lavapipe, then the 5080 through an entry. (cherry picked from commit 1acb4f1fbf1fd4df8fcee2948417dcc089909fe4) |
||
|
|
04f1587445 |
Snapshot refusals: say which clause leaves an own-pixel slot out, and count unreadable splits by it
WorkCounts::reading_draws_split_unreadable_own_pixel counted draws whose
own-pixel slot no snapshot serves without saying why: its one logged reason
lumps a branch, a sample, a derivative, a store and a function that writes
memory. On the guest compositor's 780M walk it is 23,031 draws (23,463
before f922125bb1's demote guard), so the guard served another shape, and
which clause refuses decides the next step. Counts and interface facts
only; which slots qualify is unchanged.
Translator: spirv::requirements::snapshot keeps one reach mask per clause
and states each slot left out with every clause that holds for it
(StageInterface::snapshot_refusals, StageModule::snapshot_refusals, the new
public pipeline::SnapshotRefusal): Branch, Derivative, Sample,
GroupOperation, Store, Atomic, ImageWrite, UndefinedOperand, WritesMemory,
Interlock, Coherent, Other (a slot past 127, values that do not settle, a
ray query, a mesh output count, an unmatched call, the entry's returned
value). The walk now runs also in a function that writes memory or a module
with an interlock or coherent resource, so such a slot is stated with the
per-value clauses too; its slots stay left out as before. A snapshot variant
judges none. ARTIFACT_FORMAT_VERSION 494 (two encoded fields, one enum),
SEMANTICS_VERSION 1996 (a new interface fact).
Runtime: a draw split for UnreadableOwnPixel is counted once under each
clause that leaves out any of its unreadable attached slots
(WorkCounts::reading_draws_split_unreadable_own_pixel_{branch, derivative,
sample, group_operation, store, atomic, image_write, undefined_operand,
writes_memory, interlock, coherent, other}), and the log names the clauses,
once a device per set.
Tests:
- spirv::requirements::snapshot::tests::only_values_no_helper_can_pass_on_qualify:
every sink states its one clause, with new sinks for a quad swap, a
storage-buffer store, an atomic, an image write and a coherent image.
- spirv::requirements::snapshot::tests::a_slot_left_out_by_the_function_or_its_index_says_so:
WritesMemory alone and beside a derivative; slot 200 Other beside slot 0
qualifying.
- pipeline::compile::tests::the_interface_states_why_a_slot_takes_no_snapshot:
owned fixture sd_read_discarding on the 780M's profile states none, and
Branch alone with shaderDemoteToHelperInvocation withheld; tob_read none;
the render pipeline's fragment stage the same.
- runtime_lane::snapshot_reads::a_reader_that_ends_itself_by_its_texel_takes_the_split_for_its_branch
(device): the discarding reader with demote withheld: 3 * FILL, two
splits, two unreadable own-pixel splits, both under branch alone.
api_signatures blessed (26 records); api_surface row for SnapshotRefusal;
docs/API.md's snapshot reads name snapshot_refusals.
(cherry picked from commit 4412816cc23ede42b266ad4d2c62465711853d83)
|
||
|
|
733108b25d |
fresh_contents: the Depth32Float rows' zeroed-pattern declarations are held by the row test
The family's declaration test held every allowance to the notices site or the fresh value declaration, so the two Depth32Float rows' unchecked fresh site under fresh-pattern-zeroed (55df5fa64b) failed it. The test now names that declaration, counts the texture row's three extra allowances and the pattern row's two, and checks no other row carries it. docs/CONFORMANCE-COVERAGE.md is regenerated (python3 -I scripts/conformance-coverage/coverage.py): fresh_contents now loosens one measured value. Verified: both failed in the conformance suite on gem10 (job 10312); the rerun follows. (cherry picked from commit 184d622fa578658947c19dd19df29ff160a91b9b) |
||
|
|
12f7267750 |
Depth comparisons record RestrictedDepthRange on every device without VK_EXT_depth_range_unrestricted, MoltenVK included
Without the extension Vulkan gives a depth image no value outside [0, 1]: a copy may take none (VUID-vkCmdCopyBufferToImage-pRegions-07931), and a render write is clamped to the viewport's depth range. MoltenVK's driver was measured to keep such values (DriverFact::DepthImageKeepsValuesOutsideUnitRange), and its depth comparisons required that property in place of the note; the owner's rule is never to rely on undocumented Vulkan behaviour, so the fact follows the extension and nothing else. With the extension a comparison records nothing already, so the fact, the VkProperty::DepthImageKeepsValuesOutsideUnitRange it derived and the texture plan's kept_depth_range are removed: depth_comparison records RestrictedDepthRange wherever the extension is not enabled (ANV, RADV, MoltenVK), a precision note, logged and never fatal. SEMANTICS_VERSION 1995: MoltenVK's comparing stages record the note and no longer require the property. The codec drops the variant by name (no format bump: a removed variant's tag stays unused). docs/API.md's restricted-depth-range entry, FAST-PATHS rows 79 and 80, the note's and the measurement table's docs, engine_depth_range's test (the note on MoltenVK too, no module requiring the extension), driver_facts' MoltenVK row and api_signatures (three variants) follow. The compare-clamp lane predicts restricted-depth-range by the extension alone again. Verification follows in the lane jobs; the golden tables and the authored compile census are re-blessed on development. (cherry picked from commit 90d231de945294c8428c05f79946f09bbb426819) |
||
|
|
afb53192f7 |
Depth uploads clamp on every device without VK_EXT_depth_range_unrestricted, MoltenVK included
Vulkan takes no copied depth outside [0, 1] without the extension (VUID-vkCmdCopyBufferToImage-pRegions-07931), and a driver measured to keep one (DriverFact::DepthImageKeepsValuesOutsideUnitRange, MoltenVK's) does not make the copy valid: the owner's rule is never to rely on undocumented Vulkan behaviour. MoltenVK 1.4.2 does not expose the extension, so ImageFacts::depth_clamps is now the extension's absence alone: MoltenVK's uploads (replace_region, blits from buffers, copies from colour textures, a heap's tiled copy in) clamp as ANV's do and announce restricted-depth-upload. The fact stays for the translator's depth comparisons (lower/texture/slot.rs depth_comparison, through VkProperty::DepthImageKeepsValuesOutsideUnitRange) and for the validation executor's own raw copies (candidate/platform/compute.rs). The lanes follow the rule (degrade_notices::clamps_depth_uploads, the heap lanes, texture_blits::depth_images_keep_what_their_drivers_claim, which checks the clamp where the device lacks the extension, and buffer_depth_samples). The combined-format blit lane counts apart the GPU-assisted check's reports at offsets off a depth's 4 bytes: layer 1.4.363 reads a D32_SFLOAT_S8_UINT depth aspect's buffer at 5 bytes a texel, where the spec lays it out as D32_SFLOAT's. Verification: Iris, lavapipe and the M3 lanes follow in their jobs. (cherry picked from commit 6dfbc9c0dd0b4b3690ce2824d16fb561afc51047) |
||
|
|
460a608d1b |
Depth uploads clamp into [0, 1] on devices that take no other: replace_region, blits from buffers, copies from colour textures
On a device without VK_EXT_depth_range_unrestricted whose driver is not measured to keep a depth outside [0, 1] (ImageFacts::depth_clamps, ANV on the Iris Xe), a copy into a D32_SFLOAT or D32_SFLOAT_S8_UINT depth plane took Metal's bytes as they are, which breaks VUID-vkCmdCopyBufferToImage-pRegions-07931 for any value outside [0, 1]. The heap's tiled copy-in already clamped (TiledLevelMove:: clamps_depth); every other upload now goes through the same clamp, on the bits: a NaN of either sign 1.0, -0.0 kept, other negatives 0, above 1.0 (+inf too) 1.0, the rest as they are, no denormal flushed. - Translator: bind::clamped_depth (the CPU rule) and bind::depth_clamp_module (DepthClampModule), an in-place clamp over a buffer's words in the extended-canonical kernel's shape (first, width, row and image pitches). The tiled kernel's clamp now shares the module's SPIR-V helper. - Runtime, depth_clamp.rs: clamps_depth (one test of format, aspect and device facts, which heap_tiled now uses too), the CPU clamp of packed bytes, and BlitCommandEncoder::clamp_depths / clamped_depth_copies: one dispatch a region (split into images or rows past the device's storage range or workgroup counts), each its own command so the tracker orders it between the copies. - replace_region clamps the packed bytes on the CPU before any route (a host copy, the staging queue, a submission), so no depth image holds a value outside [0, 1] that a later copy of its texels moves on. - A blit from a buffer into such a depth copies the regions' bytes into a scratch buffer, clamps them and copies from there; a plan that stages its rows clamps its staging buffer in place; a copy from a colour texture through the encoder's scratch clamps the scratch before the copy into the depth. - WorkCounts::depth_uploads_clamped counts each clamp. - restricted-depth-upload stays announced where it was; its doc, the replace_region message, docs/API.md, the blit and replace_region docs and the FAST-PATHS device-gap row say the upload clamps. - MoltenVK (DepthImageKeepsValuesOutsideUnitRange) and devices with the extension are untouched. Lanes, runtime_lane::depth_upload_clamps, under the validation layer's GPU-assisted buffer-copy check: replace_region, a blit from a buffer (as it is, through its plan's staging at an offset of 2, and into Depth32Float_Stencil8's depth) and a copy from an R32Float texture, each checking no VUID-07931, the clamp counted, and each texel read back clamped (or as written where the device keeps it). The heap lane now shares the lanes' device and message checks. Unit tests: the clamp rule, the kernel under the interpreter, the region splitting, the CPU clamp. api_signatures blessed (+16), api_surface table updated; REFUSALS.md unchanged on regeneration. Verified: not yet (Iris, lavapipe and Linux clippy are queued). (cherry picked from commit a63c3646dd5e3fad8b24e387c4adb0f94d635ac9) |
||
|
|
85465062e2 |
HOWTO section 7: where a texture over an exported frame's plane lies in place
Names the rule the runtime applies to each plane's linear image (the plain one first, else DRM_FORMAT_MOD_LINEAR), made for the export's handle type: the image format query takes that handle type, not in a dedicated allocation alone; the plane's byte in the memory is a multiple of vkGetImageMemoryRequirements' alignment; vkGetImageSubresourceLayout answers offset 0 and the plane's row pitch, its size fitting; and the device's in-place check of that exported memory passed. The shadow's causes otherwise, and the measured alignments for a 3840x2160 NV12 frame: 64 on lavapipe (m3-max-10165), 256 on the RX 550 under RADV with opaque descriptors (m3-max-10151), whose dma-buf planes are shadows. (cherry picked from commit 15affc37f6910f8ea7bababe1bcb5c69d5ae7d5c) |
||
|
|
098eec639b |
API.md: when a texture over exported memory is a shadow
The shadowed-texture list in section 10 gains the exported-memory causes the handle-type fix introduced: the check of that exported memory not passed (pending ones move in place), the image format query refusing the handle type but in a dedicated allocation, and a buffer's dedicated allocation. (cherry picked from commit cd993135eca08d877b7b55a3c0570df86df7510f) |
||
|
|
99453e91d8 |
Images bound over exported memory name its handle type; a check class per export handle
A texture over an exportable buffer (exported_memory.rs) was a PREINITIALIZED linear
image, or a DRM_FORMAT_MOD_LINEAR one, with no VkExternalMemoryImageCreateInfo, bound in
memory allocated with VkExportMemoryAllocateInfo: VUID-vkBindImageMemory-memory-02728
("it must include at least one of the handles set in
VkExternalMemoryImageCreateInfo::handleTypes"). RADV and NVIDIA tolerate it; the layer
does not.
What changed:
- memory.rs: Memory::bound_memory reads a placement's own record (the block's export,
import, own pages or read-only view, a guest RAM chunk's handle, a dma-buf import) and
answers the handle type an image bound there names: none for memory of no export, the
export's handle for a shared exported block, HOST_ALLOCATION or DMA_BUF for imports, and
no image for a buffer's dedicated allocation (VUID-vkBindImageMemory-memory-10926) or the
caller's memory. Buffer::bound_memory answers it for a buffer (a heap buffer's, its heap's).
- texture.rs alias_unbound decides the image from that record, not the route: over exported
memory the device's linear image made for the handle type (external_linear_image, the
former host_linear_image generalized), else the DRM_FORMAT_MOD_LINEAR one made for it
(ModifierMemory::Exported). Either is made UNDEFINED (VUID-VkImageCreateInfo-pNext-01443),
so its first move may discard the bytes, which only the device's check may vouch for.
- in_place.rs: two check classes, PagesClass::ExportedFd and ExportedDmaBuf. Their buffer
is an exportable Shared buffer of that handle type in a shared block; their textures take
the product's image. A texture over exported memory takes its image where the policy and
those verdicts pass for its accesses; before them it is a CheckPending shadow that moves
in place at the next quiet commit, as over the pooled memory (storage_form.rs now moves
any class over the runtime's own memory). No LinearCost bound there: another API writes
those bytes.
- The image format query (VkPhysicalDeviceExternalImageFormatInfo) must answer the handle
type exportable (importable for imports) without DEDICATED_ONLY, for the linear and the
DRM_FORMAT_MOD_LINEAR image alike; else the texture is a shadow, its notice naming the
query's refusal. A dedicated allocation keeps the shadow, its notice naming 10926.
- ycbcr_planes.rs: the two-plane image is PREINITIALIZED with no handle type, so it takes
only memory whose record says no export or import (KeptTexels::Memory elsewhere).
- in_place::CHECK_VERSION 12 -> 13: the record holds two more classes, so every driver's
check runs once more.
Checked and unchanged: heap.rs's images (heaps are never exported; over host pages they are
HOST_ALLOCATION images, over a copy in device memory a shadow or an Own linear image), the
in-place images over host pages and copies (HOST_ALLOCATION over imports, Own over device
copies), and the runtime's own images in Holds::Images/Buffers blocks.
The placement rule (in_place.rs, "The runtime's exported memory"): per texture (per plane),
the texels' offset in the memory (the buffer's first byte, or its aligned_byte, at a
multiple of 256 there, plus the texture's offset) must be a multiple of
VkMemoryRequirements::alignment from vkGetImageMemoryRequirements for the image made for the
handle type of the texture's format, extent and usage; vkGetImageSubresourceLayout of its
first subresource must answer offset 0 and Metal's rowPitch; its size must stay inside the
buffer. The linear image first, then the DRM_FORMAT_MOD_LINEAR one with its own alignment.
Test: tests/exported_textures.rs, an NV12 picture's R8 3840x2160 and RG8 1920x1080 planes at
32 and 8294432 of an exportable buffer laid with aligned_byte(32), opaque fd and dma-buf,
Private and Shared, under the validation layer: a shadow first, both moved in place after
settle_in_place_checks, readback equal, in place at once after, no layer message.
dma_buf_export settles the checks before its plane textures. Not yet run: this commit is
for the build and the device runs.
(cherry picked from commit 40872fbb4748cbd228c06c27dc0cd63ca2d0a5ec)
|
||
|
|
3f69d1af77 |
No-copy buffers and heaps whose pointer the device refuses, with no dma-buf source, are copies
On RADV (amdgpu userptr takes anonymous private pages only) a no-copy buffer over shared memory, a memfd mapping among it (QEMU's memory-backend-memfd,share=on guest RAM), made with no source of dma-bufs of its pages, was refused (Unsupported, HostMemory), where Metal makes a no-copy buffer over any page. Device::buffer_over_host_memory now makes it over a copy of the pages instead (copied.rs), announced (copied-host-pages, its detail naming the device's refusal) and counted (WorkCounts::copied_host_buffers_device_refused, of copied_host_buffers_made). A no-copy heap's own buffer takes the same path. The import with a source is unchanged: the source is still called first, and a copy follows its failure only as before. A rebind to such memory without a source is still refused (its own import path), as HOWTO section 6 now says. Docs: the runtime README, HOWTO sections 6 and Copied host buffers, HostMemory::new, Device::imports_shared_host_pointers, the copied-host-pages catalogue entry and copied.rs's opening. docs/REFUSALS.md regenerated (unchanged: the refusal stays where pages cannot be read). Test: tests::copied_device::copied_buffer_is_made_over_shared_memory_whose_pointer_the_device_refuses (Linux): where the device refuses shared memory's pointer, the buffer is a copy, announced and counted as the device's refusal, with every copy's coherence; elsewhere an import. (cherry picked from commit 0e07fff15b79cf0fdcf4f09a2836c7075db266a3) |
||
|
|
ee3f269fa3 |
Heap depth textures: the copy in clamps a 32-bit float depth into [0, 1] where the device takes no other
A heap's 32-bit float depth texture whose shadow copies the heap's bytes into its image went through vkCmdCopyBufferToImage with whatever float the bytes held. On a device without VK_EXT_depth_range_unrestricted that is invalid usage for a value outside [0, 1] (VUID-vkCmdCopyBufferToImage-pRegions-07931); ANV stored it clamped, and the runtime only announced it (restricted-depth-upload). The tiled texel kernel (metal2vulkan::bind) now clamps a level's elements on the way into the tight buffer where the level says so: - TiledLevelMove::clamps_depth, set with TiledLevelMove::clamping_depth; - the shape's level record grows to 14 words; - the clamp compares the word's bits, so no denormal is flushed: a negative value becomes 0.0, one above 1.0 (and +inf) becomes 1.0, a NaN of either sign becomes 1.0 (as nan_clear.rs clears a NaN depth), and -0.0 and every value inside [0, 1] keep their bits; - the move back is unchanged. HeapTiledCopies::new takes the image's format and marks the 4-byte depth planes' levels of a D32_SFLOAT or D32_SFLOAT_S8_UINT image where ImageFacts::depth_clamps holds: exactly where restricted-depth-upload is announced. MoltenVK, whose driver is measured to keep such values (DriverFact::DepthImageKeepsValuesOutsideUnitRange), keeps its copies as they were. The clamp is the device's own answer, so the notice stays and its text now says the copy in clamps. Tests: - bind::tiled_texels::tests::clamped_depths_move_into_the_image_inside_0_1, run through the CPU interpreter; - lane heap_textures::a_heap_depth_texture_s_copy_in_takes_no_depth_outside_0_1, which turns on the layer's GPU-assisted buffer-copy check (gpuav_buffer_copies), asserts no VUID-07931 message, and checks a blit reads the clamped values where the device clamps, else the bytes as they are. Docs: - the restricted-depth-upload declaration, docs/API.md's catalogue and its docs/FAST-PATHS.md device-gap row say the copy in clamps; - docs/FAST-PATHS.md's known gaps gain one entry: a heap texture Metal keeps uncompressed lies in its driver's layout where its image fits Metal's answer (heap-texture-untiled-layout); - api_signatures.tsv is blessed for the two new public items. Verification in the tip report. (cherry picked from commit de683c02ce08d337e8281dd752c2519f863bbe39) |
||
|
|
ddb5440aad |
An exported buffer's announced external write lets go of its shadows' standings
A texture over an exportable Private buffer whose rows no image holds (a decoder's pitch) reads it
through a shadow, and a shadow over a tracked Private buffer the runtime made stands across
command buffers (shadow_standing.rs): a later command buffer's first copy in moves nothing while
no batch wrote the buffer or the image. Another API's writes through an import of the buffer's
memory are no batch's, and Buffer::external_write_done only noted the acquire, so once such a
texture had copied in, every later external write was missed: each of reims' NVDEC pool
surfaces on the 5080 kept showing its first picture.
external_write_done now counts a write of the buffer's key against every standing recorded on
it (Standings::written_apart, LetGo::TruthWritten), so the next command buffer's first copy in of
each shadow over the bytes moves what the other API wrote. Standings stay otherwise: the
contract already says the device reads another API's writes only once the caller announces them
("What the other API writes there is the device's to read once the caller says so", "Call it
once after each of the other API's writes"), so a write made without the call keeps no new claim
on a standing, and an exported buffer's shadows keep standing between announced writes (one
copy in per write, not one per command buffer). The runtime README, HOWTO and the module docs say
what the call does for a texture's shadow.
tests::exported_memory::a_shadow_over_an_exported_buffer_reads_each_announced_write: a second
VkDevice fills the buffer through an import of its opaque descriptor (released to
VK_QUEUE_FAMILY_EXTERNAL), three values in turn, each followed by external_write_done and two
reads of a padded-row texture through a kernel: the first must read the write and copy in, the
second must read it again with the image standing.
Verification: to follow (clippy x3, the lane and the standing tests on lavapipe and the 780M, a
negative control without the let-go).
(cherry picked from commit 542237e45fe706a39d5cd9e39f861f792c4c2996)
|
||
|
|
0cadcbae8c |
Copies over RAM the device refuses always stage through the CPU; its chunks are not faulted in
On a device that refuses pointers to shared memory (RADV) and a RAM of shared memory with no dma-buf source, a gather was staged through the CPU while the device's thread had not yet tried the chunk. Once the thread's import was refused (`tried`), the same gather went to CopyTake::Waits, imported the chunk itself and was refused as Unsupported(HostMemory). So a copy Metal takes succeeded or failed depending on when it came. The first-fill bench's steady fills failed so on a Radeon 780M. A gather after a staged scatter into the chunk was refused the same way: the scatter set `scattered`, so written_over kept the gather off the CPU's path. And the thread faulted each 64 MiB chunk in before an import the device refuses whatever the pages hold. Now the plan records the refusal (Plan::shared_refused: no source, a range of shared memory, and the device answers imports_shared_host_pointers false, asked once at the use). Each chunk of shared memory under it is ChunkSlot::refused, known from the use on. copy_take answers ThroughCpu for a refused chunk whether or not the thread ran or tried it. written_over ignores a copy's write into a refused chunk, which only a staged scatter's CPU drain makes, in a host step before any later copy's. import_ahead faults no refused chunk in (it still tries the import, which is refused at once). Chunks it does fault in are counted: WorkCounts::host_ram_chunks_faulted_ahead. Tests: - copies_over_shared_ram_move_their_bytes_after_the_thread_reached_its_chunk: gather, scatter, gather over a shared memfd RAM after the thread reached its chunk. On a refusing device all three stage and move the right bytes. - the_ahead_thread_faults_in_only_chunks_the_device_may_import: 0 chunks faulted in where the device refuses, and at least the chunks imported ahead where it imports (Linux). (cherry picked from commit 590a07faf1468b162333f479a0f857aa71a353a3) |
||
|
|
4b277a28d1 |
A RAM's use, dropped, waits for its device thread: no page is read after it
The device's thread for a guest RAM (import_ahead, listed_chunks) upgraded the
RAM and faulted a chunk in by reading its pages (read_volatile, since
|
||
|
|
8b664a27a2 |
Shadow log names every shadow a texture makes; never-stood copies in split by what kept the end from standing
The walk's unskipped copies in are all of a 3648x2038 surface that never
stood, and the shadow log, which named only a texture over a buffer's bytes,
never named it. Two instruments to find out which shadow it is and why no
command buffer's end leaves it standing:
- METAL2VULKAN_LOG_SHADOWS now names each shadow a device makes of a
texture: a usage shadow (a binding beyond its usage, an attached read, a
YCbCr texture's writes), with what the texture's own image is (an aliasing
image over the bytes with or without the feedback loop usage, a shadow, or
an image of its own); a rotated texture's image of its stored frame and its
twin; a two-plane extended-range texture's image; a depth or stencil
texture's tiled twin over a surface plane; and a YCbCr texture's converted
image and render shadow. A line's truth is the buffer's bytes or the
texture's own image.
- WorkCounts::shadow_texels_never_stood_{unmet, not_current, dropped,
partial, end} split shadow_texels_unskipped_never_stood by what last kept a
command buffer's end from leaving the image standing
(shadow_standing::Missed): no end met it, an encoder ended with its image
not holding the truth, what the command buffer carried let it go, the end
held it in part or stale, or the end records no standing. Each shadow that
may stand keeps the last one; off the counts it changes nothing.
Verified: cargo fmt only so far; the checks run as a potluck job.
shadow_standing_device now asserts the five sum to never_stood and that a
first read's never-stood texels are all unmet.
(cherry picked from commit 1dd2a2ee2b9c39a2ba7aaeea3e3ad7906fd035f9)
|
||
|
|
dae9923446 |
Heap refit docs: which textures an image in place serves, and what the shadows of Metal's tiles cost
HeapTextureHostTransfer and HeapTextureLinear (and docs/API.md's catalogue) say the refit takes an image of host-transfer usage only for a texture Metal compresses or whose layout is not modelled, and of one Metal keeps uncompressed only a linear image whose every element lies where Metal's tiles place it. docs/FAST-PATHS.md's costs record the shadow of Metal's tiles kept for every other such texture, with the 1x1 shadow's GPU time measured on the Iris Xe at RUNTIME_VERSION 1909 (35.9 us against 8.1 us a frame); the compositor's 3x3 to 10x10 shapes are not measured apart. (cherry picked from commit dc30f3c6c8768ab3780bad861bba9db1ad9f4b84) |
||
|
|
ec94c62dce |
heap depth textures: a merge's keep holds the heap's bytes, not the image's
A 2-slice Depth32Float 64x64 x2 multisample texture in a Shared placement heap on ANV (Iris Xe, RPL-P, Mesa 26.2.6) lost the samples a blit wrote into one slice: 16384 of 16384 were off Metal's tiles after the merge back, while a read straight from the image matched. The heap's bytes held 0xee before the blit. The copy in hands the image 0xeeeeeeee, a float outside [0, 1], which Vulkan leaves undefined in a depth image without VK_EXT_depth_range_unrestricted, and ANV stores 0.0. The merge's keep was moved out of the image (only drivers announced drawn-depth-copy kept the heap's bytes), so it held 0.0, and the merge kept the heap's 0xee in every byte of a written sample that equals 0.0's: a probe found 9155 0xee bytes left in the slice, the 9134 zero bytes of the samples plus 21 sample bytes that are 0xee, and no sample whole. Now a heap's tiled texture with a depth aspect, of any sample count, keeps the heap's bytes: the staging buffer its copy in filled where the keep follows it (WorkCounts::shadow_keeps_from_staging), else the heap's bytes themselves, and plans no moves out of the image for the keep. Every byte a command wrote is merged whatever the copy in changed; a value the copy in changed in a texel no command wrote is written back as stored, as a copy back writes it. That clamp is the device's: a heap's 32-bit float depth texture whose shadow copies the heap's bytes into its image now announces restricted-depth-upload as it is made, on a device without VK_EXT_depth_range_unrestricted whose driver is not measured to keep such a value (ANV; not MoltenVK, NVIDIA or lavapipe with the extension). Its declaration, docs/API.md's catalogue and a device-gap row in docs/FAST-PATHS.md say so. The measured drawn-depth-copy flag a multisample texture held for its keep is gone with its one reader; the announcement at making stays. heap_multisample_textures_keep_their_samples_in_metal_s_tiles now also checks, for each counted 32-bit float depth texture, restricted-depth-upload as it is made where the device clamps, and that a blit into one slice or aspect keeps from staging. Verification in the tip report. (cherry picked from commit 688e1dcc00ff67979833fdcbaf2f5484057e18a6) |
||
|
|
e106dbf2c7 |
FAST-PATHS: the 780M's later clips at one budget for its heaps made no allocation and took 122 and 119 ms
m3-max-9499 at 9bc836c2e9 on um790's Radeon 780M alone (RADV PHOENIX, MESA_VK_DEVICE_SELECT 1002:15bf!): tests::clip_bursts' later clips made 0 and 0 allocations (16 in the first) in 121.5 and 119.2 ms, against 4 each and 237/245 ms with the placements in the system heap and a budget per heap, and 132/126 ms with them device-local. The bullet said the unified budget keeps every block; it now carries the measurement. (cherry picked from commit f2e2063f1ff7050d7eeefd6ecdc26ace0c4bc29c) |
||
|
|
6be762136b |
Memory: with unified memory the heaps keep one budget of empty blocks
With the UMA placement, a Radeon 780M's Private placements take its 5.53 GiB system heap, whose eighth (707 MiB) kept all but 3 of a video clip's 16 blocks: each later clip made 4 again (tests::clip_bursts, m3-max-9454: [4, 4]) and took 237/245 ms to make against 132/126 ms with the placements device-local (m3-max-9448). With unified memory every heap is the same memory: the budget is now an eighth of all the heaps, at most KEPT_EMPTY_BYTES, and the empty blocks of every heap count against it, so the 780M keeps 2 GiB as one budget where it kept 707 MiB and 1414 MiB apart (2.1 GiB in all). Devices without unified memory keep a budget per heap as before. Tests: tests::memory::unified_memory_keeps_one_budget_for_its_heaps (the 780M's heaps, a discrete card's, one heap). FAST-PATHS: the kept-memory row's 780M figures, and the UMA row's clip-burst cost. Verified: not yet run; lavapipe and the 780M follow as potluck jobs. (cherry picked from commit 9bc836c2e9cac4b43b86380e4c53ee3a02133214) |
||
|
|
40a634d351 |
FAST-PATHS: unified memory's Private placements in the system heap first, and what they cost
The 780M runs before and after the placement (m3-max-9103 at the base, m3-max-9157 at the change, um790, RADV PHOENIX): copies of 256 MiB at 23.9/28.8 GB/s device-local against 28.5/29.0 GB/s in the system heap's type; a 259-tile scroll beside 1 GiB of another allocation's local memory at median frames 1.31/1.29 ms before and 1.87/1.30 ms after (frames 300 and 600), alone 2.87/4.87 ms before and 1.33/1.31 ms after; no amdgpu_bo_move eviction traced in either. Recorded under the costs of matching Metal: no cost measured, no switch, not announced. (cherry picked from commit 3d1f49072ca66c9976835da4df54773f50a7f283) |
||
|
|
80b581bee2 |
Dma-buf export: README, HOWTO, the API table and REFUSALS.md
The runtime README lists exported_as, export_memory_dma_buf and external_write_done beside the opaque-fd export; HOWTO gains a section on memory another API writes (a decoder's DRM_PRIME_2 frame), the old section 7 now 8. The API signatures table is re-blessed for MemoryExport, BufferDescriptor::exported_as, with_exported_as, the two Buffer calls, Problem::ExportedNoCopy and RuntimeGap::DmaBufExport, and REFUSALS.md is regenerated with the new gap's reach (none: a runtime extension). (cherry picked from commit 3988f9ec5921e8962708ce7735937c44836361a1) |
||
|
|
259be5d3c5 |
host RAM: fault in a VMM's shared memory by reads, not under the memory map lock
What: the import-ahead thread's fault_in now reads each page of a chunk where every mapping over it is shared memory of base pages (a memfd, as QEMU maps a guest's RAM), as PROCMAP_QUERY answers (vma_flags SHARED, vma_page_size the host's page). A read fault on such a mapping allocates the page and maps it writable, changing no byte, and since Linux 6.7 runs under the mapping's own lock, so it holds no mmap_lock. Private memory, hugetlbfs (whose fault past its pool is SIGBUS) and kernels without PROCMAP_QUERY (before 6.11) keep MADV_POPULATE_WRITE in 2 MiB steps. host_memory.rs's PROCMAP_QUERY call is factored into mapping_at, shared by queried_permitted and the new shared_base_pages. Why: in a consumer's guest boot on the RTX 5080 laptop, seven slow pipeline compiles had no thread in an NVIDIA ioctl; their threads sat in an mmap_lock convoy (vCPUs in get_user_pages, mprotect from heap growth, mmap/munmap in D), and the one kernel-stack dump that caught the reader found m2v-host-ram in MADV_POPULATE_WRITE. MADV_POPULATE holds mmap_lock read for each 2 MiB step, which under reclaim and compaction takes milliseconds, and a waiting writer queues every later reader behind it. How verified so far: a C probe on um870 (Linux 7.3.1, 4 GiB memfd under MADV_HUGEPAGE, a thread calling mprotect every 0.2 ms, two mapping, touching and unmapping 4 MiB every 0.5 ms): populate in 2 MiB steps took 202-541 ms with the longest mprotect 4.8-10.1 ms (four runs); per-page reads took 239-247 ms with the longest mprotect 0.40-0.52 ms (two runs), and the write pass after them faulted no page en masse. New unit tests: the choice of way (shared memfd by reads, private and a span over both by the advice), and that a fault-in by reads leaves every page resident, writable (a write pass faults nothing) and every byte unchanged. cargo fmt only; clippy, the tests and the 5080 before/after run follow as potluck jobs. (cherry picked from commit e571995af620272b12bb3083a5c59fbf8b844e39) |
||
|
|
7fbbac9536 |
Heap textures: an image that fits Metal's answer lies in place before a shadow
A single-sample colour heap texture whose image of the route the device first took (ANV's compressed optimal image under the default HeapCompressionPolicy, say) takes more bytes or a coarser alignment of the heap than Metal's answer was a shadow of the heap's bytes in Metal's tiles, copied in before each command buffer's first use and back after each writing encoder. The owner's rule keeps a shadow as a correctness fallback only: where the device makes an image that fits the answer in the heap's memory, the texture now lies there in place, its optimal image of host-transfer usage first, else its linear image (Device::fitting_heap_image), announced heap-texture-host-transfer or heap-texture-linear with the making's facts and what the first image took. Unverified: built and measured on ms01's Iris Xe in the commits that follow. (cherry picked from commit c1a996cd53f74d0afa130dd867ab42499c2b758f) |
||
|
|
6ef13920d0 |
Shadow causes for a walk: why a private truth's first copy in moved, and a log of each shadow made
The 780M's glass composites copy large Private IOSurface planes in each command buffer: walk 9286 counted 41.07 M texels first copied in per composite, 37.70 M of them over images an earlier command buffer left standing, yet only 3 copies in a composite were decided against a standing (2 skipped) of 84 shadow copies. No count said where the rest were decided, nor why each shadow over those planes takes no image over the bytes. - WorkCounts::shadow_texels_unskipped_*: every encoder's first copy in of a Private (or Memoryless) buffer's bytes, an IOSurface plane's among them, that moved its texels, by where it was decided (shadow_standing::Unskipped): unstanding (its shadow never stands: untracked, a heap's, the caller's memory, its VkBuffer handed out, writes dropped), between_instances (a held render pass's copies between its instances, inline_splits, which no submission decides), after_encoder_writes, recorded_whole (predicated laying, no new VkCommandBuffer), command_buffer (at submission: its command buffer reaches unnamed memory or an earlier encoder wrote the truth or image), let_go (at submission: the standing let go). With shadow_texels_skipped_by_standing they sum to shadow_texels_first_copied_in_private_buffers + _private_surfaces. And, but for unstanding, by what the standing held then (shadow_standing:: LetGo, Standings::let_go): stood, never_stood, unnamed_since, truth_written, image_written; for those decided as the encoder records them, by the batches submitted so far. - METAL2VULKAN_LOG_SHADOWS (default-off diagnostic, shadow_log.rs): one line per shadow a device makes of a texture over a buffer's bytes: the call (new_texture_with_iosurface_plane for a plane's), format, size, levels, usage, the buffer's storage mode, length and object ID, the texels' offset and row pitch, and the reason its shadowed-texture notice gives (announced once a device). Two textures over the same bytes name the same object ID and offset. - Standings::stands is folded into let_go; submit.rs's gate answers where it was decided. - Tests: shadow_standing_device checks both sums in every leg, and the first read's copy in is let_go/never_stood, the read after another queue's fill let_go/truth_written, a read after its own command buffer's fill command_buffer, a read once the VkBuffer was handed out unstanding. - Docs: shadow_standing.rs, WorkCounts, docs/API.md (the log), env_vars REGISTRY; the artifact test's note on the variables the runtime reads. api_signatures blessed. No behaviour changes: counts and a default-off log only. RUNTIME_VERSION not bumped (main's). Verified: cargo fmt; builds and tests run as potluck jobs after this commit. (cherry picked from commit a82491daf4a24ad57845c6e0f62bd53946dc22f8) |
||
|
|
8e1383b1b6 |
In-place check: an unchecked verdict whose cause lasts is kept; one that may pass is checked again
The previous commit kept every unchecked verdict out of the record, so a driver that truly lacks what a class needs (an extension, a feature, an import, a format or an image of the shape, such as lavapipe's DmaBuf and Pooled rows-in-lines, which RuntimeDriverDefect:: ExplicitPlaneRowsPastHeight refuses) would be checked again by every device. Such a cause is fixed for the driver's identity, as stable as a passed or failed verdict, so it is kept; only an unchecked verdict from a cause that can change between runs is kept unmeasured and checked again. - in_place_check::Unmade: the reason the check made no pages, pass or image, and whether its cause lasts. ClassPages::make, ExportedPages::make and Round::NotMade carry it. Lasting: no host import (VK_EXT_external_memory_host), no dma-buf images, export only as a dedicated allocation, no host-visible coherent type, no DRM_FORMAT_MOD_LINEAR images, and a placement answer the image's making decides before it binds (Refused Rows, Image, Pitch, Placement, DmaBuf; another route of the shape), and an error that is the device's gap or Metal's refusal (Error::Unsupported, Error::Invalid). May pass: pages, memory or mappings not made, an export failing, a no-copy buffer copied or imported otherwise on a device that imports host memory, an answer in place that only the bind refused (the dma-buf's import), detached or sourceless pages, the writer thread not started, a first move, pass or kernel's stores failing, the kernel's buffers refused, any other error (out of memory, a lost device, a Vulkan failure, the runtime's own gap). - check_class answers, by row ends, whether an unchecked verdict met a cause that may pass; run writes those verdicts pending in the record and the rest as given. encode writes the verdicts as given; decode reads every verdict byte (unchecked among them). - Notes say which cause it was, "(a cause that lasts, kept)" or "(a cause that may pass, checked again)": the first of each kind per class and access. - CHECK_VERSION stays 12 (the bump the previous commit made, not landed): a record of 11 may hold unchecked verdicts whose cause may pass, which no device takes now. - Tests: an_unchecked_verdict_is_checked_again_where_its_cause_may_pass_and_kept_where_it_lasts (device test, replacing the previous one: the pointer class's failed import is noted as a cause that may pass and checked again by the next device; every measured verdict is recalled, each unchecked one recalled unchecked or checked again; on a driver with ExplicitPlaneRowsPastHeight the DmaBuf reads of rows inside lines are recalled unchecked). The record round trip holds passed, failed, unchecked and pending verdicts. The in-place textures lane's record test takes measured <= recalled <= VERDICTS. narrow_writes_device and freed_memory read only the report's verdict lines, not the notes after them (20 narrow lines counted where 16 were due on lavapipe, job 9303). - Docs: in_place.rs, in_place_check.rs, WorkCounts::in_place_checks_recalled, settle_in_place_checks, docs/API.md, docs/FAST-PATHS.md (the in-place row). Verified: cargo fmt; builds and tests run as potluck jobs after this commit. (cherry picked from commit b420f97f56237fc0bf153691e9ac7e5a8e923386) |
||
|
|
aa188702ad |
In-place check: an unchecked verdict is no measurement, kept unmeasured and checked again
On the Iris Xe (ANV) reims' arm-s boots made 890 shadows over guest RAM imported as dma-bufs,
every one "the device's check made no image over host pages imported as dma-bufs" (Unchecked),
small ShaderRead textures at offset 0 on whole pages among them, where a fresh check of the
same driver passes the class's reads (
|
||
|
|
a3fb1283e6 |
FAST-PATHS: the first clip's allocations stay open, with their cause and why no block is made ahead
(cherry picked from commit 4d2833ae3d662006101e3be98bfba4c7da58603e) |
||
|
|
186d327fe7 |
Memory: kept blocks past their quiet period go within a second at the next creation call; FAST-PATHS records the kept memory
A kept empty block was looked at only when a release came in its own pool, so a pool whose resources stopped coming and going kept its blocks, up to its heap's budget, until its next release. The device's creation calls (keep_room) now also free every pool's kept blocks past KEPT_EMPTY_FOR, at most once every KEPT_SWEEP_EVERY (1 s): the memory is held at most about 11 s past a working set's dip wherever the program still makes resources. docs/FAST-PATHS.md, known gaps: the NVIDIA memory block row, with the bound (an eighth of a heap, at most 2 GiB, 10 s), what it holds per device, why it has no switch (no answer of Metal's changes), and the RTX 5080 measurement of tests::clip_bursts (poolwait-burst, NVIDIA 615.71.09, two runs each): clips 2 and 3 took 41 and 40 allocations and 89 to 102 ms with 2 to 5 commits held 1 ms or more (longest 8.8 to 9.4 ms) before, none and 64 to 71 ms with no commit held (longest 0.39 to 0.67 ms) after; a first clip 44 allocations before, 16 after. Not yet built: the sweep builds and runs next on lavapipe. (cherry picked from commit b31e221ee4cfba1861320e8c674a01ea83614013) |
||
|
|
1c14b4b44a |
Staged gathers take their staging at their host step, not on the calling thread
A gather staged through the CPU (
|
||
|
|
0d65ab5579 |
Staged scatters: a first scatter into guest RAM makes no import or memory on the calling thread
A copy_to_host_ram over a chunk not yet imported used to import on the
encoding thread. With 16 ranges or fewer it imported those ranges alone
(each import about 2.3 ms on NVIDIA, its pages pinned). With more, it
imported the whole chunk or waited for its import. A clip switch's
block release (a device cache scattered to fresh guest pages) paid this
on the guest's command thread.
Such a scatter is now staged through the CPU, on devices whose thread
imports ahead (plans other than Plan::listed), as gathers are since
|
||
|
|
6f702cb76a |
docs/API.md: an exit mid-making, the difference left
What: the accepted differences' "Process exit" names what the exit hook's registrar leaves: a making on the program's own thread, which the exit does not wait for, and destructors the driver's compiler registered in the last 2 ms before the exit (or past the registrar's 16384 registrations), which can run beside the compile, where Metal compiles in another process. Why: the registrar (RUNTIME_VERSION 1899) closed the rest of exit_guard's hole for makings on the runtime's threads; what is still open is a consumer-visible difference, and one such exit (a consumer's making thread left running) ended its process with SIGSEGV inside NVIDIA's SPIR-V compiler on the RTX 5080. How verified: docs only; the figures are exit_guard's MAKING_INTERVAL and MAKING_REGISTRATIONS. (cherry picked from commit 5f1846a295017a2244fde27cdd2ed3db97bdb9cb) |
||
|
|
48cfac5cb3 |
HostRam lists kept: the docs say the lists outlive their copies, with same-host numbers
HOWTO, the runtime README and FAST-PATHS still said a copy's lists were freed with its command buffer and that every copy pays its lists' imports. They now say each list is kept past its copy for the copies of the same pages after it (at most 64 MiB and 16 lists, released once no copy took one for 2 s), and they give the numbers. The numbers come from tests/host_ram_listed_bench.rs on the Radeon 780M of one host (um790, RADV, kernel 7.3.1). The kept tip was run with a timing probe that never lands, then again with the bound sabotaged to (0, 0), which keeps nothing, back to back. Medians are commit to completion, then encode: - A 5 MiB device cache filled again: 0.37 to 0.43 ms and 0.2 to 0.4 ms, against 3.0 to 3.2 ms and 0.7 to 1.0 ms with no list kept. Over an imported chunk it takes 0.37 to 0.40 ms and 0.12 to 0.14 ms. - A surface-shaped tile's download after its fill: 0.53 to 0.60 ms, against 4.0 to 4.2 ms. - A scattered tile's download: 0.46 to 0.50 ms, against 0.98 to 1.04 ms. - A copy that imports pays the lookup through the kept lists: 48 to 63 us for a surface tile, 250 to 290 us for 1,800 scattered runs against 16 lists. - The scroll's 24 visible tiles pass the 64 MiB bound (about nine tiles), so a third to a half of their repeated fills took a kept list. - Residency is the same with and without kept lists: 4028 of 8192 MiB, and 8300 of 16384 MiB. (cherry picked from commit ee030ba7ed497aeb4bf0c92653cc33078e987379) |
||
|
|
7d4d9346df |
HostRam gathers over a chunk the device's thread imports go through the CPU, never importing on the encoding thread
copy_take answered Now for a gather over a chunk not imported yet whenever its ranges, joined where under 2 MiB apart, were at most 16 and none was the whole chunk. The copy then imported those ranges alone on the encoding thread. With runs scattered over a chunk, the joined ranges cover nearly all of it. On the RTX 5080 Laptop GPU a 24 MiB cache of 2,477 runs over five chunks, its runs joined where under 1 MiB apart, pinned 317 MiB in 61 ms (irisperf's first-fill bench), where the CPU copied the same runs in 2.8 ms. The bench's first call took 105 to 107 ms with import waits of 0, so the staged path (RT 1893) never ran: it covered only gathers that would otherwise wait. The consumer's mid-playback fills of new 4K surfaces took 3.4 to 327 ms with one clip and 1.4 to 2.1 s with three. Now, on a plan that is not listed and with the device's thread running, a gather over such a chunk is ThroughCpu however few its ranges. It is staged through the command buffer's arena, filled by the CPU at its batch's host step, and the chunk is asked of the thread. A gather the CPU path cannot take (its bytes possibly written by another use, no staging memory) still takes the imports' path. So do scatters and listed plans, as before. Docs: copy_take, the copy module's first-touch bullet, the staging check, and HOWTO's copy section. Test: host_ram_copy_device::a_first_gather_of_few_ranges_imports_nothing_on_the_encoding_thread. It gathers three pages within 2 MiB in one chunk and one in another, which before this change was an import of the ranges alone. It asserts no run import is live once the gather is encoded, the gather is staged, it waits for no import, and it reads the pages. The negative control is the old match order; it should fail on any device without AliasedImportBlitsUnordered. Not run yet. (cherry picked from commit 3dbab04a5849524c694c74aaea52b776cbef6dd2) |
||
|
|
ecddb49936 |
FAST-PATHS: the NVIDIA pool block gap with its sizes, its frees and making ahead
The RTX 5080's measurement of its own (an exclusive window, 12 blocks a size): vkAllocateMemory of a pool block's memory takes about 0.16 ms a MiB, idle or beside another process's GPU work (medians 5.5, 11.0, 20.4 and 40.6 ms for 32, 64, 128 and 254.7 MiB), vkFreeMemory about 0.035 ms a MiB, and every vkQueueSubmit another thread calls during either returns once it does. Frames every 16.7 ms met a 254.7 MiB making 28.6 to 48.6 ms late on their own thread (23 of 23 over 1 ms), and up to 67.5 ms with the making on another thread, spread over the frame or right after a submission (11 of 23 either way). So no block is made ahead on a thread of the device's own: it would not keep frames from the hold. A smaller block would shorten it in proportion, at the cost of each command buffer's pool capacity, which is the orchestrator's call. Verified: docs only; the numbers are entry poolwait-poolwait-sizes-063031-063031 (7eb0aab5e5's allocation_holds). (cherry picked from commit f3e209f7ea255d79ef6b524bd1dcd176e9792589) |
||
|
|
0d66b9de2b |
with_vk_queue: the closure gets the VkDevice its VkQueue belongs to
`CommandQueue::with_vk_queue` now calls `f(&ash::Device, vk::Queue, u32)`. The device is the serving generation's, read under the queue's lock with the VkQueue. After a recovery the queue lends the new VkDevice's VkQueue. Until now a caller could get the device only from `Device::raw` handles it had cached, and after a recovery those name the lost VkDevice. The consumer's copier did exactly that: it submitted command buffers from a pool made on the lost device to the new device's queue, and the process died inside RADV (a segfault at null+0x50 in libvulkan_radeon.so, right after our "VkDevice was lost and made again" log). No call let it see the change atomically. Every call site in the runtime, its examples and the validation lanes takes the new argument. The runtime README's interop and "A lost device" sections, `Device::raw`'s docs and docs/API.md's device-recovered entry say what the closure gets. api_signatures.tsv is re-blessed (one signature changed). Test: device_recovery::a_lent_queue_names_the_vk_device_it_belongs_to_across_a_recovery. It reads the lent queue's device before and after recover_for_test. The two differ, and the second equals what Device::raw answers after the recovery. The test also asserts the old route is wrong: the raw handle cached before the recovery differs from the lent queue's device after it. That cached handle was the only source of the device under the old signature. (cherry picked from commit b4bf228df9db98a451c997f350c6014b027f7e31) |
||
|
|
97ba27de2d |
Regenerate docs/REFUSALS.md for the version-1 symbol table's refusal site
The module-level symbol table reader (bitcode/module.rs, Names::read) refuses a summary-index entry (VST_COMBINED_ENTRY) as Unsupported(BitcodeRecord), a new construction site of that variant. Generated with python3 scripts/refusal-surface/refusal_surface.py. (cherry picked from commit b500dc8717a4dd60f84eb775fa0a70446db44cd6) |
||
|
|
bfcd71e5d6 |
Record the short last row's shadow among the known gaps
A texture over host pages whose buffer ends inside its last row's pitch is a shadow (Refused(Placement)): a linear image's last row takes the whole pitch, so the image's memory requirements reach past the buffer's bytes, over an import of the caller's pages and over a copied host buffer's copy alike, whose placement is the buffer's length. Metal reads such a texture in place, so it is a runtime cost above the driver's: docs/FAST-PATHS.md's known gaps now say so, and InPlaceRefusal::Placement's doc names the case. Seen on the Iris Xe (ANV) and the 780M and RX 550 (RADV) by a probe at the guest's shape, which stays on a branch of its own. Verified: cargo fmt; scripts/api-signatures --check (signatures unchanged; a doc change). (cherry picked from commit 9493894b26cee3b1a525d9a0916a83f3fc6a594f) |
||
|
|
da896c5a1f |
Textures over a device-allocated copy: the caller's pages' verdicts, the pooled check only for the pitched image
On RADV (the RX 550, job 8832) every texture over a copied host buffer whose copy lies in memory the device allocates stayed a shadow: the route asked the runtime's pooled class's verdicts, which the check leaves unchecked there, though the image over such a copy is mostly the driver's own linear image, which starts PREINITIALIZED and so keeps the copy's bytes at its first move. The pooled class judges only the DRM_FORMAT_MOD_LINEAR image made UNDEFINED at Metal's pitch where the driver lays its rows otherwise. So the route asks the caller's pages' class (Pointer) for texels as they lie in the copy and as they lie in the pages (a rebind may import them), and fresh pages' where the copy lies in them; copy_unplaced refuses the pitched image for its pitch where the pooled check did not pass for its accesses. The wider plans of a texture over a copy (the usages its descriptor lacks) take the caller's pages' verdicts too, as the route does. Texels::over_caller_pages answers only over a copied buffer. The device test now asserts an image over the copy where both checks passed and none where the pages' did not. Verified: cargo fmt; builds and tests run as potluck jobs after this commit. (cherry picked from commit 7911bb167b88661f3d4b8b6a4431145ff22a143c) |
||
|
|
1cf4730839 |
Textures over a copied host buffer: an image over the copy where the check passed, not a shadow
Every texture made over a copied host buffer (a no-copy buffer whose import the caller's gate
refused, or that failed) was a shadow, refused as `Refused(Placement)` ("a copy of the caller's
pages in memory of the device's own"), whatever its usage: each command buffer copied the copy's
texels into the shadow's image, and merged writes back, on top of the copy's own copy-in and merge.
A consumer whose views of guest memory pass the host's mapping budget gets copies of its large
window surfaces (reims's Iris census: 112 gate copies, 1.9 GB), and every texture over them is
such a double copy: the boots' 491 refused-placement shadows.
The GPU uses the copy in the pages' stead, so a texture's image can lie there, as a rebind onto a
copy already makes one (`in_place_over_copy`):
- route.rs: a copied buffer's class is its copy's memory's (Fresh in fresh pages the runtime
imported, else Pooled); the in-place decision asks that class's verdicts and the caller's pages'
(Pointer: a rebind may import them), each for texels that lie in lines as they lie there
(`Texels::line_start` reads the copy's offset in its memory; `over_caller_pages` the pages').
- in_place_image.rs: `unplaced` over a copy makes the image in the copy's memory: in fresh pages
the host-allocation one, as over the pages; in memory the device allocates `own_unbound`, the
driver's linear image (PREINITIALIZED) where it lays the rows at the pitch, else the
DRM_FORMAT_MOD_LINEAR one of no external memory (`unbound_in` serves both, and
`in_place_unbound`). The image is watched for rebinds and its first move holds the pages, for any
no-copy buffer's pages (the class no longer decides it). A rebind onto a device-allocated copy
takes the DRM_FORMAT_MOD_LINEAR image too where the pooled class passed for its accesses
(`class_takes`, from `fresh_pages_take`).
- The image's identity is the buffer's, so its uses name the copy: commits copy the CPU's writes
in, completions merge the GPU's back, as for the buffer.
- Counted: `WorkCounts::copied_textures_in_place` (also in `host_textures_in_place`); a shadow's
notice names the copy.
Tests (copied_device.rs): a sampled and a rendered texture over a gate-refused copy take an image
over the copy exactly where the verdicts of the copy's memory and the pages pass (before this,
every one was a shadow, so on a device whose check passes the test fails), read the caller's
texels and a CPU write before a commit, and their blit and clear reach the texels' bytes in the
pages alone; such a texture follows rebinds to another copy and back to an import.
Docs: copied.rs, in_place.rs, in_place_image.rs, route.rs, HOWTO (copied host buffers),
FAST-PATHS (the in-place row), TexturePlacement::InPlace; api_signatures blessed.
(cherry picked from commit e6573e3f1b942d11bda3063f5477745018cf9239)
|
||
|
|
15c72b1690 |
GPU pools: a block a queue lets go is the device's spare for the next queue
A queue's pool block that went (its queue went, or no lease held it for QUIET) was released, and the next queue to need a block of that kind made one again: on the RTX 5080 a 254.7 MiB vkAllocateMemory of 4.9 to 189.5 ms beside other GPU work, during which the driver holds every vkQueueSubmit of the process (docs/FAST-PATHS.md, known gaps). Now the block becomes the device's spare of its kind where the device holds none (else it is released, as before), a made-meanwhile block too, and a queue holding no block takes the spare at its first lease before it makes one. A device so makes no more blocks of a kind than the most queues that held one at once, and none as queues come and go or rest. The cost is one block of each kind beyond the queues' own until a queue takes it or the device goes: 254.7 MiB of device memory on the RTX 5080 Laptop GPU, 1 GiB of host memory kept wired on the M3 Max. The spare is safe to hand on: no lease holds a block that goes, so no command uses it, and nothing reads a pool's bytes before its own command buffer wrote them. QueueBlocks::drain pops the slots instead of taking the map. Tests: the pool CPU tests cover the spare from both releases, the made-meanwhile block, the teardown and queue churn (eight queues one after another make one block); the device tests see a later queue and a rested one take the spare without a making, and the handler test makes each round's block after a holder queue took the spare. Verified: cargo fmt only, here; the runtime and validation suites, clippy and the device runs follow as potluck jobs. (cherry picked from commit dcc2bc0cb49f391b7d14c135d7aae97f1a93795b) |
||
|
|
9024d9ee5f |
index_pools: count a completed handler's lag from its submission's return too
runtime_lane::index_pools::a_completed_handler_waits_for_no_pool_block_made_meanwhile
failed on the RTX 5080 (round
|
||
|
|
384ce01a32 |
HostRam lists: HOWTO, runtime README and FAST-PATHS with the 780M's numbers
HOWTO section 6 gains HostRam::with_dma_buf_of_runs: what the source answers, where copies take lists, what they differ from (a chunk's import pins every page of it, for good, and later copies import nothing; lists pin the copy's pages while it runs, and every copy pays its imports), and the Radeon 780M's numbers from tests/host_ram_listed_bench.rs at 4f30c38a77 (before the rebase onto development; the list path is unchanged by it): 4028 MiB of an 8 GiB guest's file held where whole chunks would make 8192 MiB resident, 8300 of 16384 for 16 GiB; a surface-shaped tile 4.1 to 4.5 ms from the commit to the completion, a scattered one 0.9 to 1.25 ms, against 0.39 to 0.48 ms over an imported chunk. The copy paragraph says where lists replace the staged and alone paths. The runtime README names the call; FAST-PATHS's row on idle dma-buf imports gains the trade (memory for per-copy time, the consumer's choice, no accuracy). (cherry picked from commit c6f08a396cc2e4713dedfae06ad0648019e9e22d) |
||
|
|
27eea49ec5 |
HostRam: a copy over a listed chunk not imported takes lists of its own pages, of an opt-in source
HostRam::with_dma_buf_of_runs(source, most_runs) gives a RAM a DmaBufRunsSource: one dma-buf of a list of runs of its pages, their pages one after another (udmabuf's UDMABUF_CREATE_LIST on Linux, at most list_limit runs a list). Only copies by runs call it, and only where the plan is Plan::listed (each held import costs every submission and the RAM's chunks are the device's dma-bufs of its source: RADV) and the device's barriers order blits through two imports of the same pages. There RamOnDevice::for_copy, for a chunk not imported, takes RamOnDevice::run_lists: the copy's ranges of the chunk by address, widened to whole host pages and joined where those share or touch a page (copy::page_runs), split into lists of at most most_runs runs and one dma-buf's bytes (copy::run_lists), each imported as one dma-buf of the source (Device::ram_runs_as_dma_buf, Imported::Runs), held by the command buffer until it completed and freed then. The chunk is neither imported nor asked for, so copies pin their own pages while they run and never a chunk's untouched pages, which udmabuf allocates for good. Without the source, a source that fails or answers a dma-buf of another length, the margin of the allocation limit, a run that is the whole chunk or passes one dma-buf, the copy takes the chunk as before. A list's VkBuffer holds each run from where the runs before it end: RamChunk keeps the runs and their offsets (RamChunk::offset_of, RamChunk::bytes), and the copy maps each piece through it; regions take their host bytes from the pieces, not the import's span. alone_ranges takes one chunk's sorted ranges (chunk_ranges with no cap) and joins them as before, so every other plan (ANV, NVIDIA, lavapipe, MoltenVK, RADV without the source) copies as before. Counted: WorkCounts::host_ram_run_list_imports (new), live in run_imports_live. Tests: copy.rs units for page_runs and run_lists; host_ram_dma_buf's tile tests over a RAM with a udmabuf list source (lists of at most 1,024 runs, no chunk, nothing asked, no untouched page resident) and, without it, the chunk; elsewhere the list source never asked. The bench takes the list source and prints first and repeated copies, sorted runs and lists per copy, over surface-shaped and scattered tiles. api_signatures blessed (three added: DmaBufRunsSource, with_dma_buf_of_runs, the counter; nothing removed); docs/REFUSALS.md regenerated (a DmaBuf site). Verified: cargo fmt and the signature and refusal scripts only; the 780M runs follow. (cherry picked from commit f2e5c143dd314835fd58cd6f8430c5c7c620e52a) |
||
|
|
bdeed7eaa6 |
HOWTO, signatures: copies over a chunk not imported, staged gathers and their counts
docs/HOWTO.md's host RAM copy paragraph said a copy over a chunk not imported waits for its import; it now says what each takes: ranges alone (at most 16, not on MoltenVK or ANV), a staged gather through the CPU on devices whose thread imports ahead, and the wait otherwise, with the counts that show each. api_signatures.tsv blessed for the six new WorkCounts fields (signatures.py --bless: six records added, none moved). (cherry picked from commit 9332df0676eea0a5336ee95ffc25deb2b5d0b05f) |
||
|
|
748465a50e |
Host RAM copies of runs each at a byte of the buffer: one call for a laid-out surface
BlitCommandEncoder::copy_runs_from_host_ram(ram, runs, destination) and copy_runs_to_host_ram(source, ram, runs) take (buffer byte, host run) pairs, so a device cache that keeps a surface's layout (row r at base + r * pitch, the padding between rows the guest's and untouched) copies every row in one call instead of a call a row (the Iris measured 2054 calls at 3.9 ms GPU and 8.1 ms CPU against 0.83 ms and 1.5 ms for one call of the same runs, m3-max-8523). The call now holds runs at their buffer bytes (Run); copy_from_host_ram and copy_to_host_ram lay theirs one after another from their offset (one_after_another), so their behaviour and refusals are as before. Runs join where they touch in the RAM and in the buffer (merged). pieces() places each piece at its buffer byte; the record path takes the span from the lowest run's first byte to the highest's last for the bindings, windows and hazard tracking, and the kernel's entries already carry their buffer word, so only the table's filling changes. Runs that all end on a word and lie at words of the buffer's memory take the dispatches; others, and copies that write a destination byte twice (a scatter's host bytes, a gather's buffer bytes), take regions, in rounds where a byte is named twice so the later run's bytes stay. For the runs calls, a run past the buffer is RangeOutOfBounds (the first such run's), and a run at a buffer byte off a word takes regions instead of being refused. Tests: a laid-out surface (rows at a pitch over scattered pages, two side by side, one in each chunk) both ways in one call with sentinels in the buffer's padding and the whole RAM compared, 4-byte rows by a dispatch per chunk, 2-byte rows and rows at a buffer byte off a word by regions; a gather naming one buffer byte twice keeps the later run's bytes; the runs calls' refusals; unit tests for merging pairs, in_words off a buffer word and pieces at their buffer bytes. The bench's laid-out one-call form now uses copy_runs_to_host_ram from the laid-out cache. Docs: both calls' API docs, the module docs, Problem::HostRam, HOWTO section 6 and the runtime README; signatures re-blessed (REFUSALS.md regenerated, unchanged). (cherry picked from commit 8292ae5075d07cbcd6eada94cf8dc99060792722) |
||
|
|
1c33448daa |
dma-buf lane: a view of single pages takes the route its device answers; ANV's dma-buf limits documented
What: the reversed-view test now asserts each measured driver's route for a no-copy Shared buffer over 64 and list_limit + 1 single pages of a memfd in reverse, mapped from the file and through udmabufs (VM_PFNMAP), placed outside the guest's range, with a dma-buf source: - RADV: through dma-bufs, one chunk, or two in a sparse buffer; - ANV: by pointer from the file; through udmabufs, one dma-buf where one udmabuf holds the view, else refused (Unsupported, HostMemory) after one request for a single dma-buf of the whole view; - lavapipe: by pointer. No route is a copy. It prints the mappings the view and the import took. with_dma_buf's docs and HOWTO now say what ANV does. It imports a dma-buf for a plain buffer but reports none for a sparse one, so its source is asked for one chunk of the whole length, which one udmabuf must hold. It refuses the pointer of a mapping of dma-bufs. Why: a consumer's probe found ANV refusing a view of list_limit + 1 pages mapped through udmabufs. The runtime's route there was not a copy, nor a skipped source: - the pointer import of the udmabuf mapping was refused: vkGetMemoryHostPointerPropertiesEXT answered memoryTypeBits 0x7f, then vkAllocateMemory with VkImportMemoryHostPointerInfoEXT returned VK_ERROR_INVALID_EXTERNAL_HANDLE on memory types 2 and 1; - the source was then asked; - vkGetPhysicalDeviceExternalBufferProperties for DMA_BUF reports import for flags 0 but not for SPARSE_BINDING, so the request's granule was the whole 4,198,400 bytes, and one udmabuf of 1,025 items is past list_limit 1024. No buffer of Vulkan binds more than one imported memory without sparse binding, so the runtime has no documented path for such a view on ANV. Verified: diagnostics on a scratch branch (never merged), on the Iris Xe (ms01, job m3-max-8433, Linux 7.3.1, i915), the 780M (job m3-max-8454) and lavapipe (gem10, job m3-max-8477). The runs of this test follow. (cherry picked from commit 32ba8392a0aa8d16b4fceb9b6ed052e5d618b1a0) |
||
|
|
ded385b661 |
YCbCr textures: announce the device's conversion at the first conversion; the lanes read in-place samples as Metal's
On the Radeon 780M, which converts the 4:2:0 formats itself and reads their planes in place, the ycbcr lanes failed 9 of 48 at this branch (um870 m3-max-8383) and 17 of 48 at development's tip (gem10 m3-max-8421), the same 9 among them. Two causes: - A texture whose conversion is the device's announced ycbcr-filter-not-exact as it was made, though a texture whose planes every function reads in place never converts and so never reads the device's conversion (a_ycbcr_texture_sampled_and_gathered_by_one_function_reads_its_planes_in_place, a_ycbcr_sample_through_an_unmeasured_filter_is_announced). Converts::new now announces it at the texture's first conversion. WorkCounts::ycbcr_device_conversions still counts the texture as it is made, so a lane can tell before a read that the texture's image holds the device's conversion. The lanes' notice predicates now take a conversion that ran, WorkCounts::ycbcr_device_samples (device_samples), in place of the textures made. - The lanes held the samples of a texture whose planes are read in place to its image's texels, the device's conversion on such a device, where a function reading the planes converts the codes itself: Metal's conversion and filter under the lane's exact_answers (YCbCrInPlacePolicy::Exact), as ycbcr.rs states. Texels::sampled takes Metal's steps of the codes (modelled) for a texture read in place and the image's texels elsewhere, in a_linear_sample_of_a_ycbcr_texture_is_metals, a_linear_sample_is_metals_through_each_sampler_and_result and its fragment twin, a_ycbcr_slot_takes_the_devices_filter_in_the_pipeline_its_creation_made and ycbcr_textures_read_the_texels_metal_converts; a_draw_samples_the_planes_as_written_before_it holds a draw read in place to Metal's conversion of the uniform codes. four_two_two_and_four_four_four_codes_read_what_metal_reads also held a code twin over a surface whose chroma plane it does not fit in to Metal's codes where the device reconstructs them itself: it now takes the device's codes there, as the test's other surfaces do. Docs: the ycbcr.rs and ycbcr_device.rs module docs, Degradation::YCbCrFilterNotExact and its docs/API.md catalogue entry say the notice comes at the first conversion. Verified: cargo fmt; the 780M runs on um870 and gem10 follow. (cherry picked from commit c498f9383a3f4a2ef3f267a135ea5494aa8fb5e4) |
||
|
|
5640e17560 |
Document the model's linear sample of planes read in place
FAST-PATHS.md gets the ledger row for ycbcr_in_place_reads (Model default, Exact switch, the 780M's exact-form cost measured at development's tip), the device-gaps row and the in-place section name the choice; API.md's policy list and the half/float filter and ycbcr-filter-not-exact catalogue entries name the model; PrecisionNote::HalfSampleFilter/FloatSampleFilter and Degradation::YCbCrFilterNotExact docs say the model records and announces them. (cherry picked from commit 5f83699d296386c3b0b357f2baa63cfefc086096) |
||
|
|
b30da69b50 |
Host RAM copies of runs of words take the pages copy's dispatches, not regions
The pages copy's table entries become three words: the run's first word in the scattered binding, its first word in the consecutive one (from the shape's first_word) and its words, at most a page's 1024. Each invocation copies its strided words below the run's count. Whole pages are entries of 1024 words, one a page as before, so their tables' entries, dispatches and windows are unchanged. In the runtime, a copy whose runs all end on a word (they already start on one, and the buffer's bytes too) takes the dispatches: plan() cuts each piece into runs of at most a page from its start and where a window of the buffer ends. Only runs that end off a word (rows of 1- or 2-byte texels), or a scatter whose runs write a byte twice (share_a_byte, so the later run's bytes stay as with regions), keep vkCmdCopyBuffer regions. The Iris measured regions at about 1.6 us of GPU and 1 us of CPU each (m3-max-8389: 8853 regions of a 31.5 MB surface, 14.0 ms GPU, against 0.99 ms for the page kernel over the same pages). Tests: the kernel's interpreter test of word runs (a word, 128, 129, a run across a page, a page less a word) with no word around them changed; the plan's cuts at a page and at a window's end; a device test of rows of 2044 bytes at a 2048 pitch from 16 bytes into a page, a run ending a word before a page's end, three pages and more from inside a page, one across the chunks' end and a word, with sentinels over every touched page, a dispatch per chunk and no region both ways, and a twice-named scatter of word runs by regions, the later run kept. The regions refusal case now ends off a word. The bench measures rows of 4-byte texels (dispatches), of 2-byte texels (regions) and 2046 bytes at a 2048 pitch. Docs: the kernel's module and entry docs, the copy module, both calls' API docs, HOWTO and the runtime README; signatures re-blessed (entry() takes the run's words and returns 12 bytes; ENTRY_WORDS). (cherry picked from commit 562fc5fc526cce2b31db280c4bbffb29314f8ac4) |