2137a20004e2b5658aedd0bdfdafc99e043606ce
1530
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
6b322fb50f |
Cut the cold making of half-heavy shaders on ANV and RADV: controlled half rounding and the device's half widening
On Intel's ANV, CoreAnimation's A2Xghfc fragment shader (313k words) took
about 14 s to make cold, for each of three states. The consumer's x86 macOS
guest stalled with "no completion in 10 s" on its first boot. Native Metal
makes it in 0.48-0.56 s on the M3. brw (Mesa's Intel backend) spends that
time in its register allocator. Its interference build is quadratic in
instruction count, it spills, and it retries several scheduling modes. Most
of its input was our half arithmetic. Two cuts, each the cheaper form, are
taken on ANV and RADV.
1. A half result computed in float rounds through the device's conversion
pair under the float controls (QuantizeForm::Controlled). It replaces
OpQuantizeToF16 plus a denormal arm, about 11 NIR operations per lane.
- The form: an OpFConvert to 16 bits and back, each decorated
NoContraction, in an entry that declares RoundingModeRTE,
DenormPreserve and SignedZeroInfNanPreserve for 16 bits, plus the
modes the device's independence ties to them (ANV: RTE for 32 and 64
bits; RADV: RTE and DenormPreserve for 64 bits). The modes are
declared post-lowering (new ExecMode kinds), and the requirements
carry the FloatControl properties.
- Exact by the Vulkan spec under either HalfRoundingPolicy: conversions
are correctly rounded, and NoContraction forbids folding the pair. No
fact, no note.
- A new DriverWorkaround, HalfConversionPairFolded, keyed on NVIDIA's
proprietary driver, keeps NVIDIA on its previous forms. NVIDIA
615.71.09 on the RTX 3090 folds the pair even under NoContraction and
every mode combination, and the PackHalf2x16 and u16-bitcast forms
fold the same way: 2,231,288,832 of 2^32 narrowings unrounded. A
plain-Vulkan repro gives 16,775,680 of 2^24 unrounded on the 3090 and
0 on ANV.
2. A half read from its bits (a load, a reinterpretation, a texel's bits) is
the device's widening under NanMinMaxPolicy::Native, the default: each
u32 lane is bitcast to f16x2 and converted to 32 bits, in place of a
12-op integer decode. A half texel takes that conversion's NaN (no keep).
- Every non-NaN half is exact by the spec: DenormPreserve covers
"values obtained via unpacking an integer into a vector of values
with smaller bit width".
- A NaN's bits are the device's, recorded as NativeNanEncoding
(native-nan-encoding), now also announced on ANV and RADV pipelines
that decode halves. A half stored back unchanged keeps its bits.
- NanMinMaxPolicy::Exact keeps the integer decode and the keep. There,
every half widened to float answers Metal's 0x7fc00000 for a NaN, as
the M3 does over every pattern from memory, constant memory, selects
and texels.
Where brw's time went, measured on A2X (a2x-s96): after cut 1, 49.6k NIR
operations, of which the rounding pairs were about 10.7k, half decodes from
memory 8.6k and texel NaN keeps 2.6k. The rest was below 5% each.
Exactness probes:
- Cut 1 (candidate half(x) over all 2^32 f32, and half + - * over every
pair): 0 non-NaN mismatches on ANV Iris Xe (Mesa 26.2.4), RADV 780M
(Mesa 26.2.4), and the 780M and RX 7900 XTX (Mesa 26.0.8).
- Cut 2 (every half pattern): 0 non-NaN differences on ANV and RADV.
- The M3 confirms Metal equals the integer reference everywhere.
Cold making (A2X, base against each cut):
- ANV Iris Xe: 13.6-14.3 s, then 5.75-6.16 s, then 4.06-4.36 s. Peak RSS
1.28 GB, then 0.50, then 0.35. GPU time per draw 4.62 -> 4.48 ms.
- RADV 780M: 0.80-0.84 s, then 0.53-0.55 s, then 0.38-0.47 s. GPU time per
draw 4.05 -> 3.43 ms after cut 1, then within its clock states' spread.
In the consumer's cold boots on ms01 (Iris Xe), A2X went from 14 s per
state, plus two 38 s remakes, to 4.0-4.3 s. The suite's pipeline making went
from 126 s to 16.7 s, with no stall. Repeat boots show metalwin unaffected:
its frame rate follows other GPU work at session start, not this change.
Tests:
- engine_native_half: the controlled conversion, and a half read from memory
under both NaN settings, NaNs stored back.
- device::tests::profile::nvidia_carries_the_folded_half_conversion_pair.
- lower::arith::tests: narrow, round_texel, half_texel, texel_round.
- spirv::requirements; spirv::builder::ops.
- Updated expectations: engine_arith half rounding, engine_spirv_cross_forms
fma, engine_metal_routines frexp (the device's NaN under the default,
Metal's under Exact).
- The validation lanes driver_deviations and native_maths expect the
controlled form.
Docs: the FAST-PATHS half-rounding row (scope) and a new row for the
widening; the NativeHalfConversion and NativeNanEncoding entries in API.md and
their rustdoc; HalfRoundingPolicy and NanMinMaxPolicy rustdoc; HOWTO's driver
note; REFUSALS regenerated. A known gap is added to the texel-NaN row: on
ANV a 16-bit float NaN texel kept as half reads back 0xFE00 from ANV's image
decode, even under Exact (announced as device-nan-encoding). SEMANTICS_VERSION
1759, runtime pin recomputed, RUNTIME_VERSION unchanged.
Tables: the golden hashes, 274-389 cells on each ANV and RADV column across
both cuts, and NVIDIA's profile fingerprints, whose words are unchanged. The
authored compile census: artifact hashes on the 780M and RPL-P ANV columns,
with no status change. No MoltenVK, lavapipe or floor cell moves.
Verified on development-fast (batches f18-f24): every lane green on the RTX
3090, ANV Iris Xe, RX 7900 XTX, both 780Ms, lavapipe and the M3 Max, plus the
CPU suites, case qualification, clippy in every configuration, docs and
packaging. Not run on the RTX 5080 Laptop (host offline; whether its driver
keeps the pair is unmeasured).
|
||
|
|
b7da00074a |
Filter a two-plane YCbCr texture with the device's sampler by default, Metal's filter behind YCbCrFilterPolicy::Exact
A draw that bound a two-plane YCbCr texture (YCBCR8_420_2P and its kin) at a
linearly sampled slot made a second VkPipeline at the draw. The slot's YCbCr
variant (RuntimeFact::YCbCrTexture) emulated Metal's filter of the format, and
the state's creation never predicts it, since the predicted key binds no
texture. On ANV, CoreAnimation's A2Xghfc paid 37.8 s for that second making,
inside a command buffer, past the x86 guest's 10 s watchdog.
Under the owner's rule (fast by default, exact on request, both kept, the
difference logged), the default is now the device's own filter. A new
DevicePolicy field, ycbcr_filter, selects the form:
- YCbCrFilterPolicy::Device, the default.
- On a device that samples natively (ANV, RADV, NVIDIA, lavapipe),
ProfileFields::ycbcr_variant is false. The slot records no fact and is
filtered by the device like any other, and a draw takes the pipeline its
state's creation made. The module's PrecisionNote::DeviceSampling
(device-sampling) states the bound.
- On MoltenVK, Metal's own sampler filters the slot's converted view
(RGBA16Float on the 1/2048 grid, RGBA32Float on 1/8192).
lower::sampler::linear::metal_filtered_ycbcr records the
HalfSampleFilter/FloatSampleFilter note under the bound format alone
(SpecKey::BoundTexelFormat). The runtime's degrade_bound_formats
announces it as ycbcr-filter-not-exact, naming the slot and the format.
A one-texel half sample on the 8192 grid records HalfTexelConversion
under that format and is announced at the draw.
- YCbCrFilterPolicy::Exact keeps the variant: Metal's filter, through one
pipeline made at the first draw binding such a texture.
DevicePolicy::exact_answers() sets it. On MoltenVK, SamplingPolicy::Exact
takes the variant too. Over a compiler limit, the native-sampling fallback
(ReducedForms) drops it with sampling and reports it.
Bound of the default, in codes of 1/255. Each figure is the largest
difference of any channel over five surfaces (420v/420f; BT.601, BT.709,
BT.2020), 65,536 random coordinates and 960 on the 1/256 grid, float and half
results. Measured against Metal's sum (checked equal to metal_step):
- NVIDIA RTX 3090 (615.71.09): 1.183
- ANV Iris Xe RPL-P (Mesa 26.2.4): 1.058
- RADV 780M and RX 7900 XTX (Mesa 26.0.8): 0.877
- lavapipe (Mesa 26.2.4): 0.872
- MoltenVK against Metal's own YCbCr filter (M3 Max, macOS 27.0.1, plain
Metal): 0.1245 for RGBA16Float and half results; 0.0157 for RGBA32Float
float results.
Reproducer (corpus-draw-ab on ANV, cold, a2x-s96 with
RGBA8Unorm:linear@3=YCBCR8_420_2P): before, two pipelines (13.9 s at
creation, 37.8 s at the draw), 52.3 s wall, 3.23 GB. After, one pipeline
(13.9 s), 14.3 s wall, 1.30 GB.
Tests of both settings:
- a_device_takes_the_ycbcr_variant_only_under_the_exact_filter (lavapipe and
MoltenVK).
- The runtime lane's default tests on native-sampling devices and on
MoltenVK: no pipeline at the YCbCr draw, bit for bit the RGBA16Float twin's
draw, the expected announcements once. The exact twins expect the variant.
- fingerprint_covers_every_policy_field.
- metal_s_own_answers_key_the_same_under_either_choice.
- The notes test helper (engine_linear_half::notes_bound) now gives
BoundTexelFormat the bound texture's class, as the runtime does.
Docs: the FAST-PATHS row and its MoltenVK bound, the API.md
ycbcr-filter-not-exact, device-sampling and half-texel-conversion entries,
the policy, profile-field, fact, lowering and runtime-kind rustdoc, and
REFUSALS regenerated. SEMANTICS_VERSION 1757, RUNTIME_VERSION 1314, runtime
pin recomputed.
Tables: the golden hashes (38 cells per natively sampling column, both tables;
every profile's fingerprint for the new policy field, MoltenVK's again for its
default) and the authored compile census (187 cases on 10 native-sampling
columns, 193 on moltenvk-m3). All are artifact hashes, with no status change.
Verified on development-fast (batches f15-f19, f24): every lane green on the
RTX 3090, ANV Iris Xe, RX 7900 XTX, both 780Ms, lavapipe and the M3 Max
(MoltenVK), plus the CPU suites, case qualification, clippy in every
configuration, docs and packaging. Not run on the RTX 5080 Laptop (host
offline). The consumer measured YCbCrFilterPolicy::Exact on MoltenVK as byte
for byte the previous variant (80 of 80 tests on the M3).
|
||
|
|
01841476dd |
Compute Metal's 8-bit unorm blend of a fetched attachment for every factor, mask and blend color
Through the pixel interlock (RADV, ANV, NVIDIA, MoltenVK) a fetched attachment is a storage image, so the shader computes Metal's blend. For R8Unorm, RG8Unorm, RGBA8Unorm and BGRA8Unorm only premultiplied source-over with every channel written was built; every other blend, any write mask that keeps a channel, and the blend color stayed FramebufferFetch / NotImplemented at the color. What: Blend::unorm8 now plans every factor and operation but the second source's, under any write mask, with the blend color, through the 16-bit planner's forms as Metal's compiler builds them for an 8-bit unorm attachment (Family::Unorm8, measured, below): - an inner sum adds the destination's atoms before the source's (Order::Destination); - a lerp takes y from the destination's product first; alpha takes no lerp of the destination alpha beside itself or held by both products; - of an added pair, the destination's product is rounded first where unorm8_rank(fs) >= rank(fd) (tables per half/float arithmetic and color/alpha); - alpha shares the one minus the blend alpha, source alpha and destination alpha (SourceAlpha- Saturated's too) that stored color lanes compute; with no color channel stored, the one minus an alpha the color channels' destination factor is; a min or max computes no factor. A shared one minus blocks a lerp of the blend or destination alpha and stays whole where added from the destination's product; - a write mask of one color channel plans that channel as a scalar (Order::Scalar: Da, D, Sa, S): no splat rules, but a one minus an alpha that its destination factor is, or that alpha's factors compute (alpha stored or not), stays whole and takes no lerp. blend_unorm8 reads the blend color from PushField::HalfBlendColor's f32 words: NaN to 0, clamped to [0, 1], rounded to half in half arithmetic; OneMinusBlendColor reads h(1 - h(c)) (f(1 - c) in float) under either math. fetch.rs pushes the field where the blend reads it and merges the channels the mask leaves out after the blend, as the 16-bit form does. Because Metal's forms depend on the mask, compiled_write_mask splits a blended RGBA8Unorm/BGRA8Unorm attachment's partial-mask class in three (alpha alone, one color channel with or without alpha, two or more color channels); other formats keep one partial class. Without that split a one-channel mask compiled under the two-channel class and missed Metal's code in 64 of 4096 texels on the 3090 and the 780M. Without fast math every state takes the rounded forms. Refused, NotImplemented(FramebufferFetch): a second-source factor; under fast math a lerp, common factor or contracted pair into R8Unorm or RG8Unorm (Metal sums those in forms of their own, EV FB8-r8-m3); every other format, now named in FAST-PATHS' known gap with the source-over survey's result (10-bit unorm and RGBA8Snorm fit the 8-bit model with their clamps; the 16-bit norms and RGBA32Float blend in float even for half4; their factor sets are not measured). No PrecisionNote or DevicePolicy kind is added: every built blend is exact. Metal's arithmetic, plain Metal on the M3 Max (macOS 27.0.1), our own MSL, 512 x 512 targets: every destination code against every source alpha code (two blocks) plus random blocks with sources out of range, infinite or NaN; half4 and float4, fast and safe; BGRA8Unorm unless named: - EV FB8-sw2-m3 (seed 388824, blend color 0.3/0.6/0.9/0.45): every factor/operation pair for color beside source-over alpha (676), the reverse (676), and the same pair for both (677). - EV FB8-rnd1-m3 (seed 424242, color 0.7/0.15/0.55/0.8): 600 random state pairs. - EV FB8-mk1-m3 (seeds 1000 + mask): masks 1 to 14, 300 random states each. - EV FB8-bc1-m3 (seeds 2001-2003): blend colors past both ends of every channel. - EV FB8-sc1-m3 (seed 7): one color channel: all 153 color keys with a lerp or common-factor candidate beside 13 alpha keys (none, OMSA, OMDA, OMBA, OMSC, OMDC, OMBC, mixes), masks B and B+A. - EV FB8-ao1-m3 (seed 9): alpha alone: all 432 alpha keys with a lerp, common or contracted form beside 8 color keys. - EV FB8-mk3-m3 (seeds 1000 + mask): masks 1, 2, 3, 4, 5, 8, 9 under two random sets of 300. - EV FB8-mm1-m3: a min or max beside one-minus factors, full mask, one channel and alpha alone. - EV FB8-r8-m3 (seed 3001): R8Unorm and RG8Unorm, same/color/random400: safe math exact in every state; fast-math misses only lerp, common and contracted forms; single, fused, zero and min/max forms exact in every state. The model fits every state of each EV (0 mismatched channels), and the Rust planner's plans equal the model's on 240,480 states (each sweep state under ten masks with and without alpha, plus the explorer states, half/float x fast/safe), compared through a scratch dump. Tests: arith::tests::blend8 adds the interpreter over a state of each rule (source alpha over, the blend color's lerps with a color past both ends, blue alone, alpha alone; half and float, fast and safe) against hand-written Metal arithmetic, and the no-alpha refusals; tests::engine_fetch_blend8 compiles eight other blends and masks (blend color pushes HalfBlendColor, nothing announced) on every interlock committed profile and keeps second-source factors refused; engine_fragment's interlock test now expects RGBA8Unorm's blend computed. runtime_lane::framebuffer_fetch::blend8 adds other_blends_masks_and_the_blend_color_store_metals_blend: the four states into BGRA8Unorm through each fixture's half4 and float4 loads on the device, every texel against the model. Verified on gem10 at the content of this commit (WIP a395835, plus REFUSALS regenerated): - cargo fmt --check; clippy --workspace --all-targets --all-features -D warnings in plain, --cfg m2v_gpu and --cfg m2v_cpu_icd; rustdoc -D warnings. - metal2vulkan nextest -E 'test(/eight_bit|blend8|blend16|fetch/)': 90 of 90 passed. - metal2vulkan-validation -E 'test(/eight_bit|framebuffer_fetch/)' (release, m2v_gpu) on the RTX 3090: 56 of 56. Every draw went through the pixel interlock with Metal's 4096/4096 texels and nothing announced: the 24 source-over draws and the 16 new ones (four states x two fixtures x half4/float4). On lavapipe (m2v_cpu_icd): 56 of 56; the device blends through input attachments and announces HalfOutputFastMathBlend and DeviceColorConversion. - The 780M was held by reims-vgpu at the final run. One run earlier, before the mask-class split, it agreed texel for texel with the 3090, including the one-channel miss the split fixes. SEMANTICS_VERSION 1754 -> 1755: the translation of these blends and the mask classes changes. RUNTIME_VERSION and the runtime-sources pin are unchanged. docs: the FAST-PATHS known gap (what is built, what is refused, and the other formats' survey), the API.md degrade catalogue, and REFUSALS.md regenerated. |
||
|
|
ea89d3f8ed |
Mark the project beta in the README
The README's status notice said alpha; the user moved the project to beta. The rest of the notice (the API, command line, pipeline JSON and SPIR-V may change during 0.x) stands. |
||
|
|
bc90b127f1 |
Compute Metal's 8-bit unorm source-over blend of a fetched attachment in the shader
The x86 macOS guest refused a render pipeline on every interlock device (RADV, ANV, NVIDIA,
MoltenVK): framebuffer fetch of a BGRA8Unorm color 0 blended One / OneMinusSourceAlpha (add,
color and alpha, mask 0xf) beside an RGBA16Float color 1 of mask none was
FramebufferFetch / NotImplemented at Color(0). Through the pixel interlock the fetched attachment
is a storage image, so no Vulkan blend applies and the shader must compute Metal's blend; only
the extended-range and 16-bit float blends were built.
What: Blend::unorm8 plans premultiplied source-over into R8Unorm, RG8Unorm, RGBA8Unorm and
BGRA8Unorm storing every channel, half4 and float4 outputs, fast and safe math, through the 16-bit
float planner's forms. blend_unorm8 clamps the output to [0, 1] (NaN to 0), reads the texel's code
exactly (RoundEven(texel * 255), then the existing exact division to f32, then half for a half4
output), and blends in the output's type: fast math fuses (h(fma(d, h(1 - a), s))), safe math
rounds each step (h(s + h(d * h(1 - a))), likewise in float). fetch::unorm8_blended then rounds the
result's code by Metal's 8-bit unorm write (color_write's Unorm{8} rule). The blend takes channels
in Metal's order from read_texel and hands them to emit_return's metal_order exchange, so ANV's
RGBA twin of a BGRA8Unorm attachment takes it unchanged. Any other blend of an 8-bit unorm
attachment, a write mask that keeps one of its channels, and every other format stay refused as
before (FramebufferFetch / NotImplemented). The color write plan treats a shader-blended 8-bit
channel as rounded in the shader, so it records no device-conversion note. No PrecisionNote or
DevicePolicy kind is added: the blend is exact.
Metal's arithmetic, measured with plain Metal on the M3 Max (macOS 27.0.1), our own MSL of the
guest's shape:
- EV FB8-dec1-m3 (seed 1): a fetch of every code reads h(c / 255) as half4 and f(c / 255) as
float4, every channel of every format. A plain write stores the code of the value clamped to
[0, 1] (NaN to 0) times 255, the exact product rounded half up.
- EV FB8-sw1-m3 (seeds 1000 * run + (output is float), runs 0 to 3; 4096 x 961 targets): every
half alpha in [0, 1] (15,361) against every destination code of each channel, four source draws
per pair (aimed within four ulps of a code midpoint, 2% out of range, infinite or NaN). That is
63 million channels per variant (BGRA8Unorm, RGBA8Unorm, RG8Unorm, R8Unorm x half4, float4 x
fast, safe), and the model above gives Metal's code in every channel: 0 mismatches.
- EV FB8-fold1-m3 (seed 7, 2048 x 2048): nine products and sums of the output, the fetched color
among them, half4 and float4, fast and safe. The clamp keeps all of them out of the blend, so
fbl8_over_product is exact too (16-bit float folds it).
Tests: arith::tests::blend8 runs the interpreter over every alpha code's value against every
destination code (half and float, fast and safe, BGRA8Unorm and R8Unorm), and checks that another
blend, mask or format is refused. tests::engine_fetch_blend8 compiles the guest's shape on every
interlock committed profile (BGRA8Unorm on each, the ANV profile asserted, no skip) for four
formats and six entries, plus the whole guest pipeline. It asserts the storage form, no note,
link and validation, and that other blends stay refused at Color(0). At d188d8b771 (before this
change) a_blended_eight_bit_unorm_fetch_computes_metals_blend fails with the guest's refusal
("unsupported: FramebufferFetch; needs NotImplemented ... color attachment 0", amd-780m-radv
BGRA8Unorm). The fixtures fbl_fetch_blend8 and fbl_fetch_blend8_safe (our own MSL, regenerated
by scripts/regen-air-fixtures) feed runtime_lane::framebuffer_fetch::blend8, which draws each
entry into the four formats on the device and compares every texel with the model; their
golden printouts (tests/air_input) come from bless_engine_goldens under the pinned LLVM 21.
Verified (gem10, release where a GPU runs):
- clippy --workspace --all-targets --all-features -D warnings in plain, --cfg m2v_gpu and
--cfg m2v_cpu_icd; rustdoc -D warnings.
- metal2vulkan nextest -E 'test(/eight_bit|blend16|fetch/)': 87 of 87 passed; -E 'test(/air_input/)'
with METAL2VULKAN_TEST_REQUIRE_PINNED_LLVM=1: 7 of 7 passed.
- metal2vulkan-validation -E 'test(/eight_bit|framebuffer_fetch/)', 55 of 55 passed, on the RTX
3090 (NVIDIA ICD) and on lavapipe (m2v_cpu_icd, LP_NUM_THREADS=1). On the 3090 every one of
the 24 fixture x format draws went through the pixel interlock with Metal's 4096/4096 texels
and nothing announced.
SEMANTICS_VERSION 1753 -> 1754 (translation of this shape changes). RUNTIME_VERSION and the
runtime-sources pin are unchanged. docs: FAST-PATHS known gaps (the interlock blend's coverage),
the API.md degrade catalogue (HalfOutputFastMathBlend), REFUSALS.md regenerated.
The blessed tables come in the same commit: golden_hashes.tsv gains 16 rows for
fbl_fetch_blend8 and fbl_fetch_blend8_safe, public_fixture_expectations_engine.tsv their 16
inventory rows in fixture order, and authored-compile.tsv only its product fingerprint (no cell
moves). Batch verification on development-fast: the fetch and blend filters green on the RX 7900
XTX, the 780M, the Iris Xe, the RTX 3090, lavapipe and the M3; the full suites at the bless green
on the Iris Xe, the XTX, the 780M and the M3 (7259 and 7274 tests). The RTX 5080 was not run.
|
||
|
|
fc9147534d |
Fetch a BGRA-order attachment through its RGBA twin without format-less reads
On a device that orders framebuffer fetch through the pixel interlock but has no shaderStorageImageReadWithoutFormat (ANV), a fetched BGRA8Unorm or BGR10A2Unorm color attachment was refused: SPIR-V names no image format for B8G8R8A8_UNORM or A2R10G10B10_UNORM_PACK32, so neither the typed nor the format-less declaration reached it. A guest pipeline of a fetched BGRA8Unorm color 0 beside an RGBA16Float color 1 was refused on the Iris Xe and aborted the consumer. What changed: - One public decision for the fetch storage view's format, StorageAttachmentUse::view_alias_of(format, profile) (the old uint_view_of took no profile). An 8-bit sRGB attachment keeps its unsigned-integer view. A BGRA-order format the device accesses without a format keeps its own format (RADV, NVIDIA, MoltenVK unchanged). One no declaration reaches takes its RGBA-order twin (R8G8B8A8_UNORM, A2B10G10R10_UNORM_PACK32) where the twin declares and stores. The compile layer (lower/fragment/fetch.rs) and the runtime (framebuffer_fetch::storage_view_format) both call it. - The fragment reads and writes such an attachment through the twin, exchanging red and blue in the shared read and write helpers (read_texel, metal_order), so every read, written value, kept channel and per-sample plane sees Metal's channel order. - The runtime makes the views: a BGRA8Unorm render target's free STORAGE candidate is made mutable to the twin (so ANV fetches it in place), and stand-ins and sample planes take the twin as their storage view. - StorageAttachmentUse::format_usages names the view's format (the one the storage image is bound in), not the attachment's. - Public rename: StorageAttachmentUse::uint_view and WriteSource::TileAttachment::uint_view become view_alias (serde keeps the old name as an alias), with StorageAttachmentUse::with_view_alias and view_alias_of. - The refusal names both routes where neither reaches (a BGR10A2Unorm attachment without shaderStorageImageExtendedFormats). The class, on a device without format-less storage reads: a fetch of a 16-bit packed attachment (B5G6R5Unorm, A1BGR5Unorm, ABGR4Unorm, BGR5A1Unorm) stays a typed FramebufferFetch refusal, and a read of an argument buffer's writable texture a typed ArgumentBufferTextures one; both are FAST-PATHS known gaps. Kernel slots, tile passes and the depth and stencil stand-ins already declare typed first. SEMANTICS_VERSION 1753, RUNTIME_VERSION 1313, runtime-sources pin recomputed. REFUSALS.md regenerated; docs/API.md says which view the storage form binds. Verified: - Metal (M3 Max, macOS 27.0.1, our own MSL probe under the Mac GPU lock): BGRA8Unorm and RGBA8Unorm targets, 1x and 4x, masks of every channel and of red and alpha, one to three fetch_ordered draws: every byte matches the model the device test checks (c read as c/255, halved, written as the exact product with 255 rounded to nearest). - ms01, Iris Xe (ANV, Mesa 26.2.4), release, --cfg m2v_gpu: runtime_lane::framebuffer_fetch::bgra passes with Metal's bytes in every case beside an RGBA16Float color 1 that keeps its clear. The BGRA8Unorm pipelines are made with view_alias R8G8B8A8_UNORM (4 pipelines); single-sampled targets are fetched in place (no storage form switch, no fetch-through-scratch notice), 4x through sample planes viewed in R8G8B8A8_UNORM. The fetch lane (runtime_lane::framebuffer_fetch::, 47 tests) and tests::srgb_fetch_images pass there too: 48 of 48. - ms01, debug: lower::fragment::fetch::tests (new: the twin on each of four ANV profiles for BGRA8Unorm and BGR10A2Unorm at 1x, in planes, under reads, writes and a red-and-blue mask; format-less profiles unchanged; both routes named; the refused class), engine_fragment::a_fetched_bgra_attachment_is_viewed_in_its_rgba_twin (the consumer's two-attachment shape on intel-irisxe-anv, 1x, 4x and a partial mask, the SPIR-V validated against the profile), with engine_fragment, engine_tile, cache::tests, pipeline::api_tests, pipeline::link::tests, fast_paths and api_surface: 217 of 217 pass. With the twin decision forced off, the five new translator tests fail, the consumer shape refused as on the Iris Xe (FramebufferFetch needs AnyOf([[ShaderStorageImageReadWithoutFormat]])). - clippy --workspace --all-targets --all-features -D warnings clean plain, with --cfg m2v_gpu and with --cfg m2v_cpu_icd. |
||
|
|
cc961dc744 |
Keep zero signs where an Exact answer needs them, and end a busy exit at once on Linux
One squash of development-fast d8546c940b..46649e335d (5 commits); the tree equals 46649e335d. - Exact float maths (FloatMathsPolicy::Exact off MoltenVK): a module whose checked product, checked OpFmaKHR or fma routine (Wide, Soft, HalfOdd) answers Metal's zero of its sign now declares SignedZeroInfNanPreserve at the routine's widths, or records DeviceSignedZeroInfNan where the device lacks the mode. A fast-math kernel declared no mode, so Vulkan let the device answer either zero sign: the RTX 3090 answered -0 where Metal answers +0. The default policy and MoltenVK are unchanged. - Exit on Linux (glibc): an exit while the driver still runs the runtime's work (a section, a making, or a CPU device's work) ends at once with the exit's status and one line on standard error, as Metal's exit does not wait; the exit handlers registered before the runtime's do not run in that case (docs/API.md, Process exit). An idle exit is unchanged; macOS keeps its waits. The exit lane test expects the new ending. - The exact golden hashes and the authored compile census re-blessed. Verified at 46649e335d (batch f10), all green: RTX 5080 7248/7248, RTX 3090 7248/7248, M3 7263/7263, Iris Xe, RX 7900 XTX and 780M 7248/7248 each, fuzz 8/8 on every venue; lavapipe 3823/3823, product 4824/4824, CPU validation 1331/1331; fmt, clippy (4 configurations), Rustdoc, packaging, qualification, refusals, the API reference check and doctests. |
||
|
|
20bd3793f3 |
Exact tiny products and fma, Metal's 16-bit blend zeros and new depth pattern, new notices, the ANV compiler-bound fallback, exit and barrier fixes
One squash of development-fast c66863112e..d8546c940b (27 commits); the tree equals d8546c940b. Exact float maths (FloatMathsPolicy::Exact only; the fast default is unchanged): - A tiny float product and OpFmaKHR flush to zero as Metal does; the native default announces the device's rounding first (float-tininess-after-rounding). The check is the compact form; its compile cost is recorded in docs/FAST-PATHS.md, and the check's own scaling multiply is NoContraction. Now Metal's: - A fetched 16-bit float blend's lone term takes Metal's zero under fast math (R16Float and RG16Float read alpha as 1). - A new Private Depth32Float or Depth32Float_Stencil8 target's NaN pattern is switched on at the pass that loads it; where the device's test is not Metal's it is announced (signed-depth-test), and a clamping device announces fresh-pattern-zeroed. - A render-target barrier from the fragment stage to an earlier stage orders the later passes' attachments. New notices for differences that were silent: unmeasured group speculation, an anisotropic sampler without mips (MoltenVK), a draw's attachment read in place, a sample level the device's arithmetic chooses (exact sampling off MoltenVK), and exact forms dropped to fit ANV's compiler. Crash and exit fixes: - ANV: a render pipeline whose largest stage passes 400,000 words under exact forms is retranslated with them dropped until it fits (ExactFormsOverCompilerLimit), instead of a SIGSEGV in Mesa's register allocator. - The exit hook sees a making that ends as it looks, and drains a CPU device's work at its first run only. Measurements: the commit hand-off cost on the Iris Xe; the M3 under macOS 27.0.1 places heap blocks and copies compressed textures as the M4 does. Tests fixed (heap-shadow fence, attachment-read routes, freed-memory thread, depth pattern per device class, the new kind's lane site) and the golden hashes, engine inventory and authored compile census blessed. Verified at d8546c940b (batch f7): RTX 5080, M3, Iris Xe, RX 7900 XTX and 780M green; lavapipe 3822/3822, product 4821/4821, CPU validation 1331/1331, fuzz, fmt, clippy (4 configurations), Rustdoc, packaging, qualification, refusals and the API reference check green; RTX 3090 7244/7245. Stress soaks of the runtime crate x2 clean on the 5080, XTX, 780M and Iris Xe. Known open: on the RTX 3090 an Exact checked OpFmaKHR can answer -0 where Metal answers +0 (the kernel's fast math declares no SignedZeroInfNanPreserve); the fix is in progress. Not yet run: consumer boots on this tree and the private-corpus translation census. |
||
|
|
29d3ebb22e |
Fix the consumer's first-move SIGBUS and deallocator fatal, restore the release door, announce the tessellator's triangle order
One commit of the 4 on development-fast (0175289314..c66863112e), squashed at the user's request:
the pin reims-vgpu tested clean.
Runtime:
- A texture's first move over host pages writes back only the bytes the move changed, and only
where the kernel says the process may write them (mach_vm_region on macOS, the maps query on
Linux). Before, it wrote back every kept byte: a SIGBUS on read-only pages on MoltenVK, and a
hang under QEMU, whose handler retried the store. A changed byte over pages the host cannot
write stays as the move left it, announced (unrestored-first-move-bytes; not observed on any
venue). WorkCounts::first_move_restored_bytes. HostMemory::new states the Linux contract that
imported pages stay writable.
- A no-copy buffer released while a submitted command buffer's live buffers' table lists its
pages runs its deallocator at the release when the caller gave a keep-alive, which keeps the
pages mapped until the import is freed. Only a release without one waits and announces
host-deallocator-delayed. Before, the keep-alive case was announced too, which the consumer
treats as fatal.
- Memory::free_then renamed release_then: it calls no Vulkan entry point, so the release door's
source scan holds again.
(RUNTIME_VERSION 1303.)
Translator: PrecisionNote::TessellationTriangleOrder, recorded on a pipeline drawn through the
device's tessellation stages where the tessellator is not Apple's
(DriverWorkaround::TessellatorNotMetals): a patch's triangle order, first corners and ring joins
are the device's. The emulation without tessellationShader draws Metal's order and records none.
(SEMANTICS 1740, ARTIFACT_FORMAT 420.)
Docs: API.md's catalogue, FAST-PATHS.md's known gaps, REFUSALS.md.
Verified on development-fast:
- the runtime crate and runtime_lane x3 on the RX 7900 XTX, Radeon 780M and RTX 3090 at
|
||
|
|
0175289314 |
Batch the development-fast round: tessellation without tessellationShader, primitive ids, mesh tooling, color groups, the vk12 floor, runtime timing and teardown fixes
One commit of the 247 on development-fast (720ef1ce9a..9f46fdf80d), squashed at the user's request. Translator: - Tessellation on a device without tessellationShader: Metal's tessellator emitted as SPIR-V, a one-workgroup scan placing each patch's triangles in Metal's order, and the post-tessellation function as a plain vertex stage (EmulatedTessellationDraws; SEMANTICS 1739, ARTIFACT_FORMAT 419). - [[primitive_id]] on a device without geometry or tessellation shaders, as a flat varying the vertex function writes; indexed lists, lines and points drawn de-indexed (RuntimeGap::PrimitiveIdIndices). - Fragment functions of more colors than the device draws at once, compiled in color groups (PrecisionNote::ColorAttachmentGroups). - Object functions' threadgroup memory from the render encoder; a kernel's mesh draws from an indirect command buffer; mesh payload sizing. - The Vulkan 1.2 floor profile (vk12-floor) and the gates it needs; Metal 27.0.1 answers as the M3 Max. - Overflow tests in the runtime-built modules by the product's high word (NVIDIA's compiler fails the division form), guarded crate-wide by tests::owned_divisions. Runtime: - Color-group passes replayed per group over twin depth/stencil; snapshot and copy-back cost cuts. - Command buffers finish on the queue waiter that saw them; the waiter holds no device handle, so a program's drop after its wait is the device's last. - Every object an encoder was handed held until its command buffer completes; deallocator order and announcements. - Driver defects recorded and announced: ANV counts a visibility sample once per color output (visibility-count-per-color); MoltenVK fails pending work when memory that held a device-address buffer is freed, so freed memory waits for the work in flight (host-deallocator-delayed). - RenderCommandEncoder::set_object_threadgroup_memory_length; Visibility::counting(). Validation: mesh tooling (object, mesh and ICB-mesh cases on both executors), the authoring census closed, the queue storm judged in Metal's unit, load-robust exits and indirect-census bounds, and the golden hashes, printouts, fixture inventory and authored compile census blessed. Docs: FAST-PATHS.md trimmed to a ledger of what is true now; API.md's catalogue and accepted differences, REFUSALS.md and METAL-COVERAGE.md current. Verified on development-fast before the squash: the full suites on the RTX 5080, RTX 3090, RX 7900 XTX, Radeon 780M, Iris Xe, lavapipe and the M3 (MoltenVK and the Metal oracle), lint in every configuration, rustdoc, doc tests, packaging and public case qualification; the timing and teardown lanes x5 on every venue; the authoring-capability census 16656/16656 with 0 unresolved, the vk12-floor translation census at 6139 translated with the slowest row 794 ms and peak 126 MiB. The tree is development-fast's at 9f46fdf80d. |
||
|
|
720ef1ce9a |
Bless the authored compile census, the golden hashes and the fixture expectations
The round's tables, left stale through its work and blessed once at its final tree.
Bless the authored compile census at the batch tree:
corpus/authored-compile.tsv, rewritten by `corpus-triage --audit
authored-compile --bless` at the round's product tree on homelab-ms01 (the private
corpus there, fleet-census's index copy, default --jobs=20).
The census at this tree:
- 2,231 cases x 21 profile-legs = 46,851 cells: 45,530 compiled, 1,321
refused, 117 uncovered (host-replayed command buffers).
- failed 0, regressions 0.
- Private sources: 1,203 read by the index's byte ranges, 0 by shard.
24 cell moves, all on vk12-floor and roadmap-2022, from the status word
the batch binds by descriptor on a device without buffer device
addresses (fix-status). They equal the dry run's 24 at the macOS 27 work's tip.
- 18 refused -> compiled:
- FunctionConstantArgument (needs BufferDeviceAddress + ShaderInt64
on vk12-floor, ShaderInt64 on roadmap-2022): 4 cases x 2 legs = 8.
- SeqCstFence (same needs): 8 cases on roadmap-2022, 2 on vk12-floor.
- 6 refusals changed on vk12-floor, all SeqCstFence needs
BufferDeviceAddress + ShaderInt64 -> CoherentMemory needs
VulkanMemoryModel. What the device truly lacks once the status word
needs no address.
- No compiled cell refused.
597 artifact= digests of the C3 venues' compiled cells rewritten (412
case lines), and artifacts_at moves to this build:
product=3918e6c5...fe42e executor=vulkan-engine-v180
-> product=15b6df4e2bd0cb440724ffe07ba95f1ccf6d0a5dd7fb5055598e70c877596734
executor=vulkan-engine-v181
Verified on ms01 at the round's product tree:
- the --bless run: 2m29s, peak RSS 267 MB, rc 0, written=true;
- then the census again without --bless: rc 0, differences 0,
artifacts_at_this_build=true, moved_artifacts 0 (a warm run: every
cell from the index's cache under this build's census key, 1 s).
Bless the golden hashes and the fixture expectations at the round's final tree:
Both tables were left stale through the round's batches and are blessed once,
here, on macOS (which assembles the .air.ll fixtures with xcrun metal-as):
the golden table by bless_golden_hashes, the expectations table by taking each
failing part's observed rows.
Every key changed in the golden table (each profile's fingerprint moved, the
fixtures' sources too), so the bless's own unchanged-key check covers nothing.
The table was instead checked by value against
|
||
|
|
c05c380139 |
Match the M3 Max under macOS 27.0.1: measurements, profile, Metal rows and MoltenVK venue
The macOS 27 work packet: the M3 Max moved to macOS 27.0.1, where MoltenVK gives it the M4's deviceID. Its measurements, its MoltenVK profile, its Metal rows (now the C3 reference) and its MoltenVK venue rows are taken again, and the tests follow. Read Metal's NotMipmapped anisotropic footprint through MoltenVK at level 0: On macOS 27 Metal's anisotropic filter reads a sampler without a mip filter differently once its level clamp reaches 1/64: the runtime's NotMipmapped form (nearest mip, lod [0, 0.25]) handed MoltenVK an anisotropic footprint that was not Metal's NotMipmapped one, and the anisotropic lane failed on the M3 Max under macOS 27.0.1. Through Metal's own sampler (VkProperty::MetalSampler) with anisotropy and equal min and mag filters the sampler now clamps to [0, 0]: with equal filters the level has no filter left to choose, and Metal answers that sampler as NotMipmapped bit for bit. With filters that differ no clamp reads Metal's answer at maxAnisotropy 2 to 16; that stays a known gap in docs/FAST-PATHS.md. RUNTIME_VERSION moves (renumbered once for the composed batch): a run of an unchanged artifact samples differently. Verified: metal::sampler unit tests (24, including the new metals_own_anisotropic_sampler_reads_not_mipmapped_at_level_zero) at a release build; runtime_lane::anisotropic_filter::anisotropic_samples_answer_within_ their_bounds_of_metals passes on the M3 Max, macOS 27.0.1, MoltenVK 1.4.1 (it failed at the round's first composed tree and at |
||
|
|
dd5a19aea1 |
Alias a padded texture that only reads by default, the shadow behind PaddedReadsPolicy::Shadow
The padded-reads work packet (the owner's choice): a padded texture that is only read aliases the
buffer by default, under the same documented first-move gap as tight aliases, checked per driver;
the exact shadow stays behind PaddedReadsPolicy::Shadow, which exact_answers() selects.
What: a 2D texture (or array) over a buffer whose rows or slices lie with bytes between them, and
whose usage as Metal reports it holds no RenderTarget, ShaderWrite, ShaderAtomic or block writes
(Unknown reads as 0x17, so it stays a shadow; a swizzled texture reports ShaderRead |
PixelFormatView and reads), is now an image over the buffer's bytes at Metal's row pitch, as a
texture of packed rows is: the device's own linear image (PREINITIALIZED over ordinary memory, for
host allocations over a no-copy buffer), a DRM_FORMAT_MOD_LINEAR image at that pitch, or one over
a dma-buf of the pages. Its subresources may hold the bytes between its rows and its last row's
padding (to row_pitch x rows); a driver whose image reaches past that is refused as for packed rows
(lavapipe's height rounded up to 4). A render target or a texture a shader writes stays a shadow.
The rebind remakes the image under the same rule (AliasKind::Linear keeps it).
The switch: DevicePolicy.padded_reads, PaddedReadsPolicy::{Alias (default), Shadow};
DevicePolicy::exact_answers() selects Shadow, the runtime's shadow copied in before each use. It
is the runtime's alone: no ProfileFields carries it, so no profile fingerprint moves
(tests::fast_paths::the_runtime_s_padded_reads_choice_keys_no_profile) and SEMANTICS_VERSION
stays. The owner's ruling (relayed by reims-vgpu-orchestrator, 2026-10-14 15:55): "I'll take 1 &
2", (2) being this, "exact to the same standard as tight aliases", under 30c8b4bff8's first-move
known gap extended to the padding bytes, checked by the same per-driver lane check.
Why it is the same standard: the first move is the only layout transition a runtime image takes.
- Every image memory barrier the runtime records is a first move (texture/first_move.rs
FirstMove::barrier), a new image's own (storage_form.rs, host_copy.rs; never an alias), or a
caller-wrapped image's Transition (submit.rs via texture/wrapped.rs).
- The tracker's barriers are VkMemoryBarriers (tracker.rs Barrier::record), which transition no
layout.
- Blits into a texture copy in GENERAL: blit_texture.rs's vkCmdCopyBufferToImage and
vkCmdCopyImage. VUID-vkCmdCopyBufferToImage-dstImageLayout-01396 and
VUID-vkCmdCopyImage-dstImageLayout-01395 allow GENERAL; GENERAL "supports all types of device
access".
- "Each source region specified by pRegions is copied from the source buffer to the destination
region of the destination image". The Memory Model: "A memory operation must not affect memory
at a memory location not within its set of memory locations".
- Every descriptor names GENERAL (binding.rs, heap_sets.rs).
- A texture over a buffer has one level (linear_plan's MipmapLevelCount), so generate_mipmaps
leaves it, and optimize_contents_for_gpu_access records nothing.
- A texture without RenderTarget usage has no COLOR_ATTACHMENT usage. A pass renders it through a
stand-in, copied in GENERAL, so no load or store operation reaches its image.
How:
- linear_plan's padding() becomes holding(layout, usage, policy) -> Result<Holds, String>, with
Holds::{Texels, Padding}, Holds::fits (texels_alone, or the new padded_alone) and only_reads.
- aliases() takes the Holds. So do alias_image, dma_buf_alias_image (DmaBufTexels.alone),
host_alias_unbound, host_pitched_image, and the pointer and dma-buf rebinds.
- storage_over_buffer decides it once, from texture_usage (the effective usage), so the shadow's
reason no longer reads the raw descriptor's RenderTarget bit. The reason of a read-only texture
shadowed under the switch names PaddedReadsPolicy::Shadow.
- RUNTIME_VERSION 1211 (renumbered at compose); the runtime-sources pin is recomputed at this tree.
Docs:
- FAST-PATHS.md: a fast-defaults row (padded_reads = PaddedReadsPolicy::Alias/Shadow, ANV's 0.63
ms copy in per tile use and 135 vs 41 us making).
- FAST-PATHS.md: the padded-row shadow row now covers textures that render or that a shader
writes.
- FAST-PATHS.md: the first-move gap row now covers the bytes between rows, with the GENERAL anchors
in prose and the M3 Max probe's point (Metal never writes padding, even under concurrent CPU
writes).
- API.md's shadowed-texture entry, ShadowedTexture's rustdoc, HOWTO.md, interop.rs and dma_buf.rs.
- The refusal surface is unchanged (refusal_surface.py --check).
Verified so far:
- clippy -D warnings, all targets, all features, --cfg m2v_cpu_icd: clean (um780, Rust 1.98.1).
- cargo fmt --check: clean.
The unit and lane runs follow with the lane checks' commit.
Check per driver that a padded texture that only reads keeps every byte of its pages:
What: three lane tests in runtime_lane::pitched_surfaces, under PaddedReadsPolicy::Alias (the lane's
own devices take exact_answers, so Shadow), each over no-copy buffers of anonymous pages:
- a_texture_that_only_reads_keeps_every_byte_of_its_pages: a ShaderRead texture over each of the
11 layouts. Its first use is a fragment function's read through its image, before anything else
touches the pages: it must read the pages' texels, and every byte of the pages, the bytes between
the rows among them, must be unchanged. That is the image's first move, the known gap
|
||
|
|
1e05c4a72c |
Make the M3 round's lane tests hold: first work, heap staging, handlers, teardown, L3
The M3 round's work packet: tests that raced or read the wrong thing on the M3 Max now check what they mean to. Count the relay's mark after an internal submission in the first-work test: What: runtime_lane::commit_work::a_new_texture_s_first_work_rides_in_the_next_submission expected vk_image()'s internal submission to raise WorkCounts::queue_submissions by exactly 1. A new test helper, relay_marks(device, queue), reads the no-work submissions the runtime adds after a use of a queue outside a batch: it calls CommandQueue::with_vk_queue(|_, _| ()), which submits nothing of its own, and returns the rise. That is 1 where the runtime relays the driver's failures and 0 elsewhere. The test now expects 1 + that. Why: on MoltenVK the runtime relays command-buffer failures (device/relay.rs). Every use_queue outside a batch, the internal submission among them, is followed under the queue's lock by a vkQueueSubmit of no work with a fence. So the internal submission is two calls there, the work's and the mark, and the test failed on the M3 Max with "left: 2, right: 1". The test was written in |
||
|
|
c6e8834550 |
Skip the vk12-floor lane test, visibly, where the device lacks a capability the profile states
runtime_lane::absent_reads::on_vk12_floor_a_removed_arguments_read_marks_through_the_status_binding
failed on ANV. The device cannot take the vk12-floor profile, and the test unwrapped that refusal
as an error.
The device: Intel(R) Iris(R) Xe Graphics (RPL-P), Mesa 26.2.4-arch3.1. vulkaninfo reports
`shaderStorageImageReadWithoutFormat = false`. vk12-floor's m2v_consumer_floor block states that
feature true. The restricted context's first check (profiles::check_within) therefore refuses the
profile ("profile vk12-floor states 1 capabilities the device lacks: feature
ShaderStorageImageReadWithoutFormat"). lane_restriction folded that typed refusal into a plain
Err("the device cannot take vk12-floor"), and the test unwrapped it.
What changes:
- lane_restriction now returns a LaneRestriction: NoLayer, Lacks { device, gaps } or Takes.
- The first check now lives in first_check(), shared with restricting(). restricting() still
turns a Lacks into the executor's typed refusal (restriction_refusal), as before.
- The test prints "SKIPPED <device>: cannot take vk12-floor: lacks <gaps>" and returns, as it
already did for a missing profiles layer.
- Every other error still fails the test.
- The profile is unchanged. Whether the floor should state the feature is an open question for
the owner.
Verified:
- msi-laptop, debug profile, -j 6, at SCHED_IDLE:
- `cargo clippy -p metal2vulkan-validation --all-targets --all-features -- -D warnings` under
RUSTFLAGS='-Dwarnings --cfg m2v_gpu': clean.
- The same with no cfg: clean.
- lavapipe, llvmpipe (LLVM 23.1.1, 256 bits), Mesa 26.2.4-arch3.1, on msi-laptop: release
--cfg m2v_cpu_icd, LP_NUM_THREADS=1, -E 'test(/^runtime_lane::absent_reads::/)'. 3 passed. The
vk12-floor test still runs there: it prints RESTRICTED, and rfs_absent_query, rfs_absent_read
and rfs_absent_sampler each print "the status reached Binding".
- ANV, ms01, release --cfg m2v_gpu, VK_DRIVER_FILES=intel_icd.json, both ANV locks held, same
filter: 3 passed.
- The vk12-floor test prints "SKIPPED Intel(R) Iris(R) Xe Graphics (RPL-P): cannot take
vk12-floor: lacks feature ShaderStorageImageReadWithoutFormat".
- The two sibling tests reach Address and Binding, as before.
Only validation sources change. No pinned input (runtime-sources, classifier inputs) covers them,
so no version moves.
Versions: unchanged.
|
||
|
|
3dd70970df |
Reach the execution status through a binding where the device addresses no buffer
The execution-status work packet: where the device addresses no buffer, the command buffer's status
words are reached through a binding the plan asks for (WriteSource::ExecutionStatus), bound by the
runtime and by both Vulkan executors, documented, with the refusal surface regenerated.
What: a stage that writes the command buffer's ExecutionStatus (an absent argument's read, a
seq_cst fence, an argument buffer's cubic-sampler test) reaches it by device address where the
device addresses buffers (bufferDeviceAddress and shaderInt64), as before, and elsewhere through
a set-0 storage buffer of its own: ResourceSlot { stage, Synthetic(ExecutionStatus), 0 }, a
storage word view the status words are written through. absent::state_status states the form;
the binding counts once in the stage's storage-buffer descriptors, so the per-stage limit check
in lower::select sees it. The ExecutionStatus fact's mechanism is SyntheticBinding on such a
device, PushConstant elsewhere. Profiles that address buffers produce the same modules as before.
Two needs, two answers past a limit (absent::StatusBinding):
- Required (an absent read, a fence): a stage past its storage-buffer limit with the binding is
refused as DescriptorCount, naming MaxPerStageDescriptorStorageBuffers.
- CubicMark (only the argument samplers' cubic test): absent::finish gives the binding back and
the stage states no cubic reach, as a fragment stage does. The mark is a may-need: only a cubic
sampler a command later lists in the argument buffer needs it, and that sampler then meets the
planner's typed refusal (SamplerBicubicFilter), so nothing is dropped silently. Refusing the
stage instead would refuse every stage near its limit that samples through an argument
buffer, cubic sampler or not, all of which compile today.
FunctionConstantArgument and SeqCstFence are now refused only where the stage lacks its stores
and atomics (a vertex or fragment stage without them), no longer for want of buffer addresses.
Why: on vk12-floor, vk12-bare, lunarg-desktop-baseline-2023, roadmap-2022 and swiftshader every
absent read and seq_cst fence was refused (on vk12-floor's census, 22 FunctionConstantArgument
and 9 SeqCstFence rows), though the device can write a storage buffer.
Tests: the absent-read, threadgroup, function-constant, seq_cst and atomics tests compile on
every profile and assert the status's reach per profile (testing::status_reach_on); a floor
interpreter run of device_fence_store binds the status by slot (word 0 is 42);
an_absent_reads_binding_counts_against_the_storage_buffer_limit (vk12-floor at its count less
one: DescriptorCount on MaxPerStageDescriptorStorageBuffers);
the_cubic_tests_binding_gives_way_to_the_storage_buffer_limit (lunarg, the limit lowered step by
step: the binding given back below the kernel's own count, every compile within the limit and
L3-valid); the kernel tests its argument samplers for a cubic filter on every heap profile.
Verified on msi-laptop (Linux, debug, LLVM 21) on this change with the binder, runtime and
validation commits that follow: clippy --workspace --all-targets --all-features -D warnings clean
by default, under --cfg m2v_cpu_icd and under --cfg m2v_gpu; rustdoc -D warnings clean; the
focused tests (engine_absent*, engine_seq_cst, engine_atomics, engine_dispatch, engine_handles,
engine_binder, engine_function_constant*, mechanism) 122/122; the metal2vulkan, air, runtime and
devtools suites 4592/4598, the 6 reds the table moves below.
Moves (blessed elsewhere, on macOS): public_fixture_expectations_engine.tsv, .ll rows, exactly 50
cells, 10 rows x the 5 profiles above, none on a profile that addresses buffers: 42 from
Unsupported{FunctionConstantArgument|SeqCstFence} to ok, and 8 to
NeedsInput{StorageTextureFormat} (absent_texture_reads_zero, fc_kernel_absent_resources,
fc_kernel_absent_sampler, fc_kernel_sampler_select on roadmap-2022 and vk12-bare: the next gate
there, which the refusal hid). golden_hashes.tsv: 104 cells, those 50 plus 54 hash changes, 18
argument-sampler rows (msf_runtime_samplers, tail_argument_samplers,
tail_argument_cube_gradient, unv_runtime_levels) on lunarg-desktop-baseline-2023, roadmap-2022
and swiftshader, which now test the cubic bit; no cell of a profile that addresses buffers.
Expected, not run here (metal-as needs macOS): the .air.ll rows of function_constant_interface
and rfs_absent_reads.
Plan the execution status's binding as WriteSource::ExecutionStatus:
What: a compute or render plan writes a stage's SyntheticBinding::ExecutionStatus binding as the
new WriteSource::ExecutionStatus: the command buffer's ExecutionStatus buffer, the one every
command of it writes, ExecutionStatus::BYTES bound. The bind module docs say how a command
reaches the status on each kind of device. WriteSource is #[non_exhaustive] and not encoded, so
neither the cache codec nor the api_surface table changes.
Why: the previous part binds the status on devices that address no buffer; the planner
refused such a binding as internal ("a compute binding ExecutionStatus").
Tests: a_seq_cst_fence_reaches_the_status_by_binding_or_address_as_the_device_allows runs
dispatch_builtins' device_fence_store through the binder harness on vk12-floor and
lunarg-desktop-baseline-2023 (one ExecutionStatus write, no status push hole) and moltenvk-m3
(the push hole, no write): each of the 24 threads increments StatusWord::SeqCstFences of the one
status (24), and the store after the fence lands (42).
Verified on msi-laptop (Linux, debug, LLVM 21) with the change's other commits: the test passes
among the 122 focused tests; clippy clean in the three cfgs; rustdoc -D warnings clean.
Bind the command buffer's status words where a plan asks for them:
What: the runtime's descriptor writer binds WriteSource::ExecutionStatus to the command buffer's
status words (command_buffer::State::status_words), the buffer whose address it pushes on a device
that addresses buffers, whole. The command buffer reads and reports it on completion as before.
Why: on a device that addresses no buffer a stage with an absent read, a seq_cst fence or an
argument-sampler cubic test now binds the status (the translator commit before); the runtime has
to bind the same buffer it reads.
Verified on msi-laptop (Linux, lavapipe, --cfg m2v_cpu_icd, debug) with the validation commit
that follows: runtime_lane::absent_reads, 3/3, on the device as it is (the status reached by
address), without shaderInt64 and restricted to vk12-floor by VK_LAYER_KHRONOS_profiles (both by
binding): each of rfs_absent_query, rfs_absent_read and rfs_absent_sampler reads zero at flag 1,
its command buffer completes with no error, and its status report states the absent read.
Bind the execution status in the Vulkan executors and prove the bound form on lavapipe:
What: the candidate executors (compute, its replays, render) hand plan_resources the status
buffer they already keep (Guest::status), and plan_resources binds WriteSource::ExecutionStatus
to it, ExecutionStatus::BYTES; device replay has none. runtime_lane::absent_reads checks, for
each of rfs_absent_query, rfs_absent_read and rfs_absent_sampler, the reach the executed pipeline
took (Ran's Reach: a SyntheticBinding::ExecutionStatus binding in its layout or the status
address in its push fields) at both flags, besides reading zero, the command buffer completing
and the report stating the absent read at flag 1. Three tests: the device as it is (address where
it addresses buffers, binding elsewhere), the device without shaderInt64 (binding), and the
device restricted to vk12-floor by VK_LAYER_KHRONOS_profiles (binding; it prints RESTRICTED and
skips visibly without the layer). device::lane_restriction (tests only) builds that restriction
for a committed profile stem, through the same restricting() runtime_restriction now uses.
Why: the translator now binds the status on devices that address no buffer; the executors must
bind it, and the evidence has to show the binding was the path that ran.
Verified on msi-laptop (Linux, lavapipe llvmpipe LLVM 23.1.1, --cfg m2v_cpu_icd, debug,
LP_NUM_THREADS=1): runtime_lane::absent_reads 3/3 with --no-capture: ABSENT-READ-COMPLETED
"reached Address" for the device as it is, "reached Binding" for the other two, RESTRICTED printed
for vk12-floor; clippy --workspace --all-targets --all-features -D warnings clean by default,
under --cfg m2v_cpu_icd and under --cfg m2v_gpu. The whole validation suites run after the
rebase onto the round.
Document the execution status's binding and regenerate the refusal surface:
What: docs/API.md section 5 says how a stage reaches the command buffer's ExecutionStatus (its
device address where the device addresses buffers, else a set-0 storage buffer of its own,
SyntheticBinding::ExecutionStatus, which counts against the stage's storage-buffer limits), and
what happens past a limit: an absent read or a fence is refused as DescriptorCount, and a stage
that would bind it only for the cubic test binds nothing, so the plan refuses a cubic sampler
listed beside it (SamplerBicubicFilter). Section 6's Status bullet says to bind the same status
buffer where a plan asks for WriteSource::ExecutionStatus. reach.tsv's SeqCstFence line now
reads "a seq_cst fence in a vertex or fragment stage without its stores and atomics".
docs/REFUSALS.md is regenerated at 43578ea93: FunctionConstantArgument and SeqCstFence no longer
list devices without buffer device addresses, and lose the sites that refused them; the rest of
the diff is the line moves since the table's last generation (f28f418da).
Verified on msi-laptop: scripts/refusal-surface/refusal_surface.py regenerates the table, then
--check and --missing-reach pass, at 43578ea93 with these docs.
Versions: SEMANTICS_VERSION 1696 -> 1698 and RUNTIME_VERSION 1203 -> 1204. SEMANTICS_VERSION moves:
absent reads and seq_cst fences compile where they were refused, and argument-sampler stages test
the cubic bit through the status. RUNTIME_VERSION moves: the status's binding is planned and bound.
ARTIFACT_FORMAT_VERSION stays: no encoded type or codec changed (WriteSource is not encoded;
SyntheticBinding::ExecutionStatus and Mechanism::SyntheticBinding already existed).
ENGINE_EXECUTOR_ABI stays: the executors bind WriteSource::ExecutionStatus only where a plan asks
for it, and no plan an earlier row recorded asks for it, so running those rows is unchanged.
crates/metal2vulkan-validation/runtime-sources.sha256 holds
d92b3692f9ec6dd09aa276901b3e5e2ca89520a9fe474835a57c7a22aeb4b85e, 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.
|
||
|
|
30c8b4bff8 |
Shadow a padded texture over a buffer exactly, and cut the shadow's cost
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 |
||
|
|
48db6e7f3b |
Answer Metal's NaN of a half texel under the NaN switch on MoltenVK too
Under NanMinMaxPolicy::Exact, a half read, sample or gather answers a
NaN texel by Metal's rule, by the class of the texture bound
(lower::texture::texel_nans_class): a 16-bit float texel's own bits
where the access reads one texel, 0x7e00 for every other NaN. That
answer was keyed on the profile's NanEncoding::Device. A profile whose
driver is measured to answer Metal's canonical NaN in its arithmetic
(DriverDeviation::MetalCanonicalNans, the MoltenVK captures) has
NanEncoding::MetalCanonical under either policy, so there the switch
emitted no class answer.
But a texel's NaN is the image's decode, which the access narrows
itself, not a result of the device's arithmetic. m3-oracle measured
runtime_lane::half_texel_nans on the Apple M3 Max through MoltenVK
under the switch: 435 breaches. A 32-bit float texel's NaN read with a
half result stored 0x7dff or 0xfe00 where Metal answers 0x7e00. Per its
diagnosis:
- the MSL under the switch and under the default was identical
(captured with MVK_CONFIG_DEBUG);
- native Metal 27 answers the committed 26.7 rule;
- the translator's SPIR-V was byte-identical under the old and new
moltenvk-m3 and moltenvk-m4 profiles.
How:
- ProfileFields gains texel_nans: TexelNanRoute { Metal, Device }. It
is derived from the policy alone: Metal under NanMinMaxPolicy::Exact,
on every device. nan_encoding cannot carry the policy where a device
fact decides it.
- texture::texel_nans_class and sampler::fetched::half_gather key on
it. The gather's fetch still needs a device without Metal's sampler,
so it changes nothing on the committed profiles.
- The default is unchanged everywhere: the device's decode, noted
DeviceNanEncoding.
- The keep of narrow::round_texel (ArithPlan::texel_nans) stays on
NanEncoding::Device. Where the class answer is emitted, a NaN lane
takes the image's decode or 0x7e00 directly
(texture::emit::metal_texel_nans), not the rounding's NaN.
Every profile's fingerprint moves (a new field), so every golden cell's
key moves. Outputs move only under the NaN switch on the MoltenVK
captures. The golden table is not re-blessed here.
Tests:
- engine_texel_nans::a_half_texels_nan_is_metals_under_the_nan_switch_
where_the_arithmetic_answers_metals, on moltenvk-m3 and moltenvk-m4:
- under the switch a read, on the interpreter, hands back a 16-bit
float texel's NaN as its own bits;
- under the switch every NaN of a 32-bit float texel, in any lane
(signalling NaNs of the smallest payload, payloads a narrowing
keeps), reads back as 0x7e00, where under the default some does
not;
- a read, nearest sample and gather read the class under the switch;
- every access holds more 0x7e00 constants than under the default;
- every module validates within the plan's estimate.
- device::tests::profile and engine_native_maths: on the MoltenVK
captures, the NaN choice now moves the fingerprint (it moves the
texel NaN route); the other choices still do not.
SEMANTICS_VERSION 1693 -> 1694.
Verified on homelab-ms01 at the round's first composed tree plus this change (before the
SEMANTICS_VERSION bump):
- cargo nextest -p metal2vulkan --all-features, the whole suite: 3,270
tests, 3,267 passed. The 3 failures:
- the two MoltenVK expectations above, updated since;
- golden_hashes_match_the_table: stale, since every profile key
moved. Its first 40 listed cells keep their output hash.
- After the updates, the tests matching engine_texel_nans,
device::tests::profile, engine_native_maths, engine_native_half,
engine_texture and fast_paths: 130 pass.
- With texel_nans_class keyed on NanEncoding::Device again (the fix
undone) and nothing else changed, the new test fails ("Read on
moltenvk-m3: the switch holds 0 0x7e00, the default 0"). The other 4
engine_texel_nans tests pass.
Not verified here: the device lane runtime_lane::half_texel_nans on the
M3 Max through MoltenVK, which needs the Mac. Its switch guarantee is
the 0x7e00 of a 32-bit float or small float texel's NaN and of a linear
sample. A 16-bit float texel's one-texel NaN under the switch is the
device's decode, printed but not asserted.
Versions: SEMANTICS_VERSION 1695 -> 1696. SEMANTICS_VERSION moves: the texel NaN route follows the
policy, so translated modules change under unchanged keys.
crates/metal2vulkan-validation/runtime-sources.sha256 holds
e3dcf31f158430ce425ce93bb0b5a8c9af8370167738acca8292cd7d78363888, 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.
|
||
|
|
4079f17441 |
Fix the translator review's findings: moved color writes, cubic refusals, bicubic inferences
The translator review's work packet: a moved color write that stores nothing selects no depth or
stencil tests (with the format components it needs generated), a cubic sampler word Metal's bicubic
filter is not measured under is refused when planning, and the extended-range bicubic reading lists
its inferences.
Generate each Vulkan format's color components into its texel block:
vk::FormatBlock gains color_components: the R, G, B and A components the registry's <format>
names for the format (empty for a depth or stencil format), which a color write mask's bits name.
Vulkan writes nothing to a component the mask leaves out or the format lacks, so a plain color
attachment's write stores something exactly where its mask intersects these components; the
binder needs that to decide whether a moved writer stores anything (next part). The data comes
from the pinned registry (Vulkan-Headers vulkan-sdk-1.4.341.0) through
scripts/regen-vk-types: format_blocks reads each format's component names, render_format_blocks
writes them as `components [R G B A]`, and vk_format_blocks! builds the flags in const context.
No hand table.
Verified: the generator's unit tests pass (python3 -m unittest discover -s scripts/regen-vk-types,
9 tests, the FormatBlock expectations updated for the new column); regen_vk_types.py --check
against the pinned registry (SHA-256 verified by the script) reports generated.rs current; the
crate builds and its suites run on homelab-gem10 (with the next parts).
Select no depth or stencil tests for a moved color write that stores nothing:
What: the interlocked storage form's plan counted a moved color's write as a
store under any write mask, and the binder's moved-writer fallback
(RuntimeFact::MovableStorageWrites) ignored the pipeline's write mask. A moved
writer whose mask covers none of its attachment's channels (a depth prepass, a
stencil mask with discard) therefore had depth and stencil tests chosen for a
write that stores nothing: a slower variant, or a refusal under
FragmentTests::Any, a non-D32 depth format or a stencil-only test, and the
runtime then split the pass or ended the shadow. A declared but unused
[[color(n)]] input that is written reached the same path.
Why and how: whether a write stores is decided from the pipeline's state, the
same rule StorageView::stores_nothing applies to the storage view. fetch.rs
counts a write as storing only when its view stores something (the moved
override is gone), and bind/graphics.rs moves a color only when its ordinary
attachment state's write mask meets the format's color components
(vk::FormatBlock::color_components, generated in the previous part). The
MovableStorageWrites and module docs say so, including that a moved plain
writer takes its tests from MovableStorageWrites.
New fixture engine/smw_unread (our MSL, compiled by scripts/regen-air-fixtures
with Metal 32023.921, SDK 27.0) declares a color input it never reads; its
expectations rows and air_input printout are added.
SEMANTICS_VERSION 1694: binding-plan facts and variant choices change for
mask-none moved writers. RUNTIME_VERSION 1190: a run of such a pipeline no
longer selects tests, splits the pass or ends the shadow.
Verified:
- New CPU tests in tests::engine_moved_writers, run before the fix (debug,
homelab-gem10): a_moved_writer_that_stores_nothing_selects_no_tests failed,
864 states on 12 profiles: 96 refused (Any), 384 selected tests, 480 asked
for a variant that states a store before its tests;
an_unread_color_input_that_stores_nothing_selects_no_tests failed, 72 draws:
12 stated a store before the tests, 48 asked for a variant, 12 refused (Any).
Both pass with the fix, and the existing moved-writer test still passes.
- runtime_lane::moved_writers gains a write-mask-none case. Release,
--cfg m2v_gpu, on AMD Radeon 780M (RADV PHOENIX, Mesa 26.2.4) at the tree
rebased on fleet/round: all 9 cases keep Metal's answer in the pixel
interlock with the shadow held; the masked case counted 12 runs.
- Golden hashes are left stale for the round's single bless.
No hot-path loop is added (one write-mask check per color per plan), so no
release translation timing was taken.
Refuse a cubic sampler word Metal's bicubic filter is not measured under when planning:
What: a runtime sampler whose min or mag filter is Cubic, bound at an
extended-range slot, makes the plan name the cubic-sampler variant
(VariantKey::cubic_samplers) for any word. A word with a mip filter,
anisotropy or another reduction (or an unnamed border color, or a
MirrorClampToEdge axis) is one the variant's function always refuses
(lower::sampler::bicubic's cubic_state and check), so the refusal arrived only
after a variant compile, and since the runtime keeps only compiled variants,
every draw under that word translated the variant again.
Why and how: metal::bicubic::runtime_cubic_measured states the words Metal's
bicubic filter is measured under, whatever the function samples: no mip
filter, isotropic, the weighted-average reduction, a border color Metal names,
and address modes the bicubic readings cover. bind::plan::slots::cubic_variant
now refuses any other bound cubic word with
NotImplemented(SamplerBicubicFilter), the class the variant's compile gives,
so graphics and compute plans refuse the draw before any variant.
cubic_state applies the same rule first, so the binder and the lowering
cannot drift; the state it builds is therefore always mip-filter none,
isotropic, weighted average.
SEMANTICS_VERSION 1695: a plan for such a word is now a refusal instead of a
variant request. RUNTIME_VERSION 1191: a draw under such a word is refused at
planning, with no variant compile.
Verified (debug, homelab-gem10):
- New test tests::engine_extended_range::bicubic::
an_unmeasured_cubic_sampler_is_refused_before_any_variant (mip filter
Nearest, max anisotropy 4, reduction Minimum, at BGRA10_XR,
RGB10A8_2P_XR10 and RGBA8Unorm, on every committed profile) failed before
the fix: the plan named the variant with cubic_samplers {sampler 0: 8}. It
passes with the fix; a device without sampler anisotropy refuses the
anisotropic word earlier with SamplerAnisotropy, which the test counts and
requires to leave other refusals.
- The extended-range bicubic tests and runtime_lane::extended_range_bicubic
(release, --cfg m2v_gpu, AMD Radeon 780M, RADV PHOENIX, Mesa 26.2.4) pass.
- Golden hashes are left stale for the round's single bless.
No hot-path loop is added (one predicate per bound cubic sampler per plan),
so no release translation timing was taken.
List the inferences in the extended-range formats' bicubic reading:
What: lower/sampler/extended.rs states Metal's bicubic reading on the
extended-range formats as one paragraph, without saying which parts no reading
of those formats covers. bicubic.rs keeps such an "except inferences" list for
its own formats; this adds the same list here: a runtime Cubic sampler with a
non-Cubic other filter; a runtime sampler under another address mode, a border
color or pixel coordinates; a half result outside clamp to edge; explicit
level, bias, gradient and fragment implicit-level samples; and textures of more
than one level. Each is the other formats' reading carried to these formats'
decoded taps.
Why: a reviewer of the extended-range bicubic work asked for the inferences to
be named where a reader of the module meets them. No Metal measurement was
taken for this change.
Verified: documentation only (a module comment); cargo fmt --all is clean and
the translator suite passes at the branch tip (see the branch's last commit).
Versions: SEMANTICS_VERSION 1694 -> 1695 and RUNTIME_VERSION 1200 -> 1202. SEMANTICS_VERSION and
RUNTIME_VERSION move: translated modules and their planned refusals change under unchanged keys.
crates/metal2vulkan-validation/runtime-sources.sha256 holds
a090937f1eca50599031bb56159f5d0ece5b30d133251621f54fc645dc4f167a, 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.
|
||
|
|
f25dfd8ea2 |
Record that a commit can wait for the driver's submission
What: a known-gap row in docs/FAST-PATHS.md. Where the scheduler is free,
commit() runs the submission pass, vkQueueSubmit included, on the
committing thread, so a submission the driver holds holds commit(), where
Metal's commit returns at once.
Why: tests::completion::a_completion_on_one_queue_is_seen_while_other_queues_are_waited_for
fails on the RTX 5080 Laptop GPU (NVIDIA 615.71.09) when it runs beside the
runtime_lane scheduler tests, about 20 processes opening devices at once.
It failed in 4 of 4 such runs, at
|
||
|
|
c5da2920fd |
Fix the M3 lanes' MoltenVK findings: cache hits, expected notices, CPU-write rows
The Mac triage work packet: what MoltenVK on the M3 Max reports, counted and expected as it is.
Count a pipeline found in its cache where every stage says so, as MoltenVK reports it:
The shader cache's driver_pipeline_hits counted a making as found in its cache only where the whole
pipeline's VkPipelineCreationFeedback said APPLICATION_PIPELINE_CACHE_HIT. MoltenVK 1.4.1 never sets
that bit for the whole pipeline: it sets it on a stage's feedback alone, where it found the stage's
converted Metal function in the pipeline cache (MVKPipelineCache::getShaderLibraryImpl), and leaves
the whole pipeline's feedback VALID (MVKGraphicsPipeline, MVKComputePipeline; read in MoltenVK
v1.4.1's MVKPipeline.mm and MVKShaderModule.mm). The runtime chained no stage feedback, so on
MoltenVK every making from a record counted as a miss, and the statistics' doc ("On every driver,
MoltenVK's included") was false there. The specification allows either form: the bit "specifies
that a readily usable pipeline or pipeline stage was found in the pipelineCache", and "when an
implementation sets this bit for the entire pipeline, it may leave it unset for any stage".
A making now chains each stage's feedback too (a graphics pipeline's where it has at most five
stages, VUID-...-06594; a compute pipeline's one, VUID-...-06566), and shader_cache::found_in_cache
counts a hit where the whole pipeline's feedback is valid and says the hit, or where every stage's
is valid and says it; a miss where the whole pipeline's is valid otherwise; nothing where it is not
valid. A driver that sets the bit for the whole pipeline counts as before. No MoltenVK check: only
what the feedback structures say. The ShaderCacheStatistics docs state the rule.
RUNTIME_VERSION 1190 (a making chains more feedback; the statistic changes on MoltenVK).
Verified on the M3 Max (macOS 27.0.1, MoltenVK 1.4.1), release --cfg m2v_gpu:
- shader_cache::found_in_cache's unit test (whole hit; whole valid and every stage a hit; mixed;
no stages; not valid) passes, with the runtime's other shader_cache tests (18 of 18).
- runtime_lane::pipeline_records, at the round's first composed tree plus this branch: all three tests that
failed at
|
||
|
|
81c82b1167 |
Fix the RX 7900 XTX and 780M lanes' findings, and measure the XTX's Function storage
The um780 lanes' work packet: busy GPU work a driver's watchdog lets run, a pass's replay logs going
before its holds, a linear-attachment diagnostic, and the RX 7900 XTX's Function storage
measurement.
Commit the lanes' busy GPU work as command buffers a driver's watchdog lets run:
The runtime lanes' busy work (first_use::Busy: one threadgroup spinning on a flag until the test
releases it or its cap of loads runs out, about 2 s) was one command buffer. Linux 7.0's amdgpu
ends any one job after 2 s by default (`modinfo -p amdgpu`: lockup_timeout "default: 2000", unset
on the host), resets the ring and loses the context, so on an RX 7900 XTX and a Radeon 780M (Mesa
26.0.8, kernel 7.0.0-38) every busy work that ran to its cap was killed: dmesg "ring gfx_0.0.0
timeout ... ring reset" in the test's thread, then DeviceLost.
first_use::frame_sized_textures_copy_texel_exact failed 2 of 2 alone on each GPU (its get_bytes
waits behind the work there), and frees_in_flight::frees_while_the_gpu_is_busy_fail_no_command_buffer
failed under load. No user may be asked to raise a kernel parameter, so the work fits the watchdog.
Busy::commit now commits the work as 8 command buffers on its queue, each a spin of at most
BUSY / 8 (250 ms at the kernel's measured rate, 8x under the 2 s watchdog), each with a ticket
of its own on the one flag; the last writes the end mark. A release ends every spin still to run
at its first load. It returns a BusyWork whose wait, error (the first link's), status and
scheduled cover every command buffer, so frees_in_flight checks each for an error.
dma_buf_imports' rebind-in-flight leg commits the busy work and then its copy behind it on the
queue (first submitted before the rebind, held on the GPU behind the work), where it encoded the
spin into the copy's own command buffer; Busy::encode is gone.
Verified on homelab-um780, both GPUs (release, --cfg m2v_gpu, each pinned with
MESA_VK_DEVICE_SELECT and MESA_VK_DEVICE_SELECT_FORCE_DEFAULT_DEVICE=1): every lane of the
helper's users (runtime_lane::{first_use, frees_in_flight, dma_buf_imports, compressed_decode},
29 tests) passed twice at -j 1 and once at default parallelism, with no amdgpu line in the kernel
log (3 to 4 ring timeouts per run before). The GPU stays busy as the tests claim: FRAME-COPY's
"through submissions" get_bytes returned after 2062 to 2079 ms, texel-exact; FIRST-USE "every call
returned with the busy work running"; FREE-IN-FLIGHT "still running after the changes".
Let a scheduler pass's replay logs go before its holds of their command buffers:
A scheduler pass hands what it spent to its caller to drop without the lock: the holds of the
command buffers it submitted, and the replay logs their first submissions ended, which hold
clones of the handles their encoders named. Spent's fields dropped in declaration order, holds
first, so once a command buffer had finished, the hold's drop opened its gate and its waiters
returned while its logs still held the program's buffers on the scheduler's thread. A program
that waited for a command buffer and then let go of a no-copy buffer was not letting go of its
last handle: the buffer, its pages and its deallocator went later, on the scheduler's thread.
That breaks the contract complete() keeps: what the commands used goes before the gate opens,
so a waiter returns after it. The lane
runtime_lane::rebinds::rebinds_before_the_first_submission_reach_the_pages_of_the_last caught it
under load: the deallocator had not run in the program's drop (runs 0, no delayed deallocator),
in about 1 of 150 runs with 16 at once, on an RX 7900 XTX and a Radeon 780M alike, never alone.
Spent now declares its logs before its holds, so they go first by its fields' declaration
order, and says so as its contract; it is generic, defaulting to the scheduler's types (as
HostAliases is), so tests::gate::a_pass_lets_go_of_its_logs_before_its_holds checks with a probe
that a log goes while the gate is still closed. With the fields in their old order that test
fails ("a log went after the hold opened the gate"). The lane's `ran` is #[track_caller], so a
failure names the check that failed. RUNTIME_VERSION 1188: when a program's no-copy deallocator
runs changed. The runtime-sources pin moves with it (below).
The other holds of command buffers checked for a resource-holding neighbour that outlives them:
completion's Submitted (its events go at the end of each batch's turn, its last batch's hold
only with the posted transition), Transition (a result alone), the scheduler's Committed and
Held (their events dropped, or their batches moved, before the hold goes into Spent), and its
Settled, Handlers and Steps lists (holds alone). Spent was the only one.
Verified on homelab-um780 (release, --cfg m2v_gpu): the unit test fails with the old field order
and passes with the new one.
Say which bytes differ when a linear attachment's pass misses the private one's:
runtime_lane::linear_attachments::scissored_blends_over_a_corner_render_in_place failed once on an
RX 7900 XTX under the full suite's load ("the pages differ from the private texture's pass") and
never alone (3 of 3, and 0 of 640 sixteen at once). A mismatch there is a race until shown
otherwise, and the message said nothing of where. blends_over_the_pages now names how many bytes
and rows differ and the first 32, each with its row, column and channel, the private pass's value
and the pages', and whether it lies inside the scissor, on its edge, or outside: stale or partial
rows point at a missing barrier, values a little off at the blend. Test-only: no product path.
Measure the RX 7900 XTX's Function storage: 96 KiB a thread:
What: device::function_storage's MEASURED table gains the AMD Radeon RX 7900 XTX (MESA_RADV,
0x1002, 0x744c) at 96 KiB a thread. Before, the XTX was a device not measured, so it took the 16 KiB
floor: every stage keeping private memory recorded PrecisionNote::FunctionStorageAssumed, and every
stage needing more than 16 KiB was refused (Unsupported{PrivateMemory}, or {Recursion} for a call
stack). The module doc and docs/FAST-PATHS.md's known-gaps entry name the XTX's failing size beside
the 780M's and list it among the measured devices. The 780M's row notes that the same series on
Mesa 26.0.8 answered as its 26.2.4 measurement did (its value is unchanged).
device/tests/profile.rs used 0x744c as its example of an unmeasured RADV GPU: it now checks that the
780M's description under the XTX's ID takes the XTX's 96 KiB, and under Navi 21's 0x73bf the floor.
engine_private_memory's rtx_3090() becomes captured_as(stem, id), a committed capture under another
device ID, which the 3090's test and the new XTX test share.
Measurement (homelab-um780, AMD Radeon RX 7900 XTX (RADV NAVI31), Mesa 26.0.8-1ubuntu0.3, kernel
7.0, release --cfg m2v_gpu, VK_DRIVER_FILES radeon_icd.json with MESA_VK_DEVICE_SELECT=1002:744c,
under the radeon_icd lock with the hang tripwire checked before each size):
runtime_lane::private_memory's sizes in ascending order, each alone and cut at 60 s, from a build
whose table took the XTX to hold 1 MiB (the lane cannot reach the device past the translator's
refusal otherwise; that build was never committed). 4, 8, 16, 32, 48, 64 and 96 KiB answered
correctly over 1, 64, 4096 and 262144 threads (262144 threads at 96 KiB in 59 ms); 128 KiB answered
correctly over 1 and 64 threads and wrongly over 4096 (53 of the 64 threads checked), so the series
stopped there. Repeats: 96 KiB three more times, 4, 32 and 64 KiB once, all correct; 128 KiB twice
more, wrong over 4096 both times (55 and 53 of 64). No size hung or timed out, and journalctl -k
showed no amdgpu line through either series. The same lane on the 780M (1002:15bf, same build and
Mesa) answered 4 to 96 KiB correctly over 262144 threads.
Test: tests::engine_private_memory::private_memory_on_the_rx_7900_xtx_rests_on_its_measurement takes
the committed amd-rdna3-radv capture (an RX 7800 XT, RDNA3 under RADV like the XTX) with the XTX's
device ID and checks that a 96 KiB private array (24576 words) compiles with no
FunctionStorageAssumed note and 24592 words are refused needing them against 96 KiB. On
homelab-um780 (release, --all-features), the 7 tests matching function_storage or
engine_private_memory:: pass; with the XTX row removed, this test fails ("24576 words: unsupported:
PrivateMemory; needs ... required: 98304, available: 16384") and
function_storage_is_the_measured_value_of_the_device fails (Assumed(16384) against
Measured(98304)), the other 5 pass.
Versions: no SEMANTICS_VERSION bump. DeviceProfile::fingerprint hashes every ProfileFields field,
so the XTX's function_storage moving from Assumed(16384) to Measured(98304) moves every key derived
on it. No committed profile has the XTX's device ID (amd-rdna3-radv is the 7800 XT's 0x747e), so the
golden tables and the authored compile census do not move. function_storage.rs is a runtime input
of the validation crate, so RUNTIME_VERSION and the runtime-sources pin move with it (below),
at landing.
Versions: RUNTIME_VERSION 1198 -> 1199. RUNTIME_VERSION moves: when a program's no-copy deallocator
runs, and the XTX's Function storage fact, change.
crates/metal2vulkan-validation/runtime-sources.sha256 holds
3634eb419d48a74cf21d54319d5026013dea4c3de8d747d0d976559096f07e6f, 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.
|
||
|
|
edfba8ac8b |
Decode AIR 2.5's stride-less kernel and vertex ICB buffer setters
AIR 2.5 (Metal compiler 31001.723, macOS 12's and 13's) declares an
indirect command's kernel and vertex buffer setters without the i64
attribute stride before the buffer index:
air.set_kernel_buffer_compute_command.p{1,2}i8
air.set_vertex_buffer_render_command.p{1,2}i8
void (ptr addrspace(1), i32, ptr addrspace(1|2), i32)
Decode had one form for these, (cmd, i32, ptr, i64 stride, i32 index),
so such a declaration classified as DeclClass::Mismatch and its module
was refused with InvalidInput(Intrinsic(SignatureMismatch)). The
translation census over ms01's private corpus at
|
||
|
|
ed87db8d58 |
Measure the RTX 3090's Function storage: 128 KiB a thread
What: device::function_storage's MEASURED table gains the NVIDIA GeForce RTX 3090
(NVIDIA_PROPRIETARY, 0x10de, 0x2204) at 128 KiB a thread. Before, the 3090 was a device not
measured, so it took the 16 KiB floor: every stage keeping private memory recorded
PrecisionNote::FunctionStorageAssumed (which the runtime announces), and every stage needing more
than 16 KiB was refused (Unsupported{PrivateMemory}, or {Recursion} for a call stack). The module
doc names the 3090's failing size beside the others'. docs/FAST-PATHS.md's known gaps gain the
floor itself: Vulkan states no per-thread scratch limit, drivers past their capacity answer
wrongly or hang, so the amount is measured per device by runtime_lane::private_memory, never
probed at device open; the devices measured; the floor, its note and its refusal for every other
device; and the scratch's memory cost on the 3090.
Why: reims-vgpu's tests on the 3090 die on function-storage-assumed. function_storage.rs is
unchanged since the 10-11 squash, so this is not a regression: the 3090 had not been measured.
Measurement (homelab-gem10, NVIDIA 615.71.09, release --cfg m2v_gpu, VK_DRIVER_FILES
nvidia_icd.json, under gpu-nvidia-3090.lock): runtime_lane::private_memory's sizes in ascending
order, each alone and cut at 60 s, from a build whose table took the 3090 to hold 1 MiB (the
lane cannot reach the device past the translator's refusal otherwise; that build was never
committed). 4, 8, 16, 32, 48, 64, 96 and 128 KiB answered correctly over 1, 64, 4096 and 262144
threads; 192 KiB answered correctly over 1 and 64 threads and then hung over 4096 (no completion
within 50 s; dmesg: NVRM Xid 109 CTX SWITCH TIMEOUT for the test process), so the series stopped
there. 4, 32, 64, 96 KiB and three more runs of 128 KiB repeated correct. The GPU recovered by
itself (P8, 51 MiB in use after). The GPU's memory in use peaked at 1.3 GiB at 32 KiB, 2.3 GiB at
64 KiB, 3.3 GiB at 96 KiB and 4.2 GiB at 128 KiB, of 24 GiB: not a memory limit.
Test: tests::engine_private_memory::private_memory_on_the_rtx_3090_rests_on_its_measurement takes
the RTX 5080 Laptop GPU's committed capture with the 3090's device ID (as engine_link's test of
the 3090 does; no 3090 capture is committed) and checks that a 128 KiB private array (32768
words) compiles with no FunctionStorageAssumed note and 32784 words are refused needing them
against 128 KiB. Without the table entry it fails on the 3090's floor ("32768 words: unsupported:
PrivateMemory; needs ... required: 131072, available: 16384"), run at
|
||
|
|
e5d1616030 |
Take a commit left to the scheduler in before its next check, and bound a commit's passes
The scheduler review's work packet: the inbox's and the work loop's fixes, and race tests that catch a lost wake. Take a commit left to the scheduler thread in before its next check, and bound a commit's passes: Four defects in the commit inbox (scheduler/inbox.rs) and the scheduler thread's loop, which broke the inbox's bound on a commit's wait and Metal's prompt commit: - A commit left to the scheduler thread during the round that took an earlier one in waited for the thread's next check (the program's code) or host step: the thread looked at the inbox once before each piece of work, not again after that round. The thread's way through its work is now `scheduler/left.rs`'s `work_through`, which makes rounds for as long as the inbox holds commits before each piece, generic so that it is tested without a device. - A committing thread passed again for as long as other threads' commits or wakes kept arriving during its passes, so one commit() was unbounded. Its look again now makes at most one pass (`inbox::AGAIN`); what is left to that pass with no other passer counted is answered as unattended, and `Scheduler::commit` wakes the scheduler thread for it (the wake's code moves into `Inbox::wake`, which `Scheduler::wake` and the tests' model share). - Checks always ran before host steps, and rounds between pieces add checks, so a step (and its queue) could wait behind checks found after it. Work now runs in the order rounds found it, a round's checks before its steps. - A pass cleared the nudge with a plain store, so the memory model gave no happens-before from a waker's change to the pass that took its nudge in. It is now a swap, which synchronizes with the waker's store it reads. Docs made true again: the inbox's and the scheduler's wait bounds, SubmissionCheck's and add_submission_handler's "a commit meanwhile still submits", the stall in texture/storage_form.rs (also after a commit left to another thread's pass), and WorkCounts::queue_submissions (the first work rides in the batch's call). RUNTIME_VERSION 1188; the runtime-sources pin follows in its own commit. Verified on msi-laptop (Linux, Rust 1.98.1), before the rebase onto fleet/round: clippy -p metal2vulkan-runtime --all-targets --all-features clean; rustdoc of the crate clean; nextest tests::inbox, tests::left and tests::scheduler 24 of 24. Each new deterministic test fails without its fix: with `if` for `while` the left commit runs after the first check ([TakenIn(1), Ran(Check, 1), TakenIn(2)...]); with checks always first a later round's check runs before an earlier round's steps; with the committer unbounded it makes 5 passes for 4 commits left to it, against 2. A paced stress (4 threads, 6 commits a ms in all, 80 us passes, release) made up to 4 passes in one commit() on the base (0.1-12% of commits over 2), and at most 2 with this change. Make the inbox's race tests catch a lost wake, and print the paths they took: The racing-commits test stopped its model scheduler thread right after the committers ended, and the stop's own notify would make the thread pass for a commit whose wake was lost, so the test could not see one. It now waits (up to its 30 s bound) for the thread to have passed every commit before it stops it, as the wakers' test does for every raise, through a shared `soon`. Both tests print how often the races took the paths they cover (commits left to another thread and left unattended; wakes left to a pass under way), as evidence that those paths ran. Test-only: the runtime sources the pin covers are unchanged. Verified on msi-laptop: tests::inbox and tests::left pass (see the landing note for counts). Versions: RUNTIME_VERSION 1196 -> 1197. RUNTIME_VERSION moves: when a commit's work is taken in and how many passes it makes change. crates/metal2vulkan-validation/runtime-sources.sha256 holds 581e5e5522ddfb5c61d4b949e7b7b01e210925bff898241bcd517ef6fdee40f2, 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. |
||
|
|
07abdd4bd9 |
Fix the encoder review's findings: inherited thread hints, kept barrier lists, draw shapes
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
|
||
|
|
0307fb8c9d |
Run every Linux CI step in the gate's container, and fix what the gate caught
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 |
||
|
|
d1059d2419 |
Say which runtime threads the default-class floor alone covers
What: the doc comment of exit_guard::raise_quality_of_service named the pool's, the scheduler's and a command buffer's completion threads as the threads the floor serves. Since the scheduler, the completion thread, each VkQueue's waiter and the handler pool run at user-interactive (spawn_user_interactive) and the pipeline pool and a compile's own thread at user-initiated (raise_to_user_initiated), the floor alone now covers threads such as the pipeline reaper and the shader cache's worker. The comment says so, and names each higher class with its threads. It also drops an evidence-run code from the comment (the measurement it cited stays). Why: the comment was stale after the user-interactive change; reims-vgpu-orchestrator flagged it. No behaviour change; comment only. The runtime-sources pin (which hashes every runtime source, comments included) moves with it. Versions: unchanged. crates/metal2vulkan-validation/runtime-sources.sha256 holds 2f7e93a9335e29d38177e561a877ec40a69994fbe733a2dd0bdff75c96a8ce3e, the hash of this tree's runtime inputs (runtime-pin.py, which reproduces build.rs's). |
||
|
|
fd22785008 |
Raise the utilization floor of the threads that take command buffers to their handlers on Linux
What: on Linux the scheduler thread, the completion thread, each VkQueue's waiter and every thread of the handler pool call sched_setattr(2) on themselves as they start, before any work, with SCHED_FLAG_KEEP_POLICY | SCHED_FLAG_KEEP_PARAMS | SCHED_FLAG_UTIL_CLAMP_MIN and sched_util_min 1024 (the 56-byte struct sched_attr; every other field 0). Only the utilization floor changes: not the policy, nice or priority, and no CPU affinity. A failure is ignored. Why: the same threads run at the user-interactive class on macOS, as Metal runs its handlers. 1024 is the top of the scale (Documentation/scheduler/sched-util-clamp): where the kernel uses the floor, capacity-aware placement on hybrid CPUs without SMT and the schedutil governor, the thread is placed and clocked as if fully busy. Unprivileged threads may raise their own floor. Elsewhere (hybrid CPUs with SMT, intel_pstate or amd-pstate in active mode, CPUs of one type) the kernel ignores it. No option or variable turns it off. The runtime-sources pin moves; RUNTIME_VERSION stays, since no run's results change. Verified: cargo clippy -p metal2vulkan-runtime --all-targets --all-features with -Dwarnings for x86_64-unknown-linux-gnu, plain and with --cfg m2v_gpu, and for macOS: clean. Not run: no test or measurement on a Linux host. |
||
|
|
f99d6b9895 |
Run the threads that take command buffers to their handlers at user-interactive on macOS
What: on macOS the scheduler thread, the completion thread, each VkQueue's waiter and every thread of the handler pool (its first and the ones it starts later) request the user-interactive quality of service as they start, before any work: exit_guard::spawn_user_interactive starts them as exit_guard::spawn does, then calls pthread_set_qos_class_self_np(QOS_CLASS_USER_INTERACTIVE, 0) (<pthread/qos.h>). The compile threads keep their user-initiated raise and every other thread of the runtime keeps the existing raise to at least the default class. No change elsewhere than macOS. Why: Metal runs every command buffer's scheduled and completed handlers at user-interactive, whatever the class of the committing thread (probe on an M3 Max, macOS 27.0.1: commits from dispatch queues at user-interactive, user-initiated, default, utility and background; every handler ran at user-interactive). These threads ran at the default class, where a new pthread starts (<sys/qos.h>, and seen on this Mac from creators at every class). No CPU affinity, and no option or environment variable turns it off; the comment at the call says so. Test: tests::exit_guard::the_threads_that_take_command_buffers_to_their_handlers_run_at_the_ user_interactive_class starts the scheduler, the completion thread with two waiters and the handler pool from threads at each class, background to user-interactive, and reads each thread's class from inside it (qos_class_self, through a test-only start hook; the pool's items read their own). It also checks the reaper runs as exit_guard::spawn starts a thread, below user-interactive. The runtime-sources pin moves (recomputed over this tree); RUNTIME_VERSION stays, since no run's results change. Verified on this Mac (M3 Max, macOS 27.0.1, Rust 1.98.1): cargo nextest run -p metal2vulkan-runtime --all-features, 869 of 869 passed, the new test among them, and the existing compile-thread and pipeline-pool class tests unchanged and passing; the new test fails with the old class (the scheduler read 0x15, default, against 0x21, user-interactive); cargo check --workspace --all-targets --all-features, plain and with RUSTFLAGS='--cfg m2v_gpu', clean. No MoltenVK lane or latency run (skipped at the user's request). |
||
|
|
c5e585f9be |
Hand a scheduler wake to the pass under way instead of waiting for its lock
The completion thread wakes the scheduler, when a batch waits at its gate or for a GPU signal to land, before it finishes the batches it saw complete. The wake took the scheduler's lock, which a pass holds across its vkQueueSubmit calls, so every completed handler waited for the whole pass. Where a pass is under way, the waker now leaves a nudge and returns, as a commit does; the pass looks again for it once done, and each pass takes it in first. Where none is, the waker takes the lock as before. Ordering is unchanged: a nudge only causes another pass. Gain, measured with separate submissions: ANV (Iris Xe), event waits, GPU end to completed handler p95 0.24 -> 0.10 ms; RADV (Radeon 780M), a Safari-shaped page, p95 0.71 -> 0.22 ms. Verified on the original branch: tests::inbox and tests::scheduler, and the runtime lanes on ANV, RADV and lavapipe. This commit was not re-tested on this tree. |
||
|
|
1cf79a9617 |
Make textures over surface buffers cheaper, laid at Metal's row pitch where drivers allow
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. |
||
|
|
2f3c6174f6 |
Keep a buffer's bytes under a texture a pass stores DontCare
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. |
||
|
|
bd21b102f5 |
Cut a draw's and a pass open's allocations
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. |
||
|
|
965eb0b538 |
Wake the scheduler thread at once for a check a commit's pass finds
A commit whose pass finds a submission check or a host step for the scheduler thread now wakes that thread at once, instead of after its own later passes and submission handlers. The scheduler thread runs one check or host step at a time, taking in waiting commits between them, and a commit handed to another thread waits at most for that thread's current pass and its handlers. The commit-latency lane measures a checked commit's wait for its submission under a consumer-like load (400 host imports, checked command buffers from one and three threads, event waits). Gain: the consumer's guest A/B on a Radeon 780M and an RX 7900 XTX (RADV): window drags +13-20% frames/s, and the commit's off-CPU wait from 9.3 to 0 ms a frame. The new test's hold fell from 71-75 ms (RADV, ANV) to prompt. Verified on the original branch: the scheduler lanes, 62 of 62 on RADV and ANV, and the runtime crate's tests. This squashed commit was not re-tested on its own. |
||
|
|
35fb5fd962 |
Cut a commit's CPU on the committing and the scheduler threads
Plan each batch's hazards without per-resource allocations or a sweep of the hazard state, plan a batch of one encoder against that state itself, list only what a commit reaches unnamed among the live buffers, and keep the scheduler order's emptied lines and head list between passes. The frame-cost lane measures a checked frame's commits on both threads and bounds their allocations. Gain: commit p50 about 40% lower; 19 -> 5 allocations a commit on the committing thread and 46.9 -> 16 on the other threads, which also cuts the allocator contention from cross-thread frees. Verified on the original branch and again on this tree: fmt, clippy in every configuration, Rustdoc, and the runtime lanes, 1311 of 1311 on RADV, ANV and lavapipe. |
||
|
|
4600bc606d |
Begin two command buffers per render pass instead of four
Keep a batch's barrier command buffers and submit them again rather than beginning new ones, cut a pass end's allocations and work where nothing needs them, count the command buffers the runtime begins, and count a frame's instructions per step in frames of their own, outside the timed ones. Gain: two command buffers begun per pass instead of four (ANV memsets each one twice), and a pass end's allocations from 52 to 36. Verified on the original branch: the runtime lanes on RADV, ANV and lavapipe. This squashed commit was not re-tested on its own. |
||
|
|
2ccf403815 |
Cut a draw's encoding work on the encoding thread
Route a render pipeline state once per encoder, keep its latest four settles, keep each texture's storage view formats, make the format candidate table once, and hold a window server frame's draws to their allocations (at most 72 a draw), with the frame-cost lane measuring a window server's frame on the encoding thread. The runtime-sources hash is pinned to this tree. Gain: frame CPU on the encoding thread fell 7.8% on RADV (Radeon 780M), 13% on an RTX 3090 and 2.1% on ANV (Iris Xe). Verified on the original branch: the frame-cost and draw lanes on RADV, NVIDIA and ANV. This squashed commit was not re-tested on its own. |
||
|
|
8963e1871b |
Submit a commit's work without waiting for the scheduler's lock
A commit no longer blocks on the scheduler's lock while another thread's pass holds it across its vkQueueSubmit calls: it leaves its batches in a commit inbox that the pass under way takes in, in commit order. A batch's first work rides in the batch's own vkQueueSubmit, a batch with nothing to end submits no command buffer, and the runtime counts its queue submissions and live memory blocks per commit. Gain: on an Intel Iris Xe host (ANV on i915), the consumer's guest A/B measured a Finder window drag at 22.1 -> 34.4 frames/s and Safari at 39.1 -> 42.7 frames/s. Verified on the original branch: the runtime lanes on ANV and lavapipe. This squashed commit was not re-tested on its own. |
||
|
|
4b564766ec |
Sample extended-range textures through Metal's bicubic filter
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. |
||
|
|
8f3edd5a6c |
Select a moved writer's depth and stencil tests in the pipeline's first plan
A render pass instance can move a color that a fragment function writes as a plain output into the
interlocked storage form: a color it keeps out of its subpass for other draws' interlocked form, or
an extended-range color whose half shadow it holds. The variant that writes the color so stores
before the depth and stencil tests and states TestedStorageWrites, from which its plan selects the
early-tests variant or the function's own tests. The pipeline as compiled stores no color so and
stated nothing, so its plan named a variant without those tests; that variant, compiled, planned
another one, and the runtime failed the draw with the internal error "the plan of a compiled
variant asks for another variant".
The fetch planner now states MovableStorageWrites { early_variant } for a function that writes
color 0 through its first output on a device that requires ordered fetch, where it discards, writes
other memory, or returns depth, stencil or a sample mask, by the rule the tested writes use
(stored_before_tests, now shared). The graphics plan reads it, for a draw that moves a color the
function writes, as it reads TestedStorageWrites, and a moved color's write counts as a store under
any mask, so the variant states the same tests and plans itself. SEMANTICS_VERSION 1692 and
ARTIFACT_FORMAT_VERSION 399 (a new encoded fact).
The owned fixture smw_writers has one plain writer per way the tests bear on such a store, and its
fullscreen triangle.
Verified on homelab-gem10 (debug builds; the unchanged translator built in its own target dirs):
- tests::engine_moved_writers: on the 12 committed profiles that order fetch through the pixel
interlock and require it ordered, for 6 writers x 2 moves x 6 kinds of draw tests, the plan of the pipeline as
compiled names the variant the moved writer needs, and that variant, compiled, plans itself, or
both refuse the draw. On
|
||
|
|
61a2efc7d3 |
Fix the GPU test failures seen on the 3090, 5080, XTX, 780M and M3
What and why, per failure (all release, --cfg m2v_gpu): AMD RADV, Ubuntu Mesa 26.0.8 (RX 7900 XTX, Radeon 780M): - generated_executions faulted the GPU (amdgpu gfxhub page fault, ring reset): RADV before 26.2 skips re-emitting a compute pipeline it thinks is bound, so the second execution's implicit preprocess ran our kernel. New RuntimeDriverDefect::ImplicitPreprocessAfterExecutionSet (RADV at every identity but the measured clean 780M at 26.2.4): the runtime preprocesses every execution of a range explicitly, then a barrier, then runs them preprocessed. RUNTIME_VERSION 1183. - The validation executor's generated-commands replay had the same fault; it now preprocesses apart on the same defect (runtime's generated_commands::preprocess_apart, now public). - float_denormals under fast math: the test checked a / b, smoothstep and (a / b) * c bit for bit, but without VK_KHR_shader_fma (26.0.8) the fast reciprocal is the device's OpFDiv(1, y), within 2.5 ulp. Those words are now checked at Metal's edges there, in full elsewhere. NVIDIA 615.71.09 (RTX 3090, RTX 5080 Laptop): - render_commands_and_render_states_run_as_the_executor_compiles_them: the executor used Vulkan device addresses as Metal addresses, and NVIDIA's lie below 2^32, where a record's address names no buffer. An addressed allocation's guest address is now its device address read signed (RADV's are sign-extended) plus 2^47 + 2^32, one translation for every allocation. - the_runtime_probe_measures_the_test_device_consistently: two driver answers Vulkan does not allow (3090: a buffer read after a linear-image copy over the same memory in one submission reads stale bytes; both: an explicit linear pitch the driver does not lay out is moved, not refused) are listed with their evidence in the test; the runtime records neither. - exits (5 tests): vkDestroyDevice takes ~55 ms alone and up to 2 s beside other processes' GPU work on the 3090, so the exit-timing tests run alone (.config/nextest.toml); the 1.5 s limit is unchanged. - pipeline_records (5080): the test assumed the driver finds a pipeline only in byte-identical records, but NVIDIA's bytes vary per compile and the two formats share entry keys. It now copies a compute pipeline's record over the render state's records, which no driver can hit. - compile_worker (5080, under load): a worker faster than the 1 ms sampler left no peak RSS. Each worker now reports its own peak (VmHWM on Linux, ru_maxrss on macOS) and the parent takes the larger. - tests::completion (both, under load): slow rounds were the GPU starting late behind another process's ~200 ms busy kernel, or NVIDIA's vkQueueSubmit returning up to 64 ms late; the completion was seen within 1 ms of the moment it could be. A command buffer is now judged from the later of its GPU end and its submission's return where the device calibrates timestamps (from the commit elsewhere, as before). - first_use::new_resources_wait_for_no_gpu_work (both, under load): the busy kernel's rate came from one wall-clock run, which collapsed under load (3 of 28 calibrations), so the busy work lasted milliseconds. The rate is now the fastest of every run at every size by GPU time, for all four lanes that share it (gpu_times::read_kinds predicts the notice a GPU time read emits, for the neutrals test). Apple M3 Max, MoltenVK 1.4.1: - heap_textures allows the shadowed-texture route for depth on drivers that lay heap depth textures apart. - The argument-buffer intersection-table test states Metal's own metadata. - The indirect lane classifies the deferred pipeline-making failure as compile-failed alike and keeps only the failed pipeline's error; Apple's 33-bit closed-form compiler crash is a known gap in docs/FAST-PATHS.md. Docs: CONTRIBUTING.md and docs/VALIDATION.md say the golden tables and the compile census are re-blessed on development. ENGINE_EXECUTOR_ABI is vulkan-engine-v181 (the RADV replay and the Metal addresses change what the executor submits): every recorded candidate row and the authored compile census go stale and need re-recording (scripts/rerecord-venue per venue, rerecord-commit, corpus-status --c3, corpus-triage --audit authored-compile --bless). Still open: M3 frees_in_flight, XTX bfloat clears, 780M half NaN blur and the 5080's one 2 s rebind_bytes_no_copy did not reproduce; the wall-clock busy calibrations of framebuffer_fetch/storage_forms.rs and queue_storms remain. Verified: - um780 full suites at the AMD fixes (before the executor and NVIDIA commits): XTX 3535/3535, 780M 3535/3535, no amdgpu kernel lines. - Each fix's focused tests before and after on its GPUs (in the agents' commits: e.g. generated/indirect 178/178 on XTX and 780M at 26.0.8 and 26.2.4; candidate 229/229 on 3090, 780M and Iris Xe; the worker peak 0 of 1440 under 24-way load on the 5080). - The combined tip: fmt, clippy (with and without --cfg m2v_gpu) and rustdoc on ms01; clippy of the validation crate on macOS; a focused run on the 3090 was stopped at 333 of 334 passed, none failed. No full suite ran on the combined tip. - The completion and first_use fixes: 3090 load set 1 of 4 runs failed before, 4 of 4 passed after (completion) and 12 runs with no first_use failure (84 calibrations, 10.19M-11.24M loads); 5080 6 of 6 and 12 of 12. fmt and clippy (no cfg, m2v_gpu, m2v_cpu_icd) on ms01. |
||
|
|
ecb80e019d |
Place heap textures needing up to 256 KiB alignment instead of refusing them
A heap's memory started at a multiple of 64 KiB of the runtime's block, and a
heap texture whose image needed a coarser alignment was refused
NotImplemented(HeapTextureAlignment), by heapTextureSizeAndAlign and
newTexture alike. On an RX 7900 XTX that refused nearly every depth texture a
program puts in a heap: four runtime-lane tests failed there on every run,
each with `alignment: 131072`, while the Radeon 780M in the same machine,
under the same driver, passed them.
Measured with a raw Vulkan probe on homelab-um780 (vkGetImageMemoryRequirements,
optimal tiling, attachment|sampled|transfer usage, 11 formats, sides 1 to
16384, 1/2/4/8 samples, one level or full mips), RADV under Mesa 26.0.8:
- RX 7900 XTX: 128 KiB for D16, D32F and D32FS8 images of 8 x 8 texels or
more; 256 KiB for multisample depth, stencil and color images from about
128 x 128 texels; single-sample color, storage and BC1 images at most
64 KiB. Nothing past 256 KiB.
- Radeon 780M: at most 64 KiB for every shape.
The base is now 256 KiB (HEAP_BASE_ALIGNMENT), the largest alignment measured.
The check moves into check_heap_base, which a GPU-free test can reach, and the
typed refusal stays for anything past the base. A heap over host pages
already starts at offset 0 of its own import, which meets any alignment.
Whole units of the base would have pushed the largest heaps past one
allocation: heap_size admits a heap up to maxMemoryAllocationSize in whole
16 KiB, and where that limit is no whole number of 256 KiB the largest heaps
asked more than the device allocates. RADV (4 GiB less 4 bytes) asked a 4 GiB
allocation for every heap from 4 GiB less 240 KiB, with a block's buffer of
addresses past maxBufferSize; MoltenVK (41,747,087,360 on the M3 Max,
9,534,832,640 on the M4, multiples of 128 KiB but not 256 KiB) would have
asked 128 KiB past the limit for its largest 128 KiB of sizes. So a buffer
past half a pooled block (32 MiB) now keeps its own size (buffer.rs's
`placed`). Such a buffer always takes a block of its own, where nothing
follows it; whole units exist only so the next placement in a pooled block
starts where the last ends. Buffers up to half a block still take whole
units, and half a block is a whole number of 256 KiB.
Cost: a heap of up to 32 MiB now starts at a multiple of 256 KiB of its pooled
block and takes whole 256 KiB units of it, up from 64 KiB units, so a small
heap can hold up to 240 KiB more of its block, on every device. A heap or
buffer past 32 MiB takes exactly its size, no longer rounded up. Programs see
no change where their images need 64 KiB or less. On the 7900 XTX the shapes
past 64 KiB now answer 128 or 256 KiB, are placed, and announce
heap-texture-larger-than-metal.
RUNTIME_VERSION 1179 -> 1181: heapTextureSizeAndAlign and newTexture answer
and refuse differently on such devices, heap buffers lie at other offsets in
the runtime's blocks, and every buffer and heap past half a pooled block
allocates its own size (WorkCounts::device_memory_allocated answers it).
runtime-sources.sha256 is re-pinned. docs/REFUSALS.md is regenerated, and the
reach mark's text says 256 KiB.
Tests:
- tests::heap::every_image_alignment_measured_fits_a_heap_s_base (GPU-free):
the measured alignments fit the base, and one past it is refused typed.
With the constant back at 64 KiB it fails (Err(NotImplemented(
HeapTextureAlignment { alignment: 131072 }))).
- tests::heap::the_largest_heap_asks_one_allocation_of_its_device (GPU-free):
every committed profile's largest heap asks at most one allocation and one
buffer. With `placed` rounding every size it fails on amd-780m-radv
(4,294,950,912 bytes asking 4294967296).
- runtime_lane::heaps::the_largest_heap_lies_in_one_allocation: where the
largest heap is at most 4 GiB, making it grows the runtime's memory by at
least its size and at most one allocation, with no validation message.
Without the size fix it failed on the 7900 XTX ("the largest heap,
4294950912 bytes, took 4294967296 bytes, past one allocation of
4294967292"). It reserves the memory without touching it: on Iris Xe a 4 GiB
heap took 0.04 s and a 53 MiB peak RSS; on lavapipe (debug) a 2 GiB heap
took 127 MiB.
Verified (release, --cfg m2v_gpu, one GPU pinned):
- The heap set (`test(/heap/) | test(/rebind/) | test(/no_copy/) |
test(/alias/)`, metal2vulkan-validation and metal2vulkan-runtime), before ->
after: RX 7900 XTX (RADV, Mesa 26.0.8) 176/180 -> 183/183 (the four
refusals pass); Radeon 780M (same host and Mesa), RTX 3090 and RTX 5080
Laptop (NVIDIA 615.71.09) and Iris Xe RPL-P (ANV, Mesa 26.2.4) 180/180 ->
183/183; lavapipe (--cfg m2v_cpu_icd, debug) 134/134. No kernel GPU
messages.
- Apple M3 Max (MoltenVK 1.4.1): the heap set plus `test(/buffer/)`. Every
failure fails identically at the base: heap_textures_answer_and_place_as_
metal_s_do, argument_buffer_intersection_table_is_encoded_at_reflected_field,
frees_while_the_gpu_is_busy_fail_no_command_buffer and
every_case_of_buffers_alone_runs_from_a_command_as_its_dispatch_2.
- Full GPU suites: RX 7900 XTX 3528/3531 and RTX 3090 3526/3531. Every
failure fails at the base or passes on rerun: on the XTX,
float_denormals_read_as_metal_reads_them and the two generated_executions
tests, which fail on the 780M too; on the 3090,
render_commands_and_render_states_run_as_the_executor_compiles_them and
the_runtime_probe_measures_the_test_device_consistently fail at the base,
and three timing tests pass on rerun.
- On the 7900 XTX, the heap lane's output shows answers and placements at
0x20000 and 0x40000 alignment and no HeapTextureAlignment.
- The runtime crate's GPU-free suite: 856/856. Clippy (workspace, all
targets, all features, and --cfg m2v_gpu) and rustdoc are clean,
refusal_surface.py --check passes, and the runtime-sources guard passes.
|
||
|
|
6cc8b08700 |
Bound compressed copy regions by their level's blocks
A level of a compressed texture that ends inside a block holds that whole block, and Metal bounds a copy region by the level's blocks, not its texels: a 4 x 4 region of a 4 x 2 BC3 level names its one block. The runtime bounded it by the texels and refused it as Copy(Region), "a copy Metal's validation stops", though Metal's validation takes it. A user reported Hollow Knight on an x86-64 macOS 26 guest sending such a copy (4x4x1 at level 9 of a 2048 x 1024 BC3_RGBA texture: Unity copies a compressed texture's small levels block by block), and the consumer ended the guest at the refusal. Measured on an M3 Max under macOS 26.7 with a probe (BC3, a 2048 x 1024 texture's levels 9 to 11, 4 x 2, 2 x 1 and 1 x 1, against an 8 x 8 texture), plain Metal and Metal's validation layer each run: - out of a texture to a buffer, between textures of one size, from a 4 x 2 level into a whole block of an 8 x 8 level and back, level 9 into level 10, getBytes and replaceRegion: a 4 x 4 region copies the whole 16-byte block, nothing past it, and validation takes it; - into a texture from a buffer at 4 x 4, a 4 x 2 region into or out of a whole block of a larger level, and 4 x 2 from y = 2 of the 4 x 2 level: validation stops them, and plain Metal copies the whole block all the same; - PVRTC 4-bit on the CPU at bytesPerRow 0: a 4 x 4 region of a 2 x 2 or 1 x 1 level reads and writes the level's bytes, as the level's own region does (validation stops it). The fix: - check_region bounds a compressed region by the level's blocks and copies it to the level's edge, as a region off its blocks already was. A region past the level's last block stays refused; an uncompressed format keeps its texels as the bound; an empty region at the blocks' end no longer underflows. - Between textures, a region that ends at its level's edge inside a block on one side only now has two sizes over the same blocks. No one VkImageCopy extent states that pair by the spec: 4 x 4 passes the 4 x 2 level's texels (VUID-vkCmdCopyImage-dstOffset-00151 into it, srcOffset-00145 out of it), and 4 x 2 is a part block away from the larger level's edge (VUID-01729 out of it; the copies chapter's "aligned ... except at the edges of the image" into it). Such a pair goes through the encoder's scratch buffer, image to buffer to image, where it was refused as BlockAlignment. That variant has no other use and is deleted; the scratch buffer's length counts blocks rather than texels; and the direct copy debug-asserts its regions are one size. Lavapipe (Mesa 26.2.4) under the validation layer 1.4.357 takes the direct copy all the same, with no message and the right block: the route rests on the spec, and the assertion is what shows the device test takes it. - The scratch buffer laid each copy right after the last, so a depth or stencil copy could start at a bufferOffset that is not a multiple of 4 (VUID-vkCmdCopyImageToBuffer-srcImage-07978): copy_texture of a 3 x 3 Depth16Unorm texture of 2 levels into an R16Unorm one put level 1 at offset 18. Each copy now starts at a multiple of both the texel block and 4. This predates the compressed change; a review of it found it. - A PVRTC CPU copy takes a region from the origin that reaches the level's edge as the whole level. - copy_from_texture_to_texture's doc no longer lists the removed refusal. A user's patch relaxed the bound alone; with it a whole block of a 4 x 2 level into a larger level was still refused as BlockAlignment. RUNTIME_VERSION 1178 -> 1179: copies the runtime refused now run, and scratch copies move to aligned offsets. The runtime sources' hash is re-pinned. Tests: compressed_regions_are_bounded_by_their_levels_blocks (copy_plan) and whole_blocks_of_small_levels_copy_between_textures (blit_plan), which fail on the parent (Err(Region) for the block); device tests whole_blocks_of_levels_smaller_than_a_block_copy_whole, whose copies out of a texture sit 32 bytes apart with the gaps checked, and depth_copies_through_the_scratch_buffer_start_at_multiples_of_four, which the validation layer fails with 07978 at offset 18 without the alignment. Verified (Rust 1.98.1; clippy on 1.99), on homelab-ms01 and homelab-gem10: - metal2vulkan-runtime's nextest: 854 passed, 1 skipped. - The runtime lane's blit tests on lavapipe under the validation layer with METAL2VULKAN_LANE_VALIDATION=sync: 28 passed, no layer message. With the scratch-buffer route taken out, the whole-block test fails at the direct copy's assertion. - The whole runtime lane on lavapipe (sync): 1284 of 1302 passed; the 18 that fail (synchronization hazards in draws and dispatches) fail alike on the parent. - clippy --workspace --all-targets --all-features, and the validation crate under --cfg m2v_gpu, -D warnings; rustdoc -D warnings; the runtime guard at the new pin; refusal_surface.py --check (no refusal changed). - The two device tests under --cfg m2v_gpu, debug, under the validation layer, each run pinned to one GPU: RTX 3090 and Radeon 780M (gem10; NVIDIA 615.71.09, RADV Mesa 26.2.4), RX 7900 XTX (um780; RADV Mesa 26.0.8), RTX 5080 Laptop (msi-laptop; NVIDIA 615.71.09) and Apple M3 Max (MoltenVK 1.4.1): 2 of 2 passed on each. |
||
|
|
dc7cd12b02 |
Re-pin the runtime sources' hash after the clippy 1.99 edits
The previous commit's runtime edits (passing over_bytes by value, try_update for fetch_update) change no behaviour of a run, so RUNTIME_VERSION stays and only the pinned hash moves. Value from the_runtime_sources_are_the_committed_ones on homelab-ms01 over the identical tree. |
||
|
|
86f0338f54 |
Pass Rust 1.99's clippy: closures by value, try_update for fetch_update
CI installs the current stable toolchain, which became 1.99 on 2026-10-01; its clippy failed the warnings-denied step on both hosts. Rust 1.99 extends needless_borrows_for_generic_args to closures passed by reference, and deprecates the atomics' fetch_update in favor of try_update. Master was clean under the fleet's 1.98.1. - Pass the Copy closures `invariant`, `compile`, `over_bytes` and `at` by value (lockstep.rs, reflection tests, render.rs, C3 venues). - Call try_update where fetch_update was (runtime sampler limit, validation worker allocator). try_update is stable in 1.98.1, so the MSRV holds. Verified on homelab-ms01 (x86_64 Linux): clippy with warnings denied passes under 1.99.0 and 1.98.1 for --workspace --all-targets --all-features and under --cfg m2v_gpu; under 1.99.0 also each feature alone, the runtime and the AIR crate alone, --cfg m2v_cpu_icd, and rustdoc. A check-only clippy for aarch64-apple-darwin passes for every crate except metal2vulkan-validation, whose bundled SQLite needs a macOS C toolchain; its macOS-only code is unchecked under 1.99. |
||
|
|
edb5ffd8cc |
Add a lane where host and GPU copies of a texture see each other's texels
runtime_lane::host_copied_textures makes Shared and Managed RGBA8Unorm
textures (16, 256 and 1024 texels square, four rounds each) and checks that
the GPU reads the zeros each was made with, then what replace_region wrote;
that get_bytes reads what a GPU blit wrote; and that both read back a
replace_region of all but a 1-texel border, which writes the border's 64-byte
lines of a tiled image only in part. It prints how many textures copied on the
host (WorkCounts::images_started_on_the_host), so a run shows the host path ran.
It is the regression check for the previous commit: on ANV's host-cached type
without coherence the GPU read stale lines of host-copied textures.
Also say in placed_image what happens where only incoherent memory is allowed:
the placement fails and host_placed_image makes the image without host-transfer
usage, its copies through submissions, so no texture is refused for it.
Verified on msi-laptop (Arrow Lake-S iGPU, Intel(R) Graphics (ARL), Mesa 26.2.4,
VK_DRIVER_FILES=intel_icd.json, --cfg m2v_gpu, debug):
- with the runtime at
|
||
|
|
9a82a7cc29 |
Keep host-copied textures out of host memory that is not coherent
A Shared or Managed texture that copies on the host (VK_EXT_host_image_copy)
took any HOST_VISIBLE | HOST_CACHED memory type (memory::host_cached), whether
coherent or not. The runtime flushes and invalidates no mapped range, as Metal's
textures need none, so on a cached type without HOST_COHERENT the texels were
left to the driver's cache upkeep around each copy. ANV (Mesa 26.2.4) on Arrow
Lake-S's Xe-LPG (0x7d67), which shares no last-level cache with the host, lists
such a type (1: DEVICE_LOCAL | HOST_VISIBLE | HOST_CACHED), and the consumer's
x86 macOS guest there showed fully transparent 4x4-texel holes (one 64-byte line
of a Tile4 32-bit image) in its textures.
host_cached now takes only coherent cached types, and an image with
host-transfer usage never takes a type the host maps without coherence
(memory::host_incoherent), so a fallback after a failed allocation cannot reach
it either. On Arrow Lake such an image takes the coherent write-combined type 0,
counted as uncached_host_images; ANV lists one queue family there, so no staging
queue takes its copies instead. Every other device measured lists only coherent
cached types (NVIDIA, RADV, MoltenVK, lavapipe), so nothing moves there.
Verified:
- the consumer's session (reims-vgpu-c7) on msi-laptop's Arrow Lake iGPU, from
boot screenshots of the guest: holes inside the boot logo 33.7% at
|
||
|
|
11715e2a3f |
Import no-copy memory a driver refuses from the caller's dma-bufs
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. |
||
|
|
e51abf38e1 |
Make development the working branch and keep master for the user
AGENTS.md told agents to merge into master at once and to run the checks and re-blesses there. The owner's rule (2026-10-11) is now that no agent works on or advances master unless the user explicitly asks: work happens on development, made from master when it is missing, or on branches off it. The git workflow section, the loop's last step and the definition of done now name development instead of master. The speed rule is unchanged: merge at once, no pre-merge gate, fix forward. Verified: docs only; cargo fmt --all left the tree unchanged, and the only remaining mention of master in AGENTS.md is the new rule itself. |