euv_core/runtime/streaming/prefetch/struct.rs
1use super::*;
2
3/// Velocity-predicted spherical lookahead volume queried by the spatial asset prefetcher.
4#[derive(Clone, Copy, Data, Debug, Default, New, PartialEq)]
5pub struct SpatialPrefetchVolume {
6 /// Current camera world position `[x, y, z]`.
7 #[get(type(copy))]
8 pub(crate) center: [f32; 3],
9 /// Current camera world velocity `[vx, vy, vz]` in meters per second.
10 #[get(type(copy))]
11 pub(crate) velocity: [f32; 3],
12 /// Lookahead horizon in seconds (typically `1.2`).
13 #[get(type(copy))]
14 pub(crate) lookahead_secs: f32,
15 /// Spherical prefetch radius around the predicted camera focus point in meters.
16 #[get(type(copy))]
17 pub(crate) radius: f32,
18}
19
20/// World-space spatial anchor binding a streamable asset key hash to a 3D bounding sphere.
21#[derive(Clone, Copy, Data, Debug, Default, New, PartialEq)]
22pub struct SpatialAssetAnchor {
23 /// Deterministic 64-bit FNV-1a asset key hash.
24 #[get(type(copy))]
25 pub(crate) key_hash: u64,
26 /// Asset world-space center `[x, y, z]`.
27 #[get(type(copy))]
28 pub(crate) position: [f32; 3],
29 /// World-space bounding sphere radius in meters.
30 #[get(type(copy))]
31 pub(crate) bounding_radius: f32,
32 /// Semantic asset decode category.
33 #[get(type(copy))]
34 pub(crate) kind: StreamJobKind,
35 /// Target GPU bindless texture slot index (`0` for non-textures).
36 #[get(type(copy))]
37 pub(crate) texture_slot: u32,
38 /// True when texture texels use sRGB encoding.
39 #[get(type(copy))]
40 pub(crate) is_srgb: bool,
41}
42
43/// Uniform 3D spatial hash index accelerating velocity-predicted lookahead prefetching and rear-frustum cancellation.
44#[derive(Clone, Debug)]
45pub struct SpatialPrefetchGrid {
46 /// Uniform grid cell width in meters.
47 pub(crate) cell_size: f32,
48 /// Registered spatial asset anchors indexed by internal slot id.
49 pub(crate) anchors: Vec<Option<SpatialAssetAnchor>>,
50 /// O(1) mapping from 64-bit asset key hash to anchor slot index.
51 pub(crate) key_to_index: HashMap<u64, usize>,
52 /// 3D spatial hash cells storing overlapping anchor indices.
53 pub(crate) cells: HashMap<(i32, i32, i32), Vec<usize>>,
54 /// Active keys currently tracked as velocity-prefetched for trailing behind-camera cancellation.
55 pub(crate) active_prefetches: HashSet<u64>,
56}