Translator: the sparse path goes
The translator kept a second form for a function that observes a texture's residency: a slot's
sparse arm (OpImageSparse* and OpImageSparseTexelsResident under shaderResourceResidency) or its
tile map (a storage buffer of tile bits the consumer would mirror from each mapping), selected by
SpecKey::SparseTexture from the bound texture's MTLTexture.isSparse, with Metal's measured
footprint rule for a sample or gather, writes dropped under the same constant, and
PrecisionNote::SparseResidency where the device answered. With the observed residency now the
constant resident word, nothing builds either form, and nothing can need one: the runtime has no
sparse heap or sparse texture API, and the consumer tells no guest it has sparse textures (every
Apple family's supportsFamily NO, sparseTileSizeInBytes 0, isSparse NO; a sparse heap refused at
newHeapWithDescriptor:). So the path is deleted (rule 4).
Public items deleted, each searched for in the consumer's checkout at 76e6c90369 (0 hits for every
name):
- RuntimeFact::SparseTexture { slot, sparse_arm, tile_map } and its mechanism; the 12-03 cleanup
ruling that kept it in the produced-then-refused group is reversed for it alone;
- SpecKey::SparseTexture;
- ResourceKind::TileMap and BindingSource::TileMap, with pipeline::tile_map, the map's format;
- PrecisionNote::SparseResidency (metal2vulkan-degrade-sparse-residency), with its API.md
catalogue entry, the conformance Degradation and validation's C3 deferred near-equivalent;
- error::Feature::SparseTexture, which nothing constructed;
- bind::TextureFacts::sparse and TextureShape::Texture's sparse, which no binder set.
Crate-internal, gone with them: the texture family's residency use flags, sparse_arm, tile_map and
sparse_writes on a slot plan, their spec constants and tile-map views, resident_access, the tile
decoding (TileLevel), the read's sparse and tile-map arms, the census's ".resident" suffix and
RESIDENCY_WORDS; the sampler's residency and footprint fields and lower::sampler::footprint (Metal's
measured footprint rule, read only to answer from a tile map), the sparse arm in sample, gather and
pixel fetch emission, and lower::texture::residency (every caller sits behind the texture family's
own refusal of a word with another bit observed). The SPIR-V layer loses what only those built:
the builder's sparse_sample, sparse_fetch, sparse_gather, sparse_dref_gather, sparse_read and
texels_resident, the sparse flag of SampleForm and of the fetch, gather and read instructions,
Inst::ImageSparseTexelsResident, its serialization, requirement (SparseResidency, and with it
shaderResourceResidency) and the interpreter's unmapped texels. VkFeature::ShaderResourceResidency
stays: profiles and the device queries name it.
Nothing compiled changes: no module held a sparse instruction or the constant since the previous
commit, so SEMANTICS_VERSION stays. ARTIFACT_FORMAT_VERSION 608 -> 609 (renumbered at landing):
the codec's ResourceKind, SpecKey, RuntimeFact, PrecisionNote and BindingSource lose variants,
which moves later tags. runtime-sources.sha256 moves for bind/state.rs, bind/heap.rs and the
deleted pipeline/tile_map.rs; no run of an unchanged artifact changes. docs/REFUSALS.md, the
runtime's error/basis.rs and tests/api_signatures.tsv are regenerated.
Tests deleted with what they tested: the serializer's sparse sweep, the builder's sparse read
under texel operands, the mechanism table's three SparseTexture rows (the variant indices close
up), C3's SparseResidency deferral (the deferred-row tests now use CubeGradientFootprint).
Verified, on the CPU with no device:
- m3-max-85203, at this change on ec56957c00, after the previous commit's own run in the same
job: the golden table's cells are the previous commit's, cell for cell (237 at each, every cell
listed at both, the two lists equal); the refusal surface's check, fmt, signatures, clippy
(plain, --cfg m2v_gpu, --cfg m2v_cpu_icd), Rustdoc, private docs, doctests and scripts/api-docs
pass; the metal2vulkan suites ran 3,495 tests: 3,494 passed, 24 skipped, and the failure is
golden_hashes_match_the_table, whose table is blessed at the next pin; validation ran 1,343
tests, all passed, 2 skipped; conformance ran 1,054 tests, all passed.
- m3-max-85366, at this commit, rebased onto development past the deletions of the anisotropic
emulation and RowLockstep (select.rs's anisotropic call and sampler/anisotropic.rs go with
development's side; the mechanism table is development's without SparseTexture, its indices closed
up to 0..60): the refusal surface's, conformance coverage's and signatures' checks, fmt and clippy
(plain, --cfg m2v_gpu, --cfg m2v_cpu_icd) pass; 185 tests (the mechanism, cache, SPIR-V serializer
and builder, bind::heap and sample-coordinate tests, the two sparse tests and the engine
inventory's llvm_as parts) all passed. The golden cells are the previous commit's, cell for cell
(237 at each, the two lists equal).
This commit is contained in:
1 parent
619e977d63
commit
2ec06b93e1
52 files changed
+225
-1615
No files matched your search
@@ -68,8 +68,6 @@ pub enum Degradation {
|
||||
MultisamplePosition,
|
||||
/// [`PrecisionNote::BicubicFilterArithmetic`].
|
||||
BicubicFilterArithmetic,
|
||||
/// [`PrecisionNote::SparseResidency`].
|
||||
SparseResidency,
|
||||
/// [`PrecisionNote::DeviceNanEncoding`].
|
||||
DeviceNanEncoding,
|
||||
/// [`PrecisionNote::RestrictedDepthRange`].
|
||||
@@ -209,7 +207,6 @@ impl Degradation {
|
||||
Degradation::Fp8Value,
|
||||
Degradation::MultisamplePosition,
|
||||
Degradation::BicubicFilterArithmetic,
|
||||
Degradation::SparseResidency,
|
||||
Degradation::DeviceNanEncoding,
|
||||
Degradation::RestrictedDepthRange,
|
||||
Degradation::CubeGradientFootprint,
|
||||
@@ -304,7 +301,6 @@ impl Degradation {
|
||||
Degradation::Fp8Value => PrecisionNote::Fp8Value,
|
||||
Degradation::MultisamplePosition => PrecisionNote::MultisamplePosition,
|
||||
Degradation::BicubicFilterArithmetic => PrecisionNote::BicubicFilterArithmetic,
|
||||
Degradation::SparseResidency => PrecisionNote::SparseResidency,
|
||||
Degradation::DeviceNanEncoding => PrecisionNote::DeviceNanEncoding,
|
||||
Degradation::RestrictedDepthRange => PrecisionNote::RestrictedDepthRange,
|
||||
Degradation::CubeGradientFootprint => PrecisionNote::CubeGradientFootprint,
|
||||
@@ -385,7 +381,6 @@ impl Degradation {
|
||||
PrecisionNote::Fp8Value => Degradation::Fp8Value,
|
||||
PrecisionNote::MultisamplePosition => Degradation::MultisamplePosition,
|
||||
PrecisionNote::BicubicFilterArithmetic => Degradation::BicubicFilterArithmetic,
|
||||
PrecisionNote::SparseResidency => Degradation::SparseResidency,
|
||||
PrecisionNote::DeviceNanEncoding => Degradation::DeviceNanEncoding,
|
||||
PrecisionNote::RestrictedDepthRange => Degradation::RestrictedDepthRange,
|
||||
PrecisionNote::CubeGradientFootprint => Degradation::CubeGradientFootprint,
|
||||
|
||||
@@ -117,8 +117,8 @@ fn main() {
|
||||
// the device a run opens and what it enables (`src/device`,
|
||||
// `src/ash_interop`), the Vulkan and Metal vocabularies the runtime maps (`src/vk`,
|
||||
// `src/metal`, and the AIR front end's `metal2vulkan-air/src/metal`, whose `MTLDataType`
|
||||
// `metal` re-exports), the record and table formats it writes (indirect commands, the rate and
|
||||
// tile maps, function tables; the rate map's and function table's words are the AIR front end's
|
||||
// `metal` re-exports), the record and table formats it writes (indirect commands, the rate
|
||||
// map, function tables; the rate map's and function table's words are the AIR front end's
|
||||
// `metal2vulkan-air/src/canon` formats), root tables, handles and the threadgroup regions'
|
||||
// alignment (`src/memory`), the dispatch-region encoding (`src/lower/dispatch.rs`, and the
|
||||
// used-parameter walk it reads, `src/lower/users.rs`), a patch's factor bytes
|
||||
@@ -181,7 +181,6 @@ fn main() {
|
||||
"metal2vulkan/src/metal/texel_format.rs",
|
||||
"metal2vulkan/src/metal/vertex.rs",
|
||||
"metal2vulkan/src/pipeline/table.rs",
|
||||
"metal2vulkan/src/pipeline/tile_map.rs",
|
||||
"metal2vulkan/src/vk/generated.rs",
|
||||
"metal2vulkan/src/vk/mod.rs",
|
||||
"metal2vulkan/src/vk/structs.rs",
|
||||
|
||||
@@ -1 +1 @@
|
||||
093c7dc198ccd45d755368e098d7e97b73200b2810831c7f029c5562131d09e2
|
||||
9679f1c8115f4456e4df7a838d8e2220c07efd615c929eee91c6e5e9ecc85da4
|
||||
@@ -7,9 +7,8 @@
|
||||
//! reading inside the bound, and an exact match with it is not a property of the translation. The
|
||||
//! user decided that such cases are listed, each with its bound and cause, keyed by case and
|
||||
//! candidate, so that a changed candidate leaves the list and is reviewed again. A row that ran a
|
||||
//! recorded near-equivalent no exact path replaces yet ([`DEFERRED_NEAR_EQUIVALENTS`]: a sparse
|
||||
//! texture's filtered access, an explicit cube
|
||||
//! gradient's footprint, a nearest cube texel from a correctly rounded reciprocal, a simdgroup
|
||||
//! recorded near-equivalent no exact path replaces yet ([`DEFERRED_NEAR_EQUIVALENTS`]: an explicit
|
||||
//! cube gradient's footprint, a nearest cube texel from a correctly rounded reciprocal, a simdgroup
|
||||
//! operation's lanes before a discard, a depth comparison the device makes, a bicubic sum's
|
||||
//! unpinned arithmetic, a varying a device interpolates otherwise than Metal, a vertex simdgroup
|
||||
//! the device groups otherwise than Apple's GPUs) is never such a reading: its difference stays
|
||||
@@ -756,13 +755,6 @@ pub struct SlotRow {
|
||||
/// mismatch is still counted as one; only its reason names the note, whatever word differs, so a
|
||||
/// difference the note did not cause is labelled deferred too but hides nothing.
|
||||
///
|
||||
/// - A sparse texture's filtered access (`SparseResidency`): outside Metal's measured footprint
|
||||
/// rule its residency word is the device's footprint, and its filtered value is the device's
|
||||
/// filter, whose sub-texel precision need not be Metal's 1/256; an emulation of Metal's measured
|
||||
/// filter would be exact but is not built. Neither can be told apart word by word: a residency
|
||||
/// word and a sampled value are ordinary data the function goes on to use (a branch on
|
||||
/// `resident()`, a blend), so a moved footprint or weight moves whatever later words they feed,
|
||||
/// and the bytes do not say which words came from a sparse access.
|
||||
/// - An explicit cube gradient's footprint (`CubeGradientFootprint`): the product passes the
|
||||
/// Euclidean length of the gradient's two counted components where Apple combines them by its own
|
||||
/// rule, so near a level or filter boundary a sample selects another level or filter than
|
||||
@@ -813,8 +805,7 @@ pub struct SlotRow {
|
||||
/// denormal, a `half` rounding) belongs in a per-word judgement of a reading's differing words,
|
||||
/// beside the check of each against Apple's bound, never in this list: a row-level match would
|
||||
/// reopen every signed-off reading whose row merely records the note.
|
||||
pub const DEFERRED_NEAR_EQUIVALENTS: [PrecisionNote; 9] = [
|
||||
PrecisionNote::SparseResidency,
|
||||
pub const DEFERRED_NEAR_EQUIVALENTS: [PrecisionNote; 8] = [
|
||||
PrecisionNote::CubeGradientFootprint,
|
||||
PrecisionNote::QuadsCountedBeforeDiscard,
|
||||
PrecisionNote::BicubicFilterArithmetic,
|
||||
@@ -859,16 +850,6 @@ impl OpenReason {
|
||||
/// The measured bound of a deferred near-equivalent ([`DEFERRED_NEAR_EQUIVALENTS`]).
|
||||
fn near_equivalent_bound(note: PrecisionNote) -> &'static str {
|
||||
match note {
|
||||
PrecisionNote::SparseResidency => {
|
||||
"no bound: outside Metal's measured footprint rule (a runtime sampler, a mip level, \
|
||||
repeat or mirrored addressing, a texel offset) a sample's or gather's residency is the \
|
||||
device's footprint, which may count a texel of weight 0; a filtered value is the \
|
||||
device's filter at its own sub-texel precision (Apple M3 Max's is 1/256, lavapipe's \
|
||||
finer: values within 2^-9 on the cases measured, and a gather's texels one over \
|
||||
where its position crosses a texel's center), and an unmapped texel's sampled value \
|
||||
is the device's without residencyNonResidentStrict; exact path: an emulation of \
|
||||
Metal's measured filter"
|
||||
}
|
||||
PrecisionNote::CubeGradientFootprint => {
|
||||
"a cube gradient's footprint from the Euclidean length of its two counted components, \
|
||||
where Apple M3 Max's lies 2.2% below to 1.7% above it by their ratio, and the level the \
|
||||
|
||||
@@ -1059,17 +1059,10 @@ fn an_entry_in_the_shape_before_the_shared_review_is_rejected() {
|
||||
assert!(ReviewedList::parse(&migrated.to_string()).is_ok());
|
||||
}
|
||||
|
||||
/// A filtered sparse access ran the device's footprint and filter (`SparseResidency`): its mismatch
|
||||
/// stays open as a deferred near-equivalent with the note's bound, the list may not review it (a
|
||||
/// reading at the row's candidate reads inconsistent and the row stays a mismatch), and a row under
|
||||
/// the note that matches Metal is a match.
|
||||
#[test]
|
||||
fn a_sparse_residency_row_is_deferred_and_never_a_reviewed_reading() {
|
||||
deferred_and_never_reviewed(PrecisionNote::SparseResidency, "SparseResidency:no bound");
|
||||
}
|
||||
|
||||
/// An explicit cube gradient's footprint (`CubeGradientFootprint`) is deferred the same way, with
|
||||
/// its measured bound.
|
||||
/// An explicit cube gradient's footprint (`CubeGradientFootprint`): its mismatch stays open as a
|
||||
/// deferred near-equivalent with the note's measured bound, the list may not review it (a reading
|
||||
/// at the row's candidate reads inconsistent and the row stays a mismatch), and a row under the
|
||||
/// note that matches Metal is a match.
|
||||
#[test]
|
||||
fn a_cube_gradient_footprint_row_is_deferred_and_never_a_reviewed_reading() {
|
||||
deferred_and_never_reviewed(
|
||||
@@ -2148,7 +2141,7 @@ fn a_regrouping_reading_is_keyed_by_its_cause_in_every_slot() {
|
||||
new_row(&fft, RADV, &OTHER, &METAL),
|
||||
&[
|
||||
PrecisionNote::FastMathRewrites,
|
||||
PrecisionNote::SparseResidency,
|
||||
PrecisionNote::CubeGradientFootprint,
|
||||
],
|
||||
);
|
||||
let report = judge(&input_of(&deferred), &list);
|
||||
@@ -2156,7 +2149,9 @@ fn a_regrouping_reading_is_keyed_by_its_cause_in_every_slot() {
|
||||
assert_eq!(verdict_of(stated, &fft), Verdict::Mismatch);
|
||||
assert_eq!(
|
||||
stated.rows[0].reason,
|
||||
Some(OpenReason::NearEquivalent(PrecisionNote::SparseResidency))
|
||||
Some(OpenReason::NearEquivalent(
|
||||
PrecisionNote::CubeGradientFootprint
|
||||
))
|
||||
);
|
||||
|
||||
// An apple_reading of the same rows stays keyed by candidate: its observation's slot alone.
|
||||
@@ -3019,8 +3014,8 @@ fn a_ray_tracing_refusal_is_out_of_scope_never_refused_or_a_gap() {
|
||||
assert!(!stated.holds());
|
||||
}
|
||||
|
||||
/// The user's decision of 2026-10-03: a row that ran a recorded near-equivalent (a sparse
|
||||
/// texture's residency here) stays open, with its measured bound as the reason, even when the list
|
||||
/// The user's decision of 2026-10-03: a row that ran a recorded near-equivalent (an explicit cube
|
||||
/// gradient's footprint here) stays open, with its measured bound as the reason, even when the list
|
||||
/// reviews it; a case whose rate map the product refuses is missing with the refusal as its reason.
|
||||
/// Neither holds C3, and an ordinary mismatch carries no reason.
|
||||
#[test]
|
||||
@@ -3042,13 +3037,13 @@ fn a_deferred_near_equivalent_stays_open_with_its_reason() {
|
||||
required_size: None,
|
||||
}),
|
||||
strategies: Default::default(),
|
||||
precision: [PrecisionNote::SparseResidency].into(),
|
||||
precision: [PrecisionNote::CubeGradientFootprint].into(),
|
||||
containment: None,
|
||||
}],
|
||||
artifact: None,
|
||||
output_words: None,
|
||||
});
|
||||
row.comparison = ComparisonClass::Unbounded([PrecisionNote::SparseResidency].into());
|
||||
row.comparison = ComparisonClass::Unbounded([PrecisionNote::CubeGradientFootprint].into());
|
||||
row.status = noted_if_different(row.status);
|
||||
assert!(row.class_holds());
|
||||
let mut refused = case(2, "refused");
|
||||
@@ -3088,15 +3083,15 @@ fn a_deferred_near_equivalent_stays_open_with_its_reason() {
|
||||
.find(|row| row.case_id == case.case_id)
|
||||
.map(|row| (row.verdict, row.reason.clone()))
|
||||
};
|
||||
let deferred = OpenReason::NearEquivalent(PrecisionNote::SparseResidency);
|
||||
let deferred = OpenReason::NearEquivalent(PrecisionNote::CubeGradientFootprint);
|
||||
assert_eq!(
|
||||
open(&decoded),
|
||||
Some((Verdict::Mismatch, Some(deferred.clone())))
|
||||
);
|
||||
assert!(
|
||||
deferred.label().starts_with(
|
||||
"deferred{near_equivalent:SparseResidency:no bound: outside Metal's measured \
|
||||
footprint rule"
|
||||
"deferred{near_equivalent:CubeGradientFootprint:a cube gradient's footprint from the \
|
||||
Euclidean length"
|
||||
),
|
||||
"{}",
|
||||
deferred.label()
|
||||
|
||||
@@ -103,16 +103,16 @@ fn a_rate_mapped_pass_records_its_regions() {
|
||||
screen_size: [37, 23],
|
||||
compiled_physical_size: [36, 23],
|
||||
regions: 2,
|
||||
precision: [PrecisionNote::SparseResidency].into(),
|
||||
precision: [PrecisionNote::CubeGradientFootprint].into(),
|
||||
});
|
||||
assert_eq!(
|
||||
census.comparison_class(),
|
||||
ComparisonClass::derive([PrecisionNote::SparseResidency], ["arith.float"])
|
||||
ComparisonClass::derive([PrecisionNote::CubeGradientFootprint], ["arith.float"])
|
||||
);
|
||||
let json = serde_json::to_value(&census).unwrap();
|
||||
assert_eq!(
|
||||
json["rate_map_pass"]["precision"],
|
||||
serde_json::json!(["SparseResidency"])
|
||||
serde_json::json!(["CubeGradientFootprint"])
|
||||
);
|
||||
assert_eq!(
|
||||
serde_json::from_value::<ExecutedCensus>(json).unwrap(),
|
||||
|
||||
@@ -202,9 +202,6 @@ impl UlpTable {
|
||||
/// and by the weights' distance times the taps, which cancellation makes any multiple of the
|
||||
/// result's ulp. The comparator cannot see a lane's footprint, so it cannot check the
|
||||
/// near-tie conditions; it hands back the narrowest bound it can check.
|
||||
/// - `SparseResidency`: unbounded: the sparse form's residency and unmapped texels are the
|
||||
/// device's, which no Metal reading has compared; another residency answer flips a whole status
|
||||
/// word, and an unmapped texel can read anything where the device is not strict.
|
||||
/// - `RestrictedDepthRange`: unbounded: without `VK_EXT_depth_range_unrestricted` a depth image
|
||||
/// takes no texel outside `[0, 1]`, so a comparison of one Metal holds there can answer
|
||||
/// otherwise.
|
||||
@@ -363,7 +360,6 @@ pub fn allowance(note: PrecisionNote) -> Allowance {
|
||||
| N::Fp8Value
|
||||
| N::MultisamplePosition
|
||||
| N::BicubicFilterArithmetic
|
||||
| N::SparseResidency
|
||||
| N::RestrictedDepthRange
|
||||
| N::CubeGradientFootprint
|
||||
| N::SrgbTexelDecode
|
||||
|
||||
@@ -52,7 +52,6 @@ fn every_precision_note_has_its_table_row() {
|
||||
(N::Fp8Value, Allowance::Unbounded),
|
||||
(N::MultisamplePosition, Allowance::Unbounded),
|
||||
(N::BicubicFilterArithmetic, Allowance::Unbounded),
|
||||
(N::SparseResidency, Allowance::Unbounded),
|
||||
(N::DeviceNanEncoding, Allowance::Recorded),
|
||||
(N::RestrictedDepthRange, Allowance::Unbounded),
|
||||
(N::CubeGradientFootprint, Allowance::Unbounded),
|
||||
@@ -128,7 +127,6 @@ fn only_the_environment_notes_are_told_value_by_value() {
|
||||
N::Fp8Value,
|
||||
N::MultisamplePosition,
|
||||
N::BicubicFilterArithmetic,
|
||||
N::SparseResidency,
|
||||
N::ViewBaseTexelOffset,
|
||||
N::DeviceColorConversion,
|
||||
] {
|
||||
|
||||
@@ -272,7 +272,6 @@ pub fn reach(note: PrecisionNote) -> Reach {
|
||||
| N::PixelSamplerScaling
|
||||
| N::ArgumentPixelSamplerScaling
|
||||
| N::BicubicFilterArithmetic
|
||||
| N::SparseResidency
|
||||
| N::RestrictedDepthRange
|
||||
| N::CubeGradientFootprint
|
||||
| N::HalfTexelConversion
|
||||
|
||||
@@ -59,10 +59,10 @@ fn bind_error(e: Error) -> BindError {
|
||||
pub(crate) enum Fit {
|
||||
/// The member is an element of the class's array.
|
||||
Holds,
|
||||
/// An unswizzled texture of a form a heap reads (`ExtendedRange::HEAP_READ`, not sparse) in a
|
||||
/// sampled float class: the class's array holds its neutral, and the unsigned integer class
|
||||
/// of its shape holds its raw texels, which a function's read decodes by the form its
|
||||
/// handle's class index names. A stage that samples heap textures does not read it so.
|
||||
/// An unswizzled texture of a form a heap reads (`ExtendedRange::HEAP_READ`) in a sampled
|
||||
/// float class: the class's array holds its neutral, and the unsigned integer class of its
|
||||
/// shape holds its raw texels, which a function's read decodes by the form its handle's class
|
||||
/// index names. A stage that samples heap textures does not read it so.
|
||||
Raw,
|
||||
/// It fits in everything but its numeric type.
|
||||
NumericType,
|
||||
@@ -216,18 +216,16 @@ fn member_texel_view(
|
||||
Ok(m.format)
|
||||
}
|
||||
|
||||
/// Whether a member of facts `shape` is a texture a heap reads by its raw texels: an unswizzled,
|
||||
/// not sparse texture of one sample, of a form of `ExtendedRange::HEAP_READ`.
|
||||
/// Whether a member of facts `shape` is a texture a heap reads by its raw texels: an unswizzled
|
||||
/// texture of one sample, of a form of `ExtendedRange::HEAP_READ`.
|
||||
pub(crate) fn raw_held(shape: &TextureShape) -> bool {
|
||||
let TextureShape::Texture {
|
||||
pixel_format,
|
||||
swizzle,
|
||||
sparse,
|
||||
sample_count,
|
||||
..
|
||||
} = *shape;
|
||||
!sparse
|
||||
&& sample_count <= 1
|
||||
sample_count <= 1
|
||||
&& swizzle.is_default()
|
||||
&& crate::metal::format::ExtendedRange::of(pixel_format)
|
||||
.and_then(crate::metal::format::ExtendedRange::heap_read)
|
||||
|
||||
@@ -33,7 +33,6 @@ fn shape(ty: TextureType, pf: PixelFormat, samples: u32, usage: TextureUsage) ->
|
||||
sample_count: samples,
|
||||
usage,
|
||||
mipmap_level_count: 1,
|
||||
sparse: false,
|
||||
swizzle: crate::metal::TextureSwizzleChannels::DEFAULT,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ impl StageInRegion {
|
||||
impl TextureFacts {
|
||||
/// The facts of an image texture that can change the variant, specialization or views a slot
|
||||
/// binds it through (its view facts): the type, the pixel format, the sample count, the
|
||||
/// usage, whether it is sparse, its level count, which decides a storage slot's level views
|
||||
/// usage, its level count, which decides a storage slot's level views
|
||||
/// and pushed level count, its swizzle and its [`offset_base_axes`](Self::offset_base_axes).
|
||||
/// Its array length only changes the view's subresource range, which is every layer.
|
||||
///
|
||||
@@ -40,7 +40,6 @@ impl TextureFacts {
|
||||
sample_count: self.sample_count,
|
||||
usage: self.usage,
|
||||
mipmap_level_count: self.mipmap_level_count,
|
||||
sparse: self.sparse,
|
||||
swizzle: self.swizzle,
|
||||
offset_base_axes: self.offset_base_axes(),
|
||||
}
|
||||
@@ -89,13 +88,6 @@ pub struct TextureFacts {
|
||||
pub usage: metal::TextureUsage,
|
||||
pub array_length: u32,
|
||||
pub mipmap_level_count: u32,
|
||||
/// `MTLTexture.isSparse`: the texture was made from a sparse heap, so regions of it may be
|
||||
/// unmapped. A function that observes the residency of its accesses of the texture
|
||||
/// (`sparse_color::resident()`, `RuntimeFact::SparseTexture`) answers a texture that is not
|
||||
/// sparse on every device, and a sparse one only where the module has its sparse form
|
||||
/// (`shaderResourceResidency`); the binder refuses it elsewhere (`Feature::SparseTexture`).
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
pub sparse: bool,
|
||||
/// `MTLTexture.swizzle`: the source of each channel the texture's reads and samples return,
|
||||
/// border texels included. A sample emulated by fetches reads its border taps through it, and
|
||||
/// an opaque-black border the device replaces is checked against it.
|
||||
@@ -126,7 +118,6 @@ impl TextureFacts {
|
||||
usage: metal::TextureUsage::SHADER_READ,
|
||||
array_length: 1,
|
||||
mipmap_level_count: 1,
|
||||
sparse: false,
|
||||
swizzle: metal::TextureSwizzleChannels::DEFAULT,
|
||||
parent_relative_level: 0,
|
||||
parent_base_size: [0; 3],
|
||||
@@ -260,11 +251,6 @@ pub enum TextureShape {
|
||||
/// views view each level, and a neutral past the last.
|
||||
#[cfg_attr(feature = "serde", serde(default = "one_level"))]
|
||||
mipmap_level_count: u32,
|
||||
/// The texture is sparse (`MTLTexture.isSparse`, [`TextureFacts::sparse`]): it selects
|
||||
/// the sparse form of a slot whose residency the function observes, or the binder's refusal
|
||||
/// where the module has none.
|
||||
#[cfg_attr(feature = "serde", serde(default))]
|
||||
sparse: bool,
|
||||
/// The texture's swizzle ([`TextureFacts::swizzle`]): the border taps of a sample emulated
|
||||
/// by fetches read through it, and an opaque-black border the device replaces is checked
|
||||
/// against it.
|
||||
|
||||
+3
-5
@@ -841,14 +841,14 @@ codec_enum! {
|
||||
Imageblock, FunctionTableDirectory, TileMemory, FunctionTableSnapshot,
|
||||
}
|
||||
ResourceKind {
|
||||
Buffer, Heap(f0), Synthetic(f0), AccelerationStructure(f0), TileAttachment(f0), TileMap,
|
||||
Buffer, Heap(f0), Synthetic(f0), AccelerationStructure(f0), TileAttachment(f0),
|
||||
}
|
||||
AccelerationStructureLevel { Primitive, Instance }
|
||||
SamplerRef { Slot(f0), Constexpr(f0) }
|
||||
SpecKey {
|
||||
LocalSize(f0), FlatLocalSize, MultiRegion, TgLength(f0), Presence(f0), SampleCount,
|
||||
AmplificationCount, ImageblockWidth, ImageblockHeight,
|
||||
RenderAreaWidth, RenderAreaHeight, OutOfBoundsAlpha(f0), SparseTexture(f0), TgOffset(f0),
|
||||
RenderAreaWidth, RenderAreaHeight, OutOfBoundsAlpha(f0), TgOffset(f0),
|
||||
TileThreadgroupLength, TileGridWidth, TextureSwizzle(f0),
|
||||
ObjectLocalSize(f0), ObjectFlatLocalSize, ObjectMultiRegion, SamplerMinLevel(f0),
|
||||
OffsetBaseAxes(f0),
|
||||
@@ -1198,7 +1198,6 @@ codec_enum! {
|
||||
OutOfBoundsAlpha { slot },
|
||||
StorageTextureLevels { slot },
|
||||
StorageTextureLevelViews { slot },
|
||||
SparseTexture { slot, sparse_arm, tile_map },
|
||||
AccelerationStructureInstanceCount { slot },
|
||||
PredicationVote, ViewportCount,
|
||||
AliasedImageblock { data_size },
|
||||
@@ -1345,7 +1344,6 @@ codec_enum! {
|
||||
Fp8Value,
|
||||
MultisamplePosition,
|
||||
BicubicFilterArithmetic,
|
||||
SparseResidency,
|
||||
DeviceNanEncoding,
|
||||
RestrictedDepthRange,
|
||||
CubeGradientFootprint,
|
||||
@@ -1412,7 +1410,7 @@ codec_enum! {
|
||||
}
|
||||
BindingSource {
|
||||
Buffer(f0), Synthetic { stage, binding }, IdentityArray,
|
||||
AccelerationStructure { slot, level }, TileAttachment(f0), TileMap(f0),
|
||||
AccelerationStructure { slot, level }, TileAttachment(f0),
|
||||
}
|
||||
VertexStride { Static(f0), PerBind }
|
||||
}
|
||||
|
||||
Vendored
+2
-2
@@ -70,11 +70,11 @@ pub const SEMANTICS_VERSION: u32 = 2368;
|
||||
/// re-typed in an encoded type, its `codec` body or its `envelope`. A variant removed while its tag
|
||||
/// stays unused needs no bump: an entry holding it fails to decode, which is a miss. The commit that
|
||||
/// bumps it says what changed; this comment keeps no history.
|
||||
pub const ARTIFACT_FORMAT_VERSION: u32 = 608;
|
||||
pub const ARTIFACT_FORMAT_VERSION: u32 = 609;
|
||||
|
||||
/// The version of what this crate gives a runtime for the runs of a compiled pipeline, beside the
|
||||
/// compile: the device a run opens and what it enables, the Vulkan and Metal vocabularies a runtime
|
||||
/// maps, the record and table formats it writes (indirect commands, rate and tile maps, function
|
||||
/// maps, the record and table formats it writes (indirect commands, the rate map, function
|
||||
/// tables, argument-buffer layouts), the texel decoders, and the other run-time data `bind` holds.
|
||||
/// Independent of [`SEMANTICS_VERSION`] (what is compiled) and [`ARTIFACT_FORMAT_VERSION`] (how it
|
||||
/// is encoded): two runs of byte-identical artifacts under one runtime version do the same thing. A
|
||||
|
||||
@@ -68,17 +68,6 @@ pub fn mechanism(fact: &RuntimeFact, profile: &DeviceProfile) -> Mechanism {
|
||||
RuntimeFact::StorageTextureLevels { .. } => Mechanism::PushConstant,
|
||||
// The binder views each level of the bound texture at its element.
|
||||
RuntimeFact::StorageTextureLevelViews { .. } => Mechanism::BinderView,
|
||||
// The bound texture's sparseness selects the sparse form or the tile map where the module
|
||||
// has one; without either the planner refuses a sparse texture.
|
||||
RuntimeFact::SparseTexture {
|
||||
sparse_arm: true, ..
|
||||
}
|
||||
| RuntimeFact::SparseTexture { tile_map: true, .. } => Mechanism::Specialization,
|
||||
RuntimeFact::SparseTexture {
|
||||
sparse_arm: false,
|
||||
tile_map: false,
|
||||
..
|
||||
} => Mechanism::PlanTimeCheck,
|
||||
// The binder writes the bound structure's instance count per dispatch or draw.
|
||||
RuntimeFact::AccelerationStructureInstanceCount { .. } => Mechanism::PushConstant,
|
||||
// The vote word is fixed in the module; the planner counts it against the limit.
|
||||
|
||||
@@ -52,21 +52,6 @@ fn every_fact() -> Vec<RuntimeFact> {
|
||||
RuntimeFact::BorderTexels { slot },
|
||||
RuntimeFact::StorageTextureLevels { slot },
|
||||
RuntimeFact::StorageTextureLevelViews { slot },
|
||||
RuntimeFact::SparseTexture {
|
||||
slot,
|
||||
sparse_arm: true,
|
||||
tile_map: false,
|
||||
},
|
||||
RuntimeFact::SparseTexture {
|
||||
slot,
|
||||
sparse_arm: false,
|
||||
tile_map: true,
|
||||
},
|
||||
RuntimeFact::SparseTexture {
|
||||
slot,
|
||||
sparse_arm: false,
|
||||
tile_map: false,
|
||||
},
|
||||
RuntimeFact::AccelerationStructureInstanceCount { slot },
|
||||
RuntimeFact::PredicationVote,
|
||||
RuntimeFact::ViewportCount,
|
||||
@@ -151,40 +136,39 @@ fn variant(f: &RuntimeFact) -> usize {
|
||||
RuntimeFact::OutOfBoundsAlpha { .. } => 25,
|
||||
RuntimeFact::StorageTextureLevels { .. } => 26,
|
||||
RuntimeFact::StorageTextureLevelViews { .. } => 27,
|
||||
RuntimeFact::SparseTexture { .. } => 28,
|
||||
RuntimeFact::AccelerationStructureInstanceCount { .. } => 29,
|
||||
RuntimeFact::PredicationVote => 30,
|
||||
RuntimeFact::ViewportCount => 31,
|
||||
RuntimeFact::AliasedImageblock { .. } => 32,
|
||||
RuntimeFact::CallStackDepth { .. } => 33,
|
||||
RuntimeFact::FlatGrid => 34,
|
||||
RuntimeFact::TileThreadgroupMemory { .. } => 35,
|
||||
RuntimeFact::TextureSwizzle { .. } => 36,
|
||||
RuntimeFact::TileImageblock { .. } => 37,
|
||||
RuntimeFact::AmplificationDraws { .. } => 38,
|
||||
RuntimeFact::FoldedGroups => 40,
|
||||
RuntimeFact::ZeroedColor { .. } => 42,
|
||||
RuntimeFact::DroppedColor { .. } => 43,
|
||||
RuntimeFact::DepthClampRange => 44,
|
||||
RuntimeFact::FunctionTableRange { .. } => 45,
|
||||
RuntimeFact::TileThreadgroup { .. } => 47,
|
||||
RuntimeFact::ObjectThreadgroupArena { .. } => 55,
|
||||
RuntimeFact::ReplayBindings => 58,
|
||||
RuntimeFact::MergedDraws => 49,
|
||||
RuntimeFact::QuadPrimitiveIds => 41,
|
||||
RuntimeFact::RotatedWeights => 54,
|
||||
RuntimeFact::PrivateList => 56,
|
||||
RuntimeFact::PartialObjectThreadgroups => 59,
|
||||
RuntimeFact::OpenClMode => 61,
|
||||
RuntimeFact::BorderTexels { .. } => 46,
|
||||
RuntimeFact::CallThreadgroups => 60,
|
||||
RuntimeFact::PartialThreadgroups => 57,
|
||||
RuntimeFact::OpenClLineTexture { .. } => 50,
|
||||
RuntimeFact::AddressAlignment { .. } => 48,
|
||||
RuntimeFact::GridTiles => 39,
|
||||
RuntimeFact::PrivateArena { .. } => 51,
|
||||
RuntimeFact::StencilBitDraws => 52,
|
||||
RuntimeFact::RobustStorageBuffers => 53,
|
||||
RuntimeFact::AccelerationStructureInstanceCount { .. } => 28,
|
||||
RuntimeFact::PredicationVote => 29,
|
||||
RuntimeFact::ViewportCount => 30,
|
||||
RuntimeFact::AliasedImageblock { .. } => 31,
|
||||
RuntimeFact::CallStackDepth { .. } => 32,
|
||||
RuntimeFact::FlatGrid => 33,
|
||||
RuntimeFact::TileThreadgroupMemory { .. } => 34,
|
||||
RuntimeFact::TextureSwizzle { .. } => 35,
|
||||
RuntimeFact::TileImageblock { .. } => 36,
|
||||
RuntimeFact::AmplificationDraws { .. } => 37,
|
||||
RuntimeFact::FoldedGroups => 39,
|
||||
RuntimeFact::ZeroedColor { .. } => 41,
|
||||
RuntimeFact::DroppedColor { .. } => 42,
|
||||
RuntimeFact::DepthClampRange => 43,
|
||||
RuntimeFact::FunctionTableRange { .. } => 44,
|
||||
RuntimeFact::TileThreadgroup { .. } => 46,
|
||||
RuntimeFact::ObjectThreadgroupArena { .. } => 54,
|
||||
RuntimeFact::ReplayBindings => 57,
|
||||
RuntimeFact::MergedDraws => 48,
|
||||
RuntimeFact::QuadPrimitiveIds => 40,
|
||||
RuntimeFact::RotatedWeights => 53,
|
||||
RuntimeFact::PrivateList => 55,
|
||||
RuntimeFact::PartialObjectThreadgroups => 58,
|
||||
RuntimeFact::OpenClMode => 60,
|
||||
RuntimeFact::BorderTexels { .. } => 45,
|
||||
RuntimeFact::CallThreadgroups => 59,
|
||||
RuntimeFact::PartialThreadgroups => 56,
|
||||
RuntimeFact::OpenClLineTexture { .. } => 49,
|
||||
RuntimeFact::AddressAlignment { .. } => 47,
|
||||
RuntimeFact::GridTiles => 38,
|
||||
RuntimeFact::PrivateArena { .. } => 50,
|
||||
RuntimeFact::StencilBitDraws => 51,
|
||||
RuntimeFact::RobustStorageBuffers => 52,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,7 +176,7 @@ fn variant(f: &RuntimeFact) -> usize {
|
||||
fn mechanism_is_total_over_every_fact_and_profile() {
|
||||
let facts = every_fact();
|
||||
let covered: std::collections::BTreeSet<usize> = facts.iter().map(variant).collect();
|
||||
assert_eq!(covered, (0..62).collect(), "every_fact misses a variant");
|
||||
assert_eq!(covered, (0..61).collect(), "every_fact misses a variant");
|
||||
for (stem, _) in super::committed_profiles() {
|
||||
let dev = device(&stem);
|
||||
let p = dev.profile();
|
||||
@@ -211,10 +195,6 @@ fn mechanism_is_total_over_every_fact_and_profile() {
|
||||
| RuntimeFact::TileFunction
|
||||
| RuntimeFact::OutOfBoundsAlpha { .. }
|
||||
| RuntimeFact::BorderTexels { .. }
|
||||
| RuntimeFact::SparseTexture {
|
||||
sparse_arm: true, ..
|
||||
}
|
||||
| RuntimeFact::SparseTexture { tile_map: true, .. }
|
||||
| RuntimeFact::TileThreadgroupMemory { .. }
|
||||
| RuntimeFact::TextureSwizzle { .. } => Mechanism::Specialization,
|
||||
RuntimeFact::LocalSizeConstraint { .. }
|
||||
@@ -222,11 +202,6 @@ fn mechanism_is_total_over_every_fact_and_profile() {
|
||||
| RuntimeFact::DeviceAddresses { .. }
|
||||
| RuntimeFact::SimdgroupEmulation { .. }
|
||||
| RuntimeFact::PredicationVote
|
||||
| RuntimeFact::SparseTexture {
|
||||
sparse_arm: false,
|
||||
tile_map: false,
|
||||
..
|
||||
}
|
||||
| RuntimeFact::ObjectThreadgroupArena { .. }
|
||||
| RuntimeFact::AddressAlignment { .. } => Mechanism::PlanTimeCheck,
|
||||
RuntimeFact::DispatchGrid
|
||||
|
||||
@@ -899,14 +899,6 @@ pub enum Feature {
|
||||
/// `CONSTANT_ALPHA` or `ONE_MINUS_CONSTANT_ALPHA` (Metal's `BlendAlpha` factors) as a color
|
||||
/// blend factor on a portability-subset device without `constantAlphaColorBlendFactors`.
|
||||
ConstantAlphaBlendFactor,
|
||||
/// A sparse texture (`MTLTexture.isSparse`) bound at `slot`, where a function observes the
|
||||
/// residency of its accesses (`sparse_color::resident()`) and the module has no sparse form
|
||||
/// for them (`RuntimeFact::SparseTexture`): it needs `shaderResourceResidency`, or, where the
|
||||
/// device has it, an access has none (a bicubic sample, not implemented). A texture that is
|
||||
/// not sparse is answered on every device.
|
||||
SparseTexture {
|
||||
slot: SlotRef,
|
||||
},
|
||||
// The runtime's refusals of texture objects and texture commands. Each depends on the Vulkan
|
||||
// device or on a Metal measurement, so another device or a later measurement can lift it;
|
||||
// what no Vulkan device can ever have is the runtime's Apple-only class instead.
|
||||
@@ -1105,8 +1097,8 @@ pub enum IdentityCause {
|
||||
/// no input names under the identity domains.
|
||||
StorageTextureFormat,
|
||||
/// A texture argument of a type the identity arrays hold no element of, or state of a bound
|
||||
/// texture or sampler beyond its resource ID that the function reads (a swizzle, a sparse
|
||||
/// texture's residency, an extended-range or sRGB-twin form, a bound format's class).
|
||||
/// texture or sampler beyond its resource ID that the function reads (a swizzle, an
|
||||
/// extended-range or sRGB-twin form, a bound format's class).
|
||||
TextureState,
|
||||
}
|
||||
|
||||
|
||||
@@ -856,13 +856,12 @@ pub(super) fn sampled_value(
|
||||
return live_or_zero(fb, live, x);
|
||||
}
|
||||
if let SampleOp::PixelFetch { offset } = &s.op {
|
||||
let (x, word) = pixel_fetch(cx, fb, s, si, image, offset.as_ref())?;
|
||||
let x = pixel_fetch(cx, fb, s, si, image, offset.as_ref())?;
|
||||
let x = live_or_zero(fb, live, x)?;
|
||||
return texel_value(cx, fb, s, image, x, word);
|
||||
return texel_value(cx, fb, s, image, x);
|
||||
}
|
||||
if let SampleOp::Bicubic(b) = &s.op {
|
||||
// No sparse form: the slot takes no sparse arm, and the word is 0. The routines return the
|
||||
// held texel, a `half` result already rounded.
|
||||
// The routines return the held texel, a `half` result already rounded; the word is 0.
|
||||
let x = super::bicubic::emit(cx, fb, s, si, image, b)?;
|
||||
let x = live_or_zero(fb, live, x)?;
|
||||
return with_word(cx, fb, &s.result, x, None);
|
||||
@@ -893,17 +892,10 @@ pub(super) fn sampled_value(
|
||||
)?;
|
||||
}
|
||||
// The plane coordinate as the sample reads it (pixel coordinates scaled), whose derivatives a
|
||||
// bias past the device's limit scales, and from which Metal's footprint of an observed access
|
||||
// follows.
|
||||
// bias past the device's limit scales.
|
||||
let plane = coord;
|
||||
let (coord, _) = layered(cx, fb, s, coord)?;
|
||||
// The access, from the sampled image `si` (loaded in the open block).
|
||||
let observe = |_: &mut EmitCx<'_>,
|
||||
fb: &mut FunctionBuilder<'_>,
|
||||
si: SValue,
|
||||
access: &dyn Fn(&mut FunctionBuilder<'_>, SValue, bool) -> BResult<SValue>|
|
||||
-> BResult<(SValue, Option<SValue>)> { Ok((access(fb, si, false)?, None)) };
|
||||
let (texel, word) = match &s.op {
|
||||
let texel = match &s.op {
|
||||
SampleOp::Sample {
|
||||
lod,
|
||||
dref,
|
||||
@@ -922,42 +914,36 @@ pub(super) fn sampled_value(
|
||||
(plane, grad, true),
|
||||
(lod, *min_lod, offset, *dref),
|
||||
)?;
|
||||
let (x, word) = observe(cx, fb, si, &sample_access(coord, dref, ops))?;
|
||||
let x = fb.sample(si, coord, dref, false, &ops)?;
|
||||
// Past the device's limit the sample with the scaled derivatives replaces the
|
||||
// implicit one; the implicit sample stays where it was, unconditional.
|
||||
let (x, word) = match beyond {
|
||||
None => (x, word),
|
||||
let x = match beyond {
|
||||
None => x,
|
||||
Some((test, grads)) => {
|
||||
let mut grad_ops = ops;
|
||||
grad_ops.bias = None;
|
||||
grad_ops.grad = Some(grads);
|
||||
let kept: Vec<SValue> = std::iter::once(x).chain(word).collect();
|
||||
let past: ArmFn<'_, EmitCx<'_>> = Box::new(|fb, cx| {
|
||||
// A sampled image is consumed in the block that makes it.
|
||||
let (si, _, _) = sampled_image(cx, fb, s.source)?;
|
||||
let access = sample_access(coord, dref, grad_ops);
|
||||
let (x, word) = observe(cx, fb, si, &access)?;
|
||||
Ok(ArmEnd::FallThrough(
|
||||
std::iter::once(x).chain(word).collect(),
|
||||
))
|
||||
let x = fb.sample(si, coord, dref, false, &grad_ops)?;
|
||||
Ok(ArmEnd::FallThrough(vec![x]))
|
||||
});
|
||||
let within: ArmFn<'_, EmitCx<'_>> =
|
||||
Box::new(move |_, _| Ok(ArmEnd::FallThrough(kept)));
|
||||
Box::new(move |_, _| Ok(ArmEnd::FallThrough(vec![x])));
|
||||
let Merged(merged) = fb.if_(cx, test, past, Some(within))?;
|
||||
match merged[..] {
|
||||
[x] => (x, None),
|
||||
[x, w] => (x, Some(w)),
|
||||
[x] => x,
|
||||
_ => return Err(cx.fail("a biased sample without its merged texel")),
|
||||
}
|
||||
}
|
||||
};
|
||||
// A depth sample without comparison reads the first component.
|
||||
let x = if s.depth && dref.is_none() {
|
||||
if s.depth && dref.is_none() {
|
||||
fb.composite_extract(x, &[0])?
|
||||
} else {
|
||||
x
|
||||
};
|
||||
(x, word)
|
||||
}
|
||||
}
|
||||
SampleOp::Gather {
|
||||
component,
|
||||
@@ -976,12 +962,10 @@ pub(super) fn sampled_value(
|
||||
Some(r) => Some(reference(cx, fb, s, *r)?),
|
||||
None => None,
|
||||
};
|
||||
observe(cx, fb, si, &|fb, si, sparse| match (dref, sparse) {
|
||||
(Some(r), true) => fb.sparse_dref_gather(si, coord, r, &ops),
|
||||
(Some(r), false) => fb.dref_gather(si, coord, r, &ops),
|
||||
(None, true) => fb.sparse_gather(si, coord, component, &ops),
|
||||
(None, false) => fb.gather(si, coord, component, &ops),
|
||||
})?
|
||||
match dref {
|
||||
Some(r) => fb.dref_gather(si, coord, r, &ops)?,
|
||||
None => fb.gather(si, coord, component, &ops)?,
|
||||
}
|
||||
}
|
||||
SampleOp::Lod { clamped } => {
|
||||
// `x` is the level the sampler would access (clamped), `y` the level relative to the
|
||||
@@ -995,7 +979,7 @@ pub(super) fn sampled_value(
|
||||
}
|
||||
};
|
||||
let texel = live_or_zero(fb, live, texel)?;
|
||||
texel_value(cx, fb, s, image, texel, word)
|
||||
texel_value(cx, fb, s, image, texel)
|
||||
}
|
||||
|
||||
/// The plane coordinate of `s`, read from the AIR operand as given: the device's sampler, and an
|
||||
@@ -1603,22 +1587,6 @@ pub(super) fn reference(
|
||||
fb.glsl(GlslOp::NClamp, &[r, zero, one])
|
||||
}
|
||||
|
||||
/// The access of a sample at `coord` with comparison `dref` and operands `ops`, from the sampled
|
||||
/// image it is handed, in its sparse form where asked.
|
||||
pub(super) fn sample_access(
|
||||
coord: SValue,
|
||||
dref: Option<SValue>,
|
||||
ops: ImageOperands,
|
||||
) -> impl Fn(&mut FunctionBuilder<'_>, SValue, bool) -> BResult<SValue> {
|
||||
move |fb, si, sparse| {
|
||||
if sparse {
|
||||
fb.sparse_sample(si, coord, dref, &ops)
|
||||
} else {
|
||||
fb.sample(si, coord, dref, false, &ops)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The derivatives of 2D plane coordinate `plane` in the open block as the axis gradients of
|
||||
/// Metal's bias `bias` on a texture of level-0 size `size` ([`axis_gradients`]).
|
||||
pub(super) fn plane_axis_gradients(
|
||||
@@ -1835,7 +1803,7 @@ fn pixel_fetch(
|
||||
si: SValue,
|
||||
image: super::CombinedImage,
|
||||
offset: Option<&Offset>,
|
||||
) -> BResult<(SValue, Option<SValue>)> {
|
||||
) -> BResult<SValue> {
|
||||
let img = fb.image(si)?;
|
||||
let zero = fb.u32_const(0)?;
|
||||
let zero = fb.module().const_value(zero)?;
|
||||
@@ -1921,28 +1889,25 @@ fn pixel_fetch(
|
||||
lod: Some(zero),
|
||||
..ImageOperands::default()
|
||||
};
|
||||
let (x, word) = (fb.fetch(img, at, &ops)?, None);
|
||||
let x = if s.depth {
|
||||
fb.composite_extract(x, &[0])?
|
||||
let x = fb.fetch(img, at, &ops)?;
|
||||
if s.depth {
|
||||
fb.composite_extract(x, &[0])
|
||||
} else {
|
||||
x
|
||||
};
|
||||
Ok((x, word))
|
||||
Ok(x)
|
||||
}
|
||||
}
|
||||
|
||||
/// The sampling result of image texel `texel`: the held texel ([`held_value`]), as `{T, i8}`
|
||||
/// where the result is one, with
|
||||
/// status word `word` (the sparse arm's; 0 where none is given, Metal's for a resident access).
|
||||
/// where the result is one, with status word 0, Metal's for a resident access.
|
||||
pub(super) fn texel_value(
|
||||
cx: &mut EmitCx<'_>,
|
||||
fb: &mut FunctionBuilder<'_>,
|
||||
s: &Sampling,
|
||||
image: super::CombinedImage,
|
||||
texel: SValue,
|
||||
word: Option<SValue>,
|
||||
) -> BResult<SValue> {
|
||||
let held = held_value(cx, fb, s, image, texel)?;
|
||||
with_word(cx, fb, &s.result, held, word)
|
||||
with_word(cx, fb, &s.result, held, None)
|
||||
}
|
||||
|
||||
/// The held texel of sampling `s`'s image texel `texel`: an 8-bit sRGB texel's raw code decoded
|
||||
|
||||
@@ -1,125 +0,0 @@
|
||||
//! Metal's footprint of a sample or gather whose residency the function observes.
|
||||
//!
|
||||
//! `sparse_color::resident()` of a filtered sample is whether every texel the filter weighs is
|
||||
//! resident. Metal counts only the texels its filter gives a nonzero weight, and Vulkan's linear
|
||||
//! footprint holds the 2x2 texels around the position even where one weighs zero (lavapipe counts
|
||||
//! it). Apple's rule, measured on apple-m3-max-macos26.7 (cases 39503d65 and efe06aaf at a width of
|
||||
//! 256, both axes and the clamp-to-zero border, 363e39a2 at 384, off the sweep, and 203caac1 along
|
||||
//! a 3D texture's z): per axis of size `N` and normalized coordinate `u`,
|
||||
//!
|
||||
//! - the position is `X = f32(u · N)`, the product rounded to `float` with ties away from zero
|
||||
//! (the probes: these cases hold no tie; `position`);
|
||||
//! - a linear filter's sample position `X - 1/2` is rounded to 1/256 of a texel, ties up:
|
||||
//! `q = floor(256·X + 1/2) - 128`; its texels are `i0 = floor(q / 256)` with weight
|
||||
//! `(256 - q mod 256) / 256`, never 0, and `i0 + 1` with weight `(q mod 256) / 256`, counted only
|
||||
//! where it is not 0;
|
||||
//! - a gather reads the same `i0` and `i0 + 1`, all four counted;
|
||||
//! - a nearest filter reads `floor(X)`, not rounded to the quantum.
|
||||
//!
|
||||
//! A clamp-to-edge axis reads the texel clamped into the level, which counts; a clamp-to-zero or
|
||||
//! clamp-to-border axis's texel outside the level is the border, which is no texel (Metal answers
|
||||
//! resident across it; fd292944 measured both modes). [`of`] states where the rule decides the
|
||||
//! footprint: a constexpr normalized sampler, no comparison or anisotropy (a lowered sampler's
|
||||
//! reduction is the weighted average), one filter for minification and magnification, clamp
|
||||
//! addressing, level 0 (the sampler not mipmapped, or a level-0 sample whose sampler neither
|
||||
//! biases nor clamps the level), and no texel offset. Elsewhere (a runtime sampler, mip levels,
|
||||
//! repeat or mirrored addressing, an offset, none of them measured) no tile map answers the
|
||||
//! access. The rule is the residency of a device without residency code of its own (no
|
||||
//! `shaderResourceResidency`), whose slot's tile map answers it; a device with it answers a
|
||||
//! sample's or gather's residency itself (its `OpImageSparse*` word,
|
||||
//! `PrecisionNote::SparseResidency`), and selection asks for no rule there.
|
||||
|
||||
use crate::air::abi::SamplerState;
|
||||
use crate::air::abi::{AddressMode, Coordinates, Filter, MipFilter};
|
||||
use crate::air::intrinsics::{ImageDim, ImageShape};
|
||||
|
||||
use super::{Lod, SampleOp};
|
||||
|
||||
/// How the footprint's texels follow from the position.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
pub enum Kind {
|
||||
/// `floor(X)`.
|
||||
Nearest,
|
||||
/// `i0`, and `i0 + 1` where its quantized weight is not 0.
|
||||
Linear,
|
||||
/// `i0` and `i0 + 1`, every one.
|
||||
Gather,
|
||||
}
|
||||
|
||||
/// Metal's footprint of one sample or gather.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
pub struct Footprint {
|
||||
pub kind: Kind,
|
||||
/// The axes (2 for a 2D or 2D-array texture, 3 for a 3D one).
|
||||
pub axes: u8,
|
||||
/// Per axis, whether a texel outside the level is the border (clamp-to-zero or
|
||||
/// clamp-to-border) rather than the edge texel (clamp-to-edge).
|
||||
pub border: [bool; 3],
|
||||
}
|
||||
|
||||
/// Metal's footprint of `op` on a texture of `shape` through the constexpr sampler `state`, where
|
||||
/// the rule decides it; `None` elsewhere. `integer`: the texture's texels are integers (a sample of
|
||||
/// one is not filtered).
|
||||
pub fn of(
|
||||
state: &SamplerState,
|
||||
op: &SampleOp,
|
||||
shape: ImageShape,
|
||||
integer: bool,
|
||||
) -> Option<Footprint> {
|
||||
if shape.ms || shape.depth {
|
||||
return None;
|
||||
}
|
||||
let axes: u8 = match (shape.dim, shape.array) {
|
||||
(ImageDim::D2, _) => 2,
|
||||
(ImageDim::D3, false) => 3,
|
||||
_ => return None,
|
||||
};
|
||||
// A comparison is the op's (`dref`, a depth texture's): the sampler's compare function
|
||||
// applies only there.
|
||||
if state.coordinates != Coordinates::Normalized || state.max_anisotropy > 1 {
|
||||
return None;
|
||||
}
|
||||
let mut border = [false; 3];
|
||||
let modes = [state.address_s, state.address_t, state.address_r];
|
||||
for (b, mode) in border.iter_mut().zip(modes).take(usize::from(axes)) {
|
||||
*b = match mode {
|
||||
AddressMode::ClampToEdge => false,
|
||||
AddressMode::ClampToZero | AddressMode::ClampToBorder => true,
|
||||
AddressMode::Repeat | AddressMode::MirroredRepeat => return None,
|
||||
};
|
||||
}
|
||||
let kind = match op {
|
||||
SampleOp::Gather { offset: None, .. } if axes == 2 => Kind::Gather,
|
||||
SampleOp::Sample {
|
||||
lod,
|
||||
dref: None,
|
||||
min_lod,
|
||||
offset: None,
|
||||
} if !integer => {
|
||||
let kind = match (state.min_filter, state.mag_filter) {
|
||||
(Filter::Nearest, Filter::Nearest) => Kind::Nearest,
|
||||
(Filter::Linear, Filter::Linear) => Kind::Linear,
|
||||
_ => return None,
|
||||
};
|
||||
// Level 0: the sampler is not mipmapped, or the sample reads level 0 and the sampler
|
||||
// neither biases nor clamps it.
|
||||
let base = matches!(
|
||||
lod,
|
||||
Lod::Level(None)
|
||||
| Lod::Base {
|
||||
bias: None,
|
||||
min: None,
|
||||
..
|
||||
}
|
||||
) && min_lod.is_none()
|
||||
&& state.lod_min_clamp.to_f32() == 0.0
|
||||
&& state.lod_bias.to_f32() == 0.0;
|
||||
if state.mip_filter != MipFilter::None && !base {
|
||||
return None;
|
||||
}
|
||||
kind
|
||||
}
|
||||
_ => return None,
|
||||
};
|
||||
Some(Footprint { kind, axes, border })
|
||||
}
|
||||
@@ -128,7 +128,6 @@ mod constexpr;
|
||||
mod emit;
|
||||
pub mod extended;
|
||||
pub mod face;
|
||||
pub mod footprint;
|
||||
pub mod level;
|
||||
pub mod linear;
|
||||
pub mod position;
|
||||
@@ -588,8 +587,8 @@ pub enum PixelPosition {
|
||||
/// unnormalizedCoordinates`) at level 0 of a view of the texture's first level: the device's
|
||||
/// own sampler reads its texel, footprint and weights from `x`. A sample or gather without
|
||||
/// comparison through a constexpr pixel sampler that sampler reads as it is
|
||||
/// (`metal::sampler::unnormalized_reads`), of a 1D or 2D texture that is no array, whose
|
||||
/// residency the function does not observe ([`BindingKey::unnormalized`]), but a nearest
|
||||
/// (`metal::sampler::unnormalized_reads`), of a 1D or 2D texture that is no array
|
||||
/// ([`BindingKey::unnormalized`]), but a nearest
|
||||
/// sample with an offset ([`UnnormalizedTexel`](Self::UnnormalizedTexel)).
|
||||
Unnormalized,
|
||||
/// `floor(x) + 0.5 + k`, the centre of the texel Metal's nearest filter reads at `x` moved by
|
||||
@@ -626,13 +625,6 @@ pub struct Sampling {
|
||||
pub pixel: Pixel,
|
||||
/// What the device is handed of the coordinate where it is in pixels.
|
||||
pub position: PixelPosition,
|
||||
/// The function observes bit 0 of the result's status word: on a slot with a sparse arm a
|
||||
/// sample, gather, or fetch takes its sparse form under the slot's `SparseTexture`
|
||||
/// specialization; otherwise (and for a bicubic sample, which has none) the word is 0.
|
||||
pub residency: bool,
|
||||
/// Metal's footprint of an observed sample or gather where the rule decides it: its word is the
|
||||
/// residency of exactly those texels, through the slot's sparse arm or tile map.
|
||||
pub footprint: Option<footprint::Footprint>,
|
||||
/// It reads a cube by a direction, whose ties between major axes the device is handed broken
|
||||
/// as Metal breaks them ([`face`]).
|
||||
pub cube: bool,
|
||||
@@ -657,16 +649,15 @@ pub struct Sampling {
|
||||
impl Sampling {
|
||||
/// The shape the arms of a switch-at-use share where it emulates once (SEMANTICS 1012,
|
||||
/// `sampler::shared_value`): this sampling with its texture slot and sampler taken out, where
|
||||
/// it is an emulation on a combined binding whose residency the function does not observe: a
|
||||
/// bicubic sample. Arms of one shape differ only in the binding they read: each emulation
|
||||
/// states its sampler's addressing in its own fields.
|
||||
/// it is an emulation on a combined binding: a bicubic sample. Arms of one shape differ only in
|
||||
/// the binding they read: each emulation states its sampler's addressing in its own fields.
|
||||
pub(crate) fn shared_shape(&self) -> Option<Sampling> {
|
||||
let Source::Combined(key) = self.source else {
|
||||
return None;
|
||||
};
|
||||
// A swizzled slot's sampling swizzles under its own slot's swizzle; an offset placed by a
|
||||
// slot's `OffsetBaseAxes` is placed by its own slot's.
|
||||
if self.residency || self.footprint.is_some() || self.swizzle || self.offset_base {
|
||||
if self.swizzle || self.offset_base {
|
||||
return None;
|
||||
}
|
||||
let mut k = self.clone();
|
||||
@@ -805,11 +796,11 @@ impl Sampling {
|
||||
|
||||
/// The estimated words: the load, the coordinate, the operation, and the texel conversion, plus
|
||||
/// the pixel scaling, the reading of a dynamic `Offset` operand, a heap element's access chain,
|
||||
/// sampled image, and null select, the sparse arm, a bias past the limit's derivatives,
|
||||
/// sampled image, and null select, a bias past the limit's derivatives,
|
||||
/// `bias_gradients`, and (for a dynamic bias) the test, the selection, and the second sample, a
|
||||
/// `half` texel's exact rounding outside the bicubic filter, an sRGB texel's raw decode, a cube
|
||||
/// gradient's footprint, a pixel coordinate's texel or block centre, the positions of an
|
||||
/// observed footprint, the lanes Metal reads as constants, a cube direction's broken ties, and
|
||||
/// gradient's footprint, a pixel coordinate's texel or block centre, the lanes Metal reads as
|
||||
/// constants, a cube direction's broken ties, and
|
||||
/// a raw heap sample's decode.
|
||||
pub fn words(&self) -> u32 {
|
||||
// A swizzled slot's sampling: its swizzle, and a gather's of each component.
|
||||
@@ -876,11 +867,6 @@ impl Sampling {
|
||||
}
|
||||
Source::HeapSampler { .. } => 56 + 2 * ENTRY_FIELD_WORDS,
|
||||
};
|
||||
let residency = if self.residency {
|
||||
crate::lower::texture::RESIDENCY_WORDS
|
||||
} else {
|
||||
0
|
||||
};
|
||||
// A `half` texel's exact rounding; the bicubic routines round their `half` result
|
||||
// themselves.
|
||||
let half = match (&self.op, self.texel) {
|
||||
@@ -908,10 +894,6 @@ impl Sampling {
|
||||
}
|
||||
_ => 0,
|
||||
};
|
||||
// The position of each axis of Metal's footprint of an observed sample or gather.
|
||||
let footprint = self
|
||||
.footprint
|
||||
.map_or(0, |fp| u32::from(fp.axes) * position::POSITION_WORDS);
|
||||
// The slot's parent tests in Metal's offset rule, on each plane axis of the bicubic
|
||||
// footprint that places the offset.
|
||||
let parent = match self.offset_base {
|
||||
@@ -920,11 +902,9 @@ impl Sampling {
|
||||
};
|
||||
base + wrap
|
||||
+ heap
|
||||
+ residency
|
||||
+ half
|
||||
+ centre
|
||||
+ word
|
||||
+ footprint
|
||||
+ parent
|
||||
+ if self.cube { face::TIE_WORDS } else { 0 }
|
||||
+ match (self.pixel, self.position) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! Metal's texel-space position of a normalized coordinate, which the filters the device has no
|
||||
//! form for read their footprints from (`bicubic`, `extended`, `heap_raw`, and the residency
|
||||
//! `footprint`), and Metal's placement of a texel offset on a repeating or mirrored axis.
|
||||
//! form for read their footprints from (`bicubic`, `extended` and `heap_raw`), and Metal's
|
||||
//! placement of a texel offset on a repeating or mirrored axis.
|
||||
//!
|
||||
//! **The position** (Apple M3 Max, macOS 26.7, and Apple M4, macOS 27.0.1, byte-identical; the
|
||||
//! tie, gather, and bicubic probes). Per axis of size `N` and normalized coordinate `u`, Apple's
|
||||
|
||||
@@ -1035,7 +1035,7 @@ fn select_slot(
|
||||
/// emulated by fetches of the raw texels on every device (`extended`). Built: a 2D or 2D array
|
||||
/// texture's sample or gradient sample without comparison (and a `BGR10_XR` or `BGRA10_XR`
|
||||
/// form's, or `_sRGB` twin's, 3D texture's sample), with a `float` or `half` result, a
|
||||
/// constant texel offset or none, no `min_lod_clamp`, and no observed residency, through a
|
||||
/// constant texel offset or none, and no `min_lod_clamp`, through a
|
||||
/// constexpr sampler with one filter for minification and magnification (nearest or linear), no
|
||||
/// anisotropy, and no mip filter, a nearest one, or a linear one of a form whose levels' blend is
|
||||
/// built (`ExtendedRange::blends_levels`) or of a bfloat form (its nearest one, as Metal's), or
|
||||
@@ -1285,8 +1285,6 @@ fn select_extended(
|
||||
SamplerArg::Heap(_) => return Err(refused()),
|
||||
},
|
||||
};
|
||||
// An observed residency is the constant resident word; another observed bit is refused.
|
||||
crate::lower::texture::residency(cx, at, ImageRef::Slot(index))?;
|
||||
// A swizzled texture of the slot's variant: the sample swizzles its decoded texel, a border
|
||||
// texel included, and a gather of a component gathers the component its swizzle names, as
|
||||
// plain Metal does.
|
||||
@@ -1800,52 +1798,8 @@ fn select_one(
|
||||
.extend(routines.iter().copied());
|
||||
cx.precision.insert(PrecisionNote::BicubicFilterArithmetic);
|
||||
}
|
||||
// An observed residency; a bicubic sample's fetches have no sparse form, so its slot takes
|
||||
// none, and an LOD query has no status word.
|
||||
let observed = !matches!(op, SampleOp::Lod { .. } | SampleOp::QueryLevel { .. })
|
||||
&& crate::lower::texture::residency(cx, at, image)?;
|
||||
let fetches = matches!(op, SampleOp::Bicubic(_));
|
||||
let sparse_images = cx
|
||||
.profile
|
||||
.fields()
|
||||
.enabled
|
||||
.features
|
||||
.contains(&VkFeature::ShaderResourceResidency);
|
||||
// Metal's footprint where its measured rule decides it, a constexpr sampler's, on a device
|
||||
// without residency code of its own (no `shaderResourceResidency`), where the slot's tile map
|
||||
// answers the residency. A device with it answers a sample's or gather's residency itself,
|
||||
// its `OpImageSparse*` word (`PrecisionNote::SparseResidency`).
|
||||
let footprint = match (observed, image, sampler) {
|
||||
(true, ImageRef::Slot(_), SamplerArg::Static(SamplerRef::Constexpr(words), _))
|
||||
if !sparse_images =>
|
||||
{
|
||||
let state = super::constexpr::state_of(words)?;
|
||||
super::footprint::of(&state, &op, shape, integer)
|
||||
}
|
||||
_ => None,
|
||||
};
|
||||
// A tile map answers a pixel sampler's fetch, whose texel the shader names, and a sample or
|
||||
// gather with Metal's footprint; every other sample's or gather's footprint is the device
|
||||
// filter's.
|
||||
let named = matches!(op, SampleOp::PixelFetch { .. }) || footprint.is_some();
|
||||
// Where the profile enables `shaderResourceResidency`, a sparse texture is a sparse image: a
|
||||
// sample's, gather's, or pixel fetch's texels in a block of it that holds no mapped tile read
|
||||
// the device's non-resident value under either arm (zero only under
|
||||
// `residencyNonResidentStrict`, and RADV's zero alpha where Metal reads a missing alpha as 1),
|
||||
// and a sample's or gather's footprint and word on the sparse arm are the device's.
|
||||
// An LOD query reads no texel.
|
||||
let texel_op = !matches!(op, SampleOp::Lod { .. } | SampleOp::QueryLevel { .. });
|
||||
// No texture is sparse (the consumer refuses a sparse texture), and the view's own components
|
||||
// read the lanes its format lacks.
|
||||
if observed && !fetches && sparse_images {
|
||||
cx.precision.insert(PrecisionNote::SparseResidency);
|
||||
}
|
||||
if let (true, ImageRef::Slot(index)) = (observed, image) {
|
||||
if let Some(s) = cx.families.texture.slots.get_mut(&index) {
|
||||
s.uses.plain_residency |= fetches;
|
||||
s.uses.untiled_residency |= !named;
|
||||
}
|
||||
}
|
||||
let residency = observed && !fetches;
|
||||
// Every sample, gather and level query goes to the device's own sampler
|
||||
// (`VkProperty::DeviceSampling`), whose answers the module records (a level query's level
|
||||
// clamped by the device into the sampler's clamp, the descriptor's).
|
||||
@@ -1993,8 +1947,6 @@ fn select_one(
|
||||
result,
|
||||
pixel,
|
||||
position,
|
||||
residency,
|
||||
footprint,
|
||||
cube,
|
||||
swizzle,
|
||||
offset_base,
|
||||
|
||||
@@ -1701,7 +1701,6 @@ fn identity_unsourced(f: &RuntimeFact) -> bool {
|
||||
f,
|
||||
RuntimeFact::ImageViewShape { .. }
|
||||
| RuntimeFact::StorageTextureNumericType { .. }
|
||||
| RuntimeFact::SparseTexture { .. }
|
||||
| RuntimeFact::TextureSwizzle { .. }
|
||||
)
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ use crate::lower::arith::narrow;
|
||||
use crate::lower::emit::EmitCx;
|
||||
use crate::lower::sync::barrier::{memory_model, BarrierModel};
|
||||
use crate::pipeline::lower_inputs::StorageImageClass;
|
||||
use crate::spirv::builder::constructs::{ArmEnd, ArmFn, LoopFn, LoopSpec, Merged};
|
||||
use crate::spirv::builder::constructs::{ArmEnd, ArmFn, LoopFn, LoopSpec};
|
||||
use crate::spirv::builder::FunctionBuilder;
|
||||
use crate::spirv::error::BResult;
|
||||
use crate::spirv::ids::{ConstId, TypeId, Value as SValue};
|
||||
@@ -1574,52 +1574,6 @@ pub(super) fn out_of_bounds_texel(
|
||||
fb.composite_construct(ty, &[zero, zero, zero, alpha])
|
||||
}
|
||||
|
||||
/// The `SparseTexture` specialization of texture slot `index`, where `residency` says the access's
|
||||
/// status word is observed and the slot has a sparse arm or a tile-map arm; `None` otherwise (the
|
||||
/// word is 0). A written slot without either arm declares the specialization only to drop its
|
||||
/// writes ([`sparse_writes_kept`]).
|
||||
pub(crate) fn sparse_spec(cx: &EmitCx<'_>, index: u32, residency: bool) -> Option<SValue> {
|
||||
let armed = cx
|
||||
.plan
|
||||
.families
|
||||
.texture
|
||||
.slots
|
||||
.get(&index)
|
||||
.is_some_and(|s| s.sparse_arm || s.tile_map);
|
||||
if !residency || !armed {
|
||||
return None;
|
||||
}
|
||||
cx.decl.families.texture.sparse.get(&index).copied()
|
||||
}
|
||||
|
||||
/// Whether a write to `image` lands: the negation of its slot's `SparseTexture` specialization,
|
||||
/// since Metal drops every write a function makes to a sparse texture; `None` where every write
|
||||
/// lands (a heap element, or a slot whose writes are not dropped).
|
||||
fn sparse_writes_kept(
|
||||
cx: &mut EmitCx<'_>,
|
||||
fb: &mut FunctionBuilder<'_>,
|
||||
image: &ImageRef,
|
||||
) -> BResult<Option<SValue>> {
|
||||
let ImageRef::Slot(index) = *image else {
|
||||
return Ok(None);
|
||||
};
|
||||
let drops = cx
|
||||
.plan
|
||||
.families
|
||||
.texture
|
||||
.slots
|
||||
.get(&index)
|
||||
.is_some_and(|s| s.sparse_writes);
|
||||
let spec = cx.decl.families.texture.sparse.get(&index).copied();
|
||||
match (drops, spec) {
|
||||
(true, Some(spec)) => Ok(Some(fb.unary(UnOp::LogicalNot, spec)?)),
|
||||
(true, None) => Err(cx.fail(format!(
|
||||
"texture slot {index} drops sparse writes without its specialization"
|
||||
))),
|
||||
(false, _) => Ok(None),
|
||||
}
|
||||
}
|
||||
|
||||
/// `a && b` of two optional conditions (`None`: true).
|
||||
fn and_kept(
|
||||
fb: &mut FunctionBuilder<'_>,
|
||||
@@ -1632,224 +1586,6 @@ fn and_kept(
|
||||
})
|
||||
}
|
||||
|
||||
/// The result and status word of an access whose residency the function observes, under slot
|
||||
/// specialization `spec` (true: the bound texture is sparse). There `access(fb, true)`, the
|
||||
/// access's sparse form, returns the struct of the residency code and the result, and the word is
|
||||
/// 1 where `OpImageSparseTexelsResident` says a texel it read is not resident (bit 0 of Metal's
|
||||
/// word, `!sparse_color::resident()`), else 0; otherwise `access(fb, false)`, the plain access,
|
||||
/// and 0, Metal's word for a texture that is not sparse, which is resident everywhere. A
|
||||
/// specialization constant is uniform, so an implicit-LOD sample in either arm keeps its
|
||||
/// derivatives. `access` builds everything it reads that must share its block (a sampled image).
|
||||
pub(crate) fn resident_access<'a, F>(
|
||||
cx: &mut EmitCx<'_>,
|
||||
fb: &mut FunctionBuilder<'_>,
|
||||
spec: SValue,
|
||||
access: F,
|
||||
) -> BResult<(SValue, SValue)>
|
||||
where
|
||||
F: Fn(&mut FunctionBuilder<'_>, bool) -> BResult<SValue> + Copy + 'a,
|
||||
{
|
||||
let sparse: ArmFn<'a, ()> = Box::new(move |fb, _| {
|
||||
let r = access(fb, true)?;
|
||||
let code = fb.composite_extract(r, &[0])?;
|
||||
let value = fb.composite_extract(r, &[1])?;
|
||||
let resident = fb.texels_resident(code)?;
|
||||
let zero = u32s(fb, 1, 0)?;
|
||||
let one = u32s(fb, 1, 1)?;
|
||||
let word = fb.select(resident, zero, one)?;
|
||||
Ok(ArmEnd::FallThrough(vec![value, word]))
|
||||
});
|
||||
let plain: ArmFn<'a, ()> = Box::new(move |fb, _| {
|
||||
let value = access(fb, false)?;
|
||||
let word = u32s(fb, 1, 0)?;
|
||||
Ok(ArmEnd::FallThrough(vec![value, word]))
|
||||
});
|
||||
let Merged(merged) = fb.if_(&mut (), spec, sparse, Some(plain))?;
|
||||
match merged[..] {
|
||||
[value, word] => Ok((value, word)),
|
||||
_ => Err(cx.fail("a sparse arm without its result and word")),
|
||||
}
|
||||
}
|
||||
|
||||
/// The tile map of texture slot `index`, where the slot has a tile-map arm.
|
||||
pub(crate) fn tile_map(cx: &EmitCx<'_>, index: u32) -> Option<crate::memory::views::View> {
|
||||
cx.decl.families.texture.tile_maps.get(&index).copied()
|
||||
}
|
||||
|
||||
/// The texel `(x, y, z)` and slice of image coordinate `coord` of an image declared `decl`, for a
|
||||
/// tile map: a 2D coordinate's `z` is 0, a 2D array's last component is the slice.
|
||||
pub(crate) fn tile_parts(
|
||||
fb: &mut FunctionBuilder<'_>,
|
||||
decl: &ImageDecl,
|
||||
coord: SValue,
|
||||
) -> BResult<([SValue; 3], SValue)> {
|
||||
let zero = u32s(fb, 1, 0)?;
|
||||
let x = fb.composite_extract(coord, &[0])?;
|
||||
let y = fb.composite_extract(coord, &[1])?;
|
||||
Ok(match (decl.dim, decl.arrayed) {
|
||||
(Dim::D3, _) => ([x, y, fb.composite_extract(coord, &[2])?], zero),
|
||||
(_, true) => ([x, y, zero], fb.composite_extract(coord, &[2])?),
|
||||
_ => ([x, y, zero], zero),
|
||||
})
|
||||
}
|
||||
|
||||
/// The words of a tile map that every texel of one level and slice shares, read once: the level's
|
||||
/// entry (clamped below 16), each axis's tile extent and tile count, and the first bit of the slice
|
||||
/// (clamped below the map's count).
|
||||
#[derive(Clone, Copy)]
|
||||
pub(crate) struct TileLevel {
|
||||
map: crate::memory::views::View,
|
||||
extents: [SValue; 3],
|
||||
counts: [SValue; 3],
|
||||
/// The slice's first bit: `slice · B + base`.
|
||||
first: SValue,
|
||||
}
|
||||
|
||||
impl TileLevel {
|
||||
/// Level `level` and slice `slice` of `map`, as `pipeline::tile_map` lays it out.
|
||||
pub(crate) fn new(
|
||||
fb: &mut FunctionBuilder<'_>,
|
||||
map: crate::memory::views::View,
|
||||
level: SValue,
|
||||
slice: SValue,
|
||||
) -> BResult<TileLevel> {
|
||||
use crate::memory::views::read_word;
|
||||
use crate::pipeline::tile_map::{
|
||||
LEVELS_WORD, LEVEL_WORDS, MAX_LEVELS, SLICES_WORD, SLICE_BITS_WORD, TILE_WORD,
|
||||
};
|
||||
let one = u32s(fb, 1, 1)?;
|
||||
let word = |fb: &mut FunctionBuilder<'_>, w: u32| -> BResult<SValue> {
|
||||
let at = u32s(fb, 1, w)?;
|
||||
read_word(fb, map, at)
|
||||
};
|
||||
let top = u32s(fb, 1, MAX_LEVELS - 1)?;
|
||||
let level = fb.glsl(GlslOp::UMin, &[level, top])?;
|
||||
let stride = u32s(fb, 1, LEVEL_WORDS)?;
|
||||
let first = u32s(fb, 1, LEVELS_WORD)?;
|
||||
let entry = fb.binary(BinOp::IMul, level, stride)?;
|
||||
let entry = fb.binary(BinOp::IAdd, entry, first)?;
|
||||
let base = read_word(fb, map, entry)?;
|
||||
let mut extents = [one; 3];
|
||||
let mut counts = [one; 3];
|
||||
for (axis, (extent, count)) in (0u32..).zip(extents.iter_mut().zip(counts.iter_mut())) {
|
||||
let e = word(fb, TILE_WORD + axis)?;
|
||||
*extent = fb.glsl(GlslOp::UMax, &[e, one])?;
|
||||
let k = u32s(fb, 1, 1 + axis)?;
|
||||
let at = fb.binary(BinOp::IAdd, entry, k)?;
|
||||
*count = read_word(fb, map, at)?;
|
||||
}
|
||||
let slices = word(fb, SLICES_WORD)?;
|
||||
let last = fb.binary(BinOp::ISub, slices, one)?;
|
||||
let slice = fb.glsl(GlslOp::UMin, &[slice, last])?;
|
||||
let slice_bits = word(fb, SLICE_BITS_WORD)?;
|
||||
let first = fb.binary(BinOp::IMul, slice, slice_bits)?;
|
||||
let first = fb.binary(BinOp::IAdd, first, base)?;
|
||||
Ok(TileLevel {
|
||||
map,
|
||||
extents,
|
||||
counts,
|
||||
first,
|
||||
})
|
||||
}
|
||||
|
||||
/// The tile along `axis` (x, y, or z, from 0) of texel coordinate `c`, clamped below the
|
||||
/// level's tiles, so the lookup stays in the map for any access.
|
||||
pub(crate) fn tile(
|
||||
&self,
|
||||
fb: &mut FunctionBuilder<'_>,
|
||||
axis: usize,
|
||||
c: SValue,
|
||||
) -> BResult<SValue> {
|
||||
let ([ex, ey, ez], [nx, ny, nz]) = (self.extents, self.counts);
|
||||
let (extent, count) = match axis {
|
||||
0 => (ex, nx),
|
||||
1 => (ey, ny),
|
||||
_ => (ez, nz),
|
||||
};
|
||||
let one = u32s(fb, 1, 1)?;
|
||||
let last = fb.binary(BinOp::ISub, count, one)?;
|
||||
let t = fb.binary(BinOp::UDiv, c, extent)?;
|
||||
fb.glsl(GlslOp::UMin, &[t, last])
|
||||
}
|
||||
|
||||
/// Whether the tile at `tiles` (each from [`TileLevel::tile`]) is mapped: its bit,
|
||||
/// `(tz · ny + ty) · nx + tx` past the slice's first.
|
||||
pub(crate) fn mapped(
|
||||
&self,
|
||||
fb: &mut FunctionBuilder<'_>,
|
||||
tiles: [SValue; 3],
|
||||
) -> BResult<SValue> {
|
||||
use crate::memory::views::read_word;
|
||||
use crate::pipeline::tile_map::BITS_WORD;
|
||||
let [tx, ty, tz] = tiles;
|
||||
let [nx, ny, _] = self.counts;
|
||||
let row = fb.binary(BinOp::IMul, tz, ny)?;
|
||||
let row = fb.binary(BinOp::IAdd, row, ty)?;
|
||||
let within = fb.binary(BinOp::IMul, row, nx)?;
|
||||
let within = fb.binary(BinOp::IAdd, within, tx)?;
|
||||
let bit = fb.binary(BinOp::IAdd, self.first, within)?;
|
||||
let five = u32s(fb, 1, 5)?;
|
||||
let index = fb.binary(BinOp::ShiftRightLogical, bit, five)?;
|
||||
let bits = u32s(fb, 1, BITS_WORD)?;
|
||||
let index = fb.binary(BinOp::IAdd, index, bits)?;
|
||||
let w = read_word(fb, self.map, index)?;
|
||||
let mask = u32s(fb, 1, 31)?;
|
||||
let shift = fb.binary(BinOp::BitwiseAnd, bit, mask)?;
|
||||
let w = fb.binary(BinOp::ShiftRightLogical, w, shift)?;
|
||||
let one = u32s(fb, 1, 1)?;
|
||||
let w = fb.binary(BinOp::BitwiseAnd, w, one)?;
|
||||
let zero = u32s(fb, 1, 0)?;
|
||||
fb.binary(BinOp::INotEqual, w, zero)
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether texel `texel` of level `level` and slice `slice` is in a mapped tile of `map`, as
|
||||
/// `pipeline::tile_map` decodes it, through [`TileLevel`].
|
||||
pub(crate) fn tile_mapped(
|
||||
fb: &mut FunctionBuilder<'_>,
|
||||
map: crate::memory::views::View,
|
||||
texel: [SValue; 3],
|
||||
level: SValue,
|
||||
slice: SValue,
|
||||
) -> BResult<SValue> {
|
||||
let l = TileLevel::new(fb, map, level, slice)?;
|
||||
let [x, y, z] = texel;
|
||||
let tiles = [l.tile(fb, 0, x)?, l.tile(fb, 1, y)?, l.tile(fb, 2, z)?];
|
||||
l.mapped(fb, tiles)
|
||||
}
|
||||
|
||||
/// The status word of an access of texel `texel` of level `level` and slice `slice` on a slot
|
||||
/// with a tile-map arm, under slot specialization `spec` (true: the bound texture is sparse): 1
|
||||
/// where the texel's tile is unmapped (bit 0 of Metal's word, `!sparse_color::resident()`), else 0;
|
||||
/// and 0 where the texture is not sparse, which reads no word of the map (a neutral buffer stands
|
||||
/// in for it).
|
||||
pub(crate) fn tiled_word(
|
||||
cx: &mut EmitCx<'_>,
|
||||
fb: &mut FunctionBuilder<'_>,
|
||||
spec: SValue,
|
||||
map: crate::memory::views::View,
|
||||
texel: [SValue; 3],
|
||||
level: SValue,
|
||||
slice: SValue,
|
||||
) -> BResult<SValue> {
|
||||
let sparse: ArmFn<'_, ()> = Box::new(move |fb, _| {
|
||||
let mapped = tile_mapped(fb, map, texel, level, slice)?;
|
||||
let zero = u32s(fb, 1, 0)?;
|
||||
let one = u32s(fb, 1, 1)?;
|
||||
let word = fb.select(mapped, zero, one)?;
|
||||
Ok(ArmEnd::FallThrough(vec![word]))
|
||||
});
|
||||
let plain: ArmFn<'_, ()> = Box::new(move |fb, _| {
|
||||
let word = u32s(fb, 1, 0)?;
|
||||
Ok(ArmEnd::FallThrough(vec![word]))
|
||||
});
|
||||
let Merged(merged) = fb.if_(&mut (), spec, sparse, Some(plain))?;
|
||||
match merged[..] {
|
||||
[word] => Ok(word),
|
||||
_ => Err(cx.fail("a tile-map arm without its word")),
|
||||
}
|
||||
}
|
||||
|
||||
/// The `{T, i8}` value of `texel` with status word `word` (0 where none is given), or the texel
|
||||
/// itself where `result` is no such struct.
|
||||
pub(crate) fn with_word(
|
||||
@@ -1875,20 +1611,17 @@ pub(crate) fn with_word(
|
||||
}
|
||||
|
||||
/// The texel a read hands the function, before a heap element's null handle zeroes it: the held
|
||||
/// texel, the heap element's liveness where the image is one, and the sparse arm's status word
|
||||
/// where the function observes it.
|
||||
/// texel, and the heap element's liveness where the image is one.
|
||||
struct ReadTexel {
|
||||
texel: SValue,
|
||||
live: Option<SValue>,
|
||||
word: Option<SValue>,
|
||||
}
|
||||
|
||||
fn read(cx: &mut EmitCx<'_>, fb: &mut FunctionBuilder<'_>, r: &Read) -> BResult<SValue> {
|
||||
let ReadTexel { texel, live, word } = read_texel(cx, fb, r)?;
|
||||
let ReadTexel { texel, live } = read_texel(cx, fb, r)?;
|
||||
let texel = live_or_zero(fb, live, texel)?;
|
||||
// `{T, i8}`: the status word is the sparse arm's where the function observes it, else 0,
|
||||
// Metal's for a resident access.
|
||||
with_word(cx, fb, &r.result, texel, word)
|
||||
// `{T, i8}`: the status word is 0, Metal's for a resident access.
|
||||
with_word(cx, fb, &r.result, texel, None)
|
||||
}
|
||||
|
||||
/// [`read`]'s texel ([`ReadTexel`]).
|
||||
@@ -2039,11 +1772,7 @@ fn read_texel(cx: &mut EmitCx<'_>, fb: &mut FunctionBuilder<'_>, r: &Read) -> BR
|
||||
let oob = out_of_bounds_texel(cx, fb, &decl, &r.image, r.alpha, flagged)?;
|
||||
let texel = fb.select(inb, texel, oob)?;
|
||||
let texel = from_image(fb, &decl, r.texel, texel)?;
|
||||
return Ok(ReadTexel {
|
||||
texel,
|
||||
live,
|
||||
word: None,
|
||||
});
|
||||
return Ok(ReadTexel { texel, live });
|
||||
}
|
||||
let plain = match (volume, r.through) {
|
||||
(true, _) => Some(u32s(fb, coord_len(&decl), 0)?),
|
||||
@@ -2060,10 +1789,6 @@ fn read_texel(cx: &mut EmitCx<'_>, fb: &mut FunctionBuilder<'_>, r: &Read) -> BR
|
||||
None => None,
|
||||
};
|
||||
let sampled = decl.usage == ImageUsage::Sampled;
|
||||
let spec = match r.image {
|
||||
ImageRef::Slot(index) => sparse_spec(cx, index, r.residency),
|
||||
ImageRef::Heap { .. } => None,
|
||||
};
|
||||
// A read through a sampler is addressed by the sampler's state (`through::address`): its level
|
||||
// and plane coordinate are the image's, so only its layer or sample index can be out of
|
||||
// bounds as a plain read's; past its level or layer it hands back zero, and outside on a
|
||||
@@ -2079,12 +1804,11 @@ fn read_texel(cx: &mut EmitCx<'_>, fb: &mut FunctionBuilder<'_>, r: &Read) -> BR
|
||||
(None, None) => return Err(cx.fail("a read without its coordinate")),
|
||||
};
|
||||
// Whether every operand of the access is in range: under the shader's check, each operand is
|
||||
// then clamped into the image so the access stays inside it; under a sparse arm, the test
|
||||
// decides the status word alone, the access left to the device's robustness otherwise. A
|
||||
// read through a sampler is tested as it accesses, with its addressed coordinate against the
|
||||
// size at its level, so only its layer or sample index can fail.
|
||||
// then clamped into the image so the access stays inside it. A read through a sampler is
|
||||
// tested as it accesses, with its addressed coordinate against the size at its level, so only
|
||||
// its layer or sample index can fail.
|
||||
let mut in_range = None;
|
||||
if (r.checked() || spec.is_some()) && !volume {
|
||||
if r.checked() && !volume {
|
||||
let size = match (&through, level) {
|
||||
// The size at the level the read through a sampler accesses, which is the image's.
|
||||
(Some((_, a)), _) => a.size,
|
||||
@@ -2094,9 +1818,7 @@ fn read_texel(cx: &mut EmitCx<'_>, fb: &mut FunctionBuilder<'_>, r: &Read) -> BR
|
||||
in_range = Some(and(fb, in_range, ok)?);
|
||||
// A size query's level must be the image's, so it reads the clamped one.
|
||||
let clamped = clamp_below(fb, l, levels, 1)?;
|
||||
if r.checked() {
|
||||
level = Some(clamped);
|
||||
}
|
||||
level = Some(clamped);
|
||||
fb.query(ImageQuery::SizeLod(clamped), img)?
|
||||
}
|
||||
(None, _) => fb.query(ImageQuery::Size, img)?,
|
||||
@@ -2105,16 +1827,12 @@ fn read_texel(cx: &mut EmitCx<'_>, fb: &mut FunctionBuilder<'_>, r: &Read) -> BR
|
||||
let lt = fb.binary(BinOp::ULessThan, coord, size)?;
|
||||
let ok = if n == 1 { lt } else { fb.unary(UnOp::All, lt)? };
|
||||
in_range = Some(and(fb, in_range, ok)?);
|
||||
if r.checked() {
|
||||
coord = clamp_below(fb, coord, size, n)?;
|
||||
}
|
||||
coord = clamp_below(fb, coord, size, n)?;
|
||||
if let Some(s) = sample {
|
||||
let samples = fb.query(ImageQuery::Samples, img)?;
|
||||
let ok = fb.binary(BinOp::ULessThan, s, samples)?;
|
||||
in_range = Some(and(fb, in_range, ok)?);
|
||||
if r.checked() {
|
||||
sample = Some(clamp_below(fb, s, samples, 1)?);
|
||||
}
|
||||
sample = Some(clamp_below(fb, s, samples, 1)?);
|
||||
}
|
||||
}
|
||||
// A level the bound texture lacks is out of bounds whatever the device's robustness: the
|
||||
@@ -2146,64 +1864,9 @@ fn read_texel(cx: &mut EmitCx<'_>, fb: &mut FunctionBuilder<'_>, r: &Read) -> BR
|
||||
} else {
|
||||
texel_memory(cx, fb, &r.image, r.coherent)?
|
||||
};
|
||||
let access = move |fb: &mut FunctionBuilder<'_>, sparse: bool| -> BResult<SValue> {
|
||||
match (sampled, sparse) {
|
||||
(true, false) => fb.fetch(img, coord, &ops),
|
||||
(true, true) => fb.sparse_fetch(img, coord, &ops),
|
||||
(false, false) => fb.read(img, coord, &ops, mem),
|
||||
(false, true) => fb.sparse_read(img, coord, &ops, mem),
|
||||
}
|
||||
};
|
||||
let tiled = match r.image {
|
||||
ImageRef::Slot(index) if spec.is_some() => tile_map(cx, index),
|
||||
_ => None,
|
||||
};
|
||||
let mut inb = inb;
|
||||
let (texel, word) = match spec {
|
||||
Some(spec) => {
|
||||
let (texel, word) = match tiled {
|
||||
// A tile map: the plain access of the ordinary image, whose unmapped texels the
|
||||
// consumer keeps at zero, and the residency of the texel's tile.
|
||||
Some(map) => {
|
||||
let texel = access(fb, false)?;
|
||||
let at = match (level, view) {
|
||||
(Some(l), _) => l,
|
||||
(None, Some(v)) => cx.operand(fb, v)?,
|
||||
(None, None) => u32s(fb, 1, 0)?,
|
||||
};
|
||||
let (xyz, slice) = tile_parts(fb, &decl, coord)?;
|
||||
(texel, tiled_word(cx, fb, spec, map, xyz, at, slice)?)
|
||||
}
|
||||
None => resident_access(cx, fb, spec, access)?,
|
||||
};
|
||||
// A read outside the image is resident, as Metal answers for every texture, sparse or
|
||||
// not, mapped or not: a device's code for it is not Vulkan's to state (lavapipe reports
|
||||
// it not resident), and the shader's clamp would read another texel's.
|
||||
let resident = match (r.checked(), in_range, within) {
|
||||
// The shader's own test.
|
||||
(true, ..) => inb,
|
||||
(false, Some(ok), Some(w)) => Some(fb.binary(BinOp::LogicalAnd, ok, w)?),
|
||||
(false, Some(ok), None) => Some(ok),
|
||||
(false, None, w) => w,
|
||||
};
|
||||
let word = match resident {
|
||||
Some(ok) => {
|
||||
let zero = u32s(fb, 1, 0)?;
|
||||
fb.select(ok, word, zero)?
|
||||
}
|
||||
None => word,
|
||||
};
|
||||
// A texel that is not resident reads Metal's unmapped value: zero memory as the
|
||||
// bound format reads it, the out-of-bounds texel. Under the sparse arm a device reads
|
||||
// that only under `residencyNonResidentStrict`; under a tile map the image holds it,
|
||||
// but where the texture is a sparse image, a block of it that holds no mapped tile
|
||||
// reads the device's value.
|
||||
let zero = u32s(fb, 1, 0)?;
|
||||
let kept = fb.binary(BinOp::IEqual, word, zero)?;
|
||||
inb = Some(and(fb, inb, kept)?);
|
||||
(texel, Some(word))
|
||||
}
|
||||
None => (access(fb, false)?, None),
|
||||
let texel = match sampled {
|
||||
true => fb.fetch(img, coord, &ops)?,
|
||||
false => fb.read(img, coord, &ops, mem)?,
|
||||
};
|
||||
// An extended-range texel's value, decoded from its raw code before Metal's out-of-bounds
|
||||
// texel is selected.
|
||||
@@ -2237,7 +1900,7 @@ fn read_texel(cx: &mut EmitCx<'_>, fb: &mut FunctionBuilder<'_>, r: &Read) -> BR
|
||||
Some((state, a)) => through::finish(cx, fb, r, (state, a), texel, None)?,
|
||||
None => texel,
|
||||
};
|
||||
Ok(ReadTexel { texel, live, word })
|
||||
Ok(ReadTexel { texel, live })
|
||||
}
|
||||
|
||||
fn write(cx: &mut EmitCx<'_>, fb: &mut FunctionBuilder<'_>, w: &Write) -> BResult<()> {
|
||||
@@ -2275,9 +1938,6 @@ fn write(cx: &mut EmitCx<'_>, fb: &mut FunctionBuilder<'_>, w: &Write) -> BResul
|
||||
// An integer texel's lanes, saturated to the format's channels as Metal stores them.
|
||||
let texel = saturated(cx, fb, &decl, (w.saturate, w.texel), texel)?;
|
||||
let mem = texel_memory(cx, fb, &w.image, w.coherent)?;
|
||||
// A write to a sparse texture is dropped.
|
||||
let kept = sparse_writes_kept(cx, fb, &w.image)?;
|
||||
let within = and_kept(fb, within, kept)?;
|
||||
if let Some((_, stored)) = volume {
|
||||
let mut cond = stored;
|
||||
for c in [live, within].into_iter().flatten() {
|
||||
@@ -2447,11 +2107,8 @@ fn slice_cells<'c>(cx: &mut EmitCx<'c>, fb: &mut FunctionBuilder<'_>, s: &Slice)
|
||||
within,
|
||||
..
|
||||
} = image(cx, fb, &s.image, s.level)?;
|
||||
// A write through the null heap element, at a level the texture lacks, or to a sparse texture
|
||||
// is dropped.
|
||||
// A write through the null heap element, or at a level the texture lacks, is dropped.
|
||||
let within = and_kept(fb, live, within)?;
|
||||
let kept = sparse_writes_kept(cx, fb, &s.image)?;
|
||||
let within = and_kept(fb, within, kept)?;
|
||||
let origin = coordinate(cx, fb, &decl, &s.at)?;
|
||||
let (w, h) = imageblock::extent(fb)?;
|
||||
let (bw, bh) = match s.size {
|
||||
|
||||
@@ -136,10 +136,13 @@
|
||||
//! set when the access touched a texel that is not resident, the only bit MSL reads
|
||||
//! (`sparse_color::resident()`). A word nothing observes is built as 0; its texel may be taken
|
||||
//! through `phi`, `select`, and `freeze` copies of the whole result. A word whose effects depend on
|
||||
//! bit 0 alone (`status::observed`'s demanded bits) is 0, resident, of a slot and a heap element
|
||||
//! alike ([`residency`]): a texture that is not sparse is resident throughout, and the consumer
|
||||
//! refuses every sparse texture. A word with another bit observed, or a whole `{T, i8}` value
|
||||
//! exposed, is refused.
|
||||
//! bit 0 alone (`status::observed`'s demanded bits) is 0 too, resident, of a slot and a heap
|
||||
//! element alike: a texture that is not sparse is resident throughout, and the runtime makes no
|
||||
//! sparse texture. Over a texture that is not sparse, Metal's `sparse_sample`, `sparse_gather` and
|
||||
//! `sparse_read` answer resident on the M3 Max (macOS 27.0.1) and the Radeon Pro 5300M (macOS
|
||||
//! 26.7.1), and not resident on the UHD Graphics 630 (macOS 26.7.1), each with the texel's colour:
|
||||
//! both answers are Metal's, and the word is the first. A word with another bit observed, or a
|
||||
//! whole `{T, i8}` value exposed, is refused.
|
||||
//!
|
||||
//! **Atomics** (`atomic`). `atomic_fetch_max` is `OpAtomic{U,S}Max` on the texel pointer of an
|
||||
//! `R32ui` / `R32i` storage image; only lane 0 of its result may be read.
|
||||
@@ -305,10 +308,6 @@ pub struct Read {
|
||||
pub texel: TexelForm,
|
||||
/// The result is `{T, i8}`, with this lowered type.
|
||||
pub result: DemoteTy,
|
||||
/// The function observes bit 0 of the result's status word: on a slot with a sparse arm the
|
||||
/// word is the sparse read's under the slot's `SparseTexture` specialization; otherwise it is
|
||||
/// 0, a texture that is not sparse being resident everywhere.
|
||||
pub residency: bool,
|
||||
/// How an out-of-bounds read returns Metal's texel.
|
||||
pub check: ReadCheck,
|
||||
/// Where the shader selects the out-of-bounds texel (under [`ReadCheck::Shader`], or past a
|
||||
@@ -341,18 +340,12 @@ pub struct Read {
|
||||
/// The estimated words of read `r`: coordinate assembly, the access, the texel conversion, and the
|
||||
/// status composite; the clamps, the in-bounds test, and the out-of-bounds select (with its
|
||||
/// alpha); the level views' count, index clamp, level test, and select; a heap element's access
|
||||
/// chain, load, and null select or guard; the sparse arm ([`RESIDENCY_WORDS`]) and the word's
|
||||
/// select outside the image, with its own in-bounds test where the shader has none; a read
|
||||
/// through a sampler's addressing ([`Through::words`]), and a heap element's border texels from
|
||||
/// the word its handle carries (a shift and two masks, with their constants); and a `half`
|
||||
/// texel's exact rounding, or an sRGB texel's raw decode.
|
||||
/// chain, load, and null select or guard; a read through a sampler's addressing
|
||||
/// ([`Through::words`]), and a heap element's border texels from the word its handle carries (a
|
||||
/// shift and two masks, with their constants); and a `half` texel's exact rounding, or an sRGB
|
||||
/// texel's raw decode.
|
||||
fn read_words(r: &Read) -> u32 {
|
||||
64 + if r.checked() { 80 } else { 0 }
|
||||
+ if r.residency {
|
||||
RESIDENCY_WORDS + if r.checked() { 8 } else { 48 }
|
||||
} else {
|
||||
0
|
||||
}
|
||||
+ if r.alpha { 12 } else { 0 }
|
||||
+ if r.level_views { 48 } else { 0 }
|
||||
+ if r.image.heap() { 32 } else { 0 }
|
||||
@@ -729,15 +722,9 @@ impl Switch {
|
||||
|
||||
impl FamilyStrategy for TextureStrategy {
|
||||
/// A read, write, atomic, or query names the in-shader check it takes (`_clamped`,
|
||||
/// `_guarded`) on a slot, a heap element (`.heap`), or a switch's arms (`.switch`); a read or
|
||||
/// sampling operation whose status word the function observes adds `.resident`.
|
||||
/// `_guarded`) on a slot, a heap element (`.heap`), or a switch's arms (`.switch`).
|
||||
fn name(&self, _: &FamilyPlans) -> Cow<'static, str> {
|
||||
let name = self.base_name();
|
||||
if self.residency() {
|
||||
Cow::Owned(format!("{name}.resident"))
|
||||
} else {
|
||||
name
|
||||
}
|
||||
self.base_name()
|
||||
}
|
||||
|
||||
fn words(&self) -> u32 {
|
||||
@@ -746,18 +733,7 @@ impl FamilyStrategy for TextureStrategy {
|
||||
}
|
||||
|
||||
impl TextureStrategy {
|
||||
/// Whether the function observes the status word of this operation (or of a switch's arm):
|
||||
/// its residency.
|
||||
fn residency(&self) -> bool {
|
||||
match self {
|
||||
TextureStrategy::Read(r) => r.residency,
|
||||
TextureStrategy::Sampling(s) => s.residency,
|
||||
TextureStrategy::Switch(s) => s.arms.iter().any(|(_, a)| a.residency()),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
/// The census name without the residency suffix.
|
||||
/// The census name ([`FamilyStrategy::name`]).
|
||||
fn base_name(&self) -> Cow<'static, str> {
|
||||
Cow::Borrowed(match self {
|
||||
TextureStrategy::Read(r) if r.image.heap() && r.checked() => {
|
||||
@@ -839,10 +815,6 @@ impl TextureStrategy {
|
||||
}
|
||||
}
|
||||
|
||||
/// The words of an access's sparse arm: the specialized branch, the sparse access, its two
|
||||
/// extractions, `OpImageSparseTexelsResident`, the word's select, and the merge's two phis.
|
||||
pub(crate) const RESIDENCY_WORDS: u32 = 48;
|
||||
|
||||
/// The texture family's part of the per-function plan (`select::FamilyPlans`).
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq)]
|
||||
pub struct TexturePlan {
|
||||
@@ -905,12 +877,6 @@ pub struct Declared {
|
||||
pub images: BTreeMap<u32, (GlobalId, TypeId)>,
|
||||
/// The set-1 heap array of each declared heap class.
|
||||
pub heap: BTreeMap<ImageHandleClass, GlobalId>,
|
||||
/// The `SparseTexture` specialization constant of each slot with a sparse arm or a tile-map
|
||||
/// arm.
|
||||
pub sparse: BTreeMap<u32, SValue>,
|
||||
/// The tile map of each slot with a tile-map arm: a word view of its `ResourceKind::TileMap`
|
||||
/// binding.
|
||||
pub tile_maps: BTreeMap<u32, crate::memory::views::View>,
|
||||
/// The `TextureSwizzle` specialization constant of each texture buffer slot whose reads
|
||||
/// apply the bound texture buffer's swizzle, and of each storage slot of
|
||||
/// `LoweringInputs::swizzled_storage` whose reads and writes apply the bound texture's, or
|
||||
@@ -1107,21 +1073,6 @@ fn status_use(cx: &mut SelectCx<'_>, at: InstId) -> Option<StatusUse> {
|
||||
.and_then(|s| s.get(&at).copied())
|
||||
}
|
||||
|
||||
/// Whether texture call `at` takes a residency form, which none does: where the function observes
|
||||
/// bit 0 of its status word alone, the word is 0 (`sparse_color::resident()` true), of a slot and
|
||||
/// a heap element alike. A texture that is not sparse is resident throughout, and the consumer
|
||||
/// refuses every sparse texture. Over a texture that is not sparse, Metal's `sparse_sample`,
|
||||
/// `sparse_gather` and `sparse_read` answer resident on the M3 Max (macOS 27.0.1) and the Radeon
|
||||
/// Pro 5300M (macOS 26.7.1), and not resident on the UHD Graphics 630 (macOS 26.7.1), each with the
|
||||
/// texel's colour: both answers are Metal's, and the word is the first. A word with another bit
|
||||
/// observed is refused.
|
||||
pub(crate) fn residency(cx: &mut SelectCx<'_>, at: InstId, _: ImageRef) -> Result<bool, Error> {
|
||||
match status_use(cx, at) {
|
||||
None | Some(StatusUse::Residency) => Ok(false),
|
||||
Some(StatusUse::Other) => Err(refuse()),
|
||||
}
|
||||
}
|
||||
|
||||
/// Record what a read, gather, or sample of `image`, of shape `shape`, with a `float` result that
|
||||
/// may read one texel (`one`) answers: the device's conversion of the texel's codes,
|
||||
/// `PrecisionNote::DeviceTexelConversion`; of a heap's texture buffer, which no class reaches, a
|
||||
@@ -1294,8 +1245,9 @@ pub fn select(
|
||||
.get(TexRole::Texture)
|
||||
.ok_or_else(|| cx.invariant("a texture operation without a texture"))?;
|
||||
// A status word with a bit other than residency observed, or a whole `{T, i8}` value
|
||||
// exposed, is not established, whatever the texture. The null texture's word is 0, as its texel
|
||||
// is (the null arm, Q7).
|
||||
// exposed, is not established, whatever the texture. One observed for its residency alone is
|
||||
// 0, resident (the module docs). The null texture's word is 0, as its texel is (the null arm,
|
||||
// Q7).
|
||||
if status_use(cx, at) == Some(StatusUse::Other) {
|
||||
return Err(refuse());
|
||||
}
|
||||
@@ -1307,11 +1259,7 @@ pub fn select(
|
||||
return slice::select(cx, (at, t), &ops, ImageRef::Heap { group, handle }, m);
|
||||
}
|
||||
if sampling {
|
||||
// The heap element through a separate heap sampler; its residency is the stage's
|
||||
// `HeapResidency` (an LOD query returns a plain float).
|
||||
if !matches!(t.op, TexOp::CalculateLod { .. }) {
|
||||
residency(cx, at, ImageRef::Heap { group, handle })?;
|
||||
}
|
||||
// The heap element through a separate heap sampler.
|
||||
return crate::lower::sampler::select_heap_sampling(
|
||||
cx, at, inst, t, &call.args, group, handle, m,
|
||||
);
|
||||
@@ -2040,7 +1988,6 @@ fn select_read(
|
||||
if let Some(t) = through {
|
||||
select_through(cx, image, texel, t)?;
|
||||
}
|
||||
let residency = residency(cx, at, image)?;
|
||||
let (storage, write_only) = image_access(cx, image)?;
|
||||
if write_only {
|
||||
return Err(refuse());
|
||||
@@ -2065,9 +2012,6 @@ fn select_read(
|
||||
// An extended-range texel is decoded from its raw code, so the device's out-of-bounds texel
|
||||
// (raw zero) is not Metal's (zero, measured): the shader selects it.
|
||||
let extended = extended_range(cx, image)?;
|
||||
if extended.is_some() && residency {
|
||||
return Err(Unsupported::not_implemented(Feature::Format).into());
|
||||
}
|
||||
// A slot's read that samples its cube element is clamped by the sample, never left to the
|
||||
// device's robustness.
|
||||
let cube_element =
|
||||
@@ -2086,10 +2030,7 @@ fn select_read(
|
||||
}
|
||||
// Metal's out-of-bounds alpha is the bound format's (1 where it has none): a read the shader
|
||||
// checks, or tests against its level views, whose alpha the function observes takes it from the
|
||||
// slot's resource ID's word, or from a heap element's handle. So does one whose
|
||||
// residency it observes, under either of its slot's arms: a texel that is not resident reads
|
||||
// Metal's unmapped value, zero memory as the bound format reads it, which is the out-of-bounds
|
||||
// texel, where a device's block that holds no mapped tile reads the device's value. A texture
|
||||
// slot's resource ID's word, or from a heap element's handle. A texture
|
||||
// buffer's swizzle applies to its reads: Metal returns each channel from the source the bound
|
||||
// A storage slot bound to a swizzled texture applies the swizzle under its variant, to the
|
||||
// converted texel, out of bounds too, as plain Metal reads it. A `ulong` texel's swizzle, and a
|
||||
@@ -2103,7 +2044,7 @@ fn select_read(
|
||||
// A `ulong` read's lanes past the first are Metal's constants `(0, 0, 1)` in and out of
|
||||
// bounds, never the image's. A swizzled read may return the alpha in any lane, so it observes
|
||||
// the alpha wherever the function reads a lane.
|
||||
let observed = (check == ReadCheck::Shader || level_views || residency)
|
||||
let observed = (check == ReadCheck::Shader || level_views)
|
||||
&& texel.lanes == 4
|
||||
&& !matches!(texel.conv, TexelConv::U64Words)
|
||||
&& (storage_swizzle || alpha_read(cx, at));
|
||||
@@ -2168,7 +2109,6 @@ fn select_read(
|
||||
sample,
|
||||
texel,
|
||||
result,
|
||||
residency,
|
||||
check,
|
||||
alpha,
|
||||
through,
|
||||
|
||||
@@ -69,16 +69,6 @@ pub struct Uses {
|
||||
pub top_level: u64,
|
||||
/// Its level count is queried (`get_num_mip_levels` of a storage texture).
|
||||
pub levels: bool,
|
||||
/// An access's residency is observed (bit 0 of its status word).
|
||||
pub residency: bool,
|
||||
/// One of those accesses has no sparse form (a bicubic sample's fetches): the slot takes no
|
||||
/// sparse arm, and the binder refuses a sparse texture at it.
|
||||
pub plain_residency: bool,
|
||||
/// One of those accesses has no answer from a tile map: a sample or gather whose footprint the
|
||||
/// device's filter decides (Metal's rule does not), or a bicubic sample. The slot takes no
|
||||
/// tile-map arm: the sparse arm where the device enables `shaderResourceResidency`, and
|
||||
/// elsewhere the binder refuses a sparse texture at it.
|
||||
pub untiled_residency: bool,
|
||||
/// A cube's texels are fetched by face (an emulated linear cube sample): the slot is declared
|
||||
/// as the binder's 2D-array view of its faces.
|
||||
pub faces: bool,
|
||||
@@ -174,16 +164,6 @@ pub struct SlotPlan {
|
||||
/// 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`].
|
||||
pub volatile: bool,
|
||||
/// The slot's accesses whose residency is observed take their sparse forms under its
|
||||
/// `SparseTexture` specialization, set by [`finish`].
|
||||
pub sparse_arm: bool,
|
||||
/// The slot's accesses whose residency is observed answer it from the slot's tile map under
|
||||
/// its `SparseTexture` specialization, set by [`finish`]: on every profile, where the slot's
|
||||
/// type has a tile map and each observed access names its texels.
|
||||
pub tile_map: bool,
|
||||
/// The slot's writes are dropped under its `SparseTexture` specialization, as Metal drops a
|
||||
/// function's writes to a sparse texture, set by [`finish`].
|
||||
pub sparse_writes: bool,
|
||||
/// A read of the slot, a texture buffer, applies the bound texture buffer's swizzle, which
|
||||
/// the slot's `TextureSwizzle` specialization gives (`RuntimeFact::TextureSwizzle`); or the
|
||||
/// slot, a storage slot of `LoweringInputs::swizzled_storage`, applies the bound texture's to
|
||||
@@ -213,9 +193,6 @@ impl SlotPlan {
|
||||
oob_alpha: false,
|
||||
border_texels: false,
|
||||
volatile: false,
|
||||
sparse_arm: false,
|
||||
tile_map: false,
|
||||
sparse_writes: false,
|
||||
swizzle: false,
|
||||
offset_base: false,
|
||||
decl: None,
|
||||
@@ -1132,18 +1109,6 @@ fn declare_slot(
|
||||
})
|
||||
}
|
||||
|
||||
/// Whether a slot of `shape` can have a tile map: a single-sample 2D, 2D array, or 3D color texture
|
||||
/// (`pipeline::tile_map`), the sparse types the case model measures.
|
||||
fn tiled_shape(shape: ImageShape) -> bool {
|
||||
!shape.ms
|
||||
&& !shape.depth
|
||||
&& match shape.dim {
|
||||
ImageDim::D2 => true,
|
||||
ImageDim::D3 => !shape.array,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
/// The device compares a depth texture's texels (a sample or gather with comparison). Metal's
|
||||
/// `Depth32Float` texels hold any `float`, which a depth image keeps outside `[0, 1]` only under
|
||||
/// `VK_EXT_depth_range_unrestricted`, which no runtime enables: without it Vulkan takes no such
|
||||
@@ -1239,44 +1204,6 @@ pub fn finish(cx: &mut SelectCx<'_>) -> Result<(), Error> {
|
||||
h.volatile = volatile_classes.contains(&class);
|
||||
}
|
||||
}
|
||||
// The slots whose accesses observe residency, and the binder states whether its bound texture
|
||||
// is sparse. On every device, a slot of a type with a tile map whose observed accesses each
|
||||
// name their texels (reads, fetches, a pixel sampler's fetch, a sample or gather with Metal's
|
||||
// footprint) has a tile-map arm: the residency of those texels' tiles, Metal's whatever the
|
||||
// device's sparse blocks. Any other slot has a sparse arm where the profile enables
|
||||
// `shaderResourceResidency` and every such access has a sparse form (a texel buffer is never
|
||||
// sparse): the residency of the device's blocks. A slot the function updates atomically has
|
||||
// neither, and the binder refuses a sparse texture there: Metal's answer to a texture atomic on
|
||||
// one is not deterministic.
|
||||
let residency = cx
|
||||
.profile
|
||||
.fields()
|
||||
.enabled
|
||||
.features
|
||||
.contains(&VkFeature::ShaderResourceResidency);
|
||||
let mut sparse = Vec::new();
|
||||
for (index, s) in &cx.families.texture.slots {
|
||||
if !s.uses.residency {
|
||||
continue;
|
||||
}
|
||||
let buffer = s.shape.is_some_and(|x| x.dim == ImageDim::Buffer);
|
||||
let atomic = s.uses.atomic;
|
||||
let tile_map = !s.uses.untiled_residency && !atomic && s.shape.is_some_and(tiled_shape);
|
||||
let sparse_arm = residency && !tile_map && !s.uses.plain_residency && !buffer && !atomic;
|
||||
facts.push(RuntimeFact::SparseTexture {
|
||||
slot: s.slot,
|
||||
sparse_arm,
|
||||
tile_map,
|
||||
});
|
||||
sparse.push((*index, sparse_arm, tile_map));
|
||||
}
|
||||
for (index, sparse_arm, tile_map) in sparse {
|
||||
if let Some(s) = cx.families.texture.slots.get_mut(&index) {
|
||||
s.sparse_arm = sparse_arm;
|
||||
s.tile_map = tile_map;
|
||||
}
|
||||
}
|
||||
// No texture is sparse (the consumer refuses one), so no write is dropped.
|
||||
for (index, d) in decls {
|
||||
// A write of an 8-bit sRGB format's codes encodes by the device's conversion
|
||||
// (`emit::srgb_codes`, `pack::pack`'s `unorm4x8_srgb`), where Metal encodes through its
|
||||
@@ -1315,15 +1242,10 @@ 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, its format's missing
|
||||
/// alpha and its border texels). A conversion by the bound format, a swizzle, sparse
|
||||
/// residency and offset bases each read a constant or a binding the slot does
|
||||
/// not have there yet.
|
||||
/// alpha and its border texels). A conversion by the bound format, a swizzle 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.sparse_arm
|
||||
|| self.tile_map
|
||||
|| self.sparse_writes
|
||||
|| self.swizzle
|
||||
|| self.offset_base;
|
||||
let state = self.swizzle || self.offset_base;
|
||||
!state
|
||||
&& self
|
||||
.decl
|
||||
|
||||
@@ -598,29 +598,6 @@ pub enum PrecisionNote {
|
||||
/// The note's class is unbounded: a lane that differs for any of these reasons is reported
|
||||
/// as explained, never accepted as a match.
|
||||
BicubicFilterArithmetic,
|
||||
/// A stage samples or gathers a texture whose residency it observes
|
||||
/// (`sparse_color::resident()`) through the slot's sparse form, which the module has where the
|
||||
/// profile enables `shaderResourceResidency`. Metal's status word is measured: every access of
|
||||
/// a texture that is not sparse is resident, inside it or outside; a read outside any texture
|
||||
/// is resident; and an access of a sparse texture is not resident where a texel it counts is
|
||||
/// unmapped, which reads zero memory (the out-of-bounds texel: zero, alpha 1 where the format
|
||||
/// has none). The module answers all of that exactly for reads, on every device. A pixel
|
||||
/// fetch reads Metal's value too: where the bound texture is a sparse image, a texel the word
|
||||
/// says is unmapped reads zero; none of them is noted. A sample's or gather's residency is the device's, noted: the word is
|
||||
/// the device's `OpImageSparse*` residency, whose footprint may count a texel of zero weight
|
||||
/// Metal does not (Vulkan's linear 2x2 footprint does, measured on lavapipe), and may call a
|
||||
/// footprint of the border alone (a `clamp_to_border` access wholly outside the texture)
|
||||
/// not resident where Metal answers resident (lavapipe does, by nearest, linear and gather
|
||||
/// sampling, beside a mapped edge too; Vulkan states only whether a texel accessed is a sparse
|
||||
/// unbound texel), and its lanes
|
||||
/// that are no constants over a texel in a block of a sparse image that holds no mapped tile
|
||||
/// are the device's non-resident value (zero on a device with `residencyNonResidentStrict`;
|
||||
/// any value elsewhere). Where the
|
||||
/// profile does not enable `shaderResourceResidency` the device has no residency of its own and
|
||||
/// nothing is noted: the bound image holds Metal's unmapped value, and the slot's tile map
|
||||
/// answers the word, by Metal's measured footprint rule for a sample or gather through a
|
||||
/// constexpr sampler (`lower::sampler::footprint`), exactly.
|
||||
SparseResidency,
|
||||
/// A `float` NaN result's bit pattern follows the device: Metal answers the canonical
|
||||
/// `0x7fc00000` for the NaN results of its float arithmetic and functions, and Vulkan states no
|
||||
/// encoding, so a device may answer another sign or payload (llvmpipe: `0xffc00000`). Recorded
|
||||
@@ -2057,7 +2034,6 @@ impl PrecisionNote {
|
||||
PrecisionNote::BicubicFilterArithmetic => {
|
||||
"metal2vulkan-degrade-bicubic-filter-arithmetic"
|
||||
}
|
||||
PrecisionNote::SparseResidency => "metal2vulkan-degrade-sparse-residency",
|
||||
PrecisionNote::DeviceNanEncoding => "metal2vulkan-degrade-device-nan-encoding",
|
||||
PrecisionNote::RestrictedDepthRange => "metal2vulkan-degrade-restricted-depth-range",
|
||||
PrecisionNote::CubeGradientFootprint => "metal2vulkan-degrade-cube-gradient-footprint",
|
||||
|
||||
@@ -122,36 +122,6 @@ pub enum RuntimeFact {
|
||||
/// holds as many elements as a texture of the slot's type can have levels on the device; the
|
||||
/// binder refuses a texture with more.
|
||||
StorageTextureLevelViews { slot: SlotRef },
|
||||
/// The function observes the residency of its reads, samples, or gathers of the texture
|
||||
/// bound to the slot: bit 0 of their `{T, i8}` status word, MSL's
|
||||
/// `sparse_color::resident()`. Whether that texture is sparse is a fact of the bound texture
|
||||
/// (`MTLTexture.isSparse`, `bind::TextureFacts::sparse`). A texture that is not sparse is
|
||||
/// resident everywhere, and the status word Metal returns for it is compiled in, exact on
|
||||
/// every device. `sparse_arm`: the module also answers a sparse texture, with the device's
|
||||
/// sparse residency (`OpImageSparse*` and `OpImageSparseTexelsResident` under
|
||||
/// `shaderResourceResidency`), selected by `SpecKey::SparseTexture`. Without it a sparse
|
||||
/// texture at the slot is refused (`Unsupported`): naming
|
||||
/// `shaderResourceResidency` where the device lacks it, `NotImplemented` where one of the
|
||||
/// slot's accesses has no sparse form (a bicubic sample), and `NotRepresentable` where the
|
||||
/// function updates the slot atomically (`SparseTextureWrites`). A slot the function writes
|
||||
/// takes either arm, its writes dropped.
|
||||
///
|
||||
/// `tile_map` (on every device): where the slot's type has a tile map (a single-sample 2D, 2D
|
||||
/// array or 3D color texture) and each observed access names its texels, the module answers a
|
||||
/// sparse texture from the slot's tile map instead (`ResourceKind::TileMap`,
|
||||
/// `pipeline::tile_map`), selected by the same `SpecKey::SparseTexture`: each access is the
|
||||
/// plain one, its residency the bits of the tiles it reads (for a sample or gather, the texels
|
||||
/// Metal's footprint rule counts), and a read of a texel that is not resident Metal's unmapped
|
||||
/// value, the out-of-bounds texel. At most one of `sparse_arm` and `tile_map` holds:
|
||||
/// `sparse_arm` only where the slot has no tile map. With neither, the binder refuses a sparse
|
||||
/// texture at the slot as above (an access the tile map does not answer on a device without
|
||||
/// `shaderResourceResidency`: a filtered sample or a gather outside Metal's measured rule, or a
|
||||
/// slot updated atomically).
|
||||
SparseTexture {
|
||||
slot: SlotRef,
|
||||
sparse_arm: bool,
|
||||
tile_map: bool,
|
||||
},
|
||||
/// The function reads the instance count of the instance acceleration structure bound at the
|
||||
/// buffer slot (`get_instance_count()`, `PushField::InstanceCount`): no Vulkan instruction
|
||||
/// reads a structure's instance count, and the consumer that built the Metal structure knows
|
||||
@@ -447,7 +417,6 @@ impl RuntimeFact {
|
||||
RuntimeFact::OutOfBoundsAlpha { .. } => "OutOfBoundsAlpha",
|
||||
RuntimeFact::StorageTextureLevels { .. } => "StorageTextureLevels",
|
||||
RuntimeFact::StorageTextureLevelViews { .. } => "StorageTextureLevelViews",
|
||||
RuntimeFact::SparseTexture { .. } => "SparseTexture",
|
||||
RuntimeFact::AccelerationStructureInstanceCount { .. } => {
|
||||
"AccelerationStructureInstanceCount"
|
||||
}
|
||||
|
||||
@@ -84,9 +84,6 @@ pub enum BindingSource {
|
||||
},
|
||||
/// A tile function's color attachment of this color index, bound as a storage image.
|
||||
TileAttachment(u32),
|
||||
/// The tile map of the sparse texture bound at a Metal `[[texture(n)]]` slot, a read-only
|
||||
/// storage buffer (`pipeline::tile_map`).
|
||||
TileMap(SlotRef),
|
||||
}
|
||||
|
||||
/// One push-constant range of a [`PipelineLayout`]: a stage's fixed window (vertex `[0, 64)`,
|
||||
|
||||
@@ -635,7 +635,6 @@ fn binding_source(slot: ResourceSlot) -> BindingSource {
|
||||
level,
|
||||
},
|
||||
ResourceKind::TileAttachment(color) => BindingSource::TileAttachment(color),
|
||||
ResourceKind::TileMap => BindingSource::TileMap(metal(SlotClass::Texture)),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -101,7 +101,6 @@ pub(crate) mod table;
|
||||
// Test support for the crate's tests.
|
||||
#[cfg(test)]
|
||||
pub(crate) mod testing;
|
||||
pub(crate) mod tile_map;
|
||||
pub(crate) mod vertex;
|
||||
|
||||
pub use artifact::{
|
||||
|
||||
@@ -200,11 +200,6 @@ pub enum ResourceKind {
|
||||
/// A tile function's color attachment of this color index, as a storage image the
|
||||
/// function's tile staging loads and stores.
|
||||
TileAttachment(u32),
|
||||
/// The tile map of the sparse texture bound at the stage's texture slot
|
||||
/// `ResourceSlot::index` (`pipeline::tile_map`): a read-only storage buffer of words from
|
||||
/// which a function answers the texture's residency where the device has no shader
|
||||
/// residency (`RuntimeFact::SparseTexture { tile_map: true, .. }`).
|
||||
TileMap,
|
||||
}
|
||||
|
||||
/// What a bound acceleration structure holds: the binder binds a top-level structure, so a
|
||||
@@ -389,9 +384,6 @@ pub enum SpecKey {
|
||||
/// texel out of bounds, with the format's missing components at their defaults
|
||||
/// (`RuntimeFact::OutOfBoundsAlpha`).
|
||||
OutOfBoundsAlpha(SlotRef),
|
||||
/// Boolean: the texture bound to the slot is sparse (`MTLTexture.isSparse`, default false),
|
||||
/// so its accesses that observe residency take the sparse form (`RuntimeFact::SparseTexture`).
|
||||
SparseTexture(SlotRef),
|
||||
/// The byte offset of a tile or fragment function's threadgroup argument `i` in its tile's
|
||||
/// threadgroup memory (`setThreadgroupMemoryLength:offset:atIndex:`, default 0).
|
||||
TgOffset(u32),
|
||||
|
||||
@@ -471,7 +471,7 @@ pub struct CoherentAccesses {
|
||||
pub buffer: usize,
|
||||
/// Loads and stores of an application word through a `PhysicalStorageBuffer` pointer.
|
||||
pub device_address: usize,
|
||||
/// `OpImageRead`, `OpImageSparseRead`, and `OpImageWrite` of a storage image.
|
||||
/// `OpImageRead` and `OpImageWrite` of a storage image.
|
||||
pub storage_image: usize,
|
||||
/// Those of them that carry `VolatileTexel` (a volatile image under the Vulkan model).
|
||||
pub volatile_texel: usize,
|
||||
@@ -555,7 +555,7 @@ pub fn interlocked_coherence(words: &[u32]) -> Result<CoherentAccesses, String>
|
||||
let (ptr, mask_at, load) = match op {
|
||||
Op::Load => (at(inst, 3)?, 4, true),
|
||||
Op::Store => (at(inst, 1)?, 3, false),
|
||||
Op::ImageRead | Op::ImageSparseRead | Op::ImageWrite => {
|
||||
Op::ImageRead | Op::ImageWrite => {
|
||||
let write = *op == Op::ImageWrite;
|
||||
let image = at(inst, if write { 1 } else { 3 })?;
|
||||
let ty = types.get(&image).copied().unwrap_or_default();
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
//! A sparse texture's tile map: the words a function reads to answer the residency of a sparse
|
||||
//! texture where the device has no shader residency.
|
||||
//!
|
||||
//! Metal maps a sparse texture's memory a tile at a time (`updateTextureMapping:mode:region:
|
||||
//! mipLevel:slice:` on an `MTLResourceStateCommandEncoder`), and a function reads whether the
|
||||
//! texels it touched were mapped (`sparse_color::resident()`). A Vulkan device without
|
||||
//! `shaderResourceResidency` cannot answer that from the image. The consumer then backs the
|
||||
//! texture with an ordinary image and keeps, beside it, a storage buffer with a bit per tile of
|
||||
//! each level and slice that is set while the tile is mapped. A module whose slot has the
|
||||
//! tile-map arm (`RuntimeFact::SparseTexture { tile_map: true, .. }`) reads it at the slot's
|
||||
//! `ResourceKind::TileMap` binding. The consumer builds the words, mirroring each mapping.
|
||||
//!
|
||||
//! **Format** (version 1): little-endian 32-bit words.
|
||||
//!
|
||||
//! | word | meaning |
|
||||
//! |---|---|
|
||||
//! | 0 | the format's version tag, `"M2T1"` read as a little-endian word |
|
||||
//! | 1, 2, 3 | the tile's width, height, and depth in texels (each at least 1) |
|
||||
//! | 4 | the slice count `S` (array layers; 1 for a 2D or 3D texture) |
|
||||
//! | 5 | `B`, the bits of one slice |
|
||||
//! | 6, 7 | 0 |
|
||||
//! | `8 + 4l + 0..4` | level `l < 16`: its first bit in a slice, its tiles across x, y, z |
|
||||
//! | [`BITS_WORD`]`..` | the bits: bit `b` is bit `b % 32` of word `BITS_WORD + b / 32` |
|
||||
//!
|
||||
//! A level in the texture's mip tail (from Metal's `firstMipmapInTail`) has one tile, the slice's
|
||||
//! tail bit, which every level of the tail shares: Metal maps and unmaps the tail as one unit. An
|
||||
//! entry past the texture's last level has one tile at bit 0.
|
||||
//!
|
||||
//! **Decoding**: the residency of texel `(x, y, z)` of level `l` and slice `s` is
|
||||
//! bit `min(s, S - 1)·B + base + (t_z·n_y + t_y)·n_x + t_x` of level `l' = min(l, 15)`, where
|
||||
//! `(base, n_x, n_y, n_z)` is that level's entry and `t_a = min(c_a / tile_a, n_a - 1)`. Every
|
||||
//! index is clamped into the words the format states, so a function reads no word past the map
|
||||
//! even for an access outside the texture (whose residency it answers from the coordinate alone).
|
||||
|
||||
/// Words 1, 2, 3: the tile's extent in texels.
|
||||
pub const TILE_WORD: u32 = 1;
|
||||
/// Word 4: the slice count.
|
||||
pub const SLICES_WORD: u32 = 4;
|
||||
/// Word 5: the bits of one slice.
|
||||
pub const SLICE_BITS_WORD: u32 = 5;
|
||||
/// The levels the map describes: a Metal texture has at most 15 (16384 texels on a side).
|
||||
pub const MAX_LEVELS: u32 = 16;
|
||||
/// The word of level 0's entry; level `l`'s is `LEVELS_WORD + LEVEL_WORDS·l`.
|
||||
pub const LEVELS_WORD: u32 = 8;
|
||||
/// The words of one level's entry: its first bit, then its tiles across x, y, and z.
|
||||
pub const LEVEL_WORDS: u32 = 4;
|
||||
/// The first word of the bits.
|
||||
pub const BITS_WORD: u32 = LEVELS_WORD + LEVEL_WORDS * MAX_LEVELS;
|
||||
@@ -430,42 +430,16 @@ impl FunctionBuilder<'_> {
|
||||
dref: Option<Value>,
|
||||
proj: bool,
|
||||
ops: &ImageOperands,
|
||||
) -> BResult<Value> {
|
||||
self.sample_form(sampled_image, coord, dref, proj, ops, false)
|
||||
}
|
||||
|
||||
/// One of the four `OpImageSparseSample*` opcodes: [`FunctionBuilder::sample`] without
|
||||
/// projection, whose result is the struct of the residency code (`u32`) and the texel
|
||||
/// ([`FunctionBuilder::texels_resident`] reads the code).
|
||||
pub fn sparse_sample(
|
||||
&mut self,
|
||||
sampled_image: Value,
|
||||
coord: Value,
|
||||
dref: Option<Value>,
|
||||
ops: &ImageOperands,
|
||||
) -> BResult<Value> {
|
||||
self.sample_form(sampled_image, coord, dref, false, ops, true)
|
||||
}
|
||||
|
||||
fn sample_form(
|
||||
&mut self,
|
||||
sampled_image: Value,
|
||||
coord: Value,
|
||||
dref: Option<Value>,
|
||||
proj: bool,
|
||||
ops: &ImageOperands,
|
||||
sparse: bool,
|
||||
) -> BResult<Value> {
|
||||
let form = SampleForm {
|
||||
implicit: ops.lod.is_none() && ops.grad.is_none(),
|
||||
proj,
|
||||
dref: dref.is_some(),
|
||||
sparse,
|
||||
};
|
||||
let op = form.to_spirv();
|
||||
if let Some(arms) = self.armed(ops) {
|
||||
return self.armed_access(op, (sampled_image, ops, &arms), &|fb, si, o| {
|
||||
fb.sample_form(si, coord, dref, proj, o, sparse)
|
||||
fb.sample(si, coord, dref, proj, o)
|
||||
});
|
||||
}
|
||||
let img = self.sampled_image_value(op, sampled_image)?;
|
||||
@@ -513,7 +487,6 @@ impl FunctionBuilder<'_> {
|
||||
} else {
|
||||
self.texel_ty(&img)?
|
||||
};
|
||||
let ty = self.sparse_result(ty, sparse)?;
|
||||
self.emit(
|
||||
Inst::ImageSample {
|
||||
form,
|
||||
@@ -530,38 +503,9 @@ impl FunctionBuilder<'_> {
|
||||
/// integer (plane + layer); operands `Lod` (integer; not buffer or multisampled),
|
||||
/// `ConstOffset`, and `Sample` (multisampled images, required). Result: `vec4`.
|
||||
pub fn fetch(&mut self, image: Value, coord: Value, ops: &ImageOperands) -> BResult<Value> {
|
||||
self.fetch_form(image, coord, ops, false)
|
||||
}
|
||||
|
||||
/// `OpImageSparseFetch`: [`FunctionBuilder::fetch`] whose result is the struct of the residency
|
||||
/// code (`u32`) and the texel.
|
||||
pub fn sparse_fetch(
|
||||
&mut self,
|
||||
image: Value,
|
||||
coord: Value,
|
||||
ops: &ImageOperands,
|
||||
) -> BResult<Value> {
|
||||
self.fetch_form(image, coord, ops, true)
|
||||
}
|
||||
|
||||
fn fetch_form(
|
||||
&mut self,
|
||||
image: Value,
|
||||
coord: Value,
|
||||
ops: &ImageOperands,
|
||||
sparse: bool,
|
||||
) -> BResult<Value> {
|
||||
let op = if sparse {
|
||||
crate::spv::Op::ImageSparseFetch
|
||||
} else {
|
||||
crate::spv::Op::ImageFetch
|
||||
};
|
||||
let op = crate::spv::Op::ImageFetch;
|
||||
let img = self.image_value(op, 0, image)?;
|
||||
// A sparse fetch reads no texel buffer (SPIR-V: `Dim` must not be `Buffer`).
|
||||
if img.usage != ImageUsage::Sampled
|
||||
|| matches!(img.dim, Dim::Cube | Dim::SubpassData)
|
||||
|| (sparse && img.dim == Dim::Buffer)
|
||||
{
|
||||
if img.usage != ImageUsage::Sampled || matches!(img.dim, Dim::Cube | Dim::SubpassData) {
|
||||
return Err(rule(op, ImageRule::ImageType));
|
||||
}
|
||||
self.check_coord(op, coord, false, plane(img.dim) + u8::from(img.arrayed))?;
|
||||
@@ -577,13 +521,11 @@ impl FunctionBuilder<'_> {
|
||||
},
|
||||
)?;
|
||||
let ty = self.texel_ty(&img)?;
|
||||
let ty = self.sparse_result(ty, sparse)?;
|
||||
self.emit(
|
||||
Inst::ImageFetch {
|
||||
image,
|
||||
coord,
|
||||
ops: *ops,
|
||||
sparse,
|
||||
},
|
||||
ty,
|
||||
)
|
||||
@@ -624,37 +566,10 @@ impl FunctionBuilder<'_> {
|
||||
component: u32,
|
||||
ops: &ImageOperands,
|
||||
) -> BResult<Value> {
|
||||
self.gather_form(sampled_image, coord, component, ops, false)
|
||||
}
|
||||
|
||||
/// `OpImageSparseGather`: [`FunctionBuilder::gather`] whose result is the struct of the
|
||||
/// residency code (`u32`) and the texel.
|
||||
pub fn sparse_gather(
|
||||
&mut self,
|
||||
sampled_image: Value,
|
||||
coord: Value,
|
||||
component: u32,
|
||||
ops: &ImageOperands,
|
||||
) -> BResult<Value> {
|
||||
self.gather_form(sampled_image, coord, component, ops, true)
|
||||
}
|
||||
|
||||
fn gather_form(
|
||||
&mut self,
|
||||
sampled_image: Value,
|
||||
coord: Value,
|
||||
component: u32,
|
||||
ops: &ImageOperands,
|
||||
sparse: bool,
|
||||
) -> BResult<Value> {
|
||||
let op = if sparse {
|
||||
crate::spv::Op::ImageSparseGather
|
||||
} else {
|
||||
crate::spv::Op::ImageGather
|
||||
};
|
||||
let op = crate::spv::Op::ImageGather;
|
||||
if let Some(arms) = self.armed(ops) {
|
||||
return self.armed_access(op, (sampled_image, ops, &arms), &|fb, si, o| {
|
||||
fb.gather_form(si, coord, component, o, sparse)
|
||||
fb.gather(si, coord, component, o)
|
||||
});
|
||||
}
|
||||
let img = self.check_gather(op, sampled_image, coord, false, ops)?;
|
||||
@@ -663,7 +578,6 @@ impl FunctionBuilder<'_> {
|
||||
}
|
||||
let component_id = self.u32_const(component)?;
|
||||
let ty = self.texel_ty(&img)?;
|
||||
let ty = self.sparse_result(ty, sparse)?;
|
||||
self.emit(
|
||||
Inst::ImageGather {
|
||||
sampled_image,
|
||||
@@ -671,7 +585,6 @@ impl FunctionBuilder<'_> {
|
||||
component,
|
||||
component_id,
|
||||
ops: *ops,
|
||||
sparse,
|
||||
},
|
||||
ty,
|
||||
)
|
||||
@@ -686,37 +599,10 @@ impl FunctionBuilder<'_> {
|
||||
dref: Value,
|
||||
ops: &ImageOperands,
|
||||
) -> BResult<Value> {
|
||||
self.dref_gather_form(sampled_image, coord, dref, ops, false)
|
||||
}
|
||||
|
||||
/// `OpImageSparseDrefGather`: [`FunctionBuilder::dref_gather`] whose result is the struct of
|
||||
/// the residency code (`u32`) and the texel.
|
||||
pub fn sparse_dref_gather(
|
||||
&mut self,
|
||||
sampled_image: Value,
|
||||
coord: Value,
|
||||
dref: Value,
|
||||
ops: &ImageOperands,
|
||||
) -> BResult<Value> {
|
||||
self.dref_gather_form(sampled_image, coord, dref, ops, true)
|
||||
}
|
||||
|
||||
fn dref_gather_form(
|
||||
&mut self,
|
||||
sampled_image: Value,
|
||||
coord: Value,
|
||||
dref: Value,
|
||||
ops: &ImageOperands,
|
||||
sparse: bool,
|
||||
) -> BResult<Value> {
|
||||
let op = if sparse {
|
||||
crate::spv::Op::ImageSparseDrefGather
|
||||
} else {
|
||||
crate::spv::Op::ImageDrefGather
|
||||
};
|
||||
let op = crate::spv::Op::ImageDrefGather;
|
||||
if let Some(arms) = self.armed(ops) {
|
||||
return self.armed_access(op, (sampled_image, ops, &arms), &|fb, si, o| {
|
||||
fb.dref_gather_form(si, coord, dref, o, sparse)
|
||||
fb.dref_gather(si, coord, dref, o)
|
||||
});
|
||||
}
|
||||
let img = self.check_gather(op, sampled_image, coord, true, ops)?;
|
||||
@@ -724,14 +610,12 @@ impl FunctionBuilder<'_> {
|
||||
return Err(rule(op, ImageRule::Value));
|
||||
}
|
||||
let ty = self.texel_ty(&img)?;
|
||||
let ty = self.sparse_result(ty, sparse)?;
|
||||
self.emit(
|
||||
Inst::ImageDrefGather {
|
||||
sampled_image,
|
||||
coord,
|
||||
dref,
|
||||
ops: *ops,
|
||||
sparse,
|
||||
},
|
||||
ty,
|
||||
)
|
||||
@@ -802,69 +686,12 @@ impl FunctionBuilder<'_> {
|
||||
image,
|
||||
coord,
|
||||
ops: *ops,
|
||||
sparse: false,
|
||||
mem,
|
||||
},
|
||||
ty,
|
||||
)
|
||||
}
|
||||
|
||||
/// `OpImageSparseRead` from a storage image that is no subpass input or texel buffer:
|
||||
/// [`FunctionBuilder::read`] whose result is the struct of the residency code (`u32`) and the
|
||||
/// texel.
|
||||
pub fn sparse_read(
|
||||
&mut self,
|
||||
image: Value,
|
||||
coord: Value,
|
||||
ops: &ImageOperands,
|
||||
mem: TexelMemory,
|
||||
) -> BResult<Value> {
|
||||
const OP: crate::spv::Op = crate::spv::Op::ImageSparseRead;
|
||||
let img = self.check_storage_access(OP, image, coord, ops, mem, false)?;
|
||||
if matches!(img.dim, Dim::SubpassData | Dim::Buffer) {
|
||||
return Err(rule(OP, ImageRule::ImageType));
|
||||
}
|
||||
let ty = self.texel_ty(&img)?;
|
||||
let ty = self.sparse_result(ty, true)?;
|
||||
self.emit(
|
||||
Inst::ImageRead {
|
||||
image,
|
||||
coord,
|
||||
ops: *ops,
|
||||
sparse: true,
|
||||
mem,
|
||||
},
|
||||
ty,
|
||||
)
|
||||
}
|
||||
|
||||
/// `OpImageSparseTexelsResident` of residency code `code`, a `u32` taken from a sparse
|
||||
/// access's result. Result: `bool`, true when every texel the access read was resident.
|
||||
pub fn texels_resident(&mut self, code: Value) -> BResult<Value> {
|
||||
const OP: crate::spv::Op = crate::spv::Op::ImageSparseTexelsResident;
|
||||
if !self
|
||||
.num(code)?
|
||||
.is_some_and(|n| n.is_int() && n.width == 32 && n.n == 1)
|
||||
{
|
||||
return Err(err(OP, OperandRule::Category(0)));
|
||||
}
|
||||
let b = self.module().ty(Type::Bool)?;
|
||||
self.emit(Inst::ImageSparseTexelsResident(code), b)
|
||||
}
|
||||
|
||||
/// The result type of an access whose plain result is `texel`: `texel` itself, or for a
|
||||
/// sparse access the struct of the `u32` residency code and `texel`.
|
||||
fn sparse_result(&mut self, texel: TypeId, sparse: bool) -> BResult<TypeId> {
|
||||
if !sparse {
|
||||
return Ok(texel);
|
||||
}
|
||||
let code = self.uint_ty(32)?;
|
||||
self.module().ty(Type::Struct {
|
||||
members: Box::new([code, texel]),
|
||||
layout: None,
|
||||
})
|
||||
}
|
||||
|
||||
/// `OpImageWrite` of a `vec4` of the sampled type to a storage image, with the texel
|
||||
/// operands `mem` (a `Made` scope is `MakeTexelAvailable`).
|
||||
pub fn write(
|
||||
|
||||
@@ -1703,7 +1703,6 @@ fn texel_operands_belong_to_storage_accesses() {
|
||||
];
|
||||
for mem in forms {
|
||||
f.read(st, c2, &none, mem).expect("read");
|
||||
f.sparse_read(st, c2, &none, mem).expect("sparse read");
|
||||
f.write(st, c2, texel, &none, mem).expect("write");
|
||||
}
|
||||
let recorded: Vec<TexelMemory> = f
|
||||
@@ -1716,7 +1715,7 @@ fn texel_operands_belong_to_storage_accesses() {
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
let want: Vec<TexelMemory> = forms.iter().flat_map(|&m| [m; 3]).collect();
|
||||
let want: Vec<TexelMemory> = forms.iter().flat_map(|&m| [m; 2]).collect();
|
||||
assert_eq!(recorded, want);
|
||||
assert_eq!(TexelMemory::made(device, true).made_scope(), Some(device));
|
||||
f.read(sp, origin, &none, TexelMemory::PRIVATE)
|
||||
|
||||
@@ -437,19 +437,10 @@ pub(super) fn exec(p: &Prog<'_>, l: &mut Lane, sh: &mut Shared, node: &InstNode)
|
||||
_ => return unmodelled(crate::spv::Op::Image),
|
||||
},
|
||||
Inst::ImageSample { form, .. } => return unmodelled(form.to_spirv()),
|
||||
Inst::ImageGather { sparse: false, .. } => return unmodelled(crate::spv::Op::ImageGather),
|
||||
Inst::ImageGather { sparse: true, .. } => {
|
||||
return unmodelled(crate::spv::Op::ImageSparseGather)
|
||||
}
|
||||
Inst::ImageDrefGather { sparse: false, .. } => {
|
||||
return unmodelled(crate::spv::Op::ImageDrefGather)
|
||||
}
|
||||
Inst::ImageDrefGather { sparse: true, .. } => {
|
||||
return unmodelled(crate::spv::Op::ImageSparseDrefGather)
|
||||
}
|
||||
Inst::ImageGather { .. } => return unmodelled(crate::spv::Op::ImageGather),
|
||||
Inst::ImageDrefGather { .. } => return unmodelled(crate::spv::Op::ImageDrefGather),
|
||||
Inst::ImageFetch { .. }
|
||||
| Inst::ImageRead { .. }
|
||||
| Inst::ImageSparseTexelsResident(_)
|
||||
| Inst::ImageWrite { .. }
|
||||
| Inst::ImageTexelPointer { .. }
|
||||
| Inst::ImageQuery { .. } => match super::image::exec(p, l, sh, &node.inst)? {
|
||||
|
||||
@@ -6,17 +6,6 @@
|
||||
//! a texel inside the image (`Root::Texel`): an atomic through it reads and writes the texel's
|
||||
//! first component, as an atomic of an `R32ui` / `R32i` image does.
|
||||
//!
|
||||
//! **Sparse residency**. An image may leave texels unmapped ([`Image::unmapped`]), as a sparse
|
||||
//! image with unbound memory does. `OpImageSparseFetch` and `OpImageSparseRead` return the struct
|
||||
//! of a residency code and the texel: the code is 0 where the texel read is mapped and 1 where it
|
||||
//! is not, and `OpImageSparseTexelsResident` is `code == 0`. A sparse or plain access reads an
|
||||
//! unmapped texel as [`Image::unmapped_texel`]: zero by default, as a device with
|
||||
//! `residencyNonResidentStrict` reads it, or another value a test chooses to model a device without
|
||||
//! it, whose value Vulkan leaves undefined. A write of an unmapped texel is discarded. A robust
|
||||
//! access outside the image reads the robust texel with code 1: Vulkan does not state its
|
||||
//! residency, and lavapipe reports it not resident (measured), so a module that answers Metal's
|
||||
//! word there (resident) must not take the device's.
|
||||
//!
|
||||
//! `OpImageFetch`'s `ConstOffset` is added to the coordinate's plane components before the texel
|
||||
//! is addressed, in 32-bit wrapping arithmetic (so a component the offset takes below zero is
|
||||
//! out of range, as any negative coordinate is); a layer is not offset (SPIR-V's image operands).
|
||||
@@ -31,8 +20,6 @@
|
||||
//! invocation last stored to that location, unless the load is volatile: the image's variable is
|
||||
//! decorated `Volatile`, or the read carries `VolatileTexel`.
|
||||
|
||||
use std::collections::BTreeSet;
|
||||
|
||||
use crate::pipeline::sym::ResourceSlot;
|
||||
use crate::spirv::ids::Value;
|
||||
use crate::spirv::ir::{Dim, ImageOperands, ImageQuery, ImageType, Inst, Type};
|
||||
@@ -70,14 +57,6 @@ pub struct Image {
|
||||
/// load is volatile: the image's variable is `Volatile`, or the read carries `VolatileTexel`.
|
||||
/// `None` (the default) traps every access outside the image.
|
||||
pub robust: Option<[u32; 4]>,
|
||||
/// The indices in [`Image::texels`] of the texels a sparse image leaves unmapped: a read of one
|
||||
/// returns [`Image::unmapped_texel`], and a sparse access reports it not resident. Empty (the
|
||||
/// default) for an image that is resident everywhere.
|
||||
pub unmapped: BTreeSet<usize>,
|
||||
/// What a read of an unmapped texel returns: zero (the default), as under Vulkan's
|
||||
/// `residencyNonResidentStrict`. A device without it returns an undefined value, which a test
|
||||
/// models by setting another one.
|
||||
pub unmapped_texel: [u32; 4],
|
||||
}
|
||||
|
||||
impl Image {
|
||||
@@ -98,8 +77,6 @@ impl Image {
|
||||
samples,
|
||||
texels: Vec::new(),
|
||||
robust: None,
|
||||
unmapped: BTreeSet::new(),
|
||||
unmapped_texel: [0; 4],
|
||||
};
|
||||
let n: usize = (0..levels).map(|l| img.level_texels(l)).sum();
|
||||
img.texels = vec![[0; 4]; n];
|
||||
@@ -262,18 +239,9 @@ pub(super) fn exec(
|
||||
inst: &Inst,
|
||||
) -> IResult<Option<Option<Val>>> {
|
||||
Ok(Some(match inst {
|
||||
Inst::ImageFetch {
|
||||
image,
|
||||
coord,
|
||||
ops,
|
||||
sparse,
|
||||
}
|
||||
Inst::ImageFetch { image, coord, ops }
|
||||
| Inst::ImageRead {
|
||||
image,
|
||||
coord,
|
||||
ops,
|
||||
sparse,
|
||||
..
|
||||
image, coord, ops, ..
|
||||
} => {
|
||||
let (k, img) = image_of(p, l, *image)?;
|
||||
// A volatile load: the image's `Volatile` decoration, or the read's `VolatileTexel`
|
||||
@@ -289,36 +257,20 @@ pub(super) fn exec(
|
||||
(_, Some(_)) => return Err(Unmodelled::Opcode(crate::spv::Op::ImageRead).err()),
|
||||
}
|
||||
let (level, sample) = level_and_sample(p, l, ops)?;
|
||||
let (t, resident) = match texel(sh, k, &img, &c, level, sample)? {
|
||||
Ok(i) => {
|
||||
let image = bound(sh, k)?;
|
||||
if image.unmapped.contains(&i) {
|
||||
(image.unmapped_texel, false)
|
||||
} else {
|
||||
let t = image
|
||||
.texels
|
||||
.get(i)
|
||||
.copied()
|
||||
.ok_or_else(|| malformed("texel index"))?;
|
||||
(t, true)
|
||||
}
|
||||
}
|
||||
let t = match texel(sh, k, &img, &c, level, sample)? {
|
||||
Ok(i) => bound(sh, k)?
|
||||
.texels
|
||||
.get(i)
|
||||
.copied()
|
||||
.ok_or_else(|| malformed("texel index"))?,
|
||||
// Robustness's texel, or the invocation's own discarded store to this location
|
||||
// where the load is not volatile; either is not resident.
|
||||
// where the load is not volatile.
|
||||
Err(robust) => match l.oob_stores.get(&(k, c, level, sample)) {
|
||||
Some(stored) if !volatile => (*stored, false),
|
||||
_ => (robust, false),
|
||||
Some(stored) if !volatile => *stored,
|
||||
_ => robust,
|
||||
},
|
||||
};
|
||||
let t = Val::C(t.iter().map(|x| Val::S(u64::from(*x))).collect());
|
||||
Some(if *sparse {
|
||||
Val::C(Box::new([Val::S(u64::from(!resident)), t]))
|
||||
} else {
|
||||
t
|
||||
})
|
||||
}
|
||||
Inst::ImageSparseTexelsResident(code) => {
|
||||
Some(Val::S(u64::from(l.get(p, *code)?.s()? == 0)))
|
||||
Some(Val::C(t.iter().map(|x| Val::S(u64::from(*x))).collect()))
|
||||
}
|
||||
Inst::ImageWrite {
|
||||
image,
|
||||
@@ -339,18 +291,14 @@ pub(super) fn exec(
|
||||
*d = *s as u32;
|
||||
}
|
||||
// Robustness discards a write outside the image; the invocation remembers it, since
|
||||
// a later load of the location may return it. A write of an unmapped texel is
|
||||
// discarded.
|
||||
// a later load of the location may return it.
|
||||
match texel(sh, k, &img, &c, level, sample)? {
|
||||
Ok(i) => {
|
||||
let image = bound(sh, k)?;
|
||||
if !image.unmapped.contains(&i) {
|
||||
let slot = image
|
||||
.texels
|
||||
.get_mut(i)
|
||||
.ok_or_else(|| malformed("texel index"))?;
|
||||
*slot = t;
|
||||
}
|
||||
let slot = bound(sh, k)?
|
||||
.texels
|
||||
.get_mut(i)
|
||||
.ok_or_else(|| malformed("texel index"))?;
|
||||
*slot = t;
|
||||
}
|
||||
Err(_) => {
|
||||
l.oob_stores.insert((k, c, level, sample), t);
|
||||
@@ -359,7 +307,7 @@ pub(super) fn exec(
|
||||
None
|
||||
}
|
||||
// A pointer to a texel inside the image, an atomic's operand. Robustness's atomic outside
|
||||
// the image, and one on an unmapped texel, are not modelled.
|
||||
// the image is not modelled.
|
||||
Inst::ImageTexelPointer {
|
||||
image,
|
||||
coord,
|
||||
@@ -381,7 +329,7 @@ pub(super) fn exec(
|
||||
let c = l.get(p, *coord)?.comps()?;
|
||||
let sample = l.get(p, *sample)?.s()?;
|
||||
match texel(sh, k, &img, &c, 0, sample)? {
|
||||
Ok(i) if !bound(sh, k)?.unmapped.contains(&i) => Some(Val::P(Ptr {
|
||||
Ok(i) => Some(Val::P(Ptr {
|
||||
root: Root::Texel(k),
|
||||
off: i as u64,
|
||||
ms: None,
|
||||
|
||||
@@ -430,8 +430,8 @@ pub struct ImageOperands {
|
||||
pub min_lod: Option<Value>,
|
||||
}
|
||||
|
||||
/// The Vulkan memory model's texel operands of a storage-image access: an `OpImageRead`,
|
||||
/// `OpImageSparseRead`, or `OpImageWrite`, the only instructions that carry one. They are kept out
|
||||
/// The Vulkan memory model's texel operands of a storage-image access: an `OpImageRead` or
|
||||
/// `OpImageWrite`, the only instructions that carry one. They are kept out
|
||||
/// of [`ImageOperands`], which every image instruction holds: an IR instruction is as large as its
|
||||
/// largest form, so a field there grows every instruction. It is eight bytes, which keeps both
|
||||
/// storage accesses no larger than the sampling instruction.
|
||||
@@ -518,10 +518,8 @@ impl TexelMemory {
|
||||
}
|
||||
}
|
||||
|
||||
/// The shape of an image-sampling opcode. The eight combinations without `sparse` are the eight
|
||||
/// `OpImage[Sample|SampleProj][Dref]{Implicit,Explicit}Lod` opcodes; with `sparse` (never
|
||||
/// projective: SPIR-V reserves `OpImageSparseSampleProj*`) the four
|
||||
/// `OpImageSparseSample[Dref]{Implicit,Explicit}Lod` opcodes.
|
||||
/// The shape of an image-sampling opcode: its eight combinations are the eight
|
||||
/// `OpImage[Sample|SampleProj][Dref]{Implicit,Explicit}Lod` opcodes.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
pub struct SampleForm {
|
||||
/// Implicit LOD (needs implicit derivatives; tangled).
|
||||
@@ -530,28 +528,21 @@ pub struct SampleForm {
|
||||
pub proj: bool,
|
||||
/// Depth comparison.
|
||||
pub dref: bool,
|
||||
/// The sparse form: the result is the residency code and the texel (`SparseResidency`).
|
||||
pub sparse: bool,
|
||||
}
|
||||
|
||||
impl SampleForm {
|
||||
/// The SPIR-V opcode. The builder never makes a sparse projective form, whose opcodes SPIR-V
|
||||
/// reserves; it maps to the non-projective sparse opcode.
|
||||
/// The SPIR-V opcode.
|
||||
pub fn to_spirv(self) -> crate::spv::Op {
|
||||
use crate::spv::Op;
|
||||
match (self.sparse, self.proj, self.dref, self.implicit) {
|
||||
(false, false, false, true) => Op::ImageSampleImplicitLod,
|
||||
(false, false, false, false) => Op::ImageSampleExplicitLod,
|
||||
(false, false, true, true) => Op::ImageSampleDrefImplicitLod,
|
||||
(false, false, true, false) => Op::ImageSampleDrefExplicitLod,
|
||||
(false, true, false, true) => Op::ImageSampleProjImplicitLod,
|
||||
(false, true, false, false) => Op::ImageSampleProjExplicitLod,
|
||||
(false, true, true, true) => Op::ImageSampleProjDrefImplicitLod,
|
||||
(false, true, true, false) => Op::ImageSampleProjDrefExplicitLod,
|
||||
(true, _, false, true) => Op::ImageSparseSampleImplicitLod,
|
||||
(true, _, false, false) => Op::ImageSparseSampleExplicitLod,
|
||||
(true, _, true, true) => Op::ImageSparseSampleDrefImplicitLod,
|
||||
(true, _, true, false) => Op::ImageSparseSampleDrefExplicitLod,
|
||||
match (self.proj, self.dref, self.implicit) {
|
||||
(false, false, true) => Op::ImageSampleImplicitLod,
|
||||
(false, false, false) => Op::ImageSampleExplicitLod,
|
||||
(false, true, true) => Op::ImageSampleDrefImplicitLod,
|
||||
(false, true, false) => Op::ImageSampleDrefExplicitLod,
|
||||
(true, false, true) => Op::ImageSampleProjImplicitLod,
|
||||
(true, false, false) => Op::ImageSampleProjExplicitLod,
|
||||
(true, true, true) => Op::ImageSampleProjDrefImplicitLod,
|
||||
(true, true, false) => Op::ImageSampleProjDrefExplicitLod,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -334,42 +334,34 @@ pub enum Inst {
|
||||
dref: Option<Value>,
|
||||
ops: ImageOperands,
|
||||
},
|
||||
/// `OpImageFetch`, or `OpImageSparseFetch` (`sparse`).
|
||||
/// `OpImageFetch`.
|
||||
ImageFetch {
|
||||
image: Value,
|
||||
coord: Value,
|
||||
ops: ImageOperands,
|
||||
sparse: bool,
|
||||
},
|
||||
/// `OpImageGather` of component `component` (carried by constant `component_id`), or
|
||||
/// `OpImageSparseGather` (`sparse`).
|
||||
/// `OpImageGather` of component `component` (carried by constant `component_id`).
|
||||
ImageGather {
|
||||
sampled_image: Value,
|
||||
coord: Value,
|
||||
component: u32,
|
||||
component_id: ConstId,
|
||||
ops: ImageOperands,
|
||||
sparse: bool,
|
||||
},
|
||||
/// `OpImageDrefGather`, or `OpImageSparseDrefGather` (`sparse`).
|
||||
/// `OpImageDrefGather`.
|
||||
ImageDrefGather {
|
||||
sampled_image: Value,
|
||||
coord: Value,
|
||||
dref: Value,
|
||||
ops: ImageOperands,
|
||||
sparse: bool,
|
||||
},
|
||||
/// `OpImageRead`, or `OpImageSparseRead` (`sparse`).
|
||||
/// `OpImageRead`.
|
||||
ImageRead {
|
||||
image: Value,
|
||||
coord: Value,
|
||||
ops: ImageOperands,
|
||||
sparse: bool,
|
||||
mem: TexelMemory,
|
||||
},
|
||||
/// `OpImageSparseTexelsResident`: whether the residency code of a sparse access says every
|
||||
/// texel it accessed was resident.
|
||||
ImageSparseTexelsResident(Value),
|
||||
/// `OpImageWrite`.
|
||||
ImageWrite {
|
||||
image: Value,
|
||||
@@ -648,7 +640,6 @@ impl Inst {
|
||||
f(*coord);
|
||||
ops(o, &mut f);
|
||||
}
|
||||
Inst::ImageSparseTexelsResident(code) => f(*code),
|
||||
Inst::ImageGather {
|
||||
sampled_image,
|
||||
coord,
|
||||
@@ -870,7 +861,6 @@ impl Inst {
|
||||
f(coord);
|
||||
ops(o, &mut f);
|
||||
}
|
||||
Inst::ImageSparseTexelsResident(code) => f(code),
|
||||
Inst::ImageGather {
|
||||
sampled_image,
|
||||
coord,
|
||||
@@ -993,7 +983,6 @@ impl Inst {
|
||||
| Inst::ImageSample { .. }
|
||||
| Inst::ImageFetch { .. }
|
||||
| Inst::ImageDrefGather { .. }
|
||||
| Inst::ImageSparseTexelsResident(_)
|
||||
| Inst::ImageQuery { .. }
|
||||
| Inst::ImageQueryLod { .. }
|
||||
| Inst::Derivative { .. }
|
||||
|
||||
@@ -1023,37 +1023,17 @@ impl Deriver<'_> {
|
||||
self.scope(*mem);
|
||||
self.semantics(*sem);
|
||||
}
|
||||
Inst::ImageSample { ops, form, .. } => {
|
||||
Inst::ImageSample { ops, .. } | Inst::ImageFetch { ops, .. } => {
|
||||
self.image_operands(ops, false);
|
||||
if form.sparse {
|
||||
self.sparse_residency();
|
||||
}
|
||||
}
|
||||
Inst::ImageFetch { ops, sparse, .. } => {
|
||||
self.image_operands(ops, false);
|
||||
if *sparse {
|
||||
self.sparse_residency();
|
||||
}
|
||||
}
|
||||
Inst::ImageDrefGather { ops, sparse, .. } | Inst::ImageGather { ops, sparse, .. } => {
|
||||
Inst::ImageDrefGather { ops, .. } | Inst::ImageGather { ops, .. } => {
|
||||
self.image_operands(ops, true);
|
||||
if *sparse {
|
||||
self.sparse_residency();
|
||||
}
|
||||
}
|
||||
Inst::ImageSparseTexelsResident(_) => self.sparse_residency(),
|
||||
Inst::ImageRead {
|
||||
image,
|
||||
ops,
|
||||
sparse,
|
||||
mem,
|
||||
..
|
||||
image, ops, mem, ..
|
||||
} => {
|
||||
self.image_operands(ops, false);
|
||||
self.texel_memory(*mem);
|
||||
if *sparse {
|
||||
self.sparse_residency();
|
||||
}
|
||||
let img = self.image_of(*image)?;
|
||||
// Enabled on the device (`DeviceProfile::check`), not by a feature listed here.
|
||||
if img.format == crate::spv::ImageFormat::Unknown && img.dim != Dim::SubpassData {
|
||||
@@ -1233,13 +1213,6 @@ impl Deriver<'_> {
|
||||
}
|
||||
}
|
||||
|
||||
/// An `OpImageSparse*` instruction: the `SparseResidency` capability, which Vulkan gates on
|
||||
/// `shaderResourceResidency`.
|
||||
fn sparse_residency(&mut self) {
|
||||
self.cap(Cap::SparseResidency);
|
||||
self.feat(VkFeature::ShaderResourceResidency);
|
||||
}
|
||||
|
||||
/// A storage access's texel operands (`NonPrivateTexel`, `VolatileTexel`, `MakeTexel*`):
|
||||
/// they need the Vulkan memory model, and their scope counts like an atomic's.
|
||||
fn texel_memory(&mut self, mem: TexelMemory) {
|
||||
|
||||
@@ -479,12 +479,9 @@ fn use_of(n: &InstNode, v: Value) -> Use<'_> {
|
||||
inst if carried_on(inst) == Some(v) && n.result.is_some() => Use::NoTexel,
|
||||
// A query of its size, levels or samples reads no texel.
|
||||
Inst::ImageQuery { image, .. } if *image == v => Use::NoTexel,
|
||||
Inst::ImageFetch {
|
||||
image,
|
||||
coord,
|
||||
ops,
|
||||
sparse: false,
|
||||
} if *image == v && *coord != v => Use::Fetch { coord: *coord, ops },
|
||||
Inst::ImageFetch { image, coord, ops } if *image == v && *coord != v => {
|
||||
Use::Fetch { coord: *coord, ops }
|
||||
}
|
||||
_ => Use::Elsewhere,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1949,27 +1949,16 @@ impl Ser<'_> {
|
||||
o.extend(self.image_ops(ops)?);
|
||||
w.inst(form.to_spirv(), &o)
|
||||
}
|
||||
Inst::ImageFetch {
|
||||
image,
|
||||
coord,
|
||||
ops,
|
||||
sparse,
|
||||
} => {
|
||||
Inst::ImageFetch { image, coord, ops } => {
|
||||
let mut o = with(head()?, &[v(*image)?, v(*coord)?]);
|
||||
o.extend(self.image_ops(ops)?);
|
||||
let op = if *sparse {
|
||||
Op::ImageSparseFetch
|
||||
} else {
|
||||
Op::ImageFetch
|
||||
};
|
||||
w.inst(op, &o)
|
||||
w.inst(Op::ImageFetch, &o)
|
||||
}
|
||||
Inst::ImageGather {
|
||||
sampled_image,
|
||||
coord,
|
||||
component_id,
|
||||
ops,
|
||||
sparse,
|
||||
..
|
||||
} => {
|
||||
let mut o = with(
|
||||
@@ -1977,47 +1966,27 @@ impl Ser<'_> {
|
||||
&[v(*sampled_image)?, v(*coord)?, self.cid(*component_id)?],
|
||||
);
|
||||
o.extend(self.image_ops(ops)?);
|
||||
let op = if *sparse {
|
||||
Op::ImageSparseGather
|
||||
} else {
|
||||
Op::ImageGather
|
||||
};
|
||||
w.inst(op, &o)
|
||||
w.inst(Op::ImageGather, &o)
|
||||
}
|
||||
Inst::ImageDrefGather {
|
||||
sampled_image,
|
||||
coord,
|
||||
dref,
|
||||
ops,
|
||||
sparse,
|
||||
} => {
|
||||
let mut o = with(head()?, &[v(*sampled_image)?, v(*coord)?, v(*dref)?]);
|
||||
o.extend(self.image_ops(ops)?);
|
||||
let op = if *sparse {
|
||||
Op::ImageSparseDrefGather
|
||||
} else {
|
||||
Op::ImageDrefGather
|
||||
};
|
||||
w.inst(op, &o)
|
||||
w.inst(Op::ImageDrefGather, &o)
|
||||
}
|
||||
Inst::ImageRead {
|
||||
image,
|
||||
coord,
|
||||
ops,
|
||||
sparse,
|
||||
mem,
|
||||
} => {
|
||||
let mut o = with(head()?, &[v(*image)?, v(*coord)?]);
|
||||
o.extend(self.storage_ops(ops, *mem, false)?);
|
||||
let op = if *sparse {
|
||||
Op::ImageSparseRead
|
||||
} else {
|
||||
Op::ImageRead
|
||||
};
|
||||
w.inst(op, &o)
|
||||
}
|
||||
Inst::ImageSparseTexelsResident(code) => {
|
||||
w.inst(Op::ImageSparseTexelsResident, &with(head()?, &[v(*code)?]))
|
||||
w.inst(Op::ImageRead, &o)
|
||||
}
|
||||
Inst::ImageWrite {
|
||||
image,
|
||||
|
||||
@@ -197,7 +197,6 @@ fn memory_write(inst: &Inst) -> Option<Write> {
|
||||
| Inst::ImageGather { .. }
|
||||
| Inst::ImageDrefGather { .. }
|
||||
| Inst::ImageRead { .. }
|
||||
| Inst::ImageSparseTexelsResident(_)
|
||||
| Inst::ImageQuery { .. }
|
||||
| Inst::ImageQueryLod { .. }
|
||||
| Inst::Derivative { .. }
|
||||
|
||||
@@ -281,126 +281,6 @@ fn sampling_in_fragment() {
|
||||
assert_spirv_valid(b.finalize().expect("finalize"));
|
||||
}
|
||||
|
||||
/// The sparse form of every access (sample with and without `Dref`, implicit and explicit LOD,
|
||||
/// gather, dref gather, fetch, storage read) and `OpImageSparseTexelsResident` of its code validate
|
||||
/// and declare `SparseResidency`, which the registry gates on `shaderResourceResidency`; a sparse
|
||||
/// fetch of a texel buffer and a residency test of a value that is no `u32` code are refused.
|
||||
#[test]
|
||||
fn sparse_accesses_and_residency() {
|
||||
let mut b = ModuleBuilder::new();
|
||||
let t = tys(&mut b);
|
||||
let smp = sampler(&mut b, 0);
|
||||
let kinds = [
|
||||
SAMPLED_2D,
|
||||
Img {
|
||||
depth: true,
|
||||
..SAMPLED_2D
|
||||
},
|
||||
Img {
|
||||
usage: ImageUsage::Storage,
|
||||
format: ImageFormat::Rgba32f,
|
||||
..SAMPLED_2D
|
||||
},
|
||||
Img {
|
||||
dim: Dim::Buffer,
|
||||
..SAMPLED_2D
|
||||
},
|
||||
];
|
||||
let g: Vec<GlobalId> = kinds
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i, k)| {
|
||||
let ty = image_ty(&mut b, t.f32_, *k);
|
||||
texture(&mut b, i as u32, ty)
|
||||
})
|
||||
.collect();
|
||||
let out = b
|
||||
.io(key("color"), IoDir::Output, t.vec4, IoDecor::default())
|
||||
.expect("output");
|
||||
let mut f = b.function(t.void).expect("main");
|
||||
let x = fvec(&mut f, &t, 1);
|
||||
let c2 = fvec(&mut f, &t, 2);
|
||||
let i2 = ivec(&mut f, 2, 0);
|
||||
let zero = cval(&mut f, t.i32_, 0);
|
||||
let none = ImageOperands::default();
|
||||
let lod = ImageOperands {
|
||||
lod: Some(x),
|
||||
..none
|
||||
};
|
||||
let s = load_global(&mut f, smp);
|
||||
let mut results = Vec::new();
|
||||
let img = load_global(&mut f, g[0]);
|
||||
let si = f.sampled_image(img, s).expect("sampled image");
|
||||
results.push(
|
||||
f.sparse_sample(si, c2, None, &none)
|
||||
.expect("sparse implicit"),
|
||||
);
|
||||
results.push(
|
||||
f.sparse_sample(si, c2, None, &lod)
|
||||
.expect("sparse explicit"),
|
||||
);
|
||||
results.push(f.sparse_gather(si, c2, 1, &none).expect("sparse gather"));
|
||||
let level = ImageOperands {
|
||||
lod: Some(zero),
|
||||
..none
|
||||
};
|
||||
results.push(f.sparse_fetch(img, i2, &level).expect("sparse fetch"));
|
||||
let img = load_global(&mut f, g[1]);
|
||||
let si = f.sampled_image(img, s).expect("sampled image");
|
||||
results.push(
|
||||
f.sparse_sample(si, c2, Some(x), &none)
|
||||
.expect("sparse dref"),
|
||||
);
|
||||
results.push(
|
||||
f.sparse_sample(si, c2, Some(x), &lod)
|
||||
.expect("sparse dref explicit"),
|
||||
);
|
||||
results.push(
|
||||
f.sparse_dref_gather(si, c2, x, &none)
|
||||
.expect("sparse dref gather"),
|
||||
);
|
||||
let img = load_global(&mut f, g[2]);
|
||||
results.push(
|
||||
f.sparse_read(img, i2, &none, TexelMemory::PRIVATE)
|
||||
.expect("sparse read"),
|
||||
);
|
||||
let img = load_global(&mut f, g[3]);
|
||||
assert!(f.sparse_fetch(img, zero, &none).is_err(), "texel buffer");
|
||||
assert!(f.texels_resident(x).is_err(), "a float code");
|
||||
let mut all = None;
|
||||
for r in &results {
|
||||
let code = f.composite_extract(*r, &[0]).expect("code");
|
||||
let resident = f.texels_resident(code).expect("resident");
|
||||
all = Some(match all {
|
||||
None => resident,
|
||||
Some(a) => f
|
||||
.binary(crate::spirv::ir::BinOp::LogicalAnd, a, resident)
|
||||
.expect("and"),
|
||||
});
|
||||
}
|
||||
let texel = f.composite_extract(results[0], &[1]).expect("texel");
|
||||
let null = f
|
||||
.module()
|
||||
.constant(crate::spirv::ir::Constant::Null { ty: t.vec4 })
|
||||
.expect("null");
|
||||
let null = f.module().const_value(null).expect("null value");
|
||||
let v = f.select(all.expect("codes"), texel, null).expect("select");
|
||||
let po = f.module().global_value(out).expect("out");
|
||||
f.store(po, v, MemAccess::default()).expect("store");
|
||||
f.ret(None).expect("ret");
|
||||
let main = f.finish().expect("finish");
|
||||
b.entry(ExecModel::Fragment, main, vec![]).expect("entry");
|
||||
let m = b.finalize().expect("finalize");
|
||||
let req = &m.requirements;
|
||||
assert!(req.spirv_capabilities.contains(&SpirvCapability::of(
|
||||
crate::spv::Capability::SparseResidency
|
||||
)));
|
||||
assert!(req
|
||||
.features
|
||||
.contains(&crate::device::requirements::VkFeature::ShaderResourceResidency));
|
||||
assert_spirv_valid(m);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fetch_read_write_and_queries() {
|
||||
let mut b = ModuleBuilder::new();
|
||||
|
||||
@@ -104,7 +104,6 @@ fn leaves_nothing(m: &TypedModule, inst: &Inst) -> bool {
|
||||
| Inst::ImageGather { .. }
|
||||
| Inst::ImageDrefGather { .. }
|
||||
| Inst::ImageRead { .. }
|
||||
| Inst::ImageSparseTexelsResident(_)
|
||||
| Inst::ImageQuery { .. }
|
||||
| Inst::ImageQueryLod { .. }
|
||||
| Inst::Derivative { .. }
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
//! a device without robust image access.
|
||||
//! - A kernel's `sparse_sample`, `sparse_gather` and `sparse_read` of texture slots
|
||||
//! (`engine/a2_sparse_status`) observe each one's residency as the constant resident word, with
|
||||
//! no `SparseTexture` fact and no sparse instruction. It passes L3.
|
||||
//! no specialization constant and no sparse instruction. It passes L3.
|
||||
//! - A kernel's plain `ulong` texture slots (`engine/unk_ulong_rw`'s `unk_ulong_access`: two
|
||||
//! reads and a write) are `RG32` unsigned images, the sampled array's unsigned class and the
|
||||
//! storage array's declared `Rg32ui`. It passes L3 and, on the CPU interpreter, joins each
|
||||
@@ -2289,9 +2289,9 @@ fn ulong_texel(e: u32, n: u32) -> ([u32; 4], u64) {
|
||||
|
||||
/// A kernel's `sparse_sample`, `sparse_gather` and `sparse_read` of texture slots, each storing its
|
||||
/// colour and its `resident()` (`engine/a2_sparse_status`), compiles under the identity domains:
|
||||
/// every observed residency is the constant 0 word, resident (`lower::texture::residency`), so
|
||||
/// the plan states no `SparseTexture` fact, the interface no specialization constant but the
|
||||
/// dispatch's, and the module holds no `OpImageSparse*` instruction. It passes L3 on each profile.
|
||||
/// every observed residency is the constant 0 word, resident (`lower::texture`'s status words), so
|
||||
/// the interface states no specialization constant but the dispatch's, and the module holds no
|
||||
/// `OpImageSparse*` instruction. It passes L3 on each profile.
|
||||
#[test]
|
||||
fn a_sparse_access_of_a_texture_slot_is_resident() {
|
||||
use crate::spv::Op;
|
||||
@@ -2318,7 +2318,7 @@ fn a_sparse_access_of_a_texture_slot_is_resident() {
|
||||
Op::ImageSparseRead,
|
||||
];
|
||||
for (stem, p) in &profiles {
|
||||
let (a, plan, _) =
|
||||
let (a, _, _) =
|
||||
compile_kept(&bc, "a2_sparse_status", p).unwrap_or_else(|e| panic!("{stem}: {e}"));
|
||||
link_and_validate(&a, p).unwrap_or_else(|e| panic!("{stem}: L3: {e}"));
|
||||
assert!(
|
||||
@@ -2326,11 +2326,6 @@ fn a_sparse_access_of_a_texture_slot_is_resident() {
|
||||
"{stem}: {:?}",
|
||||
a.interface.spec
|
||||
);
|
||||
assert!(
|
||||
!(plan.facts.iter()).any(|f| matches!(f, RuntimeFact::SparseTexture { .. })),
|
||||
"{stem}: {:?}",
|
||||
plan.facts
|
||||
);
|
||||
for op in sparse {
|
||||
let n = super::engine_handles::count(&a, op as u16);
|
||||
assert_eq!(n, 0, "{stem}: opcode {}", op as u32);
|
||||
|
||||
@@ -429,10 +429,7 @@ fn coordinates_pass_through(words: &[u32]) -> (bool, bool) {
|
||||
| O::ImageSampleDrefImplicitLod
|
||||
| O::ImageSampleDrefExplicitLod
|
||||
| O::ImageGather
|
||||
| O::ImageDrefGather
|
||||
| O::ImageSparseSampleImplicitLod
|
||||
| O::ImageSparseSampleExplicitLod
|
||||
| O::ImageSparseGather => ids(i).get(1).copied(),
|
||||
| O::ImageDrefGather => ids(i).get(1).copied(),
|
||||
_ => continue,
|
||||
};
|
||||
sampled = true;
|
||||
|
||||
@@ -886,5 +886,3 @@ fn size_queries_answer_metal_s_extent_at_every_level() {
|
||||
}
|
||||
assert!(ran > 0);
|
||||
}
|
||||
|
||||
// ---- A function's writes to a sparse texture ----
|
||||
@@ -8658,7 +8658,6 @@ variant metal2vulkan-runtime::PrecisionNote::RoundedSampleDepthCopy RoundedSampl
|
||||
variant metal2vulkan-runtime::PrecisionNote::SharedExponentKept SharedExponentKept
|
||||
variant metal2vulkan-runtime::PrecisionNote::SimdgroupAccessOrder SimdgroupAccessOrder
|
||||
variant metal2vulkan-runtime::PrecisionNote::SnormMinimumKept SnormMinimumKept
|
||||
variant metal2vulkan-runtime::PrecisionNote::SparseResidency SparseResidency
|
||||
variant metal2vulkan-runtime::PrecisionNote::SrgbTexelDecode SrgbTexelDecode
|
||||
variant metal2vulkan-runtime::PrecisionNote::StencilOutputOverlap StencilOutputOverlap
|
||||
variant metal2vulkan-runtime::PrecisionNote::SwizzledOpaqueBlackBorder SwizzledOpaqueBlackBorder
|
||||
@@ -9662,7 +9661,6 @@ variant metal2vulkan::error::Feature::SamplerLodBias SamplerLodBias
|
||||
variant metal2vulkan::error::Feature::SimdWidth SimdWidth
|
||||
variant metal2vulkan::error::Feature::SimdgroupMatrix SimdgroupMatrix
|
||||
variant metal2vulkan::error::Feature::SimdgroupMatrix16x16x16 SimdgroupMatrix16x16x16
|
||||
variant metal2vulkan::error::Feature::SparseTexture SparseTexture { slot: SlotRef }
|
||||
variant metal2vulkan::error::Feature::Stage Stage(u8)
|
||||
variant metal2vulkan::error::Feature::StageStoresAndAtomics StageStoresAndAtomics
|
||||
variant metal2vulkan::error::Feature::StaticInitializer StaticInitializer
|
||||
@@ -9929,7 +9927,6 @@ variant metal2vulkan::pipeline::BindingSource::Buffer Buffer(SlotRef)
|
||||
variant metal2vulkan::pipeline::BindingSource::IdentityArray IdentityArray
|
||||
variant metal2vulkan::pipeline::BindingSource::Synthetic Synthetic { stage: Stage, binding: SyntheticBinding }
|
||||
variant metal2vulkan::pipeline::BindingSource::TileAttachment TileAttachment(u32)
|
||||
variant metal2vulkan::pipeline::BindingSource::TileMap TileMap(SlotRef)
|
||||
variant metal2vulkan::pipeline::BufferForm::Descriptor Descriptor
|
||||
variant metal2vulkan::pipeline::BufferForm::Psb Psb
|
||||
variant metal2vulkan::pipeline::BufferKind::Buffer Buffer
|
||||
@@ -10055,7 +10052,6 @@ variant metal2vulkan::pipeline::PrecisionNote::RoundedSampleDepthCopy RoundedSam
|
||||
variant metal2vulkan::pipeline::PrecisionNote::SharedExponentKept SharedExponentKept
|
||||
variant metal2vulkan::pipeline::PrecisionNote::SimdgroupAccessOrder SimdgroupAccessOrder
|
||||
variant metal2vulkan::pipeline::PrecisionNote::SnormMinimumKept SnormMinimumKept
|
||||
variant metal2vulkan::pipeline::PrecisionNote::SparseResidency SparseResidency
|
||||
variant metal2vulkan::pipeline::PrecisionNote::SrgbTexelDecode SrgbTexelDecode
|
||||
variant metal2vulkan::pipeline::PrecisionNote::StencilOutputOverlap StencilOutputOverlap
|
||||
variant metal2vulkan::pipeline::PrecisionNote::SwizzledOpaqueBlackBorder SwizzledOpaqueBlackBorder
|
||||
@@ -10124,7 +10120,6 @@ variant metal2vulkan::pipeline::ResourceKind::Buffer Buffer
|
||||
variant metal2vulkan::pipeline::ResourceKind::Heap Heap(HandleClass)
|
||||
variant metal2vulkan::pipeline::ResourceKind::Synthetic Synthetic(SyntheticBinding)
|
||||
variant metal2vulkan::pipeline::ResourceKind::TileAttachment TileAttachment(u32)
|
||||
variant metal2vulkan::pipeline::ResourceKind::TileMap TileMap
|
||||
variant metal2vulkan::pipeline::RuntimeFact::AccelerationStructureInstanceCount AccelerationStructureInstanceCount { slot: SlotRef }
|
||||
variant metal2vulkan::pipeline::RuntimeFact::AddressAlignment AddressAlignment { slot: SlotRef, align: u32 }
|
||||
variant metal2vulkan::pipeline::RuntimeFact::AliasedImageblock AliasedImageblock { data_size: u32 }
|
||||
@@ -10168,7 +10163,6 @@ variant metal2vulkan::pipeline::RuntimeFact::RobustStorageBuffers RobustStorageB
|
||||
variant metal2vulkan::pipeline::RuntimeFact::RotatedWeights RotatedWeights
|
||||
variant metal2vulkan::pipeline::RuntimeFact::SampleCount SampleCount
|
||||
variant metal2vulkan::pipeline::RuntimeFact::SimdgroupEmulation SimdgroupEmulation { bytes_per_simdgroup: u32, arena: Option<u32> }
|
||||
variant metal2vulkan::pipeline::RuntimeFact::SparseTexture SparseTexture { slot: SlotRef, sparse_arm: bool, tile_map: bool }
|
||||
variant metal2vulkan::pipeline::RuntimeFact::StageInRegion StageInRegion
|
||||
variant metal2vulkan::pipeline::RuntimeFact::StageInStride StageInStride { layout: u32 }
|
||||
variant metal2vulkan::pipeline::RuntimeFact::StencilBitDraws StencilBitDraws
|
||||
@@ -10223,7 +10217,6 @@ variant metal2vulkan::pipeline::SpecKey::RenderAreaHeight RenderAreaHeight
|
||||
variant metal2vulkan::pipeline::SpecKey::RenderAreaWidth RenderAreaWidth
|
||||
variant metal2vulkan::pipeline::SpecKey::SampleCount SampleCount
|
||||
variant metal2vulkan::pipeline::SpecKey::SamplerMinLevel SamplerMinLevel(SlotRef)
|
||||
variant metal2vulkan::pipeline::SpecKey::SparseTexture SparseTexture(SlotRef)
|
||||
variant metal2vulkan::pipeline::SpecKey::TexelBufferWords TexelBufferWords { stage: Stage, handles: bool }
|
||||
variant metal2vulkan::pipeline::SpecKey::TextureSwizzle TextureSwizzle(SlotRef)
|
||||
variant metal2vulkan::pipeline::SpecKey::TgLength TgLength(u32)
|
||||
|
||||
|
Can't render this file because it is too large.
|
+1
-9
@@ -205,7 +205,7 @@ the runtime's, the command line's, the compile worker's and every validation too
|
||||
slot and a member of one class index one array. No variant is chosen there: a
|
||||
texture reads through the plain form whatever texture its ID names, its `float` or `half` reads
|
||||
take the device's sRGB decode with `PrecisionNote::SrgbTexelDecode`, and no texture is sparse
|
||||
(the consumer refuses a sparse texture). A texture slot sampled through a runtime sampler slot
|
||||
(the runtime makes none). A texture slot sampled through a runtime sampler slot
|
||||
samples set 1's element of the sampler arrays at the index of the sampler's pushed
|
||||
`gpuResourceID`, joined to the texture's element by `OpSampledImage`, and reads the sampler's
|
||||
word from that ID. One sampled through a constexpr sampler samples the element at the index the
|
||||
@@ -1969,14 +1969,6 @@ category, and says what makes an operation carry the note and what may differ. E
|
||||
Through an argument buffer it holds only where the command can name a texture held by its raw
|
||||
texels in a form the function filters (`BGR10_XR`, `BGRA10_XR`, the padded forms; not a bfloat
|
||||
one).
|
||||
- `metal2vulkan-degrade-sparse-residency` (precision). `PrecisionNote::SparseResidency`: A stage
|
||||
samples or gathers a texture whose residency it observes (`sparse_color::resident`) through the
|
||||
slot's sparse form, which the module has where the profile enables `shaderResourceResidency`:
|
||||
the word is the device's `OpImageSparse*` residency, whose footprint may count a texel of zero
|
||||
weight Metal does not or call a footprint of the border alone not resident where Metal answers
|
||||
resident, and an unmapped texel's lanes the device's non-resident value. Where the
|
||||
device has no residency of its own, the slot's tile map answers Metal's footprint rule exactly,
|
||||
unrecorded.
|
||||
- `metal2vulkan-degrade-device-nan-encoding` (precision). `PrecisionNote::DeviceNanEncoding`: A
|
||||
`float` NaN result's bit pattern follows the device: Metal answers the canonical `0x7fc00000` for
|
||||
the NaN results of its float arithmetic and functions, and Vulkan states no encoding, so a device
|
||||
|
||||
+4
-5
@@ -26,7 +26,7 @@ Columns:
|
||||
|
||||
| Kind | Variants | With a site | Reach system | Reach app | Reach rare | Reach none | Unassessed |
|
||||
|---|---|---|---|---|---|---|---|
|
||||
| Translator and front-end refusals | 115 | 111 | 6 | 25 | 63 | 21 | 0 |
|
||||
| Translator and front-end refusals | 114 | 111 | 6 | 25 | 62 | 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 | 41 | 67 | 0 | 0 | 4 |
|
||||
| Translator and front-end refusals | 0 | 0 | 3 | 41 | 67 | 0 | 0 | 3 |
|
||||
| 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 |
|
||||
@@ -87,7 +87,7 @@ Columns:
|
||||
| `ImageAtomics` | Image atomics beyond 32-bit integers | every device (not implemented) | `ours` | 1: `crates/metal2vulkan/src/lower/texture/atomic.rs (select)` | `rare`: texture atomics beyond 32-bit integers |
|
||||
| `DescriptorCount` | Too many descriptors of one kind in a stage or pipeline | devices short of a device limit the site names | `device` | 2: `crates/metal2vulkan/src/lower/select.rs (finish)`, `crates/metal2vulkan/src/pipeline/link.rs (limit_error)` | `app`: many textures or buffers in one stage on a smaller device |
|
||||
| `Float64Arithmetic` | 64-bit float arithmetic | devices without VkFeature::ShaderFloat64 | `device` | 2: `crates/metal2vulkan/src/device/metal.rs (unsupported_features)`, `crates/metal2vulkan/src/lower/arith/legal.rs (check_scalar)` | `rare`: doubles (MSL has none outside Apple's own code) |
|
||||
| `Format` | A pixel or vertex format not supported for the required use | devices without VkFeature::ShaderStorageImageExtendedFormats; devices without a capability the site computes (`alternatives`); devices without a capability the site computes (`missing`); devices without a capability the site computes (`routes`); devices without a format's usage; every device (no Vulkan mechanism); every device (not implemented) | `ours` | 47: `crates/metal2vulkan/src/lower/access/tile.rs (storage_format)`, `crates/metal2vulkan/src/lower/fragment/color.rs (select_param, 5 sites)` (+25) | `system`: pixel formats a device lacks for a use (CoreVideo's 4:2:x and 10-bit formats among them) |
|
||||
| `Format` | A pixel or vertex format not supported for the required use | devices without VkFeature::ShaderStorageImageExtendedFormats; devices without a capability the site computes (`alternatives`); devices without a capability the site computes (`missing`); devices without a capability the site computes (`routes`); devices without a format's usage; every device (no Vulkan mechanism); every device (not implemented) | `ours` | 46: `crates/metal2vulkan/src/lower/access/tile.rs (storage_format)`, `crates/metal2vulkan/src/lower/fragment/color.rs (select_param, 5 sites)` (+24) | `system`: pixel formats a device lacks for a use (CoreVideo's 4:2:x and 10-bit formats among them) |
|
||||
| `DivergentImplicitLod` | Divergent implicit-LOD sampling or LOD query through a multi-candidate handle | every device (not implemented) | `ours` | 1: `crates/metal2vulkan/src/lower/sampler/select.rs (tangled)` | `app`: implicit-LOD sampling through a dynamically chosen texture |
|
||||
| `ImplicitLodOutsideFragment` | Implicit-LOD sampling outside fragment | every device (not implemented) | `ours` | 3: `crates/metal2vulkan/src/lower/sampler/constexpr.rs (query_min_level)`, `crates/metal2vulkan/src/lower/sampler/select.rs (query_level_measured)` (+1) | `rare`: implicit-LOD sampling outside fragment functions |
|
||||
| `MinLodClamp` | `min_lod_clamp` without `shaderResourceMinLod` | devices without VkFeature::ShaderResourceMinLod; every device (not implemented) | `ours` | 2: `crates/metal2vulkan/src/lower/sampler/select.rs (min_lod)`, `crates/metal2vulkan/src/lower/sampler/select.rs (select_one)` | `rare`: min_lod_clamp on a device without shaderResourceMinLod |
|
||||
@@ -153,7 +153,6 @@ Columns:
|
||||
| `DepthClipClamp` | The render encoder's `MTLDepthClipModeClamp` (`depthClampEnable`) on a device without `depthClamp` | devices short of a Vulkan feature the site names | `device` | via a helper: 1: `crates/metal2vulkan/src/metal/state.rs (depth_clamp_enable)` | `app`: depth clamp on a device without depthClamp |
|
||||
| `DepthBiasClamp` | The render encoder's depth bias clamp, nonzero with a nonzero bias, on a device without `depthBiasClamp` | devices short of a Vulkan feature the site names | `device` | via a helper: 1: `crates/metal2vulkan/src/metal/state.rs (depth_bias)` | `app`: depth bias clamp on a device without depthBiasClamp |
|
||||
| `ConstantAlphaBlendFactor` | `CONSTANT_ALPHA` or `ONE_MINUS_CONSTANT_ALPHA` (Metal's `BlendAlpha` factors) as a color blend factor on a portability-subset device without... | devices without VkFeature::ConstantAlphaColorBlendFactors | `device` | 1: `crates/metal2vulkan/src/metal/state.rs (check_constant_alpha)` | `app`: blend-alpha factors on a portability-subset device without them |
|
||||
| `SparseTexture` | A sparse texture (`MTLTexture.isSparse`) bound at `slot`, where a function observes the residency of its accesses (`sparse_color::resident()`) and... | - | `-` | 0 | `rare`: sparse residency reads |
|
||||
| `TextureSwizzle` | A texture swizzle whose Metal behavior is not measured | every device (not implemented) | `ours` | 5: `crates/metal2vulkan/src/bind/heap.rs (member_texel_view)`, `crates/metal2vulkan/src/lower/sampler/select.rs (select_one)` (+3) | `app`: texture swizzles whose Metal behaviour is unmeasured |
|
||||
| `PrivateMemory` | A stage whose private memory (its `thread` variables and arrays, and the constants it holds per thread) takes more Function storage a thread than... | devices without a capability the site computes (`limit`) | `device` | 1: `crates/metal2vulkan/src/lower/access/local.rs (device_arena)` | `rare`: very large per-thread arrays |
|
||||
| `Reflection` | Reflection of an argument whose answer Metal's has not been measured for (`reflection`) | every device (not implemented) | `ours` | 8: `crates/metal2vulkan/src/reflection/derive.rs (gap_at)`, `crates/metal2vulkan/src/reflection/derive.rs (read_attributes)` (+6) | `rare`: reflection of argument kinds Metal's answer is unmeasured for |
|
||||
@@ -417,7 +416,7 @@ Each refusal's sites, with the function that builds it.
|
||||
- `feature::ImageAtomics`: `crates/metal2vulkan/src/lower/texture/atomic.rs (select)`
|
||||
- `feature::DescriptorCount`: `crates/metal2vulkan/src/lower/select.rs (finish)`; `crates/metal2vulkan/src/pipeline/link.rs (limit_error)`
|
||||
- `feature::Float64Arithmetic`: `crates/metal2vulkan/src/device/metal.rs (unsupported_features)`; `crates/metal2vulkan/src/lower/arith/legal.rs (check_scalar)`
|
||||
- `feature::Format`: `crates/metal2vulkan/src/lower/access/tile.rs (storage_format)`; `crates/metal2vulkan/src/lower/fragment/color.rs (select_param, 5 sites)`; `crates/metal2vulkan/src/lower/sampler/select.rs (select_extended)`; `crates/metal2vulkan/src/lower/stage_io/extended_color.rs (plan, 2 sites)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs (entry)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs (zeroed_output)`; `crates/metal2vulkan/src/lower/stage_io/word_color.rs (plan)`; `crates/metal2vulkan/src/lower/texture/mod.rs (select)`; `crates/metal2vulkan/src/lower/texture/mod.rs (select_image)`; `crates/metal2vulkan/src/lower/texture/mod.rs (select_read)`; `crates/metal2vulkan/src/lower/texture/slot.rs (atomic_format, 2 sites)`; `crates/metal2vulkan/src/lower/texture/slot.rs (declare_slot)`; `crates/metal2vulkan/src/lower/texture/slot.rs (storage_format, 6 sites)`; `crates/metal2vulkan/src/lower/texture/slot.rs (ulong_format, 3 sites)`; `crates/metal2vulkan/src/lower/texture/words.rs (not_built)`; `crates/metal2vulkan/src/metal/format/mod.rs (candidates)`; `crates/metal2vulkan/src/metal/format/mod.rs (held_storage_choice, 3 sites)`; `crates/metal2vulkan/src/metal/format/mod.rs (storage_choice)`; `crates/metal2vulkan/src/metal/format/mod.rs (vk_format, 2 sites)`; `crates/metal2vulkan/src/metal/vertex.rs (fetch_as, 2 sites)`; `crates/metal2vulkan/src/pipeline/color_writes.rs (rotated_blend_in_shader)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs (extended_write_mask, 2 sites)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs (graphics_state, 2 sites)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs (reads_alpha_to_coverage, 2 sites)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs (textured_fetches)`; `crates/metal2vulkan/src/pipeline/rotated_blend.rs (alpha_in_red_blend)`; `crates/metal2vulkan/src/pipeline/rotated_blend.rs (rotated_blend)`
|
||||
- `feature::Format`: `crates/metal2vulkan/src/lower/access/tile.rs (storage_format)`; `crates/metal2vulkan/src/lower/fragment/color.rs (select_param, 5 sites)`; `crates/metal2vulkan/src/lower/sampler/select.rs (select_extended)`; `crates/metal2vulkan/src/lower/stage_io/extended_color.rs (plan, 2 sites)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs (entry)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs (zeroed_output)`; `crates/metal2vulkan/src/lower/stage_io/word_color.rs (plan)`; `crates/metal2vulkan/src/lower/texture/mod.rs (select)`; `crates/metal2vulkan/src/lower/texture/mod.rs (select_image)`; `crates/metal2vulkan/src/lower/texture/slot.rs (atomic_format, 2 sites)`; `crates/metal2vulkan/src/lower/texture/slot.rs (declare_slot)`; `crates/metal2vulkan/src/lower/texture/slot.rs (storage_format, 6 sites)`; `crates/metal2vulkan/src/lower/texture/slot.rs (ulong_format, 3 sites)`; `crates/metal2vulkan/src/lower/texture/words.rs (not_built)`; `crates/metal2vulkan/src/metal/format/mod.rs (candidates)`; `crates/metal2vulkan/src/metal/format/mod.rs (held_storage_choice, 3 sites)`; `crates/metal2vulkan/src/metal/format/mod.rs (storage_choice)`; `crates/metal2vulkan/src/metal/format/mod.rs (vk_format, 2 sites)`; `crates/metal2vulkan/src/metal/vertex.rs (fetch_as, 2 sites)`; `crates/metal2vulkan/src/pipeline/color_writes.rs (rotated_blend_in_shader)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs (extended_write_mask, 2 sites)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs (graphics_state, 2 sites)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs (reads_alpha_to_coverage, 2 sites)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs (textured_fetches)`; `crates/metal2vulkan/src/pipeline/rotated_blend.rs (alpha_in_red_blend)`; `crates/metal2vulkan/src/pipeline/rotated_blend.rs (rotated_blend)`
|
||||
- `feature::DivergentImplicitLod`: `crates/metal2vulkan/src/lower/sampler/select.rs (tangled)`
|
||||
- `feature::ImplicitLodOutsideFragment`: `crates/metal2vulkan/src/lower/sampler/constexpr.rs (query_min_level)`; `crates/metal2vulkan/src/lower/sampler/select.rs (query_level_measured)`; `crates/metal2vulkan/src/lower/sampler/select.rs (query_min_level)`
|
||||
- `feature::MinLodClamp`: `crates/metal2vulkan/src/lower/sampler/select.rs (min_lod)`; `crates/metal2vulkan/src/lower/sampler/select.rs (select_one)`
|
||||
|
||||
Reference in new issue
Block a user