diff --git a/.github/workflows/macos-ci.yml b/.github/workflows/macos-ci.yml index 47cf3ca8227..27c8e5975f7 100644 --- a/.github/workflows/macos-ci.yml +++ b/.github/workflows/macos-ci.yml @@ -4,7 +4,6 @@ on: workflow_dispatch: push: branches: - - main - opengl-2 tags: - 'macos-*' @@ -27,7 +26,6 @@ on: pull_request: branches: - - main - opengl-2 paths: - 'platform/ios/**' @@ -133,7 +131,6 @@ jobs: ctest -VV --test-dir $BUILD_DIR -R mbgl-test-runner env: BUILD_DIR: ../../../maplibre-gl-native-macostestbuild - if: ${{ github.ref != 'refs/heads/main' }} - name: Check public symbols run: make darwin-check-public-symbols diff --git a/include/mbgl/platform/gl_functions.hpp b/include/mbgl/platform/gl_functions.hpp index 920e7c62539..63ae49f2353 100644 --- a/include/mbgl/platform/gl_functions.hpp +++ b/include/mbgl/platform/gl_functions.hpp @@ -313,21 +313,6 @@ extern void (* const glVertexAttribPointer)(GLuint, GLint, GLenum, GLboolean, GL /// Pointer to glViewport OpenGL function. extern void (* const glViewport)(GLint, GLint, GLsizei, GLsizei); -#ifndef MBGL_USE_GLES2 -/// Pointer to glDrawPixels OpenGL function. -extern void (* const glDrawPixels)(GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -/// Pointer to glGetDoublev OpenGL function. -extern void (* const glGetDoublev)(GLenum, GLdouble *); -/// Pointer to glPixelTransferf OpenGL function. -extern void (* const glPixelTransferf)(GLenum, GLfloat); -/// Pointer to glPixelZoom OpenGL function. -extern void (* const glPixelZoom)(GLfloat, GLfloat); -/// Pointer to glPointSize OpenGL function. -extern void (* const glPointSize)(GLfloat); -/// Pointer to glRasterPos4d OpenGL function. -extern void (* const glRasterPos4d)(GLdouble, GLdouble, GLdouble, GLdouble); -#endif - #ifndef NDEBUG /// Check for GL errors and print on the console. void glCheckError(const char *cmd, const char *file, int line); diff --git a/include/mbgl/shaders/gl/background.hpp b/include/mbgl/shaders/gl/background.hpp index b37e52b7e87..4a728f31c1e 100644 --- a/include/mbgl/shaders/gl/background.hpp +++ b/include/mbgl/shaders/gl/background.hpp @@ -1,5 +1,5 @@ // Generated code, do not modify this file! -// Generated on 2023-04-04T01:24:40.539Z by mwilsnd using shaders/generate_shader_code.js +// Generated on 2023-04-05T16:25:15.886Z by mwilsnd using shaders/generate_shader_code.js #pragma once #include @@ -8,8 +8,7 @@ namespace mbgl { namespace shaders { template <> struct ShaderSource { - static constexpr const char* vertex = R"(attribute vec2 a_pos; - + static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos; uniform mat4 u_matrix; void main() { @@ -20,10 +19,10 @@ void main() { uniform float u_opacity; void main() { - gl_FragColor = u_color * u_opacity; + fragColor = u_color * u_opacity; #ifdef OVERDRAW_INSPECTOR - gl_FragColor = vec4(1.0); + fragColor = vec4(1.0); #endif } )"; diff --git a/include/mbgl/shaders/gl/background_pattern.hpp b/include/mbgl/shaders/gl/background_pattern.hpp index e857f69aaa4..2626c78f495 100644 --- a/include/mbgl/shaders/gl/background_pattern.hpp +++ b/include/mbgl/shaders/gl/background_pattern.hpp @@ -1,5 +1,5 @@ // Generated code, do not modify this file! -// Generated on 2023-04-04T01:24:40.539Z by mwilsnd using shaders/generate_shader_code.js +// Generated on 2023-04-05T16:25:15.886Z by mwilsnd using shaders/generate_shader_code.js #pragma once #include @@ -17,10 +17,9 @@ uniform float u_scale_a; uniform float u_scale_b; uniform float u_tile_units_to_pixels; -attribute vec2 a_pos; - -varying vec2 v_pos_a; -varying vec2 v_pos_b; +layout (location = 0) in vec2 a_pos; +out vec2 v_pos_a; +out vec2 v_pos_b; void main() { gl_Position = u_matrix * vec4(a_pos, 0, 1); @@ -39,22 +38,22 @@ uniform float u_opacity; uniform sampler2D u_image; -varying vec2 v_pos_a; -varying vec2 v_pos_b; +in vec2 v_pos_a; +in vec2 v_pos_b; void main() { vec2 imagecoord = mod(v_pos_a, 1.0); vec2 pos = mix(u_pattern_tl_a / u_texsize, u_pattern_br_a / u_texsize, imagecoord); - vec4 color1 = texture2D(u_image, pos); + vec4 color1 = texture(u_image, pos); vec2 imagecoord_b = mod(v_pos_b, 1.0); vec2 pos2 = mix(u_pattern_tl_b / u_texsize, u_pattern_br_b / u_texsize, imagecoord_b); - vec4 color2 = texture2D(u_image, pos2); + vec4 color2 = texture(u_image, pos2); - gl_FragColor = mix(color1, color2, u_mix) * u_opacity; + fragColor = mix(color1, color2, u_mix) * u_opacity; #ifdef OVERDRAW_INSPECTOR - gl_FragColor = vec4(1.0); + fragColor = vec4(1.0); #endif } )"; diff --git a/include/mbgl/shaders/gl/circle.hpp b/include/mbgl/shaders/gl/circle.hpp index 0bad8bf75b1..9a32675e954 100644 --- a/include/mbgl/shaders/gl/circle.hpp +++ b/include/mbgl/shaders/gl/circle.hpp @@ -1,5 +1,5 @@ // Generated code, do not modify this file! -// Generated on 2023-04-04T01:24:40.539Z by mwilsnd using shaders/generate_shader_code.js +// Generated on 2023-04-05T16:25:15.886Z by mwilsnd using shaders/generate_shader_code.js #pragma once #include @@ -15,56 +15,55 @@ uniform vec2 u_extrude_scale; uniform lowp float u_device_pixel_ratio; uniform highp float u_camera_to_center_distance; -attribute vec2 a_pos; - -varying vec3 v_data; +layout (location = 0) in vec2 a_pos; +out vec3 v_data; #ifndef HAS_UNIFORM_u_color uniform lowp float u_color_t; -attribute highp vec4 a_color; -varying highp vec4 color; +layout (location = 1) in highp vec4 a_color; +out 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; -varying mediump float radius; +layout (location = 2) in mediump vec2 a_radius; +out 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; -varying lowp float blur; +layout (location = 3) in lowp vec2 a_blur; +out 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; -varying lowp float opacity; +layout (location = 4) in lowp vec2 a_opacity; +out 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; -varying highp vec4 stroke_color; +layout (location = 5) in highp vec4 a_stroke_color; +out 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; -varying mediump float stroke_width; +layout (location = 6) in mediump vec2 a_stroke_width; +out 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; -varying lowp float stroke_opacity; +layout (location = 7) in lowp vec2 a_stroke_opacity; +out lowp float stroke_opacity; #else uniform lowp float u_stroke_opacity; #endif @@ -143,40 +142,40 @@ lowp float stroke_opacity = u_stroke_opacity; v_data = vec3(extrude.x, extrude.y, antialiasblur); } )"; - static constexpr const char* fragment = R"(varying vec3 v_data; + static constexpr const char* fragment = R"(in vec3 v_data; #ifndef HAS_UNIFORM_u_color -varying highp vec4 color; +in highp vec4 color; #else uniform highp vec4 u_color; #endif #ifndef HAS_UNIFORM_u_radius -varying mediump float radius; +in mediump float radius; #else uniform mediump float u_radius; #endif #ifndef HAS_UNIFORM_u_blur -varying lowp float blur; +in lowp float blur; #else uniform lowp float u_blur; #endif #ifndef HAS_UNIFORM_u_opacity -varying lowp float opacity; +in lowp float opacity; #else uniform lowp float u_opacity; #endif #ifndef HAS_UNIFORM_u_stroke_color -varying highp vec4 stroke_color; +in highp vec4 stroke_color; #else uniform highp vec4 u_stroke_color; #endif #ifndef HAS_UNIFORM_u_stroke_width -varying mediump float stroke_width; +in mediump float stroke_width; #else uniform mediump float u_stroke_width; #endif #ifndef HAS_UNIFORM_u_stroke_opacity -varying lowp float stroke_opacity; +in lowp float stroke_opacity; #else uniform lowp float u_stroke_opacity; #endif @@ -218,10 +217,10 @@ lowp float stroke_opacity = u_stroke_opacity; extrude_length - radius / (radius + stroke_width) ); - gl_FragColor = opacity_t * mix(color * opacity, stroke_color * stroke_opacity, color_t); + fragColor = opacity_t * mix(color * opacity, stroke_color * stroke_opacity, color_t); #ifdef OVERDRAW_INSPECTOR - gl_FragColor = vec4(1.0); + fragColor = vec4(1.0); #endif } )"; diff --git a/include/mbgl/shaders/gl/clipping_mask.hpp b/include/mbgl/shaders/gl/clipping_mask.hpp index e89428b1266..abb4799f884 100644 --- a/include/mbgl/shaders/gl/clipping_mask.hpp +++ b/include/mbgl/shaders/gl/clipping_mask.hpp @@ -1,5 +1,5 @@ // Generated code, do not modify this file! -// Generated on 2023-04-04T01:24:40.539Z by mwilsnd using shaders/generate_shader_code.js +// Generated on 2023-04-05T16:25:15.886Z by mwilsnd using shaders/generate_shader_code.js #pragma once #include @@ -8,7 +8,7 @@ namespace mbgl { namespace shaders { template <> struct ShaderSource { - static constexpr const char* vertex = R"(attribute vec2 a_pos; + static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos; uniform mat4 u_matrix; @@ -17,7 +17,7 @@ void main() { } )"; static constexpr const char* fragment = R"(void main() { - gl_FragColor = vec4(1.0); + fragColor = vec4(1.0); } )"; }; diff --git a/include/mbgl/shaders/gl/collision_box.hpp b/include/mbgl/shaders/gl/collision_box.hpp index 73e48dd1b20..b68f4dddb05 100644 --- a/include/mbgl/shaders/gl/collision_box.hpp +++ b/include/mbgl/shaders/gl/collision_box.hpp @@ -1,5 +1,5 @@ // Generated code, do not modify this file! -// Generated on 2023-04-04T01:24:40.539Z by mwilsnd using shaders/generate_shader_code.js +// Generated on 2023-04-05T16:25:15.886Z by mwilsnd using shaders/generate_shader_code.js #pragma once #include @@ -8,18 +8,18 @@ namespace mbgl { namespace shaders { 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; -attribute vec2 a_shift; + static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos; +layout (location = 1) in vec2 a_anchor_pos; +layout (location = 2) in vec2 a_extrude; +layout (location = 3) in vec2 a_placed; +layout (location = 4) in vec2 a_shift; uniform mat4 u_matrix; uniform vec2 u_extrude_scale; uniform float u_camera_to_center_distance; -varying float v_placed; -varying float v_notUsed; +out float v_placed; +out float v_notUsed; void main() { vec4 projectedPoint = u_matrix * vec4(a_anchor_pos, 0, 1); @@ -37,24 +37,24 @@ void main() { } )"; static constexpr const char* fragment = R"( -varying float v_placed; -varying float v_notUsed; +in float v_placed; +in float v_notUsed; void main() { float alpha = 0.5; // Red = collision, hide label - gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0) * alpha; + fragColor = vec4(1.0, 0.0, 0.0, 1.0) * alpha; // Blue = no collision, label is showing if (v_placed > 0.5) { - gl_FragColor = vec4(0.0, 0.0, 1.0, 0.5) * alpha; + fragColor = vec4(0.0, 0.0, 1.0, 0.5) * alpha; } if (v_notUsed > 0.5) { // This box not used, fade it out - gl_FragColor *= .1; + fragColor *= .1; } })"; }; diff --git a/include/mbgl/shaders/gl/collision_circle.hpp b/include/mbgl/shaders/gl/collision_circle.hpp index a2b26679117..2c87ba93102 100644 --- a/include/mbgl/shaders/gl/collision_circle.hpp +++ b/include/mbgl/shaders/gl/collision_circle.hpp @@ -1,5 +1,5 @@ // Generated code, do not modify this file! -// Generated on 2023-04-04T01:24:40.539Z by mwilsnd using shaders/generate_shader_code.js +// Generated on 2023-04-05T16:25:15.886Z by mwilsnd using shaders/generate_shader_code.js #pragma once #include @@ -8,21 +8,20 @@ namespace mbgl { namespace shaders { 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; + static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos; +layout (location = 1) in vec2 a_anchor_pos; +layout (location = 2) in vec2 a_extrude; +layout (location = 3) in vec2 a_placed; uniform mat4 u_matrix; uniform vec2 u_extrude_scale; uniform float u_camera_to_center_distance; -varying float v_placed; -varying float v_notUsed; -varying float v_radius; - -varying vec2 v_extrude; -varying vec2 v_extrude_scale; +out float v_placed; +out float v_notUsed; +out float v_radius; +out vec2 v_extrude; +out vec2 v_extrude_scale; void main() { vec4 projectedPoint = u_matrix * vec4(a_anchor_pos, 0, 1); @@ -47,11 +46,11 @@ void main() { )"; static constexpr const char* fragment = R"(uniform float u_overscale_factor; -varying float v_placed; -varying float v_notUsed; -varying float v_radius; -varying vec2 v_extrude; -varying vec2 v_extrude_scale; +in float v_placed; +in float v_notUsed; +in float v_radius; +in vec2 v_extrude; +in vec2 v_extrude_scale; void main() { float alpha = 0.5; @@ -77,7 +76,7 @@ void main() { float distance_to_edge = abs(extrude_length - radius); float opacity_t = smoothstep(-stroke_width, 0.0, -distance_to_edge); - gl_FragColor = opacity_t * color; + fragColor = opacity_t * color; } )"; }; diff --git a/include/mbgl/shaders/gl/debug.hpp b/include/mbgl/shaders/gl/debug.hpp index 7fc211fc9a4..daae1d7c745 100644 --- a/include/mbgl/shaders/gl/debug.hpp +++ b/include/mbgl/shaders/gl/debug.hpp @@ -1,5 +1,5 @@ // Generated code, do not modify this file! -// Generated on 2023-04-04T01:24:40.539Z by mwilsnd using shaders/generate_shader_code.js +// Generated on 2023-04-05T16:25:15.886Z by mwilsnd using shaders/generate_shader_code.js #pragma once #include @@ -8,8 +8,8 @@ namespace mbgl { namespace shaders { template <> struct ShaderSource { - static constexpr const char* vertex = R"(attribute vec2 a_pos; -varying vec2 v_uv; + static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos; +out vec2 v_uv; uniform mat4 u_matrix; uniform float u_overlay_scale; @@ -24,11 +24,11 @@ void main() { static constexpr const char* fragment = R"(uniform highp vec4 u_color; uniform sampler2D u_overlay; -varying vec2 v_uv; +in vec2 v_uv; void main() { - vec4 overlay_color = texture2D(u_overlay, v_uv); - gl_FragColor = mix(u_color, overlay_color, overlay_color.a); + vec4 overlay_color = texture(u_overlay, v_uv); + fragColor = mix(u_color, overlay_color, overlay_color.a); } )"; }; diff --git a/include/mbgl/shaders/gl/fill.hpp b/include/mbgl/shaders/gl/fill.hpp index 8b818e4fa59..5fd3872ebce 100644 --- a/include/mbgl/shaders/gl/fill.hpp +++ b/include/mbgl/shaders/gl/fill.hpp @@ -1,5 +1,5 @@ // Generated code, do not modify this file! -// Generated on 2023-04-04T01:24:40.539Z by mwilsnd using shaders/generate_shader_code.js +// Generated on 2023-04-05T16:25:15.886Z by mwilsnd using shaders/generate_shader_code.js #pragma once #include @@ -8,21 +8,21 @@ namespace mbgl { namespace shaders { template <> struct ShaderSource { - static constexpr const char* vertex = R"(attribute vec2 a_pos; + static constexpr const char* vertex = R"(layout (location = 0) in 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; +layout (location = 1) in highp vec4 a_color; +out 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; +layout (location = 2) in lowp vec2 a_opacity; +out lowp float opacity; #else uniform lowp float u_opacity; #endif @@ -43,12 +43,12 @@ lowp float opacity = u_opacity; } )"; static constexpr const char* fragment = R"(#ifndef HAS_UNIFORM_u_color -varying highp vec4 color; +in highp vec4 color; #else uniform highp vec4 u_color; #endif #ifndef HAS_UNIFORM_u_opacity -varying lowp float opacity; +in lowp float opacity; #else uniform lowp float u_opacity; #endif @@ -61,10 +61,10 @@ highp vec4 color = u_color; lowp float opacity = u_opacity; #endif - gl_FragColor = color * opacity; + fragColor = color * opacity; #ifdef OVERDRAW_INSPECTOR - gl_FragColor = vec4(1.0); + fragColor = vec4(1.0); #endif } )"; diff --git a/include/mbgl/shaders/gl/fill_extrusion.hpp b/include/mbgl/shaders/gl/fill_extrusion.hpp index 2442275a672..41cf60e4f8f 100644 --- a/include/mbgl/shaders/gl/fill_extrusion.hpp +++ b/include/mbgl/shaders/gl/fill_extrusion.hpp @@ -1,5 +1,5 @@ // Generated code, do not modify this file! -// Generated on 2023-04-04T01:24:40.539Z by mwilsnd using shaders/generate_shader_code.js +// Generated on 2023-04-05T16:25:15.886Z by mwilsnd using shaders/generate_shader_code.js #pragma once #include @@ -15,27 +15,26 @@ uniform lowp float u_lightintensity; uniform float u_vertical_gradient; uniform lowp float u_opacity; -attribute vec2 a_pos; -attribute vec4 a_normal_ed; - -varying vec4 v_color; +layout (location = 0) in vec2 a_pos; +layout (location = 1) in vec4 a_normal_ed; +out vec4 v_color; #ifndef HAS_UNIFORM_u_base uniform lowp float u_base_t; -attribute highp vec2 a_base; +layout (location = 2) in 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; +layout (location = 3) in highp vec2 a_height; #else uniform highp float u_height; #endif #ifndef HAS_UNIFORM_u_color uniform lowp float u_color_t; -attribute highp vec4 a_color; +layout (location = 4) in highp vec4 a_color; #else uniform highp vec4 u_color; #endif @@ -102,13 +101,13 @@ highp vec4 color = u_color; v_color *= u_opacity; } )"; - static constexpr const char* fragment = R"(varying vec4 v_color; + static constexpr const char* fragment = R"(in vec4 v_color; void main() { - gl_FragColor = v_color; + fragColor = v_color; #ifdef OVERDRAW_INSPECTOR - gl_FragColor = vec4(1.0); + fragColor = vec4(1.0); #endif } )"; diff --git a/include/mbgl/shaders/gl/fill_extrusion_pattern.hpp b/include/mbgl/shaders/gl/fill_extrusion_pattern.hpp index 591f00dda3b..35d9c00cf3a 100644 --- a/include/mbgl/shaders/gl/fill_extrusion_pattern.hpp +++ b/include/mbgl/shaders/gl/fill_extrusion_pattern.hpp @@ -1,5 +1,5 @@ // Generated code, do not modify this file! -// Generated on 2023-04-04T01:24:40.539Z by mwilsnd using shaders/generate_shader_code.js +// Generated on 2023-04-05T16:25:15.886Z by mwilsnd using shaders/generate_shader_code.js #pragma once #include @@ -20,38 +20,38 @@ uniform vec3 u_lightcolor; uniform lowp vec3 u_lightpos; uniform lowp float u_lightintensity; -attribute vec2 a_pos; -attribute vec4 a_normal_ed; +layout (location = 0) in vec2 a_pos; +layout (location = 1) in vec4 a_normal_ed; -varying vec2 v_pos_a; -varying vec2 v_pos_b; -varying vec4 v_lighting; +out vec2 v_pos_a; +out vec2 v_pos_b; +out vec4 v_lighting; #ifndef HAS_UNIFORM_u_base uniform lowp float u_base_t; -attribute lowp vec2 a_base; -varying lowp float base; +layout (location = 2) in lowp vec2 a_base; +out 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; -varying lowp float height; +layout (location = 3) in lowp vec2 a_height; +out 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; -varying lowp vec4 pattern_from; +layout (location = 4) in lowp vec4 a_pattern_from; +out 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; -varying lowp vec4 pattern_to; +layout (location = 5) in lowp vec4 a_pattern_to; +out lowp vec4 pattern_to; #else uniform lowp vec4 u_pattern_to; #endif @@ -130,27 +130,27 @@ uniform float u_fade; uniform sampler2D u_image; -varying vec2 v_pos_a; -varying vec2 v_pos_b; -varying vec4 v_lighting; +in vec2 v_pos_a; +in vec2 v_pos_b; +in vec4 v_lighting; #ifndef HAS_UNIFORM_u_base -varying lowp float base; +in lowp float base; #else uniform lowp float u_base; #endif #ifndef HAS_UNIFORM_u_height -varying lowp float height; +in lowp float height; #else uniform lowp float u_height; #endif #ifndef HAS_UNIFORM_u_pattern_from -varying lowp vec4 pattern_from; +in lowp vec4 pattern_from; #else uniform lowp vec4 u_pattern_from; #endif #ifndef HAS_UNIFORM_u_pattern_to -varying lowp vec4 pattern_to; +in lowp vec4 pattern_to; #else uniform lowp vec4 u_pattern_to; #endif @@ -176,18 +176,18 @@ mediump vec4 pattern_to = u_pattern_to; vec2 imagecoord = mod(v_pos_a, 1.0); vec2 pos = mix(pattern_tl_a / u_texsize, pattern_br_a / u_texsize, imagecoord); - vec4 color1 = texture2D(u_image, pos); + vec4 color1 = texture(u_image, pos); vec2 imagecoord_b = mod(v_pos_b, 1.0); vec2 pos2 = mix(pattern_tl_b / u_texsize, pattern_br_b / u_texsize, imagecoord_b); - vec4 color2 = texture2D(u_image, pos2); + vec4 color2 = texture(u_image, pos2); vec4 mixedColor = mix(color1, color2, u_fade); - gl_FragColor = mixedColor * v_lighting; + fragColor = mixedColor * v_lighting; #ifdef OVERDRAW_INSPECTOR - gl_FragColor = vec4(1.0); + fragColor = vec4(1.0); #endif } )"; diff --git a/include/mbgl/shaders/gl/fill_outline.hpp b/include/mbgl/shaders/gl/fill_outline.hpp index d5b55715bd0..33be116975b 100644 --- a/include/mbgl/shaders/gl/fill_outline.hpp +++ b/include/mbgl/shaders/gl/fill_outline.hpp @@ -1,5 +1,5 @@ // Generated code, do not modify this file! -// Generated on 2023-04-04T01:24:40.539Z by mwilsnd using shaders/generate_shader_code.js +// Generated on 2023-04-05T16:25:15.886Z by mwilsnd using shaders/generate_shader_code.js #pragma once #include @@ -8,24 +8,24 @@ namespace mbgl { namespace shaders { template <> struct ShaderSource { - static constexpr const char* vertex = R"(attribute vec2 a_pos; + static constexpr const char* vertex = R"(layout (location = 0) in vec2 a_pos; uniform mat4 u_matrix; uniform vec2 u_world; -varying vec2 v_pos; +out 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; +layout (location = 1) in highp vec4 a_outline_color; +out 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; +layout (location = 2) in lowp vec2 a_opacity; +out lowp float opacity; #else uniform lowp float u_opacity; #endif @@ -46,15 +46,15 @@ lowp float opacity = u_opacity; v_pos = (gl_Position.xy / gl_Position.w + 1.0) / 2.0 * u_world; } )"; - static constexpr const char* fragment = R"(varying vec2 v_pos; + static constexpr const char* fragment = R"(in vec2 v_pos; #ifndef HAS_UNIFORM_u_outline_color -varying highp vec4 outline_color; +in highp vec4 outline_color; #else uniform highp vec4 u_outline_color; #endif #ifndef HAS_UNIFORM_u_opacity -varying lowp float opacity; +in lowp float opacity; #else uniform lowp float u_opacity; #endif @@ -69,10 +69,10 @@ lowp float opacity = u_opacity; float dist = length(v_pos - gl_FragCoord.xy); float alpha = 1.0 - smoothstep(0.0, 1.0, dist); - gl_FragColor = outline_color * (alpha * opacity); + fragColor = outline_color * (alpha * opacity); #ifdef OVERDRAW_INSPECTOR - gl_FragColor = vec4(1.0); + fragColor = vec4(1.0); #endif } )"; diff --git a/include/mbgl/shaders/gl/fill_outline_pattern.hpp b/include/mbgl/shaders/gl/fill_outline_pattern.hpp index 8d29322c02a..2d7a5c40b17 100644 --- a/include/mbgl/shaders/gl/fill_outline_pattern.hpp +++ b/include/mbgl/shaders/gl/fill_outline_pattern.hpp @@ -1,5 +1,5 @@ // Generated code, do not modify this file! -// Generated on 2023-04-04T01:24:40.539Z by mwilsnd using shaders/generate_shader_code.js +// Generated on 2023-04-05T16:25:15.886Z by mwilsnd using shaders/generate_shader_code.js #pragma once #include @@ -14,30 +14,30 @@ uniform vec2 u_pixel_coord_upper; uniform vec2 u_pixel_coord_lower; uniform vec4 u_scale; -attribute vec2 a_pos; +layout (location = 0) in vec2 a_pos; -varying vec2 v_pos_a; -varying vec2 v_pos_b; -varying vec2 v_pos; +out vec2 v_pos_a; +out vec2 v_pos_b; +out vec2 v_pos; #ifndef HAS_UNIFORM_u_opacity uniform lowp float u_opacity_t; -attribute lowp vec2 a_opacity; -varying lowp float opacity; +layout (location = 1) in lowp vec2 a_opacity; +out 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; -varying lowp vec4 pattern_from; +layout (location = 2) in lowp vec4 a_pattern_from; +out 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; -varying lowp vec4 pattern_to; +layout (location = 3) in lowp vec4 a_pattern_to; +out lowp vec4 pattern_to; #else uniform lowp vec4 u_pattern_to; #endif @@ -85,22 +85,22 @@ uniform vec2 u_texsize; uniform sampler2D u_image; uniform float u_fade; -varying vec2 v_pos_a; -varying vec2 v_pos_b; -varying vec2 v_pos; +in vec2 v_pos_a; +in vec2 v_pos_b; +in vec2 v_pos; #ifndef HAS_UNIFORM_u_opacity -varying lowp float opacity; +in lowp float opacity; #else uniform lowp float u_opacity; #endif #ifndef HAS_UNIFORM_u_pattern_from -varying lowp vec4 pattern_from; +in lowp vec4 pattern_from; #else uniform lowp vec4 u_pattern_from; #endif #ifndef HAS_UNIFORM_u_pattern_to -varying lowp vec4 pattern_to; +in lowp vec4 pattern_to; #else uniform lowp vec4 u_pattern_to; #endif @@ -123,11 +123,11 @@ mediump vec4 pattern_to = u_pattern_to; vec2 imagecoord = mod(v_pos_a, 1.0); vec2 pos = mix(pattern_tl_a / u_texsize, pattern_br_a / u_texsize, imagecoord); - vec4 color1 = texture2D(u_image, pos); + vec4 color1 = texture(u_image, pos); vec2 imagecoord_b = mod(v_pos_b, 1.0); vec2 pos2 = mix(pattern_tl_b / u_texsize, pattern_br_b / u_texsize, imagecoord_b); - vec4 color2 = texture2D(u_image, pos2); + vec4 color2 = texture(u_image, pos2); // find distance to outline for alpha interpolation @@ -135,10 +135,10 @@ mediump vec4 pattern_to = u_pattern_to; float alpha = 1.0 - smoothstep(0.0, 1.0, dist); - gl_FragColor = mix(color1, color2, u_fade) * alpha * opacity; + fragColor = mix(color1, color2, u_fade) * alpha * opacity; #ifdef OVERDRAW_INSPECTOR - gl_FragColor = vec4(1.0); + fragColor = vec4(1.0); #endif } )"; diff --git a/include/mbgl/shaders/gl/fill_pattern.hpp b/include/mbgl/shaders/gl/fill_pattern.hpp index b38505e2b4f..38139ca6f09 100644 --- a/include/mbgl/shaders/gl/fill_pattern.hpp +++ b/include/mbgl/shaders/gl/fill_pattern.hpp @@ -1,5 +1,5 @@ // Generated code, do not modify this file! -// Generated on 2023-04-04T01:24:40.539Z by mwilsnd using shaders/generate_shader_code.js +// Generated on 2023-04-05T16:25:15.886Z by mwilsnd using shaders/generate_shader_code.js #pragma once #include @@ -13,29 +13,29 @@ uniform vec2 u_pixel_coord_upper; uniform vec2 u_pixel_coord_lower; uniform vec4 u_scale; -attribute vec2 a_pos; +layout (location = 0) in vec2 a_pos; -varying vec2 v_pos_a; -varying vec2 v_pos_b; +out vec2 v_pos_a; +out vec2 v_pos_b; #ifndef HAS_UNIFORM_u_opacity uniform lowp float u_opacity_t; -attribute lowp vec2 a_opacity; -varying lowp float opacity; +layout (location = 1) in lowp vec2 a_opacity; +out 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; -varying lowp vec4 pattern_from; +layout (location = 2) in lowp vec4 a_pattern_from; +out 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; -varying lowp vec4 pattern_to; +layout (location = 3) in lowp vec4 a_pattern_to; +out lowp vec4 pattern_to; #else uniform lowp vec4 u_pattern_to; #endif @@ -80,21 +80,21 @@ uniform float u_fade; uniform sampler2D u_image; -varying vec2 v_pos_a; -varying vec2 v_pos_b; +in vec2 v_pos_a; +in vec2 v_pos_b; #ifndef HAS_UNIFORM_u_opacity -varying lowp float opacity; +in lowp float opacity; #else uniform lowp float u_opacity; #endif #ifndef HAS_UNIFORM_u_pattern_from -varying lowp vec4 pattern_from; +in lowp vec4 pattern_from; #else uniform lowp vec4 u_pattern_from; #endif #ifndef HAS_UNIFORM_u_pattern_to -varying lowp vec4 pattern_to; +in lowp vec4 pattern_to; #else uniform lowp vec4 u_pattern_to; #endif @@ -117,16 +117,16 @@ mediump vec4 pattern_to = u_pattern_to; vec2 imagecoord = mod(v_pos_a, 1.0); vec2 pos = mix(pattern_tl_a / u_texsize, pattern_br_a / u_texsize, imagecoord); - vec4 color1 = texture2D(u_image, pos); + vec4 color1 = texture(u_image, pos); vec2 imagecoord_b = mod(v_pos_b, 1.0); vec2 pos2 = mix(pattern_tl_b / u_texsize, pattern_br_b / u_texsize, imagecoord_b); - vec4 color2 = texture2D(u_image, pos2); + vec4 color2 = texture(u_image, pos2); - gl_FragColor = mix(color1, color2, u_fade) * opacity; + fragColor = mix(color1, color2, u_fade) * opacity; #ifdef OVERDRAW_INSPECTOR - gl_FragColor = vec4(1.0); + fragColor = vec4(1.0); #endif } )"; diff --git a/include/mbgl/shaders/gl/heatmap.hpp b/include/mbgl/shaders/gl/heatmap.hpp index bf51c57278f..edf51615dd6 100644 --- a/include/mbgl/shaders/gl/heatmap.hpp +++ b/include/mbgl/shaders/gl/heatmap.hpp @@ -1,5 +1,5 @@ // Generated code, do not modify this file! -// Generated on 2023-04-04T01:24:40.539Z by mwilsnd using shaders/generate_shader_code.js +// Generated on 2023-04-05T16:25:15.886Z by mwilsnd using shaders/generate_shader_code.js #pragma once #include @@ -8,26 +8,24 @@ namespace mbgl { namespace shaders { template <> struct ShaderSource { - static constexpr const char* vertex = R"( -uniform mat4 u_matrix; + static constexpr const char* vertex = R"(uniform mat4 u_matrix; uniform float u_extrude_scale; uniform float u_opacity; uniform float u_intensity; -attribute vec2 a_pos; - -varying vec2 v_extrude; +layout (location = 0) in vec2 a_pos; +out vec2 v_extrude; #ifndef HAS_UNIFORM_u_weight uniform lowp float u_weight_t; -attribute highp vec2 a_weight; -varying highp float weight; +layout (location = 1) in highp vec2 a_weight; +out 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; +layout (location = 2) in mediump vec2 a_radius; #else uniform mediump float u_radius; #endif @@ -84,10 +82,10 @@ mediump float radius = u_radius; )"; static constexpr const char* fragment = R"(uniform highp float u_intensity; -varying vec2 v_extrude; +in vec2 v_extrude; #ifndef HAS_UNIFORM_u_weight -varying highp float weight; +in highp float weight; #else uniform highp float u_weight; #endif @@ -104,10 +102,10 @@ highp float weight = u_weight; float d = -0.5 * 3.0 * 3.0 * dot(v_extrude, v_extrude); float val = weight * u_intensity * GAUSS_COEF * exp(d); - gl_FragColor = vec4(val, 1.0, 1.0, 1.0); + fragColor = vec4(val, 1.0, 1.0, 1.0); #ifdef OVERDRAW_INSPECTOR - gl_FragColor = vec4(1.0); + fragColor = vec4(1.0); #endif } )"; diff --git a/include/mbgl/shaders/gl/heatmap_texture.hpp b/include/mbgl/shaders/gl/heatmap_texture.hpp index 7a8ec42e3ce..e052cbdfee1 100644 --- a/include/mbgl/shaders/gl/heatmap_texture.hpp +++ b/include/mbgl/shaders/gl/heatmap_texture.hpp @@ -1,5 +1,5 @@ // Generated code, do not modify this file! -// Generated on 2023-04-04T01:24:40.539Z by mwilsnd using shaders/generate_shader_code.js +// Generated on 2023-04-05T16:25:15.886Z by mwilsnd using shaders/generate_shader_code.js #pragma once #include @@ -10,8 +10,8 @@ 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; +layout (location = 0) in vec2 a_pos; +out vec2 v_pos; void main() { gl_Position = u_matrix * vec4(a_pos * u_world, 0, 1); @@ -23,15 +23,15 @@ void main() { static constexpr const char* fragment = R"(uniform sampler2D u_image; uniform sampler2D u_color_ramp; uniform float u_opacity; -varying vec2 v_pos; +in 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; + float t = texture(u_image, v_pos).r; + vec4 color = texture(u_color_ramp, vec2(t, 0.5)); + fragColor = color * u_opacity; #ifdef OVERDRAW_INSPECTOR - gl_FragColor = vec4(0.0); + fragColor = vec4(0.0); #endif } )"; diff --git a/include/mbgl/shaders/gl/hillshade.hpp b/include/mbgl/shaders/gl/hillshade.hpp index a5f6c216be3..ed569b814ae 100644 --- a/include/mbgl/shaders/gl/hillshade.hpp +++ b/include/mbgl/shaders/gl/hillshade.hpp @@ -1,5 +1,5 @@ // Generated code, do not modify this file! -// Generated on 2023-04-04T01:24:40.539Z by mwilsnd using shaders/generate_shader_code.js +// Generated on 2023-04-05T16:25:15.886Z by mwilsnd using shaders/generate_shader_code.js #pragma once #include @@ -10,10 +10,10 @@ namespace shaders { template <> struct ShaderSource { static constexpr const char* vertex = R"(uniform mat4 u_matrix; -attribute vec2 a_pos; -attribute vec2 a_texture_pos; +layout (location = 0) in vec2 a_pos; +layout (location = 1) in vec2 a_texture_pos; -varying vec2 v_pos; +out vec2 v_pos; void main() { gl_Position = u_matrix * vec4(a_pos, 0, 1); @@ -21,7 +21,7 @@ void main() { } )"; static constexpr const char* fragment = R"(uniform sampler2D u_image; -varying vec2 v_pos; +in vec2 v_pos; uniform vec2 u_latrange; uniform vec2 u_light; @@ -32,7 +32,7 @@ uniform vec4 u_accent; #define PI 3.141592653589793 void main() { - vec4 pixel = texture2D(u_image, v_pos); + vec4 pixel = texture(u_image, v_pos); vec2 deriv = ((pixel.rg * 2.0) - 1.0); @@ -66,10 +66,10 @@ void main() { vec4 accent_color = (1.0 - accent) * u_accent * clamp(intensity * 2.0, 0.0, 1.0); float shade = abs(mod((aspect + azimuth) / PI + 0.5, 2.0) - 1.0); vec4 shade_color = mix(u_shadow, u_highlight, shade) * sin(scaledSlope) * clamp(intensity * 2.0, 0.0, 1.0); - gl_FragColor = accent_color * (1.0 - shade_color.a) + shade_color; + fragColor = accent_color * (1.0 - shade_color.a) + shade_color; #ifdef OVERDRAW_INSPECTOR - gl_FragColor = vec4(1.0); + fragColor = vec4(1.0); #endif } )"; diff --git a/include/mbgl/shaders/gl/hillshade_prepare.hpp b/include/mbgl/shaders/gl/hillshade_prepare.hpp index 2b4dba0cfb7..6e26c12a69c 100644 --- a/include/mbgl/shaders/gl/hillshade_prepare.hpp +++ b/include/mbgl/shaders/gl/hillshade_prepare.hpp @@ -1,5 +1,5 @@ // Generated code, do not modify this file! -// Generated on 2023-04-04T01:24:40.539Z by mwilsnd using shaders/generate_shader_code.js +// Generated on 2023-04-05T16:25:15.886Z by mwilsnd using shaders/generate_shader_code.js #pragma once #include @@ -11,10 +11,10 @@ template <> struct ShaderSource @@ -16,55 +16,55 @@ template <> struct ShaderSource @@ -20,48 +20,48 @@ template <> struct ShaderSource @@ -20,62 +20,62 @@ template <> struct ShaderSource @@ -20,8 +20,8 @@ template <> struct ShaderSource @@ -99,6 +99,8 @@ precision mediump float; #endif #endif + +out highp vec4 fragColor; )"; }; diff --git a/include/mbgl/shaders/gl/raster.hpp b/include/mbgl/shaders/gl/raster.hpp index 8f693fe5bba..c275c443de1 100644 --- a/include/mbgl/shaders/gl/raster.hpp +++ b/include/mbgl/shaders/gl/raster.hpp @@ -1,5 +1,5 @@ // Generated code, do not modify this file! -// Generated on 2023-04-04T01:24:40.539Z by mwilsnd using shaders/generate_shader_code.js +// Generated on 2023-04-05T16:25:15.886Z by mwilsnd using shaders/generate_shader_code.js #pragma once #include @@ -13,11 +13,11 @@ uniform vec2 u_tl_parent; uniform float u_scale_parent; uniform float u_buffer_scale; -attribute vec2 a_pos; -attribute vec2 a_texture_pos; +layout (location = 0) in vec2 a_pos; +layout (location = 1) in vec2 a_texture_pos; -varying vec2 v_pos0; -varying vec2 v_pos1; +out vec2 v_pos0; +out vec2 v_pos1; void main() { gl_Position = u_matrix * vec4(a_pos, 0, 1); @@ -34,8 +34,8 @@ void main() { uniform float u_opacity; uniform sampler2D u_image0; uniform sampler2D u_image1; -varying vec2 v_pos0; -varying vec2 v_pos1; +in vec2 v_pos0; +in vec2 v_pos1; uniform float u_brightness_low; uniform float u_brightness_high; @@ -47,8 +47,8 @@ uniform vec3 u_spin_weights; void main() { // read and cross-fade colors from the main and parent tiles - vec4 color0 = texture2D(u_image0, v_pos0); - vec4 color1 = texture2D(u_image1, v_pos1); + vec4 color0 = texture(u_image0, v_pos0); + vec4 color1 = texture(u_image1, v_pos1); if (color0.a > 0.0) { color0.rgb = color0.rgb / color0.a; } @@ -76,10 +76,10 @@ void main() { vec3 u_high_vec = vec3(u_brightness_low, u_brightness_low, u_brightness_low); vec3 u_low_vec = vec3(u_brightness_high, u_brightness_high, u_brightness_high); - gl_FragColor = vec4(mix(u_high_vec, u_low_vec, rgb) * color.a, color.a); + fragColor = vec4(mix(u_high_vec, u_low_vec, rgb) * color.a, color.a); #ifdef OVERDRAW_INSPECTOR - gl_FragColor = vec4(1.0); + fragColor = vec4(1.0); #endif } )"; diff --git a/include/mbgl/shaders/gl/symbol_icon.hpp b/include/mbgl/shaders/gl/symbol_icon.hpp index 9f60574acfb..273a1ac393a 100644 --- a/include/mbgl/shaders/gl/symbol_icon.hpp +++ b/include/mbgl/shaders/gl/symbol_icon.hpp @@ -1,5 +1,5 @@ // Generated code, do not modify this file! -// Generated on 2023-04-04T01:24:40.539Z by mwilsnd using shaders/generate_shader_code.js +// Generated on 2023-04-05T16:25:15.886Z by mwilsnd using shaders/generate_shader_code.js #pragma once #include @@ -10,11 +10,11 @@ namespace shaders { template <> struct ShaderSource { static constexpr const char* vertex = R"(const float PI = 3.141592653589793; -attribute vec4 a_pos_offset; -attribute vec4 a_data; -attribute vec4 a_pixeloffset; -attribute vec3 a_projected_pos; -attribute float a_fade_opacity; +layout (location = 0) in vec4 a_pos_offset; +layout (location = 1) in vec4 a_data; +layout (location = 2) in vec4 a_pixeloffset; +layout (location = 3) in vec3 a_projected_pos; +layout (location = 4) in float a_fade_opacity; uniform bool u_is_size_zoom_constant; uniform bool u_is_size_feature_constant; @@ -35,13 +35,13 @@ uniform bool u_pitch_with_map; uniform vec2 u_texsize; -varying vec2 v_tex; -varying float v_fade_opacity; +out vec2 v_tex; +out float v_fade_opacity; #ifndef HAS_UNIFORM_u_opacity uniform lowp float u_opacity_t; -attribute lowp vec2 a_opacity; -varying lowp float opacity; +layout (location = 5) in lowp vec2 a_opacity; +out lowp float opacity; #else uniform lowp float u_opacity; #endif @@ -115,11 +115,11 @@ lowp float opacity = u_opacity; )"; static constexpr const char* fragment = R"(uniform sampler2D u_texture; -varying vec2 v_tex; -varying float v_fade_opacity; +in vec2 v_tex; +in float v_fade_opacity; #ifndef HAS_UNIFORM_u_opacity -varying lowp float opacity; +in lowp float opacity; #else uniform lowp float u_opacity; #endif @@ -130,10 +130,10 @@ lowp float opacity = u_opacity; #endif lowp float alpha = opacity * v_fade_opacity; - gl_FragColor = texture2D(u_texture, v_tex) * alpha; + fragColor = texture(u_texture, v_tex) * alpha; #ifdef OVERDRAW_INSPECTOR - gl_FragColor = vec4(1.0); + fragColor = vec4(1.0); #endif } )"; diff --git a/include/mbgl/shaders/gl/symbol_sdf_icon.hpp b/include/mbgl/shaders/gl/symbol_sdf_icon.hpp index e657932ef2e..cbf4b9f1d92 100644 --- a/include/mbgl/shaders/gl/symbol_sdf_icon.hpp +++ b/include/mbgl/shaders/gl/symbol_sdf_icon.hpp @@ -1,5 +1,5 @@ // Generated code, do not modify this file! -// Generated on 2023-04-04T01:24:40.539Z by mwilsnd using shaders/generate_shader_code.js +// Generated on 2023-04-05T16:25:15.886Z by mwilsnd using shaders/generate_shader_code.js #pragma once #include @@ -10,11 +10,11 @@ namespace shaders { template <> struct ShaderSource { static constexpr const char* vertex = R"(const float PI = 3.141592653589793; -attribute vec4 a_pos_offset; -attribute vec4 a_data; -attribute vec4 a_pixeloffset; -attribute vec3 a_projected_pos; -attribute float a_fade_opacity; +layout (location = 0) in vec4 a_pos_offset; +layout (location = 1) in vec4 a_data; +layout (location = 2) in vec4 a_pixeloffset; +layout (location = 3) in vec3 a_projected_pos; +layout (location = 4) in float a_fade_opacity; // contents of a_size vary based on the type of property value // used for {text,icon}-size. @@ -39,41 +39,41 @@ uniform highp float u_camera_to_center_distance; uniform float u_fade_change; uniform vec2 u_texsize; -varying vec2 v_data0; -varying vec3 v_data1; +out vec2 v_data0; +out vec3 v_data1; #ifndef HAS_UNIFORM_u_fill_color uniform lowp float u_fill_color_t; -attribute highp vec4 a_fill_color; -varying highp vec4 fill_color; +layout (location = 5) in highp vec4 a_fill_color; +out 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; -varying highp vec4 halo_color; +layout (location = 6) in highp vec4 a_halo_color; +out 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; -varying lowp float opacity; +layout (location = 7) in lowp vec2 a_opacity; +out 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; -varying lowp float halo_width; +layout (location = 8) in lowp vec2 a_halo_width; +out 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; -varying lowp float halo_blur; +layout (location = 9) in lowp vec2 a_halo_blur; +out lowp float halo_blur; #else uniform lowp float u_halo_blur; #endif @@ -182,31 +182,31 @@ uniform highp float u_gamma_scale; uniform lowp float u_device_pixel_ratio; uniform bool u_is_text; -varying vec2 v_data0; -varying vec3 v_data1; +in vec2 v_data0; +in vec3 v_data1; #ifndef HAS_UNIFORM_u_fill_color -varying highp vec4 fill_color; +in highp vec4 fill_color; #else uniform highp vec4 u_fill_color; #endif #ifndef HAS_UNIFORM_u_halo_color -varying highp vec4 halo_color; +in highp vec4 halo_color; #else uniform highp vec4 u_halo_color; #endif #ifndef HAS_UNIFORM_u_opacity -varying lowp float opacity; +in lowp float opacity; #else uniform lowp float u_opacity; #endif #ifndef HAS_UNIFORM_u_halo_width -varying lowp float halo_width; +in lowp float halo_width; #else uniform lowp float u_halo_width; #endif #ifndef HAS_UNIFORM_u_halo_blur -varying lowp float halo_blur; +in lowp float halo_blur; #else uniform lowp float u_halo_blur; #endif @@ -246,14 +246,14 @@ lowp float halo_blur = u_halo_blur; buff = (6.0 - halo_width / fontScale) / SDF_PX; } - lowp float dist = texture2D(u_texture, tex).a; + lowp float dist = texture(u_texture, tex).a; highp float gamma_scaled = gamma * gamma_scale; highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist); - gl_FragColor = color * (alpha * opacity * fade_opacity); + fragColor = color * (alpha * opacity * fade_opacity); #ifdef OVERDRAW_INSPECTOR - gl_FragColor = vec4(1.0); + fragColor = vec4(1.0); #endif } )"; diff --git a/include/mbgl/shaders/gl/symbol_sdf_text.hpp b/include/mbgl/shaders/gl/symbol_sdf_text.hpp index bb299a03e5d..d453fead3b2 100644 --- a/include/mbgl/shaders/gl/symbol_sdf_text.hpp +++ b/include/mbgl/shaders/gl/symbol_sdf_text.hpp @@ -1,5 +1,5 @@ // Generated code, do not modify this file! -// Generated on 2023-04-04T01:24:40.539Z by mwilsnd using shaders/generate_shader_code.js +// Generated on 2023-04-05T16:25:15.886Z by mwilsnd using shaders/generate_shader_code.js #pragma once #include @@ -10,11 +10,11 @@ namespace shaders { template <> struct ShaderSource { static constexpr const char* vertex = R"(const float PI = 3.141592653589793; -attribute vec4 a_pos_offset; -attribute vec4 a_data; -attribute vec4 a_pixeloffset; -attribute vec3 a_projected_pos; -attribute float a_fade_opacity; +layout (location = 0) in vec4 a_pos_offset; +layout (location = 1) in vec4 a_data; +layout (location = 2) in vec4 a_pixeloffset; +layout (location = 3) in vec3 a_projected_pos; +layout (location = 4) in float a_fade_opacity; // contents of a_size vary based on the type of property value // used for {text,icon}-size. @@ -39,41 +39,41 @@ uniform highp float u_camera_to_center_distance; uniform float u_fade_change; uniform vec2 u_texsize; -varying vec2 v_data0; -varying vec3 v_data1; +out vec2 v_data0; +out vec3 v_data1; #ifndef HAS_UNIFORM_u_fill_color uniform lowp float u_fill_color_t; -attribute highp vec4 a_fill_color; -varying highp vec4 fill_color; +layout (location = 5) in highp vec4 a_fill_color; +out 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; -varying highp vec4 halo_color; +layout (location = 6) in highp vec4 a_halo_color; +out 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; -varying lowp float opacity; +layout (location = 7) in lowp vec2 a_opacity; +out 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; -varying lowp float halo_width; +layout (location = 8) in lowp vec2 a_halo_width; +out 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; -varying lowp float halo_blur; +layout (location = 9) in lowp vec2 a_halo_blur; +out lowp float halo_blur; #else uniform lowp float u_halo_blur; #endif @@ -182,31 +182,31 @@ uniform highp float u_gamma_scale; uniform lowp float u_device_pixel_ratio; uniform bool u_is_text; -varying vec2 v_data0; -varying vec3 v_data1; +in vec2 v_data0; +in vec3 v_data1; #ifndef HAS_UNIFORM_u_fill_color -varying highp vec4 fill_color; +in highp vec4 fill_color; #else uniform highp vec4 u_fill_color; #endif #ifndef HAS_UNIFORM_u_halo_color -varying highp vec4 halo_color; +in highp vec4 halo_color; #else uniform highp vec4 u_halo_color; #endif #ifndef HAS_UNIFORM_u_opacity -varying lowp float opacity; +in lowp float opacity; #else uniform lowp float u_opacity; #endif #ifndef HAS_UNIFORM_u_halo_width -varying lowp float halo_width; +in lowp float halo_width; #else uniform lowp float u_halo_width; #endif #ifndef HAS_UNIFORM_u_halo_blur -varying lowp float halo_blur; +in lowp float halo_blur; #else uniform lowp float u_halo_blur; #endif @@ -246,14 +246,14 @@ lowp float halo_blur = u_halo_blur; buff = (6.0 - halo_width / fontScale) / SDF_PX; } - lowp float dist = texture2D(u_texture, tex).a; + lowp float dist = texture(u_texture, tex).a; highp float gamma_scaled = gamma * gamma_scale; highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist); - gl_FragColor = color * (alpha * opacity * fade_opacity); + fragColor = color * (alpha * opacity * fade_opacity); #ifdef OVERDRAW_INSPECTOR - gl_FragColor = vec4(1.0); + fragColor = vec4(1.0); #endif } )"; diff --git a/include/mbgl/shaders/gl/symbol_text_and_icon.hpp b/include/mbgl/shaders/gl/symbol_text_and_icon.hpp index 0e7e72b56c7..716f75798d1 100644 --- a/include/mbgl/shaders/gl/symbol_text_and_icon.hpp +++ b/include/mbgl/shaders/gl/symbol_text_and_icon.hpp @@ -1,5 +1,5 @@ // Generated code, do not modify this file! -// Generated on 2023-04-04T01:24:40.539Z by mwilsnd using shaders/generate_shader_code.js +// Generated on 2023-04-05T16:25:15.886Z by mwilsnd using shaders/generate_shader_code.js #pragma once #include @@ -10,10 +10,10 @@ namespace shaders { template <> struct ShaderSource { static constexpr const char* vertex = R"(const float PI = 3.141592653589793; -attribute vec4 a_pos_offset; -attribute vec4 a_data; -attribute vec3 a_projected_pos; -attribute float a_fade_opacity; +layout (location = 0) in vec4 a_pos_offset; +layout (location = 1) in vec4 a_data; +layout (location = 2) in vec3 a_projected_pos; +layout (location = 3) in float a_fade_opacity; // contents of a_size vary based on the type of property value // used for {text,icon}-size. @@ -39,41 +39,41 @@ uniform float u_fade_change; uniform vec2 u_texsize; uniform vec2 u_texsize_icon; -varying vec4 v_data0; -varying vec4 v_data1; +out vec4 v_data0; +out vec4 v_data1; #ifndef HAS_UNIFORM_u_fill_color uniform lowp float u_fill_color_t; -attribute highp vec4 a_fill_color; -varying highp vec4 fill_color; +layout (location = 4) in highp vec4 a_fill_color; +out 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; -varying highp vec4 halo_color; +layout (location = 5) in highp vec4 a_halo_color; +out 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; -varying lowp float opacity; +layout (location = 6) in lowp vec2 a_opacity; +out 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; -varying lowp float halo_width; +layout (location = 7) in lowp vec2 a_halo_width; +out 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; -varying lowp float halo_blur; +layout (location = 8) in lowp vec2 a_halo_blur; +out lowp float halo_blur; #else uniform lowp float u_halo_blur; #endif @@ -186,31 +186,31 @@ uniform sampler2D u_texture_icon; uniform highp float u_gamma_scale; uniform lowp float u_device_pixel_ratio; -varying vec4 v_data0; -varying vec4 v_data1; +in vec4 v_data0; +in vec4 v_data1; #ifndef HAS_UNIFORM_u_fill_color -varying highp vec4 fill_color; +in highp vec4 fill_color; #else uniform highp vec4 u_fill_color; #endif #ifndef HAS_UNIFORM_u_halo_color -varying highp vec4 halo_color; +in highp vec4 halo_color; #else uniform highp vec4 u_halo_color; #endif #ifndef HAS_UNIFORM_u_opacity -varying lowp float opacity; +in lowp float opacity; #else uniform lowp float u_opacity; #endif #ifndef HAS_UNIFORM_u_halo_width -varying lowp float halo_width; +in lowp float halo_width; #else uniform lowp float u_halo_width; #endif #ifndef HAS_UNIFORM_u_halo_blur -varying lowp float halo_blur; +in lowp float halo_blur; #else uniform lowp float u_halo_blur; #endif @@ -237,10 +237,10 @@ lowp float halo_blur = u_halo_blur; if (v_data1.w == ICON) { vec2 tex_icon = v_data0.zw; lowp float alpha = opacity * fade_opacity; - gl_FragColor = texture2D(u_texture_icon, tex_icon) * alpha; + fragColor = texture(u_texture_icon, tex_icon) * alpha; #ifdef OVERDRAW_INSPECTOR - gl_FragColor = vec4(1.0); + fragColor = vec4(1.0); #endif return; } @@ -263,14 +263,14 @@ lowp float halo_blur = u_halo_blur; buff = (6.0 - halo_width / fontScale) / SDF_PX; } - lowp float dist = texture2D(u_texture, tex).a; + lowp float dist = texture(u_texture, tex).a; highp float gamma_scaled = gamma * gamma_scale; highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist); - gl_FragColor = color * (alpha * opacity * fade_opacity); + fragColor = color * (alpha * opacity * fade_opacity); #ifdef OVERDRAW_INSPECTOR - gl_FragColor = vec4(1.0); + fragColor = vec4(1.0); #endif } )"; diff --git a/include/mbgl/shaders/shader_manifest.hpp b/include/mbgl/shaders/shader_manifest.hpp index 29730ba94dd..6dc07583d2e 100644 --- a/include/mbgl/shaders/shader_manifest.hpp +++ b/include/mbgl/shaders/shader_manifest.hpp @@ -1,5 +1,5 @@ // Generated code, do not modify this file! -// Generated on 2023-04-04T01:24:40.539Z by mwilsnd using shaders/generate_shader_code.js +// Generated on 2023-04-05T16:25:15.886Z by mwilsnd using shaders/generate_shader_code.js #pragma once #include diff --git a/include/mbgl/shaders/shader_source.hpp b/include/mbgl/shaders/shader_source.hpp index a58c8c46fc1..9eb79b6218f 100644 --- a/include/mbgl/shaders/shader_source.hpp +++ b/include/mbgl/shaders/shader_source.hpp @@ -1,5 +1,5 @@ // Generated code, do not modify this file! -// Generated on 2023-04-04T01:24:40.539Z by mwilsnd using shaders/generate_shader_code.js +// Generated on 2023-04-05T16:25:15.886Z by mwilsnd using shaders/generate_shader_code.js #pragma once #include diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/egl/EGLConfigChooser.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/egl/EGLConfigChooser.java index eaa389f22f4..de866eef0fd 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/egl/EGLConfigChooser.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/renderer/egl/EGLConfigChooser.java @@ -43,20 +43,12 @@ public class EGLConfigChooser implements GLSurfaceView.EGLConfigChooser { private static final String TAG = "Mbgl-EGLConfigChooser"; /** - * Requires API level 17 + * Requires API level 18 * - * @see android.opengl.EGL14.EGL_CONFORMANT; + * @see android.opengl.EGL15.EGL_OPENGL_ES3_BIT; */ @SuppressWarnings("JavadocReference") - private static final int EGL_CONFORMANT = 0x3042; - - /** - * Requires API level 17 - * - * @see android.opengl.EGL14.EGL_OPENGL_ES2_BIT; - */ - @SuppressWarnings("JavadocReference") - private static final int EGL_OPENGL_ES2_BIT = 0x0004; + private static final int EGL_OPENGL_ES3_BIT = 0x0040; private boolean translucentSurface; @@ -144,16 +136,14 @@ private EGLConfig chooseBestMatchConfig(@NonNull EGL10 egl, EGLDisplay display, class Config implements Comparable { private final BufferFormat bufferFormat; private final DepthStencilFormat depthStencilFormat; - private final boolean isNotConformant; private final boolean isCaveat; private final int index; private final EGLConfig config; public Config(BufferFormat bufferFormat, DepthStencilFormat depthStencilFormat, - boolean isNotConformant, boolean isCaveat, int index, EGLConfig config) { + boolean isCaveat, int index, EGLConfig config) { this.bufferFormat = bufferFormat; this.depthStencilFormat = depthStencilFormat; - this.isNotConformant = isNotConformant; this.isCaveat = isCaveat; this.index = index; this.config = config; @@ -172,11 +162,6 @@ public int compareTo(@NonNull Config other) { return i; } - i = compare(isNotConformant, other.isNotConformant); - if (i != 0) { - return i; - } - i = compare(isCaveat, other.isCaveat); if (i != 0) { return i; @@ -202,7 +187,6 @@ public int compareTo(@NonNull Config other) { i++; int caveat = getConfigAttr(egl, display, config, EGL_CONFIG_CAVEAT); - int conformant = getConfigAttr(egl, display, config, EGL_CONFORMANT); int bits = getConfigAttr(egl, display, config, EGL_BUFFER_SIZE); int red = getConfigAttr(egl, display, config, EGL_RED_SIZE); int green = getConfigAttr(egl, display, config, EGL_GREEN_SIZE); @@ -243,12 +227,11 @@ public int compareTo(@NonNull Config other) { depthStencilFormat = DepthStencilFormat.Format24Depth8Stencil; } - boolean isNotConformant = (conformant & EGL_OPENGL_ES2_BIT) != EGL_OPENGL_ES2_BIT; boolean isCaveat = caveat != EGL_NONE; // Ignore formats we don't recognise if (bufferFormat != BufferFormat.Unknown) { - matches.add(new Config(bufferFormat, depthStencilFormat, isNotConformant, isCaveat, i, config)); + matches.add(new Config(bufferFormat, depthStencilFormat, isCaveat, i, config)); } } @@ -268,10 +251,6 @@ public int compareTo(@NonNull Config other) { Logger.w(TAG, "Chosen config has a caveat."); } - if (bestMatch.isNotConformant) { - Logger.w(TAG, "Chosen config is not conformant."); - } - return bestMatch.config; } @@ -300,9 +279,8 @@ private int[] getConfigAttributes() { EGL_ALPHA_SIZE, translucentSurface ? 8 : 0, EGL_DEPTH_SIZE, 16, EGL_STENCIL_SIZE, 8, - (emulator ? EGL_NONE : EGL_CONFORMANT), EGL_OPENGL_ES2_BIT, (emulator ? EGL_NONE : EGL_COLOR_BUFFER_TYPE), EGL_RGB_BUFFER, - EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, + EGL_RENDERABLE_TYPE, EGL_OPENGL_ES3_BIT, EGL_NONE }; } diff --git a/platform/android/android.cmake b/platform/android/android.cmake index fd9814cac40..7a810f06d83 100644 --- a/platform/android/android.cmake +++ b/platform/android/android.cmake @@ -4,7 +4,7 @@ endif() target_compile_definitions( mbgl-core - PUBLIC MBGL_USE_GLES2 + PUBLIC ) include(${PROJECT_SOURCE_DIR}/vendor/icu.cmake) @@ -83,7 +83,7 @@ target_link_libraries( mbgl-core PRIVATE EGL - GLESv2 + GLESv3 Mapbox::Base::jni.hpp android atomic @@ -107,7 +107,7 @@ target_include_directories( target_link_libraries( example-custom-layer PRIVATE - GLESv2 + GLESv3 Mapbox::Base Mapbox::Base::optional log diff --git a/platform/android/src/example_custom_layer.cpp b/platform/android/src/example_custom_layer.cpp index e1b80ffba5a..159df486595 100644 --- a/platform/android/src/example_custom_layer.cpp +++ b/platform/android/src/example_custom_layer.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -109,8 +109,8 @@ void checkCompileStatus(GLuint shader) { // /DEBUGGING -static const GLchar * vertexShaderSource = "attribute vec2 a_pos; void main() { gl_Position = vec4(a_pos, 0, 1); }"; -static const GLchar * fragmentShaderSource = "uniform highp vec4 fill_color; void main() { gl_FragColor = fill_color; }"; +static const GLchar * vertexShaderSource = "#version 300 es\nlayout (location = 0) in vec2 a_pos; void main() { gl_Position = vec4(a_pos, 0, 1); }"; +static const GLchar * fragmentShaderSource = "#version 300 es\nuniform highp vec4 fill_color; out highp vec4 fragColor; void main() { fragColor = fill_color; }"; class ExampleCustomLayer: mbgl::style::CustomLayerHost { public: diff --git a/platform/android/src/gl_functions.cpp b/platform/android/src/gl_functions.cpp index 90be88b0a1b..f1b2298fa37 100644 --- a/platform/android/src/gl_functions.cpp +++ b/platform/android/src/gl_functions.cpp @@ -1,8 +1,6 @@ #include -#define GL_GLEXT_PROTOTYPES -#include -#include +#include namespace mbgl { namespace platform { diff --git a/platform/darwin/src/gl_functions.cpp b/platform/darwin/src/gl_functions.cpp index a0da6f3e054..f2a3cd2e4c0 100644 --- a/platform/darwin/src/gl_functions.cpp +++ b/platform/darwin/src/gl_functions.cpp @@ -3,11 +3,11 @@ #include "TargetConditionals.h" #if TARGET_OS_IPHONE - #include - #include + #include + #include #elif TARGET_OS_SIMULATOR - #include - #include + #include + #include #elif TARGET_OS_MAC #include #include @@ -167,14 +167,5 @@ void (* const glVertexAttrib4fv)(GLuint, const GLfloat *) = ::glVertexAttrib4fv; void (* const glVertexAttribPointer)(GLuint, GLint, GLenum, GLboolean, GLsizei, const void *) = ::glVertexAttribPointer; void (* const glViewport)(GLint, GLint, GLsizei, GLsizei) = ::glViewport; -#ifndef MBGL_USE_GLES2 -void (* const glDrawPixels)(GLsizei, GLsizei, GLenum, GLenum, const GLvoid *) = ::glDrawPixels; -void (* const glGetDoublev)(GLenum, GLdouble *) = ::glGetDoublev; -void (* const glPixelTransferf)(GLenum, GLfloat) = ::glPixelTransferf; -void (* const glPixelZoom)(GLfloat, GLfloat) = ::glPixelZoom; -void (* const glPointSize)(GLfloat) = ::glPointSize; -void (* const glRasterPos4d)(GLdouble, GLdouble, GLdouble, GLdouble) = ::glRasterPos4d; -#endif - } // namespace platform } // namespace mbgl diff --git a/platform/darwin/src/headless_backend_eagl.mm b/platform/darwin/src/headless_backend_eagl.mm index f2c7d8c2fbb..ec34ba32218 100644 --- a/platform/darwin/src/headless_backend_eagl.mm +++ b/platform/darwin/src/headless_backend_eagl.mm @@ -10,7 +10,7 @@ class EAGLBackendImpl : public HeadlessBackend::Impl { public: EAGLBackendImpl() { - glContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; + glContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3]; if (glContext == nil) { throw std::runtime_error("Error creating GL context object"); } diff --git a/platform/glfw/glfw_view.cpp b/platform/glfw/glfw_view.cpp index d48ef2d1663..9f0eac86426 100644 --- a/platform/glfw/glfw_view.cpp +++ b/platform/glfw/glfw_view.cpp @@ -40,9 +40,7 @@ #pragma warning(pop) #endif -#if MBGL_USE_GLES2 -#define GLFW_INCLUDE_ES2 -#endif // MBGL_USE_GLES2 +#define GLFW_INCLUDE_ES3 #define GL_GLEXT_PROTOTYPES #include @@ -158,11 +156,9 @@ GLFWView::GLFWView(bool fullscreen_, bool benchmark_, const mbgl::ResourceOption glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE); #endif -#if MBGL_USE_GLES2 glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API); - glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2); + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); -#endif if (mbgl::gfx::Backend::GetType() != mbgl::gfx::Backend::Type::OpenGL) { glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); @@ -285,20 +281,6 @@ void GLFWView::onKey(GLFWwindow *window, int key, int /*scancode*/, int action, case GLFW_KEY_S: if (view->changeStyleCallback) view->changeStyleCallback(); break; -#if !MBGL_USE_GLES2 - case GLFW_KEY_B: { - auto debug = view->map->getDebug(); - if (debug & mbgl::MapDebugOptions::StencilClip) { - debug &= ~mbgl::MapDebugOptions::StencilClip; - debug |= mbgl::MapDebugOptions::DepthBuffer; - } else if (debug & mbgl::MapDebugOptions::DepthBuffer) { - debug &= ~mbgl::MapDebugOptions::DepthBuffer; - } else { - debug |= mbgl::MapDebugOptions::StencilClip; - } - view->map->setDebug(debug); - } break; -#endif // MBGL_USE_GLES2 case GLFW_KEY_N: if (!mods) view->map->easeTo(mbgl::CameraOptions().withBearing(0.0), mbgl::AnimationOptions {{mbgl::Milliseconds(500)}}); @@ -681,14 +663,9 @@ void GLFWView::updateAnimatedAnnotations() { void GLFWView::cycleDebugOptions() { auto debug = map->getDebug(); -#if !MBGL_USE_GLES2 - if (debug & mbgl::MapDebugOptions::StencilClip) + + if (debug & mbgl::MapDebugOptions::Overdraw) debug = mbgl::MapDebugOptions::NoDebug; - else if (debug & mbgl::MapDebugOptions::Overdraw) - debug = mbgl::MapDebugOptions::StencilClip; -#else - if (debug & mbgl::MapDebugOptions::Overdraw) debug = mbgl::MapDebugOptions::NoDebug; -#endif // MBGL_USE_GLES2 else if (debug & mbgl::MapDebugOptions::Collision) debug = mbgl::MapDebugOptions::Overdraw; else if (debug & mbgl::MapDebugOptions::Timestamps) diff --git a/platform/ios/ios.cmake b/platform/ios/ios.cmake index b41672932fc..b028198e40f 100644 --- a/platform/ios/ios.cmake +++ b/platform/ios/ios.cmake @@ -25,7 +25,7 @@ set_target_properties(mbgl-core PROPERTIES XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC if(MBGL_WITH_OPENGL) target_compile_definitions( mbgl-core - PUBLIC MBGL_USE_GLES2 GLES_SILENCE_DEPRECATION GLES_SILENCE_DEPRECATION + PUBLIC GLES_SILENCE_DEPRECATION GLES_SILENCE_DEPRECATION ) list(APPEND PLATFORM_FILES diff --git a/platform/ios/platform/darwin/app/LimeGreenStyleLayer.m b/platform/ios/platform/darwin/app/LimeGreenStyleLayer.m index b7e41a6582e..8348dcdcd6e 100644 --- a/platform/ios/platform/darwin/app/LimeGreenStyleLayer.m +++ b/platform/ios/platform/darwin/app/LimeGreenStyleLayer.m @@ -10,8 +10,8 @@ @implementation LimeGreenStyleLayer { } - (void)didMoveToMapView:(MLNMapView *)mapView { - static const GLchar *vertexShaderSource = "attribute vec2 a_pos; void main() { gl_Position = vec4(a_pos, 1, 1); }"; - static const GLchar *fragmentShaderSource = "void main() { gl_FragColor = vec4(0, 0.5, 0, 0.5); }"; + static const GLchar *vertexShaderSource = "#version 300 es\nlayout (location = 0) in vec2 a_pos; void main() { gl_Position = vec4(a_pos, 1, 1); }"; + static const GLchar *fragmentShaderSource = "#version 300 es\nout highp vec4 fragColor; void main() { fragColor = vec4(0, 0.5, 0, 0.5); }"; _program = glCreateProgram(); _vertexShader = glCreateShader(GL_VERTEX_SHADER); diff --git a/platform/ios/platform/ios/config.cmake b/platform/ios/platform/ios/config.cmake index 7f153558762..6af32b3b195 100644 --- a/platform/ios/platform/ios/config.cmake +++ b/platform/ios/platform/ios/config.cmake @@ -1,5 +1,3 @@ -set(USE_GLES2 ON) - macro(initialize_ios_target target) set_xcode_property(${target} IPHONEOS_DEPLOYMENT_TARGET "9.0") set_xcode_property(${target} ENABLE_BITCODE "YES") diff --git a/platform/ios/platform/ios/src/MLNMapView+OpenGL.mm b/platform/ios/platform/ios/src/MLNMapView+OpenGL.mm index 18c889eecaf..b8c4d008ec0 100644 --- a/platform/ios/platform/ios/src/MLNMapView+OpenGL.mm +++ b/platform/ios/platform/ios/src/MLNMapView+OpenGL.mm @@ -114,7 +114,7 @@ void bind() override { } if (!resource.context) { - resource.context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; + resource.context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3]; assert(resource.context); } diff --git a/platform/linux/src/gl_functions.cpp b/platform/linux/src/gl_functions.cpp index bf88f46c6c1..433255b1fc9 100644 --- a/platform/linux/src/gl_functions.cpp +++ b/platform/linux/src/gl_functions.cpp @@ -2,13 +2,8 @@ #define GL_GLEXT_PROTOTYPES -#ifndef MBGL_USE_GLES2 -#include -#include -#else -#include -#include -#endif +#include +#include namespace mbgl { namespace platform { @@ -153,14 +148,5 @@ void (* const glVertexAttrib4fv)(GLuint, const GLfloat *) = ::glVertexAttrib4fv; void (* const glVertexAttribPointer)(GLuint, GLint, GLenum, GLboolean, GLsizei, const void *) = ::glVertexAttribPointer; void (* const glViewport)(GLint, GLint, GLsizei, GLsizei) = ::glViewport; -#ifndef MBGL_USE_GLES2 -void (* const glDrawPixels)(GLsizei, GLsizei, GLenum, GLenum, const GLvoid *) = ::glDrawPixels; -void (* const glGetDoublev)(GLenum, GLdouble *) = ::glGetDoublev; -void (* const glPixelTransferf)(GLenum, GLfloat) = ::glPixelTransferf; -void (* const glPixelZoom)(GLfloat, GLfloat) = ::glPixelZoom; -void (* const glPointSize)(GLfloat) = ::glPointSize; -void (* const glRasterPos4d)(GLdouble, GLdouble, GLdouble, GLdouble) = ::glRasterPos4d; -#endif - } // namespace platform } // namespace mbgl diff --git a/platform/linux/src/headless_backend_egl.cpp b/platform/linux/src/headless_backend_egl.cpp index 580fc2cd9f7..31c64b415ea 100644 --- a/platform/linux/src/headless_backend_egl.cpp +++ b/platform/linux/src/headless_backend_egl.cpp @@ -37,9 +37,7 @@ class EGLDisplayConfig { } const EGLint attribs[] = { -#if MBGL_USE_GLES2 - EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, -#endif + EGL_RENDERABLE_TYPE, EGL_OPENGL_ES3_BIT, EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, EGL_NONE }; @@ -77,7 +75,7 @@ class EGLBackendImpl final : public HeadlessBackend::Impl { // objects and also to write vertex and fragment shaders in the OpenGL ES // Shading Language. const EGLint attribs[] = { - EGL_CONTEXT_CLIENT_VERSION, 2, + EGL_CONTEXT_CLIENT_VERSION, 3, EGL_NONE }; diff --git a/platform/node/cmake/module.cmake b/platform/node/cmake/module.cmake index cc2487601c0..ae43821c05d 100644 --- a/platform/node/cmake/module.cmake +++ b/platform/node/cmake/module.cmake @@ -218,7 +218,7 @@ function(add_node_module NAME) TARGET ${_TARGET} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy "${PROJECT_SOURCE_DIR}/platform/windows/vendor/mesa3d/${_ARCH}/libglapi.dll" "${_OUTPUT_PATH}" - COMMAND ${CMAKE_COMMAND} -E copy "${PROJECT_SOURCE_DIR}/platform/windows/vendor/mesa3d/${_ARCH}/libGLESv2.dll" "${_OUTPUT_PATH}" + COMMAND ${CMAKE_COMMAND} -E copy "${PROJECT_SOURCE_DIR}/platform/windows/vendor/mesa3d/${_ARCH}/libGLESv3.dll" "${_OUTPUT_PATH}" COMMAND ${CMAKE_COMMAND} -E copy "${PROJECT_SOURCE_DIR}/platform/windows/vendor/mesa3d/${_ARCH}/osmesa.dll" "${_OUTPUT_PATH}" ) endif() diff --git a/platform/qt/qt.cmake b/platform/qt/qt.cmake index 49f8c3a2133..166cfa60de5 100644 --- a/platform/qt/qt.cmake +++ b/platform/qt/qt.cmake @@ -122,7 +122,7 @@ target_sources( target_compile_definitions( mbgl-core PRIVATE QT_IMAGE_DECODERS - PUBLIC __QT__ MBGL_USE_GLES2 + PUBLIC __QT__ ) target_include_directories( diff --git a/platform/windows/FindOSMesa.cmake b/platform/windows/FindOSMesa.cmake index 66f8eca4033..be1c5eb5ddf 100644 --- a/platform/windows/FindOSMesa.cmake +++ b/platform/windows/FindOSMesa.cmake @@ -16,10 +16,10 @@ else() endif() find_library(OSMesa_osmesa_LIBRARY NAMES osmesa PATHS ${OSMesa_DIR}/lib PATH_SUFFIXES ${_ARCH} NO_DEFAULT_PATH) -find_library(OSMesa_libGLESv2_LIBRARY NAMES libGLESv2 PATHS ${OSMesa_DIR}/lib PATH_SUFFIXES ${_ARCH} NO_DEFAULT_PATH) +find_library(OSMesa_libGLESv3_LIBRARY NAMES libGLESv3 PATHS ${OSMesa_DIR}/lib PATH_SUFFIXES ${_ARCH} NO_DEFAULT_PATH) find_file(OSMesa_osmesa_LIBRARY_DLL NAMES osmesa.dll PATHS ${OSMesa_DIR} PATH_SUFFIXES ${_ARCH} NO_DEFAULT_PATH) -find_file(OSMesa_libGLESv2_LIBRARY_DLL NAMES libGLESv2.dll PATHS ${OSMesa_DIR} PATH_SUFFIXES ${_ARCH} NO_DEFAULT_PATH) +find_file(OSMesa_libGLESv3_LIBRARY_DLL NAMES libGLESv3.dll PATHS ${OSMesa_DIR} PATH_SUFFIXES ${_ARCH} NO_DEFAULT_PATH) unset(_ARCH) @@ -29,18 +29,18 @@ include(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(OSMesa REQUIRED_VARS OSMesa_osmesa_LIBRARY - OSMesa_libGLESv2_LIBRARY + OSMesa_libGLESv3_LIBRARY OSMesa_INCLUDE_DIR) # Hide internal variables -mark_as_advanced(OSMesa_INCLUDE_DIR OSMesa_osmesa_LIBRARY OSMesa_libGLESv2_LIBRARY) +mark_as_advanced(OSMesa_INCLUDE_DIR OSMesa_osmesa_LIBRARY OSMesa_libGLESv3_LIBRARY) # Set standard variables if(OSMesa_FOUND) set(OSMesa_INCLUDE_DIRS "${OSMesa_INCLUDE_DIR}") set(OSMesa_LIBRARIES "${OSMesa_osmesa_LIBRARY}" - "${OSMesa_libGLESv2_LIBRARY}" + "${OSMesa_libGLESv3_LIBRARY}" ) add_library(OSMesa::osmesa SHARED IMPORTED) @@ -53,13 +53,13 @@ if(OSMesa_FOUND) IMPORTED_LOCATION ${OSMesa_osmesa_LIBRARY_DLL} ) - add_library(OSMesa::libGLESv2 SHARED IMPORTED) + add_library(OSMesa::libGLESv3 SHARED IMPORTED) set_target_properties( - OSMesa::libGLESv2 + OSMesa::libGLESv3 PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${OSMesa_INCLUDE_DIRS} - IMPORTED_IMPLIB ${OSMesa_libGLESv2_LIBRARY} - IMPORTED_LOCATION ${OSMesa_libGLESv2_LIBRARY_DLL} + IMPORTED_IMPLIB ${OSMesa_libGLESv3_LIBRARY} + IMPORTED_LOCATION ${OSMesa_libGLESv3_LIBRARY_DLL} ) endif() diff --git a/platform/windows/README.md b/platform/windows/README.md index 4452b390b9a..48dec04e128 100644 --- a/platform/windows/README.md +++ b/platform/windows/README.md @@ -43,7 +43,7 @@ To configure build with OSMesa (software rendering), use the following command: cmake . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DMBGL_WITH_OSMESA=ON ``` -**WARNING:** as OSMesa doesn't have static libraries, it's necessary to copy `libglapi.dll`, `libGLESv2.dll` and `osmesa.dll` from `platform\windows\vendor\mesa3d\` to executable/dll directory you want to use, otherwise it won't run. +**WARNING:** as OSMesa doesn't have static libraries, it's necessary to copy `libglapi.dll`, `libGLESv3.dll` and `osmesa.dll` from `platform\windows\vendor\mesa3d\` to executable/dll directory you want to use, otherwise it won't run. ## Building diff --git a/platform/windows/include/gl_functions_wgl.h b/platform/windows/include/gl_functions_wgl.h index dd8bc4fe413..b7436aee8bb 100644 --- a/platform/windows/include/gl_functions_wgl.h +++ b/platform/windows/include/gl_functions_wgl.h @@ -12,16 +12,7 @@ #endif #endif -#define GL_GLEXT_PROTOTYPES - -#ifdef MBGL_USE_GLES2 -#include -#include -#else -#include -#include -#endif - +#include #include #ifdef __cplusplus @@ -495,15 +486,6 @@ HGLRC(* const wglCreateContextAttribsARB)(HDC, HGLRC, const int*) = [](HDC hDC, const char* (* const wglGetExtensionsStringARB)(HDC) = [](HDC hdc) { if (!opengl32) loadWGL(); return ::wgl_wglGetExtensionsStringARB(hdc); }; const char* (* const wglGetExtensionsStringEXT)() = [](void) { if (!opengl32) loadWGL(); return ::wgl_wglGetExtensionsStringEXT(); }; -#ifndef MBGL_USE_GLES2 -void (* const glDrawPixels)(GLsizei, GLsizei, GLenum, GLenum, const GLvoid *) = ::glDrawPixels; -void (* const glGetDoublev)(GLenum, GLdouble *) = ::glGetDoublev; -void (* const glPixelTransferf)(GLenum, GLfloat) = ::glPixelTransferf; -void (* const glPixelZoom)(GLfloat, GLfloat) = ::glPixelZoom; -void (* const glPointSize)(GLfloat) = ::glPointSize; -void (* const glRasterPos4d)(GLdouble, GLdouble, GLdouble, GLdouble) = ::glRasterPos4d; -#endif - } // namespace platform } // namespace mbgl #endif diff --git a/platform/windows/src/gl_functions.cpp b/platform/windows/src/gl_functions.cpp index fea7b9f7100..3d2cf1dd314 100644 --- a/platform/windows/src/gl_functions.cpp +++ b/platform/windows/src/gl_functions.cpp @@ -6,13 +6,8 @@ #define GL_GLEXT_PROTOTYPES #endif -#ifndef MBGL_USE_GLES2 -#include -#include -#else -#include -#include -#endif +#include +#include namespace mbgl { namespace platform { @@ -157,14 +152,5 @@ void (* const glVertexAttrib4fv)(GLuint, const GLfloat *) = ::glVertexAttrib4fv; void (* const glVertexAttribPointer)(GLuint, GLint, GLenum, GLboolean, GLsizei, const void *) = ::glVertexAttribPointer; void (* const glViewport)(GLint, GLint, GLsizei, GLsizei) = ::glViewport; -#ifndef MBGL_USE_GLES2 -void (* const glDrawPixels)(GLsizei, GLsizei, GLenum, GLenum, const GLvoid *) = ::glDrawPixels; -void (* const glGetDoublev)(GLenum, GLdouble *) = ::glGetDoublev; -void (* const glPixelTransferf)(GLenum, GLfloat) = ::glPixelTransferf; -void (* const glPixelZoom)(GLfloat, GLfloat) = ::glPixelZoom; -void (* const glPointSize)(GLfloat) = ::glPointSize; -void (* const glRasterPos4d)(GLdouble, GLdouble, GLdouble, GLdouble) = ::glRasterPos4d; -#endif - } // namespace platform } // namespace mbgl diff --git a/platform/windows/src/headless_backend_egl.cpp b/platform/windows/src/headless_backend_egl.cpp index be84e1a7b06..68b931916bf 100644 --- a/platform/windows/src/headless_backend_egl.cpp +++ b/platform/windows/src/headless_backend_egl.cpp @@ -39,9 +39,7 @@ class EGLDisplayConfig { } const EGLint attribs[] = { -#if MBGL_USE_GLES2 - EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, -#endif + EGL_RENDERABLE_TYPE, EGL_OPENGL_ES3_BIT, EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, EGL_NONE }; diff --git a/platform/windows/src/headless_backend_wgl.cpp b/platform/windows/src/headless_backend_wgl.cpp index 36a9ae4f029..dcfeec534c7 100644 --- a/platform/windows/src/headless_backend_wgl.cpp +++ b/platform/windows/src/headless_backend_wgl.cpp @@ -166,14 +166,13 @@ class WGLDisplayConfig { ARB_multisample = extensionSupportedWGL("WGL_ARB_multisample"); ARB_create_context = extensionSupportedWGL("WGL_ARB_create_context"); ARB_create_context_profile = extensionSupportedWGL("WGL_ARB_create_context_profile"); - EXT_create_context_es2_profile = extensionSupportedWGL("WGL_EXT_create_context_es2_profile"); EXT_colorspace = extensionSupportedWGL("WGL_EXT_colorspace"); ARB_pixel_format = extensionSupportedWGL("WGL_ARB_pixel_format"); - ARB_ES2_compatibility = extensionSupportedWGL("GL_ARB_ES2_compatibility"); + ARB_ES3_compatibility = extensionSupportedWGL("GL_ARB_ES3_compatibility"); - if (!ARB_create_context || !ARB_create_context_profile || !(EXT_create_context_es2_profile || ARB_ES2_compatibility)) { - Log::Error(Event::OpenGL, "OpenGL ES 2.0 is unavailable"); - throw std::runtime_error("OpenGL ES 2.0 is unavailable"); + if (!ARB_create_context || !ARB_create_context_profile || !ARB_ES3_compatibility) { + Log::Error(Event::OpenGL, "OpenGL ES 3.0 is unavailable"); + throw std::runtime_error("OpenGL ES 3.0 is unavailable"); } DestroyHelperWindow(); @@ -207,10 +206,9 @@ class WGLDisplayConfig { bool ARB_multisample = false; bool ARB_create_context = false; bool ARB_create_context_profile = false; - bool EXT_create_context_es2_profile = false; bool EXT_colorspace = false; bool ARB_pixel_format = false; - bool ARB_ES2_compatibility = false; + bool ARB_ES3_compatibility = false; WNDCLASSEXA renderingWindowClass = { sizeof(WNDCLASSEXA) }; }; @@ -316,7 +314,7 @@ class WGLBackendImpl final : public HeadlessBackend::Impl { if (wglDisplayConfig->ARB_create_context) { renderingWindowRenderingContext = mbgl::platform::wglCreateContextAttribsARB(renderingWindowDeviceContext, NULL, std::initializer_list({ - WGL_CONTEXT_MAJOR_VERSION_ARB, 2, + WGL_CONTEXT_MAJOR_VERSION_ARB, 3, WGL_CONTEXT_MINOR_VERSION_ARB, 0, WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, NULL diff --git a/platform/windows/windows.cmake b/platform/windows/windows.cmake index b5f614fa205..33c7f085974 100644 --- a/platform/windows/windows.cmake +++ b/platform/windows/windows.cmake @@ -72,8 +72,6 @@ target_compile_definitions( mbgl-core PRIVATE CURL_STATICLIB - PUBLIC - MBGL_USE_GLES2 ) if(MBGL_WITH_EGL) @@ -93,7 +91,7 @@ if(MBGL_WITH_EGL) mbgl-core PRIVATE unofficial::angle::libEGL - unofficial::angle::libGLESv2 + unofficial::angle::libGLESv3 ) elseif(MBGL_WITH_OSMESA) list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}) @@ -116,7 +114,7 @@ elseif(MBGL_WITH_OSMESA) mbgl-core PRIVATE OSMesa::osmesa - OSMesa::libGLESv2 + OSMesa::libGLESv3 ) else() find_package(OpenGL REQUIRED) diff --git a/shaders/_prelude.fragment.glsl b/shaders/_prelude.fragment.glsl index e98fb22d587..8716b728e77 100644 --- a/shaders/_prelude.fragment.glsl +++ b/shaders/_prelude.fragment.glsl @@ -15,3 +15,5 @@ precision mediump float; #endif #endif + +out highp vec4 fragColor; diff --git a/shaders/background.fragment.glsl b/shaders/background.fragment.glsl index 01e10bf6c2b..fdb7205e26d 100644 --- a/shaders/background.fragment.glsl +++ b/shaders/background.fragment.glsl @@ -2,9 +2,9 @@ uniform vec4 u_color; uniform float u_opacity; void main() { - gl_FragColor = u_color * u_opacity; + fragColor = u_color * u_opacity; #ifdef OVERDRAW_INSPECTOR - gl_FragColor = vec4(1.0); + fragColor = vec4(1.0); #endif } diff --git a/shaders/background.vertex.glsl b/shaders/background.vertex.glsl index 866c3cd2f39..3b0ec957fb9 100644 --- a/shaders/background.vertex.glsl +++ b/shaders/background.vertex.glsl @@ -1,5 +1,4 @@ -attribute vec2 a_pos; - +layout (location = 0) in vec2 a_pos; uniform mat4 u_matrix; void main() { diff --git a/shaders/background_pattern.fragment.glsl b/shaders/background_pattern.fragment.glsl index 4f9d1c34b05..7cbb25d9c04 100644 --- a/shaders/background_pattern.fragment.glsl +++ b/shaders/background_pattern.fragment.glsl @@ -8,21 +8,21 @@ uniform float u_opacity; uniform sampler2D u_image; -varying vec2 v_pos_a; -varying vec2 v_pos_b; +in vec2 v_pos_a; +in vec2 v_pos_b; void main() { vec2 imagecoord = mod(v_pos_a, 1.0); vec2 pos = mix(u_pattern_tl_a / u_texsize, u_pattern_br_a / u_texsize, imagecoord); - vec4 color1 = texture2D(u_image, pos); + vec4 color1 = texture(u_image, pos); vec2 imagecoord_b = mod(v_pos_b, 1.0); vec2 pos2 = mix(u_pattern_tl_b / u_texsize, u_pattern_br_b / u_texsize, imagecoord_b); - vec4 color2 = texture2D(u_image, pos2); + vec4 color2 = texture(u_image, pos2); - gl_FragColor = mix(color1, color2, u_mix) * u_opacity; + fragColor = mix(color1, color2, u_mix) * u_opacity; #ifdef OVERDRAW_INSPECTOR - gl_FragColor = vec4(1.0); + fragColor = vec4(1.0); #endif } diff --git a/shaders/background_pattern.vertex.glsl b/shaders/background_pattern.vertex.glsl index e8935a06270..ddada5e6c5d 100644 --- a/shaders/background_pattern.vertex.glsl +++ b/shaders/background_pattern.vertex.glsl @@ -7,10 +7,9 @@ uniform float u_scale_a; uniform float u_scale_b; uniform float u_tile_units_to_pixels; -attribute vec2 a_pos; - -varying vec2 v_pos_a; -varying vec2 v_pos_b; +layout (location = 0) in vec2 a_pos; +out vec2 v_pos_a; +out vec2 v_pos_b; void main() { gl_Position = u_matrix * vec4(a_pos, 0, 1); diff --git a/shaders/circle.fragment.glsl b/shaders/circle.fragment.glsl index 14081450b09..9aa80256591 100644 --- a/shaders/circle.fragment.glsl +++ b/shaders/circle.fragment.glsl @@ -1,4 +1,4 @@ -varying vec3 v_data; +in vec3 v_data; #pragma mapbox: define highp vec4 color #pragma mapbox: define mediump float radius @@ -31,9 +31,9 @@ void main() { extrude_length - radius / (radius + stroke_width) ); - gl_FragColor = opacity_t * mix(color * opacity, stroke_color * stroke_opacity, color_t); + fragColor = opacity_t * mix(color * opacity, stroke_color * stroke_opacity, color_t); #ifdef OVERDRAW_INSPECTOR - gl_FragColor = vec4(1.0); + fragColor = vec4(1.0); #endif } diff --git a/shaders/circle.vertex.glsl b/shaders/circle.vertex.glsl index 1f084104174..96cca876077 100644 --- a/shaders/circle.vertex.glsl +++ b/shaders/circle.vertex.glsl @@ -5,9 +5,8 @@ uniform vec2 u_extrude_scale; uniform lowp float u_device_pixel_ratio; uniform highp float u_camera_to_center_distance; -attribute vec2 a_pos; - -varying vec3 v_data; +layout (location = 0) in vec2 a_pos; +out vec3 v_data; #pragma mapbox: define highp vec4 color #pragma mapbox: define mediump float radius diff --git a/shaders/clipping_mask.fragment.glsl b/shaders/clipping_mask.fragment.glsl index fdd1a9285a6..bb3039aa5c7 100644 --- a/shaders/clipping_mask.fragment.glsl +++ b/shaders/clipping_mask.fragment.glsl @@ -1,3 +1,3 @@ void main() { - gl_FragColor = vec4(1.0); + fragColor = vec4(1.0); } diff --git a/shaders/clipping_mask.vertex.glsl b/shaders/clipping_mask.vertex.glsl index 866c3cd2f39..67b0080037f 100644 --- a/shaders/clipping_mask.vertex.glsl +++ b/shaders/clipping_mask.vertex.glsl @@ -1,4 +1,4 @@ -attribute vec2 a_pos; +layout (location = 0) in vec2 a_pos; uniform mat4 u_matrix; diff --git a/shaders/collision_box.fragment.glsl b/shaders/collision_box.fragment.glsl index 751c412ded9..f9fd48af160 100644 --- a/shaders/collision_box.fragment.glsl +++ b/shaders/collision_box.fragment.glsl @@ -1,21 +1,21 @@ -varying float v_placed; -varying float v_notUsed; +in float v_placed; +in float v_notUsed; void main() { float alpha = 0.5; // Red = collision, hide label - gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0) * alpha; + fragColor = vec4(1.0, 0.0, 0.0, 1.0) * alpha; // Blue = no collision, label is showing if (v_placed > 0.5) { - gl_FragColor = vec4(0.0, 0.0, 1.0, 0.5) * alpha; + fragColor = vec4(0.0, 0.0, 1.0, 0.5) * alpha; } if (v_notUsed > 0.5) { // This box not used, fade it out - gl_FragColor *= .1; + fragColor *= .1; } } \ No newline at end of file diff --git a/shaders/collision_box.vertex.glsl b/shaders/collision_box.vertex.glsl index 8fa4bfc025d..f5bd79acb8c 100644 --- a/shaders/collision_box.vertex.glsl +++ b/shaders/collision_box.vertex.glsl @@ -1,15 +1,15 @@ -attribute vec2 a_pos; -attribute vec2 a_anchor_pos; -attribute vec2 a_extrude; -attribute vec2 a_placed; -attribute vec2 a_shift; +layout (location = 0) in vec2 a_pos; +layout (location = 1) in vec2 a_anchor_pos; +layout (location = 2) in vec2 a_extrude; +layout (location = 3) in vec2 a_placed; +layout (location = 4) in vec2 a_shift; uniform mat4 u_matrix; uniform vec2 u_extrude_scale; uniform float u_camera_to_center_distance; -varying float v_placed; -varying float v_notUsed; +out float v_placed; +out float v_notUsed; void main() { vec4 projectedPoint = u_matrix * vec4(a_anchor_pos, 0, 1); diff --git a/shaders/collision_circle.fragment.glsl b/shaders/collision_circle.fragment.glsl index e7eedb19e34..9b5db3f753c 100644 --- a/shaders/collision_circle.fragment.glsl +++ b/shaders/collision_circle.fragment.glsl @@ -1,10 +1,10 @@ uniform float u_overscale_factor; -varying float v_placed; -varying float v_notUsed; -varying float v_radius; -varying vec2 v_extrude; -varying vec2 v_extrude_scale; +in float v_placed; +in float v_notUsed; +in float v_radius; +in vec2 v_extrude; +in vec2 v_extrude_scale; void main() { float alpha = 0.5; @@ -30,5 +30,5 @@ void main() { float distance_to_edge = abs(extrude_length - radius); float opacity_t = smoothstep(-stroke_width, 0.0, -distance_to_edge); - gl_FragColor = opacity_t * color; + fragColor = opacity_t * color; } diff --git a/shaders/collision_circle.vertex.glsl b/shaders/collision_circle.vertex.glsl index 24e06ed1c17..08950dae261 100644 --- a/shaders/collision_circle.vertex.glsl +++ b/shaders/collision_circle.vertex.glsl @@ -1,18 +1,17 @@ -attribute vec2 a_pos; -attribute vec2 a_anchor_pos; -attribute vec2 a_extrude; -attribute vec2 a_placed; +layout (location = 0) in vec2 a_pos; +layout (location = 1) in vec2 a_anchor_pos; +layout (location = 2) in vec2 a_extrude; +layout (location = 3) in vec2 a_placed; uniform mat4 u_matrix; uniform vec2 u_extrude_scale; uniform float u_camera_to_center_distance; -varying float v_placed; -varying float v_notUsed; -varying float v_radius; - -varying vec2 v_extrude; -varying vec2 v_extrude_scale; +out float v_placed; +out float v_notUsed; +out float v_radius; +out vec2 v_extrude; +out vec2 v_extrude_scale; void main() { vec4 projectedPoint = u_matrix * vec4(a_anchor_pos, 0, 1); diff --git a/shaders/debug.fragment.glsl b/shaders/debug.fragment.glsl index c15a694bd1b..53e0f40d737 100644 --- a/shaders/debug.fragment.glsl +++ b/shaders/debug.fragment.glsl @@ -1,9 +1,9 @@ uniform highp vec4 u_color; uniform sampler2D u_overlay; -varying vec2 v_uv; +in vec2 v_uv; void main() { - vec4 overlay_color = texture2D(u_overlay, v_uv); - gl_FragColor = mix(u_color, overlay_color, overlay_color.a); + vec4 overlay_color = texture(u_overlay, v_uv); + fragColor = mix(u_color, overlay_color, overlay_color.a); } diff --git a/shaders/debug.vertex.glsl b/shaders/debug.vertex.glsl index c872e7fa981..f459ffe419f 100644 --- a/shaders/debug.vertex.glsl +++ b/shaders/debug.vertex.glsl @@ -1,5 +1,5 @@ -attribute vec2 a_pos; -varying vec2 v_uv; +layout (location = 0) in vec2 a_pos; +out vec2 v_uv; uniform mat4 u_matrix; uniform float u_overlay_scale; diff --git a/shaders/fill.fragment.glsl b/shaders/fill.fragment.glsl index a156d2c3c57..ffd33c16c3d 100644 --- a/shaders/fill.fragment.glsl +++ b/shaders/fill.fragment.glsl @@ -5,9 +5,9 @@ void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float opacity - gl_FragColor = color * opacity; + fragColor = color * opacity; #ifdef OVERDRAW_INSPECTOR - gl_FragColor = vec4(1.0); + fragColor = vec4(1.0); #endif } diff --git a/shaders/fill.vertex.glsl b/shaders/fill.vertex.glsl index b4e8277fa19..7a1db638238 100644 --- a/shaders/fill.vertex.glsl +++ b/shaders/fill.vertex.glsl @@ -1,4 +1,4 @@ -attribute vec2 a_pos; +layout (location = 0) in vec2 a_pos; uniform mat4 u_matrix; diff --git a/shaders/fill_extrusion.fragment.glsl b/shaders/fill_extrusion.fragment.glsl index 1c4cec51cc9..c7913c30ee4 100644 --- a/shaders/fill_extrusion.fragment.glsl +++ b/shaders/fill_extrusion.fragment.glsl @@ -1,9 +1,9 @@ -varying vec4 v_color; +in vec4 v_color; void main() { - gl_FragColor = v_color; + fragColor = v_color; #ifdef OVERDRAW_INSPECTOR - gl_FragColor = vec4(1.0); + fragColor = vec4(1.0); #endif } diff --git a/shaders/fill_extrusion.vertex.glsl b/shaders/fill_extrusion.vertex.glsl index 7a771b6dc97..236afdc0e08 100644 --- a/shaders/fill_extrusion.vertex.glsl +++ b/shaders/fill_extrusion.vertex.glsl @@ -5,10 +5,9 @@ uniform lowp float u_lightintensity; uniform float u_vertical_gradient; uniform lowp float u_opacity; -attribute vec2 a_pos; -attribute vec4 a_normal_ed; - -varying vec4 v_color; +layout (location = 0) in vec2 a_pos; +layout (location = 1) in vec4 a_normal_ed; +out vec4 v_color; #pragma mapbox: define highp float base #pragma mapbox: define highp float height diff --git a/shaders/fill_extrusion_pattern.fragment.glsl b/shaders/fill_extrusion_pattern.fragment.glsl index f3243d74b71..e3ebeb79c06 100644 --- a/shaders/fill_extrusion_pattern.fragment.glsl +++ b/shaders/fill_extrusion_pattern.fragment.glsl @@ -3,9 +3,9 @@ uniform float u_fade; uniform sampler2D u_image; -varying vec2 v_pos_a; -varying vec2 v_pos_b; -varying vec4 v_lighting; +in vec2 v_pos_a; +in vec2 v_pos_b; +in vec4 v_lighting; #pragma mapbox: define lowp float base #pragma mapbox: define lowp float height @@ -25,17 +25,17 @@ void main() { vec2 imagecoord = mod(v_pos_a, 1.0); vec2 pos = mix(pattern_tl_a / u_texsize, pattern_br_a / u_texsize, imagecoord); - vec4 color1 = texture2D(u_image, pos); + vec4 color1 = texture(u_image, pos); vec2 imagecoord_b = mod(v_pos_b, 1.0); vec2 pos2 = mix(pattern_tl_b / u_texsize, pattern_br_b / u_texsize, imagecoord_b); - vec4 color2 = texture2D(u_image, pos2); + vec4 color2 = texture(u_image, pos2); vec4 mixedColor = mix(color1, color2, u_fade); - gl_FragColor = mixedColor * v_lighting; + fragColor = mixedColor * v_lighting; #ifdef OVERDRAW_INSPECTOR - gl_FragColor = vec4(1.0); + fragColor = vec4(1.0); #endif } diff --git a/shaders/fill_extrusion_pattern.vertex.glsl b/shaders/fill_extrusion_pattern.vertex.glsl index 2761d56b6a9..ee7f893a525 100644 --- a/shaders/fill_extrusion_pattern.vertex.glsl +++ b/shaders/fill_extrusion_pattern.vertex.glsl @@ -10,12 +10,12 @@ uniform vec3 u_lightcolor; uniform lowp vec3 u_lightpos; uniform lowp float u_lightintensity; -attribute vec2 a_pos; -attribute vec4 a_normal_ed; +layout (location = 0) in vec2 a_pos; +layout (location = 1) in vec4 a_normal_ed; -varying vec2 v_pos_a; -varying vec2 v_pos_b; -varying vec4 v_lighting; +out vec2 v_pos_a; +out vec2 v_pos_b; +out vec4 v_lighting; #pragma mapbox: define lowp float base #pragma mapbox: define lowp float height diff --git a/shaders/fill_outline.fragment.glsl b/shaders/fill_outline.fragment.glsl index 81e4934e178..f13b94edac8 100644 --- a/shaders/fill_outline.fragment.glsl +++ b/shaders/fill_outline.fragment.glsl @@ -1,4 +1,4 @@ -varying vec2 v_pos; +in vec2 v_pos; #pragma mapbox: define highp vec4 outline_color #pragma mapbox: define lowp float opacity @@ -9,9 +9,9 @@ void main() { float dist = length(v_pos - gl_FragCoord.xy); float alpha = 1.0 - smoothstep(0.0, 1.0, dist); - gl_FragColor = outline_color * (alpha * opacity); + fragColor = outline_color * (alpha * opacity); #ifdef OVERDRAW_INSPECTOR - gl_FragColor = vec4(1.0); + fragColor = vec4(1.0); #endif } diff --git a/shaders/fill_outline.vertex.glsl b/shaders/fill_outline.vertex.glsl index 2fd1f2d6912..dea871d58cd 100644 --- a/shaders/fill_outline.vertex.glsl +++ b/shaders/fill_outline.vertex.glsl @@ -1,9 +1,9 @@ -attribute vec2 a_pos; +layout (location = 0) in vec2 a_pos; uniform mat4 u_matrix; uniform vec2 u_world; -varying vec2 v_pos; +out vec2 v_pos; #pragma mapbox: define highp vec4 outline_color #pragma mapbox: define lowp float opacity diff --git a/shaders/fill_outline_pattern.fragment.glsl b/shaders/fill_outline_pattern.fragment.glsl index 8d75cbbfe4d..07984c71749 100644 --- a/shaders/fill_outline_pattern.fragment.glsl +++ b/shaders/fill_outline_pattern.fragment.glsl @@ -3,9 +3,9 @@ uniform vec2 u_texsize; uniform sampler2D u_image; uniform float u_fade; -varying vec2 v_pos_a; -varying vec2 v_pos_b; -varying vec2 v_pos; +in vec2 v_pos_a; +in vec2 v_pos_b; +in vec2 v_pos; #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp vec4 pattern_from @@ -23,11 +23,11 @@ void main() { vec2 imagecoord = mod(v_pos_a, 1.0); vec2 pos = mix(pattern_tl_a / u_texsize, pattern_br_a / u_texsize, imagecoord); - vec4 color1 = texture2D(u_image, pos); + vec4 color1 = texture(u_image, pos); vec2 imagecoord_b = mod(v_pos_b, 1.0); vec2 pos2 = mix(pattern_tl_b / u_texsize, pattern_br_b / u_texsize, imagecoord_b); - vec4 color2 = texture2D(u_image, pos2); + vec4 color2 = texture(u_image, pos2); // find distance to outline for alpha interpolation @@ -35,9 +35,9 @@ void main() { float alpha = 1.0 - smoothstep(0.0, 1.0, dist); - gl_FragColor = mix(color1, color2, u_fade) * alpha * opacity; + fragColor = mix(color1, color2, u_fade) * alpha * opacity; #ifdef OVERDRAW_INSPECTOR - gl_FragColor = vec4(1.0); + fragColor = vec4(1.0); #endif } diff --git a/shaders/fill_outline_pattern.vertex.glsl b/shaders/fill_outline_pattern.vertex.glsl index ac5ed0c423f..c4c286b783e 100644 --- a/shaders/fill_outline_pattern.vertex.glsl +++ b/shaders/fill_outline_pattern.vertex.glsl @@ -4,11 +4,11 @@ uniform vec2 u_pixel_coord_upper; uniform vec2 u_pixel_coord_lower; uniform vec4 u_scale; -attribute vec2 a_pos; +layout (location = 0) in vec2 a_pos; -varying vec2 v_pos_a; -varying vec2 v_pos_b; -varying vec2 v_pos; +out vec2 v_pos_a; +out vec2 v_pos_b; +out vec2 v_pos; #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp vec4 pattern_from diff --git a/shaders/fill_pattern.fragment.glsl b/shaders/fill_pattern.fragment.glsl index a588f2ecebd..59643ecc43d 100644 --- a/shaders/fill_pattern.fragment.glsl +++ b/shaders/fill_pattern.fragment.glsl @@ -3,8 +3,8 @@ uniform float u_fade; uniform sampler2D u_image; -varying vec2 v_pos_a; -varying vec2 v_pos_b; +in vec2 v_pos_a; +in vec2 v_pos_b; #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp vec4 pattern_from @@ -22,15 +22,15 @@ void main() { vec2 imagecoord = mod(v_pos_a, 1.0); vec2 pos = mix(pattern_tl_a / u_texsize, pattern_br_a / u_texsize, imagecoord); - vec4 color1 = texture2D(u_image, pos); + vec4 color1 = texture(u_image, pos); vec2 imagecoord_b = mod(v_pos_b, 1.0); vec2 pos2 = mix(pattern_tl_b / u_texsize, pattern_br_b / u_texsize, imagecoord_b); - vec4 color2 = texture2D(u_image, pos2); + vec4 color2 = texture(u_image, pos2); - gl_FragColor = mix(color1, color2, u_fade) * opacity; + fragColor = mix(color1, color2, u_fade) * opacity; #ifdef OVERDRAW_INSPECTOR - gl_FragColor = vec4(1.0); + fragColor = vec4(1.0); #endif } diff --git a/shaders/fill_pattern.vertex.glsl b/shaders/fill_pattern.vertex.glsl index a3be3320186..8c2540c958e 100644 --- a/shaders/fill_pattern.vertex.glsl +++ b/shaders/fill_pattern.vertex.glsl @@ -3,10 +3,10 @@ uniform vec2 u_pixel_coord_upper; uniform vec2 u_pixel_coord_lower; uniform vec4 u_scale; -attribute vec2 a_pos; +layout (location = 0) in vec2 a_pos; -varying vec2 v_pos_a; -varying vec2 v_pos_b; +out vec2 v_pos_a; +out vec2 v_pos_b; #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp vec4 pattern_from diff --git a/shaders/generate_shader_code.js b/shaders/generate_shader_code.js index 4ab2602e317..bad2af66b99 100644 --- a/shaders/generate_shader_code.js +++ b/shaders/generate_shader_code.js @@ -10,7 +10,34 @@ const generatedHeader = `// Generated code, do not modify this file! // Generated on ${new Date().toISOString()} by ${os.userInfo().username} using shaders/generate_shader_code.js `; -const pragmaMapConvert = (source, pragmaMap, pipelineStage) => { +const newAttribLocationMapping = (source) => { + return { + __alloc: findHighestAttribLocation(source) + }; +} + +const locationForAttrib = (attribLocations, locationName) => { + if (attribLocations[locationName]) { + return attribLocations[attribLocations]; + } + + attribLocations[locationName] = ++attribLocations.__alloc; + return attribLocations[locationName]; +}; + +const findHighestAttribLocation = (source) => { + const re = /layout\s*\(\s*location\s*=\s*(\d+)\s*\)\s*in\s+/g; + let match; + let topIndex = -1; + + while (match = re.exec(source)) { + topIndex = Number(match[1]) > topIndex ? Number(match[1]) : topIndex; + } + + return topIndex; +} + +const pragmaMapConvert = (source, pragmaMap, attribLocations, pipelineStage) => { const re = /#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g; if (pipelineStage == "fragment") { @@ -18,7 +45,7 @@ const pragmaMapConvert = (source, pragmaMap, pipelineStage) => { pragmaMap[name] = true; if (operation === 'define') { return `#ifndef HAS_UNIFORM_u_${name} -varying ${precision} ${type} ${name}; +in ${precision} ${type} ${name}; #else uniform ${precision} ${type} u_${name}; #endif`; @@ -40,8 +67,8 @@ ${precision} ${type} ${name} = u_${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}; +layout (location = ${locationForAttrib(attribLocations, name)}) in ${precision} ${attrType} a_${name}; +out ${precision} ${type} ${name}; #else uniform ${precision} ${type} u_${name}; #endif`; @@ -65,7 +92,7 @@ ${precision} ${type} ${name} = u_${name}; if (operation === 'define') { return `#ifndef HAS_UNIFORM_u_${name} uniform lowp float u_${name}_t; -attribute ${precision} ${attrType} a_${name}; +layout (location = ${locationForAttrib(attribLocations, name)}) in ${precision} ${attrType} a_${name}; #else uniform ${precision} ${type} u_${name}; #endif`; @@ -131,11 +158,14 @@ let shaderNames = []; JSON.parse(fs.readFileSync(path.join(args.input, "manifest.json"))) .filter(it => typeof it == "object") .forEach((elem) => { - let pragmaMap = []; const fragmentSource = fs.readFileSync(path.join(args.input, elem.glsl_frag), {encoding: "utf8"}); const vertexSource = fs.readFileSync(path.join(args.input, elem.glsl_vert), {encoding: "utf8"}); - const frag = pragmaMapConvert(fragmentSource, pragmaMap, "fragment"); - const vert = pragmaMapConvert(vertexSource, pragmaMap, "vertex"); + + let pragmaMap = []; + let attribMap = newAttribLocationMapping(vertexSource); + + const frag = pragmaMapConvert(fragmentSource, pragmaMap, attribMap, "fragment"); + const vert = pragmaMapConvert(vertexSource, pragmaMap, attribMap, "vertex"); fs.writeFileSync( path.join(args.output, elem.header + ".hpp"), diff --git a/shaders/heatmap.fragment.glsl b/shaders/heatmap.fragment.glsl index 2550ab86927..bd6aaa517f3 100644 --- a/shaders/heatmap.fragment.glsl +++ b/shaders/heatmap.fragment.glsl @@ -1,6 +1,6 @@ uniform highp float u_intensity; -varying vec2 v_extrude; +in vec2 v_extrude; #pragma mapbox: define highp float weight @@ -14,9 +14,9 @@ void main() { float d = -0.5 * 3.0 * 3.0 * dot(v_extrude, v_extrude); float val = weight * u_intensity * GAUSS_COEF * exp(d); - gl_FragColor = vec4(val, 1.0, 1.0, 1.0); + fragColor = vec4(val, 1.0, 1.0, 1.0); #ifdef OVERDRAW_INSPECTOR - gl_FragColor = vec4(1.0); + fragColor = vec4(1.0); #endif } diff --git a/shaders/heatmap.vertex.glsl b/shaders/heatmap.vertex.glsl index 3712e4f2b0f..e51b39d6319 100644 --- a/shaders/heatmap.vertex.glsl +++ b/shaders/heatmap.vertex.glsl @@ -1,12 +1,10 @@ - uniform mat4 u_matrix; uniform float u_extrude_scale; uniform float u_opacity; uniform float u_intensity; -attribute vec2 a_pos; - -varying vec2 v_extrude; +layout (location = 0) in vec2 a_pos; +out vec2 v_extrude; #pragma mapbox: define highp float weight #pragma mapbox: define mediump float radius diff --git a/shaders/heatmap_texture.fragment.glsl b/shaders/heatmap_texture.fragment.glsl index d21970d19a1..3eed37b1f0c 100644 --- a/shaders/heatmap_texture.fragment.glsl +++ b/shaders/heatmap_texture.fragment.glsl @@ -1,14 +1,14 @@ uniform sampler2D u_image; uniform sampler2D u_color_ramp; uniform float u_opacity; -varying vec2 v_pos; +in 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; + float t = texture(u_image, v_pos).r; + vec4 color = texture(u_color_ramp, vec2(t, 0.5)); + fragColor = color * u_opacity; #ifdef OVERDRAW_INSPECTOR - gl_FragColor = vec4(0.0); + fragColor = vec4(0.0); #endif } diff --git a/shaders/heatmap_texture.vertex.glsl b/shaders/heatmap_texture.vertex.glsl index 0e57d0faaf7..f0f89a1e54e 100644 --- a/shaders/heatmap_texture.vertex.glsl +++ b/shaders/heatmap_texture.vertex.glsl @@ -1,7 +1,7 @@ uniform mat4 u_matrix; uniform vec2 u_world; -attribute vec2 a_pos; -varying vec2 v_pos; +layout (location = 0) in vec2 a_pos; +out vec2 v_pos; void main() { gl_Position = u_matrix * vec4(a_pos * u_world, 0, 1); diff --git a/shaders/hillshade.fragment.glsl b/shaders/hillshade.fragment.glsl index 7d761796e88..f7b0f662d6e 100644 --- a/shaders/hillshade.fragment.glsl +++ b/shaders/hillshade.fragment.glsl @@ -1,5 +1,5 @@ uniform sampler2D u_image; -varying vec2 v_pos; +in vec2 v_pos; uniform vec2 u_latrange; uniform vec2 u_light; @@ -10,7 +10,7 @@ uniform vec4 u_accent; #define PI 3.141592653589793 void main() { - vec4 pixel = texture2D(u_image, v_pos); + vec4 pixel = texture(u_image, v_pos); vec2 deriv = ((pixel.rg * 2.0) - 1.0); @@ -44,9 +44,9 @@ void main() { vec4 accent_color = (1.0 - accent) * u_accent * clamp(intensity * 2.0, 0.0, 1.0); float shade = abs(mod((aspect + azimuth) / PI + 0.5, 2.0) - 1.0); vec4 shade_color = mix(u_shadow, u_highlight, shade) * sin(scaledSlope) * clamp(intensity * 2.0, 0.0, 1.0); - gl_FragColor = accent_color * (1.0 - shade_color.a) + shade_color; + fragColor = accent_color * (1.0 - shade_color.a) + shade_color; #ifdef OVERDRAW_INSPECTOR - gl_FragColor = vec4(1.0); + fragColor = vec4(1.0); #endif } diff --git a/shaders/hillshade.vertex.glsl b/shaders/hillshade.vertex.glsl index c1737016e1a..0bac6fdff9e 100644 --- a/shaders/hillshade.vertex.glsl +++ b/shaders/hillshade.vertex.glsl @@ -1,9 +1,9 @@ uniform mat4 u_matrix; -attribute vec2 a_pos; -attribute vec2 a_texture_pos; +layout (location = 0) in vec2 a_pos; +layout (location = 1) in vec2 a_texture_pos; -varying vec2 v_pos; +out vec2 v_pos; void main() { gl_Position = u_matrix * vec4(a_pos, 0, 1); diff --git a/shaders/hillshade_prepare.fragment.glsl b/shaders/hillshade_prepare.fragment.glsl index 27de56d6532..4734527b0af 100644 --- a/shaders/hillshade_prepare.fragment.glsl +++ b/shaders/hillshade_prepare.fragment.glsl @@ -3,7 +3,7 @@ precision highp float; #endif uniform sampler2D u_image; -varying vec2 v_pos; +in vec2 v_pos; uniform vec2 u_dimension; uniform float u_zoom; uniform float u_maxzoom; @@ -11,7 +11,7 @@ uniform vec4 u_unpack; float getElevation(vec2 coord, float bias) { // Convert encoded elevation value to meters - vec4 data = texture2D(u_image, coord) * 255.0; + vec4 data = texture(u_image, coord) * 255.0; data.a = -1.0; return dot(data, u_unpack) / 4.0; } @@ -62,13 +62,13 @@ void main() { (g + h + h + i) - (a + b + b + c) ) / pow(2.0, (u_zoom - u_maxzoom) * exaggeration + 19.2562 - u_zoom); - gl_FragColor = clamp(vec4( + fragColor = clamp(vec4( deriv.x / 2.0 + 0.5, deriv.y / 2.0 + 0.5, 1.0, 1.0), 0.0, 1.0); #ifdef OVERDRAW_INSPECTOR - gl_FragColor = vec4(1.0); + fragColor = vec4(1.0); #endif } diff --git a/shaders/hillshade_prepare.vertex.glsl b/shaders/hillshade_prepare.vertex.glsl index 582397d6df0..aa8f8320f14 100644 --- a/shaders/hillshade_prepare.vertex.glsl +++ b/shaders/hillshade_prepare.vertex.glsl @@ -1,10 +1,10 @@ uniform mat4 u_matrix; uniform vec2 u_dimension; -attribute vec2 a_pos; -attribute vec2 a_texture_pos; +layout (location = 0) in vec2 a_pos; +layout (location = 1) in vec2 a_texture_pos; -varying vec2 v_pos; +out vec2 v_pos; void main() { gl_Position = u_matrix * vec4(a_pos, 0, 1); diff --git a/shaders/line.fragment.glsl b/shaders/line.fragment.glsl index aa407f54f9a..4ea11c11a4f 100644 --- a/shaders/line.fragment.glsl +++ b/shaders/line.fragment.glsl @@ -1,8 +1,8 @@ uniform lowp float u_device_pixel_ratio; -varying vec2 v_width2; -varying vec2 v_normal; -varying float v_gamma_scale; +in vec2 v_width2; +in vec2 v_normal; +in float v_gamma_scale; #pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float blur @@ -22,9 +22,9 @@ void main() { float blur2 = (blur + 1.0 / u_device_pixel_ratio) * v_gamma_scale; float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0); - gl_FragColor = color * (alpha * opacity); + fragColor = color * (alpha * opacity); #ifdef OVERDRAW_INSPECTOR - gl_FragColor = vec4(1.0); + fragColor = vec4(1.0); #endif } diff --git a/shaders/line.vertex.glsl b/shaders/line.vertex.glsl index 9334e2b72e1..65c99911d93 100644 --- a/shaders/line.vertex.glsl +++ b/shaders/line.vertex.glsl @@ -6,18 +6,18 @@ // #define scale 63.0 #define scale 0.015873016 -attribute vec2 a_pos_normal; -attribute vec4 a_data; +layout (location = 0) in vec2 a_pos_normal; +layout (location = 1) in vec4 a_data; uniform mat4 u_matrix; uniform mediump float u_ratio; uniform vec2 u_units_to_pixels; uniform lowp float u_device_pixel_ratio; -varying vec2 v_normal; -varying vec2 v_width2; -varying float v_gamma_scale; -varying highp float v_linesofar; +out vec2 v_normal; +out vec2 v_width2; +out float v_gamma_scale; +out highp float v_linesofar; #pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float blur diff --git a/shaders/line_gradient.fragment.glsl b/shaders/line_gradient.fragment.glsl index ea168c4966e..d7e7504d6e1 100644 --- a/shaders/line_gradient.fragment.glsl +++ b/shaders/line_gradient.fragment.glsl @@ -1,10 +1,10 @@ uniform lowp float u_device_pixel_ratio; uniform sampler2D u_image; -varying vec2 v_width2; -varying vec2 v_normal; -varying float v_gamma_scale; -varying highp float v_lineprogress; +in vec2 v_width2; +in vec2 v_normal; +in float v_gamma_scale; +in highp float v_lineprogress; #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity @@ -24,11 +24,11 @@ void main() { // For gradient lines, v_lineprogress is the ratio along the entire line, // scaled to [0, 2^15), and the gradient ramp is stored in a texture. - vec4 color = texture2D(u_image, vec2(v_lineprogress, 0.5)); + vec4 color = texture(u_image, vec2(v_lineprogress, 0.5)); - gl_FragColor = color * (alpha * opacity); + fragColor = color * (alpha * opacity); #ifdef OVERDRAW_INSPECTOR - gl_FragColor = vec4(1.0); + fragColor = vec4(1.0); #endif } diff --git a/shaders/line_gradient.vertex.glsl b/shaders/line_gradient.vertex.glsl index 98281e2843c..b236f2883a3 100644 --- a/shaders/line_gradient.vertex.glsl +++ b/shaders/line_gradient.vertex.glsl @@ -10,18 +10,18 @@ // #define scale 63.0 #define scale 0.015873016 -attribute vec2 a_pos_normal; -attribute vec4 a_data; +layout (location = 0) in vec2 a_pos_normal; +layout (location = 1) in vec4 a_data; uniform mat4 u_matrix; uniform mediump float u_ratio; uniform lowp float u_device_pixel_ratio; uniform vec2 u_units_to_pixels; -varying vec2 v_normal; -varying vec2 v_width2; -varying float v_gamma_scale; -varying highp float v_lineprogress; +out vec2 v_normal; +out vec2 v_width2; +out float v_gamma_scale; +out highp float v_lineprogress; #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity diff --git a/shaders/line_pattern.fragment.glsl b/shaders/line_pattern.fragment.glsl index e18de38320e..977d9d2f2fd 100644 --- a/shaders/line_pattern.fragment.glsl +++ b/shaders/line_pattern.fragment.glsl @@ -5,10 +5,10 @@ uniform mediump vec4 u_scale; uniform sampler2D u_image; -varying vec2 v_normal; -varying vec2 v_width2; -varying float v_linesofar; -varying float v_gamma_scale; +in vec2 v_normal; +in vec2 v_width2; +in float v_linesofar; +in float v_gamma_scale; #pragma mapbox: define lowp vec4 pattern_from #pragma mapbox: define lowp vec4 pattern_to @@ -60,11 +60,11 @@ void main() { vec2 pos_a = mix(pattern_tl_a / u_texsize, pattern_br_a / u_texsize, vec2(x_a, y_a)); vec2 pos_b = mix(pattern_tl_b / u_texsize, pattern_br_b / u_texsize, vec2(x_b, y_b)); - vec4 color = mix(texture2D(u_image, pos_a), texture2D(u_image, pos_b), u_fade); + vec4 color = mix(texture(u_image, pos_a), texture(u_image, pos_b), u_fade); - gl_FragColor = color * alpha * opacity; + fragColor = color * alpha * opacity; #ifdef OVERDRAW_INSPECTOR - gl_FragColor = vec4(1.0); + fragColor = vec4(1.0); #endif } diff --git a/shaders/line_pattern.vertex.glsl b/shaders/line_pattern.vertex.glsl index 6b4eb54c87a..93a2e525ec6 100644 --- a/shaders/line_pattern.vertex.glsl +++ b/shaders/line_pattern.vertex.glsl @@ -10,18 +10,18 @@ // long distances for long segments. Use this value to unscale the distance. #define LINE_DISTANCE_SCALE 2.0 -attribute vec2 a_pos_normal; -attribute vec4 a_data; +layout (location = 0) in vec2 a_pos_normal; +layout (location = 1) in vec4 a_data; uniform mat4 u_matrix; uniform vec2 u_units_to_pixels; uniform mediump float u_ratio; uniform lowp float u_device_pixel_ratio; -varying vec2 v_normal; -varying vec2 v_width2; -varying float v_linesofar; -varying float v_gamma_scale; +out vec2 v_normal; +out vec2 v_width2; +out float v_linesofar; +out float v_gamma_scale; #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity diff --git a/shaders/line_sdf.fragment.glsl b/shaders/line_sdf.fragment.glsl index 70a74996b34..3cbd2c9b668 100644 --- a/shaders/line_sdf.fragment.glsl +++ b/shaders/line_sdf.fragment.glsl @@ -4,11 +4,11 @@ uniform sampler2D u_image; uniform float u_sdfgamma; uniform float u_mix; -varying vec2 v_normal; -varying vec2 v_width2; -varying vec2 v_tex_a; -varying vec2 v_tex_b; -varying float v_gamma_scale; +in vec2 v_normal; +in vec2 v_width2; +in vec2 v_tex_a; +in vec2 v_tex_b; +in float v_gamma_scale; #pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float blur @@ -32,14 +32,14 @@ void main() { float blur2 = (blur + 1.0 / u_device_pixel_ratio) * v_gamma_scale; float alpha = clamp(min(dist - (v_width2.t - blur2), v_width2.s - dist) / blur2, 0.0, 1.0); - float sdfdist_a = texture2D(u_image, v_tex_a).a; - float sdfdist_b = texture2D(u_image, v_tex_b).a; + float sdfdist_a = texture(u_image, v_tex_a).a; + float sdfdist_b = texture(u_image, v_tex_b).a; float sdfdist = mix(sdfdist_a, sdfdist_b, u_mix); alpha *= smoothstep(0.5 - u_sdfgamma / floorwidth, 0.5 + u_sdfgamma / floorwidth, sdfdist); - gl_FragColor = color * (alpha * opacity); + fragColor = color * (alpha * opacity); #ifdef OVERDRAW_INSPECTOR - gl_FragColor = vec4(1.0); + fragColor = vec4(1.0); #endif } diff --git a/shaders/line_sdf.vertex.glsl b/shaders/line_sdf.vertex.glsl index c85140ef7c4..24397177b5e 100644 --- a/shaders/line_sdf.vertex.glsl +++ b/shaders/line_sdf.vertex.glsl @@ -10,8 +10,8 @@ // long distances for long segments. Use this value to unscale the distance. #define LINE_DISTANCE_SCALE 2.0 -attribute vec2 a_pos_normal; -attribute vec4 a_data; +layout (location = 0) in vec2 a_pos_normal; +layout (location = 1) in vec4 a_data; uniform mat4 u_matrix; uniform mediump float u_ratio; @@ -22,11 +22,11 @@ uniform vec2 u_patternscale_b; uniform float u_tex_y_b; uniform vec2 u_units_to_pixels; -varying vec2 v_normal; -varying vec2 v_width2; -varying vec2 v_tex_a; -varying vec2 v_tex_b; -varying float v_gamma_scale; +out vec2 v_normal; +out vec2 v_width2; +out vec2 v_tex_a; +out vec2 v_tex_b; +out float v_gamma_scale; #pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float blur diff --git a/shaders/raster.fragment.glsl b/shaders/raster.fragment.glsl index 11e6d473c32..473d45ddcae 100644 --- a/shaders/raster.fragment.glsl +++ b/shaders/raster.fragment.glsl @@ -2,8 +2,8 @@ uniform float u_fade_t; uniform float u_opacity; uniform sampler2D u_image0; uniform sampler2D u_image1; -varying vec2 v_pos0; -varying vec2 v_pos1; +in vec2 v_pos0; +in vec2 v_pos1; uniform float u_brightness_low; uniform float u_brightness_high; @@ -15,8 +15,8 @@ uniform vec3 u_spin_weights; void main() { // read and cross-fade colors from the main and parent tiles - vec4 color0 = texture2D(u_image0, v_pos0); - vec4 color1 = texture2D(u_image1, v_pos1); + vec4 color0 = texture(u_image0, v_pos0); + vec4 color1 = texture(u_image1, v_pos1); if (color0.a > 0.0) { color0.rgb = color0.rgb / color0.a; } @@ -44,9 +44,9 @@ void main() { vec3 u_high_vec = vec3(u_brightness_low, u_brightness_low, u_brightness_low); vec3 u_low_vec = vec3(u_brightness_high, u_brightness_high, u_brightness_high); - gl_FragColor = vec4(mix(u_high_vec, u_low_vec, rgb) * color.a, color.a); + fragColor = vec4(mix(u_high_vec, u_low_vec, rgb) * color.a, color.a); #ifdef OVERDRAW_INSPECTOR - gl_FragColor = vec4(1.0); + fragColor = vec4(1.0); #endif } diff --git a/shaders/raster.vertex.glsl b/shaders/raster.vertex.glsl index 07f44971bed..b3a764e744e 100644 --- a/shaders/raster.vertex.glsl +++ b/shaders/raster.vertex.glsl @@ -3,11 +3,11 @@ uniform vec2 u_tl_parent; uniform float u_scale_parent; uniform float u_buffer_scale; -attribute vec2 a_pos; -attribute vec2 a_texture_pos; +layout (location = 0) in vec2 a_pos; +layout (location = 1) in vec2 a_texture_pos; -varying vec2 v_pos0; -varying vec2 v_pos1; +out vec2 v_pos0; +out vec2 v_pos1; void main() { gl_Position = u_matrix * vec4(a_pos, 0, 1); diff --git a/shaders/symbol_icon.fragment.glsl b/shaders/symbol_icon.fragment.glsl index 4f6d75e70fb..ec81b93632b 100644 --- a/shaders/symbol_icon.fragment.glsl +++ b/shaders/symbol_icon.fragment.glsl @@ -1,7 +1,7 @@ uniform sampler2D u_texture; -varying vec2 v_tex; -varying float v_fade_opacity; +in vec2 v_tex; +in float v_fade_opacity; #pragma mapbox: define lowp float opacity @@ -9,9 +9,9 @@ void main() { #pragma mapbox: initialize lowp float opacity lowp float alpha = opacity * v_fade_opacity; - gl_FragColor = texture2D(u_texture, v_tex) * alpha; + fragColor = texture(u_texture, v_tex) * alpha; #ifdef OVERDRAW_INSPECTOR - gl_FragColor = vec4(1.0); + fragColor = vec4(1.0); #endif } diff --git a/shaders/symbol_icon.vertex.glsl b/shaders/symbol_icon.vertex.glsl index 16ab111429c..1df0fccdcdc 100644 --- a/shaders/symbol_icon.vertex.glsl +++ b/shaders/symbol_icon.vertex.glsl @@ -1,10 +1,10 @@ const float PI = 3.141592653589793; -attribute vec4 a_pos_offset; -attribute vec4 a_data; -attribute vec4 a_pixeloffset; -attribute vec3 a_projected_pos; -attribute float a_fade_opacity; +layout (location = 0) in vec4 a_pos_offset; +layout (location = 1) in vec4 a_data; +layout (location = 2) in vec4 a_pixeloffset; +layout (location = 3) in vec3 a_projected_pos; +layout (location = 4) in float a_fade_opacity; uniform bool u_is_size_zoom_constant; uniform bool u_is_size_feature_constant; @@ -25,8 +25,8 @@ uniform bool u_pitch_with_map; uniform vec2 u_texsize; -varying vec2 v_tex; -varying float v_fade_opacity; +out vec2 v_tex; +out float v_fade_opacity; #pragma mapbox: define lowp float opacity diff --git a/shaders/symbol_sdf.fragment.glsl b/shaders/symbol_sdf.fragment.glsl index 6b077543069..59cf59c1c04 100644 --- a/shaders/symbol_sdf.fragment.glsl +++ b/shaders/symbol_sdf.fragment.glsl @@ -6,8 +6,8 @@ uniform highp float u_gamma_scale; uniform lowp float u_device_pixel_ratio; uniform bool u_is_text; -varying vec2 v_data0; -varying vec3 v_data1; +in vec2 v_data0; +in vec3 v_data1; #pragma mapbox: define highp vec4 fill_color #pragma mapbox: define highp vec4 halo_color @@ -40,13 +40,13 @@ void main() { buff = (6.0 - halo_width / fontScale) / SDF_PX; } - lowp float dist = texture2D(u_texture, tex).a; + lowp float dist = texture(u_texture, tex).a; highp float gamma_scaled = gamma * gamma_scale; highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist); - gl_FragColor = color * (alpha * opacity * fade_opacity); + fragColor = color * (alpha * opacity * fade_opacity); #ifdef OVERDRAW_INSPECTOR - gl_FragColor = vec4(1.0); + fragColor = vec4(1.0); #endif } diff --git a/shaders/symbol_sdf.vertex.glsl b/shaders/symbol_sdf.vertex.glsl index 71ccf3c81d7..603bb59d63c 100644 --- a/shaders/symbol_sdf.vertex.glsl +++ b/shaders/symbol_sdf.vertex.glsl @@ -1,10 +1,10 @@ const float PI = 3.141592653589793; -attribute vec4 a_pos_offset; -attribute vec4 a_data; -attribute vec4 a_pixeloffset; -attribute vec3 a_projected_pos; -attribute float a_fade_opacity; +layout (location = 0) in vec4 a_pos_offset; +layout (location = 1) in vec4 a_data; +layout (location = 2) in vec4 a_pixeloffset; +layout (location = 3) in vec3 a_projected_pos; +layout (location = 4) in float a_fade_opacity; // contents of a_size vary based on the type of property value // used for {text,icon}-size. @@ -29,8 +29,8 @@ uniform highp float u_camera_to_center_distance; uniform float u_fade_change; uniform vec2 u_texsize; -varying vec2 v_data0; -varying vec3 v_data1; +out vec2 v_data0; +out vec3 v_data1; #pragma mapbox: define highp vec4 fill_color #pragma mapbox: define highp vec4 halo_color diff --git a/shaders/symbol_text_and_icon.fragment.glsl b/shaders/symbol_text_and_icon.fragment.glsl index 6220563c415..672e1dcb1f9 100644 --- a/shaders/symbol_text_and_icon.fragment.glsl +++ b/shaders/symbol_text_and_icon.fragment.glsl @@ -9,8 +9,8 @@ uniform sampler2D u_texture_icon; uniform highp float u_gamma_scale; uniform lowp float u_device_pixel_ratio; -varying vec4 v_data0; -varying vec4 v_data1; +in vec4 v_data0; +in vec4 v_data1; #pragma mapbox: define highp vec4 fill_color #pragma mapbox: define highp vec4 halo_color @@ -30,10 +30,10 @@ void main() { if (v_data1.w == ICON) { vec2 tex_icon = v_data0.zw; lowp float alpha = opacity * fade_opacity; - gl_FragColor = texture2D(u_texture_icon, tex_icon) * alpha; + fragColor = texture(u_texture_icon, tex_icon) * alpha; #ifdef OVERDRAW_INSPECTOR - gl_FragColor = vec4(1.0); + fragColor = vec4(1.0); #endif return; } @@ -56,13 +56,13 @@ void main() { buff = (6.0 - halo_width / fontScale) / SDF_PX; } - lowp float dist = texture2D(u_texture, tex).a; + lowp float dist = texture(u_texture, tex).a; highp float gamma_scaled = gamma * gamma_scale; highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist); - gl_FragColor = color * (alpha * opacity * fade_opacity); + fragColor = color * (alpha * opacity * fade_opacity); #ifdef OVERDRAW_INSPECTOR - gl_FragColor = vec4(1.0); + fragColor = vec4(1.0); #endif } diff --git a/shaders/symbol_text_and_icon.vertex.glsl b/shaders/symbol_text_and_icon.vertex.glsl index 647310fc9c9..533ad147d4c 100644 --- a/shaders/symbol_text_and_icon.vertex.glsl +++ b/shaders/symbol_text_and_icon.vertex.glsl @@ -1,9 +1,9 @@ const float PI = 3.141592653589793; -attribute vec4 a_pos_offset; -attribute vec4 a_data; -attribute vec3 a_projected_pos; -attribute float a_fade_opacity; +layout (location = 0) in vec4 a_pos_offset; +layout (location = 1) in vec4 a_data; +layout (location = 2) in vec3 a_projected_pos; +layout (location = 3) in float a_fade_opacity; // contents of a_size vary based on the type of property value // used for {text,icon}-size. @@ -29,8 +29,8 @@ uniform float u_fade_change; uniform vec2 u_texsize; uniform vec2 u_texsize_icon; -varying vec4 v_data0; -varying vec4 v_data1; +out vec4 v_data0; +out vec4 v_data1; #pragma mapbox: define highp vec4 fill_color #pragma mapbox: define highp vec4 halo_color diff --git a/src/mbgl/gfx/context.hpp b/src/mbgl/gfx/context.hpp index d3a33d8a553..3062ab2c6b4 100644 --- a/src/mbgl/gfx/context.hpp +++ b/src/mbgl/gfx/context.hpp @@ -26,7 +26,6 @@ class Context { public: static constexpr const uint32_t minimumRequiredVertexBindingCount = 8; const uint32_t maximumVertexBindingCount; - bool supportsHalfFloatTextures = false; public: Context(Context&&) = delete; diff --git a/src/mbgl/gl/context.cpp b/src/mbgl/gl/context.cpp index 4444eb56549..69b5addf354 100644 --- a/src/mbgl/gl/context.cpp +++ b/src/mbgl/gl/context.cpp @@ -107,19 +107,6 @@ void Context::initializeExtensions(const std::function(fn); } -#if MBGL_USE_GLES2 - constexpr const char* halfFloatExtensionName = "OES_texture_half_float"; - constexpr const char* halfFloatColorBufferExtensionName = "EXT_color_buffer_half_float"; -#else - constexpr const char* halfFloatExtensionName = "ARB_half_float_pixel"; - constexpr const char* halfFloatColorBufferExtensionName = "ARB_color_buffer_float"; -#endif - if (strstr(extensions, halfFloatExtensionName) != nullptr && - strstr(extensions, halfFloatColorBufferExtensionName) != nullptr) { - - supportsHalfFloatTextures = true; - } - if (!supportsVertexArrays()) { Log::Warning(Event::OpenGL, "Not using Vertex Array Objects"); } @@ -316,18 +303,6 @@ std::unique_ptr Context::readFramebuffer(const Size size, const gfx:: return data; } -#if !MBGL_USE_GLES2 -void Context::drawPixels(const Size size, const void* data, gfx::TexturePixelType format) { - pixelStoreUnpack = { 1 }; - // TODO - if (format != gfx::TexturePixelType::RGBA) { - format = gfx::TexturePixelType::Luminance; - } - MBGL_CHECK_ERROR(glDrawPixels(size.width, size.height, Enum::to(format), - GL_UNSIGNED_BYTE, data)); -} -#endif // MBGL_USE_GLES2 - namespace { void checkFramebuffer() { @@ -486,13 +461,6 @@ void Context::setDirtyState() { activeTextureUnit.setDirty(); pixelStorePack.setDirty(); pixelStoreUnpack.setDirty(); -#if !MBGL_USE_GLES2 - pointSize.setDirty(); - pixelZoom.setDirty(); - rasterPos.setDirty(); - pixelTransferDepth.setDirty(); - pixelTransferStencil.setDirty(); -#endif // MBGL_USE_GLES2 for (auto& tex : texture) { tex.setDirty(); } @@ -610,10 +578,6 @@ void Context::draw(const gfx::DrawMode& drawMode, std::size_t indexLength) { switch (drawMode.type) { case gfx::DrawModeType::Points: -#if !MBGL_USE_GLES2 - // In OpenGL ES 2, the point size is set in the vertex shader. - pointSize = drawMode.size; -#endif // MBGL_USE_GLES2 break; case gfx::DrawModeType::Lines: case gfx::DrawModeType::LineLoop: @@ -727,56 +691,12 @@ void Context::reduceMemoryUsage() { #if !defined(NDEBUG) void Context::visualizeStencilBuffer() { -#if !MBGL_USE_GLES2 - setStencilMode(gfx::StencilMode::disabled()); - setDepthMode(gfx::DepthMode::disabled()); - setColorMode(gfx::ColorMode::unblended()); - program = 0; - - // Reset the value in case someone else changed it, or it's dirty. - pixelTransferStencil = gl::value::PixelTransferStencil::Default; - - // Read the stencil buffer - const auto viewportValue = viewport.getCurrentValue(); - auto image = readFramebuffer(viewportValue.size, false); - - // Scale the Stencil buffer to cover the entire color space. - auto it = image.data.get(); - auto end = it + viewportValue.size.width * viewportValue.size.height; - const auto factor = 255.0f / *std::max_element(it, end); - for (; it != end; ++it) { - *it *= factor; - } - - pixelZoom = { 1, 1 }; - rasterPos = { -1, -1, 0, 1 }; - drawPixels(image); -#endif + throw std::runtime_error("Not yet implemented"); } -void Context::visualizeDepthBuffer(const float depthRangeSize) { - (void)depthRangeSize; -#if !MBGL_USE_GLES2 - setStencilMode(gfx::StencilMode::disabled()); - setDepthMode(gfx::DepthMode::disabled()); - setColorMode(gfx::ColorMode::unblended()); - program = 0; - - // Scales the values in the depth buffer so that they cover the entire grayscale range. This - // makes it easier to spot tiny differences. - const float base = 1.0f / (1.0f - depthRangeSize); - pixelTransferDepth = { base, 1.0f - base }; - - // Read the stencil buffer - auto viewportValue = viewport.getCurrentValue(); - auto image = readFramebuffer(viewportValue.size, false); - - pixelZoom = { 1, 1 }; - rasterPos = { -1, -1, 0, 1 }; - drawPixels(image); -#endif +void Context::visualizeDepthBuffer([[maybe_unused]] const float depthRangeSize) { + throw std::runtime_error("Not yet implemented"); } - #endif void Context::clearStencilBuffer(const int32_t bits) { diff --git a/src/mbgl/gl/context.hpp b/src/mbgl/gl/context.hpp index ed926b3f98b..40013ead2ac 100644 --- a/src/mbgl/gl/context.hpp +++ b/src/mbgl/gl/context.hpp @@ -74,14 +74,6 @@ class Context final : public gfx::Context { return { size, readFramebuffer(size, format, flip) }; } -#if !MBGL_USE_GLES2 - template - void drawPixels(const Image& image) { - auto format = image.channels == 4 ? gfx::TexturePixelType::RGBA : gfx::TexturePixelType::Alpha; - drawPixels(image.size, image.data.get(), format); - } -#endif // MBGL_USE_GLES2 - void clear(std::optional color, std::optional depth, std::optional stencil); @@ -154,13 +146,6 @@ class Context final : public gfx::Context { State pixelStorePack; State pixelStoreUnpack; -#if !MBGL_USE_GLES2 - State pixelZoom; - State rasterPos; - State pixelTransferDepth; - State pixelTransferStencil; -#endif // MBGL_USE_GLES2 - private: State stencilFunc; State stencilMask; @@ -183,9 +168,6 @@ class Context final : public gfx::Context { State cullFace; State cullFaceSide; State cullFaceWinding; -#if !MBGL_USE_GLES2 - State pointSize; -#endif // MBGL_USE_GLES2 std::unique_ptr createOffscreenTexture(Size, gfx::TextureChannelDataType) override; @@ -198,9 +180,6 @@ class Context final : public gfx::Context { UniqueFramebuffer createFramebuffer(); std::unique_ptr readFramebuffer(Size, gfx::TexturePixelType, bool flip); -#if !MBGL_USE_GLES2 - void drawPixels(Size size, const void* data, gfx::TexturePixelType); -#endif // MBGL_USE_GLES2 VertexArray createVertexArray(); bool supportsVertexArrays() const; diff --git a/src/mbgl/gl/defines.hpp b/src/mbgl/gl/defines.hpp index 52dc92d2307..7883badc30b 100644 --- a/src/mbgl/gl/defines.hpp +++ b/src/mbgl/gl/defines.hpp @@ -164,18 +164,4 @@ #define GL_VERTEX_SHADER 0x8B31 #define GL_VIEWPORT 0x0BA2 #define GL_ZERO 0 -#ifdef MBGL_USE_GLES2 -#define GL_HALF_FLOAT 0x8D61 -#else -#define GL_CURRENT_RASTER_POSITION 0x0B07 -#define GL_DEPTH24_STENCIL8 0x88F0 -#define GL_DEPTH_BIAS 0x0D1F -#define GL_DEPTH_SCALE 0x0D1E -#define GL_HALF_FLOAT 0x140B -#define GL_INDEX_OFFSET 0x0D13 -#define GL_INDEX_SHIFT 0x0D12 -#define GL_POINT_SIZE 0x0B11 -#define GL_RGBA8 0x8058 -#define GL_ZOOM_X 0x0D16 -#define GL_ZOOM_Y 0x0D17 -#endif +#define GL_HALF_FLOAT 0x8D61 \ No newline at end of file diff --git a/src/mbgl/gl/enum.cpp b/src/mbgl/gl/enum.cpp index df1368eb281..3ad98c30688 100644 --- a/src/mbgl/gl/enum.cpp +++ b/src/mbgl/gl/enum.cpp @@ -286,15 +286,9 @@ platform::GLenum Enum::to(const gfx::TextureChannel template <> gfx::RenderbufferPixelType Enum::from(const platform::GLint value) { switch (value) { -#if !MBGL_USE_GLES2 - case GL_RGBA8: return gfx::RenderbufferPixelType::RGBA; - case GL_DEPTH_COMPONENT: return gfx::RenderbufferPixelType::Depth; - case GL_DEPTH24_STENCIL8: return gfx::RenderbufferPixelType::DepthStencil; -#else case GL_RGBA8_OES: return gfx::RenderbufferPixelType::RGBA; case GL_DEPTH_COMPONENT16: return gfx::RenderbufferPixelType::Depth; case GL_DEPTH24_STENCIL8_OES: return gfx::RenderbufferPixelType::DepthStencil; -#endif } return {}; } @@ -302,15 +296,9 @@ gfx::RenderbufferPixelType Enum::from(const platform template <> platform::GLenum Enum::to(const gfx::RenderbufferPixelType value) { switch (value) { -#if !MBGL_USE_GLES2 - case gfx::RenderbufferPixelType::RGBA: return GL_RGBA8; - case gfx::RenderbufferPixelType::Depth: return GL_DEPTH_COMPONENT; - case gfx::RenderbufferPixelType::DepthStencil: return GL_DEPTH24_STENCIL8; -#else case gfx::RenderbufferPixelType::RGBA: return GL_RGBA8_OES; case gfx::RenderbufferPixelType::Depth: return GL_DEPTH_COMPONENT16; case gfx::RenderbufferPixelType::DepthStencil: return GL_DEPTH24_STENCIL8_OES; -#endif } return GL_INVALID_ENUM; } diff --git a/src/mbgl/gl/program.hpp b/src/mbgl/gl/program.hpp index fb4bb112f6d..c601652498d 100644 --- a/src/mbgl/gl/program.hpp +++ b/src/mbgl/gl/program.hpp @@ -57,6 +57,7 @@ class Program final : public gfx::Program { const std::string& additionalDefines) { // Compile the shader std::initializer_list vertexSource = { + "#version 300 es\n", programParameters.getDefines().c_str(), additionalDefines.c_str(), shaders::ShaderSource::vertex, @@ -64,6 +65,7 @@ class Program final : public gfx::Program { }; std::initializer_list fragmentSource = { + "#version 300 es\n", programParameters.getDefines().c_str(), additionalDefines.c_str(), shaders::ShaderSource::fragment, diff --git a/src/mbgl/gl/value.cpp b/src/mbgl/gl/value.cpp index a3758fed5d8..adf98767763 100644 --- a/src/mbgl/gl/value.cpp +++ b/src/mbgl/gl/value.cpp @@ -542,76 +542,6 @@ PixelStoreUnpack::Type PixelStoreUnpack::Get() { return value; } -#if !MBGL_USE_GLES2 - -const constexpr PointSize::Type PointSize::Default; - -void PointSize::Set(const Type& value) { - MBGL_CHECK_ERROR(glPointSize(value)); -} - -PointSize::Type PointSize::Get() { - GLfloat pointSize; - MBGL_CHECK_ERROR(glGetFloatv(GL_POINT_SIZE, &pointSize)); - return pointSize; -} - -const constexpr PixelZoom::Type PixelZoom::Default; - -void PixelZoom::Set(const Type& value) { - MBGL_CHECK_ERROR(glPixelZoom(value.xfactor, value.yfactor)); -} - -PixelZoom::Type PixelZoom::Get() { - GLfloat xfactor; - GLfloat yfactor; - MBGL_CHECK_ERROR(glGetFloatv(GL_ZOOM_X, &xfactor)); - MBGL_CHECK_ERROR(glGetFloatv(GL_ZOOM_Y, &yfactor)); - return { xfactor, yfactor }; -} - -const constexpr RasterPos::Type RasterPos::Default; - -void RasterPos::Set(const Type& value) { - MBGL_CHECK_ERROR(glRasterPos4d(value.x, value.y, value.z, value.w)); -} - -RasterPos::Type RasterPos::Get() { - GLdouble pos[4]; - MBGL_CHECK_ERROR(glGetDoublev(GL_CURRENT_RASTER_POSITION, pos)); - return { pos[0], pos[1], pos[2], pos[3] }; -} - -const constexpr PixelTransferDepth::Type PixelTransferDepth::Default; - -void PixelTransferDepth::Set(const Type& value) { - MBGL_CHECK_ERROR(glPixelTransferf(GL_DEPTH_SCALE, value.scale)); - MBGL_CHECK_ERROR(glPixelTransferf(GL_DEPTH_BIAS, value.bias)); -} - -PixelTransferDepth::Type PixelTransferDepth::Get() { - Type value; - MBGL_CHECK_ERROR(glGetFloatv(GL_DEPTH_SCALE, &value.scale)); - MBGL_CHECK_ERROR(glGetFloatv(GL_DEPTH_BIAS, &value.bias)); - return value; -} - -const constexpr PixelTransferStencil::Type PixelTransferStencil::Default; - -void PixelTransferStencil::Set(const Type& value) { - MBGL_CHECK_ERROR(glPixelTransferf(GL_INDEX_SHIFT, value.shift)); - MBGL_CHECK_ERROR(glPixelTransferf(GL_INDEX_OFFSET, value.offset)); -} - -PixelTransferStencil::Type PixelTransferStencil::Get() { - Type value; - MBGL_CHECK_ERROR(glGetIntegerv(GL_INDEX_SHIFT, &value.shift)); - MBGL_CHECK_ERROR(glGetIntegerv(GL_INDEX_OFFSET, &value.offset)); - return value; -} - -#endif // MBGL_USE_GLES2 - } // namespace value } // namespace gl } // namespace mbgl diff --git a/src/mbgl/gl/value.hpp b/src/mbgl/gl/value.hpp index 04582f62b56..6897f2afa92 100644 --- a/src/mbgl/gl/value.hpp +++ b/src/mbgl/gl/value.hpp @@ -283,75 +283,6 @@ struct PixelStoreUnpack { static Type Get(); }; -#if !MBGL_USE_GLES2 - -struct PointSize { - using Type = float; - static const constexpr Type Default = 1; - static void Set(const Type&); - static Type Get(); -}; - -struct PixelZoom { - struct Type { - float xfactor; - float yfactor; - }; - static const constexpr Type Default = { 1, 1 }; - static void Set(const Type&); - static Type Get(); -}; - -constexpr bool operator!=(const PixelZoom::Type& a, const PixelZoom::Type& b) { - return a.xfactor != b.xfactor || a.yfactor != b.yfactor; -} - -struct RasterPos { - struct Type { - double x; - double y; - double z; - double w; - }; - static const constexpr Type Default = { 0, 0, 0, 1 }; - static void Set(const Type&); - static Type Get(); -}; - -constexpr bool operator!=(const RasterPos::Type& a, const RasterPos::Type& b) { - return a.x != b.x || a.y != b.y || a.z != b.z || a.w != b.w; -} - -struct PixelTransferDepth { - struct Type { - float scale; - float bias; - }; - static const constexpr Type Default = { 1, 0 }; - static void Set(const Type&); - static Type Get(); -}; - -constexpr bool operator!=(const PixelTransferDepth::Type& a, const PixelTransferDepth::Type& b) { - return a.scale != b.scale || a.bias != b.bias; -} - -struct PixelTransferStencil { - struct Type { - int32_t shift; - int32_t offset; - }; - static const constexpr Type Default = { 0, 0 }; - static void Set(const Type&); - static Type Get(); -}; - -constexpr bool operator!=(const PixelTransferStencil::Type& a, const PixelTransferStencil::Type& b) { - return a.shift != b.shift || a.offset != b.offset; -} - -#endif // MBGL_USE_GLES2 - } // namespace value } // namespace gl } // namespace mbgl diff --git a/src/mbgl/renderer/layers/render_heatmap_layer.cpp b/src/mbgl/renderer/layers/render_heatmap_layer.cpp index d13bb01ec56..b652991d1e4 100644 --- a/src/mbgl/renderer/layers/render_heatmap_layer.cpp +++ b/src/mbgl/renderer/layers/render_heatmap_layer.cpp @@ -82,20 +82,7 @@ void RenderHeatmapLayer::render(PaintParameters& parameters) { assert(colorRampTexture); if (!renderTexture || renderTexture->getSize() != size) { - renderTexture.reset(); - if (parameters.context.supportsHalfFloatTextures) { - renderTexture = parameters.context.createOffscreenTexture(size, gfx::TextureChannelDataType::HalfFloat); - - if (!renderTexture->isRenderable()) { - // can't render to a half-float texture; falling back to unsigned byte one - renderTexture.reset(); - parameters.context.supportsHalfFloatTextures = false; - } - } - - if (!renderTexture) { - renderTexture = parameters.context.createOffscreenTexture(size, gfx::TextureChannelDataType::UnsignedByte); - } + renderTexture = parameters.context.createOffscreenTexture(size, gfx::TextureChannelDataType::HalfFloat); } auto renderPass = parameters.encoder->createRenderPass( diff --git a/test/gl/gl_functions.test.cpp b/test/gl/gl_functions.test.cpp index ea28c603400..3ecf2275626 100644 --- a/test/gl/gl_functions.test.cpp +++ b/test/gl/gl_functions.test.cpp @@ -145,14 +145,3 @@ TEST(GLFunctions, OpenGLES) { EXPECT_NE(glVertexAttribPointer, nullptr); EXPECT_NE(glViewport, nullptr); } - -#ifndef MBGL_USE_GLES2 -TEST(GLFunctions, OpenDesktop) { - EXPECT_NE(glDrawPixels, nullptr); - EXPECT_NE(glGetDoublev, nullptr); - EXPECT_NE(glPixelTransferf, nullptr); - EXPECT_NE(glPixelZoom, nullptr); - EXPECT_NE(glPointSize, nullptr); - EXPECT_NE(glRasterPos4d, nullptr); -} -#endif