Lane: a points' library of shaders is made under its state's pre-rasterization record

runtime_lane::pipeline_records::a_later_device_makes_every_pipeline_an_earlier_one_made_from_its_records
failed on every device that links its pipelines from libraries in the round at
d0f800ddd0 (Iris Xe, RTX 3090, RTX 5080 Laptop, RX 7900 XTX, Radeon 780M):
"the points' making wrote its record", 0 saves where it expected 1 (on the 780M,
"the driver reported (1, 2), not (0, 3)" instead). It passed at 892e4b230b.

The change that did it is 5a1e043784 (RUNTIME_VERSION 2068), which made a library
of shaders under its part's record (GraphicsContent::record_parts) in place of its
library name. A part's record leaves out the depth bias, as a whole pipeline's
record already did, and names no topology (the point class is in a whole
pipeline's record alone). The points' pre-rasterization state differs from the
triangles' only in the bias (Metal biases triangles alone), so the points' library
is now made under the triangles' pre-rasterization record, in the cache the
state's creation made. The product lost nothing: every one of those drivers
reported the points' library found in that cache (pipeline_hits 0 -> 1 at the
points' draw, PIPELINE-RECORDS "first device, drawn"). The driver compiled
nothing, so no data was added and no record was written. A later device loads
that record at the state's creation, and its points' library is found there. The
test's expectation of a record of the points' own was stale on these devices.

The test now counts the records the makings name apart from the makings
(Makings::points_own: 1 where pipelines are made whole, 0 where they are linked).
On the first device, the points' makings load nothing and each reads its data:
unchanged, or written again where the driver's data grew (the 780M's RADV wrote
the shared record again, saves 2 -> 3). A making under a record of its own writes
it. The driver reports the shared ones found and the rest compiled. On the second
device, assert_loaded takes the records loaded and the makings from them apart:
the points' library loads nothing and is handed the loaded cache. The record
counts are the creation's plus the points' own. The module docs drop "the driver
reports no hit or miss of a library", which has been false since libraries report
(5cd5f93c9e). record_parts' doc says the points' library shares the record, and
on which drivers it was seen found.

Verification: the pipeline_records lane tests on lavapipe and the Iris Xe at this
tip, in the report to main.
This commit is contained in:
Anees Iqbal committed 2026-11-11 19:31:37 -08:00
1 parent 14a7ac2a2a
commit a61fd09bc7
2 files changed
+63 -28

No files matched your search

