Three measured cost facts for ANV (Mesa 26.2.4) on the Iris Xe of RPL-P (0xa7a0), each a pure fast
path that keeps every texel and the order of every use: no policy switch, notice or ledger row.
What changes:
- DriverFact::DontCareStoreIsOneOfMetals gains a row for this GPU: an attachment a pass stores
DontCare is Vulkan's DONT_CARE there, as on the UHD 770 and the Radeon 780M.
- New DriverFact::SampledDepthKeepsHiZ. ANV turns off a single-sample depth image's hierarchical
depth and compression in GENERAL (the layout every runtime image rests in) for an image of
transfer-source usage, but keeps its write-through form on for one of sampled usage. Where the
fact holds, a single-sample depth attachment plan the device samples takes SAMPLED too
(image_plan::hiz_candidate), heap textures and the runtime's own depth images included; the heap
size answer comes from the same plan. Memory size and alignment are equal with and without it.
- New DriverFact::MultisampledDepthFasterOutOfGeneral. A multisampled depth image renders very
slowly in GENERAL on this GPU, since the write-through hierarchical depth is single-sample only.
Where the fact holds:
- each render pass instance holds a multisampled depth attachment in
DEPTH_STENCIL_ATTACHMENT_OPTIMAL, moved from GENERAL by a barrier before it and back after
it (the feedback-loop mechanism, generalized to moved images; WorkCounts
depth_attachments_moved);
- the device's own Private multisampled depth texture stays in the attachment layout between
encoders that only render it (texture/held_depth.rs). The scheduler moves it at encoder
boundaries, before any encoder that uses it otherwise, as a tracked write of the whole image so
the hazard tracker orders it against every use on every queue. A pass holds only when nothing
else in its encoder touches the image; a later use breaking a hold fails the encoder's end
with a visible internal error. WorkCounts depth_instances_held and held_depths_released.
- An instance an execution of render commands joins, inline instances and the resolve-after
instance stay in GENERAL. Layout transitions preserve contents unless the old layout is
UNDEFINED (Vulkan, Synchronization, Image Layout Transitions).
- New measurement runtime_lane::depth_costs (ignored by default).
Why: in GENERAL these depth attachments lose the hierarchical depth test, so the depth test
rejects no fragment a block at a time; and moving back to GENERAL after every pass costs a full
hierarchical-depth resolve, about 1.95 ms a pass at 1080p with 4 samples.
Verified, release, on the Iris Xe:
- runtime_lane::dont_care_stores: every texel of its twelve kept cases was the earlier or the
stored one, none other.
- A 1080p heap Depth32Float at 32 layers: 4.72-5.66 -> 0.82-0.87 ms with sampled usage. A 4x
Depth32Float at 32 layers: 12.14 -> 1.44-1.52 ms moved per instance; held between encoders, 1
layer 2.56 -> 0.62 ms and 32 layers 4.35 -> 2.38 ms (GPU clock fixed at 300 MHz). Batches that do
not name the depth showed no CPU difference above noise.
- runtime_lane::msaa_depth_moves 9 of 9 under the validation layer with the counters checked (a
blit between passes, a resolve in its pass, frames, reads after each pass, two queues ordered by
an event, a split pass, an argument-buffer read with useResource, an encoder that also binds its
depth, an indirect-command-buffer execution); the depth, resolve, snapshot, clear-reach,
memoryless and fence-stage lanes passed. On the Radeon 780M and RTX 3090: msaa_depth_moves 9 of
9 with the fact off and every counter 0. Runtime unit filters 134 passed.
- The RTX 3090 measured neutral for both depth facts, and the RX 7900 XTX keeps DontCare as STORE
(not a measured identity), so neither is listed.
- Unaudited: no lane covers a tile dispatch in a held pass.
160 lines
5.4 KiB
Rust
160 lines
5.4 KiB
Rust
//! The held depths' moves between encoders (`texture/held_depth.rs`): each batch moves a held
|
|
//! image into the layout each encoder that names it needs, from the layout the batches submitted
|
|
//! before left it in, and a move is a write of the whole image the tracker orders.
|
|
|
|
use crate::resource::ResourceKey;
|
|
use crate::texture::held_depth::{need, BatchMoves, HeldImage, HeldImages, HELD};
|
|
use crate::tracker::{Access, Use, UseRange};
|
|
use ash::vk::{self, Handle};
|
|
use metal2vulkan::vk::{ImageAspectFlags, ImageLayout};
|
|
use std::collections::BTreeSet;
|
|
|
|
const GENERAL: ImageLayout = ImageLayout::GENERAL;
|
|
|
|
/// A registry of one held 4-layer depth image, and its key.
|
|
fn one() -> (HeldImages, ResourceKey) {
|
|
let images = HeldImages::default();
|
|
let key = ResourceKey::new();
|
|
let raw = vk::Image::from_raw(0x10);
|
|
images.insert(HeldImage::new(key, raw, ImageAspectFlags::DEPTH, 1, 4));
|
|
(images, key)
|
|
}
|
|
|
|
/// An encoder's record of what it names and holds: `held` holds `key`, which `named` names.
|
|
fn record(key: ResourceKey, named: bool, held: bool) -> (BTreeSet<ResourceKey>, Vec<ResourceKey>) {
|
|
let names = match named {
|
|
true => BTreeSet::from([key]),
|
|
false => BTreeSet::new(),
|
|
};
|
|
let holds = match held {
|
|
true => vec![key],
|
|
false => Vec::new(),
|
|
};
|
|
(names, holds)
|
|
}
|
|
|
|
/// The moves of a batch of `encoders`.
|
|
fn moves(
|
|
images: &HeldImages,
|
|
encoders: &[(BTreeSet<ResourceKey>, Vec<ResourceKey>)],
|
|
) -> BatchMoves {
|
|
images.moves(
|
|
encoders
|
|
.iter()
|
|
.map(|(named, held)| (named, held.as_slice())),
|
|
)
|
|
}
|
|
|
|
/// The moves before each of a batch's `count` encoders, as (old, new) layouts.
|
|
fn layouts(moves: &BatchMoves, count: usize) -> Vec<Vec<(ImageLayout, ImageLayout)>> {
|
|
(0..count)
|
|
.map(|at| {
|
|
moves
|
|
.transitions(at)
|
|
.iter()
|
|
.map(|t| (t.old, t.new))
|
|
.collect()
|
|
})
|
|
.collect()
|
|
}
|
|
|
|
/// A holding encoder needs the attachment layout, any other `GENERAL`.
|
|
#[test]
|
|
fn a_holding_encoder_needs_the_attachment_layout() {
|
|
assert_eq!(need(true), HELD);
|
|
assert_eq!(need(false), GENERAL);
|
|
assert_eq!(HELD, ImageLayout::DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
|
|
}
|
|
|
|
/// Hold, sample, hold in one batch: in, out (one release), in; the next batch's holding encoder
|
|
/// moves nothing once the first was submitted, and a sampling one moves it out.
|
|
#[test]
|
|
fn a_batch_moves_the_image_into_each_encoder_s_layout() {
|
|
let (images, key) = one();
|
|
let batch = [
|
|
record(key, true, true),
|
|
record(key, true, false),
|
|
record(key, true, true),
|
|
];
|
|
let planned = moves(&images, &batch);
|
|
assert_eq!(
|
|
layouts(&planned, 3),
|
|
vec![
|
|
vec![(GENERAL, HELD)],
|
|
vec![(HELD, GENERAL)],
|
|
vec![(GENERAL, HELD)]
|
|
]
|
|
);
|
|
assert_eq!(planned.released, 1);
|
|
planned.submitted();
|
|
let again = moves(&images, &[record(key, true, true)]);
|
|
assert_eq!(layouts(&again, 1), vec![Vec::new()]);
|
|
assert!(again.is_empty());
|
|
assert_eq!(again.released, 0);
|
|
again.submitted();
|
|
let sampled = moves(&images, &[record(key, true, false)]);
|
|
assert_eq!(layouts(&sampled, 1), vec![vec![(HELD, GENERAL)]]);
|
|
assert_eq!(sampled.released, 1);
|
|
}
|
|
|
|
/// A batch not submitted leaves the layout as the batches before left it: the next plans from
|
|
/// there.
|
|
#[test]
|
|
fn a_batch_not_submitted_changes_no_layout() {
|
|
let (images, key) = one();
|
|
let dropped = moves(&images, &[record(key, true, true)]);
|
|
assert_eq!(layouts(&dropped, 1), vec![vec![(GENERAL, HELD)]]);
|
|
drop(dropped);
|
|
let next = moves(&images, &[record(key, true, false)]);
|
|
assert_eq!(layouts(&next, 1), vec![Vec::new()]);
|
|
}
|
|
|
|
/// An encoder that names no held image moves none, and the image stays as it was for the next.
|
|
#[test]
|
|
fn an_encoder_that_does_not_name_the_image_moves_nothing() {
|
|
let (images, key) = one();
|
|
moves(&images, &[record(key, true, true)]).submitted();
|
|
let other = ResourceKey::new();
|
|
let unnamed = moves(&images, &[(BTreeSet::from([other]), Vec::new())]);
|
|
assert_eq!(layouts(&unnamed, 1), vec![Vec::new()]);
|
|
unnamed.submitted();
|
|
let held = moves(&images, &[record(key, true, true)]);
|
|
assert_eq!(layouts(&held, 1), vec![Vec::new()]);
|
|
}
|
|
|
|
/// A move's use is a tracked write of the whole image in every stage, so the tracker orders it
|
|
/// after every earlier use of the image, on any queue, and every later use after it.
|
|
#[test]
|
|
fn a_move_is_a_write_of_the_whole_image() {
|
|
let (images, key) = one();
|
|
let planned = moves(&images, &[record(key, true, true)]);
|
|
let expected = Use::writes(
|
|
key,
|
|
true,
|
|
UseRange::Image {
|
|
aspects: vk::ImageAspectFlags::DEPTH,
|
|
levels: 0..1,
|
|
layers: 0..4,
|
|
},
|
|
Access::new(
|
|
vk::PipelineStageFlags2::ALL_COMMANDS,
|
|
vk::AccessFlags2::MEMORY_WRITE,
|
|
),
|
|
);
|
|
assert_eq!(planned.uses(0), &[expected][..]);
|
|
}
|
|
|
|
/// An image gone is moved no more; a registry of none plans no move at all.
|
|
#[test]
|
|
fn an_image_gone_is_not_moved() {
|
|
let (images, key) = one();
|
|
images.remove(key);
|
|
assert!(!images.holds(key));
|
|
let planned = moves(
|
|
&images,
|
|
&[record(key, true, true), record(key, true, false)],
|
|
);
|
|
assert_eq!(layouts(&planned, 2), vec![Vec::new(), Vec::new()]);
|
|
assert!(planned.is_empty());
|
|
}
|