Commit Graph
2602 Commits
Author SHA1 Message Date
Anees Iqbal 8d4c3f3db1 linear_runs, merge_scratch: count a window only once the device's in-place check ended
What: each test of the two modules waits for the device's in-place check of
textures over host pages to end before it makes anything (merge_scratch::settled,
where the policy runs one), and opens each window of the device's counts through
merge_scratch::counts_alone, which asserts that no verdict is pending: the check
no longer runs.

Why: an RTX 5080 under load failed
linear_runs::passes_reading_host_pages_form_one_run with 727 passes through
copies for the test's 706. The counts are the device's. The check renders passes
over linear images of its own on its own thread, and the device counts them with
the test's. The rule the test forces (linear_rule_forced) renders those passes
apart too. That run's output holds the clear-copies notice for an R8Unorm linear
attachment, and the test makes no R8Unorm texture. Once every verdict is known,
the check runs no more, so a window opened after it holds the test's work alone,
exactly. The device memory bounds in merge_scratch read the same windows. A
target over host pages made after the verdicts takes its place for good, where
one made before them is a shadow that may move in place at a later commit.

How verified: see the tip's evidence (5080 beside a lane x20, lavapipe, MoltenVK,
and a probe without the settle showing the check running as the window opens).

(cherry picked from commit 17384c19019c8d305f66fa38b63a8f3fd2ffbd25)
2026-11-08 07:13:00 -08:00
Anees Iqbal 21262ee709 Re-pin the runtime sources after the host RAM runs calls, which change no existing answer
irisperf-pairs (8292ae5075, 02b7831f79): BlitCommandEncoder::copy_runs_from_host_ram and
copy_runs_to_host_ram take (buffer byte, host run) pairs, so a laid-out surface copies in one call;
copy_from_host_ram and copy_to_host_ram lay their runs one after another as before, behaviour and
refusals unchanged, so RUNTIME_VERSION stays.

Verified (irisperf): Iris ms01 8653 host RAM copy tests 18/18, negative control fails the
laid-out test; gem10 8633 runtime clippy plain and m2v_gpu, signature/refusal/api_surface 19/19,
lavapipe host_ram 57/57. Iris, a 31.5 MB laid-out BGRA surface downloaded in one call: 1.02 ms GPU
and 1.79 ms CPU against 4.29 ms and 8.78 ms one call per row.
2026-11-08 07:13:00 -08:00
Anees Iqbal 5b7dae6aa6 Runs at their buffer bytes: their span from the lowest and highest bytes, not a reversed range
clippy's reversed_empty_ranges refused the u64::MAX..0 start the span was
folded from (gem10, m3-max-8618); the lowest and highest bytes are folded
apart and make the span once. No behaviour changes.

(cherry picked from commit 02b7831f7985dc892fa32df9d03f4674a56e0969)
2026-11-08 07:12:13 -08:00
Anees Iqbal 748465a50e Host RAM copies of runs each at a byte of the buffer: one call for a laid-out surface
BlitCommandEncoder::copy_runs_from_host_ram(ram, runs, destination) and
copy_runs_to_host_ram(source, ram, runs) take (buffer byte, host run)
pairs, so a device cache that keeps a surface's layout (row r at
base + r * pitch, the padding between rows the guest's and untouched)
copies every row in one call instead of a call a row (the Iris measured
2054 calls at 3.9 ms GPU and 8.1 ms CPU against 0.83 ms and 1.5 ms for one
call of the same runs, m3-max-8523).

