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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
//! HDR environment maps over the protocol (v14), server side.
//!
//! A viewer's `SceneState` names an HDR panorama by the SHA-256 of its `.hdr` file
//! (`SceneEnvironment::Hdr`). Before such a request is served, the request loop resolves
//! the map ([`ensure_environment`]): already decoded in this process, else from the
//! on-disk [`AssetCache`], else by asking the viewer (`NEED_ASSET` -> `ASSET`), verifying
//! the bytes' hash, caching them and decoding them with the viewer's own builder
//! (`indicatrix::renderer::env_map::environment_from_hdr_bytes`). The tracer then lights
//! the scene with that map ([`resolved_hdr_map`]/[`environment_source`]), bit-identical
//! to the viewer's.
//!
//! A coordinator resolves the map through its OWN cache before a job starts
//! ([`ensure_held`]: asking the viewer only if the cache lacks it, decoding only when
//! its own lane renders) and answers each joined worker's `NEED_ASSET` from that copy
//! (`crate::coordinator`'s lanes, via [`HeldAsset`]); every joined worker keeps its own
//! cache, so it asks at most once per map.
//!
//! - [`cache`]: the bounded on-disk LRU (hash-named files, atomic writes, verified).
//! - `decoded`: the process-wide decoded-map registry and the tracer's environment.
//! - `fetch`: the `NEED_ASSET`/`ASSET` exchange.
//! - `held`: the map a coordinator holds for one job.
//! - [`policy`]: which requests may be served with an HDR map at all, and what a
//! coordinator advertises.
//!
//! # Configuration
//!
//! The cache directory is `$INDICATRIX_ASSET_CACHE_DIR` if set, else `asset-cache` next
//! to an anchor path: the served library database for `serve` (the coordinator's data
//! directory; opened with `--render` or a worker port), the certificate directory
//! (`--cert-dir`, default `worker-cert` in the working directory) for `join`. Its size
//! cap is `$INDICATRIX_ASSET_CACHE_MIB` MiB if set, else [`DEFAULT_CACHE_BYTES`] (2 GiB).
//! A cache that cannot be opened disables HDR on that node (a joined worker then
//! advertises `hdr: false` and gets no HDR chunks).
pub use ;
pub use ;
pub use ;
pub use HeldAsset;
pub use ;
use ;
/// Environment variable overriding the cache directory.
pub const CACHE_DIR_ENV: &str = "INDICATRIX_ASSET_CACHE_DIR";
/// Environment variable overriding the cache size cap, in MiB.
pub const CACHE_MIB_ENV: &str = "INDICATRIX_ASSET_CACHE_MIB";
/// The directory name used next to the anchor path (see the module doc comment) when
/// [`CACHE_DIR_ENV`] is unset.
pub const DEFAULT_DIR_NAME: &str = "asset-cache";
/// The cache directory and byte cap from the environment (see the module doc comment).
///
/// `anchor` is the library database `serve` serves, or `join`'s certificate directory;
/// the default directory is [`DEFAULT_DIR_NAME`] beside it.
/// Opens the configured cache (see [`configured_location`] for `anchor`), logging where
/// it lives. `None` -- HDR scenes then refused, never rendered wrongly -- when the
/// directory cannot be created or listed.