37875af7f312fc4f4ea2227fbec8d8b45ddab0cd
750
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
37875af7f3 |
Weigh a self-read's split by the texels its copy moves
The area rule (render/snapshot.rs) weighed the split as a copy of every texel of the color's
level. The split's copy for a draw that reads at its own pixels is cut: for a one-level,
one-slice color it moves only the texels inside the rectangle bounding the draw's scissors, a
pixel wider each way (render.rs's bound_own_pixel_reads, ShadowCopies::cuts). So the rule
overstated the split for readers through scissors smaller than the target, and since
|
||
|
|
902002273d |
Narrow RADV's first-write-after-suspend gap to moved and dedicated memory
Measured on the RX 7900 XTX (gem10, Mesa 26.2.6) with tests::zeroed_start's busy test, five processes each started with the GPU in runtime suspend (job m3-max-7290). The first replace_region into a texture made behind about 1.5 s of fills took 55 to 114 us with the blocks host copies place in made ready ahead, each run readying 1 block and making 0 in place. With that readying off (negative control: 5ee5d0e582's keep_room change) it took 553 to 654 ms, and the test failed on its readied-block assertion. Awake it took 58 to 63 us, against 68 to 96 us without. What stays open, from the in-process probe on the same card: a texture placed before a mid-process suspend waited 86 ms for the kernel's moves back, and a texture of its own block (4096 x 4096) waited 73 ms. (cherry picked from commit 065f04d7f3016469a01d9148aba4dc9e991dfd79) |
||
|
|
532fc35b7a |
In-place verdicts by row ends: texels that share a line of the device's memory with bytes beside them, and texels that share none
On the Iris Xe (ANV) a pass that clears and stores a linear image, and a draw into it, write back whole the 64-byte line that holds a row's last texels. That puts an older value back over a CPU write beside the texels, so the check fails render targets over host pages there, and every such texture is a shadow. The write-back cannot reach a CPU write when no line holds both a texel and a byte beside the texels: the probe read 0/100 for rows that end on a line, and 0/25 for a 3840x2160 surface of tight rows. A 3840x2160 BGRA8Unorm surface's 15360-byte rows are 240 lines each. The check's verdicts are now kept per class, access and row ends (in_place::RowEnds): - The line is the device's nonCoherentAtomSize. vkspec defines it as "the size and alignment in bytes that bounds concurrent access to host-mapped device memory". - RowEnds::of reads the texels' address, offset and pitches. Texels are OnLines where their first byte and their end lie on a line, and so do each row's (or slice's) start and end where bytes lie between rows (or slices). Elsewhere they are InLines. - The check runs the shapes whose texels share no line first (Shape::rows; seven of SHAPES at 64-byte lines). A byte changed beside one of them fails both row ends. A byte changed beside a shape that shares a line fails InLines alone, since the OnLines rounds have already run (the verdicts function). A device that fails InLines now also runs its OnLines shapes. - SHAPES gains two shapes whose rows end inside a 16-byte line, at the 16-byte pitch a driver that lays rows tight uses: BGRA8Unorm 101x51 at 416 bytes and RGBA16Float 33x17 at 272, the same shapes STORE_SHAPES already holds. MoltenVK makes no linear image with bytes between rows except at that pitch, and its line is 16 bytes. Without these two, none of its shapes whose texels share a line was made, so its reads and renders were Unchecked for those texels: on the M3, a probe of this change without them gave Pointer and Fresh reads and renders Unchecked 5/5 for InLines (m3-max-6750). - SHAPES and STORE_SHAPES gain the same widths at the 64-byte pitch of a driver that lays rows at the next multiple of 64: BGRA8Unorm 101x51 at 448 and RGBA16Float 33x17 at 320, and RGBA8Uint 101x51 at 448 and RG32Uint 33x17 at 320. On lavapipe (llvmpipe's linear images take 64-byte rows, its line 64 bytes) no shape whose texels share a line was made without them: tests::in_place_check::the_in_place_check_checks_fresh_pages_where_held_imports_cost_submissions read the Fresh verdicts Unchecked for all three accesses of those texels (m3-max-6991). The shape test now holds that drivers whose rows lie at the next multiple of 16, 64, 128 or 256 bytes each have such a shape, for each access. - The record holds 18 verdicts. CHECK_VERSION goes to 6, so a record of the old check is not read. - The report keeps its nine lines, now the InLines verdicts (the old verdict exactly, since an OnLines failure fails both), and adds nine ", rows on lines" lines after them. - The texture's own row ends decide, everywhere a texture asks for its verdict: its making (Texels::rows), a shadow's move in place (MoveWait, move_wanted) and a copied rebind into fresh pages (fresh_pages_take_images, from the watch's place in its pages). ShadowCause::CheckPending, CheckFailed and Unchecked name the row ends, and the notice says them. - Device::in_place_check_line (doc-hidden) answers the line. The lanes that hold a texture to its verdict compute its row ends themselves (runtime_lane::in_place_rows, apart from the runtime's reckoning) and read that row ends' line. Docs: FAST-PATHS row 41 and the API guide describe the row ends. The ShadowedTexture notice docs name them. The known gap for rows that end on a line is closed and deleted. Tests: RowEnds::of covers an offset, an address, a pitch and slices off a line, tight rows that do or do not end on a line, a 1-byte line, the 3840 and 3662-wide surfaces, and the check's shapes per class. The verdicts function: a change beside OnLines texels fails both row ends, a change beside InLines texels fails InLines alone, and a forced failure and an unchecked class are covered. The decision test runs every class with both row ends. The record test covers 18 verdicts. Verified, the whole check on fresh caches (the probe test, this change plus the test alone; the Iris Xe and RADV runs at 5beb0be2a5, before the 64-byte shapes, on development |
||
|
|
5aa31f836c |
Rebind a draw's slots by rebinds the plan works out once for them
A rebound draw that moved buffer offsets spent about 470 instructions a draw (lavapipe, draws.10k shape) in rebind_slots, and 13% of the M3's time, writing one 4-byte push word: each draw walked the template's stages, fields, buffers and vertex buffers again to find what the changed slots decide, though that depends on the plan and the slots alone. BindingPlan::slot_rebinds now works that out once for a list of slots (a public, opaque SlotRebinds: each changed buffer slot's place among the descriptor ranges and its push fields, the loose fields, the vertex buffer places; None where rebind_draw_slots_into answers Ok(false) whatever the state), and rebind_draw_slots_with rebinds by it, looking at the state and the commands alone and writing each word as a fixed-size store. rebind_draw_slots_into is the two in turn, so there is one implementation; builds with debug assertions check that the rebinds given are the plan's own for their slots. The runtime keeps the rebinds with the settled draw (SettledHere), made at the first draw rebound that changes a list of slots and kept while the next draws change the same slots; a new settle drops them. The rebind test now also rebinds each case by rebinds made once per plan and slot list and holds them to the whole rebind's answer and commands. docs/API.md describes the two calls; the surface table, the signature table and docs/REFUSALS.md (a renamed site) follow. (cherry picked from commit 0397cbb254eb9402d5955d2ed2edab1ea0b2b6dd) |
||
|
|
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
|
||
|
|
ee5d3cfab9 |
Regenerate the conformance coverage for lavapipe's linear texture alignment rows
|
||
|
|
0529a98e4c |
Announce each recovery's own wait, slow failing and failed making
After a device's first recovery, a later recovery's step notices were never shown: a call's wait for the recovery past 10 seconds, its command buffers taking past 10 seconds to fail, and its new VkDevice's failure all went through degrade_once(DeviceRecovered), whose record carries across generations, and the first recovery's own notice set that record. So a slow second recovery announced nothing, and a second recovery whose VkDevice could not be made left the device answering as lost with no notice (rule 2: a degradation is announced). Each recovery's notices are now its own (Device::degrade_recovery_step, whatever the kind's record says), still bounded: the wait is announced once per recovery by the first call to wait past the bound (a flag in the line's Lost state, so N waiting calls give one notice, not N), the slow failing once per recovery by the call that claimed it, the failed making once (the line fails). degrade_recovered no longer sets the kind's record, which nothing reads for this kind now. Tests (tests::device_recovery, device builds): with the bound set to zero through a per-device test hook, each_recovery_announces_its_own_wait runs a first recovery, then recoveries with three threads calling the device, and requires a later recovery to announce one wait (never two); a_later_recovery_announces_its_failure fails the second recovery's making through a hook and requires its notice to reach the sink. (cherry picked from commit fefe1396ef30708568c6811e98659fbe08771671) |
||
|
|
61a367cb51 |
Weigh a self-read's two forms at the coverage least favourable to each
A draw that reads its pass's private texture at its own pixels after a barrier takes a snapshot drawn in its subpass or splits the render pass instance; both are exact. The area rule weighed the snapshot as if the draw covered its whole scissors (20 bytes of the split's copy a pixel) against the split's copy alone, so a reader through no scissor over a large target always split. The consumer's guest draws its self-reads that way: on the Iris Xe its 3662x2039 desktop's 30 readers a frame took 10.9 to 17.4 ms of GPU time split (selfread's jobs 6068 and 5702), against about 1 ms through snapshots. What a draw covers is unknown when it records. Measured with both forms forced (a scratch build, e3792c8f2e, never landed; 30 readers a frame over private BGRA8Unorm targets of 1280x720 to 3662x2039, no scissor): - A split costs a fixed 5 to 18 us besides its copy, which is every texel here: the cut is the readers' and fills' scissors, the whole target (30 x W x H texels copied a frame, job 6674). - A snapshot costs a fixed 9 to 16 us (two barriers and the second draw) and then grows with the pixels the draw covers. - Snapshot over split, reader covering 1.5% / 100% of the target: Iris Xe 0.09-0.33 / 1.04-1.28 (jobs 6656, 6674, ms01); Radeon 780M 0.11-0.24 / 2.4-2.8 (6758, um790); RX 7900 XTX 0.25-0.43 / 1.3-2.1 (6822, gem10). The rule now weighs each form at the coverage least favourable to it and takes the one whose cost there is the smaller multiple of the other's: the snapshot where READER_COST * (READER_COST + pixels * SNAPSHOT_PIXEL_COST) <= (READER_COST + bytes)^2, with the fixed cost READER_COST a mebibyte of the copy (both forms' measured fixed costs on the iGPUs) and SNAPSHOT_PIXEL_COST still 20 (measured about 14 on the Iris Xe, 20 on the 780M, 21 on the XTX). Every reader the old rule gave the snapshot keeps it (the old rule is the case where the snapshot over its whole scissors costs no more than the copy). New snapshots: a 4-byte color's readers through scissors of up to two fifths of the target at any size (was a fifth), and at any area from 1024x768 (786,432 pixels; an 8-byte color's from 256x256). By the measurements above the rule picks the snapshot in every no-scissor cell on all three GPUs, the form whose worst case is the smaller multiple there; the cost is up to 1.28x (Iris Xe), 2.8x (780M) and 2.1x (XTX) for a reader covering the whole target, against 3x to 11x saved for sparse ones. Small scissors covered whole keep the snapshot they had, up to 2.1x on the Iris Xe (FAST-PATHS says so). Both forms are exact, so this is a cost choice with no accuracy side: no ledger row, the attachment-read paragraph of docs/FAST-PATHS.md restated. - render/snapshot.rs: snapshot_within and READER_COST; the module docs' area rule. - tests/snapshot_area.rs: the consumer's shape, the size thresholds (786,432 and 65,536 pixels exactly), two fifths at any size, and every old snapshot kept. Fails on the old rule. - runtime_lane::snapshot_reads: an RGBA8Unorm reader through a quarter of the 32x32 target now takes the snapshot where the device takes the path (was a split). - runtime_lane::attachment_read_costs::snapshot_area_costs: the measurement, the rule's form on the default device against the split with fragmentShaderPixelInterlock withheld. The composite workload's window readers now take the snapshot; its docs say so. (cherry picked from commit 65d58b231d38ad2c2ac22f8e448be3a48491bf9a) |
||
|
|
31b19fa7f0 |
In-place check: the writer sweeps the bytes beside the texels until the step ends, and a draw round
On the Iris Xe the verdict for render targets over pages imported by their pointer flipped from run to run. Devices without validation layers Failed 7 of 7 checks; devices under validation Passed 3 of 3 (m3-max-6011, 6068). A probe ran each step alone over the check's pattern, 100 rounds a step (m3-max-6080). One step changed a byte beside the texels: a render pass that clears and stores the image. It did so in 77 of 100 rounds of a 100x50 BGRA8Unorm image with rows 512 bytes apart, and 51 of 100 of a 33x17 RGBA16Float image at that pitch. The changed bytes were the ones after a row's last texels in their 64-byte line (columns 400-409 of a 400-byte row, 284-314 of a 264-byte row). Each read back the pattern where the CPU had written its complement during the step: the device wrote the line back as it had read it before the CPU's write. Nothing changed in 100 rounds each of the first move, the feedback loop moves, a pass that loads and stores, or a pass that clears and does not store. Rows that end on a line never changed (RGBA32Float 20x9 at 320 bytes, BGRA8Unorm 64x16 at 256), and neither did a 3840x2160 surface with tight rows (25 rounds). The old writer wrote each byte once, as the step began, so it caught the write-back only where one of its writes fell between the device's read of the line and its write. A step that begins later, as under validation layers, finds every write already made. The writer now sweeps the bytes beside the texels, in the stride's order, until the step ends. Each sweep writes the pattern changed by a value of its own (mark), reading each byte first, which must still hold the previous sweep's value. The compare then wants each byte's last sweep's value. A draw round: after the clear-and-store pass, each render round draws zero through a scissor of the image's last column in a pass that loads and stores the image. The draw is the crate's own: bind::check_draw_modules provides the planes merge's triangle and a fragment stage that writes a vec4 of zeros; the runtime's check_draw.rs keeps a render pass and pipeline per color format for the class's rounds. A device whose draws write back the line that holds a row's last texels now fails the check whatever its clears do, and the Iris Xe's draws do. ROUNDS stays 3, sized from the measured rate (its doc comment): four shapes' rows end inside a line, so there are twelve chances. CHECK_VERSION 5, so records of the old check are not read. FAST-PATHS: the in-place row says what the render rounds run and how the writer writes. Known gaps gains the finer class this leaves open: on the Iris, rows that end on a 64-byte line read 0/100 and could take the image in place there. Verified on the Iris Xe (ANV, Mesa 26.2.6), m3-max-6226, at the probe branch's 39a5dd1ccd (this code, with CHECK_VERSION 4, plus a probe test): - Per step, 200 rounds each, the old writer against the new one: - clear and store: 96 and 14/200 against 169 and 192/200; - draw alone: 188 and 183/200 against 200 and 200/200; - the whole render round: 160 and 1/200 against 198 and 200/200; - load and store, and the first move: 0/200 each under both writers. - The whole check on 20 fresh caches without validation: Pointer and Fresh renders Failed 20/20, writes Failed 20/20, reads Passed 20/20, 156-342 ms a check. - runtime_lane::in_place_textures::a_failed_check_keeps_the_shadow_and_no_record 20 times, a fresh check under validation each: renders Failed 20/20, passed 20/20. - Correct devices stay in place with the new writer and the draw round, the whole check on 5 fresh caches each: M3 Max, MoltenVK 1.4.2 (m3-max-6160, at 733cb8a13b, this check before the rebase), all nine verdicts Passed 5/5; RX 7900 XTX, RADV, Mesa 26.2.6 (m3-max-6523, this commit plus the probe test, steelbrain/selfread-tipprobe c3b241244e), all nine Passed 5/5, 626-642 ms a check. (cherry picked from commit 0cff30259ed6a7cba9bfcabb02643650204c1e79) |
||
|
|
b8f7b5a7f9 |
Answer minimumLinearTextureAlignmentForPixelFormat: from the device's images, per format
The query answered 16 for every format on every device, Metal's answer on an Apple GPU. On RADV a texture at 16 never goes in place over host pages: its linear images lay rows at multiples of 256 and align their memory to 256, and DRM explicit layouts take only multiples of 256. A guest that lays its buffers out by the answer then gets shadows where 256 would have given images in place. The answer is now the device's, worked out lazily at a format's first query. The runtime makes the images a 2D ShaderRead texture over host pages takes in place (in_place_unbound, the product's own maker: the driver's linear image made for host allocations at the texture's pitch, else the DRM_FORMAT_MOD_LINEAR one). It tries each power of two P from 16 to 4096, at widths of 1 to 1920 texels and 3 rows. The answer is the first P at which every width's image lies at roundup(width * texel, P) and its memory alignment divides P. Each image is released and never bound. - The first answer is kept for the device's life. - Each answer is recorded per driver, runtime and format in the shader cache's content directory. - A device that imports no host pages, a format no P brings in place, and a failed probe all answer Metal's 16. - New counts: WorkCounts::linear_alignments_probed and linear_alignments_recalled. Nothing new is refused. LINEAR_ALIGNMENT (16) stays the acceptance rule, and a texture under the answer is made as before: an image in place where the device takes its layout, else the announced shadow. The query moves from DeviceProperties to Device (Device::minimum_linear_texture_alignment_for_pixel_format), since it needs the device's images. DeviceProperties::minimum_linear_texture_alignment_for_pixel_format is removed. The private properties change as follows: - deviceLinearTextureAlignmentBytes and linearTextureAlignmentBytes are the largest per-format answer. - The iosurface pair stays 16. Supporting changes: - texture/in_place_image.rs's in_place_unbound becomes pub(super). - buffer_texture.rs's texel_bytes becomes pub(super). - The unit tests now hold Metal's rule (capabilities::linear_alignment_rule). Tests: - A record test. - runtime_lane::linear_alignments: - Every format's answer is printed. - A texture at the answer over host pages is in place wherever the check passed for reads. - A 64-byte-row texture is made, as a shadow, where the answer is larger. - A second device of the same driver reads the record and probes nothing. Regenerated: api_signatures, docs/REFUSALS.md, docs/METAL-COVERAGE.md (coverage.tsv mapping). Updated: RUNTIME-PORTING.md and the conformance device-queries docs. Verified: python generators only, so far. The builds, unit tests and the lanes on the M3, RADV, lavapipe and NVIDIA run next, and their results go with the tip. (cherry picked from commit d1510f5588e9e5c3ace5acb1622dcd6570408040) |
||
|
|
aeb74087b3 |
Zero-initialized images: pooled blocks of images, a zeroed start only over bytes no resource used
The draft gave each Shared or Managed texture that copies on the host a vkAllocateMemory of its own (Fit::Zeroed), so allocations grew with the textures. The Vulkan specification ties VK_IMAGE_LAYOUT_ZERO_INITIALIZED_EXT to the image's memory being zero, "either from being explicitly set to zero by an application or from being allocated with VK_MEMORY_ALLOCATE_ZERO_INITIALIZE_BIT_EXT", with no rule on binding offsets or dedicated allocations, and any image may move out of UNDEFINED in place of its layout (VUID-VkHostImageLayoutTransitionInfo-oldLayout-09229). So: - memory.rs: on a device that enabled zeroInitializeDeviceMemory, every block of images is allocated with VK_MEMORY_ALLOCATE_ZERO_INITIALIZE_BIT_EXT (Memory::zero_image_blocks), pooled as before. Each pooled block keeps the end of the furthest range ever placed in it (PoolBlock::placed_to); a place past it in a zeroed block reads zero (Pool::place_fresh, Placement::fresh). Fit::Zeroed, make_zeroed and allocate_image_zeroed are gone. - texture.rs: such a texture's image is made in ZERO_INITIALIZED and placed as any image; over fresh bytes it moves out of that layout on the host (counted images_started_zeroed), else it takes today's path: moved out of UNDEFINED and its zeros written on the host. - The XTX probe (job 6317, release, tests::zeroed_start, 3 rounds after runtime suspend plus one awake): development's making waited for the queued fills (180, 521, 342 ms after suspend, 1.09 s awake); the zeroed start took 0.26 to 0.32 ms. After suspend the texture's first CPU write waited instead (442 to 572 ms, until the fills ended), 71 us awake: recorded in FAST-PATHS' known gaps. - tests: memory.rs a_place_reads_zero_only_past_every_range_placed_in_a_zeroed_block (CPU); zeroed_start.rs many_shared_textures_made_in_turn_take_pooled_blocks (1000 made, kept, let go, 1000 again: times, blocks, no dedicated block, zero texels). - Docs: host_copy.rs, README, API.md, WorkCounts::images_started_zeroed. Not yet built. (cherry picked from commit b0cf11a49e44b8530b84e664d231c928421ddf93) |
||
|
|
a508b327de |
Zero-initialized images: an enables test, API.md's runtime-own extensions, the signature table
Enables::enable_zero_initialize_device_memory gets the test each runtime-own enable has (tests/enables.rs: the structure, of the registry's type 1000620000, is chained only once enabled, its member TRUE, the extension's name after host image copy's). docs/API.md's paragraph of what the runtime enables for itself outside the vocabulary names VK_EXT_zero_initialize_device_memory and when. api_signatures.tsv gains WorkCounts::images_started_zeroed (scripts/api-signatures, --bless). Not yet built; the next gem10 build runs it. (cherry picked from commit 2ec9061a61c7262e7a05b4e42f0e1122518439cf) |
||
|
|
ec9706e6e3 |
Survive the loss of the VkDevice: the device is a line of generations
Metal's MTLDevice survives a GPU recovery; the runtime's device refused every call with DeviceLost from the first loss on, and the consumer ends its VM at the first refusal. Now a device the runtime made is a line of generations (device/line.rs), each a DeviceShared over its own VkDevice, and the first call that needs the device after a loss makes a new VkDevice of the same physical device, options, queue families and extensions. - Two kinds of handle. The program's device (and its clones) is a root handle: it holds the line, pins no generation, and every public Device call goes to the generation that serves (each public method forwards to its *_now body). Objects hold generation handles, so their Vulkan calls, drops included, reach their own VkDevice alone. A generation handle's check is one relaxed load of the line's generation (Device::generation_serves). - A draw pays nothing for it. A command buffer takes its generation once, as it is made (CommandBuffer::generation); its encoders' per-draw reaches (work counts, fresh-unwritten and alias records, sampler-slot changes, attachment read notices) read it there, not through a device handle's kind. A bind's device check is one compare of the cells the two handles hold, inlined, its refusal (Device::foreign) out of line. - The state machine (Live, Lost, Failed): the claiming call recovers, every other call waits (a notice past 10 s, waiting on); threads command buffers' completion depends on never wait. Recovery: the lost generation's command buffers in flight fail through its completion path, its queues drain under their locks, create_on makes the next VkDevice, the queues are retired. - Command-buffer answers, as a real loss is one more hang: the oldest incomplete batch's command buffer fails GpuHang (exact on one VkQueue; on two or more the queue whose oldest incomplete batch was submitted first, said so in the notice), counted against its queue so the second revokes it (AccessRevoked); the others GpuRecoveryVictim; one committed on the hang's queue before the recovery runs nothing and completes with no error; one made before and committed after fails GpuRecoveryVictim. One loss names one hang: a batch that went to the driver just before the loss and reached the lost device's completion after the loss took the pending batches fails with it, as a victim (its own wait need not fail: the test hook's VkDevice runs it), and no later failure of the lost device names a second hang. - Command queues survive: a queue is a root handle and a cell of its place on one generation (VkQueue, slots, pools, hangs), which a recovery retires and the next command buffer re-makes; label and GPU-error count go on. - Objects made before a recovery are refused where they meet the new VkDevice or need their lost one: RuntimeGap::MadeBeforeRecovery, at the 38 lost-device checks (Device::lost_refusal) and at every foreign-object check of one line (Device::foreign). DeviceLost stays for a device the consumer made. - Carried across generations: the address space, resource IDs and the passing holds a making waits out before it takes one, unique identifiers, counters and the announced notice kinds. - A device handle is an enum of the two kinds (24 bytes, was 16): the shadow merge's copy-back dispatch, which holds handles, is boxed (clippy's large_enum_variant). - Device::recover_for_test (public, documented) runs the whole path with no GPU fault; RuntimeGap::AdoptedDeviceRecovery on an adopted device. - Degradation::DeviceRecovered (device-recovered), announced at each recovery with the culprit and its time. WorkCounts::vk_devices_live, vk_devices_made, device_recoveries: two VkDevices while objects of the lost one live, one after. Docs: docs/API.md catalogue entry, the runtime README's device-loss section, FAST-PATHS known gap (a make whose own submission first meets the loss is refused DeviceLost), docs/REFUSALS.md regenerated (refusal_surface.py names a forwarded body's sites by its public method), api_signatures blessed. Tests: runtime_lane::device_recovery (hang and victims, command buffers on their way to the driver at a recovery, MadeBeforeRecovery and the VkDevice bound, revocation at the second hang, a command buffer made before fails as victim, all under the validation layer; a recovery that finds nothing of the queue scheduled names no hang, its command buffers victims), tests::device_recovery (the hold of the hang's queue between a loss and the recovery), detach_lost and the MoltenVK lost-device lanes updated to the recovery's answers. Verified: - lavapipe: runtime suite and touched validation tests 1850/1850, surface 19/19 (m3-max-5695, gem10, before the rebase onto |
||
|
|
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) |
||
|
|
02562d2a1e |
Make a shared event whose timeline semaphore another API imports, exported as an opaque fd
reims's ask 2: CUDA signals the event's semaphore on the GPU after a decode (cuSignalExternalSemaphoresAsync), and waits on it, where it now orders through the host. Device::new_exportable_shared_event() makes a shared event as new_shared_event does, its timeline semaphore made with VkExportSemaphoreCreateInfo naming VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT; SharedEvent::export_semaphore_fd() answers a new OwnedFd each call (vkGetSemaphoreFdKHR), the caller's to close. An event not made exportable is refused Invalid(Problem::NotExportable). The counter stays the signal index the interop hooks name: the importer waits for vk_wait's counter and signals only one reserve_vk_signal reserved; that call's contract now names an importer's signal beside the device's queues. The device decides structurally, once: it enables VK_KHR_external_semaphore_fd wherever listed (adopted: where its consumer enabled it), and asks vkGetPhysicalDeviceExternalSemaphoreProperties for a timeline semaphore: OPAQUE_FD exportable and among the compatible types. Lacking either, the making is refused NotImplemented(RuntimeGap::ExportableSemaphore), with its REFUSALS row. Lifetime (the event outlives every import and every signal and wait an importer submitted) and device loss (state lost for the imports; a device made again exports new semaphores) are in the call and module docs, interop.rs and the README. api_signatures blessed; exit_guard's KEEPERS lists exported_semaphore.rs. Test (device, src/tests/exported_semaphore.rs): the semaphore imported into a second VkDevice; a command buffer's signal of 5 reaches vk_wait(5)'s counter there; the second device's host signal of the counter reserved for 9 raises the event to 9 and releases a command buffer that waited for 9 and then filled a buffer. Unverified at this commit. (cherry picked from commit 525580c12be28e6efa0a06ab09cde1f736ebace7) |
||
|
|
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) |
||
|
|
d694f52506 |
Copy in at a commit only the copied host buffers its command buffer's commands use
reims-vgpu's 5080 game probe past its views' budget (512 copies of stitched views) spent 65% of its CPU in its dirty logs' queries, which every commit's copy in made for every logged copy (about 110 commits a second, about 6 ms each, every copy's own log walked: m3-max-5561's profile). A command buffer's GPU reaches only the resources its commands use, as Metal's does, so the copies the others lie in need not be current for it. DirtyCommit now keeps the keys its commands used, read or written (at most 4096, past which every copy), beside the writes it kept; the commit hands them to CopiedBuffers::copy_in (copied::Written, which named the merge back's writes, is CopiesReached, the key set both take). A copy its commands do not reach is neither compared nor asked of its logs, and keeps the stamp it last synced to, so the first commit that uses it takes every write since. Every copy is copied in where the command buffer's uses went unnoted or a command may reach memory no use names (a function that reaches buffers through addresses, work on the GPU alone, a host step's records: State::reaches_unnamed). Shadows' copies in from a copy are commands of their encoder, their uses noted with the copy's key, so a texture over a copied buffer reaches its copy. Counted: WorkCounts::copied_copy_ins_unused. The copied-host-pages notice and API.md's catalogue say which copies a commit compares. tests::copied::a_commit_copies_in_only_the_copies_its_commands_use: a copy left alone keeps its bytes, the first commit that uses it takes every write since, and every copy where one may reach anything. copied_stitched_bench times a commit that uses 8 of 512 copies beside one that reaches every copy. (cherry picked from commit bc9f3f5ec63504fce3d8f89eb49110099b2b45ab) |
||
|
|
ff631aada9 |
Bump RUNTIME_VERSION to 1839: the in-place check's fresh-pages class lies in fresh pages wherever the device takes them
amdperf-22 (the six picked commits before this): Device::fresh_pages_check_buffer makes the check's fresh pages whatever the import tax, so RADV checks the class (Passed x3 on the 780M, m3-max-5640; Unchecked x3 at the parent, 5648), and a copied rebind under an image in place takes fresh pages where they passed (copied_device 29/29 780M, 33/33 lavapipe, 5667). CHECK_VERSION 4. Re-pinned; signatures and REFUSALS unchanged. Clippy plain and m2v_gpu (5701), fast_paths 21/21 (5687). |
||
|
|
406b379515 |
FAST-PATHS: the copied-rebind gap is where the check did not pass fresh pages, which it now checks on RADV too
The known gap said RADV's check gave fresh pages no verdict, so a rebind under a texture in place at another pitch than RADV's linear image's was refused there. The check now makes its fresh-pages buffer wherever the device takes such pages: on the Radeon 780M (RADV, 5640 and 5667) every Fresh verdict passed, where the control left them Unchecked. The gap stays where the check failed fresh pages or the device takes none, and the entry says so. Verified: 5640/5667 on um790's 780M (1002:15bf) and lavapipe; see the branch's earlier commits. (cherry picked from commit 756b83b22c97cc13b822cba31752d0906adb93c9) |
||
|
|
2e5a2b0d20 |
Say why short_row_kinds.m's multisampled copies died: its forked children, not Metal
short_row_kinds.m ran each case in a child that forked and did not exec, and every copy between a buffer and a multisampled texture there ended in SIGABRT inside Metal's blit. API.md read that as Metal's answer and so as a reason the multisampled short-pitch copy is unmeasured, which contradicted sample_interleave.rs's measured placement of such copies on the same GPU. multisample_buffer_copies.m (M3 Max, macOS 27.0.1, job m3-max-5571) separates the candidates. Forked without an exec, each case aborted: Metal's blit makes its program through its compiler (findOrCreateDriverProgramVariant -> MTLCompiler compileBuiltinRequestInternal -> _os_crash_msg). Spawned, every case returned with its bytes as written: RGBA8Unorm x4 and R8Unorm x2, at RenderTarget|ShaderRead, with PixelFormatView, ShaderRead alone and with PixelFormatView, Private and Shared, with and without options:, with and without a clearing pass, and without allowGPUOptimizedContents. The nine layouts multisample_buffer_layouts holds the runtime to lay exactly where it expects, at both render-target usages. So the runtime's multisampled copies stand on a measurement that holds, and the multisampled short-pitch copy stays refused only because it is not measured. The probe records that answer; short_row_kinds.m, API.md, sample_interleave.rs and the layouts test say it. No behaviour changes. (cherry picked from commit 3660f4ec2f16c6ae8e0443b9989756116c1ffc0e) |
||
|
|
54647162d4 |
Record the copied rebind a texture in place is still refused for in FAST-PATHS' known gaps
Where the device's in-place check gave fresh pages no verdict (RADV: no new buffer lies in them under the import tax) and the driver's own linear image lies at another pitch than the texels', a gate-refused or moved rebind under a texture in place is refused (NotImplemented (RebindTextures)), which Metal accepts. Recorded where a user reads it until the fresh-pages check runs wherever fresh_page_buffer works. (cherry picked from commit 9de4ad66cde6d12a58d35eed359a9246d170e31c) |
||
|
|
ae0c6c7023 |
Make a buffer whose memory another API imports, exported as an opaque fd
reims's NVIDIA video lane writes each decoded picture into a runtime buffer with cuMemcpy2DAsync, so CUDA must import the buffer's memory (cuImportExternalMemory, cuExternalMemoryGetMappedBuffer); without it the pictures take a host-pages route of about 2.7 ms a 4K picture. Device::new_exportable_buffer(length, options) makes a buffer as new_buffer does, but in an allocation of its own made exportable as VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT: the VkBuffer names the handle type (VkExternalMemoryBufferCreateInfo) and has the device-address usage of its own; its memory (VkExportMemoryAllocateInfo) is a block of its own of the memory type its storage mode takes, the buffer's dedicated allocation where the device exports only so (DEDICATED_ONLY) or the driver prefers or requires it (VkMemoryDedicatedRequirements). It is never parked for reuse. Every other buffer keeps the pooled blocks and pays nothing. Buffer::export_memory_fd() answers ExportedMemory: a new OwnedFd each call (vkGetMemoryFdKHR), the caller's to close, the allocation's size, the buffer's offset and length in it, whether it is dedicated (CUDA's cudaExternalMemoryDedicated) and its memory type (a Vulkan import names it). A buffer not made exportable is refused Invalid(Problem::NotExportable). The device decides structurally, once, as it is made: it enables VK_KHR_external_memory_fd wherever listed (outside the vocabulary, as the dma-buf route's names, which enable it too; an adopted device where its consumer enabled it), and asks vkGetPhysicalDeviceExternalBufferProperties for a buffer of the runtime's usage: OPAQUE_FD exportable and among the compatible handle types. Lacking either, the making is refused NotImplemented(RuntimeGap::ExportableMemory), with its REFUSALS row. Docs: the module docs, the call docs, interop.rs and the runtime README state the lifetime rule (the buffer outlives every import) and the device-loss rule (contents lost for every import; a device made again exports new allocations, new descriptors). api_signatures blessed (new method x2, struct and fields, two variants). Test (device, src/tests/exported_memory.rs): a Shared buffer of a 4K NV12 picture's bytes, written by the host and a GPU fill, exported and imported into a second VkDevice of the same physical device (dedicated where exported so), read there; that device's writes read back by the runtime's blit. A refusal must come from a device that lists no extension or export. It prints the make cost of Shared and Private exportable buffers beside plain ones (medians of 8). Unverified at this commit. (cherry picked from commit fd6d775ef63e350ae1f550d6b2e7ef6af763d21f) |
||
|
|
9feee35118 |
State the copied-host-pages cost in API.md's catalogue as the notice now announces it
tests::degradation_catalogue::a_runtime_kind_s_entry_states_the_cost_it_announces failed at 368f5d1b7d (m3-max-5476): the entry kept the old words. (cherry picked from commit 4b892e7ee29a748bb1b142b7601527abd7d8d505) |
||
|
|
be0a50f1a1 |
Test and document the blits at a pitch below the row for depth, stencil, buffer-backed and two-plane textures
Unit tests: Depth16Unorm and Stencil8 at a pitch below the row place each row at y x bytesPerRow both ways, Depth16Unorm on the aligned path too, a pitch off the unit or of 0 refused; a texture over a buffer's row copy at such a pitch reads overlapping buffer rows and writes them out in turn, each row but the last its first bytesPerRow bytes, a last row past the buffer refused. Device test (src/tests/short_row_kinds.rs): Depth16Unorm, Stencil8, both aspects of Depth32Float_Stencil8, an RGBA8Unorm texture over a buffer and RGB10A8_2P_XR10, 32 x 4, at half the row and half plus a texel: in, each row read whole from y x bytesPerRow; out into a buffer of 0xcc, the rows in turn, the later row's bytes standing, nothing past the span written. Docs: CopyProblem::BytesPerRow no longer names depth/stencil or buffer-backed textures at a pitch below the row (only off the unit or 0); two_planes.rs and API.md's accepted difference state the probe's answers, the multisampled copy out staying refused because every probe copy between a buffer and a multisampled texture, at the packed row too, ended its process in Metal's blit (SIGABRT). The probe's header records what it answered. REFUSALS.md regenerated (a new BufferRange site in plan_rows_copy). (cherry picked from commit e54ac4e63f4e9be0f1451ea2e7cccf8f74b66f34) |
||
|
|
d946043cc5 |
Lay a heap's one-plane YCbCr rows off 16 bytes as Metal's blits do, sharing bytes
Item 2 laid a heap's one-plane YCbCr texture whose row is not a multiple of 16 bytes in packed rows and announced heap-one-plane-layout. Metal's blits lay such a row, where it is 16 bytes or more, the row rounded down to 16 bytes apart, so consecutive rows share its last row % 16 bytes, and its copies out read each row whole from there (an Apple M3 Max under macOS 27.0.1, probes/one_plane_ycbcr_heap_rows.m, m3-max-5064: 10 x 3, 12 x 3, 13 x 7, 20 x 3, 33 x 3 and 100 x 30 at 4:2:2, 10 x 3, 13 x 7 and 33 x 3 at 4:4:4, and a 13 x 7 x 3 array, whose slices lie as its answer counts them; each last byte written matches this layout's span). That layout is one we can read, so the runtime now takes it. heap_plane_layout gives a one-plane plane one_plane_pitch: row - row % 16 for a row of 16 bytes or more in more than one row, a packed row else; an array's slices stay where the answer counts them. heap_planes returns the copies into the shadow's image and back out of it apart (PlaneCopies); a plane whose rows share bytes takes plane_copy_regions, the copies an IOSurface plane whose GPU rows share bytes takes: into the image each row whole from its own offset in two regions a slice, the shared bytes read for both rows; back each byte once, a shared one from the earlier row. Metal's blits leave the shared bytes from no one row (the even rows' at 10 x 3, 12 x 3, 20 x 3 and 13 x 7, the later row's at 33 x 3, the earlier row's at 100 x 30); the earlier row's is one of them, said in docs/API.md's accepted differences. Still announced heap-one-plane-layout: rows under 16 bytes, which Metal lays 16 apart past the answer and whose copies out read none of the rows past the first back, and mipmapped and 3D textures. The notice's doc, cost and catalogue entry say so. Tests: tests::heap's a_heap_one_plane_texture_s_rows_lie_as_metal_s_blits _lay_them (no device) holds the pitches, slice pitches and spans to the probe's for eight shapes, every texel read into the image from its own offset, and every byte written back once, a shared one from the earlier row; the device test heap_one_plane_rows lays 13 x 7, 33 x 3 and a 13 x 7 x 3 array at 4:2:2 and 4:4:4 in the heap's bytes as Metal does with no notice, and announces a 6 x 3; the lane test makes a 13 x 7 with no notice and announces a 6 x 3 and a mipmapped one. (cherry picked from commit ff300cc511502049e318d113015a5e2c14cb4645) |
||
|
|
801f35bf19 |
Name the interlocked race's causes, record the split's cost, and count the memoryless lane per pass
DriverFact::InterlockedDrawsRaceUnderLoad's doc now names its causes. - MoltenVK 1.4.2 turns render pass barriers off for every Apple GPU family (its device setup: Apple's GPUs do not support them). The by-region memory barrier between_storage_draws records therefore encodes no Metal barrier and orders nothing. The measurements agree: 16 of 20,790 passes lost with the barrier, 6 of 7,560 without it, the same rate. - MoltenVK's shaders of the lanes' fetches, dumped with MVK_CONFIG_SHADER_DUMP_DIR (m3-max-5436), declare every interlocked storage image access::read_write, memory_coherence_device and raster_order_group(0), and read and write it there alone. Metal's raster order groups are what failed to order the draws under load, not a form the translator emits. So no translator-side fix applies, and the split stands. The measurement now holds both A/B runs. m3-max-5349 and m3-max-5414 ran six processes at once, the builds in turn: 16 of 20,790 passes failed with the barrier and 0 of 20,790 with the split. docs/FAST-PATHS.md: the barrier row names the MoltenVK split, and a known gap records its cost on the M3 Max (m3-max-5414, tile_path_costs, release, four runs each). The other tile path cases kept their instances and times. - wide blended in the function: 11.5 to 12.9 ms a frame against 1.8 ms, 243 instances a frame against 9. - extended range: 11.8 to 12.4 ms against 2.5 to 2.6 ms, 234 instances against 9. - extended range, wide attached: 10.7 to 12.4 ms against 2.5 to 2.7 ms. a_memoryless_attachment_fetched_after_a_plain_inline_draw_starts_from_zero now counts each pass apart. Each pass records inline, splits before a write of the memoryless color through inputs, splits 3 times before draws after interlocked writes where the device does so (none elsewhere), and records at least its first split's instance inline. On the M3 Max the first pass's later instances recorded in secondaries and the second's inline (1 and 4, m3-max-5436), which the inline rule decides; the test does not hold it. Verified: cargo fmt. The lanes run next. (cherry picked from commit f47897d1a80cf2e959211a883707df169011104c) |
||
|
|
fcde58393c |
Announce the interlocked split with its own cause, and expect it in the fetch lanes
The split before a draw that reaches interlocked storage an earlier draw
of its instance wrote (Split::InterlockedWrites, where
DriverFact::InterlockedDrawsRaceUnderLoad holds) is announced as
render-pass-split. Its instances share one shape, so the notice gave the
generic reason ("its draws keep different attachments out of their
subpass"), which is wrong for it. SplitCauses gains interlocked_writes,
counted where the split is taken (an execution's runs through its
Found), and the notice names the cause. The RenderPassSplit doc and the
docs/API.md catalogue entry name the fact.
Three framebuffer_fetch lanes failed on the M3 Max (m3-max-5404). The
split is announced with the backing it gives a memoryless attachment,
and it adds instances. fetches_degrade_once_per_kind and
a_plain_draw_before_a_fetch_takes_the_devices_faster_form now expect
the announcement where the device splits so (splits_interlocked_writes).
a_memoryless_attachment_fetched_after_a_plain_inline_draw_starts_from_zero
counts the splits: 3 a pass there, none elsewhere.
Verified: cargo fmt. The M3 lane run follows.
(cherry picked from commit 844d58ba93764fd2b34d668114ac05b565c76a0d)
|
||
|
|
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) |
||
|
|
be1f1c141b |
Take the storage form for a private target whose self-read splits for want of STORAGE
A draw that reads its pass's color attachment at its own pixels after a render-target barrier takes the snapshot only where no later fetch could render the attachment through a stand-in (`keeps_own_attachment`: the image has STORAGE). A private texture whose device lays an image out otherwise with STORAGE (with_free_usage leaves it off: the Iris Xe's optimal BGRA8Unorm, as the orchestrator relayed from the 4845 A/B, 12-15 ms a frame of 30 splits for the private selfread target) split at every such read, every frame, for good. The fallback now notes the texture for its storage form (texture/storage_form.rs), the switch a fetching pass's scratch already takes: at a later commit its image is made again with STORAGE and its texels copied in once, announced as fetched-target-storage, and its later passes' readers take the snapshot. A texture noted already returns before its plan is asked again, as a reader that splits notes it at each such draw. Test: tests/self_read_storage.rs (device test), with a test-only switch that makes STORAGE cost every image (DeviceShared::storage_costs_forced, read in Device::if_free): a private BGRA8Unorm target's first pass splits and takes the form at its commit, its later passes' readers take the snapshot, each pass's texels Metal's; where the device does not take the path, every reader splits and nothing swaps. Docs: the fetched-target-storage declaration and its API.md entry, the FAST-PATHS attachment-read row. (cherry picked from commit e0444b4029c9372197faf8c5bab3d967cb9bb543) |
||
|
|
c34d5ad97a |
Record the chunk-length probe's numbers where the listed chunks' cap is described
The lane probe submit_per_ram_chunk_length ran on the Radeon 780M (RADV, Mesa 26.2.6, Linux 7.3.1) before the cap, two rounds, over an 8 GiB memfd RAM in 2 MiB pages with one 2 MiB object in each chunk (job m3-max-5411 on the test copy a20f678c2e of e0e069f6bf). Submission p50, round 1 / round 2: - no RAM: 14.7 / 14.0 us - 128 chunks of 64 MiB: 91.1 / 59.5 us - 64 chunks of 128 MiB: 50.3 / 36.1 us - 32 chunks of 256 MiB: 31.8 / 32.8 us - 16 chunks of 512 MiB: 23.9 / 23.5 us - 8 chunks of 1 GiB: 18.6 / 19.3 us That is 0.34 to 0.66 us per live chunk. At every length the first submission that listed the chunks took 52 to 56 ms, and the RAM was resident whole: 8192 of 8192 MiB, its objects over 16 to 256 MiB. The FAST-PATHS entry and the host_ram module docs now carry these numbers. The paragraphs touched are reflowed to 100 columns. (cherry picked from commit 9aafb46d7b86f5834c821a25bc6ad1ec1b9b935e) |
||
|
|
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) |
||
|
|
8f652b31f1 |
Write a blit's rows out of a texture below their row in turn, the later row's bytes standing
A copy out of a texture at a bytesPerRow below the region's row was refused Invalid(Copy(BytesPerRow)), as Metal writes such overlapping rows in no one order. Metal runs the copy, though, so under rule 2 it may not fail: on the Apple M3 Max under macOS 27.0.1 (probes/short_row_blits.m, jobs m3-max-5158 and 5170) every such copy returned, rows lay y x bytesPerRow apart with nothing past their span written, and of 300 shapes of 12 formats at half the row about a fifth left the later rows' bytes standing. The later row's bytes are one of Metal's own answers. placed_rows no longer refuses the copy out at a pitch below a row; the rows are placed as a copy out at any other pitch off Metal's rules is, and plan_placed_copy's later_rows_win writes them in turn: the texture goes to a packed staging buffer in one region, and the staging rows go to the buffer in one vkCmdCopyBuffer whose destination regions are each row's bytes no later row writes, disjoint as VUID-vkCmdCopyBuffer- pRegions-12482 asks, one region a row. No buffer-image region states a row length below the width (VUID-VkBufferImageCopy-bufferRowLength-09101). Still refused: a multisampled texture's copy out at such a pitch (where Metal places its rows there is not measured), a texture over a buffer, and depth and stencil formats but Depth32Float, as before. docs/API.md's accepted differences say so; CopyProblem::BytesPerRow's doc and basis lose the case and REFUSALS.md is regenerated. Tests: blit_plan's layouts test takes the copies out at a pitch below the row (rows at y x bytesPerRow); a_copy_out_at_a_pitch_below_the_row_leaves _the_later_rows (blit_plan, no device) checks the unstaged bytes for a one-plane YCbCr texture at its described row, RGBA8 at half, RGBA32Float at three quarters and R8 at a pitch of 0, nothing past the span written and at most one region a row; described_row_copies' new device test copies 501, 504 and RGBA8Unorm out at a pitch below the row into a buffer of 0xcc and reads the later rows' bytes standing. (cherry picked from commit 73554a28ae7c83ccdcb01d5ebb95787b74928c21) |
||
|
|
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) |
||
|
|
c6e1d5a9fd |
Make a BC1 or BC4 texture over a surface's plane at an offset or pitch off 16
The runtime refused a BC texture over a plane of a surface with planes whose offset or bytesPerRow is off 16 bytes, as NotImplemented(SurfacePlaneShape). The M3 Max answers nil for every BC texture over a surface, so the x86 Macs are the reference (job m3-max-4779 on macbook-pro-2019: an AMD Radeon Pro 5300M and an Intel UHD 630 under macOS 26.7.1, surface_texture_envelope.m's bgraat8.bc1 at offset 8 and bgrarow264.bc1 at 264 bytes a row). Both GPUs' blits and samples take block row j at the plane's offset + j x bytesPerRow, with no rounding to 16. linear_plan::blocks_off_sixteen makes a BC texture of 8-byte blocks (BC1, BC4) at an offset and bytesPerRow that 8 divides, at least 16 bytes a row. Every BC plane now lies at the CPU's layout on the GPU too (plan_iosurface_plane's blocks flag): at multiples of 16 the two were already equal. The CPU calls take the plane's own offset, as the 5300M's getBytes does, while the UHD 630's getBytes and replaceRegion take a plane at offset 8 from byte 0. That difference is recorded in docs/API.md's accepted differences. BC4 was not measured off 16; it takes BC1's 8-byte block rows. BC textures of 16-byte blocks (BC2, BC3, BC5, BC6H, BC7) off 16, and 8-byte ones off 8 or under 16 bytes a row, stay refused. SurfacePlaneShape's doc names them, and so does its reach mark in REFUSALS.md. Tests: tests::linear_plan makes bgraat8.bc1, bgrarow264.bc1, BC4 at (8, 264) and BC1 at offset 40, with the GPU layout equal to the CPU's. It refuses BC3, BC5 and BC7 off 16, BC1 at offset 4 and at 260 bytes a row, and BC4 at 8 bytes a row. tests::surface_shapes (a device test) gains bgraat8.bc1, bgrarow264.bc1 and bgraat8.bc4 on every path. docs: linear_plan.rs's Block-compressed surfaces, the plane call, SurfacePlaneShape, BufferRefusal::PlaneShape, the FAST-PATHS known gaps and the API.md accepted differences. Regenerating REFUSALS.md changes only the reach mark. CONFORMANCE-COVERAGE.md and the API signatures are unchanged. (cherry picked from commit ff454bd8b269fff6abf590da85cd050862d539a9) |
||
|
|
0c621da77a |
Make a texture over a surface's plane whose rows are wider than its pitch
Metal makes a 2D texture over a plane of a surface with planes whose rows are wider than the plane's bytesPerRow, and a 1D texture wider than one row; the runtime refused both as NotImplemented(SurfacePlaneShape). On the M3 Max every path reads row y whole from the plane's offset plus y times bytesPerRow (surface_texture_envelope.m's bgra1x2.65x64, bgra1x2.128x32, 420v.p0.65x64, 420v.p1.33x32 and bgra1x2.1d.128), so the texels lie in one place and the 2D texture's rows overlap, on the GPU and the CPU alike. linear_plan::wide_rows makes such a texture of a colour format over a plane whose offset and bytesPerRow are multiples of 16, its GPU layout its CPU one. A 1D texture is one row from the offset. A 2D texture's overlapping rows are held as the rows of a pitch off 16 are: a shadow whose copies reproduce the sharing, refused where a render pass stores into it, blits into it refused (NotImplemented(OverlappingSurfaceRows)), announced as CollidingSurfaceRowWrites. What is new is that the shared head can be wider than the pitch (a byte shared by three rows or more), so plane_copy_regions copies it in in pieces no wider than the pitch, and copies row 0's head back as one row. plane_rows_share_bytes asks the GPU layout alone, as a wide plane's CPU rows share bytes too. Other formats, and planes off 16, stay refused: nothing measured them. The write orders come from overlapping_plane_row_writes.m, extended in the previous commit and run on the M3 Max (macOS 27.0.1, job m3-max-5088, three processes a case), and recorded in its header. The GPU gives the shared bytes the answers it gives the rows of the same GPU pitch and row at a pitch off 16: no one order for blits, and for a kernel the earlier row's within the first threadgroup's rows. Where three rows share a byte, the kernel at 8 x 4 keeps the earliest row's. replaceRegion writes the rows in order, so the latest row's bytes stand, in every shape and process. So the runtime's copy back, which keeps the earliest row's bytes, is one of Metal's kernel answers. Its CPU writes go row by row, as Metal's do. The notice's cost now says "the earliest row's" in place of "the earlier row's", and docs/API.md's catalogue says the same. Tests: - tests::linear_plan: the probe's wide shapes are made, with their layouts. Wide rows off 16, of a depth format or of a 1D texture off 16 are refused. A render target over wide rows is OverlappingRows. - A new sweep: 2232 wide planes, 1302 of them sharing more than a pitch, over five texel sizes, pitches of 16 to 64 and 2 to 4 rows. It holds plane_copy_regions to what Vulkan allows and to the earliest-row rule (hold_the_copies, which now allows the head's pieces and a bufferRowLength of 0). - tests::buffer_texture: its sweep now holds that only a wide plane's CPU rows share bytes, its CPU layout its GPU one. - tests::surface_shapes (a device test): the probe's five wide shapes read as Metal reads them on every path, with a blit into the 2D ones refused. docs: linear_plan.rs's Beyond the plane's rows and Rows that overlap; SurfacePlaneShape, the plane call and BufferRefusal::PlaneShape; the CollidingSurfaceRowWrites declaration and its API.md entry; and the FAST-PATHS known gaps. REFUSALS.md, CONFORMANCE-COVERAGE.md and the API signatures are unchanged when regenerated. Checks: job ids are in the tip's report. (cherry picked from commit 344cd110f8f612907f26dd9a30b0871e299ddb27) |
||
|
|
6b6a7f522b |
Make mipmapped, 3D, multisample and sliced textures over a surface's plane
What. Buffer::new_texture_with_iosurface_plane over a plane of a surface
with planes makes three shapes it answered
NotImplemented(SurfacePlaneShape) for:
- a 2D texture of more than one level, a 3D texture and a 2D multisample
one, of a colour format (linear_plan::apart_from_plane: is_linear and
tail_held): a texture of the device's own memory
(Device::surface_texture_apart), zero when made in every storage mode,
a Private one's too (texture.rs's new Fresh::Zero start, which skips
Metal's fresh pattern and the uncounted held start), announced by the
new Degradation::SurfaceTexelsApart ("surface-texels-apart",
precision). A Memoryless one stays MemorylessSurfacePlane.
- a 2D array of more than one slice, of a colour format, over a plane
whose offset and bytesPerRow are multiples of 16
(linear_plan::slices_apart): its first slice over the plane as a 2D
texture's rows, its others in a tail of the texture's own. The planner
lays the slices one image apart and gives Placed::kept, the second
slice's first byte (or the buffer's length where that comes first);
Texels::kept cuts the tail there instead of at the buffer's length
(with_tail, past, staging), so the shadow's copies, blits and CPU
calls take slice 0 from the plane and the rest from the tail.
Announced by SurfaceTexelsTail, whose doc and cost now name both
cases.
Why. Metal makes these, and on the M3 Max under macOS 27.0.1
(probes/surface_texture_envelope.m, job m3-max-4776) it lays them out in
no one place: bgra1x2.mips2/mips7, 420v.p0.mips2, bgra1x2.3d.d2,
420v.p0.3d.d2 and bgra1x2.2dms4.private read level 0 or slice 0 by blit
and kernel from other bytes than its blits, replaceRegion and getBytes
put there; bgra1x2.2darray.a2 and .a2.64x64 keep slice 0 over the plane
on every path while slice 1 is read at the plane's offset by blits and
getBytes, one image on by kernels, and written at the plane's offset.
By the rule of
|
||
|
|
32b8a9dfa1 |
FAST-PATHS: the guest RAM chunk's first-submission stall as the 780M A/B measured it
The row kept the 231 to 275 ms a /proc stack sampler saw (gem10 job 4750). The A/B of the probe runtime_lane::submit_per_import::submit_per_ram_chunk on the Radeon 780M (gem10 job m3-max-5090, --exclusive, an 8 GiB memfd RAM with its udmabuf source and with_largest_dma_buf at the host's limit, 3 chunks of up to 3.94 GiB, two rounds each) measured more: - the first gather after the idle window, its chunk released and imported again (the plan before this branch): 475.7 and 480.1 ms from commit to completion, 453 and 462 ms of it submitting; with the chunks kept: 2.76 and 2.58 ms (0.49 and 0.32 ms submitting), no import made; - a gather at each 64 MiB: 240.7 and 185.3 ms released, 4.6 and 5.9 ms kept; - steady submission p50 4 s after the objects went: 14.7 and 15.3 us with no chunk live, 16.8 and 16.2 us with 3 kept. The row now gives 231 to 462 ms and both gathers' times, and 14 to 15 us with no chunk. (cherry picked from commit 52f46a21948eee752d2702b42ec171309bd3ab55) |
||
|
|
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) |
||
|
|
8eb3b6df31 |
Lay a heap's one-plane YCbCr texture in Metal's rows, not the carrier's tiles
Apple's nine one-plane YCbCr formats (501, 504, 521, 524, 560, 562, 563, 590, 607), held for copies alone in R16Uint or R32Uint, took the carrier's tiled heap layout in a placement heap: their texels lay in R32Uint/R16Uint tiles, and the texture took the carrier's tiled answer, where the size query answers Metal's packed rows (reims-vgpu's jobs m3-max-4955 to 4985). Metal lays them as rows (probes/one_plane_ycbcr_heap_rows.m on the M3 Max, jobs m3-max-5055 and 5064, every format alike): a 2D texture's rows one packed row apart where the row is a multiple of 16 bytes, a 1D texture's one row, an array's slices at multiples of 128. The runtime now answers them through planes_answer (one_plane_heap_answer, HeapLayout::Measured) and holds them as the 4:2:2 textures are held, always a shadow of the heap's bytes in rows (HeapTextureShape::rows); heap_plane_layout lays a one-plane array's slices at 128 and heap_planes copies such slices a region each. Shapes Metal lays no one way are announced, new Degradation HeapOnePlaneLayout (heap-one-plane-layout): rows off 16 bytes, which Metal's blits lay the row rounded down to 16 apart, lie packed; a mipmapped or 3D texture, whose first level Metal addresses past its answer, lies apart from the heap's bytes (AliasRoute::Unaliased) at Metal's answer. Tests: heap_one_plane_rows (device): six shapes in a 4:2:2 and a 4:4:4 format, every byte of the heap after the copies in and every texel of the copies out where Metal's are, allocatedSize Metal's answer; and the two announced shapes reading what they wrote. The probe header gains what it measured. API.md catalogue entry, api_signatures regenerated. Not yet verified: the device tests, clippy and a control follow. (cherry picked from commit 1e59e4c80f3e28c97ea80c8496e51dd6a94c4c83) |
||
|
|
e2491fe2b7 |
Read a rasterizing state's void-vertex answer from its compile, not a question
2f44dda930's render creations asked whether the vertex function returns a value on every creation, so each plain creation counted one more linked-use question, one more specialized stage entry and one more shared one than its cost record (159 cases over bounds in the whole-set replay, all those counts). The question now runs only where the state turns on it before its compile: with rasterization disabled, and in OpenGL mode. A rasterizing state outside OpenGL mode takes the answer from the vertex entry its compile specializes anyway: the link refuses a rasterizing render pipeline whose vertex stage writes no position (new DescriptorError::RasterizedVoidVertex), and the runtime answers that refusal as Metal's error for a rasterizing void vertex function, as before. The linked-use answers cache treats the vertex answer as owed only where the creation asks it. Tests: a link test refuses a rasterizing void vertex function with and without a fragment, and makes it with rasterization disabled; a runtime test counts one plain render creation at two specialized stage entries and two linked-use questions. api_signatures and REFUSALS.md regenerated. Not yet verified: suites, clippy and the M3 cost records follow. (cherry picked from commit 7f8536158d856886ebedac8c0b6130ff32d22a31) |
||
|
|
2d3b673067 |
Take a blit into a texture at a pitch below the row on Metal's aligned path
A copy into a texture from offset 0, of one image, at a bytesPerRow that is a multiple of 16 below the row was refused Copy(BytesPerRow) as unmeasured. That is the row MTLPixelFormatGetInfoForDevice describes for the one-plane YCbCr formats (a byte a texel for YCBCR8_422_1P, two for YCBCR10_444_1P: half the row), which reims-vgpu's blits use (m3-max-4955 to 4985). Measured (probes/short_row_blits.m, M3 Max, macOS 27.0.1, m3-max-5158): every row of a 32 x 8 texture (64 x 8 for R8Unorm) read whole from its own row's offset at every pitch of the texel from 16 below the row, in eight formats of 1 to 16 bytes a texel, Private and Shared, 166 of 166. The aligned path now takes such a pitch, rows at y x pitch; a pitch of 0 and an offset of 16 or more stay refused. A copy out at such a pitch stays refused: Metal writes the overlapping rows in no one order (m3-max-5170: 900 copies out at half the row, 300 shapes of 12 formats in 3 processes, later-row bytes at some widths, even rows' at others, neither at most, 15 shapes differing between processes). The CPU copies already move nothing below the row, as Metal's. Tests: blit_plan's placed-rows test takes three such pitches; described_row_copies (device) copies in at the described row of both formats and reads each row from its offset, and holds the copy out refused. REFUSALS.md regenerated (the basis states the measurement). Not yet verified: the tests and clippy follow. (cherry picked from commit 3b174b367547b6f6187671d84f01797f9fe8f8ea) |
||
|
|
2fff78740e |
Record that a sparse slice past the texture's costs its other levels and tail what it costs inside
UnitGrid::clipped_region charges a mapping update whose slice is past the texture's own what the same region inside the texture costs: the region clipped to the level's tiles, a page per tile, the slice's whole tail at firstMipmapInTail, and nothing inside the tail past it. That was measured on level 0 alone, and mapping.rs called every other level and the tail unmeasured. sparse_slice_past_levels_usedsize.m (landed with rows2's fixes) ran on the M3 Max (macOS 27.0.1, job m3-max-4446): eighteen shapes, each in its own process and run twice. It used the direct selector, the indirect one and the direct one through a view, over a 2-slice 256x256 nine-level R32Float texture. Every reading is the rule's, and so is every control's on an in-bounds slice: - a tile of level 1 or of level 2 costs one page; - 8x8 tiles on a level holding 2x2 cost four; - a tile of level 3, the first tail level, costs the slice's tail (one page here); - level 5, inside the tail, costs nothing; - an unmap gives the page back. The three forms and the two runs read alike. No behavior changes. - tests::sparse gains the readings row by row, each with its control. - mapping.rs states the rule as measured on those levels and the tail. - The probe's header records what it read. - FAST-PATHS's known gap said the runtime counts none of these pages. It counts the pages Metal's heap counts (sparse/bind.rs charges them through SparseState::charged), as docs/API.md's accepted difference already said, so the known gap now says the same. (cherry picked from commit c4a47fc17d634f750b9c62b6489c95d3d4d5d966) |
||
|
|
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)
|
||
|
|
eb6c13f52b |
Give a render target in place over host pages the storage usage its snapshot reads fetch through
On the Iris Xe (m3-max-4845, the self_reads lane, a 3662x2039 BGRA8 surface over host pages, 30 pairs of a 600x400 draw, a render-target barrier and a draw reading the target at its own pixel), a surface in place (557d9f0905) split every reading draw: 30 splits a frame, 30 copies of the whole surface into the reader's copy (224M texels copied in), 22.4 and 27.2 ms of GPU a frame, where its shadow took the snapshot (cut A, 60b9a69d39): 30 snapshotted draws, no split, 4.7 and 4.3 ms. The in-place image took the feedback loop usage (aliases 1) but not the storage usage, which a snapshot's fetch of the attachment in the pixel interlock reads through (RenderLowering::keeps_own_attachment), so snapshot_wanted fell back to the split: the image was the texture's declared plan's, where a shadow takes undeclared usages (with_undeclared_usage). A texture over host pages that renders, in place, now takes the storage usage too (framebuffer_fetch::storage_candidate over the feedback loop plan, with the view in another format a fetch stores through where the device needs one: ANV's RGBA twin of a BGRA format) where the device's check passed for a shader's writes over the pages' class and the texel is one the check's kernel stores (4, 8 or 16 bytes): with that usage a shader writes the texels in place, which the check's writes cover. Tried first, then the feedback loop plan, then the declared plan: the first the device makes the image in place with. Elsewhere its readers split as before. A rebind asks the writes verdict of an image with storage usage already. Tests: tests::in_place_storage (new, device): a render target in place over host pages has the storage usage only where the check passed for writes there, with the feedback loop usage and a fetch through storage. runtime_lane::snapshot_reads::a_surfaces_readers_take_the_snapshot_at_any_area expects a snapshot for an image in place only where it took the storage usage (Pointer writes: Passed), as for a shadow. Docs: in_place_image.rs (its usage), API.md (textures over host pages in place), FAST-PATHS.md (the attachment-read row: images over host pages, and the shadow only where a texture is one). Verified: cargo fmt; the build, clippy, lavapipe and the Iris A/B and snapshot lane follow in the tip's evidence. (cherry picked from commit e4d61153702293e23bd874cf0830ff22d6be307a) |
||
|
|
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) |
||
|
|
24ceac6e88 |
Make device copies on a discrete GPU of Managed textures over host pages alone
On a discrete GPU, a texture over host pages that only samples or reads, over memory that carries a log of its writes, was a device copy (a shadow in VRAM whose copies in take the rows the log reports) whatever its storage mode: a speed choice, so the GPU read the surface from its own memory instead of across the bus. The owner's ruling of 11-07 (confirmed for discrete): Shared and IOSurface memory over guest pages is used in place over the import, never shadowed to VRAM for speed; Managed keeps Metal's two copies on a discrete Mac. So `Texels::device_copy` now also asks for `Managed` storage and a buffer's bytes (not an IOSurface plane's, whose memory is one copy whatever the descriptor's storage mode): a Shared texture and an IOSurface's are in place over the import where the device's check passed, as on every other device. Tests: the runtime's `a_logged_device_copy_sampled_in_an_inline_pass_is_copied_in_before_the_pass` and the device_copies lane make their buffers Managed (`over_logged_as`, `over_as`); the new lane test `a_shared_surface_over_logged_pages_is_no_device_copy` asserts a Shared surface over logged pages is no device copy on any device, in place exactly where the check passed for pointer pages, and that its reads hold the pages' texels before and after a logged CPU write. Docs: API.md, the runtime README, FAST-PATHS.md's in-place row, the WorkCounts field and the lanes' module docs. (cherry picked from commit fd9fc11dd372a0985fdbc921adb2bc971ff78a3d) |
||
|
|
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) |
||
|
|
669d756fd7 |
Make a texture buffer over a surface's plane at an offset or pitch off 16
What. Buffer::new_texture_with_iosurface_plane makes a TextureBuffer over a plane of a surface with planes whose offset or bytesPerRow is off 16 bytes, where it answered NotImplemented(SurfacePlaneShape). Its texels are placed from the plane's CPU layout (placed.cpu) and go through into_texture_buffer as a buffer's texture buffer does: its CPU calls at the plane's offset, its functions from the offset rounded down to 16. A BC texture off 16 stays refused. SurfacePlaneShape's doc, the module's Beyond the plane's rows, BufferRefusal::PlaneShape and FAST-PATHS.md's known gap say so. Why. Metal makes it, in one place a path. On the M3 Max under macOS 27.0.1 (probes/surface_texture_envelope.m's bgraat8.texbuf.64, bgraat8.texbuf.128 and bgrarow264.texbuf.128, job m3-max-4776) its kernels read texel i from the offset rounded down to 16 plus i texels, and getBytes and replaceRegion from the offset, at a 264-byte pitch as at 256: the layout a texture buffer over a buffer already has in the runtime. What Metal lays out in one place stays in place. Tests: tests::surface_shapes::textures_over_surfaces_take_the_bytes_metal_does gains the three probe shapes over a plane at offset 8 and at 264 bytes a row; a kernel's reads are checked against the rows from the offset rounded down to 16 (gpu_rows_of), the CPU's from the offset. linear_plan's a_surface_plane_s_other_shapes_follow_the_probe places offsets 36, 8 and pitch 264 (CPU offset kept, GPU offset rounded down); its refused row for an off-16 texture buffer goes. Verified (same tree content on the previous base, replay-27 9a1a8abf1d): lavapipe on homelab-gem10-1 (m3-max-4868): runtime lane 174/174 with surface_shapes passing; negative control, the runtime's sources at the base with these tests: surface_shapes fails. Re-checked on this base by the branch's check job. (cherry picked from commit 5da259d2aa40580e62ec41a0aa98a06664521b43) |
||
|
|
b06871f199 |
Refuse a cube or cube array over a surface's plane as Metal's own refusal
What. Buffer::new_texture_with_iosurface_plane over a plane of a surface with planes answers a Cube or CubeArray descriptor Invalid(BufferTextureProblem::TextureType), where it answered NotImplemented(SurfacePlaneShape). BufferTextureProblem::TextureType's doc and basis name the plane's case; SurfacePlaneShape's doc, the module's Beyond the plane's rows, FAST-PATHS.md's known gap and REFUSALS.md (regenerated) follow. Why. Plain Metal itself stops it on the M3 Max under macOS 27.0.1, the release the runtime imitates: with the API validation layer off it asserts "carriesComplexTexture || numFaces == 1" in -[IOGPUMetalTexture initWithDevice:descriptor:iosurface:plane:field:args:argsSize:] and ends the process, for a cube (bgra1x2.cube.16) and a cube array (bgra1x2.cubearray.16) alike (probes/surface_texture_envelope.m, run with --hazard so each shape runs in a child process, job m3-max-4776). What Metal refuses is a typed Invalid, never a runtime gap. Tests: linear_plan's a_surface_plane_s_other_shapes_follow_the_probe expects TextureType for a 64x64 cube and a 16x16 cube array over a planar surface; it fails without the check (both planned PlaneShape). Verified (same tree content on the previous base, replay-27 9a1a8abf1d): runtime unit 56/56 on msi-laptop (m3-max-4867), runtime lane 174/174 on lavapipe on homelab-gem10-1 (m3-max-4868). Re-checked on this base by the branch's check job. (cherry picked from commit 7ea41c39ea9f471fcb14776f9c2c551cb4827209) |
||
|
|
88ddbf4f90 |
Keep a colour plane's texels past its surface in a tail of the texture's own
What. A colour texture of a plane of an IOSurface with planes (Buffer::new_texture_with_iosurface_plane) whose GPU or CPU rows run past the buffer standing for the surface is made. Its texels inside the surface are the buffer's bytes, as every texture over a buffer's are; its texels past it lie in a tail of the texture's own (Texels::past, the form |