The call now holds runs at their buffer bytes (Run); copy_from_host_ram
and copy_to_host_ram lay theirs one after another from their offset
(one_after_another), so their behaviour and refusals are as before. Runs
join where they touch in the RAM and in the buffer (merged). pieces()
places each piece at its buffer byte; the record path takes the span
from the lowest run's first byte to the highest's last for the bindings,
windows and hazard tracking, and the kernel's entries already carry their
buffer word, so only the table's filling changes. Runs that all end on a
word and lie at words of the buffer's memory take the dispatches; others,
and copies that write a destination byte twice (a scatter's host bytes, a
gather's buffer bytes), take regions, in rounds where a byte is named
twice so the later run's bytes stay. For the runs calls, a run past the
buffer is RangeOutOfBounds (the first such run's), and a run at a buffer
byte off a word takes regions instead of being refused.

Tests: a laid-out surface (rows at a pitch over scattered pages, two side
by side, one in each chunk) both ways in one call with sentinels in the
buffer's padding and the whole RAM compared, 4-byte rows by a dispatch per
chunk, 2-byte rows and rows at a buffer byte off a word by regions; a
gather naming one buffer byte twice keeps the later run's bytes; the
runs calls' refusals; unit tests for merging pairs, in_words off a buffer
word and pieces at their buffer bytes. The bench's laid-out one-call form
now uses copy_runs_to_host_ram from the laid-out cache.

Docs: both calls' API docs, the module docs, Problem::HostRam, HOWTO
section 6 and the runtime README; signatures re-blessed (REFUSALS.md
regenerated, unchanged).

(cherry picked from commit 8292ae5075d07cbcd6eada94cf8dc99060792722)
2026-11-08 07:12:13 -08:00
Anees Iqbal 7ae6123b71 Re-pin the runtime sources after the dma-buf lane's view routes and ANV's documented limit, which change no answer
viewimport (5ee3ed96c0..32ba8392a0): a lane test pins each driver's route for a reversed view of
single pages, and HostMemory::with_dma_buf's docs and HOWTO state ANV's limit: it imports a
dma-buf for a plain buffer but reports no external memory for a sparse one, so a view past one
udmabuf's list_limit cannot be assembled from several dma-bufs there and is refused.

Verified (pooledmove): Iris 8540 and 780M 8500 dma_buf_imports 18/18; clippy cpuicd/gpu and
rustdoc (8512).
2026-11-08 06:36:56 -08:00
Anees Iqbal 1c33448daa dma-buf lane: a view of single pages takes the route its device answers; ANV's dma-buf limits documented
What: the reversed-view test now asserts each measured driver's route for a no-copy Shared
buffer over 64 and list_limit + 1 single pages of a memfd in reverse, mapped from the file and
through udmabufs (VM_PFNMAP), placed outside the guest's range, with a dma-buf source:
- RADV: through dma-bufs, one chunk, or two in a sparse buffer;
- ANV: by pointer from the file; through udmabufs, one dma-buf where one udmabuf holds the view,
  else refused (Unsupported, HostMemory) after one request for a single dma-buf of the whole
  view;
- lavapipe: by pointer.
No route is a copy. It prints the mappings the view and the import took.

with_dma_buf's docs and HOWTO now say what ANV does. It imports a dma-buf for a plain buffer but
reports none for a sparse one, so its source is asked for one chunk of the whole length, which one
udmabuf must hold. It refuses the pointer of a mapping of dma-bufs.

Why: a consumer's probe found ANV refusing a view of list_limit + 1 pages mapped through
udmabufs. The runtime's route there was not a copy, nor a skipped source:
- the pointer import of the udmabuf mapping was refused: vkGetMemoryHostPointerPropertiesEXT
  answered memoryTypeBits 0x7f, then vkAllocateMemory with VkImportMemoryHostPointerInfoEXT
  returned VK_ERROR_INVALID_EXTERNAL_HANDLE on memory types 2 and 1;
- the source was then asked;
- vkGetPhysicalDeviceExternalBufferProperties for DMA_BUF reports import for flags 0 but not for
  SPARSE_BINDING, so the request's granule was the whole 4,198,400 bytes, and one udmabuf of 1,025
  items is past list_limit 1024.
No buffer of Vulkan binds more than one imported memory without sparse binding, so the runtime has
no documented path for such a view on ANV.

Verified: diagnostics on a scratch branch (never merged), on the Iris Xe (ms01, job m3-max-8433,
Linux 7.3.1, i915), the 780M (job m3-max-8454) and lavapipe (gem10, job m3-max-8477). The runs of
this test follow.

(cherry picked from commit 32ba8392a0aa8d16b4fceb9b6ed052e5d618b1a0)
2026-11-08 06:36:45 -08:00
Anees Iqbal b4007a1870 dma-buf lane: the reversed view mapped through udmabufs too, as a consumer maps a view of several runs
A consumer maps a view of more than one run of file pages as udmabufs of them, one mapping per
udmabuf (VM_PFNMAP), not from the file a mapping a page. The test now makes each of its two views
both ways (Memfd::view_through_dma_bufs).

Verified so far: cargo fmt only.

(cherry picked from commit b655204695165f3cd9abc664af0245ca2dcf3db8)
2026-11-08 06:36:45 -08:00
Anees Iqbal b0ec2b3811 dma-buf lane: a reversed view of single pages, as a consumer's probe makes one, printed
A no-copy Shared buffer placed outside the guest's range over single pages of a memfd mapped in
reverse order, with a dma-buf source of its pages: over 64 pages, which one udmabuf takes, and
over list_limit + 1, which take two. It prints the making's answer, the source's calls, and the
imports, copies and mappings it took (VIEW-IMPORT), and checks the GPU's read where it is made.

Verified so far: cargo fmt only.

(cherry picked from commit 5ee3ed96c05eeb4c142c958e4f568175ba5ce507)
2026-11-08 06:36:39 -08:00
Anees Iqbal 8329c9e954 RUNTIME_VERSION 1891: in-place YCbCr linear samples take Vulkan's model by default, Metal's behind Exact
video4k (26 commits, f195cfae62..171e80a3c1): DevicePolicy::ycbcr_in_place_reads
(YCbCrInPlacePolicy::Model by default, Exact under exact_answers) for linear samples of two-plane
4:2:0 planes read in place through texel buffers, which no device filters natively: the model
blends 4 luma and 4 chroma fetches with midpoint siting and Metal's coefficients, recorded as
HalfSampleFilter/FloatSampleFilter and announced ycbcr-filter-not-exact; Exact keeps Metal's filter.
FAST-PATHS row, both settings tested. The conversion's staging buffer, sets and refresh are made at
the first conversion, and the device-conversion notice is announced there. SEMANTICS_VERSION 1993
(the branch's). Lane fixes for devices that convert the format (780M), and half reads off Metal's
texture unit take the device's rounding (PrecisionNote::HalfTexelConversion, one half ulp).

Verified (video4k): 780M um870 8546 core 31/31, runtime ycbcr 5/5, aligned_byte 2/2, lane ycbcr
48/48; M3 8549 core 31/31, runtime 7/7, lane 48/48; 780M linear sample 1314-1744 us model against
3094-7793 us exact. gem10 780M lane 8547 and clippy x3/rustdoc/lavapipe 8550 follow post-merge.
2026-11-08 06:30:41 -08:00
Anees Iqbal 31bfbd22a9 ycbcr lanes: half reads and gathers off Metal's texture unit take the device's rounding
On the Radeon 780M the half read() and gathers of the _sRGB twins and the 10-bit 4:2:2 and
packed twins, whose images hold steps of 1/8192, lay one half ulp under Metal's at exact ties
(srgb_twins_read_what_metal_reads, four_two_two_and_four_four_four_textures_read_what_metal_reads,
packed_textures_read_what_metal_reads, ycbcr_textures_over_plane_1_read_its_codes_as_luma,
ycbcr_half_gathers_round_ties_away; um870 m3-max-8485, and at this branch's earlier tip
a8a6379b44, um870 m3-max-8499, and development's 7f2257b8af, gem10 m3-max-8421): the device's
conversion of the float texel to half rounds to nearest even, where Metal's rounds a YCbCr step
with ties away from zero. That is the device's native conversion (rule 1): the translation keeps
Metal's ties only through the routine on Metal's own texture unit (lower/texture/half.rs) and
records PrecisionNote::HalfTexelConversion for every half access off it, bound within one half
ulp of Metal's. The lanes read only NativeHalfConversion from read_half's stage as the device's
rounding, so they held such a read to Metal's ties.

Kernels::native_half now takes either note, and a half read or gather that rounds by the device
lies within one half ulp of Metal's (asserted), counted and printed as before.

Verified: cargo fmt; the 780M runs follow.
(cherry picked from commit 171e80a3c1f31234d05498cebad78268cec8aa37)
2026-11-08 06:29:49 -08:00
Anees Iqbal b2b9d89365 video lane: name the made textures' type, and pass the device as borrowed
Clippy under --cfg m2v_gpu (gem10 m3-max-8484): the kept textures' type was very complex
(type_complexity), and parts() borrowed its already borrowed device (needless_borrow).

Verified: cargo fmt; clippy follows.
(cherry picked from commit 884a3691d6987046276b43c1a63b70ec914333dd)
2026-11-08 06:29:49 -08:00
Anees Iqbal 4e7f229fac ycbcr lanes: the slot test's codes, P3 reads and outside samples on a device that converts the format
On the 780M (um870 m3-max-8485, this branch over development 7f2257b8af):
- a_ycbcr_slot_takes_the_devices_filter_in_the_pipeline_its_creation_made built Metal's steps
  from the twin's half bytes, which took the name of the surface's bytes: the surface is planes.
- textures_over_any_surface_read_what_metal_reads held a P3 surface's codes to Metal's 9/3/3/1
  sums where the device reconstructs them itself (YCBCR8_420_2P under DciP3: a chroma code 178
  where Metal's is 179): such a texture's read is now the nearest codes to the device's
  reconstruction, as the code twins' are (assert_read_codes).
- ycbcr_samples_outside_read_metals_modes held the samples of a texture whose planes are read in
  place to the image's texels, the device's conversion: the texels there are the texture's
  nearest samples at their centres, Metal's conversion of the codes, whose addressing the test
  checks.

Verified: cargo fmt; the 780M runs follow.
(cherry picked from commit 9dfe7b1bc575efeabd6c58a96c841956634dc843)
2026-11-08 06:29:49 -08:00
Anees Iqbal 9c71f43c0c ycbcr lanes: the slot test names Metal's codes apart from its sampler flag
The closure of Metal's steps took the name of the device's MetalSampler flag, which the notice
check reads after it (E0308, E0600; um870 m3-max-8468).

Verified: cargo fmt; the builds follow.
(cherry picked from commit 255aada33dd15eaeb3ca4657f8ebe484ba8071bd)
2026-11-08 06:29:49 -08:00
Anees Iqbal ded385b661 YCbCr textures: announce the device's conversion at the first conversion; the lanes read in-place samples as Metal's
On the Radeon 780M, which converts the 4:2:0 formats itself and reads their planes in place, the
ycbcr lanes failed 9 of 48 at this branch (um870 m3-max-8383) and 17 of 48 at development's tip
(gem10 m3-max-8421), the same 9 among them. Two causes:

- A texture whose conversion is the device's announced ycbcr-filter-not-exact as it was made,
  though a texture whose planes every function reads in place never converts and so never reads
  the device's conversion (a_ycbcr_texture_sampled_and_gathered_by_one_function_reads_its_planes_in_place,
  a_ycbcr_sample_through_an_unmeasured_filter_is_announced). Converts::new now announces it at
  the texture's first conversion. WorkCounts::ycbcr_device_conversions still counts the texture
  as it is made, so a lane can tell before a read that the texture's image holds the device's
  conversion. The lanes' notice predicates now take a conversion that ran,
  WorkCounts::ycbcr_device_samples (device_samples), in place of the textures made.
- The lanes held the samples of a texture whose planes are read in place to its image's texels,
  the device's conversion on such a device, where a function reading the planes converts the codes
  itself: Metal's conversion and filter under the lane's exact_answers (YCbCrInPlacePolicy::Exact),
  as ycbcr.rs states. Texels::sampled takes Metal's steps of the codes (modelled) for a texture read
  in place and the image's texels elsewhere, in a_linear_sample_of_a_ycbcr_texture_is_metals,
  a_linear_sample_is_metals_through_each_sampler_and_result and its fragment twin,
  a_ycbcr_slot_takes_the_devices_filter_in_the_pipeline_its_creation_made and
  ycbcr_textures_read_the_texels_metal_converts; a_draw_samples_the_planes_as_written_before_it
  holds a draw read in place to Metal's conversion of the uniform codes.

four_two_two_and_four_four_four_codes_read_what_metal_reads also held a code twin over a surface
whose chroma plane it does not fit in to Metal's codes where the device reconstructs them itself:
it now takes the device's codes there, as the test's other surfaces do.

Docs: the ycbcr.rs and ycbcr_device.rs module docs, Degradation::YCbCrFilterNotExact and its
docs/API.md catalogue entry say the notice comes at the first conversion.

Verified: cargo fmt; the 780M runs on um870 and gem10 follow.
(cherry picked from commit c498f9383a3f4a2ef3f267a135ea5494aa8fb5e4)
2026-11-08 06:29:49 -08:00
Anees Iqbal b15443f18d video lane: the frame over device caches made with and without aligned_byte
video_device_cache_costs (ignored, a release-mode measurement): the 10-bit 4K frame's planes at
CoreVideo's offsets (luma 32 bytes in, chroma right after its rows) in Private buffers of the
runtime's own, as a consumer that lands each decoded frame in a device cache; the frame's bytes
blitted into the cache in each frame's command buffer before the pass that samples the planes.
The caches are made without BufferDescriptor::aligned_byte, then laying byte 32 on a multiple of
256, printing (VIDEO-CACHE) the planes' placements, the GPU time and every work count the frames
moved. frame() takes the optional blit.

Verified: cargo fmt; the 780M run follows.
(cherry picked from commit 36abe1b4909c2b2238fcb06cd9c8545230306982)
2026-11-08 06:29:49 -08:00
Anees Iqbal 1c3bf462f9 video lane: the plane placement probe also makes plane textures a pass renders into
The consumer asks whether its plane textures go in place for reads, renders and shader writes.
The probe now makes each plane, at each offset and over each buffer, with ShaderRead |
RenderTarget beside ShaderRead and ShaderRead | ShaderWrite.

Verified: cargo fmt; run by the jobs that follow.
(cherry picked from commit caba7fc304d06e4df1e32142ab176509f7181996)
2026-11-08 06:29:48 -08:00
Anees Iqbal 10e85b3990 in_place model: walk each channel's coefficients by iterators, not an index
Plain clippy on Linux (gem10 m3-max-8336) refused m[channel] under lower/'s
deny(clippy::indexing_slicing). The three matrices' coefficient triples are now zipped into one
triple per channel for each range, so no index is taken.

Verified: cargo fmt; clippy runs in the job that follows.
(cherry picked from commit 62c42e8d9501f45b080d89527c1da4fbdff73481)
2026-11-08 06:29:48 -08:00
Anees Iqbal be9e3547b2 YCbCr conversion: count and announce the device's conversion once, as the texture is made
The lazy conversion (a9d9712869) announced the device's conversion as the texture was made and
again where its first conversion made the device's sampling, and counted it only there. On the
Radeon 780M (um870 job m3-max-8351) tests::ycbcr_device saw the notice twice (2 against 1), and
the ycbcr_textures lane, which reads a texture made while ycbcr_device_conversions grows as the
device's, held the device's texels of a kept image to Metal's grid (688.5 off the grid).

Both now happen once, in YCbCrConversion::new, where the texture is made, as before the
conversion was made lazily: Converts::new takes the device's conversion on the same terms (the
staging copy's planes at BYTES_AT, a multiple of 4, of the staging buffer's own VkBuffer) and
neither counts nor announces, nor does YCbCrDeviceSampling::new. The WorkCounts docs say the
count is taken as the texture is made.

Verified: cargo fmt; the 780M run follows.
(cherry picked from commit 9bd9b9077b25718979af0486c45c2ad7bb4a7b95)
2026-11-08 06:29:48 -08:00
Anees Iqbal 26db05e481 video lane: the plane placement probe also runs over Shared and Private buffers of the runtime's
A consumer may land decoded pictures in a buffer of the runtime's own and make its plane
textures over that. The probe now makes a Shared and a Private buffer and prints for each its
gpuAddress, its contents' offset into a page and the device's linear texture alignment of each
plane format, then where each plane texture lies (an image over the buffer's memory where no
shadow was counted).

Verified: cargo fmt; run on the 780M and the Iris Xe by the jobs that follow.
(cherry picked from commit 42d0566041fe3babb3a034c2780ec8896c9d7dbd)
2026-11-08 06:29:48 -08:00
Anees Iqbal 2225dac857 video lane: the plane placement probe also runs over a guest RAM's buffers
The consumer's surfaces are no-copy buffers over a HostRam of a memfd with a dma-buf source.
video_plane_placements now probes two buffers over such a RAM (the first object over its chunk,
in a run's import, and the one after it) beside anonymous pages and a memfd's pages with a
source, and prints for each buffer the imports read apart for a texture, the dma-buf images and
the dma-buf imports its textures took.

Verified: cargo fmt; run on the 780M by the job that follows.
(cherry picked from commit 57e3a5832e1dcc719d615cce875391b1fe8a76d7)
2026-11-08 06:29:48 -08:00
Anees Iqbal 7cc28f5c76 ycbcr_in_place lane: the model's reference converts with Metal's full-range chroma scale
The defaults test failed on the M3 (m3-max-8314): YCBCR84202P (Full, Bt709) half linear sample
at texel (18, 0), blue 0.69238 against the reference's 0.69498. The in-place model converts with
Metal's coefficients (bind::ycbcr_convert), whose full-range chroma is centred and scaled over
2^n (15201 / 2^23 a 10-bit unit for blue is 1.8556 / 1024), where the lane's reference used
Vulkan's conversion, over 2^n - 1: 1.8556 x 0.35 / 255 is the 0.0026 seen. model_read applies
Metal's scale before Vulkan's conversion; the video range, where the two agree, is unchanged.

The probe's VIDEO-PLACEMENT line loses a run of spaces a Python line join put in it.

Verified: cargo fmt; the M3 run follows.
(cherry picked from commit c72821400a17b722bdbb82e4d9b5e811a1def90b)
2026-11-08 06:29:48 -08:00
Anees Iqbal 4f4205852b video lane: settle in-place checks, planes 256 bytes into their pages, a plane placement probe
The video lane's devices now settle their in-place checks before measuring, so a texture over
host pages takes the placement of a session whose verdicts are known rather than Pending.

Form::AlignedPlanes runs the R16Unorm/RG16Unorm frame with both planes 256 bytes into their
pages, against CoreVideo's 32 (Form::Planes): the same frame where RADV can lay a
DRM_FORMAT_MOD_LINEAR plane, for an A/B of the shadow copies against in place.

video_plane_placements prints, for CoreVideo's 8-bit 420v planes (R8Unorm, RG8Unorm, rows 3840)
and 10-bit x420 planes (R16Unorm, RG16Unorm, rows 7680) at 0, 32, 64, 128 and 256 bytes into
their page, sampled alone and written too, over anonymous and guest-RAM dma-buf pages, the
placement answered and what the making took, then the shadowed-texture notices' words.

Verified: cargo fmt; built and run by the jobs that follow.
(cherry picked from commit 222dd960ab0c32b5cfb31fadba5289fa68f9cb95)
2026-11-08 06:29:48 -08:00
Anees Iqbal 0af2708aaf ycbcr_in_place lane: under the defaults a linear sample of planes read in place is the model's
m3-max-8291: a_ycbcr_texture_reads_its_planes_in_place_under_the_defaults
asserted Metal's grid for linear samples, which the default model leaves.
Under the defaults the lane now checks linear samples (at the centre, half
result, and between texels) against Vulkan's model of the codes' bilinear
blend within 2e-3 (2.5e-3 for half), and ycbcr-filter-not-exact announced
once; the exact_answers test keeps Metal's bits.

(cherry picked from commit 14699ca22fe400f701619e6a752b615ccee581dc)
2026-11-08 06:29:48 -08:00
Anees Iqbal 3b2468a2cd api_signatures and api_surface name YCbCrInPlacePolicy and DevicePolicy::ycbcr_in_place_reads
signatures.py --bless added the enum, its two variants and the field;
refusal_surface.py left docs/REFUSALS.md unchanged.

(cherry picked from commit 84ad350e42fffe982c5b768c5879ceb5de5a2f6f)
2026-11-08 06:29:48 -08:00
Anees Iqbal ed618c7102 Read the made conversion's refresh; the sample-and-gather test reads the note's clauses
m3-max-8228: the conversion's record still named self.refresh. An artifact
lists a specialized note among its precision notes too, so the test checks
that every clause of the model's note tests the bound sampler word.

(cherry picked from commit 6ceb3a2d3ecc76bca49d83bac92d11eb072b31ed)
2026-11-08 06:29:48 -08:00
Anees Iqbal dfdbca7d72 in_place model: weigh a chroma pair's lanes by a vec2; the lane's exact policy set by field
FMix takes operands of one type: the chroma pairs' blend now splats its
weights (m3-max-8217: ExtOperand FMix Mismatch). DevicePolicy is
non_exhaustive, so the validation lane sets the field on the default.

(cherry picked from commit 09a868c38f8fd693327bd5214b8b8ba7feb91d43)
2026-11-08 06:29:47 -08:00
Anees Iqbal d119fdeca7 YCbCr conversion: make its staging buffer, sets and refresh at its first conversion
A two-plane YCbCr texture whose planes a function reads in place still made
its conversion's staging buffer (the planes' whole byte range, 24.9 MB for a
4K x420 frame), its kernels' descriptor sets and its refresh as it was made,
though no function of it converted. On the 780M a texture made each frame
paid that every frame.

YCbCrConversion now holds what its making takes and makes the rest at its
first conversion: Encoder::plan_shadows prepares every shadow a command uses
(ShadowCopies::prepare), the one place a copy in is planned. The device's
own conversion is still announced as the texture is made. The converted
image itself is still made with the texture.

Test: ycbcr_in_place_loop::a_texture_read_only_in_place_makes_no_conversion
(no scratch buffer after two sampling dispatches of a texture read in
place; one after its first read()).

(cherry picked from commit 05cb080a878384e254921d0d97b4b7872ee4c175)
2026-11-08 06:29:47 -08:00
Anees Iqbal 2ade9a7971 in_place model: borrow the builder once per call, halve the chroma size by a shift
Built on gem10 (m3-max-8204): five double mutable borrows of the function
builder in the model's sample.

(cherry picked from commit 87fb0eec5e8406e907077033521198db5eda9060)
2026-11-08 06:29:47 -08:00
Anees Iqbal 5640e17560 Document the model's linear sample of planes read in place
FAST-PATHS.md gets the ledger row for ycbcr_in_place_reads (Model default,
Exact switch, the 780M's exact-form cost measured at development's tip),
the device-gaps row and the in-place section name the choice; API.md's
policy list and the half/float filter and ycbcr-filter-not-exact catalogue
entries name the model; PrecisionNote::HalfSampleFilter/FloatSampleFilter
and Degradation::YCbCrFilterNotExact docs say the model records and
announces them.

(cherry picked from commit 5f83699d296386c3b0b357f2baa63cfefc086096)
2026-11-08 06:29:47 -08:00
Anees Iqbal 843d22b0f5 YCbCrInPlacePolicy: the model's linear sample of planes read in place, Metal's behind Exact
A function that reads a two-plane YCbCr texture's planes in place (a
uniform texel buffer over their codes, on an integrated GPU or a CPU
device) filtered every linear sample as Metal does: four taps, each five
fetches, its chroma weighted 9/3/3/1 and rounded to a code, a fixed-point
conversion with a division, then Metal's exact sum on the grid 2048. On
the Radeon 780M that sampling cost 6.4-6.9 ms of GPU time per 4K frame.

DevicePolicy::ycbcr_in_place_reads now chooses between the model (the
default) and Exact (DevicePolicy::exact_answers). The model is Vulkan's
Y'CbCr model as the device's own conversion with a linear chroma filter
computes it: four luma codes and four chroma pairs blended bilinearly
(midpoint siting), then the surface's range and matrix (Metal's
coefficients) in float, clamped into [0, 1]: eight fetches. A nearest
sample, a border address mode, an offset placed by a parent's size and a
gather stay Metal's under either value; a runtime sampler decides by its
word as the function runs. The model records PrecisionNote::HalfSampleFilter
or FloatSampleFilter under the bound converted 4:2:0 format (and the
runtime sampler's linear, border-free word), which the runtime announces as
ycbcr-filter-not-exact.

The profile carries the choice (its fingerprint moves), SEMANTICS_VERSION
1993. Tests: the Metal-bits test runs under Exact, a new engine test checks
the model against an f64 model on lavapipe and MoltenVK profiles, the
fast_paths tests check the switch. The measurement lane times the planes
read in place under both values.

(cherry picked from commit 6c6d803e93910860a4b9e8a0659ecc472dfa7cbc)
2026-11-08 06:29:47 -08:00
Anees Iqbal bade784717 video_frames: the image's route for the same frame, and each case's route counts
A swizzled YCBCR10_420_2P texture keeps its converted image on every device,
so the same shader and sampler take the image's route (refresh, conversion,
the device's filter) beside the planes read in place.

(cherry picked from commit 7e10f693b3a732af5e8d59ab64dbc89fbe676203)
2026-11-08 06:29:47 -08:00
Anees Iqbal a921a330c5 video_frames: measure on the consumer's default policy, and take the frame apart
The lane devices take DevicePolicy::exact_answers and keep execution
records; a consumer's device takes neither. video_frame_parts samples each
form linear and nearest, over pages the CPU writes each frame and over
pages left as written.

(cherry picked from commit 6e8d0d47f1958feae2fb63a3ad2c12aa08213987)
2026-11-08 06:29:47 -08:00
Anees Iqbal 27d9fca36a video_frames: take AirLibrary into scope
(cherry picked from commit b7414b7a76af81d83cd3dc0f77a592f09ceccb57)
2026-11-08 06:29:47 -08:00
Anees Iqbal 821a2d55e2 video_frames: bind texture indices as u32
(cherry picked from commit 5ebc8623e41edef906c4253e6e248b56927c9199)
2026-11-08 06:29:47 -08:00
Anees Iqbal 065e76c632 video_frames: measure a guest's 4K P010 video frame on the device
A report-only lane (ignored by default, release builds): the CPU writes a whole
3840x2160 P010 frame (CoreVideo's x420 layout, planes 32 bytes into their
pages, 7680-byte rows) into the next of three surfaces over host pages, then one
render pass samples it into a 3840x2160 BGRA8 target, through a YCBCR10_420_2P
texture or R16Unorm and RG16Unorm plane textures. Printed: each texture's
placement, the frame's GPU time, host times and every work count it moved.

Verified: build only so far (potluck).
(cherry picked from commit f195cfae62584274979d612e46da2a8fbe2ffed2)
2026-11-08 06:29:46 -08:00
Anees Iqbal 2e381ae1f0 RUNTIME_VERSION 1890: host RAM copies of runs of words take the page kernel's dispatches
irisperf-words (562fc5fc52): the pages-copy kernel's table entries carry a word count (at most
1024; a whole page is one entry as before), so copies whose runs start, end and land on words take
dispatches; only runs that end off a word, and a scatter that writes a byte twice, keep
vkCmdCopyBuffer regions. Re-pinned.

Verified (irisperf): Iris ms01 8523 host RAM copy tests 17/17, negative control fails the new
device test; gem10 8466 clippy plain and m2v_gpu, translator tests 24/24, lavapipe host_ram 56/56.
Iris, a 31.5 MB surface of 4-byte texel rows over 7703 runs downloaded in one call: GPU 0.83 ms by
the kernel against 13.5 ms by regions and 4.3 ms by the page view's blits, no mapping.
2026-11-08 06:21:17 -08:00
Anees Iqbal b30da69b50 Host RAM copies of runs of words take the pages copy's dispatches, not regions
The pages copy's table entries become three words: the run's first word in
the scattered binding, its first word in the consecutive one (from the
shape's first_word) and its words, at most a page's 1024. Each invocation
copies its strided words below the run's count. Whole pages are entries of
1024 words, one a page as before, so their tables' entries, dispatches and
windows are unchanged.

In the runtime, a copy whose runs all end on a word (they already start on
one, and the buffer's bytes too) takes the dispatches: plan() cuts each
piece into runs of at most a page from its start and where a window of the
buffer ends. Only runs that end off a word (rows of 1- or 2-byte texels),
or a scatter whose runs write a byte twice (share_a_byte, so the later
run's bytes stay as with regions), keep vkCmdCopyBuffer regions.

The Iris measured regions at about 1.6 us of GPU and 1 us of CPU each
(m3-max-8389: 8853 regions of a 31.5 MB surface, 14.0 ms GPU, against 0.99
ms for the page kernel over the same pages).

Tests: the kernel's interpreter test of word runs (a word, 128, 129, a run
across a page, a page less a word) with no word around them changed; the
plan's cuts at a page and at a window's end; a device test of rows of 2044
bytes at a 2048 pitch from 16 bytes into a page, a run ending a word before
a page's end, three pages and more from inside a page, one across the
chunks' end and a word, with sentinels over every touched page, a dispatch
per chunk and no region both ways, and a twice-named scatter of word runs
by regions, the later run kept. The regions refusal case now ends off a
word. The bench measures rows of 4-byte texels (dispatches), of 2-byte
texels (regions) and 2046 bytes at a 2048 pitch.

Docs: the kernel's module and entry docs, the copy module, both calls' API
docs, HOWTO and the runtime README; signatures re-blessed (entry() takes
the run's words and returns 12 bytes; ENTRY_WORDS).

(cherry picked from commit 562fc5fc526cce2b31db280c4bbffb29314f8ac4)
2026-11-08 06:20:15 -08:00
Anees Iqbal 903294c24c Re-bless the authored compile census at 0578e213c0
Its product fingerprint follows development's versions at 0578e213c0. Blessed on the
M3 (s37-pl.sh censusbless --bless, dv-m3).

(cherry picked from commit 990f74d2e57c53b7a2200b11d05795461c9a1389)
2026-11-08 06:19:22 -08:00
Anees Iqbal 0578e213c0 Re-pin the runtime sources after BufferDescriptor::aligned_byte, which changes no existing answer
aligned_byte (bef28766ee, ed3f0801da) is an opt-in runtime extension for the runtime's own memory:
a buffer's chosen byte lands on a multiple of 256 bytes of its memory (refused with NoCopy,
Problem::AlignedByteNoCopy), so textures over planes at that byte alias the memory on RADV. A
buffer made without it is laid out as before, so RUNTIME_VERSION stays.

Verified (video4k): 780M gem10 8456 tests::aligned_byte 2/2, all 24 planes (R8/RG8/R16/RG16 at
0x20, 0x7e9020, 0xfd2020; read, write, render; Shared and Private) alias with the option and are
shadows at 0x20 without it; lavapipe and clippy 8457 2/2; 780M device-cache A/B 8485: 10-bit 4K
frame, 10,368,000 texels copied a frame and GPU 1946 us without, 0 and 1262 us with it.
2026-11-08 06:07:13 -08:00
Anees Iqbal 3587dde9da BufferDescriptor::aligned_byte: pass the placement and the aligned byte as one pair
zero_buffer handed buffer_of_length the placement and the byte apart, where it takes them as one
(Place, Option<u64>) pair (E0061; um870 m3-max-8425, gem10 m3-max-8426).

Verified: cargo fmt; the builds follow.
(cherry picked from commit ed3f0801da87a9031bc6e98885c2d3c22e6a4293)
2026-11-08 06:06:13 -08:00
Anees Iqbal 6ba9ac779f BufferDescriptor::aligned_byte: lay a buffer's byte on a multiple of 256 bytes of its memory
A consumer that lands decoded frames in a buffer of the runtime's own memory makes plane textures
at CoreVideo's offsets: the first plane 32 bytes into the surface, the second 32 bytes past a
multiple of 256 after the first's rows. A linear image aliasing the buffer binds at the buffer's
memory offset plus the texture's, which must meet the device's linear-image alignment (256 on
RADV, 128 on NVIDIA, 64 on lavapipe), and the runtime starts each buffer on a multiple of 256, so
those planes are shadows there (the 780M probe, um870 m3-max-8351: Shared and Private buffers,
in place at 0 and 256, shadows at 32, 64 and 128).

BufferDescriptor::aligned_byte (with_aligned_byte), a runtime extension for the runtime's own
memory, names the byte to lay on a multiple of 256 (LINEAR_IMAGE_ALIGNMENT). placed_new_buffer
then makes the VkBuffer that byte's shortfall longer, binds it where its placement starts, and
starts the buffer's bytes that many bytes into both (BufferParts offset and base, the mechanism
host imports use), so the byte lands on the multiple and textures there alias the memory. Such a
buffer is never parked nor taken from the parked, and lies in no fresh pages. Its length and
gpuAddress (the runtime's address space's) are unchanged; a Shared one's contents start the
byte's remainder short of a multiple of 256, which the field's docs name against Metal's
page-aligned contents. Refused with NoCopy contents (Problem::AlignedByteNoCopy).

tests::aligned_byte: over Shared and Private buffers laying byte 0x20, the 8-bit and 10-bit
frames' planes (R8/RG8 at rows 3840, R16/RG16 at rows 7680; the second plane at 0x20 + 0x7E9000
or 0xFD2000), sampled, written and rendered into, alias wherever the same texture at offset 0 of
a plain buffer does, and are shadows at 0x20 of a plain buffer wherever the device's linear
alignment is past 32; a blit of each sampled plane reads the bytes at its offset; length,
gpuAddress and contents as above; the refusal over NoCopy. Docs: the field, HOWTO, API.md's
shadowed-texture entry, the runtime README; api_signatures blessed and REFUSALS.md regenerated.

New public items: BufferDescriptor::aligned_byte, BufferDescriptor::with_aligned_byte,
Problem::AlignedByteNoCopy.

Verified: cargo fmt; the 780M, lavapipe and Iris runs follow.
(cherry picked from commit bef28766eee658ef30dfcc5d0492a1493171b34d)
2026-11-08 06:06:13 -08:00
Anees Iqbal 817f81470a submission_checks: hold the signaller's signals in flight at a gate the test opens
an_event_wait_a_gpu_signal_in_flight_meets_is_checked_at_once failed on the
RTX 5080 laptop in a batch beside a second lane (pkg 104 C): "at commit
false: the signaller never ran at the waiter's scheduling in 9 tries".
Its window was the signaller's GPU time: fills doubling from 4 to 1024 of
64 MiB, each try passing only where the waiter read Scheduled, and the
test thread read the companion event, before the fills ended. That window
hangs on the GPU's speed and on the host's load (it was already raised
once, from 7 tries to 9, after a host acting 145 ms late), and the two
sibling tests shared it.

Now the signaller first waits for a plain event's value 1 whose one signal
the test reserved (Event::reserve_vk_signal) and gives from the host
(vkSignalSemaphore of the reserved counter) once it looked. A plain
event's wait for a reserved signal goes to its VkQueue at once, so the
signaller is submitted and scheduled, its signals in flight and held on
the GPU until the gate opens, on every device and at any load. So each
of the three GPU-signal tests runs once, deterministic:
- the Event wait: the waiter reads Scheduled with the companion still 0,
  its check read 0, no head awaited, its fill ran; printed: how long
  after the signaller the waiter was scheduled (scheduled handlers);
- the SharedEvent wait detached in flight: companion 0 at the detach,
  checked at 1 off the committing thread, a head awaited, code 8;
- the SharedEvent wait the host meets: checked at 0, then runs.
A run dropped with its gate closed (a failed assertion) opens it, so no
command buffer waits for good. The fills, FILL and ATTEMPTS are gone.

Verified: pending (20 runs on the RTX 5080 beside a second lane, lavapipe).
(cherry picked from commit 6739c5034582bd954406c63c7c1e26f01060af12)
2026-11-08 05:47:23 -08:00
Anees Iqbal 0221b25946 RUNTIME_VERSION 1889: host RAM copies take runs at word starts and any end
irisperf-runs (1ba8aba840, f65c492f82): copy_from_host_ram and copy_to_host_ram take runs that
start on a 4-byte word and end at any byte; runs that are not whole pages copy by vkCmdCopyBuffer
regions between the chunk's import and the buffer (WorkCounts::host_ram_copy_regions), whole-page
runs keep the page-table kernel. Calls refused before (a laid-out device cache's row-cut runs,
reims-vgpu's downloads on the Iris) now copy, so the version is bumped. Re-pinned.

Verified (irisperf): Iris ms01 8389, host_ram_copy_device 10/10, negative control (whole pages
only) fails the new test; gem10 lavapipe host_ram 54/54 under nextest (8408), runtime clippy plain
and m2v_gpu (8420), signatures and refusal surface (8373). Iris 31.5 MB surface over 7703 runs:
no mappings (the page-view fallback made 7703, 15.5 ms of host work a download); GPU 14.0 ms by
regions against 9.9 ms for the view's blits.
2026-11-08 05:45:42 -08:00
Anees Iqbal 707a08c636 Host RAM run tests: rows that touch start on a word, one run named by one()
The merged() unit test joined a row starting 2 bytes off a word, which
the new rule refuses (lavapipe, job m3-max-8373), and clippy's
single_range_in_vec_init flagged a one-run array. The touching rows now
start on words and the one-run case uses the one() helper.

(cherry picked from commit f65c492f82e4f6753b6b62d56aa2d92f61831513)
2026-11-08 05:44:56 -08:00
Anees Iqbal fe5f08a4b1 Host RAM copies take runs at word starts and any end, copied by regions
reims's laid-out device cache downloads hand copy_to_host_ram each texel
row's bytes (encode_out): runs that start on the device's linear texture
alignment, always a 4-byte word, and end at any byte, short of the row's
padding, which the guest's CPU owns. merged() refused every such run
(Problem::HostRam) and the consumer fell back to a view of the surface's
pages: on ANV one mapping per 4 KiB page, 278 of 294 device caches in
boot 8267.

Now a run starts on a 4-byte word and ends at any byte past it. Copies
whose runs are all whole 4 KiB pages keep the pages copy's one dispatch
per chunk, unchanged. Any other copy records each run's bytes in a chunk
as a region of vkCmdCopyBuffer between the import that holds them (whole
pages, imported as before) and the buffer: byte offsets and sizes, so no
other byte of the runs' pages is read or written. The regions of one
import are one command, at most 1024 each (MOST_REGIONS). A scatter whose
runs name a byte twice takes a round of commands per overlap, so no byte
is written by two regions of one command (VUID-vkCmdCopyBuffer-pRegions-12482),
the later run's bytes left; a buffer over host pages the runs overlap is
refused (VUID-vkCmdCopyBuffer-pRegions-00117). Counted in the new
WorkCounts::host_ram_copy_regions.

Tests: copy.rs's unit tests (word starts, any ends, rows that touch merge,
whole_pages, rounds); host_ram_copy_device's
runs_inside_pages_move_their_bytes_alone_and_leave_the_rest_of_their_pages
(2046-byte rows at a 2048 pitch from 16 bytes into a page, a run ending 2
bytes before a page's end, one across the first chunk's end, one of 3
bytes; pattern sentinels around them; gather into Shared and Private,
scatter back; 10 regions, no dispatch; twice-named bytes; the overlapping
buffer refused); the whole-page test now also asserts no regions; the
refusal test's cases off a word. host_ram_copy_bench gains the laid-out
download: a call a row, one call, and the view with a blit a row.

Docs: copy.rs module and both calls' API docs, Problem::HostRam,
docs/HOWTO.md, the runtime README; docs/REFUSALS.md regenerated and the
API signatures re-blessed (the new WorkCounts field).

(cherry picked from commit 1ba8aba84076208a1eccaf65dd4993058ed53431)
2026-11-08 05:44:56 -08:00
Anees Iqbal 7f2257b8af Re-pin the runtime sources after the in-place lane's usage-reach fix, which changes no answer
The lane's write-or-pass-beyond-the-usage test predicted in place from the verdicts alone; it now
follows the placement query's answers for the three usage sets (in_place_image.rs's module doc
states the tie order). On the 5080 at 1024-byte rows the render-target image is refused at the
pitch (Shadow(Refused(Pitch))), so the pass renders through its shadow, as the runtime chose.

