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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/// The inclusive lower bound accepted by
/// [`RayTraceSettings::validate`] for `samples_per_axis`.
pub const RAYTRACE_SAMPLES_PER_AXIS_MIN: u32 = 1;
/// The inclusive upper bound accepted by
/// [`RayTraceSettings::validate`] for `samples_per_axis`.
pub const RAYTRACE_SAMPLES_PER_AXIS_MAX: u32 = 4;
/// The inclusive lower bound accepted by
/// [`RayTraceSettings::validate`] for `max_bounces`.
pub const RAYTRACE_MAX_BOUNCES_MIN: u32 = 0;
/// The inclusive upper bound accepted by
/// [`RayTraceSettings::validate`] for `max_bounces`.
pub const RAYTRACE_MAX_BOUNCES_MAX: u32 = 16;
/// The default `samples_per_axis` used by [`RayTraceSettings::new_default`].
pub const RAYTRACE_DEFAULT_SAMPLES_PER_AXIS: u32 = 1;
/// The default `max_bounces`, mirroring
/// [`RAYTRACE_DEFAULT_MAX_BOUNCES`](super::super::RAYTRACE_DEFAULT_MAX_BOUNCES).
pub const RAYTRACE_DEFAULT_MAX_BOUNCES_LIMIT: u32 = 4;
/// The number of `vec4` slots one packed scene node occupies.
pub const RAYTRACE_PACKED_NODE_VEC4S: usize = 3;
/// The number of `vec4` slots one packed primitive record occupies.
pub const RAYTRACE_PACKED_PRIMITIVE_VEC4S: usize = 8;
/// The number of `vec4` slots in the packed scene header.
pub const RAYTRACE_PACKED_SCENE_HEADER_VEC4S: usize = 1;
/// The number of `vec4` slots in the packed frame header.
pub const RAYTRACE_PACKED_FRAME_HEADER_VEC4S: usize = 8;
/// The number of `vec4` slots one packed light record occupies.
pub const RAYTRACE_PACKED_LIGHT_VEC4S: usize = 4;
/// The gamma exponent applied to the clamped linear color, applied
/// identically by the CPU renderer and by both shader backends.
pub const RAYTRACE_GAMMA: f64 = 2.2;
/// The largest finite `f32` magnitude, as an `f64` so the comparison needs
/// no narrowing. A component beyond this has no `f32` representation at all.
pub const RAYTRACE_MAX_F32_MAGNITUDE: f64 = f32MAX as f64;
/// The largest integer a `f32` represents exactly. Packed indices above
/// this bound would be silently truncated by the shaders.
pub const RAYTRACE_MAX_EXACT_F32_INDEX: usize = 1 << 24;
/// The largest number of packed `f32` values a single GPU buffer or data
/// texture may address, chosen as the floor of the WebGPU
/// `maxStorageBufferBindingSize` default and of the WebGL2
/// `MAX_TEXTURE_SIZE` bound on the packed-data texture.
pub const RAYTRACE_MAX_PACKED_FLOATS: usize = 134_217_728;
/// Error message returned when `samples_per_axis` is out of range.
pub const RAYTRACE_ERROR_SAMPLES_PER_AXIS: &str =
"RayTraceSettings::validate: samples_per_axis must be within 1..=4";
/// Error message returned when `max_bounces` is out of range.
pub const RAYTRACE_ERROR_MAX_BOUNCES: &str =
"RayTraceSettings::validate: max_bounces must be within 0..=16";
/// Error message returned when a render dimension is zero.
pub const RAYTRACE_ERROR_ZERO_DIMENSION: &str =
"render_raytrace_rgba: width and height must both be greater than zero";
/// Error message returned when a render dimension overflows the packed
/// buffer limit.
pub const RAYTRACE_ERROR_DIMENSION_OVERFLOW: &str =
"render_raytrace_rgba: width * height exceeds the packed buffer limit";
/// Error message returned when the packed frame would exceed the GPU data
/// size limit.
pub const RAYTRACE_ERROR_FRAME_OVERFLOW: &str =
"pack_raytrace_frame: packed frame exceeds the GPU data limit";
/// Error message returned when the packed scene would exceed the GPU data
/// size limit.
pub const RAYTRACE_ERROR_SCENE_OVERFLOW: &str =
"RayTraceScene::encode_gpu: packed scene exceeds the GPU data limit";
/// Error message returned when a geometry component is not finite.
pub const RAYTRACE_ERROR_NON_FINITE: &str =
"RayTraceScene::encode_gpu: geometry contains a non-finite component";
/// Error message returned when a geometry component overflows `f32`.
pub const RAYTRACE_ERROR_F32_RANGE: &str =
"RayTraceScene::encode_gpu: geometry component is not representable as f32";
/// Error message returned when a primitive index does not fit in `f32`.
pub const RAYTRACE_ERROR_INDEX_RANGE: &str =
"RayTraceScene::encode_gpu: primitive index is not representable as f32";
/// Error message returned when a camera component is not finite.
pub const RAYTRACE_ERROR_CAMERA_NON_FINITE: &str =
"pack_raytrace_frame: camera contains a non-finite component";
/// Error message returned when the camera basis cannot be built.
pub const RAYTRACE_ERROR_CAMERA_BASIS: &str =
"pack_raytrace_frame: camera basis is degenerate";
/// Error message returned when a light or ambient component is not finite.
pub const RAYTRACE_ERROR_LIGHT_NON_FINITE: &str =
"pack_raytrace_frame: lights contain a non-finite component";
/// Error message returned when a light component overflows `f32`.
pub const RAYTRACE_ERROR_LIGHT_F32_RANGE: &str =
"pack_raytrace_frame: light component is not representable as f32";
/// Error message returned when the camera field of view is outside the
/// open interval `(0, PI)`.
pub const RAYTRACE_ERROR_CAMERA_FOV: &str =
"pack_raytrace_frame: fov must lie strictly within 0 < fov < PI";
/// Error message returned when the camera depth range is invalid.
pub const RAYTRACE_ERROR_CAMERA_RANGE: &str =
"pack_raytrace_frame: depth range must satisfy 0 <= near < far";
/// Error message returned when a camera range component overflows `f32`.
pub const RAYTRACE_ERROR_CAMERA_F32_RANGE: &str =
"pack_raytrace_frame: camera range is not representable as f32";