a7672e9864ef00a5f16b5176bc5682fee9e495ae
1039
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
a7672e9864 |
Lane-test ASTC HDR textures against Metal's decode on the device
New runtime_lane::astc_hdr_textures (any(m2v_gpu, m2v_cpu_icd)): - astc_hdr_texels_read_as_metal_s: each of the fourteen _HDR formats, natively where the device holds its SFLOAT block, else through the carrier and twin. A new texture's zero blocks, then blocks from a CPU copy, a blit from a buffer, a fill of an HDR void-extent block and a copy from another texture: every texel's read and nearest sample compared with the decoder's Metal values (exact, NaN as NaN) where the twin carries them or the device samples through Metal's own texture unit; get_bytes and a blit into a buffer give the blocks back unchanged. It counts the decode passes, asserts carried-decoded-twin was announced exactly for the carried formats and decoded-texel-precision never, and prints which route ran. - astc_hdr_textures_of_every_usage_are_made: an ASTC8x8HDR texture of read, write, render-target and pixel-format-view usage is made; a render pass into it is refused Unsupported and a kernel's write of it refused typed (Bind or Unsupported), where Metal's validation stops both; a view in the LDR form is refused on a carrier and otherwise reads the LDR decode of the same blocks. The ASTC LDR lane's helpers it shares become pub(super). Verified (which path each ran, from the lane's printed route line): - MoltenVK on the M3 Max (--cfg m2v_gpu, through the GPU lock and memcap): both pass; 14 formats in their own block, Metal's sampler. - lavapipe (scripts/linux-gate, --cfg m2v_cpu_icd): both pass; 0 in their own block, 14 in a carrier. - The other five ASTC lanes pass on both devices. (cherry picked from commit 9193d3e09fc1e0366e55035fcb29a81b9245ffe5) |
||
|
|
7130d5d6e7 |
Make ASTC HDR textures where Metal makes them: native, else a carrier with a twin of halves
Metal on an M3 Max (macOS 27.0.1) makes every 2D ASTC HDR texture (MTLPixelFormat 222-236) with read, write and render-target usage; the runtime refused them on every device without the Vulkan SFLOAT block (the RTX 5080 among them) as a format it cannot hold. - Translator: bind::AstcDecode decodes the HDR profile, written from the Khronos Data Format Specification's ASTC chapter (new hdr.rs): HDR endpoint modes 2, 3, 7, 11, 14 and 15, the LNS-to-half mapping, LDR modes and void-extent blocks in an HDR texture, and the HDR void extent, on the CPU and in the GPU decode kernel (kernel/hdr.rs). Where the probe showed Metal's own answer it is the one taken: an LDR channel in the HDR profile is C/65536 truncated to a half (1 for 65535); a void extent's NaN halves read as the quiet NaN; an error block reads NaN in every channel. Public API: AstcDecode gains `hdr`, AstcTexels gains `Half` (R16G16B16A16_SFLOAT), AstcDecode::form picks a profile's compact form, and AstcDecode::texel_bytes is now a method (a consumer calling AstcDecode::texel_bytes(texels) writes decode.texel_bytes(texels)); api_signatures.tsv blessed. - Format table: each ASTC HDR format takes its ASTC_*_SFLOAT_BLOCK where the device holds it (the device's decode, rule 1), else FormatEmulation::Decoded over R16G16B16A16_SFLOAT. - Runtime: such a texture is the existing carrier (its 16-byte blocks, which copies and getBytes move unchanged) and a decoded twin of Metal's halves, exact, kept in step by the same GPU and CPU decodes; a new texture's twin starts at the error block's NaN. Notices: carried-decoded-twin and cpu-block-decode, as for ASTC LDR; no decoded-texel-precision (the halves are Metal's). A view in another profile (an HDR texture's LDR or sRGB view, or the reverse) is refused on a carrier (Feature::TextureView, as another footprint is); render passes into one and kernel writes of one stay refused typed (the Vulkan formats take neither), where Metal's validation stops each. - Docs: API.md's carried-decoded-twin entry, FAST-PATHS known gaps, module docs of bind::astc_decode, astc.rs and decoded_twin.rs. - Conformance: the 42 ASTC cases now name the twin notices for HDR rows too, and the decoder cross-check holds Metal's recorded HDR reads. Versions: RUNTIME_VERSION 1720 (an HDR texture is now made and read where it was refused). No SEMANTICS_VERSION or ARTIFACT_FORMAT_VERSION bump: translation output is unchanged (the Decoded candidate admits sampling usages only, so no pipeline's format answer moves) and no encoded artifact carries AstcDecode. Runtime-sources pin recomputed. Verified: - CPU decode bit-exact against Metal for 2048 seeded blocks of each of the fourteen footprints (every endpoint mode, partitions, dual plane, void extents, error blocks), as float and half reads and nearest samples (probe `reads`), checked by per-footprint digests and a 66-block fixture of Metal's float bits (bind::astc_decode::tests::hdr); the GPU kernel equals the CPU decode on every texel; the kernels are valid on every committed profile; the conformance suite's recorded astc-*-hdr reads equal the decoder's. - Plans: moltenvk-m3 native for all 14; nvidia-rtx5080-laptop, lavapipe, amd-780m-radv and intel-arl-anv in a carrier (runtime tests::image_plan). - conformance replay of the 42 ASTC cases on lavapipe (linux-gate, --cpu): the 14 HDR rows `announced` (texels exact, carried-decoded- twin and cpu-block-decode fired), exit 0; on MoltenVK the 14 HDR rows `exact` with no notice. - Touched tests in metal2vulkan, metal2vulkan-runtime, metal2vulkan-conformance; clippy (plain and --cfg m2v_gpu); refusal_surface --check, both coverage docs current; private intra-doc link loop at its ceilings. (cherry picked from commit eb6828adddde978fab87dc7d05ea1a2a55738008) |
||
|
|
69f4ad114c |
Probe what plain Metal does with ASTC HDR textures
A from-scratch Objective-C probe of MTLPixelFormat 221-236 (the _HDR form of every footprint), one case a process: - create: which descriptors make a texture, by texture type, storage mode and usage (ShaderRead, ShaderWrite, RenderTarget, all three); each descriptor in a child process, since Metal ends the process at some (1D and multisample compressed textures) even without validation. - reads: each texel's read as float4 and as half4 and its nearest sample of self-encoded blocks written by replaceRegion, through an optional view of another raw format. - zero, bytes: a new texture's texels; getBytes and blit round trips. - render, write: a pass storing a clear and a draw into one, and a kernel writing one, and what the blocks hold after. Measured on an Apple M3 Max, macOS 27.0.1, run through the Mac GPU lock without MTL_DEBUG_LAYER. The answers are stated in the module docs the following commit writes (bind::astc_decode, the runtime's astc.rs): every 2D HDR texture is made with read, write and render-target usage; reads are half-precision values, exact as float and as half; render passes and kernel writes are stopped by Metal's validation, and plain Metal's pass stores nothing while its write leaves bytes no format defines. (cherry picked from commit b5e51a65272a2f5db0e73dc50070082054d3e064) |
||
|
|
498163f1ad |
Mend two private doc links this effort broke
CI's private intra-doc link step holds each crate to its ceiling; the lane was over two of them. - metal2vulkan-air (4, ceiling 3): `const_taint`'s doc linked `entry_block_refusal`, which the undefined-constant change removed. It now names `Solver` alone, its one user. - metal2vulkan-runtime (71, ceiling 70): a redundant explicit target on `Problem::UnspecializedFunction` in `Library::new_function_with_name`'s doc, added with the by-name refusal. Verified: the step's loop run locally over all six crates (rustdoc --document-private-items, -Dwarnings): metal2vulkan 0, air 3, runtime 70, validation 0, conformance 0, devtools 0, each at its ceiling. The runtime-sources pin covers both files: recomputed (7f8ad7d3) and the_runtime_sources_are_the_committed_ones passes. (cherry picked from commit 7da81ee3d8a80992e65167ff1d2c315bd10715c6) |
||
|
|
4aac27a548 |
Ask supportsPullModelInterpolation in the lane's query census
runtime_lane::capabilities asks every Query::ALL member of the lane's device and panicked on Query::PullModelInterpolation, a query it did not ask. It now asks it, as it asks supportsSamplerReductionMode: an answer, no gap. Verified on the M3 Max (MoltenVK 1.4.2) through the Mac GPU lock, --cfg m2v_gpu: runtime_lane::capabilities, msaa_32bit and pull_model_interpolation 8/8. (cherry picked from commit a27c863842433fa94ee6ece8ffebd5db2e880077) |
||
|
|
b2625d5688 |
Name GraphicsState::interpolates_at_sample's source without a private link
The field's doc linked crate::pipeline::Sampling::Interpolant, which is not public (pipeline::stage_io is crate-private), so public rustdoc failed on a broken intra-doc link. The doc names the stage interface's sampling in plain code instead. Verified: RUSTDOCFLAGS='-D warnings' cargo doc -p metal2vulkan -p metal2vulkan-air -p metal2vulkan-runtime --all-features --no-deps is clean; the runtime-sources pin is unchanged (pin-compute.py). (cherry picked from commit 313d45dc1cf18685f5d0efd9722e3ceb98fc3796) |
||
|
|
81441ca877 |
Regenerate the surfaces for pull-model interpolation
- RUNTIME_VERSION 1719: the runtime answers supportsPullModelInterpolation and refuses a draw reading an interpolant at a sample at custom positions. - scripts/metal-coverage/coverage.tsv: supportsPullModelInterpolation implemented (DeviceProperties::supports_pull_model_interpolation); docs/METAL-COVERAGE.md and docs/CONFORMANCE-COVERAGE.md regenerated. - docs/REFUSALS.md regenerated: feature::PullModelInterpolation and gap::InterpolateAtSampleWithPositions (reach rows in reach.tsv). - crates/metal2vulkan/tests/api_signatures.tsv blessed: additions only but Query::ALL's length (8 to 9) and value. - crates/metal2vulkan-runtime/README.md: the query and what differs. - runtime-sources pin recomputed (pin-compute.py). Verified: refusal_surface.py --check, signatures.py --check, metal-coverage --check and conformance-coverage --check all current. (cherry picked from commit 2dcbbf39b6e5caeb3e87079d7f2f36540ceb0dd0) |
||
|
|
a8af53b32a |
Answer supportsPullModelInterpolation and refuse sample reads at custom positions
The runtime had no answer for supportsPullModelInterpolation (the M3 Max, a Radeon Pro 5300M and a UHD 630 answer 1), so the consumer passed none. - DeviceProperties::supports_pull_model_interpolation (Query:: PullModelInterpolation) answers yes where the compile layer lowers every interpolation function: DeviceProfile::interpolation_function_needs is empty (sampleRateShading, and MoltenVK's shaderSampleRateInterpolationFunctions), the same predicate the lowering refuses by. - A draw at custom sample positions through a pipeline whose fragment function reads an interpolant at a sample (GraphicsState::interpolates_at_sample) is refused NotImplemented(RuntimeGap::InterpolateAtSampleWithPositions) in settle_draw, which direct and indirect-command draws share: Vulkan takes no InterpolateAtSample in a pipeline made with custom sample locations (VUID-VkGraphicsPipelineCreateInfo-sampleLocationsEnable-01524), and Metal's answer there is not measured. Tests: - runtime tests::capabilities: every committed profile answers from the enabled features; every venue (moltenvk-m3, both lavapipe gates, 780M RADV, both ANV, RTX 5080) answers yes; vk12-floor no; moltenvk-m3 without the portability member no; every query answers on moltenvk-m3. - validation runtime_lane::pull_model_interpolation (--cfg m2v_gpu or m2v_cpu_icd): the probe's lane draws (one triangle of w 1, 2, 4 over 6x6, at 1 and 4 samples: center, centroid, each sample, sample_id, five offsets, the float2/float/half and half4 interpolants) against Metal's reading pull_model_interpolation_m3_max.txt, every sample's coverage equal; word for word where the profile takes MetalInterpolation, else within the device's interpolation plus the location Vulkan leaves to it; the offset pipelines alone record DeviceInterpolationOffset and require the device's origin property. A pm_sample draw at custom positions is refused; a pm_offset draw there runs. Verified on the M3 Max (MoltenVK 1.4.2, macOS 27.0.1) through the Mac GPU lock: 25 draws, 14 samples at 1x and 55 at 4x each, every word Metal's (most apart 0); the refusal and the offset draw at custom positions as stated. Negative control: the MoltenVK origin set to 1/2 put every offset draw 0.06 to 0.11 off Metal's. Not run on lavapipe here (no container runtime up); CI's lavapipe lane runs it. Runtime capabilities, degradation and families tests 47/47; clippy all features and --cfg m2v_gpu. (cherry picked from commit e9f45f7c85309ba6d1e6bc57f3b10fd47585893e) |
||
|
|
ef7a8d6f08 |
Lower Metal's pull-model interpolation (interpolant inputs)
A fragment function reading an `interpolant<T, P>` input through
interpolate_at_center, _centroid, _sample or _offset was refused as invalid
input (the AIR key air.interpolation_function was unknown), so a guest whose
device answers supportsPullModelInterpolation could not run one.
AIR: the key marks a fragment input `Sampling::Interpolant`, a device-space
handle (`AbiHandle::Interpolant`); `air.interpolate_{center,centroid,sample,
offset}_{perspective,no_perspective}.{f16,f32 x1..4}` parse as
`AirIntrinsic::Interpolate`, decided from the intrinsic family and the
metadata ABI, never names.
Lowering: the interpolant is a float Input variable of its form (NoPerspective
where not perspective), read only through its calls:
- center: as a center varying is read (its pixel-center form at more than
one sample where the device has one);
- centroid / sample / offset: GLSL.std.450 InterpolateAtCentroid,
InterpolateAtSample (index & (SampleCount - 1), Metal's i mod n) and
InterpolateAtOffset (offset moved to the device's origin and NClamped to
[minInterpolationOffset, maxInterpolationOffset], which Vulkan requires).
These need sampleRateShading (and MoltenVK's portability member): without
them the function is refused Unsupported(PullModelInterpolation).
- MoltenVK's SPIRV-Cross hands InterpolateAtOffset(v) to Metal as
interpolate_at_offset(v + 7/16): such a device gets the new
VkProperty::InterpolateAtOffsetFromSevenSixteenths and the module moves
the offset by 7/16 (a module annotation picks the property).
- An interpolant used any other way (a select of two) stays
NotImplemented(PullModelInterpolation); on RADV
(InterpolationNeedsTheWholeQuad) a sample or offset read after a discard
or outside the first block is refused; lavapipe refuses a multisampled
centroid read as it refuses a centroid varying.
- GraphicsState::interpolates_at_sample states a fragment stage that reads
at a sample (Vulkan takes no InterpolateAtSample with custom sample
locations); Sampling::Interpolant carries center/centroid/sample.
Metal measured on the M3 Max, macOS 27.0.1, with the new probe
probes/pull_model_interpolation.m over the owned fixture
pull_model_interpolants (cases origin, grid, samples, centroid, lane): an
offset is read from the pixel's corner as given, no range, no grid, NaN for
a non-finite one; sample i reads i mod n at Vulkan's standard positions;
centroid is the center when the pixel is covered whole, else the lowest
covered sample. The offset's range and grid are the device's:
PrecisionNote::DeviceInterpolationOffset (validation: Recorded), in
docs/API.md's catalogue and FAST-PATHS.md's device gaps; a centroid read
notes MultisamplePosition as a centroid varying does.
Verified: tests::engine_pull_model (309 pipelines over every committed
profile at 1 and 4 samples: instructions, mask's planned SampleCount,
origin, NClamp, note, property, L3; refusals on vk12-floor, RADV after a
discard, lavapipe centroid at 4x; pm_selected refused everywhere),
engine_multisample, engine_fragment, engine_coverage_loop, fast_paths,
api_tests, codec and cache tests, metal2vulkan-air abi/intrinsics tests and
api_surface; runtime degradation and catalogue tests; clippy all features.
Before: every pull_model_interpolants function failed InvalidInput
(Abi(UnknownKey)). Goldens: only new rows and the moltenvk-m3 profile hash
moved (its new property); inventory 24 new rows, 0 moved cells.
SEMANTICS_VERSION 1941 (refusals became translations), ARTIFACT_FORMAT_VERSION
481 (IoSampling, PrecisionNote, VkProperty and GraphicsState encodings).
(cherry picked from commit 70e01b4bd6f8a0d1421ae07ed710714fb4ce985b)
|
||
|
|
ceb666187a |
Answer Metal's supports32BitMSAA from the device's own textures
The runtime had no answer for supports32BitMSAA (METAL-COVERAGE listed it missing), so the consumer passed None through. Metal's answer promises a multisample texture of each 32-bit integer format and the resolve of each 32-bit float one; the M3 Max, a Radeon Pro 5300M and a UHD 630 all answer 1. What the runtime did before was read first: a multisample texture of each of the nine formats is planned as any texture is (image_plan), within the device's limits for the image (vkGetPhysicalDeviceImageFormatProperties2), and refused as a count its format lacks; draws and texture2d_ms reads of it, the float formats' AVERAGE resolves (Metal's own on MoltenVK, device-rounded-resolve elsewhere) and the refusal of an integer resolve (ResolveFormat, as Metal stops it) were all in place. The render pipeline, sample planes and interleave all take a format's own counts beside framebufferIntegerColorSampleCounts. Nothing was wrong; the query was missing. Device::supports_32bit_msaa answers yes where the device makes every texture and resolve the answer promises, each probed exactly as pixel_format_capabilities probes a capability (the probe closure of families::formats::answers is now a function both share): the texture sample counts hold 4, a 2D multisample RenderTarget|ShaderRead texture of each of the nine formats is made at every count above 1 the textures take, and each float format resolves (its Resolve capability). A device method, as supports_family is, because it reads the device's per-format limits: Vulkan floors an integer format at framebufferIntegerColorSampleCounts, one sample on RADV and lavapipe, while their 32-bit integer formats each take 1 to 8 (1, 4, 8 on lavapipe), as the venue profiles' captured per-format counts state. Tests: - runtime tests::msaa_32bit: every committed profile pinned, with the limits it states (a venue profile's own per-format color attachment counts, else Vulkan's floors). Yes on every venue (moltenvk-m3, both 780M RADV, both gate lavapipe, the ANV and NVIDIA ones) and on the Intel and NVIDIA profiles whose floors cover the counts; no on amd-rdna2/rdna3-radv, lavapipe, lunarg-desktop-baseline-2023, swiftshader and vk12-floor (R32Uint at the lowest count, naming FramebufferIntegerColorSampleCount), and roadmap-2022 (no 4 samples). A yes agrees with each format's Msaa and float Resolve capabilities; the rule needs 4 and every count, and a missing resolve texture says so. A negative control that probes 4 samples alone fails two of them. - validation runtime_lane::msaa_32bit (--cfg m2v_gpu): the answer is what the device makes; R32Uint and RGBA32Uint targets at 2 and 4 drawn at sample rate hold every bit, read back through texture2d_ms<uint> (Metal: every channel as written); an RG32Float 4-sample target keeps its samples and resolves to the probe's Metal texels, exact where the driver's average is Metal's; an RGBA32Uint resolve is refused. Verified: runtime tests msaa_32bit, families and capabilities, the metal_coverage and runtime-sources pin tests; on the M3 Max (MoltenVK 1.4.2, macOS 27.0.1) through the Mac GPU lock, runtime_lane msaa_32bit, families and capabilities 7/7: supports32BitMSAA true, counts [2, 4], nothing refused, 0 integer channels differ, 32 of 32 resolved channels as Metal's, device-rounded-resolve not announced. clippy with all features and with --cfg m2v_gpu, rustdoc -D warnings, refusal_surface --check (no refusal moved), api-signatures (one method added), METAL-COVERAGE and CONFORMANCE-COVERAGE regenerated (the item now implemented, not yet exercised by the suite). RUNTIME_VERSION 1718 (a new answer); runtime sources re-pinned. (cherry picked from commit 2376157b3bf7bf99221579f42a795ef351b8144c) |
||
|
|
90622adb95 |
Probe Metal's 32-bit multisample textures and float resolves
A probe, written from scratch, of what Metal answers behind
supports32BitMSAA, one shape per process:
- query: supports32BitMSAA and supportsTextureSampleCount:.
- make: a 2D multisample RenderTarget|ShaderRead texture of each of the
nine formats (R32Uint, R32Sint, RG32Uint, RG32Sint, RGBA32Uint,
RGBA32Sint, R32Float, RG32Float, RGBA32Float) at 2, 4 and 8 samples.
- int-samples: a draw at sample rate writes every sample of an integer
target (edge words 0x7fffffff, 0x80000000, 0xffffffff, 0x01000001 and a
hash), read back through texture2d_ms<T>::read.
- float-resolve: a float target drawn the same way with special values
(order-dependent sums, NaNs with payloads, infinities, a denormal input
and a denormal average, signed zeros, an overflowing sum) and
pseudo-random ones, resolved by StoreAndMultisampleResolve or
MultisampleResolve into a texture of its format, compared with the
rule runtime_lane::resolve_rounding states.
- int-resolve: an integer target's resolve.
Measured on the M3 Max under macOS 27.0.1, plain Metal through the Mac
GPU lock:
- supports32BitMSAA 1; supportsTextureSampleCount 1, 2, 4 yes, 8, 16 no.
- Every one of the nine formats made at 2 and 4 samples; at 8 Metal stops
it ("sampleCount (8) is not supported by device").
- int-samples: 0 channels differ from those written, every integer format
at 2 and 4 (RGBA32Uint at 4 also with MTL_DEBUG_LAYER=1).
- float-resolve: 0 channels differ from the rule (the samples summed in
order in float from sample 0, denormals flushed to the zero of their
sign, a NaN anywhere 0x7fc00000), each float format at 2 and 4 under
both store actions; the stored samples are bit for bit those written.
- int-resolve RGBA32Uint 4: with the validation layer, "PixelFormat
MTLPixelFormatRGBA32Uint cannot be a MSAA resolve target"; plain Metal
writes words no sample holds.
(cherry picked from commit f18cf358da5419ceb41896975ad447ea42cff77a)
|
||
|
|
03264ce9c2 |
Pace the CPU writer of the copied-log race test
tests::copied_log::a_cpu_write_the_gpu_did_not_make_survives_both_ways_logged_or_not spawns a thread that writes one byte of the pages and tells the test log of it in a tight loop, while the main thread runs 2000 rounds of merge back and copy in. TestLog keeps every write it is told, and each copy in asks it for the writes since a stamp by scanning them all, so the run time grew with the square of how far the writer outran the rounds. It took 28 s to 749 s across recent gates and timed out at nextest's 1200 s limit under an outside load of about 30 (a sample showed every stack in TestLog::changed's scan). The writer now sleeps 20 us after each write it tells. Each write is still told right after it is made, so the last write is always logged, and the writes still race the copies; the log stays bounded by the test's length. Verified: the test passes in 0.085 s under a load average of 51, twice. The runtime-sources pin is unchanged (79fe4b2f). (Carried to development from steelbrain/reims-graphics-kext 130513884f.) |
||
|
|
6f8ec46671 |
Draw a draw whose own band the translator refuses at the nearest width
A draw whose own band variant the translator refuses where the state's
first band compiled (a varying or push data the draw's variant adds, such
as a shader-side depth test's window depth and depth range, past
maxTessellationEvaluationOutputComponents or maxPushConstantsSize) was
refused with the translator's Unsupported(WideLines). Only its later
draws took the nearest width. That breaks the owner's rule that an
accuracy note is logged and never fatal: the draw can run at the nearest
width.
The draw now takes the nearest width, announced as a state's refusal is
(lines-at-nearest-width, the translator's refusal the reason). The
refusal is still kept per state and primitive (GraphicsState::refuse_band,
two answers a state). A draw's variant key follows from its bind shape,
and its route sets that shape, so a per-key memo would need the shape
before the route. Recording a draw factors what its lines' route decides
(the route, provoking vertex, listed strip, private form, settings) into
RenderLowering::routed_draw and a RoutedDraw. draw_resident settles in a
loop. Where the settle answers the translator's refusal of the draw's band
(LineRoute::refused), it marks the state's primitive refused and routes
the draw again. Routed again it draws no band of the primitive, so it
settles once more at most. settle_draw hands that refusal back to the
caller before its snapshot and shadow retries, as before.
Docs: line_width.rs, the runtime README, FAST-PATHS's known gap, API.md's
and degradation.rs's lines-at-nearest-width (no refusal named any more).
REFUSALS.md does not move (refusal_surface --check passes): the
translator's refusal stays. RUNTIME_VERSION 1717 (a refusal became an
announced draw); runtime sources re-pinned.
Verified: the new pure test
a_draw_whose_band_the_translator_refuses_takes_the_nearest_width covers
every committed profile under both policies, lines and edges, widths 0 to
16. Each band route takes either refusal (not implemented, and the
evaluation-output limit) as its primitive's. Routed again, it is the
nearest width with the refusal as the reason, or the device's lines, and
never a band. A non-WideLines refusal or a runtime gap stands. It does
not compile against be2d725fdb, which had no such decision. A negative
control that drops the decision for lines fails it ("amd-780m-radv,
Device, Lines at 0: left None, right Some(Lines)"). Runtime line_width
tests 4/4 pass. Also clean: clippy with all features and with
--cfg m2v_gpu, refusal_surface --check, the runtime-sources pin test.
Not run: the GPU lane. No draw on MoltenVK reaches this cheaply: the base
key's band and a draw's differ only by shader-side tests' additions or
push data. The orchestrator's gate covers the restructured draw path.
(Carried to development from steelbrain/reims-graphics-kext 06f08298fd.)
|
||
|
|
b3d483fd72 |
Draw triangles' wide edges as bands, and refused bands at the nearest width
Metal draws a triangle in fill mode Lines at a width other than 1 as its three edges, each the line parallelogram, facing as the triangle does and culled by it, its flat inputs from the provoking vertex (the probe's `edges` case, committed with the lane before this). The runtime drew those edges with the device's lines, at the nearest width they draw (1 pixel on MoltenVK), announced. Translator: the band variant takes a primitive (`BandPrimitive`, in `VariantKey::line_band`, `LineBandState::primitive`, `BindState` and `BindShape::line_band`). A triangle's patch is its three vertices in the quad domain at outer levels (11, 1, 6, 1) and inner levels (3, 2): the inner ring degenerates to a segment, so the spec's deterministic fans from its two vertices cover the u = 0 and u = 1 edges, and the evaluation stage places those fans' vertices at the corners of the edges' parallelograms (from the vertex of the largest w, which never moves at the near plane), every other triangle degenerate. The band faces as the triangle (the sign of its homogeneous determinant, a zero-area one back) by turning the minor axis, so the draw's own cull mode, front face and depth bias apply. `LineBandState::PATCH_CONTROL_POINTS` gives way to `BandPrimitive::patch_control_points`. A pure test checks the fan tables against the spec's triangulation: every triangle is degenerate or one of the nine that cover the parallelograms once, and each winds as a line's band, turned by the facing. Runtime: a triangle's edges (lists, strips, fans, Metal's private triangle types) route as lines do: the device's lines where they draw the width, else the band, on every device with tessellationShader; strips are listed, the last provoking vertex read from the list led by it. The band's depth bias is the device's per band triangle: announced (new `Degradation::WideEdgeDepthBias`) under a slope factor or a constant over a float depth. A pipeline state whose band variant the translator refuses (barycentric weights, a selected slice or viewport, synthesized geometry, multiview, too many outputs) now draws its lines and edges at the nearest width, announced with the refusal as the reason, instead of failing the draw: the state's first band compiles the variant of its base key and remembers a refusal per primitive (`Unrouted::Refused`). Mesh draws and tessellated patches keep the nearest width. Docs: line_width.rs, band.rs, the runtime README, FAST-PATHS (row and known gap), API.md (band variant, catalogue), REFUSALS.md regenerated; api_signatures blessed (BandPrimitive added, LineBandState::PATCH_CONTROL_POINTS removed, the three line_band fields now carry the primitive). SEMANTICS_VERSION 1940, RUNTIME_VERSION 1716; runtime sources re-pinned. Verified (M3 Max, MoltenVK, --cfg m2v_gpu, maclock and memcap): runtime_lane::line_widths 7/7 pass under both policies; 148 cases, 145 drawn as Metal's pixel for pixel, 28 of the 31 wide edge cases (facing, culling, zero-area, strips, flat IDs and primitive IDs at both provoking modes, depth across an edge, 4 samples), the other 3 the depth-bias edge cases, announced (two differ from Metal, by slope and by exponent; the uniform-depth one matches); 93 draws as bands, 0 at the nearest width. Before this commit the same lane failed 4 of 7 (31 edge cases at the nearest width, refused bands refused). Also: engine_line_band and the band's fan tests, golden_hashes_match_the_table and the engine inventory parts unchanged (no bless), runtime line_width tests (the route table for lines and edges on every profile under both policies, refused rows), api_surface, api_signatures, refusal_surface --check, clippy with all features and with --cfg m2v_gpu, rustdoc with -D warnings. (Carried to development from steelbrain/reims-graphics-kext be2d725fdb.) |
||
|
|
9c83a06f89 |
Measure Metal's wide triangle edges and check them in the line-width lane
The line-width probe gains an `edges` case: triangles in fill mode Lines on a 32x32 target, their front- and back-facing fragments counted apart under each cull mode and winding at widths 0, 1, 2.5 and 4, a square of two triangles, a strip of three, zero-area triangles and eight scattered ones; the flat vertex ID and primitive ID each fragment reads, for two triangles and a strip of two at provoking vertex modes 0 and 1; which fragments a depth bias passes against a filled triangle and a line, and the depth across a sloped triangle's edge; and 4 samples at width 2. Its output on the M3 Max (macOS 27.0.1) is appended to the lane's record. What it measured: each edge is the line parallelogram with no joins (overlaps take two fragments); fragments read the triangle's facing and the cull mode culls by it under either winding; a zero-area triangle is back-facing; a strip's triangles face alike; flat inputs come from the provoking vertex and the primitive ID is the triangle's; the depth is the edge's, constant across the width; the depth bias applies to edges (not lines) by the triangle's slope and largest depth exponent. The lane draws every one of those cases with the runtime and compares the maps pixel for pixel (front and back fragments apart, the IDs from rt6_provoking's pv_flat third color, the depth tests against a Depth32Float), adds a test that a triangle's edges at width 4 draw as a band (or at the nearest width without tessellationShader), and a test that a pipeline state whose band the translator refuses (pv_weights) draws at the nearest width rather than being refused. Verified: the probe ran on the M3 Max through maclock without the debug layer. The lane, built at this tree with --cfg m2v_gpu and run on the M3 Max (MoltenVK) through maclock and memcap, fails as expected before the runtime draws edges as bands: 4 of its 7 tests fail. Both policies: 148 cases, 117 matched, the 31 wide edge cases drawn at the nearest width (edges_matched 0); edges at width 4 took the nearest width, not the band; the refused-band draws were refused with Unsupported(WideLines). (Carried to development from steelbrain/reims-graphics-kext 7a1dae2b87.) |
||
|
|
54d78d71c8 |
Test the nearest-width line route and empty draws on the device lane
runtime_lane::line_widths, for the two commits before: - run(): nothing is refused any more. Each case's draws are counted by route (band, the device's lines, the nearest width: WorkCounts::nearest_width_line_draws) and must sum to its wide draws; each nearest-width draw announces lines-at-nearest-width (announce_each here) and only those do. A case drawn at the nearest width is compared, where that width is 1 and the probe has the geometry's width-1 map, with Metal's map at width 1, pixel for pixel. On a device without wideLines that tessellates, every edges case takes the nearest width and matches Metal's width-1 edges. WIDE_LINES holds both kinds. - a_draw_of_no_complete_primitive_draws_nothing: the consumer's shapes, Triangle and TriangleStrip of 1 and 2 vertices, by vertices and by 16-bit indices, fill mode Lines, width 2, provoking vertex 1: no error, no pixel, no route counted, no notice. Draw gains indexed and provoking_last. - edges_draw_at_the_nearest_width_the_device_s_lines_draw: a triangle's edges at width 2, twice, under once-per-device announcing: the device's lines where they draw 2, else the nearest width, counted at each draw, announced at the first alone; at width 1 Metal's width-1 edges map. - a_band_needs_tessellation becomes without_tessellation_lines_draw_at_the_nearest_width: widths 0 and 2 without tessellationShader run (the device's lines or the nearest width, announced), compared with Metal's LANE lines 1 where drawn at 1. Verified on the Apple M3 Max over MoltenVK 1.4.2 (no wideLines), RUSTFLAGS --cfg m2v_gpu, through maclock and memcap.sh: the six line_widths tests and degrade_notices::every_kind_has_a_site_a_lane_test_takes pass. Both run() policies: 117 cases, 115 matched at Metal's width, the 2 edges cases formerly refused (fill Lines widths 4 and 0) drawn at width 1 and equal to Metal's width-1 edges map; 61 band draws, 2 nearest-width draws. Negative control: with drawn() ignoring the draw's count, a_draw_of_no_complete_primitive_draws_nothing fails (routes [0, 0, 1] for a 1-vertex triangle). clippy -p metal2vulkan-validation -p metal2vulkan-runtime --all-targets --all-features under --cfg m2v_gpu is clean. (Carried to development from steelbrain/reims-graphics-kext 45b3427434.) |
||
|
|
b5e18d8fb3 |
Document the nearest-width line route; name its cause in the notice
Follows the previous commit, which drew at the nearest width what neither line route draws. Its nearest width is Metal's drawn width: w', and 1/16 at w' = 0 (Metal draws 0 as 1/16, the width-0 commit this rebased onto), clamped into lineWidthRange where the device enables wideLines, else 1. - line_width.rs: module docs for the Nearest route and what still refuses (a strip's band whose segment list cannot be drawn; the band variant's forms the translator does not build). The lines-at-nearest-width notice's object names the edges or lines drawn, its reason the width drawn, lineWidthRange (or no wideLines) and the cause. - The runtime README's line widths, FAST-PATHS.md's wide_lines row (counter nearest_width_line_draws) and its known gap (what is drawn at the nearest width, announced, instead of refused), RUNTIME-PORTING's SetLineWidth row. - refusal_surface reach.tsv: gap WideLines now reaches only a strip's band list; feature WideLines only the translator's band forms. REFUSALS.md regenerated (gap::WideLines sites 5 -> 1, the runtime's Unsupported(WideLines) site gone). - api_signatures blessed: Degradation::LinesAtNearestWidth, WorkCounts::nearest_width_line_draws. - RUNTIME_VERSION 1715 (a refusal became a run, a new announcement); runtime-sources pin recomputed on this tree (pin-compute.py, which reproduces 9ada26c9fa's pin on that tree). Verified: refusal_surface.py --check exit 0; cargo nextest run -p metal2vulkan-runtime -p metal2vulkan --all-features -E 'test(/line_width|degradation|api_signatures|api_surface|refusal_surface|apple_only|error_kinds|draw_shape|call_checks/)' 27 passed; cargo clippy --workspace --all-targets --all-features -D warnings clean. (Carried to development from steelbrain/reims-graphics-kext 7aed54b621.) |
||
|
|
9ccc90d246 |
Draw at the nearest width what neither line route draws; draw nothing for no primitive
The consumer (reims-vgpu, whose guest process ends at any refusal) measured
two problems with setLineWidth: on an M3 Max over MoltenVK:
1. A draw of no complete primitive was refused. After setLineWidth 2 in fill
mode Lines, Triangle or TriangleStrip draws of 1 or 2 vertices or indices
returned NotImplemented(WideLines), where Metal draws nothing. drawn()
ignored the draw's count. It now takes whether the draw may draw a
primitive (line_width::draws_primitives: a direct draw whose vertices or
indices complete none of its type's primitives, RewriteProgram::capacity,
draws none; an indirect draw's count is the GPU's and keeps its route, as
do patch and mesh draws), and such a draw is Plain. The shape memo keys
on it beside the assembly, so a later whole draw does not reuse its
settings.
2. Every remaining refusal refused a draw that can run. LineRoute gains
Nearest { width, why }: the device's own lines at the width nearest
Metal's they draw (w' clamped into lineWidthRange where the device
enables wideLines, else 1), announced once per device (unless
announce_each) as the new Degradation::LinesAtNearestWidth
(lines-at-nearest-width, precision), whose reason names why and both
widths, and counted in WorkCounts::nearest_width_line_draws. It takes a
triangle's edges in fill mode Lines and mesh lines the device's lines do
not draw (Unbanded), lines on a device without tessellationShader
(Untessellated, formerly Unsupported needing it), an amplified band
(Amplified), and every wide line in a rate-mapped pass (RateMapped) or of
an execution's command (Executed: ShapeInputs::executes, the replay's
lowering), whose width Metal's answer is not measured for. route() is
infallible now; Device carries whether it differs. The replay's and the
commit precompile's refusals go: an execution's command draws the
nearest width and the precompile makes its pipeline; the GPU form still
leaves such a pass to the host step, which draws and announces it.
RuntimeGap::WideLines stays for the one refusal left: a strip's band whose
list of segments the runtime cannot draw (ListGap::WideLines, as for the
provoking vertex's lists). The band variant's own refusals in the
translator (pipeline::link::band) are unchanged.
Not a speed-for-accuracy switch: the fallback for capability not built, so
no DevicePolicy switch.
Verified: cargo nextest run -p metal2vulkan-runtime -E 'test(/line_width/)'
(3 passed): each_device_routes_each_width_as_its_lines_allow now expects
the nearest width (checked against lineWidthRange) in every former refusal
cell, and rate-mapped and executed draws at the nearest width; the new
a_draw_of_no_complete_primitive_draws_nothing covers every line, triangle
and private type, direct and indexed, 1 and 3 instances, both fill modes,
on four profiles under both policies. Negative control: with drawn()
ignoring the count it fails (left: Lines, right: Nothing).
(Carried to development from steelbrain/reims-graphics-kext 5eecc33ca1.)
|
||
|
|
7ebe50a2bc |
Draw width-0 lines as Metal's width 1/16
Metal draws every setLineWidth: width below 1/16 (0, negative widths and NaN among them) exactly as 1/16: the parallelogram reaching 1/32 pixel each side of the segment along its minor axis, after snapping the endpoints to 1/256 pixel. The band drew w' = 0 at a half width of 2^-subPixelPrecisionBits (1/256 on MoltenVK), which lights only the centres the segment passes within 1/256 of: right where the endpoints are on pixel centres, as every earlier probe case had them, and short of Metal's pixels anywhere else (a consumer's scattered draw lit 3 and 5 pixels on Metal and none on the runtime). The runtime's route now pushes the band's half width as w'.max(1/16)/2, so width 0 draws as the band of 1/16 does. Width 0 keeps its route (the band; the device's lines never draw it), and every other width is unchanged. The translator's band is unchanged but for its docs. Docs: line_width.rs and band.rs state Metal's rule (snapping to 1/256, a half rounded up; width 0 as 1/16) in place of "the centres on the segment"; the runtime README and set_line_width say "at 0 as at 1/16". RUNTIME_VERSION 1714 (a width-0 draw lights other pixels); the runtime-sources pin recomputed. Verified: runtime_lane::line_widths on MoltenVK (Apple M3 Max, macOS 27.0.1), both policies: 117 cases, 115 match Metal pixel for pixel and 2 refused as documented (triangle edges), 61 draws by the band; the 11 width-0 maps that differed at the parent now match (offset rows and columns 256 pixels, scattered lists 31, the strip 33, the clip-space list and strip 3 and 5). Runtime line_width unit tests (the band's half at 0 is 1/32), tests::engine_line_band, golden_hashes_match_the_table, the engine inventory parts, tests::fast_paths and the runtime-sources guard pass; clippy clean on all features and on --cfg m2v_gpu. (Carried to development from steelbrain/reims-graphics-kext 9ada26c9fa.) |
||
|
|
2ee9856fa1 |
Measure Metal's width-0 lines off the pixel centres
The line-width probe's width-0 cases all put the endpoints on pixel centres, which cannot tell "only the centres on the segment" from a narrow band. A consumer's scattered draw at setLineWidth:0 lit pixels on Metal that the runtime did not. The probe's zero case gains: rows and columns of lines offset from the centres in steps of 1/512 pixel (64x64, widths 0 and 1/16); 48 lines of scattered endpoints on a 1/4096 grid (32x32, a 64-bit LCG the lane test repeats) at widths 0, 1/32, 1/16, -1, NaN and 2.5, the same lines reversed and drawn as two instances, and a strip of 49 points; and eight clip-space positions as a list and a strip (a pass-through vertex function), fragments counted. The probe's draws take an instance count and clip-space points. Measured on the M3 Max, macOS 27.0.1 (each case under the GPU lock, without MTL_DEBUG_LAYER): every width below 1/16 draws exactly as 1/16 (the scattered maps at 0, 1/32, 1/16, -1 and NaN are identical, 31 pixels; the offsets at 0 and 1/16 identical), a line offset from a row of centres by -15/512 to 16/512 pixel draws them (rows 17 to 48 of 4..59), i.e. the parallelogram reaching 1/32 pixel each side of the endpoints snapped to 1/256 pixel, a half rounded up. Regenerating every case reproduces the old record byte for byte; only the new maps are added. The lane test (runtime_lane::line_widths) draws the same cases. On MoltenVK it fails at this commit: 11 of the new width-0 maps differ (offset rows and columns 32 pixels against Metal's 256; scattered lists 4 against 31, the strip 5 against 33, the clip-space list and strip 0 against 3 and 5); the 1/16 and 2.5 maps match. (Carried to development from steelbrain/reims-graphics-kext 3e5a376bc4.) |
||
|
|
3f5cfb1399 |
Bless the linked_other_functions fixture's golden rows
The fixture added with the binary-function linking answers had no golden printout, engine inventory rows or golden-hash cells, so the core suite failed five tests on it (engine_fixtures_match_their_golden_printout, inventory_lists_every_fixture_in_order, golden_hashes_match_the_table and two engine inventory parts). Blessed with bless_engine_goldens, bless_golden_hashes and bless_engine_inventory. Every new row is the new fixture's (ok under every profile); no existing cell moved and no row was removed. (Carried to development from steelbrain/reims-graphics-kext 31df26ef99.) |
||
|
|
815c8af707 |
Re-pin the runtime sources at the branch tip
The previous commit changed runtime-sources inputs (the runtime's pipeline sources), so the committed digest no longer described the sources and `the_runtime_sources_are_the_committed_ones` would fail. Recomputed over the same inputs with pin-compute.py on the tree rebased onto 7cf79c50ed. REFUSALS.md regenerated on the same tree: beside nothing of this branch, it picks up the base's rename of `line_width.rs`'s `line_route` to `route`, which the base left out of the generated document. (Carried to development from steelbrain/reims-graphics-kext 6fd1ce74b1.) |
||
|
|
b2bbc86339 |
Answer linked binary functions as plain Metal does
Measured on this M3 Max under macOS 27.0.1 (binary_function_linking.m, plain
and with MTL_DEBUG_LAYER=1, source libraries and metallibs alike), the runtime
now answers what plain Metal answers rather than what its validation layer
stops:
- One name in `functions` and `binary_functions`, or twice in
`binary_functions`, one function or two: made, where the runtime refused
`Invalid(DuplicateLinkedFunction)`. `duplicate_linked_name` keeps only a name
`functions` repeats, which plain Metal's creation fails ("error: duplicated
symbol", code 3). With the previous commit, a call calls the `functions` one
and a table holds each.
- A function only `binary_functions` holds that a stage calls directly:
`Compile(NeedsInput(LinkedFunction))`, as Metal fails with code 3, where the
runtime linked it (previous commit).
- A function not compiled to a binary in a stage's `binary_functions`: plain
Metal fails the creation once the stage links, code 2 ("Internal error
during compute pipeline creation", "... tile pipeline creation", an empty
description for render and mesh-fragment stages), after a reference it
leaves unresolved (code 3 first). The runtime answered
`Invalid(BinaryFunctions(NotPrecompiled))` before the compile; it now
answers `Error::MetalError` with that problem, the M3 Max's domain and
Metal's code and text, right after the compile (`additions::check_precompiled`).
Added to a made state's stage: `MetalError` code 1 ("Failed to allocate a new
pipeline"). Added to a stage the state lacks: taken, as plain Metal makes it
(it was refused).
- A mesh pipeline's object or mesh stage linking binary functions ends plain
Metal's process ("Binary linked functions are not supported for object and
mesh shaders"): `Invalid(BinaryFunctions(ObjectOrMeshStage))`, a new problem,
where the runtime made the state.
The module docs of `pipeline/additions.rs` record the measurements, the error
and README docs follow, REFUSALS.md and the API signatures are regenerated.
RUNTIME_VERSION 1713: creation answers change class.
Verified on this Mac (MoltenVK, --cfg m2v_gpu, under maclock and memcap):
runtime_lane::tests::a_kernel_runs_the_functions_its_descriptor_links and
runtime_lane::function_tables::{binary_functions_link_as_plain_metal_links_them,
binary_functions_and_required_threads_answer_as_metal_s_do,
functions_added_to_a_stage_a_drawing_state_lacks_are_left_out} pass; each
asserts an answer the previous runtime gave otherwise. The runtime unit test of
`duplicate_linked_name` passes.
(Carried to development from steelbrain/reims-graphics-kext 580daa4338.)
|
||
|
|
3c1f56b63b |
Resolve no visible-function reference against binary functions
Metal resolves a visible-function reference against MTLLinkedFunctions'
`functions` and `privateFunctions`, never `binaryFunctions`, whose functions
only a visible-function table reaches: on this M3 Max under macOS 27.0.1
(binary_function_linking.m) a direct call to a function only binaryFunctions
holds fails the creation, plain and under validation ("unresolved visible
function reference"), from the stage's function and from a linked function
alike, while a table calls it. Two different functions of one name, one in
each list, are made: the call calls the one of `functions`, and a table holds
both, each handle calling its own definition.
The compile layer resolved references against every list, so it linked what
Metal refuses and saw two such functions as ambiguous. Now
`LinkedList::resolves_references` is `functions` and `private_functions`;
`linked_modules` reaches a table's functions by key rather than by name, and
each `LinkedName` says whether a reference resolves to it
(`resolves_references`, a new field of metal2vulkan-air's public struct), which
canonicalization's stub resolution reads. A reference only a binary function
names is `NeedsInput(LinkedFunction)`, the answer for any unresolved one.
The owned fixture `linked_other_functions` (compiled by
scripts/regen-air-fixtures) defines `linked_scale` and `table_add` with other
bodies, for the two-of-one-name shapes. SEMANTICS_VERSION 1937: the same key
now compiles otherwise (a binary-only reference refuses).
Verified: the AIR link tests, `engine_linking::a_reference_resolves_to_no_
binary_function` (interpreter: the call calls the `functions` one from either
module; a binary-only call and a binary-only nested call refuse) and
`engine_tables::a_table_holds_a_binary_function_of_another_s_name`
(interpreter: alternating own and other `table_add` through one table) pass;
with the stub filter removed, the link test and the engine_linking test fail.
API signatures blessed (one new field).
(Carried to development from steelbrain/reims-graphics-kext 64bd644d0b.)
|
||
|
|
6264c2d3f9 |
Probe what Metal answers for linked binary functions
A probe written from scratch, binary_function_linking.m, of compute, render
(vertex, fragment), tile and mesh pipelines whose linked binaryFunctions hold a
function alone (called directly, through a visible-function table, or not at
all), one name beside a function of `functions` or twice, a function not
compiled to a binary, and the same for functions added to a made state. Each
case is one process; the probe reads its libraries compiled from source or
from metallibs built ahead of time.
Measured on this M3 Max under macOS 27.0.1, plain and with MTL_DEBUG_LAYER=1,
both library kinds alike: no direct call resolves to a function only
binaryFunctions holds (code 3 "unresolved visible function reference"), a
table calls it; one name in both lists, or twice in binaryFunctions, is made
plain (validation stops it) and a direct call calls the one of `functions`; a
function not compiled to a binary fails the creation with code 2 ("Internal
error during compute pipeline creation", the tile form, or an empty
description for render stages) and an addition with code 1 ("Failed to
allocate a new pipeline"); a mesh or object stage's binary functions end the
process. While a compile-to-binary function lives, newFunctionWithName: of the
same library function answers that one object (options 1), which explains the
consumer's repro reading its "unbinary" cases as binary ones.
The results are in the probe's header; the runtime docs and tests follow in
the next commits.
(Carried to development from steelbrain/reims-graphics-kext 7d83e83da2.)
|
||
|
|
51817ce0ef |
Test each committed device's wide-line route under both policies
The device's-own-lines route (WideLinePolicy::Device, and the exact device route) runs on no lane venue here: MoltenVK has no wideLines, so runtime_lane::line_widths cannot tell the two settings apart. The route decision is now a function of the device profile, the policy, Metal's width, what the draw draws and whether it is amplified or rate-mapped (render/line_width.rs route, drawn), which ShapeInputs::line_route calls and announces from; no behaviour changes. render/line_width/tests.rs asserts the route of every draw at widths 0, 0.5, 1, 1.5, on and off each device's granularity, the top of its range and a sixteenth above it, and 16, read from the committed profiles amd-780m-radv, amd-780m-hawkpoint-radv, amd-rdna3-radv, intel-arl-anv, lavapipe, nvidia-rtx5080-laptop, moltenvk-m3, swiftshader, vk12-floor, roadmap-2022 and lunarg-desktop-baseline-2023, under Device and Exact, for a list of lines, a triangle's edges in fill mode Lines, an emulated mesh's lines and an amplified list: device lines exact or announced, the band (its half width checked), Unsupported needing tessellationShader, or NotImplemented(WideLines); a rate-mapped pass refuses every width but 1. The runtime-sources pin is rewritten (the previous commit's profile reader and this one's runtime files; no behaviour change, so no RUNTIME_VERSION bump). Correction to b16d03150c's message: the lane's two refused cases are the triangles in fill mode Lines at widths 4 and 0, not both at 4. Verified: nextest render::line_width (2 pass); negative controls, each reverted: dropping `w > 1.0` from the exact test fails it at amd-780m-radv lines/Device 0.5 (Exact for Announced), and dropping `|| !band` fails it at amd-780m-radv edges/Exact (Gap for Announced); the runtime crate's suite (1179 pass); runtime_lane::line_widths on the M3 Max under MoltenVK through maclock (4 pass, unchanged counts); cargo clippy --workspace --all-targets --all-features -D warnings. (Carried to development from steelbrain/reims-graphics-kext 7cf79c50ed.) |
||
|
|
bbc7866fa0 |
Read nonStrictWideLinesUseParallelogram from the maintenance5 properties
The profile reader took VkPhysicalDeviceMaintenance5Properties' members only through VkPhysicalDeviceVulkan14Properties, so a capture of a Vulkan 1.3 device exposing VK_KHR_maintenance5, which carries only the extension's structure, read nonStrictWideLinesUseParallelogram as false, and the runtime would announce or band wide lines its device draws as Metal's parallelogram. PROPERTY_STRUCTS now lists VkPhysicalDeviceMaintenance5Properties and its KHR name; the member is still read only where maintenance5 is exposed (the extension or 1.4). The profile generator's EXTENSION_PROPERTIES states the member at the value the reader takes when a requirements document lists the extension and omits it (false). Nothing moves: every committed capture that carries the extension structure also carries the Vulkan 1.4 one, with the same value (golden_hashes passes unblessed). The runtime-sources pin, which hashes this file, is rewritten in the next commit. Verified: nextest device::tests::description (23 pass), among them the new wide_line_parallelograms_read_the_maintenance5_structure (a 1.3 document with the extension and either structure name reads true, without the extension false, a 1.4 document's Vulkan 1.4 block true); negative control: with the two names left out of PROPERTY_STRUCTS the test fails; golden_hashes and fast_paths pass; scripts/regen-device- profiles test_device_profiles.py and check_device_profiles.py clean. (Carried to development from steelbrain/reims-graphics-kext 5651992284.) |
||
|
|
eb41a55e82 |
Draw every width Apple's setLineWidth: takes, as Metal draws it
RenderCommandEncoder::set_line_width refused every width but 1 (AppleOnly::LineWidth). Measured on the Apple M3 Max under macOS 27.0.1 (probes/line_widths.m): each encoder starts at 1 and the width holds across draws and pipeline states; Metal draws w' = floor(16 w) / 16 clamped to [0, 16] (NaN and negatives as 0, infinity as 16); at w' = 1 its ordinary diamond-exit lines; at every other w' Vulkan's non-strict parallelogram (major axis the larger extent, x on a tie; minor-axis edges through the endpoints, w' long and centred; ends not extended; centres inside, top-left ties; the width not rounded); at 0 exactly the pixel centres on the segment; one parallelogram per strip segment with no joins; triangles in fill mode Lines draw their edges so; at 4 samples every width is the parallelogram at the sample positions. The runtime (render/line_width.rs) keeps the quantized width in the encoder state and routes each draw at w' != 1: - the device's own lines (lineWidth w', no Bresenham mode) where it enables wideLines and w' lies in lineWidthRange above 0: exact where strictLines is unset, nonStrictWideLinesUseParallelogram set, w' > 1 and on lineWidthGranularity; elsewhere announced device-wide-lines under the default DevicePolicy::wide_lines = WideLinePolicy::Device, and the band under WideLinePolicy::Exact (exact_answers() selects it); - the pipeline's band variant otherwise (no wideLines, MoltenVK among them; w' outside the range; w' = 0 at half a width of 2^-subPixelPrecisionBits): cull none, the band's front face, fill mode, a PATCH_LIST of two points, viewport 0's half extent pushed with the half width; strips and loops listed as their segments (ListGap::WideLines), flat inputs under the last provoking vertex read from the list led by the last vertex, which covers the same pixels. Refused: Unsupported(WideLines) needing tessellationShader where neither route draws a line; NotImplemented(RuntimeGap::WideLines) for a triangle's edges or a mesh draw's lines the device's lines do not draw, an amplified band, a rate-mapped pass and an execution's commands. Counted: WorkCounts::device_wide_line_draws, line_band_draws. The lane test runtime_lane::line_widths draws the probe's cases through owned fixtures and compares every pixel with Metal's answers (line_widths_m3_max.txt, the probe's output), checks each wide draw took a route, and that every fragment is front-facing; its site WIDE_LINES holds the new kind in the lane's degrade-notice closure. Docs: FAST-PATHS.md's row for wide_lines and a known-gap bullet (edges and mesh lines on devices without wideLines, near-plane cuts, band fragments' inputs uncompared, width 1 on multisampled targets off MoltenVK); API.md's policy bullet and degrade catalogue; the runtime README's Line widths; RUNTIME-PORTING's row; REFUSALS.md regenerated (reach rows for feature and gap WideLines, apple LineWidth gone). Validation: the line limits the device description gained describe execution and are not compared in a profile's subset check; the generator's CORE_PROPERTIES and roadmap-2022's m2v_layer_presentation state them at the reader's absent values; opened_chains reblessed (one member more, wide_lines, on every device with it); golden_hashes' profile fingerprints reblessed (no output cell moved); api_signatures and api_surface name WideLinePolicy and LineBandState. RUNTIME_VERSION 1712; the runtime-sources pin rewritten. Verified on the M3 Max under MoltenVK 1.4.2 through maclock with the validation layer: runtime_lane::line_widths, 4 tests pass. Default and exact policies each: 102 cases, 100 matched pixel for pixel, 2 refused (the two fill-mode Lines cases at width 4, NotImplemented(WideLines)), 0 announced; 46 draws took the band, 0 the device's lines (MoltenVK has no wideLines). a_band_needs_tessellation (tessellationShader withheld: width 0 refused needing it, width 2 refused, width 1 matches) and the_lane_s_maps_tell_the_widths_apart pass. Negative control: the band widened by 1/16 of a pixel fails both runs at LANE lines 0.5. Also cargo clippy --workspace --all-targets --all-features -D warnings, plain and with --cfg m2v_gpu; nextest of metal2vulkan, -air, -runtime and -devtools (4954 run, the one failure the missing lane site, now declared), of metal2vulkan-validation (the failures the profile rules, chains and pin fixed here, rerun green) and of metal2vulkan-conformance (1007 pass). Not run: lavapipe, RADV, ANV and NVIDIA lanes, which take the device route. (Carried to development from steelbrain/reims-graphics-kext b16d03150c.) |
||
|
|
fe22294b09 |
Carry every vertex output through a line band's control stage
On MoltenVK the band drew every line from its first endpoint to the target's right edge: the second control point's position read the bytes after the first vertex's. MoltenVK runs a vertex stage followed by tessellation as a compute kernel that writes its outputs into one record per vertex, the location outputs, Position and PointSize (which the translator's MoltenVK vertex stages always write), and lays the control stage's input record out from what that stage declares. A control stage that declared only Position read records of 32 bytes from records of 48. The band's stages now carry the vertex stage's outputs entire: every varying, read or not by the fragment stage, and PointSize where the vertex function writes one and the device enables shaderTessellationAndGeometryPointSize (TessellationPointSize, now a requirement rule for tessellation entries beside GeometryPointSize). A corner takes the first control point's point size, as it does a flat varying. The input arrays are gl_MaxPatchVertices long again. The binder also plans a band variant: its synthesized control and evaluation stages run no Metal function and bind nothing, as link's geometry stages (bind::graphics::metal_stages, with a plan test). Two match expressions become matches! (clippy). SEMANTICS_VERSION 1936: the band variant's control and evaluation modules change under the same key. Verified: nextest tests::engine_line_band, 4 tests pass, among them the new the_control_stage_takes_every_value_the_vertex_stage_writes (the control stage's per-vertex inputs and outputs and the evaluation stage's inputs equal the vertex stage's outputs on every committed profile with tessellationShader, PointSize included where the device takes it). Negative control: with the point size left out it fails (left [BuiltIn(0), Location(0), Location(1)], right adds BuiltIn(1)), and the MoltenVK lane runtime_lane::line_widths draws LANE lines 0.5 otherwise than Metal. With the fix the lane matches Metal's maps on the M3 Max under MoltenVK (the runtime commit that follows). (Carried to development from steelbrain/reims-graphics-kext 8b865a057d.) |
||
|
|
14dc4c5f2e |
Draw a line wider than the device's lines as a band of two triangles
Metal draws a line under Apple's setLineWidth: at a width other than 1 as the parallelogram Vulkan's non-strict wide lines may be (major axis the larger framebuffer extent, minor-axis edges through the endpoints, centred, w long). Devices without wideLines (MoltenVK among them) or whose wide lines are strict or not parallelograms cannot draw it with their own lines. A render pipeline's band variant (VariantKey::line_band) adds two synthesized stages after the vertex stage (pipeline::link::band): a tessellation control stage that copies each of a line's two vertices and writes every level 1 in the quad domain, and an evaluation stage that places each corner at its endpoint moved across the segment by half the width in framebuffer pixels along the minor axis, taken to clip space through Vulkan viewport 0's half extent, which the draw pushes (PushField::LineBand, BindState::line_band, its own 16-byte aligned push range). Ends behind w = 2^-20 are clipped first; smooth varyings and clip distances follow their endpoint, flat and integer ones take the first control point's. GraphicsState::line_band (LineBandState) states the consumer's contract: PATCH_LIST of two control points, no culling, its front face, the push offset. The device description gains what chooses the route: VkFeature::WideLines, and the limits lineWidthRange, lineWidthGranularity, strictLines, nonStrictWideLinesUseParallelogram (VK_KHR_maintenance5) and subPixelPrecisionBits, read from Khronos profile JSON and from ash. The verifier and requirement rules take the per-vertex arrays of tessellation control inputs and outputs and evaluation inputs, and TessLevelOuter and TessLevelInner as arrays. ARTIFACT_FORMAT_VERSION 480 for the new encoded fields (VariantKey, GraphicsState, LineBandState, PushField, VkFeature). Verified: cargo build --workspace --all-features --all-targets; nextest tests::engine_line_band (the band variant on every committed profile with tessellationShader validates in spirv-val and requirements, draws PATCH_LIST with its own push range; flat varyings take the first control point; without tessellationShader it is refused needing it; barycentric reads are not implemented) and the tessellation push_offset tests pass. (Carried to development from steelbrain/reims-graphics-kext 19814d7bb3.) |
||
|
|
8ef82fffa5 |
SEMANTICS_VERSION 1935; bless the stitched caller's rows
Translation output changes: a pipeline that links a function from a module carrying a stitching signature (or a linked-constants signature on a module that declares no constant) now compiles instead of refusing, so SEMANTICS_VERSION moves from 1933 to 1935 (1934 is reserved). The golden tables gain the new fixture's rows and nothing else moved: golden_hashes.tsv and public_fixture_expectations_engine.tsv each add stitched_caller's two kernels in its two forms (.ll and .air.ll), every profile NeedsInput(LinkedFunction) for `fused` and `fused4`, which no module defines there; tests/air_input/stitched_caller.txt is the new fixture's decode golden. Blessed with bless_golden_hashes, bless_engine_inventory and bless_engine_goldens (llvm-as 21); git diff shows only these additions. (Carried to development from steelbrain/reims-graphics-kext 4ba981e668.) |
||
|
|
1146929b09 |
Lane test: a stitched function computes its graph on the device
The consumer's path end to end through the runtime: the stitched library made from its bytes (Device::new_library_with_data, the form it takes when a guest hands it over), its functions linked into the caller's kernels in privateFunctions and in functions, one thread on 2, 3, 4 and 5. runtime_lane::stitched_functions checks Metal's measured words, 20 for `fused` and 25 for `fused4`, read back from the device. The runtime README says that a stitched function links as any linked function does and that the runtime makes no stitched library itself. The runtime's sources are unchanged. Verified on the M3 Max through MoltenVK under the validation layer (RUSTFLAGS='--cfg m2v_gpu', through the Mac GPU lock): runtime_lane::stitched_functions::a_stitched_function_computes_its_graph passes, beside runtime_lane::linked_functions' two tests; with the translator's old signature gate restored it fails, the pipeline state refused with the consumer's error. (Carried to development from steelbrain/reims-graphics-kext 199df8d7b3.) |
||
|
|
43ba8cf525 |
Test stitched functions linked into their caller
Metal's stitcher writes its library only at run time, so the tests get its structure from a writer of our own: metal2vulkan_devtools::stitched writes, as LLVM text, the module the probe stitched_function_linked.m read back from Metal for a graph of float stitchable functions (the stitched function with its nodes inlined, its air.visible entry and air.stitching_info naming internal helpers kept by llvm.compiler.used, and an !air.signature of kind air.stitching_modules_signature listing the graph in post-order and a digest per stitchable function), and the executable metallib holding one visible (TYPE 4) module per function. PROBE_GRAPHS are the probe's `fused` and `fused4`. No Apple-produced bytes are committed. The owned fixture engine/stitched_caller (regen-air-fixtures, macOS 27.0 target, as the probe compiled) holds the stitchable sum2 and product2 and the kernels stitch_caller and stitch_caller4 that call `fused` and `fused4`. tests::engine_stitched checks Metal's answers: through the public API the stitched library's functions are visible and each kernel's compute pipeline links its function in privateFunctions and in functions; on the SPIR-V interpreter the kernels store the probe's 20 and 25 (and the graph's value on two other input sets); and each link passes L3 on every committed profile. Verified: the three tests pass; with the previous commit's gate restored all three fail, the link refused with exactly the consumer's error (Linking, NotImplemented, stitch_caller block 0 instruction 5, symbol "fused"). regen-air-fixtures --check: up to date. (Carried to development from steelbrain/reims-graphics-kext 88a6b651a7.) |
||
|
|
59209afdf7 |
Link stitched functions: read a linked module's signature as the entry's
A pipeline linking a function Metal's stitcher made was refused,
`Unsupported { feature: Linking, needs: NotImplemented }` at the call
(stitch_caller, block 0, instruction 5, symbol "fused"), because
link::plan refused every linked module that carries an !air.signature.
Each module of a stitched library carries one, of kind
air.stitching_modules_signature: it records the graph the function was
made from and the stitchable modules' digests, while the module's own
code (the graph's nodes inlined into the stitched function) is what
runs. The entry side already read a signature that way and refused only
a linked-constants module that still declares function constants, which
has no reading.
The rule is now one function, canon::unread_signature, which both the
entry's specialization and the linked module's plan use: a stitched
module and a linked-constants module that declares no constant link like
any other module; a linked-constants module that still declares one is
refused at the surviving call as before. The dynamic-library export
check, which blocks any signature, is unchanged: a stitched library is
an executable library and cannot be a dynamic one.
Verified: link_tests::a_linked_module_s_signature_is_read_as_the_entry_s
(replacing the test that held the old refusal) passes, and fails with
the old gate restored. Against the stitched library the probe dumped on
the M3 (not committed), the old gate reproduces the consumer's refusal
exactly, and with this change both stitched functions link, privately
or not, and compute 20 and 25 on the SPIR-V interpreter.
(Carried to development from steelbrain/reims-graphics-kext 3ebc1a708a.)
|
||
|
|
1083e38ecf |
Probe a stitched function linked into a compute pipeline
A consumer's guest makes a stitched library with Metal's own stitcher (newLibraryWithStitchedDescriptor:) and links its function `fused` into a kernel as a private linked function; the translator refused that pipeline. This probe measures Metal's answer from our own stitchable source: `fused(a, b, c) = product2(sum2(a, b), c)` linked into `stitch_caller` in privateFunctions or in functions, and the three-node `fused4`, each run on 2, 3, 4 and 5, and it writes the stitched library's bytes (its libraryDataContents) for inspection. Measured on the M3 Max under macOS 27.0.1, each case in its own process through the Mac GPU lock, MTL_DEBUG_LAYER unset: private 20, functions 20, deep 25, every command buffer status 4. The dumped library (11484 bytes, byte-identical across runs) is an executable metallib with one visible (TYPE 4) function per module, each module carrying an !air.signature of kind air.stitching_modules_signature. (Carried to development from steelbrain/reims-graphics-kext 453a4a2b23.) |
||
|
|
4180cb2edb |
RUNTIME_VERSION 1710 for linking under specialized names
The branch changes what a runtime run does: linked functions resolve under their specialized names, function-table handle keys carry the link name and specialization, linked modules with function constants link instead of refusing, and a pipeline of an unspecialized function that declares constants is refused. The runtime-sources guard asks for a RUNTIME_VERSION bump with such a change; 1710 is unused on every branch. The pin (4fc5e9992a...) does not move with it. (Carried to development from steelbrain/reims-graphics-kext 37280bc223.) |
||
|
|
45380bd58f |
Re-pin the runtime sources at the branch tip
The branch changes runtime-sources inputs: metal2vulkan-runtime's
error.rs, library.rs, pipeline/{additions,mod,render,tile,
unspecialized}.rs and warm/codec.rs, and metal2vulkan's
pipeline/table.rs. Recomputed over the same inputs, as
the_runtime_sources_are_the_committed_ones computes it.
These edits can change what a run does: a linked function links under
its specialized name, a visible-function handle's key holds the
specialized name and flag, a linked module with function constants is
specialized instead of refused, and a stage function made by name whose
function declares constants is refused. The guard's rule asks for a
RUNTIME_VERSION bump with such edits; RUNTIME_VERSION stays 1709 here
because its number is the orchestrator's to give, and the bump is left
for that number.
Verified: the guard passes (1/1).
(Carried to development from steelbrain/reims-graphics-kext ce415fe9f6.)
|
||
|
|
468a91feab |
Size a copied constant's children with size_of_val
clippy's manual_slice_size_calculation (rust 1.98) stopped the workspace's clippy at copy_bytes, the linked-module copy's ledger estimate: size_of::<ConstId>() * children().len() over the slice children() returns. The same bytes, as size_of_val of that slice. Verified: cargo clippy --workspace --all-targets --all-features -D warnings, plain and under --cfg m2v_gpu (own target), clean; rustdoc -D warnings for the workspace, clean. (Carried to development from steelbrain/reims-graphics-kext d232492977.) |
||
|
|
e54a2c12aa |
Refuse a pipeline of an unspecialized function that declares constants
Since functions whose constants are left undefined compile (a2e34a9d2f),
the runtime made a pipeline state of a function made by
newFunctionWithName: whose function declares function constants. Plain
Metal ends its process there, at every creator's descriptor validation
(probes/undefined_function_constant_values.m, new cases <how>:<shape>,
on the M3 Max under macOS 27.0.1, MTL_DEBUG_LAYER unset, exit 134):
"Compute Pipeline Descriptor Validation / function ko cannot be used to
build a pipeline state. Use newFunctionWithName:constantValues:... to get
the specialized function"; the render and mesh creators name
vertexFunction, fragmentFunction, objectFunction and meshFunction, and
the tile creator says "without setting constant values first". It does
so for an optional constant read only where is_function_constant_defined
says (ko) and for a constant that only gates arguments (kg). Made: a
function made by name that declares none (kn, plain, tile-plain,
mesh-plain), and every shape made with constant values that hold none or
by newFunctionWithDescriptor: without them (each then answers an empty
functionConstantsDictionary; ko stored 7, kn 9).
- metal2vulkan: FunctionDescriptor gains `specialized` (false by default,
a function made by name; a descriptor with constant values is
specialized whatever it says) and with_specialized, and
needs_specialization(budget, entries) answers whether Metal makes no
state of the stage: not specialized and a non-empty
functionConstantsDictionary. A module function's constants are read
through the StageEntries' module decodes (constants_dictionary_with),
which the stage's compile copies, so the check decodes nothing the
compile does not. The compile itself is unchanged.
- metal2vulkan-runtime: Function::function_descriptor marks the stage
specialized where the function was made with constant values or by
descriptor. pipeline/unspecialized.rs refuses before anything is
compiled, Invalid with the new Problem::UnspecializedFunction { stage,
name }: compute and tile states (of_kernel), render states (vertex,
fragment) and mesh states (object, mesh, fragment). A linked function
keeps its own rule (LinkProblem::UnresolvedConstant).
- Pipeline records carry the stage's specialized flag, RECORD_FORMAT 3:
without it every specialized stage's record read back unspecialized
and went unrecorded.
- The owned fixture engine/unspecialized_stage_functions (the probe's
shapes at every stage); its golden rows, inventory and printout are
new rows only (11 functions by 2 forms in each table).
- docs/API.md ("Function constants"), the FunctionConstantValues and
creators' docs, the runtime README, docs/REFUSALS.md regenerated, the
signatures blessed (FunctionDescriptor.specialized, with_specialized,
needs_specialization, Problem::UnspecializedFunction).
Verified:
- metal2vulkan tests::engine_unspecialized 2/2 (every declaring function
of the fixture needs specialization made by name, no free one does,
and the eleven answers read one module decode, (1, 10); specialized or
valued, none does, decoding nothing).
- On MoltenVK (M3 Max) through maclock, --cfg m2v_gpu:
runtime_lane::unspecialized_functions 3/3 (by name: guarded and gate
kernels, vertex, fragment, tile, mesh and object refused; free kernel
stores 9; plain render state made; empty-valued and descriptor-made
guarded kernels store 7, gate kernels made, render states made; tile
and mesh states of them not refused as unspecialized) and
runtime_lane::linked_functions 2/2.
- metal2vulkan-runtime suite 1177/1177; tests::warm_record 4/4.
- metal2vulkan and metal2vulkan-air: 3748 of 3753 before blessing, the 5
failures the new fixture's table rows; after blessing they and the
signature and surface tests pass.
- Negative controls: needs_specialization answering false fails
engine_unspecialized's by-name test; function_descriptor without the
specialized flag fails all three lane tests (the empty-valued and
descriptor-made functions refused); the stage flag removed from the
record's writes and reads fails the four warm_record tests.
(Carried to development from steelbrain/reims-graphics-kext 116efd0dfe.)
|
||
|
|
c4523d1bdb |
Record a linked function's specialization and specialized name
A pipeline record wrote each linked function's function, constants and precompiled flag, but not the specialized name or the specialized flag the specializedName commits added to LinkedFunction. The record is read back at its making and kept only where it equals the creation's descriptor, so every creation linking a function by name (specialized false, where the reader's with_constants set it true) or under a specialized name went unrecorded. Each linked function now records its fields in declaration order: function, constants, specialized name (present flag, then its bytes), specialized, precompiled. RECORD_FORMAT 2; a record of format 1 is not read. Verified (final tree, with the next commit): metal2vulkan-runtime tests::warm_record 4/4 (the round trip now links one function under the specialized name custom_fn), and with the linked fields' writes and reads removed all four fail (negative control). (Carried to development from steelbrain/reims-graphics-kext 4f8730fa05.) |
||
|
|
6a41f826c8 |
Document linked-function names and constants; lane test on the device
docs/API.md section 3 states the rule: a reference resolves by LinkedFunction::name (the specialized name, else the function's own), a linked module with constants is specialized with the function's values, a specialized function reads an unvalued constant as undefined, and an unspecialized one (newFunctionWithName:) that reaches a constant is refused with LinkProblem::UnresolvedConstant. Section 10 adds the zero read of a linked function's unvalued constant to the accepted differences. The runtime README says how a stage links visible functions and by which name. The probe's header records its 19 cases as measured on the M3 Max under macOS 27.0.1 (26A434), MTL_DEBUG_LAYER unset, one case a process through maclock: the four of the brief (specialized 16, plain and other unresolved custom_fn, both 16) and the constant shapes (newFunctionWithName: reaching the constant, guarded or not, fails "cannot lower module with unresolved function constants"; plain_fn links; every specialized form links, unvalued reads storing nothing). runtime_lane::linked_functions runs both through the runtime: names answered, 16 at word 0 with every word 3x + 1, plain and another_fn needing custom_fn, both 16; derived 6x, guarded 3x and x - 1, plain_fn x + 2, base_fn unvalued 1; by name: base_fn and guarded_fn refused UnresolvedConstant, plain_fn 7, constantValues 3 16, empty values and a descriptor without values link. tests::pipeline gains the duplicate-name check by link name: one function under its own and a specialized name is no repeat, two under one specialized name are. Verified: on this M3 Max, MoltenVK, through maclock and memcap (6 GiB), RUSTFLAGS='--cfg m2v_gpu' cargo nextest run -p metal2vulkan-validation --all-features -E 'test(/runtime_lane::linked_functions::/)': 2/2 passed. cargo nextest run -p metal2vulkan-runtime --all-features -E 'test(/tests::pipeline::/)': 5/5 passed. (Carried to development from steelbrain/reims-graphics-kext 228cf1424c.) |
||
|
|
5a0f529a26 |
SEMANTICS_VERSION 1933; bless the signatures and the new fixtures' rows
SEMANTICS_VERSION 1933: a reference now resolves by a linked function's specialized name, and a linked module that declares function constants or has a static initializer is specialized and linked rather than refused (NotImplemented "air.function_constants" / "air.static_init"), an unspecialized function reaching a constant refused with LinkProblem::UnresolvedConstant instead. api_signatures.tsv (scripts/api-signatures/signatures.py --bless): 13 records added, none removed. They are LinkedName.function/.specialized, LinkedFunction.specialized_name/.specialized, name, with_specialized_name and with_specialized, LinkedSource::with_specialized_name/with_specialized, the runtime's FunctionDescriptor.specialized_name and with_specialized_name, and LinkProblem::UnresolvedConstant in both crates. No public type was added, so the api_surface table is unchanged. scripts/refusal-surface/refusal_surface.py leaves docs/REFUSALS.md unchanged (LinkProblem is not one of its families; the Linking sites are counted per function). Golden tables: bless_engine_goldens wrote the two new fixtures' printouts; bless_engine_inventory and bless_golden_hashes added 10 rows each, all engine/linked_specialized_* (the caller's four kernels need their linked function; the functions module's kernel is ok on every profile). No existing row or cell moved. Verified: the 17 fixture, inventory and golden-hash tests that failed before the bless (air_input, public_fixtures_engine::*, golden_hashes) pass. (Carried to development from steelbrain/reims-graphics-kext cd04514790.) |
||
|
|
cbd5ce6048 |
Test linking under a specialized name and linked modules with constants
engine_specialized_name runs the probe's shapes through the public API and the CPU interpreter, over the owned fixtures linked_specialized_caller (now with kernels that call base_fn, guarded_fn and plain_fn by their own names, as the probe's kb, kg and kp do) and linked_specialized_functions: - specialized resolves custom_fn; plain and another_fn need custom_fn; both links; a private function resolves by its specialized name; a reference to the function's own name is not resolved by its specialized copy; - the specialized name and the specialization are in the compile key, and a specialized name equal to the function's own is no other name; - computed values: base_fn with scale 3 stores the probe's 16 at word 0 and 3x + 1 throughout; derived_fn 6x (the static initializer's twice); guarded_fn 3x with the value and x - 1 without; plain_fn x + 2; base_fn specialized without a value reads scale as zero (1); - newFunctionWithName: reaching the constant is refused with LinkProblem::UnresolvedConstant, guarded or not, as Metal refuses byname and guarded-byname; plain_fn links; empty constant values, with_specialized(true) (a descriptor without values) and a value all link; - the specialized kernels pass L3 on every committed profile. A function made by newFunctionWithDescriptor: without constant values links as specialized, as Metal links it (the probe's descriptor-nil and descriptor-empty make the pipeline). The runtime's own `specialized` flag, which its MTLFunction property answers read, is left as it was: whether Metal's properties of such a function are the specialized ones is not measured. Verified: PATH with llvm@21 first, cargo nextest run -p metal2vulkan --all-features -E 'test(/engine_specialized_name/)' --no-capture: 5/5 passed, no SKIPPED line. (Carried to development from steelbrain/reims-graphics-kext d8efd9838c.) |
||
|
|
ae7b7b29ae |
WIP: link functions under their specialized name; specialize linked modules with constants
Parked mid-task at the coordinator's request (owner travelling). Not ready to merge.
What is done:
- Probe crates/metal2vulkan-conformance/probes/linked_function_specialized_name.m, extended
with function-constant shapes. Rerun on this M3 Max, macOS 27.0.1 (26A434), MTL_DEBUG_LAYER
unset, one case a process through maclock. specialized: name custom_fn, word 16. plain and
other: "unresolved visible function reference: custom_fn". both: 16. byname
(newFunctionWithName:, reads the constant): "cannot lower module with unresolved function
constants". guarded-byname (read only behind is_function_constant_defined): the same
refusal. constant-free-byname: 7. byname-empty, descriptor-nil, descriptor-empty, unvalued,
unvalued-empty and derived-empty: the pipeline is made and the word stays the 0xAB fill
(undefined read, store dropped). byname-valued 16, guarded 4, guarded-empty 4,
guarded-valued 15, derived 30, constant-free 7. The header does not record these answers yet.
- metal2vulkan-air: LinkedName gains `function` (the definition's name in its module; `name`
is the name it links under) and `specialized`. plan() no longer refuses a module that
declares function constants or has a static initializer. Such a module is copied,
constants bound (fc::check/bind) and its static initializer evaluated. A specialized
function then has SCCP run over each function it reaches, and unvalued constants read as
undefined. An unspecialized one folds nothing, and a constant (or a global derived from
one) that it reaches is refused with the new LinkProblem::UnresolvedConstant { index }.
reach() takes ModuleParts.
- metal2vulkan: LinkedFunction gains specialized_name (with_specialized_name, name()) and
specialized (with_specialized; with_constants and with_specialized_name set it).
LinkedKey, key hashing, table handles and linked_modules all use the link name and the
full identity. LinkedSource gains with_specialized_name and with_specialized.
- metal2vulkan-runtime: FunctionDescriptor.specialized_name (+ with_specialized_name).
Function answers it as name() and links under it. Functions made by descriptor link as
specialized. duplicate_linked_name and the additions identity compare the link name.
- Owned fixtures linked_specialized_caller/functions (.metal plus regen-air-fixtures
companions, TOOLCHAIN line).
Verified: cargo build --workspace --all-features; metal2vulkan-air suite 486/486 with the new
link_tests (specialized computes with its values; specialized without a value reads zero;
unspecialized reaching a constant is refused, guarded too; constant-free and dead calls
link; links under its name, not its function's; a static initializer without constants
runs).
Not done: translator tests over the new fixtures (specialized, plain, both, other, the
constant shapes); runtime lane test on MoltenVK; negative controls; clippy (plain and
--cfg m2v_gpu); the metal2vulkan suite; SEMANTICS_VERSION 1933; api-signatures bless and
api_surface; docs/REFUSALS.md regen; docs/API.md, the runtime README and the
FAST-PATHS/accepted-differences text; the probe header's measured answers.
Next step: write the engine_linking tests on the fixtures, run the metal2vulkan suite, bump
SEMANTICS_VERSION, bless the signatures, regenerate REFUSALS.md, update docs, run the
negative controls and the lane test, then commit.
(Carried to development from steelbrain/reims-graphics-kext fe07eff5e0.)
|
||
|
|
b4a3540c9d |
Keep a Core Image kernel library's HASH as read instead of verifying it
Core Image's own kernel libraries (ci_stdlib, ci_filters, ci_raw: file
type 1, extern functions over one module) were refused as
Container(HashMismatch), so Library::from_metallib, the runtime's
new_library_with_data and the command line ("FALLBACK (input not read)")
refused what Metal reads, in every process that uses Core Image. The
function table, metadata, extended header (HDYN, UUID) and shared module
were all in the shape the reader already takes; only the HASH check
failed.
What the HASH is, measured with libraries written from scratch under
Xcode 27.2's toolchain (metal -fcikernel, metallib -cikernel) on an M3
Max under macOS 27.0.1:
- metallib -cikernel writes one HASH for every function. For some modules
it is the SHA-256 of the module it writes (the two-kernel library the
file-type-1 support was first measured with, kernels with short
loops); for others it is not, e.g. one kernel with a three-iteration
loop of sin and cos. Not the digest of the input .air, of the stream
without the wrapper, of the module without its zero padding or with
other padding, or of the module round-tripped through metal-opt.
metallib is deterministic, and feeding the written module back through
it gives the same module and the same HASH. What it is a digest of is
not known, so it is not interpreted.
- Metal checks no HASH: the new probe
(crates/metal2vulkan-conformance/probes/metallib_function_hashes.m)
loads an executable library and a Core Image kernel library with one
bit of every HASH flipped exactly as written (the kernel's pipeline
stores 1,4,7,10 both ways), and the Core Image library whose HASH is
not its module's digest as well.
So a Core Image kernel library's HASH is read as 32 bytes, once, present
(as before), kept as read in LibraryFunction::raw_tags, and each
function's content key (LibraryFunction::hash, FunctionInfo::air_hash)
is its module's SHA-256, computed once for the shared range. Every other
library's HASH stays verified (HashMismatch), which is stricter than
Metal; docs/API.md says so.
The same probe found that Metal's externFunctionNames order is not the
reverse of the table's in general: a two-kernel library (tint, shift)
answers it, but a four-kernel library written from scratch, libraries of
10 to 200 kernels and Core Image's own answer the same names in an order
that is neither the table's, its reverse, nor sorted. The runtime keeps
the reverse; Library::extern_function_names' doc now says the order
differs from Metal's (doc only).
No cache version moves: a type-1 library whose HASH matched keeps the
same content key, and one whose HASH did not was refused before. No
translation output changes. The runtime-sources pin moves for the doc
comment in the runtime's library.rs (no behaviour): re-pinned to
d000eb23746160492052af4ff3e62bb81ab598b44fc8684b3cf36105d2c67026.
Verified (M3 Max, macOS 27.0.1):
- New test container::tests::a_core_image_library_hash_is_kept_as_read:
a synthetic type-1 library of three extern functions over one module
whose HASH is not the module's SHA-256 parses, each function's hash is
the module's digest and its HASH is kept raw; one whose HASH is the
digest reads the same; a missing, duplicate or 31-byte HASH is still
MissingTag, DuplicateTag, BadTag; the same table as a dynamic library
is HashMismatch. Negative control: with the exception disabled
(every library verified) the test fails (HashMismatch at parse), the
other 18 container tests pass.
- cargo nextest -p metal2vulkan-air --all-features: 482 passed.
- Locally only, nothing of it committed: Core Image's ci_stdlib,
ci_filters, ci_raw (and ci_stdlib_h) now read through the command line
and through the runtime on MoltenVK: each lists only extern functions
(as many as its table holds), function_names empty, every name made by
new_extern_function_with_name and new_function_with_name with
FunctionType::Extern, a sample of six per library refused as a compute
pipeline (Compile, EntryNotFound), as Metal answers; Metal's own answers
for the same files through the probe agree (type executable, no
function names, the same count of extern names, functionType 4 for
each).
- metal2vulkan core_image_libraries and api_signatures (3), the
validation runtime-sources guard after the re-pin: pass. clippy
--workspace --all-targets --all-features -D warnings, plain and under
--cfg m2v_gpu (own target): clean. rustdoc -D warnings for the three
published crates: clean.
- Not run: the other suites, the device tests, golden tables (no
translation output changes), a corpus census. Core Image's link of
these extern functions into ciKernelMain was not reached locally:
rendering ten built-in filters did not go through Metal's image-filter
link calls on this Mac.
(Carried to development from steelbrain/reims-graphics-kext 2d3259adbf.)
|
||
|
|
0192f03f68 |
Store the zero where a function writes a pass color its pipeline lacks
A fragment function that writes a color of the pass its render pipeline has no pixel format for was refused NotImplemented(Lowering(StageIo)) at that color: what Metal stores there was unmeasured. A consumer's guest hit it on 685 draws (a pass with color 1, a pipeline without it, a function writing [[color(1)]]). Measured with a probe written from scratch (committed as metal2vulkan-conformance/probes/written_color_the_pipeline_lacks.m), on the M3 Max under macOS 27.0.1 with MTL_DEBUG_LAYER unset: plain Metal stores exactly what it stores for a function that does not write the color, zero bytes at every covered texel and the clear or loaded bytes elsewhere. That holds over RGBA8Unorm, RGBA16Float, R32Uint and RGBA32Sint, written in their own numeric class and in another, cleared and loaded, and at 4x through the resolve. So the zeroed variant's fragment function now stores its own output at such a color nowhere, and the zero zeroed_output writes stands as that color's output. A function that reads such a color stays NotImplemented (unmeasured). SEMANTICS_VERSION 1930 -> 1931: a refusal became a module. Verified: - clippy -D warnings, plain and --cfg m2v_gpu (metal2vulkan, metal2vulkan-validation); - the metal2vulkan stage-io, zeroed-color and golden-hash tests (48/48, golden table unchanged); - runtime_lane::extra_colors on MoltenVK on the M3 (6/6), the new a_pass_color_the_pipeline_lacks_is_zeroed_where_the_function_writes_it among them. Without the plan.rs change it fails with the consumer's error, Lowering(StageIo) NotImplemented at Color(1); - the refusal surface and the runtime-sources pin unchanged. Not run: lavapipe, the full suites. On development this lands after the function-constant fix ( |
||
|
|
fbce5e0eeb |
Expect the command line to compile a kernel whose constant is undefined
llvm_text_is_assembled_by_llvm_as still expected the command line to ask for the kernel's function constant (exit 2, a --constant hint). Since undefined constants compile as Metal's do, the kernel compiles without the value; the test now checks that it writes its module, then compiles it again with the value. The test skips its llvm-as half when llvm-as is not on PATH, which is why the lane's suite runs passed it; development's post-merge checks, with Homebrew's LLVM on PATH, failed it. Verified: cargo nextest run -p metal2vulkan --all-features -E 'binary(cli)' with /opt/homebrew/opt/llvm/bin on PATH, 8/8, the llvm-as half running. |
||
|
|
9c80a4957b |
Compile functions whose function constants are left undefined
A function constant the request leaves unset no longer refuses the pipeline with NeedsInput(FunctionConstant). Metal makes that pipeline, optional or required: is_function_constant_defined is false, arguments gated on the constant (negated or not) are absent, and its reads vary from read to read (probes/undefined_function_constant_values.m on the M3 Max, macOS 27.0.1: u + 3 read 0, u * 7 + 1 read 1, u == 0 ? 111 : 222 read 222, b ? 5 : 6 read 5). WindowServer's QuartzCore pipelines leave optional constants unset (fixed_vert_lpf_gen without constant 53), so the desktop could not draw. SCCP's lattice is now flat, the undefined value one more value beside the constants: - a value computed from an undefined constant alone stays undefined, and a pure instruction computing one becomes its type's zero (an address keeps naming the constant's global); - a branch on one takes its false way (a rewrite only where no other way was opened), and a select its false arm; - an and with zero, an or with all ones and a mul by zero are that constant whatever the undefined operand holds, in SCCP and in the static initializer, so QuartzCore's generic || (...) is true with generic set; - an operation that also reads a run's value, and a PHI (an undefined entry merges as overdefined), keep what the run computes, so a defined way keeps its value and a loop counting from the constant still counts. The entry-block refusal and its inliner gate are gone. Entry gains undefined_reads, the undefined constants the specialized body reads, which validation's case checker uses where it used the refusal to prove an omitted constant unread. Removed: MissingInput::FunctionConstant (metal2vulkan-air), RuntimeInput::FunctionConstant (metal2vulkan), the command line's --constant hint. docs/API.md lists the reads under accepted differences. SEMANTICS_VERSION 1932. The golden tables and the engine inventory move only the 532 cells (28 rows by 19 profiles) that were the refusal; each is now ok. Verified: metal2vulkan-air 481/481, with negative controls (absorbing rule off: the two new and/or tests fail; the PHI mapping off: the loop test fails); the core suites; clippy (all features, --cfg m2v_gpu); the command line on the M3's QuartzCore library: fixed_vert_lpf_gen with reims's values (0 and 1 true, 3 = 0) and the whole pipeline with fixed_frag_lpf_cpf translate and pass spirv-val on moltenvk-m3, nvidia-rtx5080-laptop and intel-uhd770-rpls-anv, with generic true keeping the texture-matrix path (521 lines of SPIR-V against 290); every fixed_* pair and backdrop_capture_compute_tile_* with no constants translates but the _spc vertex functions, which ask for a vertex descriptor. |
||
|
|
bf3ce3813c |
Read Core Image kernel libraries and split whole aggregate accesses
A Core Image kernel library (metal -fcikernel, metallib -cikernel) is a
metallib of file type 1 whose kernels (!air.ci) are listed as function
TYPE 5 over one shared module. The container refused the file type
(Unsupported LibraryKind(1)), so newLibraryWithData: failed where Metal
succeeds; the consumer's graphics-kext lane hit it on Core Image's own
helper library in a macOS 26 guest, so every Core Image path stopped
there.
What Metal answers, measured with kernels written from scratch on an M3
Max under macOS 27.0.1 (probe programs over Metal's API and objc's message
log of a CIColorKernel render):
- newLibraryWithData: takes it as MTLLibraryTypeExecutable; functionNames
is empty; the private externFunctionNames lists the kernels in the
reverse of the table's order (libraries of two and four kernels);
- newFunctionWithName:, newFunctionWithDescriptor: and the private
newExternFunctionWithName: make each kernel with functionType 4 (no SDK
enumerator; its description prints "Unknown"); newExternFunctionWithName:
answers as newFunctionWithName: for any library, a kernel of an
executable one included, and nil for a missing name;
- a compute pipeline made from an extern function fails ("Function tint
was not found in the module");
- Core Image fetches each kernel and its own helpers with
newExternFunctionWithName: and links them on the CPU, in Metal.framework's
base device class, into an ordinary executable library holding one
kernel, ciKernelMain, of which it builds a plain compute pipeline.
So now:
- container: file type 1 is read (executable; its functions may share one
bitcode range, hashed once, as a dynamic library's); TYPE 5 is the new
FunctionStage::Extern, no stage: the ABI cross-check refuses it as a
mismatch, Library::Function compiles it as no entry (EntryNotFound,
available 0). Unobserved file types stay LibraryKind refusals.
- FunctionType gains the private enumerator Extern = 4
(regen-metal-enums PRIVATE); reflection maps Extern to it.
- runtime Library: function_names leaves extern functions out;
extern_function_names (reverse table order) and
new_extern_function_with_name are new.
ciKernelMain itself was refused next: Lowering(Arith) at its first
load, `load [4 x <4 x float>], ptr addrspace(2)`, a whole array loaded
from the constant buffer and passed by value to a helper. Lowering reads
and writes buffer and threadgroup memory a scalar or vector at a time.
The new canon pass `aggregates` (after SCCP, beside the other expansions)
replaces each non-volatile, non-atomic load or store of a pointer-free
array or struct in device, constant or threadgroup memory by its members'
accesses in layout order (a getelementptr i8 at the member's distance, the
access's alignment lowered to what the distance allows, joined by
insertvalue or split by extractvalue), at most 256 members, 8 deep.
Thread memory, pointer-holding aggregates (handles), volatile accesses
and larger types stay whole as before. The same-type pointer bitcast
beside the load was never the problem (verified alone).
Public surface: metal2vulkan-air FunctionStage::Extern; metal2vulkan
FunctionStage::Extern and FunctionType::Extern; runtime
Library::extern_function_names and new_extern_function_with_name
(api_signatures blessed: 5 added, none changed or removed). devtools
gains core_image_metallib. The metal-enum generation now records the
macOS 27.2 SDK (the host's Xcode); no SDK value changed, only Extern was
added. LibraryKind's doc and reach note name what it refuses now.
No cache version moves: file type 1 and aggregate accesses outside thread
memory were refused before, so no key reached them, and
golden_hashes_match_the_table passes unchanged (every public fixture
assembled: this Mac's Xcode 27.2 now has its Metal toolchain). The
runtime-sources pin moves (runtime library.rs): re-pinned here to
23766690fd75227c5333e976bfc1fdfafa6ff78f43e0c5ba8fa5183574cd9371.
Verified (M3 Max, macOS 27.0.1):
- Metal versus this tree's runtime on MoltenVK: Core Image's linked
ciKernelMain for a tint color kernel and for a sampler kernel (both
from-scratch CI kernels; the linked libraries captured from Metal in
scratch and deleted after), same constant buffer, source texture and
sampler, 4x4 RGBA32Float target: byte-identical texels, the early-out
column untouched on both. The parent tree answers FALLBACK (Lowering
Arith) for both. Release CLI: 0.01-0.03 s, 11 MiB each.
- Release CLI, parent vs this tree, largest public fixtures
(hfb_filter_bank render pair, tns_mm_flags), three runs each:
0.12-0.13 s vs 0.12-0.16 s and 0.05-0.06 s vs 0.04-0.05 s, 27 MiB both
(runs beside a test suite; the same within noise).
- New tests: canon aggregates (split loads, stores with nested arrays and
lowered alignments, threadgroup; volatile, pointer-holding and
300-element aggregates stay whole), an engine test running a
ciKernelMain-shaped kernel on the CPU interpreter on three profiles,
core_image_libraries (container types, stages, shared hash, functionType
4, EntryNotFound), and a runtime device test on MoltenVK (names, extern
names, both lookups, pipeline refusal, an executable library's kernel
through the extern lookup). Negative controls: the split and execution
tests fail with the pass disabled; the library tests fail with file
type 1 refused.
- cargo nextest -p metal2vulkan -p metal2vulkan-air -p metal2vulkan-runtime
-p metal2vulkan-devtools --all-features: 4927 passed (golden hashes and
the metal-as fixture parts included); -p metal2vulkan-validation
-p metal2vulkan-conformance: 2369, all passed after the re-pin; doctests
ok; clippy --workspace --all-targets --all-features -D warnings and the
runtime's under --cfg m2v_gpu: clean; rustdoc -D warnings and
scripts/api-docs: clean; REFUSALS, METAL-COVERAGE and
CONFORMANCE-COVERAGE re-derived (MTLFunctionTypeExtern is listed as not
yet compared by a conformance case). Not run: a corpus translation
census, and the device suites beyond the new runtime test.
|
||
|
|
cd511955f7 |
Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no longer described the sources and `the_runtime_sources_are_the_committed_ones` would fail. Recomputed over the same inputs and committed by land-pkt.sh. |