Note a heap texture's YCbCr filter where its handles and sampler can reach one that filters

What. A filtered `half` or `float` sample of a texture an argument buffer holds (a heap's) now
records `PrecisionNote::HalfSampleFilter` / `FloatSampleFilter` on a device that samples through
Metal's own sampler (MoltenVK), as a slot's sample does, under clauses the plan answers at each
draw or dispatch:
- `SpecKey::HeapYCbCrTextures(stage)`: a heap member of the command reaching the stage (a texture
  it makes resident, or binds at a texture slot of the stage) is of a two-plane YCbCr class
  (`TexelFormat::two_plane_ycbcr`);
- through an argument buffer's sampler, `SpecKey::FilteringArgumentSampler`: a listed argument
  sampler (`BindShape::argument_samplers`, every live state) has a linear min, mag or mip filter,
  anisotropy or a cubic filter; through a runtime slot, the bound word (`filtering_word`); a
  constexpr sampler that reads one texel of one level records nothing.
Only a 2D, one-layer, color, single-sample heap sample can reach a two-plane texture, so 3D, array,
depth and multisample heap samples record nothing. The plan computes both keys in `record_noted`
(which now takes the heap's stage reach), so they are a function of the bind shape: the runtime's
bound-value memo, keyed by (variant, plan, specialization), stays valid. The runtime announces a
holding heap clause as `ycbcr-filter-not-exact` (`degrade_clauses`), naming the stage.

Why. A probe on the M3 Max (MoltenVK) showed a 4:4:4 two-plane texture (identity address-mode map:
`YCBCR8_444_2P`, `YCBCR10_444_2P`, their sRGB twins, the packed 10-bit one) held by an argument
buffer and sampled linearly through a constexpr, runtime-slot or argument-buffer sampler ran and
announced nothing, where Metal's own sampler filters the kept image's float texels, not Metal's
exact filter: an under-announcement. (4:2:0, 4:2:2 and the code-reading 4:4:4 textures reached
through handles are refused, `MappedTextureSampling { through: Handles }`; a slot texture sampled
through an argument buffer's sampler is refused at translation, `ArgumentBufferTextures`.) Which
sampler state an argument buffer holds is in its memory, which no plan reads (the binder's rule:
argument samplers come from object lifetimes), so the argument-sampler test is "a live state
filters": a program whose live states are all nearest announces nothing.

SEMANTICS_VERSION 1973 -> 1974 (precision notes change for heap samples on metal-sampler
profiles); ARTIFACT_FORMAT_VERSION 489 -> 490 (two `SpecKey` variants in the codec). The golden
table does not move (no SPIR-V changes). `api_signatures.tsv` gains the two variants.
heap_linear_samples_are_the_device_s now expects the specialized note on MoltenVK 2D samples.

Verified (potluck):
- M3 Max, MoltenVK, GPU (job m3-max-2786): 64/64 lane tests (ycbcr_textures, ycbcr_in_place,
  degrade_notices, pixel_samplers, ycbcr_device_reads, argument_linear_samples), the new
  a_ycbcr_texture_through_an_argument_buffer_announces_its_filter_only_where_it_can_filter
  printing, for YCBCR8_444_2P and YCBCR10_444_2P_sRGB: constexpr linear 1, runtime nearest 0,
  runtime linear 1, argument nearest 0, argument linear 1, argument nearest with a linear state
  alive 1; RGBA16Float 0 in every case.
- lavapipe (msi, llvmpipe LLVM 23.1.1; job m3-max-2775): the same 64/64; announced only where
  the device converted the 8-bit 4:4:4 texture itself.
- M3 unit tests (jobs m3-max-2767, m3-max-2774): the new
  tests::engine_heap_binder::a_heap_texture_s_ycbcr_filter_note_holds_where_its_sampler_can_filter
  and 134 more (engine_heap_binder, engine_ycbcr_in_place, engine_handles, golden_hashes, cache),
  api_signatures/api_surface/refusal_surface 19/19, runtime tests::degradation 17/17; clippy
  plain, --cfg m2v_gpu, --cfg m2v_cpu_icd and rustdoc -D warnings clean.
- Negative controls, both failing: no heap note (the unit test, and the lane's constexpr linear
  case announcing nothing on the M3); a plan answering 1 for both keys (the unit test at
  "YCBCR84442P beside none", the lane's argument nearest case announcing on the M3).
- Release CLI on moltenvk-m3, tip against 80d2dc465f, 3 runs: tail_argument_samplers
  argument_sampler_sample 0.02 s / 25.1 MB both; handles argument_buffer_runtime_sampler 0.02 s /
  25.6 MB both; grd_half_many_samples 0.05 s / 25.9 MB both.

(cherry picked from commit 8403d3746182d6c1acf7795666fc46fea811e660)
This commit is contained in:
Anees Iqbal committed 2026-11-07 02:57:47 -08:00
1 parent cbb3d3891e
commit b37276fa4c
17 files changed
+552 -58

No files matched your search

+11 -3
View File
@@ -2395,7 +2395,14 @@ bound.
format of their codes, which Metal's sampler filters as that format's: neither is announced),
and through a runtime sampler slot only where the sampler bound there filters (a linear
minification, magnification or mip filter, anisotropy, or a cubic filter), read at each draw or
dispatch; an argument buffer's sampler announces it whatever it states.
dispatch. A filtered sample of a texture an argument buffer holds (a 4:4:4 one: a 4:2:0 or 4:2:2
texture a function that samples through handles can reach is refused) is announced at a draw or
dispatch where a texture the command makes resident or binds that its handles can name is
two-plane YCbCr, through a runtime sampler slot only where the bound sampler filters, and
through an argument buffer's sampler only where a live sampler state filters: the runtime does
not read which state the buffer's memory names, so one linear state alive announces it for a
buffer that holds a nearest one. A texture the command neither names nor makes resident, which
its function may still reach through its ID (Metal's read of it is undefined), is not counted.
Cost: where the device converts the planes'
format, the texels are its own Y′CbCr conversion's, at its precision and unclamped where it does
not clamp, not Metal's fixed-point read; elsewhere the texels hold Metal's reads exactly, but the
@@ -3312,7 +3319,8 @@ bound.
module samples a texture with a `half` result through a filter (linear minification or
magnification, a linear mip filter, anisotropy, or a runtime sampler slot whose bound sampler
filters so) that Metal's own sampler (MoltenVK) answers otherwise than Metal filters the format
bound there: a two-plane YCbCr texture's.
bound there: a two-plane YCbCr texture's, at a slot or held by an argument buffer (announced as
`ycbcr-filter-not-exact`).
- `metal2vulkan-degrade-srgb-texel-decode` (precision). `PrecisionNote::SrgbTexelDecode`: The module
reads, samples, or gathers a texture with a `half` or `float` result through the device's sRGB
decode, or decodes the device's filter of its codes, where the texture may be bound in an 8-bit
@@ -3327,7 +3335,7 @@ bound.
- `metal2vulkan-degrade-float-sample-filter` (precision). `PrecisionNote::FloatSampleFilter`: The
module samples a texture with a `float` result through a filter that Metal's own sampler
(MoltenVK) answers otherwise than Metal filters the format bound there: a two-plane YCbCr
texture's.
texture's, at a slot or held by an argument buffer (announced as `ycbcr-filter-not-exact`).
- `metal2vulkan-degrade-function-storage-assumed` (precision).
`PrecisionNote::FunctionStorageAssumed`: A vertex or fragment function keeps more private memory
(its `alloca`s, a call stack among them, or constants held as `Private` variables) than the floor,