diff --git a/CMakeLists.txt b/CMakeLists.txt index 7bf7ecb10..0b02c5f01 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -869,6 +869,35 @@ if(MBGL_WITH_OPENGL) ${PROJECT_SOURCE_DIR}/include/mbgl/layermanager/location_indicator_layer_factory.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/platform/gl_functions.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/style/layers/location_indicator_layer.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/shader_source.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/shader_manifest.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/prelude.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/background.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/background_pattern.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/circle.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/clipping_mask.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/collision_box.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/collision_circle.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/debug.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/fill_extrusion_pattern.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/fill_extrusion.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/fill_outline_pattern.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/fill_outline.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/fill_pattern.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/fill.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/heatmap_texture.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/heatmap.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/hillshade_prepare.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/hillshade.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/line_gradient.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/line_pattern.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/line_sdf.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/line.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/raster.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/symbol_icon.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/symbol_sdf_text.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/symbol_sdf_icon.hpp + ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/symbol_text_and_icon.hpp ${PROJECT_SOURCE_DIR}/src/mbgl/gl/attribute.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/gl/attribute.hpp ${PROJECT_SOURCE_DIR}/src/mbgl/gl/command_encoder.cpp @@ -919,37 +948,6 @@ if(MBGL_WITH_OPENGL) ${PROJECT_SOURCE_DIR}/src/mbgl/gl/vertex_buffer_resource.hpp ${PROJECT_SOURCE_DIR}/src/mbgl/layermanager/location_indicator_layer_factory.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/platform/gl_functions.cpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/gl/background.cpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/gl/background_pattern.cpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/gl/circle.cpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/gl/clipping_mask.cpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/gl/collision_box.cpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/gl/collision_circle.cpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/gl/debug.cpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/gl/fill.cpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/gl/fill_extrusion.cpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/gl/fill_extrusion_pattern.cpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/gl/fill_outline.cpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/gl/fill_outline_pattern.cpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/gl/fill_pattern.cpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/gl/heatmap.cpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/gl/heatmap_texture.cpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/gl/hillshade.cpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/gl/hillshade_prepare.cpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/gl/line.cpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/gl/line_gradient.cpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/gl/line_pattern.cpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/gl/line_sdf.cpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/gl/preludes.hpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/gl/raster.cpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/gl/shader_source.cpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/gl/shader_source.hpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/gl/shaders.cpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/gl/shaders.hpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/gl/symbol_icon.cpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/gl/symbol_sdf_icon.cpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/gl/symbol_sdf_text.cpp - ${PROJECT_SOURCE_DIR}/src/mbgl/programs/gl/symbol_text_and_icon.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/render_location_indicator_layer.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/render_location_indicator_layer.hpp ${PROJECT_SOURCE_DIR}/src/mbgl/style/layers/location_indicator_layer.cpp diff --git a/include/mbgl/gfx/backend.hpp b/include/mbgl/gfx/backend.hpp index eed63dfcb..ef6df989b 100644 --- a/include/mbgl/gfx/backend.hpp +++ b/include/mbgl/gfx/backend.hpp @@ -9,8 +9,11 @@ namespace gfx { class Backend { public: + /// @brief The active graphics API/backend type. enum class Type : uint8_t { - OpenGL, + OpenGL, ///< The OpenGL API backend + TYPE_MAX, ///< Not a valid backend type, used to determine the number + ///< of available backends (ie for array allocation). }; static constexpr Type DefaultType = Type::OpenGL; diff --git a/include/mbgl/gfx/shader_registry.hpp b/include/mbgl/gfx/shader_registry.hpp index 04c876a0f..055eb4696 100644 --- a/include/mbgl/gfx/shader_registry.hpp +++ b/include/mbgl/gfx/shader_registry.hpp @@ -65,6 +65,26 @@ class ShaderRegistry { return std::static_pointer_cast(shader); } + /// @brief Ensure the destination 'to' is populated with the requested + /// shader. If already non-null, does nothing. + /// @tparam T Derived type, inheriting `gfx::Shader` + /// @param to Location to store the shader + /// @return True if 'to' has a valid program object, false otherwise. + template, bool>* = nullptr> + bool populate(std::shared_ptr& to) noexcept { + if (to) { + return true; + } + + auto shader = getShader(std::string(T::Name)); + if (!shader || (shader->name() != T::Name)) { + return false; + } + to = std::static_pointer_cast(shader); + return true; + } + private: std::unordered_map< std::string, diff --git a/include/mbgl/shaders/gl/background.hpp b/include/mbgl/shaders/gl/background.hpp new file mode 100644 index 000000000..b37e52b7e --- /dev/null +++ b/include/mbgl/shaders/gl/background.hpp @@ -0,0 +1,33 @@ +// Generated code, do not modify this file! +// Generated on 2023-04-04T01:24:40.539Z by mwilsnd using shaders/generate_shader_code.js + +#pragma once +#include + +namespace mbgl { +namespace shaders { + +template <> struct ShaderSource { + static constexpr const char* vertex = R"(attribute vec2 a_pos; + +uniform mat4 u_matrix; + +void main() { + gl_Position = u_matrix * vec4(a_pos, 0, 1); +} +)"; + static constexpr const char* fragment = R"(uniform vec4 u_color; +uniform float u_opacity; + +void main() { + gl_FragColor = u_color * u_opacity; + +#ifdef OVERDRAW_INSPECTOR + gl_FragColor = vec4(1.0); +#endif +} +)"; +}; + +} // namespace shaders +} // namespace mbgl diff --git a/src/mbgl/programs/gl/background_pattern.cpp b/include/mbgl/shaders/gl/background_pattern.hpp similarity index 50% rename from src/mbgl/programs/gl/background_pattern.cpp rename to include/mbgl/shaders/gl/background_pattern.hpp index 6a1273458..e857f69aa 100644 --- a/src/mbgl/programs/gl/background_pattern.cpp +++ b/include/mbgl/shaders/gl/background_pattern.hpp @@ -1,45 +1,14 @@ -// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. -// clang-format off -#include -#include -#include -#include +// Generated code, do not modify this file! +// Generated on 2023-04-04T01:24:40.539Z by mwilsnd using shaders/generate_shader_code.js + +#pragma once +#include namespace mbgl { -namespace programs { -namespace gl { +namespace shaders { -template -struct ShaderSource; - -template <> -struct ShaderSource { - static constexpr const char* name = "background_pattern"; - static constexpr const uint8_t hash[8] = {0x70, 0x13, 0xc8, 0x7e, 0xba, 0x18, 0xf5, 0x19}; - static constexpr const auto vertexOffset = 1675; - static constexpr const auto fragmentOffset = 2266; -}; - -constexpr const char* ShaderSource::name; -constexpr const uint8_t ShaderSource::hash[8]; - -} // namespace gl -} // namespace programs - -namespace gfx { - -template <> -std::unique_ptr> -Backend::Create(const ProgramParameters& programParameters) { - return std::make_unique>(programParameters); -} - -} // namespace gfx -} // namespace mbgl - -// Uncompressed source of background_pattern.vertex.glsl: -/* -uniform mat4 u_matrix; +template <> struct ShaderSource { + static constexpr const char* vertex = R"(uniform mat4 u_matrix; uniform vec2 u_pattern_size_a; uniform vec2 u_pattern_size_b; uniform vec2 u_pixel_coord_upper; @@ -59,12 +28,8 @@ void main() { v_pos_a = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, u_scale_a * u_pattern_size_a, u_tile_units_to_pixels, a_pos); v_pos_b = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, u_scale_b * u_pattern_size_b, u_tile_units_to_pixels, a_pos); } - -*/ - -// Uncompressed source of background_pattern.fragment.glsl: -/* -uniform vec2 u_pattern_tl_a; +)"; + static constexpr const char* fragment = R"(uniform vec2 u_pattern_tl_a; uniform vec2 u_pattern_br_a; uniform vec2 u_pattern_tl_b; uniform vec2 u_pattern_br_b; @@ -92,6 +57,8 @@ void main() { gl_FragColor = vec4(1.0); #endif } +)"; +}; -*/ -// clang-format on +} // namespace shaders +} // namespace mbgl diff --git a/src/mbgl/programs/gl/circle.cpp b/include/mbgl/shaders/gl/circle.hpp similarity index 63% rename from src/mbgl/programs/gl/circle.cpp rename to include/mbgl/shaders/gl/circle.hpp index 6f987e6e2..0bad8bf75 100644 --- a/src/mbgl/programs/gl/circle.cpp +++ b/include/mbgl/shaders/gl/circle.hpp @@ -1,45 +1,14 @@ -// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. -// clang-format off -#include -#include -#include -#include +// Generated code, do not modify this file! +// Generated on 2023-04-04T01:24:40.539Z by mwilsnd using shaders/generate_shader_code.js + +#pragma once +#include namespace mbgl { -namespace programs { -namespace gl { +namespace shaders { -template -struct ShaderSource; - -template <> -struct ShaderSource { - static constexpr const char* name = "circle"; - static constexpr const uint8_t hash[8] = {0x1d, 0x47, 0x35, 0xbb, 0x94, 0x3d, 0x93, 0xca}; - static constexpr const auto vertexOffset = 2927; - static constexpr const auto fragmentOffset = 6135; -}; - -constexpr const char* ShaderSource::name; -constexpr const uint8_t ShaderSource::hash[8]; - -} // namespace gl -} // namespace programs - -namespace gfx { - -template <> -std::unique_ptr> -Backend::Create(const ProgramParameters& programParameters) { - return std::make_unique>(programParameters); -} - -} // namespace gfx -} // namespace mbgl - -// Uncompressed source of circle.vertex.glsl: -/* -uniform mat4 u_matrix; +template <> struct ShaderSource { + static constexpr const char* vertex = R"(uniform mat4 u_matrix; uniform bool u_scale_with_map; uniform bool u_pitch_with_map; uniform vec2 u_extrude_scale; @@ -50,7 +19,6 @@ attribute vec2 a_pos; varying vec3 v_data; - #ifndef HAS_UNIFORM_u_color uniform lowp float u_color_t; attribute highp vec4 a_color; @@ -58,8 +26,6 @@ varying highp vec4 color; #else uniform highp vec4 u_color; #endif - - #ifndef HAS_UNIFORM_u_radius uniform lowp float u_radius_t; attribute mediump vec2 a_radius; @@ -67,8 +33,6 @@ varying mediump float radius; #else uniform mediump float u_radius; #endif - - #ifndef HAS_UNIFORM_u_blur uniform lowp float u_blur_t; attribute lowp vec2 a_blur; @@ -76,8 +40,6 @@ varying lowp float blur; #else uniform lowp float u_blur; #endif - - #ifndef HAS_UNIFORM_u_opacity uniform lowp float u_opacity_t; attribute lowp vec2 a_opacity; @@ -85,8 +47,6 @@ varying lowp float opacity; #else uniform lowp float u_opacity; #endif - - #ifndef HAS_UNIFORM_u_stroke_color uniform lowp float u_stroke_color_t; attribute highp vec4 a_stroke_color; @@ -94,8 +54,6 @@ varying highp vec4 stroke_color; #else uniform highp vec4 u_stroke_color; #endif - - #ifndef HAS_UNIFORM_u_stroke_width uniform lowp float u_stroke_width_t; attribute mediump vec2 a_stroke_width; @@ -103,8 +61,6 @@ varying mediump float stroke_width; #else uniform mediump float u_stroke_width; #endif - - #ifndef HAS_UNIFORM_u_stroke_opacity uniform lowp float u_stroke_opacity_t; attribute lowp vec2 a_stroke_opacity; @@ -113,58 +69,43 @@ varying lowp float stroke_opacity; uniform lowp float u_stroke_opacity; #endif - void main(void) { - -#ifndef HAS_UNIFORM_u_color - color = unpack_mix_color(a_color, u_color_t); + #ifndef HAS_UNIFORM_u_color +color = unpack_mix_color(a_color, u_color_t); #else - highp vec4 color = u_color; +highp vec4 color = u_color; #endif - - -#ifndef HAS_UNIFORM_u_radius - radius = unpack_mix_vec2(a_radius, u_radius_t); + #ifndef HAS_UNIFORM_u_radius +radius = unpack_mix_vec2(a_radius, u_radius_t); #else - mediump float radius = u_radius; +mediump float radius = u_radius; #endif - - -#ifndef HAS_UNIFORM_u_blur - blur = unpack_mix_vec2(a_blur, u_blur_t); + #ifndef HAS_UNIFORM_u_blur +blur = unpack_mix_vec2(a_blur, u_blur_t); #else - lowp float blur = u_blur; +lowp float blur = u_blur; #endif - - -#ifndef HAS_UNIFORM_u_opacity - opacity = unpack_mix_vec2(a_opacity, u_opacity_t); + #ifndef HAS_UNIFORM_u_opacity +opacity = unpack_mix_vec2(a_opacity, u_opacity_t); #else - lowp float opacity = u_opacity; +lowp float opacity = u_opacity; #endif - - -#ifndef HAS_UNIFORM_u_stroke_color - stroke_color = unpack_mix_color(a_stroke_color, u_stroke_color_t); + #ifndef HAS_UNIFORM_u_stroke_color +stroke_color = unpack_mix_color(a_stroke_color, u_stroke_color_t); #else - highp vec4 stroke_color = u_stroke_color; +highp vec4 stroke_color = u_stroke_color; #endif - - -#ifndef HAS_UNIFORM_u_stroke_width - stroke_width = unpack_mix_vec2(a_stroke_width, u_stroke_width_t); + #ifndef HAS_UNIFORM_u_stroke_width +stroke_width = unpack_mix_vec2(a_stroke_width, u_stroke_width_t); #else - mediump float stroke_width = u_stroke_width; +mediump float stroke_width = u_stroke_width; #endif - - -#ifndef HAS_UNIFORM_u_stroke_opacity - stroke_opacity = unpack_mix_vec2(a_stroke_opacity, u_stroke_opacity_t); + #ifndef HAS_UNIFORM_u_stroke_opacity +stroke_opacity = unpack_mix_vec2(a_stroke_opacity, u_stroke_opacity_t); #else - lowp float stroke_opacity = u_stroke_opacity; +lowp float stroke_opacity = u_stroke_opacity; #endif - // unencode the extrusion vector that we snuck into the a_pos vector vec2 extrude = vec2(mod(a_pos, 2.0) * 2.0 - 1.0); @@ -201,100 +142,68 @@ void main(void) { v_data = vec3(extrude.x, extrude.y, antialiasblur); } - -*/ - -// Uncompressed source of circle.fragment.glsl: -/* -varying vec3 v_data; - +)"; + static constexpr const char* fragment = R"(varying vec3 v_data; #ifndef HAS_UNIFORM_u_color varying highp vec4 color; #else uniform highp vec4 u_color; #endif - - #ifndef HAS_UNIFORM_u_radius varying mediump float radius; #else uniform mediump float u_radius; #endif - - #ifndef HAS_UNIFORM_u_blur varying lowp float blur; #else uniform lowp float u_blur; #endif - - #ifndef HAS_UNIFORM_u_opacity varying lowp float opacity; #else uniform lowp float u_opacity; #endif - - #ifndef HAS_UNIFORM_u_stroke_color varying highp vec4 stroke_color; #else uniform highp vec4 u_stroke_color; #endif - - #ifndef HAS_UNIFORM_u_stroke_width varying mediump float stroke_width; #else uniform mediump float u_stroke_width; #endif - - #ifndef HAS_UNIFORM_u_stroke_opacity varying lowp float stroke_opacity; #else uniform lowp float u_stroke_opacity; #endif - void main() { - -#ifdef HAS_UNIFORM_u_color - highp vec4 color = u_color; + #ifdef HAS_UNIFORM_u_color +highp vec4 color = u_color; #endif - - -#ifdef HAS_UNIFORM_u_radius - mediump float radius = u_radius; + #ifdef HAS_UNIFORM_u_radius +mediump float radius = u_radius; #endif - - -#ifdef HAS_UNIFORM_u_blur - lowp float blur = u_blur; + #ifdef HAS_UNIFORM_u_blur +lowp float blur = u_blur; #endif - - -#ifdef HAS_UNIFORM_u_opacity - lowp float opacity = u_opacity; + #ifdef HAS_UNIFORM_u_opacity +lowp float opacity = u_opacity; #endif - - -#ifdef HAS_UNIFORM_u_stroke_color - highp vec4 stroke_color = u_stroke_color; + #ifdef HAS_UNIFORM_u_stroke_color +highp vec4 stroke_color = u_stroke_color; #endif - - -#ifdef HAS_UNIFORM_u_stroke_width - mediump float stroke_width = u_stroke_width; + #ifdef HAS_UNIFORM_u_stroke_width +mediump float stroke_width = u_stroke_width; #endif - - -#ifdef HAS_UNIFORM_u_stroke_opacity - lowp float stroke_opacity = u_stroke_opacity; + #ifdef HAS_UNIFORM_u_stroke_opacity +lowp float stroke_opacity = u_stroke_opacity; #endif - vec2 extrude = v_data.xy; float extrude_length = length(extrude); @@ -315,6 +224,8 @@ void main() { gl_FragColor = vec4(1.0); #endif } +)"; +}; -*/ -// clang-format on +} // namespace shaders +} // namespace mbgl diff --git a/include/mbgl/shaders/gl/clipping_mask.hpp b/include/mbgl/shaders/gl/clipping_mask.hpp new file mode 100644 index 000000000..e89428b12 --- /dev/null +++ b/include/mbgl/shaders/gl/clipping_mask.hpp @@ -0,0 +1,26 @@ +// Generated code, do not modify this file! +// Generated on 2023-04-04T01:24:40.539Z by mwilsnd using shaders/generate_shader_code.js + +#pragma once +#include + +namespace mbgl { +namespace shaders { + +template <> struct ShaderSource { + static constexpr const char* vertex = R"(attribute vec2 a_pos; + +uniform mat4 u_matrix; + +void main() { + gl_Position = u_matrix * vec4(a_pos, 0, 1); +} +)"; + static constexpr const char* fragment = R"(void main() { + gl_FragColor = vec4(1.0); +} +)"; +}; + +} // namespace shaders +} // namespace mbgl diff --git a/src/mbgl/programs/gl/collision_box.cpp b/include/mbgl/shaders/gl/collision_box.hpp similarity index 50% rename from src/mbgl/programs/gl/collision_box.cpp rename to include/mbgl/shaders/gl/collision_box.hpp index a4c06bb5a..73e48dd1b 100644 --- a/src/mbgl/programs/gl/collision_box.cpp +++ b/include/mbgl/shaders/gl/collision_box.hpp @@ -1,45 +1,14 @@ -// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. -// clang-format off -#include -#include -#include -#include +// Generated code, do not modify this file! +// Generated on 2023-04-04T01:24:40.539Z by mwilsnd using shaders/generate_shader_code.js + +#pragma once +#include namespace mbgl { -namespace programs { -namespace gl { +namespace shaders { -template -struct ShaderSource; - -template <> -struct ShaderSource { - static constexpr const char* name = "collision_box"; - static constexpr const uint8_t hash[8] = {0xcb, 0x6a, 0x9b, 0xd1, 0x1f, 0x31, 0xf8, 0x5b}; - static constexpr const auto vertexOffset = 10000; - static constexpr const auto fragmentOffset = 10679; -}; - -constexpr const char* ShaderSource::name; -constexpr const uint8_t ShaderSource::hash[8]; - -} // namespace gl -} // namespace programs - -namespace gfx { - -template <> -std::unique_ptr> -Backend::Create(const ProgramParameters& programParameters) { - return std::make_unique>(programParameters); -} - -} // namespace gfx -} // namespace mbgl - -// Uncompressed source of collision_box.vertex.glsl: -/* -attribute vec2 a_pos; +template <> struct ShaderSource { + static constexpr const char* vertex = R"(attribute vec2 a_pos; attribute vec2 a_anchor_pos; attribute vec2 a_extrude; attribute vec2 a_placed; @@ -66,12 +35,8 @@ void main() { v_placed = a_placed.x; v_notUsed = a_placed.y; } - -*/ - -// Uncompressed source of collision_box.fragment.glsl: -/* - +)"; + static constexpr const char* fragment = R"( varying float v_placed; varying float v_notUsed; @@ -91,6 +56,8 @@ void main() { // This box not used, fade it out gl_FragColor *= .1; } -} -*/ -// clang-format on +})"; +}; + +} // namespace shaders +} // namespace mbgl diff --git a/src/mbgl/programs/gl/collision_circle.cpp b/include/mbgl/shaders/gl/collision_circle.hpp similarity index 62% rename from src/mbgl/programs/gl/collision_circle.cpp rename to include/mbgl/shaders/gl/collision_circle.hpp index c715ef9a0..a2b266791 100644 --- a/src/mbgl/programs/gl/collision_circle.cpp +++ b/include/mbgl/shaders/gl/collision_circle.hpp @@ -1,45 +1,14 @@ -// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. -// clang-format off -#include -#include -#include -#include +// Generated code, do not modify this file! +// Generated on 2023-04-04T01:24:40.539Z by mwilsnd using shaders/generate_shader_code.js + +#pragma once +#include namespace mbgl { -namespace programs { -namespace gl { +namespace shaders { -template -struct ShaderSource; - -template <> -struct ShaderSource { - static constexpr const char* name = "collision_circle"; - static constexpr const uint8_t hash[8] = {0x99, 0x2e, 0xad, 0x8c, 0xd3, 0x88, 0xae, 0x82}; - static constexpr const auto vertexOffset = 10902; - static constexpr const auto fragmentOffset = 11818; -}; - -constexpr const char* ShaderSource::name; -constexpr const uint8_t ShaderSource::hash[8]; - -} // namespace gl -} // namespace programs - -namespace gfx { - -template <> -std::unique_ptr> -Backend::Create(const ProgramParameters& programParameters) { - return std::make_unique>(programParameters); -} - -} // namespace gfx -} // namespace mbgl - -// Uncompressed source of collision_circle.vertex.glsl: -/* -attribute vec2 a_pos; +template <> struct ShaderSource { + static constexpr const char* vertex = R"(attribute vec2 a_pos; attribute vec2 a_anchor_pos; attribute vec2 a_extrude; attribute vec2 a_placed; @@ -75,12 +44,8 @@ void main() { v_extrude = a_extrude * padding_factor; v_extrude_scale = u_extrude_scale * u_camera_to_center_distance * collision_perspective_ratio; } - -*/ - -// Uncompressed source of collision_circle.fragment.glsl: -/* -uniform float u_overscale_factor; +)"; + static constexpr const char* fragment = R"(uniform float u_overscale_factor; varying float v_placed; varying float v_notUsed; @@ -114,6 +79,8 @@ void main() { gl_FragColor = opacity_t * color; } +)"; +}; -*/ -// clang-format on +} // namespace shaders +} // namespace mbgl diff --git a/include/mbgl/shaders/gl/debug.hpp b/include/mbgl/shaders/gl/debug.hpp new file mode 100644 index 000000000..7fc211fc9 --- /dev/null +++ b/include/mbgl/shaders/gl/debug.hpp @@ -0,0 +1,37 @@ +// Generated code, do not modify this file! +// Generated on 2023-04-04T01:24:40.539Z by mwilsnd using shaders/generate_shader_code.js + +#pragma once +#include + +namespace mbgl { +namespace shaders { + +template <> struct ShaderSource { + static constexpr const char* vertex = R"(attribute vec2 a_pos; +varying vec2 v_uv; + +uniform mat4 u_matrix; +uniform float u_overlay_scale; + +void main() { + // This vertex shader expects a EXTENT x EXTENT quad, + // The UV co-ordinates for the overlay texture can be calculated using that knowledge + v_uv = a_pos / 8192.0; + gl_Position = u_matrix * vec4(a_pos * u_overlay_scale, 0, 1); +} +)"; + static constexpr const char* fragment = R"(uniform highp vec4 u_color; +uniform sampler2D u_overlay; + +varying vec2 v_uv; + +void main() { + vec4 overlay_color = texture2D(u_overlay, v_uv); + gl_FragColor = mix(u_color, overlay_color, overlay_color.a); +} +)"; +}; + +} // namespace shaders +} // namespace mbgl diff --git a/include/mbgl/shaders/gl/fill.hpp b/include/mbgl/shaders/gl/fill.hpp new file mode 100644 index 000000000..8b818e4fa --- /dev/null +++ b/include/mbgl/shaders/gl/fill.hpp @@ -0,0 +1,74 @@ +// Generated code, do not modify this file! +// Generated on 2023-04-04T01:24:40.539Z by mwilsnd using shaders/generate_shader_code.js + +#pragma once +#include + +namespace mbgl { +namespace shaders { + +template <> struct ShaderSource { + static constexpr const char* vertex = R"(attribute vec2 a_pos; + +uniform mat4 u_matrix; + +#ifndef HAS_UNIFORM_u_color +uniform lowp float u_color_t; +attribute highp vec4 a_color; +varying highp vec4 color; +#else +uniform highp vec4 u_color; +#endif +#ifndef HAS_UNIFORM_u_opacity +uniform lowp float u_opacity_t; +attribute lowp vec2 a_opacity; +varying lowp float opacity; +#else +uniform lowp float u_opacity; +#endif + +void main() { + #ifndef HAS_UNIFORM_u_color +color = unpack_mix_color(a_color, u_color_t); +#else +highp vec4 color = u_color; +#endif + #ifndef HAS_UNIFORM_u_opacity +opacity = unpack_mix_vec2(a_opacity, u_opacity_t); +#else +lowp float opacity = u_opacity; +#endif + + gl_Position = u_matrix * vec4(a_pos, 0, 1); +} +)"; + static constexpr const char* fragment = R"(#ifndef HAS_UNIFORM_u_color +varying highp vec4 color; +#else +uniform highp vec4 u_color; +#endif +#ifndef HAS_UNIFORM_u_opacity +varying lowp float opacity; +#else +uniform lowp float u_opacity; +#endif + +void main() { + #ifdef HAS_UNIFORM_u_color +highp vec4 color = u_color; +#endif + #ifdef HAS_UNIFORM_u_opacity +lowp float opacity = u_opacity; +#endif + + gl_FragColor = color * opacity; + +#ifdef OVERDRAW_INSPECTOR + gl_FragColor = vec4(1.0); +#endif +} +)"; +}; + +} // namespace shaders +} // namespace mbgl diff --git a/src/mbgl/programs/gl/fill_extrusion.cpp b/include/mbgl/shaders/gl/fill_extrusion.hpp similarity index 63% rename from src/mbgl/programs/gl/fill_extrusion.cpp rename to include/mbgl/shaders/gl/fill_extrusion.hpp index c86c69f11..2442275a6 100644 --- a/src/mbgl/programs/gl/fill_extrusion.cpp +++ b/include/mbgl/shaders/gl/fill_extrusion.hpp @@ -1,45 +1,14 @@ -// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. -// clang-format off -#include -#include -#include -#include +// Generated code, do not modify this file! +// Generated on 2023-04-04T01:24:40.539Z by mwilsnd using shaders/generate_shader_code.js + +#pragma once +#include namespace mbgl { -namespace programs { -namespace gl { +namespace shaders { -template -struct ShaderSource; - -template <> -struct ShaderSource { - static constexpr const char* name = "fill_extrusion"; - static constexpr const uint8_t hash[8] = {0x9d, 0x76, 0x7f, 0xaa, 0x86, 0x57, 0x56, 0x96}; - static constexpr const auto vertexOffset = 21491; - static constexpr const auto fragmentOffset = 23422; -}; - -constexpr const char* ShaderSource::name; -constexpr const uint8_t ShaderSource::hash[8]; - -} // namespace gl -} // namespace programs - -namespace gfx { - -template <> -std::unique_ptr> -Backend::Create(const ProgramParameters& programParameters) { - return std::make_unique>(programParameters); -} - -} // namespace gfx -} // namespace mbgl - -// Uncompressed source of fill_extrusion.vertex.glsl: -/* -uniform mat4 u_matrix; +template <> struct ShaderSource { + static constexpr const char* vertex = R"(uniform mat4 u_matrix; uniform vec3 u_lightcolor; uniform lowp vec3 u_lightpos; uniform lowp float u_lightintensity; @@ -51,15 +20,12 @@ attribute vec4 a_normal_ed; varying vec4 v_color; - #ifndef HAS_UNIFORM_u_base uniform lowp float u_base_t; attribute highp vec2 a_base; #else uniform highp float u_base; #endif - - #ifndef HAS_UNIFORM_u_height uniform lowp float u_height_t; attribute highp vec2 a_height; @@ -67,8 +33,6 @@ attribute highp vec2 a_height; uniform highp float u_height; #endif - - #ifndef HAS_UNIFORM_u_color uniform lowp float u_color_t; attribute highp vec4 a_color; @@ -76,30 +40,23 @@ attribute highp vec4 a_color; uniform highp vec4 u_color; #endif - void main() { - -#ifndef HAS_UNIFORM_u_base - highp float base = unpack_mix_vec2(a_base, u_base_t); + #ifndef HAS_UNIFORM_u_base +highp float base = unpack_mix_vec2(a_base, u_base_t); #else - highp float base = u_base; +highp float base = u_base; #endif - - -#ifndef HAS_UNIFORM_u_height - highp float height = unpack_mix_vec2(a_height, u_height_t); + #ifndef HAS_UNIFORM_u_height +highp float height = unpack_mix_vec2(a_height, u_height_t); #else - highp float height = u_height; +highp float height = u_height; #endif - - -#ifndef HAS_UNIFORM_u_color - highp vec4 color = unpack_mix_color(a_color, u_color_t); + #ifndef HAS_UNIFORM_u_color +highp vec4 color = unpack_mix_color(a_color, u_color_t); #else - highp vec4 color = u_color; +highp vec4 color = u_color; #endif - vec3 normal = a_normal_ed.xyz; base = max(0.0, base); @@ -144,12 +101,8 @@ void main() { v_color.b += clamp(color.b * directional * u_lightcolor.b, mix(0.0, 0.3, 1.0 - u_lightcolor.b), 1.0); v_color *= u_opacity; } - -*/ - -// Uncompressed source of fill_extrusion.fragment.glsl: -/* -varying vec4 v_color; +)"; + static constexpr const char* fragment = R"(varying vec4 v_color; void main() { gl_FragColor = v_color; @@ -158,6 +111,8 @@ void main() { gl_FragColor = vec4(1.0); #endif } +)"; +}; -*/ -// clang-format on +} // namespace shaders +} // namespace mbgl diff --git a/src/mbgl/programs/gl/fill_extrusion_pattern.cpp b/include/mbgl/shaders/gl/fill_extrusion_pattern.hpp similarity index 67% rename from src/mbgl/programs/gl/fill_extrusion_pattern.cpp rename to include/mbgl/shaders/gl/fill_extrusion_pattern.hpp index f89086de3..591f00dda 100644 --- a/src/mbgl/programs/gl/fill_extrusion_pattern.cpp +++ b/include/mbgl/shaders/gl/fill_extrusion_pattern.hpp @@ -1,45 +1,14 @@ -// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. -// clang-format off -#include -#include -#include -#include +// Generated code, do not modify this file! +// Generated on 2023-04-04T01:24:40.539Z by mwilsnd using shaders/generate_shader_code.js + +#pragma once +#include namespace mbgl { -namespace programs { -namespace gl { +namespace shaders { -template -struct ShaderSource; - -template <> -struct ShaderSource { - static constexpr const char* name = "fill_extrusion_pattern"; - static constexpr const uint8_t hash[8] = {0x5a, 0x8f, 0x1a, 0xbf, 0x43, 0x62, 0xf0, 0x86}; - static constexpr const auto vertexOffset = 23538; - static constexpr const auto fragmentOffset = 26509; -}; - -constexpr const char* ShaderSource::name; -constexpr const uint8_t ShaderSource::hash[8]; - -} // namespace gl -} // namespace programs - -namespace gfx { - -template <> -std::unique_ptr> -Backend::Create(const ProgramParameters& programParameters) { - return std::make_unique>(programParameters); -} - -} // namespace gfx -} // namespace mbgl - -// Uncompressed source of fill_extrusion_pattern.vertex.glsl: -/* -uniform mat4 u_matrix; +template <> struct ShaderSource { + static constexpr const char* vertex = R"(uniform mat4 u_matrix; uniform vec2 u_pixel_coord_upper; uniform vec2 u_pixel_coord_lower; uniform float u_height_factor; @@ -58,7 +27,6 @@ varying vec2 v_pos_a; varying vec2 v_pos_b; varying vec4 v_lighting; - #ifndef HAS_UNIFORM_u_base uniform lowp float u_base_t; attribute lowp vec2 a_base; @@ -66,8 +34,6 @@ varying lowp float base; #else uniform lowp float u_base; #endif - - #ifndef HAS_UNIFORM_u_height uniform lowp float u_height_t; attribute lowp vec2 a_height; @@ -75,8 +41,6 @@ varying lowp float height; #else uniform lowp float u_height; #endif - - #ifndef HAS_UNIFORM_u_pattern_from uniform lowp float u_pattern_from_t; attribute lowp vec4 a_pattern_from; @@ -84,8 +48,6 @@ varying lowp vec4 pattern_from; #else uniform lowp vec4 u_pattern_from; #endif - - #ifndef HAS_UNIFORM_u_pattern_to uniform lowp float u_pattern_to_t; attribute lowp vec4 a_pattern_to; @@ -94,37 +56,28 @@ varying lowp vec4 pattern_to; uniform lowp vec4 u_pattern_to; #endif - void main() { - -#ifndef HAS_UNIFORM_u_base - base = unpack_mix_vec2(a_base, u_base_t); + #ifndef HAS_UNIFORM_u_base +base = unpack_mix_vec2(a_base, u_base_t); #else - lowp float base = u_base; +lowp float base = u_base; #endif - - -#ifndef HAS_UNIFORM_u_height - height = unpack_mix_vec2(a_height, u_height_t); + #ifndef HAS_UNIFORM_u_height +height = unpack_mix_vec2(a_height, u_height_t); #else - lowp float height = u_height; +lowp float height = u_height; #endif - - -#ifndef HAS_UNIFORM_u_pattern_from - pattern_from = a_pattern_from; + #ifndef HAS_UNIFORM_u_pattern_from +pattern_from = a_pattern_from; #else - mediump vec4 pattern_from = u_pattern_from; +mediump vec4 pattern_from = u_pattern_from; #endif - - -#ifndef HAS_UNIFORM_u_pattern_to - pattern_to = a_pattern_to; + #ifndef HAS_UNIFORM_u_pattern_to +pattern_to = a_pattern_to; #else - mediump vec4 pattern_to = u_pattern_to; +mediump vec4 pattern_to = u_pattern_to; #endif - vec2 pattern_tl_a = pattern_from.xy; vec2 pattern_br_a = pattern_from.zw; vec2 pattern_tl_b = pattern_to.xy; @@ -171,12 +124,8 @@ void main() { v_lighting.rgb += clamp(directional * u_lightcolor, mix(vec3(0.0), vec3(0.3), 1.0 - u_lightcolor), vec3(1.0)); v_lighting *= u_opacity; } - -*/ - -// Uncompressed source of fill_extrusion_pattern.fragment.glsl: -/* -uniform vec2 u_texsize; +)"; + static constexpr const char* fragment = R"(uniform vec2 u_texsize; uniform float u_fade; uniform sampler2D u_image; @@ -185,57 +134,41 @@ varying vec2 v_pos_a; varying vec2 v_pos_b; varying vec4 v_lighting; - #ifndef HAS_UNIFORM_u_base varying lowp float base; #else uniform lowp float u_base; #endif - - #ifndef HAS_UNIFORM_u_height varying lowp float height; #else uniform lowp float u_height; #endif - - #ifndef HAS_UNIFORM_u_pattern_from varying lowp vec4 pattern_from; #else uniform lowp vec4 u_pattern_from; #endif - - #ifndef HAS_UNIFORM_u_pattern_to varying lowp vec4 pattern_to; #else uniform lowp vec4 u_pattern_to; #endif - void main() { - -#ifdef HAS_UNIFORM_u_base - lowp float base = u_base; + #ifdef HAS_UNIFORM_u_base +lowp float base = u_base; #endif - - -#ifdef HAS_UNIFORM_u_height - lowp float height = u_height; + #ifdef HAS_UNIFORM_u_height +lowp float height = u_height; #endif - - -#ifdef HAS_UNIFORM_u_pattern_from - mediump vec4 pattern_from = u_pattern_from; + #ifdef HAS_UNIFORM_u_pattern_from +mediump vec4 pattern_from = u_pattern_from; #endif - - -#ifdef HAS_UNIFORM_u_pattern_to - mediump vec4 pattern_to = u_pattern_to; + #ifdef HAS_UNIFORM_u_pattern_to +mediump vec4 pattern_to = u_pattern_to; #endif - vec2 pattern_tl_a = pattern_from.xy; vec2 pattern_br_a = pattern_from.zw; vec2 pattern_tl_b = pattern_to.xy; @@ -257,6 +190,8 @@ void main() { gl_FragColor = vec4(1.0); #endif } +)"; +}; -*/ -// clang-format on +} // namespace shaders +} // namespace mbgl diff --git a/include/mbgl/shaders/gl/fill_outline.hpp b/include/mbgl/shaders/gl/fill_outline.hpp new file mode 100644 index 000000000..d5b55715b --- /dev/null +++ b/include/mbgl/shaders/gl/fill_outline.hpp @@ -0,0 +1,82 @@ +// Generated code, do not modify this file! +// Generated on 2023-04-04T01:24:40.539Z by mwilsnd using shaders/generate_shader_code.js + +#pragma once +#include + +namespace mbgl { +namespace shaders { + +template <> struct ShaderSource { + static constexpr const char* vertex = R"(attribute vec2 a_pos; + +uniform mat4 u_matrix; +uniform vec2 u_world; + +varying vec2 v_pos; + +#ifndef HAS_UNIFORM_u_outline_color +uniform lowp float u_outline_color_t; +attribute highp vec4 a_outline_color; +varying highp vec4 outline_color; +#else +uniform highp vec4 u_outline_color; +#endif +#ifndef HAS_UNIFORM_u_opacity +uniform lowp float u_opacity_t; +attribute lowp vec2 a_opacity; +varying lowp float opacity; +#else +uniform lowp float u_opacity; +#endif + +void main() { + #ifndef HAS_UNIFORM_u_outline_color +outline_color = unpack_mix_color(a_outline_color, u_outline_color_t); +#else +highp vec4 outline_color = u_outline_color; +#endif + #ifndef HAS_UNIFORM_u_opacity +opacity = unpack_mix_vec2(a_opacity, u_opacity_t); +#else +lowp float opacity = u_opacity; +#endif + + gl_Position = u_matrix * vec4(a_pos, 0, 1); + v_pos = (gl_Position.xy / gl_Position.w + 1.0) / 2.0 * u_world; +} +)"; + static constexpr const char* fragment = R"(varying vec2 v_pos; + +#ifndef HAS_UNIFORM_u_outline_color +varying highp vec4 outline_color; +#else +uniform highp vec4 u_outline_color; +#endif +#ifndef HAS_UNIFORM_u_opacity +varying lowp float opacity; +#else +uniform lowp float u_opacity; +#endif + +void main() { + #ifdef HAS_UNIFORM_u_outline_color +highp vec4 outline_color = u_outline_color; +#endif + #ifdef HAS_UNIFORM_u_opacity +lowp float opacity = u_opacity; +#endif + + float dist = length(v_pos - gl_FragCoord.xy); + float alpha = 1.0 - smoothstep(0.0, 1.0, dist); + gl_FragColor = outline_color * (alpha * opacity); + +#ifdef OVERDRAW_INSPECTOR + gl_FragColor = vec4(1.0); +#endif +} +)"; +}; + +} // namespace shaders +} // namespace mbgl diff --git a/src/mbgl/programs/gl/fill_outline_pattern.cpp b/include/mbgl/shaders/gl/fill_outline_pattern.hpp similarity index 60% rename from src/mbgl/programs/gl/fill_outline_pattern.cpp rename to include/mbgl/shaders/gl/fill_outline_pattern.hpp index bb09e482d..8d29322c0 100644 --- a/src/mbgl/programs/gl/fill_outline_pattern.cpp +++ b/include/mbgl/shaders/gl/fill_outline_pattern.hpp @@ -1,45 +1,14 @@ -// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. -// clang-format off -#include -#include -#include -#include +// Generated code, do not modify this file! +// Generated on 2023-04-04T01:24:40.539Z by mwilsnd using shaders/generate_shader_code.js + +#pragma once +#include namespace mbgl { -namespace programs { -namespace gl { +namespace shaders { -template -struct ShaderSource; - -template <> -struct ShaderSource { - static constexpr const char* name = "fill_outline_pattern"; - static constexpr const uint8_t hash[8] = {0x56, 0x9c, 0x2f, 0x58, 0x6b, 0x31, 0xff, 0x84}; - static constexpr const auto vertexOffset = 15345; - static constexpr const auto fragmentOffset = 17205; -}; - -constexpr const char* ShaderSource::name; -constexpr const uint8_t ShaderSource::hash[8]; - -} // namespace gl -} // namespace programs - -namespace gfx { - -template <> -std::unique_ptr> -Backend::Create(const ProgramParameters& programParameters) { - return std::make_unique>(programParameters); -} - -} // namespace gfx -} // namespace mbgl - -// Uncompressed source of fill_outline_pattern.vertex.glsl: -/* -uniform mat4 u_matrix; +template <> struct ShaderSource { + static constexpr const char* vertex = R"(uniform mat4 u_matrix; uniform vec2 u_world; uniform vec2 u_pixel_coord_upper; uniform vec2 u_pixel_coord_lower; @@ -51,7 +20,6 @@ varying vec2 v_pos_a; varying vec2 v_pos_b; varying vec2 v_pos; - #ifndef HAS_UNIFORM_u_opacity uniform lowp float u_opacity_t; attribute lowp vec2 a_opacity; @@ -59,8 +27,6 @@ varying lowp float opacity; #else uniform lowp float u_opacity; #endif - - #ifndef HAS_UNIFORM_u_pattern_from uniform lowp float u_pattern_from_t; attribute lowp vec4 a_pattern_from; @@ -68,8 +34,6 @@ varying lowp vec4 pattern_from; #else uniform lowp vec4 u_pattern_from; #endif - - #ifndef HAS_UNIFORM_u_pattern_to uniform lowp float u_pattern_to_t; attribute lowp vec4 a_pattern_to; @@ -78,30 +42,23 @@ varying lowp vec4 pattern_to; uniform lowp vec4 u_pattern_to; #endif - void main() { - -#ifndef HAS_UNIFORM_u_opacity - opacity = unpack_mix_vec2(a_opacity, u_opacity_t); + #ifndef HAS_UNIFORM_u_opacity +opacity = unpack_mix_vec2(a_opacity, u_opacity_t); #else - lowp float opacity = u_opacity; +lowp float opacity = u_opacity; #endif - - -#ifndef HAS_UNIFORM_u_pattern_from - pattern_from = a_pattern_from; + #ifndef HAS_UNIFORM_u_pattern_from +pattern_from = a_pattern_from; #else - mediump vec4 pattern_from = u_pattern_from; +mediump vec4 pattern_from = u_pattern_from; #endif - - -#ifndef HAS_UNIFORM_u_pattern_to - pattern_to = a_pattern_to; + #ifndef HAS_UNIFORM_u_pattern_to +pattern_to = a_pattern_to; #else - mediump vec4 pattern_to = u_pattern_to; +mediump vec4 pattern_to = u_pattern_to; #endif - vec2 pattern_tl_a = pattern_from.xy; vec2 pattern_br_a = pattern_from.zw; vec2 pattern_tl_b = pattern_to.xy; @@ -122,12 +79,8 @@ void main() { v_pos = (gl_Position.xy / gl_Position.w + 1.0) / 2.0 * u_world; } - -*/ - -// Uncompressed source of fill_outline_pattern.fragment.glsl: -/* - +)"; + static constexpr const char* fragment = R"( uniform vec2 u_texsize; uniform sampler2D u_image; uniform float u_fade; @@ -136,45 +89,33 @@ varying vec2 v_pos_a; varying vec2 v_pos_b; varying vec2 v_pos; - #ifndef HAS_UNIFORM_u_opacity varying lowp float opacity; #else uniform lowp float u_opacity; #endif - - #ifndef HAS_UNIFORM_u_pattern_from varying lowp vec4 pattern_from; #else uniform lowp vec4 u_pattern_from; #endif - - #ifndef HAS_UNIFORM_u_pattern_to varying lowp vec4 pattern_to; #else uniform lowp vec4 u_pattern_to; #endif - void main() { - -#ifdef HAS_UNIFORM_u_opacity - lowp float opacity = u_opacity; + #ifdef HAS_UNIFORM_u_opacity +lowp float opacity = u_opacity; #endif - - -#ifdef HAS_UNIFORM_u_pattern_from - mediump vec4 pattern_from = u_pattern_from; + #ifdef HAS_UNIFORM_u_pattern_from +mediump vec4 pattern_from = u_pattern_from; #endif - - -#ifdef HAS_UNIFORM_u_pattern_to - mediump vec4 pattern_to = u_pattern_to; + #ifdef HAS_UNIFORM_u_pattern_to +mediump vec4 pattern_to = u_pattern_to; #endif - vec2 pattern_tl_a = pattern_from.xy; vec2 pattern_br_a = pattern_from.zw; vec2 pattern_tl_b = pattern_to.xy; @@ -200,6 +141,8 @@ void main() { gl_FragColor = vec4(1.0); #endif } +)"; +}; -*/ -// clang-format on +} // namespace shaders +} // namespace mbgl diff --git a/src/mbgl/programs/gl/fill_pattern.cpp b/include/mbgl/shaders/gl/fill_pattern.hpp similarity index 58% rename from src/mbgl/programs/gl/fill_pattern.cpp rename to include/mbgl/shaders/gl/fill_pattern.hpp index 1e6e84d3e..b38505e2b 100644 --- a/src/mbgl/programs/gl/fill_pattern.cpp +++ b/include/mbgl/shaders/gl/fill_pattern.hpp @@ -1,45 +1,14 @@ -// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. -// clang-format off -#include -#include -#include -#include +// Generated code, do not modify this file! +// Generated on 2023-04-04T01:24:40.539Z by mwilsnd using shaders/generate_shader_code.js + +#pragma once +#include namespace mbgl { -namespace programs { -namespace gl { +namespace shaders { -template -struct ShaderSource; - -template <> -struct ShaderSource { - static constexpr const char* name = "fill_pattern"; - static constexpr const uint8_t hash[8] = {0x74, 0xa9, 0x97, 0x01, 0x96, 0xbd, 0x87, 0x36}; - static constexpr const auto vertexOffset = 18512; - static constexpr const auto fragmentOffset = 20291; -}; - -constexpr const char* ShaderSource::name; -constexpr const uint8_t ShaderSource::hash[8]; - -} // namespace gl -} // namespace programs - -namespace gfx { - -template <> -std::unique_ptr> -Backend::Create(const ProgramParameters& programParameters) { - return std::make_unique>(programParameters); -} - -} // namespace gfx -} // namespace mbgl - -// Uncompressed source of fill_pattern.vertex.glsl: -/* -uniform mat4 u_matrix; +template <> struct ShaderSource { + static constexpr const char* vertex = R"(uniform mat4 u_matrix; uniform vec2 u_pixel_coord_upper; uniform vec2 u_pixel_coord_lower; uniform vec4 u_scale; @@ -49,7 +18,6 @@ attribute vec2 a_pos; varying vec2 v_pos_a; varying vec2 v_pos_b; - #ifndef HAS_UNIFORM_u_opacity uniform lowp float u_opacity_t; attribute lowp vec2 a_opacity; @@ -57,8 +25,6 @@ varying lowp float opacity; #else uniform lowp float u_opacity; #endif - - #ifndef HAS_UNIFORM_u_pattern_from uniform lowp float u_pattern_from_t; attribute lowp vec4 a_pattern_from; @@ -66,8 +32,6 @@ varying lowp vec4 pattern_from; #else uniform lowp vec4 u_pattern_from; #endif - - #ifndef HAS_UNIFORM_u_pattern_to uniform lowp float u_pattern_to_t; attribute lowp vec4 a_pattern_to; @@ -76,30 +40,23 @@ varying lowp vec4 pattern_to; uniform lowp vec4 u_pattern_to; #endif - void main() { - -#ifndef HAS_UNIFORM_u_opacity - opacity = unpack_mix_vec2(a_opacity, u_opacity_t); + #ifndef HAS_UNIFORM_u_opacity +opacity = unpack_mix_vec2(a_opacity, u_opacity_t); #else - lowp float opacity = u_opacity; +lowp float opacity = u_opacity; #endif - - -#ifndef HAS_UNIFORM_u_pattern_from - pattern_from = a_pattern_from; + #ifndef HAS_UNIFORM_u_pattern_from +pattern_from = a_pattern_from; #else - mediump vec4 pattern_from = u_pattern_from; +mediump vec4 pattern_from = u_pattern_from; #endif - - -#ifndef HAS_UNIFORM_u_pattern_to - pattern_to = a_pattern_to; + #ifndef HAS_UNIFORM_u_pattern_to +pattern_to = a_pattern_to; #else - mediump vec4 pattern_to = u_pattern_to; +mediump vec4 pattern_to = u_pattern_to; #endif - vec2 pattern_tl_a = pattern_from.xy; vec2 pattern_br_a = pattern_from.zw; vec2 pattern_tl_b = pattern_to.xy; @@ -117,12 +74,8 @@ void main() { v_pos_a = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, fromScale * display_size_a, tileZoomRatio, a_pos); v_pos_b = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, toScale * display_size_b, tileZoomRatio, a_pos); } - -*/ - -// Uncompressed source of fill_pattern.fragment.glsl: -/* -uniform vec2 u_texsize; +)"; + static constexpr const char* fragment = R"(uniform vec2 u_texsize; uniform float u_fade; uniform sampler2D u_image; @@ -130,45 +83,33 @@ uniform sampler2D u_image; varying vec2 v_pos_a; varying vec2 v_pos_b; - #ifndef HAS_UNIFORM_u_opacity varying lowp float opacity; #else uniform lowp float u_opacity; #endif - - #ifndef HAS_UNIFORM_u_pattern_from varying lowp vec4 pattern_from; #else uniform lowp vec4 u_pattern_from; #endif - - #ifndef HAS_UNIFORM_u_pattern_to varying lowp vec4 pattern_to; #else uniform lowp vec4 u_pattern_to; #endif - void main() { - -#ifdef HAS_UNIFORM_u_opacity - lowp float opacity = u_opacity; + #ifdef HAS_UNIFORM_u_opacity +lowp float opacity = u_opacity; #endif - - -#ifdef HAS_UNIFORM_u_pattern_from - mediump vec4 pattern_from = u_pattern_from; + #ifdef HAS_UNIFORM_u_pattern_from +mediump vec4 pattern_from = u_pattern_from; #endif - - -#ifdef HAS_UNIFORM_u_pattern_to - mediump vec4 pattern_to = u_pattern_to; + #ifdef HAS_UNIFORM_u_pattern_to +mediump vec4 pattern_to = u_pattern_to; #endif - vec2 pattern_tl_a = pattern_from.xy; vec2 pattern_br_a = pattern_from.zw; vec2 pattern_tl_b = pattern_to.xy; @@ -188,6 +129,8 @@ void main() { gl_FragColor = vec4(1.0); #endif } +)"; +}; -*/ -// clang-format on +} // namespace shaders +} // namespace mbgl diff --git a/src/mbgl/programs/gl/heatmap.cpp b/include/mbgl/shaders/gl/heatmap.hpp similarity index 64% rename from src/mbgl/programs/gl/heatmap.cpp rename to include/mbgl/shaders/gl/heatmap.hpp index bf2c663cb..bf51c5727 100644 --- a/src/mbgl/programs/gl/heatmap.cpp +++ b/include/mbgl/shaders/gl/heatmap.hpp @@ -1,45 +1,14 @@ -// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. -// clang-format off -#include -#include -#include -#include +// Generated code, do not modify this file! +// Generated on 2023-04-04T01:24:40.539Z by mwilsnd using shaders/generate_shader_code.js + +#pragma once +#include namespace mbgl { -namespace programs { -namespace gl { - -template -struct ShaderSource; - -template <> -struct ShaderSource { - static constexpr const char* name = "heatmap"; - static constexpr const uint8_t hash[8] = {0xe5, 0xa4, 0x9c, 0x31, 0x01, 0xe5, 0x4a, 0xe0}; - static constexpr const auto vertexOffset = 8026; - static constexpr const auto fragmentOffset = 9074; -}; - -constexpr const char* ShaderSource::name; -constexpr const uint8_t ShaderSource::hash[8]; - -} // namespace gl -} // namespace programs - -namespace gfx { - -template <> -std::unique_ptr> -Backend::Create(const ProgramParameters& programParameters) { - return std::make_unique>(programParameters); -} - -} // namespace gfx -} // namespace mbgl - -// Uncompressed source of heatmap.vertex.glsl: -/* +namespace shaders { +template <> struct ShaderSource { + static constexpr const char* vertex = R"( uniform mat4 u_matrix; uniform float u_extrude_scale; uniform float u_opacity; @@ -49,7 +18,6 @@ attribute vec2 a_pos; varying vec2 v_extrude; - #ifndef HAS_UNIFORM_u_weight uniform lowp float u_weight_t; attribute highp vec2 a_weight; @@ -57,8 +25,6 @@ varying highp float weight; #else uniform highp float u_weight; #endif - - #ifndef HAS_UNIFORM_u_radius uniform lowp float u_radius_t; attribute mediump vec2 a_radius; @@ -66,7 +32,6 @@ attribute mediump vec2 a_radius; uniform mediump float u_radius; #endif - // Effective "0" in the kernel density texture to adjust the kernel size to; // this empirically chosen number minimizes artifacts on overlapping kernels // for typical heatmap cases (assuming clustered source) @@ -76,21 +41,17 @@ const highp float ZERO = 1.0 / 255.0 / 16.0; #define GAUSS_COEF 0.3989422804014327 void main(void) { - -#ifndef HAS_UNIFORM_u_weight - weight = unpack_mix_vec2(a_weight, u_weight_t); + #ifndef HAS_UNIFORM_u_weight +weight = unpack_mix_vec2(a_weight, u_weight_t); #else - highp float weight = u_weight; +highp float weight = u_weight; #endif - - -#ifndef HAS_UNIFORM_u_radius - mediump float radius = unpack_mix_vec2(a_radius, u_radius_t); + #ifndef HAS_UNIFORM_u_radius +mediump float radius = unpack_mix_vec2(a_radius, u_radius_t); #else - mediump float radius = u_radius; +mediump float radius = u_radius; #endif - // unencode the extrusion vector that we snuck into the a_pos vector vec2 unscaled_extrude = vec2(mod(a_pos, 2.0) * 2.0 - 1.0); @@ -120,33 +81,25 @@ void main(void) { gl_Position = u_matrix * pos; } - -*/ - -// Uncompressed source of heatmap.fragment.glsl: -/* -uniform highp float u_intensity; +)"; + static constexpr const char* fragment = R"(uniform highp float u_intensity; varying vec2 v_extrude; - #ifndef HAS_UNIFORM_u_weight varying highp float weight; #else uniform highp float u_weight; #endif - // Gaussian kernel coefficient: 1 / sqrt(2 * PI) #define GAUSS_COEF 0.3989422804014327 void main() { - -#ifdef HAS_UNIFORM_u_weight - highp float weight = u_weight; + #ifdef HAS_UNIFORM_u_weight +highp float weight = u_weight; #endif - // Kernel density estimation with a Gaussian kernel of size 5x5 float d = -0.5 * 3.0 * 3.0 * dot(v_extrude, v_extrude); float val = weight * u_intensity * GAUSS_COEF * exp(d); @@ -157,6 +110,8 @@ void main() { gl_FragColor = vec4(1.0); #endif } +)"; +}; -*/ -// clang-format on +} // namespace shaders +} // namespace mbgl diff --git a/include/mbgl/shaders/gl/heatmap_texture.hpp b/include/mbgl/shaders/gl/heatmap_texture.hpp new file mode 100644 index 000000000..7a8ec42e3 --- /dev/null +++ b/include/mbgl/shaders/gl/heatmap_texture.hpp @@ -0,0 +1,41 @@ +// Generated code, do not modify this file! +// Generated on 2023-04-04T01:24:40.539Z by mwilsnd using shaders/generate_shader_code.js + +#pragma once +#include + +namespace mbgl { +namespace shaders { + +template <> struct ShaderSource { + static constexpr const char* vertex = R"(uniform mat4 u_matrix; +uniform vec2 u_world; +attribute vec2 a_pos; +varying vec2 v_pos; + +void main() { + gl_Position = u_matrix * vec4(a_pos * u_world, 0, 1); + + v_pos.x = a_pos.x; + v_pos.y = 1.0 - a_pos.y; +} +)"; + static constexpr const char* fragment = R"(uniform sampler2D u_image; +uniform sampler2D u_color_ramp; +uniform float u_opacity; +varying vec2 v_pos; + +void main() { + float t = texture2D(u_image, v_pos).r; + vec4 color = texture2D(u_color_ramp, vec2(t, 0.5)); + gl_FragColor = color * u_opacity; + +#ifdef OVERDRAW_INSPECTOR + gl_FragColor = vec4(0.0); +#endif +} +)"; +}; + +} // namespace shaders +} // namespace mbgl diff --git a/src/mbgl/programs/gl/hillshade.cpp b/include/mbgl/shaders/gl/hillshade.hpp similarity index 69% rename from src/mbgl/programs/gl/hillshade.cpp rename to include/mbgl/shaders/gl/hillshade.hpp index 9985ff9af..a5f6c216b 100644 --- a/src/mbgl/programs/gl/hillshade.cpp +++ b/include/mbgl/shaders/gl/hillshade.hpp @@ -1,45 +1,14 @@ -// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. -// clang-format off -#include -#include -#include -#include +// Generated code, do not modify this file! +// Generated on 2023-04-04T01:24:40.539Z by mwilsnd using shaders/generate_shader_code.js + +#pragma once +#include namespace mbgl { -namespace programs { -namespace gl { +namespace shaders { -template -struct ShaderSource; - -template <> -struct ShaderSource { - static constexpr const char* name = "hillshade"; - static constexpr const uint8_t hash[8] = {0x8a, 0x11, 0x29, 0x18, 0x52, 0x7f, 0x3b, 0xbb}; - static constexpr const auto vertexOffset = 29333; - static constexpr const auto fragmentOffset = 29504; -}; - -constexpr const char* ShaderSource::name; -constexpr const uint8_t ShaderSource::hash[8]; - -} // namespace gl -} // namespace programs - -namespace gfx { - -template <> -std::unique_ptr> -Backend::Create(const ProgramParameters& programParameters) { - return std::make_unique>(programParameters); -} - -} // namespace gfx -} // namespace mbgl - -// Uncompressed source of hillshade.vertex.glsl: -/* -uniform mat4 u_matrix; +template <> struct ShaderSource { + static constexpr const char* vertex = R"(uniform mat4 u_matrix; attribute vec2 a_pos; attribute vec2 a_texture_pos; @@ -50,12 +19,8 @@ void main() { gl_Position = u_matrix * vec4(a_pos, 0, 1); v_pos = a_texture_pos / 8192.0; } - -*/ - -// Uncompressed source of hillshade.fragment.glsl: -/* -uniform sampler2D u_image; +)"; + static constexpr const char* fragment = R"(uniform sampler2D u_image; varying vec2 v_pos; uniform vec2 u_latrange; @@ -107,6 +72,8 @@ void main() { gl_FragColor = vec4(1.0); #endif } +)"; +}; -*/ -// clang-format on +} // namespace shaders +} // namespace mbgl diff --git a/src/mbgl/programs/gl/hillshade_prepare.cpp b/include/mbgl/shaders/gl/hillshade_prepare.hpp similarity index 68% rename from src/mbgl/programs/gl/hillshade_prepare.cpp rename to include/mbgl/shaders/gl/hillshade_prepare.hpp index 0c2ee8383..2b4dba0cf 100644 --- a/src/mbgl/programs/gl/hillshade_prepare.cpp +++ b/include/mbgl/shaders/gl/hillshade_prepare.hpp @@ -1,45 +1,14 @@ -// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. -// clang-format off -#include -#include -#include -#include +// Generated code, do not modify this file! +// Generated on 2023-04-04T01:24:40.539Z by mwilsnd using shaders/generate_shader_code.js + +#pragma once +#include namespace mbgl { -namespace programs { -namespace gl { +namespace shaders { -template -struct ShaderSource; - -template <> -struct ShaderSource { - static constexpr const char* name = "hillshade_prepare"; - static constexpr const uint8_t hash[8] = {0xbd, 0xa0, 0x8a, 0x88, 0x91, 0xe3, 0x73, 0x66}; - static constexpr const auto vertexOffset = 27906; - static constexpr const auto fragmentOffset = 28199; -}; - -constexpr const char* ShaderSource::name; -constexpr const uint8_t ShaderSource::hash[8]; - -} // namespace gl -} // namespace programs - -namespace gfx { - -template <> -std::unique_ptr> -Backend::Create(const ProgramParameters& programParameters) { - return std::make_unique>(programParameters); -} - -} // namespace gfx -} // namespace mbgl - -// Uncompressed source of hillshade_prepare.vertex.glsl: -/* -uniform mat4 u_matrix; +template <> struct ShaderSource { + static constexpr const char* vertex = R"(uniform mat4 u_matrix; uniform vec2 u_dimension; attribute vec2 a_pos; @@ -54,12 +23,8 @@ void main() { float scale = (u_dimension.x - 2.0) / u_dimension.x; v_pos = (a_texture_pos / 8192.0) * scale + epsilon; } - -*/ - -// Uncompressed source of hillshade_prepare.fragment.glsl: -/* -#ifdef GL_ES +)"; + static constexpr const char* fragment = R"(#ifdef GL_ES precision highp float; #endif @@ -133,6 +98,8 @@ void main() { gl_FragColor = vec4(1.0); #endif } +)"; +}; -*/ -// clang-format on +} // namespace shaders +} // namespace mbgl diff --git a/src/mbgl/programs/gl/line.cpp b/include/mbgl/shaders/gl/line.hpp similarity index 68% rename from src/mbgl/programs/gl/line.cpp rename to include/mbgl/shaders/gl/line.hpp index f337e5fe0..dde7fe4f9 100644 --- a/src/mbgl/programs/gl/line.cpp +++ b/include/mbgl/shaders/gl/line.hpp @@ -1,45 +1,14 @@ -// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. -// clang-format off -#include -#include -#include -#include +// Generated code, do not modify this file! +// Generated on 2023-04-04T01:24:40.539Z by mwilsnd using shaders/generate_shader_code.js + +#pragma once +#include namespace mbgl { -namespace programs { -namespace gl { +namespace shaders { -template -struct ShaderSource; - -template <> -struct ShaderSource { - static constexpr const char* name = "line"; - static constexpr const uint8_t hash[8] = {0x7f, 0x8e, 0xaa, 0x53, 0x75, 0x78, 0xac, 0x2c}; - static constexpr const auto vertexOffset = 30578; - static constexpr const auto fragmentOffset = 33575; -}; - -constexpr const char* ShaderSource::name; -constexpr const uint8_t ShaderSource::hash[8]; - -} // namespace gl -} // namespace programs - -namespace gfx { - -template <> -std::unique_ptr> -Backend::Create(const ProgramParameters& programParameters) { - return std::make_unique>(programParameters); -} - -} // namespace gfx -} // namespace mbgl - -// Uncompressed source of line.vertex.glsl: -/* -// floor(127 / 2) == 63.0 +template <> struct ShaderSource { + static constexpr const char* vertex = R"(// floor(127 / 2) == 63.0 // the maximum allowed miter limit is 2.0 at the moment. the extrude normal is // stored in a byte (-128..127). we scale regular normals up to length 63, but // there are also "special" normals that have a bigger length (of up to 126 in @@ -60,7 +29,6 @@ varying vec2 v_width2; varying float v_gamma_scale; varying highp float v_linesofar; - #ifndef HAS_UNIFORM_u_color uniform lowp float u_color_t; attribute highp vec4 a_color; @@ -68,8 +36,6 @@ varying highp vec4 color; #else uniform highp vec4 u_color; #endif - - #ifndef HAS_UNIFORM_u_blur uniform lowp float u_blur_t; attribute lowp vec2 a_blur; @@ -77,8 +43,6 @@ varying lowp float blur; #else uniform lowp float u_blur; #endif - - #ifndef HAS_UNIFORM_u_opacity uniform lowp float u_opacity_t; attribute lowp vec2 a_opacity; @@ -86,24 +50,18 @@ varying lowp float opacity; #else uniform lowp float u_opacity; #endif - - #ifndef HAS_UNIFORM_u_gapwidth uniform lowp float u_gapwidth_t; attribute mediump vec2 a_gapwidth; #else uniform mediump float u_gapwidth; #endif - - #ifndef HAS_UNIFORM_u_offset uniform lowp float u_offset_t; attribute lowp vec2 a_offset; #else uniform lowp float u_offset; #endif - - #ifndef HAS_UNIFORM_u_width uniform lowp float u_width_t; attribute mediump vec2 a_width; @@ -111,51 +69,38 @@ attribute mediump vec2 a_width; uniform mediump float u_width; #endif - void main() { - -#ifndef HAS_UNIFORM_u_color - color = unpack_mix_color(a_color, u_color_t); + #ifndef HAS_UNIFORM_u_color +color = unpack_mix_color(a_color, u_color_t); #else - highp vec4 color = u_color; +highp vec4 color = u_color; #endif - - -#ifndef HAS_UNIFORM_u_blur - blur = unpack_mix_vec2(a_blur, u_blur_t); + #ifndef HAS_UNIFORM_u_blur +blur = unpack_mix_vec2(a_blur, u_blur_t); #else - lowp float blur = u_blur; +lowp float blur = u_blur; #endif - - -#ifndef HAS_UNIFORM_u_opacity - opacity = unpack_mix_vec2(a_opacity, u_opacity_t); + #ifndef HAS_UNIFORM_u_opacity +opacity = unpack_mix_vec2(a_opacity, u_opacity_t); #else - lowp float opacity = u_opacity; +lowp float opacity = u_opacity; #endif - - -#ifndef HAS_UNIFORM_u_gapwidth - mediump float gapwidth = unpack_mix_vec2(a_gapwidth, u_gapwidth_t); + #ifndef HAS_UNIFORM_u_gapwidth +mediump float gapwidth = unpack_mix_vec2(a_gapwidth, u_gapwidth_t); #else - mediump float gapwidth = u_gapwidth; +mediump float gapwidth = u_gapwidth; #endif - - -#ifndef HAS_UNIFORM_u_offset - lowp float offset = unpack_mix_vec2(a_offset, u_offset_t); + #ifndef HAS_UNIFORM_u_offset +lowp float offset = unpack_mix_vec2(a_offset, u_offset_t); #else - lowp float offset = u_offset; +lowp float offset = u_offset; #endif - - -#ifndef HAS_UNIFORM_u_width - mediump float width = unpack_mix_vec2(a_width, u_width_t); + #ifndef HAS_UNIFORM_u_width +mediump float width = unpack_mix_vec2(a_width, u_width_t); #else - mediump float width = u_width; +mediump float width = u_width; #endif - // the distance over which the line edge fades out. // Retina devices need a smaller distance to avoid aliasing. float ANTIALIASING = 1.0 / u_device_pixel_ratio / 2.0; @@ -205,56 +150,40 @@ void main() { v_width2 = vec2(outset, inset); } - -*/ - -// Uncompressed source of line.fragment.glsl: -/* -uniform lowp float u_device_pixel_ratio; +)"; + static constexpr const char* fragment = R"(uniform lowp float u_device_pixel_ratio; varying vec2 v_width2; varying vec2 v_normal; varying float v_gamma_scale; - #ifndef HAS_UNIFORM_u_color varying highp vec4 color; #else uniform highp vec4 u_color; #endif - - #ifndef HAS_UNIFORM_u_blur varying lowp float blur; #else uniform lowp float u_blur; #endif - - #ifndef HAS_UNIFORM_u_opacity varying lowp float opacity; #else uniform lowp float u_opacity; #endif - void main() { - -#ifdef HAS_UNIFORM_u_color - highp vec4 color = u_color; + #ifdef HAS_UNIFORM_u_color +highp vec4 color = u_color; #endif - - -#ifdef HAS_UNIFORM_u_blur - lowp float blur = u_blur; + #ifdef HAS_UNIFORM_u_blur +lowp float blur = u_blur; #endif - - -#ifdef HAS_UNIFORM_u_opacity - lowp float opacity = u_opacity; + #ifdef HAS_UNIFORM_u_opacity +lowp float opacity = u_opacity; #endif - // Calculate the distance of the pixel from the line in pixels. float dist = length(v_normal) * v_width2.s; @@ -270,6 +199,8 @@ void main() { gl_FragColor = vec4(1.0); #endif } +)"; +}; -*/ -// clang-format on +} // namespace shaders +} // namespace mbgl diff --git a/src/mbgl/programs/gl/line_gradient.cpp b/include/mbgl/shaders/gl/line_gradient.hpp similarity index 70% rename from src/mbgl/programs/gl/line_gradient.cpp rename to include/mbgl/shaders/gl/line_gradient.hpp index 8358880a6..347c891f4 100644 --- a/src/mbgl/programs/gl/line_gradient.cpp +++ b/include/mbgl/shaders/gl/line_gradient.hpp @@ -1,45 +1,14 @@ -// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. -// clang-format off -#include -#include -#include -#include +// Generated code, do not modify this file! +// Generated on 2023-04-04T01:24:40.539Z by mwilsnd using shaders/generate_shader_code.js + +#pragma once +#include namespace mbgl { -namespace programs { -namespace gl { - -template -struct ShaderSource; - -template <> -struct ShaderSource { - static constexpr const char* name = "line_gradient"; - static constexpr const uint8_t hash[8] = {0x3f, 0xba, 0xc6, 0x33, 0xcd, 0x86, 0xa2, 0xe8}; - static constexpr const auto vertexOffset = 34444; - static constexpr const auto fragmentOffset = 37236; -}; - -constexpr const char* ShaderSource::name; -constexpr const uint8_t ShaderSource::hash[8]; - -} // namespace gl -} // namespace programs - -namespace gfx { - -template <> -std::unique_ptr> -Backend::Create(const ProgramParameters& programParameters) { - return std::make_unique>(programParameters); -} - -} // namespace gfx -} // namespace mbgl - -// Uncompressed source of line_gradient.vertex.glsl: -/* +namespace shaders { +template <> struct ShaderSource { + static constexpr const char* vertex = R"( // the attribute conveying progress along a line is scaled to [0, 2^15) #define MAX_LINE_DISTANCE 32767.0 @@ -64,7 +33,6 @@ varying vec2 v_width2; varying float v_gamma_scale; varying highp float v_lineprogress; - #ifndef HAS_UNIFORM_u_blur uniform lowp float u_blur_t; attribute lowp vec2 a_blur; @@ -72,8 +40,6 @@ varying lowp float blur; #else uniform lowp float u_blur; #endif - - #ifndef HAS_UNIFORM_u_opacity uniform lowp float u_opacity_t; attribute lowp vec2 a_opacity; @@ -81,24 +47,18 @@ varying lowp float opacity; #else uniform lowp float u_opacity; #endif - - #ifndef HAS_UNIFORM_u_gapwidth uniform lowp float u_gapwidth_t; attribute mediump vec2 a_gapwidth; #else uniform mediump float u_gapwidth; #endif - - #ifndef HAS_UNIFORM_u_offset uniform lowp float u_offset_t; attribute lowp vec2 a_offset; #else uniform lowp float u_offset; #endif - - #ifndef HAS_UNIFORM_u_width uniform lowp float u_width_t; attribute mediump vec2 a_width; @@ -106,44 +66,33 @@ attribute mediump vec2 a_width; uniform mediump float u_width; #endif - void main() { - -#ifndef HAS_UNIFORM_u_blur - blur = unpack_mix_vec2(a_blur, u_blur_t); + #ifndef HAS_UNIFORM_u_blur +blur = unpack_mix_vec2(a_blur, u_blur_t); #else - lowp float blur = u_blur; +lowp float blur = u_blur; #endif - - -#ifndef HAS_UNIFORM_u_opacity - opacity = unpack_mix_vec2(a_opacity, u_opacity_t); + #ifndef HAS_UNIFORM_u_opacity +opacity = unpack_mix_vec2(a_opacity, u_opacity_t); #else - lowp float opacity = u_opacity; +lowp float opacity = u_opacity; #endif - - -#ifndef HAS_UNIFORM_u_gapwidth - mediump float gapwidth = unpack_mix_vec2(a_gapwidth, u_gapwidth_t); + #ifndef HAS_UNIFORM_u_gapwidth +mediump float gapwidth = unpack_mix_vec2(a_gapwidth, u_gapwidth_t); #else - mediump float gapwidth = u_gapwidth; +mediump float gapwidth = u_gapwidth; #endif - - -#ifndef HAS_UNIFORM_u_offset - lowp float offset = unpack_mix_vec2(a_offset, u_offset_t); + #ifndef HAS_UNIFORM_u_offset +lowp float offset = unpack_mix_vec2(a_offset, u_offset_t); #else - lowp float offset = u_offset; +lowp float offset = u_offset; #endif - - -#ifndef HAS_UNIFORM_u_width - mediump float width = unpack_mix_vec2(a_width, u_width_t); + #ifndef HAS_UNIFORM_u_width +mediump float width = unpack_mix_vec2(a_width, u_width_t); #else - mediump float width = u_width; +mediump float width = u_width; #endif - // the distance over which the line edge fades out. // Retina devices need a smaller distance to avoid aliasing. float ANTIALIASING = 1.0 / u_device_pixel_ratio / 2.0; @@ -193,12 +142,8 @@ void main() { v_width2 = vec2(outset, inset); } - -*/ - -// Uncompressed source of line_gradient.fragment.glsl: -/* -uniform lowp float u_device_pixel_ratio; +)"; + static constexpr const char* fragment = R"(uniform lowp float u_device_pixel_ratio; uniform sampler2D u_image; varying vec2 v_width2; @@ -206,33 +151,25 @@ varying vec2 v_normal; varying float v_gamma_scale; varying highp float v_lineprogress; - #ifndef HAS_UNIFORM_u_blur varying lowp float blur; #else uniform lowp float u_blur; #endif - - #ifndef HAS_UNIFORM_u_opacity varying lowp float opacity; #else uniform lowp float u_opacity; #endif - void main() { - -#ifdef HAS_UNIFORM_u_blur - lowp float blur = u_blur; + #ifdef HAS_UNIFORM_u_blur +lowp float blur = u_blur; #endif - - -#ifdef HAS_UNIFORM_u_opacity - lowp float opacity = u_opacity; + #ifdef HAS_UNIFORM_u_opacity +lowp float opacity = u_opacity; #endif - // Calculate the distance of the pixel from the line in pixels. float dist = length(v_normal) * v_width2.s; @@ -252,6 +189,8 @@ void main() { gl_FragColor = vec4(1.0); #endif } +)"; +}; -*/ -// clang-format on +} // namespace shaders +} // namespace mbgl diff --git a/src/mbgl/programs/gl/line_pattern.cpp b/include/mbgl/shaders/gl/line_pattern.hpp similarity index 74% rename from src/mbgl/programs/gl/line_pattern.cpp rename to include/mbgl/shaders/gl/line_pattern.hpp index d0a5c8dd0..e35d52f4d 100644 --- a/src/mbgl/programs/gl/line_pattern.cpp +++ b/include/mbgl/shaders/gl/line_pattern.hpp @@ -1,45 +1,14 @@ -// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. -// clang-format off -#include -#include -#include -#include +// Generated code, do not modify this file! +// Generated on 2023-04-04T01:24:40.539Z by mwilsnd using shaders/generate_shader_code.js + +#pragma once +#include namespace mbgl { -namespace programs { -namespace gl { +namespace shaders { -template -struct ShaderSource; - -template <> -struct ShaderSource { - static constexpr const char* name = "line_pattern"; - static constexpr const uint8_t hash[8] = {0x38, 0x9c, 0x3d, 0xde, 0xb4, 0xe0, 0xd1, 0x61}; - static constexpr const auto vertexOffset = 38066; - static constexpr const auto fragmentOffset = 41460; -}; - -constexpr const char* ShaderSource::name; -constexpr const uint8_t ShaderSource::hash[8]; - -} // namespace gl -} // namespace programs - -namespace gfx { - -template <> -std::unique_ptr> -Backend::Create(const ProgramParameters& programParameters) { - return std::make_unique>(programParameters); -} - -} // namespace gfx -} // namespace mbgl - -// Uncompressed source of line_pattern.vertex.glsl: -/* -// floor(127 / 2) == 63.0 +template <> struct ShaderSource { + static constexpr const char* vertex = R"(// floor(127 / 2) == 63.0 // the maximum allowed miter limit is 2.0 at the moment. the extrude normal is // stored in a byte (-128..127). we scale regular normals up to length 63, but // there are also "special" normals that have a bigger length (of up to 126 in @@ -64,7 +33,6 @@ varying vec2 v_width2; varying float v_linesofar; varying float v_gamma_scale; - #ifndef HAS_UNIFORM_u_blur uniform lowp float u_blur_t; attribute lowp vec2 a_blur; @@ -72,8 +40,6 @@ varying lowp float blur; #else uniform lowp float u_blur; #endif - - #ifndef HAS_UNIFORM_u_opacity uniform lowp float u_opacity_t; attribute lowp vec2 a_opacity; @@ -81,32 +47,24 @@ varying lowp float opacity; #else uniform lowp float u_opacity; #endif - - #ifndef HAS_UNIFORM_u_offset uniform lowp float u_offset_t; attribute lowp vec2 a_offset; #else uniform lowp float u_offset; #endif - - #ifndef HAS_UNIFORM_u_gapwidth uniform lowp float u_gapwidth_t; attribute mediump vec2 a_gapwidth; #else uniform mediump float u_gapwidth; #endif - - #ifndef HAS_UNIFORM_u_width uniform lowp float u_width_t; attribute mediump vec2 a_width; #else uniform mediump float u_width; #endif - - #ifndef HAS_UNIFORM_u_pattern_from uniform lowp float u_pattern_from_t; attribute lowp vec4 a_pattern_from; @@ -114,8 +72,6 @@ varying lowp vec4 pattern_from; #else uniform lowp vec4 u_pattern_from; #endif - - #ifndef HAS_UNIFORM_u_pattern_to uniform lowp float u_pattern_to_t; attribute lowp vec4 a_pattern_to; @@ -124,58 +80,43 @@ varying lowp vec4 pattern_to; uniform lowp vec4 u_pattern_to; #endif - void main() { - -#ifndef HAS_UNIFORM_u_blur - blur = unpack_mix_vec2(a_blur, u_blur_t); + #ifndef HAS_UNIFORM_u_blur +blur = unpack_mix_vec2(a_blur, u_blur_t); #else - lowp float blur = u_blur; +lowp float blur = u_blur; #endif - - -#ifndef HAS_UNIFORM_u_opacity - opacity = unpack_mix_vec2(a_opacity, u_opacity_t); + #ifndef HAS_UNIFORM_u_opacity +opacity = unpack_mix_vec2(a_opacity, u_opacity_t); #else - lowp float opacity = u_opacity; +lowp float opacity = u_opacity; #endif - - -#ifndef HAS_UNIFORM_u_offset - lowp float offset = unpack_mix_vec2(a_offset, u_offset_t); + #ifndef HAS_UNIFORM_u_offset +lowp float offset = unpack_mix_vec2(a_offset, u_offset_t); #else - lowp float offset = u_offset; +lowp float offset = u_offset; #endif - - -#ifndef HAS_UNIFORM_u_gapwidth - mediump float gapwidth = unpack_mix_vec2(a_gapwidth, u_gapwidth_t); + #ifndef HAS_UNIFORM_u_gapwidth +mediump float gapwidth = unpack_mix_vec2(a_gapwidth, u_gapwidth_t); #else - mediump float gapwidth = u_gapwidth; +mediump float gapwidth = u_gapwidth; #endif - - -#ifndef HAS_UNIFORM_u_width - mediump float width = unpack_mix_vec2(a_width, u_width_t); + #ifndef HAS_UNIFORM_u_width +mediump float width = unpack_mix_vec2(a_width, u_width_t); #else - mediump float width = u_width; +mediump float width = u_width; #endif - - -#ifndef HAS_UNIFORM_u_pattern_from - pattern_from = a_pattern_from; + #ifndef HAS_UNIFORM_u_pattern_from +pattern_from = a_pattern_from; #else - mediump vec4 pattern_from = u_pattern_from; +mediump vec4 pattern_from = u_pattern_from; #endif - - -#ifndef HAS_UNIFORM_u_pattern_to - pattern_to = a_pattern_to; + #ifndef HAS_UNIFORM_u_pattern_to +pattern_to = a_pattern_to; #else - mediump vec4 pattern_to = u_pattern_to; +mediump vec4 pattern_to = u_pattern_to; #endif - // the distance over which the line edge fades out. // Retina devices need a smaller distance to avoid aliasing. float ANTIALIASING = 1.0 / u_device_pixel_ratio / 2.0; @@ -225,12 +166,8 @@ void main() { v_linesofar = a_linesofar; v_width2 = vec2(outset, inset); } - -*/ - -// Uncompressed source of line_pattern.fragment.glsl: -/* -uniform lowp float u_device_pixel_ratio; +)"; + static constexpr const char* fragment = R"(uniform lowp float u_device_pixel_ratio; uniform vec2 u_texsize; uniform float u_fade; uniform mediump vec4 u_scale; @@ -242,58 +179,42 @@ varying vec2 v_width2; varying float v_linesofar; varying float v_gamma_scale; - #ifndef HAS_UNIFORM_u_pattern_from varying lowp vec4 pattern_from; #else uniform lowp vec4 u_pattern_from; #endif - - #ifndef HAS_UNIFORM_u_pattern_to varying lowp vec4 pattern_to; #else uniform lowp vec4 u_pattern_to; #endif - - #ifndef HAS_UNIFORM_u_blur varying lowp float blur; #else uniform lowp float u_blur; #endif - - #ifndef HAS_UNIFORM_u_opacity varying lowp float opacity; #else uniform lowp float u_opacity; #endif - void main() { - -#ifdef HAS_UNIFORM_u_pattern_from - mediump vec4 pattern_from = u_pattern_from; + #ifdef HAS_UNIFORM_u_pattern_from +mediump vec4 pattern_from = u_pattern_from; +#endif + #ifdef HAS_UNIFORM_u_pattern_to +mediump vec4 pattern_to = u_pattern_to; #endif - -#ifdef HAS_UNIFORM_u_pattern_to - mediump vec4 pattern_to = u_pattern_to; + #ifdef HAS_UNIFORM_u_blur +lowp float blur = u_blur; #endif - - - -#ifdef HAS_UNIFORM_u_blur - lowp float blur = u_blur; + #ifdef HAS_UNIFORM_u_opacity +lowp float opacity = u_opacity; #endif - -#ifdef HAS_UNIFORM_u_opacity - lowp float opacity = u_opacity; -#endif - - vec2 pattern_tl_a = pattern_from.xy; vec2 pattern_br_a = pattern_from.zw; vec2 pattern_tl_b = pattern_to.xy; @@ -340,6 +261,8 @@ void main() { gl_FragColor = vec4(1.0); #endif } +)"; +}; -*/ -// clang-format on +} // namespace shaders +} // namespace mbgl diff --git a/src/mbgl/programs/gl/line_sdf.cpp b/include/mbgl/shaders/gl/line_sdf.hpp similarity index 71% rename from src/mbgl/programs/gl/line_sdf.cpp rename to include/mbgl/shaders/gl/line_sdf.hpp index b583fd061..c83eb930a 100644 --- a/src/mbgl/programs/gl/line_sdf.cpp +++ b/include/mbgl/shaders/gl/line_sdf.hpp @@ -1,45 +1,14 @@ -// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. -// clang-format off -#include -#include -#include -#include +// Generated code, do not modify this file! +// Generated on 2023-04-04T01:24:40.539Z by mwilsnd using shaders/generate_shader_code.js + +#pragma once +#include namespace mbgl { -namespace programs { -namespace gl { +namespace shaders { -template -struct ShaderSource; - -template <> -struct ShaderSource { - static constexpr const char* name = "line_sdf"; - static constexpr const uint8_t hash[8] = {0x25, 0x94, 0x7f, 0xad, 0x84, 0xfe, 0x96, 0xad}; - static constexpr const auto vertexOffset = 43815; - static constexpr const auto fragmentOffset = 47502; -}; - -constexpr const char* ShaderSource::name; -constexpr const uint8_t ShaderSource::hash[8]; - -} // namespace gl -} // namespace programs - -namespace gfx { - -template <> -std::unique_ptr> -Backend::Create(const ProgramParameters& programParameters) { - return std::make_unique>(programParameters); -} - -} // namespace gfx -} // namespace mbgl - -// Uncompressed source of line_sdf.vertex.glsl: -/* -// floor(127 / 2) == 63.0 +template <> struct ShaderSource { + static constexpr const char* vertex = R"(// floor(127 / 2) == 63.0 // the maximum allowed miter limit is 2.0 at the moment. the extrude normal is // stored in a byte (-128..127). we scale regular normals up to length 63, but // there are also "special" normals that have a bigger length (of up to 126 in @@ -69,7 +38,6 @@ varying vec2 v_tex_a; varying vec2 v_tex_b; varying float v_gamma_scale; - #ifndef HAS_UNIFORM_u_color uniform lowp float u_color_t; attribute highp vec4 a_color; @@ -77,8 +45,6 @@ varying highp vec4 color; #else uniform highp vec4 u_color; #endif - - #ifndef HAS_UNIFORM_u_blur uniform lowp float u_blur_t; attribute lowp vec2 a_blur; @@ -86,8 +52,6 @@ varying lowp float blur; #else uniform lowp float u_blur; #endif - - #ifndef HAS_UNIFORM_u_opacity uniform lowp float u_opacity_t; attribute lowp vec2 a_opacity; @@ -95,24 +59,18 @@ varying lowp float opacity; #else uniform lowp float u_opacity; #endif - - #ifndef HAS_UNIFORM_u_gapwidth uniform lowp float u_gapwidth_t; attribute mediump vec2 a_gapwidth; #else uniform mediump float u_gapwidth; #endif - - #ifndef HAS_UNIFORM_u_offset uniform lowp float u_offset_t; attribute lowp vec2 a_offset; #else uniform lowp float u_offset; #endif - - #ifndef HAS_UNIFORM_u_width uniform lowp float u_width_t; attribute mediump vec2 a_width; @@ -120,8 +78,6 @@ varying mediump float width; #else uniform mediump float u_width; #endif - - #ifndef HAS_UNIFORM_u_floorwidth uniform lowp float u_floorwidth_t; attribute lowp vec2 a_floorwidth; @@ -130,58 +86,43 @@ varying lowp float floorwidth; uniform lowp float u_floorwidth; #endif - void main() { - -#ifndef HAS_UNIFORM_u_color - color = unpack_mix_color(a_color, u_color_t); + #ifndef HAS_UNIFORM_u_color +color = unpack_mix_color(a_color, u_color_t); #else - highp vec4 color = u_color; +highp vec4 color = u_color; #endif - - -#ifndef HAS_UNIFORM_u_blur - blur = unpack_mix_vec2(a_blur, u_blur_t); + #ifndef HAS_UNIFORM_u_blur +blur = unpack_mix_vec2(a_blur, u_blur_t); #else - lowp float blur = u_blur; +lowp float blur = u_blur; #endif - - -#ifndef HAS_UNIFORM_u_opacity - opacity = unpack_mix_vec2(a_opacity, u_opacity_t); + #ifndef HAS_UNIFORM_u_opacity +opacity = unpack_mix_vec2(a_opacity, u_opacity_t); #else - lowp float opacity = u_opacity; +lowp float opacity = u_opacity; #endif - - -#ifndef HAS_UNIFORM_u_gapwidth - mediump float gapwidth = unpack_mix_vec2(a_gapwidth, u_gapwidth_t); + #ifndef HAS_UNIFORM_u_gapwidth +mediump float gapwidth = unpack_mix_vec2(a_gapwidth, u_gapwidth_t); #else - mediump float gapwidth = u_gapwidth; +mediump float gapwidth = u_gapwidth; #endif - - -#ifndef HAS_UNIFORM_u_offset - lowp float offset = unpack_mix_vec2(a_offset, u_offset_t); + #ifndef HAS_UNIFORM_u_offset +lowp float offset = unpack_mix_vec2(a_offset, u_offset_t); #else - lowp float offset = u_offset; +lowp float offset = u_offset; #endif - - -#ifndef HAS_UNIFORM_u_width - width = unpack_mix_vec2(a_width, u_width_t); + #ifndef HAS_UNIFORM_u_width +width = unpack_mix_vec2(a_width, u_width_t); #else - mediump float width = u_width; +mediump float width = u_width; #endif - - -#ifndef HAS_UNIFORM_u_floorwidth - floorwidth = unpack_mix_vec2(a_floorwidth, u_floorwidth_t); + #ifndef HAS_UNIFORM_u_floorwidth +floorwidth = unpack_mix_vec2(a_floorwidth, u_floorwidth_t); #else - lowp float floorwidth = u_floorwidth; +lowp float floorwidth = u_floorwidth; #endif - // the distance over which the line edge fades out. // Retina devices need a smaller distance to avoid aliasing. float ANTIALIASING = 1.0 / u_device_pixel_ratio / 2.0; @@ -233,12 +174,8 @@ void main() { v_width2 = vec2(outset, inset); } - -*/ - -// Uncompressed source of line_sdf.fragment.glsl: -/* - +)"; + static constexpr const char* fragment = R"( uniform lowp float u_device_pixel_ratio; uniform sampler2D u_image; uniform float u_sdfgamma; @@ -250,69 +187,49 @@ varying vec2 v_tex_a; varying vec2 v_tex_b; varying float v_gamma_scale; - #ifndef HAS_UNIFORM_u_color varying highp vec4 color; #else uniform highp vec4 u_color; #endif - - #ifndef HAS_UNIFORM_u_blur varying lowp float blur; #else uniform lowp float u_blur; #endif - - #ifndef HAS_UNIFORM_u_opacity varying lowp float opacity; #else uniform lowp float u_opacity; #endif - - #ifndef HAS_UNIFORM_u_width varying mediump float width; #else uniform mediump float u_width; #endif - - #ifndef HAS_UNIFORM_u_floorwidth varying lowp float floorwidth; #else uniform lowp float u_floorwidth; #endif - void main() { - -#ifdef HAS_UNIFORM_u_color - highp vec4 color = u_color; + #ifdef HAS_UNIFORM_u_color +highp vec4 color = u_color; #endif - - -#ifdef HAS_UNIFORM_u_blur - lowp float blur = u_blur; + #ifdef HAS_UNIFORM_u_blur +lowp float blur = u_blur; #endif - - -#ifdef HAS_UNIFORM_u_opacity - lowp float opacity = u_opacity; + #ifdef HAS_UNIFORM_u_opacity +lowp float opacity = u_opacity; #endif - - -#ifdef HAS_UNIFORM_u_width - mediump float width = u_width; + #ifdef HAS_UNIFORM_u_width +mediump float width = u_width; #endif - - -#ifdef HAS_UNIFORM_u_floorwidth - lowp float floorwidth = u_floorwidth; + #ifdef HAS_UNIFORM_u_floorwidth +lowp float floorwidth = u_floorwidth; #endif - // Calculate the distance of the pixel from the line in pixels. float dist = length(v_normal) * v_width2.s; @@ -333,6 +250,8 @@ void main() { gl_FragColor = vec4(1.0); #endif } +)"; +}; -*/ -// clang-format on +} // namespace shaders +} // namespace mbgl diff --git a/include/mbgl/shaders/gl/prelude.hpp b/include/mbgl/shaders/gl/prelude.hpp new file mode 100644 index 000000000..7aeb888de --- /dev/null +++ b/include/mbgl/shaders/gl/prelude.hpp @@ -0,0 +1,106 @@ +// Generated code, do not modify this file! +// Generated on 2023-04-04T01:24:40.539Z by mwilsnd using shaders/generate_shader_code.js + +#pragma once +#include + +namespace mbgl { +namespace shaders { + +template <> struct ShaderSource { + static constexpr const char* vertex = R"(#ifdef GL_ES +precision highp float; +#else + +#if !defined(lowp) +#define lowp +#endif + +#if !defined(mediump) +#define mediump +#endif + +#if !defined(highp) +#define highp +#endif + +#endif + +// Unpack a pair of values that have been packed into a single float. +// The packed values are assumed to be 8-bit unsigned integers, and are +// packed like so: +// packedValue = floor(input[0]) * 256 + input[1], +vec2 unpack_float(const float packedValue) { + int packedIntValue = int(packedValue); + int v0 = packedIntValue / 256; + return vec2(v0, packedIntValue - v0 * 256); +} + +vec2 unpack_opacity(const float packedOpacity) { + int intOpacity = int(packedOpacity) / 2; + return vec2(float(intOpacity) / 127.0, mod(packedOpacity, 2.0)); +} + +// To minimize the number of attributes needed, we encode a 4-component +// color into a pair of floats (i.e. a vec2) as follows: +// [ floor(color.r * 255) * 256 + color.g * 255, +// floor(color.b * 255) * 256 + color.g * 255 ] +vec4 decode_color(const vec2 encodedColor) { + return vec4( + unpack_float(encodedColor[0]) / 255.0, + unpack_float(encodedColor[1]) / 255.0 + ); +} + +// Unpack a pair of paint values and interpolate between them. +float unpack_mix_vec2(const vec2 packedValue, const float t) { + return mix(packedValue[0], packedValue[1], t); +} + +// Unpack a pair of paint values and interpolate between them. +vec4 unpack_mix_color(const vec4 packedColors, const float t) { + vec4 minColor = decode_color(vec2(packedColors[0], packedColors[1])); + vec4 maxColor = decode_color(vec2(packedColors[2], packedColors[3])); + return mix(minColor, maxColor, t); +} + +// The offset depends on how many pixels are between the world origin and the edge of the tile: +// vec2 offset = mod(pixel_coord, size) +// +// At high zoom levels there are a ton of pixels between the world origin and the edge of the tile. +// The glsl spec only guarantees 16 bits of precision for highp floats. We need more than that. +// +// The pixel_coord is passed in as two 16 bit values: +// pixel_coord_upper = floor(pixel_coord / 2^16) +// pixel_coord_lower = mod(pixel_coord, 2^16) +// +// The offset is calculated in a series of steps that should preserve this precision: +vec2 get_pattern_pos(const vec2 pixel_coord_upper, const vec2 pixel_coord_lower, + const vec2 pattern_size, const float tile_units_to_pixels, const vec2 pos) { + + vec2 offset = mod(mod(mod(pixel_coord_upper, pattern_size) * 256.0, pattern_size) * 256.0 + pixel_coord_lower, pattern_size); + return (tile_units_to_pixels * pos + offset) / pattern_size; +} +)"; + static constexpr const char* fragment = R"(#ifdef GL_ES +precision mediump float; +#else + +#if !defined(lowp) +#define lowp +#endif + +#if !defined(mediump) +#define mediump +#endif + +#if !defined(highp) +#define highp +#endif + +#endif +)"; +}; + +} // namespace shaders +} // namespace mbgl diff --git a/src/mbgl/programs/gl/raster.cpp b/include/mbgl/shaders/gl/raster.hpp similarity index 64% rename from src/mbgl/programs/gl/raster.cpp rename to include/mbgl/shaders/gl/raster.hpp index d18f411e6..8f693fe5b 100644 --- a/src/mbgl/programs/gl/raster.cpp +++ b/include/mbgl/shaders/gl/raster.hpp @@ -1,45 +1,14 @@ -// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. -// clang-format off -#include -#include -#include -#include +// Generated code, do not modify this file! +// Generated on 2023-04-04T01:24:40.539Z by mwilsnd using shaders/generate_shader_code.js + +#pragma once +#include namespace mbgl { -namespace programs { -namespace gl { +namespace shaders { -template -struct ShaderSource; - -template <> -struct ShaderSource { - static constexpr const char* name = "raster"; - static constexpr const uint8_t hash[8] = {0x40, 0x3d, 0x6c, 0xf4, 0xd0, 0x41, 0x51, 0x0e}; - static constexpr const auto vertexOffset = 49047; - static constexpr const auto fragmentOffset = 49396; -}; - -constexpr const char* ShaderSource::name; -constexpr const uint8_t ShaderSource::hash[8]; - -} // namespace gl -} // namespace programs - -namespace gfx { - -template <> -std::unique_ptr> -Backend::Create(const ProgramParameters& programParameters) { - return std::make_unique>(programParameters); -} - -} // namespace gfx -} // namespace mbgl - -// Uncompressed source of raster.vertex.glsl: -/* -uniform mat4 u_matrix; +template <> struct ShaderSource { + static constexpr const char* vertex = R"(uniform mat4 u_matrix; uniform vec2 u_tl_parent; uniform float u_scale_parent; uniform float u_buffer_scale; @@ -60,12 +29,8 @@ void main() { v_pos0 = (((a_texture_pos / 8192.0) - 0.5) / u_buffer_scale ) + 0.5; v_pos1 = (v_pos0 * u_scale_parent) + u_tl_parent; } - -*/ - -// Uncompressed source of raster.fragment.glsl: -/* -uniform float u_fade_t; +)"; + static constexpr const char* fragment = R"(uniform float u_fade_t; uniform float u_opacity; uniform sampler2D u_image0; uniform sampler2D u_image1; @@ -117,6 +82,8 @@ void main() { gl_FragColor = vec4(1.0); #endif } +)"; +}; -*/ -// clang-format on +} // namespace shaders +} // namespace mbgl diff --git a/src/mbgl/programs/gl/symbol_icon.cpp b/include/mbgl/shaders/gl/symbol_icon.hpp similarity index 71% rename from src/mbgl/programs/gl/symbol_icon.cpp rename to include/mbgl/shaders/gl/symbol_icon.hpp index 8b8fc2d2a..9f60574ac 100644 --- a/src/mbgl/programs/gl/symbol_icon.cpp +++ b/include/mbgl/shaders/gl/symbol_icon.hpp @@ -1,45 +1,14 @@ -// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. -// clang-format off -#include -#include -#include -#include +// Generated code, do not modify this file! +// Generated on 2023-04-04T01:24:40.539Z by mwilsnd using shaders/generate_shader_code.js + +#pragma once +#include namespace mbgl { -namespace programs { -namespace gl { +namespace shaders { -template -struct ShaderSource; - -template <> -struct ShaderSource { - static constexpr const char* name = "symbol_icon"; - static constexpr const uint8_t hash[8] = {0xa9, 0xd8, 0x73, 0xdf, 0xd9, 0xd8, 0x82, 0xf2}; - static constexpr const auto vertexOffset = 50455; - static constexpr const auto fragmentOffset = 53204; -}; - -constexpr const char* ShaderSource::name; -constexpr const uint8_t ShaderSource::hash[8]; - -} // namespace gl -} // namespace programs - -namespace gfx { - -template <> -std::unique_ptr> -Backend::Create(const ProgramParameters& programParameters) { - return std::make_unique>(programParameters); -} - -} // namespace gfx -} // namespace mbgl - -// Uncompressed source of symbol_icon.vertex.glsl: -/* -const float PI = 3.141592653589793; +template <> struct ShaderSource { + static constexpr const char* vertex = R"(const float PI = 3.141592653589793; attribute vec4 a_pos_offset; attribute vec4 a_data; @@ -69,7 +38,6 @@ uniform vec2 u_texsize; varying vec2 v_tex; varying float v_fade_opacity; - #ifndef HAS_UNIFORM_u_opacity uniform lowp float u_opacity_t; attribute lowp vec2 a_opacity; @@ -78,16 +46,13 @@ varying lowp float opacity; uniform lowp float u_opacity; #endif - void main() { - -#ifndef HAS_UNIFORM_u_opacity - opacity = unpack_mix_vec2(a_opacity, u_opacity_t); + #ifndef HAS_UNIFORM_u_opacity +opacity = unpack_mix_vec2(a_opacity, u_opacity_t); #else - lowp float opacity = u_opacity; +lowp float opacity = u_opacity; #endif - vec2 a_pos = a_pos_offset.xy; vec2 a_offset = a_pos_offset.zw; @@ -147,31 +112,23 @@ void main() { float fade_change = fade_opacity[1] > 0.5 ? u_fade_change : -u_fade_change; v_fade_opacity = max(0.0, min(1.0, fade_opacity[0] + fade_change)); } - -*/ - -// Uncompressed source of symbol_icon.fragment.glsl: -/* -uniform sampler2D u_texture; +)"; + static constexpr const char* fragment = R"(uniform sampler2D u_texture; varying vec2 v_tex; varying float v_fade_opacity; - #ifndef HAS_UNIFORM_u_opacity varying lowp float opacity; #else uniform lowp float u_opacity; #endif - void main() { - -#ifdef HAS_UNIFORM_u_opacity - lowp float opacity = u_opacity; + #ifdef HAS_UNIFORM_u_opacity +lowp float opacity = u_opacity; #endif - lowp float alpha = opacity * v_fade_opacity; gl_FragColor = texture2D(u_texture, v_tex) * alpha; @@ -179,6 +136,8 @@ void main() { gl_FragColor = vec4(1.0); #endif } +)"; +}; -*/ -// clang-format on +} // namespace shaders +} // namespace mbgl diff --git a/src/mbgl/programs/gl/symbol_sdf_text.cpp b/include/mbgl/shaders/gl/symbol_sdf_icon.hpp similarity index 74% rename from src/mbgl/programs/gl/symbol_sdf_text.cpp rename to include/mbgl/shaders/gl/symbol_sdf_icon.hpp index 017d8cb31..e657932ef 100644 --- a/src/mbgl/programs/gl/symbol_sdf_text.cpp +++ b/include/mbgl/shaders/gl/symbol_sdf_icon.hpp @@ -1,45 +1,14 @@ -// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. -// clang-format off -#include -#include -#include -#include +// Generated code, do not modify this file! +// Generated on 2023-04-04T01:24:40.539Z by mwilsnd using shaders/generate_shader_code.js + +#pragma once +#include namespace mbgl { -namespace programs { -namespace gl { +namespace shaders { -template -struct ShaderSource; - -template <> -struct ShaderSource { - static constexpr const char* name = "symbol_sdf_text"; - static constexpr const uint8_t hash[8] = {0x46, 0xe9, 0x60, 0xde, 0x1e, 0x85, 0x36, 0x54}; - static constexpr const auto vertexOffset = 53609; - static constexpr const auto fragmentOffset = 57649; -}; - -constexpr const char* ShaderSource::name; -constexpr const uint8_t ShaderSource::hash[8]; - -} // namespace gl -} // namespace programs - -namespace gfx { - -template <> -std::unique_ptr> -Backend::Create(const ProgramParameters& programParameters) { - return std::make_unique>(programParameters); -} - -} // namespace gfx -} // namespace mbgl - -// Uncompressed source of symbol_sdf_text.vertex.glsl: -/* -const float PI = 3.141592653589793; +template <> struct ShaderSource { + static constexpr const char* vertex = R"(const float PI = 3.141592653589793; attribute vec4 a_pos_offset; attribute vec4 a_data; @@ -73,7 +42,6 @@ uniform vec2 u_texsize; varying vec2 v_data0; varying vec3 v_data1; - #ifndef HAS_UNIFORM_u_fill_color uniform lowp float u_fill_color_t; attribute highp vec4 a_fill_color; @@ -81,8 +49,6 @@ varying highp vec4 fill_color; #else uniform highp vec4 u_fill_color; #endif - - #ifndef HAS_UNIFORM_u_halo_color uniform lowp float u_halo_color_t; attribute highp vec4 a_halo_color; @@ -90,8 +56,6 @@ varying highp vec4 halo_color; #else uniform highp vec4 u_halo_color; #endif - - #ifndef HAS_UNIFORM_u_opacity uniform lowp float u_opacity_t; attribute lowp vec2 a_opacity; @@ -99,8 +63,6 @@ varying lowp float opacity; #else uniform lowp float u_opacity; #endif - - #ifndef HAS_UNIFORM_u_halo_width uniform lowp float u_halo_width_t; attribute lowp vec2 a_halo_width; @@ -108,8 +70,6 @@ varying lowp float halo_width; #else uniform lowp float u_halo_width; #endif - - #ifndef HAS_UNIFORM_u_halo_blur uniform lowp float u_halo_blur_t; attribute lowp vec2 a_halo_blur; @@ -118,44 +78,33 @@ varying lowp float halo_blur; uniform lowp float u_halo_blur; #endif - void main() { - -#ifndef HAS_UNIFORM_u_fill_color - fill_color = unpack_mix_color(a_fill_color, u_fill_color_t); + #ifndef HAS_UNIFORM_u_fill_color +fill_color = unpack_mix_color(a_fill_color, u_fill_color_t); #else - highp vec4 fill_color = u_fill_color; +highp vec4 fill_color = u_fill_color; #endif - - -#ifndef HAS_UNIFORM_u_halo_color - halo_color = unpack_mix_color(a_halo_color, u_halo_color_t); + #ifndef HAS_UNIFORM_u_halo_color +halo_color = unpack_mix_color(a_halo_color, u_halo_color_t); #else - highp vec4 halo_color = u_halo_color; +highp vec4 halo_color = u_halo_color; #endif - - -#ifndef HAS_UNIFORM_u_opacity - opacity = unpack_mix_vec2(a_opacity, u_opacity_t); + #ifndef HAS_UNIFORM_u_opacity +opacity = unpack_mix_vec2(a_opacity, u_opacity_t); #else - lowp float opacity = u_opacity; +lowp float opacity = u_opacity; #endif - - -#ifndef HAS_UNIFORM_u_halo_width - halo_width = unpack_mix_vec2(a_halo_width, u_halo_width_t); + #ifndef HAS_UNIFORM_u_halo_width +halo_width = unpack_mix_vec2(a_halo_width, u_halo_width_t); #else - lowp float halo_width = u_halo_width; +lowp float halo_width = u_halo_width; #endif - - -#ifndef HAS_UNIFORM_u_halo_blur - halo_blur = unpack_mix_vec2(a_halo_blur, u_halo_blur_t); + #ifndef HAS_UNIFORM_u_halo_blur +halo_blur = unpack_mix_vec2(a_halo_blur, u_halo_blur_t); #else - lowp float halo_blur = u_halo_blur; +lowp float halo_blur = u_halo_blur; #endif - vec2 a_pos = a_pos_offset.xy; vec2 a_offset = a_pos_offset.zw; @@ -224,12 +173,8 @@ void main() { v_data0 = a_tex / u_texsize; v_data1 = vec3(gamma_scale, size, interpolated_fade_opacity); } - -*/ - -// Uncompressed source of symbol_sdf_text.fragment.glsl: -/* -#define SDF_PX 8.0 +)"; + static constexpr const char* fragment = R"(#define SDF_PX 8.0 uniform bool u_is_halo; uniform sampler2D u_texture; @@ -240,69 +185,49 @@ uniform bool u_is_text; varying vec2 v_data0; varying vec3 v_data1; - #ifndef HAS_UNIFORM_u_fill_color varying highp vec4 fill_color; #else uniform highp vec4 u_fill_color; #endif - - #ifndef HAS_UNIFORM_u_halo_color varying highp vec4 halo_color; #else uniform highp vec4 u_halo_color; #endif - - #ifndef HAS_UNIFORM_u_opacity varying lowp float opacity; #else uniform lowp float u_opacity; #endif - - #ifndef HAS_UNIFORM_u_halo_width varying lowp float halo_width; #else uniform lowp float u_halo_width; #endif - - #ifndef HAS_UNIFORM_u_halo_blur varying lowp float halo_blur; #else uniform lowp float u_halo_blur; #endif - void main() { - -#ifdef HAS_UNIFORM_u_fill_color - highp vec4 fill_color = u_fill_color; + #ifdef HAS_UNIFORM_u_fill_color +highp vec4 fill_color = u_fill_color; #endif - - -#ifdef HAS_UNIFORM_u_halo_color - highp vec4 halo_color = u_halo_color; + #ifdef HAS_UNIFORM_u_halo_color +highp vec4 halo_color = u_halo_color; #endif - - -#ifdef HAS_UNIFORM_u_opacity - lowp float opacity = u_opacity; + #ifdef HAS_UNIFORM_u_opacity +lowp float opacity = u_opacity; #endif - - -#ifdef HAS_UNIFORM_u_halo_width - lowp float halo_width = u_halo_width; + #ifdef HAS_UNIFORM_u_halo_width +lowp float halo_width = u_halo_width; #endif - - -#ifdef HAS_UNIFORM_u_halo_blur - lowp float halo_blur = u_halo_blur; + #ifdef HAS_UNIFORM_u_halo_blur +lowp float halo_blur = u_halo_blur; #endif - float EDGE_GAMMA = 0.105 / u_device_pixel_ratio; vec2 tex = v_data0.xy; @@ -331,6 +256,8 @@ void main() { gl_FragColor = vec4(1.0); #endif } +)"; +}; -*/ -// clang-format on +} // namespace shaders +} // namespace mbgl diff --git a/src/mbgl/programs/gl/symbol_sdf_icon.cpp b/include/mbgl/shaders/gl/symbol_sdf_text.hpp similarity index 74% rename from src/mbgl/programs/gl/symbol_sdf_icon.cpp rename to include/mbgl/shaders/gl/symbol_sdf_text.hpp index bf49137c1..bb299a03e 100644 --- a/src/mbgl/programs/gl/symbol_sdf_icon.cpp +++ b/include/mbgl/shaders/gl/symbol_sdf_text.hpp @@ -1,45 +1,14 @@ -// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. -// clang-format off -#include -#include -#include -#include +// Generated code, do not modify this file! +// Generated on 2023-04-04T01:24:40.539Z by mwilsnd using shaders/generate_shader_code.js + +#pragma once +#include namespace mbgl { -namespace programs { -namespace gl { +namespace shaders { -template -struct ShaderSource; - -template <> -struct ShaderSource { - static constexpr const char* name = "symbol_sdf_icon"; - static constexpr const uint8_t hash[8] = {0x46, 0xe9, 0x60, 0xde, 0x1e, 0x85, 0x36, 0x54}; - static constexpr const auto vertexOffset = 53609; - static constexpr const auto fragmentOffset = 57649; -}; - -constexpr const char* ShaderSource::name; -constexpr const uint8_t ShaderSource::hash[8]; - -} // namespace gl -} // namespace programs - -namespace gfx { - -template <> -std::unique_ptr> -Backend::Create(const ProgramParameters& programParameters) { - return std::make_unique>(programParameters); -} - -} // namespace gfx -} // namespace mbgl - -// Uncompressed source of symbol_sdf_icon.vertex.glsl: -/* -const float PI = 3.141592653589793; +template <> struct ShaderSource { + static constexpr const char* vertex = R"(const float PI = 3.141592653589793; attribute vec4 a_pos_offset; attribute vec4 a_data; @@ -73,7 +42,6 @@ uniform vec2 u_texsize; varying vec2 v_data0; varying vec3 v_data1; - #ifndef HAS_UNIFORM_u_fill_color uniform lowp float u_fill_color_t; attribute highp vec4 a_fill_color; @@ -81,8 +49,6 @@ varying highp vec4 fill_color; #else uniform highp vec4 u_fill_color; #endif - - #ifndef HAS_UNIFORM_u_halo_color uniform lowp float u_halo_color_t; attribute highp vec4 a_halo_color; @@ -90,8 +56,6 @@ varying highp vec4 halo_color; #else uniform highp vec4 u_halo_color; #endif - - #ifndef HAS_UNIFORM_u_opacity uniform lowp float u_opacity_t; attribute lowp vec2 a_opacity; @@ -99,8 +63,6 @@ varying lowp float opacity; #else uniform lowp float u_opacity; #endif - - #ifndef HAS_UNIFORM_u_halo_width uniform lowp float u_halo_width_t; attribute lowp vec2 a_halo_width; @@ -108,8 +70,6 @@ varying lowp float halo_width; #else uniform lowp float u_halo_width; #endif - - #ifndef HAS_UNIFORM_u_halo_blur uniform lowp float u_halo_blur_t; attribute lowp vec2 a_halo_blur; @@ -118,44 +78,33 @@ varying lowp float halo_blur; uniform lowp float u_halo_blur; #endif - void main() { - -#ifndef HAS_UNIFORM_u_fill_color - fill_color = unpack_mix_color(a_fill_color, u_fill_color_t); + #ifndef HAS_UNIFORM_u_fill_color +fill_color = unpack_mix_color(a_fill_color, u_fill_color_t); #else - highp vec4 fill_color = u_fill_color; +highp vec4 fill_color = u_fill_color; #endif - - -#ifndef HAS_UNIFORM_u_halo_color - halo_color = unpack_mix_color(a_halo_color, u_halo_color_t); + #ifndef HAS_UNIFORM_u_halo_color +halo_color = unpack_mix_color(a_halo_color, u_halo_color_t); #else - highp vec4 halo_color = u_halo_color; +highp vec4 halo_color = u_halo_color; #endif - - -#ifndef HAS_UNIFORM_u_opacity - opacity = unpack_mix_vec2(a_opacity, u_opacity_t); + #ifndef HAS_UNIFORM_u_opacity +opacity = unpack_mix_vec2(a_opacity, u_opacity_t); #else - lowp float opacity = u_opacity; +lowp float opacity = u_opacity; #endif - - -#ifndef HAS_UNIFORM_u_halo_width - halo_width = unpack_mix_vec2(a_halo_width, u_halo_width_t); + #ifndef HAS_UNIFORM_u_halo_width +halo_width = unpack_mix_vec2(a_halo_width, u_halo_width_t); #else - lowp float halo_width = u_halo_width; +lowp float halo_width = u_halo_width; #endif - - -#ifndef HAS_UNIFORM_u_halo_blur - halo_blur = unpack_mix_vec2(a_halo_blur, u_halo_blur_t); + #ifndef HAS_UNIFORM_u_halo_blur +halo_blur = unpack_mix_vec2(a_halo_blur, u_halo_blur_t); #else - lowp float halo_blur = u_halo_blur; +lowp float halo_blur = u_halo_blur; #endif - vec2 a_pos = a_pos_offset.xy; vec2 a_offset = a_pos_offset.zw; @@ -224,12 +173,8 @@ void main() { v_data0 = a_tex / u_texsize; v_data1 = vec3(gamma_scale, size, interpolated_fade_opacity); } - -*/ - -// Uncompressed source of symbol_sdf_icon.fragment.glsl: -/* -#define SDF_PX 8.0 +)"; + static constexpr const char* fragment = R"(#define SDF_PX 8.0 uniform bool u_is_halo; uniform sampler2D u_texture; @@ -240,69 +185,49 @@ uniform bool u_is_text; varying vec2 v_data0; varying vec3 v_data1; - #ifndef HAS_UNIFORM_u_fill_color varying highp vec4 fill_color; #else uniform highp vec4 u_fill_color; #endif - - #ifndef HAS_UNIFORM_u_halo_color varying highp vec4 halo_color; #else uniform highp vec4 u_halo_color; #endif - - #ifndef HAS_UNIFORM_u_opacity varying lowp float opacity; #else uniform lowp float u_opacity; #endif - - #ifndef HAS_UNIFORM_u_halo_width varying lowp float halo_width; #else uniform lowp float u_halo_width; #endif - - #ifndef HAS_UNIFORM_u_halo_blur varying lowp float halo_blur; #else uniform lowp float u_halo_blur; #endif - void main() { - -#ifdef HAS_UNIFORM_u_fill_color - highp vec4 fill_color = u_fill_color; + #ifdef HAS_UNIFORM_u_fill_color +highp vec4 fill_color = u_fill_color; #endif - - -#ifdef HAS_UNIFORM_u_halo_color - highp vec4 halo_color = u_halo_color; + #ifdef HAS_UNIFORM_u_halo_color +highp vec4 halo_color = u_halo_color; #endif - - -#ifdef HAS_UNIFORM_u_opacity - lowp float opacity = u_opacity; + #ifdef HAS_UNIFORM_u_opacity +lowp float opacity = u_opacity; #endif - - -#ifdef HAS_UNIFORM_u_halo_width - lowp float halo_width = u_halo_width; + #ifdef HAS_UNIFORM_u_halo_width +lowp float halo_width = u_halo_width; #endif - - -#ifdef HAS_UNIFORM_u_halo_blur - lowp float halo_blur = u_halo_blur; + #ifdef HAS_UNIFORM_u_halo_blur +lowp float halo_blur = u_halo_blur; #endif - float EDGE_GAMMA = 0.105 / u_device_pixel_ratio; vec2 tex = v_data0.xy; @@ -331,6 +256,8 @@ void main() { gl_FragColor = vec4(1.0); #endif } +)"; +}; -*/ -// clang-format on +} // namespace shaders +} // namespace mbgl diff --git a/src/mbgl/programs/gl/symbol_text_and_icon.cpp b/include/mbgl/shaders/gl/symbol_text_and_icon.hpp similarity index 74% rename from src/mbgl/programs/gl/symbol_text_and_icon.cpp rename to include/mbgl/shaders/gl/symbol_text_and_icon.hpp index a86702290..0e7e72b56 100644 --- a/src/mbgl/programs/gl/symbol_text_and_icon.cpp +++ b/include/mbgl/shaders/gl/symbol_text_and_icon.hpp @@ -1,45 +1,14 @@ -// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. -// clang-format off -#include -#include -#include -#include +// Generated code, do not modify this file! +// Generated on 2023-04-04T01:24:40.539Z by mwilsnd using shaders/generate_shader_code.js + +#pragma once +#include namespace mbgl { -namespace programs { -namespace gl { +namespace shaders { -template -struct ShaderSource; - -template <> -struct ShaderSource { - static constexpr const char* name = "symbol_text_and_icon"; - static constexpr const uint8_t hash[8] = {0x7e, 0xbe, 0x72, 0x43, 0x55, 0x8e, 0xb5, 0xeb}; - static constexpr const auto vertexOffset = 59485; - static constexpr const auto fragmentOffset = 63541; -}; - -constexpr const char* ShaderSource::name; -constexpr const uint8_t ShaderSource::hash[8]; - -} // namespace gl -} // namespace programs - -namespace gfx { - -template <> -std::unique_ptr> -Backend::Create(const ProgramParameters& programParameters) { - return std::make_unique>(programParameters); -} - -} // namespace gfx -} // namespace mbgl - -// Uncompressed source of symbol_text_and_icon.vertex.glsl: -/* -const float PI = 3.141592653589793; +template <> struct ShaderSource { + static constexpr const char* vertex = R"(const float PI = 3.141592653589793; attribute vec4 a_pos_offset; attribute vec4 a_data; @@ -73,7 +42,6 @@ uniform vec2 u_texsize_icon; varying vec4 v_data0; varying vec4 v_data1; - #ifndef HAS_UNIFORM_u_fill_color uniform lowp float u_fill_color_t; attribute highp vec4 a_fill_color; @@ -81,8 +49,6 @@ varying highp vec4 fill_color; #else uniform highp vec4 u_fill_color; #endif - - #ifndef HAS_UNIFORM_u_halo_color uniform lowp float u_halo_color_t; attribute highp vec4 a_halo_color; @@ -90,8 +56,6 @@ varying highp vec4 halo_color; #else uniform highp vec4 u_halo_color; #endif - - #ifndef HAS_UNIFORM_u_opacity uniform lowp float u_opacity_t; attribute lowp vec2 a_opacity; @@ -99,8 +63,6 @@ varying lowp float opacity; #else uniform lowp float u_opacity; #endif - - #ifndef HAS_UNIFORM_u_halo_width uniform lowp float u_halo_width_t; attribute lowp vec2 a_halo_width; @@ -108,8 +70,6 @@ varying lowp float halo_width; #else uniform lowp float u_halo_width; #endif - - #ifndef HAS_UNIFORM_u_halo_blur uniform lowp float u_halo_blur_t; attribute lowp vec2 a_halo_blur; @@ -118,44 +78,33 @@ varying lowp float halo_blur; uniform lowp float u_halo_blur; #endif - void main() { - -#ifndef HAS_UNIFORM_u_fill_color - fill_color = unpack_mix_color(a_fill_color, u_fill_color_t); + #ifndef HAS_UNIFORM_u_fill_color +fill_color = unpack_mix_color(a_fill_color, u_fill_color_t); #else - highp vec4 fill_color = u_fill_color; +highp vec4 fill_color = u_fill_color; #endif - - -#ifndef HAS_UNIFORM_u_halo_color - halo_color = unpack_mix_color(a_halo_color, u_halo_color_t); + #ifndef HAS_UNIFORM_u_halo_color +halo_color = unpack_mix_color(a_halo_color, u_halo_color_t); #else - highp vec4 halo_color = u_halo_color; +highp vec4 halo_color = u_halo_color; #endif - - -#ifndef HAS_UNIFORM_u_opacity - opacity = unpack_mix_vec2(a_opacity, u_opacity_t); + #ifndef HAS_UNIFORM_u_opacity +opacity = unpack_mix_vec2(a_opacity, u_opacity_t); #else - lowp float opacity = u_opacity; +lowp float opacity = u_opacity; #endif - - -#ifndef HAS_UNIFORM_u_halo_width - halo_width = unpack_mix_vec2(a_halo_width, u_halo_width_t); + #ifndef HAS_UNIFORM_u_halo_width +halo_width = unpack_mix_vec2(a_halo_width, u_halo_width_t); #else - lowp float halo_width = u_halo_width; +lowp float halo_width = u_halo_width; #endif - - -#ifndef HAS_UNIFORM_u_halo_blur - halo_blur = unpack_mix_vec2(a_halo_blur, u_halo_blur_t); + #ifndef HAS_UNIFORM_u_halo_blur +halo_blur = unpack_mix_vec2(a_halo_blur, u_halo_blur_t); #else - lowp float halo_blur = u_halo_blur; +lowp float halo_blur = u_halo_blur; #endif - vec2 a_pos = a_pos_offset.xy; vec2 a_offset = a_pos_offset.zw; @@ -225,12 +174,8 @@ void main() { v_data0.zw = a_tex / u_texsize_icon; v_data1 = vec4(gamma_scale, size, interpolated_fade_opacity, is_sdf); } - -*/ - -// Uncompressed source of symbol_text_and_icon.fragment.glsl: -/* -#define SDF_PX 8.0 +)"; + static constexpr const char* fragment = R"(#define SDF_PX 8.0 #define SDF 1.0 #define ICON 0.0 @@ -244,69 +189,49 @@ uniform lowp float u_device_pixel_ratio; varying vec4 v_data0; varying vec4 v_data1; - #ifndef HAS_UNIFORM_u_fill_color varying highp vec4 fill_color; #else uniform highp vec4 u_fill_color; #endif - - #ifndef HAS_UNIFORM_u_halo_color varying highp vec4 halo_color; #else uniform highp vec4 u_halo_color; #endif - - #ifndef HAS_UNIFORM_u_opacity varying lowp float opacity; #else uniform lowp float u_opacity; #endif - - #ifndef HAS_UNIFORM_u_halo_width varying lowp float halo_width; #else uniform lowp float u_halo_width; #endif - - #ifndef HAS_UNIFORM_u_halo_blur varying lowp float halo_blur; #else uniform lowp float u_halo_blur; #endif - void main() { - -#ifdef HAS_UNIFORM_u_fill_color - highp vec4 fill_color = u_fill_color; + #ifdef HAS_UNIFORM_u_fill_color +highp vec4 fill_color = u_fill_color; #endif - - -#ifdef HAS_UNIFORM_u_halo_color - highp vec4 halo_color = u_halo_color; + #ifdef HAS_UNIFORM_u_halo_color +highp vec4 halo_color = u_halo_color; #endif - - -#ifdef HAS_UNIFORM_u_opacity - lowp float opacity = u_opacity; + #ifdef HAS_UNIFORM_u_opacity +lowp float opacity = u_opacity; #endif - - -#ifdef HAS_UNIFORM_u_halo_width - lowp float halo_width = u_halo_width; + #ifdef HAS_UNIFORM_u_halo_width +lowp float halo_width = u_halo_width; #endif - - -#ifdef HAS_UNIFORM_u_halo_blur - lowp float halo_blur = u_halo_blur; + #ifdef HAS_UNIFORM_u_halo_blur +lowp float halo_blur = u_halo_blur; #endif - float fade_opacity = v_data1[2]; if (v_data1.w == ICON) { @@ -348,6 +273,8 @@ void main() { gl_FragColor = vec4(1.0); #endif } +)"; +}; -*/ -// clang-format on +} // namespace shaders +} // namespace mbgl diff --git a/include/mbgl/shaders/shader_manifest.hpp b/include/mbgl/shaders/shader_manifest.hpp new file mode 100644 index 000000000..29730ba94 --- /dev/null +++ b/include/mbgl/shaders/shader_manifest.hpp @@ -0,0 +1,35 @@ +// Generated code, do not modify this file! +// Generated on 2023-04-04T01:24:40.539Z by mwilsnd using shaders/generate_shader_code.js + +#pragma once +#include + +#ifdef MBGL_RENDER_BACKEND_OPENGL +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif diff --git a/include/mbgl/shaders/shader_source.hpp b/include/mbgl/shaders/shader_source.hpp new file mode 100644 index 000000000..a58c8c46f --- /dev/null +++ b/include/mbgl/shaders/shader_source.hpp @@ -0,0 +1,57 @@ +// Generated code, do not modify this file! +// Generated on 2023-04-04T01:24:40.539Z by mwilsnd using shaders/generate_shader_code.js + +#pragma once +#include + +namespace mbgl { +namespace shaders { + +/// @brief This enum is used with the ShaderSource template to select +/// source code for the desired program and graphics back-end. +enum class BuiltIn { + None, + Prelude, + BackgroundProgram, + BackgroundPatternProgram, + CircleProgram, + ClippingMaskProgram, + CollisionBoxProgram, + CollisionCircleProgram, + DebugProgram, + FillExtrusionPatternProgram, + FillExtrusionProgram, + FillOutlinePatternProgram, + FillOutlineProgram, + FillPatternProgram, + FillProgram, + HeatmapTextureProgram, + HeatmapProgram, + HillshadePrepareProgram, + HillshadeProgram, + LineGradientProgram, + LinePatternProgram, + LineSDFProgram, + LineProgram, + RasterProgram, + SymbolIconProgram, + SymbolSDFTextProgram, + SymbolSDFIconProgram, + SymbolTextAndIconProgram +}; + +/// @brief Select shader source based on a program type and a desired +/// graphics API. +/// @tparam T One of the built-in shader types available in the BuiltIn enum +/// @tparam The desired graphics API to request shader code for. One of +/// gfx::Backend::Type enums. +template struct ShaderSource; + +/// @brief A specialization of the ShaderSource template for no shader code. +template <> struct ShaderSource { + static constexpr const char* vertex = ""; + static constexpr const char* fragment = ""; +}; + +} // namespace shaders +} // namespace mbgl diff --git a/scripts/generate-shaders.js b/scripts/generate-shaders.js deleted file mode 100755 index baf3e51b1..000000000 --- a/scripts/generate-shaders.js +++ /dev/null @@ -1,195 +0,0 @@ -#!/usr/bin/env node - -require('@mapbox/flow-remove-types/register'); - -const path = require('path'); -const outputPath = 'src/mbgl/programs'; -const zlib = require('zlib'); -const crypto = require('crypto'); - -var shaders = require('../shaders'); - -require('./style-code'); - -let concatenated = ''; -let offsets = {}; - -function basicMinify(src) { - return src = src.trim() // strip whitespace at the start/end - .replace(/\s*\/\/[^\n]*\n/g, '\n') // strip double-slash comments - .replace(/\n+/g, '\n') // collapse multi line breaks - .replace(/\n\s+/g, '\n') // strip identation - .replace(/\s?([+-\/*=,])\s?/g, '$1') // strip whitespace around operators - .replace(/([;\(\),\{\}])\n(?=[^#])/g, '$1'); // strip more line breaks -} - -for (const key in shaders) { - const hash = crypto.createHash('sha1'); - - const vertex = concatenated.length; - const vertexSource = basicMinify(shaders[key].vertexSource) + '\n\0'; - hash.update(vertexSource); - concatenated += vertexSource; - - const fragment = concatenated.length; - const fragmentSource = basicMinify(shaders[key].fragmentSource) + '\n\0'; - hash.update(fragmentSource); - concatenated += fragmentSource; - - offsets[key] = { - vertex, - fragment, - originalKey: key, - hash: hash.digest('hex').substring(0, 16).match(/.{1,2}/g).map(n => `0x${n}`).join(', '), - shaderName: key.replace(/[A-Z]+/g, (match) => `_${match.toLowerCase()}`), - ShaderName: key.replace(/^[a-z]/g, (match) => match.toUpperCase()) - }; -} - -// Overrides: The symbolSDF shader is used for two underlying programs. -offsets.symbolSDFIcon = { - vertex: offsets.symbolSDF.vertex, - fragment: offsets.symbolSDF.fragment, - hash: offsets.symbolSDF.hash, - originalKey: 'symbolSDF', - shaderName: 'symbol_sdf_icon', - ShaderName: 'SymbolSDFIcon', -}; - -offsets.symbolSDFText = { - vertex: offsets.symbolSDF.vertex, - fragment: offsets.symbolSDF.fragment, - hash: offsets.symbolSDF.hash, - originalKey: 'symbolSDF', - shaderName: 'symbol_sdf_text', - ShaderName: 'SymbolSDFText', -}; - -delete offsets.symbolSDF; - -const compressed = zlib.deflateSync(concatenated, {level: zlib.Z_BEST_COMPRESSION}) - .toString('hex') - .match(/.{1,32}/g) - .map(line => line.match(/.{1,2}/g).map(n => `0x${n}`).join(', ')) - .join(',\n ') - .trim(); - -writeIfModified(path.join(outputPath, 'gl', 'shader_source.hpp'), `// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. - -#pragma once - -namespace mbgl { -namespace programs { -namespace gl { - -const char* shaderSource(); - -template -struct ShaderSource; - -} // namespace gl -} // namespace programs -} // namespace mbgl -`); - -writeIfModified(path.join(outputPath, 'gl', 'shader_source.cpp'), `// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. -// clang-format off -#include -#include - -#include - -namespace mbgl { -namespace programs { -namespace gl { - -constexpr const uint8_t compressedShaderSource[] = { - ${compressed}}; - -const char* shaderSource() { - static std::string decompressed = util::decompress(std::string(reinterpret_cast(compressedShaderSource), sizeof(compressedShaderSource))); - return decompressed.c_str(); -}; - -} // namespace gl -} // namespace programs -} // namespace mbgl -// clang-format on -`); - -writeIfModified(path.join(outputPath, 'gl', 'preludes.hpp'), `// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. - -#pragma once - -#include - -namespace mbgl { -namespace programs { -namespace gl { - -constexpr const uint8_t preludeHash[8] = {${offsets['prelude'].hash}}; -constexpr const auto vertexPreludeOffset = ${offsets['prelude'].vertex}; -constexpr const auto fragmentPreludeOffset = ${offsets['prelude'].fragment}; - -} // namespace gl -} // namespace programs -} // namespace mbgl -`); - -for (const key in offsets) { - if (key === 'prelude') - continue; - - const { shaderName, ShaderName, originalKey } = offsets[key]; - - writeIfModified(path.join(outputPath, 'gl', `${shaderName}.cpp`), `// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. -// clang-format off -#include -#include -#include -#include - -namespace mbgl { -namespace programs { -namespace gl { - -template -struct ShaderSource; - -template <> -struct ShaderSource<${ShaderName}Program> { - static constexpr const char* name = "${shaderName}"; - static constexpr const uint8_t hash[8] = {${offsets[key].hash}}; - static constexpr const auto vertexOffset = ${offsets[key].vertex}; - static constexpr const auto fragmentOffset = ${offsets[key].fragment}; -}; - -constexpr const char* ShaderSource<${ShaderName}Program>::name; -constexpr const uint8_t ShaderSource<${ShaderName}Program>::hash[8]; - -} // namespace gl -} // namespace programs - -namespace gfx { - -template <> -std::unique_ptr> -Backend::Create(const ProgramParameters& programParameters) { - return std::make_unique>(programParameters); -} - -} // namespace gfx -} // namespace mbgl - -// Uncompressed source of ${shaderName}.vertex.glsl: -/* -${shaders[originalKey].vertexSource} -*/ - -// Uncompressed source of ${shaderName}.fragment.glsl: -/* -${shaders[originalKey].fragmentSource} -*/ -// clang-format on -`); -} diff --git a/shaders/encode_attribute.js b/shaders/encode_attribute.js deleted file mode 100644 index 7e09dd696..000000000 --- a/shaders/encode_attribute.js +++ /dev/null @@ -1,17 +0,0 @@ -// @flow - -import {clamp} from '../util/util'; - -/** - * Packs two numbers, interpreted as 8-bit unsigned integers, into a single - * float. Unpack them in the shader using the `unpack_float()` function, - * defined in _prelude.vertex.glsl - * - * @private - */ -export function packUint8ToFloat(a: number, b: number) { - // coerce a and b to 8-bit ints - a = clamp(Math.floor(a), 0, 255); - b = clamp(Math.floor(b), 0, 255); - return 256 * a + b; -} diff --git a/shaders/index.js b/shaders/index.js deleted file mode 100644 index 3af8f6ae1..000000000 --- a/shaders/index.js +++ /dev/null @@ -1,20 +0,0 @@ -// This file is intended for use in the GL-JS test suite -// It provides the shaders entry point for Node (tests and GL Native) -// In a browser environment, this file is replaced with ./src/shaders/shaders.js -// when Rollup builds the main bundle. -// See https://github.com/mapbox/mapbox-gl-js/blob/master/package.json#L104-L108 - -/* eslint-disable import/unambiguous, import/no-commonjs, flowtype/require-valid-file-annotation, no-global-assign */ - -const fs = require('fs'); - -// enable ES Modules in Node -require = require("esm")(module); - -// enable requiring GLSL in Node -require.extensions['.glsl'] = function (module, filename) { - const content = fs.readFileSync(filename, 'utf8'); - module._compile(`module.exports = \`${content}\``, filename); -}; - -module.exports = require("./shaders.js"); diff --git a/shaders/shaders.js b/shaders/shaders.js deleted file mode 100644 index 221728dfd..000000000 --- a/shaders/shaders.js +++ /dev/null @@ -1,180 +0,0 @@ - -// Disable Flow annotations here because Flow doesn't support importing GLSL files -/* eslint-disable flowtype/require-valid-file-annotation */ - -import preludeFrag from './_prelude.fragment.glsl'; -import preludeVert from './_prelude.vertex.glsl'; -import backgroundFrag from './background.fragment.glsl'; -import backgroundVert from './background.vertex.glsl'; -import backgroundPatternFrag from './background_pattern.fragment.glsl'; -import backgroundPatternVert from './background_pattern.vertex.glsl'; -import circleFrag from './circle.fragment.glsl'; -import circleVert from './circle.vertex.glsl'; -import clippingMaskFrag from './clipping_mask.fragment.glsl'; -import clippingMaskVert from './clipping_mask.vertex.glsl'; -import heatmapFrag from './heatmap.fragment.glsl'; -import heatmapVert from './heatmap.vertex.glsl'; -import heatmapTextureFrag from './heatmap_texture.fragment.glsl'; -import heatmapTextureVert from './heatmap_texture.vertex.glsl'; -import collisionBoxFrag from './collision_box.fragment.glsl'; -import collisionBoxVert from './collision_box.vertex.glsl'; -import collisionCircleFrag from './collision_circle.fragment.glsl'; -import collisionCircleVert from './collision_circle.vertex.glsl'; -import debugFrag from './debug.fragment.glsl'; -import debugVert from './debug.vertex.glsl'; -import fillFrag from './fill.fragment.glsl'; -import fillVert from './fill.vertex.glsl'; -import fillOutlineFrag from './fill_outline.fragment.glsl'; -import fillOutlineVert from './fill_outline.vertex.glsl'; -import fillOutlinePatternFrag from './fill_outline_pattern.fragment.glsl'; -import fillOutlinePatternVert from './fill_outline_pattern.vertex.glsl'; -import fillPatternFrag from './fill_pattern.fragment.glsl'; -import fillPatternVert from './fill_pattern.vertex.glsl'; -import fillExtrusionFrag from './fill_extrusion.fragment.glsl'; -import fillExtrusionVert from './fill_extrusion.vertex.glsl'; -import fillExtrusionPatternFrag from './fill_extrusion_pattern.fragment.glsl'; -import fillExtrusionPatternVert from './fill_extrusion_pattern.vertex.glsl'; -import hillshadePrepareFrag from './hillshade_prepare.fragment.glsl'; -import hillshadePrepareVert from './hillshade_prepare.vertex.glsl'; -import hillshadeFrag from './hillshade.fragment.glsl'; -import hillshadeVert from './hillshade.vertex.glsl'; -import lineFrag from './line.fragment.glsl'; -import lineVert from './line.vertex.glsl'; -import lineGradientFrag from './line_gradient.fragment.glsl'; -import lineGradientVert from './line_gradient.vertex.glsl'; -import linePatternFrag from './line_pattern.fragment.glsl'; -import linePatternVert from './line_pattern.vertex.glsl'; -import lineSDFFrag from './line_sdf.fragment.glsl'; -import lineSDFVert from './line_sdf.vertex.glsl'; -import rasterFrag from './raster.fragment.glsl'; -import rasterVert from './raster.vertex.glsl'; -import symbolIconFrag from './symbol_icon.fragment.glsl'; -import symbolIconVert from './symbol_icon.vertex.glsl'; -import symbolSDFFrag from './symbol_sdf.fragment.glsl'; -import symbolSDFVert from './symbol_sdf.vertex.glsl'; -import symbolTextAndIconFrag from './symbol_text_and_icon.fragment.glsl'; -import symbolTextAndIconVert from './symbol_text_and_icon.vertex.glsl'; - -export const prelude = compile(preludeFrag, preludeVert); -export const background = compile(backgroundFrag, backgroundVert); -export const backgroundPattern = compile(backgroundPatternFrag, backgroundPatternVert); -export const circle = compile(circleFrag, circleVert); -export const clippingMask = compile(clippingMaskFrag, clippingMaskVert); -export const heatmap = compile(heatmapFrag, heatmapVert); -export const heatmapTexture = compile(heatmapTextureFrag, heatmapTextureVert); -export const collisionBox = compile(collisionBoxFrag, collisionBoxVert); -export const collisionCircle = compile(collisionCircleFrag, collisionCircleVert); -export const debug = compile(debugFrag, debugVert); -export const fill = compile(fillFrag, fillVert); -export const fillOutline = compile(fillOutlineFrag, fillOutlineVert); -export const fillOutlinePattern = compile(fillOutlinePatternFrag, fillOutlinePatternVert); -export const fillPattern = compile(fillPatternFrag, fillPatternVert); -export const fillExtrusion = compile(fillExtrusionFrag, fillExtrusionVert); -export const fillExtrusionPattern = compile(fillExtrusionPatternFrag, fillExtrusionPatternVert); -export const hillshadePrepare = compile(hillshadePrepareFrag, hillshadePrepareVert); -export const hillshade = compile(hillshadeFrag, hillshadeVert); -export const line = compile(lineFrag, lineVert); -export const lineGradient = compile(lineGradientFrag, lineGradientVert); -export const linePattern = compile(linePatternFrag, linePatternVert); -export const lineSDF = compile(lineSDFFrag, lineSDFVert); -export const raster = compile(rasterFrag, rasterVert); -export const symbolIcon = compile(symbolIconFrag, symbolIconVert); -export const symbolSDF = compile(symbolSDFFrag, symbolSDFVert); -export const symbolTextAndIcon = compile(symbolTextAndIconFrag, symbolTextAndIconVert); - -// Expand #pragmas to #ifdefs. - -function compile(fragmentSource, vertexSource) { - const re = /#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g; - - const fragmentPragmas = {}; - - fragmentSource = fragmentSource.replace(re, (match, operation, precision, type, name) => { - fragmentPragmas[name] = true; - if (operation === 'define') { - return ` -#ifndef HAS_UNIFORM_u_${name} -varying ${precision} ${type} ${name}; -#else -uniform ${precision} ${type} u_${name}; -#endif -`; - } else /* if (operation === 'initialize') */ { - return ` -#ifdef HAS_UNIFORM_u_${name} - ${precision} ${type} ${name} = u_${name}; -#endif -`; - } - }); - - vertexSource = vertexSource.replace(re, (match, operation, precision, type, name) => { - const attrType = type === 'float' ? 'vec2' : 'vec4'; - const unpackType = name.match(/color/) ? 'color' : attrType; - - if (fragmentPragmas[name]) { - if (operation === 'define') { - return ` -#ifndef HAS_UNIFORM_u_${name} -uniform lowp float u_${name}_t; -attribute ${precision} ${attrType} a_${name}; -varying ${precision} ${type} ${name}; -#else -uniform ${precision} ${type} u_${name}; -#endif -`; - } else /* if (operation === 'initialize') */ { - if (unpackType === 'vec4') { - // vec4 attributes are only used for cross-faded properties, and are not packed - return ` -#ifndef HAS_UNIFORM_u_${name} - ${name} = a_${name}; -#else - ${precision} ${type} ${name} = u_${name}; -#endif -`; - } else { - return ` -#ifndef HAS_UNIFORM_u_${name} - ${name} = unpack_mix_${unpackType}(a_${name}, u_${name}_t); -#else - ${precision} ${type} ${name} = u_${name}; -#endif -`; - } - } - } else { - if (operation === 'define') { - return ` -#ifndef HAS_UNIFORM_u_${name} -uniform lowp float u_${name}_t; -attribute ${precision} ${attrType} a_${name}; -#else -uniform ${precision} ${type} u_${name}; -#endif -`; - } else /* if (operation === 'initialize') */ { - if (unpackType === 'vec4') { - // vec4 attributes are only used for cross-faded properties, and are not packed - return ` -#ifndef HAS_UNIFORM_u_${name} - ${precision} ${type} ${name} = a_${name}; -#else - ${precision} ${type} ${name} = u_${name}; -#endif -`; - } else /* */{ - return ` -#ifndef HAS_UNIFORM_u_${name} - ${precision} ${type} ${name} = unpack_mix_${unpackType}(a_${name}, u_${name}_t); -#else - ${precision} ${type} ${name} = u_${name}; -#endif -`; - } - } - } - }); - - return {fragmentSource, vertexSource}; -} diff --git a/src/mbgl/gfx/context.hpp b/src/mbgl/gfx/context.hpp index 4be292911..d3a33d8a5 100644 --- a/src/mbgl/gfx/context.hpp +++ b/src/mbgl/gfx/context.hpp @@ -76,12 +76,6 @@ public: protected: virtual std::unique_ptr createDrawScopeResource() = 0; -public: - template - std::unique_ptr> createProgram(const ProgramParameters& programParameters) { - return Backend::Create, const ProgramParameters&>(programParameters); - } - public: virtual std::unique_ptr createCommandEncoder() = 0; diff --git a/src/mbgl/gl/program.hpp b/src/mbgl/gl/program.hpp index a42598b91..fb4bb112f 100644 --- a/src/mbgl/gl/program.hpp +++ b/src/mbgl/gl/program.hpp @@ -16,8 +16,7 @@ #include #include -#include -#include +#include #include @@ -37,9 +36,6 @@ public: const ProgramParameters programParameters; - static constexpr const auto vertexOffset = programs::gl::ShaderSource::vertexOffset; - static constexpr const auto fragmentOffset = programs::gl::ShaderSource::fragmentOffset; - class Instance { public: Instance(Context& context, @@ -63,19 +59,15 @@ public: std::initializer_list vertexSource = { programParameters.getDefines().c_str(), additionalDefines.c_str(), - (programs::gl::shaderSource() + programs::gl::vertexPreludeOffset), - programParameters.vertexSource().length() == 0 ? - (programs::gl::shaderSource() + vertexOffset) : - programParameters.vertexSource().c_str() + shaders::ShaderSource::vertex, + programParameters.vertexSource(gfx::Backend::Type::OpenGL).c_str() }; std::initializer_list fragmentSource = { programParameters.getDefines().c_str(), additionalDefines.c_str(), - (programs::gl::shaderSource() + programs::gl::fragmentPreludeOffset), - programParameters.fragmentSource().length() == 0 ? - (programs::gl::shaderSource() + fragmentOffset) : - programParameters.fragmentSource().c_str() + shaders::ShaderSource::fragment, + programParameters.fragmentSource(gfx::Backend::Type::OpenGL).c_str() }; return std::make_unique(context, vertexSource, fragmentSource); @@ -111,13 +103,17 @@ public: const uint32_t key = gl::AttributeKey::compute(attributeBindings); auto it = instances.find(key); if (it == instances.end()) { - it = instances - .emplace(key, - Instance::createInstance( - context, - programParameters, - gl::AttributeKey::defines(attributeBindings))) - .first; + try { + it = instances.emplace(key, + Instance::createInstance( + context, + programParameters, + gl::AttributeKey::defines(attributeBindings) + )).first; + } catch (const std::runtime_error& e) { + Log::Error(Event::OpenGL, e.what()); + return; + } } auto& instance = *it->second; diff --git a/src/mbgl/programs/background_program.hpp b/src/mbgl/programs/background_program.hpp index dd0683776..c8be589e4 100644 --- a/src/mbgl/programs/background_program.hpp +++ b/src/mbgl/programs/background_program.hpp @@ -39,8 +39,9 @@ using BackgroundPatternUniforms = TypeList< uniforms::pixel_coord_lower, uniforms::tile_units_to_pixels>; -class BackgroundProgram : public Program< +class BackgroundProgram final : public Program< BackgroundProgram, + shaders::BuiltIn::BackgroundProgram, gfx::PrimitiveType::Triangle, BackgroundLayoutAttributes, BackgroundUniforms, @@ -48,11 +49,17 @@ class BackgroundProgram : public Program< style::Properties<>> { public: + static constexpr std::string_view Name{"BackgroundProgram"}; + const std::string_view name() const noexcept override { + return Name; + } + using Program::Program; }; -class BackgroundPatternProgram : public Program< +class BackgroundPatternProgram final : public Program< BackgroundPatternProgram, + shaders::BuiltIn::BackgroundPatternProgram, gfx::PrimitiveType::Triangle, BackgroundLayoutAttributes, BackgroundPatternUniforms, @@ -61,6 +68,11 @@ class BackgroundPatternProgram : public Program< style::Properties<>> { public: + static constexpr std::string_view Name{"BackgroundPatternProgram"}; + const std::string_view name() const noexcept override { + return Name; + } + using Program::Program; static LayoutUniformValues layoutUniformValues(mat4 matrix, @@ -76,13 +88,4 @@ public: using BackgroundLayoutVertex = BackgroundProgram::LayoutVertex; using BackgroundAttributes = BackgroundProgram::AttributeList; -class BackgroundLayerPrograms final : public LayerTypePrograms { -public: - BackgroundLayerPrograms(gfx::Context& context, const ProgramParameters& programParameters) - : background(context, programParameters), - backgroundPattern(context, programParameters) {} - BackgroundProgram background; - BackgroundPatternProgram backgroundPattern; -}; - } // namespace mbgl diff --git a/src/mbgl/programs/circle_program.hpp b/src/mbgl/programs/circle_program.hpp index c9e03d05e..a32c2ab78 100644 --- a/src/mbgl/programs/circle_program.hpp +++ b/src/mbgl/programs/circle_program.hpp @@ -12,8 +12,9 @@ namespace uniforms { MBGL_DEFINE_UNIFORM_SCALAR(bool, scale_with_map); } // namespace uniforms -class CircleProgram : public Program< +class CircleProgram final : public Program< CircleProgram, + shaders::BuiltIn::CircleProgram, gfx::PrimitiveType::Triangle, TypeList< attributes::pos>, @@ -28,6 +29,11 @@ class CircleProgram : public Program< style::CirclePaintProperties> { public: + static constexpr std::string_view Name{"CircleProgram"}; + const std::string_view name() const noexcept override { + return Name; + } + using Program::Program; /* @@ -49,11 +55,4 @@ public: using CircleLayoutVertex = CircleProgram::LayoutVertex; using CircleAttributes = CircleProgram::AttributeList; -class CircleLayerPrograms final : public LayerTypePrograms { -public: - CircleLayerPrograms(gfx::Context& context, const ProgramParameters& programParameters) - : circle(context, programParameters) {} - CircleProgram circle; -}; - } // namespace mbgl diff --git a/src/mbgl/programs/clipping_mask_program.hpp b/src/mbgl/programs/clipping_mask_program.hpp index 14d66a870..e4e1bca93 100644 --- a/src/mbgl/programs/clipping_mask_program.hpp +++ b/src/mbgl/programs/clipping_mask_program.hpp @@ -7,8 +7,9 @@ namespace mbgl { -class ClippingMaskProgram : public Program< +class ClippingMaskProgram final : public Program< ClippingMaskProgram, + shaders::BuiltIn::ClippingMaskProgram, gfx::PrimitiveType::Triangle, PositionOnlyLayoutAttributes, TypeList< @@ -17,6 +18,11 @@ class ClippingMaskProgram : public Program< style::Properties<>> { public: + static constexpr std::string_view Name{"ClippingMaskProgram"}; + const std::string_view name() const noexcept override { + return Name; + } + using Program::Program; }; diff --git a/src/mbgl/programs/collision_box_program.hpp b/src/mbgl/programs/collision_box_program.hpp index 9ba967956..7ec0f0ec1 100644 --- a/src/mbgl/programs/collision_box_program.hpp +++ b/src/mbgl/programs/collision_box_program.hpp @@ -17,8 +17,9 @@ using CollisionBoxLayoutAttributes = TypeList< using CollisionBoxDynamicAttributes = TypeList; -class CollisionBoxProgram : public Program< +class CollisionBoxProgram final : public Program< CollisionBoxProgram, + shaders::BuiltIn::CollisionBoxProgram, gfx::PrimitiveType::Line, TypeListConcat, TypeList< @@ -29,6 +30,11 @@ class CollisionBoxProgram : public Program< style::Properties<>> { public: + static constexpr std::string_view Name{"CollisionBoxProgram"}; + const std::string_view name() const noexcept override { + return Name; + } + using Program::Program; static gfx::Vertex layoutVertex(Point a, Point anchor, Point o) { @@ -108,8 +114,9 @@ public: }; -class CollisionCircleProgram : public Program< +class CollisionCircleProgram final : public Program< CollisionCircleProgram, + shaders::BuiltIn::CollisionCircleProgram, gfx::PrimitiveType::Triangle, TypeListConcat, TypeList< @@ -121,6 +128,11 @@ class CollisionCircleProgram : public Program< style::Properties<>> { public: + static constexpr std::string_view Name{"CollisionCircleProgram"}; + const std::string_view name() const noexcept override { + return Name; + } + using Program::Program; static gfx::Vertex vertex(Point a, Point anchor, Point o) { diff --git a/src/mbgl/programs/debug_program.hpp b/src/mbgl/programs/debug_program.hpp index c96a176db..fea3c31ad 100644 --- a/src/mbgl/programs/debug_program.hpp +++ b/src/mbgl/programs/debug_program.hpp @@ -11,13 +11,21 @@ namespace mbgl { namespace uniforms { MBGL_DEFINE_UNIFORM_SCALAR(float, overlay_scale); } -class DebugProgram : public Program, - TypeList, - TypeList, - style::Properties<>> { +class DebugProgram final : public Program< + DebugProgram, + shaders::BuiltIn::DebugProgram, + gfx::PrimitiveType::Line, + TypeList, + TypeList, + TypeList, + style::Properties<>> +{ public: + static constexpr std::string_view Name{"DebugProgram"}; + const std::string_view name() const noexcept override { + return Name; + } + using Program::Program; }; diff --git a/src/mbgl/programs/fill_extrusion_program.hpp b/src/mbgl/programs/fill_extrusion_program.hpp index f92bd7c96..dc34b1abd 100644 --- a/src/mbgl/programs/fill_extrusion_program.hpp +++ b/src/mbgl/programs/fill_extrusion_program.hpp @@ -54,8 +54,9 @@ using FillExtrusionPatternUniforms = TypeList< uniforms::lightintensity, uniforms::vertical_gradient>; -class FillExtrusionProgram : public Program< +class FillExtrusionProgram final : public Program< FillExtrusionProgram, + shaders::BuiltIn::FillExtrusionProgram, gfx::PrimitiveType::Triangle, FillExtrusionLayoutAttributes, FillExtrusionUniforms, @@ -63,6 +64,11 @@ class FillExtrusionProgram : public Program< style::FillExtrusionPaintProperties> { public: + static constexpr std::string_view Name{"FillExtrusionProgram"}; + const std::string_view name() const noexcept override { + return Name; + } + using Program::Program; static LayoutVertex layoutVertex(Point p, double nx, double ny, double nz, unsigned short t, uint16_t e) { @@ -89,8 +95,9 @@ public: mat4, const TransformState&, float opacity, const EvaluatedLight&, float verticalGradient); }; -class FillExtrusionPatternProgram : public Program< +class FillExtrusionPatternProgram final : public Program< FillExtrusionPatternProgram, + shaders::BuiltIn::FillExtrusionPatternProgram, gfx::PrimitiveType::Triangle, FillExtrusionLayoutAttributes, FillExtrusionPatternUniforms, @@ -99,6 +106,11 @@ class FillExtrusionPatternProgram : public Program< style::FillExtrusionPaintProperties> { public: + static constexpr std::string_view Name{"FillExtrusionPatternProgram"}; + const std::string_view name() const noexcept override { + return Name; + } + using Program::Program; static LayoutUniformValues layoutUniformValues(mat4, @@ -116,15 +128,4 @@ public: using FillExtrusionLayoutVertex = FillExtrusionProgram::LayoutVertex; using FillExtrusionAttributes = FillExtrusionProgram::AttributeList; - -class FillExtrusionLayerPrograms final : public LayerTypePrograms { -public: - FillExtrusionLayerPrograms(gfx::Context& context, const ProgramParameters& programParameters) - : fillExtrusion(context, programParameters), - fillExtrusionPattern(context, programParameters) { - } - FillExtrusionProgram fillExtrusion; - FillExtrusionPatternProgram fillExtrusionPattern; -}; - } // namespace mbgl diff --git a/src/mbgl/programs/fill_program.hpp b/src/mbgl/programs/fill_program.hpp index da39fe40b..d41be25b5 100644 --- a/src/mbgl/programs/fill_program.hpp +++ b/src/mbgl/programs/fill_program.hpp @@ -33,8 +33,9 @@ using FillPatternUniforms = TypeList< uniforms::pixel_coord_upper, uniforms::pixel_coord_lower>; -class FillProgram : public Program< +class FillProgram final : public Program< FillProgram, + shaders::BuiltIn::FillProgram, gfx::PrimitiveType::Triangle, FillLayoutAttributes, FillUniforms, @@ -42,6 +43,11 @@ class FillProgram : public Program< style::FillPaintProperties> { public: + static constexpr std::string_view Name{"FillProgram"}; + const std::string_view name() const noexcept override { + return Name; + } + using Program::Program; static LayoutVertex layoutVertex(Point p) { @@ -54,8 +60,9 @@ public: } }; -class FillPatternProgram : public Program< +class FillPatternProgram final : public Program< FillPatternProgram, + shaders::BuiltIn::FillPatternProgram, gfx::PrimitiveType::Triangle, FillLayoutAttributes, FillPatternUniforms, @@ -64,6 +71,11 @@ class FillPatternProgram : public Program< style::FillPaintProperties> { public: + static constexpr std::string_view Name{"FillPatternProgram"}; + const std::string_view name() const noexcept override { + return Name; + } + using Program::Program; static LayoutUniformValues layoutUniformValues(mat4 matrix, @@ -75,8 +87,9 @@ public: float pixelRatio); }; -class FillOutlineProgram : public Program< +class FillOutlineProgram final : public Program< FillOutlineProgram, + shaders::BuiltIn::FillOutlineProgram, gfx::PrimitiveType::Line, FillLayoutAttributes, FillUniforms, @@ -84,11 +97,17 @@ class FillOutlineProgram : public Program< style::FillPaintProperties> { public: + static constexpr std::string_view Name{"FillOutlineProgram"}; + const std::string_view name() const noexcept override { + return Name; + } + using Program::Program; }; -class FillOutlinePatternProgram : public Program< +class FillOutlinePatternProgram final : public Program< FillOutlinePatternProgram, + shaders::BuiltIn::FillOutlinePatternProgram, gfx::PrimitiveType::Line, FillLayoutAttributes, FillPatternUniforms, @@ -97,23 +116,15 @@ class FillOutlinePatternProgram : public Program< style::FillPaintProperties> { public: + static constexpr std::string_view Name{"FillOutlinePatternProgram"}; + const std::string_view name() const noexcept override { + return Name; + } + using Program::Program; }; using FillLayoutVertex = FillProgram::LayoutVertex; using FillAttributes = FillProgram::AttributeList; -class FillLayerPrograms final : public LayerTypePrograms { -public: - FillLayerPrograms(gfx::Context& context, const ProgramParameters& programParameters) - : fill(context, programParameters), - fillPattern(context, programParameters), - fillOutline(context, programParameters), - fillOutlinePattern(context, programParameters) {} - FillProgram fill; - FillPatternProgram fillPattern; - FillOutlineProgram fillOutline; - FillOutlinePatternProgram fillOutlinePattern; -}; - } // namespace mbgl diff --git a/src/mbgl/programs/gl/background.cpp b/src/mbgl/programs/gl/background.cpp deleted file mode 100644 index 8ba56c305..000000000 --- a/src/mbgl/programs/gl/background.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. -// clang-format off -#include -#include -#include -#include - -namespace mbgl { -namespace programs { -namespace gl { - -template -struct ShaderSource; - -template <> -struct ShaderSource { - static constexpr const char* name = "background"; - static constexpr const uint8_t hash[8] = {0x2d, 0xef, 0x97, 0xa2, 0xec, 0xb5, 0x67, 0xef}; - static constexpr const auto vertexOffset = 1429; - static constexpr const auto fragmentOffset = 1525; -}; - -constexpr const char* ShaderSource::name; -constexpr const uint8_t ShaderSource::hash[8]; - -} // namespace gl -} // namespace programs - -namespace gfx { - -template <> -std::unique_ptr> -Backend::Create(const ProgramParameters& programParameters) { - return std::make_unique>(programParameters); -} - -} // namespace gfx -} // namespace mbgl - -// Uncompressed source of background.vertex.glsl: -/* -attribute vec2 a_pos; - -uniform mat4 u_matrix; - -void main() { - gl_Position = u_matrix * vec4(a_pos, 0, 1); -} - -*/ - -// Uncompressed source of background.fragment.glsl: -/* -uniform vec4 u_color; -uniform float u_opacity; - -void main() { - gl_FragColor = u_color * u_opacity; - -#ifdef OVERDRAW_INSPECTOR - gl_FragColor = vec4(1.0); -#endif -} - -*/ -// clang-format on diff --git a/src/mbgl/programs/gl/clipping_mask.cpp b/src/mbgl/programs/gl/clipping_mask.cpp deleted file mode 100644 index 717ba4bac..000000000 --- a/src/mbgl/programs/gl/clipping_mask.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. -// clang-format off -#include -#include -#include -#include - -namespace mbgl { -namespace programs { -namespace gl { - -template -struct ShaderSource; - -template <> -struct ShaderSource { - static constexpr const char* name = "clipping_mask"; - static constexpr const uint8_t hash[8] = {0x3e, 0x17, 0xc2, 0x3a, 0x1f, 0xf0, 0xa8, 0xa3}; - static constexpr const auto vertexOffset = 7891; - static constexpr const auto fragmentOffset = 7987; -}; - -constexpr const char* ShaderSource::name; -constexpr const uint8_t ShaderSource::hash[8]; - -} // namespace gl -} // namespace programs - -namespace gfx { - -template <> -std::unique_ptr> -Backend::Create(const ProgramParameters& programParameters) { - return std::make_unique>(programParameters); -} - -} // namespace gfx -} // namespace mbgl - -// Uncompressed source of clipping_mask.vertex.glsl: -/* -attribute vec2 a_pos; - -uniform mat4 u_matrix; - -void main() { - gl_Position = u_matrix * vec4(a_pos, 0, 1); -} - -*/ - -// Uncompressed source of clipping_mask.fragment.glsl: -/* -void main() { - gl_FragColor = vec4(1.0); -} - -*/ -// clang-format on diff --git a/src/mbgl/programs/gl/debug.cpp b/src/mbgl/programs/gl/debug.cpp deleted file mode 100644 index 200d7599e..000000000 --- a/src/mbgl/programs/gl/debug.cpp +++ /dev/null @@ -1,70 +0,0 @@ -// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. -// clang-format off -#include -#include -#include -#include - -namespace mbgl { -namespace programs { -namespace gl { - -template -struct ShaderSource; - -template <> -struct ShaderSource { - static constexpr const char* name = "debug"; - static constexpr const uint8_t hash[8] = {0x07, 0x98, 0x41, 0xa8, 0x6b, 0x73, 0xaf, 0x34}; - static constexpr const auto vertexOffset = 12494; - static constexpr const auto fragmentOffset = 12672; -}; - -constexpr const char* ShaderSource::name; -constexpr const uint8_t ShaderSource::hash[8]; - -} // namespace gl -} // namespace programs - -namespace gfx { - -template <> -std::unique_ptr> -Backend::Create(const ProgramParameters& programParameters) { - return std::make_unique>(programParameters); -} - -} // namespace gfx -} // namespace mbgl - -// Uncompressed source of debug.vertex.glsl: -/* -attribute vec2 a_pos; -varying vec2 v_uv; - -uniform mat4 u_matrix; -uniform float u_overlay_scale; - -void main() { - // This vertex shader expects a EXTENT x EXTENT quad, - // The UV co-ordinates for the overlay texture can be calculated using that knowledge - v_uv = a_pos / 8192.0; - gl_Position = u_matrix * vec4(a_pos * u_overlay_scale, 0, 1); -} - -*/ - -// Uncompressed source of debug.fragment.glsl: -/* -uniform highp vec4 u_color; -uniform sampler2D u_overlay; - -varying vec2 v_uv; - -void main() { - vec4 overlay_color = texture2D(u_overlay, v_uv); - gl_FragColor = mix(u_color, overlay_color, overlay_color.a); -} - -*/ -// clang-format on diff --git a/src/mbgl/programs/gl/fill.cpp b/src/mbgl/programs/gl/fill.cpp deleted file mode 100644 index 07a60cd7c..000000000 --- a/src/mbgl/programs/gl/fill.cpp +++ /dev/null @@ -1,123 +0,0 @@ -// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. -// clang-format off -#include -#include -#include -#include - -namespace mbgl { -namespace programs { -namespace gl { - -template -struct ShaderSource; - -template <> -struct ShaderSource { - static constexpr const char* name = "fill"; - static constexpr const uint8_t hash[8] = {0x87, 0xea, 0x65, 0x7f, 0x0c, 0x9b, 0x97, 0x5d}; - static constexpr const auto vertexOffset = 12862; - static constexpr const auto fragmentOffset = 13506; -}; - -constexpr const char* ShaderSource::name; -constexpr const uint8_t ShaderSource::hash[8]; - -} // namespace gl -} // namespace programs - -namespace gfx { - -template <> -std::unique_ptr> -Backend::Create(const ProgramParameters& programParameters) { - return std::make_unique>(programParameters); -} - -} // namespace gfx -} // namespace mbgl - -// Uncompressed source of fill.vertex.glsl: -/* -attribute vec2 a_pos; - -uniform mat4 u_matrix; - - -#ifndef HAS_UNIFORM_u_color -uniform lowp float u_color_t; -attribute highp vec4 a_color; -varying highp vec4 color; -#else -uniform highp vec4 u_color; -#endif - - -#ifndef HAS_UNIFORM_u_opacity -uniform lowp float u_opacity_t; -attribute lowp vec2 a_opacity; -varying lowp float opacity; -#else -uniform lowp float u_opacity; -#endif - - -void main() { - -#ifndef HAS_UNIFORM_u_color - color = unpack_mix_color(a_color, u_color_t); -#else - highp vec4 color = u_color; -#endif - - -#ifndef HAS_UNIFORM_u_opacity - opacity = unpack_mix_vec2(a_opacity, u_opacity_t); -#else - lowp float opacity = u_opacity; -#endif - - - gl_Position = u_matrix * vec4(a_pos, 0, 1); -} - -*/ - -// Uncompressed source of fill.fragment.glsl: -/* - -#ifndef HAS_UNIFORM_u_color -varying highp vec4 color; -#else -uniform highp vec4 u_color; -#endif - - -#ifndef HAS_UNIFORM_u_opacity -varying lowp float opacity; -#else -uniform lowp float u_opacity; -#endif - - -void main() { - -#ifdef HAS_UNIFORM_u_color - highp vec4 color = u_color; -#endif - - -#ifdef HAS_UNIFORM_u_opacity - lowp float opacity = u_opacity; -#endif - - - gl_FragColor = color * opacity; - -#ifdef OVERDRAW_INSPECTOR - gl_FragColor = vec4(1.0); -#endif -} - -*/ -// clang-format on diff --git a/src/mbgl/programs/gl/fill_outline.cpp b/src/mbgl/programs/gl/fill_outline.cpp deleted file mode 100644 index 01c8e9309..000000000 --- a/src/mbgl/programs/gl/fill_outline.cpp +++ /dev/null @@ -1,131 +0,0 @@ -// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. -// clang-format off -#include -#include -#include -#include - -namespace mbgl { -namespace programs { -namespace gl { - -template -struct ShaderSource; - -template <> -struct ShaderSource { - static constexpr const char* name = "fill_outline"; - static constexpr const uint8_t hash[8] = {0x51, 0x25, 0x43, 0x9d, 0x41, 0x73, 0xe1, 0xbb}; - static constexpr const auto vertexOffset = 13930; - static constexpr const auto fragmentOffset = 14755; -}; - -constexpr const char* ShaderSource::name; -constexpr const uint8_t ShaderSource::hash[8]; - -} // namespace gl -} // namespace programs - -namespace gfx { - -template <> -std::unique_ptr> -Backend::Create(const ProgramParameters& programParameters) { - return std::make_unique>(programParameters); -} - -} // namespace gfx -} // namespace mbgl - -// Uncompressed source of fill_outline.vertex.glsl: -/* -attribute vec2 a_pos; - -uniform mat4 u_matrix; -uniform vec2 u_world; - -varying vec2 v_pos; - - -#ifndef HAS_UNIFORM_u_outline_color -uniform lowp float u_outline_color_t; -attribute highp vec4 a_outline_color; -varying highp vec4 outline_color; -#else -uniform highp vec4 u_outline_color; -#endif - - -#ifndef HAS_UNIFORM_u_opacity -uniform lowp float u_opacity_t; -attribute lowp vec2 a_opacity; -varying lowp float opacity; -#else -uniform lowp float u_opacity; -#endif - - -void main() { - -#ifndef HAS_UNIFORM_u_outline_color - outline_color = unpack_mix_color(a_outline_color, u_outline_color_t); -#else - highp vec4 outline_color = u_outline_color; -#endif - - -#ifndef HAS_UNIFORM_u_opacity - opacity = unpack_mix_vec2(a_opacity, u_opacity_t); -#else - lowp float opacity = u_opacity; -#endif - - - gl_Position = u_matrix * vec4(a_pos, 0, 1); - v_pos = (gl_Position.xy / gl_Position.w + 1.0) / 2.0 * u_world; -} - -*/ - -// Uncompressed source of fill_outline.fragment.glsl: -/* -varying vec2 v_pos; - - -#ifndef HAS_UNIFORM_u_outline_color -varying highp vec4 outline_color; -#else -uniform highp vec4 u_outline_color; -#endif - - -#ifndef HAS_UNIFORM_u_opacity -varying lowp float opacity; -#else -uniform lowp float u_opacity; -#endif - - -void main() { - -#ifdef HAS_UNIFORM_u_outline_color - highp vec4 outline_color = u_outline_color; -#endif - - -#ifdef HAS_UNIFORM_u_opacity - lowp float opacity = u_opacity; -#endif - - - float dist = length(v_pos - gl_FragCoord.xy); - float alpha = 1.0 - smoothstep(0.0, 1.0, dist); - gl_FragColor = outline_color * (alpha * opacity); - -#ifdef OVERDRAW_INSPECTOR - gl_FragColor = vec4(1.0); -#endif -} - -*/ -// clang-format on diff --git a/src/mbgl/programs/gl/heatmap_texture.cpp b/src/mbgl/programs/gl/heatmap_texture.cpp deleted file mode 100644 index caa7d4652..000000000 --- a/src/mbgl/programs/gl/heatmap_texture.cpp +++ /dev/null @@ -1,74 +0,0 @@ -// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. -// clang-format off -#include -#include -#include -#include - -namespace mbgl { -namespace programs { -namespace gl { - -template -struct ShaderSource; - -template <> -struct ShaderSource { - static constexpr const char* name = "heatmap_texture"; - static constexpr const uint8_t hash[8] = {0x9f, 0xc7, 0x56, 0xb2, 0x9e, 0x8f, 0x15, 0xff}; - static constexpr const auto vertexOffset = 9535; - static constexpr const auto fragmentOffset = 9715; -}; - -constexpr const char* ShaderSource::name; -constexpr const uint8_t ShaderSource::hash[8]; - -} // namespace gl -} // namespace programs - -namespace gfx { - -template <> -std::unique_ptr> -Backend::Create(const ProgramParameters& programParameters) { - return std::make_unique>(programParameters); -} - -} // namespace gfx -} // namespace mbgl - -// Uncompressed source of heatmap_texture.vertex.glsl: -/* -uniform mat4 u_matrix; -uniform vec2 u_world; -attribute vec2 a_pos; -varying vec2 v_pos; - -void main() { - gl_Position = u_matrix * vec4(a_pos * u_world, 0, 1); - - v_pos.x = a_pos.x; - v_pos.y = 1.0 - a_pos.y; -} - -*/ - -// Uncompressed source of heatmap_texture.fragment.glsl: -/* -uniform sampler2D u_image; -uniform sampler2D u_color_ramp; -uniform float u_opacity; -varying vec2 v_pos; - -void main() { - float t = texture2D(u_image, v_pos).r; - vec4 color = texture2D(u_color_ramp, vec2(t, 0.5)); - gl_FragColor = color * u_opacity; - -#ifdef OVERDRAW_INSPECTOR - gl_FragColor = vec4(0.0); -#endif -} - -*/ -// clang-format on diff --git a/src/mbgl/programs/gl/preludes.hpp b/src/mbgl/programs/gl/preludes.hpp deleted file mode 100644 index ddd72b0f0..000000000 --- a/src/mbgl/programs/gl/preludes.hpp +++ /dev/null @@ -1,17 +0,0 @@ -// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. - -#pragma once - -#include - -namespace mbgl { -namespace programs { -namespace gl { - -constexpr const uint8_t preludeHash[8] = {0x24, 0x91, 0x82, 0x37, 0x02, 0xad, 0x98, 0x0a}; -constexpr const auto vertexPreludeOffset = 0; -constexpr const auto fragmentPreludeOffset = 1252; - -} // namespace gl -} // namespace programs -} // namespace mbgl diff --git a/src/mbgl/programs/gl/shader_source.cpp b/src/mbgl/programs/gl/shader_source.cpp deleted file mode 100644 index 8630d973a..000000000 --- a/src/mbgl/programs/gl/shader_source.cpp +++ /dev/null @@ -1,490 +0,0 @@ -// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. -// clang-format off -#include -#include - -#include - -namespace mbgl { -namespace programs { -namespace gl { - -constexpr const uint8_t compressedShaderSource[] = { - 0x78, 0xda, 0xed, 0x3d, 0x6b, 0x6f, 0xe3, 0x38, 0x92, 0xfb, 0x39, 0xbf, 0xc2, 0x83, 0x01, 0x16, - 0x92, 0x2c, 0x5b, 0xb6, 0x93, 0xf4, 0x63, 0xb4, 0xba, 0x41, 0xa3, 0x1f, 0x73, 0x01, 0x66, 0xba, - 0x1b, 0x9d, 0xd9, 0xbd, 0xc5, 0x0e, 0x1a, 0x86, 0x64, 0x2b, 0x8e, 0x6e, 0x6d, 0xcb, 0x67, 0x2b, - 0x89, 0x9d, 0x45, 0xfe, 0xfb, 0xb1, 0xf8, 0x26, 0x45, 0xca, 0x8f, 0xc4, 0xce, 0x63, 0x84, 0xc1, - 0x74, 0x2c, 0xb2, 0x58, 0x2c, 0x92, 0xc5, 0x62, 0x55, 0x91, 0x2c, 0xfe, 0x98, 0x5d, 0x0c, 0xd3, - 0x8b, 0xc6, 0x2f, 0xbf, 0xf6, 0x3f, 0x9e, 0x1f, 0xcd, 0xe6, 0xe9, 0x20, 0x5b, 0x64, 0xf9, 0xb4, - 0x71, 0x99, 0x8d, 0x2e, 0x67, 0x8d, 0x8b, 0x71, 0x1e, 0x17, 0xe1, 0xd1, 0x8f, 0xe9, 0x78, 0x91, - 0x1e, 0xfd, 0x98, 0x5d, 0x34, 0x7e, 0x40, 0xb0, 0xd9, 0x34, 0x1d, 0x3a, 0xe3, 0xfc, 0x66, 0xe6, - 0x1e, 0xfd, 0x48, 0x3e, 0x1b, 0xf0, 0x85, 0xa0, 0xa6, 0xc3, 0xec, 0x42, 0x05, 0x9b, 0xa4, 0xc3, - 0xec, 0x6a, 0x22, 0x41, 0xd2, 0x04, 0x23, 0x30, 0xae, 0x53, 0x80, 0xe2, 0x4f, 0x0e, 0x48, 0xfe, - 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43, 0x4e, 0xd1, 0x45, 0xba, 0x1c, 0x31, 0x74, 0x89, 0x6f, 0xe8, 0x05, 0x9f, 0xb7, - 0xdb, 0xd3, 0x07, 0xc0, 0x37, 0x37, 0xd1, 0xc7, 0x95, 0xb3, 0x8a, 0x93, 0x7b, 0x57, 0x9c, 0xe8, - 0x15, 0x27, 0x6b, 0x2a, 0x56, 0x99, 0x5c, 0x66, 0x8d, 0x62, 0x6c, 0x67, 0x9b, 0x64, 0x6e, 0xcf, - 0x43, 0xe5, 0x92, 0x8a, 0x72, 0xa5, 0xbc, 0x22, 0x5d, 0x62, 0xf9, 0xa3, 0x73, 0xc4, 0x44, 0xe2, - 0x69, 0x7d, 0xaa, 0xb1, 0xf4, 0x45, 0x3c, 0x99, 0x8d, 0xd3, 0x79, 0xef, 0x03, 0xca, 0xcb, 0x26, - 0xf1, 0x28, 0xdd, 0x95, 0x3b, 0x70, 0x0e, 0xc6, 0x80, 0x7b, 0x15, 0x0b, 0x6a, 0x5a, 0xda, 0xc7, - 0xd3, 0x8f, 0x09, 0xf4, 0x08, 0x56, 0x20, 0xb5, 0x93, 0x02, 0xde, 0x06, 0x5f, 0xed, 0x21, 0x29, - 0x43, 0xa0, 0xa6, 0x8b, 0x21, 0x16, 0x08, 0xdd, 0x08, 0xe5, 0x23, 0x59, 0x9d, 0xf6, 0x3e, 0x38, - 0xb4, 0x01, 0x3e, 0x61, 0x07, 0x95, 0x1c, 0xc4, 0x18, 0x82, 0xa0, 0x44, 0x25, 0xa8, 0x57, 0xa6, - 0x28, 0xb1, 0x51, 0x94, 0x18, 0x29, 0xea, 0x27, 0x32, 0x4d, 0x3d, 0x33, 0x4d, 0x3d, 0x37, 0x54, - 0x04, 0x13, 0x54, 0x4a, 0xda, 0xe0, 0x93, 0x62, 0x3e, 0x1e, 0x31, 0xf7, 0x30, 0x32, 0x2e, 0xc9, - 0xf3, 0x31, 0x17, 0x26, 0x37, 0x59, 0x71, 0x89, 0x00, 0x66, 0x7a, 0xee,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4a, 0x21, 0x38, 0x12, 0x2f, 0x45, 0xa2, - 0x56, 0x9e, 0xe3, 0xa6, 0xf3, 0x62, 0xb8, 0x29, 0x20, 0x2f, 0xd0, 0x38, 0xa0, 0xc9, 0x8e, 0x9d, - 0xac, 0xb8, 0x77, 0xc8, 0x48, 0x04, 0x22, 0x95, 0x21, 0x25, 0x19, 0xae, 0xc7, 0xbe, 0x21, 0x02, - 0x30, 0x14, 0x60, 0x64, 0x63, 0x86, 0xc1, 0xe3, 0x25, 0x55, 0xc8, 0xf6, 0x50, 0x71, 0x26, 0xdd, - 0x6b, 0xc5, 0x03, 0x45, 0x52, 0x20, 0xdc, 0x19, 0xf9, 0x45, 0x0d, 0x71, 0xd1, 0xac, 0x5e, 0xd9, - 0x17, 0x01, 0x2c, 0x4c, 0xc2, 0xc3, 0x80, 0xf2, 0xe9, 0x90, 0xb1, 0x69, 0xd2, 0xfe, 0x72, 0x83, - 0xaf, 0x67, 0x58, 0x96, 0x08, 0x6e, 0x22, 0x01, 0xa7, 0xa1, 0x10, 0xad, 0x99, 0x04, 0x27, 0x21, - 0x33, 0xc1, 0x97, 0x98, 0xdf, 0xc7, 0x40, 0x48, 0x6d, 0x41, 0x9c, 0x2c, 0x13, 0x5f, 0x4d, 0x94, - 0x22, 0x87, 0xe4, 0x16, 0x12, 0x56, 0x94, 0x2a, 0x6e, 0xc7, 0x6e, 0x53, 0xfa, 0xbc, 0x9f, 0x70, - 0xe3, 0x53, 0x12, 0x53, 0x8a, 0x43, 0x32, 0x9f, 0xbe, 0x79, 0x7d, 0xdc, 0xe9, 0xbe, 0x3a, 0x32, - 0x49, 0x38, 0xea, 0x97, 0x2c, 0x6f, 0x3e, 0xe1, 0x98, 0xfd, 0xd5, 0xca, 0x6b, 0x39, 0xca, 0xad, - 0xfc, 0xd8, 0x17, 0x95, 0x36, 0xfa, 0xeb, 0x84, 0x9b, 0xbe, 0x19, 0xa6, 0xc9, 0x37, 0x4a, 0xa6, - 0x96, 0x8a, 0x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c, 0x76, 0x9b, 0xd4, 0x06, 0x45, 0xab, 0xf6, - 0x33, 0xd4, 0x7e, 0x86, 0xda, 0xcf, 0x70, 0x28, 0x3f, 0x83, 0x98, 0xae, 0xb1, 0xac, 0xf4, 0x3f, - 0xac, 0xff, 0x61, 0x9b, 0xeb, 0xa8, 0x8a, 0xac, 0xd3, 0xe3, 0xbc, 0xac, 0x75, 0x64, 0x1c, 0xce, - 0xc8, 0x79, 0x29, 0xb7, 0x41, 0xff, 0x0c, 0xde, 0x99, 0x27, 0x74, 0xad, 0xf4, 0x11, 0xbd, 0x47, - 0x75, 0xdc, 0xe4, 0x97, 0xf5, 0x9a, 0x8a, 0xdc, 0xd5, 0x72, 0xfb, 0xd4, 0x36, 0xb7, 0x97, 0x1e, - 0xef, 0xb5, 0x40, 0x8d, 0x40, 0xac, 0x01, 0xae, 0x4c, 0x38, 0x13, 0x03, 0x4e, 0x44, 0xb5, 0x47, - 0xfb, 0xbb, 0x0a, 0x23, 0x50, 0x1c, 0x3e, 0x33, 0x97, 0x25, 0xc1, 0xb6, 0x44, 0x5d, 0x49, 0xae, - 0x37, 0xf3, 0x25, 0x22, 0x50, 0x7b, 0xba, 0xbd, 0x54, 0xe1, 0x93, 0x6a, 0xf8, 0x44, 0x85, 0x5f, - 0xf5, 0xf1, 0xcb, 0xd2, 0x4d, 0xde, 0x17, 0x48, 0x0f, 0xa2, 0x97, 0xe5, 0x38, 0x7d, 0x98, 0x26, - 0x47, 0xab, 0x75, 0xd5, 0xec, 0xd1, 0xd7, 0x64, 0x5c, 0x9d, 0xa0, 0x95, 0x40, 0x9e, 0xec, 0x82, - 0x3c, 0xb1, 0x23, 0x4f, 0x04, 0x6b, 0xe0, 0xf8, 0x27, 0xdb, 0x5f, 0x36, 0xc7, 0x3c, 0x84, 0x7a, - 0xd5, 0x47, 0x2d, 0x77, 0x25, 0x5c, 0xc9, 0x0e, 0x57, 0xc5, 0x29, 0xae, 0x04, 0xe1, 0x4a, 0x5c, - 0xc5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, 0xc3, 0x0d, 0x88, 0x43, 0xf6, 0xae, 0x01, 0xc3, 0xd4, 0x80, 0x2a, 0xef, - 0x57, 0xa3, 0xa8, 0x4d, 0xc5, 0x4c, 0x72, 0xa9, 0x28, 0xba, 0x53, 0x1d, 0x72, 0x5f, 0xf3, 0x6c, - 0x5a, 0xac, 0x0b, 0xad, 0x4e, 0xa3, 0x62, 0x73, 0x71, 0x85, 0x64, 0xd4, 0x65, 0x2e, 0xc4, 0x55, - 0xa4, 0x62, 0x6b, 0xdf, 0x28, 0xc5, 0x18, 0x14, 0x11, 0x3f, 0x91, 0x3e, 0xd5, 0x1b, 0x3f, 0x1f, - 0x59, 0x11, 0x07, 0x15, 0x32, 0xb2, 0xf1, 0xd3, 0x51, 0x45, 0x6e, 0x60, 0xc5, 0xa9, 0xd0, 0x26, - 0xb9, 0xce, 0x28, 0x79, 0xc4, 0xa8, 0x03, 0x2b, 0x07, 0xfc, 0xa4, 0x2a, 0xed, 0xd8, 0x70, 0x03, - 0x2f, 0x77, 0x08, 0x3d, 0xe9, 0x45, 0xa5, 0xd2, 0xec, 0x28, 0x17, 0x67, 0x4b, 0x2e, 0xee, 0x1a, - 0x3f, 0x63, 0xbe, 0x0a, 0x7a, 0x27, 0xd8, 0x95, 0x8b, 0x47, 0x42, 0x61, 0x4e, 0x2c, 0xbe, 0x89, - 0x30, 0x07, 0x3b, 0x00, 0xd5, 0x14, 0x12, 0x86, 0x50, 0xe4, 0x3b, 0xd3, 0x34, 0x09, 0x9f, 0x7f, - 0x5d, 0x3b, 0x88, 0x24, 0x0e, 0x77, 0x17, 0x87, 0x07, 0xe7, 0x4f, 0x0a, 0xc5, 0xfa, 0x78, 0x2d, - 0x57, 0x41, 0x69, 0x04, 0x31, 0x64, 0x12, 0x99, 0x2a, 0x02, 0x78, 0x63, 0xfa, 0x4d, 0xa8, 0x37, - 0x03, 0xc7, 0x12, 0x76, 0xe0, 0xb8, 0x17, 0x3e, 0x53, 0xa6, 0xae, 0x44, 0x3e, 0x9c, 0x18, 0x83, - 0x63, 0x69, 0xe1, 0x9d, 0xdc, 0x15, 0x78, 0x7e, 0x22, 0x5e, 0x9d, 0x46, 0x38, 0x64, 0xad, 0x3c, - 0x6b, 0x9b, 0x1a, 0x7e, 0x95, 0x3f, 0x49, 0xc1, 0x01, 0x92, 0x60, 0x38, 0x50, 0x6f, 0x75, 0x41, - 0xf0, 0x52, 0x37, 0xd8, 0x27, 0xed, 0xb8, 0x08, 0xbb, 0xae, 0x39, 0x1a, 0x1f, 0x6f, 0x06, 0x70, - 0x72, 0x7c, 0xfd, 0xd7, 0x80, 0x46, 0x7d, 0x96, 0xdd, 0xdb, 0x20, 0x3f, 0x4d, 0x2b, 0x24, 0x1f, - 0x13, 0x19, 0x12, 0x75, 0xa4, 0x12, 0x40, 0x48, 0xb2, 0x02, 0xe5, 0x15, 0x94, 0xba, 0xbc, 0xb5, - 0x92, 0x81, 0x9a, 0x70, 0xd3, 0xd4, 0x1a, 0xe3, 0xf1, 0x1d, 0xb7, 0xe0, 0x18, 0xb6, 0x4f, 0xe0, - 0x2d, 0x22, 0x55, 0x68, 0xfa, 0x9c, 0x4f, 0x61, 0x17, 0x87, 0xc9, 0xdb, 0xa0, 0xfb, 0x4a, 0x09, - 0x56, 0x7e, 0x4d, 0x45, 0x3b, 0xfa, 0x37, 0x90, 0x16, 0x62, 0x60, 0x0f, 0x79, 0xa9, 0x65, 0x6b, - 0x12, 0xfd, 0x74, 0x54, 0x2d, 0x8c, 0x87, 0xb2, 0x17, 0xba, 0x46, 0x24, 0xe7, 0x23, 0xb1, 0x88, - 0x4d, 0x16, 0x08, 0xda, 0xac, 0x68, 0x24, 0x8d, 0x9f, 0x5a, 0xaa, 0x86, 0xa2, 0x2e, 0xf0, 0xfc, - 0x49, 0x2e, 0xf0, 0xc2, 0x40, 0xa0, 0x75, 0x05, 0x69, 0xe7, 0x7b, 0x53, 0x2a, 0xea, 0xba, 0xb6, - 0x98, 0xe4, 0xd4, 0x12, 0x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 0xff, 0x13, 0xc4, 0xf3, - 0x14, 0x61, 0x9d, 0x62, 0xbd, 0xd6, 0xe2, 0xed, 0xdf, 0x6c, 0xb7, 0x60, 0xd7, 0x9d, 0x01, 0x83, - 0xb2, 0x57, 0x3b, 0xfa, 0x6b, 0x47, 0x3f, 0x75, 0xf4, 0xff, 0x3f, 0xe9, 0x2d, 0xb6, 0x55}; - -const char* shaderSource() { - static std::string decompressed = util::decompress(std::string(reinterpret_cast(compressedShaderSource), sizeof(compressedShaderSource))); - return decompressed.c_str(); -}; - -} // namespace gl -} // namespace programs -} // namespace mbgl -// clang-format on diff --git a/src/mbgl/programs/gl/shader_source.hpp b/src/mbgl/programs/gl/shader_source.hpp deleted file mode 100644 index 1a5fbddae..000000000 --- a/src/mbgl/programs/gl/shader_source.hpp +++ /dev/null @@ -1,16 +0,0 @@ -// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. - -#pragma once - -namespace mbgl { -namespace programs { -namespace gl { - -const char* shaderSource(); - -template -struct ShaderSource; - -} // namespace gl -} // namespace programs -} // namespace mbgl diff --git a/src/mbgl/programs/gl/shaders.cpp b/src/mbgl/programs/gl/shaders.cpp deleted file mode 100644 index e8c9bdfc3..000000000 --- a/src/mbgl/programs/gl/shaders.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include -#include -#include -#include - -#include - -namespace mbgl { -namespace programs { -namespace gl { - -std::string programIdentifier(const std::string& defines1, - const std::string& defines2, - const uint8_t hash1[8], - const uint8_t hash2[8]) { - std::string result; - result.reserve(8 + 8 + (sizeof(size_t) * 2) * 2 + 2); - result.append(util::toHex(static_cast(std::hash()(defines1)))); - result.append(util::toHex(static_cast(std::hash()(defines2)))); - result.append(hash1, hash2 + 8); - result.append(hash2, hash2 + 8); - result.append("v3"); - return result; -} - -} // namespace gl -} // namespace programs -} // namespace mbgl diff --git a/src/mbgl/programs/gl/shaders.hpp b/src/mbgl/programs/gl/shaders.hpp deleted file mode 100644 index 25a1e6cb5..000000000 --- a/src/mbgl/programs/gl/shaders.hpp +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - -#include -#include - -namespace mbgl { - -class ProgramParameters; - -namespace programs { -namespace gl { - -std::string programIdentifier(const std::string& defines1, - const std::string& defines2, - const uint8_t hash1[8], - const uint8_t hash2[8]); - -} // namespace gl -} // namespace programs -} // namespace mbgl diff --git a/src/mbgl/programs/heatmap_program.hpp b/src/mbgl/programs/heatmap_program.hpp index 537a9e956..18640dfa3 100644 --- a/src/mbgl/programs/heatmap_program.hpp +++ b/src/mbgl/programs/heatmap_program.hpp @@ -13,8 +13,9 @@ namespace uniforms { MBGL_DEFINE_UNIFORM_SCALAR(float, intensity); } // namespace uniforms -class HeatmapProgram : public Program< +class HeatmapProgram final : public Program< HeatmapProgram, + shaders::BuiltIn::HeatmapProgram, gfx::PrimitiveType::Triangle, TypeList< attributes::pos>, @@ -26,6 +27,11 @@ class HeatmapProgram : public Program< style::HeatmapPaintProperties> { public: + static constexpr std::string_view Name{"HeatmapProgram"}; + const std::string_view name() const noexcept override { + return Name; + } + using Program::Program; /* @@ -47,13 +53,4 @@ public: using HeatmapLayoutVertex = HeatmapProgram::LayoutVertex; using HeatmapAttributes = HeatmapProgram::AttributeList; -class HeatmapLayerPrograms final : public LayerTypePrograms { -public: - HeatmapLayerPrograms(gfx::Context& context, const ProgramParameters& programParameters) - : heatmap(context, programParameters), - heatmapTexture(context, programParameters) {} - HeatmapProgram heatmap; - HeatmapTextureProgram heatmapTexture; -}; - } // namespace mbgl diff --git a/src/mbgl/programs/heatmap_texture_program.hpp b/src/mbgl/programs/heatmap_texture_program.hpp index 6762f8c7f..8653a5792 100644 --- a/src/mbgl/programs/heatmap_texture_program.hpp +++ b/src/mbgl/programs/heatmap_texture_program.hpp @@ -9,8 +9,9 @@ namespace mbgl { -class HeatmapTextureProgram : public Program< +class HeatmapTextureProgram final : public Program< HeatmapTextureProgram, + shaders::BuiltIn::HeatmapTextureProgram, gfx::PrimitiveType::Triangle, TypeList, TypeList< @@ -22,6 +23,11 @@ class HeatmapTextureProgram : public Program< textures::color_ramp>, style::Properties<>> { public: + static constexpr std::string_view Name{"HeatmapTextureProgram"}; + const std::string_view name() const noexcept override { + return Name; + } + using Program::Program; static LayoutVertex layoutVertex(Point p) { diff --git a/src/mbgl/programs/hillshade_prepare_program.hpp b/src/mbgl/programs/hillshade_prepare_program.hpp index c85b5bc60..b4966f15e 100644 --- a/src/mbgl/programs/hillshade_prepare_program.hpp +++ b/src/mbgl/programs/hillshade_prepare_program.hpp @@ -14,8 +14,9 @@ MBGL_DEFINE_UNIFORM_SCALAR(float, maxzoom); MBGL_DEFINE_UNIFORM_VECTOR(float, 4, unpack); } // namespace uniforms -class HillshadePrepareProgram : public Program< +class HillshadePrepareProgram final : public Program< HillshadePrepareProgram, + shaders::BuiltIn::HillshadePrepareProgram, gfx::PrimitiveType::Triangle, TypeList< attributes::pos, @@ -30,6 +31,11 @@ class HillshadePrepareProgram : public Program< textures::image>, style::Properties<>> { public: + static constexpr std::string_view Name{"HillshadePrepareProgram"}; + const std::string_view name() const noexcept override { + return Name; + } + using Program::Program; static LayoutVertex layoutVertex(Point p, Point t) { diff --git a/src/mbgl/programs/hillshade_program.hpp b/src/mbgl/programs/hillshade_program.hpp index 33f91abef..f8a3763b7 100644 --- a/src/mbgl/programs/hillshade_program.hpp +++ b/src/mbgl/programs/hillshade_program.hpp @@ -18,8 +18,9 @@ MBGL_DEFINE_UNIFORM_VECTOR(float, 2, light); MBGL_DEFINE_UNIFORM_VECTOR(float, 2, latrange); } // namespace uniforms -class HillshadeProgram : public Program< +class HillshadeProgram final : public Program< HillshadeProgram, + shaders::BuiltIn::HillshadeProgram, gfx::PrimitiveType::Triangle, TypeList< attributes::pos, @@ -35,6 +36,11 @@ class HillshadeProgram : public Program< textures::image>, style::HillshadePaintProperties>{ public: + static constexpr std::string_view Name{"HillshadeProgram"}; + const std::string_view name() const noexcept override { + return Name; + } + using Program::Program; static LayoutVertex layoutVertex(Point p, Point t) { @@ -54,13 +60,4 @@ public: using HillshadeLayoutVertex = HillshadeProgram::LayoutVertex; using HillshadeAttributes = HillshadeProgram::AttributeList; -class HillshadeLayerPrograms final : public LayerTypePrograms { -public: - HillshadeLayerPrograms(gfx::Context& context, const ProgramParameters& programParameters) - : hillshade(context, programParameters), - hillshadePrepare(context, programParameters) {} - HillshadeProgram hillshade; - HillshadePrepareProgram hillshadePrepare; -}; - } // namespace mbgl diff --git a/src/mbgl/programs/line_program.hpp b/src/mbgl/programs/line_program.hpp index 145ac9d6c..76ca92ef6 100644 --- a/src/mbgl/programs/line_program.hpp +++ b/src/mbgl/programs/line_program.hpp @@ -30,8 +30,9 @@ using LineLayoutAttributes = TypeList< attributes::pos_normal, attributes::data>; -class LineProgram : public Program< +class LineProgram final : public Program< LineProgram, + shaders::BuiltIn::LineProgram, gfx::PrimitiveType::Triangle, LineLayoutAttributes, TypeList< @@ -43,6 +44,11 @@ class LineProgram : public Program< style::LinePaintProperties> { public: + static constexpr std::string_view Name{"LineProgram"}; + const std::string_view name() const noexcept override { + return Name; + } + using Program::Program; /* @@ -95,8 +101,9 @@ public: float pixelRatio); }; -class LinePatternProgram : public Program< +class LinePatternProgram final : public Program< LinePatternProgram, + shaders::BuiltIn::LinePatternProgram, gfx::PrimitiveType::Triangle, LineLayoutAttributes, TypeList< @@ -112,6 +119,11 @@ class LinePatternProgram : public Program< style::LinePaintProperties> { public: + static constexpr std::string_view Name{"LinePatternProgram"}; + const std::string_view name() const noexcept override { + return Name; + } + using Program::Program; static LayoutUniformValues layoutUniformValues(const style::LinePaintProperties::PossiblyEvaluated&, @@ -123,8 +135,9 @@ public: const CrossfadeParameters& crossfade); }; -class LineSDFProgram : public Program< +class LineSDFProgram final : public Program< LineSDFProgram, + shaders::BuiltIn::LineSDFProgram, gfx::PrimitiveType::Triangle, LineLayoutAttributes, TypeList< @@ -143,6 +156,11 @@ class LineSDFProgram : public Program< style::LinePaintProperties> { public: + static constexpr std::string_view Name{"LineSDFProgram"}; + const std::string_view name() const noexcept override { + return Name; + } + using Program::Program; static LayoutUniformValues @@ -157,8 +175,9 @@ public: float atlasWidth); }; -class LineGradientProgram : public Program< +class LineGradientProgram final : public Program< LineGradientProgram, + shaders::BuiltIn::LineGradientProgram, gfx::PrimitiveType::Triangle, LineLayoutAttributes, TypeList< @@ -171,6 +190,11 @@ class LineGradientProgram : public Program< style::LinePaintProperties> { public: + static constexpr std::string_view Name{"LineGradientProgram"}; + const std::string_view name() const noexcept override { + return Name; + } + using Program::Program; static LayoutUniformValues layoutUniformValues(const style::LinePaintProperties::PossiblyEvaluated&, @@ -183,17 +207,4 @@ public: using LineLayoutVertex = LineProgram::LayoutVertex; using LineAttributes = LineProgram::AttributeList; -class LineLayerPrograms final : public LayerTypePrograms { -public: - LineLayerPrograms(gfx::Context& context, const ProgramParameters& programParameters) - : line(context, programParameters), - lineGradient(context, programParameters), - lineSDF(context, programParameters), - linePattern(context, programParameters) {} - LineProgram line; - LineGradientProgram lineGradient; - LineSDFProgram lineSDF; - LinePatternProgram linePattern; -}; - } // namespace mbgl diff --git a/src/mbgl/programs/program.hpp b/src/mbgl/programs/program.hpp index 9f833a774..1e312f1bf 100644 --- a/src/mbgl/programs/program.hpp +++ b/src/mbgl/programs/program.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include #include @@ -12,6 +13,11 @@ #include +#include +#ifdef MBGL_RENDER_BACKEND_OPENGL +#include +#endif + namespace mbgl { namespace gfx { @@ -19,12 +25,13 @@ class RenderPass; } // namespace gfx template -class Program { +class Program : public gfx::Shader { public: using LayoutVertex = gfx::Vertex; @@ -45,8 +52,23 @@ public: std::unique_ptr> program; - Program(gfx::Context& context, const ProgramParameters& programParameters) - : program(context.createProgram(programParameters)) { + Program(const ProgramParameters& programParameters) { + switch (gfx::Backend::GetType()) { +#ifdef MBGL_RENDER_BACKEND_OPENGL + case gfx::Backend::Type::OpenGL: { + program = std::make_unique>(programParameters + .withDefaultSource({ + gfx::Backend::Type::OpenGL, + shaders::ShaderSource::vertex, + shaders::ShaderSource::fragment + })); + break; + } +#endif + default: { + throw std::runtime_error("Unsupported rendering backend!"); + } + } } static UniformValues computeAllUniformValues( diff --git a/src/mbgl/programs/program_parameters.cpp b/src/mbgl/programs/program_parameters.cpp index a61bb884e..28f10ecca 100644 --- a/src/mbgl/programs/program_parameters.cpp +++ b/src/mbgl/programs/program_parameters.cpp @@ -1,30 +1,44 @@ #include #include #include +#include namespace mbgl { ProgramParameters::ProgramParameters(const float pixelRatio, const bool overdraw) : defines([&] { - std::string result; - result.reserve(32); - result += "#define DEVICE_PIXEL_RATIO "; - result += util::toString(pixelRatio, true); - result += '\n'; - if (overdraw) { - result += "#define OVERDRAW_INSPECTOR\n"; - } - return result; + std::string result; + result.reserve(32); + result += "#define DEVICE_PIXEL_RATIO "; + result += util::toString(pixelRatio, true); + result += '\n'; + if (overdraw) { + result += "#define OVERDRAW_INSPECTOR\n"; + } + return result; }()) {} -ProgramParameters ProgramParameters::withShaderSource(std::string_view vertexSource, - std::string_view fragmentSource) const noexcept +ProgramParameters ProgramParameters::withShaderSource( + const ProgramSource &source) const noexcept { + assert(gfx::Backend::Type::TYPE_MAX != source.backend); + ProgramParameters params = *this; - params.vertexSource_ = vertexSource; - params.fragmentSource_ = fragmentSource; + params.userSources[static_cast(source.backend)] + = source; + return params; +} + +ProgramParameters ProgramParameters::withDefaultSource( + const ProgramSource &source) const noexcept +{ + assert(gfx::Backend::Type::TYPE_MAX != source.backend); + + ProgramParameters params = *this; + params.defaultSources[static_cast(source.backend)] + = source; return params; } @@ -32,12 +46,30 @@ const std::string& ProgramParameters::getDefines() const { return defines; } -const std::string& ProgramParameters::vertexSource() const noexcept { - return vertexSource_; +const std::string& +ProgramParameters::vertexSource(gfx::Backend::Type backend) const { + assert(gfx::Backend::Type::TYPE_MAX != backend); + + if (userSources[static_cast(backend)].vertex.length() > 0) { + return userSources[static_cast(backend)].vertex; + } else if (defaultSources[static_cast(backend)].vertex.length() > 0) { + return defaultSources[static_cast(backend)].vertex; + } else { + throw std::runtime_error("No vertex shader source provided for selected backend!"); + } } -const std::string& ProgramParameters::fragmentSource() const noexcept { - return fragmentSource_; +const std::string& +ProgramParameters::fragmentSource(gfx::Backend::Type backend) const { + assert(gfx::Backend::Type::TYPE_MAX != backend); + + if (userSources[static_cast(backend)].fragment.length() > 0) { + return userSources[static_cast(backend)].fragment; + } else if (defaultSources[static_cast(backend)].fragment.length() > 0) { + return defaultSources[static_cast(backend)].fragment; + } else { + throw std::runtime_error("No fragment shader source provided for selected backend!"); + } } } // namespace mbgl diff --git a/src/mbgl/programs/program_parameters.hpp b/src/mbgl/programs/program_parameters.hpp index 99e554aff..01c40766b 100644 --- a/src/mbgl/programs/program_parameters.hpp +++ b/src/mbgl/programs/program_parameters.hpp @@ -1,25 +1,69 @@ #pragma once +#include + +#include +#include #include namespace mbgl { class ProgramParameters { -public: - ProgramParameters(float pixelRatio, bool overdraw); + public: + struct ProgramSource { + gfx::Backend::Type backend{gfx::Backend::Type::TYPE_MAX}; + std::string vertex; + std::string fragment; - ProgramParameters withShaderSource(std::string_view vertexSource, - std::string_view fragmentSource) const noexcept; + ProgramSource() = default; - const std::string& getDefines() const; + /// @brief Construct a new ProgramSource object + /// @param forBackend The provided source code is intended for use with the give + /// rendering backend. + /// @param vertex_ The vertex shader source code, or empty string if not provided. + /// @param fragment_ The fragment shader source code, or empty string if not provided. + ProgramSource(gfx::Backend::Type forBackend, const std::string& vertex_, + const std::string& fragment_) + : backend(forBackend), vertex(vertex_), fragment(fragment_) + { + assert(gfx::Backend::Type::TYPE_MAX != forBackend); + } + }; - const std::string& vertexSource() const noexcept; - const std::string& fragmentSource() const noexcept; + ProgramParameters(float pixelRatio, bool overdraw); + + /// @brief Provide custom shader code which overrides any default source present + /// @param source ProgramSource + /// @return Mutated ProgramParameters + ProgramParameters withShaderSource(const ProgramSource& source) const noexcept; -private: - std::string defines; - std::string vertexSource_{""}; - std::string fragmentSource_{""}; + /// @brief Provide default shader source + /// @param source ProgramSource + /// @return Mutated ProgramParameters + ProgramParameters withDefaultSource(const ProgramSource& source) const noexcept; + + /// @brief Get a list of built-in shader preprocessor defines + /// @return Shader source string + /// @todo With the addition of future backends, defines should also be backend-aware + const std::string& getDefines() const; + + /// @brief Get source code for the vertex shader compatible with the requested backend + /// @param backend Backend type + /// @return Shader source string + const std::string& vertexSource(gfx::Backend::Type backend) const; + + /// @brief Get source code for the fragment shader compatible with the requested backend + /// @param backend Backend type + /// @return Shader source string + const std::string& fragmentSource(gfx::Backend::Type backend) const; + + private: + std::string defines; + + std::array(gfx::Backend::Type::TYPE_MAX)> + defaultSources; + std::array(gfx::Backend::Type::TYPE_MAX)> + userSources; }; } // namespace mbgl diff --git a/src/mbgl/programs/programs.cpp b/src/mbgl/programs/programs.cpp index 14af28d37..8d2035cdc 100644 --- a/src/mbgl/programs/programs.cpp +++ b/src/mbgl/programs/programs.cpp @@ -10,79 +10,71 @@ #include #include +#include +#include + namespace mbgl { -Programs::Programs(gfx::Context& context_, const ProgramParameters& programParameters_) - : debug(context_, programParameters_), - clippingMask(context_, programParameters_), - context(context_), - programParameters(programParameters_) {} +Programs::Programs(const ProgramParameters& programParameters_) + : programParameters(programParameters_) {} Programs::~Programs() = default; -void Programs::registerWith([[maybe_unused]] gfx::ShaderRegistry& registry) noexcept {} +/// @brief Register a list of types with a shader registry instance +/// @tparam ...T Type list parameter pack +/// @param registry A shader registry instance +/// programParameters_ ProgramParameters used to initialize each instance +template +void registerTypes(gfx::ShaderRegistry& registry, + const ProgramParameters& programParameters_) +{ + /// The following fold expression will create a shared_ptr for every type + /// in the parameter pack and register it with the shader registry. -BackgroundLayerPrograms& Programs::getBackgroundLayerPrograms() noexcept { - if (!backgroundPrograms) { - backgroundPrograms = std::make_unique(context, programParameters); - } - return static_cast(*backgroundPrograms); + /// Registration calls are wrapped in a lambda that throws on registration + /// failure, we shouldn't expect registration to faill unless the shader + /// registry instance provided already has conflicting programs present. + ( [](bool expr) { + if (!expr) { + throw std::runtime_error( + "Failed to register " + + std::string(T::Name) + + " with shader registry!"); + } + }( registry.registerShader( + std::make_shared(programParameters_))), ... ); } -RasterLayerPrograms& Programs::getRasterLayerPrograms() noexcept { - if (!rasterPrograms) { - rasterPrograms = std::make_unique(context, programParameters); - } - return static_cast(*rasterPrograms); -} - -HeatmapLayerPrograms& Programs::getHeatmapLayerPrograms() noexcept { - if (!heatmapPrograms) { - heatmapPrograms = std::make_unique(context, programParameters); - } - return static_cast(*heatmapPrograms); -} - -HillshadeLayerPrograms& Programs::getHillshadeLayerPrograms() noexcept { - if (!hillshadePrograms) { - hillshadePrograms = std::make_unique(context, programParameters); - } - return static_cast(*hillshadePrograms); -} - -FillLayerPrograms& Programs::getFillLayerPrograms() noexcept { - if (!fillPrograms) { - fillPrograms = std::make_unique(context, programParameters); - } - return static_cast(*fillPrograms); -} - -FillExtrusionLayerPrograms& Programs::getFillExtrusionLayerPrograms() noexcept { - if (!fillExtrusionPrograms) { - fillExtrusionPrograms = std::make_unique(context, programParameters); - } - return static_cast(*fillExtrusionPrograms); -} - -CircleLayerPrograms& Programs::getCircleLayerPrograms() noexcept { - if (!circlePrograms) { - circlePrograms = std::make_unique(context, programParameters); - } - return static_cast(*circlePrograms); -} - -LineLayerPrograms& Programs::getLineLayerPrograms() noexcept { - if (!linePrograms) { - linePrograms = std::make_unique(context, programParameters); - } - return static_cast(*linePrograms); -} - -SymbolLayerPrograms& Programs::getSymbolLayerPrograms() noexcept { - if (!symbolPrograms) { - symbolPrograms = std::make_unique(context, programParameters); - } - return static_cast(*symbolPrograms); +void Programs::registerWith(gfx::ShaderRegistry& registry) { + /// The following types will be registered + registerTypes< + BackgroundProgram, + BackgroundPatternProgram, + RasterProgram, + HeatmapProgram, + HeatmapTextureProgram, + HillshadeProgram, + HillshadePrepareProgram, + FillProgram, + FillPatternProgram, + FillOutlineProgram, + FillOutlinePatternProgram, + FillExtrusionProgram, + FillExtrusionPatternProgram, + CircleProgram, + LineProgram, + LineGradientProgram, + LineSDFProgram, + LinePatternProgram, + SymbolIconProgram, + SymbolSDFIconProgram, + SymbolSDFTextProgram, + SymbolTextAndIconProgram, + CollisionBoxProgram, + CollisionCircleProgram, + DebugProgram, + ClippingMaskProgram + >(registry, programParameters); } } // namespace mbgl diff --git a/src/mbgl/programs/programs.hpp b/src/mbgl/programs/programs.hpp index 21a0ac516..9049a2337 100644 --- a/src/mbgl/programs/programs.hpp +++ b/src/mbgl/programs/programs.hpp @@ -21,38 +21,14 @@ class SymbolLayerPrograms; class Programs { public: - Programs(gfx::Context&, const ProgramParameters&); + Programs(const ProgramParameters&); ~Programs(); /// @brief Registers built-in programs with the provided registry. /// @param registry gfx::ShaderRegistry to populate with built-in programs. - void registerWith(gfx::ShaderRegistry& registry) noexcept; - - BackgroundLayerPrograms& getBackgroundLayerPrograms() noexcept; - RasterLayerPrograms& getRasterLayerPrograms() noexcept; - HeatmapLayerPrograms& getHeatmapLayerPrograms() noexcept; - CircleLayerPrograms& getCircleLayerPrograms() noexcept; - HillshadeLayerPrograms& getHillshadeLayerPrograms() noexcept; - FillLayerPrograms& getFillLayerPrograms() noexcept; - FillExtrusionLayerPrograms& getFillExtrusionLayerPrograms() noexcept; - LineLayerPrograms& getLineLayerPrograms() noexcept; - SymbolLayerPrograms& getSymbolLayerPrograms() noexcept; - - DebugProgram debug; - ClippingMaskProgram clippingMask; + void registerWith(gfx::ShaderRegistry& registry); private: - std::unique_ptr backgroundPrograms; - std::unique_ptr circlePrograms; - std::unique_ptr rasterPrograms; - std::unique_ptr heatmapPrograms; - std::unique_ptr hillshadePrograms; - std::unique_ptr fillPrograms; - std::unique_ptr fillExtrusionPrograms; - std::unique_ptr linePrograms; - std::unique_ptr symbolPrograms; - - gfx::Context& context; ProgramParameters programParameters; }; diff --git a/src/mbgl/programs/raster_program.hpp b/src/mbgl/programs/raster_program.hpp index e84ada0bd..e15585dab 100644 --- a/src/mbgl/programs/raster_program.hpp +++ b/src/mbgl/programs/raster_program.hpp @@ -21,8 +21,9 @@ MBGL_DEFINE_UNIFORM_VECTOR(float, 3, spin_weights); MBGL_DEFINE_UNIFORM_VECTOR(float, 2, tl_parent); } // namespace uniforms -class RasterProgram : public Program< +class RasterProgram final : public Program< RasterProgram, + shaders::BuiltIn::RasterProgram, gfx::PrimitiveType::Triangle, TypeList< attributes::pos, @@ -45,6 +46,11 @@ class RasterProgram : public Program< style::RasterPaintProperties> { public: + static constexpr std::string_view Name{"RasterProgram"}; + const std::string_view name() const noexcept override { + return Name; + } + using Program::Program; static LayoutVertex layoutVertex(Point p, Point t) { @@ -64,11 +70,4 @@ public: using RasterLayoutVertex = RasterProgram::LayoutVertex; using RasterAttributes = RasterProgram::AttributeList; -class RasterLayerPrograms final : public LayerTypePrograms { -public: - RasterLayerPrograms(gfx::Context& context, const ProgramParameters& programParameters) - : raster(context, programParameters) {} - RasterProgram raster; -}; - } // namespace mbgl diff --git a/src/mbgl/programs/symbol_program.cpp b/src/mbgl/programs/symbol_program.cpp index 65a829254..76c266f03 100644 --- a/src/mbgl/programs/symbol_program.cpp +++ b/src/mbgl/programs/symbol_program.cpp @@ -123,9 +123,9 @@ SymbolIconProgram::layoutUniformValues(const bool isText, ); } -template -typename SymbolSDFProgram::LayoutUniformValues -SymbolSDFProgram::layoutUniformValues(const bool isText, +template +typename SymbolSDFProgram::LayoutUniformValues +SymbolSDFProgram::layoutUniformValues(const bool isText, const bool hasVariablePacement, const style::SymbolPropertyValues& values, const Size& texsize, @@ -140,7 +140,7 @@ SymbolSDFProgram::layoutUniformValues(const bool isText, ? static_cast(std::cos(state.getPitch())) * state.getCameraToCenterDistance() : 1.0f); - return makeValues::LayoutUniformValues>( + return makeValues::LayoutUniformValues>( isText, hasVariablePacement, values, @@ -168,21 +168,23 @@ SymbolTextAndIconProgram::LayoutUniformValues SymbolTextAndIconProgram::layoutUn const TransformState& state, const float symbolFadeChange, const SymbolSDFPart part) { - return {SymbolSDFProgram::layoutUniformValues(true, - hasVariablePacement, - values, - texsize, - pixelsToGLUnits, - pixelRatio, - alongLine, - tile, - state, - symbolFadeChange, - part) - .concat(gfx::UniformValues(uniforms::texsize::Value(texsize_icon)))}; + return {SymbolSDFProgram + ::layoutUniformValues( + true, + hasVariablePacement, + values, + texsize, + pixelsToGLUnits, + pixelRatio, + alongLine, + tile, + state, + symbolFadeChange, + part) + .concat(gfx::UniformValues(uniforms::texsize::Value(texsize_icon)))}; } -template class SymbolSDFProgram; -template class SymbolSDFProgram; +template class SymbolSDFProgram; +template class SymbolSDFProgram; } // namespace mbgl diff --git a/src/mbgl/programs/symbol_program.hpp b/src/mbgl/programs/symbol_program.hpp index 8c4bc1f1d..a3e088cab 100644 --- a/src/mbgl/programs/symbol_program.hpp +++ b/src/mbgl/programs/symbol_program.hpp @@ -17,6 +17,11 @@ #include #include +#include +#ifdef MBGL_RENDER_BACKEND_OPENGL +#include +#endif + namespace mbgl { const uint16_t MAX_GLYPH_ICON_SIZE = 255; @@ -195,7 +200,7 @@ public: Range coveringZoomStops; }; -class SymbolProgramBase { +class SymbolProgramBase : public gfx::Shader { public: static gfx::Vertex layoutVertex(Point labelAnchor, Point o, @@ -241,6 +246,7 @@ public: }; template > program; - SymbolProgram(gfx::Context& context, const ProgramParameters& programParameters) - : program(context.createProgram(programParameters)) { + SymbolProgram(const ProgramParameters& programParameters) { + switch (gfx::Backend::GetType()) { +#ifdef MBGL_RENDER_BACKEND_OPENGL + case gfx::Backend::Type::OpenGL: { + program = std::make_unique>(programParameters + .withDefaultSource({ + gfx::Backend::Type::OpenGL, + shaders::ShaderSource::vertex, + shaders::ShaderSource::fragment + })); + break; + } +#endif + default: { + throw std::runtime_error("Unsupported rendering backend!"); + } + } } static UniformValues computeAllUniformValues( @@ -382,8 +403,9 @@ public: } }; -class SymbolIconProgram : public SymbolProgram< +class SymbolIconProgram final : public SymbolProgram< SymbolIconProgram, + shaders::BuiltIn::SymbolIconProgram, gfx::PrimitiveType::Triangle, SymbolLayoutAttributes, TypeList< @@ -404,6 +426,11 @@ class SymbolIconProgram : public SymbolProgram< style::IconPaintProperties> { public: + static constexpr std::string_view Name{"SymbolIconProgram"}; + const std::string_view name() const noexcept override { + return Name; + } + using SymbolProgram::SymbolProgram; static LayoutUniformValues layoutUniformValues(bool isText, @@ -438,8 +465,9 @@ using SymbolSDFProgramUniforms = TypeList; -template +template class SymbolSDFProgram : public SymbolProgram { public: using BaseProgram = SymbolProgram; -class SymbolTextAndIconProgram +class SymbolTextAndIconProgram final : public SymbolProgram, TypeList, style::TextPaintProperties> { public: + static constexpr std::string_view Name{"SymbolTextAndIconProgram"}; + const std::string_view name() const noexcept override { + return Name; + } + using BaseProgram = SymbolProgram, @@ -504,13 +540,31 @@ public: SymbolSDFPart); }; -class SymbolSDFIconProgram : public SymbolSDFProgram { +class SymbolSDFIconProgram final : public SymbolSDFProgram< + SymbolSDFIconProgram, + shaders::BuiltIn::SymbolSDFIconProgram, + style::IconPaintProperties> +{ public: + static constexpr std::string_view Name{"SymbolSDFIconProgram"}; + const std::string_view name() const noexcept override { + return Name; + } + using SymbolSDFProgram::SymbolSDFProgram; }; -class SymbolSDFTextProgram : public SymbolSDFProgram { +class SymbolSDFTextProgram final : public SymbolSDFProgram< + SymbolSDFTextProgram, + shaders::BuiltIn::SymbolSDFTextProgram, + style::TextPaintProperties> +{ public: + static constexpr std::string_view Name{"SymbolSDFTextProgram"}; + const std::string_view name() const noexcept override { + return Name; + } + using SymbolSDFProgram::SymbolSDFProgram; }; @@ -518,21 +572,4 @@ using SymbolLayoutVertex = gfx::Vertex; using SymbolIconAttributes = SymbolIconProgram::AttributeList; using SymbolTextAttributes = SymbolSDFTextProgram::AttributeList; -class SymbolLayerPrograms final : public LayerTypePrograms { -public: - SymbolLayerPrograms(gfx::Context& context, const ProgramParameters& programParameters) - : symbolIcon(context, programParameters), - symbolIconSDF(context, programParameters), - symbolGlyph(context, programParameters), - symbolTextAndIcon(context, programParameters), - collisionBox(context, programParameters), - collisionCircle(context, programParameters) {} - SymbolIconProgram symbolIcon; - SymbolSDFIconProgram symbolIconSDF; - SymbolSDFTextProgram symbolGlyph; - SymbolTextAndIconProgram symbolTextAndIcon; - CollisionBoxProgram collisionBox; - CollisionCircleProgram collisionCircle; -}; - } // namespace mbgl diff --git a/src/mbgl/renderer/layers/render_background_layer.cpp b/src/mbgl/renderer/layers/render_background_layer.cpp index 79afb8ac3..95537c0ff 100644 --- a/src/mbgl/renderer/layers/render_background_layer.cpp +++ b/src/mbgl/renderer/layers/render_background_layer.cpp @@ -10,6 +10,7 @@ #include #include #include +#include namespace mbgl { @@ -64,6 +65,10 @@ void RenderBackgroundLayer::render(PaintParameters& parameters) { // Note that for bottommost layers without a pattern, the background color is drawn with // glClear rather than this method. + // Ensure programs are available + if (!parameters.shaders.populate(backgroundProgram)) return; + if (!parameters.shaders.populate(backgroundPatternProgram)) return; + const Properties<>::PossiblyEvaluated properties; const BackgroundProgram::Binders paintAttributeData(properties, 0); @@ -117,7 +122,7 @@ void RenderBackgroundLayer::render(PaintParameters& parameters) { uint32_t i = 0; for (const auto& tileID : util::tileCover(parameters.state, parameters.state.getIntegerZoom())) { const UnwrappedTileID unwrappedTileID = tileID.toUnwrapped(); - draw(parameters.programs.getBackgroundLayerPrograms().backgroundPattern, + draw(*backgroundPatternProgram, BackgroundPatternProgram::layoutUniformValues(parameters.matrixForTile(unwrappedTileID), evaluated.get(), parameters.patternAtlas.getPixelSize(), @@ -140,7 +145,7 @@ void RenderBackgroundLayer::render(PaintParameters& parameters) { } uint32_t i = 0; for (const auto& tileID : util::tileCover(parameters.state, parameters.state.getIntegerZoom())) { - draw(parameters.programs.getBackgroundLayerPrograms().background, + draw(*backgroundProgram, BackgroundProgram::LayoutUniformValues{ uniforms::matrix::Value(parameters.matrixForTile(tileID.toUnwrapped())), uniforms::color::Value(evaluated.get()), diff --git a/src/mbgl/renderer/layers/render_background_layer.hpp b/src/mbgl/renderer/layers/render_background_layer.hpp index 9770534f0..f0cfd2012 100644 --- a/src/mbgl/renderer/layers/render_background_layer.hpp +++ b/src/mbgl/renderer/layers/render_background_layer.hpp @@ -24,6 +24,10 @@ private: // Paint properties style::BackgroundPaintProperties::Unevaluated unevaluated; SegmentVector segments; + + // Programs + std::shared_ptr backgroundProgram; + std::shared_ptr backgroundPatternProgram; }; } // namespace mbgl diff --git a/src/mbgl/renderer/layers/render_circle_layer.cpp b/src/mbgl/renderer/layers/render_circle_layer.cpp index a89ad7d52..28e9368ed 100644 --- a/src/mbgl/renderer/layers/render_circle_layer.cpp +++ b/src/mbgl/renderer/layers/render_circle_layer.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -80,6 +81,9 @@ void RenderCircleLayer::render(PaintParameters& parameters) { if (parameters.pass == RenderPass::Opaque) { return; } + + if (!parameters.shaders.populate(circleProgram)) return; + const auto drawTile = [&](const RenderTile& tile, const LayerRenderData* data, const auto& segments) { auto& circleBucket = static_cast(*data->bucket); const auto& evaluated = getEvaluated(data->layerProperties); @@ -87,7 +91,6 @@ void RenderCircleLayer::render(PaintParameters& parameters) { const bool pitchWithMap = evaluated.template get() == AlignmentType::Map; const auto& paintPropertyBinders = circleBucket.paintPropertyBinders.at(getID()); - auto& programInstance = parameters.programs.getCircleLayerPrograms().circle; using LayoutUniformValues = CircleProgram::LayoutUniformValues; const auto& allUniformValues = CircleProgram::computeAllUniformValues( LayoutUniformValues( @@ -110,19 +113,19 @@ void RenderCircleLayer::render(PaintParameters& parameters) { checkRenderability(parameters, CircleProgram::activeBindingCount(allAttributeBindings)); - programInstance.draw(parameters.context, - *parameters.renderPass, - gfx::Triangles(), - parameters.depthModeForSublayer(0, gfx::DepthMaskType::ReadOnly), - gfx::StencilMode::disabled(), - parameters.colorModeForRenderPass(), - gfx::CullFaceMode::disabled(), - *circleBucket.indexBuffer, - segments, - allUniformValues, - allAttributeBindings, - CircleProgram::TextureBindings{}, - getID()); + circleProgram->draw(parameters.context, + *parameters.renderPass, + gfx::Triangles(), + parameters.depthModeForSublayer(0, gfx::DepthMaskType::ReadOnly), + gfx::StencilMode::disabled(), + parameters.colorModeForRenderPass(), + gfx::CullFaceMode::disabled(), + *circleBucket.indexBuffer, + segments, + allUniformValues, + allAttributeBindings, + CircleProgram::TextureBindings{}, + getID()); }; const bool sortFeaturesByKey = !impl_cast(baseImpl).layout.get().isUndefined(); diff --git a/src/mbgl/renderer/layers/render_circle_layer.hpp b/src/mbgl/renderer/layers/render_circle_layer.hpp index d551e9e37..ccf4d40b7 100644 --- a/src/mbgl/renderer/layers/render_circle_layer.hpp +++ b/src/mbgl/renderer/layers/render_circle_layer.hpp @@ -6,6 +6,8 @@ namespace mbgl { +class CircleProgram; + class RenderCircleLayer final : public RenderLayer { public: explicit RenderCircleLayer(Immutable); @@ -28,6 +30,9 @@ private: // Paint properties style::CirclePaintProperties::Unevaluated unevaluated; + + // Programs + std::shared_ptr circleProgram; }; } // namespace mbgl diff --git a/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp b/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp index 0703bb879..b6f4d9641 100644 --- a/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp +++ b/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -71,6 +72,9 @@ void RenderFillExtrusionLayer::render(PaintParameters& parameters) { return; } + if (!parameters.shaders.populate(fillExtrusionProgram)) return; + if (!parameters.shaders.populate(fillExtrusionPatternProgram)) return; + const auto& evaluated = static_cast(*evaluatedProperties).evaluated; const auto& crossfade = static_cast(*evaluatedProperties).crossfade; if (evaluatedProperties->renderPasses == mbgl::underlying_type(RenderPass::None)) { @@ -133,7 +137,7 @@ void RenderFillExtrusionLayer::render(PaintParameters& parameters) { } auto& bucket = static_cast(*renderData->bucket); draw( - parameters.programs.getFillExtrusionLayerPrograms().fillExtrusion, + *fillExtrusionProgram, evaluated, crossfade, stencilMode_, @@ -184,7 +188,7 @@ void RenderFillExtrusionLayer::render(PaintParameters& parameters) { std::optional patternPosB = tile.getPattern(fillPatternValue.to.id()); draw( - parameters.programs.getFillExtrusionLayerPrograms().fillExtrusionPattern, + *fillExtrusionPatternProgram, evaluated, crossfade, stencilMode_, diff --git a/src/mbgl/renderer/layers/render_fill_extrusion_layer.hpp b/src/mbgl/renderer/layers/render_fill_extrusion_layer.hpp index 558ea8cdb..62fbac0c9 100644 --- a/src/mbgl/renderer/layers/render_fill_extrusion_layer.hpp +++ b/src/mbgl/renderer/layers/render_fill_extrusion_layer.hpp @@ -7,6 +7,9 @@ namespace mbgl { +class FillExtrusionProgram; +class FillExtrusionPatternProgram; + class RenderFillExtrusionLayer final : public RenderLayer { public: explicit RenderFillExtrusionLayer(Immutable); @@ -31,6 +34,10 @@ private: // Paint properties style::FillExtrusionPaintProperties::Unevaluated unevaluated; + // Programs + std::shared_ptr fillExtrusionProgram; + std::shared_ptr fillExtrusionPatternProgram; + std::unique_ptr renderTexture; }; diff --git a/src/mbgl/renderer/layers/render_fill_layer.cpp b/src/mbgl/renderer/layers/render_fill_layer.cpp index 50369aed8..c3baae8bd 100644 --- a/src/mbgl/renderer/layers/render_fill_layer.cpp +++ b/src/mbgl/renderer/layers/render_fill_layer.cpp @@ -74,6 +74,12 @@ bool RenderFillLayer::hasCrossfade() const { void RenderFillLayer::render(PaintParameters& parameters) { assert(renderTiles); + + if (!parameters.shaders.populate(fillProgram)) return; + if (!parameters.shaders.populate(fillPatternProgram)) return; + if (!parameters.shaders.populate(fillOutlineProgram)) return; + if (!parameters.shaders.populate(fillOutlinePatternProgram)) return; + if (unevaluated.get().isUndefined()) { parameters.renderTileClippingMasks(renderTiles); for (const RenderTile& tile : *renderTiles) { @@ -132,7 +138,7 @@ void RenderFillLayer::render(PaintParameters& parameters) { && evaluated.get().constantOr(0) >= 1.0f && parameters.currentLayer >= parameters.opaquePassCutoff) ? RenderPass::Opaque : RenderPass::Translucent; if (bucket.triangleIndexBuffer && parameters.pass == fillRenderPass) { - draw(parameters.programs.getFillLayerPrograms().fill, + draw(*fillProgram, gfx::Triangles(), parameters.depthModeForSublayer(1, parameters.pass == RenderPass::Opaque ? gfx::DepthMaskType::ReadWrite @@ -143,7 +149,7 @@ void RenderFillLayer::render(PaintParameters& parameters) { } if (evaluated.get() && parameters.pass == RenderPass::Translucent) { - draw(parameters.programs.getFillLayerPrograms().fillOutline, + draw(*fillOutlineProgram, gfx::Lines{ 2.0f }, parameters.depthModeForSublayer( unevaluated.get().isUndefined() ? 2 : 0, @@ -222,7 +228,7 @@ void RenderFillLayer::render(PaintParameters& parameters) { }; if (bucket.triangleIndexBuffer) { - draw(parameters.programs.getFillLayerPrograms().fillPattern, + draw(*fillPatternProgram, gfx::Triangles(), parameters.depthModeForSublayer(1, gfx::DepthMaskType::ReadWrite), *bucket.triangleIndexBuffer, @@ -232,7 +238,7 @@ void RenderFillLayer::render(PaintParameters& parameters) { }); } if (evaluated.get() && unevaluated.get().isUndefined()) { - draw(parameters.programs.getFillLayerPrograms().fillOutlinePattern, + draw(*fillOutlinePatternProgram, gfx::Lines { 2.0f }, parameters.depthModeForSublayer(2, gfx::DepthMaskType::ReadOnly), *bucket.lineIndexBuffer, diff --git a/src/mbgl/renderer/layers/render_fill_layer.hpp b/src/mbgl/renderer/layers/render_fill_layer.hpp index f3ef9ab66..864500b09 100644 --- a/src/mbgl/renderer/layers/render_fill_layer.hpp +++ b/src/mbgl/renderer/layers/render_fill_layer.hpp @@ -8,6 +8,10 @@ namespace mbgl { class FillBucket; +class FillProgram; +class FillPatternProgram; +class FillOutlineProgram; +class FillOutlinePatternProgram; class RenderFillLayer final : public RenderLayer { public: @@ -31,6 +35,12 @@ private: // Paint properties style::FillPaintProperties::Unevaluated unevaluated; + + // Programs + std::shared_ptr fillProgram; + std::shared_ptr fillPatternProgram; + std::shared_ptr fillOutlineProgram; + std::shared_ptr fillOutlinePatternProgram; }; } // namespace mbgl diff --git a/src/mbgl/renderer/layers/render_heatmap_layer.cpp b/src/mbgl/renderer/layers/render_heatmap_layer.cpp index 4a5b35140..d13bb01ec 100644 --- a/src/mbgl/renderer/layers/render_heatmap_layer.cpp +++ b/src/mbgl/renderer/layers/render_heatmap_layer.cpp @@ -72,6 +72,9 @@ void RenderHeatmapLayer::render(PaintParameters& parameters) { return; } + if (!parameters.shaders.populate(heatmapProgram)) return; + if (!parameters.shaders.populate(heatmapTextureProgram)) return; + if (parameters.pass == RenderPass::Pass3D) { const auto& viewportSize = parameters.staticData.backendSize; const auto size = Size{viewportSize.width / 4, viewportSize.height / 4}; @@ -110,8 +113,6 @@ void RenderHeatmapLayer::render(PaintParameters& parameters) { const auto& paintPropertyBinders = bucket.paintPropertyBinders.at(getID()); - auto& programInstance = parameters.programs.getHeatmapLayerPrograms().heatmap; - const auto allUniformValues = HeatmapProgram::computeAllUniformValues( HeatmapProgram::LayoutUniformValues{ uniforms::intensity::Value(evaluated.get()), @@ -125,7 +126,7 @@ void RenderHeatmapLayer::render(PaintParameters& parameters) { checkRenderability(parameters, HeatmapProgram::activeBindingCount(allAttributeBindings)); - programInstance.draw(parameters.context, + heatmapProgram->draw(parameters.context, *renderPass, gfx::Triangles(), gfx::DepthMode::disabled(), @@ -149,8 +150,6 @@ void RenderHeatmapLayer::render(PaintParameters& parameters) { const Properties<>::PossiblyEvaluated properties; const HeatmapTextureProgram::Binders paintAttributeData{ properties, 0 }; - auto& programInstance = parameters.programs.getHeatmapLayerPrograms().heatmapTexture; - const auto allUniformValues = HeatmapTextureProgram::computeAllUniformValues( HeatmapTextureProgram::LayoutUniformValues{ uniforms::matrix::Value(viewportMat), @@ -169,7 +168,7 @@ void RenderHeatmapLayer::render(PaintParameters& parameters) { // Copy over the segments so that we can create our own DrawScopes. segments = RenderStaticData::heatmapTextureSegments(); } - programInstance.draw( + heatmapTextureProgram->draw( parameters.context, *parameters.renderPass, gfx::Triangles(), diff --git a/src/mbgl/renderer/layers/render_heatmap_layer.hpp b/src/mbgl/renderer/layers/render_heatmap_layer.hpp index 1d8b12b4a..94be5c5da 100644 --- a/src/mbgl/renderer/layers/render_heatmap_layer.hpp +++ b/src/mbgl/renderer/layers/render_heatmap_layer.hpp @@ -39,6 +39,10 @@ private: std::unique_ptr renderTexture; std::optional colorRampTexture; SegmentVector segments; + + // Programs + std::shared_ptr heatmapProgram; + std::shared_ptr heatmapTextureProgram; }; } // namespace mbgl diff --git a/src/mbgl/renderer/layers/render_hillshade_layer.cpp b/src/mbgl/renderer/layers/render_hillshade_layer.cpp index 75b2f3fc3..e8955c474 100644 --- a/src/mbgl/renderer/layers/render_hillshade_layer.cpp +++ b/src/mbgl/renderer/layers/render_hillshade_layer.cpp @@ -78,6 +78,10 @@ void RenderHillshadeLayer::render(PaintParameters& parameters) { assert(renderTiles); if (parameters.pass != RenderPass::Translucent && parameters.pass != RenderPass::Pass3D) return; + + if (!parameters.shaders.populate(hillshadeProgram)) return; + if (!parameters.shaders.populate(hillshadePrepareProgram)) return; + const auto& evaluated = static_cast(*evaluatedProperties).evaluated; auto draw = [&] (const mat4& matrix, const auto& vertexBuffer, @@ -85,8 +89,6 @@ void RenderHillshadeLayer::render(PaintParameters& parameters) { const auto& segments, const UnwrappedTileID& id, const auto& textureBindings) { - auto& programInstance = parameters.programs.getHillshadeLayerPrograms().hillshade; - const HillshadeProgram::Binders paintAttributeData{ evaluated, 0 }; const auto allUniformValues = HillshadeProgram::computeAllUniformValues( @@ -106,7 +108,7 @@ void RenderHillshadeLayer::render(PaintParameters& parameters) { checkRenderability(parameters, HillshadeProgram::activeBindingCount(allAttributeBindings)); - programInstance.draw(parameters.context, + hillshadeProgram->draw(parameters.context, *parameters.renderPass, gfx::Triangles(), parameters.depthModeForSublayer(0, gfx::DepthMaskType::ReadOnly), @@ -148,8 +150,6 @@ void RenderHillshadeLayer::render(PaintParameters& parameters) { const Properties<>::PossiblyEvaluated properties; const HillshadePrepareProgram::Binders paintAttributeData{ properties, 0 }; - - auto& programInstance = parameters.programs.getHillshadeLayerPrograms().hillshadePrepare; const auto allUniformValues = HillshadePrepareProgram::computeAllUniformValues( HillshadePrepareProgram::LayoutUniformValues{ @@ -170,7 +170,7 @@ void RenderHillshadeLayer::render(PaintParameters& parameters) { // Copy over the segments so that we can create our own DrawScopes that get destroyed // after this draw call. auto segments = RenderStaticData::rasterSegments(); - programInstance.draw(parameters.context, + hillshadePrepareProgram->draw(parameters.context, *renderPass, gfx::Triangles(), parameters.depthModeForSublayer(0, gfx::DepthMaskType::ReadOnly), diff --git a/src/mbgl/renderer/layers/render_hillshade_layer.hpp b/src/mbgl/renderer/layers/render_hillshade_layer.hpp index 829b66971..1f21892c2 100644 --- a/src/mbgl/renderer/layers/render_hillshade_layer.hpp +++ b/src/mbgl/renderer/layers/render_hillshade_layer.hpp @@ -7,6 +7,9 @@ namespace mbgl { +class HillshadeProgram; +class HillshadePrepareProgram; + class RenderHillshadeLayer: public RenderLayer { public: explicit RenderHillshadeLayer(Immutable); @@ -27,6 +30,10 @@ private: std::array getLatRange(const UnwrappedTileID& id); std::array getLight(const PaintParameters& parameters); + + // Programs + std::shared_ptr hillshadeProgram; + std::shared_ptr hillshadePrepareProgram; }; } // namespace mbgl diff --git a/src/mbgl/renderer/layers/render_line_layer.cpp b/src/mbgl/renderer/layers/render_line_layer.cpp index 070d3ecf9..8dc72bab9 100644 --- a/src/mbgl/renderer/layers/render_line_layer.cpp +++ b/src/mbgl/renderer/layers/render_line_layer.cpp @@ -95,6 +95,11 @@ void RenderLineLayer::render(PaintParameters& parameters) { return; } + if (!parameters.shaders.populate(lineProgram)) return; + if (!parameters.shaders.populate(lineGradientProgram)) return; + if (!parameters.shaders.populate(lineSDFProgram)) return; + if (!parameters.shaders.populate(linePatternProgram)) return; + parameters.renderTileClippingMasks(renderTiles); for (const RenderTile& tile : *renderTiles) { @@ -148,7 +153,7 @@ void RenderLineLayer::render(PaintParameters& parameters) { const auto& dashPatternTexture = parameters.lineAtlas.getDashPatternTexture( evaluated.get().from, evaluated.get().to, cap); - draw(parameters.programs.getLineLayerPrograms().lineSDF, + draw(*lineSDFProgram, LineSDFProgram::layoutUniformValues(evaluated, parameters.pixelRatio, tile, @@ -171,7 +176,7 @@ void RenderLineLayer::render(PaintParameters& parameters) { std::optional posA = tile.getPattern(linePatternValue.from.id()); std::optional posB = tile.getPattern(linePatternValue.to.id()); - draw(parameters.programs.getLineLayerPrograms().linePattern, + draw(*linePatternProgram, LinePatternProgram::layoutUniformValues( evaluated, tile, @@ -188,7 +193,7 @@ void RenderLineLayer::render(PaintParameters& parameters) { } else if (!unevaluated.get().getValue().isUndefined()) { assert(colorRampTexture); - draw(parameters.programs.getLineLayerPrograms().lineGradient, + draw(*lineGradientProgram, LineGradientProgram::layoutUniformValues( evaluated, tile, @@ -201,7 +206,7 @@ void RenderLineLayer::render(PaintParameters& parameters) { textures::image::Value{ colorRampTexture->getResource(), gfx::TextureFilterType::Linear }, }); } else { - draw(parameters.programs.getLineLayerPrograms().line, + draw(*lineProgram, LineProgram::layoutUniformValues( evaluated, tile, diff --git a/src/mbgl/renderer/layers/render_line_layer.hpp b/src/mbgl/renderer/layers/render_line_layer.hpp index a5eda223e..88f794f0f 100644 --- a/src/mbgl/renderer/layers/render_line_layer.hpp +++ b/src/mbgl/renderer/layers/render_line_layer.hpp @@ -10,6 +10,11 @@ namespace mbgl { +class LineProgram; +class LineGradientProgram; +class LineSDFProgram; +class LinePatternProgram; + class RenderLineLayer final : public RenderLayer { public: explicit RenderLineLayer(Immutable); @@ -40,6 +45,12 @@ private: PremultipliedImage colorRamp; std::optional colorRampTexture; + + // Programs + std::shared_ptr lineProgram; + std::shared_ptr lineGradientProgram; + std::shared_ptr lineSDFProgram; + std::shared_ptr linePatternProgram; }; } // namespace mbgl diff --git a/src/mbgl/renderer/layers/render_raster_layer.cpp b/src/mbgl/renderer/layers/render_raster_layer.cpp index 4e4884c76..650537732 100644 --- a/src/mbgl/renderer/layers/render_raster_layer.cpp +++ b/src/mbgl/renderer/layers/render_raster_layer.cpp @@ -89,6 +89,9 @@ void RenderRasterLayer::render(PaintParameters& parameters) { if (parameters.pass != RenderPass::Translucent || (!renderTiles && !imageData)) { return; } + + if (!parameters.shaders.populate(rasterProgram)) return; + const auto& evaluated = static_cast(*evaluatedProperties).evaluated; RasterProgram::Binders paintAttributeData{ evaluated, 0 }; @@ -98,8 +101,6 @@ void RenderRasterLayer::render(PaintParameters& parameters) { const auto& segments, const auto& textureBindings, const std::string& drawScopeID) { - auto& programInstance = parameters.programs.getRasterLayerPrograms().raster; - const auto allUniformValues = RasterProgram::computeAllUniformValues( RasterProgram::LayoutUniformValues{ uniforms::matrix::Value(matrix), @@ -122,7 +123,7 @@ void RenderRasterLayer::render(PaintParameters& parameters) { checkRenderability(parameters, RasterProgram::activeBindingCount(allAttributeBindings)); - programInstance.draw( + rasterProgram->draw( parameters.context, *parameters.renderPass, gfx::Triangles(), diff --git a/src/mbgl/renderer/layers/render_raster_layer.hpp b/src/mbgl/renderer/layers/render_raster_layer.hpp index 94bbd36a0..bcde1b730 100644 --- a/src/mbgl/renderer/layers/render_raster_layer.hpp +++ b/src/mbgl/renderer/layers/render_raster_layer.hpp @@ -7,6 +7,7 @@ namespace mbgl { class ImageSourceRenderData; +class RasterProgram; class RenderRasterLayer final : public RenderLayer { public: @@ -24,6 +25,9 @@ private: // Paint properties style::RasterPaintProperties::Unevaluated unevaluated; const ImageSourceRenderData* imageData = nullptr; + + // Programs + std::shared_ptr rasterProgram; }; } // namespace mbgl diff --git a/src/mbgl/renderer/layers/render_symbol_layer.cpp b/src/mbgl/renderer/layers/render_symbol_layer.cpp index c74c71dcc..a4c92ac0c 100644 --- a/src/mbgl/renderer/layers/render_symbol_layer.cpp +++ b/src/mbgl/renderer/layers/render_symbol_layer.cpp @@ -105,7 +105,8 @@ struct RenderableSegment { }; template -void drawIcon(const DrawFn& draw, +void drawIcon(const RenderSymbolLayer::Programs& programs, + const DrawFn& draw, const RenderTile& tile, const LayerRenderData& renderData, SegmentsWrapper iconSegments, @@ -136,7 +137,7 @@ void drawIcon(const DrawFn& draw, if (sdfIcons) { if (values.hasHalo) { - draw(parameters.programs.getSymbolLayerPrograms().symbolIconSDF, + draw(*programs.symbolSDFIconProgram, SymbolSDFIconProgram::layoutUniformValues(false, variablePlacedIcon, values, iconSize, parameters.pixelsToGLUnits, parameters.pixelRatio, alongLine, tile, parameters.state, parameters.symbolFadeChange, SymbolSDFPart::Halo), bucket.sdfIcon, iconSegments, @@ -150,7 +151,7 @@ void drawIcon(const DrawFn& draw, } if (values.hasFill) { - draw(parameters.programs.getSymbolLayerPrograms().symbolIconSDF, + draw(*programs.symbolSDFIconProgram, SymbolSDFIconProgram::layoutUniformValues(false, variablePlacedIcon, values, iconSize, parameters.pixelsToGLUnits, parameters.pixelRatio, alongLine, tile, parameters.state, parameters.symbolFadeChange, SymbolSDFPart::Fill), bucket.sdfIcon, iconSegments, @@ -163,7 +164,7 @@ void drawIcon(const DrawFn& draw, "fill"); } } else { - draw(parameters.programs.getSymbolLayerPrograms().symbolIcon, + draw(*programs.symbolIconProgram, SymbolIconProgram::layoutUniformValues(false, variablePlacedIcon, values, iconSize, parameters.pixelsToGLUnits, alongLine, tile, parameters.state, parameters.symbolFadeChange), bucket.icon, iconSegments, @@ -178,7 +179,8 @@ void drawIcon(const DrawFn& draw, } template -void drawText(const DrawFn& draw, +void drawText(const RenderSymbolLayer::Programs& programs, + const DrawFn& draw, const RenderTile& tile, const LayerRenderData& renderData, SegmentsWrapper textSegments, @@ -221,7 +223,7 @@ void drawText(const DrawFn& draw, ? gfx::TextureFilterType::Linear : gfx::TextureFilterType::Nearest}; if (values.hasHalo) { - drawGlyphs(parameters.programs.getSymbolLayerPrograms().symbolTextAndIcon, + drawGlyphs(*programs.symbolTextAndIconProgram, SymbolTextAndIconProgram::layoutUniformValues(bucket.hasVariablePlacement, values, glyphTexSize, @@ -238,7 +240,7 @@ void drawText(const DrawFn& draw, } if (values.hasFill) { - drawGlyphs(parameters.programs.getSymbolLayerPrograms().symbolTextAndIcon, + drawGlyphs(*programs.symbolTextAndIconProgram, SymbolTextAndIconProgram::layoutUniformValues(bucket.hasVariablePlacement, values, glyphTexSize, @@ -255,7 +257,7 @@ void drawText(const DrawFn& draw, } } else { if (values.hasHalo) { - drawGlyphs(parameters.programs.getSymbolLayerPrograms().symbolGlyph, + drawGlyphs(*programs.symbolSDFTextProgram, SymbolSDFTextProgram::layoutUniformValues(true, bucket.hasVariablePlacement, values, @@ -272,7 +274,7 @@ void drawText(const DrawFn& draw, } if (values.hasFill) { - drawGlyphs(parameters.programs.getSymbolLayerPrograms().symbolGlyph, + drawGlyphs(*programs.symbolSDFTextProgram, SymbolSDFTextProgram::layoutUniformValues(true, bucket.hasVariablePlacement, values, @@ -346,6 +348,13 @@ void RenderSymbolLayer::render(PaintParameters& parameters) { return; } + if (!parameters.shaders.populate(programs.symbolIconProgram)) return; + if (!parameters.shaders.populate(programs.symbolSDFIconProgram)) return; + if (!parameters.shaders.populate(programs.symbolSDFTextProgram)) return; + if (!parameters.shaders.populate(programs.symbolTextAndIconProgram)) return; + if (!parameters.shaders.populate(programs.collisionBoxProgram)) return; + if (!parameters.shaders.populate(programs.collisionCircleProgram)) return; + const bool sortFeaturesByKey = !impl_cast(baseImpl).layout.get().isUndefined(); std::multiset renderableSegments; @@ -437,7 +446,7 @@ void RenderSymbolLayer::render(PaintParameters& parameters) { if (sortFeaturesByKey) { addRenderables(bucket.icon.segments, SymbolType::IconRGBA); } else { - drawIcon(draw, tile, *renderData, std::ref(bucket.icon.segments), bucketPaintProperties, parameters, false /*sdfIcon*/); + drawIcon(programs, draw, tile, *renderData, std::ref(bucket.icon.segments), bucketPaintProperties, parameters, false /*sdfIcon*/); } } @@ -445,7 +454,7 @@ void RenderSymbolLayer::render(PaintParameters& parameters) { if (sortFeaturesByKey) { addRenderables(bucket.sdfIcon.segments, SymbolType::IconSDF); } else { - drawIcon(draw, tile, *renderData, std::ref(bucket.sdfIcon.segments), bucketPaintProperties, parameters, true /*sdfIcon*/); + drawIcon(programs, draw, tile, *renderData, std::ref(bucket.sdfIcon.segments), bucketPaintProperties, parameters, true /*sdfIcon*/); } } @@ -453,7 +462,7 @@ void RenderSymbolLayer::render(PaintParameters& parameters) { if (sortFeaturesByKey) { addRenderables(bucket.text.segments, SymbolType::Text); } else { - drawText(draw, tile, *renderData, std::ref(bucket.text.segments), bucketPaintProperties, parameters); + drawText(programs, draw, tile, *renderData, std::ref(bucket.text.segments), bucketPaintProperties, parameters); } } @@ -476,7 +485,7 @@ void RenderSymbolLayer::render(PaintParameters& parameters) { if (hasCollisionBox) { const auto& collisionBox = isText ? bucket.textCollisionBox : bucket.iconCollisionBox; - parameters.programs.getSymbolLayerPrograms().collisionBox.draw( + programs.collisionBoxProgram->draw( parameters.context, *parameters.renderPass, gfx::Lines{ 1.0f }, @@ -503,7 +512,7 @@ void RenderSymbolLayer::render(PaintParameters& parameters) { } if (hasCollisionCircle) { const auto& collisionCircle = isText ? bucket.textCollisionCircle : bucket.iconCollisionCircle; - parameters.programs.getSymbolLayerPrograms().collisionCircle.draw( + programs.collisionCircleProgram->draw( parameters.context, *parameters.renderPass, gfx::Triangles(), @@ -537,9 +546,9 @@ void RenderSymbolLayer::render(PaintParameters& parameters) { if (sortFeaturesByKey) { for (auto& renderable : renderableSegments) { if (renderable.type == SymbolType::Text) { - drawText(draw, renderable.tile, renderable.renderData, renderable.segment, renderable.bucketPaintProperties, parameters); + drawText(programs, draw, renderable.tile, renderable.renderData, renderable.segment, renderable.bucketPaintProperties, parameters); } else { - drawIcon(draw, renderable.tile, renderable.renderData, renderable.segment, renderable.bucketPaintProperties, parameters, renderable.type == SymbolType::IconSDF); + drawIcon(programs, draw, renderable.tile, renderable.renderData, renderable.segment, renderable.bucketPaintProperties, parameters, renderable.type == SymbolType::IconSDF); } } } diff --git a/src/mbgl/renderer/layers/render_symbol_layer.hpp b/src/mbgl/renderer/layers/render_symbol_layer.hpp index 5fcb9e2c8..83df195a1 100644 --- a/src/mbgl/renderer/layers/render_symbol_layer.hpp +++ b/src/mbgl/renderer/layers/render_symbol_layer.hpp @@ -58,7 +58,24 @@ enum class SymbolType : uint8_t { } // namespace style +class SymbolIconProgram; +class SymbolSDFIconProgram; +class SymbolSDFTextProgram; +class SymbolTextAndIconProgram; +class CollisionBoxProgram; +class CollisionCircleProgram; + class RenderSymbolLayer final: public RenderLayer { +public: + struct Programs { + std::shared_ptr symbolIconProgram; + std::shared_ptr symbolSDFIconProgram; + std::shared_ptr symbolSDFTextProgram; + std::shared_ptr symbolTextAndIconProgram; + std::shared_ptr collisionBoxProgram; + std::shared_ptr collisionCircleProgram; + }; + public: explicit RenderSymbolLayer(Immutable); ~RenderSymbolLayer() override; @@ -81,6 +98,9 @@ private: float textSize = 16.0f; bool hasFormatSectionOverrides = false; + + // Programs + Programs programs; }; } // namespace mbgl diff --git a/src/mbgl/renderer/paint_parameters.cpp b/src/mbgl/renderer/paint_parameters.cpp index 5e46d105d..caa44e189 100644 --- a/src/mbgl/renderer/paint_parameters.cpp +++ b/src/mbgl/renderer/paint_parameters.cpp @@ -122,7 +122,11 @@ void PaintParameters::renderTileClippingMasks(const RenderTiles& renderTiles) { tileClippingMaskIDs.clear(); - auto& program = staticData.programs.clippingMask; + auto program = staticData.shaders->get(); + if (!program) { + return; + } + const style::Properties<>::PossiblyEvaluated properties {}; const ClippingMaskProgram::Binders paintAttributeData(properties, 0); @@ -130,7 +134,7 @@ void PaintParameters::renderTileClippingMasks(const RenderTiles& renderTiles) { const int32_t stencilID = nextStencilID++; tileClippingMaskIDs.emplace(renderTile.id, stencilID); - program.draw(context, + program->draw(context, *renderPass, gfx::Triangles(), gfx::DepthMode::disabled(), diff --git a/src/mbgl/renderer/render_static_data.cpp b/src/mbgl/renderer/render_static_data.cpp index 72de16346..2522cbaed 100644 --- a/src/mbgl/renderer/render_static_data.cpp +++ b/src/mbgl/renderer/render_static_data.cpp @@ -49,14 +49,14 @@ static gfx::VertexVector heatmapTextureVertices() { return result; } -RenderStaticData::RenderStaticData(gfx::Context& context, float pixelRatio, +RenderStaticData::RenderStaticData(float pixelRatio, std::unique_ptr&& shaders_) - : programs(context, ProgramParameters{pixelRatio, false}), + : programs(ProgramParameters{pixelRatio, false}), shaders(std::move(shaders_)), clippingMaskSegments(tileTriangleSegments()) #ifndef NDEBUG , - overdrawPrograms(context, ProgramParameters{pixelRatio, true}) + overdrawPrograms(ProgramParameters{pixelRatio, true}) #endif { } diff --git a/src/mbgl/renderer/render_static_data.hpp b/src/mbgl/renderer/render_static_data.hpp index c2c509022..ccf500a8e 100644 --- a/src/mbgl/renderer/render_static_data.hpp +++ b/src/mbgl/renderer/render_static_data.hpp @@ -20,8 +20,7 @@ class UploadPass; class RenderStaticData { public: - RenderStaticData(gfx::Context&, float pixelRatio, - std::unique_ptr&& shaders_); + RenderStaticData(float pixelRatio, std::unique_ptr&& shaders_); void upload(gfx::UploadPass&); diff --git a/src/mbgl/renderer/render_tile.cpp b/src/mbgl/renderer/render_tile.cpp index dfb65214a..92a18022b 100644 --- a/src/mbgl/renderer/render_tile.cpp +++ b/src/mbgl/renderer/render_tile.cpp @@ -134,14 +134,17 @@ void RenderTile::finishRender(PaintParameters& parameters) const { static const style::Properties<>::PossiblyEvaluated properties {}; static const DebugProgram::Binders paintAttributeData(properties, 0); - auto& program = parameters.programs.debug; + auto program = parameters.shaders.get(); + if (!program) { + return; + } if (parameters.debugOptions & (MapDebugOptions::Timestamps | MapDebugOptions::ParseStatus)) { assert(debugBucket); const auto allAttributeBindings = DebugProgram::computeAllAttributeBindings(*debugBucket->vertexBuffer, paintAttributeData, properties); - program.draw(parameters.context, + program->draw(parameters.context, *parameters.renderPass, gfx::Lines{4.0f * parameters.pixelRatio}, gfx::DepthMode::disabled(), @@ -161,7 +164,7 @@ void RenderTile::finishRender(PaintParameters& parameters) const { DebugProgram::TextureBindings{textures::image::Value{debugBucket->texture->getResource()}}, "text-outline"); - program.draw(parameters.context, + program->draw(parameters.context, *parameters.renderPass, gfx::Lines{2.0f * parameters.pixelRatio}, gfx::DepthMode::disabled(), @@ -187,7 +190,7 @@ void RenderTile::finishRender(PaintParameters& parameters) const { if (debugBucket->tileBorderSegments.empty()) { debugBucket->tileBorderSegments = RenderStaticData::tileBorderSegments(); } - parameters.programs.debug.draw( + program->draw( parameters.context, *parameters.renderPass, gfx::LineStrip{4.0f * parameters.pixelRatio}, diff --git a/src/mbgl/renderer/renderer_impl.cpp b/src/mbgl/renderer/renderer_impl.cpp index 3029988e6..1c1fe7f97 100644 --- a/src/mbgl/renderer/renderer_impl.cpp +++ b/src/mbgl/renderer/renderer_impl.cpp @@ -48,7 +48,7 @@ void Renderer::Impl::render(const RenderTree& renderTree) { const auto& renderTreeParameters = renderTree.getParameters(); if (!staticData) { - staticData = std::make_unique(backend.getContext(), pixelRatio, + staticData = std::make_unique(pixelRatio, std::make_unique()); staticData->programs.registerWith(*staticData->shaders); observer->onRegisterShaders(*staticData->shaders); diff --git a/src/mbgl/renderer/sources/render_image_source.cpp b/src/mbgl/renderer/sources/render_image_source.cpp index 38db2569a..ce865374d 100644 --- a/src/mbgl/renderer/sources/render_image_source.cpp +++ b/src/mbgl/renderer/sources/render_image_source.cpp @@ -39,10 +39,13 @@ void ImageSourceRenderData::render(PaintParameters& parameters) const { static const style::Properties<>::PossiblyEvaluated properties {}; static const DebugProgram::Binders paintAttributeData(properties, 0); - auto& programInstance = parameters.programs.debug; + auto programInstance = parameters.shaders.get(); + if (!programInstance) { + return; + } for (auto matrix : matrices) { - programInstance.draw(parameters.context, + programInstance->draw(parameters.context, *parameters.renderPass, gfx::LineStrip{4.0f * parameters.pixelRatio}, gfx::DepthMode::disabled(), diff --git a/test/fixtures/shader_registry/glsl_replace_1/expected.png b/test/fixtures/shader_registry/glsl_replace_1/expected.png new file mode 100644 index 000000000..4be1a88fd Binary files /dev/null and b/test/fixtures/shader_registry/glsl_replace_1/expected.png differ diff --git a/test/fixtures/shader_registry/glsl_replace_2/expected.png b/test/fixtures/shader_registry/glsl_replace_2/expected.png new file mode 100644 index 000000000..0b1d4dd4a Binary files /dev/null and b/test/fixtures/shader_registry/glsl_replace_2/expected.png differ diff --git a/test/fixtures/shader_registry/glsl_replace_noop/expected.png b/test/fixtures/shader_registry/glsl_replace_noop/expected.png new file mode 100644 index 000000000..eec8d1534 Binary files /dev/null and b/test/fixtures/shader_registry/glsl_replace_noop/expected.png differ diff --git a/test/renderer/shader_registry.test.cpp b/test/renderer/shader_registry.test.cpp index 092dbdead..c5558b6f0 100644 --- a/test/renderer/shader_registry.test.cpp +++ b/test/renderer/shader_registry.test.cpp @@ -5,11 +5,64 @@ #include #include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include using namespace mbgl; namespace { +class MapInstance { + public: + class ShaderAndStyleObserver : public MapObserver { + public: + public: + void onDidFinishLoadingStyle() override { + styleLoaded(); + } + + void onRegisterShaders(gfx::ShaderRegistry& registry) override { + registerShaders(registry); + }; + + std::function styleLoaded; + std::function registerShaders; + }; + + MapInstance(float pixelRatio, MapObserver& observer) : + frontend(pixelRatio), + adapter(frontend, observer, std::make_shared( + ResourceOptions() + .withCachePath(":memory:") + .withAssetPath("test/fixtures/api/assets"), + ClientOptions() + ), + MapOptions() + .withMapMode(MapMode::Static) + .withSize(frontend.getSize()) + .withPixelRatio(pixelRatio)) + {} + + public: + HeadlessFrontend frontend; + MapAdapter adapter; +}; + template class StubProgramBase : public gfx::Shader { public: @@ -111,3 +164,132 @@ TEST(ShaderRegistry, ShaderRTTI) { ASSERT_EQ(asBase->to(), &program1); ASSERT_EQ(asBase->to(), nullptr); } + +// Test replacing an actual program instance with a similar instance +TEST(ShaderRegistry, GLSLReplacement_NoOp) { + MapInstance::ShaderAndStyleObserver observer; + util::RunLoop runLoop; + auto map = MapInstance(1.0f, observer); + + // Just replace with a default instance + observer.registerShaders = [&](gfx::ShaderRegistry& registry) { + if (!registry.replaceShader(std::make_shared( + ProgramParameters(1.0f, false)))) + { + throw std::runtime_error("Failed to register shader!"); + } + }; + + observer.styleLoaded = [&] { + auto fillLayer = std::make_unique("green_fill", "mapbox"); + fillLayer->setSourceLayer("water"); + fillLayer->setFillColor(Color(0.25f, 0.88f, 0.82f, 1.0f)); + map.adapter.getStyle().addLayer(std::move(fillLayer)); + }; + + map.adapter.getStyle().loadJSON(util::read_file("test/fixtures/api/water.json")); + auto img = map.frontend.render(map.adapter).image; + test::checkImage("test/fixtures/shader_registry/glsl_replace_noop", img, 0.005, 0.1); +} + +// Test replacing an actual program with a similar instance using a different fragment +// shader +TEST(ShaderRegistry, GLSLReplacement1) { + MapInstance::ShaderAndStyleObserver observer; + util::RunLoop runLoop; + auto map = MapInstance(1.0f, observer); + + // Replace with an instance that only renders blue + observer.registerShaders = [&](gfx::ShaderRegistry& registry) { + if (!registry.replaceShader(std::make_shared( + ProgramParameters(1.0f, false).withShaderSource( + ProgramParameters::ProgramSource( + gfx::Backend::Type::OpenGL, + "", + R"( +void main() { + gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0); +} + )" + ) + ) + ))) + { + throw std::runtime_error("Failed to register shader!"); + } + }; + + observer.styleLoaded = [&] { + auto fillLayer = std::make_unique("green_fill", "mapbox"); + fillLayer->setSourceLayer("water"); + fillLayer->setFillColor(Color(0.25f, 0.88f, 0.82f, 1.0f)); + map.adapter.getStyle().addLayer(std::move(fillLayer)); + }; + + map.adapter.getStyle().loadJSON(util::read_file("test/fixtures/api/water.json")); + auto img = map.frontend.render(map.adapter).image; + test::checkImage("test/fixtures/shader_registry/glsl_replace_1", img, 0.005, 0.1); +} + +// Test replacing an actual program with a similar instance using a different fragment +// shader +TEST(ShaderRegistry, GLSLReplacement2) { + MapInstance::ShaderAndStyleObserver observer; + util::RunLoop runLoop; + auto map = MapInstance(1.0f, observer); + + // Replace with an instance that adds some red and green + observer.registerShaders = [&](gfx::ShaderRegistry& registry) { + if (!registry.replaceShader(std::make_shared( + ProgramParameters(1.0f, false).withShaderSource( + ProgramParameters::ProgramSource( + gfx::Backend::Type::OpenGL, + "", + R"( +#ifndef HAS_UNIFORM_u_color +varying highp vec4 color; +#else +uniform highp vec4 u_color; +#endif + +#ifndef HAS_UNIFORM_u_opacity +varying lowp float opacity; +#else +uniform lowp float u_opacity; +#endif + +void main() { +#ifdef HAS_UNIFORM_u_color + highp vec4 color = u_color; +#endif +#ifdef HAS_UNIFORM_u_opacity + lowp float opacity = u_opacity; +#endif + + gl_FragColor = mix(color * opacity, + vec4(0.3, 0.5, 0.0, 1.0), 0.5); + +#ifdef OVERDRAW_INSPECTOR + gl_FragColor = vec4(1.0); +#endif +} + )" + ) + ) + ))) + { + throw std::runtime_error("Failed to register shader!"); + } + }; + + observer.styleLoaded = [&] { + auto fillLayer = std::make_unique("green_fill", "mapbox"); + fillLayer->setSourceLayer("water"); + fillLayer->setFillColor(Color(0.25f, 0.88f, 0.82f, 1.0f)); + map.adapter.getStyle().addLayer(std::move(fillLayer)); + }; + + map.adapter.getStyle().loadJSON(util::read_file("test/fixtures/api/water.json")); + auto img = map.frontend.render(map.adapter).image; + test::checkImage("test/fixtures/shader_registry/glsl_replace_2", img, 0.005, 0.1); +}