observe: size the safe half of the lost-texel population, and correct what the
sample-count record claims
Component: crates/reims-vgpu, runtime/draw/{mod.rs,vulkan.rs}.
Pathway: x86 macOS / Linux Vulkan. Rail: macos-15.
Observation only: no guest-visible behavior changes, so no conformance
battery applies.
Boot s4 (HEAD 8aee8882, tree clean, host WHITE/233.478, dock-sweep repair
PAINTED/123.342) read the two censuses added above:
draw_partial_preserving_from_target 32 423
draw_partial_preserving_seeded 69
draw_partial_preserving_unseeded 575
draw_partial_preserving_unseeded_lost_texels 2 884 701
attach_samples_multisample_no_resolve 2
2.9 million texels a boot are overwritten with [0.0; 4] on attachments whose
declared load action promised to keep them. That is the dominant loss by
three orders of magnitude over the multisample thread beside it.
Correction, and it retires a claim this session made two commits ago.
`ResolvedRenderTarget::sample_count` is a hardcoded provisional `1` at every
one of its construction sites -- a linear texture resource's dimensions do
not retain the creation descriptor's sample count, and the field's own
documentation says the Vulkan encode is expected to replace it with the
pipeline's. So `pipeline != target` was never evidence that the guest's
texture is single-sample, and "did this device invent the multisample?" was
not a question that record could answer. It cannot see the texture's
declaration at all.
What boot s4 does establish about that thread: exactly two such passes in a
whole boot, both `pipeline_samples=4 resolve_ref=0 store=0x1` on 300x300
linear GVA targets, and they are the same two the corrected skipped-draw
tail reports as engine_drew_store_lost_it. Two out of a boot's several
hundred pipelines is also what says raster_sample_count is decoded correctly
rather than misread -- it comes from a TLV tag, and a misread tag would not
be that rare. So the guest really does run a 4x pass, and the open question
is now what it expects to find in those guest pages afterwards: Metal writes
nothing to a linear buffer for a multisample MTLStoreActionStore, and this
device writes the pass's clear colour there. Nothing establishes which the
guest reads, so no repair there is supportable yet. The route names are
corrected accordingly -- `attach_samples_multisample_no_resolve` and
`attach_samples_below_provisional` replace the "promoted"/"demoted" pair,
which asserted a comparison that was not being made.
Behavior changed. None. The lost-texel population is split by whether the
target has guest-visible backing, because that is the line between a repair
that is safe and one that is not:
draw_partial_preserving_unseeded_guest_backed a type-11 mapping or task GVA
draw_partial_preserving_unseeded_resident_only neither
The prior contents these passes needed are on the engine resident. Loading
them back is only unambiguous when nothing outside this device can have
changed the surface since the resident was published, and the one writer
this device cannot see is the guest's own CPU writing the surface's pages.
A target with guest backing has such pages, and reusing its resident without
the currency query is the documented fixpoint where "renders correctly for a
few frames then stays corrupted" comes from. A target with neither has no
guest pages, hence no guest-side writer, and its resident is the only place
its prior contents exist -- authoritative by construction, with nothing to
reconcile. Sizing that subset is the precondition for repairing it.
Focused tests. a_dontcare_partial_draw_is_priced_by_the_area_it_destroyed
now also asserts the two halves are counted apart.
an_attachment_sample_count_taken_from_the_pipeline_names_where_the_samples_go
is updated to the corrected reading and still holds its arms apart.
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 the guest-backed/resident-only split, so the
size of the safe subset is still unknown -- that is what this commit exists
to ask. Boot s4's menu-close probe ran and reported CLEAN; the web-content
probe again exited 2 on its own setup gate, so symptom 2 still has no
witness. No boot since h1 has panicked, but that is two boots and does not
speak to the panic's rate.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
8aee8882ee
commit
f0933a82cc
3 files changed
+148
-40
No files matched your search
@@ -3054,7 +3054,18 @@ 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.
|
||||
/// What [`super::render_target::ResolvedRenderTarget`] carried.
|
||||
///
|
||||
/// **Not the texture's creation sample count**, and reading it as one is a
|
||||
/// mistake this record has already caused once. That field is a hardcoded
|
||||
/// `1` at every one of its construction sites, because a linear texture
|
||||
/// resource's dimensions do not retain the creation descriptor's sample
|
||||
/// count — the field's own documentation says so, and says the Vulkan
|
||||
/// encode is expected to replace the provisional value with the pipeline's.
|
||||
///
|
||||
/// So `pipeline != target` is *not* evidence that the guest's texture is
|
||||
/// single-sample. It is only evidence that the pipeline declared more than
|
||||
/// one sample, which is the case worth naming here for the reason below.
|
||||
pub target: u32,
|
||||
/// What this device gave the attachment. Today: the pipeline's, when it has
|
||||
/// one.
|
||||
@@ -3067,12 +3078,14 @@ pub(crate) struct AttachmentSampleCounts {
|
||||
/// # 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.
|
||||
/// every colour attachment it renders into, and this device recovers that count
|
||||
/// from the pipeline because the resolved target cannot carry it (see
|
||||
/// [`AttachmentSampleCounts::target`]). So this record does not report a
|
||||
/// disagreement between the guest's two declarations — it cannot see the
|
||||
/// texture's declaration at all. What it reports is the passes that end up
|
||||
/// multisampled, and where their samples are meant to go.
|
||||
///
|
||||
/// That promotion has a downstream cost the promotion site cannot see. The
|
||||
/// That matters because it has a downstream cost the 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
|
||||
@@ -3081,11 +3094,20 @@ pub(crate) struct AttachmentSampleCounts {
|
||||
/// 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.
|
||||
/// Measured on rail macos-15, boot s4: **two** records in a whole boot, both
|
||||
/// `pipeline_samples=4 resolve_ref=0 store=0x1` on 300x300 linear GVA targets,
|
||||
/// and they are the same two passes the corrected skipped-draw tail reports as
|
||||
/// `engine_drew_store_lost_it`. Two out of a boot's several hundred pipelines
|
||||
/// is also what says the pipeline's count is decoded correctly rather than
|
||||
/// misread: `raster_sample_count` comes from a TLV tag, and a misread tag would
|
||||
/// not be this rare.
|
||||
///
|
||||
/// So the guest really does run a 4x pass here, and the open question is no
|
||||
/// longer "who invented the multisample" — it is **what the guest expects to
|
||||
/// find in those guest pages afterwards**. Metal writes nothing to a linear
|
||||
/// buffer for a multisample `MTLStoreActionStore`; this device writes the
|
||||
/// pass's clear colour there. Neither this record nor any other establishes
|
||||
/// which the guest reads, and until one does, no repair here is supportable.
|
||||
///
|
||||
/// 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.
|
||||
@@ -3110,9 +3132,9 @@ pub(crate) fn note_attachment_sample_count_override(
|
||||
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"
|
||||
"attach_samples_multisample_no_resolve"
|
||||
} else {
|
||||
"attach_samples_demoted"
|
||||
"attach_samples_below_provisional"
|
||||
});
|
||||
if crate::observe::first_sight(
|
||||
"attachment_sample_count_override",
|
||||
|
||||
@@ -7464,23 +7464,28 @@ fn a_dontcare_colour_attachment_is_still_served_its_prior_contents() {
|
||||
);
|
||||
}
|
||||
|
||||
/// 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.
|
||||
/// A pass that ends up multisampled is named, and split by where its samples
|
||||
/// are meant 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 count comes from the pipeline because the resolved target cannot carry
|
||||
/// it — `ResolvedRenderTarget::sample_count` is a hardcoded provisional `1` at
|
||||
/// every construction site, since a linear texture resource's dimensions do not
|
||||
/// retain the creation descriptor's sample count. So this census does not
|
||||
/// compare two guest declarations; it reports the passes whose pipeline
|
||||
/// declared more than one sample, which is the rare case and the costly one.
|
||||
///
|
||||
/// 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
|
||||
/// A pipeline that matches the provisional value is the overwhelming majority
|
||||
/// and carries no record — asserted here as the first arm, because a census
|
||||
/// firing on every attachment of every draw would cost a store route per
|
||||
/// attachment per draw and could not be read.
|
||||
///
|
||||
/// The three remaining arms are kept apart because they have different owners.
|
||||
/// Multisample **with** a resolve texture is a shape this device can land.
|
||||
/// Multisample **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.
|
||||
/// pipeline below the provisional value is neither, and should not exist.
|
||||
///
|
||||
/// Delta form, because the census map is process-global and the rest of the
|
||||
/// suite shares it.
|
||||
@@ -7491,14 +7496,14 @@ fn an_attachment_sample_count_taken_from_the_pipeline_names_where_the_samples_go
|
||||
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 NO_RESOLVE: &str = "attach_samples_multisample_no_resolve";
|
||||
const WITH_RESOLVE: &str = "attach_samples_from_pipeline_with_resolve";
|
||||
const DEMOTED: &str = "attach_samples_demoted";
|
||||
const BELOW: &str = "attach_samples_below_provisional";
|
||||
|
||||
let before = (
|
||||
store_route_count(PROMOTED),
|
||||
store_route_count(NO_RESOLVE),
|
||||
store_route_count(WITH_RESOLVE),
|
||||
store_route_count(DEMOTED),
|
||||
store_route_count(BELOW),
|
||||
);
|
||||
let att = |resolve_ref: u32| ColorAttachment {
|
||||
texture_ref: 7,
|
||||
@@ -7516,28 +7521,28 @@ fn an_attachment_sample_count_taken_from_the_pipeline_names_where_the_samples_go
|
||||
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(NO_RESOLVE),
|
||||
store_route_count(WITH_RESOLVE),
|
||||
store_route_count(DEMOTED),
|
||||
store_route_count(BELOW),
|
||||
),
|
||||
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.
|
||||
// Multisample with nowhere to resolve to: the shape that loses the tile.
|
||||
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(NO_RESOLVE), before.0 + 1);
|
||||
assert_eq!(store_route_count(WITH_RESOLVE), before.1);
|
||||
assert_eq!(store_route_count(DEMOTED), before.2);
|
||||
assert_eq!(store_route_count(BELOW), before.2);
|
||||
|
||||
// Promotion with a declared resolve texture is a different owner.
|
||||
// Multisample 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(NO_RESOLVE), before.0 + 1);
|
||||
assert_eq!(store_route_count(WITH_RESOLVE), before.1 + 1);
|
||||
|
||||
// And the opposite disagreement is neither of those.
|
||||
// And a pipeline below the provisional value 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);
|
||||
assert_eq!(store_route_count(BELOW), before.2 + 1);
|
||||
assert_eq!(store_route_count(NO_RESOLVE), before.0 + 1);
|
||||
}
|
||||
@@ -5699,6 +5699,7 @@ fn note_draw_coverage(
|
||||
load_action: Option<u16>,
|
||||
seeded: bool,
|
||||
from_target: bool,
|
||||
guest_backed: bool,
|
||||
) {
|
||||
let covers = scissor.covers(target_w, target_h);
|
||||
crate::runtime::drain::note_store_route(if covers {
|
||||
@@ -5793,6 +5794,29 @@ fn note_draw_coverage(
|
||||
"draw_partial_preserving_unseeded_lost_texels",
|
||||
target.saturating_sub(covered),
|
||||
);
|
||||
// And split by whether the target has guest-visible backing,
|
||||
// because that is exactly the line between a repair that is safe
|
||||
// and one that is not.
|
||||
//
|
||||
// The prior contents this pass needed are on the engine resident.
|
||||
// Loading them back is only unambiguous when nothing outside this
|
||||
// device can have changed the surface since the resident was
|
||||
// published — and the one writer this device cannot see is the
|
||||
// guest's own CPU writing the surface's pages. A target with a
|
||||
// type-11 mapping or a task GVA has such pages, and reusing its
|
||||
// resident without the currency query is the documented fixpoint
|
||||
// where "renders correctly for a few frames then stays corrupted"
|
||||
// comes from.
|
||||
//
|
||||
// A target with neither has no guest pages at all, so it has no
|
||||
// guest-side writer, and its resident is the *only* place its prior
|
||||
// contents exist. For that subset the resident is authoritative by
|
||||
// construction and there is nothing to reconcile.
|
||||
crate::runtime::drain::note_store_route(if guest_backed {
|
||||
"draw_partial_preserving_unseeded_guest_backed"
|
||||
} else {
|
||||
"draw_partial_preserving_unseeded_resident_only"
|
||||
});
|
||||
}
|
||||
}
|
||||
// How much of the surface this draw's scissor actually covers.
|
||||
@@ -8453,6 +8477,13 @@ fn try_metal2vulkan_draw<M: HostMemory + HostOps>(
|
||||
req.colors.first().map(|c| c.load_action),
|
||||
target_rgba8.is_some() || target_guest_seed.is_some(),
|
||||
chain_load_from_target,
|
||||
// Guest-visible backing is a type-11 mapping or a task GVA, and
|
||||
// the two are exclusive — `ColorRtRequest::target_gva` documents
|
||||
// that. Either one means the surface has pages the guest's own
|
||||
// CPU can write without this device seeing it.
|
||||
req.colors
|
||||
.first()
|
||||
.is_some_and(|c| c.mapping_id != 0 || c.target_gva != 0),
|
||||
);
|
||||
}
|
||||
// The mode is the guest's raw `MTLVisibilityResultMode`; the engine
|
||||
@@ -10751,6 +10782,7 @@ mod vulkan_split_tests {
|
||||
Some(super::MTL_LOAD_ACTION_DONT_CARE),
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
);
|
||||
assert_eq!(
|
||||
store_route_count(LOST),
|
||||
@@ -10768,6 +10800,7 @@ mod vulkan_split_tests {
|
||||
Some(super::MTL_LOAD_ACTION_DONT_CARE),
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
);
|
||||
note_draw_coverage(
|
||||
scissor,
|
||||
@@ -10776,6 +10809,7 @@ mod vulkan_split_tests {
|
||||
Some(super::MTL_LOAD_ACTION_LOAD),
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
);
|
||||
assert_eq!(
|
||||
store_route_count(LOST),
|
||||
@@ -10791,12 +10825,51 @@ mod vulkan_split_tests {
|
||||
Some(super::MTL_LOAD_ACTION_CLEAR),
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
);
|
||||
assert_eq!(
|
||||
store_route_count(LOST),
|
||||
held,
|
||||
"a Clear got the destruction it asked for and is not a loss"
|
||||
);
|
||||
|
||||
// The loss is also split by whether the target has guest-visible
|
||||
// backing, and that split is the line between a repair that is safe and
|
||||
// one that is not: a target with no guest pages has no guest-side
|
||||
// writer, so its resident is the only place its prior contents exist
|
||||
// and is authoritative by construction. One with pages needs the
|
||||
// currency query, and reusing its resident without one is the
|
||||
// documented "corrupts and stays corrupted" fixpoint.
|
||||
const BACKED: &str = "draw_partial_preserving_unseeded_guest_backed";
|
||||
const RESIDENT: &str = "draw_partial_preserving_unseeded_resident_only";
|
||||
let (b0, r0) = (store_route_count(BACKED), store_route_count(RESIDENT));
|
||||
note_draw_coverage(
|
||||
scissor,
|
||||
100,
|
||||
100,
|
||||
Some(super::MTL_LOAD_ACTION_DONT_CARE),
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
);
|
||||
assert_eq!(store_route_count(BACKED), b0 + 1);
|
||||
assert_eq!(store_route_count(RESIDENT), r0);
|
||||
note_draw_coverage(
|
||||
scissor,
|
||||
100,
|
||||
100,
|
||||
Some(super::MTL_LOAD_ACTION_DONT_CARE),
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
);
|
||||
assert_eq!(store_route_count(BACKED), b0 + 1);
|
||||
assert_eq!(
|
||||
store_route_count(RESIDENT),
|
||||
r0 + 1,
|
||||
"the two halves of the loss are counted apart, so the safe subset \
|
||||
can be sized before it is repaired"
|
||||
);
|
||||
}
|
||||
|
||||
/// A draw the engine made and a draw the engine refused do not report the
|
||||
@@ -11072,6 +11145,7 @@ mod vulkan_split_tests {
|
||||
None,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
);
|
||||
note_draw_coverage(
|
||||
ScissorRect {
|
||||
@@ -11085,6 +11159,7 @@ mod vulkan_split_tests {
|
||||
None,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
);
|
||||
note_pass_scissor_union(1000, 1000);
|
||||
assert_eq!(
|
||||
@@ -11107,6 +11182,7 @@ mod vulkan_split_tests {
|
||||
None,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
);
|
||||
note_pass_scissor_union(1000, 1000);
|
||||
assert_eq!(
|
||||
@@ -11130,6 +11206,7 @@ mod vulkan_split_tests {
|
||||
None,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
);
|
||||
note_draw_coverage(
|
||||
ScissorRect {
|
||||
@@ -11143,6 +11220,7 @@ mod vulkan_split_tests {
|
||||
None,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
);
|
||||
note_pass_scissor_union(1000, 1000);
|
||||
assert_eq!(
|
||||
@@ -11192,6 +11270,7 @@ mod vulkan_split_tests {
|
||||
None,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
);
|
||||
assert_eq!(
|
||||
store_route_count(slug),
|
||||
@@ -11215,6 +11294,7 @@ mod vulkan_split_tests {
|
||||
None,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
);
|
||||
assert_eq!(
|
||||
store_route_count("draw_scissor_area_gt50"),
|
||||
@@ -11235,6 +11315,7 @@ mod vulkan_split_tests {
|
||||
None,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user