4b37878cdaa103cb8b0fe882474cd5961baafafe
618
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
12497a0aad |
State a gathered 32-bit float NaN in device-texel-conversion's bound
half_read_nans failed on the RTX 5080 Laptop GPU (NVIDIA 615.71.09): a gather of R32Float, RG32Float and RGBA32Float hands back 0x7fffffff for every NaN texel (64 lanes each), where Metal hands back the stored words; the same texels read and sampled come back as stored. The gather records PrecisionNote::DeviceTexelConversion off Apple's GPUs, whose bound said every class but a half-float or small-float NaN is Metal's value. What: the bound (the note's rustdoc and API.md's catalogue) states a 32-bit float texel's NaN in a gather as the device's encoding, with the 5080's answer; half_read_nans takes a gathered 32-bit float NaN for Metal's where the device's texture unit is not Metal's, as it takes a half-float texel's NaN. No note is recorded differently, so no version moves. Verified: compile and the 5080 and M3 runs follow in the lane proof run. (cherry picked from commit 8e537ae9c2c3ad814c0973841b2454fa15d66120) |
||
|
|
fc79fdd4e9 |
Announce every NVIDIA RTX 5080 Laptop clear and plain fill off a whole code: its clears take either nearest code
runtime_lane::color_fills::plain_color_fills_are_the_device_s_clear (vkCmdClearColorImage of 762
colours into each of 70 formats) on the RTX 5080 Laptop GPU at
|
||
|
|
f1def3dffe |
Count a texel's half rounding as the measured conversion on MetalHalfConversion profiles
Re-applies 384734851d (reverted in the stack by
|
||
|
|
5dbf6f3be3 |
Revert counting a texel's half rounding as measured on MetalHalfConversion profiles
This reverts the stack's pick of 384734851d ("Count a texel's half rounding as the measured
conversion on MetalHalfConversion profiles"); SEMANTICS_VERSION goes to 1965, since the recorded
notes change back.
The stack 28 gate's M3 lane run failed
runtime_lane::cross_class_reads::argument_buffer_cross_class_reads_are_the_native_words: an
argument buffer's half read of an integer texture (R8Sint, RGBA8Sint, RG16Sint, RGBA16Sint,
RGBA32Sint, RGBA16Uint, RGBA32Uint; 66 of 2170 lanes) answers the device's quiet NaN 0x7e00 where
the slot's read of the same texel keeps its bits (0xfff5 and the like). The heap read rounds its
texel through float, and that rounding's narrowing no longer recorded NativeHalfConversion on
moltenvk-m3, so the stage carried no note that leaves a half NaN's bits to the device (the notes
were SetPastLayoutSupport, DeviceNanEncoding and HalfTexelConversion). The commit's measurement
covered the extended-range forms' codes, not an integer texel's bits read as half. Until a fix
keeps those bits or notes them, the note stays as it was before the change.
The doc conflict in driver_facts.rs (a later pick's measurement paragraph for the reverted rule)
takes the text from before the change.
Verified: not yet; the gate reruns the core suite and the M3 lanes on this tree.
|
||
|
|
bc1d0ab837 |
Say in render-pass-split's trigger that a read of the clear alone takes a cleared copy instead
The declaration in degradation.rs and docs/API.md's catalogue entry both said a draw that reads a color attachment's texture after a memory barrier splits the pass. A read of the clear alone before any draw of the pass now reads its copy cleared to the clear in the pass's one instance where the copy can be (WorkCounts::attachment_read_clears), so both name that exception. Docs only; unverified beyond cargo fmt. (cherry picked from commit 1bcf89e89571bc7f65694c10ea34bdde6c3af6b0) |
||
|
|
de64560175 |
Name the pass-start read's cleared copy in the API guide's accepted difference
docs/API.md: a draw that reads the clear after a render-target barrier before any draw of its pass reads its copy cleared to the clear in the pass's first instance where the copy can be so (WorkCounts::attachment_read_clears), else an instance after one of the clear alone. Unverified: documentation of 4259b7f41c, whose runs are pending. (cherry picked from commit cc9312dcc9a97d5c663efbfea3f0f25374581249) |
||
|
|
749daae1d9 |
Say a texture's image of any storage mode may overflow past device-local memory
Every texture's image is placed in Private memory (image_plan.rs), so a Shared or Managed texture's image overflows as a Private one does; the notice's declaration, the catalogue entry, the runtime README and the lane's site note now say so. Verified: nothing (docs and comments only). (cherry picked from commit ec5b5a70fdea000eb9a7d5ab84e5aaad02fffed4) |
||
|
|
8ccb2934c9 |
Place resources past a full device-local heap in system memory
Placement refused a resource once device-local memory was full: memory.rs gives the Private class only DEVICE_LOCAL types, every texture's image is Private, and a Managed buffer's own bytes on a device without unified memory are Private, so place() returned OutOfMemory(Device). On the RTX 5080, 96 of 5090 1-MiB Managed GPU copies were refused at about 5 GB held, where Metal on a 4 GiB Radeon Pro 5300M made, used and read back 12 GiB of Managed buffers, six 1 GiB Private buffers and a 17 GB Private heap. - memory.rs: overflow_candidates, the types a Private or Memoryless resource overflows into where none of its own has room (allowed, allocatable, neither device-local nor lazily allocated; those the host does not map first). place() tries them after the class's own types; such a placement is marked (Placement::overflowed) and counted (Memory::overflows, WorkCounts::device_memory_overflows). Metal's own refusals (max_buffer_length, texture limits) stay where they are. - Driver paging first: VK_EXT_pageable_device_local_memory with VK_EXT_memory_priority, enabled where the device lists both and has pageableDeviceLocalMemory (enables.rs, create.rs); the spec lets such a driver page memory out rather than fail an allocation. Every allocation keeps the default priority. - Degradation::DeviceMemoryOverflow (performance), announced once for a program's buffer or heap (degrade_system_memory, which now names the storage mode) and texture (Texture::overflowed) that overflowed. - Tests: tests::memory::device_local_classes_overflow_into_system_memory, tests::device::pageable_device_local_memory_is_enabled_where_the_device_has_it, and the device test tests::device_memory_overflow (a GPU hazard, under m2v_gpu_hazards on a GPU, in the shape of 7b57d9a87a; check-cfg added), which fills device-local memory where it can overflow and makes, uses and reads back Private buffers, a Private heap with a buffer and a texture, Private textures and Managed buffers past it. The lane names the kind's site as the runtime's test (degrade_notices OVERFLOWED). - Docs: API.md (runtime-own extensions, catalogue entry), runtime README memory model. Verified: nothing yet (cargo fmt only); builds and runs follow as potluck jobs. (cherry picked from commit 586f2d0b5c6708016d9a255c0934f9727569125c) |
||
|
|
504d01b759 |
Present the Mac class the consumer declares, by default its GPU's, as the fresh-texture key
The fresh-texture key (DeviceProperties::lossless_compression) was
has_unified_memory. That is wrong for every integrated GPU that is not
Apple's. The consumer's oracle shows an Intel UHD 630 Mac reports unified
memory and reads zero or a released texture's texels from a new Private
texture, as the AMD 5300M does, and never Apple's pattern. The owner's
choice (option B): the consumer declares the Mac class the device presents,
and the default follows the GPU family.
What:
- MacClass { AppleSilicon, IntelOrAmd } (public, capabilities.rs), with
MacClass::of_vendor: an Apple GPU (vendorID 0x106b, MoltenVK on Apple
silicon) is AppleSilicon, every other GPU IntelOrAmd.
- DeviceOptions::mac_class and RawDevice::mac_class (Option, None by default:
the GPU's class) feed presents_lossless_compression, still the one place
the key is decided. lossless_compression is class == AppleSilicon. The
options' equality and Debug list the field.
- A new Private texture under IntelOrAmd on a GPU that is not Apple's holds
what its memory held, as before (private_textures_unfilled). On an Apple
GPU, whose own image of such a texture is compressed and reads Apple's
pattern, it is filled with zeros as it is made, which is what such a Mac
reads where its memory held nothing. Counted by the new
WorkCounts::private_textures_zero_filled. The pattern path now runs only
where the device presents compression.
- AppleSilicon keeps the runtime's pattern and zeros on any GPU. The device's
own contents are not Metal's pattern on the M3: in the negative control
(m3-max-88) leaving Private textures unfilled failed 16 of the 28 lanes.
No PrecisionNote: the fill is capability (the declared Mac's contract),
not arithmetic. An Apple-class pattern that no clear or copy writes
exactly still announces fresh-pattern-zeroed.
- Defaults change only where unified memory and GPU family disagree: Intel
and AMD integrated GPUs and lavapipe now present no compression (their new
Private textures are unfilled). The M3 (Apple) and the discrete GPUs
answer as before.
- Docs: docs/API.md (the accepted difference and the fresh-pattern-zeroed
entry), the runtime README, the degradation declaration, the work-count
docs. api_signatures blessed. REFUSALS.md regenerated with no change. No
FAST-PATHS row: no speed-for-accuracy choice.
Tests:
- tests::capabilities::lossless_compression_is_the_presented_mac_class
(no device): every vendor kind (Apple, Intel, AMD integrated and
discrete, NVIDIA, Mesa CPU) under no declaration and both declarations.
- tests::mac_class (device, both settings):
the_default_class_is_the_gpu_s and
a_declared_class_other_than_the_gpu_s_is_presented. Each reads a new
Private RGBA8Unorm target and checks the counters: AppleSilicon reads
Metal's magenta pattern; IntelOrAmd on an Apple GPU reads zero
(zero_filled +1); IntelOrAmd elsewhere is unfilled (+1).
Verified: cargo fmt --all. Build, clippy and tests run as potluck jobs
after this commit (results in the next commit or report).
(cherry picked from commit f3d6f24ca447fbcadc8df56e63e598cbc92e09b7)
|
||
|
|
9fe1b0175f |
Key the compressed shape's clear route in the extended-range and bfloat clear checks
A clear takes Metal's straight route only where nan_clear::keeps_nan_sign holds (render.rs),
which the fresh-texture key now makes false on a device that presents a Mac keeping no texture
compressed: there a 16 x 16 plain target is not compressed, so it clears through half, as
Metal's uncompressed targets do (expected, not measured on such a Mac). Three checks still
expected the straight route there and failed on the RTX 5080 Laptop at fd34a10316:
- conformance xr-clear-routes-{bgra10xr,bgra10xr-srgb,bgr10xr,bgr10xr-srgb}: divergent at
case/plain-16/texels/0..3 alone (15 sites), unlisted, in the replay of job m3-max-120; the
baseline replay at
|
||
|
|
64bea51c0c |
Put the fresh-texture key behind one presented fact, and give every lane and case its arm
The key that decides whether the Mac a device presents keeps textures losslessly compressed is now one public fact, DeviceProperties::lossless_compression, decided in one private function, capabilities.rs presents_lossless_compression. Today it is has_unified_memory, as the approved proposal said; the owner's open question (unified memory, a consumer-declared Mac class, or a family split) changes that one function. Everything that differs because Apple silicon compresses reads only that field: Device::metal_compresses_textures() (a new Private texture's fill, compressed_blit::compressed(), nan_clear::keeps_nan_sign), the validation lanes (fresh_contents::unfilled, patterns_of) and the conformance venue (Venue::lossless_compression; the Metal side answers supportsFamily(MTLGPUFamily::Apple1)). This finishes what the parked commit before it listed as open: - docs/API.md: a new accepted-differences group, "The Mac a device presents", whose entry (slug a-device-that-presents-a-mac-without-texture-compression-answers-as-that-mac) gives reims's measured AMD 5300M and Intel UHD 630 rows for fresh Private contents and marks the blit encodings, fills and NaN clear sign as expected, and states the Intel-iGPU limit. The fresh-pattern-zeroed catalogue entry and its rustdoc say the key; so does the runtime README's "New resources" bullet. - Conformance: Justification::WithoutUnifiedMemory became WithoutCompression (and Unjustified::VenueCompresses, Offered::lossless_compression, replay::without_compression / WITHOUT_COMPRESSION). The fresh family's Private rows declare it at their fresh site; the compressed-blits-* rows of the BGRA10_XR formats (the only ones whose canonical encoding the runtime writes) declare it at the seven sites a blit reaches through the compressed texture. The fresh test now asserts the new shape (renamed a_row_loosens_the_notices_site_and_a_private_texture_s_fresh_site); the compressed-blits test asserts the venue declarations site by site. - Lane arms on an unfilled device: fresh_costs (the counter moves by count x runs per Private shape; no readback), fresh_writes (patterns_of in both controls and the scratch test; the forced single-sample note only where the device fills), parallel_encodes (no expected pattern), depth_denormals (no draw/store check of unwritten texels, no sign, no zeroed note), compressed_blits (the notes and the Canonical rewrite only where the device compresses). degrade_notices needs none (FRESH_PATTERNS is only its catalogue list); the tile-store lanes (rotated_textures, snorm_tile_store, padded_loads, extended_range_blends) read draw notes, which are not keyed. - api_signatures.tsv blessed for DeviceProperties.lossless_compression and WorkCounts.private_textures_unfilled. docs/CONFORMANCE-COVERAGE.md regenerated (the Metal leg now calls supportsFamily:, and WithoutCompression is a justification it names). No RUNTIME_VERSION or runtime-sources pin change here: left to the orchestrator. Verified on the M3 Max, no device: cargo clippy -D warnings over the runtime, validation and conformance (all targets, all features) plain and with --cfg m2v_gpu; nextest metal2vulkan-conformance 1011/1011, metal2vulkan-runtime 1234/1234 (2 skipped), metal2vulkan api_signatures + api_surface 15/15; the refusal-surface and metal-coverage checks pass. UNVERIFIED: no device run yet (the lanes, the nan_signs test and the conformance replays, on the M3 and the 5080), and no negative control yet. (cherry picked from commit fd34a1031602645e87e4cb192d1044790f79a88f) |
||
|
|
61e6e1f9ac |
Announce device-pack-conversion where a heap set holds a texture by its raw texels
A heap holds a texture of a form ExtendedRange::HEAP_READ names
(BGR10_XR, BGRA10_XR, R10Unorm_X6, RG10Unorm_X12 and the bfloat
formats) by its raw texels alone, its raw view in the unsigned integer
class. A function's float read, sample or gather of it through an
argument buffer decodes the raw texels itself, by the device's
arithmetic, within the bounds PrecisionNote::DevicePackConversion
states. That is the same conversion a slot's read records statically,
but nothing announced it for a heap read: the stage cannot know which
textures an argument buffer names, and recording the note on every heap
float read would announce it for argument buffers that never hold such
a texture.
Scope it through the run-time mechanism a decoded twin already uses.
heap_sets now notes, per set, the textures whose raw view a set's
unsigned integer array holds (SetEntry.raws, detected in texture_info
by the class and bind::heap_raw_form). It announces
Degradation::DevicePackConversion, naming the texture ("BGRA10XR
texture at resource ID n"), at the first command that binds a set
holding one, and once (degrade_once) as one is placed in a set a
pending command buffer may read through. This matches TwinRead's
twin_read and twin_placed. A command whose sets hold no such texture
announces nothing. A command that binds a set holding one announces it
whether or not its function reads that texture, because the runtime
does not see which textures an argument buffer names. The twin
bookkeeping shares the new noted and pending_read helpers.
The runtime's DevicePackConversion doc, docs/API.md's
device-pack-conversion entry and heap_sets' module docs say so.
New lane test
runtime_lane::heap_extended_reads::a_heap_set_holding_a_raw_texture_announces_its_decode.
It dispatches a heap float-read kernel with only an RGBA8Unorm texture
live (no device-pack-conversion announced), then with a BGRA10XR
texture made (the notice names that texture's resource ID). It prints
the stage's own notes beside the notices.
No RUNTIME_VERSION bump (not asked for on this branch).
Verification: the branch's next CPU job (clippy, runtime suites) and
GPU job (the heap_extended_reads lane on MoltenVK on the M3).
(cherry picked from commit f5c2127ebee39d3fcf221e1930e287d26c7f9e68)
|
||
|
|
75228b052b |
Record no device-nan-encoding for a color output that only ever returns NaN-free constants
A fragment function's color output to a half-float attachment recorded PrecisionNote::DeviceNanEncoding wherever the device's conversion stores a NaN otherwise than Metal, even when every value the function returns there is a constant with no NaN lane, which stores no NaN. Texture writes already skip the note for such a constant texel (texture::holds_no_nan); color outputs now apply the same structural rule. stage_io::returns_no_nan follows each `ret` of the function to the output's member (through insertvalue chains and aggregate constants), and color_write::plan, called from the output-variable path and from the storage-form path, leaves the note out when every return holds such a constant. Any computed, undef, argument or partly unknown member keeps the note. Per-site audit of the device-nan-encoding notes on MoltenVK on the M3 (the reims strict Mac tests), with the translator CLI over each site's stages: - (a) undefined tests x3 (xr_constant_fragment and the other constant-colour fragments): their outputs are NaN-free constants, so the note was wrong there. Fixed here. - (c) encode_render x2 (sweep_fragment, sweep_half_fragment): computed outputs that sweep through NaN values. The device stores its own NaN encoding, so the note stays. - (c) rgbx x3 (rgbx_write_half, store_half, read_write_half, and the NaN clears and half NaN writes): deliberate NaN texel writes. The note stays. - (c) slice_write_repro x1 (slice_write, slice_write_l0): computed texel writes. The note stays. New public fixture ncw_constant_colors (our own MSL, compiled by scripts/regen-air-fixtures). It covers a half and a float constant colour, a constant NaN colour, a computed colour, and a two-member struct whose member 0 is a constant and member 1 computed. The new test engine_link::constant_colors_without_a_nan_record_no_nan_encoding checks, on the lavapipe and moltenvk-m3 profiles, that the note is recorded exactly for the NaN constant, the computed colour and the pair's computed member, and that each stage links and validates. docs/API.md's device-nan-encoding entry states the rule. SEMANTICS_VERSION goes to 1963 because the recorded notes change. The golden tables need the new fixture's rows, re-blessed on development. Verification: the new test and the touched suites run in the branch's next CPU job. (cherry picked from commit 2d436ebc2963f1aac1854b850ff1808e654c61f3) |
||
|
|
6eb2a66d6e |
Gather a two-plane YCbCr texture's planes in place
A function that samples a YCBCR8_420_2P or YCBCR10_420_2P texture and also gathers it (a probe asking each lane for a sample or a gather of red or blue) lost the in-place form for the whole slot: `in_place_sample` built no gather, so the gather set `in_place.blocked`, the slot bound the converted image, and on MoltenVK its linear samples went through Metal's sampler of RGBA16F-like texels: `ycbcr-filter-not-exact` (Half/FloatSampleFilter), and through a pixel sampler `pixel-sampler-scaling`. Those notes killed three of a consumer's strict Mac tests. What: the in-place form now builds a 2D gather of a component without comparison, constant offset or none, through a constexpr sampler (either filter: a gather follows none) or a runtime one. The gather is the extended-range emulation's `gathered` over `Decode::InPlace` taps: the four taps of the linear footprint, each the texel Metal reads there (the border texel past a border axis), in Vulkan's order, a runtime sampler's word mapped as a 4:2:0 texture addresses. A gathered slot stays off the device's own Y'CbCr conversion (`device: false`): VUID-RuntimeSpirv-OpTypeSampledImage-12206 admits only samples through it. No Quad routine for a gather. SEMANTICS_VERSION 1962 (facts and modules of gathered slots change). Tests (engine_ycbcr_in_place): every gather of each component of random 8- and 10-bit planes under three conversions, constexpr and runtime samplers, float and half, on the lavapipe and moltenvk-m3 profiles, equals Metal's model taps on the interpreter; a gather states the in-place fact with `device: false`; a function that samples and gathers through one runtime sampler notes FloatSampleFilter/HalfSampleFilter on its image compile and states the fact, and its in-place compile builds both forms and notes neither those nor PixelSamplerScaling. Device evidence against Metal's rows follows with the fixture and conformance cases. Docs: API.md and FAST-PATHS (in-place reads and the planes-image row), RuntimeFact::YCbCrInPlace, InPlaceReads, the runtime README. (cherry picked from commit b95b95a355f9a8ff4c1bfacbf329a728c4896db9) |
||
|
|
2e2c1ec056 |
Leave fneg, fabs, floor and ceil unnoted where the M3's Metal keeps their denormals
MoltenVK on the Apple M3 Max runs a SPIR-V `OpFNegate`, `FAbs`, `Floor` and `Ceil` through Metal's own compiler, which keeps a denormal operand of negation and absolute value and reads it as the zero of its sign in floor and ceil, as plain Metal does. The translator noted `DeviceDenormals` on every such operation, so a strict consumer died on a kernel that negates a float though the answer is Metal's. What: a new APPLE9-only `DriverDeviation::MetalUnaryDenormals` (and its `VkProperty`) on the moltenvk-m3 profile. A function whose float negation, fabs, floor or ceil the deviation covers records no `DeviceDenormals` for them and requires the property instead; fabs keeps its Metal-own exemption on every other profile, and trunc, round, rint, fract, sign and the rest stay noted (the lane does not check them). `ARTIFACT_FORMAT_VERSION` 486 (the property's tag), `SEMANTICS_VERSION` 1961 (notes and requirements change). Evidence: the committed MoltenVK M3 observations of the four denormal cases (nan_denormals, nan_denormals_fast, dfl, dfl_fast) hash equal to Metal's on the same M3. The float_denormals gate lane now checks probe rows -a, 0-a, -(a*b), fabs(a), floor and ceil where the deviation is taken, and asserts the module requires the property exactly then; the arith unit test covers each op under each fast and unary setting. Device runs follow on the GPU job for this stack. Docs: FAST-PATHS row on device denormals, API.md degrade catalogue, driver_facts' measurement paragraph, api_signatures.tsv; refusal surface and signatures checks pass. (cherry picked from commit f3f65903a395b46b3a8001c4259bb1e4bb7bc203) |
||
|
|
a139f39c89 |
Note a texel centre's denormal only under an address mode that parts texel -1 from texel 0
What: a nearest pixel-coordinate sample at its texel's centre, floor(x) + 0.5, records
DeviceDenormals for that floor: Metal's sampler reads a negative subnormal x as texel -1, where a
floor that flushes it (MoltenVK's) makes texel 0. Clamp to edge, mirror clamp to edge and mirrored
repeat read texel -1 as texel 0, so the note now holds only where the s or t mode is repeat, clamp
to zero or clamp to the border:
- a constexpr sampler decides it from its (mapped) s and t modes at compile (centre_parts);
- a runtime sampler slot's clauses add, per axis, a test of the bound sampler's word that the
axis's mode is none of the three. The word is read through a new note-only key,
SpecKey::BoundSamplerWord(slot): no constant declares it and no pipeline's key carries it, so
the mode adds no VkPipeline variant (the alternative, the ADDRESS bits in SamplerState's fields,
would split every runtime pixel sampler slot's pipelines by mode on every device). The plan
records its value beside the pushed specialized values (slots::record_noted, given by
BindingPlan::specialized_value), SpecClause::tests_bound_values counts it, and the runtime's
degrade_bound_values announces such a clause at each draw or dispatch, as it does for a pushed
format class. The runtime's notice reads "under the formats and samplers it binds".
- NoteOn::BoundSampler is the lowering's name for the key.
Why: reims-vgpu's strict Mac tests died on device-denormals from a nearest clamp-to-edge pixel
sampler, under which the device's texel is Metal's.
Tests: tests::engine_sample_coordinates::a_texel_centre_notes_denormals_only_where_its_mode_
parts_texel_minus_one (constexpr array samples per mode on every committed profile; the runtime
slot's clauses evaluated over every s/t mode pair, and never under a normalized state);
cache::tests::the_version_485_member_round_trips;
runtime_lane::pixel_samplers::a_texel_centre_s_denormals_wait_for_a_mode_that_parts_texel_minus_one
(device: nothing at making, nor under clamp to edge and mirror clamp to edge, once under clamp to
zero). Conformance: four cases pixel-samplers-subnormal-{edge,zero,border,mirror}, the RGBA8Unorm
texture through a nearest filter at sixteen coordinates of subnormals, zeros and -2^-126 on each
axis, recorded on Metal in a following commit.
Versions: ARTIFACT_FORMAT_VERSION 485 (the SpecKey variant), SEMANTICS_VERSION 1960 (the clauses).
api_signatures gains the variant. Docs: API.md and FAST-PATHS.md (device-denormals), the
DeviceDenormals, SpecKey, SpecClause and plan rustdoc.
(cherry picked from commit 624008697abfab1dbb3039a926902373b84e1268)
|
||
|
|
6e63f015b5 |
Count a texel's half rounding as the measured conversion on MetalHalfConversion profiles
What: narrow::round_texel rounds through round_measured, so in QuantizeForm::Converted the conversion pair's narrowing is recorded as measured. On a profile that takes DriverDeviation::MetalHalfConversion (MoltenVK on the Apple M3 Max's macOS 27 identity) a texel's half rounding no longer records PrecisionNote::NativeHalfConversion. That covers a texel the module decodes itself (extended_range::decode) and a merge of texels (a heap read's phi of its fetched texel and its decode routine's), as well as an image instruction's. The module requires VkProperty::MetalHalfConversion instead. The note stays for roundings by narrow::round: half operations and functions computed in float, filter sums, packs and the rest. Other profiles never read the measured set, so they are unchanged by construction. The SPIR-V is unchanged too: round_measured emits the same pair. Why: reims-vgpu's strict Mac tests die on native-half-conversion at a kernel that reads an argument buffer's texture as half (their ycbcr_probe.metal read_held). Every heap half read carries the decode routine of the seven extended-range/padded/bfloat forms, and its merge, so it recorded the note even for a BGRA8Unorm texture. The note states that the device's conversion may differ from Metal's half(float), and MetalHalfConversion measured that conversion as Metal's half(float) for loaded and computed floats. Where Metal's half texel is not the nearest even half of the texel's value, the access's own note states it: HalfTexelConversion (outright for a heap element, by the bound class at a slot) or DevicePackConversion (a decoded texel). Verified: - New core tests heap_half_texels_round_by_the_measured_conversion (heap half read, nearest sample and gather on moltenvk-m3: no note and the property with the deviation, the note without it, HalfTexelConversion kept; a linear sample's filter sum keeps the note on both) and decoded_half_texels_round_by_the_measured_conversion (a slot's half read of each extended-range form: the same, DevicePackConversion kept). Both fail with round_texel's old rounding and pass with the change; half_conversions_are_metals_where_measured still passes. - Notes of every public fixture subject on moltenvk-m3, lavapipe and nvidia-rtx5080-laptop before and after (a temporary dump over the golden-hash subjects, 2,915 per profile): 7 change, all on moltenvk-m3, each losing NativeHalfConversion alone and keeping HalfTexelConversion (a8r_buffer_read_half, hlf_half_buffer, selected_member_texture and kernel_texture_variant_leftovers, the .ll and .air.ll forms). - reims's ycbcr_probe read_held on moltenvk-m3 through the CLI: [DeviceNanEncoding, HalfTexelConversion, NativeHalfConversion] before. - Pending: the M3 lane heap_half_reads_of_every_code_round_their_float (new) and the lanes that read the note (alpha_in_red now requires a8r_buffer_read_half to be Metal's there). Docs: the PrecisionNote, DriverDeviation and VkProperty rustdoc, API.md's native-half-conversion exemption, the driver-facts record, narrow's docs. (cherry picked from commit 384734851de7b2f1a3106355a6c941080f097be4) |
||
|
|
493178c82e |
Keep a draw's heap part while what it is made of holds
A replayed page's host step costs about 400 ns per replayed draw per
resident texture (reims: 14 s a frame). Each draw works its heap part
out again for every texture its encoder made resident, though the
residency did not change and the command rebinds only a buffer:
- the handle tables, at every heap member (bind::heap::member_id,
table_bytes);
- where the heap writes go (heap_elements, member_id again);
- each heap entry's view check (bound_view, view_reading,
binding_view, Image::view);
- for every member, a neutral image descriptor in each heap image
array whose class it does not fit (neutral_view, border_texel,
BicubicTexels::with_border). heap_sets::bind then dropped every one
of those.
Now:
- The translator splits the heap part from the rest of a draw's
commands:
- BindingPlan::instantiate_draw_apart_into writes every command but
the heap tables;
- heap_tables_into writes the heap tables alone (handle tables,
sampler tables, function-table directories);
- heap_slots names the texture slots they read besides the used
resources.
instantiate_draw_into is unchanged. A consumer breaks nowhere: all
three are additions. docs/API.md says when the tables may be kept.
- The runtime keeps each draw's heap part in its encoder's LiveBind
(render/heap_part.rs): the heap tables, where the heap writes go
(Arc<HeapElements>), and the writes past the heap's entries
(binding::PastHeap). The first draw that checks every entry's view
lists those writes, and meets no notice the device announces at each
occurrence (EachWatch) while it does.
- What a part is made of:
- the plan, by address;
- the variant's heap capacity;
- the residency's generation;
- the argument samplers: the count of sampler-ID slot changes they
were listed at, else compared state by state;
- the function tables, compared;
- what the plan's heap slots bind, compared;
- the heap placement and the token order.
- Parts are kept for the last 8 plans, so pipeline states drawn in
turn and the plans a draw's primitive type picks each keep their
own. They go as the encoder ends.
- Builds with debug assertions check every kept part against one
worked out whole, and every listing of writes past the heap against
one listed again.
- bind_into writes no heap image element at all, whatever the plan
reads: the device's heap set holds each one. One predicate,
heap_sets::holds_element, now says this for bind_into and
heap_sets::bind.
- WorkCounts::draw_heap_parts_made counts the parts worked out. The
replayed-frames lanes print it, and the resident uses' walk counters.
Builds with debug assertions check a kept listing against the writes
listed again in place, allocating nothing.
Measured, release, the replayed textured page
(runtime_lane::replayed_textured, 3 frames, interleaved with the
commit before over two rounds):
- Apple M3 Max, MoltenVK 1.4.2:
- host_step_ms 10363-10491 a frame before, 1489-1621 after;
- test time 31.7-32.5 s before, 5.1-5.3 s after;
- pixels e3306dc52a1c9e86 in both;
- peak RSS 306-317 MiB in both.
- RTX 5080 Laptop (b5080 entry resident-x-heap-part-004402, kind t):
- host_step_ms 8800-8931 before, 1309-1359 after;
- pixels 8e977e2bb4582473 in both.
- After, in both: draw_heap_parts_made 2 a frame (the point draws'
plan and the other draws'). resident_uses_made stays 10,009,006 a
frame; the next commit addresses it.
The 5080 binaries came from build-only commits. Their release code
equals this tree's but for the Deferred Send and Sync below this
commit and the lane's extra counter print.
Verified:
- On the M3 (potluck), clippy, plain and --cfg m2v_gpu, all targets,
of the translator, the runtime and the validation crate; Rustdoc
-D warnings; scripts/api-docs.
- The translator's heap, binder, instantiate and api tests, 143 of
143. Among them, graphics tests check that instantiate_draw_apart_into
plus heap_tables_into equals instantiate_draw_into wherever the
latter succeeds.
- The runtime's suite, debug, --cfg m2v_gpu, hazard filter: 1626 of
1627. The one failure, exit_guard's
only_the_listed_modules_keep_the_device_s_functions, fails on the
base too: a547d0ce33's command_buffer Parts shares a name with the
device's Parts.
- The validation lanes over residency, draws and notices, debug,
--cfg m2v_gpu, hazard filter: 246 of 247. The one failure is
runtime_lane::frame_costs::a_frame_s_draws_and_pass_ends_allocate_
within_their_bounds: 21.50 allocations a draw on the M3 against
DRAW_ALLOCATIONS_DEBUG, 20. Whether that comes from this change or
from its base is not yet measured. The release bound
(DRAW_ALLOCATIONS) was not run.
- Negative control: with the kept part never kept, the new test fails
at draw 1 (heap_parts 1, expected 0).
(cherry picked from commit 12f8301c62ffbbc149c04792007895649b8fe9ed)
|
||
|
|
5b451a6508 |
Hold a commit's refused recording of a write-resident ICB's records for the host step
A commit that recorded an execution from the CPU's records and found a record it refuses failed there, though a route met after the commit may still write those records before the work runs: another queue's command buffer that the work waits for through a shared event, encoded and committed after this commit. Metal runs what that route wrote (the new probe crates/metal2vulkan-conformance/probes/icb_cross_queue_writes.m, M3 Max, macOS 27.0.1, validation off: `written` completes both command buffers with the kernel's green triangle; `unwritten` completes too, drawing the CPU's mismatched-format command as garbage). Dying there where Metal runs breaks the owner's rule 2. Now, where the commit's recording of a render pass's executions, or of a compute execution, is refused and the command buffer made one of the executed buffers resident for writing (Residency::writable_indirect_command_buffers), the segment is held for its host step (Prepared::held sets Segment::host), prepared as a step's: settled variants and made-ahead pipelines, its footprint bound. The step waits for the work before it, records from the records as they stand then, and fails the command buffer at that batch's submission only where they are still refused. A refusal of another buffer's records, and every valid recording, keep the commit-time path. Counted: WorkCounts::commit_refusals_held (api_signatures row). The lane test write_routes::a_refused_command_another_queue_writes_again_runs_what_it_wrote runs the probe's `written` shape: both command buffers complete, the centre is green, and the counter moved once. docs/API.md states the held refusal. Verified: clippy -D warnings, all features, plain and --cfg m2v_gpu, for the runtime and validation crates; api_signatures/api_surface 15/15. The lane test is not run on a device yet. (cherry picked from commit 83a1365119f1563ce45f97941a335ea119bc9efc) |
||
|
|
cee5c7eeb3 |
Name a draw's read behind a barrier as the cause in the render-pass-split notice
What: a split made so a draw reads a color attachment's texture after a memory barrier (`Split::AttachedRead`, the pass-start barrier's split among them) is now counted for the split's degrade notice (`SplitCauses::attached_reads`), whose reason says so: "draws that read a color attachment's texture after a memory barrier read what its load actions and the draws before the barrier stored, in a Vulkan render pass instance after theirs, ending N of them". The `RenderPassSplit` declaration and docs/API.md's catalogue entry list the cause. Why: such a split counted neither as a barrier split (`self.barrier` is false for a render-target barrier before any draw, and for one between draws, which records in the instance) nor as any other cause, so the notice fell to its last reason, "its draws keep different attachments out of their subpass", which describes no part of this pass. The conformance replays of the pass-start barrier family showed the split announced on every barrier row (Apple M3 Max, lavapipe). How verified: builds (conformance binary, debug). The lane assertion added to `a_draw_after_a_barrier_at_the_pass_start_reads_the_clear` (the split's reason, and a notice exactly where a pass split) is NOT yet run; the runtime-sources pin is not re-hashed (the coordinator's). (cherry picked from commit 30b797c61b27d4dbe34386c36a27837bb3ed8ead) |
||
|
|
34bafa410d |
Record the pass-start barrier family on the M3 Max (unverified on our side)
WORK IN PROGRESS, parked: recorded on Metal, not yet replayed on the runtime.
pass_start_reads.rs adds 13 conformance cases (pass-start-barrier-*), each a pass that clears a
BGRA8Unorm target and draws a read of it (owned fixture psb_reads):
- 32x32 private and over-a-buffer targets, each with: the barrier then a read at own pixels; the
barrier then a pixel-coordinate sample; the read and the sample with no barrier; a solid draw,
the barrier, then the read.
- display-masked-read: a 1728x1216 private target holding an earlier DontCare pass's leftovers
(61x55, 45x45), cleared, the barrier, a read at own pixels through a 453x100 scissor beside an
A8Unorm mask over a buffer at texture 3.
- new-texture-chain: two new 896x576 private textures, each cleared, the barrier, a read at own
pixels through 841x521 (the second beside the first at texture 3), then a target over a buffer,
loaded, the barrier, and a read of the second over it.
- new-texture-tile: a new 448x576 texture cleared, the barrier, a read over all of it.
Texels are recorded as runs of equal texels (fresh_contents::texel_runs, now pub(super)). Rows
with a barrier accept, beside the M3 Max's recorded answer, the Mac2 answer the case states, by
docs/API.md's accepted difference a-barrier-over-the-render-targets-orders-what-it-names-as-a-
mac2-gpu-s-does (the sentence naming these cases is added to it here). tests.rs bills the 13
cases' cost records to the next whole-set run (AFTER_THE_LAST_RUN).
Verified:
- conformance record on the M3 Max (macOS 27, 3 runs, one outcome each): every row's read
draws the texels from before its pass, the barrier or not; Metal's validated leg stops the
barrier ("scope (0x4) cannot contain MTLBarrierScopeRenderTargets on this device; afterStages
(0x2) can not contain ... MTLRenderStageFragment on this device").
- cases::pass_start_reads unit tests pass (plain target), including
metal_reads_the_texels_from_before_the_pass_on_the_small_rows against these recordings.
- clippy -p metal2vulkan-conformance --all-targets --all-features -D warnings.
Unverified / owed:
- conformance replay of these cases on the runtime (M3 MoltenVK, 5080, lavapipe): whether each
barrier row matches the stated Mac2 answer exactly, and which notices each venue announces
(shared-in-system-memory is declared; shadowed-texture or dont-care-stand-in may be needed).
- times::every_case_carries_its_timing fails until `conformance times --write` runs over these
13 cases on the M3.
- docs/CONFORMANCE-COVERAGE.md not regenerated.
- new-texture-chain's recording is 1.46 MB of pretty-printed JSON (three 896x576 sites of 1042
runs each); consider dropping the first texture's site.
(cherry picked from commit 724afbf80b78c14a8824dfb96203df3813fba9aa)
|
||
|
|
60d3c512a6 |
Announce copied-host-pages for a buffer that lies in a live copy
What: a no-copy buffer or rebind that lies in the live copy of the same bytes (`Device::degrade_copied_shared`) announces `copied-host-pages`, its detail saying it lies in that copy and whether the copy drops the GPU's writes. docs/API.md says so. Why: such a buffer makes no copy of its own, but the GPU uses a copy for it all the same (`Buffer::host_backing` answers `Copied`); before the join each one was a copy and was announced. A consumer that asks for the kind at each occurrence (`DeviceOptions::announce_each`) hears it per buffer as before. Verified: cargo check of the runtime (all features); the lane runs follow on the M3. (cherry picked from commit a4a75f118381a9f049157b1da063ba2fa4c9bff5) |
||
|
|
6c4b409fb0 |
Lay a no-copy buffer over a live copied host buffer's bytes in its copy
What: a copied host buffer (the caller's gate refused the import, or an admitted import failed) now joins its memory and is placed as an import is (`HostAliases::join` with `Kind::Copy`, `HostAliases::place`). A later no-copy buffer over exactly the same first byte and length, of either storage mode, finds it (`HostAliases::import`: an import of its class, else the live copy), lies in it through `Device::buffer_in_import`, is named to it (`copied_as`) and joins its key, with the gate not asked. A rebind onto such bytes lies in the copy too where its textures were planned at the copy's offset (its first byte) and no image in place rides on it; an import keeps the old `!moved` rule. A heap's own copy is placed but joins nothing; a buffer whose writes are dropped keeps its read-only view. New counter `WorkCounts::copied_host_buffers_shared`. Why: two copies of one memory agreed only through the pages (merge back at the writer's completion, copy in at the reader's commit). reims-vgpu measured on the M3 (MoltenVK) two textures over one 64x64 BGRA8 surface, each over its own refused no-copy buffer: a blit write then a blit read in one command buffer, and a reader committed first on a second queue waiting on the writer's event, both read all 16384 bytes stale, where Metal and the runtime in place read the write. The consumer also made a full copy of the surface per texture per present. The remaining GPU-to-GPU gap, between a copy and another copy or import of overlapping but different bytes, is recorded in copied.rs, docs/API.md, docs/HOWTO.md and docs/FAST-PATHS.md's known gaps. Verified: cargo check of the runtime with tests; the lane in the next commit, run on the M3 (see its message). (cherry picked from commit 69feb791dc6ec3bc2405dbf5b6ae5d0b27d936aa) |
||
|
|
3797c098eb |
Order a pass's clear before a draw that reads it after a barrier at the pass's start
A pass that clears a color and begins with a memory barrier over the render targets (after the fragment stage, before it) and then samples that color's texture in a draw read the texels from before the pass. Mac2 GPUs read the clear there (an Intel UHD 630 after the barrier, an AMD Radeon Pro 5300M with or without it). The draw reads the texture's copy, taken ahead of the pass's load actions (render/shadows.rs), and a barrier split the pass only where a draw of the current instance came before it, so a barrier at the pass's start split nothing. Such a barrier now orders the pass's load actions (`loads_ordered`): the scope form with the render targets, or the resource form over an attachment's texture, after the fragment stage and before a stage at or before it, recorded before any draw of the pass. A draw after it that samples the texture of a color the pass clears (`Texture::cleared_in`) takes the existing after-barrier path: it records into an instance after the pass's first, which runs the clear and draws nothing (`next_instance` keeps the first instead of replacing it), so the copy before it holds the clear; or, where the device has them, it reads through snapshots inside the first instance. The split is counted as the after-barrier read's (`attachment_read_splits`, `instance_splits_attached_read`) and reloads stand-ins over a buffer's bytes as one after a barrier does. A pass with such a barrier but no such draw records as without it. docs/API.md section 10 gets the accepted difference this ordering is: Apple GPUs do not support the render-target scope, and the M3 Max reads the texels from before the pass after it. The owned fixture psb_reads (regen-air-fixtures) holds the functions the lane and the coming conformance cases draw with: a read and a pixel-coordinate sample of texture 0 at the fragment's own pixel, channels reordered so a read is told from a skipped draw, and two-texture reads. Verified on the M3 Max (MoltenVK, debug, --cfg m2v_gpu), runtime_lane::attachment_reads: - a_draw_after_a_barrier_at_the_pass_start_reads_the_clear: both targets (own image, over a buffer), psb_read and psb_sample, the scope alone, with the textures and the resource form: the clear inside the scissor, one split each (attachment_read_splits 1, instance splits 1, 2 instances begun), own-pixel copies of 308 texels (the 20x12 scissor and a pixel round). - a_draw_after_a_clear_with_no_barrier_reads_the_texels_from_before_the_pass: no split. - a_barrier_at_the_pass_start_costs_nothing_without_a_read_of_a_cleared_color: a loaded target read after the barrier, and a cleared one with a draw reading another texture: no split, as many instances begun and copies taken as with no barrier. Negative control: the same tests on the tree without the runtime change fail at pixel (4, 4), reading [0, 64, 0, 255] (the texel from before the pass, reordered) where the clear's [120, 200, 40, 255] is due. (cherry picked from commit 923095effcd188a93ee5134ecc4dad3fab21b3fe) |
||
|
|
b2df1add01 |
Bind a storage view of a whole buffer from its space's start, so draws that move only an offset keep their set 0
What: `bind::instantiate::planned_range` gives a descriptor-form slot read through a storage view of its `Whole` window the range from the start of the bound buffer's space to its padded end, whatever the bind offset, and the bind offset as its `SlotBindOffset` residual. `bind_buffers` (every draw's and dispatch's instantiation) and `rebind_slots` (`rebind_draw_slots_into`) take it. Every other slot keeps `descriptor_range`'s range: uniform views (whose `RangeAtBindOffset` specialization reads a range from the bind offset), bounded windows, and a storage view whose range from 0 would pass the view's `maxStorageBufferRange` (`PlannedBuffer::max_range`) or 2^32 bytes (a 32-bit residual and offset), or whose bind offset lies at or past the padded end. The tessellation factor and index bindings keep it too. Why: `EncoderCore::set_zero_of` was 14.3% (draws.10k) and 8.8% (WS-like) of the encoding thread's samples: every draw allocated, wrote and bound a set 0 of its own. A `device T *` slot's range started at the bind offset aligned down, so each new offset wrote another descriptor and neither `LastSetZero` nor `SetCache` could match. Vulkan: the descriptor's offset is the space's start (256-aligned, as a bind at offset 0 has it today) and its range ends where today's ends (the padded end), so offset + range, and a dynamic binding's effective offset + range (VUID-vkCmdBindDescriptorSets-pDescriptorSets-01979), are what they were. dynamic_writes moves that same start into the dynamic offset for every bind offset. The range is explicit, never VK_WHOLE_SIZE (06715 does not apply). Hazard ranges are untouched: they come from the plan's use ranges from the bind offset (`binding::bytes_use`). Behaviour: a Metal offset m from the bind offset reads byte residual + m of the range, the same byte as before for every access inside the window. An access that reaches back before the bind offset (a negative index, the 32-bit offset wrapping) and lands in the buffer's space now reads and writes the buffer's bytes there, as Metal's does; before, it lay outside the descriptor range unless it stayed within the alignment's residue. On a device with robustBufferAccess (or under in-shader containment against the view's size) accesses are bounded by the larger range [space start, padded end) instead of [bind offset aligned down, padded end): such an access before the bind offset is in range and reaches the buffer's bytes where it was a robust out-of-bounds access (a zero, a value from within the buffer, or a dropped write). Accesses past the end are bounded as before. SEMANTICS_VERSION 1957 -> 1958: instantiated descriptor ranges and residuals change. golden_hashes_match_the_table passed unchanged here (it hashes compiled modules, which this does not change); the re-bless on development decides. Tests: planned_range's unit tests (the range from 0 and the residual at every 4-byte offset for base alignments 16, 64 and 256, and a 2^32-byte buffer at its last word; each fallback equal to descriptor_range's answer). A device test, set_zero_at_offsets: 9 draws of colored_vertex moving only two device buffers' offsets reuse 8 sets and bind 1, and draw what 9 draws of buffers of their own draw (0 reused, 9 bound). dynamic_multi_variable's moved-offset dispatches now reuse their predecessor's set (7 of 8) and still answer Metal's values from each dispatch's own offset. docs/API.md states the range. Verified: the translator suite, 3324 of 3324 (plain). On the M3 Max (MoltenVK 1.4.2), debug, --cfg m2v_gpu, under maclock and memcap: 96 of 96 runtime tests (fix 1's set plus set_zero_at_offsets, dynamic_multi_variable, uniform_bind_offsets, binding_view, range, rebind_descriptor_slip, rebind_behind_a_wait, depth_ranges, attributes), and 220 of 220 validation lanes under the validation layer (fix 1's set plus stage_in_regions, stage_in_strides, padded_loads, escaped_slots, absent_reads, chosen_pointers, dispatch_*, read_through_views, guarded_effects, index_fetches, first_vertex, vertex_strides, host_bytes, pointer_uploads, commands_recorded, runtime_lane::tests, among them renders::public_render_cases_match_metal and tests::stage_in_region_cases_match_metal). Negative control: planned_range forced to fall back fails set_zero_at_offsets ((0, 9) against (8, 1)) and both dynamic_multi_variable moved-offset tests ((0, 0) against (7, 0)). clippy plain and with --cfg m2v_gpu clean. Per draw on the encoding thread, release with thin LTO, 3 interleaved rounds against the parent build, medians: draws.10k 11201.7 -> 9212.4 instructions (-17.8%), 616-661 -> 485-495 ns WS-like 23121.1 -> 21752.5 instructions (-5.9%) One round's counts: draws.10k 0 -> 29880 sets reused, 30000 -> 120 vkCmdBindDescriptorSets, 6 -> 60000 vkCmdPushConstants (the residuals; both stages' writes are pushed where either changes); WS-like 0 -> 3744 sets found in the command buffer's cache, binds unchanged at 4000. (cherry picked from commit b875660ecbad7dd6f9dfa9f976ef1c2b32bded1e) (cherry picked from commit b09293e9c22d80e4ae4c505b00ba0e07e6a8165c) |
||
|
|
cc6b083fc2 |
Let what every write route of a command buffer may write reach every buffer it made resident for writing
What: what an indirect command buffer's records may hold (WrittenCommands, command_writes) took a writer's writes only from the encoder that made the buffer resident for writing (Writers: the state set then, each set after, and that encoder's executions). The routes that mark the buffer (write_routes.rs) were already the command buffer's. Routes now keeps what all of its routes may write (states set in any encoder, before the residency or after it, and what executed buffers' records may name) and adds it to every buffer made resident for writing, at the call that brings either; an encoder opens with what the ended ones met. For two encoders open together (a parallel render encoder's) the commit adds what each did not see of the other, and the followers that sets off are marked outside the command buffer's lock, as the commit's marks are. Writers is gone: Routes holds a superset of what it held. Why: Metal runs what a kernel wrote with the buffer resident for writing in any encoder of the command buffer, before the kernel's or after it (the probe icb_routed_writes.m, M3 Max, macOS 27.0.1). The marks matched that; the summary did not, and an execution of a buffer that inherits the encoder's state decides on the summary whether the GPU alone runs it, as draws of the one primitive type it allows. With the residency in another encoder than the kernel's, the GPU alone ran the kernel's point as a draw of the CPU's triangles, which drew nothing (the previous commit's lane). The bug is older than the write routes: the summary was per encoder before them too. What it moves: an execution of a buffer whose command buffer sets, in another encoder than the one that made the buffer resident, a state that may write what the GPU-alone forms rule out: a render execution takes the host step where that state may write more than draws of one primitive type, buffers, resets and cleared barriers; a compute execution in a concurrent encoder orders its commands where it may set a barrier, and a checked one calls its check where the records may name a state that may encode. The lanes that made a buffer writable with a state set in an encoder of its own (indirect_host_steps::encoding_state_set: icb_replay_encode's, which may set pipelines, dispatch, set threadgroup lengths and barriers) showed it: with it, 6 of the 480 tests of the 40 modules changed (render_merged_executions' GPU forms into a shadowed target took the host step, 6 executions; five dispatch_executions tests saw barriers, check calls and a host step), all others as before, resident_draws among them (its writer and residency share an encoder: no host step on its write path, its chunks kept). Those lanes are about the GPU-written path, not about what the state writes, so the lever now sets icb_reset_encode's state (resets alone, which no GPU-alone form rules out). Docs: written_commands.rs and write_routes.rs module docs, IndirectCommandBuffer::command_writes, render/executions/gpu.rs, the runtime README and docs/API.md section 10. How verified (debug, --cfg m2v_gpu, M3 Max under MoltenVK): runtime_lane::write_routes passes (it failed before this commit: After and Before drew no point); the 39 ICB lane modules and write_routes, 480 tests, pass with the reset lever; the runtime's tests::write_routes_device::a_route_reaches_every_buffer_its_command_buffer_made_writable (new: a later encoder's state, one set before the residency, and a parallel encoder's at the commit) and tests::written_commands pass; clippy -D warnings with --cfg m2v_gpu is clean. (cherry picked from commit 7d13a4dee21162a972b40fd9868e3e2f9112a677) (cherry picked from commit 13b9646e48b767defdd189bf156a2a9130b3b857) |
||
|
|
e924d293c5 |
Compare against Metal what an execution runs of commands a kernel wrote, by where the command buffer made the buffer resident for writing
What: a new owned fixture, icb_routed_writes, whose kernels write command 0 of an indirect command buffer: a render command with its state taken from the argument buffer (irw_encode_draw), a render command of a buffer that inherits the encoder's state, a point at the target's centre beside the CPU's triangle in command 1 (irw_encode_point), and a compute command with its state from the argument buffer (irw_encode_dispatch). A Metal probe (crates/metal2vulkan-conformance/probes/icb_routed_writes.m) and a lane (runtime_lane::write_routes) run the same four shapes: the buffer made resident for writing in the kernel's encoder, only in an encoder after it, only in one before it, and nowhere; a later encoder of the same command buffer executes the buffer. Why: the marks of a buffer the GPU may write are the command buffer's, while what its records may hold was gathered per encoder. The lane asks whether an execution runs what the GPU wrote, with the right state and pixels, wherever the command buffer paired the residency with the writer. Metal's answers (the probe, M3 Max, macOS 27.0.1, validation off, verified): in the kernel's encoder, after it and before it, all three kinds ran the kernel's command (green, green, words 0x100 to 0x103). Nowhere: the render command and the point did not run (the CPU's records: red), the compute command did. docs/API.md records that last difference: no encoder of the command buffer made the buffer resident for writing, which Metal's contract asks of a function's write, and the runtime runs the CPU's records there (APART in the lane). How verified: the lane, debug with --cfg m2v_gpu on the M3 Max under MoltenVK, fails at this commit, which is the bug the next commit fixes: [(Same, [true, true, true]), (After, [true, false, true]), (Before, [true, false, true]), (Nowhere, [false, false, false])] against Metal's (with the compute command apart), the inherited state's executions taking 2, 0, 0 and 0 host steps: with the residency in another encoder than the kernel's, the GPU alone ran the kernel's point as a draw of the CPU's triangles, which drew nothing. The render command and the compute command ran right in every shape. (cherry picked from commit 25134688d13d1abedab5e3ee5e1ff4c9db442a90) (cherry picked from commit ba7f047a7987a63a9e1f6fd78ae7093f27326e55) |
||
|
|
f35128eb43 |
Mark an indirect command buffer at the call that completes a write route, and let the routes go at the commit
The write routes marked a buffer at its command buffer's commit. An execution's segment is cut into a part of its own, which waits for the work before it, as it is encoded (`Segment::host`, from `gpu_written` then), so an execution encoded after the writer in the same command buffer, in its encoder or a later one, was recorded with the writer's part and ran the CPU's records: indirect_host_steps' commands_a_kernel_writes_run_after_it and 19 other lanes drew nothing. The routes now mark at the call that completes the pair: a write use where a state that may encode, or an execution whose records may name one, was met in the command buffer; such a state set, or such an execution encoded, where a write use was. An encoder opens with what its command buffer's ended encoders met (`Routes::carried`), so a later encoder's execution is encoded as one the GPU may write, as it was when a write use marked the buffer at its call. The commit still decides again from what the records name then, and still leaves the followers. The command buffer's routes held each buffer made resident for writing or executed until the command buffer itself dropped, past its completion: a released buffer's range and resource ID stayed taken (indirect_command_buffers' buffer_identifiers_follow_metal_s_encoders, resource_ids' an_indirect_command_buffer_s_id_is_held_as_metal_holds_it). The commit now clears them once it decided; what it leaves unmarked is held until completion, as before. Docs: the gpu_written contract, write_routes.rs, docs/API.md and the runtime README say when. Verified with the lane commit after this one (debug, --cfg m2v_gpu, this M3 Max on MoltenVK): the 39 lane modules that execute indirect command buffers, 479 tests, all pass, where B alone failed 35; the runtime's written_commands, degradation, degradation_catalogue and degradation_sites unit tests pass; fmt; clippy -D warnings of the runtime and validation crates, all targets and features, under --cfg m2v_gpu. (cherry picked from commit e8e85c6936ecc731fa557440033ac9d3e40953e2) (cherry picked from commit 106af168144e7a76fcc5366e39fec10a3693611c) (cherry picked from commit 38605155f851abdf697c818c5387c1980af6a0bd) |
||
|
|
66c9163ce3 |
Mark an indirect command buffer written by the GPU only where a route that may write its records meets it
A write residency of an indirect command buffer (useResource:usage: with MTLResourceUsageWrite) marked it written by the GPU at the call, whatever the encoder's functions could do. Every execution of it then waited for the work before it and was recorded by a host step, and kept no chunk. A page whose kernel only counts, with the buffer made resident for writing, paid the host step every frame (51 to 61% of the write frame in the kept-steps measurement), though no function of it can reach a record: a function writes records only through an indirect-command operation. The mark now comes from the routes that can write records (write_routes.rs), decided by structure alone: - the commit of a command buffer that made the buffer resident for writing in any of its compute or render encoders (residency is the command buffer's) and also set, in any of them, before or after, a pipeline state whose functions' indirect_command_writes is not empty (the translator's answer from their AIR: the indirect-command operations their bodies may call, every one where a body makes a call the translator cannot see into), or executed commands whose records may name such a state; - after a commit that found neither, the first CPU or GPU write that leaves such a state in the records of a buffer it executed (the executed buffers hold the commit's unmarked buffers weakly until then, released as the command buffer completes; the marks run once the setter let its locks go); - a blit's copy into the buffer or reset of a range in it, at the call, as before. A heap holds no indirect command buffer and residency sets are refused, so neither is a route. The mark is for good, as before. It keeps the route that met the buffer first, which the host-replay notice names: for a state, its functions' names and the kinds of indirect-command operation they may call; else the route. WorkCounts::indirect_write_residencies_unmarked counts each commit's write-resident buffers it left unmarked. The resident_draws fixture gains rd_encode, a kernel that may reset a command and resets none, regenerated with scripts/regen-air-fixtures; the lane's `encode` path uses it, off the measured paths. Docs: the gpu_written contract, the runtime README, docs/API.md (the catalogue's HostReplayedIndirectCommands trigger and cost, and the contract), the module docs that named the old rule. api_signatures.tsv blessed (one field). Verified (debug, --cfg m2v_gpu, this M3 Max on MoltenVK): the resident_draws lane's three tests pass: a kernel that cannot encode (rd_touch) leaves the buffer unmarked, with no host step in any of three frames, its two chunks run from the kept recording in the third, one unmarked residency counted a commit, and the read path's pixels; a kernel that may encode (rd_encode) marks it at the first commit, a host step every frame, no chunk kept, the same pixels, and the notice names rd_encode and its reset; every path draws the encoder's pixels. Negative control (neg.py: every state counted as calling no operation, and no executed buffer's records as naming one): the encoding test fails (no host step in frame 0), the other passes. The runtime's written_commands (a new test of the followers), degradation, degradation_catalogue and degradation_sites unit tests pass. fmt; clippy -D warnings of the runtime and validation crates, all targets and features, under --cfg m2v_gpu. (cherry picked from commit 6e1b62a03039dd81a2005afa26a3001de2064110) (cherry picked from commit 13dac865f4096559a5b97841d893e1da02e160ec) (cherry picked from commit 862a72c76e82b657ef158ee1c7cbf789240ea745) |
||
|
|
81531d6c10 |
Keep the used resources out of root tables the commit points elsewhere
Every draw and dispatch whose functions read loaded pointers uploads a root table per stage
that reads one. Each table embedded the whole resident set: every bound buffer, every
Buffer and Heap made resident, every listed range, sorted and coalesced per command
(resident_entries). The runtime then copied and uploaded those bytes and added each range
to its command buffer's root_ranges. Yet the commit points every table at the command
buffer's own resident set (State::point_root_tables; a host step's table is pointed at
once), so the GPU never reads the embedded copy. With N draws among N resident resources
that was N^2 work and bytes: 13% of the M3 profile of the argument-table shape at N 2000.
BindState::resident_apart is a consumer's opt-in, not part of the shape. It says the
consumer points every root table of the command at a resident set it uploads apart
(ResidentSet, RootTable::resident_fields). That set must hold every Buffer and Heap of
used_resources and every listed range, as well as the table's own ranges. With the flag, a
root table's own resident set holds the bound buffers alone (resident::table_entries), and
RootTable::resident_ranges lists only those. Without it, nothing changes, and replay
preprocess tables keep resident_entries either way.
The runtime sets the flag on the states whose tables go through binding::root_table:
RenderLowering::refresh_bind_state, the compute bind_state and dispatch_tiles_resident. It
leaves it off for gpu_execute and the GPU form, whose tables carry live ranges and are
pointed nowhere. The set the commit points at already holds what was dropped:
State::make_resident adds the joined residency's resident_ranges (every encoder's used
buffers and heaps) beyond the live buffers, and first_submission's remake does too.
Counted: WorkCounts::root_table_ranges_noted (State::root_table).
Functions: bind::resident::{table_entries (new), coalesced (new), bound_allocations (new),
resident_allocations, resident_entries}; bind::graphics and bind::dispatch build root tables
from table_entries; BindState gains resident_apart; State::root_table counts its ranges.
docs/API.md says what the flag asks of the consumer.
Verified:
- bind::resident::tests::a_state_resident_apart_keeps_the_used_resources_out_of_its_tables
(300 pseudo-random states whose bound buffers, used buffers and heaps and listed ranges
nest, overlap, touch and repeat): without the flag the table holds resident_entries; with
it, the bound buffers' set. A set made of the table's ranges plus the used and listed
ranges, as the runtime makes its own, resolves every address alike either way. The shape
is unchanged. A negative control (an empty table under the flag) fails it.
- bind::resident, bind::heap, bind::graphics, bind::dispatch and pipeline::api_tests pass
(74 tests).
- M3 numbers at the tip of this series are in its last commit. At N 300, every counter but
the new ones is the parent's on every path and binding of both shapes, barriers and uses
included, except the upload arena's buffers parked and recycled (54 -> 4: smaller tables).
The pixels are the parent's too.
(cherry picked from commit dcda2dc0368867436fb37ac78af79265088d6596)
(cherry picked from commit d6f17f77ab484eef479aa15df9c08055cf1101da)
|
||
|
|
5b5f1847d8 |
Find a state's heap members by search where it lists them in token order
A handle table's bytes (bind::heap::table_bytes, inside every draw's and dispatch's
instantiation) and a plan's heap elements (BindingPlan::heap_elements, which the runtime
asks for at each draw) found each heap member's used-resource entries through a map built
for the call over every used resource: a BTreeMap entry and a Vec a token, for every
resource made resident, at every command. A pass of N draws among N resident resources so
cost N^2. In the M3 profile of the argument-table shape at N 2000 these two were 44% of the
frame.
BindState::used_in_token_order is a consumer's opt-in, not part of the shape. It says it
lists used_resources in token order (each entry's token at least the one before, so a
token's entries lie together; a debug build asserts it). The binder then finds a member's
entries by search, O(members x log n), and without the flag it gathers them as before
(UsedByToken::{Listed, Gathered}). The runtime sets the flag on every state it lists from a
residency: Residency::used_resources lists in token order, and tile_resources keeps that
order.
Functions: bind::heap::{UsedByToken::of, UsedByToken::get, member_id, handle_table_bytes,
heap_elements}; BindState gains used_in_token_order; the runtime sets it in
RenderLowering::refresh_bind_state, the compute bind_state, dispatch_tiles_resident,
gpu_execute's total and the GPU form's preprocess. docs/API.md says what it does.
Verified:
- bind::heap::tests::a_state_in_token_order_finds_its_members_by_search: 200 used
resources, members among buffers, one listed twice under one ID. The ordered state is
searched (Listed), the same state without the flag is gathered, and both give equal
tables and heap elements and the same internal errors for a member with two IDs and a
member not listed.
- The rest of bind::heap and pipeline::api_tests (the serde round trip names the field)
pass.
- M3 frame times at the tip of this series are in its last commit.
(cherry picked from commit d23e702339ce57f4a75cfae9f4a8247ff6875bd4)
(cherry picked from commit a38aeff46479332628c5350d73f7fc319635c713)
|
||
|
|
61a9508e92 |
Build visibilityResultType: Accumulate takes a pass's results into the buffer's words
RenderPassDescriptor gains visibility_result_type (MTLVisibilityResultType: Reset, the default and today's behaviour, and Accumulate). Under Accumulate no query result is copied over its offset's word: every query of an offset, the first one too, is copied into the upload region the continuations already use, and the crate-owned combine takes them into the word as the buffer holds it. The combine already loaded the destination word as its accumulator, so Accumulate is the first query becoming one more source. A `Boolean` word ORs the device's results in; a `Counting` word is summed in through a new table mode of the combine, into the word's low 32 bits alone, wrapping there, its high 32 bits kept (ContinuedResult::low_half / in_low_half). That last part is what the M3 Max answered when recorded: 0xffff_fff8 plus 16 samples writes 8, and 0xffff_ffff_ffff_fff8 plus 16 writes 0xffff_ffff_0000_0008. A plain 64-bit sum was divergent there. An offset set with no draw after it keeps its word, because a query with no draw adds 0. Where a no-copy buffer's bytes start off a multiple of 8, so the results land in an upload region, the words are now copied into that region before the combine (Landing::inward). Reset records exactly what it did before. Conformance: RenderPass gains visibility_type (typed()), and words() appends it only where it is not Reset, so existing fingerprints read as before. Both sides set it. There are four new visibility cases, recorded on the M3 Max (macOS 27.0.1): visibility-counting-accumulate (two command buffers; words 100/5/7/0xffff_fff8/u64::MAX-7), visibility-counting-accumulate-one-command-buffer (two passes in one command buffer, read once), visibility-counting-accumulate-revisit, and visibility-boolean-accumulate (words 0/2/3 under covering and non-covering draws, an offset set with no draw, then a second command buffer). The family's acts key states the type, and a joined shape adds a command-buffer input. Cost and timing records for the new cases are not written here. Lane tests (runtime_lane): accumulated_counts_add_to_the_words, accumulated_booleans_or_into_the_words, and host_bytes::accumulated_visibility_results_land_where_their_bytes_lie. Unit tests: the combine's accumulated_counts_are_summed_into_the_low_half, its plan's table mode, and the type's raw values. Coverage: coverage.tsv marks MTLRenderPassDescriptor.visibilityResultType implemented (its unused "visibility" group is removed), and METAL-COVERAGE.md is regenerated. MTLVisibilityResultType joins the enum table, so metal_enumerators.tsv and CONFORMANCE-COVERAGE.md are regenerated. The API signatures are re-blessed. REFUSALS.md is regenerated: VisibilityResultType::from_raw is one more UndefinedValue site. The regeneration also picks up two bind/graphics.rs sites the committed file was missing. The degrade docs (landed results, Boolean) state Accumulate. Verified on the M3 Max under MoltenVK 1.4.2: - The 52 visibility-touching lane tests pass: visibility, host_bytes, depth_never, amplified_draws, degrade_notices and the framebuffer_fetch split pass. - The visibility family's replay is all announced (no divergence), after the low-half change. - Negative control with Accumulate forced to Reset: all three Accumulate lane tests fail, and all four new cases replay divergent. - Negative control with no inward copy: the landing test fails at 4 bytes past a page (2 read 0, 100 read 16). - Before the low-half change, visibility-counting-accumulate replayed divergent at words 3 and 4. - The combine's low-half test fails on the interpreter without the high-half select ([8, 1] for [8, 0]). clippy (plain and --cfg m2v_gpu), rustdoc and scripts/api-docs are clean. SEMANTICS_VERSION: no translated shader changes, but the owned combine module's words do (main's call). RUNTIME_VERSION and the runtime-sources pin are not touched here. (cherry picked from commit 1c172968ad6492cebcae2a568fc99e90565d4d11) (cherry picked from commit 9f47ebcf006920f7561a16a77f77e422de7201c1) |
||
|
|
d806c0a792 |
Write Boolean visibility results as the device's nonzero query result, without the resolve
Metal's Boolean visibility result is nonzero where any sample passed and 0 otherwise. The Apple M3 Max writes 1; Metal on the AMD Radeon Pro 5300M and the Intel UHD Graphics 630 (macOS 26.7.1, the reims-vgpu team's probes) writes the samples that passed. The runtime had a crate-owned dispatch (bind::visibility_resolve_module) after every pass with a Boolean offset whose only job was to rewrite that word to exactly 1. Under AGENTS.md rule 1 the device's native answer is the only form: a Boolean result is now the imprecise occlusion query's own result, which Vulkan states as "When any samples are passed, boolean queries will return a non-zero result value, otherwise a result value of zero is returned" (occlusionQueryPrecise). Across a split pass's render pass instances the combine still ORs the continuations, so zero stays zero exactly where no instance passed a sample. Counting queries stay precise. - Runtime: the resolve's plan, uploads, sets and dispatch are gone from visibility.rs, and OwnedModule::VisibilityResolve from owned_kernel.rs. A pass with no continuation now records only vkCmdCopyQueryPoolResults. The combine's in-place words are declared as shader reads and writes for every combined offset (they were declared only for Boolean ones). A new precision degradation, DeviceBooleanVisibility (device-boolean-visibility), is announced where a pass's Boolean results record; its catalogue entry is in docs/API.md section 9 and a device-gaps row in docs/FAST-PATHS.md, as for the other native-answer kinds. - Translator: bind/visibility_resolve.rs and its tests are deleted (VisibilityResolve, VisibilityResolveModule, visibility_resolve_module leave the public surface). Its shared helpers (windows, words_buffer, u32_value) move into visibility_combine.rs; the combine's plan tests take the two refusal cases only the resolve's tests held. No translation output changes. - Conformance: a new Loosening::Nonzero, and an allowance may name one element of a byte region as <site>/<byte offset>. The visibility family loosens each Boolean result's word, and only that word, by Nonzero, justified by device-boolean-visibility, which its Boolean cases also declare at the notices site. Every other word still compares exactly. No recording changes. README and docs/CONFORMANCE-COVERAGE.md (regenerated) say so. - Validation lane: every Boolean expectation reads the word by its contract (visibility::by_contract: nonzero and not the buffer's starting word reads as 1), in visibility, framebuffer_fetch, host_bytes, depth_never and amplified_draws; the notice is a new lane site (visibility::BOOLEANS) taken by boolean_results_announce_the_device_s_value and expected where other tests' notice sets are exact. boolean_results_are_copied_with_no_dispatch counts one query result copy and no vkCmdDispatch for a pass of two Boolean offsets. Verified: cargo clippy --workspace --all-targets --all-features -D warnings with --cfg m2v_gpu; the runtime's degradation catalogue and site tests, the translator's combine, owned-division, resolve-helper users', api_surface and api_signatures tests; the conformance suite's 1024 device-free tests. The device lane tests run on the M3 with the next step. (cherry picked from commit a4976cdc3734c21c1b9ed4cf603bbf6bab2523f0) (cherry picked from commit 34e44e3a12a46e6ff4b651cc4689002690d680fc) |
||
|
|
185bbd6328 |
Host steps: record off the scheduler's thread, order by what the execution reaches, make only named states
A batch executing indirect commands the GPU may write waits for its gate, then its host step records the commands from their records. Three costs fell on every other queue meanwhile: - The step ran on the scheduler's thread, which submitted nothing while it recorded (thousands of draws take milliseconds). - Its footprint was unknown (tracker::ordered's None), so every later batch of another queue that made a tracked use was held behind it until it was submitted. - At commit, the render settle made a VkPipeline for every live state that supports indirect command buffers, times the topology class's primitive types (1,280 lookups and 513 makings for 256 live states on the measured frame), and the step waited for all of them, up to the command buffer's bound. Now: - The scheduler hands each step to a steps' thread (scheduler/steps.rs, started at the first step, user-interactive like the scheduler's, recording inline where the host cannot start it), which records the steps in order, each a section of the exit guard, and wakes the scheduler. The batch is marked as stepping meanwhile (CommandBufferShared::begin_step/end_step), so it waits and no pass hands it over twice. - commit bounds a step's uses where it can (Segment::bound): for a compute execution, the resources the command buffer made resident and the ICB's storage (and an indirect range's copy); for a render pass, the pass's own uses, the resident resources and each execution's storage. CommandBufferShared::footprint uses that bound, so only a later batch sharing one of those is held. An execution that inherits buffers, is gated or preprocessed, reaches tile memory, has shadows or lends visibility stays unbounded (None), as before. - The render settle makes the states the CPU set on the executed commands (IndirectCommandBuffer::set_render_states, each state once), or the inherited one. A draw of a state a GPU-written record names that no settle made is begun at the step, made on its thread or handed to the device's pool and waited for until the command buffer's bound, as before; it holds no other queue's batch, and it is counted. On the kept recordings of the commit before (item 1), set_render_states reads the states the CPU set from the buffer's per-command map (Commands::states, a range of it), each state once. New counters: WorkCounts::host_steps_recorded, host_step_nanos, and host_step_pipelines_made (the VkPipelines a step began itself, made on its thread or handed to the device's pool and waited for: counted at the variant's making on the step's thread and at pipeline_pooled). The degrade notice host-replayed-indirect-commands states the new cost (degradation.rs and docs/API.md, same text). Verified on the M3 Max (MoltenVK 1.4.2), release, runtime_lane::host_replay_frames (the next commit: 256 live states, an ICB of 5000 draws naming 4, made resident for writing by a compute pass each frame, and a presenter clearing a texture on another queue every 8.33 ms), the parent and this tree run alternately twice, 60 frames each after 4 cold ones, on a loaded host: - the presenter: 80 of 244 and 73 of 192 ticks presented before (commit to completion median 16.9 and 16.4 ms, p90 40.8 and 23.7 ms), 186 of 186 and 185 of 189 after (1.13 and 1.13 ms, p90 1.49 and 2.23 ms); heads held behind earlier commits 23 and 13 before, 0 after; - the first frame's commit: 377 and 168 ms before (513 variant pipelines made, 1,284 looked up), 5.3 and 5.1 ms after (9 made, 24 looked up); a steady commit 2.38 and 2.33 ms before, 0.14 ms after; - the frame itself (commit to the last completion): median 28.7 and 24.4 ms before, 23.3 and 24.6 ms after, within the host's noise; the host step takes about 20 ms of it (host_step_nanos), recording the 5000 draws. The consumer's ICB repro (one state, 5001 draws, the ICB made resident for writing, another queue's one-dispatch command buffers meanwhile), same runs: that queue's commit to completion at the 99th percentile 53.5 and 24.3 ms before, 2.96 and 3.71 ms after, 140 and 119 command buffers in 40 frames before, 2,281 and 2,062 after; the frame alike (21 to 26 ms). Tests: runtime_lane::render_executions:: a_host_step_makes_the_pipeline_of_a_state_only_a_gpu_written_record_names (a blit-copied record naming a state, of another variant, that the CPU set on no executed command: both commands draw, the step's beginning of that state's VkPipeline is counted, and the step's time). --cfg m2v_gpu under the validation layer, on this tree before the pipeline_pooled count and the test: 234 tests of the indirect_*, kept_*, render_executions, render_gpu_executions, render_merged_executions, mesh_commands and executions lanes; 1,644 tests of the runtime crate's lib and the commands_recorded, dispatch_executions, generated_executions, kept_variants, device_commands, queue_order, submission_checks and grouped_submissions lanes. clippy -D warnings, plain and --cfg m2v_gpu; rustdoc -D warnings; scripts/api-signatures --check. Needs a RUNTIME_VERSION bump (what a run submits, when, and its counts) and a runtime-sources pin. (cherry picked from commit 4b05004999403684a2bdf4f3994108b53c7dc776) (cherry picked from commit 3831ba7e1298203779597feb0ea2943f77f9f5df) |
||
|
|
0e7e09a064 |
Answer a required threadgroup size's threads as a state's maxTotalThreadsPerThreadgroup
A compute or tile state whose descriptor states requiredThreadsPerThreadgroup now answers that
size's threads as its maxTotalThreadsPerThreadgroup. The answer is lowered only where this device
holds fewer threads for the kernel than the size. A state that requires no size keeps today's
answer, the compiled pipeline's limit. Before this change every state answered the compiled limit
(1024 on a full device) whatever size it required. Metal answers the size.
Measured on the M3 Max under macOS 27.0.1. Each state came from a source compiled once and never
before, with an integer baked into it:
- Compute: exactly W*H*D. 1x1x1 gives 1, 3x1x1 gives 3, 3x3x1 gives 9, 7x3x1 gives 21, 8x8x2
gives 128, 1x1x64 gives 64, 32x32x1 and 1024x1x1 give 1024. No size gives 1024.
[[max_total_threads_per_threadgroup(128)]] with 8x8x1 gives 64.
- Tile (threadgroupSizeMatchesTileSize on or off): W*H*D rounded down to a multiple of 4.
1x1, 2x1 and 3x1 give 0, 3x3 gives 8, 7x3 gives 20, 2x2 gives 4, 6x6 gives 36, 8x8 gives 64,
16x16 gives 256, 32x32 gives 1024. A tile dispatch of the state's own size runs no thread
where the threads are not a multiple of 4 (1x1, 2x1, 3x3, 7x3). The command buffer completes
with no error.
- Metal keeps a state it compiled and hands its limit to a later state of the same function
that differs only in the required size. For compute this was seen in the same process; for
tile, in the same process and in a later one. A compute state with 8x8x1, and one with no
size, answered 16 after a 4x4x1 state of the same MTLFunction. An 8x8 tile state answered 16
after a 4x4 one, and its 8x8 dispatch ran no thread. The module doc's earlier "the state's
maxTotalThreadsPerThreadgroup stays the kernel's own" reads like such a measurement: a
function compiled first with no size.
Rule 1 does not cover this: it is an API value Metal reports, not arithmetic. So the runtime
answers Metal's first-compile rule and does not imitate its cache. Following the owner's
decision, a tile state also answers the size's threads where Metal rounds them down, and its
dispatch of that size runs. Metal runs no thread there, which is its own defect. docs/API.md's
accepted differences records both and Metal's cache answer.
How:
- ComputePipelineState::max_total_threads_per_threadgroup answers
pipeline::reported_max_total_threads(required size, compiled limit). A tile state's
RenderPipelineState answer goes through its tile function's compute state, so it follows.
- The compiled limit moves to pipeline_max_total_threads_per_threadgroup (crate-private). The
replay and folded indirect-dispatch paths (gpu_execute, indirect_dispatch) read it, so no
dispatch path changes.
- Docs: the additions module's measurement, the tile module's answers, the render and compute
accessors, the translator's descriptor fields and ComputePipelineMetalInfo, and docs/API.md's
accepted differences.
Tests:
- tests::pipeline::a_required_size_is_the_states_thread_limit (CPU): the rule, the device's
lower limit, no size, and axes whose product overflows.
- runtime_lane::compute_threadgroups::a_compute_state_with_a_required_size_answers_its_threads
and runtime_lane::tile_states::a_tile_state_with_a_required_size_answers_its_threads
(--cfg m2v_gpu): states made through the runtime with and without a size.
Verified:
- cargo clippy -D warnings, plain (metal2vulkan, metal2vulkan-runtime, metal2vulkan-validation)
and with --cfg m2v_gpu (metal2vulkan-validation);
- RUSTDOCFLAGS=-D warnings cargo doc (metal2vulkan, metal2vulkan-runtime);
- scripts/api-docs;
- the metal2vulkan-runtime and metal2vulkan-air suites: 1715 passed, 4 skipped;
- the device lanes on the M3 Max through MoltenVK (tile_states, compute_threadgroups,
tile_threadgroups, indirect_dispatches, indirect_executions, function_tables): 124 passed.
With the old answer put back, both new device tests fail ("left: 1024, right: 1" at 1x1x1).
No version bump and no pin here: they come at stacking.
(cherry picked from commit 94fbec600e2155fff4c05b88894155054569621e)
(cherry picked from commit 09be67cab1968bbadcc698456fb245ec6e94f20a)
|
||
|
|
7996b9a164 |
Mark a queue long by its command buffer's own GPU time, not the host's view of its head's age
What: a command queue is now marked long where one of its command buffers' own timestamps (its first batch's start to its last's end) span over LONG_HEAD (2 ms), in the completion turn that read them (CommandBufferShared::place_gpu_times), before the turn finishes it. The waiter's host-age check in command_buffer/completion.rs (HeadWatch, Device::head_watch) is removed, and went_long returns at once unless the device shares. A device whose command buffers write no timestamps the host reads (gpu_times_from_host, a driver whose timestamps wait for every queue's, or no calibrated timestamps) no longer shares: queue_switch_check::timed() gates the check, and recall settles Unchecked and counts the new WorkCounts::queue_sharing_untimed where the device has two VkQueues of one family to share. Two runtime extensions, doc-hidden, for the lanes and the probe: CommandQueue::vk_queue_sharing() (its VkQueue and long mark) and Device::shares_vk_queues(). Why: the host's view of a batch's age as its VkQueue's oldest also holds its wait for the GPU to start it and the waiter's lateness to see it complete, so short command buffers marked their queues long for good. On the RTX 5080 Laptop GPU, 2x3 runs in a slow stretch had each thread's queue marked long mid-run (at 20 ms to 1,238 ms) and settled apart, the PerQueue placement, at PerQueue's rates. Measured cause, with a diagnostic build printing each host-age mark beside the command buffer's own GPU span: beside another process's 30 ms command buffers, draws of 11 and 16 us of GPU time were seen 2.0 and 2.3 ms after they became their VkQueue's oldest, 1.8 and 2.1 ms of that before they started; that run's thread queue settled apart and ran at PerQueue's 4.1k. In the runs without contention, every true mark had a GPU span within 1.2 ms of its host age (the 30 ms command buffers and the probe's 2.7 ms sizing one); under contention the sizing command buffer's host age exceeded its span by 4.2 ms. Neither suggested alternative fits: the false marks came mid-run, not only in a queue's first command buffers, and decaying the mark after short heads would let the trap and alternating shapes' long queues rejoin and stall the compositor again. Tests: tests::queue_share_device gains a_device_that_answers_gpu_times_from_the_host_does_not_ share_and_counts_it (expected, not run, to fail without the gate on the 5080: there it printed "Unchecked ... could share: true", so the recorded Idles verdict would make it share), and asserts queue_sharing_untimed == 0 elsewhere; its isolation runs print each queue's VkQueue and mark over the run. The queues lane's a_queue_joining_another_s_busy_vk_queue_is_announced_once now makes its device under QueueSharingPolicy::Adaptive (over the lane's exact_answers()), lets the busy queue's fills be submitted first, and asserts queue_joins > 0 exactly where the device shares, saying why where it does not. cross_queue_shadows gains the signal-in-between and the waiting-writer cases on one VkQueue: no spin, Adaptive, the check settled, queue 2 joining queue 1's busy VkQueue; they assert the join, neither queue long, the hold still withheld while the waiting writer has not completed, and the bytes. Docs: QueueSharingPolicy::Adaptive, the FAST-PATHS row (the rule, the untimed exclusion, the new ranges), docs/API.md (the policy section and the notice), the queue-sharing notice's cost text, queue.rs and queue_share.rs; api_signatures blessed (additions only). Verified on the RTX 5080 Laptop GPU (NVIDIA 615.71.09, msi, under gpu-locks, no VM), release probe: - 2 threads x 3 in flight, 10 runs each in turn: Adaptive 48.3, 28.0, 50.7, 52.9, 28.1, 53.7, 48.6, 29.9, 31.5, 53.0k against PerQueue 21.4, 24.9, 27.8, 28.0, 27.6, 27.4, 27.1, 23.3, 26.9, 27.3k, Adaptive above PerQueue in each pair; no thread's queue marked long in any run (gone long 1 each: the probe's sizing queue). The 28-31k runs keep the shared placement, with waiter parks 0.23 against 0.02-0.05 per command buffer in the fast ones: a host-side mode, not a move. - Beside another process's 30 ms command buffers, 3 runs each: the old rule 4.1k (a thread's queue marked long by its host age), 5.2k, 6.6k; this rule 6.7k, 5.4k, 5.1k (no mark); PerQueue 4.1k, 4.1k, 4.0k. There, draws' own spans reached 1.16 to 1.52 ms (timesliced), under the bound. - Isolation, 3 runs each: trap and slow-alternating 64 completions over 10 ms under Adaptive (the one first-long stall, at most 26.4 to 30.1 ms) against none under PerQueue (at most 5.6 to 9.7 ms); alternating none under Adaptive (at most 5.7 to 9.8 ms) against 7, 0, 0 under PerQueue. Unchanged from the host-age rule's runs. - 8 threads: 3 in flight 53.4k, 54.4k against 27.8k, 27.4k; 1 in flight 50.1k, 49.3k against 14.0k, 13.9k. - Device tests (debug, --cfg m2v_gpu): tests::queue_share_device 8/8, the joining lane test and cross_queue_shadows 7/7 (the one-VkQueue cases: X's and Y's queues both on VkQueue 1, neither long, holds withheld 2, gated copies in 2). The compositor isolation test, old rule and new in turn, 3 each: p99 2.66-2.94 ms against 2.16-2.83 ms, 0 stalls, the same placement (the compositor alone on VkQueue 1, the application long on VkQueue 0, gone long 1). Its one earlier failure under this rule (p99 7.93 ms, 20 stalls, 5,579 of ~9,600 commits made) ran right after a 74 s compile inside the hold, with the same placement and gone long 1: host load, not the rule. On the M3 Max (MoltenVK, no sharing), tests::queue_share*, command_queues, cross_queue_shadows, gpu_time and host_memory: 90/90. clippy -D warnings plain and --cfg m2v_gpu; RUSTDOCFLAGS=-D warnings cargo doc; fast_paths, degradation*, api_signatures, api_surface, work_counts pass. No RUNTIME_VERSION bump or pin here. (cherry picked from commit 4fd88b7564cd9cd3651543bb3f8cd529b021709e, two claims corrected to what was run) (cherry picked from commit eb0153e9d0fe6d272f2411c65f0a1ecda2c78bc2) |
||
|
|
50b41ecc54 |
Draw the kept draw again rebound after texture and sampler binds too: rewrite those slots alone
A vertex or fragment texture or sampler bind forgot the encoder's kept draw, so a draw after one
took every step: the compositor shape (a buffer and a texture bound before each draw) never
reached the bind tail.
Now:
- Texture and sampler binds keep the kept draw (log_keeping), as buffer binds do; the next draw
compares the tables' stamps.
- BindingPlan::rebind_draw_slots_into (was rebind_draw_buffers_into) takes buffer, texture and
sampler slots. A texture or sampler slot decides none of the commands. It answers Ok(false)
for a texture buffer's texel range and a YCbCr texture's planes.
- binding::rebind_into writes a changed texture's or sampler's image descriptor as bind_into
does (image_descriptor, through the encoder's memo, its samplers kept for retaining). It
answers Ok(false) for a changed texel buffer, YCbCr image or argument sampler.
- The draw rebound brings in texture and sampler slots and stops where every step would differ:
- a memoryless texture its functions use (the full path fails the command buffer there);
- runtime samplers' address modes other than the kept draw's;
- a changed shape (a sampler of other addressing, which the pipeline's specialization
reads, takes every step);
- a plan that samples or writes a color attachment's texture;
- an extended-range shadow.
It retains the new samplers and notes whether its uses read an image (Kept::reads_images).
- Docs: rebound.rs, WorkCounts::draws_rebound, docs/API.md, api_signatures.tsv.
Check: tests::draw_again::draws_after_texture_and_sampler_changes_rebind_what_every_step_binds
(tob_sample). It covers another texture each draw, another sampler of the same shape, both,
and samplers of other addressing. It checks rebound counts (0 for the last), commands, state
commands, noted uses and pixels against every step, with the debug cross-check on every second
hit. It fails without the change (0 rebounds). The buffer test's slot-of-another-class case is
now more slots than a draw rebound takes (samplers 0 to 8). Passes on the M3 (MoltenVK) with
the draw_again tests; clippy clean, plain and with --cfg m2v_gpu.
(cherry picked from commit ecf97956b214836a1309affe539aff8454239e97)
(cherry picked from commit 8472edf4c0ae174c3dab7bc667cecfa6874aa942)
|
||
|
|
e3f2c95dfe |
Draw the kept draw again rebound: after buffer, offset or bytes binds, rewrite those slots alone
A render encoder's kept draw (render/draw_again.rs) drawn again after calls that bound other
buffers, offsets or inline bytes at vertex or fragment buffer slots now rebinds only those slots
(render/draw_again/rebound.rs, WorkCounts::draws_rebound), where it took every step of a draw.
- Translator: BindingPlan::rebind_draw_buffers_into(state, slots, commands) writes again, over
the same draw's commands of a state of the same shape, only what the buffer slots decide: their
descriptor ranges at their places, the SlotBindOffset, SlotGuestBase and pulled-stride push
fields that read them, and their vertex buffers' offsets. Ok(false) for a device-address slot,
an argument or root table, a per-bind stride's vertex binding, a mesh, patch or de-indexed draw,
or a uniform view a written slot may alias. docs/API.md says so; api_signatures gains it and
WorkCounts::draws_rebound.
- Runtime: buffer and bytes binds keep the kept draw (log_keeping); the draw compares its tables'
stamps with the kept draw's. On a difference, the tables' changes since (argument_table::
changed_since: buffer slots alone, at most 8) are brought into the kept bind state
(refresh_changed), and the draw goes on only where its shape stays, its variant and plan then
the bind state's kept settle (LiveBind::settles_kept). It rewrites the commands
(rebind_draw_buffers_into), set 0's writes and dynamic offsets (binding::rebind_into), push
bytes and vertex buffers, and its uses whole (command_uses_into), and takes the checks a draw
takes of them: a pulled attribute's reach, the stages' function tables, the attachments' reads;
it stops at a pass whose fragments wrote memory, a shadowed texture among its uses, a barrier
its fragments need after earlier geometry writes, or a detached buffer. It records with set 0
as any draw finds or writes it (EncoderCore::set_zero_of), its uses noted as any draw notes
them, through the kept draw's recording parts against what its command buffer holds; a notice
met at each occurrence forgets it once recorded, as every step does. The kept parts (set-0
writes that hold no keeper, dynamic states, the rest of its recording) live in the bind state's
storage (LiveBind::kept), filled at the keep alone: a draw that takes every step pays one
KeptStorage::keep and nothing per recording.
- Checked in builds with debug assertions: the first rebound draw of a kept draw and every second
after it take every step instead, which must keep the draw, with the same commands, set-0
writes, dynamic offsets, push bytes, vertex buffers and uses.
Tests: tests::draw_again::draws_after_buffer_changes_rebind_what_every_step_binds (MoltenVK, M3):
draws after offset and bytes changes rebind (draws_rebound == the draws again but those the check
takes), with the same commands of every kind, state commands, noted uses and pixels as the same
draws each taking every step, every draw at its own offset and color; a sampler bind between them
takes every step. Negative control: the translator not rewriting a changed slot's range fails it
at the cross-check ("other commands"). metal2vulkan's tests::engine_graphics_binder rebind test:
1360 rebinds over stage-io plans equal a full instantiate, and its negative control fails.
host_ab encode, release, 10k draws per command buffer, us/draw, offset case (one
set_vertex_buffer_offset before each draw), measured on this change before its last revision
(which moved the kept parts' fill from every full draw's recording to the keep and dropped three
Arc clones a keep; its own numbers come with the next landing):
Apple M3 Max, MoltenVK 1.4.2, three interleaved rounds (median / mean of round p50s / max p90):
lock fix 1.561 / 1.550 / 1.591 -> 0.550 / 0.548 / 0.592
RTX 5080 Laptop GPU, thread CPU per draw, host_ab threads workload, one thread:
lock fix 2.006 (shared PSO), 2.001 (own) -> 0.541, 0.585; on 8 threads 10.3 Mdraws/s (was 2.9)
The unchanged draw (static) holds: 0.044 -> 0.046 on the M3.
(cherry picked from commit 2ee3520ff104094afde523e2eebf7bc8a9a9626d)
(cherry picked from commit d00975ea7da92da4886a29f1ebda6397f64202b1)
|
||
|
|
aa9b38e6fd |
State the padded sRGB twins' code and decode bounds as measured
DevicePackConversion's documented bound for the extended-range and padded conversions said "a code within one" of Metal's. For R10Unorm_X6_sRGB and RGB10A2Unorm_sRGB that is wrong. Metal's write of these formats rounds the value clamped to [0, 1] to 2^-13 (nearest even) and then looks it up in its encode table (R10X6_SRGB_ENCODE_FIRST). The device writes the MSL transfer by its own maths, times 1023, RoundEven. In the transfer's linear segment, one 2^-13 step spans 1.6 codes, so the two can land two codes apart. Measured: for each 2^-13 step over [0, 1], the f32s at and next to both edges, where Metal's code is constant within a step and the device's code rises with the value. The device's code (exact transfer) lies at most two from Metal's table. It reaches two only below 0.0031308: at 1.5/8192, just above 6.5/8192, and at 24.5/8192. Everywhere else it is within one, beyond the Pow's bound. Metal's recorded writes and stores of RGB10A2Unorm_sRGB on the M3 Max under macOS 27.0.1 (rgb10a2-srgb-writes, -stores-f, -stores-h) show exactly that: three words each, at k/16384 for k = 3 and 49, and at the 1.5/8192 special. Metal's decode of RGB10A2Unorm_sRGB's colour (the rgb10a2-srgb-reads recording, every code) lies up to 1.637 steps of 2^-13 from the exact transfer (code 952: Metal 0.84912109, exact 0.84932096). That is the 1.64 the docs gave for R10Unorm_X6_sRGB only. So artifact.rs's DevicePackConversion, the FAST-PATHS air.pack row and API.md's catalogue entry now give, for those two formats only: a colour code within two below 0.0031308, and a decoded colour within 1.64 steps. Doc text only: the device's conversion is unchanged (rule 1), and so is behaviour. No version bump. (cherry picked from commit 8bfaab43bd6c6368c41d58caa7e9c91fe64820d5) (cherry picked from commit e728f0fa394c46c528d2f99df89a33751f5691d7) |
||
|
|
549609b26f |
device-color-conversion: state the measured unorm rounding at a tie
The note's doc said every Vulkan driver measured but MoltenVK rounds the f32 product with ties to even and that Metal "rounds a half toward zero". Neither fits an exact tie in an 8-bit unorm attachment: Metal stores 0x80 for 0.5 (127.5), and the RTX 5080 stores 0x7f, which ties to even would not give. "A half" meant a half-float channel, which read as 0.5. Measured over every 8-bit code's exact value and every tie with two f32 steps either side, BGRA8Unorm and RGBA8Unorm: - Apple M3 Max, macOS 27.0.1, plain Metal (a probe of our own): all 1531 inputs store the exact product rounded to nearest, the tie up; 128 of them differ from the f32 product rounded with ties to even. 0.5 -> 0x80, f32(1.5/255) -> 2, f32(2.5/255) -> 3. - RTX 5080 Laptop GPU, NVIDIA 615.71.09, through the runtime (the color_writes lane's pipeline, plain draw and an indirect command buffer's draw of the same state): plain and ICB identical in every channel; every input on a tie or up to two f32 steps above one stores the lower code (0x7f, 1, 2 for the three above), every other input Metal's code; 638 of 1531 inputs differ from Metal. The doc now says so (artifact.rs, the color_writes module, API.md's catalogue entry), names the half-float channel plainly, and keeps the ties-to-even claim for ANV, RADV and lavapipe only, as earlier measured; the RTX 5080 is no longer among them. The fragment stage records DeviceColorConversion on the 5080 for that pipeline, plain and ICB alike (verified: both stages' notes printed, and with device-color-conversion asked at every occurrence the plain draw and the ICB's replayed draw each announced it once). Docs and comments only. (cherry picked from commit 5021f1c4ba7f29a6dc54f76f4d12402795af7162) (cherry picked from commit e21d7c945b383ddfbfe54a8d82fc89342e6f7d13) |
||
|
|
be47523f80 |
State queue sharing's residual stall and the unshared form for queues that must never wait
What: docs/FAST-PATHS.md's queue sharing row, docs/API.md's policy bullet and the runtime README's new_command_queue_unshared entry now state the residual stall exactly: once per logical queue that goes long, for a queue that joined its VkQueue during its short phase, about one long command buffer's length. They also say a queue that must never wait (a compositor's) is made with Device::new_command_queue_unshared. The row's cost column carries the measured rates. The queue_share example's rates mode takes --threads, --in-flight and --one-vk-queue for one shape. It prints each command buffer's GPU end and commit to its completed handler, the submission, scheduler and wake counts per command buffer, and the busiest threads' CPU from /proc (Linux). Why: on the RTX 5080 Laptop GPU (NVIDIA 615.71.09, release, 3 runs a side), the trap and slow-alternating shapes cost a shared compositor 64 completions over 10 ms, at most 29.4 to 30.6 ms, in every run, with one join each. That is the first long command buffer of the application it joined during the application's short phase. PerQueue had none in 5 of those 6 runs and 4 in the sixth (at most 3.7 to 10.7 ms). An unshared compositor had none over 10 ms in any run. No join rule built on what a queue has shown can avoid the first one: the long command buffer gives no sign before it runs. A re-pick at submission would not either: the compositor holds about 4 uncompleted command buffers at each commit (p50 commit to handler 0.78 to 0.87 ms at a 208 us period), and the stall is all or nothing in a queue's own order. So the docs name the unshared form as the answer for such a queue. The probe settled the 2 threads x 3 in flight drop (15.4k against 26.0k a second in one run): it was the lock hold's warm-up. In the hold's first runs both policies ran slow (11.1k and 10.4k), and later runs gave Adaptive 46.5k and 39.7k against PerQueue's 25.2k and 26.5k. Two queues on one forced VkQueue ran 38.1k to 46.6k under PerQueue and 41.4k to 49.9k pinned under Adaptive, so one VkQueue is not slow in the runtime's path. No runtime thread was busy in the slow runs (scheduler 10%, handler threads 5%, waiters 3%), and every shape made one vkQueueSubmit per command buffer. Verified: tests::fast_paths, degradation_catalogue and degradation_sites (25 passed); clippy of the example with all features. (cherry picked from commit b1dbea95dad3a5a156191df01084db0f86cb67a0) (cherry picked from commit 24af60dbf8175da8e60ea24f38f9103c20c23e8b) |
||
|
|
510e0c0cca |
Share VkQueues between command queues where the GPU idles at each switch, with an unshared opt-out
What: a new DevicePolicy switch, queue_sharing: QueueSharingPolicy { Adaptive (default),
PerQueue }; exact_answers() selects PerQueue. Under Adaptive, on a device whose own self-check
finds its GPU idle when consecutive work comes from another VkQueue, a command queue chooses its
VkQueue again each time it makes a command buffer while it holds no other uncompleted one (the
slot take with held.all == 1, under its slots lock): it joins the busy VkQueue of its family
whose oldest batch has run under 0.5 ms, the most batches in flight first, then the latest
submission (Device::pick_vk_queue: one pass of atomics over the round robin's VkQueues, no lock).
A queue whose batch ran over 2 ms as its VkQueue's oldest is marked long by the waiter that saw
it complete, under the completion's pending lock, before the turn that finishes it
(command_buffer/completion.rs); no queue joins a long queue's VkQueue, and the long queue moves
once more at its next idle point, to the least recently used idle VkQueue no long or unshared
queue holds. Its mark moves with it and a dropped queue subtracts its marks. Presenting queues and
a queue that lent its VkQueue (with_vk_queue, pinned from then on) never move. A queue's vk_queue
is now an atomic; everything that reads it does so between a command buffer's make and its
completion, when no move can happen.
The self-check (queue_switch_check.rs) is the runtime's own, kept like the in-place check's, not
a DriverFact row: on a thread of its own, once per driver, release and runtime, 24 rounds of two
timestamp-only batches held behind one host-signalled gate on two same-family VkQueues against
24 on one; the switch cost is the difference of the median gaps; Idles above 20 us, DoesNotIdle
below, Unchecked where the device has no calibrated timestamps, no two VkQueues of one family, or
a run failed. Its verdict is written as one record in the shader cache's content directory and
read back as the next device of the same driver, release and runtime is made. Before the verdict,
every queue keeps the VkQueue it took at creation.
Device::new_command_queue_unshared(count): a queue that never moves and that no adaptive queue
joins; a queue already on its VkQueue leaves at its next idle point. Placement where the device
shares: a round-robin VkQueue no command queue holds, least recently used first; else one no
long or unshared queue holds, the fewest queues first; else the round robin's next. Why that
order: an empty VkQueue gives isolation at once, with no wait for another queue's idle point; of
the empty ones the least recently used is the one least likely to hold a moving queue's work in
flight (a queue that just left it may still have batches there, and the unshared queue would
wait behind those); where none is empty, the least held one has the fewest queues to move off,
each at its own next idle point, so isolation arrives soonest, and a VkQueue a long or unshared
queue holds is never taken since that would put the opt-out behind exactly the work it opts out
of. A queue's claim of a VkQueue and an unshared queue's are ordered so that two at once never
both succeed: each counts itself there first, then reads the other's count (SeqCst both sides).
Under PerQueue, and where the device does not share, it is
new_command_queue_with_max_command_buffer_count. A count of 0 and a lost device are refused.
Why: NVIDIA 615.71.09 on the RTX 5080 Laptop GPU leaves the GPU idle 56 to 62 us whenever its
next work comes from another VkQueue, so one VkQueue per command queue, round robin, capped eight
threads' one-draw command buffers at 25,800 to 29,500 a second (GPU idle 60% of its time at the
switches), where one VkQueue ran 54,700 to 58,700 (the audit that set this design). Moving only
at idle points keeps every queue's own order without a cross-queue fence. The cost is the
runtime Degradation kind QueueSharing ("queue-sharing", performance), announced once per device
at the first join, in CommandQueue::command_buffer on the making thread: the first long command
buffer of a queue that shared holds the command buffers committed behind it on its VkQueue for
its whole length. The opt-out exists so a compositor never pays even that one stall.
Counted: WorkCounts::queue_moves, queue_joins, queues_gone_long, long_queue_settles,
queue_moves_off_unshared, joins_withheld_from_unshared, queue_switch_checks_run and
queue_switch_checks_recalled. The policy keys no profile (tests::fast_paths), so
SEMANTICS_VERSION does not move. Docs: FAST-PATHS row, docs/API.md (the policy and the notice
catalogue), the runtime README (the opt-out, with_vk_queue's pin), queue.rs's module doc on
isolation; REFUSALS regenerated (the new site of MaxCommandBufferCount); api_surface and
api_signatures (additions only). The example queue_share runs the workloads under either policy.
Verified: cargo clippy --workspace --all-targets --all-features -D warnings, and the runtime and
validation crates with --cfg m2v_gpu; RUSTDOCFLAGS=-D warnings cargo doc --workspace
--all-features --no-deps; nextest of tests::queue_share (the choice, settling, the unshared order,
the record), tests::fast_paths, tests::degradation*, api_surface, work_counts: 66 passed. On the
RTX 5080 Laptop GPU (release) the check answered Idles at 51.3 us, and its form measured 49.0 to
50.7 us in five more runs, where a chained form measured 53.2 to 59.3 us. The device tests
(tests::queue_share_device, runtime_lane::command_queues::a_queue_joining_...) are not yet run
on a GPU in this commit.
(cherry picked from commit a2f17a5132faf0312fb3953d634e21c927cde62e)
(cherry picked from commit 862b2cb49a9481d0a2a19fb1bc3acec79932d1bd)
|
||
|
|
822263b1b7 |
Hold the precise trig at NaN operands to what its stage records
The owned fixture precise-trigonometric-functions-at-nan-operands-under-fast-math calls precise sin, cos, tan and sincos in a fast-math entry. MoltenVK compiles an entry in one math mode, so those precise calls take their fast forms. On the Apple M3 Max through MoltenVK 1.4.2, sin, cos and sincos of a NaN answer 0 (and other words keep payloads such as ffc00000 or 7fc12345) where Metal answers 7fc00000. The live stage already records PrecisionNote::DeviceTranscendentals and NativeNanEncoding, and the runtime announces both. Apple states no answer at a NaN operand under fast math. The test, though, held every NaN word to Metal's canonical NaN on a profile with MetalCanonicalNans. What changed: - owned_float_fixtures_answer_metal takes the case's notes. A NaN word's bits are the device's where the stage records NativeNanEncoding. A function's answer word (not the operand word, DFL_TRIG_OPERAND) may be a number where it records DeviceTranscendentals. - Each note the answers needed must be recorded. Every recorded note must be announced, checked once over the test's notices, so a once-per-device announcement is not lost between cases. - DeviceTranscendentals' doc (pipeline/artifact.rs) and its docs/API.md entry now say that a NaN operand may answer a number in such an entry. No note is added: the stage recorded both before the change. Verified: runtime_lane::driver_deviations::owned_float_fixtures_answer_metal passes on the Apple M3 Max through MoltenVK 1.4.2 (--cfg m2v_gpu), together with the next commit's minimum rows. (cherry picked from commit 91f122b133c93af4b155a258d088e0001ff55a72) (cherry picked from commit 54a9b15a1fe0a27e8bf9d2a3a236813b9c117347) |
||
|
|
1e44dcf8da |
Drop the call of MSL's empty inline assembly at decode: asm sideeffect "", "" of void ()
What: decode drops a call whose callee is the inline assembly expression `asm sideeffect "",
""` at the call type `void ()`, the way it drops the markers: the call takes a record number
but no instruction. The match is structural and exact:
- the call type is `void ()`, not vararg, with no arguments;
- the template and the constraint string are empty (no operand, result or clobber);
- `sideeffect` is the only flag (no alignstack, inteldialect or unwind).
Any other inline assembly stays an indirect call through its constant. post_check refuses it
as InlineAsm by name where an entry reaches it.
Why: MSL accepts exactly one asm statement, an empty `asm("")` / `asm volatile("")`. A
template, an operand or a clobber is "illegal asm statement" (Metal 32023.922). That statement
always compiles to this call, attributes {convergent nounwind}. It assembles to no
instruction and names nothing it reads or writes. Its `sideeffect` only constrains Metal's
optimizers: they may not remove it or move a memory access across it, and a loop holding it
is kept. A shader generator writes it into loop bodies for that reason. No value a race-free
program computes depends on it. The decode-only refusal of the previous commit still ended
the consumer's VM, so the drop is what fixes their S1. Refusing it would refuse every
pipeline whose generator writes it.
The edge, documented in docs/API.md's accepted differences ("Inline assembly"): a racy spin
loop over plain (non-atomic) memory could tell the barrier is gone, and MSL's memory model
leaves that loop undefined. A loop with a visible effect runs every iteration either way.
The drop records no note and no degrade: it is no precision difference, no value changes.
Fixture: engine/kernel_inline_asm's asm_in_loop now stores every partial sum, the final sum
and its iteration count. The trip count comes from a buffer. All three entries translate.
REFUSALS.md is regenerated: InlineAsm's doc and its reach mark, now `none`, since only
hand-written AIR can hold another asm.
Verified (M3, macOS 27):
- engine_inline_asm, through both llvm-as and xcrun metal-as:
- asm_in_loop, asm_in_helper and asm_free translate, link and validate on all 19 committed
profiles;
- asm_in_loop on the CPU interpreter with n = 6 over 4 threads writes every expected word
in both scheduling orders: every iteration stored;
- synthetic modules with "nop", "~{memory}", an "=r" result, no sideeffect, and alignstack
each refuse as InlineAsm naming the expression; the empty one translates.
- Negative control: with the drop disabled, all three engine tests fail.
- metal2vulkan-air suite: 492 pass.
- metal2vulkan: the air_input, air_canon and air_abi sweeps and the api surface and
signatures checks pass. The text-shape sweep discounts the dropped call, as it does the
markers.
- clippy -D warnings in both configurations.
- Golden printout of kernel_inline_asm re-blessed: only that file.
Still owed a bless on development, new rows only:
- golden_hashes.tsv: the fixture's cells, all new;
- public_fixture_expectations_engine.tsv: 2 fixtures.
SEMANTICS_VERSION stays 1950, landing together with the previous commit.
(cherry picked from commit 53c6faaf4d2215fc3e629b39803f47979d71f765)
(cherry picked from commit f9361582833d1f5ca0c151d42d68e3cfa7e228af)
|
||
|
|
48ec97832d |
Take new textures' pattern reads at the commit, in commit order, not as encoded
What: a command buffer now logs its commands' reads and writes of noted new textures (`fresh_unwritten.rs`'s FreshLog: pass loads, clears, resolves, blit writes and reads, shader reads, and a pass's load of a signed-depth pattern) in encode order, and its commit replays the log against the device's record under one lock, before the scheduler sees it, announcing `fresh-pattern-zeroed`, `device-nan-encoding` (a fresh texture's converted NaNs) and `signed-depth-test` (a loaded signed-NaN depth pattern) there. A command buffer dropped uncommitted takes nothing; a refused commit's log is discarded. With no noted texture a command reads one flag and logs nothing, and a commit reads it once. Why: the record followed encode order, so a queue's command buffers encoded out of commit order (the consumer's host encodes one queue on several threads, then commits in order) announced a read Metal never makes (a load after a committed-earlier clear, encoded first: a precision note the consumer makes fatal) and missed one it makes (a load before a committed-later clear, encoded after it: the texture read zero where Metal reads its pattern, unannounced). Metal runs a queue's command buffers in commit order. Tests: runtime_lane::parallel_encodes::a_fresh_texture_s_pattern_notice_follows_the_commit_order runs two command buffers of depth-only passes (4-sample and single-sample Depth32Float, clear-then-load and load-then-clear) serially and with the later-committed one encoded whole first on another thread, and requires the same notices both ways and Metal's reads of the pattern. Before the fix it failed on the M3 Max (MoltenVK 1.4.2): 1 notice instead of 0, and 0 instead of 1. The same module's a_shadowed_texture_keeps_each_command_buffer_s_bytes (a texture over a Private buffer at 48-byte rows, eight command buffers on four threads) checks every copy and read against its own command buffer's words and prints the copies in. Docs: fresh_unwritten.rs's Observed and Order bullets, the FreshPatternZeroed and SignedDepthTest declarations, docs/API.md's catalogue entries. Verified on the M3 Max under --cfg m2v_gpu: the new test passes; so do runtime_lane's fresh_writes, fresh_contents, depth_denormals, degrade_notices, made_at_creation, texture_blits, renders, sample_copies, nan_resolves, buffer_depth_samples, compressed_blits, color_fills, color_writes, cross_class_storage and half_* modules, and the runtime's tests::fresh_unwritten and tests::heap_tiled (118 tests); degradation_catalogue passes. clippy -D warnings clean for the runtime crate (plain). (cherry picked from commit 95d7bdf6dc8c6e411114b2d9a8203ea1e4970168) |
||
|
|
91cdb80938 |
Say what a YCbCr twin's half sample through a runtime sampler slot rounds to: measured toward zero
What: PrecisionNote::HalfTexelConversion's doc, its docs/API.md catalogue entry, docs/FAST-PATHS.md's
texel-conversion row and the comment where select.rs records the note said a two-plane YCbCr
texture on the grid 8192, sampled through a runtime sampler slot whose word reads one texel,
rounds that texel's step to nearest even. It is the device's rounding of the step's float, and
on MoltenVK 1.4.2 over the Apple M3 Max that is toward zero: runtime_lane::ycbcr_textures'
srgb_twins_read_what_metal_reads measured 8,409 channels of the _sRGB twins over six surfaces and
three matrices, each within one half ulp of Metal's ties-away step (lane commit
|
||
|
|
4837c93ca4 |
Announce decoded-texel-precision at the decoded twin's first read, not at its texture's making
What: a decoded twin whose texels are not Metal's decode exactly (an ASTC LDR form's 8-bit codes, an EAC 11-bit format's 16-bit codes, a 4:2:2 texture's device conversion) announced decoded-texel-precision where its texture was made, though only a sampled view reads the twin: copies, blits, fills and CPU accesses move the carrier's blocks. A consumer that makes notes fatal died on a test that only fills a BGRG422 texture and on one that checks the runtime's fills. How: the twin carries what a read of it announces (TwinRead, made with the twin and with an ASTC carrier's second twin). It is announced, once per device, where a command may first read it: - Texture::bound_view, a command's sampled binding of the texture or a view of it: the set-0 slot path (slot_view, draws, dispatches, tile dispatches) and a heap entry a command names (binding.rs); - heap_sets::bind, the first command that binds a heap set holding the twin's view, named or not (each set keeps its twins by resource ID beside its shadows); - a twin's placement into a heap set whose shared version a command buffer that bound it and has not completed still holds, or whose own version an uncommitted command buffer bound (SetEntry::twin), announced once whatever announce_each says, as a submission may place it on a runtime thread. Placing the view in a heap set uses Texture::held_view, which announces nothing. carried-decoded-twin (performance) is still announced where the texture is made. Docs: degradation.rs's contract, docs/API.md's catalogue entry and docs/FAST-PATHS.md's ASTC and 4:2:2 rows say where it is announced; texture/decoded_twin.rs's and heap_sets.rs's module docs gain the reads. Lanes: texture_fills and texture_blits' mipmaps no longer expect the note at making (twins_carried keeps its carried half alone). Conformance: the allowances of cases that read no twin (texture-fills, chroma-pair copies, texture-pairs-usage-crossings, format footprints) no longer name decoded-texel-precision; the reads' and samples' keep it. Test: tests::twin_reads walks every route on a device of its own (ASTC_4x2_LDR on every device, BGRG422 and GBGR422 where the device converts them): made, written by replace_region and blits, filled, copied and read back announces no decoded-texel-precision; the route's first read (slot read, sample, gather, a view's read, a heap read named and unnamed) announces it once; a twin placed in a set a pending command buffer bound announces as it is made; an ASTC sRGB twin announces nothing and its LDR view's second twin announces at the view's first read. Verified at this commit: tests::twin_reads (3 tests) and ycbcr_device's 4:2:2 test pass on this M3 Max (MoltenVK 1.4.2, --cfg m2v_gpu), walking ASTC4x2LDR, BGRG422 and GBGR422. (cherry picked from commit 37f72d3ffb402ad9afae9571489edbf2b8157442) |
||
|
|
763965c854 |
Record a texture write's NaN encoding only where its stored NaN is not measured to be Metal's
reims-vgpu treats precision notes as fatal on Apple GPUs. A kernel's write of halves into a
32-bit float or RG11B10Float texture died with DeviceNanEncoding, and through NativeNanEncoding,
on the M3 Max where the stored bytes are Metal's; a write of a constant texel with no NaN died
the same way on every device.
What:
- A new DriverDeviation::MetalSmallFloatNans (VkProperty::MetalSmallFloatNans), taken by the
APPLE9 MoltenVK row alone: the device stores a float's or a half's NaN written to a
B10G11R11_UFLOAT_PACK32 storage image as Metal does.
- half_write_nans (a half texel's write) classifies the slot's storage choice: a 16-bit float
format takes MetalHalfTexelWrites as before, a 32-bit float one MetalNanMoves (the widened
half's bits are Metal's 0x7fc00000), the packed small float one MetalSmallFloatNans; a taken
deviation drops the note and requires its property. A slot declared without a format (every
float storage choice on MoltenVK and lavapipe) records the note under the bound format's class
(a SpecializedNote of BoundTexelFormat), one clause per class the profile does not cover, so
the runtime announces it only when such a texture is bound.
- half_storage_facts (a float texel's write) drops the small-float note the same way.
- A texture write of a constant texel none of whose lanes is a NaN records neither note.
- A new module side table, stored_texels, records each texture-family write's texel (kept
through edit.rs's retain and the roll pass's check). narrow::moves_unfolded no longer counts a
widened half's store as such a texel as an escape: the write's own DeviceNanEncoding accounts
for its stored NaN under the format it stores.
Verified on this M3 Max, byte for byte against plain Metal (an MSL probe): a float4 write of
33,792 words (16,446 NaNs) and a half4 write of all 65,536 halves (2,046 NaNs) into RG11B10Float,
RGBA32Float, RG32Float and R32Float store Metal's bytes; into R16Float and RGBA16Float a half
NaN's payload differs (the device stores 0x7e00), so those keep the note.
- runtime_lane::half_write_nans on MoltenVK: half writes into rgba32f, r32f and rg11b10f announce
nothing and 0 texels differ; rgba16f announces device-nan-encoding (2,045 NaNs differ). Without
note_stored_texel the lane fails ("write r32f: ... native-nan-encoding true").
- New core tests: a_half_texel_write_s_nan_into_wide_and_small_float_images_is_metal_s_where_
measured (declared and formatless choices on moltenvk-m3 with and without each deviation, and
lavapipe; the bound-class clauses evaluated per format) and a_constant_texel_without_a_nan_
records_no_nan_encoding (zero and 0x7e00 constants, every committed profile); the existing
device-nan-encoding and half-storage-notes tests follow the deviations. Each fails with its
change disabled (the NaN test forced true; the stored-texel exemption removed).
- Notes of every public fixture on moltenvk-m3, lavapipe and nvidia-rtx5080-laptop before and
after: DeviceNanEncoding leaves 65 moltenvk-m3 rows and 6 rows on each other profile (constant
texels), 17 formatless rows per profile go from unconditional to specialized by bound format,
58 moltenvk-m3 rows lose their small-float clause, NativeNanEncoding leaves 11 moltenvk-m3 rows,
and no row gains a note. Consumer AIR on moltenvk-m3: DeviceNanEncoding 33 entries to 21,
NativeNanEncoding 9 to 5.
Docs: API.md (device-nan-encoding and native-nan-encoding exemptions), HOWTO.md, the
PrecisionNote, VkProperty and deviation rustdoc, the driver-facts measurement record.
api_signatures gains the two variants. The versions bumped in the previous commit cover this one.
(cherry picked from commit 05d96c61107989813c186961087ee70d573cf876)
|
||
|
|
217cc233f5 |
Carve MoltenVK on the M3 Max's identity out of NativeHalfConversion for measured conversions
reims-vgpu treats precision notes as fatal on Apple GPUs; NativeHalfConversion was its largest group of Mac-only failures (37 tests). The note says a half rounded through the device's conversion to 16 bits and back may differ from Metal's. On the M3 Max (MoltenVK 1.4.2, macOS 27.0.1), MoltenVK writes OpFConvert to 16 bits as MSL half(x), which is Metal's half(float), and Metal's compiler folds the conversion of an image instruction's float texel into the access. What: a new DriverDeviation::MetalHalfConversion (VkProperty::MetalHalfConversion), taken by the APPLE9 MoltenVK row alone. Where the profile takes it: - narrow::round_measured rounds a float the function holds (an AIR fptrunc or air.convert from float, through resize) by the conversion pair and records the pair's narrowing in a new module side table, measured_roundings (kept through edit.rs's retain and the roll pass's check); - narrow::rounds_unmeasured finds any other conversion pair: one neither recorded nor of a texel an image read, fetch, sample or gather hands back (directly, through a composite extract, or through a parameter every call passes such a texel); - the compile records NativeHalfConversion only where such an unmeasured pair exists, and otherwise requires the property. A half operation or function computed in float and rounded keeps the note: Metal's half tanh answers 7 of the 65,536 halves otherwise than the conversion of its float tanh. exp, sqrt and a reciprocal on half matched, but they are functions, not the conversion, so they stay noted. Verified on this M3 Max, word for word against plain Metal (an MSL probe, fast and safe math): - the conversion of a float loaded (425,216 words), of a sum, product and quotient (144,896 pairs each), of an fma (123,648) and of an integer's quotient (190,208): 0 words differ; - the half result of read, nearest sample at the centre, linear sample a quarter texel off and gather of every texel of ten formats (RGBA32Float, RGBA16Float, RGBA8Unorm and its sRGB twin, RGBA8Snorm, RGBA16Unorm, RGBA16Snorm, RGB10A2Unorm, RG11B10Float, RGB9E5Float): 0 differ. - New lane runtime_lane::half_conversions on MoltenVK: load, sum, product and fma kernels carry no note and 0 of 253,958 lanes per kernel differ from the half model; the half tanh kernel keeps the note. With measured_conversion forced false the lane fails. - New core test half_conversions_are_metals_where_measured: the four forms lose the note and require the property on moltenvk-m3 with the deviation, keep it without the deviation, and the half tanh keeps it on both; it fails with the carve disabled. - Notes of every public fixture on moltenvk-m3, lavapipe and nvidia-rtx5080-laptop before and after: NativeHalfConversion leaves 58 moltenvk-m3 rows, and no row gains a note. Consumer AIR on moltenvk-m3: 23 entries noted before, 2 after (a heap texture's held half read). Docs: API.md (native-half-conversion exemption), HOWTO.md, the PrecisionNote, VkProperty and deviation rustdoc, the driver-facts measurement record. SEMANTICS_VERSION 1949 and ARTIFACT_FORMAT_VERSION 484 (new VkProperty variants in the codec); these bumps cover the rest of this branch. api_signatures gains the two variants. (cherry picked from commit 266f7cd26327e408d9cd1f0d6ea5ba33e49e10b3) |
||
|
|
4b194d24af |
Write Metal's encoding through compressed BGRA10_XR blits under an exact-answers switch
What: a new DevicePolicy switch, `extended_range_blits` (ExtendedRangeBlitPolicy::Kept, the default, and ::Canonical, which `exact_answers()` selects). Under Canonical a blit or fill through a BGRA10_XR or BGRA10_XR_sRGB texture Metal keeps losslessly compressed writes Metal's canonical encoding: each 16-bit field's low six bits cleared and, for a blit, the alpha code clamped to [384, 894]. - bind::extended_canonical_module, a compute kernel that rewrites a texel range's words in place (bind/extended_canonical.rs, with extended_range_canonical as its reference and interpreter tests); the runtime owns it as OwnedModule::ExtendedCanonical. - The runtime (extended_canonical.rs): after a blit into such a texture, or out of one into another texture of the format, the written regions go out to a scratch buffer, one dispatch per region rewrites them, and they go back; after a blit out of one into a buffer, or into a texture over a buffer's bytes, one dispatch rewrites the words in place at the layout's rows. A fill's texel is encoded before it is written (fills clear the low bits alone: Metal's fill keeps alpha codes 4 and 1023 on the M3 Max under 27.0.1). A buffer the device cannot bind (offset or pitch off 4, past maxStorageBufferRange) or a texture over a buffer whose rows share bytes keeps the bytes and announces extended-range-bits-kept, as under Kept. Under Canonical the note is not announced for the blits it makes exact. - copy_from_buffer_to_texture's body moved into buffer_into_texture, which a fill's row copies call with Writer::Fill (so a fill announces its own wording and is never rewritten as a blit). Why: Metal's GPU blits through the compression rewrite these bits (measured on the M3 Max under macOS 27.0.1, plain Metal, xr_matrix: compression iff allowGPUOptimizedContents, shorter side >= 16, neither ShaderWrite nor PixelFormatView usage; every storage mode alike; CPU copies keep the bytes; fills clear the low six bits only). The device's copy keeps the bytes. It is the runtime's choice, not a native answer (no device arithmetic is involved: a copy's bytes), so per rule 1 the fast form stays the default and the exact form is the switch. Ledger: FAST-PATHS row (fast defaults), API.md section 1 bullet and the extended-range-bits-kept catalogue entry, the Degradation doc, the conformance Policy doc. Known gaps: the 28 rows of compressed-blits-bgra10xr and -srgb (7 sites x 2 formats x Apple M3 Max and llvmpipe) dropped: under the suite's exact policy those sites now hold Metal's bytes. RUNTIME_VERSION 1728 -> 1731 (a run under the exact policy writes other bytes). Also fixes forward a clippy needless borrow in engine_arith's pack test (7a99b93af2). Verified (M3 Max, macOS 27.0.1, MoltenVK 1.4.2; and lavapipe in scripts/linux-gate, arm64, LLVM 21.1.8 128 bits): - runtime_lane::compressed_blits on MoltenVK: both tests pass; the new extended_range_blits_write_metal_s_encoding_under_the_canonical_policy checks every direction, level 3 into padded rows, Shared CPU/blit mixes, texture to texture both ways, a fill of a compressed and a plain texture, and a copy into a texture over a buffer with padded rows, under both values (Canonical: Metal's bytes and no notice; Kept: the bytes and the notice once). - conformance replay of the four compressed-blits cases on MoltenVK: exit 0, the ledger as edited (bgra10xr and -srgb `announced` only for staged-texture-copy/shadowed-texture). - the full `conformance replay --cpu` on lavapipe at 68074019a3 and at this change: the only difference is the 14 llvmpipe sites of the two XR cases, which no longer diverge (divergent 244 -> 242, exact 458 -> 460); the 265 other ledger mismatches of that arm64 venue are the same at both (it is not CI's amd64 lavapipe). - 154 touched validation lanes on MoltenVK (blits, fills, extended-range, NaN, pack, padded, rotated, no-copy, two-plane heap): 143 passed, 10 failed, 1 ignored; the same 10 fail with the same messages and the same differing texels at 68074019a3 (pre-existing). (cherry picked from commit 612ff50b86bc29515b158d9b2596b14a45431467) |