RUNTIME 2386: WorkCounts count the descriptor writes compute dispatches push

What: a default-on count beside dispatches_pushing_set_zero, one relaxed add of the push's write
count per pushing dispatch (compute.rs), so writes over pushes is the descriptors a compute push
writes. Listed in the host_ab example's counts; the dispatch_work lane test asserts every push
carries the same writes, at least one, and that writes are counted exactly where pushes are.

Why: on the consumer's Iris Xe, binding::push_set's instructions over a guest compute benchmark's
timed pass rose 21-36% between two runtime pins with the same Mesa (26.2.6), almost all of it
under compute dispatches' pushes, inside the driver's vkCmdPushDescriptorSet. Whether each push
carries more descriptors, or more dispatches push, needs both counts; draws already count theirs
(set_zero_writes_pushed).

Verified: msi m3-max-33677 at the lane tip 9794e48d50: clippy (runtime, all targets, all features) 0;
lavapipe runtime_lane::dispatch_work::dispatches_push_their_set_zero_where_the_device_pushes passes both
ways (4 pushes carried 8 descriptor writes / 0 pushes carried 0). clippy m2v_gpu/m2v_cpu_icd and rustdoc follow.
This commit is contained in:
Anees Iqbal committed 2026-11-15 14:26:41 -08:00
1 parent 82ebc34ae1
commit a2a46d52fd
6 files changed
+38 -8

No files matched your search

