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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
//! 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.
// The built-in programs' WGSL and MSL started as MapLibre Native's, and
// read the vertices and blocks this renderer makes.
//
// Their GLSL is the C++ core's, copied from the raw string literals of
// include/mln/shaders/vulkan/background.hpp
// include/mln/shaders/vulkan/circle.hpp
// include/mln/shaders/vulkan/clipping_mask.hpp
// include/mln/shaders/vulkan/collision.hpp
// include/mln/shaders/vulkan/color_relief.hpp
// include/mln/shaders/vulkan/common.hpp
// include/mln/shaders/vulkan/fill.hpp
// include/mln/shaders/vulkan/fill_extrusion.hpp
// include/mln/shaders/vulkan/globe_depth.hpp
// include/mln/shaders/vulkan/heatmap.hpp
// include/mln/shaders/vulkan/heatmap_texture.hpp
// include/mln/shaders/vulkan/hillshade.hpp
// include/mln/shaders/vulkan/hillshade_prepare.hpp
// include/mln/shaders/vulkan/line.hpp
// include/mln/shaders/vulkan/raster.hpp
// include/mln/shaders/vulkan/sky.hpp
// include/mln/shaders/vulkan/symbol.hpp
// with the port's changes, so that it reads the vertices and UBOs its
// renderer makes, and compiles with naga's GLSL front end:
// - The stages read what their programs declare (`mln_glsl`'s declarations)
// by its names there. There is no `GlobalPlatformParamsUBO`.
// - A texture and its sampler are two bindings, `<name>_texture` and
// `<name>_sampler`, combined where they are sampled.
// - Symbols read vertex attributes, with the port's `tex_origin` and
// `height_offset`, where C++ reads per-instance storage buffers.
// - A fill extrusion wall reads its outline vertex and the next one as
// instance attributes, where C++ indexes a storage buffer of the outline
// with `gl_InstanceIndex`. The port's pulled walls and outlines have no
// vertex inputs: they read the bucket's vertices from storage buffers in
// the drawable set, by `gl_VertexIndex`.
// - 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 (`applySurfaceTransform`), the SPIR-V back end does for Vulkan.
//
// Their GLSL ES is the C++ core's, copied from the raw string literals of
// include/mln/shaders/gl/atmosphere.hpp
// include/mln/shaders/gl/background.hpp
// include/mln/shaders/gl/background_pattern.hpp
// include/mln/shaders/gl/circle.hpp
// include/mln/shaders/gl/clipping_mask.hpp
// include/mln/shaders/gl/color_relief.hpp
// include/mln/shaders/gl/fill.hpp
// include/mln/shaders/gl/fill_extrusion.hpp
// include/mln/shaders/gl/fill_extrusion_instanced.hpp
// include/mln/shaders/gl/fill_extrusion_pattern.hpp
// include/mln/shaders/gl/fill_extrusion_pattern_instanced.hpp
// include/mln/shaders/gl/fill_outline.hpp
// include/mln/shaders/gl/fill_outline_pattern.hpp
// include/mln/shaders/gl/fill_pattern.hpp
// include/mln/shaders/gl/globe_depth.hpp
// include/mln/shaders/gl/heatmap.hpp
// include/mln/shaders/gl/heatmap_texture.hpp
// include/mln/shaders/gl/hillshade.hpp
// include/mln/shaders/gl/hillshade_prepare.hpp
// include/mln/shaders/gl/line.hpp
// include/mln/shaders/gl/line_gradient.hpp
// include/mln/shaders/gl/line_gradient_sdf.hpp
// include/mln/shaders/gl/line_pattern.hpp
// include/mln/shaders/gl/line_sdf.hpp
// include/mln/shaders/gl/prelude.hpp
// include/mln/shaders/gl/raster.hpp
// include/mln/shaders/gl/shader_group_gl.hpp
// include/mln/shaders/gl/shader_info.hpp
// include/mln/shaders/gl/shader_program_gl.hpp
// include/mln/shaders/gl/sky.hpp
// include/mln/shaders/gl/symbol_icon.hpp
// include/mln/shaders/gl/symbol_sdf.hpp
// include/mln/shaders/gl/symbol_text_and_icon.hpp
// with the port's changes, so that it reads the vertices its renderer makes
// and draws what its WGSL does:
// - `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 the symbol shaders read `a_height_offset`, the symbol's
// `symbol-height-offset`, as GL JS's do.
// - 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, which C++ has no GLSL
// for, the walls: an instance of a quad per outline vertex, as the port's
// WGSL does (C++'s GLSL draws both from one vertex buffer with normals).
// - The instanced fill outline shaders, which C++ doesn't have, 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, as GL JS's do: overzoomed past a
// source's maxzoom, their pattern positions outgrow a 16-bit mediump
// float (maplibre/maplibre-native#4951). The background pattern draws at
// the current zoom, so its positions stay small.
// - ClippingMaskProgram 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 have no C++ counterpart: they are the port's own, with
// the WGSL's height rule.
/// The terrain's programs and the blocks they read, which the terrain keeps
/// with its text.
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)).