Pass the rotated input blends' colors into graphics_state, which reads no facts

5cf7146404 read f.facts at pipeline/link/graphics.rs, where fs is the
fragment's StageInterface, which has no facts (E0609): the facts live on
the FunctionArtifact. development's metal2vulkan lib and lib test did
not compile (m3-max-4430, m3-max-4462).

link.rs now collects the colors whose blend the fragment states as
RuntimeFact::RotatedInputBlend, beside fetch::input_blends, from the
FunctionArtifact it already holds, and graphics_state takes them with
input_blends; the input attachment check admits a rotated attachment's
input attachment where that set names its color, as 5cf7146404 meant.

(cherry picked from commit f987bdc54be459b8303e87bc7ac9fbd9fed1de39)
This commit is contained in:
Anees Iqbal committed 2026-11-07 10:14:12 -08:00
1 parent aa27cddc00
commit 284fdf5f92
2 files changed
+17 -10

No files matched your search

+11 -1
View File
@@ -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<u32> = (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(
@@ -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<TessellationState>,
input_blends: &BTreeMap<u32, vk::ColorComponentFlags>,
(input_blends, rotated_inputs): (&BTreeMap<u32, vk::ColorComponentFlags>, &BTreeSet<u32>),
p: &DeviceProfile,
) -> Result<GraphicsState, Error> {
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)
{