Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade OpenGL backend to ES 3.0 #995

Merged
merged 12 commits into from
Apr 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/macos-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
workflow_dispatch:
push:
branches:
- main
- opengl-2
tags:
- 'macos-*'
Expand All @@ -27,7 +26,6 @@ on:

pull_request:
branches:
- main
- opengl-2
paths:
- 'platform/ios/**'
Expand Down Expand Up @@ -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
Expand Down
15 changes: 0 additions & 15 deletions include/mbgl/platform/gl_functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 4 additions & 5 deletions include/mbgl/shaders/gl/background.hpp
Original file line number Diff line number Diff line change
@@ -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 <mbgl/shaders/shader_source.hpp>
Expand All @@ -8,8 +8,7 @@ namespace mbgl {
namespace shaders {

template <> struct ShaderSource<BuiltIn::BackgroundProgram, gfx::Backend::Type::OpenGL> {
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() {
Expand All @@ -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
}
)";
Expand Down
21 changes: 10 additions & 11 deletions include/mbgl/shaders/gl/background_pattern.hpp
Original file line number Diff line number Diff line change
@@ -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 <mbgl/shaders/shader_source.hpp>
Expand All @@ -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);
Expand All @@ -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
}
)";
Expand Down
55 changes: 27 additions & 28 deletions include/mbgl/shaders/gl/circle.hpp
Original file line number Diff line number Diff line change
@@ -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 <mbgl/shaders/shader_source.hpp>
Expand All @@ -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;
louwers marked this conversation as resolved.
Show resolved Hide resolved
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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
)";
Expand Down
6 changes: 3 additions & 3 deletions include/mbgl/shaders/gl/clipping_mask.hpp
Original file line number Diff line number Diff line change
@@ -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 <mbgl/shaders/shader_source.hpp>
Expand All @@ -8,7 +8,7 @@ namespace mbgl {
namespace shaders {

template <> struct ShaderSource<BuiltIn::ClippingMaskProgram, gfx::Backend::Type::OpenGL> {
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;

Expand All @@ -17,7 +17,7 @@ void main() {
}
)";
static constexpr const char* fragment = R"(void main() {
gl_FragColor = vec4(1.0);
fragColor = vec4(1.0);
}
)";
};
Expand Down
26 changes: 13 additions & 13 deletions include/mbgl/shaders/gl/collision_box.hpp
Original file line number Diff line number Diff line change
@@ -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 <mbgl/shaders/shader_source.hpp>
Expand All @@ -8,18 +8,18 @@ namespace mbgl {
namespace shaders {

template <> struct ShaderSource<BuiltIn::CollisionBoxProgram, gfx::Backend::Type::OpenGL> {
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);
Expand All @@ -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;
}
})";
};
Expand Down
Loading