Translator and runtime: a nearest runtime pixel sampler keeps its texel centre; only linear takes the level-0 arm
The exact arm hands the device's unnormalized sampler Metal's coordinate itself. Under a linear filter that is the device's own filter at Metal's coordinate (DeviceSampling). Under a nearest filter it moves texel selection onto the device sampler's own handling of the coordinate, and the pixel-samplers replays at 82b6989d59 show new slot divergences where the cards matched Metal before: - RX 550 (m3-max-85883): rgba8 and rgba16f nearest-zero and -border. - RTX 3090 (m3-max-85881): subnormal-zero and -border. Metal's recorded answers for the subnormal cases read texel -1 at a negative subnormal and texel 0 at a positive one, so no flush of a subnormal to 0 is taken. What changes: - SamplerWord::reads_unnormalized holds only for pixel coordinates with linear min and mag filters (no mip filter, isotropic, s and t clamped), the descriptor's unnormalized_reads of linear filters. - The shader's level-0 test compares the word's filter bits with UNNORMALIZED_LINEAR alone. Two instructions fewer per test. - A nearest word takes the form shipping before the series: the texel's centre over the size. A gather through a nearest word takes x / N with its PixelSamplerScaling note, as before the series. - The runtime makes twins, and holds level-0 elements, only for linear states. - SamplerWord::UNNORMALIZED_NEAREST is deleted. This series added it and nothing reads it now; it is not on development. - a_words_unnormalized_reads_are_its_descriptors now pairs the word with the descriptor's unnormalized_reads of linear filters: 9 descriptors, linear with linear over 3 by 3 modes. - Docs: the predicate's filters in docs/RESOURCE-ID.md and the runtime README; the sampler module's pixel-coordinate list names the level-0 arm. The conformance pixel_samplers module doc is corrected: a const site under the identity domains reads a normalized sampler, a linear slot site the twin. SEMANTICS_VERSION 2376 and RUNTIME_VERSION 2575 (a nearest word's arm and the runtime's linear-only twins and level-0 elements); the runtime-sources pin is recomputed. Checks: red d9abcdde67 holds only_a_linear_pixel_samplers_word_reads_unnormalized. This commit's gate and the family's card replays are named in the ledger commit that follows.
This commit is contained in:
1 parent
bdf5f42619
commit
c99bf0c6c3
9 files changed
+52
-48
No files matched your search
@@ -23,14 +23,17 @@
|
||||
//! `the_recorded_digests_are_the_m4_answers` hold the recorded M3 answers against the digests an
|
||||
//! Apple M4 answered: same question, two chips.
|
||||
//!
|
||||
//! **What may differ, and what justifies it.** A `const` site hands the device's unnormalized
|
||||
//! sampler the coordinate itself, and a nearest `slot` or `arg` site hands the device's normalized
|
||||
//! sampler its texel's centre over the size, where the device reads exactly Metal's texel. A linear
|
||||
//! `slot` or `arg` site hands it the coordinate divided by the size, which the device's sampler
|
||||
//! reads in its own arithmetic: at a sub-texel step it may read the neighbouring step, which the
|
||||
//! runtime announces on every device (`pixel-sampler-scaling`, and
|
||||
//! `argument-pixel-sampler-scaling` for `arg`). The `slot` site announces it under a nearest
|
||||
//! state too, as the function does not know the bound state.
|
||||
//! **What may differ, and what justifies it.** A nearest site hands the device's normalized
|
||||
//! sampler its texel's centre over the size, where the device reads exactly Metal's texel (a
|
||||
//! nearest `const` site clamped to the edge fetches the texel). A linear `const` or `arg` site
|
||||
//! hands it the coordinate divided by the size, which the device's sampler reads in its own
|
||||
//! arithmetic: at a sub-texel step it may read the neighbouring step, which the runtime announces
|
||||
//! on every device (`pixel-sampler-scaling`, and `argument-pixel-sampler-scaling` for `arg`). A
|
||||
//! linear `slot` site hands the coordinate itself to the bound state's unnormalized twin at the
|
||||
//! texture's level-0 element, so the device's own filter reads Metal's coordinate
|
||||
//! (`device-sampling`, a native note): its weights may still be another sub-texel step than
|
||||
//! Metal's, by the device's own precision. The `slot` site announces `pixel-sampler-scaling`
|
||||
//! under every state, as the function does not know the bound state.
|
||||
//! Each notice is declared at the notices site alone, so a texel that differs still fails the case
|
||||
//! where it differs, and is a `known-gaps-rt.tsv` row naming the note.
|
||||
//!
|
||||
@@ -40,8 +43,9 @@
|
||||
//! sign, or `-2^-126` beside them (`subnormal_grid`). A nearest `slot` or `arg` site hands the
|
||||
//! device its texel's centre `floor(x) + 0.5`, whose `floor` reads a subnormal by the device's
|
||||
//! float controls (`device-denormals`, a native note): where a negative subnormal is a texel apart
|
||||
//! from zero to Metal's sampler, an address mode that reads texel -1 as texel 0 (clamp to edge,
|
||||
//! mirror clamp to edge) answers alike, and clamp to zero and to the border read the border.
|
||||
//! from zero to Metal's sampler (the recorded answers read texel -1 there, and texel 0 at a
|
||||
//! positive subnormal), an address mode that reads texel -1 as texel 0 (clamp to edge, mirror
|
||||
//! clamp to edge) answers alike, and clamp to zero and to the border read the border.
|
||||
//!
|
||||
//! Nothing here can fault a GPU: one small texture, three or four compute passes a case, no loop.
|
||||
//! The coordinates do reach outside the texture, which is what the address modes are for.
|
||||
|
||||
@@ -1803,8 +1803,8 @@ once, as it is made, with no lock, and never rewritten for layouts.
|
||||
count, these and those of a function that asks `get_num_mip_levels` of a storage texture.
|
||||
- Binding 0's elements 131,072 to 196,607 are level-0 elements, and binding 2's elements 8,000 to
|
||||
15,999 unnormalized twins. A sample or gather through a sampler slot whose state reads pixel
|
||||
coordinates (`SamplerWord::reads_unnormalized`: nearest or linear filters alike for min and
|
||||
mag, no mip filter, no anisotropy, and s and t clamped to the edge, to zero or to the border)
|
||||
coordinates (`SamplerWord::reads_unnormalized`: linear filters for min and mag, no mip
|
||||
filter, no anisotropy, and s and t clamped to the edge, to zero or to the border)
|
||||
of a 1D or 2D texture slot, with no compare (`TextureSlot::level_zero_samplers`), samples at
|
||||
the coordinate Metal gives, at level 0, through the state's twin at element `s + 8,000`, the
|
||||
same sampler with Vulkan's unnormalized coordinates, and the texture's level-0 element at
|
||||
|
||||
@@ -1 +1 @@
|
||||
fd0bc690352769791ffb9cdd1459945b6e28444b6429dc68c66b4f0b6ca7b100
|
||||
dfca0dd814c3e885907f41caa3a8b9d0b1d3bf267426c5c7d238d02a4c5bbefb
|
||||
Vendored
+2
-2
@@ -60,7 +60,7 @@ mod tests;
|
||||
/// unchanged version, and its bless records the version. Independent of the crate's version and of
|
||||
/// [`ARTIFACT_FORMAT_VERSION`]. The commit that bumps it says what changed; this comment keeps no
|
||||
/// history.
|
||||
pub const SEMANTICS_VERSION: u32 = 2375;
|
||||
pub const SEMANTICS_VERSION: u32 = 2376;
|
||||
|
||||
/// The byte-layout version of encoded artifacts (`CompiledFunction::to_bytes` and the
|
||||
/// [`PipelineArtifact`] encodings). Every encoded artifact carries it, and a decode under another
|
||||
@@ -93,7 +93,7 @@ pub const ARTIFACT_FORMAT_VERSION: u32 = 610;
|
||||
/// changes no behaviour, and then updates that hash alone with the commit saying why, or changes
|
||||
/// behaviour and also bumps this version. The commit that bumps it says what changed; this comment
|
||||
/// keeps no history.
|
||||
pub const RUNTIME_VERSION: u32 = 2574;
|
||||
pub const RUNTIME_VERSION: u32 = 2575;
|
||||
|
||||
/// Writes a digest as lowercase hex.
|
||||
pub(crate) fn write_hex(f: &mut fmt::Formatter<'_>, name: &str, hash: &Hash256) -> fmt::Result {
|
||||
|
||||
@@ -893,11 +893,8 @@ fn level_zero_test(
|
||||
let word = sampler_word(cx, fb, Pixel::Spec(n))?;
|
||||
let mask = k(fb, SamplerWord::UNNORMALIZED_FILTERS)?;
|
||||
let filters = fb.binary(BinOp::BitwiseAnd, word, mask)?;
|
||||
let nearest = k(fb, SamplerWord::UNNORMALIZED_NEAREST)?;
|
||||
let linear = k(fb, SamplerWord::UNNORMALIZED_LINEAR)?;
|
||||
let is_nearest = fb.binary(BinOp::IEqual, filters, nearest)?;
|
||||
let is_linear = fb.binary(BinOp::IEqual, filters, linear)?;
|
||||
let mut at = fb.binary(BinOp::LogicalOr, is_nearest, is_linear)?;
|
||||
let mut at = fb.binary(BinOp::IEqual, filters, linear)?;
|
||||
// The `s` and `t` axes' address fields.
|
||||
let axes = SamplerWord::ADDRESS
|
||||
.into_iter()
|
||||
|
||||
@@ -84,7 +84,14 @@
|
||||
//! - Every other access is handed `x / N`, from which the device reads its texels and weights in
|
||||
//! its own arithmetic ([`PixelPosition::Scaled`], `PrecisionNote::PixelSamplerScaling`,
|
||||
//! `PrecisionNote::ArgumentPixelSamplerScaling`): a linear filter's sample or a gather through
|
||||
//! any pixel sampler; a comparison's linear filter; and a level query.
|
||||
//! any pixel sampler; a comparison's linear filter; and a level query. The exception is a
|
||||
//! sample or gather through a runtime sampler slot of a float 1D or 2D texture that is no array
|
||||
//! ([`Sampling::level_zero`]): where the bound state's word reads unnormalized (pixel
|
||||
//! coordinates and linear filters, `SamplerWord::reads_unnormalized`) it hands `x` itself to
|
||||
//! the state's unnormalized twin at the texture's level-0 element, and the device's own filter
|
||||
//! reads Metal's coordinate (`PrecisionNote::DeviceSampling`). A nearest word keeps its texel's
|
||||
//! centre above, which reads Metal's texel at a texel's edge and at a subnormal coordinate
|
||||
//! where a device's unnormalized sampler handed `x` may read another.
|
||||
//!
|
||||
//! A constexpr pixel sampler with nearest filtering and clamp-to-edge addressing instead fetches
|
||||
//! its texel, `OpImageFetch(clamp(floor(coord) + offset))` ([`SampleOp::PixelFetch`]), which also
|
||||
|
||||
@@ -981,18 +981,14 @@ impl SamplerWord {
|
||||
mask
|
||||
}
|
||||
|
||||
/// The bits of a sampler's filters that decide whether the device's unnormalized sampler reads
|
||||
/// it ([`reads_unnormalized`](Self::reads_unnormalized)): the word masked by them is
|
||||
/// [`UNNORMALIZED_NEAREST`](Self::UNNORMALIZED_NEAREST) or
|
||||
/// [`UNNORMALIZED_LINEAR`](Self::UNNORMALIZED_LINEAR) exactly for one.
|
||||
/// The bits of a sampler's filters that decide whether a runtime sampler slot reads it through
|
||||
/// the device's unnormalized sampler ([`reads_unnormalized`](Self::reads_unnormalized)): the
|
||||
/// word masked by them is [`UNNORMALIZED_LINEAR`](Self::UNNORMALIZED_LINEAR) exactly for one.
|
||||
pub const UNNORMALIZED_FILTERS: u32 = Self::PIXEL_COORDINATES
|
||||
| Self::MIN_LINEAR
|
||||
| Self::MAG_LINEAR
|
||||
| Self::MIP_FILTER
|
||||
| Self::ANISOTROPIC;
|
||||
/// [`UNNORMALIZED_FILTERS`](Self::UNNORMALIZED_FILTERS) of a pixel sampler of nearest filters,
|
||||
/// no mip filter, isotropic.
|
||||
pub const UNNORMALIZED_NEAREST: u32 = Self::PIXEL_COORDINATES;
|
||||
/// [`UNNORMALIZED_FILTERS`](Self::UNNORMALIZED_FILTERS) of a pixel sampler of linear filters,
|
||||
/// no mip filter, isotropic.
|
||||
pub const UNNORMALIZED_LINEAR: u32 = Self::PIXEL_COORDINATES | Self::LINEAR;
|
||||
@@ -1001,21 +997,22 @@ impl SamplerWord {
|
||||
/// device's `CLAMP_TO_EDGE` and `CLAMP_TO_BORDER` are.
|
||||
pub const UNNORMALIZED_MODES: [u32; 3] = [0, 4, 5];
|
||||
|
||||
/// Whether the device's unnormalized sampler (`VkSamplerCreateInfo::unnormalizedCoordinates`)
|
||||
/// reads the sampler of this word as it is, the word's form of a descriptor's
|
||||
/// `metal::sampler::unnormalized_reads`: pixel coordinates, one minification and
|
||||
/// magnification filter (nearest or linear), no mip filter, no anisotropy, and on the `s` and
|
||||
/// `t` axes one of [`UNNORMALIZED_MODES`](Self::UNNORMALIZED_MODES). A sample or gather
|
||||
/// Whether a runtime sampler slot reads the sampler of this word through the device's
|
||||
/// unnormalized sampler (`VkSamplerCreateInfo::unnormalizedCoordinates`): pixel coordinates,
|
||||
/// linear minification and magnification filters, no mip filter, no anisotropy, and on the `s`
|
||||
/// and `t` axes one of [`UNNORMALIZED_MODES`](Self::UNNORMALIZED_MODES), the word's form of a
|
||||
/// descriptor's `metal::sampler::unnormalized_reads` of linear filters. A sample or gather
|
||||
/// through a runtime sampler slot whose word this holds for reads the texture's level-0
|
||||
/// element through the state's unnormalized twin at the coordinate itself (docs/RESOURCE-ID.md,
|
||||
/// [`TextureSlot::level_zero_samplers`](crate::pipeline::TextureSlot::level_zero_samplers)).
|
||||
/// A pixel sampler of nearest filters is handed its texel's centre over the size instead,
|
||||
/// which reads Metal's texel at a texel's edge and at a subnormal coordinate, where a device's
|
||||
/// unnormalized sampler handed the coordinate itself may read another.
|
||||
pub fn reads_unnormalized(self) -> bool {
|
||||
let filters = self.0 & Self::UNNORMALIZED_FILTERS;
|
||||
let mode = |axis: usize| (self.0 & Self::ADDRESS[axis]) >> Self::ADDRESS_SHIFT[axis];
|
||||
matches!(
|
||||
filters,
|
||||
Self::UNNORMALIZED_NEAREST | Self::UNNORMALIZED_LINEAR
|
||||
) && (0..2).all(|axis| Self::UNNORMALIZED_MODES.contains(&mode(axis)))
|
||||
filters == Self::UNNORMALIZED_LINEAR
|
||||
&& (0..2).all(|axis| Self::UNNORMALIZED_MODES.contains(&mode(axis)))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1048,9 +1045,10 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
/// A word's `reads_unnormalized` is its descriptor's `unnormalized_reads`, over every
|
||||
/// coordinate kind, pair of filters, mip filter, anisotropy and pair of `s` and `t` address
|
||||
/// modes, with the `r` axis's mode, the border, the comparison and the reduction moved too.
|
||||
/// A word's `reads_unnormalized` is its descriptor's `unnormalized_reads` of linear filters,
|
||||
/// over every coordinate kind, pair of filters, mip filter, anisotropy and pair of `s` and `t`
|
||||
/// address modes, with the `r` axis's mode, the border, the comparison and the reduction moved
|
||||
/// too.
|
||||
#[test]
|
||||
fn a_words_unnormalized_reads_are_its_descriptors() {
|
||||
let mut seen = [0usize; 2];
|
||||
@@ -1075,7 +1073,9 @@ mod tests {
|
||||
reduction_mode: SamplerReductionMode::Minimum,
|
||||
..metal_default()
|
||||
};
|
||||
let reads = unnormalized_reads(&desc);
|
||||
let reads = unnormalized_reads(&desc)
|
||||
&& min_filter == SamplerMinMagFilter::Linear
|
||||
&& mag_filter == SamplerMinMagFilter::Linear;
|
||||
assert_eq!(
|
||||
SamplerWord::of(&desc).reads_unnormalized(),
|
||||
reads,
|
||||
@@ -1089,10 +1089,8 @@ mod tests {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Each answer is met: the five pairs of filters that read as one (nearest with nearest or
|
||||
// Metal's raw value 2, which filters as nearest, in either place, and linear with linear),
|
||||
// three modes on each axis.
|
||||
assert_eq!(seen[1], 5 * 3 * 3);
|
||||
// Each answer is met: linear with linear, three modes on each axis.
|
||||
assert_eq!(seen[1], 3 * 3);
|
||||
}
|
||||
|
||||
/// Of the pixel samplers the device's unnormalized sampler reads, a runtime sampler slot reads
|
||||
|
||||
@@ -119,7 +119,6 @@ assoc-const metal2vulkan::metal::sampler::SamplerWord::REDUCTION_SHIFT pub const
|
||||
assoc-const metal2vulkan::metal::sampler::SamplerWord::UNNORMALIZED_FILTERS pub const UNNORMALIZED_FILTERS: u32
|
||||
assoc-const metal2vulkan::metal::sampler::SamplerWord::UNNORMALIZED_LINEAR pub const UNNORMALIZED_LINEAR: u32
|
||||
assoc-const metal2vulkan::metal::sampler::SamplerWord::UNNORMALIZED_MODES pub const UNNORMALIZED_MODES: [u32; 3]
|
||||
assoc-const metal2vulkan::metal::sampler::SamplerWord::UNNORMALIZED_NEAREST pub const UNNORMALIZED_NEAREST: u32
|
||||
assoc-const metal2vulkan::pipeline::AccessSet::READ pub const READ: AccessSet
|
||||
assoc-const metal2vulkan::pipeline::AccessSet::READ_WRITE pub const READ_WRITE: AccessSet
|
||||
assoc-const metal2vulkan::pipeline::AccessSet::UNUSED pub const UNUSED: AccessSet
|
||||
@@ -291,7 +290,6 @@ assoc-const-value metal2vulkan::metal::sampler::SamplerWord::REDUCTION_SHIFT 19
|
||||
assoc-const-value metal2vulkan::metal::sampler::SamplerWord::UNNORMALIZED_FILTERS Self::PIXEL_COORDINATES | Self::MIN_LINEAR | Self::MAG_LINEAR | Self::MIP_FILTER | Self::ANISOTROPIC
|
||||
assoc-const-value metal2vulkan::metal::sampler::SamplerWord::UNNORMALIZED_LINEAR Self::PIXEL_COORDINATES | Self::LINEAR
|
||||
assoc-const-value metal2vulkan::metal::sampler::SamplerWord::UNNORMALIZED_MODES [0, 4, 5]
|
||||
assoc-const-value metal2vulkan::metal::sampler::SamplerWord::UNNORMALIZED_NEAREST Self::PIXEL_COORDINATES
|
||||
assoc-const-value metal2vulkan::pipeline::AccessSet::READ AccessSet
|
||||
assoc-const-value metal2vulkan::pipeline::AccessSet::READ_WRITE AccessSet
|
||||
assoc-const-value metal2vulkan::pipeline::AccessSet::UNUSED AccessSet
|
||||
|
||||
|
Can't render this file because it is too large.
|
+2
-2
@@ -119,8 +119,8 @@ sample depends on them (pixel coordinates, a nearest pixel sampler).
|
||||
|
||||
A runtime sampler slot's sample or gather of a 1D or 2D texture slot, not an array, with no
|
||||
compare, takes Metal's pixel coordinate itself where the bound sampler's word reads unnormalized
|
||||
(`SamplerWord::reads_unnormalized`: pixel coordinates, nearest or linear filters alike for min and
|
||||
mag, no mip filter, no anisotropy, and `s` and `t` clamped to the edge, to zero or to the border)
|
||||
(`SamplerWord::reads_unnormalized`: pixel coordinates, linear filters for min and mag, no mip
|
||||
filter, no anisotropy, and `s` and `t` clamped to the edge, to zero or to the border)
|
||||
and the texture's index is below 65,536. It samples at that coordinate, moved by its offset, at
|
||||
level 0, through element `s + 8,000` of binding 2 (`pipeline::UNNORMALIZED_TWIN_ELEMENT`), the
|
||||
device sampler of sampler `s`'s descriptor made with `unnormalizedCoordinates`, and element
|
||||
|
||||
Reference in new issue
Block a user