One work packet, landed as 4 commits (87ed7f903a..1af72fc0d8 on archive/development-linear-2026-10-28), in order: * Make the mipmap compute filter a plain bilinear filter in float The owner's decision for generate_mipmaps: the device's blit chain is the answer wherever the device blit-filters the format, and a compute filter runs only where it cannot (extended-range formats, formats without blits or linear filtering). That filter is a plain bilinear (trilinear in 3D) filter at texel centres in float, not a model of Apple's datapath. bind::mipmap_filter keeps its planning, scratch layout and first-level fetch, and drops the exact machinery: the measured answer tables, the reciprocal and tail models, the soft-float arithmetic and MipmapRule. The kernel decodes each field to float (Metal's 8-bit sRGB and extended-range sRGB tables, the packed floats and RGB9E5 exactly), sums the taps a linear sampler takes at the texel centres in tap order with no contraction, and encodes to nearest even. It needs no 64-bit integers. cpu.rs is the same filter on the CPU, the kernel's reference. The runtime still names the removed items; it follows in the next commit. Verified: cargo nextest run -p metal2vulkan --all-features --lib -E 'test(/mipmap_filter/) | test(/owned_divisions/)', 9 passed: every kernel validates on every committed profile, and the kernel run in the SPIR-V interpreter equals the CPU filter byte for byte over 38 formats and 9 shapes (arrays, cube, 3D, strips) and over 39 fetched first levels. * Make generate_mipmaps the device's filter: its blits, else the compute filter The owner's decision for generate_mipmaps: the device's blit chain (vkCmdBlitImage, VK_FILTER_LINEAR) is the answer for every format its blits filter, and the compute filter only where they cannot. No refusal for accuracy; refusals stay for what cannot run or what Metal refuses. mipmap_plan::plan_mipmaps now plans Blits, Picks or Filter. A filtered format takes the blit chain where the image's format has BLIT_SRC, BLIT_DST and SAMPLED_IMAGE_FILTER_LINEAR and the image takes transfers; it takes the compute filter where they lack (an extended-range format, an 8-bit sRGB texture held as its UNORM twin, a format without blits or linear filtering) and the filter computes the format in an image of its bytes. Otherwise the refusal names what the blits lack. The 1D refusal is gone (Metal makes 1D textures of one level, which are left as they are). Removed: the per-format first-use check against mipmap_answers.txt (mipmap.rs keeps only the blit recorder), mipmap_answers.txt, MipmapVerdict and Device::mipmap_generation, metal_release::MIPMAP_RULE, the texture facts' check cache, new_runtime_texture (only the check used it), and the degradation kinds mipmaps-within-spread and mipmap-tie-rounding. One kind replaces them: device-filtered-mipmaps (precision), announced once per device on both paths. WorkCounts::mipmaps_filtered counts compute-filter chains; image_blits_recorded counts the chain's blits. The filter kernel now decodes normalized, sRGB-step and extended-range codes by a product with a reciprocal rounded once to f32 instead of a division, so every operation is one Vulkan has a device round correctly and the CPU model is the device's answer on a device keeping f32 subnormals. The validation lane mipmaps_exact becomes mipmap_chains: the blit chain (work counts, each halving level within a code of the float filter, announced), every format the filter computes (the device's blits or the filter, the filter's levels byte for byte the CPU's), an extended-range texture announced as the filter, the picks, and the in-place fetch. texture_blits' every-format lane prints each format's way. Docs: API.md's catalogue, FAST-PATHS.md (a device-gaps row; the BGRA4Unorm gap's text), the runtime README, REFUSALS.md regenerated, api_signatures blessed, api_surface's table. RUNTIME_VERSION 1665 -> 1666 (mipmap behaviour changed) and the runtime-sources pin. Verified: cargo clippy --workspace --all-targets --all-features -D warnings, plain and with --cfg m2v_gpu; rustdoc -D warnings for metal2vulkan and the runtime; the runtime's whole suite plus the translator's surface, fast paths, refusal and mipmap tests (1180 passed); the runtime-sources guard. On lavapipe (scripts/linux-gate, arm64, --cfg m2v_cpu_icd), 13 passed: mipmap_chains (5), texture_blits' every-format lane, read_through_views' mipmaps, memoryless_uses (4), rgbx_textures' refusals and degrade_notices' site list. There the blits made 29 of the 38 formats the filter computes (87 chains), the compute filter made R8Unorm_sRGB, RG8Unorm_sRGB, RG11B10Float, RGB9E5Float, BGR10A2Unorm and the four XR formats (27 chains), each the CPU's byte for byte, and device-filtered-mipmaps was announced once. * Hold the device's filtered mipmaps among the conformance suite's native notes generate_mipmaps is now the device's filter (its blit chain, else the compute filter) and announces device-filtered-mipmaps: the device's own filtering, which rule 1 names, so it joins replay::NATIVE_NOTES beside device-sampling. Values still compare field by field. Verified on the merged tree (5a1a62bb0e + the mipmap commits): clippy --workspace --all-targets --all-features clean; nextest -p metal2vulkan-conformance -p metal2vulkan-runtime: 2140 passed. * 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.
95 lines
5.5 KiB
Rust
95 lines
5.5 KiB
Rust
//! How each kind of degradation's answer stands to Metal's.
|
|
//!
|
|
//! [`Degradation::category`] says what a kind costs; [`Degradation::exactness`] says whether a
|
|
//! program still gets Metal's answer, which a consumer that answers as Metal needs at each
|
|
//! announcement. It follows each kind's documentation, which states the evidence. A precision
|
|
//! kind is a near-equivalent unless its documentation says Metal's own answer is not one value,
|
|
//! or that the work fails instead. A performance kind is exact unless its cost says a pool of the
|
|
//! command buffer's can fail the work.
|
|
|
|
use crate::degradation::{Degradation, DegradationCategory};
|
|
use crate::error::CommandBufferError;
|
|
|
|
/// How a degradation's answer stands to Metal's ([`Degradation::exactness`]).
|
|
#[non_exhaustive]
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
pub enum Exactness {
|
|
/// Metal's answer, exactly: at a cost Metal does not pay
|
|
/// ([`DegradationCategory::Performance`]), or through a use of the device its driver does not
|
|
/// advertise but is measured to run as Metal does ([`DegradationCategory::Validity`]).
|
|
Exact,
|
|
/// Metal's own answer is not one value there (it reads memory-dependent bytes, keeps or
|
|
/// loses texels as its tiler runs, races, or differs from run to run or between Apple's
|
|
/// GPUs), and the runtime gives one such answer.
|
|
OneOfMetals,
|
|
/// The runtime gives no answer where Metal's would differ: the command buffer whose work
|
|
/// would show the difference fails with this error, of
|
|
/// [`FailureOrigin::Runtime`](crate::FailureOrigin::Runtime), where Metal runs it.
|
|
FailsInstead(CommandBufferError),
|
|
/// Metal's answer, exactly, at a cost Metal does not pay, while a pool of the command buffer
|
|
/// (a sixty-fourth of the device's largest device-local heap) holds the work: a draw the pool
|
|
/// cannot hold draws nothing, and its command buffer fails with a [`CommandBufferError`] of
|
|
/// [`FailureOrigin::Runtime`](crate::FailureOrigin::Runtime) where Metal draws it
|
|
/// ([`CommandBufferError::IndexPoolOverflow`] for `indirect-index-bounds-pass`,
|
|
/// [`CommandBufferError::MeshRecordsOverflow`] for `emulated-mesh-draws`,
|
|
/// [`CommandBufferError::TessellationRecordsOverflow`] for `emulated-tessellation-draws`).
|
|
ExactWithinPool,
|
|
/// A recorded near-equivalent of Metal's answer, or an answer where none of Metal's is
|
|
/// measured.
|
|
NearEquivalent,
|
|
}
|
|
|
|
impl Degradation {
|
|
/// How the kind's answer stands to Metal's (the module docs), the same for every
|
|
/// occurrence.
|
|
pub const fn exactness(self) -> Exactness {
|
|
use CommandBufferError as E;
|
|
use Degradation as D;
|
|
match self.category() {
|
|
DegradationCategory::Performance | DegradationCategory::Validity => match self {
|
|
D::IndirectIndexBoundsPass
|
|
| D::EmulatedMeshDraws
|
|
| D::EmulatedTessellationDraws => Exactness::ExactWithinPool,
|
|
_ => Exactness::Exact,
|
|
},
|
|
DegradationCategory::Precision => match self {
|
|
// As each kind's documentation says, Metal reads the memory past the buffer;
|
|
// keeps the earlier texels unless its tiler overflows; reads rows past the first
|
|
// as memory-dependent bytes; runs no stable range; reads what its copy already
|
|
// wrote, differently from run to run; answers a plain state's identifier, an
|
|
// address that differs from run to run. Not `device-filtered-mipmaps`: its levels are
|
|
// the device's filter, at no Apple GPU's answer exactly, so they are a
|
|
// near-equivalent, not one of Metal's. A removed argument's read: Metal gives it no
|
|
// one value (its compiler drops or folds it, and its debug layer reads zero), and
|
|
// the runtime gives zero. A color fill packed where fills ignore the color: Metal
|
|
// writes a constant of its process's, and the runtime one constant, zero. A texture
|
|
// buffer fill's bytes past its pattern's copies: Metal's stack's, zeros in our
|
|
// probes, and the runtime's zeros.
|
|
D::ZeroedIndexFetch
|
|
| D::DontCareStore
|
|
| D::NarrowSurfaceRows
|
|
// Two rows of an IOSurface plane writing the bytes they share: a kernel is the
|
|
// only writer such a plane takes (blits into one are refused) and the row its
|
|
// writes leave there moves with the threadgroup shape, so Metal's answer is not
|
|
// one value; the runtime leaves the earlier row's, one of them.
|
|
| D::CollidingSurfaceRowWrites
|
|
| D::RepeatedExecutionStart
|
|
| D::OverlappingTextureCopyAsMemmove
|
|
| D::PlainStateUniqueIdentifier
|
|
| D::AbsentArgumentRead
|
|
| D::UnpackedFillColor
|
|
| D::TextureBufferFillLeftover
|
|
// Rows of a two-plane buffer blit meeting between Metal's groups of 32 rows: Metal
|
|
// leaves either row's bytes from run to run, the runtime its most frequent whole
|
|
// outcome.
|
|
| D::TwoPlaneBufferBlitOrder
|
|
// Points Metal sizes none of: what it draws is undefined, mostly nothing, and the
|
|
// runtime draws nothing.
|
|
| D::UnsizedPoints => Exactness::OneOfMetals,
|
|
D::EncodedUseRebound => Exactness::FailsInstead(E::EncodedUseRebound),
|
|
_ => Exactness::NearEquivalent,
|
|
},
|
|
}
|
|
}
|
|
}
|