Identity domains: a read through a sampler takes its border texels from the resource ID's word
MSL 4.1's read(sampler, coord[, offset][, lod]) of a texture slot, through a constexpr sampler
with a clamp_to_zero or clamp_to_border axis or through a runtime [[sampler(n)]], reads Metal's
border texel at an index outside the level. The default domains take the border texels from the
slot's BorderTexels specialization (RuntimeFact::BorderTexels); under the identity domains that was
state of the bound texture they did not source, so such a kernel was
Unsupported{IdentityDomains}. The border texels are bits 0-11 of the texture word
(TextureWord::BORDER_TEXELS, docs/RESOURCE-ID.md), already in the slot's pushed resource ID
(PushField::SlotGuestBase). Under the identity domains select_through now sets neither the slot's
border_texels nor the fact, and border_bits reads the word through emit::identity_id and masks
it, as the format's missing alpha is read. SlotPlan::identity_lowered and identity_unsourced drop
the border texels, which the identity domains now source. An argument buffer's texture read so
(its handle-table entry's border texels) is still refused. The default domains are unchanged.
Conformance (known-gaps-rt.tsv, runtime on lavapipe against the committed Metal answers): six
read-through rows translate and match, so their rows go: read-through-int exact;
read-through-half, -layers, -line, -read-write and -volume differ only by notices the suite
declares. read-through-volume reads through a runtime sampler of an opaque-black border, whose
sampler state the runtime notes on every device: the case now declares that notice
(replay::swizzled_border_notice) wherever it reads through such a sampler, as border_swizzles
does. The four plane rows (a8, r32f, rgba8, rgba8-swizzled) now make every pipeline up to
rt_heap_zero, an argument buffer's texture read through a border sampler, where they are still
refused; their rows move there.
Docs: RESOURCE-ID.md says a slot's read through a sampler takes its border texel from bits 0-11
of the word; API.md's identity forms name the read through a sampler (the paragraph's lines
reflowed); CONFORMANCE-COVERAGE.md re-derived for the six rows gone (REFUSALS.md re-derives
unchanged).
Test: engine_identity's a_read_through_a_sampler_takes_its_border_texels_from_the_word:
engine/kernel_read_through's rt_arg (a runtime sampler, offset (1, -1)) under the identity domains
on lavapipe, moltenvk-m3 and moltenvk-m3 without robustImageAccess2: L3, no specialization
constant but the dispatch's, no BorderTexels fact, and on the CPU interpreter, through a sampler
that clamps every axis to the border, each of R32Float, RGBA8Unorm, A8Unorm and RGBA8Unorm
swizzled (a, b, 0, r), under each border color, reads metal::sampler::border_texel's texel past
the right, left and top edges and the texel inside.
SEMANTICS_VERSION 2234, one above the previous commit's (main renumbers at landing): a refusal
becomes a module. The old runtime's render descriptor key changes with it, pinned at landing.
Verified (potluck; the jobs ran this diff on the previous commit's diff on development
846f7c1428, and this commit is the same diff on the previous commit, whose base 62c563f564 touches
none of its lines but SEMANTICS_VERSION and the API.md paragraph's neighbours):
- m3-max-61431 (msi, at the WIP tree b94d87fbf1, this diff but the coverage document): cargo fmt
--check, clippy with all features, with --cfg m2v_gpu and with --cfg m2v_cpu_icd, and Rustdoc
-D warnings pass; nextest of metal2vulkan and metal2vulkan-conformance 4364 run, 4362 passed,
among them both engine_identity tests of this and the previous commit and
golden_hashes_match_the_table; the two failures the old render descriptor key above and
the_conformance_coverage_document_is_what_the_sources_derive, for the coverage document this
commit re-derives (coverage.py --check passes at this tree); the metal2vulkan-conformance suite
under --cfg m2v_cpu_icd on lavapipe 1014 of 1015 passed, the one failure that coverage document.
- m3-max-61342 (msi, at the WIP tree 80c41fdb12, the code before the ledger rows): conformance
replay --cpu of the read-through cases and swizzled-storage-atomics: read-through-int exact;
-half, -layers, -line and -read-write announced (declared notices); -volume divergent by the
undeclared opaque-black border notice, which the case now declares; the four plane rows
refused at rt_heap_zero.
- m3-max-61353 (um870, llvmpipe LLVM 23.1.4, at b94d87fbf1): the same replay with the ledger rows
and the declared notice: announced 5, exact 1, refused 7, "exactly the open gaps
known-gaps-rt.tsv expects", exit 0.
- States-only play (the probe player, M2V_PROBE_STATES_ONLY=1, on lavapipe) built at b94d87fbf1
plus the five probe commits (m3-max-61345, um790), run over the 36 recorded streams on five
nodes (m3-max-61358 ms01, 61377 um790, 61379 gem10, 61404 um870, 61423 msi): 61 runs of 36
distinct streams, every one exit 0; 502920 render and 108189 compute states made, 0 refused.
This commit is contained in:
1 parent
2dd8ffce0d
commit
841c6872ac
11 files changed
+230
-43
No files matched your search
@@ -1490,18 +1490,12 @@ pixel-samplers-subnormal-zero llvmpipe divergent case/output/arg the digest is 5
|
||||
pixel-samplers-subnormal-zero llvmpipe divergent case/output/const the digest is d2b0dd0910609edc836eaf77d970e58e8b5bf1584a81e5bbdd581f10260b7c09 on Metal and 3cd68225ecf825024f7bc75bb6318d367d514eb2a722c30f35fa16240a59742a here The device's own answer (rule 1), every source alike: one digest per answer across the sources, as Metal's. lavapipe converts the `RGBA8Unorm` texture's codes by the reciprocal (note `device-texel-conversion`, one `f32` ulp of Metal's `c / 255`) and reads a subnormal coordinate by its own float controls (`device-denormals`, `device-sampling`). The site records a digest alone, so the run names no coordinate.
|
||||
pixel-samplers-subnormal-zero llvmpipe divergent case/output/norm the digest is b30d65a5b6c3adc9ccc52e398c23da742007c7663d6cfbb22c308e8b024dd9fd on Metal and 3a540b3ab22cd6439a2a70d799a84132af84526a78ab31fca25780b6c4c86174 here The device's own answer (rule 1), every source alike: one digest per answer across the sources, as Metal's. lavapipe converts the `RGBA8Unorm` texture's codes by the reciprocal (note `device-texel-conversion`, one `f32` ulp of Metal's `c / 255`) and reads a subnormal coordinate by its own float controls (`device-denormals`, `device-sampling`). The site records a digest alone, so the run names no coordinate.
|
||||
pixel-samplers-subnormal-zero llvmpipe divergent case/output/slot the digest is 527c2d3be9d37505e6907a1303a4f8c6b432290236e2baae359b54fa908f931c on Metal and 195b8e80f6e42c1cc1e4091a31b6a00a38620d1e99aaa4f0a5505931f9b77a00 here The device's own answer (rule 1), every source alike: one digest per answer across the sources, as Metal's. lavapipe converts the `RGBA8Unorm` texture's codes by the reciprocal (note `device-texel-conversion`, one `f32` ulp of Metal's `c / 255`) and reads a subnormal coordinate by its own float controls (`device-denormals`, `device-sampling`). The site records a digest alone, so the run names no coordinate.
|
||||
read-through-a8 * refused case/pipeline/rt_zero Err(Error::Translation("the translator made no pipeline: unsupported: IdentityDomains (texture argument SlotRef { stage: Kernel, class: Texture, index: 0 }: a type the identity arrays hold no element of, or state of the bound texture beyond its resource ID); needs NotImplemented")) refused: no stream uses it yet (states-only play 11-19, m3-max-56371-56373, 56375, player 44668b439f: 32 streams, every render and compute pipeline state made). The translator refuses the state (IdentityDomains: a form the identity domains do not lower); rt README, Known gaps of pipeline states.
|
||||
read-through-half * refused case/pipeline/rt_half Err(Error::Translation("the translator made no pipeline: unsupported: IdentityDomains (texture argument SlotRef { stage: Kernel, class: Texture, index: 0 }: a type the identity arrays hold no element of, or state of the bound texture beyond its resource ID); needs NotImplemented")) refused: no stream uses it yet (states-only play 11-19, m3-max-56371-56373, 56375, player 44668b439f: 32 streams, every render and compute pipeline state made). The translator refuses the state (IdentityDomains: a form the identity domains do not lower); rt README, Known gaps of pipeline states.
|
||||
read-through-a8 * refused case/pipeline/rt_heap_zero Err(Error::Translation("the translator made no pipeline: unsupported: IdentityDomains (a texture handle that reads its table entry beyond its element (Indexed { alpha: false, class: false, red_blue: false, unreadable: false })); needs NotImplemented")) refused: no stream uses it yet (states-only play 11-19, m3-max-56371-56373, 56375, player 44668b439f: 32 streams, every render and compute pipeline state made). The translator refuses the state (IdentityDomains: a form the identity domains do not lower); rt README, Known gaps of pipeline states.
|
||||
read-through-heap-border * refused case/pipeline/rt_heap_ow Err(Error::Translation("the translator made no pipeline: unsupported: IdentityDomains (a texture handle that reads its table entry beyond its element (Indexed { alpha: false, class: false, red_blue: false, unreadable: false })); needs NotImplemented")) refused: no stream uses it yet (states-only play 11-19, m3-max-56371-56373, 56375, player 44668b439f: 32 streams, every render and compute pipeline state made). The translator refuses the state (IdentityDomains: a form the identity domains do not lower); rt README, Known gaps of pipeline states.
|
||||
read-through-heap-sampler * refused case/pipeline/rt_heap_arg Err(Error::Translation("the translator made no pipeline: unsupported: IdentityDomains (a texture handle that reads its table entry beyond its element (Indexed { alpha: false, class: false, red_blue: false, unreadable: false })); needs NotImplemented")) refused: no stream uses it yet (states-only play 11-19, m3-max-56371-56373, 56375, player 44668b439f: 32 streams, every render and compute pipeline state made). The translator refuses the state (IdentityDomains: a form the identity domains do not lower); rt README, Known gaps of pipeline states.
|
||||
read-through-int * refused case/pipeline/rt_int Err(Error::Translation("the translator made no pipeline: unsupported: IdentityDomains (texture argument SlotRef { stage: Kernel, class: Texture, index: 0 }: a type the identity arrays hold no element of, or state of the bound texture beyond its resource ID); needs NotImplemented")) refused: no stream uses it yet (states-only play 11-19, m3-max-56371-56373, 56375, player 44668b439f: 32 streams, every render and compute pipeline state made). The translator refuses the state (IdentityDomains: a form the identity domains do not lower); rt README, Known gaps of pipeline states.
|
||||
read-through-layers * refused case/pipeline/rt_array Err(Error::Translation("the translator made no pipeline: unsupported: IdentityDomains (texture argument SlotRef { stage: Kernel, class: Texture, index: 0 }: a type the identity arrays hold no element of, or state of the bound texture beyond its resource ID); needs NotImplemented")) refused: no stream uses it yet (states-only play 11-19, m3-max-56371-56373, 56375, player 44668b439f: 32 streams, every render and compute pipeline state made). The translator refuses the state (IdentityDomains: a form the identity domains do not lower); rt README, Known gaps of pipeline states.
|
||||
read-through-line * refused case/pipeline/rt_line Err(Error::Translation("the translator made no pipeline: unsupported: IdentityDomains (texture argument SlotRef { stage: Kernel, class: Texture, index: 0 }: a type the identity arrays hold no element of, or state of the bound texture beyond its resource ID); needs NotImplemented")) refused: no stream uses it yet (states-only play 11-19, m3-max-56371-56373, 56375, player 44668b439f: 32 streams, every render and compute pipeline state made). The translator refuses the state (IdentityDomains: a form the identity domains do not lower); rt README, Known gaps of pipeline states.
|
||||
read-through-r32f * refused case/pipeline/rt_zero Err(Error::Translation("the translator made no pipeline: unsupported: IdentityDomains (texture argument SlotRef { stage: Kernel, class: Texture, index: 0 }: a type the identity arrays hold no element of, or state of the bound texture beyond its resource ID); needs NotImplemented")) refused: no stream uses it yet (states-only play 11-19, m3-max-56371-56373, 56375, player 44668b439f: 32 streams, every render and compute pipeline state made). The translator refuses the state (IdentityDomains: a form the identity domains do not lower); rt README, Known gaps of pipeline states.
|
||||
read-through-read-write * refused case/pipeline/rt_rw Err(Error::Translation("the translator made no pipeline: unsupported: IdentityDomains (texture argument SlotRef { stage: Kernel, class: Texture, index: 0 }: a type the identity arrays hold no element of, or state of the bound texture beyond its resource ID); needs NotImplemented")) refused: no stream uses it yet (states-only play 11-19, m3-max-56371-56373, 56375, player 44668b439f: 32 streams, every render and compute pipeline state made). The translator refuses the state (IdentityDomains: a form the identity domains do not lower); rt README, Known gaps of pipeline states.
|
||||
read-through-rgba8 * refused case/pipeline/rt_zero Err(Error::Translation("the translator made no pipeline: unsupported: IdentityDomains (texture argument SlotRef { stage: Kernel, class: Texture, index: 0 }: a type the identity arrays hold no element of, or state of the bound texture beyond its resource ID); needs NotImplemented")) refused: no stream uses it yet (states-only play 11-19, m3-max-56371-56373, 56375, player 44668b439f: 32 streams, every render and compute pipeline state made). The translator refuses the state (IdentityDomains: a form the identity domains do not lower); rt README, Known gaps of pipeline states.
|
||||
read-through-rgba8-swizzled * refused case/pipeline/rt_zero Err(Error::Translation("the translator made no pipeline: unsupported: IdentityDomains (texture argument SlotRef { stage: Kernel, class: Texture, index: 0 }: a type the identity arrays hold no element of, or state of the bound texture beyond its resource ID); needs NotImplemented")) refused: no stream uses it yet (states-only play 11-19, m3-max-56371-56373, 56375, player 44668b439f: 32 streams, every render and compute pipeline state made). The translator refuses the state (IdentityDomains: a form the identity domains do not lower); rt README, Known gaps of pipeline states.
|
||||
read-through-volume * refused case/pipeline/rt_volume Err(Error::Translation("the translator made no pipeline: unsupported: IdentityDomains (texture argument SlotRef { stage: Kernel, class: Texture, index: 0 }: a type the identity arrays hold no element of, or state of the bound texture beyond its resource ID); needs NotImplemented")) refused: no stream uses it yet (states-only play 11-19, m3-max-56371-56373, 56375, player 44668b439f: 32 streams, every render and compute pipeline state made). The translator refuses the state (IdentityDomains: a form the identity domains do not lower); rt README, Known gaps of pipeline states.
|
||||
read-through-r32f * refused case/pipeline/rt_heap_zero Err(Error::Translation("the translator made no pipeline: unsupported: IdentityDomains (a texture handle that reads its table entry beyond its element (Indexed { alpha: false, class: false, red_blue: false, unreadable: false })); needs NotImplemented")) refused: no stream uses it yet (states-only play 11-19, m3-max-56371-56373, 56375, player 44668b439f: 32 streams, every render and compute pipeline state made). The translator refuses the state (IdentityDomains: a form the identity domains do not lower); rt README, Known gaps of pipeline states.
|
||||
read-through-rgba8 * refused case/pipeline/rt_heap_zero Err(Error::Translation("the translator made no pipeline: unsupported: IdentityDomains (a texture handle that reads its table entry beyond its element (Indexed { alpha: false, class: false, red_blue: false, unreadable: false })); needs NotImplemented")) refused: no stream uses it yet (states-only play 11-19, m3-max-56371-56373, 56375, player 44668b439f: 32 streams, every render and compute pipeline state made). The translator refuses the state (IdentityDomains: a form the identity domains do not lower); rt README, Known gaps of pipeline states.
|
||||
read-through-rgba8-swizzled * refused case/pipeline/rt_heap_zero Err(Error::Translation("the translator made no pipeline: unsupported: IdentityDomains (a texture handle that reads its table entry beyond its element (Indexed { alpha: false, class: false, red_blue: false, unreadable: false })); needs NotImplemented")) refused: no stream uses it yet (states-only play 11-19, m3-max-56371-56373, 56375, player 44668b439f: 32 streams, every render and compute pipeline state made). The translator refuses the state (IdentityDomains: a form the identity domains do not lower); rt README, Known gaps of pipeline states.
|
||||
read-write-tier-held * divergent case/MTLPixelFormatA8Unorm/beyond/stored-bytes 64 elements differ (U8), the largest difference 238 Known gap (rt README, Known gaps of textures): the kernel writes a texture with no storage element on this device through the argument buffer, with no use_resource declaring the write, which is outside documented Metal: the write is dropped and the storage read there answers zeros.
|
||||
read-write-tier-held * divergent case/MTLPixelFormatA8Unorm/beyond/texels 64 elements differ (U32), the largest difference 1055846127 Known gap (rt README, Known gaps of textures): the kernel writes a texture with no storage element on this device through the argument buffer, with no use_resource declaring the write, which is outside documented Metal: the write is dropped and the storage read there answers zeros.
|
||||
read-write-tier-held NVIDIA divergent case/MTLPixelFormatBGR10A2Unorm/beyond/stored-bytes 256 elements differ (U8), the largest difference 235 Known gap (rt README, Known gaps of textures): the kernel writes a texture with no storage element on this device through the argument buffer, with no use_resource declaring the write, which is outside documented Metal: the write is dropped and the storage read there answers zeros.
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -896,6 +896,22 @@ impl Case for ReadThrough {
|
||||
sites.push(words);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// A case that reads through a runtime sampler of an opaque-black border (`border-black`)
|
||||
/// makes that sampler state, which the runtime notes on every device
|
||||
/// (`crate::replay::swizzled_border_notice`).
|
||||
fn allowances(&self) -> Vec<crate::allowance::Allowance> {
|
||||
let black = (self.reads.iter()).any(|read| match read.through {
|
||||
Through::Slot(_, spec)
|
||||
| Through::Table(_, spec)
|
||||
| Through::HeapTextureSlot(_, spec) => crate::replay::reads_opaque_black_border(&spec),
|
||||
Through::Constexpr | Through::HeapTexture => false,
|
||||
});
|
||||
match black {
|
||||
true => vec![crate::replay::swizzled_border_notice()],
|
||||
false => Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Vendored
+1
-1
@@ -61,7 +61,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 = 2233;
|
||||
pub const SEMANTICS_VERSION: u32 = 2234;
|
||||
|
||||
/// The byte-layout version of encoded artifacts (`CompiledFunction::to_bytes` and the
|
||||
/// [`PipelineArtifact`] encodings). Every encoded artifact carries it, and a decode under another
|
||||
|
||||
@@ -1878,8 +1878,8 @@ fn finish(
|
||||
}
|
||||
|
||||
/// Whether fact `f` names state of a bound texture or sampler the identity domains do not source
|
||||
/// yet: anything but a texture's presence and its format's missing alpha, which its resource ID
|
||||
/// holds.
|
||||
/// yet: anything but a texture's presence, its format's missing alpha and its border texels,
|
||||
/// which its resource ID holds.
|
||||
fn identity_unsourced(f: &RuntimeFact) -> bool {
|
||||
matches!(
|
||||
f,
|
||||
@@ -1915,7 +1915,6 @@ fn identity_unsourced(f: &RuntimeFact) -> bool {
|
||||
| RuntimeFact::StorageTextureIntegerChannels { .. }
|
||||
| RuntimeFact::YCbCrInPlace { .. }
|
||||
| RuntimeFact::TexelRows { .. }
|
||||
| RuntimeFact::BorderTexels { .. }
|
||||
| RuntimeFact::TexelBufferParts { .. }
|
||||
)
|
||||
}
|
||||
@@ -1924,7 +1923,8 @@ fn identity_unsourced(f: &RuntimeFact) -> bool {
|
||||
/// fragment function that reaches memory only through its buffer slots' device addresses, the
|
||||
/// device addresses it loads or makes from integers (`access::dynamic`, no root table), its
|
||||
/// textures' and runtime samplers' resource IDs and its constexpr samplers' pushed indices, with no
|
||||
/// descriptor and no state of a bound texture or sampler but its resource ID's
|
||||
/// descriptor and no state of a bound texture or sampler but its resource ID's: a texture's
|
||||
/// presence, its format's missing alpha and the border texels a read through a sampler reads
|
||||
/// (`SlotPlan::identity_lowered`, [`identity_unsourced`]). The values it reads of the encoder are
|
||||
/// pushed: the dispatch's region, a storage texture's integer channel widths, the compute
|
||||
/// encoder's stage-in region (`PushField::StageInRegion`), the stride of a vertex layout whose
|
||||
|
||||
@@ -315,15 +315,25 @@ pub(super) fn finish(
|
||||
}
|
||||
|
||||
/// The border texels of `image` (a `u32`, bit `3c + b` set where channel `c` of Metal's border
|
||||
/// texel for border color `b` reads 1): a slot's `BorderTexels` specialization, or a heap
|
||||
/// element's handle-table entry's (`memory::handles::FLAG_BORDER_TEXELS`), which the entry index
|
||||
/// its handle carries names.
|
||||
/// texel for border color `b` reads 1): a slot's `BorderTexels` specialization, under the identity
|
||||
/// domains bits 0-11 of its resource ID's word (`TextureWord::BORDER_TEXELS`), or a heap element's
|
||||
/// handle-table entry's (`memory::handles::FLAG_BORDER_TEXELS`), which the entry index its handle
|
||||
/// carries names.
|
||||
fn border_bits(
|
||||
cx: &mut EmitCx<'_>,
|
||||
fb: &mut FunctionBuilder<'_>,
|
||||
image: ImageRef,
|
||||
) -> BResult<SValue> {
|
||||
match image {
|
||||
ImageRef::Slot(index) if cx.plan.families.access.identity => {
|
||||
let (_, word) = super::identity_id(cx, fb, index)?;
|
||||
let mask = u32s(
|
||||
fb,
|
||||
1,
|
||||
crate::metal::resource_word::TextureWord::BORDER_TEXELS,
|
||||
)?;
|
||||
fb.binary(BinOp::BitwiseAnd, word, mask)
|
||||
}
|
||||
ImageRef::Slot(index) => {
|
||||
let bits = cx.decl.families.texture.border_texels.get(&index).copied();
|
||||
bits.ok_or_else(|| {
|
||||
|
||||
@@ -3662,10 +3662,11 @@ fn constant_read_sampler(state: &crate::air::abi::SamplerState) -> ReadSampler {
|
||||
|
||||
/// Plan what read through a sampler `t` of `image` reads besides the image: a runtime slot's
|
||||
/// word (`RuntimeSlot::reads`), and where an index outside the level may read the border texel, a
|
||||
/// slot's `BorderTexels` specialization (`RuntimeFact::BorderTexels`), or a heap element's
|
||||
/// handle-table entry's (`memory::handles::FLAG_BORDER_TEXELS`), which the module's search then
|
||||
/// names by its index in the handle (`AccessPlan::heap_border`). A `ulong` texel's border, which
|
||||
/// is not measured, is not implemented.
|
||||
/// slot's `BorderTexels` specialization (`RuntimeFact::BorderTexels`; under the identity domains
|
||||
/// its resource ID's word holds them, `emit::identity_id`), or a heap element's handle-table
|
||||
/// entry's (`memory::handles::FLAG_BORDER_TEXELS`), which the module's search then names by its
|
||||
/// index in the handle (`AccessPlan::heap_border`). A `ulong` texel's border, which is not
|
||||
/// measured, is not implemented.
|
||||
fn select_through(
|
||||
cx: &mut SelectCx<'_>,
|
||||
image: ImageRef,
|
||||
@@ -3685,6 +3686,7 @@ fn select_through(
|
||||
return Err(Unsupported::not_implemented(Feature::Lowering(LowerFamily::Texture)).into());
|
||||
}
|
||||
match image {
|
||||
ImageRef::Slot(_) if crate::lower::access::identity(cx.profile) => Ok(()),
|
||||
ImageRef::Slot(index) => {
|
||||
let Some(s) = cx.families.texture.slots.get_mut(&index) else {
|
||||
return Err(cx.invariant("an unplanned texture slot"));
|
||||
|
||||
@@ -221,7 +221,8 @@ pub struct SlotPlan {
|
||||
/// checks, or a level-view read under any check, past the bound level count.
|
||||
pub oob_alpha: bool,
|
||||
/// A read of the slot through a sampler may read the border texel, which the slot's
|
||||
/// `BorderTexels` specialization gives (`RuntimeFact::BorderTexels`).
|
||||
/// `BorderTexels` specialization gives (`RuntimeFact::BorderTexels`). Never under the identity
|
||||
/// domains, where the slot's resource ID's word holds the border texels.
|
||||
pub border_texels: bool,
|
||||
/// The device is left both an out-of-bounds store and an out-of-bounds load of the slot, so
|
||||
/// its variable is decorated `Volatile`; set by [`finish`].
|
||||
@@ -1763,13 +1764,12 @@ pub fn finish(cx: &mut SelectCx<'_>) -> Result<(), Error> {
|
||||
impl SlotPlan {
|
||||
/// Whether the identity domains lower the slot: its declaration has an identity array class
|
||||
/// ([`identity_class`]), or it has none (a slot that is only tested for presence), and it reads
|
||||
/// no state of the bound texture but its resource ID's (its presence and its format's missing
|
||||
/// alpha). A conversion by the bound format, a swizzle, sparse residency, border texels,
|
||||
/// constant lanes and offset bases each read a constant or a binding the slot does not have
|
||||
/// there yet.
|
||||
/// no state of the bound texture but its resource ID's (its presence, its format's missing
|
||||
/// alpha and its border texels). A conversion by the bound format, a swizzle, sparse
|
||||
/// residency, constant lanes and offset bases each read a constant or a binding the slot does
|
||||
/// not have there yet.
|
||||
pub(crate) fn identity_lowered(&self) -> bool {
|
||||
let state = self.border_texels
|
||||
|| self.sparse_arm
|
||||
let state = self.sparse_arm
|
||||
|| self.tile_map
|
||||
|| self.sparse_writes
|
||||
|| self.declares_texel_format()
|
||||
|
||||
@@ -37,6 +37,11 @@
|
||||
//! array's. It passes L3 and, on the CPU interpreter, adds to the texels of the element its
|
||||
//! pushed resource ID names and answers the texels they held, guarded by the element's size on
|
||||
//! a device without robust image access.
|
||||
//! - A slot's read through a runtime sampler that clamps to its border color
|
||||
//! (`engine/kernel_read_through`'s `rt_arg`) takes the border texels from bits 0-11 of the
|
||||
//! slot's resource ID's word, with no `BorderTexels` specialization or fact. It passes L3 and,
|
||||
//! on the CPU interpreter, reads Metal's border texel of `R32Float`, `RGBA8Unorm`, `A8Unorm`
|
||||
//! and a swizzled `RGBA8Unorm` under each border color, and the texel inside the texture.
|
||||
//! - The same kernel with its textures in an argument buffer (`tex` with `ab`) reads their
|
||||
//! resource IDs from the buffer's members, at its pushed address, and answers the same at the
|
||||
//! same elements, with no handle table and no descriptor; IDs whose indices are 65,536 past
|
||||
@@ -1783,6 +1788,169 @@ fn a_texture_atomic_is_the_r32_storage_element_its_resource_id_names() {
|
||||
}
|
||||
}
|
||||
|
||||
/// The address of the positions [`a_read_through_a_sampler_takes_its_border_texels_from_the_word`]
|
||||
/// pushes for `rt_arg`'s buffer 0.
|
||||
const POSITIONS: u64 = 0x5_0000_0000;
|
||||
|
||||
/// A slot's read through a runtime sampler that clamps every axis to its border color
|
||||
/// (`engine/kernel_read_through`'s `rt_arg`: `texture2d<float>`, offset `(1, -1)`) under the
|
||||
/// identity domains takes the texel an index outside the texture reads from bits 0-11 of the slot's
|
||||
/// resource ID's word, for the color the sampler's word names: no specialization constant but the
|
||||
/// dispatch's, and no `BorderTexels` fact. On the CPU interpreter the border texels of
|
||||
/// `R32Float`, `RGBA8Unorm`, `A8Unorm` and an `RGBA8Unorm` swizzled `(a, b, 0, r)` match Metal's
|
||||
/// ([`border_texel`](crate::metal::sampler::border_texel)) under each border color, and a read
|
||||
/// inside the texture reads its texel.
|
||||
#[test]
|
||||
fn a_read_through_a_sampler_takes_its_border_texels_from_the_word() {
|
||||
use crate::metal::sampler::{border_texel, SamplerWord, BORDER_COLORS};
|
||||
use crate::metal::{SamplerAddressMode, SamplerBorderColor, TextureSwizzle};
|
||||
let Some(bc) = assemble("kernel_read_through") else {
|
||||
return;
|
||||
};
|
||||
// Thread `i` reads at `P[i] + (1, -1)`: inside at (1, 0) and (1, 1), and past the right, left
|
||||
// and top edges of the 2 × 2 texture.
|
||||
const P: [[i32; 4]; 5] = [
|
||||
[0, 1, 0, 0],
|
||||
[1, 2, 0, 0],
|
||||
[-2, 1, 0, 0],
|
||||
[0, 0, 0, 0],
|
||||
[0, 2, 0, 0],
|
||||
];
|
||||
const INSIDE: [Option<(u32, u32)>; 5] = [Some((1, 0)), None, None, None, Some((1, 1))];
|
||||
const L: [u32; 3] = [5, 1, 1];
|
||||
// The texture at index 3 of the sampled array, the sampler at index 1 of its arrays.
|
||||
const TEX: u32 = 3;
|
||||
const SAMPLER: u32 = 1;
|
||||
let swizzled = TextureSwizzleChannels::new(
|
||||
TextureSwizzle::Alpha,
|
||||
TextureSwizzle::Blue,
|
||||
TextureSwizzle::Zero,
|
||||
TextureSwizzle::Red,
|
||||
);
|
||||
let formats = [
|
||||
(PixelFormat::R32Float, TextureSwizzleChannels::DEFAULT),
|
||||
(PixelFormat::RGBA8Unorm, TextureSwizzleChannels::DEFAULT),
|
||||
(PixelFormat::A8Unorm, TextureSwizzleChannels::DEFAULT),
|
||||
(PixelFormat::RGBA8Unorm, swizzled),
|
||||
];
|
||||
let colors = [
|
||||
SamplerBorderColor::TransparentBlack,
|
||||
SamplerBorderColor::OpaqueBlack,
|
||||
SamplerBorderColor::OpaqueWhite,
|
||||
];
|
||||
let f = |v: f32| v.to_bits();
|
||||
let held = |x: u32, y: u32| [f(x as f32 + 0.25), f(y as f32 + 0.5), f(0.125), f(0.75)];
|
||||
let filler = |_: u32, _: u32| [0xdead_beef; 4];
|
||||
let mut profiles: Vec<(String, DeviceProfile)> = PROFILES
|
||||
.iter()
|
||||
.map(|stem| {
|
||||
let p = profile(stem, identity()).unwrap_or_else(|e| panic!("{e}"));
|
||||
(stem.to_string(), p)
|
||||
})
|
||||
.collect();
|
||||
profiles.push((
|
||||
"moltenvk-m3 without robustImageAccess2".to_string(),
|
||||
identity_without("moltenvk-m3", &[VkFeature::RobustImageAccess2]),
|
||||
));
|
||||
for (stem, p) in &profiles {
|
||||
let (a, plan, module) =
|
||||
compile_kept(&bc, "rt_arg", p).unwrap_or_else(|e| panic!("{stem}: {e}"));
|
||||
link_and_validate(&a, p).unwrap_or_else(|e| panic!("{stem}: L3: {e}"));
|
||||
assert!(
|
||||
(a.interface.spec.iter()).all(|c| dispatch_key(c.key)),
|
||||
"{stem}: {:?}",
|
||||
a.interface.spec
|
||||
);
|
||||
assert!(
|
||||
!(plan.facts.iter()).any(|f| matches!(f, RuntimeFact::BorderTexels { .. })),
|
||||
"{stem}: {:?}",
|
||||
plan.facts
|
||||
);
|
||||
let linked = link(&[&a], &LinkInputs::standalone(), p).unwrap_or_else(|e| panic!("{e}"));
|
||||
let sampled: Vec<ResourceSlot> = (linked.table.bindings.iter())
|
||||
.filter(|(slot, _)| matches!(slot.kind, ResourceKind::Heap(HandleClass::Image(_))))
|
||||
.map(|(slot, _)| *slot)
|
||||
.collect();
|
||||
let [sampled] = sampled[..] else {
|
||||
panic!("{stem}: {sampled:?}");
|
||||
};
|
||||
for (pf, swizzle) in formats {
|
||||
let word = TextureWord::of(pf, swizzle).expect("a word").0;
|
||||
let present = crate::metal::format::channels(pf).expect("channels");
|
||||
for (color, rgba) in colors.into_iter().zip(BORDER_COLORS) {
|
||||
let mut desc = crate::bind::SamplerDescriptor::new();
|
||||
desc.s_address_mode = SamplerAddressMode::ClampToBorderColor;
|
||||
desc.t_address_mode = SamplerAddressMode::ClampToBorderColor;
|
||||
desc.r_address_mode = SamplerAddressMode::ClampToBorderColor;
|
||||
desc.border_color = color;
|
||||
let sampler = SamplerWord::of(&desc).0;
|
||||
let mut push = vec![0u8; plan.push.push_range.map_or(0, |(_, end)| end as usize)];
|
||||
for field in &plan.push.fields {
|
||||
let PushLoc::Push { offset } = field.loc else {
|
||||
panic!("{stem}: {field:?} spilled");
|
||||
};
|
||||
let o = offset as usize;
|
||||
let bytes = match field.field {
|
||||
PushField::SlotGuestBase(s) => match (s.class, s.index) {
|
||||
(SlotClass::Buffer, 0) => slot_word(POSITIONS),
|
||||
(SlotClass::Buffer, 1) => slot_word(OUT),
|
||||
(SlotClass::Texture, 0) => resource_id(TEX, word),
|
||||
(SlotClass::Sampler, 0) => resource_id(SAMPLER, sampler),
|
||||
_ => panic!("{stem}: unexpected slot {s:?}"),
|
||||
},
|
||||
PushField::DispatchRegion => {
|
||||
let region = region_bytes([0; 3], L, L).expect("packs");
|
||||
push[o..o + 32].copy_from_slice(®ion);
|
||||
continue;
|
||||
}
|
||||
PushField::SlotBounds(s) => {
|
||||
push[o..o + 8].copy_from_slice(&bounds_word(16 * P.len(), 0));
|
||||
assert_eq!(s.class, SlotClass::Buffer, "{stem}");
|
||||
continue;
|
||||
}
|
||||
PushField::ZeroAddress => ZERO_UNMAPPED,
|
||||
_ => panic!("{stem}: unexpected push field {field:?}"),
|
||||
};
|
||||
push[o..o + 8].copy_from_slice(&bytes.to_le_bytes());
|
||||
}
|
||||
let mut images: Vec<Image> = (0..TEX)
|
||||
.map(|e| texture(sampled, e, [1, 1], filler, None))
|
||||
.collect();
|
||||
images.push(texture(sampled, TEX, [2, 2], held, None));
|
||||
let positions = P.iter().flatten().flat_map(|v| v.to_le_bytes()).collect();
|
||||
let res = Resources {
|
||||
buffers: vec![
|
||||
Buffer {
|
||||
slot: None,
|
||||
address: Some(POSITIONS),
|
||||
bytes: positions,
|
||||
},
|
||||
Buffer {
|
||||
slot: None,
|
||||
address: Some(OUT),
|
||||
bytes: vec![0; 16 * P.len()],
|
||||
},
|
||||
],
|
||||
push,
|
||||
spec: local_size3(L),
|
||||
};
|
||||
let (got, _) = run_with_images(&module, &Config::default(), res, images)
|
||||
.unwrap_or_else(|e| panic!("{stem}: {e}"));
|
||||
let border =
|
||||
border_texel(pf, present, swizzle, rgba).map(|one| f(f32::from(u8::from(one))));
|
||||
let want: Vec<u8> = (INSIDE.iter())
|
||||
.flat_map(|at| match at {
|
||||
Some((x, y)) => held(*x, *y),
|
||||
None => border,
|
||||
})
|
||||
.flat_map(|lane| lane.to_le_bytes())
|
||||
.collect();
|
||||
assert_eq!(got.buffers[1], want, "{stem}: {pf:?} {swizzle:?} {color:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The read buffers of a kernel of [`many_of`]: with its output, 21 slot addresses of 8 bytes.
|
||||
const READS: u32 = 20;
|
||||
|
||||
|
||||
+7
-6
@@ -213,12 +213,13 @@ compile does. `DevicePolicy::default()` is `DevicePolicy::UNTRUSTED`:
|
||||
its texture slots and its argument buffers' textures, those of an argument buffer a pointer
|
||||
member reaches included, updates its texture slots atomically (a slot declared `R32ui` or
|
||||
`R32i`, the storage-image array's element at its ID's index), and samples its texture slots
|
||||
through its runtime sampler slots and its constexpr samplers. Any other function is refused as
|
||||
`Unsupported{IdentityDomains}`, whose symbol names the first such form the function holds: one
|
||||
that samples through an argument buffer's sampler or an array of samplers or samples an argument
|
||||
buffer's texture, emulates a sampler's anisotropy, samples a 1D texture or at pixel coordinates
|
||||
through a bicubic filter, uses a texture buffer, a slot's levels or swizzle, a two-plane,
|
||||
extended-range or sRGB-twin form, reads an argument buffer's texture
|
||||
through its runtime sampler slots and its constexpr samplers and reads them through those (MSL
|
||||
4.1's `read(sampler, coord)`, its border texel from bits 0-11 of the ID's word). Any other
|
||||
function is refused as `Unsupported{IdentityDomains}`, whose symbol names the first such form
|
||||
the function holds: one that samples through an argument buffer's sampler or an array of
|
||||
samplers or samples an argument buffer's texture, emulates a sampler's anisotropy, samples a 1D
|
||||
texture or at pixel coordinates through a bicubic filter, uses a texture buffer, a slot's levels
|
||||
or 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
|
||||
beyond its ID.
|
||||
An argument buffer's texture reads the element at its ID's index masked to its low 16 bits,
|
||||
|
||||
@@ -42,7 +42,7 @@ Its limits, measured rather than asserted:
|
||||
| committed recordings | 1319 |
|
||||
| distinct SDK items the Metal leg reaches, of any status | 804 |
|
||||
| of those, reached only where this cannot name the family | 5 |
|
||||
| ledger rows (a case whose gap is recorded) | 7695 |
|
||||
| ledger rows (a case whose gap is recorded) | 7689 |
|
||||
| declared crossings of the option space (pairs put to Metal at once) | 26 |
|
||||
| declared crossings that are no pair of it (a boolean or numeric field, or one type in two slots) | 30 |
|
||||
|
||||
@@ -3530,17 +3530,11 @@ A case whose difference from Metal is recorded rather than compared away. The le
|
||||
| `pixel-samplers-subnormal-zero` | The device's own answer (rule 1), every source alike: one digest per answer across the sources, as Metal's. lavapipe converts the `RGBA8Unorm` texture's codes b… |
|
||||
| `pixel-samplers-subnormal-zero` | The device's own answer (rule 1), every source alike: one digest per answer across the sources, as Metal's. lavapipe converts the `RGBA8Unorm` texture's codes b… |
|
||||
| `read-through-a8` | refused: no stream uses it yet (states-only play 11-19, m3-max-56371-56373, 56375, player 44668b439f: 32 streams, every render and compute pipeline state made).… |
|
||||
| `read-through-half` | refused: no stream uses it yet (states-only play 11-19, m3-max-56371-56373, 56375, player 44668b439f: 32 streams, every render and compute pipeline state made).… |
|
||||
| `read-through-heap-border` | refused: no stream uses it yet (states-only play 11-19, m3-max-56371-56373, 56375, player 44668b439f: 32 streams, every render and compute pipeline state made).… |
|
||||
| `read-through-heap-sampler` | refused: no stream uses it yet (states-only play 11-19, m3-max-56371-56373, 56375, player 44668b439f: 32 streams, every render and compute pipeline state made).… |
|
||||
| `read-through-int` | refused: no stream uses it yet (states-only play 11-19, m3-max-56371-56373, 56375, player 44668b439f: 32 streams, every render and compute pipeline state made).… |
|
||||
| `read-through-layers` | refused: no stream uses it yet (states-only play 11-19, m3-max-56371-56373, 56375, player 44668b439f: 32 streams, every render and compute pipeline state made).… |
|
||||
| `read-through-line` | refused: no stream uses it yet (states-only play 11-19, m3-max-56371-56373, 56375, player 44668b439f: 32 streams, every render and compute pipeline state made).… |
|
||||
| `read-through-r32f` | refused: no stream uses it yet (states-only play 11-19, m3-max-56371-56373, 56375, player 44668b439f: 32 streams, every render and compute pipeline state made).… |
|
||||
| `read-through-read-write` | refused: no stream uses it yet (states-only play 11-19, m3-max-56371-56373, 56375, player 44668b439f: 32 streams, every render and compute pipeline state made).… |
|
||||
| `read-through-rgba8` | refused: no stream uses it yet (states-only play 11-19, m3-max-56371-56373, 56375, player 44668b439f: 32 streams, every render and compute pipeline state made).… |
|
||||
| `read-through-rgba8-swizzled` | refused: no stream uses it yet (states-only play 11-19, m3-max-56371-56373, 56375, player 44668b439f: 32 streams, every render and compute pipeline state made).… |
|
||||
| `read-through-volume` | refused: no stream uses it yet (states-only play 11-19, m3-max-56371-56373, 56375, player 44668b439f: 32 streams, every render and compute pipeline state made).… |
|
||||
| `read-write-tier-held` | Known gap (rt README, Known gaps of textures): the kernel writes a texture with no storage element on this device through the argument buffer, with no use_resou… |
|
||||
| `read-write-tier-held` | Known gap (rt README, Known gaps of textures): the kernel writes a texture with no storage element on this device through the argument buffer, with no use_resou… |
|
||||
| `read-write-tier-held` | Known gap (rt README, Known gaps of textures): the kernel writes a texture with no storage element on this device through the argument buffer, with no use_resou… |
|
||||
|
||||
+3
-1
@@ -63,7 +63,9 @@ A shader takes a texture slot's ID from the slot's push field (`PushField::SlotG
|
||||
argument buffer's texture's ID from the member's 8 bytes, with no table between. It indexes the
|
||||
arrays with the low word, answers `is_null_texture` by whether the index is 0, and,
|
||||
where it checks a `read` itself (a device without `robustImageAccess2`), takes an out-of-bounds
|
||||
alpha of 1 from bit 12 of the word. The runtime writes a slot's ID, so its index is an element;
|
||||
alpha of 1 from bit 12 of the word. A slot's `read` through a sampler (MSL 4.1) takes the border
|
||||
texel an index outside the level reads on a border axis from bits 0-11 of the word, for the
|
||||
sampler's border color. The runtime writes a slot's ID, so its index is an element;
|
||||
the program writes an argument buffer's, so the shader masks its index to its low 16 bits: a bad
|
||||
ID reads the element at `index & 0xFFFF`, never one outside the arrays.
|
||||
|
||||
|
||||
Reference in new issue
Block a user