Commit Graph

62 Commits

Author SHA1 Message Date
Chris Loer
30de793c2a [core] Update shaders/tests from GL JS. 2017-11-17 10:05:15 -08:00
Anand Thakker
f648cfeef6 Implement Expressions (#9439)
Ports https://github.com/mapbox/mapbox-gl-js/pull/4777 (and its several follow-ups)
2017-11-08 12:34:02 -05:00
John Firebaugh
aa4dff1095 [core] Align line vertex to 4-byte boundary
10 byte vertices are heavily penalized by common GL implementations.
2017-09-08 09:35:47 -07:00
John Firebaugh
822df3dd51 [core] Use separate attribute component for line normals
Broadcom GPUs don't cope well with using the least significant bit for this.
2017-08-08 18:06:44 -07:00
John Firebaugh
86ee821c6e [core] No need for optional in map of VertexArrays 2017-07-12 14:55:02 -07:00
John Firebaugh
49726cdc75 [core] Remove segment.cpp 2017-07-12 14:48:22 -07:00
John Firebaugh
01aff01274 [core] Use a type alias for SegmentVector 2017-07-12 14:48:22 -07:00
John Firebaugh
358b0305ae [core] Per-segment-per-layer vertex arrays
Reduces rebinding, matches gl-js, and works around the buggy VAO implementation on PowerVR SGX544 GPUs.
2017-07-12 14:48:22 -07:00
John Firebaugh
c61041b44c [core] Rework attribute binding (again)
These changes are necessary for programs whose set of active attributes is not fixed at compile time by a template parameter pack, but rather varies based on the generated shader text at runtime. In such cases, the attribute location of a given named attribute may vary between instances of the same Program.

Previously, attribute bindings were implicitly associated with a location based on template parameter order, and -1 was used to indicate an inactive attribute. This left us unable to disable the appropriate attribute when it went from active to inactive. Now, the state tracker for bindings explicitly associates locations and state, and an empty optional is used to indicate an inactive attribute.

In addition, a gl::VertexArray class is now exposed, allowing more flexibility in the relationship between Programs, Segments, and attribute bindings. In this commit, that relationship does not change, but the subsequent commit adjusts it to match gl-js, reduce rebinds, and work around buggy VAO implementations.

VertexArray uses a pimpl idiom in order to support implementations that lack the VAO extension. In that case, all VertexArrays share global binding state, reflecting the platform reality in the absence of VAOs, while still providing a uniform API.
2017-07-12 14:48:22 -07:00
Chris Loer
e8657becc5 [core] Update shaders.
Implements 'icon-pitch-alignment' (issue #9345)
Fixes issue #9456 (map-aligned point label regression)
2017-07-12 14:14:09 -07:00
Bruno de Oliveira Abinader
21031b624f [core] Added missing header includes 2017-07-12 20:42:29 +03:00
Ansis Brammanis
e514138b69 [core] improve legibility of labels that follow lines
port https://github.com/mapbox/mapbox-gl-js/pull/4781

This improves legibility of labels that follow lines in pitched views.
The previous approach used the limited information in the shader to
calculate put the glyph in approximatelyright place. The new approach
does this more accurately by doing it on the cpu where we have access to
the entire line geometry.
2017-07-11 09:10:24 -07:00
Chris Loer
8c23f14a9f [core] Use fade texture in collision debug boxes so that they agree more closely with symbol shaders. 2017-07-11 09:10:23 -07:00
Chris Loer
f8402e2042 [core] Set "max_camera_distance" to 1.5 for viewport-aligned road labels.
Viewport-aligned curved labels start to look very strange in the distance. Until we have a better system for projecting them, just prevent them from showing.
2017-07-11 09:10:23 -07:00
Chris Loer
8f5e0b66ab [core] Pass pitch-scaling vertex attributes and uniforms to shaders. 2017-07-11 09:10:23 -07:00
Chris Loer
59df3a90f4 [core] Improved label pitch-scaling: approximate collision box shapes based on tile distance from camera. 2017-07-11 09:10:22 -07:00
Chris Loer
d5fbcb242a [core] Implement circle-pitch-alignment property
Closes issue #9349.
2017-07-06 09:39:26 -07:00
Lauren Budorick
87a70c4793 [core] Enable property functions for line-width (#9250) 2017-06-19 14:27:43 -07:00
John Firebaugh
f3bb99f919 [core] Eliminate constant attribute bindings
Rather than binding constant attributes that will never be used, just disable the attribute.
2017-06-14 11:14:05 -07:00
Konstantin Käfer
7a3f7980b0 [core] rename a_gap_width => a_gapwidth, u_gap_width => u_gapwidth to reflect naming in the shader
not sure how this ever worked
2017-06-14 11:14:05 -07:00
John Firebaugh
fd45242d05 [core] Don't use "current" icon/text-size when binding
The current value is not passed to `SymbolSizeBinder::uniformValues`, so we shouldn't check `currentValue.isConstant()` in `SymbolSizeBinder::attributeBindings`. If it were true, then we might end up using attribute bindings that are appropriate only for a constant property, but uniform bindings that are appropriate only for a source or composite function.

Instead, just wait for a new bucket to be generated. This will happen automatically, since icon/text-size are layout properties.
2017-06-14 11:14:05 -07:00
John Firebaugh
9d276f3b0f [core] Dynamic program compilation for data-driven properties 2017-06-13 12:21:50 -07:00
Konstantin Käfer
18b50f51b4 [core] cleanup ProgramParameters 2017-06-13 12:21:50 -07:00
Konstantin Käfer
1708b297a7 [core] add constant DDS values as uniforms 2017-06-13 12:21:50 -07:00
Konstantin Käfer
2c6fcd9f44 [core] add uniforms to DataDrivenPaintPropertys 2017-06-13 12:21:50 -07:00
John Firebaugh
0b68731207 [core] Per-bucket icon atlases 2017-06-13 10:18:43 -07:00
Anand Thakker
f59eb822e1 Fix undefined memory access in getCoveringRanges() (#9227)
* Add simple unit tests for SymbolSizeBinder

* Fix bug in symbol size uniform value calculation

For camera functions we were setting the zoom levels in "covering ranges" to
`[(zoom stop <= tile zoom), (zoom stop >= 1 + tile zoom)]`, but then evaluating
the function at `[tile_zoom, tile_zoom + 1]`.

* Check for it != end() before accessing it->first
2017-06-09 06:28:14 -04:00
John Firebaugh
1759603e12 [core] Simplify and fix sprite atlas coordinate calculations
* Always return image metrics exclusive of padding
* Work with integer coordinates whenever possible
* Eliminate redundant SpriteAtlasElement members
* Fix asymmetric re-padding in getIconQuad when pixelRatio != 1
* Add explanatory comments
2017-05-23 12:59:27 -07:00
John Firebaugh
71c8f6aa10 [core] Move pattern coordinate division by texture size into shader
This makes pattern usage more like icons, and will be necessary for data-driven *-pattern properties.
2017-05-23 12:59:27 -07:00
Konstantin Käfer
eae2c715f1 [core] add error for non-virtual destructor deletes + add virtual dtors 2017-05-18 16:57:12 +02:00
John Firebaugh
63558e06ad [core] Remove obsolete modular arithmetic on atlas coordinates
We switched to 16-bit coordinates in attributes in b0cb8715ed, so there's no longer any reason to require that they are divisible by four.
2017-05-17 09:36:43 -07:00
John Firebaugh
da4d735e2c [core] Unify {Paint,Layout,Light}Properties 2017-05-15 09:45:55 -07:00
Asheem Mamoowala
84e39611a0 [core] Move renderer/* files into sub-folders (#8983)
Move renderer/* files into sub-folders
2017-05-12 17:07:48 -07:00
Bruno de Oliveira Abinader
870067360f [tidy] modernize-pass-by-value 2017-05-12 18:07:36 +03:00
John Firebaugh
d5f4d0f05f [core] Move render-related sources out of style directory/namespace
Moves the following to the renderer directory and out of the style namespace:

* CascadeParameters
* PropertyEvaluationParameters
* UpdateParameters
* PropertyEvaluator
* DataDrivenPropertyEvaluator
* CrossFadedPropertyEvaluator
* PaintPropertyBinder
* PaintProperyStatistics
* PossiblyEvaluatedPropertyValue
* TransitioningLight
* EvaluatedLight
2017-05-03 08:30:17 -07:00
Lauren Budorick
f6e79d7073 [core] Render fill-extrusion layers (#8431) 2017-04-27 15:56:55 -07:00
Ivo van Dongen
3c175adf30 [core] split off render layers 2017-04-25 17:23:54 -07:00
Anand Thakker
693c9f3641 [core] Add DDS support for {text,icon}-size (#8593)
* Update gl-js and generate style code

* Factor out packUint8Pair() helper function

* Draft implementation of DDS for {text,icon}-size

Ports https://github.com/mapbox/mapbox-gl-js/pull/4455

* Fix text-size/composite-function-line-placement test

* Refactor to PaintPropertyBinders-like strategy

* Dedupe gl::Program construction

* Use exponential function base for interpolation

* Dedupe coveringZoomStops method

* Fixup tests

* Fix CI errors (hidden within #if block)
2017-04-06 15:29:59 -04:00
Konstantin Käfer
3c91b6b7de [core] cache binary shaders on Android 2017-03-22 15:59:10 +01:00
John Firebaugh
ff413f6b99 [core] Fix overspecialization of PaintPropertyBinder template
PaintPropertyBinder and subclass templates were being instantiated for every unique attribute type (e.g. a_color, a_fill_color, a_halo_color) even though they behave identically for a given property value type (e.g. Color). To fix this, a unique type such as a_color no longer derives from gl::Attribute<...> -- instead it has an inner Type typedef, which should be used wherever neither a unique type nor attribute name is required. This reduces binary size substantially:

     VM SIZE                               FILE SIZE
 ++++++++++++++ GROWING                 ++++++++++++++

 -------------- SHRINKING               --------------
  -2.0% -49.3Ki __TEXT,__text           -49.3Ki  -2.0%
  -3.1% -5.21Ki [None]                  -2.79Ki  -1.6%
  -2.1% -4.12Ki __TEXT,__const          -4.12Ki  -2.1%
  -1.4% -4.04Ki __TEXT,__gcc_except_tab -4.04Ki  -1.4%
 -19.3% -3.62Ki __DATA,__data           -3.62Ki -19.3%
  -2.5% -1.65Ki __TEXT,__unwind_info    -1.65Ki  -2.5%
  -4.2%      -8 __DATA,__mod_init_func        0  [ = ]

  -1.9% -68.0Ki TOTAL                   -65.6Ki  -1.9%
2017-03-17 08:27:53 -07:00
John Firebaugh
0dca6cd9bf [core] Don't need to use normalized attributes anymore 2017-03-17 08:27:53 -07:00
John Firebaugh
d5c2920104 [core] Extract and de-templatize several Program static methods 2017-03-09 10:32:34 -08:00
Molly Lloyd
692f5e0a9f Pack min + max into one attribute 💪
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.
2017-03-08 15:23:25 -08:00
John Firebaugh
b83b14feb0 [core] De-duplicate shader prelude source 2017-03-08 13:49:24 -08:00
Anand Thakker
f901e776b3 [core] Implement data-driven styling for {text,icon}-{color,opacity,halo-color,halo-blur,halo-width} (#7939)
* Add symbol dds attributes and adapt style code generation

* Update to mapbox-gl-js/master

* Refactor SymbolFeature as a subclass of GeometryTileFeature

Prepares for enabling DDS on symbol paint properties by allowing the
SymbolFeatures, which we keep around after constructing SymbolLayout,
to be used in evaluating data-driven paint properties later in the
layout process.

* Draft approach for splitting icon/text paint properties

The `Program` types are set up to bind GL attributes to each of the
data-driven paint properties specified in the `PaintProperties` type
provided.  Since `SymbolPaintProperties` specifies both `Text*` and
`Icon*` properties, the symbolIcon, symbolIconSDF, and symbolGlyph
programs each attempt to bind roughly double the number of attributes
that they actually need.

This change addresses this by:
- Adding the more specific `IconPaintProperties` and `TextPaintProperties` types, which are subsets of the full `SymbolPaintProperties`.
- The symbol layer continues to use its `SymbolPaintProperties paint` member to track layer property state, but it provides helpers that construct objects of each the specific `{Icon,Text}PaintProperties::Evaluated` type, for use by the painter.
- The three symbol programs instantiate `Program<>` using the appropriate `{Icon,Text}PaintProperties` type.

* check in generated style code

* Populate paint buffers for symbol DDS properties

* Address first round of review comments

* Refactor VectorTile{Layer,Feature} to explicitly share data

* Update submodule
2017-02-28 19:54:24 -08:00
John Firebaugh
d819ece74c [core] Combine SpriteAtlas::getPosition with SpriteAtlas::getImage 2017-02-14 16:28:12 -06:00
John Firebaugh
9f2f7ddd12 [core] Check in generated shader code
One step toward eliminating the node/npm dependency for platforms other than node.
2017-02-07 11:27:36 -06:00
John Firebaugh
141e995806 [core] Add support for data-driven styling 2017-02-02 09:44:42 -08:00
Konstantin Käfer
62ea1f2185 [core] remove trailing whitespace, add trailing newlines, add space after // 2017-01-27 11:44:16 +01:00
Konstantin Käfer
a37ae27aed [core] fix rendering 180° line joins 2017-01-23 17:02:40 +01:00