summaryrefslogtreecommitdiff
path: root/src/mbgl/programs
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2017-07-06 08:06:12 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-07-12 14:48:22 -0700
commit358b0305ae1f52b477ae145bcca4b7af242dd5c3 (patch)
treef5b1315e650079fce12130611896836e1c8cfa98 /src/mbgl/programs
parentc61041b44cd9181641db2351f4657cc356300226 (diff)
downloadqtlocation-mapboxgl-358b0305ae1f52b477ae145bcca4b7af242dd5c3.tar.gz
[core] Per-segment-per-layer vertex arrays
Reduces rebinding, matches gl-js, and works around the buggy VAO implementation on PowerVR SGX544 GPUs.
Diffstat (limited to 'src/mbgl/programs')
-rw-r--r--src/mbgl/programs/program.hpp11
-rw-r--r--src/mbgl/programs/segment.hpp9
-rw-r--r--src/mbgl/programs/symbol_program.hpp11
3 files changed, 22 insertions, 9 deletions
diff --git a/src/mbgl/programs/program.hpp b/src/mbgl/programs/program.hpp
index 0199752b06..71d7569f53 100644
--- a/src/mbgl/programs/program.hpp
+++ b/src/mbgl/programs/program.hpp
@@ -58,7 +58,8 @@ public:
const SegmentVector<Attributes>& segments,
const PaintPropertyBinders& paintPropertyBinders,
const typename PaintProperties::PossiblyEvaluated& currentProperties,
- float currentZoom) {
+ float currentZoom,
+ const std::string& layerID) {
typename AllUniforms::Values allUniformValues = uniformValues
.concat(paintPropertyBinders.uniformValues(currentZoom, currentProperties));
@@ -66,8 +67,10 @@ public:
.concat(paintPropertyBinders.attributeBindings(currentProperties));
for (auto& segment : segments) {
- if (!segment.vertexArray) {
- segment.vertexArray = context.createVertexArray();
+ optional<gl::VertexArray>& vertexArray = segment.vertexArrays[layerID];
+
+ if (!vertexArray) {
+ vertexArray = context.createVertexArray();
}
program.draw(
@@ -77,7 +80,7 @@ public:
std::move(stencilMode),
std::move(colorMode),
allUniformValues,
- *segment.vertexArray,
+ *vertexArray,
Attributes::offsetBindings(allAttributeBindings, segment.vertexOffset),
indexBuffer,
segment.indexOffset,
diff --git a/src/mbgl/programs/segment.hpp b/src/mbgl/programs/segment.hpp
index d8cc9679d7..74bf4a75c5 100644
--- a/src/mbgl/programs/segment.hpp
+++ b/src/mbgl/programs/segment.hpp
@@ -28,7 +28,14 @@ public:
std::size_t vertexLength;
std::size_t indexLength;
- mutable optional<gl::VertexArray> vertexArray;
+ // One VertexArray per layer ID. This minimizes rebinding in cases where
+ // several layers share buckets but have different sets of active attributes.
+ // This can happen:
+ // * when two layers have the same layout properties, but differing
+ // data-driven paint properties
+ // * when two fill layers have the same layout properties, but one
+ // uses fill-color and the other uses fill-pattern
+ mutable std::map<std::string, optional<gl::VertexArray>> vertexArrays;
};
template <class Attributes>
diff --git a/src/mbgl/programs/symbol_program.hpp b/src/mbgl/programs/symbol_program.hpp
index 8c59cfd5a2..ee4855cf8f 100644
--- a/src/mbgl/programs/symbol_program.hpp
+++ b/src/mbgl/programs/symbol_program.hpp
@@ -315,7 +315,8 @@ public:
const SegmentVector<Attributes>& segments,
const PaintPropertyBinders& paintPropertyBinders,
const typename PaintProperties::PossiblyEvaluated& currentProperties,
- float currentZoom) {
+ float currentZoom,
+ const std::string& layerID) {
typename AllUniforms::Values allUniformValues = uniformValues
.concat(symbolSizeBinder.uniformValues(currentZoom))
.concat(paintPropertyBinders.uniformValues(currentZoom, currentProperties));
@@ -325,8 +326,10 @@ public:
.concat(paintPropertyBinders.attributeBindings(currentProperties));
for (auto& segment : segments) {
- if (!segment.vertexArray) {
- segment.vertexArray = context.createVertexArray();
+ optional<gl::VertexArray>& vertexArray = segment.vertexArrays[layerID];
+
+ if (!vertexArray) {
+ vertexArray = context.createVertexArray();
}
program.draw(
@@ -336,7 +339,7 @@ public:
std::move(stencilMode),
std::move(colorMode),
allUniformValues,
- *segment.vertexArray,
+ *vertexArray,
Attributes::offsetBindings(allAttributeBindings, segment.vertexOffset),
indexBuffer,
segment.indexOffset,