observe: an attachment's sample count comes from the pipeline, and nothing said
when that disagreed with the texture Component: crates/reims-vgpu, runtime/draw/mod.rs. Pathway: x86 macOS / Linux Vulkan. Rail: macos-15. Observation only: no guest-visible behavior changes, so no conformance battery applies. Established first, on two live boots (s3 and h1, HEAD27a0dc1dande273bd4f, rail macos-15). With the skipped-draw tail corrected, the whole population that reaches it reads: chain_resident_land_fail reason=read_target target=Gva { gva: 54280192, width: 300, height: 300, generation: 227, format: B8G8R8A8_UNORM } err=vk_engine_target_read: reason=read_target_multisample_image linux_clear_store draws_skipped refused_by=engine_drew_store_lost_it pipe=1129 vtx=6 mid=0 gva=0x33c4000 300x300 load=0x2 store=0x1 clear=[0.947,0.913,0.847,1.000] The guest declares a 300x300 GVA target, MTLLoadActionClear with a warm off-white clear and MTLStoreActionStore. The engine draws it successfully. resident_read_snapshot then refuses the readback because the resident's sample_count is not 1, nothing is stored, runtime::exec::finish_stream applies the pass's clear, and a rendered tile reaches the guest as a flat colour. Twice per boot, on every boot measured, the second instance at clear=[0.024,0.026,0.028,1.000]. API contract. MTLRenderPipelineDescriptor.rasterSampleCount must equal the sample count of every colour attachment the pipeline renders into. Reading the count off the pipeline is therefore normally a restatement of what the destination texture already says. The seam. runtime/draw/mod.rs takes the attachment's sample count from the bound pipeline and lets it *override* the destination texture's own: let attachment_sample_count = pipeline_sample_count.unwrap_or(target_sample_count); When the two agree that is a restatement. When they disagree it is not: the destination is single-sample and this device has promoted it to a multisample attachment on the pipeline's word, with no record that it did. The engine then creates the resident at the promoted count and the readback refusal above follows -- so the promotion's cost is paid three layers away from the promotion, and nothing connected them. Behavior changed. None. The disagreement is now named, split by whether the samples have anywhere to go, because the halves have different owners: attach_samples_from_pipeline_with_resolve a resolve texture is declared attach_samples_promoted_no_resolve promoted with nowhere to resolve attach_samples_demoted the opposite disagreement plus a per-(pipeline, texture) latched line carrying both counts, the resolve ref, the load and store actions, the geometry and the destination. Agreement, and a pipeline that could not be resolved, stay silent -- a census firing on every attachment of every draw would cost a store route per attachment per draw and could not be read. This exists to answer exactly one question before any repair is designed: did the guest declare the multisample, or did this device invent it? A record with target 1, pipeline greater, and no resolve_texture_ref is the second -- a promotion with nowhere for the samples to go, which is not a shape Metal can express and which this device should refuse rather than silently lose. Focused test. an_attachment_sample_count_taken_from_the_pipeline_names_where_the_samples_go asserts silence on agreement and on an unresolvable pipeline, and holds the three disagreement arms apart from each other. Delta form, because the census map is process-global. Verification run. cargo fmt --all and --check clean. All three clippy arms at -D warnings, each invoked separately: aarch64-apple-darwin/backend-metal, host backend-vulkan,host-window, and x86_64-unknown-linux-gnu backend-vulkan,host-window. Serial suite 2391 passed, 0 failed. Not verified. No boot has read these counters, so which of the three arms the 300x300 case falls in is still unknown -- that is the question this commit exists to ask, not one it answers. No repair is proposed here. Also recorded, and unresolved: boot h1 ended in a guest kernel panic -- "corrupt list around element ... at _pmap_enter_options", in UserNotificationCenter under vm_fault_enter, a memory-corruption signature. Preserved in journal/panic-2026-08-30-h1/. HEAD was27a0dc1dwith a clean tree and every commit at that point was observation-only, so no guest-visible behavior change was active; the device log shows duty=0.001 with no submissions and no typed failure near it. Causality is unknown and is not claimed either way. It has not been reproduced and no baseline was run against it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
69602dd5b5
commit
8aee8882ee
2 files changed
+181
No files matched your search
@@ -3047,6 +3047,97 @@ pub fn load_composite_premult_one_omsa(draw_rgba: &[u8], seed_rgba: &[u8]) -> (V
|
||||
feature = "backend-vulkan",
|
||||
all(feature = "backend-metal", target_os = "macos")
|
||||
))]
|
||||
/// The three sample counts in play when a colour attachment is resolved, named
|
||||
/// so the record below cannot transpose two of them.
|
||||
#[cfg(feature = "backend-vulkan")]
|
||||
pub(crate) struct AttachmentSampleCounts {
|
||||
/// `MTLRenderPipelineDescriptor.rasterSampleCount` of the bound pipeline,
|
||||
/// or `None` when the pipeline could not be resolved.
|
||||
pub pipeline: Option<u32>,
|
||||
/// The destination texture's own immutable creation sample count.
|
||||
pub target: u32,
|
||||
/// What this device gave the attachment. Today: the pipeline's, when it has
|
||||
/// one.
|
||||
pub resolved: u32,
|
||||
}
|
||||
|
||||
/// Report a colour attachment whose sample count this device took from the
|
||||
/// **pipeline** while the destination texture declared a different one.
|
||||
///
|
||||
/// # Why this needs a record
|
||||
///
|
||||
/// Metal requires a pipeline's `rasterSampleCount` to equal the sample count of
|
||||
/// every colour attachment it renders into, so reading the count off the
|
||||
/// pipeline is normally a restatement of what the texture already says. When
|
||||
/// the two disagree, it is not: the destination is single-sample and this
|
||||
/// device has promoted it to a multisample attachment on the pipeline's word.
|
||||
///
|
||||
/// That promotion has a downstream cost the promotion site cannot see. The
|
||||
/// engine creates the resident at the promoted count, the draw succeeds, and
|
||||
/// then `resident_read_snapshot` refuses to read a `sample_count != 1` resident
|
||||
/// back — so nothing is stored, `runtime::exec::finish_stream` applies the
|
||||
/// pass's clear, and a rendered tile reaches the guest as a flat colour. On
|
||||
/// this rail that is measured at twice per boot on 300x300 targets, and until
|
||||
/// the skipped-draw tail was corrected it was reported as an engine refusal
|
||||
/// that never happened.
|
||||
///
|
||||
/// So the question this record exists to answer is exactly one: **did the guest
|
||||
/// declare the multisample, or did this device invent it?** A record where
|
||||
/// `target` is 1 and `pipeline` is greater, with no `resolve_texture_ref`, is
|
||||
/// the second — a promotion with nowhere to resolve to, which is not a shape
|
||||
/// Metal can express and which this device should refuse rather than lose.
|
||||
///
|
||||
/// Latched per `(pipeline, texture)`: a guest that means this means it every
|
||||
/// frame, and the population's size belongs to a counter, not to this line.
|
||||
/// The counter is beside it and is not conditioned on first sight.
|
||||
#[cfg(feature = "backend-vulkan")]
|
||||
pub(crate) fn note_attachment_sample_count_override(
|
||||
pipeline_ref: u32,
|
||||
att: ColorAttachment,
|
||||
counts: AttachmentSampleCounts,
|
||||
geom: (u32, u32),
|
||||
dest: (u32, u64),
|
||||
) {
|
||||
let Some(pipeline) = counts.pipeline else {
|
||||
return;
|
||||
};
|
||||
if pipeline == counts.target {
|
||||
return;
|
||||
}
|
||||
// Split at the emitter, because the two halves have different owners. A
|
||||
// promotion with a resolve texture declared is a shape this device can
|
||||
// still land; one without has nowhere for the samples to go.
|
||||
crate::runtime::drain::note_store_route(if att.resolve_texture_ref != 0 {
|
||||
"attach_samples_from_pipeline_with_resolve"
|
||||
} else if pipeline > counts.target {
|
||||
"attach_samples_promoted_no_resolve"
|
||||
} else {
|
||||
"attach_samples_demoted"
|
||||
});
|
||||
if crate::observe::first_sight(
|
||||
"attachment_sample_count_override",
|
||||
(u64::from(pipeline_ref) << 32) | u64::from(att.texture_ref),
|
||||
) {
|
||||
crate::observe::off(format!(
|
||||
"attachment_sample_count_override pipe={pipeline_ref} tex_ref={} \
|
||||
resolve_ref={} pipeline_samples={pipeline} target_samples={} \
|
||||
resolved_samples={} load={:#x} store={:#x} {}x{} mid={} gva={:#x} \
|
||||
(Metal requires these to agree; a promotion with no resolve \
|
||||
texture has nowhere to put the samples)",
|
||||
att.texture_ref,
|
||||
att.resolve_texture_ref,
|
||||
counts.target,
|
||||
counts.resolved,
|
||||
att.load_action,
|
||||
att.store_action,
|
||||
geom.0,
|
||||
geom.1,
|
||||
dest.0,
|
||||
dest.1,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn load_action_in_contract(pipeline_ref: u32, load_action: u16) -> bool {
|
||||
if is_declared_load_action(load_action) {
|
||||
return true;
|
||||
@@ -4786,6 +4877,18 @@ pub fn mrt_draw_request<M: HostMemory + HostOps>(
|
||||
let attachment_sample_count = pipeline_sample_count.unwrap_or(target_sample_count);
|
||||
#[cfg(not(feature = "backend-vulkan"))]
|
||||
let attachment_sample_count = target_sample_count;
|
||||
#[cfg(feature = "backend-vulkan")]
|
||||
note_attachment_sample_count_override(
|
||||
pipeline_ref,
|
||||
att,
|
||||
AttachmentSampleCounts {
|
||||
pipeline: pipeline_sample_count,
|
||||
target: target_sample_count,
|
||||
resolved: attachment_sample_count,
|
||||
},
|
||||
(mw, mh),
|
||||
(mapping_id, gva),
|
||||
);
|
||||
if base_w == 0 {
|
||||
base_w = mw;
|
||||
base_h = mh;
|
||||
|
||||
@@ -7463,3 +7463,81 @@ fn a_dontcare_colour_attachment_is_still_served_its_prior_contents() {
|
||||
"an explicit provenance seed still excludes the resident candidate"
|
||||
);
|
||||
}
|
||||
|
||||
/// A colour attachment whose sample count came from the pipeline rather than
|
||||
/// from the destination texture is split by whether the samples have anywhere
|
||||
/// to go.
|
||||
///
|
||||
/// Metal requires a pipeline's `rasterSampleCount` to equal the sample count of
|
||||
/// every colour attachment it renders into, so the two agreeing is the normal
|
||||
/// case and carries no record — asserted here as the first arm, because a
|
||||
/// census that fired on every draw would be unreadable and would cost a store
|
||||
/// route per attachment per draw.
|
||||
///
|
||||
/// The three arms that remain are kept apart because they have different
|
||||
/// owners. A promotion **with** a resolve texture is a shape this device can
|
||||
/// still land. A promotion **without** one has nowhere to put the samples: the
|
||||
/// engine creates the resident multisampled, the draw succeeds, and
|
||||
/// `resident_read_snapshot` then refuses to read a `sample_count != 1` resident
|
||||
/// back, so the rendered tile reaches the guest as the pass's flat clear. A
|
||||
/// demotion is the opposite disagreement and is neither.
|
||||
///
|
||||
/// Delta form, because the census map is process-global and the rest of the
|
||||
/// suite shares it.
|
||||
#[cfg(feature = "backend-vulkan")]
|
||||
#[test]
|
||||
fn an_attachment_sample_count_taken_from_the_pipeline_names_where_the_samples_go() {
|
||||
use crate::runtime::decode::render::ColorAttachment;
|
||||
use crate::runtime::drain::store_route_count;
|
||||
use crate::runtime::draw::{note_attachment_sample_count_override, AttachmentSampleCounts};
|
||||
|
||||
const PROMOTED: &str = "attach_samples_promoted_no_resolve";
|
||||
const WITH_RESOLVE: &str = "attach_samples_from_pipeline_with_resolve";
|
||||
const DEMOTED: &str = "attach_samples_demoted";
|
||||
|
||||
let before = (
|
||||
store_route_count(PROMOTED),
|
||||
store_route_count(WITH_RESOLVE),
|
||||
store_route_count(DEMOTED),
|
||||
);
|
||||
let att = |resolve_ref: u32| ColorAttachment {
|
||||
texture_ref: 7,
|
||||
resolve_texture_ref: resolve_ref,
|
||||
..Default::default()
|
||||
};
|
||||
let counts_of = |pipeline: Option<u32>, target: u32| AttachmentSampleCounts {
|
||||
pipeline,
|
||||
target,
|
||||
resolved: pipeline.unwrap_or(target),
|
||||
};
|
||||
|
||||
// Agreement, and an unresolvable pipeline, are both silent.
|
||||
note_attachment_sample_count_override(11, att(0), counts_of(Some(4), 4), (300, 300), (0, 0));
|
||||
note_attachment_sample_count_override(12, att(0), counts_of(None, 1), (300, 300), (0, 0));
|
||||
assert_eq!(
|
||||
(
|
||||
store_route_count(PROMOTED),
|
||||
store_route_count(WITH_RESOLVE),
|
||||
store_route_count(DEMOTED),
|
||||
),
|
||||
before,
|
||||
"a pipeline that agrees with its attachment, and one that could not be \
|
||||
resolved at all, are not disagreements"
|
||||
);
|
||||
|
||||
// Promotion with nowhere to resolve to: the defect shape.
|
||||
note_attachment_sample_count_override(13, att(0), counts_of(Some(4), 1), (300, 300), (0, 0));
|
||||
assert_eq!(store_route_count(PROMOTED), before.0 + 1);
|
||||
assert_eq!(store_route_count(WITH_RESOLVE), before.1);
|
||||
assert_eq!(store_route_count(DEMOTED), before.2);
|
||||
|
||||
// Promotion with a declared resolve texture is a different owner.
|
||||
note_attachment_sample_count_override(14, att(9), counts_of(Some(4), 1), (300, 300), (0, 0));
|
||||
assert_eq!(store_route_count(PROMOTED), before.0 + 1);
|
||||
assert_eq!(store_route_count(WITH_RESOLVE), before.1 + 1);
|
||||
|
||||
// And the opposite disagreement is neither of those.
|
||||
note_attachment_sample_count_override(15, att(0), counts_of(Some(1), 4), (300, 300), (0, 0));
|
||||
assert_eq!(store_route_count(DEMOTED), before.2 + 1);
|
||||
assert_eq!(store_route_count(PROMOTED), before.0 + 1);
|
||||
}
|
||||
Reference in new issue
Block a user