@@ -1854,6 +1854,10 @@ impl Gpu for Runtime {
c.set_zero_writes_if_shapes_shared,
),
("dispatches_pushing_set_zero", c.dispatches_pushing_set_zero),
(
"dispatch_set_zero_writes_pushed",
c.dispatch_set_zero_writes_pushed,
),
("set_zero_sets_reused", c.set_zero_sets_reused),
("set_zero_sets_found", c.set_zero_sets_found),
("draw_shapes_reused", c.draw_shapes_reused),
+1 -1
View File
@@ -3151,7 +3151,7 @@ fn record(
}
core.shadow_copies(&copies);
if !pushed.is_empty() {
device.shared().counts.thread().dispatch_pushing_set_zero();
(device.shared().counts.thread()).dispatch_pushing_set_zero(pushed.len() as u64);
}
let recording = Recording {
layout: objects.layout(),
+13 -2
View File
@@ -866,6 +866,7 @@ struct CommandCounters {
dispatches_planned_across_grids: AtomicU64,
whole_dispatches_on_partial_variants: AtomicU64,
dispatches_pushing_set_zero: AtomicU64,
dispatch_set_zero_writes_pushed: AtomicU64,
baked_sampler_dispatches_apart: AtomicU64,
argument_tables_retained: AtomicU64,
argument_objects_retained: AtomicU64,
@@ -1669,9 +1670,12 @@ impl Counting<'_> {
self.0.add(|counts| &counts.draws_pushing_set_zero, 1);
}
/// A dispatch encoded with its set 0 pushed (`pipeline::objects::pushes_set_zero`).
pub(crate) fn dispatch_pushing_set_zero(&self) {
/// A dispatch encoded with its set 0 pushed (`pipeline::objects::pushes_set_zero`), its push
/// carrying `writes` descriptor writes.
pub(crate) fn dispatch_pushing_set_zero(&self, writes: u64) {
self.0.add(|counts| &counts.dispatches_pushing_set_zero, 1);
self.0
.add(|counts| &counts.dispatch_set_zero_writes_pushed, writes);
}
/// A command that bound the set 0 its encoder's last command wrote, the same descriptors
@@ -9080,6 +9084,10 @@ pub struct WorkCounts {
/// a kernel's variant whose set 0 a push descriptor set layout can hold, on a device of Vulkan
/// 1.4 or `VK_KHR_push_descriptor`. Every dispatch pushes all of its set's writes.
pub dispatches_pushing_set_zero: u64,
/// The descriptor writes those dispatches' pushes carried: each push's whole set 0 (its
/// writes, then its variant's baked samplers' pushes), one write a descriptor, so over
/// `dispatches_pushing_set_zero` the descriptors a dispatch's push writes.
pub dispatch_set_zero_writes_pushed: u64,
/// Draws and dispatches that bound the set 0 their encoder's last command allocated and wrote,
/// rather than allocating and writing their own: those that write the same descriptors into a
/// set of the same layout (`binding::LastSetZero`). Their recording binds no set where the set
@@ -12305,6 +12313,9 @@ impl Device {
&counts.set_zero_writes_if_shapes_shared
}),
dispatches_pushing_set_zero: commands(|counts| &counts.dispatches_pushing_set_zero),
dispatch_set_zero_writes_pushed: commands(|counts| {
&counts.dispatch_set_zero_writes_pushed
}),
set_zero_sets_reused: commands(|counts| &counts.set_zero_sets_reused),
set_zero_sets_found: commands(|counts| &counts.set_zero_sets_found),
draw_shapes_reused: commands(|counts| &counts.draw_shapes_reused),
@@ -1,7 +1,8 @@
//! Device tests of a dispatch's set 0 on the device the cfg selects, under the validation layer:
//! pushed (`vkCmdPushDescriptorSet` at the compute bind point) where the device has the push
//! command, else allocated, written and bound, and the same words either way
//! (`WorkCounts::dispatches_pushing_set_zero`); and what a dispatch settles, taken again by the
//! (`WorkCounts::dispatches_pushing_set_zero`), each push's writes counted
//! (`dispatch_set_zero_writes_pushed`); and what a dispatch settles, taken again by the
//! encoder's next dispatch only where its inputs are the same (`WorkCounts::
//! dispatches_settled_as_before`, `set_zero_sets_reused`). Each runs both ways
//! (`draw_work::on_device_both_ways`). And what a dispatch settles with what the encoder made
@@ -33,7 +34,8 @@ const THREADS: u64 = 16;
const DISPATCHES: u64 = 4;
/// Dispatches that each bind other offsets of the same buffers push their set 0 where the device
/// pushes it, and bind it where it does not: every dispatch's words are its own, both ways.
/// pushes it, and bind it where it does not: every dispatch's words are its own, both ways. Each
/// push carries the same writes, at least one, and counts them.
#[test]
fn dispatches_push_their_set_zero_where_the_device_pushes() {
on_device_both_ways(|device| {
@@ -56,8 +58,20 @@ fn dispatches_push_their_set_zero_where_the_device_pushes() {
.dispatch_threads(Size::new(THREADS, 1, 1), Size::new(THREADS, 1, 1))
.unwrap();
}
let pushed =
device.work_counts().dispatches_pushing_set_zero - before.dispatches_pushing_set_zero;
let counts = device.work_counts();
let pushed = grew(&before, &counts, |counts| {
counts.dispatches_pushing_set_zero
});
let writes = grew(&before, &counts, |counts| {
counts.dispatch_set_zero_writes_pushed
});
eprintln!("DISPATCH-WORK: {pushed} pushes carried {writes} descriptor writes");
assert!(
writes >= pushed && (pushed == 0 || writes.is_multiple_of(pushed)),
"each push carries its set's writes, the same for each dispatch: {pushed} pushes, \
{writes} writes"
);
assert_eq!(writes == 0, pushed == 0);
encoder.end_encoding().unwrap();
command_buffer.commit().unwrap();
command_buffer.wait_until_completed_for(WAIT).unwrap();
+1 -1
View File
@@ -94,7 +94,7 @@ pub const ARTIFACT_FORMAT_VERSION: u32 = 523;
/// changes no behaviour, and then updates that hash alone with the commit saying why, or changes
/// behaviour and also bumps this version. The commit that bumps it says what changed; this comment
/// keeps no history.
pub const RUNTIME_VERSION: u32 = 2385;
pub const RUNTIME_VERSION: u32 = 2386;
/// The digest of the sources this build of the crate was compiled from: SHA-256, as lowercase hex,
/// of the manifest, the build script, and exactly the files the crate roots' module tree compiles
@@ -2905,6 +2905,7 @@ field metal2vulkan-runtime::WorkCounts.dirty_wait_nanos pub dirty_wait_nanos: u6
field metal2vulkan-runtime::WorkCounts.dirty_waits pub dirty_waits: u64
field metal2vulkan-runtime::WorkCounts.dirty_waits_unanswered pub dirty_waits_unanswered: u64
field metal2vulkan-runtime::WorkCounts.dispatch_pipelines_pooled pub dispatch_pipelines_pooled: u64
field metal2vulkan-runtime::WorkCounts.dispatch_set_zero_writes_pushed pub dispatch_set_zero_writes_pushed: u64
field metal2vulkan-runtime::WorkCounts.dispatch_shapes_found pub dispatch_shapes_found: u64
field metal2vulkan-runtime::WorkCounts.dispatch_shapes_made pub dispatch_shapes_made: u64
field metal2vulkan-runtime::WorkCounts.dispatch_used_resources_listed pub dispatch_used_resources_listed: u64
Can't render this file because it is too large.