1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// The runtime cache segment (`cache/0`) as this crate sees it: the compiled
// shader binaries and driver pipeline blobs a renderer init produces, the
// moments they reach disk, and the read-only copy of the same segment a bundle
// ships.
//
// The segment is read once, on the first lookup, and written at a checkpoint.
// Nothing here writes per entry: an init that compiles fifty shaders stores
// fifty times into memory and touches the file once, which is what keeps the
// cache cheaper than the compiles it saves.
//
// Both producers route through this module rather than through
// `concinnity_host` directly, so the cargo-test opt-out sits in one place:
// under test nothing is read and nothing is written, which keeps the suite out
// of a developer's state directory and keeps a previous run's artifact from
// masking a compile change.
use CacheEntryKind;
use cache;
// Off under `cargo test`, where every operation below is a no-op.
pub
// The bytes stored for `key`, or `None` when the segment holds no such entry.
pub
// The same lookup against the read-only segment a bundle ships, for a caller
// `load` missed. Read once, like the writable one: a lookup here parses
// nothing, so an init consulting it fifty times still costs one file read.
pub
// Hold `bytes` under `key` until the next checkpoint, reporting whether the
// segment took them.
pub
// Drop `key`'s entry, for a caller whose artifact turned out unusable. Only the
// pipeline blobs have one: a shader artifact is content-addressed, so a bad
// entry is a bad key rather than one to withdraw.
pub
// Adopt `id` as the host shader toolchain the segment's entries were produced
// by, reporting whether entries another toolchain produced were discarded.
pub
// Write everything produced since the last checkpoint. Called at the end of a
// renderer init, so a crash later in the session cannot lose the warm-up, and
// again at teardown for what was built lazily after it.
pub