Depth stand-ins go: no variant runs its draw's depth or stencil test in the shader

The runtime asks for every render variant with VariantKey::new() (render.rs) and never states
FragmentTests, so VariantKey::shader_tests, shader_stencil and window_depth_varying are false on
its path. No variant it makes tests a fragment's depth or stencil against a stand-in of the pass's
attachment. That variant, its stand-ins and their consumer contract are deleted. The consumer
names none of them on its development branch (consumer check below).

The binder: for a fragment function that stores before Vulkan's tests (TestedStorageWrites), a
draw whose depth test writes (FragmentTests::Depth { writes: true }) or whose stencil test acts
(Stencil, or Drop for a function without the early-tests variant) ran the in-shader variant. It is
now refused NotImplemented at the tested attachment, of the feature that stores first
(FramebufferFetch, or Imageblocks for an imageblock alone):
- a function with the early-tests variant: at the depth attachment for Depth, at the stencil
  attachment for Stencil;
- a function without it: at the depth attachment, or the stencil one where the pass has no depth,
  as Any already was.
A draw whose tests drop but write and count nothing keeps the early-tests variant, and one whose
tests drop nothing runs the pipeline as compiled, as before.

Removed:
- the inputs and keys: VariantKey and LoweringInputs::{shader_tests, shader_stencil,
  window_depth_varying}, and their key bytes;
- the lowering: lower/fragment/depth_test.rs (DepthTest, StencilTest, depth_test_form,
  stencil_test_form, depth_test_word, stencil_test_word, STAND_IN_FORMAT) and its calls from
  fetch's and the imageblock's tests, and the stencil output stage_io stored nowhere under it;
