Fetch between draws: the barrier on every driver, and the executor's barriers

On the M3 (MoltenVK 1.4.2) the runtime lane's
fetches_between_draws_read_every_earlier_draw_and_note_the_draw_itself
counted 3 fetch barriers for 4 draws. The cause: the race split
(DriverFact::InterlockedDrawsRaceUnderLoad, held by MoltenVK on Apple's
GPUs) tested InterlockedStorage::meets, which since the between-draws form
includes the fetch kinds. So on the M3's withheld venue each draw after
the first went into a new render pass instance (Split::InterlockedWrites)
instead of after the barrier. The white write took no barrier at all, and
each later fetch took the split plus the new instance's BEGUN barrier.
That ordered the draws twice.

The race is the interlock's. The fact's measure is of interlocked storage
images, which MoltenVK encodes as raster order group 0 with no barrier
inside its Metal render pass. Input attachments ordered between draws are
not interlocked, and their barrier is by region with INPUT_ATTACHMENT_READ
in its destination. MoltenVK's MVKCmdPipelineBarrier::encode (v1.4.2, on a
tile-based GPU) ends its Metal render pass and begins another for exactly
that barrier. The split now tests only the interlocked kinds
(InterlockedStorage::meets_interlocked). The fetch kinds take the Whole
barrier on every driver: one barrier per draw, as on lavapipe and the
RX 550. The lane test now asserts (barriers, interlocked splits) = (4, 0),
(3, 0) and (1, 0). Without the fix the M3 gives (3, 3) in the first section.

The second fallout is the validation executor's planner test
a_framebuffer_fetch_case_plans_its_ordered_input_attachment. It expected a
device with neither ordered form to refuse the fetch, which the product no
longer does. The executor is a consumer of that contract
(GraphicsState::rasterization_order_attachment_access): a pipeline with
input attachments and no rasterization-order access must be ordered between
draws by a barrier of the subpass's dependency on itself.
- The executor's render pass self-dependency now covers both directions:
  color writes to input attachment and color reads, and fragment-shader
  reads to color writes (FETCH_SELF_DEPENDENCY).
- It records that barrier before each of its draws where
  fetches_between_draws holds, after the load operations too, as the
  runtime does.
- The planner tests now plan the neither device: input attachment 0, no
  rasterization-order access, neither ordered feature required, the note
  on the fragment stage. Every public fetch case on lunarg-2023 and
  vk12-floor plans the same way; a multisampled one may be refused as on
  every device.
- The executor's device test of the halving fetch expects one instance
  exact and three (one draw) each texel at some order's 2^-k on a device
  with neither form, where it used to expect the refusal.

Verified: see the hkfbfetch-2 report (M3 lane module, lavapipe whole
validation suite, RX 550 module and executor fetch test, clippy).
This commit is contained in:
Anees Iqbal committed 2026-11-11 05:12:37 -08:00
1 parent 3b9e504e85
commit 4575273972
6 files changed
+225 -85

No files matched your search

