Sample extended-range textures through Metal's bicubic filter
A sample of a BGR10_XR, BGRA10_XR or RGB10A8_2P_XR10 texture (or an sRGB twin) through a constexpr bicubic sampler, or through a runtime sampler whose bound word states Cubic, was refused (NotImplemented(SamplerBicubicFilter) in the lowering, NotImplemented(Format) in the binder). It is now Metal's bicubic filter of the decoded texels, measured on an Apple M3 Max (macOS 26.7) through the owned fixture xr_bicubic: random codes of each of the six formats at 16x16, 7x5, 3x3, 2x6 and 1x1, 2,304 coordinates each (every texel's centre, then random ones up to 0.15 of the texture past its edges), through 12 kernels (a runtime Cubic sampler with float and half results; constexpr samplers under clamp to edge with float and half results, repeat, mirrored repeat, clamp to zero, the opaque-white and opaque-black borders, pixel coordinates, and an offset under clamp to edge and repeat): 3,317,760 lanes. What Metal does, and what the lowering now does: the footprint, weights, addressing, a mirrored axis and a level below four texels are the other formats' bicubic filter's, each tap the decoded texel or the border texel through the format's channels; a level below four texels sums as the extended-range linear filter (terms truncated); otherwise each tap's step is weighed by the product of Metal's weights and summed exactly (no term truncated, unlike the linear filter), the step rounded half up, clamped into the steps of the codes 0 and 1023 (a color lane's (0-384)/510 and (1023-384)/510, an sRGB twin's table steps, alpha [0, 1]), and divided by the grid exactly; a half result rounds as the linear filter's does. The clamp is applied to the rounded result, which equals clamping the step because each rounding is monotonic. Every lane but 4,050 matches that model; each of the 4,050 is one step from Metal's (1/8160 a color lane, 1/8192 an sRGB color lane, 1/4080 alpha), its exact sum within 0.014 of a step of a rounding tie that Metal rounds the other way. No model of Metal's datapath tried closes that residue, so the sample records PrecisionNote::BicubicFilterArithmetic, and docs/FAST-PATHS.md and docs/API.md say so. A bfloat or padded form's bicubic sample, a swizzled texture's and a gather through a bicubic sampler were not measured and are refused. How: select_extended takes the bicubic state of a constexpr sampler or of the slot's cubic-sampler variant (LoweringInputs::cubic_samplers) and plans Metal's bicubic filter; the extended sampler emits it through bicubic::filter with Texels::Extended, which fetches each tap's raw texel and decodes it, through the exact routines alone, then clamps. The binder takes a cubic word at an extended-range slot as the cubic-sampler variant's, and gives such a slot the neutral BicubicTexels value in the plan of the pipeline as compiled, which binds the neutral there (it refused the format before naming the variant: the device lane found that). SEMANTICS_VERSION 1693; RUNTIME_VERSION 1184, as a run of an existing artifact with a cubic sampler at an extended-range slot is no longer refused; the runtime-sources hash re-pinned. The table: xr_bicubic.tsv (2,067 samples of the probe's, per texture and kernel the middle texel's centre, four random coordinates, the first sample with a lane at a clamp bound and the first with a lane at a tie), shared through metal2vulkan_devtools::xr_bicubic with the probe's texture generator. Verified on homelab-gem10 (debug builds): - tests::engine_extended_range::bicubic, on the CPU interpreter on the lavapipe and MoltenVK-M3 profiles: every lane of the table through the same 12 kernels, compiled under the six forms' variants (the runtime ones under the cubic-sampler word the binder plans), is Metal's bits but the 136 lanes the table marks, each one step away; each compile validates and its estimate bounds it. A padded or bfloat form's bicubic sample, a swizzled texture's and a gather are refused as above (a two-plane gather as Format, under any sampler); on every committed profile the pipeline as compiled plans the variants with the XR texture and a Cubic sampler bound, and the variant's pipeline plans the same key. - runtime_lane::extended_range_bicubic (new): the 8,268 lanes on the Radeon 780M (RADV), the RTX 3090 and lavapipe, textures written as the probe wrote them: 0 differ from Metal (136 at a tie, one step away), and the state announces bicubic-filter-arithmetic. The extended_range_samples, two_plane_samples and two_plane_copies lanes, whose helpers this shares, pass on all three. - Release build, 12 kernels x 6 forms x 5 profiles (lavapipe, 780M, RTX 5080 Laptop, Arc ANV, MoltenVK-M3): 360 translations, mean 1.31 ms, slowest 1.97 ms (xrb_runtime, BGRA10_XR sRGB, 780M), budget ledger peak at most 935 KiB, process peak RSS 15.6 MB; the linear XR kernels take 0.81 ms on average. - clippy -D warnings (workspace, all features, all targets; validation also under m2v_gpu), rustdoc -D warnings and the doctests pass. Suites: metal2vulkan, -air, -runtime and -devtools 4,566 of 4,567, validation 1,293 of 1,293. The one failure is tests::golden_hashes, whose 380 stale cells are the two new fixtures' alone (smw_writers 7 and xr_bicubic 12 entries x 20 profiles), left to be blessed on development.
This commit is contained in:
1 parent
8f3edd5a6c
commit
4b564766ec
28 files changed
+4272
-141
No files matched your search
+8
-5
@@ -1634,11 +1634,14 @@ fast forms record, and each `PrecisionNote`'s rustdoc states its bound.
|
||||
fragment's evaluated point lies within a bounded distance of Metal's.
|
||||
- `metal2vulkan-degrade-bicubic-filter-arithmetic` (precision).
|
||||
`PrecisionNote::BicubicFilterArithmetic`: Metal's bicubic filter, emulated by fetches with Metal's
|
||||
weights, the 8- and 16-bit normalized formats' exact sum rounded half up onto the format's grid,
|
||||
and the 32-bit float and half-float formats' sums through Metal's accumulators, differs from an
|
||||
Apple M3 Max in what is not yet pinned: a 2D normalized sum within about `2^-21` of the format's
|
||||
range (`1` unsigned, `2` signed) of a rounding tie: Metal may round it to the other side, one grid
|
||||
step away (`1/65535` or `1/32767` for 16-bit, `1/4080` or `1/2032` for 8-bit).
|
||||
weights, the 8- and 16-bit normalized and the extended-range formats' exact sum rounded half up
|
||||
onto the format's grid, and the 32-bit float and half-float formats' sums through Metal's
|
||||
accumulators, differs from an Apple M3 Max in what is not yet pinned: a 2D normalized sum within
|
||||
about `2^-21` of the format's range (`1` unsigned, `2` signed) of a rounding tie: Metal may round
|
||||
it to the other side, one grid step away (`1/65535` or `1/32767` for 16-bit, `1/4080` or `1/2032`
|
||||
for 8-bit); an extended-range 2D sum (`BGR10_XR`, `BGRA10_XR`, `RGB10A8_2P_XR10` and their sRGB
|
||||
twins) within 0.014 of a grid step of a tie likewise (`1/8160` a color lane, `1/8192` an sRGB
|
||||
color lane, `1/4080` alpha).
|
||||
- `metal2vulkan-degrade-sparse-residency` (precision). `PrecisionNote::SparseResidency`: A stage
|
||||
samples or gathers a texture whose residency it observes (`sparse_color::resident()`) through the
|
||||
slot's sparse form, which the module has where the profile enables `shaderResourceResidency`.
|
||||
|
||||
Reference in new issue
Block a user