The padded-texture work packet. A texture over a buffer whose image would hold bytes that are not
its texels is drawn through a shadow image with exact copies, since a render pass or a layout
transition may write those bytes. Then the shadow's cost is cut, exactly: no copies for a pass that
reaches no tile, a copy back bounded by the draws' scissors, and cost lines that show each part.
Shadow a texture over a buffer whose image would hold bytes that are not its texels:
A texture over a buffer is a linear (or DRM_FORMAT_MOD_LINEAR) image over the buffer's bytes only
where every byte of the image's subresources is one of its texels: its rows lie one after another
(or it has one), its slices likewise, and its last subresource ends at its texels' last byte or
before. Anything else is the shadow, whose copies address the buffer's texels alone. The Metal
texture over an MTLBuffer (MoltenVK) is exempt: every write through it is Metal's own.
Why: Vulkan lets a render pass's load and store operations "read and write back any memory
locations within the image subresource bound for that attachment" (renderpass.adoc, Load and
Store Operations), and VkSubresourceLayout's size "includes any extra memory that is required
based on rowPitch", so the bytes between padded rows lie inside the subresource. Metal leaves them
as the program writes them. No query promises otherwise, so no image may alias padded rows.
Bytes past every subresource stay allowed: Memory Aliasing bounds the bytes a write through an
image affects to "those overlapped by the image subresources that were written". Measured on
lavapipe (Mesa 26.2.4 llvmpipe, gem10) at the round's base: pitched_surfaces' 657x128/5312
RGBA16Float tile took lavapipe's own linear image (its pitch 660 texels rounded to 64 bytes is
the lane's 5312), and a clear-blend-store pass rewrote 13 padding bytes in 13 rows (row 3 byte
5265 0x7c -> 0x7e: texels 657..659 of its 4-texel blocks read and written back, signaling NaNs
quieted). The reliance predates 1cf79a9617 (own linear images whose pitch equals bytesPerRow,
the dma-buf explicit planes); 1cf79a9617 made it every padded surface on ANV and NVIDIA's wider
pitches.
How: linear_plan's padding() and texels_alone(), used by alias_image (before any image is made),
aliases() (now given the subresource's size), host_alias_unbound (the own linear image's fit and
the pitched image's), the dma-buf alias (before the pages' source is asked, counted as a
fallback; its plane's size checked for textures over buffers, not heaps') and the rebind (the
alias kind keeps the texels' layout). Importer::makes_modifier_images, a duplicate of
makes_dma_buf_images, is folded into it. RUNTIME_VERSION 1188.
Tests: the aliases unit test covers padded rows, slices apart, a one-row pitch, a subresource
past the texels and a whole-array report. pitched_surfaces checks the pages after every step
(now naming the changed bytes outside the texels), asserts padded rows are never aliased off
MoltenVK, adds a load-blend-DontCare step, packed layouts of 510 and 126 rows and of 200, and a
fragment function's writes over six layouts (shader read/write usage). no_copy_textures asserts
padded rows shadow off MoltenVK (it asserted ANV's pitched image); dma_buf_imports' 60-texel case
now shadows. Docs: API.md (the extension paragraph and the shadowed-texture entry),
ShadowedTexture's rustdoc, HOWTO.md section 6, Texture::vk_image, dma_buf.rs, and a known-gap
entry in FAST-PATHS.md with ANV's cost (making the browser tile ~135 us as a shadow vs ~41 us
as a pitched image, 1cf79a9617's numbers).
Verified on lavapipe (gem10, release, --cfg m2v_cpu_icd, LP_NUM_THREADS=1): runtime_lane's
pitched_surfaces, no_copy_textures, buffer_texture_blits, dma_buf_imports, linear_attachments,
buffer_textures, buffer_texture_order, buffer_texture_renders, dont_care_stores,
kept_buffer_bytes, rotated_textures, and tests::linear_plan / degradation: 137 of 140 passed;
a_half_float_tile passes (it failed at the base), every padded layout is shadowed, 300x200/1200
is a pitched image. The three failures: the runtime-sources pin (written here), and the two
packed odd-height layouts, 658x126/5264 (rows 126..127 past the texture rewritten) and
1308x510/5232 (SIGSEGV, rows 510..511 written past the mapping): a lavapipe defect of explicit
DRM_FORMAT_MOD_LINEAR planes, handled in the next part. GPU lanes (ANV, RADV, NVIDIA,
MoltenVK) not run yet.
Make no explicit-plane modifier image of an odd height where lavapipe renders rows past it:
RuntimeDriverDefect::ExplicitPlaneRowsPastHeight: a DRM_FORMAT_MOD_LINEAR image whose one plane
the caller lays out (VkImageDrmFormatModifierExplicitCreateInfoEXT) is rendered in blocks of 4
rows, its rows past its height up to a multiple of 4 written past its subresource and past its
memory requirements. On a driver with the defect (lavapipe, MESA_LLVMPIPE, every release until a
probe finds one clean) neither host_pitched_image nor the dma-buf image (textures over buffers
and heaps' textures alike) is made of a height that is no multiple of 4: the texture takes its
shadow, announced as shadowed-texture with the defect named. The trigger is structural (the
image's height); the driver's own linear images are untouched, as they report the rounded rows
in their subresource (the previous part's texels_alone then shadows them).
Why: a write past an image's own memory is a spec violation no query reveals. Measured on lavapipe
(Mesa 26.2.4, llvmpipe LLVM 23.1.1 256 bits, gem10, release, LP_NUM_THREADS=1) at the previous
commit, pitched_surfaces' packed odd-height layouts, each a pitched image (pitched host images 1):
658x126/5264 RGBA16Float, a load-blend-store pass rewrote 21 bytes of rows 126..127 past the
texture (signaling NaNs quieted); 1308x510/5232 BGRA8Unorm, the same pass wrote rows 510..511 past
the no-copy buffer's mapping and the process took SIGSEGV. lavapipe 26.0.8 is unprobed.
How: Device::explicit_plane_rows (dma_buf.rs), asked by host_pitched_image and
dma_buf_image_unbound after their format checks. The registry entry and its test, the variant's
rustdoc, ShadowedTexture's rustdoc and API.md's shadowed-texture entry. No refusal is added, so
docs/REFUSALS.md has no row for it (refusal_surface.py --check passes); the api_surface table
names the enum, not its variants. RUNTIME_VERSION 1189.
Verified: see the landing run (lavapipe, the pitched_surfaces odd-height layouts shadowed and
passing).
Record that an image over host-pointer pages keeps its bytes past its first move only by drivers:
A known gap in docs/FAST-PATHS.md, and a lane check that turns a driver that drops the bytes into
a visible failure. No behaviour changes (no RUNTIME_VERSION bump): whether every texture over
pointer-imported pages becomes a shadow is the owner's call.
The gap: an image of host allocations must start UNDEFINED (VUID-VkImageCreateInfo-pNext-01443),
and a transition from UNDEFINED "will cause the contents of the image's memory to be undefined"
(resources.adoc, VkImageLayout). Memory imported from a host pointer "shares ownership of the
memory between the host and the Vulkan implementation", with host access synchronized as for any
memory (memory.adoc, VkImportMemoryHostPointerInfoEXT), so the external-memory acquire from
VK_QUEUE_FAMILY_EXTERNAL/FOREIGN is not blessed for it. sync2's ignored-layout barrier keeps
contents but leaves the image UNDEFINED, invalid to use as GENERAL. Paths that rely on the drivers:
host_linear_image, host_pitched_image, and metal_alias_image (VkImportMetalTextureInfoEXT says
nothing of contents). Spec-backed: dma-buf images, acquired from VK_QUEUE_FAMILY_FOREIGN_EXT in
GENERAL (the external memory chapter's ownership transfer and its note that the UNDEFINED initial
layout is a placeholder), and the runtime's own linear images, made PREINITIALIZED.
The check: pitched_surfaces::a_texture_s_first_use_reads_the_bytes_it_was_made_over makes a
texture over each layout and reads it first through its image (a fragment function's read)
before anything else touches the pages: the read must be the pages' texels and the pages
unchanged.
Verified: see the landing run (lavapipe).
Expect a shadow wherever no linear image holds a texture's texels alone:
The runtime aliases a texture over an ordinary buffer with a linear image only
where the image's subresource holds the texture's texels and nothing else
(linear_plan::texels_alone): no padding between rows, the driver's row pitch
Metal's, and no subresource bytes past the last texel. The lanes' expectation
helper, buffer_texture_blits::linear_rows_differ, compared only the driver's
row pitch, so on lavapipe, whose linear 64x2 RGBA8Uint at a 256-byte pitch
reports a 1024-byte subresource (its height rounded up to 4 rows) while the
texels end at 512, resource_ids expected no shadow and failed with "announced
past []: [ShadowedTexture, UnnamedShadowedTexture]".
The helper now applies the same rule: rows with bytes between them, a
subresource offset other than 0, a row pitch other than the buffer's, or a
subresource size past (height - 1) * row + width * texel. It takes the texel
size, which every caller knows. The callers' expectations move the same way:
resource_ids' 64-texel rows (the size rule), buffer_texture_blits' 4x4
textures at 32-byte rows and the IOSurface planes at 9, 20 and 40 bytes, and
view_reinterpretation's rows 16 bytes past their texels (the padding rule,
which shadows them on every device).
Verified on gem10's lavapipe (Mesa 26.2.4, --cfg m2v_cpu_icd,
LP_NUM_THREADS=1, release): the focused filter over pitched_surfaces,
no_copy_textures, buffer_texture_blits, dma_buf_imports, linear_attachments,
buffer_textures, buffer_texture_order, buffer_texture_renders,
dont_care_stores, kept_buffer_bytes, rotated_textures, resource_ids,
view_reinterpretation and the runtime's linear_plan, degradation and
driver_defects tests: 186 of 187 pass, resource_ids'
a_buffer_under_a_texture_goes_at_its_release_whatever_keeps_the_image among
them; the one failure is the runtime-sources pin, which moves with this work (below).
Test-only: no runtime source changes.
Name the layout transitions as what may write a padded texture's padding:
A texture over a buffer whose rows (or slices) lie with bytes between them
is a shadow off MoltenVK, since an image over those rows would hold the
bytes between them in its subresource. The shadowed-texture notice gave one
reason for every such texture: Vulkan lets a render pass's load and store
operations write those bytes back. That cannot apply to a texture without
RenderTarget usage, which never becomes an attachment, and ms01's A/B saw
read-only padded textures shadowed under that reason.
For such a texture the basis is the layout-transition rule (the
Synchronization chapter's Image Layout Transitions): "Image layout
transitions may perform read and write accesses on all memory bound to the
image subresource range", and "If the old layout is
VK_IMAGE_LAYOUT_UNDEFINED, the contents of that range may be discarded".
Every image takes one transition before any use: its first move into
GENERAL, from UNDEFINED for imports (VUID-VkImageCreateInfo-pNext-01443)
or PREINITIALIZED for ordinary buffers. No descriptor or copy takes an image
in either layout, and host image copy's transition is a transition too. So
no transition-free path exists for a read-only linear image, and the shadow
stays. After the first move every runtime image rests in GENERAL, so no
later barrier transitions it; copies and shader accesses touch texels alone
(the Memory Model: "A memory operation must not affect memory at a memory
location not within its set of memory locations").
linear_plan::padding now takes whether the texture renders (RenderTarget
usage). Its reason names the layout transitions, its first move among them,
and for a render target also the render pass's load and store operations.
The doc comment quotes both texts. The ShadowedTexture rustdoc, docs/API.md's
catalogue entry, docs/HOWTO.md, docs/FAST-PATHS.md's known gap, and the
dma_buf.rs and linear_plan.rs module docs say the same.
Tests:
- tests::linear_plan::a_padded_texture_s_shadow_names_what_may_write_its_padding
checks both reasons' exact text.
- The lane test pitched_surfaces::a_padded_texture_s_shadow_names_what_may_write_its_padding
makes the browser's 1307x512/5248 tile over an ordinary buffer, which
shadows on every device, MoltenVK included. It runs a fresh device per
usage (ShaderRead; RenderTarget | ShaderRead) and checks the
shadowed-texture notice's reason.
RUNTIME_VERSION 1190 (fleet/round's 1189 + 1). The runtime-sources pin is
recomputed at this tree.
Verified on gem10's lavapipe (Mesa 26.2.4, llvmpipe LLVM 23.1.1,
--cfg m2v_cpu_icd, LP_NUM_THREADS=1, release). The focused filter
(pitched_surfaces, no_copy_textures, buffer_texture_blits, dma_buf_imports,
linear_attachments, buffer_textures, buffer_texture_order,
buffer_texture_renders, dont_care_stores, kept_buffer_bytes,
rotated_textures, resource_ids, view_reinterpretation, and the runtime's
linear_plan, degradation and driver_defects tests) ran 189 tests. 188
passed, both new tests among them, printing:
- ShaderRead: "its rows lie 5248 bytes apart, 5228 bytes of texels each: an
image over them holds the bytes between them, which Vulkan lets its layout
transitions read and write, its first move from the layout it is made in
among them"
- RenderTarget: "... which Vulkan lets its layout transitions read and
write, and a render pass's load and store operations write back"
The one failure was the runtime-sources pin before this commit set it
(860ca881...). Clippy with all features (no cfg) is clean.
Take the surface texture cost frame apart, per part and per texture:
surface_texture_costs measures a browser-like frame: five surface textures
over new no-copy buffers, each loaded and stored by a pass that draws
nothing, then each blitted into a private texture. On ANV, ms01 measured
commit-to-completion rising by about 2.8 ms a frame where four of them
became shadows. That number alone cannot say where the time goes: the
shadows' copies in and back, their making and release, or work beside them.
It also cannot say why the packed 1024x512/4096 tile, which stays the
driver's own linear image in both forms, took longer to make.
The new ignored measurement surface_texture_cost_parts (run by name, release,
as the others) runs the frame over anonymous pages in parts:
- Empty: the textures made and released around an empty command buffer.
- PassesStored: Load/Store passes, i.e. a shadow's copy in and copy back.
- PassesNotStored: Load/DontCare passes, a copy in only.
- PassesDrawn: Load passes that blend a rectangle and store, as a browser's
passes draw.
- Blits: the blits alone, which read a texture over a buffer as its bytes.
- Both: the original frame.
It runs over every layout, then over the packed layouts alone, so no shadow
is made beside them. Per set and part it prints (SURFTEX-PART): the forms;
each texture's making median and p90; the frame's release, encoding,
commit-to-completion and process CPU time; and the per-frame work counts.
frame() takes the part, and surface_texture_costs passes Part::Both, so its
own output is unchanged.
Test-only. It compiles at fleet/base as well (it names nothing newer), so the
same measurement runs on the earlier form. Checked with clippy --cfg m2v_gpu,
all targets and features, -D warnings, on gem10.
Copy no shadow in or back for an attachment a pass that reaches no tile loads:
A texture over a buffer whose image would hold bytes that are not its texels
is a shadow: an image of its own that encoders copy the texels into before
use and back after a write. A render pass copied its shadowed color
attachment in before the pass and back after it whenever it loaded and
stored it, even where the pass reached no tile: no draw call, or draw calls
that draw nothing (clear_reach::PassReach::Nothing). Such a pass changes no
texel:
- Metal loads and stores only the tiles a draw reaches (PassReach's EVs).
- Vulkan's load and store write back what they read: "Load operations only
update values within the defined render area", and store operations
alike.
So the copies moved a texture's every texel twice for nothing. On ANV,
surface_texture_costs' frame (whose passes draw nothing) paid that for four
padded surfaces since they became shadows.
attachment_shadows now takes no use of such an attachment: a color
attachment of a pass that reaches no tile, that loads it (Load, also a
DontCare load the pass loads), stores it Store or DontCare, resolves
nothing, and has no stand-in or planes, where the shadow is a plain image of
a buffer's bytes (ShadowTarget::Image, writes kept). No copy in, nothing
dirty, no copy back. Rotated, converted and image shadows keep their copies.
The pass still renders into the shadow image, whose attachment uses order it
as before. Every later use copies in again, since the shadow was never marked
current.
New public counter WorkCounts::shadow_copies: copies between a shadowed
texture's truth and its shadow that encoders planned (in, back, keep and
merge). It is counted where EncoderCore plans them and at each of the three
end-of-encoder finishes.
Lane test pitched_surfaces::a_pass_that_draws_nothing_copies_no_shadow: the
browser's 1307x512/5248 tile over an ordinary buffer (a shadow on every
device). Load/Store and Load/DontCare passes that draw nothing plan 0 copies
and leave every byte of the buffer. A pass that blends a rectangle plans 2
(in and back). Without this change, the expected counts for the two empty
passes are 2 and 1.
This shrinks surface_texture_costs' frame, whose passes draw nothing, not a
browser's, whose passes draw. surface_texture_cost_parts' PassesDrawn part
measures that apart.
RUNTIME_VERSION and the runtime-sources pin move with this work (below).
Verified on gem10's lavapipe (Mesa 26.2.4, --cfg m2v_cpu_icd,
LP_NUM_THREADS=1, release): the earlier focused filter plus the runtime's
shadow tests ran 200 tests, 199 passed, the new test among them. The one
failure was the pin. clippy -D warnings, all targets and features, is clean
with no cfg and with --cfg m2v_gpu.
Copy back only the texels inside a pass's draws' scissors:
A shadowed texture's copy back after a render pass moved every texel from
the shadow image to the buffer. On ANV that write-back is the shadow's cost:
ms01's surface_texture_cost_parts put a stored shadow at about 0.8 ms of
commit-to-completion a frame (1307x512 BGRA8). A pass that loads a color
attachment changes no texel outside its draws' scissors:
- "Samples with coordinates outside the scissor rectangle at the
corresponding ViewportIndex will have their coverage set to 0" (the
Fragment Operations chapter's Scissor Test).
- "Load operations only update values within the defined render area" and
"Store operations only update values within the defined render area" (the
Render Pass chapter), writing back what they read.
- Each Vulkan scissor is Metal's rectangle clipped to the pixels its viewport
overlaps (render_state.rs's implicit scissor), so Metal's draw writes no
pixel past it either.
The image's other texels are what the last copy in left, which the buffer
still holds, and a write of the bytes another way leaves the image stale, so
they need no copy back.
How:
- ShadowUse gains an area: where a command writes through the texture, where
it bounds that. render.rs passes the bounds of the pass's DrawnArea (its
draws' Vulkan scissors) for a pass whose draws reach tiles, unless a reach
clear runs before the pass, together with which color attachments the
encoder set to Load, read before the DontCare loads and reach clears change
any. attachment_shadows gives that area to a loaded color attachment with
no resolve, stand-in or planes that is the whole of a one-level, one-slice
texture.
- join and ShadowSync::after keep the rectangle bounding the writes since
the last copy back, or none where one does not bound them. copy_back puts
it on the ShadowCopy.
- record() cuts the one region of a ShadowTarget::Image without staging to
it, by part_of: the buffer offset moved to the rectangle's first texel at
the region's row length, clamped to the image. ShadowTarget::Image now
carries its texel size (none for a heap's depth or stencil shadow, which
takes no area).
- Copies in still move every texel.
New public counter WorkCounts::shadow_texels_copied_back: the texels copies
back of buffers' textures' images move.
Tests:
- tests::shadow::a_copy_back_covers_only_where_the_commands_wrote: areas
through ShadowSync and join.
- tests::shadow::a_part_of_a_region_starts_at_its_first_texel: the region
arithmetic, clamping, empty parts and tight rows.
- Lane pitched_surfaces::a_pass_copies_back_only_the_texels_its_scissors_reach:
the browser's 1307x512/5248 tile over an ordinary buffer (a shadow on every
device), blended under a 300x200 scissor, moves 60000 texels back. The
buffer then holds a private texture's blend inside the scissor and every
other byte as it was. Unscissored, the pass moves all 669184.
docs/FAST-PATHS.md's known gaps record the race the bound leaves: Metal
stores only the 32x32 tiles a primitive touches (reims-vgpu's padding probe,
M3 Max, macOS 27.0.1). A concurrent CPU write to an undrawn texel in an
untouched tile inside the scissors can be undone here, where Metal keeps it.
No copy reaches the bytes between rows.
The batch's version commit moves RUNTIME_VERSION; the runtime-sources pin follows it.
Verified on gem10's lavapipe (Mesa 26.2.4, --cfg m2v_cpu_icd,
LP_NUM_THREADS=1, release). The shadow lanes (the previous part's list,
plus scissors and capture_reach where they exist) and the runtime's shadow,
shadow_stencil, linear_plan, degradation and driver_defects tests ran 319
tests, and 318 passed, the three new ones among them. The one failure was
the runtime-sources pin. clippy -D warnings, all targets and features,
--cfg m2v_gpu, is clean.
Measure a scissored drawn pass and a shadow's copies alone:
Two additions to the surface texture cost measurements, both ignored and
run by name in release builds.
surface_texture_cost_parts gains PassesScissored: the drawn pass (Load, a
rectangle blended over the left half, Store) under a scissor of the left
half, as a browser's pass redrawing a damaged part of a tile draws. With the
previous part, its shadows copy back only the scissored half.
PassesDrawn's default scissor covers the whole tile, so its copy back moves
every texel.
shadow_copy_costs times each copy alone in its own command buffer, committed
and waited for, on the browser's 1307x512 BGRA8 tile at 5248-byte rows:
- a private texture made as a shadow is (render target and shader read) into
a no-copy buffer over anonymous pages: a copy back's way;
- the pages into the texture: a copy in's way;
- the texture into a private buffer and into a Shared buffer;
- a private buffer into the pages, and back.
It prints SURFTEX-COPY lines with commit-to-completion medians and p90s.
These tell the image's tiling (detiling) from the pages' memory (writes into
imported host memory) as the cause of ANV's copy back.
Test-only. clippy -D warnings with --cfg m2v_gpu, all targets and features,
is clean on gem10.
Print a frame's shadow copies and the texels its copies back move in the surface cost lines:
What: the surface texture cost lines' per-frame work counts (SURFTEX-COST, SURFTEX-PART) now
end with the shadow copies the encoders planned and the texels their copies back moved, both
per frame.
Why: a change to how a shadow's image is made or copied must leave the copies and the texels
they move as they were; the cost lines then show it beside the times, in the same run.
Verified: test-only; built and run with the measurements on Linux hosts in the next steps
(no build on the Mac).
Wrap the surface texture costs' SURFTEX-QUERY sentence at 100 columns:
The commit that added a frame's shadow copies to the cost lines left the module doc's
SURFTEX-QUERY sentence on one 154-column line; the tree wraps doc comments at 100. Doc only.
Verified: awk finds no line of the file over 100 columns but the ignored-tests sentence (110),
which predates that commit; cargo fmt --all leaves the tree unchanged.
Versions: RUNTIME_VERSION 1202 -> 1203. RUNTIME_VERSION moves: padded textures over buffers are
drawn through shadows, and the shadows' copies change.
crates/metal2vulkan-validation/runtime-sources.sha256 holds
52d6ce1648b67055d046e043e6d1cd126e0a8315d04a922261df93ad0a25f734, the hash of this tree's runtime
inputs (runtime-pin.py, which reproduces build.rs's). Version numbers quoted above are the values
the work's branch built with. Each part's Verified lines name the tree it ran at.
The encoder review's work packet: the handler threads' utilization floor no longer reaches the
threads they start, a draw state's used-resources shape is made once, a kept barrier list out of use
gives way to a new one, and a render state's helper threads start with the runtime's own.
Keep the handler threads' utilization floor out of the threads they start, and drop the dead QoS raise:
What: on Linux, exit_guard::run_at_user_interactive (the scheduler, the completion thread, each
VkQueue's waiter, the handler pool) now reads its own attributes with sched_getattr(2) and calls
sched_setattr(2) with the policy it read, without SCHED_FLAG_KEEP_POLICY, and with
SCHED_FLAG_RESET_ON_FORK | SCHED_FLAG_KEEP_PARAMS | SCHED_FLAG_UTIL_CLAMP_MIN, sched_util_min 1024.
The struct is exit_guard::SchedAttr, mutable across the call (a kernel whose struct is shorter writes
its size back before E2BIG), with SAFETY comments that say so. On macOS, raise_quality_of_service is
deleted, with its calls in exit_guard::spawn and spawn_scoped. Docs: spawn, spawn_user_interactive,
the Linux comment (the reset's effect on real-time policy and negative nice, the setting a handler
cannot clear, and the host-wide uclamp accounting the first call turns on until reboot), and the
public Handler, add_scheduled_handler and add_completed_handler (the handler threads'
user-interactive class on macOS, the floor on Linux, and that neither carries into a thread a
handler starts).
Why:
- With KEEP_POLICY the kernel keeps the thread's reset-on-fork setting and ignores RESET_ON_FORK
(__sched_setscheduler: policy < 0), so uclamp_fork gave every thread a boosted thread starts the
1024 floor for its life: the pipeline reaper a pipeline state's last release starts on a handler
thread (Program::drop -> PieceHolds::close -> Reaper::start), the notices thread, pool and
compile threads a program's call in a handler starts, a program's own thread made in a handler.
The policy is passed back as read, so SCHED_OTHER, SCHED_BATCH and SCHED_IDLE (a session
ananicy-cpp moved to SCHED_IDLE) stay as found; KEEP_PARAMS keeps nice, priority and slice.
- raise_quality_of_service never acted. A thread made by pthread_create with no QoS class in its
attributes starts at QOS_CLASS_DEFAULT (<sys/qos.h> line 83), std::thread sets only the stack size
(pthread_attr_init + pthread_attr_setstacksize), and every runtime thread runs it first thing on
such a thread, so its utility-or-background test never held. Its doc said a new thread takes its
creator's class, which is false. Under a process-wide clamp a new thread still reads DEFAULT and a
request for DEFAULT changes neither its class nor its priority, so it could not help there either.
Probe on this Mac (M3 Max, macOS 27.0.1 26A434, cc and rustc 1.98.1), a C program creating
threads with pthread_attr_init + setstacksize from creators at background, utility, default,
user-initiated and user-interactive, each new thread reading pthread_get_qos_class_np and
thread_info's pth_curpri/pth_priority/pth_maxpriority, then calling
pthread_set_qos_class_self_np(DEFAULT) and reading again:
plain: every new thread 0x15 (DEFAULT), pri 31/31/63, unchanged after
taskpolicy -c utility: every new thread 0x15, pri 20/20/20, unchanged after
taskpolicy -c background: every new thread 0x15, pri 4/4/4, unchanged after
taskpolicy -c maintenance: every new thread 0x15, pri 4/4/4, unchanged after
taskpolicy -b: every new thread 0x15, pri 4/4/4, unchanged after
taskpolicy -t 5 -l 5: every new thread 0x15, pri 31/31/63, unchanged after
taskpolicy -b -t 5 -l 5: every new thread 0x15, pri 4/4/4, unchanged after
and a Rust probe (std::thread::Builder::spawn from creators at each class, reading
qos_class_self): 0x15 from every creator, plain, under taskpolicy -c background and under
taskpolicy -b. The core of the C probe:
static void *child(void *start) {
qos_class_t c, after; int r;
pthread_get_qos_class_np(pthread_self(), &c, &r);
int before = pri(); /* thread_info(THREAD_EXTENDED_INFO) pth_curpri, pth_priority, pth_maxpriority */
int set = pthread_set_qos_class_self_np(QOS_CLASS_DEFAULT, 0);
pthread_get_qos_class_np(pthread_self(), &after, &r);
printf("creator %#x: new thread %#x pri %d; set DEFAULT rc %d -> %#x pri %d\n", ...);
}
for each start class: pthread_set_qos_class_self_np(start, 0); pthread_attr_init(&a);
pthread_attr_setstacksize(&a, 1 << 20); pthread_create(&t, &a, child, ...); pthread_join(t, 0);
- The handler threads' class and floor differ from a plain thread's, which the public items did
not say (AGENTS.md: name what differs from Metal).
Tests:
- tests::exit_guard::the_threads_that_take_command_buffers_to_their_handlers_run_with_the_
utilization_floor (new, Linux): from creator threads at SCHED_OTHER, SCHED_BATCH and SCHED_IDLE
(each it may enter; SCHED_IDLE required), the scheduler, completion, both waiters and two
handler-pool threads read their own sched_getattr: floor 1024, reset-on-fork set, the creator's
policy and nice; a thread each starts through exit_guard::spawn reads floor 0, no reset, the same
policy and nice. On a kernel that refuses the floor it expects none and that the kernel refuses
one the test asks for itself.
- tests::exit_guard::a_runtime_thread_starts_at_the_default_quality_of_service_whoever_started_it
(macOS, rewritten from a_runtime_thread_runs_at_no_lower_quality_of_service_than_the_default): a
plain and a runtime thread from a creator at each class both read DEFAULT. The user-interactive
test now expects the reaper at DEFAULT.
RUNTIME_VERSION stays: no run's results change. The runtime-sources pin moves in this branch's last
commit (on fleet/base this tree hashed to 3ef35b8d...).
Verified on homelab-um780 (Ryzen 7 7840HS, Linux 7.0.0-38-generic, CONFIG_UCLAMP_TASK=y, Rust
1.98.1, release, RUSTFLAGS='-Dwarnings --cfg m2v_cpu_icd'): cargo nextest run -p
metal2vulkan-runtime -E 'test(/exit_guard::/)': 30 of 30 passed; the new Linux test entered all
three policies (nice 5) and read floor 1024 on the six threads, 0 on their children. With the old
flags (KEEP_POLICY, no RESET_ON_FORK) restored it fails: a boosted thread reads reset false. The validation pin test passed with
3ef35b8d... on fleet/base. The macOS tests are not run here (routed to the Mac).
Make a draw state's used-resources shape once when finding its bind shape among the kept ones:
What: BindState::position_of_shape(shapes) answers where among `shapes` the state's shape is (the
first of which has_shape answers true), making the shape of the resources the state lists at most
once for all of them, and only where a shape's every other field matches; has_shape compares the
used resources last, after every field it compares in place. GraphicsState::kept_shape finds a
draw's shape among its state's latest settles through it. docs/API.md names it beside has_shape.
The crate's test allocator (constant_blob_footprint.rs) also counts allocations
(allocations_during).
Why: kept_shape called has_shape once per kept settle (up to four), under the settles' lock, and
each call made the used-resources map again where the state lists used resources (useResource:,
argument-buffer programs): up to four maps a draw where one does.
Test: tests::bind_shape_of::a_state_s_shape_is_found_among_many_with_its_used_resources_made_once:
a state listing 16 used resources against four shapes equal in every other field, its own last:
position_of_shape allocates as much as one has_shape, and has_shape one by one four times that; a
state listing none, or of another field, makes nothing.
Let a kept barrier list out of use give way to a new one:
What: once a VkQueue keeps LISTS (8) lists of barrier command buffers, a new list replaces the one
taken least lately among those no batch took in the last STALE (256) values of the queue's timeline
and whose command buffers all completed; that list's command buffers become spares, which later
recordings take before allocating. The kept pool is made with RESET_COMMAND_BUFFER, so a spare's
begin resets it. Lists all in use in turn replace none, as before. The choice is
QueueKept::take (Take::Kept, Take::Record, Take::Past), apart from the Vulkan calls in
KeptBarriers::take.
Why: the first 8 distinct lists a queue met kept their places for the device's life, so where a
program's first batches (uploads, first moves) filled them, every later per-frame list was recorded
by its batch, a command buffer begun per batch, for good: the work 4600bc606d set out to remove.
The staleness window keeps lists in use in turn from replacing each other at every use (with more
than 8 of them, the first 8 stay kept, as before).
Tests (tests::kept_barriers, no device: handles the test makes): a list met twice in one batch takes
two command buffers, reused once that batch completed; a failed submission's command buffer waits
for the value the next batch signals in its place; past KEPT pending buffers or LISTS lists in use a
batch records its own; a list out of use gives way to a new one, recorded into its command buffers,
never a list in use or one with a buffer pending; more than LISTS lists in use in turn replace none.
a_list_out_of_use_gives_way_to_a_new_one fails without the change (the new list gets Own, for good).
RUNTIME_VERSION moves: a run submits kept command buffers where it recorded its own.
Test a rebound slot's retain, and keep only the measured bounds in the frame-cost lane:
What: runtime_lane::draw_work::a_slot_rebound_to_a_texture_let_go_after_its_draw_holds_it_until_
completion binds two fragment textures, rebinds slot 0 mid-encoder to a fresh texture the program
drops after its draw, and draws again with nothing changed: ArgumentTable::retain's per-slot check
retains the table at each draw that changed the slot (6 after the first draw), not at one that
changed nothing, and every column is its own draw's texture's under the validation layer.
frame_costs.rs: the doc comments of DRAW_ALLOCATIONS, OPEN_ALLOCATIONS, PASS_END_ALLOCATIONS,
COMMIT_ALLOCATIONS and SUBMIT_ALLOCATIONS keep the measured values and their venues and drop what
each measured before earlier changes.
Why: retain's per-slot address check had no test of a rebind among unchanged slots; and AGENTS.md
keeps history out of code comments (it belongs in the commits that moved the numbers).
No behaviour change.
Start a render state's reflection and log-hash threads as the runtime starts its own:
What: pipeline/render.rs starts the thread that works out a render state's reflection beside its
creation, and the creation log's SPIR-V hashing thread, through exit_guard::spawn_scoped instead of
std::thread::Builder::spawn_scoped.
Why: exit_guard::spawn says every thread the runtime starts is started through it, so the guard
knows it as the runtime's (may_call, in_program_call, the debug check that a runtime thread reaches
the device only inside a section); these two were not. Neither calls the device or the program's
code: the reflection is the translator's, and the hash reads the variant's SPIR-V.
No run's results change.
Say plainly why kept barrier lists in use in turn replace none:
What: the module doc of command_buffer/kept_barriers.rs: where more than LISTS lists are in use in
turn, the first kept stay kept, since replacing one at each use would record every list at each of
its uses.
Why: the sentence it replaces read as if the rest were recorded like a replaced list. Comment only.
Versions: RUNTIME_VERSION 1195 -> 1196. RUNTIME_VERSION moves: kept barrier lists and thread
start-up change what a run does. crates/metal2vulkan-validation/runtime-sources.sha256 holds
e9ed22eb2280cb6f1a7ea8811e3f4b2c2a32bcc5aca217dc670864b84f357848, the hash of this tree's runtime
inputs (runtime-pin.py, which reproduces build.rs's). Version numbers quoted above are the values
the work's branch built with. Each part's Verified lines name the tree it ran at.
The Linux gate's work packet: CI's Linux steps now run in the gate's own container, and the failures
that run found are fixed: depth and stencil formats over a DRM_FORMAT_MOD_LINEAR image, test IR that
LLVM 21 rejects, and a frame-cost check that allocated.
Run every Linux step of ci.yml in the Linux gate's container:
What: scripts/linux-gate-ci gains the three steps ci.yml's Linux job runs and it did not:
"Clippy under each feature alone" (metal2vulkan with no feature and with serde, ash and cli each
alone; metal2vulkan-runtime; metal2vulkan-air with no feature and with serde), "Build the new
API's consumer reference" (scripts/api-docs) and "Package the published crates". Its "Test
metal2vulkan" step now tests the packages ci.yml's does (metal2vulkan, -air, -runtime and
-devtools), where it tested metal2vulkan alone. The steps run in ci.yml's order, each with the
container's build share.
Why: the script's header says every Linux run: step of ci.yml has one step here, and
docs/VALIDATION.md presents the container as ci.yml's Linux job; a change that broke only a
feature-alone build, the reference, packaging, or the AIR front end's, runtime's or dev tools'
tests passed the container and failed CI.
Verified: bash -n; the steps compared one by one with ci.yml at fd22785008. A full container run
of the script follows on msi-laptop.
Make no DRM_FORMAT_MOD_LINEAR image of a depth or stencil format:
What: Device::modifier_image_checks, which every DRM_FORMAT_MOD_LINEAR image the runtime makes
passes (host_pitched_image's at Metal's row pitch over host pages since 1cf79a9617, and
dma_buf_image's and dma_buf_natural_layout's over dma-buf pages since 11715e2a3f), refuses a
format with a depth or stencil component (FormatBlock::depth / ::stencil of the image's format).
Such a texture takes the shadow (`shadowed-texture`, naming why), as it already did on every driver
that lists no linear modifier for the format. RUNTIME_VERSION 1187; the runtime-sources pin moves
with it. docs/API.md (the dma-buf paragraph and the shadowed-texture notice), docs/HOWTO.md and
Degradation::ShadowedTexture's rustdoc say so.
Why: the runtime asks the layout of every such image of memory plane 0, and Vulkan has no valid
such query of a depth or stencil format. Vulkan 1.4.357's validusage.json: of a DRM format
modifier's tiling the aspect "must be VK_IMAGE_ASPECT_MEMORY_PLANE_i_BIT_EXT"
(VUID-vkGetImageSubresourceLayout-tiling-09433), of a format with a depth component it "must
contain VK_IMAGE_ASPECT_DEPTH_BIT" (-format-04462; stencil, -format-04463), and it "must only have
a single bit set" (-aspectMask-00997). lavapipe (Mesa 26.2.4) lists the linear modifier for
D16_UNORM, D32_SFLOAT and D32_SFLOAT_S8_UINT, so since 1cf79a9617 a depth or stencil texture over a
no-copy buffer's surface plane was made at Metal's row pitch and the validation layer reported
-format-04462/-04463, failing CI's CPU-ICD step:
runtime_lane::buffer_texture_blits::a_planar_surface_s_depth_or_stencil_texture_reads_and_stores_the_plane
and ..._s_passes_write_metal_s_elements_alone. The dma-buf paths had the same gap, reached only
where a driver refuses the host pointer and lists the modifier for such a format.
Test: runtime_lane::buffer_texture_blits::no_depth_or_stencil_texture_over_a_buffer_asks_for_a_modifier_image
makes each depth or stencil format's texture over a surface plane (ordinary and no-copy buffers,
read and render usage, rows 64 and 256 bytes apart) and checks that WorkCounts'
pitched_host_images, pitched_host_image_refusals and dma_buf_images do not move (each layout query
follows such an image), and that the validation layer reports nothing.
Verified on msi-laptop, lavapipe (llvmpipe, LLVM 23.1.1, 256 bits; Mesa 26.2.4, validation layer
1.4.357), --cfg m2v_cpu_icd, LP_NUM_THREADS=1, VK_DRIVER_FILES=lvp_icd.json: without the
modifier_image_checks change the new test fails ("NoCopy Depth16Unorm MTLTextureUsageShaderRead,
rows 64 bytes apart": (1, 0, 0) against (0, 0, 0)) beside the old one; with it, every test of
runtime_lane::{buffer_texture_blits, no_copy_textures, dma_buf_imports, surface_texture_costs,
pitched_surfaces} passes (47 of 49 selected) except
pitched_surfaces::a_half_float_tile_reads_writes_and_renders_as_metal, the known-open lavapipe
padding-bytes failure 1cf79a9617 names (fleet/fix-pitched owns it), and the runtime-sources pin,
which printed the hash written here.
Write the handle tests' sample coordinates as floats LLVM 21 reads:
What: tests::engine_handles' sampled-handle kernels (the 2D and 3D sample calls of
heap_gathers_and_nearest_samples_fetch_by_the_handle_s_class, heap_half_texels_convert_by_the_handle_s_class
and heap_linear_samples_are_emulated_by_the_handle_s_class) state their coordinates as the hex
of the floats they meant, 0x3FD3333340000000, 0x3FE3333340000000 and 0x3FDCCCCCC0000000, in place
of the decimals 0.3, 0.6 and 0.45.
Why: LLVM 21's llvm-as, which CI's Linux job (Ubuntu 26.04) assembles with, refuses a float
decimal that is not exactly a float ("floating point constant invalid for type"), so the three
tests failed there; LLVM 23 rounds it to the nearest float, which is the value the hex states
(checked on msi-laptop: `ret float 0.3` under llvm-as 23 and `ret float 0x3FD3333340000000` under
llvm-as 21 disassemble alike), so the modules are unchanged where they assembled before. These
were the only float or half decimals in crates/ that a float does not hold exactly (a scan of
every .rs and .ll).
Verified on msi-laptop with /opt/llvm-21.1.8 first on PATH and
METAL2VULKAN_TEST_REQUIRE_PINNED_LLVM=1, as CI runs: the three tests failed at fd22785008 and pass
here.
Check a stage table brought in place slot by slot, allocating nothing:
What: the debug builds' check in ArgumentTable::refresh_reading, that the table it brought in
place is the table the stage's function reads whole, is ArgumentTable::check_reading. It compares
slot by slot, with no table read whole made and nothing printed unless a slot differs: every
kept buffer, texture and sampler slot against the binding stage_table_reading would derive for it
(and the sampler as the address maps bind it), every slot that reading has against the kept
table, and the kept threadgroup lengths and acceleration structures against none. A sampler is
compared as it prints (same_as_printed: every field by `==`, the LOD clamps as bits or both NaN,
since `{:?}` tells -0.0 from 0.0 and prints every NaN alike). A slot that differs is named in the
panic. Builds without debug assertions compile none of it: their behaviour is unchanged, so
RUNTIME_VERSION stays; the runtime-sources pin moves.
Why: the check read the whole table again and compared the two as format!("{:?}") strings at
every draw, so a debug build's draw made several times the allocations of a release build's, and
CI's CPU-ICD step (a debug build) failed
runtime_lane::frame_costs::a_frame_s_draws_and_pass_ends_allocate_within_their_bounds at every
sha since its bound came: 86.60 allocations a draw on lavapipe against the bound's 27, where the
same build with CARGO_PROFILE_DEV_DEBUG_ASSERTIONS=false makes 24.62. With this, a debug build's
draw makes 35.93; the rest of the difference is LiveBind::shape's checks, which build whole bind
shapes and stay exact (the next part bounds a debug draw with them).
Tests: tests::argument_table::samplers_compare_as_they_print holds same_as_printed equal to
comparing the printed forms (opposite zero signs, NaNs of other sign and payload, a NaN against a
number, f32::MAX against infinity, and other fields); the_check_compares_every_field fails when
StageTable, BoundSampler or SamplerDescriptor gains a field, until the check compares it.
Verified on msi-laptop (Linux, debug, LLVM 21): clippy --workspace --all-targets --all-features
-D warnings clean; the two unit tests pass; on lavapipe (--cfg m2v_cpu_icd), the frame_costs
draws count 35.93 (86.60 before) and runtime_lane::{render_state, function_tables,
buffer_texture_blits}, whose draws run the check, pass (32 tests); the runtime-sources pin test
passes with the hash written here.
Bound a debug build's draw allocations by what its shape checks add:
What: runtime_lane::frame_costs::a_frame_s_draws_and_pass_ends_allocate_within_their_bounds holds
a build with debug assertions' draws to DRAW_ALLOCATIONS_DEBUG (38) and other builds' to
DRAW_ALLOCATIONS (27, unchanged). The new bound states what it holds: the draw path's
allocations and those of LiveBind::shape's two debug_assert!s, which build the state's whole bind
shape at each draw to compare the kept or the found one with it; measured 35.93 on lavapipe
(llvmpipe, LLVM 23.1.1, Mesa 26.2.4), where a build without debug assertions makes 24.62. The pass
end, pass open and commit bounds hold unchanged in both builds.
Why: CI's tests are debug builds, and its CPU-ICD step failed this test at every sha since the
bound came (86.60 allocations a draw; 35.93 since the previous part made the stage table's check
allocation-free). The shape checks stay exact: making them allocation-free would compare through
BindState::has_shape, the function the found-shape check exists to cross-check, and a reusable
shape would need new public API in the published crate. With a debug bound the CPU-ICD step keeps
holding the draw path in CI: a new allocation in it moves both counts alike, and the bound keeps
the release bound's slack (about 2.4 allocations).
Verified on msi-laptop, lavapipe, --cfg m2v_cpu_icd, debug, LP_NUM_THREADS=1, twice: the four
a_frame_s_ bound tests pass (draws 35.93 of 38, pass ends 38.63 of 40, opens 13.00 of 14, commits
5.00 of 6 and 17.08 / 17.24 of 20 on the other threads); the same tests with
CARGO_PROFILE_DEV_DEBUG_ASSERTIONS=false at fd22785008 gave 24.62, 38.63, 13.00 and 4.99; clippy
--workspace --all-targets --all-features under --cfg m2v_gpu is clean.
Versions: RUNTIME_VERSION 1186 -> 1195. RUNTIME_VERSION moves: a depth or stencil texture over a
buffer no longer gets a linear image. crates/metal2vulkan-validation/runtime-sources.sha256 holds
4a161b14058fa3e4c4b039726845c4bb221965a409dae3153e6232d213f22330, the hash of this tree's runtime
inputs (runtime-pin.py, which reproduces build.rs's). Version numbers quoted above are the values
the work's branch built with. Each part's Verified lines name the tree it ran at.
A shadow of a texture over a buffer starts as the buffer's memory lies, instead of zeros that the
copy-in then overwrites, and a format's linear-modifier features are asked of the driver once. A
no-copy texture is laid at Metal's row pitch as a linear image over the buffer wherever the driver
takes that explicit pitch, and a driver's refusal is remembered per exact image (up to 256). The
lanes check textures at a browser's padded row pitches and say which pitches each driver takes.
RUNTIME_VERSION 1186.
Gain: a surface texture's shadow on ANV 1048 -> 135 us, RADV 484 -> 90 us. With the pitched images,
every padded surface aliases on ANV with no shadow: a tile 1048 -> 41 us.
Verified on the original branches: the runtime lanes on RADV, ANV and NVIDIA. Known open:
pitched_surfaces::a_half_float_tile_reads_writes_and_renders_as_metal fails on lavapipe (a
clear-blend-store pass writes a few padding bytes past the row), as it did on the original branch.
This squashed commit was not re-tested on its own.
A pass that does not store a color whose texture lies over a buffer now renders it into an image the
texture keeps (a Load copies the buffer's texels in first; nothing is copied back), so the buffer
keeps its bytes, as Metal does: measured on an M3 Max, every DontCare case kept the buffer's bytes,
with or without a barrier between draws. On MoltenVK a pass that Metal receives whole keeps using
Metal's own DontCare at no cost; only split or restarted passes use the kept image. New performance
notice `dont-care-stand-in`, a `kept_bytes_passes` work count, a frame-cost shape whose layers are
textures over buffers, and the cost recorded in docs/FAST-PATHS.md. RUNTIME_VERSION 1185.
Gain: correct bytes where the old form wrote rendered or cleared texels into the buffer. Cost on ANV:
a Load + DontCare pass about 10 us more; Clear + DontCare frames got cheaper (12.33 -> 11.18 ms).
Verified on the original branch: the four focused lane modules, 35 of 35 on RADV, an RTX 3090,
lavapipe and ANV, and its MoltenVK lanes on the M3 Max. This squashed commit was not re-tested on its
own.
Compare a draw's graphics key in place, keep a drawing state's routing for the pass colors it last
met, write descriptors from the stack and allocate the set in place, keep a draw's small lists on
the stack, hold what a draw retains by reference in one entry per encoder, find a draw's bind shape
among its state's settles, fill push bytes in place, bound coverage without allocating, gather named
keys only once a draw reaches the resident set, compare viewport compensations as they come, list
argument samplers again only where the device's changed, and keep each pass shape's compatible
render pass on the device (up to 64 shapes). The frame-cost lane bounds a draw at 27 allocations and
a pass open at 14.
Gain: allocations per draw from 67.5 to 24.5 and per pass open from 18 to 13 on RADV, ANV and
lavapipe. Frame CPU on ANV (Iris Xe), clean rounds: 5.66 -> 5.02 ms.
Verified on the original branch: the runtime lanes, 1313 of 1313 on RADV, ANV and lavapipe. This
squashed commit (with the wake fix under it) was not re-tested on its own.
A sample of a BGR10_XR, BGRA10_XR or RGB10A8_2P_XR10 texture (or an sRGB twin) through a constexpr
bicubic sampler, or through a runtime sampler whose bound word states Cubic, was refused
(NotImplemented(SamplerBicubicFilter) in the lowering, NotImplemented(Format) in the binder). It is
now Metal's bicubic filter of the decoded texels, measured on an Apple M3 Max (macOS 26.7) through
the owned fixture xr_bicubic: random codes of each of the six formats at 16x16, 7x5, 3x3, 2x6 and
1x1, 2,304 coordinates each (every texel's centre, then random ones up to 0.15 of the texture past
its edges), through 12 kernels (a runtime Cubic sampler with float and half results; constexpr
samplers under clamp to edge with float and half results, repeat, mirrored repeat, clamp to zero,
the opaque-white and opaque-black borders, pixel coordinates, and an offset under clamp to edge and
repeat): 3,317,760 lanes.
What Metal does, and what the lowering now does: the footprint, weights, addressing, a mirrored
axis and a level below four texels are the other formats' bicubic filter's, each tap the decoded
texel or the border texel through the format's channels; a level below four texels sums as the
extended-range linear filter (terms truncated); otherwise each tap's step is weighed by the
product of Metal's weights and summed exactly (no term truncated, unlike the linear filter), the
step rounded half up, clamped into the steps of the codes 0 and 1023 (a color lane's (0-384)/510
and (1023-384)/510, an sRGB twin's table steps, alpha [0, 1]), and divided by the grid exactly; a
half result rounds as the linear filter's does. The clamp is applied to the rounded result, which
equals clamping the step because each rounding is monotonic. Every lane but 4,050 matches that
model; each of the 4,050 is one step from Metal's (1/8160 a color lane, 1/8192 an sRGB color lane,
1/4080 alpha), its exact sum within 0.014 of a step of a rounding tie that Metal rounds the other
way. No model of Metal's datapath tried closes that residue, so the sample records
PrecisionNote::BicubicFilterArithmetic, and docs/FAST-PATHS.md and docs/API.md say so. A bfloat or
padded form's bicubic sample, a swizzled texture's and a gather through a bicubic sampler were not
measured and are refused.
How: select_extended takes the bicubic state of a constexpr sampler or of the slot's cubic-sampler
variant (LoweringInputs::cubic_samplers) and plans Metal's bicubic filter; the extended sampler emits
it through bicubic::filter with Texels::Extended, which fetches each tap's raw texel and decodes it,
through the exact routines alone, then clamps. The binder takes a cubic word at an extended-range
slot as the cubic-sampler variant's, and gives such a slot the neutral BicubicTexels value in the
plan of the pipeline as compiled, which binds the neutral there (it refused the format before
naming the variant: the device lane found that). SEMANTICS_VERSION 1693; RUNTIME_VERSION 1184, as
a run of an existing artifact with a cubic sampler at an extended-range slot is no longer refused;
the runtime-sources hash re-pinned.
The table: xr_bicubic.tsv (2,067 samples of the probe's, per texture and kernel the middle
texel's centre, four random coordinates, the first sample with a lane at a clamp bound and the
first with a lane at a tie), shared through metal2vulkan_devtools::xr_bicubic with the probe's
texture generator.
Verified on homelab-gem10 (debug builds):
- tests::engine_extended_range::bicubic, on the CPU interpreter on the lavapipe and MoltenVK-M3
profiles: every lane of the table through the same 12 kernels, compiled under the six forms'
variants (the runtime ones under the cubic-sampler word the binder plans), is Metal's bits but
the 136 lanes the table marks, each one step away; each compile validates and its estimate
bounds it. A padded or bfloat form's bicubic sample, a swizzled texture's and a gather are
refused as above (a two-plane gather as Format, under any sampler); on every committed profile
the pipeline as compiled plans the variants with the XR texture and a Cubic sampler bound, and
the variant's pipeline plans the same key.
- runtime_lane::extended_range_bicubic (new): the 8,268 lanes on the Radeon 780M (RADV), the RTX
3090 and lavapipe, textures written as the probe wrote them: 0 differ from Metal (136 at a tie,
one step away), and the state announces bicubic-filter-arithmetic. The extended_range_samples,
two_plane_samples and two_plane_copies lanes, whose helpers this shares, pass on all three.
- Release build, 12 kernels x 6 forms x 5 profiles (lavapipe, 780M, RTX 5080 Laptop, Arc ANV,
MoltenVK-M3): 360 translations, mean 1.31 ms, slowest 1.97 ms (xrb_runtime, BGRA10_XR sRGB,
780M), budget ledger peak at most 935 KiB, process peak RSS 15.6 MB; the linear XR kernels
take 0.81 ms on average.
- clippy -D warnings (workspace, all features, all targets; validation also under m2v_gpu),
rustdoc -D warnings and the doctests pass. Suites: metal2vulkan, -air, -runtime and -devtools
4,566 of 4,567, validation 1,293 of 1,293. The one failure is tests::golden_hashes, whose 380
stale cells are the two new fixtures' alone (smw_writers 7 and xr_bicubic 12 entries x 20
profiles), left to be blessed on development.
RADV imports host pointers through amdgpu userptr with ANONONLY, so it
refuses MAP_SHARED memfd pages (QEMU's memory-backend-memfd guest RAM and
views of it): every no-copy buffer, heap and rebind over them was refused,
and a macOS guest could not boot on AMD. NVIDIA imports the same pages.
What:
- The five no-copy entry points (new_buffer_with_bytes_no_copy, both
new_heap_with_bytes_no_copy calls, Buffer and Heap rebind_bytes_no_copy)
take a HostMemory; HostMemory::with_dma_buf adds a retained DmaBufSource.
- Where the pointer import is refused, and only there, on any device that
lists VK_KHR_external_memory_fd and VK_EXT_external_memory_dma_buf, the
runtime asks the source for dma-bufs of the window's pages (chunks cut at
the device's sparse granule, sized by the caller within udmabuf's default
limits) and binds one buffer over them: plain for one chunk, sparse for
several (vkQueueBindSparse signalling queue 0's timeline; later work waits
on it, no host wait). Every path that imported before is unchanged.
- Textures over such pages get a dedicated DRM_FORMAT_MOD_LINEAR image import
of their own pages where the driver takes the plane offset and row pitch
(multiples of 256 on RADV), with 64-bit modifier features; elsewhere, or on
a source error, the existing shadow path.
- The extensions are enabled outside the compile profile: no device's enable
set, fingerprint or ARTIFACT_FORMAT_VERSION changes. The translator crate is
unchanged.
- Imports free inside exit-guard sections; the source is never called with a
runtime lock held. WorkCounts gains dma_buf_imports, dma_buf_sparse_buffers,
dma_buf_images and dma_buf_image_fallbacks.
Verified:
- Product suites 4553/4553, validation suite 1289/1289, clippy in every
configuration, rustdoc -D warnings, scripts/api-docs.
- runtime_lane::dma_buf_imports and rebinds on RADV Mesa 26.2.4 (validation
layer clean), the RTX 3090 and lavapipe (pointer imported, source never
called), and dma_buf_imports on RADV Mesa 26.0.8.
- reims-vgpu on the Radeon 780M (RADV 26.0.8, udmabuf at its defaults): a
macOS 26 guest cold-boots to the desktop and runs Safari; 5,119 dma-buf
requests, none refused.
- 64 MiB on RADV 26.2.4, release: pointer import 187 us; one chunk 665 us;
16 chunks 16.9 ms, about half of it the refused pointer attempt. The old
host-fence bind waited 1.26 s behind queue-0 work on RADV 26.0.8.
Rolls up everything since 43c46ac8 into a single commit. Its tree is
identical to the tree of private master at
b3c77f2d2b20a432be10591a2129547c10b1c24b.
- A Cargo workspace of five crates under crates/: metal2vulkan (the
translator and the metal2vulkan command), metal2vulkan-runtime (the
Metal API on Vulkan), metal2vulkan-air (the AIR front end),
metal2vulkan-validation and metal2vulkan-devtools.
- Dual license: GPL-2.0-or-later OR LGPL-3.0-or-later.
- docs/: API, architecture, fast paths, how-to, Metal coverage,
refusals, runtime porting and validation guides.
Private-Commit: b3c77f2d2b20a432be10591a2129547c10b1c24b