diff options
author | Molly Lloyd <molly@mapbox.com> | 2017-03-01 11:28:31 -0800 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2017-03-08 15:23:25 -0800 |
commit | 692f5e0a9f5321ee2932a976a8eb9e0a83fc3352 (patch) | |
tree | cb9ff13dc30455f1700eeb691dc155d0981c4116 /src/mbgl/programs/symbol_program.hpp | |
parent | 3afae825c7b2f95e58cbcb85c59857f2253c945e (diff) | |
download | qtlocation-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/programs/symbol_program.hpp')
-rw-r--r-- | src/mbgl/programs/symbol_program.hpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/mbgl/programs/symbol_program.hpp b/src/mbgl/programs/symbol_program.hpp index 0537c25a2c..fdd1aa5c3b 100644 --- a/src/mbgl/programs/symbol_program.hpp +++ b/src/mbgl/programs/symbol_program.hpp @@ -35,8 +35,7 @@ MBGL_DEFINE_UNIFORM_SCALAR(float, u_gamma_scale); } // namespace uniforms struct SymbolLayoutAttributes : gl::Attributes< - attributes::a_pos, - attributes::a_offset<2>, + attributes::a_pos_offset, attributes::a_texture_pos, attributes::a_data<4>> { @@ -49,11 +48,10 @@ struct SymbolLayoutAttributes : gl::Attributes< float labelminzoom, uint8_t labelangle) { return Vertex { + // combining pos and offset to reduce number of vertex attributes passed to shader (8 max for some devices) {{ static_cast<int16_t>(a.x), - static_cast<int16_t>(a.y) - }}, - {{ + static_cast<int16_t>(a.y), static_cast<int16_t>(::round(o.x * 64)), // use 1/64 pixels for placement static_cast<int16_t>(::round(o.y * 64)) }}, |