Files
metal2vulkan/crates
Anees Iqbal 273ea7efe4 A device keeps its compiled pipelines' stage digests past their variants
What: a variant whose objects are made new, with no kept instance to
give them back, names its modules by the SHA-256 of each stage's words
(words_digest). That's one pass over every word. The device now keeps
the digests a variant took in WordsDigests (DeviceShared::words_digests).
It's an LRU of at most 16384 compiled pipelines, keyed like the memo by
the compiled pipeline (kept::Compiled), holding one 32-byte digest per
stage and no Vulkan object. A later variant of the same compiled
pipeline that gets no digests from its caller takes them from there
and hashes nothing. A caller's own digests are used as before (a
render creation that linked its pipeline asks its functions).

Why: a warm pass makes each record's variant and keeps none of its
objects (warm/pass.rs), so the program's state of the same pipeline
makes its variant's objects again. Until now it also hashed every word
of every stage again, the same digest the pass had just taken. So does
any variant made again after its kept instance went, as when the memo
let its pipeline go. For ccb_conv_array's 16348 words that hash takes
17.1 us on lavapipe on msi (COMPUTE-CREATE-PARTS), on every such
creation. A key names one compiled pipeline in a process, which the
memo already trusts, so it names those words.

Verified: the_program_s_state_after_a_pass_hashes_no_stage_words
(tests/warm.rs) warms a recorded compute state's record, then has the
program create that state. The program's creation makes its variant's
objects (the shader-module counts move) and derives no digest
(words_digests_derived stays still). The pass itself derived one at
least, so the test fails without the map.

It passed with the warm, render_stage_digests, kept_variants and
functions_translated tests, 19 of 19, on lavapipe on msi at the tree
of this commit (9262ddd00a). I didn't run it with the map removed, so
the failure without the fix is by construction, not observed.
compute_create_bench's new round shows the time: for ccb_conv_array
on lavapipe, a program's states after a warm pass, memo of 1 byte,
take 115.1 us at the median, against 133.6 us on a new device with no
pass, which hashes. The gap matches the 17.1 us digest.
2026-11-13 03:23:39 -08:00
..