@@ -681,7 +681,14 @@ impl GraphicsContent {
/// names it: Metal biases triangles alone, so a state's line pipeline has the bias off where
/// its triangle sibling has it on, and the bias reaches no stage's conversion. So the two
/// share one record and one cache, where naming it made the line pipeline convert its stages
/// again (120 ms and more for a 271k-word fragment module).
/// again (120 ms and more for a 271k-word fragment module). Where the device links its
/// pipelines from libraries, a pre-rasterization library is made under this record too, and a
/// part's record names no topology (the point class is named by a whole pipeline's record
/// alone, [`record`](Self::record)), so a state's points' pre-rasterization library, whose
/// state differs from its triangles' only in the bias, is made in its triangles' cache and
/// writes no record of its own: the driver reported it found there on ANV (Iris Xe), RADV
/// (RX 7900 XTX, Radeon 780M) and NVIDIA (RTX 3090, RTX 5080 Laptop)
/// (`runtime_lane::pipeline_records`).
fn record_parts(
&self,
objects: &VariantObjects,
@@ -48,13 +48,18 @@
//! inside the making.
//!
//! **Makings where the device links libraries**: a pipeline there is linked from libraries of its
//! parts, and each library of shaders is a making of its own with its record ([`Makings`]): a
//! state's creation makes two, its pre-rasterization and fragment shader libraries, and the points'
//! draw one, its pre-rasterization library (Metal biases depth for triangles only, so the points'
//! pre-rasterization state is another, and their fragment's is the state's). Every count above is
//! of those makings there; a library's record written over with the compute pipeline's data holds
//! another pipeline's data, whichever library it is. The driver reports no hit or miss of a
//! library, which [`assert_reported`] takes.
//! parts, and each library of shaders is a making of its own under its part's record
//! ([`Makings`]): a state's creation makes two, its pre-rasterization and fragment shader
//! libraries, and the points' draw one, its pre-rasterization library (Metal biases depth for
//! triangles only, so the points' pre-rasterization state is another, and their fragment's is the
//! state's). A part's record leaves out the depth bias, as a whole pipeline's does, and the point
//! class, which only a whole pipeline's names, so the points' library is made under the state's
//! pre-rasterization record: handed the cache the creation made, the driver reports it found
//! there, it reads its data (unchanged, or written again where the driver's data grew), and it
//! leaves no record of its own. A later device's points' library is handed that record's cache,
//! loaded at the state's creation, and loads nothing. Every count above is of those makings
//! there; a library's record written over with the compute pipeline's data holds another
//! pipeline's data, whichever library it is.
//!
//! **The driver's own cache is fresh for each device**: Mesa's and NVIDIA's shader disk caches are
//! pointed into a new scratch directory before each device or maker process is made
@@ -127,29 +132,39 @@ fn state(device: &Device, library: &Library, format: PixelFormat) -> RenderPipel
}
/// The driver's makings that keep a record (the module docs): of a state's creation, and of the
/// points' draw after it.
/// points' draw after it, with the records the points' makings name that the creation's do not.
#[derive(Clone, Copy, Debug)]
struct Makings {
creation: u64,
points: u64,
points_own: u64,
}
impl Makings {
/// Those of `device`, which has made a state: one whole pipeline each where it makes its
/// pipelines whole; where it links them from libraries (it linked the state's), the state's
/// pre-rasterization and fragment shader libraries, and the points' pre-rasterization one.
/// pipelines whole, the points' under a record of its own; where it links them from
/// libraries (it linked the state's), the state's pre-rasterization and fragment shader
/// libraries, and the points' pre-rasterization one, under the state's pre-rasterization
/// record.
fn of(device: &Device) -> Makings {
match device.work_counts().pipelines_linked {
0 => Makings {
creation: 1,
points: 1,
points_own: 1,
},
_ => Makings {
creation: 2,
points: 1,
points_own: 0,
},
}
}
/// The records its makings write: the creation's and the points' own.
fn records(&self) -> u64 {
self.creation + self.points_own
}
}
/// The records (`M2VPPLC\0`) under `cache`'s layout directory, by their paths under it, with
@@ -587,7 +602,8 @@ fn changed(before: &BTreeMap<PathBuf, Vec<u8>>, now: &BTreeMap<PathBuf, Vec<u8>>
.count() as u64
}
/// Of `statistics` since `since`, the makings that loaded a record: each the driver reports
/// Of `statistics` since `since`, `loads` records loaded and `makings` makings handed a cache
/// loaded from a record (one loaded then, or earlier on the device): each the driver reports
/// found there read no data back (as many as its hits), and each other one either read its data
/// unchanged or wrote the record again, where the driver's data was no longer the record's. The
/// records written again, which the caller holds to the files changed once the device is gone
@@ -595,7 +611,7 @@ fn changed(before: &BTreeMap<PathBuf, Vec<u8>>, now: &BTreeMap<PathBuf, Vec<u8>>
fn assert_loaded(
which: &str,
(since, statistics): (&ShaderCacheStatistics, &ShaderCacheStatistics),
loads: u64,
(loads, makings): (u64, u64),
) -> u64 {
let saves = statistics.driver_saves - since.driver_saves;
let unchanged = statistics.driver_data_unchanged - since.driver_data_unchanged;
@@ -605,8 +621,9 @@ fn assert_loaded(
statistics.driver_loads - since.driver_loads,
saves + unchanged + found
),
(loads, loads),
"{which}: the makings from records, each found, unchanged or written again"
(loads, makings),
"{which}: the records loaded, and the makings from them, each found, unchanged or written \
again"
);
assert_eq!(
found,
@@ -655,15 +672,26 @@ fn a_later_device_makes_every_pipeline_an_earlier_one_made_from_its_records() {
let drawn = device.shader_cache_statistics();
report("first device, drawn", &drawn);
if keeps {
// A making under its own record writes it; one under a record the creation's
// makings named is handed the cache they made, which the driver reports it found
// there, and reads its data: unchanged, or written again where the driver's data
// grew (RADV's does).
let saves = drawn.driver_saves - created.driver_saves;
let unchanged = drawn.driver_data_unchanged - created.driver_data_unchanged;
assert_eq!(
drawn.driver_saves - created.driver_saves,
makings.points,
"the points' making wrote its record"
(drawn.driver_loads - created.driver_loads, saves + unchanged),
(0, makings.points),
"the points' makings loaded nothing, and each read its data ({makings:?})"
);
assert!(
saves >= makings.points_own,
"the points' making wrote its own record: {saves} saves ({makings:?})"
);
let shared = makings.points - makings.points_own;
assert_reported(
"first device, drawn",
&drawn,
(0, makings.creation + makings.points),
(shared, makings.creation + makings.points_own),
);
} else {
assert_eq!(drawn.driver_saves, 0, "a driver that keeps nothing wrote");
@@ -675,8 +703,8 @@ fn a_later_device_makes_every_pipeline_an_earlier_one_made_from_its_records() {
if driver.whole() {
assert_eq!(
written.len() as u64,
makings.creation + makings.points,
"one record per making"
makings.records(),
"one record per record the makings name"
);
let bytes: Vec<&[u8]> = written.values().map(|bytes| &bytes[..]).collect();
driver.assert_records(&bytes);
@@ -709,11 +737,11 @@ fn a_later_device_makes_every_pipeline_an_earlier_one_made_from_its_records() {
let saves = assert_loaded(
"second device, created: the triangles' makings from their records",
(&none, &created),
makings.creation,
(makings.creation, makings.creation),
) + assert_loaded(
"second device, drawn: the points' making from its record",
"second device, drawn: the points' making from its record, or the creation's",
(&created, &drawn),
makings.points,
(makings.points_own, makings.points),
);
// Hits where the driver's data holds its pipelines, misses where it holds none; its
// own cache is fresh, so a hit is the record's.
@@ -742,7 +770,7 @@ fn a_later_device_makes_every_pipeline_an_earlier_one_made_from_its_records() {
);
assert_eq!(
now.len() as u64,
makings.creation + makings.points,
makings.records(),
"no record but the makings'"
);
let bytes: Vec<&[u8]> = now.values().map(|bytes| &bytes[..]).collect();
@@ -930,7 +958,7 @@ fn a_record_holding_another_pipeline_s_data_is_written_again() {
assert_loaded(
"the compute pipeline's data in its place",
(&none, &made),
makings.creation,
(makings.creation, makings.creation),
),
changed,
"the compute pipeline's data in its place: written again exactly where a record changed"
@@ -978,7 +1006,7 @@ fn a_record_holding_another_pipeline_s_data_is_written_again() {
assert_loaded(
"written again, a later device",
(&none, &made),
makings.creation,
(makings.creation, makings.creation),
),
changed,
"written again, a later device: exactly where a record changed"
@@ -1052,7 +1080,7 @@ fn two_processes_making_one_pipeline_leave_one_whole_record() {
true => assert_loaded(
"after two makers: the records loaded whole",
(&none, &made),
makings.creation,
(makings.creation, makings.creation),
),
false => 0,
};