Translator: the anisotropic emulation deleted; a device without samplerAnisotropy refuses an anisotropic sampler

What: lower/sampler/anisotropic.rs and its tests, the emulated filter's
routine arm, SpecKey::SamplerAnisotropy, LoweringInputs and VariantKey's
anisotropic samplers, and PrecisionNote::AnisotropicFilter and
DeviceAnisotropicFilter (no producer is left) are deleted.
metal::sampler::check_sampler refuses a sampler of maxAnisotropy above 1
for a use that filters on a device without samplerAnisotropy
(Feature::SamplerAnisotropy, needing the feature): a constexpr sampler
where the function that samples through it compiles, a runtime or
argument buffer's sampler where it is made. A runtime slot's sample
compiles as the plain sample.

docs/API.md's precision-note catalogue loses the two notes,
docs/REFUSALS.md and scripts/refusal-surface/reach.tsv are regenerated
(SamplerAnisotropy is now a device refusal), api_signatures.tsv loses
the deleted items, and the runtime README line on the emulation goes.
SEMANTICS_VERSION 2363 (renumbered at landing: 2360, 2361 and 2362 went to
the seq_cst fence, the argument buffer border texels and the
partial-threadgroups cause). runtime-sources.sha256
is pinned at this tree.

Consumer search (read only), reims-vgpu development 4bb5db49fc and every
steelbrain/* branch younger than a day, 184 refs, git grep over *.rs,
*.toml and *.md: AnisotropicFilter, DeviceAnisotropicFilter,
anisotropic_samplers, SpecKey::SamplerAnisotropy and both degrade ids:
0 hits each.

Why: the planner ruled the emulation deleted directly after G1: under the
one form it is reached only on a device without samplerAnisotropy, where
Metal's anisotropic filter is not the device's, and the refusal names
the feature that device lacks.

Verified: job m3-max-84770 (CPU only, no card): the previous commit's red
test passes at this commit (1 run, 1 passed); the golden and engine
inventory lists at 9886324e31 and at this commit show 0 computed cells
moved of 28,950 and no inventory line (the table's 28,950 cells are
re-keyed by development's own profile changes, waiting for the pin's
bless). The stack's tip ran the whole gate (see its message).
This commit is contained in:
Anees Iqbal committed 2026-12-03 11:57:02 -08:00
1 parent c347ac4287
commit 09b6d0fb89
33 files changed
+85 -2360

No files matched your search

@@ -108,10 +108,6 @@ pub enum Degradation {
ArgumentPixelSamplerScaling,
/// [`PrecisionNote::HalfOutputPrecision`].
HalfOutputPrecision,
/// [`PrecisionNote::AnisotropicFilter`].
AnisotropicFilter,
/// [`PrecisionNote::DeviceAnisotropicFilter`].
DeviceAnisotropicFilter,
/// [`PrecisionNote::DevicePointSize`].
DevicePointSize,
/// [`PrecisionNote::ClippedCoverageSplit`].
@@ -233,8 +229,6 @@ impl Degradation {
Degradation::LinkedSamplerNumbering,
Degradation::ArgumentPixelSamplerScaling,
Degradation::HalfOutputPrecision,
Degradation::AnisotropicFilter,
Degradation::DeviceAnisotropicFilter,
Degradation::DevicePointSize,
Degradation::ClippedCoverageSplit,
Degradation::LoopedSampleOutputs,
@@ -330,8 +324,6 @@ impl Degradation {
Degradation::LinkedSamplerNumbering => PrecisionNote::LinkedSamplerNumbering,
Degradation::ArgumentPixelSamplerScaling => PrecisionNote::ArgumentPixelSamplerScaling,
Degradation::HalfOutputPrecision => PrecisionNote::HalfOutputPrecision,
Degradation::AnisotropicFilter => PrecisionNote::AnisotropicFilter,
Degradation::DeviceAnisotropicFilter => PrecisionNote::DeviceAnisotropicFilter,
Degradation::DevicePointSize => PrecisionNote::DevicePointSize,
Degradation::ClippedCoverageSplit => PrecisionNote::ClippedCoverageSplit,
Degradation::LoopedSampleOutputs => PrecisionNote::LoopedSampleOutputs,
@@ -413,8 +405,6 @@ impl Degradation {
PrecisionNote::LinkedSamplerNumbering => Degradation::LinkedSamplerNumbering,
PrecisionNote::ArgumentPixelSamplerScaling => Degradation::ArgumentPixelSamplerScaling,
PrecisionNote::HalfOutputPrecision => Degradation::HalfOutputPrecision,
PrecisionNote::AnisotropicFilter => Degradation::AnisotropicFilter,
PrecisionNote::DeviceAnisotropicFilter => Degradation::DeviceAnisotropicFilter,
PrecisionNote::DevicePointSize => Degradation::DevicePointSize,
PrecisionNote::ClippedCoverageSplit => Degradation::ClippedCoverageSplit,
PrecisionNote::LoopedSampleOutputs => Degradation::LoopedSampleOutputs,
@@ -479,8 +479,8 @@ pub fn reads_opaque_black_border(spec: &crate::case::SamplerSpec) -> bool {
/// visibility result (`device-occlusion-count`), announced by every such mode set.
///
/// **What is not here**, and stays each case's to declare: a note of what the device **lacks**
/// (`device-signed-zero-inf-nan`, `device-anisotropic-filter`, `device-point-size`,
/// `restricted-depth-range`, `restricted-depth-upload`), of an emulation's own precision (`grad-from-bias`,
/// (`device-signed-zero-inf-nan`, `device-point-size`, `restricted-depth-range`,
/// `restricted-depth-upload`), of an emulation's own precision (`grad-from-bias`,
/// `pixel-sampler-scaling`, `bicubic-filter-arithmetic`), of a Metal form not measured or not built
/// (`blended-write-rounding`, `device-interpolation`, `reduction-order`), a native answer whose
/// catalogue entry states the bound the cases that read it hold it to (the device's decode of a
+2 -2
View File
@@ -4523,8 +4523,8 @@ cache is answered compile-required on both.
`a_storage_cube_written_by_face_is_the_2d_array_element_of_its_faces`;
- a texture argument sampled through a sampler the identity sampling does not take ("a texture
argument sampled through a sampler the identity sampling does not take"), and a sampler
argument whose minimum level or emulated filter the function specializes ("a sampler argument
whose minimum level or emulated filter the function specializes"): no test yet. A clamped LOD
argument whose minimum level the function specializes ("a sampler argument whose minimum level
the function specializes"): no test yet. A clamped LOD
query outside a fragment function through a sampler argument is lowered, its level read from
the word of the sampler's resource ID (docs/API.md, Accepted differences): the translator test
`under_the_identity_domains_a_runtime_samplers_query_reads_its_pushed_word`;
@@ -1 +1 @@
b369da90281b9e18a37347585baa6c31498764bc993d780ed3ac76a9a2489c60
33ebe1edbb044de9d8562b94ef26a1e72899caadb81f75f81b1538d1b2650b34
@@ -368,8 +368,6 @@ pub fn allowance(note: PrecisionNote) -> Allowance {
| N::CubeGradientFootprint
| N::SrgbTexelDecode
| N::QuadsCountedBeforeDiscard
| N::AnisotropicFilter
| N::DeviceAnisotropicFilter
| N::ClippedCoverageSplit
| N::HalfOutputFastMathBlend
| N::DeviceSampling
@@ -279,8 +279,6 @@ pub fn reach(note: PrecisionNote) -> Reach {
| N::SrgbTexelDecode
| N::ViewBaseTexelOffset
| N::LinkedSamplerNumbering
| N::AnisotropicFilter
| N::DeviceAnisotropicFilter
| N::DeviceSampling
| N::DeviceTexelConversion
| N::DeviceSampleLevel
+1 -3
View File
@@ -851,7 +851,7 @@ codec_enum! {
RenderAreaWidth, RenderAreaHeight, OutOfBoundsAlpha(f0), SparseTexture(f0), TgOffset(f0),
TileThreadgroupLength, TileGridWidth, TextureSwizzle(f0),
ObjectLocalSize(f0), ObjectFlatLocalSize, ObjectMultiRegion, SamplerMinLevel(f0),
OffsetBaseAxes(f0), SamplerAnisotropy(f0),
OffsetBaseAxes(f0),
NearestPixelSampler(f0),
BorderTexels(f0), DeepThreadgroup,
WorkgroupSize(f0), TexelBufferWords { stage, handles },
@@ -1364,8 +1364,6 @@ codec_enum! {
LinkedSamplerNumbering,
ArgumentPixelSamplerScaling,
HalfOutputPrecision,
AnisotropicFilter,
DeviceAnisotropicFilter,
DevicePointSize,
ClippedCoverageSplit,
LoopedSampleOutputs,
+2 -14
View File
@@ -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 = 2362;
pub const SEMANTICS_VERSION: u32 = 2363;
/// The byte-layout version of encoded artifacts (`CompiledFunction::to_bytes` and the
/// [`PipelineArtifact`] encodings). Every encoded artifact carries it, and a decode under another
@@ -281,11 +281,6 @@ pub struct VariantKey {
/// a list's base vertex cannot carry (`RuntimeFact::PrivateList`).
#[cfg_attr(feature = "serde", serde(default))]
pub private_list: bool,
/// The runtime sampler slots that the shape binds to a sampler whose word states anisotropy (`SamplerWord::ANISOTROPIC`,
/// `LoweringInputs::anisotropic_samplers`): the variant whose function takes Metal's
/// anisotropic filter, emulated, at each one's samples.
#[cfg_attr(feature = "serde", serde(default))]
pub anisotropic_samplers: BTreeSet<SlotRef>,
/// The texture slots of a kernel of OpenCL mode whose `RuntimeFact::OpenClLineTexture` (a 1D
/// image it reads as the 2D texture of height 1 Apple's OpenCL binds) the shape binds a 1D or
/// 1D array texture at (`LoweringInputs::open_cl_lines`): the variant's kernel declares each
@@ -329,13 +324,12 @@ impl VariantKey {
&& self.primitive_id_indices.is_none()
&& !self.quad_primitive_ids
&& !self.private_list
&& self.anisotropic_samplers.is_empty()
&& self.open_cl_lines.is_empty()
&& !self.region_viewports
}
/// The lowering inputs of the function of `stage` under this key: its storage-image choices,
/// device-address slots, kept storage views, raw sRGB slots, anisotropic samplers,
/// device-address slots, kept storage views, raw sRGB slots,
/// for the kernel the emulated simdgroups, the flat grid, the folded groups, the partial
/// threadgroups and the replay's bindings, for the vertex and fragment functions the draws of one amplification each, for
/// the fragment function the colors it writes zero to and those it drops, its depth's clamp
@@ -383,12 +377,6 @@ impl VariantKey {
.filter(|_| stage != crate::pipeline::sym::Stage::Kernel);
out.region_viewports =
self.region_viewports && stage == crate::pipeline::sym::Stage::Vertex;
out.anisotropic_samplers = self
.anisotropic_samplers
.iter()
.filter(|s| s.stage == stage)
.copied()
.collect();
out.open_cl_lines = self
.open_cl_lines
.iter()
+3 -3
View File
@@ -691,7 +691,8 @@ pub enum Feature {
StorageTextureInVertexStage,
/// Cube arrays.
CubeArray,
/// Sampler anisotropy an argument buffer lists, on a device without `samplerAnisotropy`.
/// A sampler of `maxAnisotropy` above 1 for a use that filters, on a device without
/// `samplerAnisotropy` (`metal::sampler::check_sampler`).
SamplerAnisotropy,
/// Sampler border colors Vulkan cannot express.
SamplerBorderColor,
@@ -1109,8 +1110,7 @@ pub enum IdentityCause {
/// function.
ObjectOrMeshStage,
/// A sample through a sampler the identity sampling does not take: a sampler argument whose
/// minimum level or emulated filter the function specializes, a bicubic filter of a 1D
/// texture, or an anisotropic sampler slot whose filter the function emulates.
/// minimum level the function specializes, or a bicubic filter of a 1D texture.
SamplerState,
/// A storage texture access the device takes only with a declared format, whose bound format
/// no input names under the identity domains.
File diff suppressed because it is too large. Load diff
@@ -1,377 +0,0 @@
//! Metal's anisotropic filter: where a sample takes the device's own filter, the module's shape and
//! the notes it records; every module validated by `spirv-val` under its profile. These are shape
//! tests.
//!
//! `llvm-as` assembles the fixtures; without it the tests skip visibly.
use std::sync::atomic::{AtomicU64, Ordering};
use crate::air::abi::{Filter, MipFilter};
use crate::device::profile::DeviceProfile;
use crate::device::requirements::VkFeature;
use crate::device::Device;
use crate::library::FunctionArtifact;
use crate::pipeline::artifact::PrecisionNote;
use crate::pipeline::testing::{compile, link_and_validate, llvm_assemble, profile, AssembleError};
const HEADER: &str = "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v24:32:32-v32:32:32-v48:64:64-v64:64:64-v96:128:128-v128:128:128-v192:256:256-v256:256:256-v512:512:512-v1024:1024:1024-n8:16:32\"\ntarget triple = \"air64_v28-apple-macosx26.0.0\"\n\n";
/// A public fixture's constexpr sampler words (bit 63 clear), the base of the states below.
const BASE_WORDS: u64 = 34901797601036873;
const OP_IMAGE_SAMPLE_IMPLICIT_LOD: u16 = 87;
const OP_IMAGE_SAMPLE_EXPLICIT_LOD: u16 = 88;
const OP_IMAGE_QUERY_LEVELS: u16 = 106;
/// The constexpr sampler words of linear filters, mip filter `mip` and `maxAnisotropy` `aniso`.
fn words(mip: MipFilter, aniso: u32) -> u64 {
let mut s = super::super::constexpr::state_of([BASE_WORDS, 0]).expect("state");
s.min_filter = Filter::Linear;
s.mag_filter = Filter::Linear;
s.mip_filter = mip;
s.max_anisotropy = aniso;
super::super::constexpr::state_words(&s)[0]
}
fn assemble(name: &str, body: &str) -> Option<Vec<u8>> {
static NEXT: AtomicU64 = AtomicU64::new(0);
let dir = std::env::temp_dir().join(format!(
"m2v-anisotropic-{}-{}-{name}",
std::process::id(),
NEXT.fetch_add(1, Ordering::Relaxed)
));
std::fs::create_dir_all(&dir).expect("scratch");
let ll = dir.join("k.ll");
std::fs::write(&ll, format!("{HEADER}{body}")).expect("write");
let r = llvm_assemble(&ll);
let _ = std::fs::remove_dir_all(&dir);
match r {
Ok(b) => Some(b),
Err(AssembleError::Missing(why)) => {
eprintln!("SKIPPED: {why}");
None
}
Err(AssembleError::Rejected(why)) => panic!("llvm-as rejected {name}: {why}\n{body}"),
}
}
/// A fragment function sampling `texture2d<float>` slot 0 at its position over 16 at its
/// implicit level, through the constexpr sampler of first state word `words`.
fn constexpr_fragment(words: u64) -> String {
format!(
r#"@__air_sampler_state = internal addrspace(2) constant [2 x i64] [i64 {words}, i64 0], align 8
define <4 x float> @k(<4 x float> %pos, ptr addrspace(1) %t) {{
%xy = shufflevector <4 x float> %pos, <4 x float> poison, <2 x i32> <i32 0, i32 1>
%uv = fmul <2 x float> %xy, <float 6.250000e-02, float 6.250000e-02>
%r = call {{ <4 x float>, i8 }} @air.sample_texture_2d.v4f32(ptr addrspace(1) %t, ptr addrspace(2) @__air_sampler_state, <2 x float> %uv, i1 true, <2 x i32> zeroinitializer, i1 false, float 0.000000e+00, float 0.000000e+00, i32 0)
%v = extractvalue {{ <4 x float>, i8 }} %r, 0
ret <4 x float> %v
}}
declare {{ <4 x float>, i8 }} @air.sample_texture_2d.v4f32(ptr addrspace(1), ptr addrspace(2), <2 x float>, i1, <2 x i32>, i1, float, float, i32)
!air.fragment = !{{!0}}
!air.sampler_states = !{{!6}}
!0 = !{{ptr @k, !1, !3}}
!1 = !{{!2}}
!2 = !{{!"air.render_target", i32 0, i32 0, !"air.arg_type_name", !"float4"}}
!3 = !{{!4, !5}}
!4 = !{{i32 0, !"air.position", !"air.center", !"air.no_perspective", !"air.arg_type_name", !"float4", !"air.arg_name", !"position"}}
!5 = !{{i32 1, !"air.texture", !"air.location_index", i32 0, i32 1, !"air.sample", !"air.arg_type_name", !"texture2d<float, sample>", !"air.arg_name", !"t"}}
!6 = !{{!"air.sampler_state", ptr addrspace(2) @__air_sampler_state}}
"#
)
}
/// Committed profile `stem` without `samplerAnisotropy`: every Vulkan sampler is isotropic there,
/// so Metal's anisotropic filter is emulated (the emulation's home), the profile the emulation's
/// shape tests compile under.
fn p(stem: &str) -> DeviceProfile {
let mut desc = crate::pipeline::testing::description(stem).expect(stem);
desc.features.remove(&VkFeature::SamplerAnisotropy);
Device::from_queries(desc).expect(stem).profile().clone()
}
/// Committed profile `stem` as described, `samplerAnisotropy` included: the device's own
/// anisotropic filter.
fn full(stem: &str) -> DeviceProfile {
profile(stem).expect(stem)
}
fn ok(bc: &[u8], entry: &str, p: &DeviceProfile) -> std::sync::Arc<FunctionArtifact> {
let a = compile(bc, entry, p).unwrap_or_else(|e| panic!("{entry}: compile: {e}"));
link_and_validate(&a, p).unwrap_or_else(|e| panic!("{entry}: L3: {e}"));
a
}
/// The count of instructions of opcode `op` in `a`'s module.
fn count(a: &FunctionArtifact, op: u16) -> usize {
let words = &a.module.words;
let mut n = 0;
let mut i = 5;
while i < words.len() {
let len = ((words[i] >> 16) as usize).max(1);
n += usize::from((words[i] & 0xffff) as u16 == op);
i += len;
}
n
}
/// The loops of `a`'s module whose `OpLoopMerge` asks the driver not to unroll them
/// (`LoopControl` `DontUnroll`, `0x2`).
fn dont_unroll_loops(a: &FunctionArtifact) -> usize {
const OP_LOOP_MERGE: u32 = 246;
const DONT_UNROLL: u32 = 0x2;
let words = &a.module.words;
let mut n = 0;
let mut i = 5;
while i < words.len() {
let len = ((words[i] >> 16) as usize).max(1);
if words[i] & 0xffff == OP_LOOP_MERGE && len >= 4 {
n += usize::from(words[i + 3] & DONT_UNROLL != 0);
}
i += len;
}
n
}
/// A fragment's implicit-level sample through a constexpr sampler of `maxAnisotropy` 3, 8 and 16
/// under a linear mip filter is the device's own sample on a device with `samplerAnisotropy` (the
/// runtime's floor requires it; MoltenVK's here): one implicit-level sample, unrecorded. An
/// isotropic sampler's is untouched too.
#[test]
fn a_constexpr_anisotropic_sample_takes_metals_filter() {
for aniso in [3, 8, 16] {
let what = format!("maxAnisotropy {aniso}");
let Some(bc) = assemble(&what, &constexpr_fragment(words(MipFilter::Linear, aniso))) else {
return;
};
let a = ok(&bc, "k", &full("moltenvk-m3"));
assert_eq!(
count(&a, OP_IMAGE_SAMPLE_IMPLICIT_LOD),
1,
"{what}, MoltenVK"
);
assert!(
!a.precision.contains(&PrecisionNote::AnisotropicFilter),
"{what}"
);
}
// An isotropic sampler is untouched.
let Some(bc) = assemble(
"isotropic",
&constexpr_fragment(words(MipFilter::Linear, 1)),
) else {
return;
};
let a = ok(&bc, "k", &full("lavapipe"));
assert_eq!(count(&a, OP_IMAGE_SAMPLE_IMPLICIT_LOD), 1, "isotropic");
assert!(!a.precision.contains(&PrecisionNote::AnisotropicFilter));
}
/// A fragment function sampling slot 0, a texture of AIR type `tex_ty`, at its implicit level
/// through the constexpr sampler of first state word `words`: `call` makes `%v` (a `float4`) of
/// `%uv` (the position over 16) or `%uvw` (`%uv` and 0.5); `decl` is the intrinsic's declaration.
fn out_of_reach_fragment(words: u64, tex_ty: &str, call: &str, decl: &str) -> String {
format!(
r#"@__air_sampler_state = internal addrspace(2) constant [2 x i64] [i64 {words}, i64 0], align 8
define <4 x float> @k(<4 x float> %pos, ptr addrspace(1) %t) {{
%xy = shufflevector <4 x float> %pos, <4 x float> poison, <2 x i32> <i32 0, i32 1>
%uv = fmul <2 x float> %xy, <float 6.250000e-02, float 6.250000e-02>
%uvw = shufflevector <2 x float> %uv, <2 x float> <float 5.000000e-01, float 5.000000e-01>, <3 x i32> <i32 0, i32 1, i32 2>
{call}
ret <4 x float> %v
}}
declare {decl}
!air.fragment = !{{!0}}
!air.sampler_states = !{{!6}}
!0 = !{{ptr @k, !1, !3}}
!1 = !{{!2}}
!2 = !{{!"air.render_target", i32 0, i32 0, !"air.arg_type_name", !"float4"}}
!3 = !{{!4, !5}}
!4 = !{{i32 0, !"air.position", !"air.center", !"air.no_perspective", !"air.arg_type_name", !"float4", !"air.arg_name", !"position"}}
!5 = !{{i32 1, !"air.texture", !"air.location_index", i32 0, i32 1, !"air.sample", !"air.arg_type_name", !"{tex_ty}", !"air.arg_name", !"t"}}
!6 = !{{!"air.sampler_state", ptr addrspace(2) @__air_sampler_state}}
"#
)
}
/// [`out_of_reach_fragment`]'s call and declaration of a cube's implicit-level sample.
const CUBE_CALL: &str = "%r = call { <4 x float>, i8 } @air.sample_texture_cube.v4f32(ptr addrspace(1) %t, ptr addrspace(2) @__air_sampler_state, <3 x float> %uvw, i1 false, float 0.0, float 0.0, i32 0)\n %v = extractvalue { <4 x float>, i8 } %r, 0";
const CUBE_DECL: &str = "{ <4 x float>, i8 } @air.sample_texture_cube.v4f32(ptr addrspace(1), ptr addrspace(2), <3 x float>, i1, float, float, i32)";
/// An implicit-level sample out of the emulation's reach (a cube, a 3D texture, a depth texture, a
/// comparison) through a constexpr sampler of `maxAnisotropy` 8 is the device's own filter, and
/// records `DeviceAnisotropicFilter` (never `AnisotropicFilter`) on every device without
/// `samplerAnisotropy`: the sample stays at its implicit level, with no tap. With the feature
/// (MoltenVK's here) neither note is recorded. The same samples through an isotropic sampler record
/// neither.
#[test]
fn an_anisotropic_sample_out_of_reach_records_the_device_filter() {
let anisotropic = words(MipFilter::Linear, 8);
let isotropic = words(MipFilter::Linear, 1);
// `compare_func::less` in a constexpr sampler's first word.
let less = |w: u64| w & !(0xf << 16) | 1 << 16;
let depth = |what: &str| {
format!(
"%r = call {{ float, i8 }} @air.{what}(ptr addrspace(1) %t, ptr addrspace(2) @__air_sampler_state, i32 1, <2 x float> %uv,{} i1 true, <2 x i32> zeroinitializer, i1 false, float 0.0, float 0.0, i32 0)\n %f = extractvalue {{ float, i8 }} %r, 0\n %v = insertelement <4 x float> <float 0.0, float 0.0, float 0.0, float 1.0>, float %f, i64 0",
if what.starts_with("sample_compare") { " float 0.5," } else { "" }
)
};
let cases: [(&str, u64, u64, &str, String, &str); 4] = [
(
"cube",
anisotropic,
isotropic,
"texturecube<float, sample>",
CUBE_CALL.to_owned(),
CUBE_DECL,
),
(
"3d",
anisotropic,
isotropic,
"texture3d<float, sample>",
"%r = call { <4 x float>, i8 } @air.sample_texture_3d.v4f32(ptr addrspace(1) %t, ptr addrspace(2) @__air_sampler_state, <3 x float> %uvw, i1 true, <3 x i32> zeroinitializer, i1 false, float 0.0, float 0.0, i32 0)\n %v = extractvalue { <4 x float>, i8 } %r, 0".to_owned(),
"{ <4 x float>, i8 } @air.sample_texture_3d.v4f32(ptr addrspace(1), ptr addrspace(2), <3 x float>, i1, <3 x i32>, i1, float, float, i32)",
),
(
"depth",
anisotropic,
isotropic,
"depth2d<float, sample>",
depth("sample_depth_2d.f32"),
"{ float, i8 } @air.sample_depth_2d.f32(ptr addrspace(1), ptr addrspace(2), i32, <2 x float>, i1, <2 x i32>, i1, float, float, i32)",
),
(
"compare",
less(anisotropic),
less(isotropic),
"depth2d<float, sample>",
depth("sample_compare_depth_2d.f32"),
"{ float, i8 } @air.sample_compare_depth_2d.f32(ptr addrspace(1), ptr addrspace(2), i32, <2 x float>, float, i1, <2 x i32>, i1, float, float, i32)",
),
];
for (name, anisotropic, isotropic, tex_ty, call, decl) in &cases {
let text = out_of_reach_fragment(*anisotropic, tex_ty, call, decl);
let Some(bc) = assemble(name, &text) else {
return;
};
for stem in ["lavapipe", "amd-780m-radv", "intel-irisxe-anv"] {
let what = format!("{name}, {stem}");
let a = ok(&bc, "k", &p(stem));
assert!(
a.precision
.contains(&PrecisionNote::DeviceAnisotropicFilter),
"{what}: {:?}",
a.precision
);
assert!(
!a.precision.contains(&PrecisionNote::AnisotropicFilter),
"{what}"
);
assert_eq!(count(&a, OP_IMAGE_SAMPLE_EXPLICIT_LOD), 0, "{what}");
assert_eq!(dont_unroll_loops(&a), 0, "{what}");
}
let a = ok(&bc, "k", &full("moltenvk-m3"));
assert!(
!a.precision
.contains(&PrecisionNote::DeviceAnisotropicFilter),
"{name}, MoltenVK"
);
let text = out_of_reach_fragment(*isotropic, tex_ty, call, decl);
let Some(bc) = assemble(name, &text) else {
return;
};
let a = ok(&bc, "k", &p("lavapipe"));
assert!(
!a.precision
.contains(&PrecisionNote::DeviceAnisotropicFilter),
"{name}, isotropic"
);
}
}
/// A kernel sampling `texturecube<float>` slot 0 with explicit gradients through the constexpr
/// sampler of first state word `words`, writing the texel to buffer 0.
fn constexpr_cube_kernel(words: u64) -> String {
format!(
r#"@__air_sampler_state = internal addrspace(2) constant [2 x i64] [i64 {words}, i64 0], align 8
define void @k(ptr addrspace(1) %t, ptr addrspace(1) %o, i32 %gid) {{
%xf = uitofp i32 %gid to float
%y = fmul float %xf, 1.562500e-02
%d = insertelement <3 x float> <float 1.000000e+00, float 0.000000e+00, float -5.000000e-01>, float %y, i64 1
%r = call {{ <4 x float>, i8 }} @air.sample_texture_cube_grad.v4f32(ptr addrspace(1) %t, ptr addrspace(2) @__air_sampler_state, <3 x float> %d, <3 x float> <float 0.000000e+00, float 2.500000e-01, float 0.000000e+00>, <3 x float> <float 0.000000e+00, float 0.000000e+00, float 3.125000e-02>, float 0.000000e+00, i32 0)
%v = extractvalue {{ <4 x float>, i8 }} %r, 0
%p = getelementptr <4 x float>, ptr addrspace(1) %o, i32 %gid
store <4 x float> %v, ptr addrspace(1) %p, align 16
ret void
}}
declare {{ <4 x float>, i8 }} @air.sample_texture_cube_grad.v4f32(ptr addrspace(1), ptr addrspace(2), <3 x float>, <3 x float>, <3 x float>, float, i32)
!air.kernel = !{{!0}}
!air.sampler_states = !{{!6}}
!0 = !{{ptr @k, !1, !2}}
!1 = !{{}}
!2 = !{{!3, !4, !5}}
!3 = !{{i32 0, !"air.texture", !"air.location_index", i32 0, i32 1, !"air.sample", !"air.arg_type_name", !"texturecube<float, sample>", !"air.arg_name", !"t"}}
!4 = !{{i32 1, !"air.buffer", !"air.location_index", i32 0, i32 1, !"air.read_write", !"air.address_space", i32 1, !"air.arg_type_size", i32 16, !"air.arg_type_align_size", i32 16, !"air.arg_type_name", !"float4", !"air.arg_name", !"o"}}
!5 = !{{i32 2, !"air.thread_position_in_grid", !"air.arg_type_name", !"uint", !"air.arg_name", !"gid"}}
!6 = !{{!"air.sampler_state", ptr addrspace(2) @__air_sampler_state}}
"#
)
}
/// A cube's explicit gradients through a constexpr sampler of `maxAnisotropy` 8 or 1 under a
/// linear mip filter keep the device's own gradient sample on `moltenvk-m3`, whose sampler is
/// anisotropic: Vulkan's rule's form, recorded as `CubeGradientFootprint`, with no level query and
/// no `AnisotropicFilter`.
#[test]
fn a_cubes_explicit_gradients_take_metals_level_and_taps() {
const GRAD: u32 = 0x4;
for aniso in [8, 1] {
let what = format!("maxAnisotropy {aniso}, moltenvk-m3");
let Some(bc) = assemble(
&what,
&constexpr_cube_kernel(words(MipFilter::Linear, aniso)),
) else {
return;
};
let a = ok(&bc, "k", &full("moltenvk-m3"));
assert_eq!(count(&a, OP_IMAGE_SAMPLE_EXPLICIT_LOD), 1, "{what}");
assert_eq!(count(&a, OP_IMAGE_QUERY_LEVELS), 0, "{what}");
assert_eq!(gradient_masks(&a), vec![GRAD], "{what}");
assert!(
!a.precision.contains(&PrecisionNote::AnisotropicFilter),
"{what}: {:?}",
a.precision
);
// Vulkan's rule's form, the device's reading.
assert!(
a.precision.contains(&PrecisionNote::CubeGradientFootprint),
"{what}: {:?}",
a.precision
);
}
}
/// The `Grad` and `Lod` bits of each `OpImageSampleExplicitLod`'s image operands in `a`'s module.
fn gradient_masks(a: &FunctionArtifact) -> Vec<u32> {
let words = &a.module.words;
let mut out = Vec::new();
let mut i = 5;
while i < words.len() {
let len = ((words[i] >> 16) as usize).max(1);
if (words[i] & 0xffff) as u16 == OP_IMAGE_SAMPLE_EXPLICIT_LOD && len > 5 {
out.push(words[i + 5] & 0x6);
}
i += len;
}
out
}
@@ -393,12 +393,12 @@ mod tests {
(d.min_filter, d.mag_filter),
(vk::Filter::NEAREST, vk::Filter::NEAREST)
);
// Anisotropy maps on every device: its Vulkan sampler is isotropic without the feature.
// Anisotropy maps where the device has `samplerAnisotropy`, which the runtime's floor
// requires; a device without it makes no anisotropic sampler (`check_sampler`).
let mut s = state(FIXTURE_WORDS[0]);
s.max_anisotropy = 8;
let d = constexpr_desc(state_words(&s), SamplerUse::default(), &p).expect("maps");
let aniso_ok = p.fields().images.sampler_anisotropy;
assert_eq!(d.max_anisotropy.is_some(), aniso_ok, "{d:?}");
assert!(d.max_anisotropy.is_some(), "{d:?}");
// A bias beyond every device's limit.
let mut s = state(FIXTURE_WORDS[0]);
s.lod_bias = Half(0x7bff); // 65504
+26 -24
View File
@@ -8,8 +8,8 @@ use crate::spirv::builder::FunctionBuilder;
use crate::spirv::error::{BResult, BuildError, OperandRule};
use crate::spirv::ids::{TypeId, Value as SValue};
use crate::spirv::ir::{
BinOp, ConstBits, Constant, ConvOp, DerivOp, GlslOp, ImageOperands, ImageQuery, MemAccess,
Type as SType, UnOp,
BinOp, ConstBits, Constant, Contraction, ConvOp, DerivOp, GlslOp, ImageOperands, ImageQuery,
MemAccess, Type as SType, UnOp,
};
use crate::air::ir::ValueId;
@@ -415,8 +415,8 @@ fn scaled_axis_gradients(
///
/// - [`CubeFootprint::Length`] (an isotropic sampler): each gradient's two tangent components
/// combined by Metal's length, `max(M + 3m/16, 49M/64 + 21m/32)` of the larger and smaller
/// magnitude (the anisotropic emulation's, measured on 2D textures), on the tangent `(a + 2) mod
/// 3` alone. Vulkan's rule ("Cube Map Derivative Transformation") reads a gradient whose normal
/// magnitude (Metal's gradient length, measured on 2D textures; [`metal_length`]), on the
/// tangent `(a + 2) mod 3` alone. Vulkan's rule ("Cube Map Derivative Transformation") reads a gradient whose normal
/// component is zero as `∂s_c / (2 |m_a|)` and `∂t_c / (2 |m_a|)`, so the device reads Metal's
/// length whatever its approximation of a vector's (one component is nonzero); its level is its
/// own logarithm of it, where Metal's piecewise-linear one minifies only past a footprint of
@@ -535,7 +535,7 @@ fn tangent_length(
// and `y` on a `z` face.
let first = fb.select(m.y_or_z, gx, gy)?;
let second = fb.select(m.z, gy, gz)?;
let length = super::anisotropic::metal_length(fb, first, second)?;
let length = metal_length(fb, first, second)?;
// The tangent `(a + 2) mod 3`: `z` for an `x` face, `x` for a `y` face, `y` for a `z`
// face.
let on_x = fb.select(m.y, length, zero)?;
@@ -849,11 +849,6 @@ pub(super) fn sampled_value(
s: &Sampling,
grads: Option<(SValue, SValue)>,
) -> BResult<SValue> {
// Metal's anisotropic filter emulated by the device's samples at explicit levels; a runtime
// sampler's where its word states anisotropy, the rest of this path elsewhere.
if let Some(a) = s.anisotropic.as_ref() {
return super::anisotropic::sample(cx, fb, s, a, grads);
}
let (si, image, live) = sampled_image(cx, fb, s.source)?;
if let SampleOp::QueryLevel { min } = &s.op {
let x = query_level(cx, fb, si, *min)?;
@@ -1636,20 +1631,6 @@ pub(super) fn plane_axis_gradients(
axis_gradients(fb, (dx, dy), bias, size, size_lanes)
}
/// Whether sampler word `word` (a `u32`) has any bit of `bits`.
pub(super) fn word_states_any(
fb: &mut FunctionBuilder<'_>,
word: SValue,
bits: u32,
) -> BResult<SValue> {
let m = fb.u32_const(bits)?;
let m = fb.module().const_value(m)?;
let zero = fb.u32_const(0)?;
let zero = fb.module().const_value(zero)?;
let have = fb.binary(BinOp::BitwiseAnd, word, m)?;
fb.binary(BinOp::INotEqual, have, zero)
}
/// The derivatives of plane coordinate `plane` (`lanes` floats) in the open block, scaled by
/// `2^bias` ([`bias_gradients`]).
fn plane_bias_gradients(
@@ -1768,6 +1749,27 @@ fn word_min_level(fb: &mut FunctionBuilder<'_>, word: SValue) -> BResult<SValue>
}
/// The `f32` constant with bits `bits`.
/// Metal's length of the gradient of components `x` and `y` (`f32`s): `max(M + 3m/16, 49M/64 +
/// 21m/32)` of their larger and smaller magnitude `M` and `m`, each product and sum rounded as
/// written (no contraction). Measured on an Apple M4 under macOS 27.0.1, 2D textures sampled with
/// gradients through anisotropic samplers.
fn metal_length(fb: &mut FunctionBuilder<'_>, x: SValue, y: SValue) -> BResult<SValue> {
let x = fb.glsl(GlslOp::FAbs, &[x])?;
let y = fb.glsl(GlslOp::FAbs, &[y])?;
let big = fb.glsl(GlslOp::FMax, &[x, y])?;
let small = fb.glsl(GlslOp::FMin, &[x, y])?;
let term = |fb: &mut FunctionBuilder<'_>, p: f32, q: f32| -> BResult<SValue> {
let pc = f32_const(fb, p.to_bits())?;
let qc = f32_const(fb, q.to_bits())?;
let a = fb.binary_with(BinOp::FMul, big, pc, Contraction::Forbidden)?;
let b = fb.binary_with(BinOp::FMul, small, qc, Contraction::Forbidden)?;
fb.binary_with(BinOp::FAdd, a, b, Contraction::Forbidden)
};
let first = term(fb, 1.0, 0.1875)?;
let second = term(fb, 0.765_625, 0.656_25)?;
fb.glsl(GlslOp::FMax, &[first, second])
}
fn f32_const(fb: &mut FunctionBuilder<'_>, bits: u32) -> BResult<SValue> {
let f = f32_ty(fb)?;
let c = fb.module().constant(Constant::Scalar {
@@ -550,9 +550,7 @@ pub(crate) fn emit(
let f = match cx.sampling.get(&shape, &tys) {
Some(f) => f,
None => {
let Shape::Extended(r) = &shape else {
return Err(cx.fail("an extended-range routine of another shape"));
};
let Shape::Extended(r) = &shape;
let mut rcx = cx.for_new_function();
let made = define(&mut rcx, fb.module(), r, &tys);
cx.adopt(rcx);
@@ -1,7 +1,6 @@
//! `metal_ties` on the interpreter against Metal's rule. Each kernel invocation reads a direction's
//! bits and writes the bits of the direction the device is handed. `anisotropic` checks
//! `emit::cube_footprint`'s gradients through a constexpr anisotropic sampler, and `routines` the
//! sampling routines' function controls.
//! bits and writes the bits of the direction the device is handed. `routines` checks the sampling
//! routines' function controls.
use super::metal_ties;
use crate::pipeline::sym::{ResourceKind, ResourceSlot, Stage};
@@ -598,5 +597,4 @@ fn the_estimate_bounds_the_emitted_words() {
}
}
mod anisotropic;
mod routines;
@@ -1,300 +0,0 @@
//! `emit::cube_footprint`, on the interpreter, against Metal's footprint. Each kernel invocation
//! reads a direction's bits and writes the bits of the gradient the device is handed for a constant
//! explicit gradient `g`.
//!
//! - Metal under macOS 27.0.1 (the Apple M3 Max, the probe `emit::cube_footprint` cites) reads,
//! on the direction's face, the face's two tangent components, `(σ_s g[s], σ_t g[t])` in
//! Vulkan's face orientation, `s` and `t` the axes of the face's `s_c` and `t_c` and `σ` their
//! signs, with `dPdx`'s `t` component and `dPdy`'s `s` component times `ρ = σ_s σ_t` through an
//! anisotropic sampler. Vulkan's cube derivative rule must read that from the `Face` form over
//! `2 |m_a|`, and nothing on the normal; and the `Length` form must hand Metal's length of the
//! two on one tangent.
//!
//! Through a runtime sampler `emit::word_footprint` hands one of those forms or the isotropic one
//! by the sampler's word (`emit::by_anisotropy`).
use super::super::super::anisotropic::cube_face;
use super::super::super::emit::{by_anisotropy, cube_footprint};
use super::super::super::CubeFootprint;
use super::{kernel_on, run_records};
use crate::metal::sampler::SamplerWord;
use crate::spirv::builder::ModuleBuilder;
use crate::spirv::ir::{ConstBits, Constant, Type};
/// Vulkan's face of direction `d` ("Cube map face selection"; no ties among `d`'s magnitudes):
/// its major axis, and the axis and sign of its `s_c` and of its `t_c`. Metal's faces are the
/// same.
fn face_of(d: [f32; 3]) -> (usize, (usize, f32), (usize, f32)) {
let m = d.map(f32::abs);
let a = if m[2] >= m[0] && m[2] >= m[1] {
2
} else if m[1] >= m[0] {
1
} else {
0
};
let positive = d[a] > 0.0;
let (s, t) = match (a, positive) {
(0, true) => ((2, -1.0), (1, -1.0)),
(0, false) => ((2, 1.0), (1, -1.0)),
(1, true) => ((0, 1.0), (2, 1.0)),
(1, false) => ((0, 1.0), (2, -1.0)),
(_, true) => ((0, 1.0), (1, -1.0)),
(_, false) => ((0, -1.0), (1, -1.0)),
};
(a, s, t)
}
/// The face gradient Metal reads under macOS 27 from gradient `g` (`dPdx` where `is_dx`, else
/// `dPdy`) at direction `d` through an anisotropic sampler, in Vulkan's face orientation.
fn metal_reading(g: [f32; 3], d: [f32; 3], is_dx: bool) -> [f32; 2] {
let (_, (s, s_sign), (t, t_sign)) = face_of(d);
let rho = s_sign * t_sign;
match is_dx {
true => [s_sign * g[s], rho * t_sign * g[t]],
false => [rho * s_sign * g[s], t_sign * g[t]],
}
}
/// Metal's length of a gradient of components `x` and `y`: `max(M + 3m/16, 49M/64 + 21m/32)`.
fn metal_length(x: f32, y: f32) -> f32 {
let (big, small) = (x.abs().max(y.abs()), x.abs().min(y.abs()));
(big + small * 0.1875).max(big * 0.765_625 + small * 0.656_25)
}
/// Directions on each of the six faces, at the face's center and off it.
fn directions() -> Vec<[f32; 3]> {
let mut out = Vec::new();
for a in 0..3 {
for sign in [1.0f32, -1.0] {
for (u, v) in [(0.0f32, 0.0f32), (0.25, -0.5), (-0.75, 0.125)] {
let mut d = [0.0f32; 3];
d[a] = 2.0 * sign;
d[(a + 1) % 3] = u;
d[(a + 2) % 3] = v;
out.push(d);
}
}
}
out
}
/// The gradients `cube_footprint` hands the device in `form` for gradient `g` (as `dPdx` where
/// `is_dx`, else as `dPdy`), per direction of `lanes`.
fn handed_as(form: CubeFootprint, g: [f32; 3], lanes: &[[f32; 3]], is_dx: bool) -> Vec<[f32; 3]> {
let records: Vec<u32> = lanes.iter().flat_map(|d| d.map(f32::to_bits)).collect();
let m = kernel_on(ModuleBuilder::new(), 3, &|f, p, _| {
let f32_ = f.module().ty(Type::Float { width: 32 })?;
let vec3 = f.module().ty(Type::Vector { elem: f32_, len: 3 })?;
let zero = f.module().constant(Constant::Scalar {
ty: f32_,
bits: ConstBits(0),
})?;
let zero = f.module().const_value(zero)?;
let mut c = Vec::new();
for x in g {
let k = f.module().constant(Constant::Scalar {
ty: f32_,
bits: ConstBits(u64::from(x.to_bits())),
})?;
c.push(f.module().const_value(k)?);
}
let g = f.composite_construct(vec3, &c)?;
let other = f.composite_construct(vec3, &[zero, zero, zero])?;
let (dx, dy) = cube_footprint(f, p, (g, other), form)?;
let (dx2, dy2) = cube_footprint(f, p, (other, g), form)?;
let _ = (dy, dx2);
Ok(match is_dx {
true => dx,
false => dy2,
})
})
.expect("kernel");
run_records(&m, &records, lanes.len())
}
/// The gradients `cube_footprint` hands the device in `form` for `dPdx` `g`, per direction of
/// `lanes`.
fn handed(form: CubeFootprint, g: [f32; 3], lanes: &[[f32; 3]]) -> Vec<[f32; 3]> {
handed_as(form, g, lanes, true)
}
const GRADIENTS: [[f32; 3]; 3] = [[1.0, 2.0, 4.0], [-3.0, 0.5, -7.25], [0.0, -1.5, 6.0]];
/// Vulkan's rule reads Metal's macOS 27 face gradients from the `Face` form, for `dPdx` and
/// `dPdy` alike, the normal's component zero.
#[test]
fn a_face_footprint_keeps_metals_face_gradients() {
let lanes = directions();
for g in GRADIENTS {
for is_dx in [true, false] {
for (d, h) in lanes
.iter()
.zip(handed_as(CubeFootprint::Face, g, &lanes, is_dx))
{
let (a, (s, s_sign), (t, t_sign)) = face_of(*d);
assert_eq!(h[a], 0.0, "{d:?} {g:?}: the normal's component {h:?}");
let read = [s_sign * h[s], t_sign * h[t]];
let metal = metal_reading(g, *d, is_dx);
assert_eq!(read, metal, "{d:?} {g:?} dx {is_dx}: handed {h:?}");
}
}
}
}
/// The `Length` form hands Metal's length of the face's two tangent components on the tangent `(a
/// + 2) mod 3` alone, bit for bit, which Vulkan's rule and every Metal reading read alike.
#[test]
fn a_length_footprint_hands_metals_length_on_one_tangent() {
let lanes = directions();
for g in GRADIENTS {
for (d, h) in lanes.iter().zip(handed(CubeFootprint::Length, g, &lanes)) {
let (a, (s, _), (t, _)) = face_of(*d);
let b = (a + 2) % 3;
let mut want = [0.0f32; 3];
want[b] = metal_length(g[s], g[t]);
assert_eq!(
h.map(f32::to_bits),
want.map(f32::to_bits),
"{d:?} {g:?}: handed {h:?}"
);
}
}
}
/// What `by_anisotropy` hands the device for gradient `g` through a sampler of word `word`, per
/// direction of `lanes`, choosing between the gradients `cube_footprint` hands in form `set` and in
/// form `clear`.
fn by_word(
(set, clear): (CubeFootprint, CubeFootprint),
word: u32,
g: [f32; 3],
lanes: &[[f32; 3]],
) -> Vec<[f32; 3]> {
let records: Vec<u32> = lanes
.iter()
.flat_map(|d| [d[0].to_bits(), d[1].to_bits(), d[2].to_bits(), word])
.collect();
let m = kernel_on(ModuleBuilder::new(), 4, &|f, p, w| {
let f32_ = f.module().ty(Type::Float { width: 32 })?;
let vec3 = f.module().ty(Type::Vector { elem: f32_, len: 3 })?;
let mut c = Vec::new();
for x in g {
let k = f.module().constant(Constant::Scalar {
ty: f32_,
bits: ConstBits(u64::from(x.to_bits())),
})?;
c.push(f.module().const_value(k)?);
}
let g = f.composite_construct(vec3, &c)?;
let a = cube_footprint(f, p, (g, g), set)?;
let i = cube_footprint(f, p, (g, g), clear)?;
Ok(by_anisotropy(f, w, a, i)?.0)
})
.expect("kernel");
run_records(&m, &records, lanes.len())
}
/// A runtime sampler's footprint by its word (`word_footprint`) takes, on every lane and bit for
/// bit, the anisotropic arm where the word states `SamplerWord::ANISOTROPIC`, whatever its other
/// fields, and the isotropic arm where it does not: the choice is `by_anisotropy`'s, between
/// whatever two forms it is given.
#[test]
fn a_footprint_by_the_word_takes_the_form_its_anisotropy_states() {
let lanes = directions();
let others = SamplerWord::MIN_LINEAR
| SamplerWord::MAG_LINEAR
| (2 << SamplerWord::MIP_FILTER_SHIFT)
| SamplerWord::LEVEL_MAX;
let bits =
|v: &[[f32; 3]]| -> Vec<[u32; 3]> { v.iter().map(|x| x.map(f32::to_bits)).collect() };
let (set, clear) = (CubeFootprint::Face, CubeFootprint::Length);
for g in GRADIENTS {
let (when_set, when_clear) = (
bits(&handed(set, g, &lanes)),
bits(&handed(clear, g, &lanes)),
);
assert_ne!(when_set, when_clear, "{g:?}");
for (word, want) in [
(0, &when_clear),
(others, &when_clear),
(SamplerWord::ANISOTROPIC, &when_set),
(SamplerWord::ANISOTROPIC | others, &when_set),
] {
let got = bits(&by_word((set, clear), word, g, &lanes));
assert_eq!(&got, want, "{g:?} {word:#x}");
}
}
}
/// The emulation's face of each direction of `lanes` and gradient `g` (`anisotropic::cube_face`):
/// `out` 0 and 1, Metal's face gradient of `g` as `dPdx` and as `dPdy` (on `x` and `y`, `z` 0);
/// 2 and 3, the steps of the direction that move the face's `s` and `t` by one.
fn emulated_face(g: [f32; 3], lanes: &[[f32; 3]], out: usize) -> Vec<[f32; 3]> {
let records: Vec<u32> = lanes.iter().flat_map(|d| d.map(f32::to_bits)).collect();
let m = kernel_on(ModuleBuilder::new(), 3, &|f, p, _| {
let f32_ = f.module().ty(Type::Float { width: 32 })?;
let vec3 = f.module().ty(Type::Vector { elem: f32_, len: 3 })?;
let zero = f.module().constant(Constant::Scalar {
ty: f32_,
bits: ConstBits(0),
})?;
let zero = f.module().const_value(zero)?;
let mut c = Vec::new();
for x in g {
let k = f.module().constant(Constant::Scalar {
ty: f32_,
bits: ConstBits(u64::from(x.to_bits())),
})?;
c.push(f.module().const_value(k)?);
}
let g = f.composite_construct(vec3, &c)?;
let other = f.composite_construct(vec3, &[zero, zero, zero])?;
let (face, (gx, _)) = cube_face(f, p, (g, other))?;
let (_, (_, gy)) = cube_face(f, p, (other, g))?;
let pair = |f: &mut crate::spirv::builder::FunctionBuilder<'_>, v| {
let x = f.composite_extract(v, &[0])?;
let y = f.composite_extract(v, &[1])?;
f.composite_construct(vec3, &[x, y, zero])
};
match out {
0 => pair(f, gx),
1 => pair(f, gy),
2 => Ok(face.s),
_ => Ok(face.t),
}
})
.expect("kernel");
run_records(&m, &records, lanes.len())
}
/// The anisotropic emulation's face of a cube direction takes Metal's macOS 27 face gradients
/// (`metal_reading`) over `2 |m_a|`, bit for bit (the directions' major magnitude is 2), for
/// `dPdx` and `dPdy` alike; and its steps move the direction along the face's `s` and `t` axes by
/// `2 |m_a|` times their signs, so the face coordinate Vulkan projects moves by one.
#[test]
fn the_emulations_face_takes_metals_gradients_and_steps() {
let lanes = directions();
for g in GRADIENTS {
for (out, is_dx) in [(0, true), (1, false)] {
for (d, h) in lanes.iter().zip(emulated_face(g, &lanes, out)) {
let metal = metal_reading(g, *d, is_dx);
let want = [metal[0] / 4.0, metal[1] / 4.0, 0.0];
assert_eq!(
h.map(f32::to_bits),
want.map(f32::to_bits),
"{d:?} {g:?} dx {is_dx}: {h:?}"
);
}
}
}
for (out, axis) in [(2, 0), (3, 1)] {
for (d, h) in lanes.iter().zip(emulated_face(GRADIENTS[0], &lanes, out)) {
let (_, s, t) = face_of(*d);
let (on, sign) = [s, t][axis];
let mut want = [0.0f32; 3];
want[on] = 4.0 * sign;
assert_eq!(h, want, "{d:?}: step {axis} {h:?}");
}
}
}
@@ -123,7 +123,6 @@
//! sampled through several sampler candidates, the binding-array rule, and the bicubic forms
//! [`bicubic`] refuses.
pub mod anisotropic;
pub mod bicubic;
mod constexpr;
mod emit;
@@ -653,10 +652,6 @@ pub struct Sampling {
/// base-level size, which Metal reads, is not a power of two where the bound view's is
/// (`position::offset_dropped`).
pub offset_base: bool,
/// A sample through an anisotropic sampler that Metal's anisotropic filter, emulated by the
/// device's samples at explicit levels, answers ([`anisotropic`]): through a constexpr
/// sampler always, through a runtime sampler slot where its word states anisotropy.
pub anisotropic: Option<anisotropic::Anisotropic>,
/// A fragment function's depth comparison whose reference the pipeline's private
/// `fragmentDepthCompareClampMask` clamps (`LoweringInputs::depth_compare_clamp_mask`): the
/// reference is clamped to `[0, 1]`, a NaN taken as 0, before every comparison
@@ -973,9 +968,6 @@ pub struct RuntimeSlot {
/// extended-range sample whose linear mip filter blends two levels (`extended::Level::Word`):
/// the function reads its `SpecKey::SamplerMinLevel` specialization.
pub min_level: bool,
/// An emulated anisotropic sample reads it ([`anisotropic`]): the function reads its word's
/// anisotropy and mip filter and its `SpecKey::SamplerAnisotropy` specialization.
pub emulated: bool,
/// A Metal 4.1 read through it addresses its texel by its word (`texture::Through`): the
/// function reads its word's address modes, border color, and mip filter.
pub reads: bool,
@@ -1085,9 +1077,6 @@ pub struct Declared {
/// The `SamplerMinLevel` specialization constant (`u32`) of each runtime sampler slot a
/// clamped LOD query outside a fragment function reads.
pub min_levels: BTreeMap<u32, SValue>,
/// The `SamplerAnisotropy` specialization constant (`u32`) of each runtime sampler slot an
/// emulated anisotropic sample reads ([`anisotropic`]).
pub degrees: BTreeMap<u32, SValue>,
/// The 2D bicubic samples' routine, when the module has one.
pub bicubic_plane: Option<bicubic::routines::Plane>,
/// The 1D bicubic samples' routine, when the module has one.
@@ -1353,14 +1342,6 @@ pub fn declare(
let c = mb.spec(SpecKey::SamplerMinLevel(r.slot), u, ConstBits(0))?;
d.min_levels.insert(*n, mb.const_value(c)?);
}
if r.emulated {
let u = mb.ty(SType::Int {
width: 32,
signed: false,
})?;
let c = mb.spec(SpecKey::SamplerAnisotropy(r.slot), u, ConstBits(0))?;
d.degrees.insert(*n, mb.const_value(c)?);
}
}
for r in &plan.families.sampler.bicubic_routines {
match r {
@@ -1413,7 +1394,6 @@ pub fn select_param(cx: &mut SelectCx<'_>, b: &ParamBinding) -> Result<(), Error
fetch_levels: false,
anisotropy: false,
min_level: false,
emulated: false,
reads: false,
});
}
@@ -8,13 +8,9 @@
//! emulation as one routine that 256 sites call, declared `DontInline`, made in 0.39 s on the RTX
//! 3090 where the 256 inlined copies took 10.2 s.
//!
//! **What a routine holds.** One per shape ([`Shape`]):
//! - [`Filter`]: Metal's anisotropic filter emulated (`anisotropic`): the level-0 size and level
//! count, the sampler's degree and mip filter, the footprint, and the taps' samples at explicit
//! levels and their sum.
//! - [`Extended`]: an extended-range texture's sample (`extended`): the levels its mip filter
//! reads, the filter's footprint and addressing, the fetches and their decodes, the sums' calls,
//! the border and the swizzle.
//! **What a routine holds.** One per shape ([`Shape`]): [`Extended`], an extended-range texture's
//! sample (`extended`): the levels its mip filter reads, the filter's footprint and addressing,
//! the fetches and their decodes, the sums' calls, the border and the swizzle.
//!
//! The routine reads its binding's image and sampler variables and its slots' specialization
//! constants (the runtime sampler's word, the offset tests) itself, so no image handle crosses a
@@ -22,23 +18,15 @@
//! keeps the word's tests, the device's sample with its level, bias or gradients, and the texel's
//! conversion: no implicit level crosses a call, so every answer is the one the inline code gave.
//!
//! An anisotropic sample's call passes its coordinate (a cube's direction, its ties broken), its
//! gradients (a cube's on its face) and a cube's face steps, the array layer and the
//! `min_lod_clamp`, and its texel offset, constant or dynamic, where the profile admits the
//! `Offset` operand on a sample (`maintenance8` and `shaderImageGatherExtended`), which the taps'
//! samples take, so the samples at every offset call one routine; elsewhere a constant offset is
//! the shape's, as the taps' `ConstOffset`. The site keeps the gradients (no implicit derivative
//! crosses a call), the word's test, the plain arm and the texel's conversion of the sum. An
//! extended-range sample's call passes its coordinate, the array layer and the level its mip
//! An extended-range sample's call passes its coordinate, the array layer and the level its mip
//! filter reads at (an explicit level, or the level of detail its site takes from derivatives or
//! gradients), and its constant texel offset, which the routine places on each lane, so the
//! samples at every offset call one routine; the site keeps the result's status word.
//!
//! **Not routines.** A heap image's sample (an argument buffer's), whose `NonUniform` handle a
//! call would carry (a later step's check); a switch-at-use's shared emulation
//! (`sampler::shared_value`), which runs once already; a gather's fetches; an anisotropic sample
//! at a dynamic texel offset on a profile without the `Offset` operand on a sample, whose arms its
//! site's access reads; and the bicubic filter's site code.
//! (`sampler::shared_value`), which runs once already; a gather's fetches; and the bicubic filter's
//! site code.
//!
//! **The call's control.** A sampling routine is a kept routine (`ModuleBuilder::kept_routine`),
//! declared `DontInline` on every device: a driver that honours the control (NVIDIA's) compiles
@@ -47,18 +35,16 @@
//!
//! **Census**. An extended-range sample's routine is counted once per shape the plan notes
//! ([`note_extended`], `sampler::routine_words`), under `sampler.extended_range.routine`
//! (`extended::Sample::words` its site's). The census counts no anisotropic emulation, at its
//! sites or in a routine.
//! (`extended::Sample::words` its site's).
use std::collections::HashMap;
use crate::metal::format::ExtendedRange;
use crate::spirv::ids::{FuncId, TypeId};
use super::anisotropic::Anisotropic;
use super::bicubic::Bicubic;
use super::extended;
use super::{BindingKey, SamplerPlan};
use super::SamplerPlan;
/// The estimated words a routine adds besides its body: `OpFunction`, its parameters, the entry
/// label, the return, and `OpFunctionEnd`.
@@ -72,8 +58,6 @@ pub const CALL_WORDS: u32 = 32;
/// argument types.
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub enum Shape {
/// Metal's anisotropic filter emulated (`anisotropic`).
Anisotropic(Filter),
/// An extended-range texture's sample (`extended`).
Extended(Box<Extended>),
}
@@ -82,7 +66,6 @@ impl Shape {
/// The census name of the shape's routines.
pub fn census_name(&self) -> &'static str {
match self {
Shape::Anisotropic(_) => "sampler.anisotropic.routine",
Shape::Extended(_) => "sampler.extended_range.routine",
}
}
@@ -91,41 +74,11 @@ impl Shape {
/// the function's own.
pub fn words(&self) -> u32 {
match self {
Shape::Anisotropic(_) => FILTER_WORDS + ROUTINE_WORDS,
Shape::Extended(e) => e.words + ROUTINE_WORDS,
}
}
}
/// The estimated words of an anisotropic emulation's body (`anisotropic`), its taps past the first
/// in one loop: about 2,100 measured on a runtime slot's.
pub const FILTER_WORDS: u32 = 2_400;
/// Metal's anisotropic filter emulated (`anisotropic`), as a sample of a texture slot through its
/// combined binding takes it.
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct Filter {
/// The sample's combined binding.
pub binding: BindingKey,
/// The sampler's degree, mip filter and the device's anisotropy.
pub filter: Anisotropic,
/// The coordinate's plane lanes (2; a cube direction's 3).
pub lanes: u8,
/// The sample reads a cube: its call passes the face's steps.
pub cube: bool,
/// The sample reads an array's layer.
pub layer: bool,
/// The sample states a `min_lod_clamp`.
pub min_lod: bool,
/// The constant texel offset the taps' samples take as `ConstOffset`, where the sample has one
/// and the profile admits no `Offset` operand on a sample.
pub offset: Option<Vec<i32>>,
/// The call passes the sample's texel offset, constant or dynamic, which the taps' samples
/// take as their `Offset` operand: on a profile that admits it on a sample (`maintenance8`
/// and `shaderImageGatherExtended`), so the samples at every offset call one routine.
pub passed_offset: bool,
}
/// An extended-range texture's sample (`extended::Sample`) without the operands its call passes:
/// its coordinate, layer and the level its mip filter reads at.
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
@@ -16,7 +16,6 @@ use crate::lower::texture::{
TexelForm, TextureStrategy,
};
use crate::memory::handles::Candidate;
use crate::metal::sampler::SamplerUse;
use crate::pipeline::artifact::PrecisionNote;
use crate::pipeline::sym::{ImageAccess, SamplerRef, SlotClass, SlotRef, Stage};
@@ -1968,28 +1967,14 @@ fn select_one(
}
_ => false,
};
// Metal's anisotropic filter emulated by the device's samples at explicit levels, where it
// reaches the sample; the device's anisotropic filter, recorded, where it does not.
let anisotropic = super::anisotropic::select(
cx,
&op,
(stat.map(|(r, _)| r), image, shape),
(integer, observed, swizzle),
SamplerUse::new(compare, integer),
)?;
// A cube's explicit gradients handed to the device in a form other than Metal's own: the
// footprint's note, but where a constexpr sampler's emulation answers every word of the
// sample (a runtime sampler's answers only the words its variant names).
// footprint's note.
if let SampleOp::Sample {
lod: Lod::CubeGrad(..),
..
} = &op
{
let emulated =
anisotropic.is_some_and(|a| matches!(a.degree, super::anisotropic::Degree::Const(_)));
if !emulated {
cx.precision.insert(PrecisionNote::CubeGradientFootprint);
}
cx.precision.insert(PrecisionNote::CubeGradientFootprint);
}
let result = cx.lowered_repr(Value::Inst(at), inst.ty)?;
let value = id(cx, Value::Inst(at))?;
@@ -2014,7 +1999,6 @@ fn select_one(
cube,
swizzle,
offset_base,
anisotropic,
clamp_reference,
};
Ok(sampling)
+2 -2
View File
@@ -1891,8 +1891,8 @@ fn identity_refusal(plan: &Plan) -> Option<(IdentityCause, String)> {
BICUBIC_LINE_FORM,
),
(
(sampled.slots.values()).any(|r| r.min_level || r.emulated),
"a sampler argument whose minimum level or emulated filter the function specializes",
(sampled.slots.values()).any(|r| r.min_level),
"a sampler argument whose minimum level the function specializes",
),
];
if let Some((_, form)) = refused.iter().find(|(refused, _)| *refused) {
+16 -103
View File
@@ -285,14 +285,12 @@ pub(crate) fn query_min_level(desc: &SamplerDescriptor) -> u32 {
/// never disagree.
///
/// Refusals, in this order: `MirrorClampToEdge` without `samplerMirrorClampToEdge`; comparison on
/// a portability-subset device without `mutableComparisonSamplers`. NaN or inverted LOD clamps are
/// invalid descriptors. A min or max reduction is no refusal: the sampler reads the weighted
/// average ([`vk_sampler`]). Nor is anisotropy above 1 without `samplerAnisotropy`: the Vulkan
/// sampler is isotropic there, and a function samples through it with Metal's anisotropic filter
/// emulated where the emulation reaches the sample (`PrecisionNote::AnisotropicFilter`) and the
/// device's isotropic filter, recorded, elsewhere (`PrecisionNote::DeviceAnisotropicFilter`). An
/// argument buffer's anisotropic sampler, whose anisotropy the function does not know, is refused
/// there where the binding plan checks it (`Unsupported`, `SamplerAnisotropy`).
/// a portability-subset device without `mutableComparisonSamplers`; `maxAnisotropy` above 1 for a
/// use that filters (any but an integer texture's) without `samplerAnisotropy`
/// (`Feature::SamplerAnisotropy`), every Vulkan sampler being isotropic there: a constexpr
/// sampler's where the function that samples through it is compiled, a runtime or argument
/// buffer's sampler's where it is made. NaN or inverted LOD clamps are invalid descriptors. A min
/// or max reduction is no refusal: the sampler reads the weighted average ([`vk_sampler`]).
pub fn check_sampler(
shape: &SamplerShape,
use_: SamplerUse,
@@ -313,6 +311,13 @@ pub fn check_sampler(
Unsupported::needs(Feature::SamplerCompare, Capability::Feature(mutable)).into(),
);
}
if shape.anisotropic && !use_.integer_texture && !images.sampler_anisotropy {
return Err(Unsupported::needs(
Feature::SamplerAnisotropy,
Capability::Feature(VkFeature::SamplerAnisotropy),
)
.into());
}
if !shape.valid_lod_clamps {
return Err(Error::InvalidDescriptor(DescriptorError::SamplerLodClamp));
}
@@ -457,9 +462,9 @@ pub fn vk_sampler(
/// Anisotropy is a quality bound in both APIs; Vulkan requires it within the limit. It is a
/// filter, so an integer texture has none. A sampler with a nearest min or mag filter is handed
/// its degree too: Vulkan leaves the anisotropic scheme to the implementation (ANV's filters a
/// nearest one linearly). A sampler on a device without `samplerAnisotropy` is handed none, where
/// the emulation's taps read the isotropic sampler
/// (`VUID-VkSamplerCreateInfo-anisotropyEnable-01070`: "If the samplerAnisotropy feature is not
/// nearest one linearly). A device without `samplerAnisotropy` makes no sampler of `maxAnisotropy`
/// above 1 for a use that filters ([`check_sampler`];
/// `VUID-VkSamplerCreateInfo-anisotropyEnable-01070`: "If the samplerAnisotropy feature is not
/// enabled, anisotropyEnable must be VK_FALSE").
pub(crate) fn device_anisotropy(
desc: &SamplerDescriptor,
@@ -469,29 +474,6 @@ pub(crate) fn device_anisotropy(
desc.max_anisotropy > 1 && profile.fields().images.sampler_anisotropy && !use_.integer_texture
}
/// [`device_anisotropy`] of an anisotropic sampler under `use_` on `profile`, by the filters a
/// sampler word states (`SamplerWord::MIN_LINEAR`, `SamplerWord::MAG_LINEAR`): `(linear, nearest)`,
/// its value where both filters are linear and where one is nearest. A word with a cubic filter
/// (`SamplerWord::CUBIC`) states neither: its other filter may be nearest or not.
pub(crate) fn device_anisotropy_by_filters(
use_: SamplerUse,
profile: &DeviceProfile,
) -> (bool, bool) {
let of = |min_filter, mag_filter| {
let desc = SamplerDescriptor {
min_filter,
mag_filter,
max_anisotropy: 2,
..SamplerDescriptor::new()
};
device_anisotropy(&desc, use_, profile)
};
(
of(SamplerMinMagFilter::Linear, SamplerMinMagFilter::Linear),
of(SamplerMinMagFilter::Nearest, SamplerMinMagFilter::Linear),
)
}
/// The one border color a sampler replaces texels with, if any axis clamps to a border: the
/// descriptor's, under `ClampToZero` as under `ClampToBorderColor`. Metal's `ClampToZero` reads
/// the sampler's border color, not transparent black (an Apple M3 Max and an Apple M4, every probed
@@ -2347,73 +2329,4 @@ mod tests {
}
}
}
/// The anisotropic emulation hands its level for level 0 by the device's sampler's anisotropy
/// (`lower::sampler::anisotropic`'s `minified_level`): a runtime sampler's by the filters its
/// word states (`device_anisotropy_by_filters`), which must be `vk_sampler`'s own flag
/// (`anisotropyEnable`, `max_anisotropy` set) for every sampler a word of those filters
/// states, on every committed profile, for the use the emulation reaches (no comparison, no
/// integer texture), whatever the sampler's other fields.
#[test]
fn the_word_filters_state_the_device_samplers_anisotropy() {
use SamplerMinMagFilter as F;
let mut checked = 0;
for (stem, desc) in committed_descriptions() {
let mut desc = desc;
desc.features.insert(VkFeature::SamplerAnisotropy);
desc.limits.max_sampler_anisotropy_bits = 16f32.to_bits();
let dev = Device::from_queries(desc).unwrap();
{
let use_ = SamplerUse::new(false, false);
let (linear, nearest) = device_anisotropy_by_filters(use_, dev.profile());
for (min, mag) in [
(F::Nearest, F::Nearest),
(F::Nearest, F::Linear),
(F::Linear, F::Nearest),
(F::Linear, F::Linear),
] {
for mip in [
SamplerMipFilter::NotMipmapped,
SamplerMipFilter::Nearest,
SamplerMipFilter::Linear,
] {
for (degree, (lo, hi)) in [2, 3, 8, 16].into_iter().zip([
(0.0, f32::MAX),
(0.25, 4.0),
(1.0, 2.5),
(0.0, 0.0),
]) {
let d = SamplerDescriptor {
min_filter: min,
mag_filter: mag,
mip_filter: mip,
max_anisotropy: degree,
lod_min_clamp: lo,
lod_max_clamp: hi,
s_address_mode: SamplerAddressMode::Repeat,
..metal_default()
};
let Ok(made) = vk_sampler(&d, use_, dev.profile()) else {
continue;
};
let word = SamplerWord::of(&d).0;
let both = SamplerWord::MIN_LINEAR | SamplerWord::MAG_LINEAR;
let stated = match word & both == both {
true => linear,
false => nearest,
};
assert_eq!(
stated,
made.max_anisotropy.is_some(),
"{stem}: {d:?} under {use_:?}"
);
assert_eq!(stated, device_anisotropy(&d, use_, dev.profile()));
checked += 1;
}
}
}
}
}
assert!(checked > 0);
}
}
@@ -119,7 +119,6 @@ mod serde_round_trips {
primitive_id_indices: Some(metal::IndexType::UInt16),
quad_primitive_ids: true,
private_list: true,
anisotropic_samplers: BTreeSet::from([slot(Stage::Fragment, SlotClass::Sampler, 1)]),
open_cl_lines: BTreeSet::from([slot(Stage::Kernel, SlotClass::Texture, 1)]),
region_viewports: true,
});
@@ -264,7 +263,6 @@ mod serde_round_trips {
threadgroup_size_matches_tile_size: true,
rotated_blends: BTreeSet::from([4, 6]),
texture_write_rounding: metal::TextureWriteRoundingMode::NearestEven,
anisotropic_samplers: BTreeSet::from([slot(Stage::Fragment, SlotClass::Sampler, 3)]),
open_cl_lines: BTreeSet::from([slot(Stage::Kernel, SlotClass::Texture, 2)]),
uniform_varyings: BTreeSet::from([VaryingKey::user(b"user(tint)")]),
instanced_attributes: BTreeSet::from([1]),
@@ -690,10 +690,6 @@ pub enum PrecisionNote {
/// select another level or filter than Metal's. A runtime or argument buffer's sampler takes
/// the form its word's anisotropy states.
///
/// Not recorded where the module takes Metal's footprint itself through an anisotropic
/// constexpr sampler on a device without `samplerAnisotropy` (`lower::sampler::anisotropic`):
/// Metal's level and taps (`PrecisionNote::AnisotropicFilter`).
///
/// Also recorded for every cube access whose level comes from the fragment's derivatives (an
/// implicit-level sample, one whose gradients a switch-at-use hoisted, or an LOD query): its
/// level is the device's, of the direction handed to it, and Metal's rule there is not
@@ -1052,58 +1048,6 @@ pub enum PrecisionNote {
/// Validation derives no tolerance and no explanation from it: a difference stays a
/// mismatch for review, deferred until an exact path exists.
HalfOutputPrecision,
/// The module samples a texture through an anisotropic sampler with Metal's anisotropic
/// filter emulated by the device's samples at explicit levels (`lower::sampler::anisotropic`),
/// on a device without `samplerAnisotropy`, every Vulkan sampler being isotropic there, each
/// tap the device's isotropic filter: a sample without comparison of a 2D texture or 2D array
/// at the fragment's implicit level or with explicit gradients, or of a cube or cube array with
/// explicit gradients, through a constexpr sampler of `maxAnisotropy` above 1, or through a
/// runtime sampler slot whose word states anisotropy (under that word alone). A device with
/// the feature samples with its own anisotropic filter. Metal's footprint (its gradient lengths,
/// level rule, tap count thresholds, tap weights and direction) is reproduced as measured on
/// an Apple M4 (the M3 Max answering identically), in the device's arithmetic: its `Log2` and
/// `Exp2` where Metal takes a piecewise-linear `log2` and its chords, the level and the
/// spacing unrounded where Metal rounds them to 256ths and 4096ths, and under a linear mip
/// filter the device's own blend of the two levels at the fractional level where Metal blends
/// them by 256ths. The residue:
/// - the level may differ from Metal's by its rounding (Metal's `log2` is within about
/// `0.006` of a level of the true one), and a tap count at a threshold may differ by one
/// count;
/// - the tap spacing is a fitted approximation for three or more taps below the cap (up to
/// about 18/256 of a texel at the outer tap of 10 or more taps), and otherwise the device's
/// unrounded value;
/// - the blend of two levels is the device's linear mip filter at the fractional level, within
/// its `mipmapPrecisionBits`;
/// - each tap is the device's own filter at the level the shader hands it, so its footprint
/// and sum are the device's (Metal's own on MoltenVK; elsewhere
/// [`PrecisionNote::DeviceSampling`]);
/// - a cube's taps step across the direction's face by Metal's face gradients (Metal under
/// macOS 27 samples a cube as the face's 2D plane, measured on the Apple M3 Max), the
/// direction moved and projected onto the face again by the device, and a tap past the
/// face's edge reads the next face as the device projects it, where Metal's is not measured.
///
/// Measured against the M4's answers on `rgba8Unorm`
/// at `maxAnisotropy` 2 to 16, with Metal's logarithm and blend (the device's are not yet
/// measured there). With a linear filter, every channel is within a code: at most
/// 0.53 (mean up to 0.071) on lavapipe, 0.41 (0.027) on ANV (Iris Xe), 0.91 (0.043) on RADV
/// (Radeon 780M; its bilinear filter's own residue) and 0.68 (0.075) on an RTX 3090. An RTX
/// 3090's own anisotropic filter misses by up to 62 codes (mean 6.8). With a nearest filter,
/// the same on every device: up to 24.5 codes where a tap lies within the spacing's residue of
/// a texel edge and reads the neighbouring texel. That is 4 of 5,072 channels (mean up to
/// 0.024) at `maxAnisotropy` 8 or less, and 37 to 47 (mean up to 0.066) at 16. The 3090's own
/// nearest anisotropic filter misses by up to 194 (mean 16). Validation derives no tolerance
/// from it.
AnisotropicFilter,
/// The module samples a texture through a sampler whose anisotropy is known where Metal's
/// anisotropic filter is not emulated ([`PrecisionNote::AnisotropicFilter`]'s reach), on a
/// device without `samplerAnisotropy`, which filters it isotropically: a cube, a 3D texture, a
/// comparison, a sample whose residency the function observes, or a texture of another class
/// than its declared one, at an implicit level or with explicit gradients, through a constexpr
/// sampler of `maxAnisotropy` above 1 or a runtime sampler slot whose word states anisotropy
/// (under that word alone). An argument buffer's anisotropic sampler, whose anisotropy the
/// function does not know, is refused there (`SamplerAnisotropy`). Validation derives no
/// tolerance from it.
DeviceAnisotropicFilter,
/// A vertex function writes `[[point_size]]`, or a mesh function that outputs points
/// `set_point_size` (a line or triangle mesh's size draws nothing, and records no note), on a
/// device whose `pointSizeRange` ends below Metal's largest point, 511 pixels
@@ -2143,10 +2087,6 @@ impl PrecisionNote {
"metal2vulkan-degrade-argument-pixel-sampler-scaling"
}
PrecisionNote::HalfOutputPrecision => "metal2vulkan-degrade-half-output-precision",
PrecisionNote::AnisotropicFilter => "metal2vulkan-degrade-anisotropic-filter",
PrecisionNote::DeviceAnisotropicFilter => {
"metal2vulkan-degrade-device-anisotropic-filter"
}
PrecisionNote::DevicePointSize => "metal2vulkan-degrade-device-point-size",
PrecisionNote::ClippedCoverageSplit => "metal2vulkan-degrade-clipped-coverage-split",
PrecisionNote::LoopedSampleOutputs => "metal2vulkan-degrade-looped-sample-outputs",
@@ -403,12 +403,6 @@ pub fn function_key(
if inputs.texture_write_rounding != crate::metal::TextureWriteRoundingMode::TowardZero {
h.bytes(b"texture-write-rounding-nearest-even");
}
// Appended only when set, as `signed_color_attachments`: a function bound to no anisotropic
// sampler keeps every key.
if !inputs.anisotropic_samplers.is_empty() {
h.bytes(b"anisotropic-samplers")
.bytes(format!("{:?}", inputs.anisotropic_samplers).as_bytes());
}
// Appended only when set, as `signed_color_attachments`: a kernel whose 1D images are bound as Apple's
// OpenCL binds them keeps its key.
if !inputs.open_cl_lines.is_empty() {
@@ -663,7 +663,6 @@ fn the_inputs_encoding_is_the_earlier_derived_debug() {
.replace(", threadgroup_size_matches_tile_size: false", "")
.replace(", rotated_blends: {}", "")
.replace(", texture_write_rounding: TowardZero", "")
.replace(", anisotropic_samplers: {}", "")
.replace(", open_cl_lines: {}", "")
.replace(", uniform_varyings: {}", "")
.replace(", instanced_attributes: {}", "")
@@ -629,15 +629,6 @@ pub struct LoweringInputs {
/// that writes no such texel, compiles as without it.
#[cfg_attr(feature = "serde", serde(default))]
pub texture_write_rounding: metal::TextureWriteRoundingMode,
/// The runtime sampler slots bound to a sampler whose word states anisotropy
/// (`VariantKey::anisotropic_samplers`): a sample through
/// such a slot that Metal's anisotropic filter, emulated, reaches
/// (`lower::sampler::anisotropic`) takes it where the slot's word states anisotropy and the
/// plain sample elsewhere. A slot the function samples through without being named here takes
/// the plain sample, with no emulation in the module: the binder names every slot whose bound
/// word states anisotropy. Empty for any other function.
#[cfg_attr(feature = "serde", serde(default))]
pub anisotropic_samplers: BTreeSet<SlotRef>,
/// With [`open_cl_mode`](Self::open_cl_mode), the kernel's texture slots of a 1D image
/// (`RuntimeFact::OpenClLineTexture`) bound to a 1D or 1D array texture
/// (`VariantKey::open_cl_lines`), where Apple's OpenCL binds a 2D texture of height 1: the
-5
View File
@@ -432,11 +432,6 @@ pub enum SpecKey {
/// size, the parent's, is not a power of two. A slot bound to any other texture, or to none,
/// takes 0.
OffsetBaseAxes(SlotRef),
/// The degree the runtime sampler bound to the slot filters with (`u32`, default 0): `log2`
/// of its `maxAnisotropy` as Metal samples it (rounded up to a power of two; 32 for 17 to 31),
/// which an emulated anisotropic sample reads. A slot bound to an isotropic sampler, or to
/// none, takes 0.
SamplerAnisotropy(SlotRef),
/// Boolean: the runtime sampler bound to the slot is a nearest pixel sampler of one level
/// (default false): it reads pixel coordinates (`normalizedCoordinates` false) through nearest
/// minification and magnification filters, without a mip filter and isotropically (its word
@@ -441,10 +441,6 @@ fn an_anisotropic_sampler_takes_the_axis_gradients() {
assert_eq!(s.glsl_count(GLSL_LENGTH), 2, "{what}");
s.reads_metals_bias(1, &what);
assert!(a.precision.contains(&PrecisionNote::GradFromBias), "{what}");
assert!(
!a.precision.contains(&PrecisionNote::AnisotropicFilter),
"{what}"
);
}
}
}
@@ -309,18 +309,10 @@ fn explicit_cube_gradients_take_metals_footprint() {
assert!(compiled >= 4, "{compiled}");
}
/// The textures `unk_cube_grad_lod` samples, a cube and a cube array, twice each: Metal's level and
/// taps of a cube's explicit gradients, emulated, is one sampling routine per texture
/// (`routine::Filter`), which each of its samples calls.
const CUBE_GRAD_TEXTURES: usize = 2;
/// An anisotropic constexpr sampler (`max_anisotropy(2)`, bits 20-23 of the state's first word) on
/// a cube's explicit gradients takes Metal's footprint on every profile that compiles the isotropic
/// fixture. Without `samplerAnisotropy`, whose Vulkan sampler is isotropic, the shader takes
/// Metal's level and taps: each texture's routine, which its samples call, queries the level count
/// and loops over its taps, `AnisotropicFilter` is recorded and `CubeGradientFootprint` is not;
/// with the feature, and through the isotropic sampler on every profile, the device's sample at
/// Metal's footprint: no loop, no level query, `CubeGradientFootprint` recorded. Neither module
/// fixture, each with `samplerAnisotropy`: the device's sample at Metal's footprint, as through the
/// isotropic sampler: no loop, no level query, `CubeGradientFootprint` recorded. Neither module
/// has a `Length`.
#[test]
fn an_anisotropic_constexpr_sampler_takes_metals_cube_gradient_footprint() {
@@ -349,7 +341,7 @@ fn an_anisotropic_constexpr_sampler_takes_metals_cube_gradient_footprint() {
let Some(i) = artifact(&iso, "unk_cube_grad_lod", &stem, &p) else {
continue;
};
let shader = !p.fields().images.sampler_anisotropy;
assert!(p.fields().images.sampler_anisotropy, "{stem}");
assert_eq!(glsl(&i, GLSL_LENGTH), 0, "{stem}");
let samples = uses(&i, "sampler.sample_cube_grad") as usize;
assert!(samples > 0, "{stem}");
@@ -359,10 +351,6 @@ fn an_anisotropic_constexpr_sampler_takes_metals_cube_gradient_footprint() {
i.precision.contains(&PrecisionNote::CubeGradientFootprint),
"{stem}"
);
assert!(
!i.precision.contains(&PrecisionNote::AnisotropicFilter),
"{stem}"
);
let a = artifact(&aniso, "unk_cube_grad_lod", &stem, &p)
.unwrap_or_else(|| panic!("{stem}: the anisotropic sampler refused"));
compiled += 1;
@@ -372,20 +360,10 @@ fn an_anisotropic_constexpr_sampler_takes_metals_cube_gradient_footprint() {
"{stem}"
);
assert_eq!(glsl(&a, GLSL_LENGTH), 0, "{stem}");
assert_eq!(
count(&a, OP_LOOP_MERGE),
if shader { CUBE_GRAD_TEXTURES } else { 0 },
"{stem}"
);
assert_eq!(
a.precision.contains(&PrecisionNote::AnisotropicFilter),
shader,
"{stem}: {:?}",
a.precision
);
assert_eq!(
assert_eq!(count(&a, OP_IMAGE_QUERY_LEVELS), 0, "{stem}");
assert_eq!(count(&a, OP_LOOP_MERGE), 0, "{stem}");
assert!(
a.precision.contains(&PrecisionNote::CubeGradientFootprint),
!shader,
"{stem}: {:?}",
a.precision
);
@@ -395,8 +373,7 @@ fn an_anisotropic_constexpr_sampler_takes_metals_cube_gradient_footprint() {
/// Vulkan's cube-gradient rule: `moltenvk-m3` takes the device's own reading of the form handed
/// to it: `unk_cube_grad_lod` through its isotropic sampler and through an anisotropic constexpr
/// one queries no level count, loops over no taps and records `CubeGradientFootprint`, not
/// `AnisotropicFilter`.
/// one queries no level count, loops over no taps and records `CubeGradientFootprint`.
#[test]
fn a_cube_gradient_route_takes_the_devices_reading() {
let path = engine_dir().join("unk_cube_grad_lod.ll");
@@ -431,11 +408,6 @@ fn a_cube_gradient_route_takes_the_devices_reading() {
assert!(samples > 0, "{what}");
assert_eq!(count(&u, OP_IMAGE_QUERY_LEVELS), 0, "{what}");
assert_eq!(count(&u, OP_LOOP_MERGE), 0, "{what}");
assert!(
!u.precision.contains(&PrecisionNote::AnisotropicFilter),
"{what}: {:?}",
u.precision
);
assert!(
u.precision.contains(&PrecisionNote::CubeGradientFootprint),
"{what}: {:?}",
@@ -2049,7 +2049,6 @@ field metal2vulkan::cache::SpecializationKey.data pub data: Vec<u8>
field metal2vulkan::cache::SpecializationKey.entries pub entries: Vec<vk::SpecializationMapEntry>
field metal2vulkan::cache::VariantKey.addressed_function_tables pub addressed_function_tables: bool
field metal2vulkan::cache::VariantKey.amplification_draws pub amplification_draws: Option<crate::pipeline::AmplificationDraws>
field metal2vulkan::cache::VariantKey.anisotropic_samplers pub anisotropic_samplers: BTreeSet<SlotRef>
field metal2vulkan::cache::VariantKey.call_threadgroups pub call_threadgroups: bool
field metal2vulkan::cache::VariantKey.depth_clamp_range pub depth_clamp_range: bool
field metal2vulkan::cache::VariantKey.dropped_colors pub dropped_colors: BTreeSet<u32>
@@ -2537,7 +2536,6 @@ field metal2vulkan::pipeline::LoweringInputs.addressed_function_tables pub addre
field metal2vulkan::pipeline::LoweringInputs.alpha_in_red_colors pub alpha_in_red_colors: BTreeSet<u32>
field metal2vulkan::pipeline::LoweringInputs.alpha_test pub alpha_test: Option<crate::metal::CompareFunction>
field metal2vulkan::pipeline::LoweringInputs.amplification_draws pub amplification_draws: Option<AmplificationDraws>
field metal2vulkan::pipeline::LoweringInputs.anisotropic_samplers pub anisotropic_samplers: BTreeSet<SlotRef>
field metal2vulkan::pipeline::LoweringInputs.arrayed_fetches pub arrayed_fetches: BTreeSet<u32>
field metal2vulkan::pipeline::LoweringInputs.call_threadgroups pub call_threadgroups: bool
field metal2vulkan::pipeline::LoweringInputs.color_writes pub color_writes: BTreeMap<u32, [Option<ChannelWrite>; 4]>
@@ -8602,7 +8600,6 @@ variant metal2vulkan-runtime::PartialThreadgroupsSite::SimdGroups SimdGroups { w
variant metal2vulkan-runtime::PartialThreadgroupsSite::Structure Structure { cause: PartialThreadgroupsCause }
variant metal2vulkan-runtime::PartialThreadgroupsSite::Translator Translator
variant metal2vulkan-runtime::PartialThreadgroupsSite::VoteWord VoteWord { static_length: u32, max: u32 }
variant metal2vulkan-runtime::PrecisionNote::AnisotropicFilter AnisotropicFilter
variant metal2vulkan-runtime::PrecisionNote::ArgumentPixelSamplerScaling ArgumentPixelSamplerScaling
variant metal2vulkan-runtime::PrecisionNote::BicubicFilterArithmetic BicubicFilterArithmetic
variant metal2vulkan-runtime::PrecisionNote::BlendedWriteRounding BlendedWriteRounding
@@ -8613,7 +8610,6 @@ variant metal2vulkan-runtime::PrecisionNote::CoverageReadsRoundedAlpha CoverageR
variant metal2vulkan-runtime::PrecisionNote::CubeGradientFootprint CubeGradientFootprint
variant metal2vulkan-runtime::PrecisionNote::DepthDenormals DepthDenormals
variant metal2vulkan-runtime::PrecisionNote::DeviceAlphaCoverage DeviceAlphaCoverage
variant metal2vulkan-runtime::PrecisionNote::DeviceAnisotropicFilter DeviceAnisotropicFilter
variant metal2vulkan-runtime::PrecisionNote::DeviceArithmetic DeviceArithmetic
variant metal2vulkan-runtime::PrecisionNote::DeviceColorConversion DeviceColorConversion
variant metal2vulkan-runtime::PrecisionNote::DeviceDenormals DeviceDenormals
@@ -10007,7 +10003,6 @@ variant metal2vulkan::pipeline::OwnKernel::ExecutionCounts ExecutionCounts
variant metal2vulkan::pipeline::OwnKernel::SamplesToBytes SamplesToBytes { aspect: SampleAspect, arrayed: bool }
variant metal2vulkan::pipeline::PatchDomain::Quad Quad
variant metal2vulkan::pipeline::PatchDomain::Triangle Triangle
variant metal2vulkan::pipeline::PrecisionNote::AnisotropicFilter AnisotropicFilter
variant metal2vulkan::pipeline::PrecisionNote::ArgumentPixelSamplerScaling ArgumentPixelSamplerScaling
variant metal2vulkan::pipeline::PrecisionNote::BicubicFilterArithmetic BicubicFilterArithmetic
variant metal2vulkan::pipeline::PrecisionNote::BlendedWriteRounding BlendedWriteRounding
@@ -10018,7 +10013,6 @@ variant metal2vulkan::pipeline::PrecisionNote::CoverageReadsRoundedAlpha Coverag
variant metal2vulkan::pipeline::PrecisionNote::CubeGradientFootprint CubeGradientFootprint
variant metal2vulkan::pipeline::PrecisionNote::DepthDenormals DepthDenormals
variant metal2vulkan::pipeline::PrecisionNote::DeviceAlphaCoverage DeviceAlphaCoverage
variant metal2vulkan::pipeline::PrecisionNote::DeviceAnisotropicFilter DeviceAnisotropicFilter
variant metal2vulkan::pipeline::PrecisionNote::DeviceArithmetic DeviceArithmetic
variant metal2vulkan::pipeline::PrecisionNote::DeviceColorConversion DeviceColorConversion
variant metal2vulkan::pipeline::PrecisionNote::DeviceDenormals DeviceDenormals
@@ -10245,7 +10239,6 @@ variant metal2vulkan::pipeline::SpecKey::Presence Presence(SlotRef)
variant metal2vulkan::pipeline::SpecKey::RenderAreaHeight RenderAreaHeight
variant metal2vulkan::pipeline::SpecKey::RenderAreaWidth RenderAreaWidth
variant metal2vulkan::pipeline::SpecKey::SampleCount SampleCount
variant metal2vulkan::pipeline::SpecKey::SamplerAnisotropy SamplerAnisotropy(SlotRef)
variant metal2vulkan::pipeline::SpecKey::SamplerMinLevel SamplerMinLevel(SlotRef)
variant metal2vulkan::pipeline::SpecKey::SparseTexture SparseTexture(SlotRef)
variant metal2vulkan::pipeline::SpecKey::TexelBufferWords TexelBufferWords { stage: Stage, handles: bool }
Can't render this file because it is too large.
+2 -25
View File
@@ -277,7 +277,7 @@ the runtime's, the command line's, the compile worker's and every validation too
0-11 of the ID's word, a slot's pushed and a member's in the argument buffer). Any other
function is refused as `Unsupported{IdentityDomains}`, whose cause (`Cause::Identity`) names
the family of the first such form the function holds and whose symbol names the form: one that samples through an argument buffer's sampler or samples an
argument buffer's texture, emulates a sampler's anisotropy, samples a 1D
argument buffer's texture, samples a 1D
texture through a bicubic filter, uses a slot's swizzle, a two-plane, extended-range or sRGB-twin form, reads an
argument buffer's texture
through another numeric type or as raw texels, or uses any other state of a texture or sampler
@@ -2045,8 +2045,7 @@ category, and says what makes an operation carry the note and what may differ. E
`PrecisionNote::CubeGradientFootprint`: An explicit-gradient sample of a cube texture takes
Metal's footprint in the form Vulkan's rule reads, in every stage on every device. Cost: the
sample takes the device's logarithm of Metal's footprint and, if anisotropic, the device's taps,
so a level or blend near a boundary can differ from Metal's. Where the shader takes Metal's level
and taps itself (`PrecisionNote::AnisotropicFilter`) this note is not recorded.
so a level or blend near a boundary can differ from Metal's.
- `metal2vulkan-degrade-half-texel-conversion` (precision). `PrecisionNote::HalfTexelConversion`:
The module reads, gathers, or samples a texture with a `half` result, the device's `float` texel
rounded to nearest even on every device: within one `half` ulp of Metal's, but a 32-bit float
@@ -2259,28 +2258,6 @@ category, and says what makes an operation carry the note and what may differ. E
some channel written (`StageIo::half_blend_colors`, which the pipeline's stage reads), or its
module names no math mode (under fast math the pipeline's stage records
`PrecisionNote::HalfOutputFastMathBlend` instead).
- `metal2vulkan-degrade-anisotropic-filter` (precision). `PrecisionNote::AnisotropicFilter`: The
module samples a texture through an anisotropic sampler with Metal's anisotropic filter emulated
by the device's samples at explicit levels (`lower::sampler::anisotropic`), on a device without
`samplerAnisotropy`, every Vulkan sampler being isotropic there, each tap the device's isotropic
filter: a sample without comparison of a 2D texture or 2D array at the fragment's implicit
level or with explicit gradients, or of a cube or cube array with explicit gradients, through a
constexpr sampler of `maxAnisotropy` above 1, or through a runtime sampler slot whose word states
anisotropy (under that word alone). A device with the feature samples with its own anisotropic
filter. The footprint's logarithms and powers are the device's `Log2` and `Exp2`, its level and
spacing unrounded, and a linear mip filter's two levels the device's own blend at the fractional
level, where Metal takes a piecewise-linear `log2`, 256ths and 4096ths. Cost: a
cube's taps step across its face by Metal's face gradients, and a tap past the face's edge reads
the next face as the device projects it, which Metal's own is not measured against.
- `metal2vulkan-degrade-device-anisotropic-filter` (precision).
`PrecisionNote::DeviceAnisotropicFilter`: The module samples a texture through a sampler whose
anisotropy is known where Metal's anisotropic filter is not emulated
(`PrecisionNote::AnisotropicFilter`'s reach), on a device without `samplerAnisotropy`, which
filters it isotropically: a cube, a 3D texture, a comparison, a sample whose residency the
function observes, or a texture of another class than its declared one, at an implicit level or
with explicit gradients, through a constexpr sampler of `maxAnisotropy` above 1 or a runtime
sampler slot whose word states anisotropy (under that word alone). An argument buffer's
anisotropic sampler, which the function cannot record, is refused there (`SamplerAnisotropy`).
- `metal2vulkan-degrade-device-point-size` (precision). `PrecisionNote::DevicePointSize`: A vertex
function writes `[[point_size]]`, or a mesh function that outputs points `set_point_size`, on a
device whose `pointSizeRange` ends below Metal's largest point, 511 pixels
+4 -3
View File
@@ -26,7 +26,7 @@ Columns:
| Kind | Variants | With a site | Reach system | Reach app | Reach rare | Reach none | Unassessed |
|---|---|---|---|---|---|---|---|
| Translator and front-end refusals | 120 | 115 | 6 | 27 | 66 | 21 | 0 |
| Translator and front-end refusals | 120 | 116 | 6 | 27 | 66 | 21 | 0 |
| Translation caps | 14 | 14 | 0 | 0 | 7 | 7 | 0 |
| Rate maps the compile layer does not compile | 5 | 5 | 0 | 0 | 4 | 1 | 0 |
| The translation deadline | 1 | 1 | 0 | 0 | 0 | 1 | 0 |
@@ -39,7 +39,7 @@ Columns:
| Kind | `metal-measured` | `metal-documented` | `metal-takes` | `device` | `ours` | `unknown` | `delegated` | `-` |
|---|---|---|---|---|---|---|---|---|
| Translator and front-end refusals | 0 | 0 | 3 | 45 | 67 | 0 | 0 | 5 |
| Translator and front-end refusals | 0 | 0 | 3 | 46 | 67 | 0 | 0 | 4 |
| Translation caps | 0 | 0 | 0 | 0 | 14 | 0 | 0 | 0 |
| Rate maps the compile layer does not compile | 0 | 0 | 0 | 0 | 5 | 0 | 0 | 0 |
| The translation deadline | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 |
@@ -101,7 +101,7 @@ Columns:
| `StorageImageMultisample` | Multisampled storage images | every device (not implemented) | `ours` | 2: `crates/metal2vulkan/src/lower/texture/slot.rs (declare_heap)`, `crates/metal2vulkan/src/lower/texture/slot.rs (declare_slot)` | `rare`: writable multisampled textures |
| `StorageTextureInVertexStage` | Storage images in the vertex stage | devices short of a Vulkan feature the site names | `device` | via a helper: 1: `crates/metal2vulkan/src/lower/texture/slot.rs (stage_stores)` | `rare`: writable textures in vertex functions |
| `CubeArray` | Cube arrays | devices without VkFeature::ImageCubeArray | `device` | 2: `crates/metal2vulkan/src/lower/sampler/select.rs (select_one)`, `crates/metal2vulkan/src/lower/texture/slot.rs (declare_heap)` | `rare`: cube arrays on a device without imageCubeArray |
| `SamplerAnisotropy` | Sampler anisotropy an argument buffer lists, on a device without `samplerAnisotropy` | - | `-` | 0 | `app`: anisotropic samplers an argument buffer lists, on a device without samplerAnisotropy |
| `SamplerAnisotropy` | A sampler of `maxAnisotropy` above 1 for a use that filters, on a device without `samplerAnisotropy` (`metal::sampler::check_sampler`) | devices without VkFeature::SamplerAnisotropy | `device` | 1: `crates/metal2vulkan/src/metal/sampler.rs (check_sampler)` | `app`: anisotropic samplers on a device without samplerAnisotropy |
| `SamplerBorderColor` | Sampler border colors Vulkan cannot express | devices without a capability the site computes (`missing`); devices without a capability the site computes (`need`); devices without a capability the site computes (`vec![need]`); every device (not implemented) | `ours` | 4: `crates/metal2vulkan/src/metal/sampler.rs (border_read, 4 sites)` | `app`: border colors a device cannot express |
| `SamplerLodBias` | Sampler LOD bias | devices short of a Vulkan feature the site names; devices without VkLimit::MaxSamplerLodBias; every device (no Vulkan mechanism) | `device` | 3: `crates/metal2vulkan/src/lower/sampler/constexpr.rs (constexpr_desc, 3 sites)` | `app`: constexpr samplers with an LOD bias |
| `SamplerCompare` | Sampler compare functions outside what Vulkan allows for the image | devices short of a Vulkan feature the site names | `device` | 1: `crates/metal2vulkan/src/metal/sampler.rs (check_sampler)` | `app`: compare samplers a device cannot apply to the image |
@@ -436,6 +436,7 @@ Each refusal's sites, with the function that builds it.
- `feature::StorageImageMultisample`: `crates/metal2vulkan/src/lower/texture/slot.rs (declare_heap)`; `crates/metal2vulkan/src/lower/texture/slot.rs (declare_slot)`
- `feature::StorageTextureInVertexStage`: `crates/metal2vulkan/src/lower/texture/slot.rs (stage_stores)`
- `feature::CubeArray`: `crates/metal2vulkan/src/lower/sampler/select.rs (select_one)`; `crates/metal2vulkan/src/lower/texture/slot.rs (declare_heap)`
- `feature::SamplerAnisotropy`: `crates/metal2vulkan/src/metal/sampler.rs (check_sampler)`
- `feature::SamplerBorderColor`: `crates/metal2vulkan/src/metal/sampler.rs (border_read, 4 sites)`
- `feature::SamplerLodBias`: `crates/metal2vulkan/src/lower/sampler/constexpr.rs (constexpr_desc, 3 sites)`
- `feature::SamplerCompare`: `crates/metal2vulkan/src/metal/sampler.rs (check_sampler)`
+1 -1
View File
@@ -51,7 +51,7 @@ feature GatherExtended rare gathers with dynamic offsets or components
feature StorageImageMultisample rare writable multisampled textures
feature StorageTextureInVertexStage rare writable textures in vertex functions
feature CubeArray rare cube arrays on a device without imageCubeArray
feature SamplerAnisotropy app anisotropic samplers an argument buffer lists, on a device without samplerAnisotropy
feature SamplerAnisotropy app anisotropic samplers on a device without samplerAnisotropy
feature SamplerBorderColor app border colors a device cannot express
feature SamplerLodBias app constexpr samplers with an LOD bias
feature SamplerCompare app compare samplers a device cannot apply to the image
Can't render this file because it contains an unexpected character in line 17 and column 65.