Verified (pooledmove): 5080 c entry pm-usage-reach-1 (batch 8349) 3/3 in_place_textures incl.
the round 5ce ln02 failure; lavapipe 10/10 (8223); clippy cpuicd/gpu and rustdoc (8282).
2026-11-08 05:31:24 -08:00
Anees Iqbal d59428a608 In-place image docs: the usages paragraph wrapped at 100 columns
The previous commit left one line of in_place_image.rs's module docs at 162 columns. Comment only.

Verified for the change before this one (8f0125351c), whose test this paragraph documents:
- RTX 5080 (b5080 c entry pooledmove-pm-usage-reach-1-042641, batch m3-max-8349): the three
  in_place_textures tests passed. At a 1024-byte pitch the placement answers were: ShaderWrite
  and RenderTarget Shadow(Refused(Pitch)), ShaderWrite InPlace, RenderTarget Shadow(Refused(Pitch));
  the kernel wrote in place and the pass rendered through its shadow, as the test now expects. At
  512 bytes all three were InPlace and both forms lay in place.
- lavapipe (msi, job m3-max-8223): in_place_textures 10 of 10; all three answers InPlace at both
  pitches.
- Linux clippy (cpuicd, gpu) and rustdoc (um790, job m3-max-8282): clean.

(cherry picked from commit 411b2a66ffa1e51df16fb5801ad8fcacc771447f)
2026-11-08 05:31:15 -08:00
Anees Iqbal ab9a56e55b In-place lane: a write or pass beyond the usage reaches the pages where the image took that usage, by the placement query's answers
What: writes_and_passes_beyond_the_usage_reach_the_pages_where_their_checks_passed expected a pass
over a sampled-only texture over host pages in place wherever the check passed renders over the
class, and a kernel's writes wherever it passed writes. But the image in place takes one set of the
usages the texture lacks: the first the device makes it with, the most first, the storage usage
before the attachment usage (Device::in_place_plans' order). Where the device makes the image with
the storage usage and not with both, the texture takes the storage usage, and a pass renders
through a stand-in whatever the renders verdict. The test now asks the placement query for a
texture of the same shape declaring ShaderWrite and RenderTarget, ShaderWrite, and RenderTarget
(the verdicts for their accesses and the image's making up to the bind), and expects the kernel
in place where the first or second is InPlace, the pass where the first is, or the third with the
second not. It asserts the verdicts the query asked too, and prints the three answers.
in_place_image.rs's module docs name the order.

Why: on the RTX 5080 (dev round 5ce05e1908, b5080 entry m2v-orch-dv-ln02-034557, built at
8a974ab605) the pass over the 64x64 RGBA16Float texture at a 1024-byte pitch took the usage shadow
while Pointer renders, rows on lines, passed, after the kernel form of the same shape had written
in place with no shadow: the image took the storage usage.

Verified so far: cargo fmt only; the 5080 and lavapipe runs follow, printing the three answers.

(cherry picked from commit 8f0125351c88ff5f1b7a97fd33b5c0d2e1043027)
2026-11-08 05:30:24 -08:00
Anees Iqbal f05387f9a7 RUNTIME_VERSION 1888: pooled textures made before the check's verdict move in place once it passes
pooledmove (b9d2be92aa..4f81997bbe): a texture over a padding-unobserved buffer of the runtime's
pooled memory made before the pooled class's verdict takes a PendingMove and moves to its
DRM_FORMAT_MOD_LINEAR image at Metal's pitch at the first lone commit after the verdict passes,
through the host-page moves' path (WorkCounts::pooled_textures_moved_in_place,
pooled_texture_shadows_freed_after_move). Resolved one conflict in padding_unobserved.rs's module
doc by keeping both bullets (the Private-only bound and the moves). Re-pinned.

Verified (pooledmove, at 4f81997bbe on e659154063): Iris 8371 16/16, 93 caches made before the
check -> 65 moved in place, 28 shadows (as caches made after it); negative control 8379 fails
both new tests; M3 8342 40/40; lavapipe 8340 16/16; clippy cpuicd/gpu and rustdoc clean; 780M
8333 15/15 (no image at the pitch, unchanged).
2026-11-08 05:23:29 -08:00
Anees Iqbal 2cc13a8b1f Pooled moves lane test: a cache made before the check lies in place where the device's linear image takes its pitch
The test held every cache made before the device's check answered to be a shadow. A cache whose
rows the device's own linear image lays out at their pitch lies in place on that image, which
takes no verdict: 45 of the 93 on lavapipe. The test now counts those first and holds the rest to
be shadows, with none at its pitch.

Verified: lavapipe on homelab-um870-1 (job m3-max-8234, at 290ba21c8c) failed with 'before the
check answered: 0 at their pitch, 48 shadows, where all 93 are shadows', the other lapses clear
(45 in place before and after, 0 moved); the rerun follows.

(cherry picked from commit 4f81997bbe9d067148b0d965ccd002b6b7e5bf7f)
2026-11-08 05:22:32 -08:00