+17 -6
View File
@@ -1044,7 +1044,12 @@ impl DrawStates {
/// self-dependency does ("A vkCmdPipelineBarrier inside a subpass can synchronize prior attachment
/// writes in the subpass with subsequent input attachment reads", the Render Pass chapter's
/// Common Render Pass Data Races), and the fetching stage records what it leaves unordered
/// (`PrecisionNote::UnorderedFetchWithinDraw`).
/// (`PrecisionNote::UnorderedFetchWithinDraw`). They take that barrier on a driver whose
/// interlocked draws race under load too, not a new instance: the race is the interlock's
/// (`InterlockedDrawsRaceUnderLoad`'s measure is of interlocked storage images), and MoltenVK, the
/// driver with it, ends its Metal render pass and begins another at a by-region barrier whose
/// destination reads input attachments (`MVKCmdPipelineBarrier::encode`, on a tile-based GPU),
/// which this barrier is.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
struct InterlockedStorage {
/// The pass's fragment imageblock storage (`fragment_imageblock.rs`).
@@ -1132,10 +1137,15 @@ impl InterlockedStorage {
/// Whether a kind is in both.
fn meets(self, other: Self) -> bool {
self.meets_interlocked(other) || self.meets_fetch(other)
}
/// Whether a kind of storage the pixel interlock orders is in both: the imageblock's, a
/// color's or the depth's stand-in.
fn meets_interlocked(self, other: Self) -> bool {
(self.imageblock && other.imageblock)
|| (self.colors && other.colors)
|| (self.depth && other.depth)
|| self.meets_fetch(other)
}
/// Whether a kind of input attachments ordered between draws is in both: the barrier that
@@ -8862,10 +8872,11 @@ impl RenderLowering {
(colors_ordered, between_draws),
);
// On a driver whose draws of one instance race on the interlocked storage under load
// (`DriverFact::InterlockedDrawsRaceUnderLoad`), a draw that reaches storage an earlier
// draw of the instance wrote records into a new instance, after the one that wrote it, in
// place of the barrier between them (`InterlockedStorage`).
let storage_split = interlocked.meets(self.current.interlocked_writes)
// (`DriverFact::InterlockedDrawsRaceUnderLoad`), a draw that reaches interlocked storage
// an earlier draw of the instance wrote records into a new instance, after the one that
// wrote it, in place of the barrier between them (`InterlockedStorage`). Input
// attachments ordered between draws alone take their barrier there too.
let storage_split = interlocked.meets_interlocked(self.current.interlocked_writes)
&& driver_facts.contains(&DriverFact::InterlockedDrawsRaceUnderLoad);
let failing = match &failing_state {
None => None,
@@ -340,13 +340,14 @@ fn a_multisampled_stencil_output_case_plans_a_shadow_of_its_samples() {
/// attachment 0 through an input-attachment write, and the pipeline states rasterization-order
/// access and requires the feature. On moltenvk-m3, which lacks the feature but has the pixel
/// interlock, it plans the interlocked storage form: one storage write of the attachment, which is
/// no color attachment of the subpass. Without the interlock too, the product refuses the fetch,
/// naming both forms.
/// no color attachment of the subpass. Without the interlock too, it plans the input attachment
/// with no rasterization-order access, which the consumer orders between draws alone (its
/// barriers, `platform::graphics_pipeline::fetch_between_draws`), the fragment stage noting
/// `PrecisionNote::UnorderedFetchWithinDraw`, and requires neither ordered form.
#[test]
fn a_framebuffer_fetch_case_plans_its_ordered_input_attachment() {
use metal2vulkan::bind::WriteSource;
use metal2vulkan::device::VkFeature;
use metal2vulkan::error::{Capability, Feature, Needs};
let Some(bitcode) = assembled(&metal2vulkan_devtools::engine_dir().join("fragment_fetch.ll"))
else {
return;
@@ -416,7 +417,7 @@ fn a_framebuffer_fetch_case_plans_its_ordered_input_attachment() {
.count(),
1
);
// Without the interlock either, the product refuses the fetch, naming both ordered forms.
// Without the interlock either, the input attachment ordered between draws alone, noted.
let path = crate::engine::profiles_dir().join("moltenvk-m3.json");
let mut description =
DeviceDescription::from_khronos_json(&std::fs::read_to_string(path).unwrap(), None)
@@ -425,21 +426,43 @@ fn a_framebuffer_fetch_case_plans_its_ordered_input_attachment() {
.features
.remove(&VkFeature::FragmentShaderPixelInterlock);
let unordered = Device::new(description, DevicePolicy::default()).unwrap();
match plan_render(&unordered, &render, libraries) {
Err(Error::Unsupported(refusal)) => {
assert_eq!(refusal.feature, Feature::FramebufferFetch);
assert_eq!(
refusal.needs,
Needs::AnyOf(vec![
vec![Capability::Feature(
VkFeature::RasterizationOrderColorAttachmentAccess
)],
vec![Capability::Feature(VkFeature::FragmentShaderPixelInterlock)],
])
);
}
other => panic!("an unordered fetch was ordered: {other:?}"),
let (pipeline, plan, _) = planned_draw(&unordered, &render, libraries).unwrap();
let read: Vec<u32> = (pipeline.graphics.input_attachments.iter())
.map(|input| input.color_index)
.collect();
assert_eq!(read, [0]);
assert!(!pipeline.graphics.rasterization_order_attachment_access);
assert!(pipeline.graphics.storage_attachments.is_empty());
assert!(pipeline.graphics.color_attachments[0].is_some());
for ordered in [
VkFeature::RasterizationOrderColorAttachmentAccess,
VkFeature::FragmentShaderPixelInterlock,
] {
assert!(
!pipeline.requirements.features.contains(&ordered),
"{ordered:?}"
);
}
assert_eq!(
plan.descriptors
.iter()
.filter(|write| matches!(write.source, WriteSource::Attachment { color_index: 0 }))
.count(),
1
);
assert!(unordered_within_draw(&pipeline));
}
/// Whether `pipeline`'s fragment stage records `PrecisionNote::UnorderedFetchWithinDraw`: its
/// fetch is ordered between draws alone.
fn unordered_within_draw(pipeline: &metal2vulkan::pipeline::RenderPipeline) -> bool {
(pipeline.stages.iter())
.filter(|stage| stage.stage == vk::ShaderStage::FRAGMENT)
.any(|stage| {
stage
.precision_notes
.contains(&PrecisionNote::UnorderedFetchWithinDraw)
})
}
/// A fragment case draws through its passthrough vertex companion with its own resources on the
@@ -2151,16 +2174,19 @@ fn public_framebuffer_fetch_cases_plan_their_ordered_input_attachments() {
}
/// On `lunarg-desktop-baseline-2023` and `vk12-floor`, which offer no ordered form of framebuffer
/// fetch (no rasterization-order attachment access), every installed public framebuffer-fetch case
/// is refused `FramebufferFetch`: an unordered read is never compiled.
/// fetch (neither rasterization-order attachment access nor the pixel interlock), every installed
/// public framebuffer-fetch case plans its color inputs as input attachments with no
/// rasterization-order access, which the consumer orders between draws alone, and its fragment
/// stage notes `PrecisionNote::UnorderedFetchWithinDraw`; or, a multisampled pass, is refused as on
/// every device (the coverage read beside it, or a sample count the attachments lack).
#[test]
fn public_framebuffer_fetch_cases_are_refused_without_an_ordered_form() {
fn public_framebuffer_fetch_cases_plan_input_attachments_without_an_ordered_form() {
use crate::air::reflect::ResourceKind;
let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("corpus");
let store = CorpusStore::new(&root);
let sources = public_sources().unwrap();
for stem in ["lunarg-desktop-baseline-2023", "vk12-floor"] {
let ordered = device(stem);
let unordered = device(stem);
let mut fetches = 0;
for shard in 0..64 {
for case in store.read_case_shard(shard).unwrap() {
@@ -2187,7 +2213,7 @@ fn public_framebuffer_fetch_cases_are_refused_without_an_ordered_form() {
continue;
}
fetches += 1;
let scratch = crate::ScratchDir::new("public-fetch-refused").unwrap();
let scratch = crate::ScratchDir::new("public-fetch-unordered").unwrap();
let ll = scratch.path().join("case.ll");
std::fs::write(&ll, &row.air_ll).unwrap();
let Some(bitcode) = assembled(&ll) else {
@@ -2210,15 +2236,32 @@ fn public_framebuffer_fetch_cases_are_refused_without_an_ordered_form() {
vertex: &companion,
fragment: Some(&bitcode),
};
match plan_render(&ordered, &render, libraries) {
Err(Error::Unsupported(refusal)) => assert_eq!(
refusal.feature,
metal2vulkan::error::Feature::FramebufferFetch,
"{stem} {}",
case.name
),
other => panic!("{stem} {}: {other:?}", case.name),
}
let pipeline = match planned_draw(&unordered, &render, libraries) {
Ok((pipeline, _, _)) => pipeline,
// A multisampled pass's refusals of every device's form (the lavapipe test's).
Err(Error::Unsupported(refusal)) if case.raster_sample_count.is_some() => {
use metal2vulkan::error::{Feature, Needs};
match (&refusal.feature, &refusal.needs) {
(Feature::PixelCoverageAtSampleRate, Needs::NotRepresentable)
| (Feature::RasterSampleCount, Needs::AnyOf(_)) => continue,
_ => panic!("{stem} {}: {refusal:?}", case.name),
}
}
Err(other) => panic!("{stem} {}: {other:?}", case.name),
};
let mut read: Vec<u32> = (pipeline.graphics.input_attachments.iter())
.map(|input| input.color_index)
.collect();
read.sort_unstable();
let mut colors = colors;
colors.sort_unstable();
assert_eq!(read, colors, "{stem} {}", case.name);
assert!(
!pipeline.graphics.rasterization_order_attachment_access,
"{stem} {}",
case.name
);
assert!(unordered_within_draw(&pipeline), "{stem} {}", case.name);
}
}
assert!(fetches > 0, "{stem}: no public framebuffer-fetch case");
@@ -137,11 +137,12 @@ pub(super) fn has_depth(format: vk::Format) -> bool {
/// The render pass of `graphics`: one subpass writing every color attachment at its Metal index
/// (`VK_ATTACHMENT_UNUSED` for an absent one), in `COLOR_ATTACHMENT_OPTIMAL` (`GENERAL` for an
/// attachment a framebuffer-fetch input also reads, as the input attachment of the same index,
/// with a by-region self-dependency from color writes to input-attachment reads), then the
/// depth/stencil attachment ([`depth_stencil_format`]) in `DEPTH_STENCIL_ATTACHMENT_OPTIMAL`.
/// with the by-region self-dependency of [`FETCH_SELF_DEPENDENCY`]), then the depth/stencil
/// attachment ([`depth_stencil_format`]) in `DEPTH_STENCIL_ATTACHMENT_OPTIMAL`.
/// The subpass has rasterization-order color access when the artifact states it
/// (`GraphicsState::rasterization_order_attachment_access`), so each fetch sees the earlier
/// fragments of the draw that cover its pixel, as in Metal. Every attachment is loaded before and
/// fragments of the draw that cover its pixel, as in Metal; where it does not, each draw records
/// after a barrier of that dependency ([`fetch_between_draws`]). Every attachment is loaded before and
/// stored after the subpass. The framebuffer's views are the present color attachments in index
/// order, then the depth/stencil one.
pub(super) fn create_render_pass(
@@ -263,13 +264,14 @@ pub(super) fn create_render_pass(
let subpasses = [subpass];
// Framebuffer fetch reads the attachment the same subpass writes: the contract's by-region
// self-dependency.
let scopes = FETCH_SELF_DEPENDENCY;
let dependencies = [vk::SubpassDependency::default()
.src_subpass(0)
.dst_subpass(0)
.src_stage_mask(vk::PipelineStageFlags::COLOR_ATTACHMENT_OUTPUT)
.dst_stage_mask(vk::PipelineStageFlags::FRAGMENT_SHADER)
.src_access_mask(vk::AccessFlags::COLOR_ATTACHMENT_WRITE)
.dst_access_mask(vk::AccessFlags::INPUT_ATTACHMENT_READ)
.src_stage_mask(scopes.0)
.dst_stage_mask(scopes.0)
.src_access_mask(scopes.1)
.dst_access_mask(scopes.2)
.dependency_flags(vk::DependencyFlags::BY_REGION)];
let mut info = vk::RenderPassCreateInfo::default()
.attachments(&attachments)
@@ -282,6 +284,61 @@ pub(super) fn create_render_pass(
.map_err(|error| GraphicsError::Refused(format!("create render pass: {error}")))
}
/// The stages and the source and destination accesses of the self-dependency of a subpass whose
/// colors a framebuffer-fetch input reads ([`create_render_pass`]), by region: from the color
/// writes to the input attachment reads (a fetch after an earlier draw's writes, or the load
/// operations'), and from the fragment shader's reads to the color reads and writes (a write
/// after an earlier draw's fetch).
pub(super) const FETCH_SELF_DEPENDENCY: (vk::PipelineStageFlags, vk::AccessFlags, vk::AccessFlags) = (
vk::PipelineStageFlags::from_raw(
vk::PipelineStageFlags::FRAGMENT_SHADER.as_raw()
| vk::PipelineStageFlags::COLOR_ATTACHMENT_OUTPUT.as_raw(),
),
vk::AccessFlags::COLOR_ATTACHMENT_WRITE,
vk::AccessFlags::from_raw(
vk::AccessFlags::INPUT_ATTACHMENT_READ.as_raw()
| vk::AccessFlags::COLOR_ATTACHMENT_READ.as_raw()
| vk::AccessFlags::COLOR_ATTACHMENT_WRITE.as_raw(),
),
);
/// Whether `graphics` reads input attachments ordered between draws alone: on a device with
/// neither rasterization-order color attachment access nor the pixel interlock, which states no
/// rasterization-order access (`GraphicsState::rasterization_order_attachment_access`). The
/// contract has the consumer order each draw of it after the color writes of the draws before,
/// and each draw that writes a color after their reads, by a barrier of the subpass's dependency
/// on itself; the executor records one before each of its draws ([`fetch_between_draws`]), after
/// the load operations too, as the runtime does.
pub(super) fn fetches_between_draws(graphics: &GraphicsState) -> bool {
!graphics.input_attachments.is_empty() && !graphics.rasterization_order_attachment_access
}
/// Record, into `command`, inside a render pass of [`create_render_pass`] whose subpass reads
/// input attachments, the barrier of its [`FETCH_SELF_DEPENDENCY`]: the draws after it read and
/// write the colors after the draws before it wrote and read them.
///
/// # Safety
///
/// `command` is recording inside such a render pass instance, on `device`.
pub(super) unsafe fn fetch_between_draws(device: &ash::Device, command: vk::CommandBuffer) {
let (stages, src, dst) = FETCH_SELF_DEPENDENCY;
let barrier = vk::MemoryBarrier::default()
.src_access_mask(src)
.dst_access_mask(dst);
// SAFETY: the caller's contract; the subpass depends on itself by region with these scopes.
unsafe {
device.cmd_pipeline_barrier(
command,
stages,
stages,
vk::DependencyFlags::BY_REGION,
&[barrier],
&[],
&[],
);
}
}
/// The subpass flags of `graphics`: rasterization-order color access where it states it.
pub(super) fn subpass_flags(graphics: &GraphicsState) -> vk::SubpassDescriptionFlags {
if graphics.rasterization_order_attachment_access {
@@ -697,6 +697,7 @@ fn execute(
primitive_restart,
encoder,
rasterizer_discard: pipeline.graphics.rasterizer_discard,
graphics: &pipeline.graphics,
draw: &commands,
shadow: shadow.as_ref(),
replayed: None,
@@ -1172,6 +1173,7 @@ fn draw_child(
primitive_restart,
encoder,
rasterizer_discard: pipeline.graphics.rasterizer_discard,
graphics: &pipeline.graphics,
draw: commands,
shadow: None,
replayed,
@@ -2286,6 +2288,8 @@ struct Recording<'r> {
/// The pipeline has rasterization disabled, so it has no fragment shader or fragment output
/// state for dynamic state to set.
rasterizer_discard: bool,
/// The pipeline's graphics state, whose render pass the draws record in.
graphics: &'r GraphicsState,
draw: &'r DrawCommands,
/// The shader-side stencil's shadow, copied in before the render pass and out after it.
shadow: Option<&'r shadow::ShadowStencil<'r>>,
@@ -2777,7 +2781,14 @@ fn record_and_submit(
dynamic(vk::DynamicState::SCISSOR),
);
// One draw per recording of it: the whole target, or each region of a rate-mapped pass.
// A fetch ordered between draws alone records after the barrier of the subpass's
// dependency on itself before each: the pass is `create_render_pass`'s of the pipeline's
// graphics state, whose subpass then reads input attachments.
let between_draws = graphics_pipeline::fetches_between_draws(recording.graphics);
for (viewport, scissor) in recording.draws {
if between_draws {
graphics_pipeline::fetch_between_draws(device, command);
}
if set_viewport {
device.cmd_set_viewport(command, 0, std::slice::from_ref(viewport));
}
@@ -471,13 +471,15 @@ fn a_back_culled_patch_and_its_mirror_leave_exactly_one_drawn() {
/// times in order, so under rasterization-order access each instance reads what the one before it
/// wrote and the attachment ends at `2^-n` of its contents. A device without that access but with
/// the pixel interlock (MoltenVK, RADV, ANV) reads and writes the attachment as a storage image
/// inside the interlock, in the same order, to the same result. A device with neither refuses the
/// fetch, typed, naming both.
/// inside the interlock, in the same order, to the same result. A device with neither reads it as
/// an input attachment with no rasterization-order access, after a barrier between draws
/// (`platform::graphics_pipeline::fetch_between_draws`), and its fragment module notes
/// `PrecisionNote::UnorderedFetchWithinDraw`: one instance halves the attachment exactly, and
/// three, one draw, leave each texel some order's `2^-k` of its contents, `k` in 1 to 3.
#[cfg(any(target_os = "linux", target_os = "macos"))]
#[test]
fn a_framebuffer_fetch_halves_its_attachment_once_per_overlapping_instance() {
use crate::check::admission::NotSupported;
use crate::engine::Outcome;
use metal2vulkan::pipeline::PrecisionNote;
let fragment = llvm_assemble(&metal2vulkan_devtools::engine_dir().join("fragment_fetch.ll"))
.expect("llvm-as on the device lane");
let mut authored =
@@ -505,24 +507,27 @@ fn a_framebuffer_fetch_halves_its_attachment_once_per_overlapping_instance() {
},
) {
Ok(run) => {
let scale = 0.5f32.powi(instances as i32);
let expected: Vec<f32> = initial.iter().map(|value| value * scale).collect();
assert_eq!(run.output, floats(&expected), "{instances} instance(s)");
assert_eq!(run.status, metal2vulkan::bind::StatusReport::default());
}
Err(ExecutorError::NotSupported(NotSupported::Product {
outcome:
Outcome::DeviceCapabilityMissing {
feature,
capability,
},
..
})) => {
assert!(feature.contains("FramebufferFetch"), "{feature}");
assert!(
capability.contains("RasterizationOrderColorAttachmentAccess"),
"{capability}"
let unordered = (run.census.modules.iter()).any(|m| {
m.precision
.contains(&PrecisionNote::UnorderedFetchWithinDraw)
});
let scale = |k: u32| 0.5f32.powi(k as i32);
let scaled = |k| floats(&initial.map(|value| value * scale(k)));
if unordered && instances > 1 {
let orders: Vec<Vec<u8>> = (1..=instances).map(scaled).collect();
for (texel, got) in run.output.as_chunks::<4>().0.iter().enumerate() {
assert!(
(orders.iter()).any(|order| order[texel * 4..][..4] == got[..]),
"{instances} instances, texel {texel}: {got:?}"
);
}
} else {
assert_eq!(run.output, scaled(instances), "{instances} instance(s)");
}
eprintln!(
"ENGINE-FETCH {instances} instance(s): unordered within the draw: {unordered}"
);
assert_eq!(run.status, metal2vulkan::bind::StatusReport::default());
}
Err(other) => panic!("{instances} instance(s): {other}"),
}
@@ -8,8 +8,11 @@
//! of the draws' subpass's dependency on itself, by region, before a draw that reads input
//! attachments after an earlier draw of its render pass instance, or its load operations, wrote a
//! color, and before a draw that writes a color after an earlier one read them
//! (`WorkCounts::fetch_draw_barriers`). Each pass draws the fullscreen triangle (`rt6_resolves`'s
//! `rt6_resolve_full`) over a 4² target:
//! (`WorkCounts::fetch_draw_barriers`). It records the barrier, not a new render pass instance, on
//! a driver whose interlocked draws race under load too (MoltenVK on Apple's GPUs): nothing here is
//! interlocked, so no pass splits for that race (`WorkCounts::instance_splits_interlocked_writes`
//! stays). Each pass draws the fullscreen triangle (`rt6_resolves`'s `rt6_resolve_full`) over a 4²
//! target:
//!
//! - **Draws in order**: an `R32Float` target cleared to 0.75, then `fetch_scalar`
//! (`fragment_fetch`, half what it reads), `rt6_resolve_white` (1), `fetch_scalar` twice: 0.25,
@@ -64,9 +67,19 @@ fn unordered_lane() -> (Messages, ScratchCache, Lane) {
})
}
/// The device's `fetch_draw_barriers` so far.
fn barriers(lane: &Lane) -> u64 {
lane.device.work_counts().fetch_draw_barriers
/// The device's `fetch_draw_barriers` and `instance_splits_interlocked_writes` so far.
fn ordering(lane: &Lane) -> (u64, u64) {
let counts = lane.device.work_counts();
(
counts.fetch_draw_barriers,
counts.instance_splits_interlocked_writes,
)
}
/// The barriers between draws and the interlocked splits since `before` ([`ordering`]).
fn since(lane: &Lane, before: (u64, u64)) -> (u64, u64) {
let now = ordering(lane);
(now.0 - before.0, now.1 - before.1)
}
/// The kind the fetching fragment stage records.
@@ -118,8 +131,8 @@ fn fetches_between_draws_read_every_earlier_draw_and_note_the_draw_itself() {
let announced = counts(&messages.take_notices());
assert_eq!(announced.get(&note()), Some(&1), "{device}: {announced:?}");
// Draws in order: 0.25, four barriers.
let before = barriers(&lane);
// Draws in order: 0.25, four barriers, no split.
let before = ordering(&lane);
let target = lane.texture(pf, ONE, TextureUsage::RENDER_TARGET);
let clear = ClearColor::new(0.75, 0.0, 0.0, 0.0);
let targets = [(&target, clear, StoreAction::Store)];
@@ -136,16 +149,16 @@ fn fetches_between_draws_read_every_earlier_draw_and_note_the_draw_itself() {
"{device}: draws in order"
);
assert_eq!(
barriers(&lane) - before,
4,
"{device}: barriers between the draws"
since(&lane, before),
(4, 0),
"{device}: barriers between the draws, and interlocked splits"
);
eprintln!("FETCH-BETWEEN-DRAWS draws in order on {device}: 0.25 at every texel, 4 barriers");
// Integer read-modify-writes: exact, three barriers.
// Integer read-modify-writes: exact, three barriers, no split.
let integers = [PixelFormat::RGBA32Uint];
let step = pipeline(&lane, &vertices, (&count, "exf_fetch_count"), &integers, 1).unwrap();
let before = barriers(&lane);
let before = ordering(&lane);
let target = lane.texture(PixelFormat::RGBA32Uint, ONE, TextureUsage::RENDER_TARGET);
let clear = ClearColor::new(1.0, 2.0, 3.0, 4.0);
let targets = [(&target, clear, StoreAction::Store)];
@@ -157,15 +170,15 @@ fn fetches_between_draws_read_every_earlier_draw_and_note_the_draw_itself() {
"{device}: integer read-modify-writes"
);
assert_eq!(
barriers(&lane) - before,
3,
"{device}: barriers between the draws"
since(&lane, before),
(3, 0),
"{device}: barriers between the draws, and interlocked splits"
);
eprintln!("FETCH-BETWEEN-DRAWS integer read-modify-writes on {device}: exact, 3 barriers");
// One draw over itself: each texel one of the two orders of its fragments, the one barrier
// after the clear.
let before = barriers(&lane);
let before = ordering(&lane);
let target = lane.texture(pf, ONE, TextureUsage::RENDER_TARGET);
let clear = ClearColor::new(0.75, 0.0, 0.0, 0.0);
let targets = [(&target, clear, StoreAction::Store)];
@@ -194,9 +207,9 @@ fn fetches_between_draws_read_every_earlier_draw_and_note_the_draw_itself() {
}
}
assert_eq!(
barriers(&lane) - before,
1,
"{device}: a barrier inside one draw"
since(&lane, before),
(1, 0),
"{device}: a barrier inside one draw, and interlocked splits"
);
eprintln!(
"FETCH-BETWEEN-DRAWS one draw over itself on {device}: {metals} of {TEXELS} texels \