From c8a41e013d6636ace93b990a3bfc4091d7cd48d0 Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Mon, 9 Nov 2026 04:29:59 -0800 Subject: [PATCH] Fetch gate: the alpha_in_red color inputs, color_groups' fetch scene and four extended-range blends The RX 550 run of development (potluck 11625) found seven more tests unwrapping the typed FramebufferFetch refusal: alpha_in_red's two A8 color-input tests, the device-width color_groups scenes (whose fetch scene and cg_fetch pipeline need a fetch form) and four extended_range_blends tests (a blend into an extended-range color holds its shadow in the pixel interlock). Each opens with framebuffer_fetch::fetches; color_groups skips only its fetch scene and requires cg_fetch's refusal to be FramebufferFetch where the device has no form. (cherry picked from commit a63850737a463164609dc0ba99c53cf21d7156e0) --- .../src/runtime_lane/alpha_in_red.rs | 13 ++++++++-- .../src/runtime_lane/color_groups.rs | 26 +++++++++++++++---- .../src/runtime_lane/extended_range_blends.rs | 12 +++++++++ 3 files changed, 44 insertions(+), 7 deletions(-) diff --git a/crates/metal2vulkan-validation/src/runtime_lane/alpha_in_red.rs b/crates/metal2vulkan-validation/src/runtime_lane/alpha_in_red.rs index 02d047da2..e161b12ee 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/alpha_in_red.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/alpha_in_red.rs @@ -30,6 +30,7 @@ use super::degrade_notices::{made_render_kinds, resolve_kind}; use super::driver_deviations::stage_notes; +use super::framebuffer_fetch::fetches; use super::pixel_samplers::metal_sampler; use super::{ buffer_with, converted_holds, half_within, layer_reported_nothing_at_all, read_buffer, @@ -1086,13 +1087,17 @@ const FETCH_MASKS: [(ColorWriteMask, u8); 3] = [ /// function's write after it stores the alpha as the write mask lets it, at one sample and at four, /// as Metal's do: on the device without `A8_UNORM` (its `R8_UNORM` image read through the input /// attachment or the interlocked storage form, whichever the device orders fetch with), and with -/// its own `A8_UNORM` where it has the format. +/// its own `A8_UNORM` where it has the format. A device without a fetch form skips it +/// ([`fetches`]). #[test] fn a8_color_input_reads_alpha_as_metal() { let messages = Messages::default(); let cache = ScratchCache::new().unwrap(); for withheld in [true, false] { let lane = Lane::new(&messages, &cache, withheld); + if !fetches(&lane.device) { + continue; + } let name = lane.device.name().to_owned(); if withheld { assert!(lane.in_red(), "{name}: A8Unorm is not held in red"); @@ -1164,7 +1169,8 @@ fn a8_color_input_reads_alpha_as_metal() { /// `A8_UNORM`: the fetch reads the planes in the pixel interlock, declared without a format by the /// format's own bit, and the planes are held in `A8_UNORM` itself (`bind::PlanesCopy::Alpha8`), as /// no unsigned view reads its class. A target cleared to 0.6 reads `(0, 0, 0, 0.6)` at every -/// sample, and the write of [`COLOR`] after it resolves to 204, as Metal's (probe `a8`'s uses). +/// sample, and the write of [`COLOR`] after it resolves to 204, as Metal's (probe `a8`'s uses). A +/// device without a fetch form skips it ([`fetches`]). #[test] fn a8_color_input_through_sample_planes_reads_alpha_as_metal() { let messages = Messages::default(); @@ -1186,6 +1192,9 @@ fn a8_color_input_through_sample_planes_reads_alpha_as_metal() { layer_reported_nothing_at_all(&messages); return; } + if !fetches(&lane.device) { + return; + } let pipeline = lane .pipeline( ("a8r_vertex", "a8r_fetch"), diff --git a/crates/metal2vulkan-validation/src/runtime_lane/color_groups.rs b/crates/metal2vulkan-validation/src/runtime_lane/color_groups.rs index 917961fbf..207431d32 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/color_groups.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/color_groups.rs @@ -33,6 +33,7 @@ //! color of another group. A pipeline of four colors in the five-color pass, which the device //! draws in groups, is refused `NotImplemented(ColorAttachmentGroups)`. +use super::framebuffer_fetch::fetches; use super::{layer_reported_nothing_at_all, validated_device_with, Messages, ScratchCache, WAIT}; use crate::air_library::AirLibrary; use crate::gpu::TEST_DEVICE; @@ -471,8 +472,12 @@ fn scenes(width: Width) { }); depth_scene(&lane, &five); load_scene(&lane, &five); - fetch_scene(&lane); - refusals(&lane, &five); + // A device without a fetch form refuses the fetching pipelines, typed ([`fetches`]). + let fetching = fetches(&lane.device); + if fetching { + fetch_scene(&lane); + } + refusals(&lane, &five, fetching); let announced: BTreeSet = (messages.take_notices().iter()) .filter_map(|message| message.degradation.as_ref()) .map(|notice| notice.degradation) @@ -731,8 +736,9 @@ fn fetch_scene(lane: &Lane) { }); } -/// What the restricted device refuses, and the device as it is draws (the module docs). -fn refusals(lane: &Lane, five: &[usize]) { +/// What the restricted device refuses, and the device as it is draws (the module docs); on a +/// device without a fetch form (not `fetching`), `cg_fetch` is refused there as `FramebufferFetch`. +fn refusals(lane: &Lane, five: &[usize], fetching: bool) { let name = lane.device.name().to_owned(); // The pipeline's limit refusal: its attachments reach index 4 on a device of four. let limit = Error::Unsupported(Unsupported::needs( @@ -774,7 +780,17 @@ fn refusals(lane: &Lane, five: &[usize]) { } Width::Device => { counts.unwrap(); - fetch.unwrap(); + match fetching { + true => { + fetch.unwrap(); + } + false => match fetch { + Err(Error::Unsupported(refusal)) + if refusal.feature == Feature::FramebufferFetch => {} + Err(error) => panic!("cg_fetch on {name} without a fetch form: {error}"), + Ok(_) => panic!("cg_fetch on {name}: made without a fetch form"), + }, + } } } } diff --git a/crates/metal2vulkan-validation/src/runtime_lane/extended_range_blends.rs b/crates/metal2vulkan-validation/src/runtime_lane/extended_range_blends.rs index 6aff792b7..40bc6cf49 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/extended_range_blends.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/extended_range_blends.rs @@ -402,6 +402,9 @@ fn first_texels(got: &[u8], size: usize) -> String { #[test] fn blends_of_half_outputs_into_extended_range_texels() { let (messages, _cache, lane) = lane(); + if !fetches(&lane.device) { + return; + } let name = lane.device.name().to_owned(); let halves = halves(); let read = kernel(&lane, "xr2p_read_float"); @@ -538,6 +541,9 @@ pub(super) const STORED_CODES: [Degradation; 1] = [Degradation::ExtendedRangeBle #[test] fn a_blend_onto_an_earlier_draw_announces_the_stored_codes_only_past_its_shadow() { let (messages, _cache, lane) = lane(); + if !fetches(&lane.device) { + return; + } let halves = halves(); let pf = PixelFormat::RGB10A82PXR10; let form = ExtendedRange::of(pf).expect("an extended-range format"); @@ -619,6 +625,9 @@ fn a_blend_onto_an_earlier_draw_announces_the_stored_codes_only_past_its_shadow( #[test] fn a_blend_onto_a_clear_between_two_codes_reads_the_clears_half() { let (messages, _cache, lane) = lane(); + if !fetches(&lane.device) { + return; + } let halves = halves(); let pf = PixelFormat::RGB10A82PXR10; let form = ExtendedRange::of(pf).expect("an extended-range format"); @@ -659,6 +668,9 @@ fn a_blend_onto_a_clear_between_two_codes_reads_the_clears_half() { #[test] fn a_blend_into_extended_range_announces_its_source_note() { let (messages, _cache, lane) = lane(); + if !fetches(&lane.device) { + return; + } let pf = PixelFormat::RGB10A82PXR10; let source = Degradation::ExtendedRangeBlendSource; let float_source = Degradation::ExtendedRangeFloatBlendSource;