Tests: a fetch on a device with neither ordered form compiles through input attachments, noted

The core suite at 6bbdbdabc6 (job m3-max-14695, homelab-ms01-1) still expected the refusal on a
device with neither rasterization-order access nor the pixel interlock (vk12-floor,
lunarg-desktop-baseline-2023, roadmap-2022):

- engine_dead_fetch: a live read there reads color 0's input attachment, no storage form, and
  notes UnorderedFetchWithinDraw (an ordered form notes nothing); the three forms partition the
  profiles, so the refusal arm is gone.
- engine_fragment's framebuffer_fetch_reads_in_an_ordered_form_where_the_device_has_one: with
  neither form each entry (fetch_ordered's raster order group included) compiles to one input
  attachment a color with its FramebufferFetch fact, noted; the rasterization-order form notes
  nothing.
- engine_function_constant_interface: the declared color input on vk12-floor compiles, its
  FramebufferFetch fact and the note.
- the runtime's image_plan check: a color attachment is an input attachment exactly where
  framebuffer_fetch::through_inputs holds (rasterization order, or between draws), as the image
  plan decides.
This commit is contained in:
Anees Iqbal committed 2026-11-11 04:01:36 -08:00
1 parent 3d18018dad
commit 03eb5af335
4 files changed
+60 -41

No files matched your search

@@ -210,11 +210,12 @@ fn check_plan(
);
}
// A color attachment is an input attachment exactly where the device's framebuffer fetch
// reads input attachments.
// reads input attachments: in rasterization order, or, with neither ordered form, between
// draws.
assert_eq!(
plan.usage.contains(ImageUsageFlags::INPUT_ATTACHMENT),
plan.usage.contains(ImageUsageFlags::COLOR_ATTACHMENT)
&& profile.fragment().rasterization_order_color_access,
&& crate::framebuffer_fetch::through_inputs(profile),
"{what}"
);
if plan
@@ -14,8 +14,9 @@
//! shader) and no input attachment, its stages passing L3. Specialized with the read live, each
//! reads color 0 in the form the device orders a fetch by: a written storage attachment and no
//! color attachment where it orders fetch through the pixel interlock alone, an input attachment
//! where it orders it through rasterization-order input attachments, and refused where it has
//! neither. Before the fetch state was decided from the specialized function's uses, a dead read
//! where it orders it through rasterization-order input attachments, and an input attachment
//! ordered between draws alone where it has neither, its fragment stage noting
//! `UnorderedFetchWithinDraw`. Before the fetch state was decided from the specialized function's uses, a dead read
//! took the storage form on every interlock profile, with the blend computed in the shader.
//! No GPU is used.
@@ -27,7 +28,7 @@ use crate::error::Error;
use crate::library::{FunctionConstantValue, FunctionConstantValues, Library};
use crate::lower::fragment::{inputs_order, interlock_orders};
use crate::metal::{BlendFactor, BlendOperation, DataType, PixelFormat};
use crate::pipeline::artifact::RenderPipeline;
use crate::pipeline::artifact::{PrecisionNote, RenderPipeline};
use crate::pipeline::descriptor::{
ColorAttachmentDescriptor, FunctionDescriptor, RenderPipelineDescriptor, StageSource,
};
@@ -163,19 +164,19 @@ fn a_framebuffer_read_dead_after_specialization_takes_no_fetch_form() {
pipe.graphics.color_attachments[0]
);
interlocked += 1;
} else if inputs_order(&p) {
} else {
// Rasterization-order input attachments, or with neither ordered form input
// attachments ordered between draws alone, noted.
let pipe = live.unwrap_or_else(|e| panic!("{what}, live: {e}"));
let read: Vec<u32> = (pipe.graphics.input_attachments.iter())
.map(|u| u.color_index)
.collect();
assert_eq!(read, [0], "{what}, live");
assert_eq!(storage(&pipe), [], "{what}, live");
} else {
assert!(
matches!(live, Err(Error::Unsupported(_))),
"{what}, live: {:?}",
live.map(|_| ())
);
let noted = (pipe.stages.iter()).any(|s| {
(s.precision_notes).contains(&PrecisionNote::UnorderedFetchWithinDraw)
});
assert_eq!(noted, !inputs_order(&p), "{what}, live");
}
}
}
@@ -474,8 +474,10 @@ fn fetch_state(read: &[u32], formats: &[PixelFormat], blending: bool) -> Lowerin
/// fact. With only the ordered pixel interlock it is one storage image read (and written) inside
/// the interlock, under its pipeline's state (standalone, the function needs that state); a
/// blended attachment's blend the shader computes, Metal's of a 16-bit float or 8-bit unorm one,
/// the generic one, noted `UnmeasuredFetchBlend`, of another. With neither, it is refused naming
/// both. Every compiled module passes L3.
/// the generic one, noted `UnmeasuredFetchBlend`, of another. With neither, it is one input
/// attachment with a `FramebufferFetch` fact, ordered between draws alone and noted
/// `UnorderedFetchWithinDraw`, a raster order group on it (`fetch_ordered`) taking no interlock.
/// Every compiled module passes L3.
#[test]
fn framebuffer_fetch_reads_in_an_ordered_form_where_the_device_has_one() {
let Some(bc) = fixture("fragment_fetch") else {
@@ -500,9 +502,9 @@ fn framebuffer_fetch_reads_in_an_ordered_form_where_the_device_has_one() {
for (stem, strict) in committed_profiles().expect("profiles") {
let frag = strict.fields().fragment;
for (entry, colors, formats) in entries {
// A color input in a raster order group needs the interlock, where rasterization-order
// access orders the read; with neither ordered form the read is refused first, naming
// both (below).
// A color input in a raster order group needs the interlock where rasterization-order
// access orders the read; with neither ordered form the group orders the read alone
// (below).
if entry == "fetch_ordered"
&& !frag.pixel_interlock
&& frag.rasterization_order_color_access
@@ -530,6 +532,11 @@ fn framebuffer_fetch_reads_in_an_ordered_form_where_the_device_has_one() {
a.facts
);
}
assert!(
!a.precision
.contains(&PrecisionNote::UnorderedFetchWithinDraw),
"{entry} on {stem}"
);
}
} else if frag.pixel_interlock {
forms[1] += 1;
@@ -578,25 +585,23 @@ fn framebuffer_fetch_reads_in_an_ordered_form_where_the_device_has_one() {
);
} else {
forms[2] += 1;
// Each entry writes the color it reads first: the interlock's alternative names
// what the device lacks of the interlock and the fragment-stage store.
let mut interlock =
vec![Capability::Feature(VkFeature::FragmentShaderPixelInterlock)];
if !strict.fields().leaf.fragment_stores_and_atomics {
interlock.push(Capability::Feature(VkFeature::FragmentStoresAndAtomics));
let a = compile_with(&bc, entry, &strict, &LoweringInputs::new())
.unwrap_or_else(|e| panic!("{entry} on {stem}: {e}"));
link_and_validate(&a, &strict)
.unwrap_or_else(|e| panic!("{entry} on {stem}: L3: {e}"));
assert_eq!(attachments(&a), colors, "{entry} on {stem}");
for &color in colors {
assert!(
a.facts.contains(&RuntimeFact::FramebufferFetch { color }),
"{entry} on {stem}: {:?}",
a.facts
);
}
assert_eq!(
refusal(&bc, entry, &strict),
(
Feature::FramebufferFetch,
Needs::AnyOf(vec![
vec![Capability::Feature(
VkFeature::RasterizationOrderColorAttachmentAccess
)],
interlock,
])
),
"{entry} on {stem}"
assert!(
a.precision
.contains(&PrecisionNote::UnorderedFetchWithinDraw),
"{entry} on {stem}: {:?}",
a.precision
);
}
}
@@ -37,9 +37,10 @@ use std::sync::Arc;
use crate::budget::SPIRV_WORDS;
use crate::device::{DevicePolicy, DeviceProfile};
use crate::error::{DescriptorError, Error, Feature, RuntimeInput};
use crate::error::{DescriptorError, Error, RuntimeInput};
use crate::library::{FunctionArtifact, FunctionConstantValue, FunctionConstantValues};
use crate::metal::DataType;
use crate::pipeline::artifact::PrecisionNote;
use crate::pipeline::compile::{compile_bitcode, EntryRef};
use crate::pipeline::facts::RuntimeFact;
use crate::pipeline::link::link;
@@ -206,9 +207,9 @@ fn an_unobserved_gated_off_input_compiles() {
validate(&off, &p);
}
// Defined (and so declared), the color input is read: a framebuffer fetch. `vk12-floor` has
// neither ordered form, so the default policy refuses it; `moltenvk-m3` orders a fetch only
// through the pixel interlock, in a storage form that needs its pipeline's state, which a
// standalone compile does not have.
// neither ordered form, so it reads color 0's input attachment, ordered between draws alone
// and noted; `moltenvk-m3` orders a fetch only through the pixel interlock, in a storage form
// that needs its pipeline's state, which a standalone compile does not have.
for stem in ["vk12-floor", "moltenvk-m3"] {
let r = compile_bitcode(
&bc,
@@ -221,8 +222,19 @@ fn an_unobserved_gated_off_input_compiles() {
SPIRV_WORDS,
);
match (stem, r) {
("vk12-floor", Err(Error::Unsupported(u))) => {
assert_eq!(u.feature, Feature::FramebufferFetch)
("vk12-floor", Ok(a)) => {
assert!(
a.facts
.contains(&RuntimeFact::FramebufferFetch { color: 0 }),
"{stem}: {:?}",
a.facts
);
assert!(
a.precision
.contains(&PrecisionNote::UnorderedFetchWithinDraw),
"{stem}: {:?}",
a.precision
);
}
("moltenvk-m3", Err(Error::NeedsInput(RuntimeInput::FramebufferFetch))) => {}
(_, other) => panic!("{stem}: declared color input: {:?}", other.map(|_| ())),