diff --git a/crates/metal2vulkan/src/pipeline/link.rs b/crates/metal2vulkan/src/pipeline/link.rs index fda198bba..ecf5b0a34 100644 --- a/crates/metal2vulkan/src/pipeline/link.rs +++ b/crates/metal2vulkan/src/pipeline/link.rs @@ -80,6 +80,7 @@ use crate::pipeline::descriptor::{ ColorAttachmentDescriptor, MeshPipelineDescriptor, RenderPipelineDescriptor, TessellationDescriptor, VertexDescriptor, }; +use crate::pipeline::facts::RuntimeFact; use crate::pipeline::graphics::GraphicsState; use crate::pipeline::interface::{PipelineInterface, StageDescriptor, StageInterface}; use crate::pipeline::layout::{ @@ -581,11 +582,20 @@ fn render_state( // The extended-range blends the fragment computes over input attachments, against this // pipeline's attachments. let input_blends = fetch::input_blends(r, fragment, p)?; + // Those of them held with their channels rotated, whose input attachments link admits for + // that blend alone. + let rotated_inputs: BTreeSet = (fragment.into_iter().flat_map(|f| &f.facts)) + .filter_map(|fact| match *fact { + RuntimeFact::RotatedInputBlend { color, .. } => Some(color), + _ => None, + }) + .collect(); // The word merges the fragment computes over input attachments, against this pipeline's // write masks. fetch::word_merges(r, fragment, p)?; let fs = fragment.map(|f| &f.interface); - let mut gs = graphics::graphics_state(r, (geometry, fs), vi, ts, &input_blends, p)?; + let blends = (&input_blends, &rotated_inputs); + let mut gs = graphics::graphics_state(r, (geometry, fs), vi, ts, blends, p)?; // The color writes the fragment rounds against this pipeline's attachments, once the // descriptor's checks of its outputs passed. crate::pipeline::color_writes::check( diff --git a/crates/metal2vulkan/src/pipeline/link/graphics.rs b/crates/metal2vulkan/src/pipeline/link/graphics.rs index 6785031d8..204869aea 100644 --- a/crates/metal2vulkan/src/pipeline/link/graphics.rs +++ b/crates/metal2vulkan/src/pipeline/link/graphics.rs @@ -198,7 +198,6 @@ use crate::metal::state::{ use crate::metal::PrimitiveTopologyClass; use crate::pipeline::artifact::PrecisionNote; use crate::pipeline::color_writes; -use crate::pipeline::facts::RuntimeFact; use crate::pipeline::graphics::{ ColorAttachmentState, GraphicsState, InputAttachmentUse, TessellationState, }; @@ -296,13 +295,15 @@ fn vertex_amplification(r: &RenderLinkInputs, mesh: bool, p: &DeviceProfile) -> /// input `vi`, and, for a tessellation pipeline, its tessellation state `tessellation`: its /// topology is `PATCH_LIST` and never dynamic state, as its draws draw patches only. /// `input_blends`: the extended-range attachments whose blend the fragment function computes over -/// their input attachments, and the channels each write keeps (`link::fetch::input_blends`). +/// their input attachments, and the channels each write keeps (`link::fetch::input_blends`); +/// `rotated_inputs`: those of them held with their channels rotated, whose blend the function +/// states as `RuntimeFact::RotatedInputBlend`. pub fn graphics_state( r: &RenderLinkInputs, (vs, fs): (&StageInterface, Option<&StageInterface>), vi: &VertexInputState, tessellation: Option, - input_blends: &BTreeMap, + (input_blends, rotated_inputs): (&BTreeMap, &BTreeSet), p: &DeviceProfile, ) -> Result { if r.alpha_to_one && !p.fields().enabled.features.contains(&VkFeature::AlphaToOne) { @@ -602,12 +603,8 @@ pub fn graphics_state( // `StageIo::alpha_in_red_colors`, which `color_writes::check` holds to the pipeline's.) // Nor is a two-plane YCbCr attachment's, whose texels Metal holds as halves and the // attachment as the function's floats. - let rotated_blend = fs.is_some_and(|f| { - f.facts.iter().any(|fact| { - matches!(*fact, RuntimeFact::RotatedInputBlend { color: c, .. } if c == color) - }) - }); - if (metal::format::rotated_channels(attachment.pixel_format) && !rotated_blend) + if (metal::format::rotated_channels(attachment.pixel_format) + && !rotated_inputs.contains(&color)) || metal::format::ycbcr_renders(attachment.pixel_format) || metal::format::ycbcr_pass_refused(attachment.pixel_format) {