Tests: a runtime sampler's LOD query outside a fragment function compiles under the identity domains (red)
Under the identity domains (the runtime's policy) a clamped calculate_clamped_lod in a kernel or a vertex function through a runtime sampler argument is refused on every profile, "a sampler argument whose minimum level or emulated filter the function specializes": the query wants the slot's SamplerMinLevel specialization, which no binder chooses there. The two tests compile rfs_kernel_lod's runtime-sampler entries (lod_2d, lod_2d_array, lod_3d, lod_cube, lod_vertex) and sampling_completion's lod_query_kernel under the identity policy on the lavapipe and moltenvk-m3 profiles, and require L3 to pass, no SamplerMinLevel or SamplerState specialization, the sampler slot's resource ID pushed, one OpImageQueryLevels and no OpImageQueryLod. Red at this commit: each compile is the IdentityDomains refusal. The red run is the lane's next potluck job.
This commit is contained in:
1 parent
dfbc157464
commit
c04212227d
2 files changed
+104
-5
No files matched your search
@@ -6,17 +6,22 @@
|
||||
//! sixty-fourths of its `half` clamp. No query asks the device (`OpImageQueryLod`). A depth
|
||||
//! texture's query was not measured and is refused.
|
||||
//!
|
||||
//! Under the identity domains a runtime sampler's minimum is read from the word of the resource ID
|
||||
//! its slot pushes (`PushField::SlotGuestBase`): 0 where the word states no mip filter, else the
|
||||
//! level a nearest mip filter reads at `lodMinClamp` (`SamplerWord::LEVEL_MIN`), with no
|
||||
//! specialization.
|
||||
//!
|
||||
//! The values are checked by the fixture's authored cases on Metal; here the structure. `llvm-as`
|
||||
//! assembles the fixture; without it the tests skip visibly.
|
||||
|
||||
use crate::device::profile::DeviceProfile;
|
||||
use crate::device::profile::{DeviceProfile, HandleDomain, PointerDomain};
|
||||
use crate::device::requirements::VkFeature;
|
||||
use crate::device::DevicePolicy;
|
||||
use crate::error::{Capability, Error, Feature, Needs};
|
||||
use crate::library::FunctionArtifact;
|
||||
use crate::pipeline::sym::{SlotClass, SlotRef, SpecKey, Stage};
|
||||
use crate::pipeline::sym::{PushField, SlotClass, SlotRef, SpecKey, Stage};
|
||||
use crate::pipeline::testing::{
|
||||
compile, engine_dir, link_and_validate, llvm_assemble, profile, AssembleError,
|
||||
compile, compile_kept, engine_dir, link_and_validate, llvm_assemble, profile, AssembleError,
|
||||
};
|
||||
use crate::spirv::testing::committed_profiles;
|
||||
|
||||
@@ -50,6 +55,27 @@ fn m3() -> DeviceProfile {
|
||||
profile("moltenvk-m3", DevicePolicy::RESIDENT_TABLES).expect("profile")
|
||||
}
|
||||
|
||||
/// The runtime's policy: the identity domains.
|
||||
fn identity() -> DevicePolicy {
|
||||
DevicePolicy {
|
||||
pointer_domain: PointerDomain::Identity,
|
||||
handle_domain: HandleDomain::Identity,
|
||||
..DevicePolicy::RESIDENT_TABLES
|
||||
}
|
||||
}
|
||||
|
||||
/// Profiles with `bufferDeviceAddress` and `shaderInt64`, which the identity domains need.
|
||||
const IDENTITY_PROFILES: [&str; 2] = ["lavapipe", "moltenvk-m3"];
|
||||
|
||||
/// The entries that query through runtime sampler slot 0, and their stages.
|
||||
const RUNTIME_SAMPLER_ENTRIES: [(&str, Stage); 5] = [
|
||||
("lod_2d", Stage::Kernel),
|
||||
("lod_2d_array", Stage::Kernel),
|
||||
("lod_3d", Stage::Kernel),
|
||||
("lod_cube", Stage::Kernel),
|
||||
("lod_vertex", Stage::Vertex),
|
||||
];
|
||||
|
||||
/// The instructions of a SPIR-V module: opcode and word offset.
|
||||
fn insts(words: &[u32]) -> Vec<(u16, usize)> {
|
||||
let mut out = Vec::new();
|
||||
@@ -207,3 +233,44 @@ fn a_constexpr_samplers_query_is_its_minimum_level() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Under the identity domains a runtime sampler's clamped query compiles and passes L3 on every
|
||||
/// identity profile, in kernels over every measured texture type and in a vertex function: it
|
||||
/// reads the word of the resource ID its sampler slot pushes, with no `SamplerMinLevel` or
|
||||
/// `SamplerState` specialization, against the texture's level count, and asks the device for no
|
||||
/// level of detail.
|
||||
#[test]
|
||||
fn under_the_identity_domains_a_runtime_samplers_query_reads_its_pushed_word() {
|
||||
let Some(bc) = fixture() else {
|
||||
return;
|
||||
};
|
||||
for stem in IDENTITY_PROFILES {
|
||||
let p = profile(stem, identity()).unwrap_or_else(|e| panic!("{stem}: {e}"));
|
||||
for (entry, stage) in RUNTIME_SAMPLER_ENTRIES {
|
||||
let what = format!("{entry} on {stem}");
|
||||
let (a, plan, _) =
|
||||
compile_kept(&bc, entry, &p).unwrap_or_else(|e| panic!("{what}: {e}"));
|
||||
link_and_validate(&a, &p).unwrap_or_else(|e| panic!("{what}: L3: {e}"));
|
||||
let slot = SlotRef {
|
||||
stage,
|
||||
class: SlotClass::Sampler,
|
||||
index: 0,
|
||||
};
|
||||
let keys = spec_keys(&a);
|
||||
assert!(
|
||||
!keys.iter().any(|k| matches!(
|
||||
k,
|
||||
SpecKey::SamplerMinLevel(_) | SpecKey::SamplerState { .. }
|
||||
)),
|
||||
"{what}: {keys:?}"
|
||||
);
|
||||
assert!(
|
||||
(plan.push.fields.iter()).any(|f| f.field == PushField::SlotGuestBase(slot)),
|
||||
"{what}: the sampler's resource ID is not pushed"
|
||||
);
|
||||
assert_eq!(uses(&a, "sampler.query_level"), 2, "{what}");
|
||||
assert_eq!(count(&a, OP_IMAGE_QUERY_LEVELS), 1, "{what}");
|
||||
assert_eq!(count(&a, OP_IMAGE_QUERY_LOD), 0, "{what}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,8 @@
|
||||
//! dynamic offset; a switch whose arms all fetch hoists nothing.
|
||||
//! - Outside a fragment function a bias and a minimum-LOD clamp select an explicit level; an LOD
|
||||
//! query there answers Metal's measured level: the clamped one is the runtime sampler's
|
||||
//! `SamplerMinLevel` specialization bounded by the texture's last level.
|
||||
//! `SamplerMinLevel` specialization bounded by the texture's last level, and under the identity
|
||||
//! domains the minimum level its pushed resource ID's word states.
|
||||
//! - A dynamic offset on a sample through any other sampler is the `Offset` operand, the value
|
||||
//! Metal applies, where the profile has `maintenance8` and `shaderImageGatherExtended`, and a
|
||||
//! typed refusal naming the missing ones elsewhere (replacing the refusal).
|
||||
@@ -22,7 +23,7 @@
|
||||
//!
|
||||
//! `llvm-as` assembles the fixtures; without it the tests skip visibly.
|
||||
|
||||
use crate::device::profile::DeviceProfile;
|
||||
use crate::device::profile::{DeviceProfile, HandleDomain, PointerDomain};
|
||||
use crate::device::requirements::VkFeature;
|
||||
use crate::device::DevicePolicy;
|
||||
use crate::library::FunctionArtifact;
|
||||
@@ -206,6 +207,37 @@ fn a_kernels_clamped_lod_query_reads_the_samplers_minimum_level() {
|
||||
);
|
||||
}
|
||||
|
||||
/// Under the identity domains the kernel's clamped LOD query compiles and passes L3 on every
|
||||
/// identity profile: it reads its sampler slot's pushed resource ID, no specialization, against
|
||||
/// the texture's last level, and makes no `OpImageQueryLod`.
|
||||
#[test]
|
||||
fn under_the_identity_domains_a_kernels_clamped_lod_query_reads_the_samplers_word() {
|
||||
let Some(bc) = fixture() else {
|
||||
return;
|
||||
};
|
||||
let policy = DevicePolicy {
|
||||
pointer_domain: PointerDomain::Identity,
|
||||
handle_domain: HandleDomain::Identity,
|
||||
..DevicePolicy::RESIDENT_TABLES
|
||||
};
|
||||
for stem in ["lavapipe", "moltenvk-m3"] {
|
||||
let p = profile(stem, policy).unwrap_or_else(|e| panic!("{stem}: {e}"));
|
||||
let a = ok(&bc, "lod_query_kernel", &p);
|
||||
assert_eq!(uses(&a, "sampler.query_level"), 1, "{stem}");
|
||||
assert_eq!(count(&a, OP_IMAGE_QUERY_LOD), 0, "{stem}");
|
||||
assert_eq!(count(&a, OP_IMAGE_QUERY_LEVELS), 1, "{stem}");
|
||||
assert_eq!(glsl(&a, GLSL_FMIN), 1, "{stem}");
|
||||
let keys = a.interface.read_keys();
|
||||
assert!(
|
||||
!keys.iter().any(|k| matches!(
|
||||
k,
|
||||
SpecKey::SamplerMinLevel(_) | SpecKey::SamplerState { .. }
|
||||
)),
|
||||
"{stem}: {keys:?}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// A sampler selected between a runtime and a constexpr sampler is a switch at the use, one arm and
|
||||
/// one combined binding per sampler; the runtime arm keeps its coordinate specialization and the
|
||||
/// constexpr binding is the layout's immutable sampler.
|
||||
|
||||
Reference in new issue
Block a user