summaryrefslogtreecommitdiff
path: root/src/mbgl/shaders/line_sdf.cpp
diff options
context:
space:
mode:
authorMolly Lloyd <molly@mapbox.com>2017-03-01 11:28:31 -0800
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-03-08 15:23:25 -0800
commit692f5e0a9f5321ee2932a976a8eb9e0a83fc3352 (patch)
treecb9ff13dc30455f1700eeb691dc155d0981c4116 /src/mbgl/shaders/line_sdf.cpp
parent3afae825c7b2f95e58cbcb85c59857f2253c945e (diff)
downloadqtlocation-mapboxgl-692f5e0a9f5321ee2932a976a8eb9e0a83fc3352.tar.gz
Pack min + max into one attribute :muscle:
Some devices supported by Mapbox GL provide only 8 vertex attributes; this change packs existing attributes to get us just under that limit. For properties using a composite function, pack the min and max values into a single attribute with two logical components instead of using two separate attributes and buffers. Special logic is included for color attributes, whose integer components must be packed into the available bits of floating-point attributes. (We don't have access to ivec types in GL ES 2.0.) For source functions, continue to bind just a one-component attribute even though the GLSL type is vec2 (or vec4 for colors). The type-checking done by gl::Attribute is relaxed slightly to accommodate this.
Diffstat (limited to 'src/mbgl/shaders/line_sdf.cpp')
-rw-r--r--src/mbgl/shaders/line_sdf.cpp25
1 files changed, 10 insertions, 15 deletions
diff --git a/src/mbgl/shaders/line_sdf.cpp b/src/mbgl/shaders/line_sdf.cpp
index 5f01cf00c0..cd0d4ac318 100644
--- a/src/mbgl/shaders/line_sdf.cpp
+++ b/src/mbgl/shaders/line_sdf.cpp
@@ -42,32 +42,27 @@ varying vec2 v_tex_b;
varying float v_gamma_scale;
uniform lowp float a_color_t;
-attribute lowp vec4 a_color_min;
-attribute lowp vec4 a_color_max;
+attribute lowp vec4 a_color;
varying lowp vec4 color;
uniform lowp float a_blur_t;
-attribute lowp float a_blur_min;
-attribute lowp float a_blur_max;
+attribute lowp vec2 a_blur;
varying lowp float blur;
uniform lowp float a_opacity_t;
-attribute lowp float a_opacity_min;
-attribute lowp float a_opacity_max;
+attribute lowp vec2 a_opacity;
varying lowp float opacity;
uniform lowp float a_gapwidth_t;
-attribute mediump float a_gapwidth_min;
-attribute mediump float a_gapwidth_max;
+attribute mediump vec2 a_gapwidth;
varying mediump float gapwidth;
uniform lowp float a_offset_t;
-attribute lowp float a_offset_min;
-attribute lowp float a_offset_max;
+attribute lowp vec2 a_offset;
varying lowp float offset;
void main() {
- color = mix(a_color_min, a_color_max, a_color_t);
- blur = mix(a_blur_min, a_blur_max, a_blur_t);
- opacity = mix(a_opacity_min, a_opacity_max, a_opacity_t);
- gapwidth = mix(a_gapwidth_min, a_gapwidth_max, a_gapwidth_t);
- offset = mix(a_offset_min, a_offset_max, a_offset_t);
+ color = unpack_mix_vec4(a_color, a_color_t);
+ blur = unpack_mix_vec2(a_blur, a_blur_t);
+ opacity = unpack_mix_vec2(a_opacity, a_opacity_t);
+ gapwidth = unpack_mix_vec2(a_gapwidth, a_gapwidth_t);
+ offset = unpack_mix_vec2(a_offset, a_offset_t);
vec2 a_extrude = a_data.xy - 128.0;
float a_direction = mod(a_data.z, 4.0) - 1.0;