- the window depth varying: IoRole::WindowDepth, VaryingKey::window_depth, the vertex function's
  store (stage_io's WindowDepth) and the fragment's input, and its link checks;
- the facts and state: RuntimeFact::ShaderTests and ShaderStencilTest, GraphicsState::shader_tests,
  ShaderTestsUse, StandInUse, StandInView, link/shader_tests.rs, and compile::api's stand-in
  requirements;
- the bindings: SyntheticBinding::DepthStandIn and StencilStandIn, WriteSource::DepthStandIn and
  StencilStandIn, PushField::ShaderTestsState and ShaderStencilState, the binder's push words and
  ShaderTestsTemplate, and BindState::{depth_range, depth_clip_mode_clamp, stencil_references},
  which only those words read;
- the copies: DepthStencilCopy::DepthFromStandIn, DepthStandInForm, DepthSplitModule and
  depth_split_module;
- the notes and kinds: PrecisionNote::ComputedSampleDepth (and its conformance Degradation, C3
  deferral and comparison rows, and its catalogue entry in docs/API.md),
  Feature::MultisampledShaderDepthTest (and its reach row), DriverDeviation and VkProperty
  CenterFragCoordDepth and SampleFragCoordDepth, which nothing else reads;
- DrawReplayRule::ShaderTests, and the mechanism rows of the two facts;
- the runtime's translator_fields row for shader_tests.

Tests:
- engine_fragment: the discarding fetch beside depth expects a depth test that writes refused at
  the depth attachment and a stencil test that acts at the stencil attachment. The per-sample
  depth test, the memory-writing fetch's Drop draw, a returned depth
  (a_fetch_that_returns_its_depth_refuses_a_draw_whose_depth_test_writes, which keeps the compiled
  pipeline's checks) and a returned stencil or mask
  (a_returned_stencil_or_sample_mask_refuses_a_draw_whose_tests_act) expect the refusal. The
  stencil test in the shader goes.
- engine_fragment_imageblock: a tested imageblock writer's depth draw is refused
  NotImplemented(Imageblocks) at the depth attachment.
- engine_moved_writers: the writers' wanted tests are the early-tests variant alone; a draw that
  ran the function's own tests is refused.
- depth_stencil_copy, owned_divisions, the mechanism table, api_tests, the binder's templates, the
  variant key's debug text: their stand-in rows go. The binder's stencil words test goes.

api_surface loses its rows; api_signatures is blessed; docs/REFUSALS.md is regenerated.

SEMANTICS_VERSION 2227, ARTIFACT_FORMAT_VERSION 572, RUNTIME_VERSION 2547 (placeholders; main
renumbers). SEMANTICS: the binder's plans of such draws change, and the key bytes go. ARTIFACT: the
codec loses SyntheticBinding, PushField, RuntimeFact, IoRole, VkProperty and PrecisionNote variants,
GraphicsState's field and three structs. RUNTIME: plans and BindState change. The runtime pin
moves.

Consumer check (consumer-uses.sh, consumer development 0140a12682, 61 refs): 0 hits (code) for
ShaderTestsUse, StandInUse, StandInView, shader_tests, shader_stencil, window_depth_varying,
DepthStandInForm, DepthSplitModule, depth_split_module, DepthFromStandIn,
MultisampledShaderDepthTest, CenterFragCoordDepth, SampleFragCoordDepth, ShaderTestsState,
ShaderStencilState, DepthStandIn, StencilStandIn, WindowDepth, window_depth, stencil_references,
depth_clip_mode_clamp, ShaderStencilTest, DepthTest and ShaderTests; depth_range in link-order
lists only. ComputedSampleDepth: 0 on development; used in crates/reims-vgpu-vulkan/src/answer.rs
on 38 of the consumer's steelbrain/* branches, a crate its development no longer has.

Verified: m3-max-61056 (msi) at this commit's tree: fmt, clippy, Rustdoc, and nextest of
metal2vulkan, -conformance, -validation and -runtime, 5885 of 5886 passed; the one failure is
the_old_render_descriptor_key_keeps_its_value, which moves with SEMANTICS_VERSION (main pins it).
States-only plays on lavapipe of the probe player built at the change on 999b82bfe2
(steelbrain/cutxlate-siplay, m3-max-61016): m3-max-61022 to 61026, 61 runs over the 36 streams,
render 502920 states made and 0 refused, compute 108189 made and 0 refused, the counts of the play
before the change: no state a stream makes meets the new refusal.
This commit is contained in:
Anees Iqbal committed 2026-11-20 18:07:17 -08:00
1 parent 8529ecbd09
commit a8d448f4ce
54 files changed
+199 -2674

No files matched your search

@@ -109,8 +109,6 @@ pub enum Degradation {
RotatedBlendRounding,
/// `metal2vulkan-degrade-linked-sampler-numbering`.
LinkedSamplerNumbering,
/// `metal2vulkan-degrade-computed-sample-depth`.
ComputedSampleDepth,
/// `metal2vulkan-degrade-argument-pixel-sampler-scaling`.
ArgumentPixelSamplerScaling,
/// `metal2vulkan-degrade-half-output-precision`.
@@ -241,7 +239,6 @@ impl Degradation {
Degradation::BlendedWriteRounding,
Degradation::RotatedBlendRounding,
Degradation::LinkedSamplerNumbering,
Degradation::ComputedSampleDepth,
Degradation::ArgumentPixelSamplerScaling,
Degradation::HalfOutputPrecision,
Degradation::ExtendedRangeBlendSource,
@@ -356,7 +353,6 @@ impl Degradation {
Degradation::BlendedWriteRounding => "metal2vulkan-degrade-blended-write-rounding",
Degradation::RotatedBlendRounding => "metal2vulkan-degrade-rotated-blend-rounding",
Degradation::LinkedSamplerNumbering => "metal2vulkan-degrade-linked-sampler-numbering",
Degradation::ComputedSampleDepth => "metal2vulkan-degrade-computed-sample-depth",
Degradation::ArgumentPixelSamplerScaling => {
"metal2vulkan-degrade-argument-pixel-sampler-scaling"
}
@@ -467,7 +463,6 @@ impl Degradation {
PrecisionNote::BlendedWriteRounding => Degradation::BlendedWriteRounding,
PrecisionNote::RotatedBlendRounding => Degradation::RotatedBlendRounding,
PrecisionNote::LinkedSamplerNumbering => Degradation::LinkedSamplerNumbering,
PrecisionNote::ComputedSampleDepth => Degradation::ComputedSampleDepth,
PrecisionNote::ArgumentPixelSamplerScaling => Degradation::ArgumentPixelSamplerScaling,
PrecisionNote::HalfOutputPrecision => Degradation::HalfOutputPrecision,
PrecisionNote::ExtendedRangeBlendSource => Degradation::ExtendedRangeBlendSource,
@@ -101,7 +101,6 @@ const GRAPHICS_STATE: &[(&str, Verdict)] = &[
Fact("the runtime takes every attachment of a draw's pass as written"),
),
("sample_mask", Applied),
("shader_tests", Refused(VARIANT)),
("snapshot_reads", Refused(VARIANT)),
(
"color_group",
@@ -1 +1 @@
9052663b837f14f037ccc58cd8b61c3a412416b96ce89310e5ec80bb597c6473
c2ecce5df86b7f8bb3c6ca10091d3f0dfdb814b9eec8d2befc31c8d17eb5111c
+1 -14
View File
@@ -751,11 +751,6 @@ pub struct SlotRow {
/// (`RotatedBlendRounding`): Apple's blend computes a factor pair apart in its color and alpha
/// arithmetic, which the rotation swaps for Metal's alpha and blue, and the stored code is
/// ordinary data later words use. Open until the blend state has a measured form.
/// - A fragment function that runs its draw's depth test itself at more than one sample from
/// each sample's computed depth (`ComputedSampleDepth`): under perspective, a slope-scaled bias
/// or another depth range a sample's depth may be up to 2 ulp from the device's, so a close test
/// may decide otherwise and keep or drop a sample's color. Open until the sample's own depth is
/// read exactly.
///
/// A varying the device interpolates (`DeviceInterpolation`) is not deferred: every fragment
/// function that reads one records it on every device but MoltenVK's, so a row-level deferral
@@ -768,7 +763,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; 10] = [
pub const DEFERRED_NEAR_EQUIVALENTS: [PrecisionNote; 9] = [
PrecisionNote::RasterizationRateMap,
PrecisionNote::SparseResidency,
PrecisionNote::CubeGradientFootprint,
@@ -778,7 +773,6 @@ pub const DEFERRED_NEAR_EQUIVALENTS: [PrecisionNote; 10] = [
PrecisionNote::BlendedWriteRounding,
PrecisionNote::CoverageReadsRoundedAlpha,
PrecisionNote::RotatedBlendRounding,
PrecisionNote::ComputedSampleDepth,
];
/// Why a case stays open in a slot although its difference is known: deferred until an exact
@@ -887,13 +881,6 @@ fn near_equivalent_bound(note: PrecisionNote) -> &'static str {
and Metal's alpha into its red (up to 1,767 of 65,536 tie-heavy texels over 440 \
swept states); exact path: a measured form for the state"
}
PrecisionNote::ComputedSampleDepth => {
"a fragment function that runs its draw's depth test itself at more than one sample \
computes each sample's depth from its vertex function's window depth; under \
perspective, a slope-scaled bias or another depth range it may be up to 2 ulp from \
the depth the device stores, so a close test may decide \
otherwise; exact path: the sample's own depth read exactly"
}
_ => "unbounded",
}
}
@@ -304,7 +304,6 @@ pub fn allowance(note: PrecisionNote) -> Allowance {
| N::QuadsCountedBeforeDiscard
| N::DeviceInterpolation
| N::ExtrapolatedInterpolation
| N::ComputedSampleDepth
| N::QuadsSplitByClipping
| N::FragmentSimdgroupGrouping
| N::BlendedWriteRounding
@@ -75,7 +75,6 @@ fn every_precision_note_has_its_table_row() {
(N::CoverageReadsRoundedAlpha, Allowance::Unbounded),
(N::DeviceAlphaCoverage, Allowance::Unbounded),
(N::RotatedBlendRounding, Allowance::Unbounded),
(N::ComputedSampleDepth, Allowance::Unbounded),
(N::UnorderedFetchWithinDraw, Allowance::Unbounded),
(N::NativeLogicOperation, Allowance::Unbounded),
(N::NativeFloat8, Allowance::Unbounded),
@@ -48,15 +48,6 @@
//! The fragment stage reads `SampleId`, so it runs once per sample (`sampleRateShading`): the
//! consumer enables sample shading with `minSampleShading` 1, and each invocation writes its own
//! sample. A pixel's `FragCoord` is its center, `(x + 0.5, y + 0.5)`, truncated to `(x, y)`.
//! - **The depth stand-in's copy back** ([`DepthStencilCopy::DepthFromStandIn`]): the draw's
//! fragment stage reads sample `SampleId` of pixel `FragCoord.xy` of a depth stand-in, an
//! `R32_SFLOAT` storage image ([`DepthStandInForm`]: multisampled, or the sample planes of a 2D
//! array whose layer `s` holds sample `s`), and writes it as `FragDepth`, as
//! [`DepthStencilCopy::Depth`] does from an aspect.
//! - **The depth split** ([`DepthSplitModule`]): as the stencil split below, from the float depth
//! aspect into a depth stand-in of either form: the stand-in's copy in. Its invocation `(x, y,
//! s)` inside the stand-in's extent and the source's samples writes sample `s` of texel `(x, y)`
//! of a multisampled stand-in, or texel `(x, y, s)` of the planes.
//! - **The stencil split** ([`StencilSplitModule`]): a `GLCompute` entry `main` with local size
//! ([`StencilSplitModule::LOCAL_SIZE`], [`StencilSplitModule::LOCAL_SIZE`], 1) whose invocation
//! `(x, y, s)` inside the destination fetches sample `s` of pixel `(x, y)` of the unsigned source
@@ -142,59 +133,6 @@ pub enum DepthStencilCopy {
/// of the unsigned colour output at `Location` 0, from a sampled view of a 16-bit depth
/// aspect: a 16-bit depth's copy out, exact by construction (the module docs).
Depth16Bits,
/// The depth, as `FragDepth`, from a depth stand-in of `form`.
DepthFromStandIn { form: DepthStandInForm },
}
/// The form of a depth stand-in: an `R32_SFLOAT` storage image of the pass's extent that holds its
/// depth attachment's samples while a fragment function tests depth itself.
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum DepthStandInForm {
/// A multisampled 2D image: sample `s` of texel `(x, y)` holds sample `s` of pixel `(x, y)`
/// (`shaderStorageImageMultisample`).
Multisampled,
/// Sample planes: a single-sample 2D-array image whose texel `(x, y)` of layer `s` holds sample
/// `s` of pixel `(x, y)`.
SamplePlanes,
}
/// The crate-owned depth split of one device and stand-in form, validated like any output.
#[non_exhaustive]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct DepthSplitModule {
/// SPIR-V 1.5 words, entry point `main`, bindings numbered as below in set 0.
pub spirv: Arc<[u32]>,
/// What the module needs from the device: multisampled storage images for a multisampled
/// stand-in.
pub requirements: Requirements,
}
impl DepthSplitModule {
/// Descriptor set of every binding.
pub const SET: u32 = 0;
/// The source, a sampled image of the depth aspect.
pub const SOURCE_BINDING: u32 = 0;
/// The destination, the stand-in's `R32_SFLOAT` storage image.
pub const DESTINATION_BINDING: u32 = 1;
/// Invocations of one workgroup along x, and along y.
pub const LOCAL_SIZE: u32 = 8;
}
/// The `R32_SFLOAT` storage image type of a depth stand-in of `form` (`f32_` the float type).
fn stand_in_image(b: &mut ModuleBuilder, f32_: TypeId, form: DepthStandInForm) -> BResult<TypeId> {
let format = crate::spv::ImageFormat::R32f;
match form {
DepthStandInForm::Multisampled => multisampled_image(b, f32_, ImageUsage::Storage, format),
DepthStandInForm::SamplePlanes => b.ty(Type::Image(ImageType {
sampled_type: f32_,
dim: Dim::D2,
depth: false,
arrayed: true,
multisampled: false,
usage: ImageUsage::Storage,
format,
})),
}
}
/// The crate-owned modules of one copy draw on one device, validated like any output.
@@ -324,15 +262,9 @@ pub fn fragment_typed_module(copy: DepthStencilCopy) -> BResult<TypedModule> {
| DepthStencilCopy::DepthBits
| DepthStencilCopy::StencilBits
| DepthStencilCopy::Depth16Code
| DepthStencilCopy::Depth16Bits
| DepthStencilCopy::DepthFromStandIn { .. } => CopySource::Aspect,
};
let stand_in = match copy {
DepthStencilCopy::DepthFromStandIn { form } => Some(form),
_ => None,
| DepthStencilCopy::Depth16Bits => CopySource::Aspect,
};
let source_ty = match (copy, source) {
(DepthStencilCopy::DepthFromStandIn { form }, _) => stand_in_image(&mut b, f32_, form)?,
(
DepthStencilCopy::Depth | DepthStencilCopy::DepthBits | DepthStencilCopy::Depth16Bits,
_,
@@ -375,19 +307,9 @@ pub fn fragment_typed_module(copy: DepthStencilCopy) -> BResult<TypedModule> {
sample: Some(sample),
..ImageOperands::default()
};
let texel = match (stand_in, source) {
(Some(DepthStandInForm::Multisampled), _) => {
f.read(image, pixel, &ops, TexelMemory::default())?
}
(Some(DepthStandInForm::SamplePlanes), _) => {
let uvec3 = f.module().ty(Type::Vector { elem: u32_, len: 3 })?;
let layer = f.convert(ConvOp::Bitcast, sample, u32_)?;
let at = f.composite_construct(uvec3, &[x, y, layer])?;
let plain = ImageOperands::default();
f.read(image, at, &plain, TexelMemory::default())?
}
(None, CopySource::Aspect) => f.fetch(image, pixel, &ops)?,
(None, CopySource::Shadow) => f.read(image, pixel, &ops, TexelMemory::default())?,
let texel = match source {
CopySource::Aspect => f.fetch(image, pixel, &ops)?,
CopySource::Shadow => f.read(image, pixel, &ops, TexelMemory::default())?,
};
let value = f.composite_extract(texel, &[0])?;
match copy {
@@ -411,7 +333,7 @@ pub fn fragment_typed_module(copy: DepthStencilCopy) -> BResult<TypedModule> {
let output = f.module().global_value(output)?;
f.store(output, reference, MemAccess::default())?;
}
DepthStencilCopy::Depth | DepthStencilCopy::DepthFromStandIn { .. } => {
DepthStencilCopy::Depth => {
let output = f
.module()
.builtin(crate::spv::BuiltIn::FragDepth, IoDir::Output, f32_)?;
@@ -461,9 +383,9 @@ pub fn fragment_typed_module(copy: DepthStencilCopy) -> BResult<TypedModule> {
match copy {
DepthStencilCopy::StencilPlane { .. } => {}
DepthStencilCopy::StencilExport { .. } => modes.push(ExecMode::StencilRefReplacing),
DepthStencilCopy::Depth
| DepthStencilCopy::Depth16Code
| DepthStencilCopy::DepthFromStandIn { .. } => modes.push(ExecMode::DepthReplacing),
DepthStencilCopy::Depth | DepthStencilCopy::Depth16Code => {
modes.push(ExecMode::DepthReplacing)
}
DepthStencilCopy::DepthBits
| DepthStencilCopy::StencilBits
| DepthStencilCopy::Depth16Bits => {}
@@ -553,97 +475,6 @@ pub fn split_typed_module() -> BResult<TypedModule> {
b.finalize()
}
/// The depth split into a stand-in of `form` as a typed module, before serialization: the module
/// [`depth_split_module`] serializes. Its bindings are the symbols [`SPLIT_SOURCE`] and
/// [`SPLIT_DESTINATION`], numbered as the stencil split's.
pub fn depth_split_typed_module(form: DepthStandInForm) -> BResult<TypedModule> {
let mut b = ModuleBuilder::new();
let u32_ = u32_ty(&mut b)?;
let f32_ = b.ty(Type::Float { width: 32 })?;
let uvec2 = b.ty(Type::Vector { elem: u32_, len: 2 })?;
let uvec3 = b.ty(Type::Vector { elem: u32_, len: 3 })?;
let source_ty = multisampled_image(
&mut b,
f32_,
ImageUsage::Sampled,
crate::spv::ImageFormat::Unknown,
)?;
let destination_ty = stand_in_image(&mut b, f32_, form)?;
let source = b.resource(SPLIT_SOURCE, StorageClass::UniformConstant, source_ty)?;
let destination = b.resource(
SPLIT_DESTINATION,
StorageClass::UniformConstant,
destination_ty,
)?;
let invocation = b.builtin(crate::spv::BuiltIn::GlobalInvocationId, IoDir::Input, uvec3)?;
let void = b.ty(Type::Void)?;
let mut f = b.function(void)?;
let invocation = f.module().global_value(invocation)?;
let invocation = f.load(invocation, MemAccess::default())?;
let destination = f.module().global_value(destination)?;
let destination = f.load(destination, MemAccess::default())?;
let source = f.module().global_value(source)?;
let source = f.load(source, MemAccess::default())?;
let size = f.query(ImageQuery::Size, destination)?;
let samples = f.query(ImageQuery::Samples, source)?;
let mut inside = None;
for axis in 0..3 {
let at = f.composite_extract(invocation, &[axis])?;
let end = if axis < 2 {
f.composite_extract(size, &[axis])?
} else {
samples
};
let below = f.binary(BinOp::ULessThan, at, end)?;
inside = Some(match inside {
None => below,
Some(all) => f.binary(BinOp::LogicalAnd, all, below)?,
});
}
let inside = inside.ok_or(crate::spirv::error::BuildError::IdSpaceExhausted)?;
// Invocation `(x, y, s)` inside the stand-in copies sample `s` of pixel `(x, y)`.
let copy_sample: ArmFn<'_, ()> = Box::new(move |f, _| {
let x = f.composite_extract(invocation, &[0])?;
let y = f.composite_extract(invocation, &[1])?;
let s = f.composite_extract(invocation, &[2])?;
let pixel = f.composite_construct(uvec2, &[x, y])?;
let ops = ImageOperands {
sample: Some(s),
..ImageOperands::default()
};
let texel = f.fetch(source, pixel, &ops)?;
match form {
DepthStandInForm::Multisampled => {
f.write(destination, pixel, texel, &ops, TexelMemory::default())?;
}
DepthStandInForm::SamplePlanes => {
let plain = ImageOperands::default();
f.write(
destination,
invocation,
texel,
&plain,
TexelMemory::default(),
)?;
}
}
Ok(ArmEnd::FallThrough(Vec::new()))
});
f.if_(&mut (), inside, copy_sample, None)?;
f.ret(None)?;
let id = f.finish()?;
b.entry(
ExecModel::GLCompute,
id,
vec![ExecMode::LocalSize {
x: DepthSplitModule::LOCAL_SIZE,
y: DepthSplitModule::LOCAL_SIZE,
z: 1,
}],
)?;
b.finalize()
}
/// The fixed binding numbers of the modules' symbols.
fn binding_of(sym: &Symbol) -> Option<u32> {
match sym {
@@ -729,25 +560,5 @@ pub fn stencil_split_module(
})
}
/// The depth split into a stand-in of `form` on `device`, built and checked as
/// [`depth_stencil_copy_modules`] is; refused likewise where the device lacks what it needs
/// (multisampled storage images, for a multisampled stand-in).
pub fn depth_split_module(
device: &Device,
form: DepthStandInForm,
feature: Feature,
) -> Result<DepthSplitModule, Error> {
let (spirv, requirements) = finish(
device,
depth_split_typed_module(form)?,
&feature,
"depth split",
)?;
Ok(DepthSplitModule {
spirv,
requirements,
})
}
#[cfg(test)]
mod tests;
@@ -23,18 +23,9 @@ fn every_copy() -> Vec<DepthStencilCopy> {
copies.push(DepthStencilCopy::StencilBits);
copies.push(DepthStencilCopy::Depth16Code);
copies.push(DepthStencilCopy::Depth16Bits);
for form in FORMS {
copies.push(DepthStencilCopy::DepthFromStandIn { form });
}
copies
}
/// Both depth stand-in forms.
const FORMS: [DepthStandInForm; 2] = [
DepthStandInForm::Multisampled,
DepthStandInForm::SamplePlanes,
];
/// The requirements of `m` as serialized.
fn needs(m: TypedModule) -> Requirements {
crate::spirv::serialize::serialize(m)
@@ -73,8 +64,6 @@ fn each_module_needs_what_its_docs_say() {
..
} | DepthStencilCopy::StencilExport {
source: CopySource::Shadow
} | DepthStencilCopy::DepthFromStandIn {
form: DepthStandInForm::Multisampled
}
);
assert_eq!(
@@ -92,26 +81,6 @@ fn each_module_needs_what_its_docs_say() {
assert!(r.features.contains(&feature), "{feature:?}: {r:?}");
}
assert!(!r.features.contains(&VkFeature::SampleRateShading), "{r:?}");
// The depth split: multisampled storage images for a multisampled stand-in alone, and no
// extended format (`R32_SFLOAT` is a base storage format) nor sample-rate shading.
for form in FORMS {
let r = needs(depth_split_typed_module(form).expect("depth split"));
assert_eq!(
r.features
.contains(&VkFeature::ShaderStorageImageMultisample),
form == DepthStandInForm::Multisampled,
"{form:?}: {r:?}"
);
assert!(
!r.features
.contains(&VkFeature::ShaderStorageImageExtendedFormats),
"{form:?}: {r:?}"
);
assert!(
!r.features.contains(&VkFeature::SampleRateShading),
"{form:?}: {r:?}"
);
}
}
/// Every committed device (`validation/profiles/*.json`), derived with the default policy, by
@@ -181,34 +150,6 @@ fn the_modules_are_valid_where_the_device_has_what_they_need() {
assert!(draws > 0 && splits > 0, "{draws} {splits}");
}
/// On every committed device the depth split into each stand-in form is valid where the device
/// has what it needs and refused, typed, where it does not; the planes' form runs on every
/// committed device (it needs no multisampled storage image).
#[test]
fn the_depth_split_is_valid_where_the_device_has_what_it_needs() {
let feature = Feature::FramebufferFetch;
for (name, device) in committed_devices() {
let profile = device.profile();
for form in FORMS {
let m = || depth_split_typed_module(form).expect("depth split");
let fit = profile.check(&needs(m())).is_ok();
match depth_split_module(&device, form, feature.clone()) {
Ok(module) => {
assert!(fit, "{name} {form:?}");
assert_valid(m(), profile);
assert!(!module.spirv.is_empty());
}
Err(Error::Unsupported(u)) => {
assert!(!fit, "{name} {form:?}");
assert!(form != DepthStandInForm::SamplePlanes, "{name}");
assert_eq!(u.feature, feature, "{name} {form:?}");
}
Err(other) => panic!("{name} {form:?}: {other}"),
}
}
}
}
/// The 16-bit depth pair's arithmetic is exact for **every** code: of all 65536 codes, each one
/// `Depth16Code` turns into a depth and `Depth16Bits` turns back lands on itself, whether or not
/// the device contracts the multiply and add into one fused operation, and the margin the
+44 -178
View File
@@ -144,12 +144,9 @@
//! `RuntimeFact::MovableStorageWrites`, which states the `early_variant` the moved writer's
//! variant states, where the pipeline as compiled states no `TestedStorageWrites`; a moved write
//! whose mask names none of the attachment's components stores nothing, and takes no tests. (A
//! draw whose depth test alone acts, `Depth`, runs the variant whose function runs it itself,
//! `VariantKey::shader_tests`, unless it writes nothing and the early-tests variant serves it;
//! one whose stencil test acts and whose tests write, `Stencil`, or a `Drop` draw of a function
//! without the early-tests variant, runs the variant whose function runs both,
//! `VariantKey::shader_stencil`, in a pass with a depth and a stencil attachment; a pass with a
//! stencil attachment alone is `NotImplemented(FramebufferFetch)` at it.)
//! draw whose depth test alone acts, `Depth`, is `NotImplemented(FramebufferFetch)` at the depth
//! attachment, unless it writes nothing and the early-tests variant serves it; one whose stencil
//! test acts and whose tests write, `Stencil`, is so at the stencil attachment.)
//! - **Draws.** A Metal draw maps to the Vulkan draw of the same arguments; an indirect draw is
//! GPU-side unless a stage reads `BaseVertexInstance` from push constants or the plan is
//! multiview, in which case `indirect_needs_arguments` asks for the CPU read.
@@ -292,8 +289,8 @@ use crate::bind::plan::slots::{
use crate::bind::plan::{
AccessClass, BindingPlan, BoundKind, ByteRange, DescriptorWrite, FactorTemplate, FieldLocation,
GraphicsTemplate, GroupLimits, GroupStage, MeshTemplate, PlannedVertexBuffer,
PushFieldPlacement, PushTemplate, ResourceUse, ShaderTestsTemplate, ShadowTemplate,
StageTemplate, StrideRules, UseTarget, VertexBufferBind, ViewSetup, WriteSource,
PushFieldPlacement, PushTemplate, ResourceUse, ShadowTemplate, StageTemplate, StrideRules,
UseTarget, VertexBufferBind, ViewSetup, WriteSource,
};
use crate::bind::resident::{stage_root_table, table_entries};
use crate::bind::state::{
@@ -988,8 +985,8 @@ fn plan(p: &RenderPipeline, device: &Device, shape: &BindShape) -> Result<Bindin
// run the same fragments (the pipeline differs only in its dynamic write masks), the first
// with every mask 0 running none of the function past its copy, so the pipeline may hold
// nothing else either draw writes, tests, or orders: one sample, no depth or stencil, no
// memory either function writes, no attachment, imageblock, tile memory, stencil shadow or
// stand-in of the storage form or an input attachment, and no other interlock. A tessellation
// memory either function writes, no attachment, imageblock, tile memory or stencil shadow of
// the storage form or an input attachment, and no other interlock. A tessellation
// or mesh pipeline's, and an amplified or layered draw's are not built.
// The device makes the variant's pipeline: its feedback loop flag and dynamic write masks
// need `attachmentFeedbackLoopLayout` and `extendedDynamicState3ColorWriteMask`.
@@ -1009,7 +1006,6 @@ fn plan(p: &RenderPipeline, device: &Device, shape: &BindShape) -> Result<Bindin
&& p.graphics.storage_attachments.is_empty()
&& p.graphics.input_attachments.is_empty()
&& p.graphics.fragment_imageblock.is_none()
&& p.graphics.shader_tests.is_none()
&& p.graphics.tessellation.is_none()
&& shadow.is_none()
&& tile_memory.is_none()
@@ -1113,94 +1109,46 @@ fn plan(p: &RenderPipeline, device: &Device, shape: &BindShape) -> Result<Bindin
Some(_) if p.graphics.storage_attachments.is_empty() => Feature::Imageblocks,
_ => Feature::FramebufferFetch,
};
// Where only the depth test can drop a fragment, the stencil test does nothing and nothing
// is counted, the variant whose function runs the depth test itself (`shader_tests`), where
// the device ships it at the pipeline's samples; a draw whose tests write nothing keeps the
// early-tests variant where the function has one.
let samples = p.graphics.rasterization_samples.as_raw().max(1);
// The variant whose function runs the depth test itself, and the stencil test too where
// `stencil`, or the refusal of the device or the attachment that lacks it.
let in_shader = |stencil: bool| -> Result<(bool, bool, bool, bool), BindError> {
// The stand-in holds 32-bit float depth (link refuses Metal's other depth formats).
let float = matches!(
p.graphics.depth_format,
Some(vk::Format::D32_SFLOAT | vk::Format::D32_SFLOAT_S8_UINT)
);
if !float {
return Err(BindError::Unsupported(
Unsupported::not_implemented(tested_feature.clone())
.at_attachment(Attachment::Depth),
));
}
// A function that returns its depth tests that, at every sample alike.
let form =
crate::lower::fragment::depth_test_form(profile, samples > 1, p.graphics.writes_depth)
.map_err(|refused| {
BindError::Unsupported(refused.at_attachment(Attachment::Depth))
})?;
if stencil {
crate::lower::fragment::stencil_test_form(profile, samples > 1).map_err(|refused| {
BindError::Unsupported(refused.at_attachment(Attachment::Stencil))
})?;
}
// Each sample's depth computed from the vertex function's window depth.
Ok((false, true, form.computed, stencil))
};
// A draw whose tests drop some fragments but write and count nothing runs the early-tests
// variant where the function has one; a draw whose tests may drop a fragment and write, or
// count, is not implemented, as the function stores before Vulkan's tests. The refusal is
// placed at the tested attachment: the depth one where the pipeline has one, else the
// stencil.
let depth = p.graphics.depth_format.is_some();
let stencil = p.graphics.stencil_format.is_some();
let (read_only_tests, shader_tests, window_depth_varying, shader_stencil) =
match (tested, shape.fragment_tests) {
(Some((_, true)), FragmentTests::Drop | FragmentTests::Depth { writes: false })
if tested_attachments =>
{
(true, false, false, false)
}
(Some(_), FragmentTests::Depth { .. }) if depth => in_shader(false)?,
// The stencil test acts (or, for a function without the early-tests variant, may):
// the function runs both tests, in a pass with both attachments. A pass with a
// stencil attachment alone has no depth for the form's attachment: not implemented,
// refused at the stencil attachment.
(Some(_), FragmentTests::Drop | FragmentTests::Stencil) if depth && stencil => {
in_shader(true)?
}
(Some(_), FragmentTests::Drop | FragmentTests::Stencil) if stencil => {
return Err(BindError::Unsupported(
Unsupported::not_implemented(tested_feature.clone())
.at_attachment(Attachment::Stencil),
));
}
// A function that writes other memory or returns depth, stencil, or a sample mask: its
// stores are Metal's only where no test can drop a fragment. The refusal is placed at
// the tested attachment (the depth one where the pipeline has one, else the stencil).
(
Some((_, false)),
FragmentTests::Drop
| FragmentTests::Depth { .. }
| FragmentTests::Any
| FragmentTests::Stencil,
) if tested_attachments => {
let at = match p.graphics.depth_format {
Some(_) => Attachment::Depth,
None => Attachment::Stencil,
};
return Err(BindError::Unsupported(
Unsupported::not_implemented(tested_feature.clone()).at_attachment(at),
));
}
(Some(_), FragmentTests::Any | FragmentTests::Stencil) if tested_attachments => {
return Err(not_implemented(tested_feature.clone()));
}
_ => (false, false, false, false),
};
let at = |attachment: Attachment| {
Err(BindError::Unsupported(
Unsupported::not_implemented(tested_feature.clone()).at_attachment(attachment),
))
};
let read_only_tests = match (tested, shape.fragment_tests) {
(Some((_, true)), FragmentTests::Drop | FragmentTests::Depth { writes: false })
if tested_attachments =>
{
true
}
// A function that writes other memory or returns depth, stencil, or a sample mask: its
// stores are Metal's only where no test can drop a fragment.
(
Some((_, false)),
FragmentTests::Drop
| FragmentTests::Depth { .. }
| FragmentTests::Any
| FragmentTests::Stencil,
) if tested_attachments => {
return at(match depth {
true => Attachment::Depth,
false => Attachment::Stencil,
});
}
(Some(_), FragmentTests::Depth { .. }) if depth => return at(Attachment::Depth),
(Some(_), FragmentTests::Stencil) if stencil => return at(Attachment::Stencil),
(Some(_), FragmentTests::Any | FragmentTests::Stencil) if tested_attachments => {
return Err(not_implemented(tested_feature.clone()));
}
_ => false,
};
let compiled_tests = tested.is_some_and(|(early, _)| early);
let compiled_shader_tests = p
.dependencies
.iter()
.any(|d| matches!(d.fact, RuntimeFact::ShaderTests { .. }));
let compiled_shader_stencil = p
.dependencies
.iter()
.any(|d| matches!(d.fact, RuntimeFact::ShaderStencilTest { .. }));
// A mesh entry's `Layer` at or past `maxMeshOutputLayers` is undefined: a pass of more layers
// than that, which a mesh function choosing its slice could render into, is past the device.
let mesh_layers = limits.mesh.max_mesh_output_layers;
@@ -1349,10 +1297,6 @@ fn plan(p: &RenderPipeline, device: &Device, shape: &BindShape) -> Result<Bindin
PushField::YCbCrInPlace(_) | PushField::TexelRows(_) => {}
// The encoder's stencil state, which instantiation reads from the state.
PushField::ShadowStencilState if stage == Stage::Fragment => {}
// The encoder's depth state, which instantiation reads from the state, and its
// stencil state and references.
PushField::ShaderTestsState | PushField::ShaderStencilState
if stage == Stage::Fragment => {}
// The encoder's viewport count, which instantiation reads from the state, in the
// stage that chooses a viewport (a mesh function per primitive).
PushField::ViewportCount if matches!(stage, Stage::Vertex | Stage::Mesh) => {}
@@ -1671,28 +1615,6 @@ fn plan(p: &RenderPipeline, device: &Device, shape: &BindShape) -> Result<Bindin
}),
}
}
// The depth attachment's stand-in: a plan asks for the variant only where the
// pipeline has a depth attachment, whose pipeline states its stand-in.
SyntheticBinding::DepthStandIn if stage == Stage::Fragment => {
match &p.graphics.shader_tests {
Some(_) => WriteSource::DepthStandIn,
None => {
return Err(internal("a depth stand-in without a depth attachment"))
}
}
}
// The stencil attachment's stand-in: a plan asks for the variant only where
// the pipeline has a depth and a stencil attachment.
SyntheticBinding::StencilStandIn if stage == Stage::Fragment => {
match p.graphics.shader_tests.and_then(|t| t.stencil) {
Some(_) => WriteSource::StencilStandIn,
None => {
return Err(internal(
"a stencil stand-in without a stencil attachment",
))
}
}
}
// The command buffer's status, on a device that does not address buffers.
SyntheticBinding::ExecutionStatus => WriteSource::ExecutionStatus,
// A fan-out variant's region table, and a probe's flags.
@@ -2118,9 +2040,6 @@ fn plan(p: &RenderPipeline, device: &Device, shape: &BindShape) -> Result<Bindin
variant.rotated_weights = rotated_weights;
variant.line_band = line_band;
variant.read_only_tests = read_only_tests;
variant.shader_tests = shader_tests;
variant.shader_stencil = shader_stencil;
variant.window_depth_varying = window_depth_varying;
variant.primitive_id_indices = primitive_id_indices;
variant.quad_primitive_ids = quad_primitive_ids;
variant.private_list = private_list;
@@ -2159,8 +2078,6 @@ fn plan(p: &RenderPipeline, device: &Device, shape: &BindShape) -> Result<Bindin
|| compiled_rotated != rotated_weights
|| compiled_band != line_band
|| compiled_tests != read_only_tests
|| compiled_shader_tests != shader_tests
|| compiled_shader_stencil != shader_stencil
|| compiled_quads != quad_primitive_ids
|| compiled_list != private_list
|| compiled_regions != region_viewports
@@ -2190,11 +2107,6 @@ fn plan(p: &RenderPipeline, device: &Device, shape: &BindShape) -> Result<Bindin
)?,
shadow_stencil: shadow,
mesh,
shader_tests: p
.graphics
.shader_tests
.is_some()
.then_some(ShaderTestsTemplate),
deindexed: primitive_id_indices,
private_list,
storage_kept: storage_kept(p)?,
@@ -2265,8 +2177,6 @@ fn shadow_stencil_words(t: &ShadowTemplate, state: &BindState) -> Result<FieldBy
})))
}
/// The `PushField::ShaderTestsState` words of a draw under encoder state `state`: the depth compare
/// function, write enable and clip mode, and viewport 0's depth range.
/// The 8-bit unorm code Metal's private alpha test compares the reference `reference` as
/// (`setAlphaTestReferenceValue:`, Apple SPI; `PushField::AlphaTestReference`, probes on an Apple
/// M3 Max): NaN is 0, the value is clamped to `[0, 1]`, and the code is the exact product with
@@ -2282,38 +2192,6 @@ pub fn alpha_test_code(reference: f32) -> u32 {
(clamped * 255.0).round_ties_even() as u32
}
fn shader_tests_words(state: &BindState) -> FieldBytes {
let ds = &state.depth_stencil;
let clamp = state.depth_clip_mode_clamp;
let word = crate::lower::fragment::depth_test_word(
ds.depth_compare_function.as_raw(),
ds.depth_write_enabled,
clamp,
);
let [near, far] = state.depth_range;
FieldBytes::words([word, near.to_bits(), far.to_bits(), 0])
}
/// The `PushField::ShaderStencilState` words of a draw under encoder state `state`: each face's
/// stencil word (`lower::fragment::stencil_test_word`), the front then the back, the references'
/// low 8 bits (front in bits 0 to 7, back in bits 8 to 15), and a zero word.
fn shader_stencil_words(state: &BindState) -> FieldBytes {
let ds = &state.depth_stencil;
let [front_face, back_face] = [&ds.front_face_stencil, &ds.back_face_stencil].map(|f| {
crate::lower::fragment::stencil_test_word(
f.stencil_compare_function.as_raw(),
f.stencil_failure_operation.as_raw(),
f.depth_failure_operation.as_raw(),
f.depth_stencil_pass_operation.as_raw(),
f.read_mask,
f.write_mask,
)
});
let [front, back] = state.stencil_references;
let references = (front & 0xFF) | (back & 0xFF) << 8;
FieldBytes::words([front_face, back_face, references, 0])
}
/// The address alignment and the element bytes the fixed-function attributes of `binding` read
/// ([`PlannedVertexBuffer::alignment`] and `reads`): each attribute's format block gives its
/// Vulkan alignment (the component size, or the whole word of a packed format) and size.
@@ -3643,18 +3521,6 @@ fn instantiate(
};
shadow_stencil_words(shadow, state)?
}
PushField::ShaderTestsState => {
if t.shader_tests.is_none() {
return Err(internal("a depth state without its in-shader depth test"));
}
shader_tests_words(state)
}
PushField::ShaderStencilState => {
if t.shader_tests.is_none() {
return Err(internal("a stencil state without its in-shader tests"));
}
shader_stencil_words(state)
}
PushField::DispatchRegion => match mesh.as_ref().and_then(|m| m.region(st.stage)) {
Some(region) => FieldBytes::of(&region),
None => return Err(internal("a dispatch region outside a mesh draw")),
@@ -617,7 +617,6 @@ fn instantiation_bounds_a_draw_by_its_index_buffer() {
robust_index_fetch,
shadow_stencil: None,
mesh: None,
shader_tests: None,
deindexed: None,
private_list: false,
storage_kept: 0,
@@ -667,7 +666,6 @@ fn a_draw_of_no_index_binds_inside_the_buffer() {
robust_index_fetch,
shadow_stencil: None,
mesh: None,
shader_tests: None,
deindexed: None,
private_list: false,
storage_kept: 0,
@@ -752,7 +750,6 @@ fn an_unbounded_indexed_indirect_draw_reads_its_arguments() {
robust_index_fetch,
shadow_stencil: None,
mesh: None,
shader_tests: None,
deindexed: None,
private_list: false,
storage_kept: 0,
@@ -809,7 +806,6 @@ fn draws_bind_vertex_buffers_at_aligned_offsets_with_their_windows() {
robust_index_fetch: false,
shadow_stencil: None,
mesh: None,
shader_tests: None,
deindexed: None,
private_list: false,
storage_kept: 0,
@@ -901,7 +897,6 @@ fn inline_vertex_bytes_bind_the_strides_a_dynamic_layout_reads() {
robust_index_fetch: false,
shadow_stencil: None,
mesh: None,
shader_tests: None,
deindexed: None,
private_list: false,
storage_kept: 0,
@@ -1505,7 +1500,6 @@ fn mesh_template(flat: bool, multiples: Vec<u32>) -> GraphicsTemplate {
folded: false,
partial_groups: false,
}),
shader_tests: None,
deindexed: None,
private_list: false,
storage_kept: 0,
@@ -2111,48 +2105,3 @@ fn mesh_draws_specialize_their_threadgroup_within_the_device() {
Ok(None)
);
}
/// `PushField::ShaderStencilState`'s words: each face's word in its documented bits (the
/// shader-side stencil's fields, the depth-failure operation in bits 25 to 27, masks cut to 8
/// bits), the front face's first, then the references' low 8 bits (front in bits 0 to 7, back in
/// bits 8 to 15), then zero.
#[test]
fn shader_stencil_words_pack_each_face_then_the_references() {
use metal::{CompareFunction, StencilOperation};
let mut state = BindState::default();
let front = &mut state.depth_stencil.front_face_stencil;
front.stencil_compare_function = CompareFunction::Equal;
front.stencil_failure_operation = StencilOperation::Zero;
front.depth_failure_operation = StencilOperation::DecrementWrap;
front.depth_stencil_pass_operation = StencilOperation::Replace;
front.read_mask = 0x0F;
front.write_mask = 0x1F0;
let back = &mut state.depth_stencil.back_face_stencil;
back.stencil_compare_function = CompareFunction::Greater;
back.depth_failure_operation = StencilOperation::Invert;
state.stencil_references = [0x1A5, 0x3C];
let words: Vec<u32> = shader_stencil_words(&state)
.chunks(4)
.map(|c| u32::from_le_bytes([c[0], c[1], c[2], c[3]]))
.collect();
let field = |w: u32, offset: u32, width: u32| (w >> offset) & ((1 << width) - 1);
let [f, b, references, zero] = words[..] else {
panic!("{words:?}");
};
// compare, stencil failure, pass, read mask, write mask, depth failure
let fields = |w| {
[
field(w, 0, 3),
field(w, 3, 3),
field(w, 6, 3),
field(w, 9, 8),
field(w, 17, 8),
field(w, 25, 3),
]
};
assert_eq!(fields(f), [2, 1, 2, 0x0F, 0xF0, 7]);
assert_eq!(fields(b), [4, 0, 0, 0xFF, 0xFF, 5]);
assert_eq!([f >> 28, b >> 28], [0, 0], "bits 28 to 31 stay clear");
assert_eq!(references, 0xA5 | 0x3C << 8);
assert_eq!(zero, 0);
}
+2 -3
View File
@@ -120,9 +120,8 @@ pub use astc_decode::{AstcDecode, AstcTexels};
pub use chroma_decode::ChromaDecode;
pub use depth_clamp::clamped_depth;
pub use depth_stencil_copy::{
depth_split_module, depth_stencil_copy_modules, stencil_split_module, CopySource,
DepthSplitModule, DepthStandInForm, DepthStencilCopy, DepthStencilCopyModules, StencilBit,
StencilSplitModule,
depth_stencil_copy_modules, stencil_split_module, CopySource, DepthStencilCopy,
DepthStencilCopyModules, StencilBit, StencilSplitModule,
};
pub use dispatch::{Dispatch, DispatchCommands, DispatchRegion, IndirectArgs};
pub use etc_decode::{EtcDecode, EtcTexels};
-22
View File
@@ -215,11 +215,6 @@ pub struct GraphicsTemplate {
/// specialization.
#[cfg_attr(feature = "serde", serde(default))]
pub(crate) mesh: Option<MeshTemplate>,
/// A fragment function that runs the draw's depth test itself: its draws write the encoder's
/// depth state as `PushField::ShaderTestsState`, and, where it runs the stencil test too, the
/// encoder's stencil state and references as `PushField::ShaderStencilState`.
#[cfg_attr(feature = "serde", serde(default))]
pub(crate) shader_tests: Option<ShaderTestsTemplate>,
/// A pipeline compiled in the primitive ID's de-indexed form of this index type
/// (`VariantKey::primitive_id_indices`): its indexed draws write `PushField::CaptureLayout`
/// and run without indices.
@@ -301,12 +296,6 @@ pub(crate) enum GroupStage {
Mesh,
}
/// What a draw of a pipeline whose fragment function runs the draw's depth test itself
/// instantiates: the encoder's depth state, which the plan reads from the draw's state.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub(crate) struct ShaderTestsTemplate;
/// What a draw of a pipeline with a shader-side stencil instantiates.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
@@ -802,23 +791,12 @@ pub enum WriteSource {
/// zero ([`ExecutionStatus::initial`](crate::bind::ExecutionStatus::initial)). The consumer
/// reads it once the command buffer completes.
ExecutionStatus,
/// The stand-in of the render pass's depth attachment that a fragment function that runs
/// the draw's depth test itself tests and writes (`GraphicsState::shader_tests`): the
/// consumer's `R32_SFLOAT` storage image of the attachment's extent, holding its samples as
/// the stand-in's view says, in `GENERAL` layout
/// ([`StandInUse`](crate::pipeline::StandInUse)).
DepthStandIn,
/// The snapshot of the texture the draw binds at fragment texture slot `slot`
/// (`BindingSource::SnapshotTexels`, `VariantKey::snapshot_textures`): the consumer's
/// single-sample 2D `R32G32B32A32_UINT` storage image covering the draw's render area, in
/// `GENERAL` layout, which the draw's fragments write at their pixels in the draw that takes
/// the snapshot and read in the draw that reads it (`PushHole::SnapshotPhase`).
SnapshotTexels { slot: u32 },
/// The stand-in of the render pass's stencil attachment that a fragment function that runs
/// the draw's stencil test itself tests and writes (`ShaderTestsUse::stencil`): the
/// consumer's `R8_UINT` storage image of the attachment's extent and the pipeline's samples,
/// in `GENERAL` layout ([`StandInUse`](crate::pipeline::StandInUse)).
StencilStandIn,
}
/// The image of a combined image-sampler write.
@@ -48,8 +48,6 @@ pub enum DrawReplayRule {
FragmentImageblock,
/// The state tests stencil in its shaders.
ShaderStencil,
/// The state tests depth or stencil in its shaders.
ShaderTests,
/// The state reads its attachments.
InputAttachments,
/// The state's indirect draw needs its arguments on the CPU.
@@ -106,9 +104,6 @@ impl fmt::Display for DrawReplayRule {
}
DrawReplayRule::FragmentImageblock => "the inherited state has a fragment imageblock",
DrawReplayRule::ShaderStencil => "the inherited state tests stencil in its shaders",
DrawReplayRule::ShaderTests => {
"the inherited state tests depth or stencil in its shaders"
}
DrawReplayRule::InputAttachments => "the inherited state reads its attachments",
DrawReplayRule::ArgumentsOnCpu => {
"the inherited state's indirect draw needs its arguments on the CPU"
@@ -218,7 +213,6 @@ pub fn draw_replay_state(graphics: &GraphicsState, merged: bool) -> Result<(), D
graphics.shadow_stencil.is_some(),
DrawReplayRule::ShaderStencil,
),
(graphics.shader_tests.is_some(), DrawReplayRule::ShaderTests),
(
!graphics.input_attachments.is_empty(),
DrawReplayRule::InputAttachments,
+8 -32
View File
@@ -324,27 +324,6 @@ pub struct BindState {
/// the shape.
#[cfg_attr(feature = "serde", serde(default))]
pub alpha_test_reference: Option<f32>,
/// Viewport 0's depth range `[near, far]` as the encoder set it (`setViewport:`; Metal's
/// default viewport has `[0, 1]`), which a fragment function that runs the draw's depth test
/// itself clamps its depth to in depth clamp mode (`PushField::ShaderTestsState`). Read only
/// by a draw of such a pipeline (`GraphicsState::shader_tests`), whose consumer sets it;
/// only the draw's bytes depend on it, so it is not part of the shape.
#[cfg_attr(feature = "serde", serde(default))]
pub depth_range: [f32; 2],
/// The encoder's depth clip mode is `MTLDepthClipModeClamp` (`setDepthClipMode:`), under
/// which such a function clamps its depth to the viewport's range, where in clip mode it
/// clamps to `[0, 1]` (`PushField::ShaderTestsState`). Read only by a draw of such a
/// pipeline; not part of the shape.
#[cfg_attr(feature = "serde", serde(default))]
pub depth_clip_mode_clamp: bool,
/// The encoder's stencil references, the front face's then the back face's
/// (`setStencilReferenceValue:` sets both, `setStencilFrontReferenceValue:backReferenceValue:`
/// each; Metal's default is 0), which a fragment function that runs the draw's stencil test
/// itself compares and replaces with (`PushField::ShaderStencilState`). Read only by a draw of
/// such a pipeline (`ShaderTestsUse::stencil`), whose consumer sets it; only the draw's bytes
/// depend on it, so it is not part of the shape.
#[cfg_attr(feature = "serde", serde(default))]
pub stencil_references: [u32; 2],
}
/// What a draw's depth and stencil tests can do to its fragments (`BindState::fragment_tests`).
@@ -353,9 +332,8 @@ pub struct BindState {
/// storage form stores inside the shader, so where it discards, and so cannot be tested early
/// whatever the draw's state, whether its store is Metal's is the draw's tests' to decide.
///
/// Where the tests drop fragments, such a function runs them itself where it can:
/// [`FragmentTests::Depth`] and [`FragmentTests::Stencil`] name the tests it runs, and a
/// [`FragmentTests::Drop`] draw of a function that may not declare early tests runs both.
/// Where the tests drop fragments and write, such a draw is refused: [`FragmentTests::Depth`] and
/// [`FragmentTests::Stencil`] name the test that acts, and so the attachment the refusal names.
#[non_exhaustive]
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
@@ -372,25 +350,23 @@ pub enum FragmentTests {
/// the encoder counts nothing: early tests drop the fragments Metal's later tests drop and
/// leave the attachments as Metal's do, so such a draw runs the variant that declares them
/// (`VariantKey::read_only_tests`). (A function that may not declare them, since it writes
/// other memory or returns depth, runs the tests itself as under [`FragmentTests::Stencil`].)
/// other memory or returns depth, is refused at the tested attachment.)
Drop,
/// No test can drop a fragment: a store before the tests is the store Metal makes after
/// them, so such a draw runs the pipeline as compiled.
Pass,
/// Only the depth test can drop a fragment, and it writes the depth attachment where
/// `writes`; the stencil test can neither drop nor write, and the encoder counts nothing.
/// Such a draw of a function that stores before the tests runs the variant whose function
/// runs the depth test itself (`VariantKey::shader_tests`) where the device ships it, or, where
/// it writes nothing and the function has one, the variant that declares early tests, as
/// Such a draw of a function that stores before the tests is refused
/// `NotImplemented(FramebufferFetch)` at the depth attachment, unless it writes nothing and
/// the function has the variant that declares early tests, which it runs, as
/// [`FragmentTests::Drop`].
Depth { writes: bool },
/// The stencil test can drop a fragment or write the stencil attachment, and some test
/// writes its attachment (the stencil test's operations, or the depth test's writes; where
/// none does, the tests are [`FragmentTests::Drop`]); the encoder counts nothing. Such a draw
/// of a function that stores before the tests runs the variant whose function runs the
/// stencil and depth tests itself (`VariantKey::shader_stencil`), where the pass has a depth
/// and a stencil attachment and the device ships the form; a pass with a stencil attachment
/// alone is refused at it.
/// of a function that stores before the tests is refused `NotImplemented(FramebufferFetch)`
/// at the stencil attachment.
Stencil,
}
+4 -15
View File
@@ -42,8 +42,7 @@ use crate::pipeline::facts::{Mechanism, RuntimeFact, UniformViewChoice};
use crate::pipeline::graphics::{
BandPrimitive, BlendState, ColorAttachmentState, FanOutState, FragmentImageblock,
GraphicsState, ImageblockMechanism, InputAttachmentUse, LineBandState, RegionFanOut,
ShaderTestsUse, ShadowStencilUse, StandInUse, StandInView, StorageAttachmentUse,
StorageAttachmentView, TessellationState,
ShadowStencilUse, StorageAttachmentUse, StorageAttachmentView, TessellationState,
};
use crate::pipeline::interface::{
AccessSet, BufferForm, BufferKind, BufferSlot, CommandWrites, DescriptorView, LevelReads,
@@ -858,8 +857,6 @@ codec_enum! {
ControlPointIndices,
TileMemory,
FunctionTableSnapshot,
DepthStandIn,
StencilStandIn,
}
ResourceKind {
Buffer, Texture, Sampler, Heap(f0), Synthetic(f0), InputAttachment(f0),
@@ -893,11 +890,9 @@ codec_enum! {
PatchIndexOffset, PatchIndexBound, ControlPointIndexOffset, StageInStride(f0),
AmplificationId, AmplificationLayerOffset, AmplificationViewportOffset,
DepthClampRange,
ShaderTestsState,
CaptureLayout,
CaptureIndexAddress,
StorageKeptChannels,
ShaderStencilState,
TextureIntegerChannels(f0),
BicubicTexels(f0),
Specialized(f0),
@@ -1057,7 +1052,7 @@ codec_enum! {
MetalHalfFma, MetalFloatDenormals,
MetalCenterVaryings, MetalSmallFloatColorWrites, MetalNorm16ColorWrites, MetalMinMax,
MetalHalfArithmetic, MetalHalfStorageWrites, MetalHalfStorageNans,
MetalFragmentSimdgroups, MetalVertexSimdgroups, CenterFragCoordDepth, SampleFragCoordDepth,
MetalFragmentSimdgroups, MetalVertexSimdgroups,
MetalHalfTexelWrites, MetalNormStorageWrites, DeviceSampling,
MetalDepth16Stores, MetalDepth16BiasedStores, MetalInterpolation, MetalFirstVertexIndices,
MetalFullQuads, ProvokingVertexModePerPipeline,
@@ -1198,7 +1193,7 @@ codec_enum! {
IoRole {
Attribute { index }, Varying { user, interpolation },
Color { attachment, index },
ViewportIndex, RenderTargetArrayIndex, PrimitiveVarying { user }, WindowDepth,
ViewportIndex, RenderTargetArrayIndex, PrimitiveVarying { user },
Barycentric { perspective }, SelectedLayer, SelectedViewport, PrimitiveId, MergedCommand,
}
IoInterpolation { Flat, Smooth { sampling, perspective } }
@@ -1289,9 +1284,7 @@ codec_enum! {
ConstexprSampled { slot, modes },
CubicSampler { slot },
CubicArgumentSampler { stage },
ShaderTests { formatless, multisampled, planes },
HeapRawSamples { stage, sampler },
ShaderStencilTest { formatless },
ExtendedRangeInputBlend { color, blend, kept },
WordInputMerge { color, kept },
CrossClassReads { slot },
@@ -1410,7 +1403,7 @@ codec_struct! {
tessellation, fragment_imageblock, vertex_writes_memory, writes_viewport_index,
storage_attachments, shadow_stencil, writes_point_size, writes_depth,
reads_barycentric_coord, reads_primitive_id, fragment_writes_memory, color_outputs,
sample_mask, shader_tests, snapshot_reads, color_group, logic_op, line_band, region_fan_out,
sample_mask, snapshot_reads, color_group, logic_op, line_band, region_fan_out,
}
TessellationState {
patch_control_points, domain, control_points, factor_step_function, push_offset,
@@ -1424,8 +1417,6 @@ codec_struct! {
InputAttachmentUse { color_index, input_attachment_index, format_class }
StorageAttachmentUse { color_index, format, writes, formatless, view, view_alias, kept }
ShadowStencilUse { format, formatless, samples }
ShaderTestsUse { depth, stencil }
StandInUse { format, formatless, samples, view }
}
codec_enum! {
@@ -1435,7 +1426,6 @@ codec_enum! {
SlotWriteGap { UnresolvedIndex, UnmeasuredPayloadStage, MemberRole }
ImageblockMechanism { StorageImageInterlock }
StorageAttachmentView { Attachment, SamplePlanes { layers } }
StandInView { Image, SamplePlanes { layers } }
BandPrimitive { Lines, Triangles }
RegionFanOut { Draw, Probe, DrawFew, RegionCopies }
PrecisionNote {
@@ -1467,7 +1457,6 @@ codec_enum! {
BlendedWriteRounding,
RotatedBlendRounding,
LinkedSamplerNumbering,
ComputedSampleDepth,
ArgumentPixelSamplerScaling,
HalfOutputPrecision,
ExtendedRangeBlendSource,
+3 -29
View File
@@ -61,7 +61,7 @@ mod tests;
/// unchanged version, and its bless records the version. Independent of the crate's version and of
/// [`ARTIFACT_FORMAT_VERSION`]. The commit that bumps it says what changed; this comment keeps no
/// history.
pub const SEMANTICS_VERSION: u32 = 2226;
pub const SEMANTICS_VERSION: u32 = 2227;
/// The byte-layout version of encoded artifacts (`CompiledFunction::to_bytes` and the
/// [`PipelineArtifact`] encodings). Every encoded artifact carries it, and a decode under another
@@ -71,7 +71,7 @@ pub const SEMANTICS_VERSION: u32 = 2226;
/// 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 = 571;
pub const ARTIFACT_FORMAT_VERSION: u32 = 572;
/// The version of what this crate's runtime does with a compiled pipeline: instantiating a binding
/// plan (`BindingPlan::instantiate_*`: descriptor ranges, push bytes, root, argument, and handle
@@ -94,7 +94,7 @@ pub const ARTIFACT_FORMAT_VERSION: u32 = 571;
/// changes no behaviour, and then updates that hash alone with the commit saying why, or changes
/// behaviour and also bumps this version. The commit that bumps it says what changed; this comment
/// keeps no history.
pub const RUNTIME_VERSION: u32 = 2546;
pub const RUNTIME_VERSION: u32 = 2547;
/// Writes a digest as lowercase hex.
pub(crate) fn write_hex(f: &mut fmt::Formatter<'_>, name: &str, hash: &Hash256) -> fmt::Result {
@@ -401,25 +401,6 @@ pub struct VariantKey {
/// it.
#[cfg_attr(feature = "serde", serde(default))]
pub read_only_tests: bool,
/// Only the draw's depth test can drop fragments (`BindShape::fragment_tests`,
/// `FragmentTests::Depth`), and the fragment function stores a color through the interlocked
/// storage form before the tests (`RuntimeFact::TestedStorageWrites`): the variant whose
/// function runs the depth test itself against a stand-in of the depth attachment
/// (`LoweringInputs::shader_tests`). The plan of a pipeline compiled under it states it.
#[cfg_attr(feature = "serde", serde(default))]
pub shader_tests: bool,
/// Under `shader_tests`, the draw's stencil test can drop fragments or write too
/// (`FragmentTests::Stencil`, or `FragmentTests::Drop` for a function without an early-tests
/// variant), in a pass with a depth and a stencil attachment: the variant whose function also
/// runs the stencil test itself against a stand-in of the stencil attachment
/// (`LoweringInputs::shader_stencil`). The plan of a pipeline compiled under it states it.
#[cfg_attr(feature = "serde", serde(default))]
pub shader_stencil: bool,
/// Under `shader_tests` at more than one sample, on a device whose fragment function computes
/// each sample's depth (`VkProperty::CenterFragCoordDepth`): the vertex function also writes
/// its window depth for it (`LoweringInputs::window_depth_varying`).
#[cfg_attr(feature = "serde", serde(default))]
pub window_depth_varying: bool,
/// The runtime sampler slots of a `RuntimeFact::CubicSampler` that the shape binds to a
/// sampler whose min or mag filter is `Cubic`, each with the bound word masked by
/// `SamplerWord::CUBIC_STATE` (`LoweringInputs::cubic_samplers`): the variant whose function
@@ -604,9 +585,6 @@ impl VariantKey {
&& !self.addressed_function_tables
&& self.interlocked_colors.is_empty()
&& !self.read_only_tests
&& !self.shader_tests
&& !self.shader_stencil
&& !self.window_depth_varying
&& self.cubic_samplers.is_empty()
&& self.primitive_id_indices.is_none()
&& !self.quad_primitive_ids
@@ -776,11 +754,7 @@ impl VariantKey {
out.depth_clamp_range = self.depth_clamp_range;
out.rotated_weights = self.rotated_weights;
out.read_only_tests = self.read_only_tests;
out.shader_tests = self.shader_tests;
out.shader_stencil = self.shader_stencil;
}
out.window_depth_varying =
self.window_depth_varying && stage == crate::pipeline::sym::Stage::Vertex;
out.primitive_id_indices = self
.primitive_id_indices
.filter(|_| stage == crate::pipeline::sym::Stage::Vertex);
@@ -123,12 +123,6 @@ pub fn mechanism(fact: &RuntimeFact, profile: &DeviceProfile) -> Mechanism {
// The consumer keeps the stencil's shadow and binds it, with the encoder's stencil state
// as push data (`GraphicsState::shadow_stencil`).
RuntimeFact::ShadowStencil { .. } => Mechanism::RenderPassContract,
// The consumer keeps the depth attachment's stand-in and binds it, with the encoder's
// depth state as push data (`GraphicsState::shader_tests`).
RuntimeFact::ShaderTests { .. } => Mechanism::RenderPassContract,
// The consumer keeps the stencil attachment's stand-in and binds it, with the encoder's
// stencil state and references as push data (`ShaderTestsUse::stencil`).
RuntimeFact::ShaderStencilTest { .. } => Mechanism::RenderPassContract,
// The vote word is fixed in the module; the planner counts it against the limit.
RuntimeFact::PredicationVote => Mechanism::PlanTimeCheck,
// The binder pushes the bound format's class, which selects its conversion.
@@ -278,14 +278,6 @@ impl DeviceProfile {
.enabled
.properties
.contains(&VkProperty::MetalVertexSimdgroups),
DriverDeviation::CenterFragCoordDepth => f
.enabled
.properties
.contains(&VkProperty::CenterFragCoordDepth),
DriverDeviation::SampleFragCoordDepth => f
.enabled
.properties
.contains(&VkProperty::SampleFragCoordDepth),
DriverDeviation::MetalHalfTexelWrites => f
.enabled
.properties
@@ -748,21 +748,6 @@ pub enum VkProperty {
/// No Vulkan query reports it. A vertex module that uses subgroup operations requires it in
/// place of `SubgroupStage(Vertex)` on such a device.
MetalVertexSimdgroups,
/// In a per-sample fragment invocation of a multisampled pipeline the device gives
/// `FragCoord.z`, the draw's depth bias included, and a no-perspective varying read as it is
/// at the pixel centre, and `InterpolateAtSample` at the sample, while its depth test stores
/// each sample's own depth (the driver's measured deviation
/// [`DriverDeviation::CenterFragCoordDepth`](crate::error::DriverDeviation::CenterFragCoordDepth)).
/// No Vulkan query reports it. A fragment module that computes each sample's depth from those
/// reads for its in-shader depth test requires it.
CenterFragCoordDepth,
/// In a per-sample fragment invocation of a multisampled pipeline the device gives
/// `FragCoord.z` at the invocation's sample, the draw's depth bias included, the depth its
/// depth test stores there (the driver's measured deviation
/// [`DriverDeviation::SampleFragCoordDepth`](crate::error::DriverDeviation::SampleFragCoordDepth)).
/// No Vulkan query reports it. A fragment module whose in-shader depth test reads `FragCoord.z`
/// at each sample requires it.
SampleFragCoordDepth,
/// The device stores the widened `half` a shader writes to a 16-bit float storage image as
/// the half's own bits, a signalling NaN's unquieted, and the NaN `0x7fc00000` written to a
/// packed small float one as the format's canonical NaN (the driver's measured deviation
@@ -193,17 +193,11 @@ fn every_fact() -> Vec<RuntimeFact> {
RuntimeFact::CubicArgumentSampler {
stage: Stage::Kernel,
},
RuntimeFact::ShaderTests {
formatless: false,
multisampled: true,
planes: true,
},
RuntimeFact::StorageTextureIntegerChannels { slot },
RuntimeFact::HeapRawSamples {
stage: Stage::Fragment,
sampler: Some(1),
},
RuntimeFact::ShaderStencilTest { formatless: true },
RuntimeFact::ExtendedRangeInputBlend {
color: 0,
blend: {
@@ -367,9 +361,7 @@ fn variant(f: &RuntimeFact) -> usize {
RuntimeFact::ConstexprSampled { .. } => 67,
RuntimeFact::CubicSampler { .. } => 68,
RuntimeFact::CubicArgumentSampler { .. } => 69,
RuntimeFact::ShaderTests { .. } => 70,
RuntimeFact::HeapRawSamples { .. } => 73,
RuntimeFact::ShaderStencilTest { .. } => 74,
RuntimeFact::ExtendedRangeInputBlend { .. } => 75,
RuntimeFact::CrossClassReads { .. } => 76,
RuntimeFact::StorageTextureWriteRounding { .. } => 77,
@@ -400,8 +392,8 @@ fn variant(f: &RuntimeFact) -> usize {
RuntimeFact::TexelRows { .. } => 99,
RuntimeFact::HeapStorageReads { .. } => 100,
RuntimeFact::UnitAxes { .. } => 101,
RuntimeFact::TexelBufferParts { .. } => 102,
RuntimeFact::OpenClLineTexture { .. } => 103,
RuntimeFact::TexelBufferParts { .. } => 70,
RuntimeFact::OpenClLineTexture { .. } => 74,
RuntimeFact::AddressAlignment { .. } => 71,
RuntimeFact::GridTiles => 55,
}
@@ -411,7 +403,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..104).collect(), "every_fact misses a variant");
assert_eq!(covered, (0..102).collect(), "every_fact misses a variant");
for (stem, _) in super::committed_profiles() {
let dev = device(&stem);
let p = dev.profile();
@@ -531,8 +523,6 @@ fn mechanism_is_total_over_every_fact_and_profile() {
| RuntimeFact::FragmentImageblock { .. }
| RuntimeFact::InterlockedFramebufferFetch { .. }
| RuntimeFact::ShadowStencil { .. }
| RuntimeFact::ShaderTests { .. }
| RuntimeFact::ShaderStencilTest { .. }
| RuntimeFact::TileImageblock { .. }
| RuntimeFact::ExtendedRangeInputBlend { .. }
| RuntimeFact::RotatedInputBlend { .. }
-26
View File
@@ -660,25 +660,6 @@ pub enum DriverDeviation {
/// requires the property in place of `VkProperty::SubgroupStage(Vertex)`. Unmeasured, the stage
/// has none, as the device states.
MetalVertexSimdgroups,
/// In a fragment invocation of a multisampled pipeline that runs once per sample, the device
/// gives `FragCoord.z` at the pixel centre, the draw's depth bias included, as Metal gives
/// `[[position]].z`, reads a no-perspective varying at the pixel centre where it is read as it
/// is and at the sample through `InterpolateAtSample`, and its depth test stores each sample's
/// own depth (`VkProperty::CenterFragCoordDepth`). Where the profile takes it, a fragment
/// function that runs its draw's depth test itself at more than one sample computes each
/// sample's depth: its vertex function's window depth read at the sample, plus `FragCoord.z`
/// less that varying read at the centre, which carries the bias
/// (`PrecisionNote::ComputedSampleDepth`). Unmeasured, that test is refused at more than one
/// sample.
CenterFragCoordDepth,
/// In a fragment invocation of a multisampled pipeline that runs once per sample, the device
/// gives `FragCoord.z` at the invocation's sample, the draw's depth bias included: the depth
/// its own depth test stores at that sample (`VkProperty::SampleFragCoordDepth`). Where the
/// profile takes it, a fragment function that runs its draw's depth test itself at more than
/// one sample tests `FragCoord.z` at each sample, exact as at one sample. Unmeasured, that test
/// is refused at more than one sample, or computes each sample's depth where the profile takes
/// [`DriverDeviation::CenterFragCoordDepth`].
SampleFragCoordDepth,
/// The device stores a `half` texel's write as Metal stores it once the shader hands it the
/// half widened to `float` in a 16-bit float storage image, and the NaN `0x7fc00000` in a
/// packed small float one (`VkProperty::MetalHalfTexelWrites`): the half's own bits, a
@@ -1010,13 +991,6 @@ pub enum Feature {
/// access, or the pixel interlock's storage form where the pipeline's state lets it be
/// exact), or in a shape not implemented.
FramebufferFetch,
/// A fragment function that runs its draw's depth test itself (`lower::fragment::depth_test`)
/// at more than one sample, where it does not return its depth: not lowered, on any device.
/// Each sample's test needs that sample's depth, and Vulkan states no location for
/// `FragCoord.z` under sample shading: devices differ (RADV answers the sample's, MoltenVK the
/// pixel centre's), and no device query says which. A function that returns its depth tests
/// that, the same at every sample, and is lowered.
MultisampledShaderDepthTest,
/// `[[primitive_id]]` in a fragment function: behind a mesh function on a device without
/// geometry or tessellation shaders, whose fragment stage reads it from a varying no mesh
/// function writes; and, of a pipeline whose vertex function writes that varying, the
@@ -1,924 +0,0 @@
//! A fragment function that runs its draw's depth test itself, inside the ordered pixel
//! interlock, against a stand-in of the depth attachment.
//!
//! **Where.** A function that writes a color through the interlocked storage form stores inside the
//! shader, before Vulkan's tests. Where its draws' tests may drop a fragment and it cannot declare
//! early tests (`RuntimeFact::TestedStorageWrites`: it discards under tests that write, writes
//! other memory, or runs on a driver that drops an early-tests shader's image writes at more than
//! one sample), a store before the tests keeps colors Metal's tests drop. Compiled for a draw whose
//! depth test alone can drop a fragment (`LoweringInputs::shader_tests`, the binder's
//! `FragmentTests::Depth`), the function runs that test at its return instead, next to its color
//! store, as Metal tests after the function:
//!
//! - the consumer keeps the depth attachment in the subpass under `Always` without writes, and
//! holds its depth in a stand-in (`GraphicsState::shader_tests`, `SyntheticBinding::DepthStandIn`):
//! an `R32_SFLOAT` storage image of the pass's size, texel `(x, y)` for pixel `(x, y)`, copied
//! from the attachment before the draws and back after them;
//! - at each return, unless a discard was recorded, the function takes the fragment's depth,
//! clamps it as Metal does by the draw's depth clip mode (to `[0, 1]` in clip mode, to the
//! viewport's range `[min(near, far), max(near, far)]` in clamp mode; a `-0` as `+0`), compares
//! it with the stand-in's texel by the draw's compare function, writes it there where it passes
//! and the draw writes depth, and records a failing fragment as discarded, so the storage form's
//! color store skips it and the entry kills it after the critical section;
//! - the draw's depth state is `PushField::ShaderTestsState` (see its docs).
//!
//! The ordered interlock makes each fragment's test, depth write and color store one step in
//! primitive order across the draws of a subpass, so the next fragment tests against the depth
//! the last one left: Metal's order. The body runs whole, every memory write included, for every
//! fragment, as Metal runs it before its tests.
//!
//! **The fragment's depth**. At one sample it is `FragCoord.z`: the device's own depth, which its
//! fixed-function test compares, with the draw's depth bias, at the pixel's one sample (on the M4,
//! Metal's `[[position]].z`, equal bit for bit to the depth Metal tests once clamped; on ANV, RADV
//! and NVIDIA the depth the device's own draw stores).
//!
//! **More than one sample.** The function runs once per covered sample (its `SampleId`) and tests
//! its sample of a stand-in holding each: a multisampled storage image, or, on a device without
//! one, sample planes (a 2D array, layer `s` for sample `s`). A device whose `FragCoord.z` there is
//! its sample's, the depth its own test stores at that sample (RADV, measured,
//! `VkProperty::SampleFragCoordDepth`), tests `FragCoord.z` as at one sample. A device whose
//! `FragCoord.z` is the pixel centre's there while each sample stores its own (MoltenVK, measured,
//! `VkProperty::CenterFragCoordDepth`) has the function compute each sample's depth: its vertex
//! function writes the position's window depth `z / w` to a no-perspective varying
//! (`IoRole::WindowDepth`, `LoweringInputs::window_depth_varying`), and the function takes
//! `v(sample) · (far − near) + near`, plus `FragCoord.z` less `v(centre) · (far − near) + near`,
//! which carries the draw's depth bias, each operation rounded on its own: `v(sample)` read through
//! `InterpolateAtSample` at the invocation's sample, `v(centre)` read as it is, which that device
//! reads at the pixel centre. On the M4 that is the depth MoltenVK stores at each sample in the
//! flat, sloped and steep cases, under a constant bias, and where the clamp decides; under
//! perspective, a slope-scaled bias, or a viewport range other than `[0, 1]` it is within 2 ulp.
//! The module records `PrecisionNote::ComputedSampleDepth`, which no draw's
//! state can rule out at compile time. Both properties were measured facts, which no query
//! produces, so on every device a function that does not return its depth is refused at more than
//! one sample, as its own kind (`Feature::MultisampledShaderDepthTest`).
//!
//! **A returned depth**. A function that returns `[[depth(...)]]` tests the depth it returns at
//! that return, in place of `FragCoord.z`, as Metal tests it: a positive NaN fails the test,
//! `Always` included, which the return's store of the depth output records as discarded before the
//! test (`stage_io::clamp_depth`); any other value with its sign bit set is +0 (a negative NaN
//! stays 0 in clamp mode, past the range); a value past 1 is 1; then, in clamp mode, the viewport's
//! range clamps it. It takes no depth bias, and is the same at every sample, so it needs neither of
//! the per-sample depth sources above.
//!
//! **The stencil test**. Compiled for a draw whose stencil test can drop a fragment or write too
//! (`LoweringInputs::shader_stencil`, the binder's `FragmentTests::Stencil`, in a pass with a depth
//! and a stencil attachment), the function runs it first, as Metal does, against a stand-in of the
//! stencil (`SyntheticBinding::StencilStandIn`): an `R8_UINT` storage image of the pass's size,
//! texel `(x, y)` for pixel `(x, y)`, each sample at more than one (multisampled; sample planes are
//! not implemented). At each return, unless a discard was recorded, the face's state (`FrontFacing`
//! selects the front or back word and reference of `PushField::ShaderStencilState`) compares the
//! reference with the stand-in's value under the read mask; the face's stencil-failure operation
//! applies where that fails, its depth-failure operation where the depth test fails, and its pass
//! operation where both pass, under the write mask, as `s' = (s & !mask) | (op(s, r) & mask)` with
//! Metal's clamps and wraps (measured: Vulkan's rule); and only a fragment that passes both tests
//! writes its depth and stores its colors. The stand-in's read, operation and write are one step of
//! the critical section, as the depth's are.
//!
//! **A returned stencil and sample mask**. A function that returns `[[stencil]]` tests with the
//! output's low 8 bits as both faces' reference, in place of the draw's (measured), its stencil
//! output stored nowhere else: the device's stencil test is off for such draws (`stage_io`), and
//! where their stencil test does nothing the output changes nothing. A function that returns
//! `[[sample_mask]]` keeps a fragment only where the mask holds the invocation's sample's bit (bit
//! 0 at one sample; a per-sample invocation's other bits do nothing): at each return, before the
//! tests, a fragment without it is recorded as discarded, so it runs no test, writes neither
//! stand-in, and stores no color, as Metal drops the samples outside the mask (measured on an M4).
//! Beside a returned stencil Metal still runs the stencil test for such a sample, with the returned
//! reference, and fails its depth test whatever the draw's compare function: the stencil-failure
//! operation where the stencil test fails, else the depth-failure operation, no depth write and no
//! color. So does the function, where it runs the stencil test.
use crate::device::requirements::{FormatUsage, VkFeature, VkProperty};
use crate::device::DeviceProfile;
use crate::error::{Attachment, Capability, Error, Feature, Unsupported};
use crate::lower::emit::EmitCx;
use crate::lower::select::SelectCx;
use crate::lower::stage_io::{self, Returned};
use crate::lower::sync::memory_model;
use crate::metal::format::{spirv_image_format, without_format_gaps, StorageUse};
use crate::pipeline::artifact::PrecisionNote;
use crate::pipeline::facts::RuntimeFact;
use crate::pipeline::sym::{PushField, ResourceKind, ResourceSlot, Stage, SyntheticBinding};
use crate::spirv::builder::constructs::{ArmEnd, ArmFn};
use crate::spirv::builder::{FunctionBuilder, ModuleBuilder};
use crate::spirv::error::BResult;
use crate::spirv::ids::{GlobalId, Value as SValue};
use crate::spirv::ir::{
BinOp, ConstBits, Constant, ConvOp, Dim, GlslOp, ImageOperands, ImageType, ImageUsage,
MemAccess, StorageClass, Type as SType, UnOp,
};
use crate::vk;
use super::fetch::StorageSamples;
use super::stencil::{self, SHADOW_FORMAT};
/// The depth stand-in's format: Metal's depth values are 32-bit floats.
pub(crate) const STAND_IN_FORMAT: vk::Format = vk::Format::R32_SFLOAT;
/// Bit 3 of the state's word: the draw writes depth.
const WRITE_BIT: u32 = 1 << 3;
/// Bit 4 of the state's word: the draw's depth clip mode is `MTLDepthClipModeClamp`.
const CLAMP_BIT: u32 = 1 << 4;
/// The first word of `PushField::ShaderTestsState` (see its docs): Metal's depth compare function
/// `compare` by its raw value, [`WRITE_BIT`] where the draw writes depth, and [`CLAMP_BIT`] in
/// depth clamp mode.
pub(crate) fn depth_test_word(compare: u32, write: bool, clamp: bool) -> u32 {
(compare & 7) | if write { WRITE_BIT } else { 0 } | if clamp { CLAMP_BIT } else { 0 }
}
/// The word of one face of `PushField::ShaderStencilState` (see its docs): the shader-side
/// stencil's face word (`stencil::face_word`, its attached bit clear) of Metal's compare function
/// `compare`, operations `stencil_failure` and `pass`, and masks `read_mask` and `write_mask`, with
/// the depth-failure operation `depth_failure` in bits 25 to 27.
pub(crate) fn stencil_test_word(
compare: u32,
stencil_failure: u32,
depth_failure: u32,
pass: u32,
read_mask: u32,
write_mask: u32,
) -> u32 {
stencil::face_word(compare, stencil_failure, pass, read_mask, write_mask, false)
| (depth_failure & 7) << 25
}
/// The in-shader depth test's form on a device: how the module declares the stand-in and holds
/// its samples, and where the fragment's depth comes from.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub(crate) struct DepthForm {
/// The declared SPIR-V image format: `R32f`, or `Unknown` for a formatless declaration.
pub declared: crate::spv::ImageFormat,
/// How the stand-in holds the pipeline's samples.
pub samples: StorageSamples,
/// Each sample's depth is computed from the vertex function's window depth (see the module
/// docs), which the vertex function then writes (`LoweringInputs::window_depth_varying`);
/// otherwise the depth is `FragCoord.z`.
pub computed: bool,
}
/// The in-shader depth test's plan: how the module declares the stand-in and holds its samples.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct DepthTest {
/// The declared SPIR-V image format: `R32f`, or `Unknown` for a formatless declaration.
pub declared: crate::spv::ImageFormat,
/// How the stand-in holds the pipeline's samples.
pub samples: StorageSamples,
/// The stage interface's window-depth input object (`IoRole::WindowDepth`), from which each
/// sample's depth is computed; `None` where the depth is `FragCoord.z` or returned.
pub window: Option<usize>,
/// The returned value's field that holds the function's `[[depth(...)]]` output (0 for a
/// returned value itself), which the test takes in place of `FragCoord.z`; `None` where the
/// function returns no depth.
pub returned: Option<u32>,
/// The stencil test the function runs first (see the module docs); `None` where the draws it
/// serves have a stencil test that does nothing.
pub stencil: Option<StencilTest>,
/// The returned value's field that holds the function's `[[sample_mask]]` output, whose bit of
/// the invocation's sample (bit 0 at one sample) keeps the fragment before the tests; `None`
/// where the function returns no sample mask.
pub mask: Option<u32>,
}
/// The in-shader stencil test's plan: how the module declares the stencil's stand-in (of the
/// depth test's samples, which are then one or multisampled), and the face it tests.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct StencilTest {
/// The declared SPIR-V image format: `R8ui`, or `Unknown` for a formatless declaration.
pub declared: crate::spv::ImageFormat,
/// The stage interface's `FrontFacing` object, which selects the face's state.
pub front_facing: usize,
/// The returned value's field that holds the function's `[[stencil]]` output, whose low 8
/// bits are both faces' reference in place of the draw's; `None` where the function returns
/// no stencil.
pub returned: Option<u32>,
}
fn not_implemented() -> Unsupported {
Unsupported::not_implemented(Feature::FramebufferFetch)
}
/// The in-shader depth test's form on `p` for a pipeline of more than one sample where
/// `multisampled`, or what the device lacks for it (see the module docs): the ordered pixel
/// interlock, fragment stores, the stand-in's format as a storage image, declared `R32f` (a base
/// storage format) or without a format where the device grants that access; at more than one sample
/// `sampleRateShading`, and each sample's depth: `FragCoord.z` where the device is measured to give
/// its sample's (`VkProperty::SampleFragCoordDepth`), else computed where it is measured to give
/// the centre's (`VkProperty::CenterFragCoordDepth`), which also takes the interpolation functions
/// (on a portability-subset device `shaderSampleRateInterpolationFunctions`); elsewhere not
/// implemented. A function that returns its depth (`returned`) tests that, the same at every
/// sample, and needs no per-sample depth source.
pub(crate) fn depth_test_form(
p: &DeviceProfile,
multisampled: bool,
returned: bool,
) -> Result<DepthForm, Unsupported> {
let f = p.fields();
let measured = |property| f.enabled.properties.contains(&property);
let computed = match multisampled {
false => false,
true if returned => false,
true if measured(VkProperty::SampleFragCoordDepth) => false,
true if measured(VkProperty::CenterFragCoordDepth) => true,
true => {
return Err(Unsupported::not_implemented(
Feature::MultisampledShaderDepthTest,
))
}
};
let mut missing = Vec::new();
if multisampled && !f.fragment.sample_rate_shading {
missing.push(Capability::Feature(VkFeature::SampleRateShading));
}
if computed {
let interpolation = VkFeature::ShaderSampleRateInterpolationFunctions;
if f.enabled.portability_withholds(interpolation) {
missing.push(Capability::Feature(interpolation));
}
}
if !f.fragment.pixel_interlock {
missing.push(Capability::Feature(VkFeature::FragmentShaderPixelInterlock));
}
if !f.leaf.fragment_stores_and_atomics {
missing.push(Capability::Feature(VkFeature::FragmentStoresAndAtomics));
}
if !p.supports_format(STAND_IN_FORMAT, FormatUsage::StorageImage) {
missing.push(Capability::Format {
format: STAND_IN_FORMAT,
usage: FormatUsage::StorageImage,
});
}
let typed = spirv_image_format(STAND_IN_FORMAT).filter(|d| {
!crate::spirv::requirements::extended_format(*d) || f.images.storage_extended_formats
});
let declared = match typed {
Some(d) => Some(d),
None if without_format_gaps(STAND_IN_FORMAT, StorageUse::texture(true, true), p)
.is_empty() =>
{
Some(crate::spv::ImageFormat::Unknown)
}
None => {
missing.push(Capability::Feature(
VkFeature::ShaderStorageImageExtendedFormats,
));
None
}
};
let samples = match (multisampled, f.images.storage_multisample) {
(false, _) => StorageSamples::One,
(true, true) => StorageSamples::Multisampled,
(true, false) => StorageSamples::Planes,
};
match declared {
Some(declared) if missing.is_empty() => Ok(DepthForm {
declared,
samples,
computed,
}),
_ => Err(Unsupported::needs_any_of(
Feature::FramebufferFetch,
vec![missing],
)),
}
}
/// The in-shader stencil test's declaration of the stencil's stand-in on `p` for a pipeline of
/// more than one sample where `multisampled`, or what it lacks (see the module docs); the
/// interlock, the fragment stores and the per-sample invocation are the depth test's
/// ([`depth_test_form`]). The stand-in's format as a storage image, declared `R8ui` where the
/// device has the extended storage formats, else without a format where it grants that access; at
/// more than one sample a multisampled storage image (sample planes, on a device without one, are
/// not implemented), and `maintenance8`, whose depth/stencil and color copies move the samples
/// between the stencil aspect and the stand-in (as the shader-side stencil's shadow's).
pub(crate) fn stencil_test_form(
p: &DeviceProfile,
multisampled: bool,
) -> Result<crate::spv::ImageFormat, Unsupported> {
let f = p.fields();
if multisampled && !f.images.storage_multisample {
return Err(not_implemented());
}
let mut missing = Vec::new();
if multisampled && !f.enabled.features.contains(&VkFeature::Maintenance8) {
missing.push(Capability::Feature(VkFeature::Maintenance8));
}
if !p.supports_format(SHADOW_FORMAT, FormatUsage::StorageImage) {
missing.push(Capability::Format {
format: SHADOW_FORMAT,
usage: FormatUsage::StorageImage,
});
}
let declared = if f.images.storage_extended_formats {
Some(crate::spv::ImageFormat::R8ui)
} else if without_format_gaps(SHADOW_FORMAT, StorageUse::texture(true, true), p).is_empty() {
Some(crate::spv::ImageFormat::Unknown)
} else {
// `R8ui` is an extended format: the typed declaration needs only the feature.
missing.push(Capability::Feature(
VkFeature::ShaderStorageImageExtendedFormats,
));
None
};
match declared {
Some(d) if missing.is_empty() => Ok(d),
_ => Err(Unsupported::needs_any_of(
Feature::FramebufferFetch,
vec![missing],
)),
}
}
/// The fields of a function's returned value that hold its exports, which the in-shader tests
/// take (see the module docs): `[[depth(...)]]`, `[[stencil]]` and `[[sample_mask]]`.
#[derive(Clone, Copy, Debug, Default)]
pub(super) struct Exports {
pub depth: Option<u32>,
pub stencil: Option<u32>,
pub mask: Option<u32>,
}
/// Plan the in-shader depth test of a function that stores a color before the tests, compiled
/// for a draw whose depth test alone can drop a fragment (`LoweringInputs::shader_tests`), which
/// returns its depth, stencil and sample mask in the fields of its returned value `exports` names
/// (see the module docs). A refusal is placed at the depth attachment. Compiled for a draw whose
/// stencil test acts too (`LoweringInputs::shader_stencil`), plan the stencil test as well; a
/// refusal of its form is placed at the stencil attachment.
pub(super) fn plan(cx: &mut SelectCx<'_>, exports: Exports) -> Result<(), Error> {
let at_depth = |u: Unsupported| Error::from(u).at_attachment(Attachment::Depth);
let returned = exports.depth;
let form = depth_test_form(cx.profile, cx.inputs.multisampled, returned.is_some())
.map_err(at_depth)?;
let coord = stage_io::frag_coord(cx);
// At more than one sample the function runs once per sample and tests its own (`SampleId`).
super::fetch::plan_sample(cx)?;
// Each sample's depth from the vertex function's window depth, where `FragCoord.z` is the
// pixel centre's; else `FragCoord.z`.
let window = match form.computed {
true => {
cx.precision.insert(PrecisionNote::ComputedSampleDepth);
Some(stage_io::window_depth_input(cx)?)
}
false => None,
};
let stencil = match cx.inputs.shader_stencil {
true => {
let declared = stencil_test_form(cx.profile, cx.inputs.multisampled)
.map_err(|u| Error::from(u).at_attachment(Attachment::Stencil))?;
let front_facing = stage_io::front_facing(cx);
cx.facts.insert(RuntimeFact::ShaderStencilTest {
formatless: declared == crate::spv::ImageFormat::Unknown,
});
cx.push.insert(PushField::ShaderStencilState);
cx.descriptors.storage_images = cx.descriptors.storage_images.saturating_add(1);
Some(StencilTest {
declared,
front_facing,
returned: exports.stencil,
})
}
false => None,
};
let fp = &mut cx.families.fragment;
fp.fetch_coord = Some(coord);
fp.depth_test = Some(DepthTest {
declared: form.declared,
samples: form.samples,
window,
returned,
stencil,
mask: exports.mask,
});
cx.facts.insert(RuntimeFact::ShaderTests {
formatless: form.declared == crate::spv::ImageFormat::Unknown,
multisampled: cx.inputs.multisampled,
planes: form.samples == StorageSamples::Planes,
});
cx.push.insert(PushField::ShaderTestsState);
cx.descriptors.storage_images = cx.descriptors.storage_images.saturating_add(1);
Ok(())
}
/// An upper estimate of the words the test adds: the stand-in and its type, and at each of
/// `rets` returns the guard, the state's fields, the depth (computed per sample, with its two
/// reads of the window depth, or returned, with Metal's rule for its sign, NaN and range) and
/// its clamp, the comparison's selections, the read, and the write; with the stencil test, its
/// stand-in and type, and at each return the face's state, the comparison's and operations'
/// selections, the read, and the write; and with a returned sample mask, at each return its bit's
/// test and the drop.
pub(super) fn words(cx: &SelectCx<'_>, rets: u64) -> u64 {
const OBJECT: u64 = 40;
const RETURN: u64 = 400;
const COMPUTED: u64 = 120;
const RETURNED: u64 = 160;
const STENCIL: u64 = 520;
const MASK: u64 = 80;
let Some(plan) = cx.families.fragment.depth_test else {
return 0;
};
let per_return = match (plan.window, plan.returned) {
(Some(_), _) => RETURN + COMPUTED,
(None, Some(_)) => RETURN + RETURNED,
(None, None) => RETURN,
};
let (objects, per_return) = match plan.stencil {
Some(_) => (2 * OBJECT, per_return + STENCIL),
None => (OBJECT, per_return),
};
let per_return = match plan.mask {
Some(_) => per_return + MASK,
None => per_return,
};
objects.saturating_add(rets.saturating_mul(per_return))
}
/// Declare the stand-in: a 2D `float` storage image of the planned declaration, multisampled or
/// arrayed as it holds the samples ([`StorageSamples`]).
pub(super) fn declare(
mb: &mut ModuleBuilder,
plan: Option<&DepthTest>,
) -> BResult<Option<GlobalId>> {
let Some(plan) = plan else {
return Ok(None);
};
let sampled_type = mb.ty(SType::Float { width: 32 })?;
let ty = mb.ty(SType::Image(ImageType {
sampled_type,
dim: Dim::D2,
depth: false,
arrayed: plan.samples == StorageSamples::Planes,
multisampled: plan.samples == StorageSamples::Multisampled,
usage: ImageUsage::Storage,
format: plan.declared,
}))?;
let slot = ResourceSlot {
stage: Stage::Fragment,
kind: ResourceKind::Synthetic(SyntheticBinding::DepthStandIn),
index: 0,
};
mb.resource(slot, StorageClass::UniformConstant, ty)
.map(Some)
}
/// Declare the stencil's stand-in, where the test runs the stencil test: a 2D `uint` storage
/// image of the planned declaration, multisampled where the depth's stand-in is.
pub(super) fn declare_stencil(
mb: &mut ModuleBuilder,
plan: Option<&DepthTest>,
) -> BResult<Option<GlobalId>> {
let Some((plan, stencil)) = plan.and_then(|p| Some((p, p.stencil?))) else {
return Ok(None);
};
let sampled_type = mb.ty(SType::Int {
width: 32,
signed: false,
})?;
let ty = mb.ty(SType::Image(ImageType {
sampled_type,
dim: Dim::D2,
depth: false,
arrayed: false,
multisampled: plan.samples == StorageSamples::Multisampled,
usage: ImageUsage::Storage,
format: stencil.declared,
}))?;
let slot = ResourceSlot {
stage: Stage::Fragment,
kind: ResourceKind::Synthetic(SyntheticBinding::StencilStandIn),
index: 0,
};
mb.resource(slot, StorageClass::UniformConstant, ty)
.map(Some)
}
/// A `u32` constant.
fn u32_value(fb: &mut FunctionBuilder<'_>, v: u32) -> BResult<SValue> {
let c = fb.u32_const(v)?;
fb.module().const_value(c)
}
/// An `f32` constant.
fn f32_value(fb: &mut FunctionBuilder<'_>, v: f32) -> BResult<SValue> {
let ty = fb.module().ty(SType::Float { width: 32 })?;
let c = fb.module().constant(Constant::Scalar {
ty,
bits: ConstBits(u64::from(v.to_bits())),
})?;
fb.module().const_value(c)
}
/// Whether `a cmp b` under Metal's compare function `code` (`MTLCompareFunction`: never, less,
/// equal, less-equal, greater, not-equal, greater-equal, always), with `a` the fragment's clamped
/// depth and `b` the stand-in's: neither is a NaN.
fn compare(fb: &mut FunctionBuilder<'_>, code: SValue, a: SValue, b: SValue) -> BResult<SValue> {
let never = super::bool_const(fb, false)?;
let always = super::bool_const(fb, true)?;
let less = fb.binary(BinOp::FOrdLessThan, a, b)?;
let equal = fb.binary(BinOp::FOrdEqual, a, b)?;
let less_equal = fb.binary(BinOp::FOrdLessThanEqual, a, b)?;
let greater = fb.binary(BinOp::FOrdGreaterThan, a, b)?;
let not_equal = fb.binary(BinOp::FOrdNotEqual, a, b)?;
let greater_equal = fb.binary(BinOp::FOrdGreaterThanEqual, a, b)?;
let choices = [
never,
less,
equal,
less_equal,
greater,
not_equal,
greater_equal,
always,
];
let mut out = choices[7];
for (i, &choice) in choices.iter().enumerate().take(7).rev() {
let k = u32_value(fb, i as u32)?;
let is = fb.binary(BinOp::IEqual, code, k)?;
out = fb.select(is, choice, out)?;
}
Ok(out)
}
/// Whether bit `bit` of `word` is set.
fn bit_set(fb: &mut FunctionBuilder<'_>, word: SValue, bit: u32) -> BResult<SValue> {
let b = u32_value(fb, bit)?;
let masked = fb.binary(BinOp::BitwiseAnd, word, b)?;
let zero = u32_value(fb, 0)?;
fb.binary(BinOp::INotEqual, masked, zero)
}
/// Depth `z` clamped as Metal clamps the depth it tests and stores, under the state's word `word`
/// and its depth range `near`, `far`: to the viewport's range `[min(near, far), max(near, far)]` in
/// clamp mode, to `[0, 1]` in clip mode; a `-0` as `+0`, on the bits, which no float optimization
/// folds away.
fn clamped(
fb: &mut FunctionBuilder<'_>,
z: SValue,
word: SValue,
(near, far): (SValue, SValue),
) -> BResult<SValue> {
let clamp_mode = bit_set(fb, word, CLAMP_BIT)?;
let low = fb.glsl(GlslOp::FMin, &[near, far])?;
let high = fb.glsl(GlslOp::FMax, &[near, far])?;
let zero = f32_value(fb, 0.0)?;
let one = f32_value(fb, 1.0)?;
let low = fb.select(clamp_mode, low, zero)?;
let high = fb.select(clamp_mode, high, one)?;
let z = fb.glsl(GlslOp::FClamp, &[z, low, high])?;
let u32_ = fb.module().ty(SType::Int {
width: 32,
signed: false,
})?;
let f32_ = fb.module().ty(SType::Float { width: 32 })?;
let bits = fb.convert(ConvOp::Bitcast, z, u32_)?;
let negative_zero = u32_value(fb, 0x8000_0000)?;
let is_negative_zero = fb.binary(BinOp::IEqual, bits, negative_zero)?;
let zero_bits = u32_value(fb, 0)?;
let bits = fb.select(is_negative_zero, zero_bits, bits)?;
fb.convert(ConvOp::Bitcast, bits, f32_)
}
/// A returned depth `z` as Metal tests and stores it, under the state's word `word` and its depth
/// range `near`, `far`: a value with its sign bit set is +0 (a negative NaN stays 0 in clamp mode,
/// past the range); a value past 1, `+inf` included, is 1; then, in clamp mode, the range
/// `[min(near, far), max(near, far)]` clamps it, a `-0` as `+0`. The sign and the unit clamp are
/// decided on the bits, so a positive denormal is kept. A positive NaN, which fails Metal's test
/// whatever the compare function, never reaches it: the return's store of the depth output recorded
/// it as discarded (`stage_io::clamp_depth`).
fn returned_depth(
fb: &mut FunctionBuilder<'_>,
z: SValue,
word: SValue,
(near, far): (SValue, SValue),
) -> BResult<SValue> {
let u32_ = fb.module().ty(SType::Int {
width: 32,
signed: false,
})?;
let f32_ = fb.module().ty(SType::Float { width: 32 })?;
let bits = fb.convert(ConvOp::Bitcast, z, u32_)?;
let magnitude_mask = u32_value(fb, 0x7FFF_FFFF)?;
let magnitude = fb.binary(BinOp::BitwiseAnd, bits, magnitude_mask)?;
let infinity = u32_value(fb, 0x7F80_0000)?;
let nan = fb.binary(BinOp::UGreaterThan, magnitude, infinity)?;
let sign_bit = u32_value(fb, 0x8000_0000)?;
let negative = fb.binary(BinOp::UGreaterThanEqual, bits, sign_bit)?;
let negative_nan = fb.binary(BinOp::LogicalAnd, nan, negative)?;
let one = u32_value(fb, 0x3F80_0000)?;
let past_one = fb.binary(BinOp::UGreaterThan, bits, one)?;
let unit = fb.select(past_one, one, bits)?;
let zero = u32_value(fb, 0)?;
let unit = fb.select(negative, zero, unit)?;
let unit = fb.convert(ConvOp::Bitcast, unit, f32_)?;
let clamp_mode = bit_set(fb, word, CLAMP_BIT)?;
let low = fb.glsl(GlslOp::FMin, &[near, far])?;
let high = fb.glsl(GlslOp::FMax, &[near, far])?;
let ranged = fb.glsl(GlslOp::FClamp, &[unit, low, high])?;
let not_nan = fb.unary(UnOp::LogicalNot, negative_nan)?;
let ranges = fb.binary(BinOp::LogicalAnd, clamp_mode, not_nan)?;
let z = fb.select(ranges, ranged, unit)?;
let bits = fb.convert(ConvOp::Bitcast, z, u32_)?;
let is_negative_zero = fb.binary(BinOp::IEqual, bits, sign_bit)?;
let bits = fb.select(is_negative_zero, zero, bits)?;
fb.convert(ConvOp::Bitcast, bits, f32_)
}
/// At a return of value `v`: unless a discard was recorded, test the fragment's clamped depth (its
/// returned one where it returns depth) against the stand-in's texel at its pixel by the draw's
/// compare function, run the stencil test where the plan has one (its comparison, then the
/// operation the two tests' results select, written to the stencil's stand-in), write the depth
/// where both pass and the draw writes depth, and record a failing fragment as discarded (see the
/// module docs). Called before the storage form's color store, which a recorded discard skips.
pub(super) fn emit_return(
cx: &mut EmitCx<'_>,
fb: &mut FunctionBuilder<'_>,
v: Option<crate::air::ir::ValueId>,
) -> BResult<()> {
let Some(plan) = cx.plan.families.fragment.depth_test else {
return Ok(());
};
let Some(stand_in) = cx.decl.families.fragment.depth_stand_in else {
return Err(cx.fail("the depth stand-in is not declared"));
};
let Some(discarded) = cx.decl.families.fragment.discarded else {
return Err(cx.fail("an in-shader depth test without its discard predicate"));
};
let Some(coord) = cx.plan.families.fragment.fetch_coord else {
return Err(cx.fail("an in-shader depth test without its FragCoord"));
};
let state = cx.push_field(fb, PushField::ShaderTestsState)?;
let (pixel, operands) = texel(cx, fb, plan.samples)?;
let mem = memory_model::coherence(cx.plan).texel(fb)?;
let frag = stage_io::object_global(cx, coord)?;
let frag = fb.module().global_value(frag)?;
let frag = fb.load(frag, MemAccess::default())?;
let depth = fb.composite_extract(frag, &[2])?;
let f32_ = fb.module().ty(SType::Float { width: 32 })?;
let word = fb.composite_extract(state, &[0, 0])?;
let near = fb.composite_extract(state, &[0, 1])?;
let near = fb.convert(ConvOp::Bitcast, near, f32_)?;
let far = fb.composite_extract(state, &[0, 2])?;
let far = fb.convert(ConvOp::Bitcast, far, f32_)?;
let returned = match plan.returned {
Some(field) => Some(exported(cx, fb, v, field)?),
None => None,
};
let depth = match (plan.window, returned) {
(_, Some(returned)) => returned,
(Some(window), None) => sample_depth(cx, fb, window, depth, (near, far))?,
(None, None) => depth,
};
// The stencil test's stand-in, the face's word and reference.
let stencil = match plan.stencil {
Some(s) => {
let Some(image) = cx.decl.families.fragment.stencil_stand_in else {
return Err(cx.fail("the stencil stand-in is not declared"));
};
let state = cx.push_field(fb, PushField::ShaderStencilState)?;
let facing = stage_io::object_global(cx, s.front_facing)?;
let facing = fb.module().global_value(facing)?;
let front = fb.load(facing, MemAccess::default())?;
let front_word = fb.composite_extract(state, &[0, 0])?;
let back_word = fb.composite_extract(state, &[0, 1])?;
let face = fb.select(front, front_word, back_word)?;
// A returned stencil's low 8 bits are both faces' reference, in place of the draw's.
let reference = match s.returned {
Some(field) => exported(cx, fb, v, field)?,
None => {
let references = fb.composite_extract(state, &[0, 2])?;
let zero = u32_value(fb, 0)?;
let eight = u32_value(fb, 8)?;
let shift = fb.select(front, zero, eight)?;
fb.binary(BinOp::ShiftRightLogical, references, shift)?
}
};
let max = u32_value(fb, 0xFF)?;
let reference = fb.binary(BinOp::BitwiseAnd, reference, max)?;
Some(StencilStep {
image,
face,
reference,
})
}
None => None,
};
let p = fb.module().global_value(discarded)?;
let was = fb.load(p, MemAccess::default())?;
// A returned sample mask without the invocation's sample's bit (bit 0 at one sample) drops
// the fragment before the tests, as Metal's coverage does: no test, no write, no store.
// Beside a returned stencil the stencil test still runs for it, its depth test failing
// (measured): `uncovered` reaches the tests.
let returned_stencil = plan.stencil.is_some_and(|t| t.returned.is_some());
let (was, uncovered) = match plan.mask {
Some(field) => {
let mask = exported(cx, fb, v, field)?;
let sample = match plan.samples {
StorageSamples::One => u32_value(fb, 0)?,
StorageSamples::Multisampled | StorageSamples::Planes => {
match super::fetch::sample(cx, fb)? {
Some(sample) => sample,
None => return Err(cx.fail("a per-sample mask without its SampleId")),
}
}
};
let bit = fb.binary(BinOp::ShiftRightLogical, mask, sample)?;
let one = u32_value(fb, 1)?;
let bit = fb.binary(BinOp::BitwiseAnd, bit, one)?;
let zero = u32_value(fb, 0)?;
let uncovered = fb.binary(BinOp::IEqual, bit, zero)?;
match returned_stencil {
true => (was, Some(uncovered)),
false => {
let dropped = fb.binary(BinOp::LogicalOr, was, uncovered)?;
fb.store(p, dropped, MemAccess::default())?;
(dropped, None)
}
}
}
None => (was, None),
};
let kept = fb.unary(UnOp::LogicalNot, was)?;
let is_returned = returned.is_some();
let arm: ArmFn<'_, ()> = Box::new(move |fb, _| {
let z = match is_returned {
true => returned_depth(fb, depth, word, (near, far))?,
false => clamped(fb, depth, word, (near, far))?,
};
let image = fb.module().global_value(stand_in)?;
let image = fb.load(image, MemAccess::default())?;
let texel = fb.read(image, pixel, &operands, mem)?;
let stored = fb.composite_extract(texel, &[0])?;
let seven = u32_value(fb, 7)?;
let code = fb.binary(BinOp::BitwiseAnd, word, seven)?;
let passed = compare(fb, code, z, stored)?;
// Outside a returned mask, beside a returned stencil, the depth test fails.
let passed = match uncovered {
Some(uncovered) => {
let covered = fb.unary(UnOp::LogicalNot, uncovered)?;
fb.binary(BinOp::LogicalAnd, passed, covered)?
}
None => passed,
};
// The stencil test, first in Metal's order: its operation follows both results.
let passed = match stencil {
Some(step) => stencil_test(fb, step, (pixel, &operands, mem), passed)?,
None => passed,
};
let writes = bit_set(fb, word, WRITE_BIT)?;
let store = fb.binary(BinOp::LogicalAnd, passed, writes)?;
let write: ArmFn<'_, ()> = Box::new(move |fb, _| {
let f32_ = fb.module().ty(SType::Float { width: 32 })?;
let vec4 = fb.module().ty(SType::Vector { elem: f32_, len: 4 })?;
let zero = f32_value(fb, 0.0)?;
let texel = fb.composite_construct(vec4, &[z, zero, zero, zero])?;
fb.write(image, pixel, texel, &operands, mem)?;
Ok(ArmEnd::FallThrough(Vec::new()))
});
fb.if_(&mut (), store, write, None)?;
// A failing fragment is dropped: the entry kills it after the critical section, and
// the return's color store skips it.
let failed = fb.unary(UnOp::LogicalNot, passed)?;
let p = fb.module().global_value(discarded)?;
fb.store(p, failed, MemAccess::default())?;
Ok(ArmEnd::FallThrough(Vec::new()))
});
fb.if_(&mut (), kept, arm, None)?;
Ok(())
}
/// Field `field` of the returned value `v` (the value itself where the entry returns one
/// output): an export the in-shader tests take.
fn exported(
cx: &mut EmitCx<'_>,
fb: &mut FunctionBuilder<'_>,
v: Option<crate::air::ir::ValueId>,
field: u32,
) -> BResult<SValue> {
let Some(v) = v else {
return Err(cx.fail("a tested export without a returned value"));
};
let x = cx.operand(fb, v)?;
match cx.plan.families.stage_io.returned {
Returned::Struct => fb.composite_extract(x, &[field]),
Returned::Value => Ok(x),
Returned::Void => Err(cx.fail("a tested export of a void entry")),
}
}
/// What the stencil test of one return reads: the stencil's stand-in (its global), and the face's
/// word and 8-bit reference.
#[derive(Clone, Copy)]
struct StencilStep {
image: GlobalId,
face: SValue,
reference: SValue,
}
/// Metal's stencil test of the fragment at its texel `at` (the depth's stand-in's texel, image
/// operands and coherence: one sample, or the invocation's sample of a multisampled stand-in)
/// under `step`, after the depth test, which passed where `depth_passed` (see the module docs):
/// read the stand-in's value, compare the reference with it under the read mask, write the
/// stencil-failure, depth-failure or pass operation's value under the write mask. Whether both
/// tests passed.
fn stencil_test(
fb: &mut FunctionBuilder<'_>,
step: StencilStep,
(pixel, operands, mem): (SValue, &ImageOperands, crate::spirv::ir::TexelMemory),
depth_passed: SValue,
) -> BResult<SValue> {
let StencilStep {
image,
face,
reference,
} = step;
let image = fb.module().global_value(image)?;
let image = fb.load(image, MemAccess::default())?;
let texel = fb.read(image, pixel, operands, mem)?;
let stored = fb.composite_extract(texel, &[0])?;
let compare_code = stencil::field_of(fb, face, 0, 3)?;
let fail_code = stencil::field_of(fb, face, 3, 3)?;
let pass_code = stencil::field_of(fb, face, 6, 3)?;
let read_mask = stencil::field_of(fb, face, 9, 8)?;
let write_mask = stencil::field_of(fb, face, 17, 8)?;
let depth_fail_code = stencil::field_of(fb, face, 25, 3)?;
let a = fb.binary(BinOp::BitwiseAnd, reference, read_mask)?;
let b = fb.binary(BinOp::BitwiseAnd, stored, read_mask)?;
let stencil_passed = stencil::compare(fb, compare_code, a, b)?;
let on_pass = fb.select(depth_passed, pass_code, depth_fail_code)?;
let code = fb.select(stencil_passed, on_pass, fail_code)?;
let written = stencil::operation(fb, code, stored, reference)?;
let max = u32_value(fb, 0xFF)?;
let keep_mask = fb.binary(BinOp::BitwiseXor, write_mask, max)?;
let kept_bits = fb.binary(BinOp::BitwiseAnd, stored, keep_mask)?;
let new_bits = fb.binary(BinOp::BitwiseAnd, written, write_mask)?;
let value = fb.binary(BinOp::BitwiseOr, kept_bits, new_bits)?;
let u32_ = fb.module().ty(SType::Int {
width: 32,
signed: false,
})?;
let uvec4 = fb.module().ty(SType::Vector { elem: u32_, len: 4 })?;
let zero = u32_value(fb, 0)?;
let texel = fb.composite_construct(uvec4, &[value, zero, zero, zero])?;
fb.write(image, pixel, texel, operands, mem)?;
fb.binary(BinOp::LogicalAnd, stencil_passed, depth_passed)
}
/// The stand-in's texel of the invocation's sample held as `samples`, and the access's image
/// operands: the pixel alone at one sample; with the `Sample` operand of its `SampleId` in a
/// multisampled image; and for planes the pixel and its `SampleId` as the layer.
fn texel(
cx: &mut EmitCx<'_>,
fb: &mut FunctionBuilder<'_>,
samples: StorageSamples,
) -> BResult<(SValue, ImageOperands)> {
let pixel = super::fetch::pixel(cx, fb)?;
if samples == StorageSamples::One {
return Ok((pixel, ImageOperands::default()));
}
let Some(sample) = super::fetch::sample(cx, fb)? else {
return Err(cx.fail("a per-sample depth test without its SampleId"));
};
if samples == StorageSamples::Multisampled {
let operands = ImageOperands {
sample: Some(sample),
..ImageOperands::default()
};
return Ok((pixel, operands));
}
let u32_ = fb.module().ty(SType::Int {
width: 32,
signed: false,
})?;
let uvec3 = fb.module().ty(SType::Vector { elem: u32_, len: 3 })?;
let x = fb.composite_extract(pixel, &[0])?;
let y = fb.composite_extract(pixel, &[1])?;
let at = fb.composite_construct(uvec3, &[x, y, sample])?;
Ok((at, ImageOperands::default()))
}
/// The invocation's sample's depth computed from the window-depth input object `window` and the
/// pixel centre's `FragCoord.z` `centre` under the viewport's depth range `near`, `far` (see the
/// module docs): `(v(sample) · (far − near) + near) + (centre − (v(centre) · (far − near) +
/// near))`, each operation rounded on its own.
fn sample_depth(
cx: &mut EmitCx<'_>,
fb: &mut FunctionBuilder<'_>,
window: usize,
centre: SValue,
(near, far): (SValue, SValue),
) -> BResult<SValue> {
let Some(sample) = super::fetch::sample(cx, fb)? else {
return Err(cx.fail("a computed sample depth without its SampleId"));
};
let var = stage_io::object_global(cx, window)?;
let var = fb.module().global_value(var)?;
let at_sample = fb.glsl(GlslOp::InterpolateAtSample, &[var, sample])?;
let at_centre = fb.load(var, MemAccess::default())?;
let range = fb.binary_no_contraction(BinOp::FSub, far, near)?;
let window_depth = |fb: &mut FunctionBuilder<'_>, v: SValue| -> BResult<SValue> {
let scaled = fb.binary_no_contraction(BinOp::FMul, v, range)?;
fb.binary_no_contraction(BinOp::FAdd, scaled, near)
};
let at_sample = window_depth(fb, at_sample)?;
let at_centre = window_depth(fb, at_centre)?;
let carried = fb.binary_no_contraction(BinOp::FSub, centre, at_centre)?;
fb.binary_no_contraction(BinOp::FAdd, at_sample, carried)
}
@@ -1881,21 +1881,6 @@ pub(super) fn plan(cx: &mut SelectCx<'_>) -> Result<(), Error> {
early_tests,
early_variant: tested && !untested,
});
// Compiled for a draw whose depth test alone can drop a fragment, the function runs that
// test itself, before its store (`depth_test`).
if cx.inputs.shader_tests {
// A returned depth is tested, a returned stencil is the stencil test's reference, and
// a returned sample mask keeps the fragment's samples before the tests.
let field = |role: fn(&OutputRole) -> bool| {
outputs.iter().find(|o| role(&o.role)).map(|o| o.field)
};
let exports = super::depth_test::Exports {
depth: field(|r| matches!(r, OutputRole::Depth(_))),
stencil: field(|r| matches!(r, OutputRole::Stencil)),
mask: field(|r| matches!(r, OutputRole::SampleMask)),
};
super::depth_test::plan(cx, exports)?;
}
}
// A per-sample function's returned mask gates its storage writes. At one sample too, on the
// mask's bit 0 (measured: Metal stores no color there without it).
@@ -514,22 +514,18 @@ fn declared_early(cx: &SelectCx<'_>) -> bool {
/// - any other writes before Vulkan's tests and states `RuntimeFact::TestedStorageWrites`, as the
/// framebuffer fetch's storage form does: a draw whose tests drop no fragment runs it as
/// compiled, one whose tests drop some but write and count nothing the variant that declares
/// early tests (where only a discard kept them away, `early_variant`), and one whose depth test
/// acts the variant that runs the draw's depth test itself, before the write
/// (`depth_test`), and its stencil test too where that acts (`bind::graphics`).
/// early tests (where only a discard kept them away, `early_variant`); the binder refuses a draw
/// whose depth or stencil test acts (`bind::graphics`).
fn plan_tests(cx: &mut SelectCx<'_>) -> Result<bool, Error> {
if declared_early(cx) {
return Ok(false);
}
let outputs = &cx.entry.ep.outputs;
let field =
|role: fn(&OutputRole) -> bool| outputs.iter().find(|o| role(&o.role)).map(|o| o.field);
let exports = super::depth_test::Exports {
depth: field(|r| matches!(r, OutputRole::Depth(_))),
stencil: field(|r| matches!(r, OutputRole::Stencil)),
mask: field(|r| matches!(r, OutputRole::SampleMask)),
};
let exported = exports.depth.is_some() || exports.stencil.is_some() || exports.mask.is_some();
let exported = cx.entry.ep.outputs.iter().any(|o| {
matches!(
o.role,
OutputRole::Depth(_) | OutputRole::Stencil | OutputRole::SampleMask
)
});
let body = super::fetch::body_facts(cx);
let only_outputs = !exported && !body.side_effects;
let fp = &cx.families.fragment;
@@ -550,9 +546,6 @@ fn plan_tests(cx: &mut SelectCx<'_>) -> Result<bool, Error> {
early_tests: only_outputs && cx.inputs.read_only_tests,
early_variant: only_outputs,
});
if cx.inputs.shader_tests && cx.families.fragment.depth_test.is_none() {
super::depth_test::plan(cx, exports)?;
}
}
Ok(stated.is_none() && only_outputs && cx.inputs.read_only_tests)
}
+4 -28
View File
@@ -29,12 +29,6 @@
//! output is tested and written by the function itself against a shadow of the stencil, inside
//! the interlock critical section, at each return; a failing fragment is recorded as discarded
//! and killed after the critical section.
//! - **The depth test in the shader** (`depth_test`): a function that stores a color in the storage
//! form before its draws' tests, compiled for a draw whose depth test alone can drop a fragment,
//! tests and writes its depth itself against a stand-in of the depth attachment, inside the
//! interlock critical section, at each return; a failing fragment is recorded as discarded and
//! killed after the critical section. Compiled for a draw whose stencil test acts too, it runs
//! that first, against a stand-in of the stencil attachment.
//! - **Coverage at sample rate** (`coverage`): a function that reads `[[sample_mask]]` and that
//! Metal runs once per covered sample runs, compiled for a multisampled pipeline, once per pixel,
//! and its body once per covered sample from a loop over the pixel's coverage ([`wrap_entry`]),
@@ -57,7 +51,6 @@
mod color;
mod coverage;
mod depth_test;
mod discard;
pub(crate) mod fetch;
mod imageblock;
@@ -100,10 +93,6 @@ use crate::spirv::ir::{
pub use color::ColorInput;
pub use coverage::CoveragePlan;
pub use depth_test::DepthTest;
pub(crate) use depth_test::{
depth_test_form, depth_test_word, stencil_test_form, stencil_test_word, STAND_IN_FORMAT,
};
pub use discard::DiscardForm;
pub(crate) use fetch::{
compiled_write_mask, extended_range_blend, half_float_format, inputs_order, interlock_orders,
@@ -238,9 +227,6 @@ pub struct FragmentPlan {
pub fetch_mask: Option<u32>,
/// The function's `[[stencil]]` output is a shader-side stencil (`stencil`).
pub stencil: Option<ShadowStencil>,
/// The function runs its draw's depth test itself against a stand-in of the depth
/// attachment (`depth_test`).
pub depth_test: Option<DepthTest>,
/// The function reads `[[sample_mask]]` and runs once per covered sample on Metal: its loop
/// over the covered samples, or why it has none (`coverage`).
pub coverage: Option<CoveragePlan>,
@@ -274,15 +260,14 @@ impl FragmentPlan {
/// The function declares `discarded`: a predicated site, inside an interlocked body a
/// terminate-form site (which records the discard and returns to the entry) or a depth output
/// (whose returns record a positive NaN), a shader-side stencil, or an in-shader depth test,
/// which records a failing fragment.
/// (whose returns record a positive NaN), or a shader-side stencil, which records a failing
/// fragment.
pub fn records_discards(&self) -> bool {
self.predicated()
|| (self.interlock.is_some()
&& (self.depth_output
|| self.discards.values().any(|f| *f == DiscardForm::Terminate)))
|| self.stencil.is_some()
|| self.depth_test.is_some()
}
fn kill_form(&self) -> KillForm {
@@ -416,7 +401,6 @@ pub fn finish(cx: &mut SelectCx<'_>, m: &mut Meter) -> Result<(), Error> {
.saturating_add(input_blend::words(cx, returns(cx)))
.saturating_add(word_input::words(cx, returns(cx)))
.saturating_add(logic::words(cx, returns(cx)))
.saturating_add(depth_test::words(cx, rets))
.saturating_add(killing_rets.saturating_mul(RETURN_KILL_WORDS))
.saturating_add((quad_exits.len() as u64).saturating_mul(QUAD_EXIT_WORDS))
.saturating_add((guarded.len() as u64).saturating_mul(GUARD_WORDS))
@@ -452,10 +436,6 @@ pub struct Declared {
pub imageblock: Option<GlobalId>,
/// The shadow of a shader-side stencil.
pub shadow_stencil: Option<GlobalId>,
/// The stand-in of the depth attachment an in-shader depth test reads and writes.
pub depth_stand_in: Option<GlobalId>,
/// The stand-in of the stencil attachment an in-shader stencil test reads and writes.
pub stencil_stand_in: Option<GlobalId>,
/// The `Private u32` holding the sample of the loop's pass over the covered samples.
pub loop_sample: Option<GlobalId>,
/// The `Private u32` copy of the `SampleMask` input's word, which the entry stores before it
@@ -504,8 +484,6 @@ pub fn declare(
)?;
d.imageblock = imageblock::declare(mb, fp.imageblock.as_ref())?;
d.shadow_stencil = stencil::declare(mb, fp.stencil.as_ref())?;
d.depth_stand_in = depth_test::declare(mb, fp.depth_test.as_ref())?;
d.stencil_stand_in = depth_test::declare_stencil(mb, fp.depth_test.as_ref())?;
d.loop_sample = coverage::declare(mb, plan)?;
d.snapshot = snapshot::declare(mb, &fp.snapshot)?;
if wraps_body(fp) && sample_mask_input(plan).is_some() {
@@ -862,9 +840,8 @@ pub fn not_discarded(cx: &mut EmitCx<'_>, fb: &mut FunctionBuilder<'_>) -> BResu
}
/// Emit the entry's return terminator after `stage_io::emit_return` stored the outputs: a
/// shader-side stencil tests and writes its shadow, recording a failing fragment as discarded, and
/// an in-shader depth test its stand-in; the outputs of returned value `v` to attachments in the
/// storage form and its imageblock output are written, then a predicated discard kills a discarded
/// shader-side stencil tests and writes its shadow, recording a failing fragment as discarded; the
/// outputs of returned value `v` to attachments in the storage form and its imageblock output are written, then a predicated discard kills a discarded
/// invocation, which drops its outputs. An interlocked body only returns; its caller kills after
/// the critical section.
pub fn emit_return(
@@ -873,7 +850,6 @@ pub fn emit_return(
v: Option<crate::air::ir::ValueId>,
) -> BResult<()> {
stencil::emit_return(cx, fb, v)?;
depth_test::emit_return(cx, fb, v)?;
fetch::emit_return(cx, fb, v)?;
imageblock::emit_return(cx, fb, v)?;
let fp = &cx.plan.families.fragment;
-4
View File
@@ -180,10 +180,6 @@ pub const fn shape(f: PushField) -> FieldShape {
PushField::VerticesPerPrimitive => FieldShape::U32,
// The front face's word, then the back face's.
PushField::ShadowStencilState => FieldShape::UVec2,
// The depth word, viewport 0's near and far, and a zero word.
PushField::ShaderTestsState => FieldShape::UVec4Array(1),
// The faces' stencil words, the references, and a zero word.
PushField::ShaderStencilState => FieldShape::UVec4Array(1),
// A zero word, the index count, the first instance, and the base vertex.
PushField::CaptureLayout => FieldShape::UVec4Array(1),
// Four bits of kept channels per color attachment.
@@ -492,9 +492,6 @@ pub struct StageIoPlan {
/// builtin, because its device takes the first vertex's as Metal does
/// (`VkProperty::MetalFirstVertexIndices`): the module requires that property.
pub first_vertex_indices_by_device: bool,
/// A vertex function compiled under `LoweringInputs::window_depth_varying` writes its
/// position's window depth to a varying ([`WindowDepth`]).
pub window_depth: Option<WindowDepth>,
/// A vertex function compiled in the de-indexed or private list form reads its vertex from
/// the draw's indices ([`CapturedIndex`]): planned where the function reads it
/// (`[[vertex_id]]`, a per-vertex attribute, `[[base_vertex]]` or the primitive ID).
@@ -581,21 +578,6 @@ pub enum FirstVertex {
/// an extract, the subtraction, the division and the store.
const PRIMITIVE_ID_WORDS: u64 = 56;
/// How a vertex function compiled under `LoweringInputs::window_depth_varying` writes its
/// window depth: at each return, the `z / w` of the value it stores to its `Position` object
/// (`position`, after any clamp) to its `IoRole::WindowDepth` varying
/// (`object`), for a fragment function that computes each sample's depth from it
/// (`lower::fragment`'s `depth_test`).
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct WindowDepth {
pub position: usize,
pub object: usize,
}
/// The words a vertex function's window depth adds: its variable, decorations and interface
/// entry, two extracts, the division, and the store.
const WINDOW_DEPTH_WORDS: u64 = 40;
/// How a vertex function compiled in the primitive ID's de-indexed form
/// (`LoweringInputs::primitive_id_indices`) reads its vertex: its stream position
/// `p = VertexIndex` (`vertex` is the input builtin's object; the draw starts at vertex 0) names
@@ -624,15 +606,6 @@ pub struct CapturedIndex {
/// alignment and shift, and the base vertex's extract and add (at most 224, a `u16` read's).
pub(super) const CAPTURED_INDEX_WORDS: u64 = 400;
/// Plan the fragment's window-depth input for a fragment function that computes each sample's
/// depth for its in-shader depth test: the index of its object, a no-perspective `float` varying of
/// `IoRole::WindowDepth`.
pub fn window_depth_input(cx: &mut SelectCx<'_>) -> Result<usize, Error> {
let sp = &mut cx.families.stage_io;
sp.words = sp.words.saturating_add(WINDOW_DEPTH_WORDS);
plan::window_depth(sp, IoDir::Input)
}
/// The second output (`[[color(n), index(1)]]`) a fragment function writes for an attachment held
/// with its channels rotated (`LoweringInputs::rotated_factors`): beside its first output there,
/// the returned value's field `field` (0 for a returned value itself), whose channels or
@@ -1848,7 +1821,6 @@ pub fn emit_return(
let seconds = plan.rotated_seconds.clone();
let region_copy = plan.region_copy;
let depth_clamp = plan.depth_clamp;
let window_depth = plan.window_depth;
let primitive_id = plan.primitive_id;
// The private masks: the pixel's ANDed into the function's own `[[sample_mask]]` output
// where this return stores one, else stored as that output.
@@ -1891,9 +1863,6 @@ pub fn emit_return(
}
None => part,
};
if let Some(w) = window_depth.filter(|w| w.position == o.link.object) {
store_window_depth(cx, fb, w, part)?;
}
let part = match private_mask.filter(|m| m.object == o.link.object) {
Some(m) => {
masked = true;
@@ -2042,28 +2011,6 @@ pub(crate) fn metal_point_size(fb: &mut FunctionBuilder<'_>, size: SValue) -> BR
/// three constants.
pub(crate) const POINT_SIZE_WORDS: u64 = 7;
/// Store the window depth `z / w` of position `position`, as the vertex function stores it, to
/// its varying ([`WindowDepth`]): the division of the measured form, unfused.
fn store_window_depth(
cx: &mut EmitCx<'_>,
fb: &mut FunctionBuilder<'_>,
w: WindowDepth,
position: SValue,
) -> BResult<()> {
let z = fb.composite_extract(position, &[2])?;
let clip_w = fb.composite_extract(position, &[3])?;
let depth = fb.binary(BinOp::FDiv, z, clip_w)?;
let link = Link {
object: w.object,
place: Place::Whole,
form: Form {
held: Held::Float(crate::lower::arith::FloatFmt::F32),
lanes: 1,
},
};
store(cx, fb, &link, depth)
}
/// Store the primitive ID of the primitive the vertex provokes to its varying
/// ([`PrimitiveIdStore`]): `(VertexIndex - first) / n`, `n` from
/// `PushField::VerticesPerPrimitive`.
@@ -1682,38 +1682,6 @@ fn zero_index(
Ok(())
}
/// The window depth's `float` variable in direction `dir` (`IoRole::WindowDepth`): a vertex
/// function's output, or the no-perspective input of a fragment function that computes each
/// sample's depth from it.
pub(super) fn window_depth(sp: &mut StageIoPlan, dir: IoDir) -> Result<usize, Error> {
let key = VaryingKey::window_depth();
let ty = IoType {
numeric: IoNumeric::Float,
components: 1,
source_bits: 32,
};
let mut deco = IoDecor {
packed: true,
..IoDecor::default()
};
let list = match dir {
IoDir::Input => {
deco.interpolation = SInterp::NoPerspective;
&mut sp.interface.inputs
}
IoDir::Output => &mut sp.interface.outputs,
};
push_var(
list,
IoVariable {
key: key.clone(),
role: IoRole::WindowDepth,
ty,
},
);
user(sp, key, dir, ty, deco)
}
/// The primitive ID's flat `uint` variable in direction `dir` (`IoRole::PrimitiveId`): the input a
/// fragment function reads as `[[primitive_id]]` on a device without a fragment `PrimitiveId` or
/// under `LoweringInputs::primitive_id_varying`, or the output of a vertex function compiled under
@@ -2394,17 +2362,6 @@ pub fn entry(cx: &mut SelectCx<'_>) -> Result<(), Error> {
crate::lower::fragment::select_imageblock_output(cx, o.field, ib, o.ty.align, ty)?;
continue;
}
// Compiled for draws whose fragment function runs their depth and stencil tests itself
// (`fragment::depth_test`), the device's stencil test is off: a stencil output is the
// in-shader stencil test's reference where the draws' stencil test acts, and changes
// nothing where it does not. Stored nowhere, on any device, so no shader-side stencil.
if matches!(o.role, OutputRole::Stencil)
&& cx.stage == Stage::Fragment
&& cx.inputs.shader_tests
{
int_scalar_form(cx, ty)?;
continue;
}
// A stencil output on a device without stencil export is the shader-side stencil,
// written to the stencil's shadow, not an interface variable.
if matches!(o.role, OutputRole::Stencil)
@@ -2666,27 +2623,6 @@ pub fn entry(cx: &mut SelectCx<'_>) -> Result<(), Error> {
if cx.inputs.region_copies && cx.stage == Stage::Vertex {
region_copy(cx, &outputs, returned)?;
}
// The window depth of the position the function stores, for a fragment function that
// computes each sample's depth from it. A function that writes no position rasterizes
// nothing.
if cx.inputs.window_depth_varying && cx.stage == Stage::Vertex {
let sp = &mut cx.families.stage_io;
let position = sp.objects.iter().position(|o| {
matches!(
o,
IoObject::Builtin {
builtin: B::Position,
dir: IoDir::Output,
..
}
)
});
if let Some(position) = position {
let object = window_depth(sp, IoDir::Output)?;
sp.window_depth = Some(super::WindowDepth { position, object });
sp.words = sp.words.saturating_add(super::WINDOW_DEPTH_WORDS);
}
}
// The primitive ID a fragment function reads from its varying.
if cx.inputs.primitive_id_varying && cx.stage == Stage::Vertex {
primitive_id_output(cx)?;
@@ -250,9 +250,6 @@ mod serde_round_trips {
addressed_function_tables: true,
interlocked_colors: BTreeSet::from([1]),
read_only_tests: true,
shader_tests: true,
shader_stencil: true,
window_depth_varying: true,
address_maps: BTreeMap::from([(
slot(Stage::Kernel, SlotClass::Texture, 7),
metal::sampler::AddressModeMap::IDENTITY.with(
@@ -449,9 +446,6 @@ mod serde_round_trips {
logic_operation: Some(crate::vk::LogicOp::XOR),
depth_compare_clamp_mask: 0x8000_0005,
read_only_tests: true,
shader_tests: true,
shader_stencil: true,
window_depth_varying: true,
rotated_colors: BTreeSet::from([4]),
alpha_in_red_colors: BTreeSet::from([4]),
rotated_factors: BTreeMap::from([(
@@ -639,20 +633,6 @@ mod serde_round_trips {
fragment_writes_memory: true,
color_outputs: 0b101,
sample_mask: Some(0b1001),
shader_tests: Some(crate::pipeline::graphics::ShaderTestsUse {
depth: crate::pipeline::graphics::StandInUse {
format: vk::Format::R32_SFLOAT,
formatless: false,
samples: 4,
view: crate::pipeline::graphics::StandInView::SamplePlanes { layers: 4 },
},
stencil: Some(crate::pipeline::graphics::StandInUse {
format: vk::Format::R8_UINT,
formatless: true,
samples: 4,
view: crate::pipeline::graphics::StandInView::Image,
}),
}),
snapshot_reads: true,
color_group: Some(crate::pipeline::ColorGroup {
present: vec![0, 5],
@@ -1015,9 +995,6 @@ mod bind_serde_round_trips {
interlocked_colors: BTreeSet::from([0, 3]),
fragment_tests: crate::bind::FragmentTests::Depth { writes: true },
snapshot_textures: BTreeSet::from([2]),
depth_range: [0.25, 0.75],
depth_clip_mode_clamp: true,
stencil_references: [0x5A, 0xC3],
blend_color: [0.25, -0.5, 1.5, 0.75],
alpha_test_reference: Some(0.375),
primitive_type: Some(metal::PrimitiveType::TriangleStrip),
@@ -1288,21 +1288,6 @@ pub enum PrecisionNote {
/// Validation derives no tolerance and no explanation from it: a difference stays a
/// mismatch for review.
LinkedSamplerNumbering,
/// A fragment function runs its draw's depth test itself at more than one sample on a device
/// whose `FragCoord.z` is the pixel centre's there
/// ([`VkProperty::CenterFragCoordDepth`](crate::device::VkProperty::CenterFragCoordDepth)), and
/// computes each sample's depth from its vertex function's window depth read at the sample,
/// plus `FragCoord.z` less that depth read at the centre, which carries the depth bias. On the
/// M4 that is the depth MoltenVK stores at every sample of flat, sloped and steep triangles
/// at the viewport's default depth range, under a constant bias, and where the clamp decides;
/// under perspective, a slope-scaled bias, or another depth range a sample's depth may be up
/// to 2 ulp from it, so a depth test between surfaces that close may decide
/// otherwise than Metal's. No draw's state is known when the module is made, so the function
/// records the note wherever it computes the depth.
///
/// Validation derives no tolerance and no explanation from it: a difference stays a
/// mismatch for review, deferred in C3 until an exact path exists.
ComputedSampleDepth,
/// An access through an argument buffer's sampler whose word the specialized module cannot read
/// may hand the device a pixel coordinate scaled by the texture's size, where the sampler
/// states pixel coordinates: the device's sampler reads its texels from that coordinate in its
@@ -1212,24 +1212,6 @@ fn graphics_requirements(
requirements.features.insert(VkFeature::Maintenance8);
}
}
// An in-shader depth test's stand-in; the module's own requirements name the interlock and
// the fragment stores. A multisampled stand-in has the pipeline's samples; planes are
// single-sample.
let mut multisampled_stand_in = false;
if let Some(t) = &graphics.shader_tests {
requirements.formats.extend(t.depth.format_usages());
multisampled_stand_in =
t.depth.view == crate::pipeline::graphics::StandInView::Image && t.depth.samples > 1;
// The stencil's stand-in, a multisampled image at more than one sample, copied to and
// from the stencil aspect by image copies there (`maintenance8`).
if let Some(s) = &t.stencil {
requirements.formats.extend(s.format_usages());
if s.samples > 1 {
requirements.features.insert(VkFeature::Maintenance8);
multisampled_stand_in = true;
}
}
}
let multisampled_shadow = artifacts.iter().any(|a| {
a.facts.iter().any(|f| {
matches!(
@@ -1248,7 +1230,7 @@ fn graphics_requirements(
.iter()
.any(|a| a.view == StorageAttachmentView::Attachment)
&& graphics.rasterization_samples.as_raw() > 1;
if multisampled_shadow || multisampled_storage || multisampled_stand_in {
if multisampled_shadow || multisampled_storage {
requirements
.properties
.insert(VkProperty::StorageImageSampleCount(
@@ -443,18 +443,6 @@ pub fn function_key(
h.bytes(b"read-only-tests");
}
// Appended only when set.
if inputs.shader_tests {
h.bytes(b"shader-tests");
}
// Appended only when set.
if inputs.shader_stencil {
h.bytes(b"shader-stencil");
}
// Appended only when set.
if inputs.window_depth_varying {
h.bytes(b"window-depth-varying");
}
// Appended only when set.
if inputs.threadgroup_size_matches_tile_size {
h.bytes(b"threadgroup-size-matches-tile-size");
}
@@ -717,9 +717,6 @@ fn the_inputs_encoding_is_the_earlier_derived_debug() {
.replace(", logic_operation: None", "")
.replace(", depth_compare_clamp_mask: 0", "")
.replace(", read_only_tests: false", "")
.replace(", shader_tests: false", "")
.replace(", shader_stencil: false", "")
.replace(", window_depth_varying: false", "")
.replace(", rotated_colors: {}", "")
.replace(", alpha_in_red_colors: {}", "")
.replace(", rotated_factors: {}", "")
-25
View File
@@ -585,20 +585,6 @@ pub enum RuntimeFact {
/// states it: the mark is a store, which costs a fragment function the device's hidden-surface
/// removal and early depth test although it never runs.
CubicArgumentSampler { stage: Stage },
/// The function runs the draw's depth test itself (`LoweringInputs::shader_tests`): compiled
/// for a draw whose tests may drop fragments, a function with `TestedStorageWrites` tests its
/// fragment's depth against a stand-in of the depth attachment inside the ordered pixel
/// interlock (`SyntheticBinding::DepthStandIn`, `PushField::ShaderTestsState`), stores its
/// colors and writes the stand-in only where it passes, and kills a fragment that fails
/// (`GraphicsState::shader_tests`). `formatless`: the module declares the stand-in without a
/// format (`Unknown`), else as `R32f`. `multisampled`: compiled for a pipeline of more than
/// one sample, the stand-in holds each sample, `planes` as a single-sample 2D array of one
/// layer per sample, else as a multisampled image.
ShaderTests {
formatless: bool,
multisampled: bool,
planes: bool,
},
/// The `stage` function samples, gathers, or queries a level of a heap texture of a sampled
/// float class of one sample, where for a texture a heap holds by its raw texels alone
/// (`bind::heap_raw_form`) it reads the class's neutral (zero, or the neutral's level) where
@@ -616,15 +602,6 @@ pub enum RuntimeFact {
/// with `None`, or naming a slot whose bound sampler states what the emulation does not
/// answer (`Unsupported(ArgumentBufferTextures)`).
HeapRawSamples { stage: Stage, sampler: Option<u32> },
/// Beside its depth test (`ShaderTests`), the function runs the draw's stencil test itself,
/// before the depth test, against a stand-in of the stencil attachment inside the ordered
/// pixel interlock (`SyntheticBinding::StencilStandIn`, `PushField::ShaderStencilState`): the
/// face's comparison of the reference with the stand-in's value under the read mask, then
/// its stencil-failure, depth-failure or pass operation under the write mask, as the two
/// tests decide. A fragment that fails either test is killed (`ShaderTestsUse::stencil`).
/// `formatless`: the module declares the stand-in without a format (`Unknown`), else as
/// `R8ui`. The stand-in holds the pipeline's samples as a multisampled image at more than one.
ShaderStencilTest { formatless: bool },
/// On a device that orders framebuffer fetch through rasterization-order input attachments,
/// the function computes Metal's blend `blend` into extended-range color attachment `color`
/// in the shader: it reads the attachment's raw texel through its input attachment
@@ -958,9 +935,7 @@ impl RuntimeFact {
RuntimeFact::ConstexprSampled { .. } => "ConstexprSampled",
RuntimeFact::CubicSampler { .. } => "CubicSampler",
RuntimeFact::CubicArgumentSampler { .. } => "CubicArgumentSampler",
RuntimeFact::ShaderTests { .. } => "ShaderTests",
RuntimeFact::HeapRawSamples { .. } => "HeapRawSamples",
RuntimeFact::ShaderStencilTest { .. } => "ShaderStencilTest",
RuntimeFact::ExtendedRangeInputBlend { .. } => "ExtendedRangeInputBlend",
RuntimeFact::RotatedInputBlend { .. } => "RotatedInputBlend",
RuntimeFact::WordInputMerge { .. } => "WordInputMerge",
@@ -220,13 +220,6 @@ pub struct GraphicsState {
/// or declares `[[early_fragment_tests]]` does; the consumer then passes no mask.
#[cfg_attr(feature = "serde", serde(default))]
pub sample_mask: Option<u32>,
/// The fragment function runs the draw's depth test itself, inside the ordered pixel
/// interlock, against a stand-in of the pass's depth attachment: a function that stores a color
/// through the interlocked storage form before Vulkan's tests, compiled for a draw whose tests
/// may drop fragments (`VariantKey::shader_tests`). `None` for every other pipeline. See
/// [`ShaderTestsUse`] for the consumer contract.
#[cfg_attr(feature = "serde", serde(default))]
pub shader_tests: Option<ShaderTestsUse>,
/// The fragment function reads textures through snapshots (`VariantKey::snapshot_textures`):
/// each draw of the pipeline is drawn twice in its subpass, the texture's attachment in
/// `VK_IMAGE_LAYOUT_ATTACHMENT_FEEDBACK_LOOP_OPTIMAL_EXT`, first with every color write mask 0,
@@ -478,7 +471,6 @@ impl GraphicsState {
fragment_writes_memory: false,
color_outputs: 0,
sample_mask: None,
shader_tests: None,
snapshot_reads: false,
color_group: None,
logic_op: None,
@@ -1083,120 +1075,6 @@ impl ShadowStencilUse {
}
}
/// A render pipeline whose fragment function runs the draw's depth test itself
/// (`GraphicsState::shader_tests`).
///
/// A function that stores a color through the interlocked storage form stores before Vulkan's
/// tests, where Metal stores only the fragments that pass them. For a draw whose tests may drop
/// fragments, the function tests itself: at each return, inside the ordered pixel interlock, it
/// reads the pixel's depth (its sample's, in a pipeline of more than one sample) from a stand-in of
/// the depth attachment, compares the fragment's depth with it by the encoder's compare function,
/// writes the stand-in where the test passes and depth writes are enabled, and stores its colors
/// only where it passes; a failing fragment is killed after the critical section, so the pass's
/// other color attachments drop it too. A discarded fragment changes nothing. The fragment's depth
/// is the device's `FragCoord.z` (Metal's `[[position]].z`), clamped as Metal clamps it: to `[0,
/// 1]` in depth clip mode, to the viewport's depth range in clamp mode.
///
/// The consumer, for each draw with such a pipeline:
///
/// - keeps the pass's depth/stencil attachment in the draw's subpass, with the depth test
/// enabled under `VK_COMPARE_OP_ALWAYS`, depth writes, the stencil test, and depth bounds off,
/// whatever the encoder's depth/stencil state: the function is the test, and the attachment is
/// not written during the draw;
/// - keeps the stand-in ([`StandInUse`]): an image of the depth attachment's extent with
/// `STORAGE` usage, in `GENERAL` layout, bound as the plan's `WriteSource::DepthStandIn`,
/// whose texel `(x, y)` holds pixel `(x, y)`'s depth as an `f32` (each sample's, as the
/// stand-in's view says);
/// - fills the stand-in from the depth aspect before the draw (or sets it to the pass's clear
/// depth where the draw's render pass instance clears the attachment) and writes it back to the
/// depth aspect after it, outside the render pass, with the barriers each copy needs.
/// Consecutive such draws share one fill and one write-back while nothing else uses the depth
/// attachment between them; a draw of another pipeline in between ends the instance;
/// - sets `BindState::depth_stencil`, `BindState::depth_range` and
/// `BindState::depth_clip_mode_clamp` to the encoder's state for the draw.
///
/// Where the draw's stencil test can drop a fragment or write (`stencil`), the function runs it
/// too, first, as Metal does: the face's (`FrontFacing`) comparison of its reference with the
/// stand-in's value under the read mask, then its stencil-failure, depth-failure or pass operation
/// under the write mask, and the depth test and color stores only where the stencil test passes.
/// The consumer then also (the stencil test staying off, as above):
///
/// - keeps the stencil's stand-in: an `R8_UINT` image of the stencil attachment's extent and the
/// pipeline's samples (multisampled at more than one) with `STORAGE` usage, in `GENERAL`
/// layout, bound as the plan's `WriteSource::StencilStandIn`, whose texel `(x, y)` (each
/// sample) holds pixel `(x, y)`'s stencil (that sample's);
/// - fills it from the stencil aspect before the draw (or sets it to the pass's clear value
/// where the draw's render pass instance clears the stencil) and writes it back to the stencil
/// aspect after it, as for the depth: of one sample through a buffer, of more by
/// `vkCmdCopyImage` between the stencil aspect and the stand-in, which `VK_KHR_maintenance8`
/// allows (the pipeline requires it then), as for the shader-side stencil's shadow
/// ([`ShadowStencilUse`]);
/// - sets `BindState::stencil_references` to the encoder's front and back references.
///
/// The binder refuses a counted draw (a visibility result mode is set), an amplified draw, and a
/// pass of more than one layer; it asks for the function only for a pass with a depth
/// attachment, and for the stencil's stand-in only for a pass with both.
#[non_exhaustive]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ShaderTestsUse {
/// The depth attachment's stand-in.
pub depth: StandInUse,
/// The stencil attachment's stand-in, where the function runs the stencil test too
/// (`RuntimeFact::ShaderStencilTest`): `R8_UINT`, viewed as an image of the pipeline's
/// samples. `None` where the draws it serves have a stencil test that does nothing.
#[cfg_attr(feature = "serde", serde(default))]
pub stencil: Option<StandInUse>,
}
/// A stand-in of a depth or stencil attachment's plane, which a fragment function that runs the
/// draw's tests itself reads and writes as a storage image (`GraphicsState::shader_tests`).
#[non_exhaustive]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct StandInUse {
/// The stand-in's format: `R32_SFLOAT` for depth, `R8_UINT` for stencil.
pub format: vk::Format,
/// The function declares the stand-in without a format (`Unknown`), so the format supports
/// storage reads and writes without one; otherwise the declaration names it.
pub formatless: bool,
/// The pipeline's rasterization samples.
pub samples: u32,
/// How the image holds the samples.
pub view: StandInView,
}
impl StandInUse {
/// The format usages the consumer's stand-in image and view need: `StorageImage`, and the
/// without-format accesses of a formatless declaration.
pub(crate) fn format_usages(
&self,
) -> Vec<(vk::Format, crate::device::requirements::FormatUsage)> {
use crate::device::requirements::FormatUsage as U;
let mut out = vec![(self.format, U::StorageImage)];
if self.formatless {
out.push((self.format, U::StorageImageReadWithoutFormat));
out.push((self.format, U::StorageImageWriteWithoutFormat));
}
out
}
}
/// How a stand-in holds a pipeline's samples (as the storage form's attachments do).
#[non_exhaustive]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum StandInView {
/// A 2D image of the pipeline's samples: single-sample at one sample, multisampled at more
/// (on a device with multisampled storage images), sample `s` of pixel `(x, y)` at texel
/// `(x, y)`, sample `s`.
Image,
/// A single-sample 2D-array image of `layers` layers (the pipeline's samples), bound through
/// a 2D-array view: layer `s` holds sample `s` of each pixel, on a device without multisampled
/// storage images.
SamplePlanes { layers: u32 },
}
/// A framebuffer-fetch input: color attachment `color_index` read as input attachment
/// `input_attachment_index`. The consumer's render pass provides the self-dependency (or
/// `dynamicRenderingLocalRead` mapping) that the contract names, and, without
-4
View File
@@ -56,7 +56,6 @@ pub mod geometry;
pub mod graphics;
pub mod imageblock;
pub mod mesh;
pub mod shader_tests;
pub mod stencil;
pub mod tessellation;
pub mod varyings;
@@ -646,8 +645,6 @@ fn render_state(
// The shader-side stencil against this pipeline's state, before the sample invocations its
// shadow writes would also refuse.
let shadow = stencil::shadow_stencil(r, fragment, p)?;
// The fragment's own depth test against this pipeline's state.
let shader_tests = shader_tests::shader_tests(r, fragment, p)?;
// The extended-range blends the fragment computes over input attachments, against this
// pipeline's attachments.
let input_blends = fetch::input_blends(r, fragment, p)?;
@@ -677,7 +674,6 @@ fn render_state(
gs.color_outputs = color_outputs(fs, &storage)?;
gs.storage_attachments = storage;
gs.shadow_stencil = shadow;
gs.shader_tests = shader_tests;
Ok(gs)
}
@@ -299,7 +299,7 @@ pub fn plan(
IoRole::Varying {
interpolation: Some(Interpolation::Smooth { .. }),
..
} | IoRole::WindowDepth
}
)
});
BandVarying {
@@ -813,8 +813,6 @@ pub fn graphics_state(
// The storage form's writes join the outputs' once `link::fetch` decided them.
color_outputs: 0,
sample_mask: None,
// The fragment stage's facts decide it (`link::shader_tests`).
shader_tests: None,
snapshot_reads,
color_group: r.color_group.clone(),
// The pipeline's private logic operation, once compile decided it
@@ -1,138 +0,0 @@
//! A render pipeline's in-shader depth test: `GraphicsState::shader_tests` from the fragment
//! stage's `RuntimeFact::ShaderTests`.
//!
//! A fragment function compiled for a draw whose tests may drop fragments
//! (`LoweringInputs::shader_tests`) tests its fragment's depth itself against a stand-in of the
//! depth attachment (`lower::fragment`'s `depth_test`). Link checks the pipeline's state against
//! the function's form:
//!
//! - the form follows the pipeline's samples: a function compiled for a pipeline of more than one
//! sample (`LoweringInputs::multisampled`) tests its sample of a stand-in that holds each, and
//! one linked into a pipeline of another kind is `NeedsInput(Multisampled)`;
//! - a multisampled stand-in (or the neutral that stands in for it) is a storage image of the
//! pipeline's samples (`storageImageSampleCounts`); sample planes are single-sample;
//! - alpha to coverage drops a fragment's samples after the function tested and wrote them:
//! not implemented;
//! - the binder asks for the function only for a pipeline with a depth attachment: one linked
//! into a pipeline without one was compiled for another pipeline's state
//! (`NeedsInput(FramebufferFetch)`);
//! - the stand-in holds 32-bit floats, Metal's `Depth32Float` and `Depth32Float_Stencil8` depth:
//! another depth format (`Depth16Unorm`, `Depth24Unorm_Stencil8`) stores codes the function's
//! float depth would have to round to as Metal does, not implemented (refinement 3), refused at
//! the depth attachment.
//! - a function that runs the stencil test too (`RuntimeFact::ShaderStencilTest`) holds the stencil
//! in a stand-in of the pipeline's samples (`R8_UINT`, a multisampled image at more than one),
//! which the consumer copies to and from the stencil aspect, at more than one sample by
//! maintenance8's image copies: one linked into a pipeline without a stencil attachment was
//! compiled for another pipeline's state (`NeedsInput(FramebufferFetch)`), and at more than one
//! sample a device without `maintenance8` is refused at the stencil attachment, naming it.
use crate::device::requirements::{VkFeature, VkProperty};
use crate::device::DeviceProfile;
use crate::error::{Attachment, Capability, Error, Feature, RuntimeInput, Unsupported};
use crate::library::FunctionArtifact;
use crate::lower::fragment::{SHADOW_FORMAT, STAND_IN_FORMAT};
use crate::metal::PixelFormat;
use crate::pipeline::facts::RuntimeFact;
use crate::pipeline::graphics::{ShaderTestsUse, StandInUse, StandInView};
use crate::pipeline::link::RenderLinkInputs;
/// The in-shader depth test of the fragment stage `fragment` of render inputs `r` on `p` (see
/// the module docs).
pub fn shader_tests(
r: &RenderLinkInputs,
fragment: Option<&FunctionArtifact>,
p: &DeviceProfile,
) -> Result<Option<ShaderTestsUse>, Error> {
let Some((formatless, multisampled, planes)) = fragment.and_then(|f| {
f.facts.iter().find_map(|fact| match *fact {
RuntimeFact::ShaderTests {
formatless,
multisampled,
planes,
} => Some((formatless, multisampled, planes)),
_ => None,
})
}) else {
return Ok(None);
};
if !r.rasterization_enabled {
return Ok(None);
}
let samples = r.raster_sample_count.max(1);
if multisampled != (samples > 1) {
return Err(Error::NeedsInput(RuntimeInput::Multisampled));
}
if r.alpha_to_coverage {
return Err(Unsupported::not_implemented(Feature::FramebufferFetch).into());
}
if multisampled && !planes {
let property = VkProperty::StorageImageSampleCount(samples);
if !p.fields().enabled.properties.contains(&property) {
return Err(Unsupported::needs(
Feature::FramebufferFetch,
Capability::Property(property),
)
.into());
}
}
match r.depth_format {
None => return Err(Error::NeedsInput(RuntimeInput::FramebufferFetch)),
Some(PixelFormat::Depth32Float | PixelFormat::Depth32FloatStencil8) => {}
Some(_) => {
return Err(
Error::from(Unsupported::not_implemented(Feature::FramebufferFetch))
.at_attachment(Attachment::Depth),
)
}
}
let view = match planes {
true => StandInView::SamplePlanes { layers: samples },
false => StandInView::Image,
};
let stencil = match stencil_formatless(fragment) {
Some(formatless) => {
if r.stencil_format.is_none() {
return Err(Error::NeedsInput(RuntimeInput::FramebufferFetch));
}
if samples > 1
&& !p
.fields()
.enabled
.features
.contains(&VkFeature::Maintenance8)
{
return Err(Error::from(Unsupported::needs(
Feature::FramebufferFetch,
Capability::Feature(VkFeature::Maintenance8),
))
.at_attachment(Attachment::Stencil));
}
Some(StandInUse {
format: SHADOW_FORMAT,
formatless,
samples,
view: StandInView::Image,
})
}
None => None,
};
Ok(Some(ShaderTestsUse {
depth: StandInUse {
format: STAND_IN_FORMAT,
formatless,
samples,
view,
},
stencil,
}))
}
/// Whether `fragment` runs the stencil test too, and whether it declares the stencil's stand-in
/// without a format: its `RuntimeFact::ShaderStencilTest`.
fn stencil_formatless(fragment: Option<&FunctionArtifact>) -> Option<bool> {
fragment?.facts.iter().find_map(|fact| match *fact {
RuntimeFact::ShaderStencilTest { formatless } => Some(formatless),
_ => None,
})
}
@@ -17,11 +17,7 @@
//! stage writes, is `NeedsInput(ViewportIndex)`. The raw render target slice index
//! (`IoRole::RenderTargetArrayIndex`) is the same for `[[render_target_array_index]]`
//! (`LoweringInputs::render_target_array_index_varying`, `NeedsInput(RenderTargetArrayIndex)`),
//! which a vertex function writes in every variant, the one without `Layer` included. The window
//! depth (`IoRole::WindowDepth`) is such a varying too, read without perspective: a fragment
//! function that reads it was compiled for a draw whose vertex function writes it
//! (`LoweringInputs::window_depth_varying`), and one linked with another vertex function is
//! `NeedsInput(FramebufferFetch)`.
//! which a vertex function writes in every variant, the one without `Layer` included.
//! The primitive ID (`IoRole::PrimitiveId`) is such a varying, read flat: a fragment function
//! compiled for a device that cannot declare a fragment `PrimitiveId` reads its
//! `[[primitive_id]]` from it, and its pipeline's
@@ -139,7 +135,6 @@ fn check_roles(stage: Stage, io: &StageIo) -> Result<(), Error> {
..
} | IoRole::ViewportIndex
| IoRole::RenderTargetArrayIndex
| IoRole::WindowDepth
| IoRole::SelectedLayer
| IoRole::SelectedViewport
| IoRole::PrimitiveId
@@ -157,7 +152,6 @@ fn check_roles(stage: Stage, io: &StageIo) -> Result<(), Error> {
..
} | IoRole::ViewportIndex
| IoRole::RenderTargetArrayIndex
| IoRole::WindowDepth
| IoRole::Barycentric { .. }
| IoRole::PrimitiveId
| IoRole::MergedCommand
@@ -201,12 +195,6 @@ fn check_raw_indices(v: &StageIo, f: &StageIo) -> Result<(), Error> {
return Err(Error::NeedsInput(input));
}
}
// The window depth: compiled for a draw whose vertex function writes it.
let writes = v.outputs.iter().any(|x| x.role == IoRole::WindowDepth);
let reads = f.inputs.iter().any(|x| x.role == IoRole::WindowDepth);
if reads && !writes {
return Err(Error::NeedsInput(RuntimeInput::FramebufferFetch));
}
Ok(())
}
@@ -480,11 +468,6 @@ fn varyings<'a>(
| IoRole::SelectedViewport
| IoRole::PrimitiveId
| IoRole::MergedCommand => Some(Interpolation::Flat),
// The window depth is read without perspective, at the centre and at a sample.
IoRole::WindowDepth => Some(Interpolation::Smooth {
sampling: crate::pipeline::stage_io::Sampling::Center,
perspective: false,
}),
IoRole::Barycentric { perspective } => Some(Interpolation::Smooth {
sampling: crate::pipeline::stage_io::Sampling::Center,
perspective: *perspective,
@@ -639,25 +639,6 @@ pub struct LoweringInputs {
/// do, and states the fact with `early_tests`. Any other function compiles as without it.
#[cfg_attr(feature = "serde", serde(default))]
pub read_only_tests: bool,
/// Only the depth test of the draws that run the fragment function can drop fragments
/// (`VariantKey::shader_tests`): a function that stores a color through the interlocked
/// storage form before the tests (`RuntimeFact::TestedStorageWrites`) runs the depth test
/// itself, inside the ordered pixel interlock, against a stand-in of the depth attachment, and
/// states `RuntimeFact::ShaderTests`. Any other function compiles as without it.
#[cfg_attr(feature = "serde", serde(default))]
pub shader_tests: bool,
/// Under `shader_tests`, the draw's stencil test can drop fragments or write too
/// (`VariantKey::shader_stencil`): the function also runs the stencil test itself, before its
/// depth test, against a stand-in of the stencil attachment, and states
/// `RuntimeFact::ShaderStencilTest`.
#[cfg_attr(feature = "serde", serde(default))]
pub shader_stencil: bool,
/// A vertex function's fragment function runs its draw's depth test itself at more than one
/// sample from each sample's computed depth (`VariantKey::window_depth_varying`): the function
/// also writes its position's window depth `z / w` to a no-perspective varying
/// (`IoRole::WindowDepth`), which the fragment function reads. Read only by a vertex function.
#[cfg_attr(feature = "serde", serde(default))]
pub window_depth_varying: bool,
/// The color attachments the fragment function's render pipeline gives a format held with
/// its channels rotated (`metal::format::rotated_channels`, `ARGB8Unorm`), by color index:
/// each such attachment's image holds Metal's alpha, red, green and blue in its red, green,
+1 -2
View File
@@ -118,8 +118,7 @@ pub use descriptor::{
pub use graphics::{
BandPrimitive, BlendState, ColorAttachmentState, FanOutState, FragmentImageblock,
GraphicsState, ImageblockMechanism, InputAttachmentUse, LineBandState, RegionFanOut,
ShaderTestsUse, ShadowStencilUse, StandInUse, StandInView, StorageAttachmentUse,
StorageAttachmentView, TessellationState,
ShadowStencilUse, StorageAttachmentUse, StorageAttachmentView, TessellationState,
};
pub use interface::{
AccessSet, AttributeFetch, BufferForm, BufferKind, BufferSlot, CommandWrites, DescriptorView,
+3 -29
View File
@@ -18,9 +18,6 @@
//! - [`IoRole::RenderTargetArrayIndex`]: the `[[render_target_array_index]]` a vertex function
//! writes, as written, carried to a fragment function that reads it. A flat `uint` varying for
//! link, one key ([`VaryingKey::render_target_array_index`]) on both sides.
//! - [`IoRole::WindowDepth`]: a vertex function's window depth, carried to a fragment function
//! that runs its draw's depth test itself at more than one sample. A no-perspective `float`
//! varying for link, one key ([`VaryingKey::window_depth`]) on both sides.
//! - [`IoRole::Barycentric`]: the first two barycentric weights a fragment function reads as
//! `[[barycentric_coord]]` on a device without `fragmentShaderBarycentric`, which the pipeline's
//! synthesized geometry stage writes. A `float2` varying, perspective-correct or not, one key
@@ -41,7 +38,7 @@
//!
//! The roles live in disjoint key namespaces ([`VaryingKey::user`], [`VaryingKey::attribute`],
//! [`VaryingKey::color`], [`VaryingKey::viewport_index`],
//! [`VaryingKey::render_target_array_index`], [`VaryingKey::window_depth`],
//! [`VaryingKey::render_target_array_index`],
//! [`VaryingKey::barycentric`], [`VaryingKey::selected_layer`],
//! [`VaryingKey::selected_viewport`], [`VaryingKey::primitive_id`],
//! [`VaryingKey::merged_command`]): the key bytes start with a
@@ -75,7 +72,6 @@ const ATTRIBUTE: u8 = 1;
const COLOR: u8 = 2;
const VIEWPORT_INDEX: u8 = 3;
const RENDER_TARGET_ARRAY_INDEX: u8 = 4;
const WINDOW_DEPTH: u8 = 5;
const BARYCENTRIC: u8 = 6;
const SELECTED_LAYER: u8 = 7;
const SELECTED_VIEWPORT: u8 = 8;
@@ -118,12 +114,6 @@ impl VaryingKey {
VaryingKey(AirUserKey(vec![RENDER_TARGET_ARRAY_INDEX].into()))
}
/// The key of the window depth a vertex function writes and a fragment function that runs
/// its draw's depth test itself at more than one sample reads (`IoRole::WindowDepth`).
pub fn window_depth() -> VaryingKey {
VaryingKey(AirUserKey(vec![WINDOW_DEPTH].into()))
}
/// The key of the barycentric weights a pipeline's synthesized geometry stage writes and a
/// fragment function reads as `[[barycentric_coord]]` (`IoRole::Barycentric`), in the form
/// `perspective` names.
@@ -744,12 +734,6 @@ pub enum IoRole {
/// flat [`IoRole::Varying`] its function reads per primitive
/// ([`StageIo::primitive_inputs`]).
PrimitiveVarying { user: AirUserKey },
/// The window depth `z / w` of the position a vertex function compiled under
/// `LoweringInputs::window_depth_varying` stores: a vertex output, and the no-perspective
/// input of a fragment function that runs its draw's depth test itself at more than one
/// sample, which reads it at its sample and at the pixel centre to compute each sample's
/// depth (`lower::fragment`'s `depth_test`).
WindowDepth,
/// The first two barycentric weights a fragment function compiled for a device without
/// `fragmentShaderBarycentric` reads as its `[[barycentric_coord]]`: a center-sampled `float2`
/// input, perspective-correct when `perspective`, which no Metal function writes. Link
@@ -793,7 +777,7 @@ pub enum IoRole {
impl IoRole {
/// Whether the role is a varying: a user varying, a raw index a vertex function writes for
/// its fragment function, its window depth, the barycentric weights a synthesized geometry
/// its fragment function, the barycentric weights a synthesized geometry
/// stage writes, a selected index the geometry stage reads, the primitive ID, or a merged
/// draw's command. Link numbers these, and packs those a vertex function writes.
pub(crate) fn is_varying(&self) -> bool {
@@ -802,7 +786,6 @@ impl IoRole {
IoRole::Varying { .. }
| IoRole::ViewportIndex
| IoRole::RenderTargetArrayIndex
| IoRole::WindowDepth
| IoRole::Barycentric { .. }
| IoRole::SelectedLayer
| IoRole::SelectedViewport
@@ -971,18 +954,9 @@ mod tests {
let color = VaryingKey::color(3, 0);
let viewport = VaryingKey::viewport_index();
let layer = VaryingKey::render_target_array_index();
let depth = VaryingKey::window_depth();
let perspective = VaryingKey::barycentric(true);
let linear = VaryingKey::barycentric(false);
let tagged = [
&attr,
&color,
&viewport,
&layer,
&depth,
&perspective,
&linear,
];
let tagged = [&attr, &color, &viewport, &layer, &perspective, &linear];
for (i, a) in tagged.iter().enumerate() {
for b in &tagged[i + 1..] {
assert_ne!(a, b);
-27
View File
@@ -340,18 +340,6 @@ pub enum SyntheticBinding {
/// its words ([`FunctionTableSnapshot`](crate::bind::FunctionTableSnapshot)). The stage's
/// function-table directory gives each id the word offset of its table's record.
FunctionTableSnapshot,
/// The stand-in of the render pass's depth attachment a fragment function that runs the
/// draw's depth test itself tests and writes (`GraphicsState::shader_tests`): a coherent
/// `R32f` storage image holding pixel `(x, y)`'s depth at texel `(x, y)` (its samples as the
/// stand-in's view says), read and written inside the fragment's ordered pixel-interlock
/// critical section.
DepthStandIn,
/// The stand-in of the render pass's stencil attachment a fragment function that runs the
/// draw's stencil test itself, beside its depth test, tests and writes
/// (`ShaderTestsUse::stencil`): a coherent `R8ui` storage image holding pixel `(x, y)`'s
/// stencil at texel `(x, y)` (each sample, multisampled at more than one), read and written
/// inside the fragment's ordered pixel-interlock critical section.
StencilStandIn,
}
/// What kind of resource a [`ResourceSlot`] names.
@@ -1135,12 +1123,6 @@ pub enum PushField {
/// the bits of two `f32`s, `[low, high]`, which the function clamps the depth it writes to
/// after Metal's `[0, 1]` (`BindState::depth_clamp_range`).
DepthClampRange,
/// The draw's depth state for a fragment function that runs the draw's depth test itself
/// (`RuntimeFact::ShaderTests`), a `uvec4`: word 0 holds the depth `MTLCompareFunction` in
/// bits 0 to 2, whether depth writes are enabled in bit 3, and whether the encoder's depth
/// clip mode is `MTLDepthClipModeClamp` in bit 4; words 1 and 2 the bits of viewport 0's near
/// and far depth (`f32`); word 3 is 0 (`bind::shader_tests_words`).
ShaderTestsState,
/// The draw's layout for a vertex function compiled in the primitive ID's de-indexed form
/// (`LoweringInputs::primitive_id_indices`), a `uvec4`, of a draw run from vertex 0: 0, the
/// index count, the first instance, and the base vertex. Stream position `p = VertexIndex`
@@ -1153,15 +1135,6 @@ pub enum PushField {
/// (`StorageAttachmentUse::kept`), so every write mask that keeps some of a format's channels
/// shares one module.
StorageKeptChannels,
/// The draw's stencil state for a fragment function that runs the draw's stencil test itself
/// beside its depth test (`RuntimeFact::ShaderStencilTest`), a `uvec4`: words 0 and 1 the
/// front face's and the back face's words, each holding the face's `MTLCompareFunction` in
/// bits 0 to 2, its stencil-failure and depth-stencil-pass `MTLStencilOperation`s in bits 3 to
/// 5 and 6 to 8, its read mask in bits 9 to 16, its write mask in bits 17 to 24, and its
/// depth-failure operation in bits 25 to 27; word 2 the front reference in bits 0 to 7 and
/// the back reference in bits 8 to 15 (`BindState::stencil_references`); word 3 is 0
/// (`bind::shader_stencil_words`).
ShaderStencilState,
/// The channel widths of the storage texture bound to the slot (`u32`;
/// `metal::format::integer_channels_word`, 0 where the binder binds a neutral): byte `c`
/// holds `32 - bits` of channel `c` (red to alpha) of an integer format narrower than 32 bits,
@@ -27,9 +27,7 @@
//! The shader-side stencil's shadow (`Synthetic(ShadowStencil)`) is the product's too: its writes
//! carry Metal's stencil test, which Metal applies per sample whether the function runs per pixel
//! or per sample, so they do not make the function run per sample. An image write counts unless its
//! image is a load of that binding. So are the depth and stencil attachments' stand-ins
//! (`Synthetic(DepthStandIn)` and `Synthetic(StencilStandIn)`), whose writes carry Metal's depth
//! and stencil tests.
//! image is a load of that binding.
//!
//! So is a color attachment's interlocked storage form (`TileAttachment`): its writes carry
//! Metal's color attachment write, a
@@ -95,9 +93,8 @@ fn class(m: &TypedModule, ptr: Value) -> BResult<StorageClass> {
struct Status<'m> {
/// The variables of the `Synthetic(ExecutionStatus)` binding.
bindings: Vec<Value>,
/// The variables of the `Synthetic(ShadowStencil)`, `Synthetic(DepthStandIn)`,
/// `Synthetic(StencilStandIn)`, `TileAttachment` and `SnapshotTexels` bindings, and the loads
/// of them.
/// The variables of the `Synthetic(ShadowStencil)`, `TileAttachment` and `SnapshotTexels`
/// bindings, and the loads of them.
shadows: Vec<Value>,
/// The push block's variable.
block: Option<Value>,
@@ -124,11 +121,8 @@ impl<'m> Status<'m> {
GlobalKind::Resource(slot)
if matches!(
slot.kind,
ResourceKind::Synthetic(
SyntheticBinding::ShadowStencil
| SyntheticBinding::DepthStandIn
| SyntheticBinding::StencilStandIn
) | ResourceKind::TileAttachment(_)
ResourceKind::Synthetic(SyntheticBinding::ShadowStencil)
| ResourceKind::TileAttachment(_)
| ResourceKind::SnapshotTexels(_)
) =>
{
+66 -298
View File
@@ -1065,10 +1065,9 @@ fn the_storage_form_declares_early_tests_only_where_they_keep_metals_writes() {
/// the tests, and states `TestedStorageWrites` without the early-tests variant: Metal runs its
/// memory writes for the fragments its tests drop. Without such an attachment it
/// states nothing. The whole pipeline on `moltenvk-m3` (a `BGRA8Unorm_sRGB` color,
/// `Depth32Float_Stencil8`) plans a draw whose tests drop no fragment, and refuses one that does
/// not state its tests, or whose tests a visibility result counts, at the depth attachment. (A draw
/// whose tests may drop fragments but write and count nothing runs the variant whose function runs
/// both tests itself, after its memory writes, as Metal tests after them.)
/// `Depth32Float_Stencil8`) plans a draw whose tests drop no fragment, and refuses at the depth
/// attachment one that does not state its tests, whose tests a visibility result counts, or whose
/// tests may drop fragments but write and count nothing.
#[test]
fn a_fetch_that_writes_memory_beside_depth_runs_only_draws_whose_tests_drop_nothing() {
use crate::bind::FragmentTests;
@@ -1151,20 +1150,13 @@ fn a_fetch_that_writes_memory_beside_depth_runs_only_draws_whose_tests_drop_noth
.at_attachment(Attachment::Depth)
))
);
let drop = base.plan(&dev, &shape(FragmentTests::Drop)).expect("drop");
assert!(drop.variant.shader_tests && drop.variant.shader_stencil);
assert!(!drop.variant.read_only_tests);
let variant = dev
.compile_render_variant(&d, &drop.variant, &Budget::standard())
.expect("the in-shader tests' variant");
for m in &variant.stages {
check_words_valid(&m.spirv, &variant.requirements, dev.profile())
.unwrap_or_else(|e| panic!("L3: {e}"));
}
let again = variant
.plan(&dev, &shape(FragmentTests::Drop))
.expect("the variant's plan");
assert_eq!(again.variant, drop.variant, "a fixed point");
assert_eq!(
base.plan(&dev, &shape(FragmentTests::Drop)).map(|_| ()),
Err(BindError::Unsupported(
Unsupported::not_implemented(Feature::FramebufferFetch)
.at_attachment(Attachment::Depth)
))
);
}
/// The pipeline state of `con_fetch_coverage`, as the guest's path-coverage pipeline has it: a
@@ -2498,8 +2490,10 @@ fn a_fetched_extended_range_attachment_is_refused() {
/// `RGB10A2Unorm_sRGB`, the four-channel padded form, where the guest's were `RGB10A8_2P_XR10`,
/// whose blend is refused (`blended_pipelines`). On `moltenvk-m3` the whole pipeline is made; a
/// draw whose tests drop no fragment runs it as compiled, one whose tests drop fragments but write
/// and count nothing asks for the early-tests variant, whose plan states the same key, and any
/// other (or one that states nothing) is refused `NotImplemented(FramebufferFetch)`.
/// and count nothing asks for the early-tests variant, whose plan states the same key; one whose
/// depth test writes is refused `NotImplemented(FramebufferFetch)` at the depth attachment, one
/// whose stencil test acts at the stencil attachment, and any other (or one that states nothing)
/// so without an attachment.
#[test]
fn a_discarding_fetch_beside_depth_stores_before_the_tests_its_draws_check() {
use crate::bind::FragmentTests;
@@ -2693,48 +2687,35 @@ fn a_discarding_fetch_beside_depth_stores_before_the_tests_its_draws_check() {
.plan(&dev, &shape(FragmentTests::Drop))
.expect("variant plan");
assert_eq!(again.variant, drop.variant, "a fixed point");
// A depth test that writes nothing keeps the early-tests variant; one that writes runs the
// variant whose function tests depth itself against the stand-in, at one sample.
// A depth test that writes nothing keeps the early-tests variant; one that writes, and a
// stencil test that acts, are refused at their attachments: the function stores before
// Vulkan's tests.
let read_only = base
.plan(&dev, &shape(FragmentTests::Depth { writes: false }))
.expect("depth without writes");
assert!(read_only.variant.read_only_tests && !read_only.variant.shader_tests);
let depth = base
.plan(&dev, &shape(FragmentTests::Depth { writes: true }))
.expect("depth with writes");
assert!(depth.variant.shader_tests && !depth.variant.read_only_tests);
let tested = dev
.compile_render_variant(&d, &depth.variant, &Budget::standard())
.expect("the in-shader depth test's variant");
assert!(tested.dependencies.iter().any(|x| x.fact
== RuntimeFact::ShaderTests {
formatless: false,
multisampled: false,
planes: false,
}));
let stand_in = tested.graphics.shader_tests.expect("the stand-in").depth;
assert_eq!(stand_in.format, crate::vk::Format::R32_SFLOAT);
assert_eq!(stand_in.samples, 1);
assert_eq!(stand_in.view, crate::pipeline::StandInView::Image);
for m in &tested.stages {
check_words_valid(&m.spirv, &tested.requirements, dev.profile())
.unwrap_or_else(|e| panic!("L3: {e}"));
assert!(read_only.variant.read_only_tests);
for (tests, at) in [
(
FragmentTests::Depth { writes: true },
crate::error::Attachment::Depth,
),
(FragmentTests::Stencil, crate::error::Attachment::Stencil),
] {
assert_eq!(
base.plan(&dev, &shape(tests)).map(|_| ()),
Err(BindError::Unsupported(
crate::error::Unsupported::not_implemented(Feature::FramebufferFetch)
.at_attachment(at)
)),
"{tests:?}"
);
}
let again = tested
.plan(&dev, &shape(FragmentTests::Depth { writes: true }))
.expect("the in-shader depth test's plan");
assert_eq!(again.variant, depth.variant, "a fixed point");
assert!(again
.descriptors
.iter()
.any(|w| w.source == crate::bind::WriteSource::DepthStandIn));
}
/// At 4 samples a discarding fetch that stores a color through the interlock beside a
/// `Depth32Float_Stencil8` attachment, without early tests: a draw whose depth test writes would run
/// the variant whose function tests depth itself, which needs each sample's depth, so the draw is
/// refused at the depth attachment on every device (MoltenVK on the M3 Max, RADV, Intel's ANV), as
/// its own kind: `Feature::MultisampledShaderDepthTest`.
/// `Depth32Float_Stencil8` attachment, without early tests: a draw whose depth test writes is
/// refused `NotImplemented(FramebufferFetch)` at the depth attachment on every device (MoltenVK on
/// the M3 Max, RADV, Intel's ANV), as at one sample.
#[test]
fn a_per_sample_depth_test_is_refused_at_the_depth_attachment() {
use crate::bind::FragmentTests;
@@ -2781,7 +2762,7 @@ fn a_per_sample_depth_test_is_refused_at_the_depth_attachment() {
base.plan(&dev, &shape(FragmentTests::Depth { writes: true }))
.map(|_| ()),
Err(BindError::Unsupported(
Unsupported::not_implemented(Feature::MultisampledShaderDepthTest)
Unsupported::not_implemented(Feature::FramebufferFetch)
.at_attachment(Attachment::Depth)
)),
"{stem}"
@@ -2789,159 +2770,15 @@ fn a_per_sample_depth_test_is_refused_at_the_depth_attachment() {
}
}
/// A discarding fetch that stores a color through the interlock beside a `Depth32Float_Stencil8`
/// attachment, without early tests. A draw whose stencil test acts and whose tests write
/// (`FragmentTests::Stencil`) runs the variant whose function runs the stencil test itself before
/// the depth test: at one sample on MoltenVK (M3 Max, M4), RADV and Intel's ANV, the variant states
/// `ShaderStencilTest`, holds the stencil's stand-in as an `R8_UINT` image of the pipeline's
/// samples, validates, and plans as a fixed point that binds both stand-ins. At four samples
/// MoltenVK and RADV are refused at the depth attachment: the depth test in the shader needs each
/// sample's depth, which no profile states
/// (`a_per_sample_depth_test_is_refused_at_the_depth_attachment`). A draw whose stencil test drops
/// fragments but whose tests write nothing keeps the early-tests variant, and a pass with a
/// stencil attachment alone is refused at it.
#[test]
fn a_stencil_test_that_acts_runs_in_the_shader_before_the_depth_test() {
use crate::bind::FragmentTests;
use crate::error::{Attachment, Unsupported};
let (Some(tested), Some(io)) = (fixture("tsw_fetch_discard"), fixture("stage_io")) else {
return;
};
let function = |bc: &[u8], name: &str| {
StageSource::Function(FunctionDescriptor::new(
Library::from_air(bc)
.expect("library")
.function(name)
.expect("function"),
))
};
let device = |stem: &str| {
let path = Path::new(env!("CARGO_MANIFEST_DIR"))
.join(format!("../metal2vulkan-validation/profiles/{stem}.json"));
let text = std::fs::read_to_string(path).expect("profile");
let desc = DeviceDescription::from_khronos_json(&text, None).expect("description");
Device::from_queries(desc, DevicePolicy::default()).expect("device")
};
let descriptor = |samples: u32| {
let mut d = RenderPipelineDescriptor::new(function(&io, "stage_io_vertex_position"));
d.fragment = Some(function(&tested, "tsw_fetch_discard"));
d.color_attachments[0] = Some(ColorAttachmentDescriptor::new(PixelFormat::RGBA16Float));
d.color_attachments[1] = Some(ColorAttachmentDescriptor::new(PixelFormat::RG16Float));
d.depth_format = Some(PixelFormat::Depth32FloatStencil8);
d.stencil_format = Some(PixelFormat::Depth32FloatStencil8);
d.raster_sample_count = samples;
d
};
let shape = |fragment_tests: FragmentTests| {
BindState {
fragment_tests,
..Default::default()
}
.shape()
};
let shipped = [
("moltenvk-m3", 1),
("amd-780m-radv", 1),
("intel-irisxe-rplp-anv", 1),
];
for (stem, samples) in shipped {
let at = format!("{stem} at {samples}");
let dev = device(stem);
let d = descriptor(samples);
let base = dev
.compile_render_pipeline(&d, &Budget::standard())
.expect("the pipeline");
let plan = base
.plan(&dev, &shape(FragmentTests::Stencil))
.unwrap_or_else(|e| panic!("{at}: {e:?}"));
assert!(
plan.variant.shader_tests && plan.variant.shader_stencil,
"{at}"
);
assert!(!plan.variant.read_only_tests, "{at}");
let variant = dev
.compile_render_variant(&d, &plan.variant, &Budget::standard())
.expect("the in-shader tests' variant");
assert!(
variant
.dependencies
.iter()
.any(|x| matches!(x.fact, RuntimeFact::ShaderStencilTest { .. })),
"{at}"
);
let tests = variant.graphics.shader_tests.expect("the stand-ins");
let stencil = tests.stencil.expect("the stencil's stand-in");
assert_eq!(stencil.format, crate::vk::Format::R8_UINT, "{at}");
assert_eq!(stencil.samples, samples, "{at}");
assert_eq!(stencil.view, crate::pipeline::StandInView::Image, "{at}");
for m in &variant.stages {
check_words_valid(&m.spirv, &variant.requirements, dev.profile())
.unwrap_or_else(|e| panic!("{at} L3: {e}"));
}
let again = variant
.plan(&dev, &shape(FragmentTests::Stencil))
.expect("the variant's plan");
assert_eq!(again.variant, plan.variant, "{at}: a fixed point");
for source in [WriteSource::DepthStandIn, WriteSource::StencilStandIn] {
assert!(
again.descriptors.iter().any(|w| w.source == source),
"{at}: {source:?}"
);
}
// A stencil test that drops fragments but writes nothing, beside a depth test that
// writes nothing, keeps the early-tests variant.
let drop = base
.plan(&dev, &shape(FragmentTests::Drop))
.expect("the plan without writes");
assert!(
drop.variant.read_only_tests && !drop.variant.shader_stencil,
"{at}"
);
}
// At four samples: the depth test in the shader needs each sample's depth.
for stem in ["moltenvk-m3", "amd-780m-radv"] {
let dev = device(stem);
let base = dev
.compile_render_pipeline(&descriptor(4), &Budget::standard())
.expect("the pipeline");
assert_eq!(
base.plan(&dev, &shape(FragmentTests::Stencil)).map(|_| ()),
Err(BindError::Unsupported(
Unsupported::not_implemented(Feature::MultisampledShaderDepthTest)
.at_attachment(Attachment::Depth)
)),
"{stem}"
);
}
// A pass with a stencil attachment alone.
let dev = device("amd-780m-radv");
let mut d = descriptor(1);
d.depth_format = None;
d.stencil_format = Some(PixelFormat::Stencil8);
let base = dev
.compile_render_pipeline(&d, &Budget::standard())
.expect("the stencil-only pipeline");
assert_eq!(
base.plan(&dev, &shape(FragmentTests::Stencil)).map(|_| ()),
Err(BindError::Unsupported(
Unsupported::not_implemented(Feature::FramebufferFetch)
.at_attachment(Attachment::Stencil)
))
);
}
/// A fetch that writes its color through the interlock and returns its depth
/// (`dsx_fetch_returned_depth`), beside a `Depth32Float` attachment, stores before the tests and
/// has no early-tests variant; a draw whose depth test writes runs the variant whose function tests
/// the depth it returns. At one sample and at four on MoltenVK (M3 Max, M4), RADV and Intel's ANV
/// alike: a returned depth is the same at every sample, so no device needs a per-sample depth
/// source for it, no vertex function writes the window depth, and no note is recorded. The
/// variant's words validate and its plan is a fixed point that binds the stand-in. The compiled
/// pipeline (a draw under `Always`, `FragmentTests::Pass`) and the variant alike record a positive
/// NaN it returns as discarded and kill it once, after the critical section (the lanes: before, the
/// compiled pipeline stored its color).
/// has no early-tests variant. At one sample and at four on MoltenVK (M3 Max, M4), RADV and Intel's
/// ANV alike, the compiled pipeline (a draw under `Always`, `FragmentTests::Pass`) records a
/// positive NaN it returns as discarded and kills it once, after the critical section (the lanes:
/// before, the compiled pipeline stored its color), and a draw whose depth test writes is refused
/// `NotImplemented(FramebufferFetch)` at the depth attachment.
#[test]
fn a_returned_depth_is_tested_in_the_shader_at_every_sample_count() {
fn a_fetch_that_returns_its_depth_refuses_a_draw_whose_depth_test_writes() {
use crate::bind::FragmentTests;
let (Some(returned), Some(io)) = (fixture("dsx_fetch_returned_depth"), fixture("stage_io"))
else {
@@ -2995,64 +2832,28 @@ fn a_returned_depth_is_tested_in_the_shader_at_every_sample_count() {
}),
"{at}: stores before the tests, without an early-tests variant"
);
let plan = base
.plan(&dev, &shape(FragmentTests::Depth { writes: true }))
.unwrap_or_else(|e| panic!("{at}: the plan: {e:?}"));
assert!(plan.variant.shader_tests, "{at}");
assert!(!plan.variant.window_depth_varying, "{at}");
let variant = dev
.compile_render_variant(&d, &plan.variant, &Budget::standard())
.expect("the in-shader depth test's variant");
assert!(
variant.dependencies.iter().any(|x| matches!(
x.fact,
RuntimeFact::ShaderTests { multisampled, .. } if multisampled == (samples > 1)
assert_eq!(
base.plan(&dev, &shape(FragmentTests::Depth { writes: true }))
.map(|_| ()),
Err(BindError::Unsupported(
crate::error::Unsupported::not_implemented(Feature::FramebufferFetch)
.at_attachment(crate::error::Attachment::Depth)
)),
"{at}"
);
assert!(
kills_after_the_interlock(&variant.stages),
"{at}: the variant"
);
let notes: Vec<PrecisionNote> = variant
.stages
.iter()
.flat_map(|m| m.precision_notes.iter().copied())
.collect();
assert!(!notes.contains(&PrecisionNote::ComputedSampleDepth), "{at}");
for m in &variant.stages {
check_words_valid(&m.spirv, &variant.requirements, dev.profile())
.unwrap_or_else(|e| panic!("{at} L3: {e}"));
}
let again = variant
.plan(&dev, &shape(FragmentTests::Depth { writes: true }))
.expect("the variant's plan");
assert_eq!(again.variant, plan.variant, "{at}: a fixed point");
assert!(
again
.descriptors
.iter()
.any(|w| w.source == WriteSource::DepthStandIn),
"{at}"
);
}
}
}
/// Fetches that write their color through the interlock and return a stencil, a sample mask, or
/// both (`dsx_fetch_returned_stencil`), beside a `Depth32Float_Stencil8` attachment, store before
/// the tests without an early-tests variant. A draw whose stencil test acts runs the variant that
/// runs both tests in the shader, the returned stencil its reference and the returned mask keeping
/// the fragment's samples; a draw whose depth test alone acts, the depth test's variant. At one
/// sample on MoltenVK (M4), RADV, Intel's ANV and NVIDIA (without stencil export, whose compiled
/// pipeline holds a returned stencil in the shader-side stencil's shadow, and refuses a returned
/// sample mask beside it): each variant states its tests, holds no shader-side stencil (the stencil
/// output is stored nowhere), validates, and plans as a fixed point that binds its stand-ins. At
/// four samples RADV refuses the variants at the depth attachment: the depth test in the shader
/// needs each sample's depth, which no profile states
/// (`a_per_sample_depth_test_is_refused_at_the_depth_attachment`).
/// the tests without an early-tests variant. At one sample on RADV, Intel's ANV and NVIDIA (without
/// stencil export, whose compiled pipeline holds a returned stencil in the shader-side stencil's
/// shadow, and refuses a returned sample mask beside it), and at four on RADV, a draw whose stencil
/// test acts or whose depth test writes is refused `NotImplemented(FramebufferFetch)` at the depth
/// attachment.
#[test]
fn a_returned_stencil_and_sample_mask_are_tested_in_the_shader() {
fn a_returned_stencil_or_sample_mask_refuses_a_draw_whose_tests_act() {
use crate::bind::FragmentTests;
let (Some(returned), Some(io)) = (fixture("dsx_fetch_returned_stencil"), fixture("stage_io"))
else {
@@ -3108,10 +2909,8 @@ fn a_returned_stencil_and_sample_mask_are_tested_in_the_shader() {
assert_eq!(
base.plan(&radv, &shape(tests)).map(|_| ()),
Err(BindError::Unsupported(
crate::error::Unsupported::not_implemented(
Feature::MultisampledShaderDepthTest
)
.at_attachment(crate::error::Attachment::Depth)
crate::error::Unsupported::not_implemented(Feature::FramebufferFetch)
.at_attachment(crate::error::Attachment::Depth)
)),
"{name} at 4x under {tests:?}"
);
@@ -3147,49 +2946,18 @@ fn a_returned_stencil_and_sample_mask_are_tested_in_the_shader() {
}),
"{at}: stores before the tests, without an early-tests variant"
);
for (tests, stencil) in [
(FragmentTests::Stencil, true),
(FragmentTests::Depth { writes: true }, false),
for tests in [
FragmentTests::Stencil,
FragmentTests::Depth { writes: true },
] {
let at = format!("{at} under {tests:?}");
let plan = base
.plan(&dev, &shape(tests))
.unwrap_or_else(|e| panic!("{at}: the plan: {e:?}"));
assert!(plan.variant.shader_tests, "{at}");
assert_eq!(plan.variant.shader_stencil, stencil, "{at}");
let variant = dev
.compile_render_variant(&d, &plan.variant, &Budget::standard())
.unwrap_or_else(|e| panic!("{at}: the variant: {e:?}"));
assert_eq!(
variant
.dependencies
.iter()
.any(|x| matches!(x.fact, RuntimeFact::ShaderStencilTest { .. })),
stencil,
"{at}"
base.plan(&dev, &shape(tests)).map(|_| ()),
Err(BindError::Unsupported(
crate::error::Unsupported::not_implemented(Feature::FramebufferFetch)
.at_attachment(crate::error::Attachment::Depth)
)),
"{at} under {tests:?}"
);
assert!(
variant.graphics.shadow_stencil.is_none(),
"{at}: no shader-side stencil"
);
for m in &variant.stages {
check_words_valid(&m.spirv, &variant.requirements, dev.profile())
.unwrap_or_else(|e| panic!("{at} L3: {e}"));
}
let again = variant
.plan(&dev, &shape(tests))
.unwrap_or_else(|e| panic!("{at}: the variant's plan: {e:?}"));
assert_eq!(again.variant, plan.variant, "{at}: a fixed point");
let sources: &[WriteSource] = match stencil {
true => &[WriteSource::DepthStandIn, WriteSource::StencilStandIn],
false => &[WriteSource::DepthStandIn],
};
for source in sources {
assert!(
again.descriptors.iter().any(|w| w.source == *source),
"{at}: {source:?}"
);
}
}
}
}
@@ -818,9 +818,8 @@ fn the_binder_writes_the_storage_and_refuses_layered_passes() {
/// layers `sample * words + w`; the pipeline links, and the graphics state records the storage. A
/// function whose only effects are its outputs and its write declares early tests as at one
/// sample, on MoltenVK on the M3 Max and on RADV alike; a function that states
/// `TestedStorageWrites` needs, for a draw whose depth test acts, the variant that tests depth in
/// the shader, before the write, whose plan is refused at the depth attachment on every device:
/// each sample's test needs its sample's depth (`Feature::MultisampledShaderDepthTest`).
/// `TestedStorageWrites`, for a draw whose depth test acts, is refused `NotImplemented(Imageblocks)`
/// at the depth attachment on every device, as its write precedes Vulkan's tests.
#[test]
fn a_multisampled_pipeline_reaches_each_sample_s_cell() {
use crate::bind::FragmentTests;
@@ -862,7 +861,7 @@ fn a_multisampled_pipeline_reaches_each_sample_s_cell() {
(true, Some(_)) => panic!("{what}: early tests beside a tested write"),
};
assert_eq!(got, want, "{what}");
// A draw whose depth test acts runs the in-shader test before the write.
// A draw whose depth test acts is refused: the write precedes Vulkan's tests.
if let Tests::Tested { .. } = got {
let shape = BindState {
fragment_tests: FragmentTests::Depth { writes: true },
@@ -870,11 +869,15 @@ fn a_multisampled_pipeline_reaches_each_sample_s_cell() {
}
.shape();
match p.plan(&dev, &shape) {
Err(BindError::Unsupported(u)) => assert_eq!(
(u.feature, u.needs),
(Feature::MultisampledShaderDepthTest, Needs::NotImplemented),
"{what}"
),
Err(BindError::Unsupported(u)) => {
assert_eq!(
(u.feature, u.needs),
(Feature::Imageblocks, Needs::NotImplemented),
"{what}"
);
let at = u.location.as_ref().and_then(|l| l.attachment());
assert_eq!(at, Some(crate::error::Attachment::Depth), "{what}");
}
other => panic!("{what}: the plan: {:?}", other.map(|_| ())),
}
}
@@ -6,9 +6,8 @@
//! function and so before the depth and stencil tests. The owned fixture `smw_writers` has one
//! plain writer of color 0 per way those tests bear on such a store: none (no discard, no other
//! write, or Metal's early tests), its discard alone (the early-tests variant where the tests
//! write nothing, the function's own depth or stencil test where they write), and a write of
//! other memory or a returned depth or sample mask (the function's own tests wherever the draw's
//! tests can drop a fragment).
//! write nothing, refused where they write), and a write of other memory or a returned depth or
//! sample mask (refused wherever the draw's tests can drop a fragment).
//!
//! On every committed profile that orders fetch through the pixel interlock alone, in a pass with
//! a depth and stencil attachment, under each kind of draw tests: the plan of the pipeline as
@@ -139,17 +138,16 @@ fn device(stem: &str) -> Device {
Device::from_queries(desc, DevicePolicy::default()).expect("device")
}
/// The early-tests variant (`read_only_tests`) and the function's own tests (`shader_tests`) a
/// writer of `class` needs under `tests`; `None` where the draw is refused (tests that may count
/// what they keep, or that the draw does not state).
fn wanted(class: Class, tests: FragmentTests) -> Option<(bool, bool)> {
/// Whether a writer of `class` needs the early-tests variant (`read_only_tests`) under `tests`;
/// `None` where the draw is refused (tests that may drop a fragment and write or count, or that
/// the draw does not state).
fn wanted(class: Class, tests: FragmentTests) -> Option<bool> {
match (class, tests) {
(Class::Free, _) | (_, FragmentTests::Pass) => Some((false, false)),
(Class::Free, _) | (_, FragmentTests::Pass) => Some(false),
(Class::EarlyVariant, FragmentTests::Drop | FragmentTests::Depth { writes: false }) => {
Some((true, false))
Some(true)
}
(_, FragmentTests::Any) => None,
_ => Some((false, true)),
_ => None,
}
}
@@ -160,9 +158,9 @@ fn a_moved_writer_selects_its_tests_in_its_first_plan() {
};
let devices = ordering_devices();
// The profiles checked, and the writers' variants that planned themselves, by the tests
// they run (`read_only_tests`, `shader_tests`).
// they run (`read_only_tests`).
let mut checked = Vec::new();
let mut fixed_points = std::collections::BTreeSet::<(&str, (bool, bool))>::new();
let mut fixed_points = std::collections::BTreeSet::<(&str, bool)>::new();
for (stem, dev) in &devices {
checked.push(stem.as_str());
for (writer, class) in WRITERS {
@@ -211,11 +209,6 @@ fn a_moved_writer_selects_its_tests_in_its_first_plan() {
let plan = match (planned, wanted(class, tests)) {
(Ok(plan), Some(_)) => plan,
(Err(BindError::Unsupported(_)), None) => continue,
// The function's own tests the device does not ship.
(Err(BindError::Unsupported(u)), Some((_, true))) => {
eprintln!("{what}: its own tests refused: {u:?}");
continue;
}
(planned, want) => {
panic!(
"{what}: planned {:?}, wanted {want:?}",
@@ -223,12 +216,8 @@ fn a_moved_writer_selects_its_tests_in_its_first_plan() {
)
}
};
let (read_only, shader) = wanted(class, tests).expect("planned");
assert_eq!(
(plan.variant.read_only_tests, plan.variant.shader_tests),
(read_only, shader),
"{what}"
);
let read_only = wanted(class, tests).expect("planned");
assert_eq!(plan.variant.read_only_tests, read_only, "{what}");
let variant = variant.expect("compiled for the plan");
assert!(
storage_write(&variant).is_some(),
@@ -243,17 +232,16 @@ fn a_moved_writer_selects_its_tests_in_its_first_plan() {
check_words_valid(&m.spirv, &variant.requirements, dev.profile())
.unwrap_or_else(|e| panic!("{what}: L3: {e}"));
}
fixed_points.insert((writer, (read_only, shader)));
fixed_points.insert((writer, read_only));
}
}
}
// Not vacuous: each writer planned itself under every kind of tests it takes.
eprintln!("moved writers: checked on {checked:?}");
for (writer, class) in WRITERS {
let kinds: &[(bool, bool)] = match class {
Class::Free => &[(false, false)],
Class::EarlyVariant => &[(false, false), (true, false), (false, true)],
Class::Untested => &[(false, false), (false, true)],
let kinds: &[bool] = match class {
Class::Free | Class::Untested => &[false],
Class::EarlyVariant => &[false, true],
};
for kind in kinds {
assert!(
@@ -314,7 +302,7 @@ fn a_moved_writer_that_stores_nothing_selects_no_tests() {
}
};
let key = &plan.variant;
if key.read_only_tests || key.shader_tests || key.shader_stencil {
if key.read_only_tests {
miss("the plan selects tests");
}
let variant = dev
@@ -8,7 +8,7 @@
use std::collections::BTreeSet;
use std::sync::Arc;
use crate::bind::{self, DepthStandInForm, PlanesCopy};
use crate::bind::{self, PlanesCopy};
use crate::device::{Device, DevicePolicy};
use crate::error::{Error, Feature};
use crate::spirv::testing::{all_ones_divisions, committed_descriptions};
@@ -56,15 +56,6 @@ fn modules() -> Vec<Build> {
"stencil_split_module".into(),
Box::new(|d| Ok(bind::stencil_split_module(d, Feature::Format)?.spirv)),
);
for form in [
DepthStandInForm::Multisampled,
DepthStandInForm::SamplePlanes,
] {
push(
format!("depth_split_module({form:?})"),
Box::new(move |d| Ok(bind::depth_split_module(d, form, Feature::Format)?.spirv)),
);
}
out
}
@@ -54,10 +54,6 @@ assoc-const metal2vulkan::bind::AstcDecode::BLOCK_BYTES pub const BLOCK_BYTES: u
assoc-const metal2vulkan::bind::ChromaDecode::ALL pub const ALL: [ChromaDecode; 2]
assoc-const metal2vulkan::bind::ChromaDecode::BLOCK_BYTES pub const BLOCK_BYTES: u32
assoc-const metal2vulkan::bind::ChromaDecode::TEXEL_BYTES pub const TEXEL_BYTES: u32
assoc-const metal2vulkan::bind::DepthSplitModule::DESTINATION_BINDING pub const DESTINATION_BINDING: u32
assoc-const metal2vulkan::bind::DepthSplitModule::LOCAL_SIZE pub const LOCAL_SIZE: u32
assoc-const metal2vulkan::bind::DepthSplitModule::SET pub const SET: u32
assoc-const metal2vulkan::bind::DepthSplitModule::SOURCE_BINDING pub const SOURCE_BINDING: u32
assoc-const metal2vulkan::bind::DepthStencilCopyModules::SET pub const SET: u32
assoc-const metal2vulkan::bind::DepthStencilCopyModules::SOURCE_BINDING pub const SOURCE_BINDING: u32
assoc-const metal2vulkan::bind::DrawMergeModule::HEADER_PUSH pub const HEADER_PUSH: u32
@@ -272,10 +268,6 @@ assoc-const-value metal2vulkan::bind::AstcDecode::BLOCK_BYTES 16
assoc-const-value metal2vulkan::bind::ChromaDecode::ALL [ChromaDecode::Gbgr, ChromaDecode::Bgrg]
assoc-const-value metal2vulkan::bind::ChromaDecode::BLOCK_BYTES 4
assoc-const-value metal2vulkan::bind::ChromaDecode::TEXEL_BYTES 4
assoc-const-value metal2vulkan::bind::DepthSplitModule::DESTINATION_BINDING 1
assoc-const-value metal2vulkan::bind::DepthSplitModule::LOCAL_SIZE 8
assoc-const-value metal2vulkan::bind::DepthSplitModule::SET 0
assoc-const-value metal2vulkan::bind::DepthSplitModule::SOURCE_BINDING 0
assoc-const-value metal2vulkan::bind::DepthStencilCopyModules::SET 0
assoc-const-value metal2vulkan::bind::DepthStencilCopyModules::SOURCE_BINDING 0
assoc-const-value metal2vulkan::bind::DrawMergeModule::HEADER_PUSH 0
@@ -810,7 +802,6 @@ enum metal2vulkan::bind::BoundTexture #[cfg_attr(feature = "serde", derive(serde
enum metal2vulkan::bind::BufferShape #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub enum BufferShape
enum metal2vulkan::bind::ChromaDecode #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum ChromaDecode
enum metal2vulkan::bind::CopySource #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum CopySource
enum metal2vulkan::bind::DepthStandInForm #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum DepthStandInForm
enum metal2vulkan::bind::DepthStencilCopy #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub enum DepthStencilCopy
enum metal2vulkan::bind::Dispatch #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum Dispatch
enum metal2vulkan::bind::DrawCall #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum DrawCall
@@ -961,7 +952,6 @@ enum metal2vulkan::pipeline::SnapshotRefusal #[cfg_attr(feature = "serde", deriv
enum metal2vulkan::pipeline::SpecKey #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub enum SpecKey
enum metal2vulkan::pipeline::Stage #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub enum Stage
enum metal2vulkan::pipeline::StageSource #[derive(Clone, Debug, PartialEq, Eq)] pub enum StageSource
enum metal2vulkan::pipeline::StandInView #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub enum StandInView
enum metal2vulkan::pipeline::StorageAttachmentView #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)] pub enum StorageAttachmentView
enum metal2vulkan::pipeline::StorageFormatClass #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub enum StorageFormatClass
enum metal2vulkan::pipeline::StorageImageClass #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub enum StorageImageClass
@@ -1995,8 +1985,6 @@ field metal2vulkan::bind::BindState.alpha_test_reference pub alpha_test_referenc
field metal2vulkan::bind::BindState.argument_samplers pub argument_samplers: Vec<ArgumentSampler>
field metal2vulkan::bind::BindState.blend_color pub blend_color: [f32; 4]
field metal2vulkan::bind::BindState.depth_clamp_range pub depth_clamp_range: Option<[f32; 2]>
field metal2vulkan::bind::BindState.depth_clip_mode_clamp pub depth_clip_mode_clamp: bool
field metal2vulkan::bind::BindState.depth_range pub depth_range: [f32; 2]
field metal2vulkan::bind::BindState.depth_stencil pub depth_stencil: metal::state::DepthStencilDescriptor
field metal2vulkan::bind::BindState.dropped_colors pub dropped_colors: BTreeSet<u32>
field metal2vulkan::bind::BindState.far_vertex_buffers pub far_vertex_buffers: BTreeSet<u32>
@@ -2021,7 +2009,6 @@ field metal2vulkan::bind::BindState.rotated_weights pub rotated_weights: bool
field metal2vulkan::bind::BindState.snapshot_textures pub snapshot_textures: BTreeSet<u32>
field metal2vulkan::bind::BindState.stage_in_region pub stage_in_region: Option<StageInRegion>
field metal2vulkan::bind::BindState.stages pub stages: BTreeMap<Stage, StageTable>
field metal2vulkan::bind::BindState.stencil_references pub stencil_references: [u32; 2]
field metal2vulkan::bind::BindState.tessellation_factors pub tessellation_factors: TessellationFactors
field metal2vulkan::bind::BindState.tile_threadgroup pub tile_threadgroup: TileThreadgroupMemory
field metal2vulkan::bind::BindState.uniform_views_at_residual pub uniform_views_at_residual: bool
@@ -2056,8 +2043,6 @@ field metal2vulkan::bind::BufferRanges.storage pub storage: u32
field metal2vulkan::bind::BufferRanges.uniform pub uniform: u32
field metal2vulkan::bind::ByteRange.len pub len: u64
field metal2vulkan::bind::ByteRange.offset pub offset: u64
field metal2vulkan::bind::DepthSplitModule.requirements pub requirements: Requirements
field metal2vulkan::bind::DepthSplitModule.spirv pub spirv: Arc<[u32]>
field metal2vulkan::bind::DepthStencilCopyModules.fragment pub fragment: Arc<[u32]>
field metal2vulkan::bind::DepthStencilCopyModules.requirements pub requirements: Requirements
field metal2vulkan::bind::DepthStencilCopyModules.vertex pub vertex: Arc<[u32]>
@@ -2436,8 +2421,6 @@ field metal2vulkan::cache::VariantKey.region_fan_out pub region_fan_out: Option<
field metal2vulkan::cache::VariantKey.region_viewports pub region_viewports: bool
field metal2vulkan::cache::VariantKey.replay_bindings pub replay_bindings: bool
field metal2vulkan::cache::VariantKey.rotated_weights pub rotated_weights: bool
field metal2vulkan::cache::VariantKey.shader_stencil pub shader_stencil: bool
field metal2vulkan::cache::VariantKey.shader_tests pub shader_tests: bool
field metal2vulkan::cache::VariantKey.snapshot_textures pub snapshot_textures: BTreeMap<SlotRef, SnapshotForm>
field metal2vulkan::cache::VariantKey.srgb_textures pub srgb_textures: BTreeSet<SlotRef>
field metal2vulkan::cache::VariantKey.storage_images pub storage_images: BTreeMap<SlotRef, StorageImageChoice>
@@ -2446,7 +2429,6 @@ field metal2vulkan::cache::VariantKey.swizzled_storage pub swizzled_storage: BTr
field metal2vulkan::cache::VariantKey.texel_buffer_parts pub texel_buffer_parts: BTreeMap<SlotRef, u32>
field metal2vulkan::cache::VariantKey.texel_rows pub texel_rows: BTreeSet<SlotRef>
field metal2vulkan::cache::VariantKey.unit_axes pub unit_axes: u8
field metal2vulkan::cache::VariantKey.window_depth_varying pub window_depth_varying: bool
field metal2vulkan::cache::VariantKey.ycbcr_in_place pub ycbcr_in_place: BTreeSet<SlotRef>
field metal2vulkan::cache::VariantKey.ycbcr_planes_sampled pub ycbcr_planes_sampled: BTreeMap<SlotRef, crate::bind::YCbCrPlanesSampler>
field metal2vulkan::cache::VariantKey.zeroed_colors pub zeroed_colors: BTreeMap<u32, crate::metal::PixelFormat>
@@ -2931,7 +2913,6 @@ field metal2vulkan::pipeline::GraphicsState.reads_barycentric_coord pub reads_ba
field metal2vulkan::pipeline::GraphicsState.reads_primitive_id pub reads_primitive_id: bool
field metal2vulkan::pipeline::GraphicsState.region_fan_out pub region_fan_out: Option<FanOutState>
field metal2vulkan::pipeline::GraphicsState.sample_mask pub sample_mask: Option<u32>
field metal2vulkan::pipeline::GraphicsState.shader_tests pub shader_tests: Option<ShaderTestsUse>
field metal2vulkan::pipeline::GraphicsState.shadow_stencil pub shadow_stencil: Option<ShadowStencilUse>
field metal2vulkan::pipeline::GraphicsState.snapshot_reads pub snapshot_reads: bool
field metal2vulkan::pipeline::GraphicsState.stencil_format pub stencil_format: Option<vk::Format>
@@ -3018,8 +2999,6 @@ field metal2vulkan::pipeline::LoweringInputs.rotated_colors pub rotated_colors:
field metal2vulkan::pipeline::LoweringInputs.rotated_factors pub rotated_factors: BTreeMap<u32, [FactorLane; 4]>
field metal2vulkan::pipeline::LoweringInputs.rotated_weights pub rotated_weights: bool
field metal2vulkan::pipeline::LoweringInputs.sample_mask pub sample_mask: Option<[u32; 4]>
field metal2vulkan::pipeline::LoweringInputs.shader_stencil pub shader_stencil: bool
field metal2vulkan::pipeline::LoweringInputs.shader_tests pub shader_tests: bool
field metal2vulkan::pipeline::LoweringInputs.signed_color_attachments pub signed_color_attachments: BTreeSet<u32>
field metal2vulkan::pipeline::LoweringInputs.snapshot_textures pub snapshot_textures: BTreeMap<SlotRef, SnapshotForm>
field metal2vulkan::pipeline::LoweringInputs.srgb_textures pub srgb_textures: BTreeSet<SlotRef>
@@ -3037,7 +3016,6 @@ field metal2vulkan::pipeline::LoweringInputs.uniform_varyings pub uniform_varyin
field metal2vulkan::pipeline::LoweringInputs.unit_axes pub unit_axes: u8
field metal2vulkan::pipeline::LoweringInputs.vertex_fetch pub vertex_fetch: Option<VertexFetchProjection>
field metal2vulkan::pipeline::LoweringInputs.viewport_index_varying pub viewport_index_varying: bool
field metal2vulkan::pipeline::LoweringInputs.window_depth_varying pub window_depth_varying: bool
field metal2vulkan::pipeline::LoweringInputs.word_colors pub word_colors: BTreeMap<u32, metal::format::WordAttachment>
field metal2vulkan::pipeline::LoweringInputs.ycbcr_in_place pub ycbcr_in_place: BTreeSet<SlotRef>
field metal2vulkan::pipeline::LoweringInputs.ycbcr_planes_sampled pub ycbcr_planes_sampled: BTreeMap<SlotRef, crate::bind::YCbCrPlanesSampler>
@@ -3179,8 +3157,6 @@ field metal2vulkan::pipeline::SamplerLevels.max_lod pub max_lod: f32
field metal2vulkan::pipeline::SamplerLevels.min_lod pub min_lod: f32
field metal2vulkan::pipeline::SamplerSlot.compare pub compare: bool
field metal2vulkan::pipeline::SamplerSlot.coordinate_sensitive pub coordinate_sensitive: bool
field metal2vulkan::pipeline::ShaderTestsUse.depth pub depth: StandInUse
field metal2vulkan::pipeline::ShaderTestsUse.stencil pub stencil: Option<StandInUse>
field metal2vulkan::pipeline::ShadowStencilUse.format pub format: vk::Format
field metal2vulkan::pipeline::ShadowStencilUse.formatless pub formatless: bool
field metal2vulkan::pipeline::ShadowStencilUse.samples pub samples: u32
@@ -3228,10 +3204,6 @@ field metal2vulkan::pipeline::StageModule.stage pub stage: vk::ShaderStage
field metal2vulkan::pipeline::StageModule.stage_flags pub stage_flags: vk::PipelineShaderStageCreateFlags
field metal2vulkan::pipeline::StageModule.stats pub stats: ModuleStats
field metal2vulkan::pipeline::StageModule.strategies pub strategies: StrategyCensus
field metal2vulkan::pipeline::StandInUse.format pub format: vk::Format
field metal2vulkan::pipeline::StandInUse.formatless pub formatless: bool
field metal2vulkan::pipeline::StandInUse.samples pub samples: u32
field metal2vulkan::pipeline::StandInUse.view pub view: StandInView
field metal2vulkan::pipeline::StandaloneModule.layout pub layout: PipelineLayout
field metal2vulkan::pipeline::StandaloneModule.words pub words: Vec<u32>
field metal2vulkan::pipeline::StorageAttachmentUse.color_index pub color_index: u32
@@ -3382,7 +3354,6 @@ fn metal2vulkan-runtime::host_time pub fn host_time() -> u64
fn metal2vulkan::ash_interop::sampler_create_info pub fn sampler_create_info<'a>(desc: &vk::SamplerDesc, reduction: &'a mut ash::vk::SamplerReductionModeCreateInfo<'static>, border: &'a mut ash::vk::SamplerBorderColorComponentMappingCreateInfoEXT<'static>) -> ash::vk::SamplerCreateInfo<'a>
fn metal2vulkan::bind::alpha_test_code pub fn alpha_test_code(reference: f32) -> u32
fn metal2vulkan::bind::clamped_depth pub const fn clamped_depth(bits: u32) -> u32
fn metal2vulkan::bind::depth_split_module pub fn depth_split_module(device: &Device, form: DepthStandInForm, feature: Feature) -> Result<DepthSplitModule, Error>
fn metal2vulkan::bind::depth_stencil_copy_modules pub fn depth_stencil_copy_modules(device: &Device, copy: DepthStencilCopy, feature: Feature) -> Result<DepthStencilCopyModules, Error>
fn metal2vulkan::bind::draw_merge_module pub fn draw_merge_module(device: &Device, phase: MergePhase) -> Result<DrawMergeModule, Error>
fn metal2vulkan::bind::draw_replay_draw pub fn draw_replay_draw(commands: &DrawCommands, (plan, key): (&BindingPlan, &VariantKey), merged: bool) -> Result<(), DrawReplayRule>
@@ -7359,7 +7330,6 @@ method metal2vulkan::pipeline::VaryingKey::selected_layer pub fn selected_layer(
method metal2vulkan::pipeline::VaryingKey::selected_viewport pub fn selected_viewport() -> VaryingKey
method metal2vulkan::pipeline::VaryingKey::user pub fn user(k: &[u8]) -> VaryingKey
method metal2vulkan::pipeline::VaryingKey::viewport_index pub fn viewport_index() -> VaryingKey
method metal2vulkan::pipeline::VaryingKey::window_depth pub fn window_depth() -> VaryingKey
method metal2vulkan::pipeline::VertexAttributeDescriptor::new pub fn new(format: metal::VertexFormat, offset: u32, buffer_index: u32) -> Self
method metal2vulkan::pipeline::VertexBufferLayoutDescriptor::new pub fn new(stride: Option<u32>) -> VertexBufferLayoutDescriptor
method metal2vulkan::pipeline::VertexDescriptor::new pub fn new() -> VertexDescriptor
@@ -7683,7 +7653,6 @@ struct metal2vulkan::bind::BufferRange #[cfg_attr(feature = "serde", derive(serd
struct metal2vulkan::bind::BufferRanges #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)] #[non_exhaustive] pub struct BufferRanges
struct metal2vulkan::bind::ByteRange #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub struct ByteRange
struct metal2vulkan::bind::ComputeTemplate #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub struct ComputeTemplate
struct metal2vulkan::bind::DepthSplitModule #[derive(Clone, Debug, PartialEq, Eq)] #[non_exhaustive] pub struct DepthSplitModule
struct metal2vulkan::bind::DepthStencilCopyModules #[derive(Clone, Debug, PartialEq, Eq)] #[non_exhaustive] pub struct DepthStencilCopyModules
struct metal2vulkan::bind::DescriptorBytes #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub struct DescriptorBytes
struct metal2vulkan::bind::DescriptorRange #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub struct DescriptorRange
@@ -7893,7 +7862,6 @@ struct metal2vulkan::pipeline::SampledLevels #[cfg_attr(feature = "serde", deriv
struct metal2vulkan::pipeline::SamplerArray #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub struct SamplerArray
struct metal2vulkan::pipeline::SamplerLevels #[derive(Clone, Copy, Debug, PartialEq)] #[non_exhaustive] pub struct SamplerLevels
struct metal2vulkan::pipeline::SamplerSlot #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub struct SamplerSlot
struct metal2vulkan::pipeline::ShaderTestsUse #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub struct ShaderTestsUse
struct metal2vulkan::pipeline::ShadowStencilUse #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub struct ShadowStencilUse
struct metal2vulkan::pipeline::SlotRef #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct SlotRef
struct metal2vulkan::pipeline::SpecClause #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub struct SpecClause
@@ -7906,7 +7874,6 @@ struct metal2vulkan::pipeline::StageInputAttributeDescriptor #[cfg_attr(feature
struct metal2vulkan::pipeline::StageInputDescriptor #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub struct StageInputDescriptor
struct metal2vulkan::pipeline::StageInputLayoutDescriptor #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub struct StageInputLayoutDescriptor
struct metal2vulkan::pipeline::StageModule #[derive(Clone, Debug, PartialEq, Eq)] #[non_exhaustive] pub struct StageModule
struct metal2vulkan::pipeline::StandInUse #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub struct StandInUse
struct metal2vulkan::pipeline::StandaloneModule #[derive(Clone, Debug, PartialEq, Eq)] #[non_exhaustive] pub struct StandaloneModule
struct metal2vulkan::pipeline::StorageAttachmentUse #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[non_exhaustive] pub struct StorageAttachmentUse
struct metal2vulkan::pipeline::StorageImageChoice #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub struct StorageImageChoice
@@ -9318,7 +9285,6 @@ variant metal2vulkan-runtime::PrecisionNote::CappedLodBias CappedLodBias
variant metal2vulkan-runtime::PrecisionNote::ClippedCoverageSplit ClippedCoverageSplit
variant metal2vulkan-runtime::PrecisionNote::ColorAttachmentGroups ColorAttachmentGroups
variant metal2vulkan-runtime::PrecisionNote::CompressedTexelDecode CompressedTexelDecode
variant metal2vulkan-runtime::PrecisionNote::ComputedSampleDepth ComputedSampleDepth
variant metal2vulkan-runtime::PrecisionNote::CoverageReadsRoundedAlpha CoverageReadsRoundedAlpha
variant metal2vulkan-runtime::PrecisionNote::CubeGradientFootprint CubeGradientFootprint
variant metal2vulkan-runtime::PrecisionNote::DepthDenormals DepthDenormals
@@ -9581,13 +9547,10 @@ variant metal2vulkan::bind::ChromaDecode::Bgrg Bgrg
variant metal2vulkan::bind::ChromaDecode::Gbgr Gbgr
variant metal2vulkan::bind::CopySource::Aspect Aspect
variant metal2vulkan::bind::CopySource::Shadow Shadow
variant metal2vulkan::bind::DepthStandInForm::Multisampled Multisampled
variant metal2vulkan::bind::DepthStandInForm::SamplePlanes SamplePlanes
variant metal2vulkan::bind::DepthStencilCopy::Depth Depth
variant metal2vulkan::bind::DepthStencilCopy::Depth16Bits Depth16Bits
variant metal2vulkan::bind::DepthStencilCopy::Depth16Code Depth16Code
variant metal2vulkan::bind::DepthStencilCopy::DepthBits DepthBits
variant metal2vulkan::bind::DepthStencilCopy::DepthFromStandIn DepthFromStandIn { form: DepthStandInForm }
variant metal2vulkan::bind::DepthStencilCopy::StencilBits StencilBits
variant metal2vulkan::bind::DepthStencilCopy::StencilExport StencilExport { source: CopySource }
variant metal2vulkan::bind::DepthStencilCopy::StencilPlane StencilPlane { source: CopySource, bit: StencilBit }
@@ -9616,7 +9579,6 @@ variant metal2vulkan::bind::DrawReplayRule::Operations Operations(u32)
variant metal2vulkan::bind::DrawReplayRule::OwnPipelineStates OwnPipelineStates
variant metal2vulkan::bind::DrawReplayRule::PrimitiveTypes PrimitiveTypes(u8)
variant metal2vulkan::bind::DrawReplayRule::ShaderStencil ShaderStencil
variant metal2vulkan::bind::DrawReplayRule::ShaderTests ShaderTests
variant metal2vulkan::bind::DrawReplayRule::SharedSlotTable SharedSlotTable
variant metal2vulkan::bind::DrawReplayRule::VertexAttributes VertexAttributes
variant metal2vulkan::bind::DrawReplayRule::VertexWritesMemory VertexWritesMemory
@@ -9764,7 +9726,6 @@ variant metal2vulkan::bind::WriteSource::Buffer Buffer { slot: SlotRef }
variant metal2vulkan::bind::WriteSource::CombinedImageSampler CombinedImageSampler { image: ImageSource, sampler: SamplerSource }
variant metal2vulkan::bind::WriteSource::ConstantBlob ConstantBlob { stage: Stage }
variant metal2vulkan::bind::WriteSource::ControlPointIndices ControlPointIndices
variant metal2vulkan::bind::WriteSource::DepthStandIn DepthStandIn
variant metal2vulkan::bind::WriteSource::ExecutionStatus ExecutionStatus
variant metal2vulkan::bind::WriteSource::FunctionTable FunctionTable { index: u32 }
variant metal2vulkan::bind::WriteSource::FunctionTableSnapshot FunctionTableSnapshot
@@ -9779,7 +9740,6 @@ variant metal2vulkan::bind::WriteSource::RateMapRegions RateMapRegions
variant metal2vulkan::bind::WriteSource::Sampler Sampler { slot: SlotRef, compare: bool, integer: bool, opaque_black: OpaqueBlackBorder }
variant metal2vulkan::bind::WriteSource::ShadowStencil ShadowStencil
variant metal2vulkan::bind::WriteSource::SnapshotTexels SnapshotTexels { slot: u32 }
variant metal2vulkan::bind::WriteSource::StencilStandIn StencilStandIn
variant metal2vulkan::bind::WriteSource::TessellationFactors TessellationFactors
variant metal2vulkan::bind::WriteSource::TexelBuffer TexelBuffer { slot: SlotRef, format: vk::Format, window: Window }
variant metal2vulkan::bind::WriteSource::TexelRows TexelRows { slot: SlotRef, format: vk::Format }
@@ -10266,7 +10226,6 @@ variant metal2vulkan::device::VkLimit::MinTexelBufferOffsetAlignment MinTexelBuf
variant metal2vulkan::device::VkLimit::MinTexelGatherOffset MinTexelGatherOffset
variant metal2vulkan::device::VkLimit::MinTexelOffset MinTexelOffset
variant metal2vulkan::device::VkLimit::MinUniformBufferOffsetAlignment MinUniformBufferOffsetAlignment
variant metal2vulkan::device::VkProperty::CenterFragCoordDepth CenterFragCoordDepth
variant metal2vulkan::device::VkProperty::ColorAttachmentSampleCount ColorAttachmentSampleCount(vk::Format, u32)
variant metal2vulkan::device::VkProperty::DenormIndependence32BitOnly DenormIndependence32BitOnly
variant metal2vulkan::device::VkProperty::DenormIndependenceAll DenormIndependenceAll
@@ -10316,7 +10275,6 @@ variant metal2vulkan::device::VkProperty::RequiredSubgroupSizeStage RequiredSubg
variant metal2vulkan::device::VkProperty::Rgba4OpaqueBlackSwizzled Rgba4OpaqueBlackSwizzled
variant metal2vulkan::device::VkProperty::RoundingIndependence32BitOnly RoundingIndependence32BitOnly
variant metal2vulkan::device::VkProperty::RoundingIndependenceAll RoundingIndependenceAll
variant metal2vulkan::device::VkProperty::SampleFragCoordDepth SampleFragCoordDepth
variant metal2vulkan::device::VkProperty::SampleLocationSampleCount SampleLocationSampleCount(u32)
variant metal2vulkan::device::VkProperty::SimdgroupLockstep SimdgroupLockstep
variant metal2vulkan::device::VkProperty::StencilResolveMode StencilResolveMode(ResolveMode)
@@ -10458,7 +10416,6 @@ variant metal2vulkan::error::DescriptorError::VertexAmplificationCount VertexAmp
variant metal2vulkan::error::DescriptorError::VertexAttribute VertexAttribute { attribute: u32 }
variant metal2vulkan::error::DescriptorError::VertexLayout VertexLayout { layout: u32 }
variant metal2vulkan::error::DescriptorError::VertexStepRate VertexStepRate { step_rate: u32 }
variant metal2vulkan::error::DriverDeviation::CenterFragCoordDepth CenterFragCoordDepth
variant metal2vulkan::error::DriverDeviation::CubeGradientRoute CubeGradientRoute
variant metal2vulkan::error::DriverDeviation::GraphicsCubeGradientTangents GraphicsCubeGradientTangents
variant metal2vulkan::error::DriverDeviation::MetalAlphaCoverage MetalAlphaCoverage
@@ -10491,7 +10448,6 @@ variant metal2vulkan::error::DriverDeviation::MetalSmallFloatColorWrites MetalSm
variant metal2vulkan::error::DriverDeviation::MetalSmallFloatNans MetalSmallFloatNans
variant metal2vulkan::error::DriverDeviation::MetalUnaryDenormals MetalUnaryDenormals
variant metal2vulkan::error::DriverDeviation::MetalVertexSimdgroups MetalVertexSimdgroups
variant metal2vulkan::error::DriverDeviation::SampleFragCoordDepth SampleFragCoordDepth
variant metal2vulkan::error::DriverDeviation::SimdgroupLockstep SimdgroupLockstep
variant metal2vulkan::error::DynamicLibraryProblem::FunctionConstants FunctionConstants
variant metal2vulkan::error::DynamicLibraryProblem::NoInstallName NoInstallName
@@ -10577,7 +10533,6 @@ variant metal2vulkan::error::Feature::MeshShading MeshShading
variant metal2vulkan::error::Feature::MinLodClamp MinLodClamp
variant metal2vulkan::error::Feature::MipmapGeneration MipmapGeneration
variant metal2vulkan::error::Feature::ModuleRecord ModuleRecord { code: u32 }
variant metal2vulkan::error::Feature::MultisampledShaderDepthTest MultisampledShaderDepthTest
variant metal2vulkan::error::Feature::PixelCoverageAtSampleRate PixelCoverageAtSampleRate
variant metal2vulkan::error::Feature::PixelSamplerCompare PixelSamplerCompare
variant metal2vulkan::error::Feature::PointerCompare PointerCompare
@@ -10937,7 +10892,6 @@ variant metal2vulkan::pipeline::PrecisionNote::CappedLodBias CappedLodBias
variant metal2vulkan::pipeline::PrecisionNote::ClippedCoverageSplit ClippedCoverageSplit
variant metal2vulkan::pipeline::PrecisionNote::ColorAttachmentGroups ColorAttachmentGroups
variant metal2vulkan::pipeline::PrecisionNote::CompressedTexelDecode CompressedTexelDecode
variant metal2vulkan::pipeline::PrecisionNote::ComputedSampleDepth ComputedSampleDepth
variant metal2vulkan::pipeline::PrecisionNote::CoverageReadsRoundedAlpha CoverageReadsRoundedAlpha
variant metal2vulkan::pipeline::PrecisionNote::CubeGradientFootprint CubeGradientFootprint
variant metal2vulkan::pipeline::PrecisionNote::DepthDenormals DepthDenormals
@@ -11045,8 +10999,6 @@ variant metal2vulkan::pipeline::PushField::RegionProbe RegionProbe
variant metal2vulkan::pipeline::PushField::RenderTargetArrayLength RenderTargetArrayLength
variant metal2vulkan::pipeline::PushField::ReplayRegionAddress ReplayRegionAddress
variant metal2vulkan::pipeline::PushField::RootTableAddress RootTableAddress
variant metal2vulkan::pipeline::PushField::ShaderStencilState ShaderStencilState
variant metal2vulkan::pipeline::PushField::ShaderTestsState ShaderTestsState
variant metal2vulkan::pipeline::PushField::ShadowStencilState ShadowStencilState
variant metal2vulkan::pipeline::PushField::SlotBindOffset SlotBindOffset(SlotRef)
variant metal2vulkan::pipeline::PushField::SlotBounds SlotBounds(SlotRef)
@@ -11160,8 +11112,6 @@ variant metal2vulkan::pipeline::RuntimeFact::RowLockstep RowLockstep
variant metal2vulkan::pipeline::RuntimeFact::SampleCount SampleCount
variant metal2vulkan::pipeline::RuntimeFact::SamplerCoordinates SamplerCoordinates { slot: SlotRef }
variant metal2vulkan::pipeline::RuntimeFact::SamplerReduction SamplerReduction { slot: SlotRef }
variant metal2vulkan::pipeline::RuntimeFact::ShaderStencilTest ShaderStencilTest { formatless: bool }
variant metal2vulkan::pipeline::RuntimeFact::ShaderTests ShaderTests { formatless: bool, multisampled: bool, planes: bool }
variant metal2vulkan::pipeline::RuntimeFact::ShadowStencil ShadowStencil { formatless: bool, multisampled: bool }
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 }
@@ -11280,8 +11230,6 @@ variant metal2vulkan::pipeline::Stage::Object Object
variant metal2vulkan::pipeline::Stage::Vertex Vertex
variant metal2vulkan::pipeline::StageSource::Compiled Compiled(CompiledFunction)
variant metal2vulkan::pipeline::StageSource::Function Function(FunctionDescriptor)
variant metal2vulkan::pipeline::StandInView::Image Image
variant metal2vulkan::pipeline::StandInView::SamplePlanes SamplePlanes { layers: u32 }
variant metal2vulkan::pipeline::StorageAttachmentView::Attachment Attachment
variant metal2vulkan::pipeline::StorageAttachmentView::SamplePlanes SamplePlanes { layers: u32 }
variant metal2vulkan::pipeline::StorageFormatClass::Format Format(vk::Format)
@@ -11302,7 +11250,6 @@ variant metal2vulkan::pipeline::Symbol::SpecId SpecId(SpecKey)
variant metal2vulkan::pipeline::SyntheticBinding::ArgumentTable ArgumentTable
variant metal2vulkan::pipeline::SyntheticBinding::ConstantBlob ConstantBlob
variant metal2vulkan::pipeline::SyntheticBinding::ControlPointIndices ControlPointIndices
variant metal2vulkan::pipeline::SyntheticBinding::DepthStandIn DepthStandIn
variant metal2vulkan::pipeline::SyntheticBinding::ExecutionStatus ExecutionStatus
variant metal2vulkan::pipeline::SyntheticBinding::FunctionTableDirectory FunctionTableDirectory
variant metal2vulkan::pipeline::SyntheticBinding::FunctionTableSnapshot FunctionTableSnapshot
@@ -11314,7 +11261,6 @@ variant metal2vulkan::pipeline::SyntheticBinding::RateMapRegions RateMapRegions
variant metal2vulkan::pipeline::SyntheticBinding::RootTable RootTable
variant metal2vulkan::pipeline::SyntheticBinding::SamplerTable SamplerTable
variant metal2vulkan::pipeline::SyntheticBinding::ShadowStencil ShadowStencil
variant metal2vulkan::pipeline::SyntheticBinding::StencilStandIn StencilStandIn
variant metal2vulkan::pipeline::SyntheticBinding::TessellationFactors TessellationFactors
variant metal2vulkan::pipeline::SyntheticBinding::TileMemory TileMemory
variant metal2vulkan::pipeline::UniformViewChoice::Kept Kept
Can't render this file because it is too large.
-6
View File
@@ -364,10 +364,7 @@ surface! {
struct InputAttachmentUse N;
struct LineBandState N;
enum RegionFanOut E;
struct ShaderTestsUse N;
struct ShadowStencilUse N;
struct StandInUse N;
enum StandInView N;
struct StorageAttachmentUse N;
enum StorageAttachmentView E;
struct TessellationState N;
@@ -653,10 +650,7 @@ surface! {
struct InterleaveSplitModule N;
fn depth_stencil_copy_modules;
fn stencil_split_module;
fn depth_split_module;
enum CopySource E;
enum DepthStandInForm E;
struct DepthSplitModule N;
enum DepthStencilCopy N;
struct DepthStencilCopyModules N;
struct StencilBit O;
-4
View File
@@ -2334,10 +2334,6 @@ bound.
do not decide; or a function a table can hold that linking did not import could not be planned, so
its samplers are not known; or a dynamic library's symbol, a binary function or a function-pointer
group's function brings them, whose numbering is not measured.
- `metal2vulkan-degrade-computed-sample-depth` (precision). `PrecisionNote::ComputedSampleDepth`:
Recorded by no device: its condition, the measured `VkProperty::CenterFragCoordDepth`, is in no
profile, so a fragment function that would run its draw's depth test itself at more than one
sample, without returning its depth, is `Feature::MultisampledShaderDepthTest`, not implemented.
- `metal2vulkan-degrade-argument-pixel-sampler-scaling` (precision).
`PrecisionNote::ArgumentPixelSamplerScaling`: A sample, gather or comparison through an argument
buffer's sampler whose word the specialized module cannot read may hand the device a pixel
+4 -6
View File
@@ -26,7 +26,7 @@ Columns:
| Kind | Variants | With a site | Reach system | Reach app | Reach rare | Reach none | Unassessed |
|---|---|---|---|---|---|---|---|
| Translator and front-end refusals | 136 | 121 | 8 | 33 | 74 | 21 | 0 |
| Translator and front-end refusals | 135 | 120 | 8 | 33 | 73 | 21 | 0 |
| Binder refusals at a device limit | 9 | 9 | 0 | 1 | 7 | 1 | 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 |
@@ -40,7 +40,7 @@ Columns:
| Kind | `metal-measured` | `metal-documented` | `metal-takes` | `device` | `ours` | `unknown` | `delegated` | `-` |
|---|---|---|---|---|---|---|---|---|
| Translator and front-end refusals | 0 | 0 | 0 | 41 | 58 | 0 | 0 | 37 |
| Translator and front-end refusals | 0 | 0 | 0 | 41 | 57 | 0 | 0 | 37 |
| Binder refusals at a device limit | 0 | 0 | 0 | 9 | 0 | 0 | 0 | 0 |
| Translation caps | 0 | 0 | 0 | 0 | 14 | 0 | 0 | 0 |
| Rate maps the compile layer does not compile | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 5 |
@@ -110,8 +110,7 @@ Columns:
| `PixelSamplerCompare` | A constexpr sampler with pixel coordinates and a compare function, which Apple's compiler rejects ("invalid values combination in sampler... | every device (no Vulkan mechanism) | `device` | 1: `crates/metal2vulkan/src/lower/sampler/constexpr.rs (lowered)` | `none`: Apple's compiler rejects it |
| `TexelBuffer` | Texture buffers beyond the device's texel-buffer limits | devices without a format's usage; every device (no Vulkan mechanism) | `device` | 3: `crates/metal2vulkan/src/bind/instantiate.rs (texel_ranges, 2 sites)`, `crates/metal2vulkan/src/bind/plan/resources.rs (plain_texture)` | `app`: texture buffers past a device's texel-buffer limits |
| `RasterOrderGroups` | Raster order groups without fragment shader interlock | devices without VkFeature::FragmentShaderPixelInterlock; devices without VkFeature::FragmentShaderSampleInterlock; devices without a capability the site computes (`alternatives`); every device (not implemented) | `ours` | 4: `crates/metal2vulkan/src/device/metal.rs (unsupported_features)`, `crates/metal2vulkan/src/lower/fragment/rog.rs (mode, 2 sites)` (+1) | `rare`: raster order groups |
| `FramebufferFetch` | Framebuffer fetch without an ordered form on the device (rasterization-order attachment access, or the pixel interlock's storage form where the... | devices short of a Vulkan property the site names; devices without VkFeature::FragmentShaderPixelInterlock; devices without VkFeature::RasterizationOrderColorAttachmentAccess; devices without VkFeature::SampleRateShading; devices without a capability the site computes (`alternatives`); devices without a capability the site computes (`c`); devices without a capability the site computes (`missing`); every device (not implemented) | `ours` | 15: `crates/metal2vulkan/src/bind/sample_planes.rs (finish)`, `crates/metal2vulkan/src/lower/arith/extended_range/blend.rs (packed16)` (+11) | `system`: programmable blending (framebuffer fetch); macOS 26.6.2's login reaches it (two WindowServer and RenderBox pipelines fetch RGB10A8_2P_XR10 attachments, the consumer's boots) |
| `MultisampledShaderDepthTest` | A fragment function that runs its draw's depth test itself (`lower::fragment::depth_test`) at more than one sample, where it does not return its depth | every device (not implemented) | `ours` | 1: `crates/metal2vulkan/src/lower/fragment/depth_test.rs (depth_test_form)` | `rare`: a fragment function whose draw's depth test runs in the shader at more than one sample (tested storage writes, framebuffer fetch beside depth) |
| `FramebufferFetch` | Framebuffer fetch without an ordered form on the device (rasterization-order attachment access, or the pixel interlock's storage form where the... | devices short of a Vulkan property the site names; devices without VkFeature::FragmentShaderPixelInterlock; devices without VkFeature::RasterizationOrderColorAttachmentAccess; devices without VkFeature::SampleRateShading; devices without a capability the site computes (`alternatives`); devices without a capability the site computes (`c`); every device (not implemented) | `ours` | 12: `crates/metal2vulkan/src/bind/sample_planes.rs (finish)`, `crates/metal2vulkan/src/lower/arith/extended_range/blend.rs (packed16)` (+8) | `system`: programmable blending (framebuffer fetch); macOS 26.6.2's login reaches it (two WindowServer and RenderBox pipelines fetch RGB10A8_2P_XR10 attachments, the consumer's boots) |
| `PrimitiveId` | `[[primitive_id]]` in a fragment function | devices without a capability the site computes; every device (not implemented) | `ours` | 2: `crates/metal2vulkan/src/lower/stage_io/plan.rs (finish)`, `crates/metal2vulkan/src/pipeline/link/varyings.rs (check_primitive_id)` | `rare`: primitive_id on a device without geometry or tessellation shaders, in an indexed draw or behind a mesh function |
| `PrivatePrimitives` | One of Metal's private primitive types (a line loop, a triangle fan, quads, a quad strip) drawn in the pulled list form... | - | `-` | via a helper: 1: `crates/metal2vulkan/src/lower/stage_io/plan.rs (indices_feature)` | `rare`: a private primitive type drawn in the pulled list form (a vertex function that writes memory or the primitive_id varying, a vertex start past 2^31) on a device without device addresses |
| `VertexAmplification` | Vertex amplification | devices without VkFeature::Multiview; devices without VkFeature::MultiviewTessellationShader; devices without VkLimit::MaxMultiviewInstanceIndex; devices without a capability the site computes (`needs`); every device (not implemented) | `ours` | 5: `crates/metal2vulkan/src/bind/graphics.rs (multiview_instances)`, `crates/metal2vulkan/src/lower/stage_io/plan.rs (own_index_store)` (+3) | `rare`: vertex amplification |
@@ -451,8 +450,7 @@ Each refusal's sites, with the function that builds it.
- `feature::PixelSamplerCompare`: `crates/metal2vulkan/src/lower/sampler/constexpr.rs (lowered)`
- `feature::TexelBuffer`: `crates/metal2vulkan/src/bind/instantiate.rs (texel_ranges, 2 sites)`; `crates/metal2vulkan/src/bind/plan/resources.rs (plain_texture)`
- `feature::RasterOrderGroups`: `crates/metal2vulkan/src/device/metal.rs (unsupported_features)`; `crates/metal2vulkan/src/lower/fragment/rog.rs (mode, 2 sites)`; `crates/metal2vulkan/src/lower/fragment/snapshot.rs (finish)`
- `feature::FramebufferFetch`: `crates/metal2vulkan/src/bind/sample_planes.rs (finish)`; `crates/metal2vulkan/src/lower/arith/extended_range/blend.rs (packed16)`; `crates/metal2vulkan/src/lower/arith/extended_range/blend.rs (srgb8)`; `crates/metal2vulkan/src/lower/arith/extended_range/blend.rs (unorm8, 3 sites)`; `crates/metal2vulkan/src/lower/fragment/color.rs (unordered)`; `crates/metal2vulkan/src/lower/fragment/depth_test.rs (depth_test_form)`; `crates/metal2vulkan/src/lower/fragment/depth_test.rs (not_implemented)`; `crates/metal2vulkan/src/lower/fragment/depth_test.rs (stencil_test_form)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs (not_implemented)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs (plan_sample)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs (storage_form)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs (unordered_extended_fetch)`; `crates/metal2vulkan/src/pipeline/link/fetch.rs (storage_attachments)`
- `feature::MultisampledShaderDepthTest`: `crates/metal2vulkan/src/lower/fragment/depth_test.rs (depth_test_form)`
- `feature::FramebufferFetch`: `crates/metal2vulkan/src/bind/sample_planes.rs (finish)`; `crates/metal2vulkan/src/lower/arith/extended_range/blend.rs (packed16)`; `crates/metal2vulkan/src/lower/arith/extended_range/blend.rs (srgb8)`; `crates/metal2vulkan/src/lower/arith/extended_range/blend.rs (unorm8, 3 sites)`; `crates/metal2vulkan/src/lower/fragment/color.rs (unordered)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs (not_implemented)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs (plan_sample)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs (storage_form)`; `crates/metal2vulkan/src/lower/fragment/fetch.rs (unordered_extended_fetch)`; `crates/metal2vulkan/src/pipeline/link/fetch.rs (storage_attachments)`
- `feature::PrimitiveId`: `crates/metal2vulkan/src/lower/stage_io/plan.rs (finish)`; `crates/metal2vulkan/src/pipeline/link/varyings.rs (check_primitive_id)`
- `feature::PrivatePrimitives`: `crates/metal2vulkan/src/lower/stage_io/plan.rs (indices_feature)`
- `feature::VertexAmplification`: `crates/metal2vulkan/src/bind/graphics.rs (multiview_instances)`; `crates/metal2vulkan/src/lower/stage_io/plan.rs (own_index_store)`; `crates/metal2vulkan/src/lower/tessellation/mod.rs (select_param)`; `crates/metal2vulkan/src/pipeline/link/graphics.rs (vertex_amplification)`; `crates/metal2vulkan/src/pipeline/link/tessellation/mod.rs (control_plan)`
-1
View File
@@ -68,7 +68,6 @@ feature DualSourceBlending rare dual-source blending on a device without it
feature Barycentrics rare barycentric coordinates
feature StencilExport rare stencil from the shader
feature SampleRateShading rare per-sample shading
feature MultisampledShaderDepthTest rare a fragment function whose draw's depth test runs in the shader at more than one sample (tested storage writes, framebuffer fetch beside depth)
feature PullModelInterpolation rare interpolant inputs read at the centroid, a sample or an offset
feature DivergentInterpolation rare an interpolant read at a sample or an offset in a branch, a loop or after a discard
feature SamplePositions rare custom sample positions on a device that takes none at the pass's sample count
Can't render this file because it contains an unexpected character in line 17 and column 65.