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
//! The engine's programs: its own ([`programs`]), the blocks they read
//! ([`ubo`]) and their text in each language, and every program it draws
//! with ([`PROGRAMS`]): those and the terrain's ([`terrain`]). A layer
//! type's programs are in its own module.
// Every built-in program has text in WGSL, MSL, GLSL and GLSL ES. Each
// reads the vertex layouts and the blocks (`ubo`) that the renderer makes,
// and they all draw the same.
//
// The GLSL compiles with naga's GLSL front end:
// - The stages read what their programs declare (`mln_glsl`'s declarations)
// by its names there.
// - A texture and its sampler are two bindings, `<name>_texture` and
// `<name>_sampler`, combined where they are sampled.
// - Symbols read a quad's atlas origin and height offset as the vertex
// attributes `tex_origin` and `height_offset`.
// - A fill extrusion wall reads its outline vertex and the next one as
// instance attributes. The pulled walls and outlines have no vertex
// inputs: they read the bucket's vertices from storage buffers in the
// drawable set, by `gl_InstanceIndex` plus `gl_VertexIndex` / 4.
// - Atlas positions go through `atlas_pos`, and the pattern rectangles reach
// the fragment stage flat.
// - On the globe, a symbol vertex stage puts a screen-aligned label whose
// anchor is behind the horizon outside the clip volume, unless the label
// is raised.
// - On the globe, points on the sphere are offsets from the tile's anchor,
// which the projection matrix carries, so float32 keeps them exact close
// in (`projectToSphere`).
// - What naga doesn't take is written another way: no precision qualifiers,
// `int` for the `bool` members of buffers, no sampler parameters, and
// `flat` on an integer output.
// - Clip space is y-up, as in OpenGL, Metal, D3D and naga's IR: no stage
// flips Y; the SPIR-V back end does for Vulkan.
//
// The GLSL ES:
// - `atlas_pos` (the fragment prelude) places the samples of an atlas image,
// in the pattern and symbol shaders, and the pattern rectangles and the
// symbols' atlas origins reach the fragment shaders `flat`.
// - The symbol shaders read `a_tex_origin`, the atlas origin of a quad's
// image, and `a_height_offset`, the symbol's `symbol-height-offset`.
// - On the globe, the symbol shaders drop a screen-aligned label whose anchor
// is behind the horizon, unless the label is raised.
// - The fill extrusion shaders declare `gl_Position` invariant. Their vertex
// shaders draw the roofs, and the instanced ones the walls: an instance of
// a quad per outline vertex, as the WGSL does.
// - The instanced fill outline shaders draw an outline where the context
// draws no 2 px lines: a quad per segment, two pixels wide as a wide line
// is, with the line shaders' fragment shaders.
// - The fill, fill outline, fill extrusion and line pattern fragment shaders
// set `precision highp float` on GL ES: overzoomed past a
// source's maxzoom, their pattern positions outgrow a 16-bit mediump
// float. The background pattern draws at the current zoom, so its
// positions stay small.
// - The clipping mask program projects through the projection block as the
// other shaders do, and has a globe variant.
// - On the globe, points on the sphere are offsets from the tile's anchor,
// which the projection matrix carries, so float32 keeps them exact close
// in (`projectToSphere`).
// - The terrain shaders apply the WGSL's height rule.
/// The terrain's programs and the blocks they read, which the terrain keeps
/// with its text, and its surface's prelude in each language, for a program
/// that reads the surface as the terrain's programs do: `ground_height!()`,
/// with `terrain_fog!()` and `terrain_props!()` in GLSL, and the prelude as
/// one text in WGSL.
use ProjectionVariant;
use Program;
/// The programs the engine draws with: its own and the terrain's. Each
/// crate of layer types lists its own (in `mln_builtins`,
/// `mln_builtins::shaders::PROGRAMS`).
pub static PROGRAMS: & = &;
/// The projection variants of a program: those that stand on terrain too,
/// for one that `stands`, a program of a layer type that stands on terrain
/// ([`OnTerrain::Stands`](crate::layer::OnTerrain::Stands)).